Normand Briere
2019-06-21 15123b19e7bc8da2869429b07f0fbaa0598e945e
Object3D.java
....@@ -14,11 +14,20 @@
1414 import //weka.core.
1515 matrix.Matrix;
1616
17
+import java.util.UUID;
18
+
1719 //import net.sourceforge.sizeof.SizeOf;
1820 public class Object3D extends Vector<Object3D> implements java.io.Serializable, iSendInfo //, aurelienribon.tweenengine.TweenAccessor<Object3D>
1921 {
2022 //static final long serialVersionUID = -607422624994562685L;
2123 static final long serialVersionUID = 5022536242724664900L;
24
+
25
+ private UUID uuid = UUID.randomUUID();
26
+
27
+ // TEMPORARY for mocap undo
28
+ mocap.reader.BVHReader.BVHResult bvh;
29
+ Object3D skeleton;
30
+ //
2231
2332 ScriptNode scriptnode;
2433
....@@ -100,64 +109,136 @@
100109
101110 // transient boolean reduced; // for morph reduction
102111
103
-transient com.bulletphysics.linearmath.Transform cache; // for fast merge
104
-transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
112
+ transient com.bulletphysics.linearmath.Transform cache; // for fast merge
113
+ transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
105114
106
-transient Object3D transientsupport; // for cloning
107
-transient boolean transientlink2master;
115
+ transient Object3D transientsupport; // for cloning
116
+ transient boolean transientlink2master;
108117
109
-void SaveSupports()
110
-{
111
- if (blockloop)
112
- return;
113
-
114
- transientsupport = support;
115
- transientlink2master = link2master;
116
-
117
- support = null;
118
- link2master = false;
119
-
120
- if (bRep != null)
118
+ void SaveSupports()
121119 {
122
- bRep.SaveSupports();
123
- }
124
-
125
- for (int i = 0; i < Size(); i++)
126
- {
127
- Object3D child = (Object3D) get(i);
128
- if (child == null)
129
- continue;
130
- blockloop = true;
131
- child.SaveSupports();
132
- blockloop = false;
133
- }
134
-}
120
+ if (blockloop)
121
+ return;
135122
136
-void RestoreSupports()
137
-{
138
- if (blockloop)
139
- return;
123
+ transientsupport = support;
124
+ transientlink2master = link2master;
140125
141
- support = transientsupport;
142
- link2master = transientlink2master;
143
- transientsupport = null;
144
- transientlink2master = false;
145
-
146
- if (bRep != null)
147
- {
148
- bRep.RestoreSupports();
126
+ support = null;
127
+ link2master = false;
128
+
129
+ if (bRep != null)
130
+ {
131
+ bRep.SaveSupports();
132
+ }
133
+
134
+ for (int i = 0; i < Size(); i++)
135
+ {
136
+ Object3D child = (Object3D) get(i);
137
+ if (child == null)
138
+ continue;
139
+ blockloop = true;
140
+ child.SaveSupports();
141
+ blockloop = false;
142
+ }
149143 }
150
-
151
- for (int i = 0; i < Size(); i++)
144
+
145
+ void RestoreSupports()
152146 {
153
- Object3D child = (Object3D) get(i);
154
- if (child == null)
155
- continue;
156
- blockloop = true;
157
- child.RestoreSupports();
158
- blockloop = false;
147
+ if (blockloop)
148
+ return;
149
+
150
+ support = transientsupport;
151
+ link2master = transientlink2master;
152
+ transientsupport = null;
153
+ transientlink2master = false;
154
+
155
+ if (bRep != null)
156
+ {
157
+ bRep.RestoreSupports();
158
+ }
159
+
160
+ for (int i = 0; i < Size(); i++)
161
+ {
162
+ Object3D child = (Object3D) get(i);
163
+ if (child == null)
164
+ continue;
165
+ blockloop = true;
166
+ child.RestoreSupports();
167
+ blockloop = false;
168
+ }
159169 }
160
-}
170
+
171
+ void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
172
+ {
173
+ if (hashtable.containsKey(GetUUID()))
174
+ {
175
+ Object3D o = hashtable.get(GetUUID());
176
+
177
+ Grafreed.Assert(this.bRep == o.bRep);
178
+ if (this.bRep != null)
179
+ assert(this.bRep.support == o.transientrep);
180
+
181
+ return;
182
+ }
183
+
184
+ Object3D o = new Object3D();
185
+
186
+ hashtable.put(GetUUID(), o);
187
+
188
+ for (int i=0; i<Size(); i++)
189
+ {
190
+ get(i).ExtractBigData(hashtable);
191
+ }
192
+
193
+ ExtractBigData(o);
194
+ }
195
+
196
+ void ExtractBigData(Object3D o)
197
+ {
198
+ o.bRep = this.bRep;
199
+ if (this.bRep != null)
200
+ {
201
+ o.transientrep = this.bRep.support;
202
+ o.bRep.support = null;
203
+ }
204
+
205
+ // o.support = this.support;
206
+ // o.fileparent = this.fileparent;
207
+ // if (this.bRep != null)
208
+ // o.bRep = this.bRep.support;
209
+
210
+ this.bRep = null;
211
+ // if (this.bRep != null)
212
+ // this.bRep.support = null;
213
+ // this.support = null;
214
+ // this.fileparent = null;
215
+ }
216
+
217
+ void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
218
+ {
219
+ if (!hashtable.containsKey(GetUUID()))
220
+ return;
221
+
222
+ Object3D o = hashtable.get(GetUUID());
223
+
224
+ RestoreBigData(o);
225
+
226
+ hashtable.remove(GetUUID());
227
+
228
+ for (int i=0; i<Size(); i++)
229
+ {
230
+ get(i).RestoreBigData(hashtable);
231
+ }
232
+ }
233
+
234
+ void RestoreBigData(Object3D o)
235
+ {
236
+ this.bRep = o.bRep;
237
+ if (this.bRep != null)
238
+ this.bRep.support = o.transientrep;
239
+ // this.support = o.support;
240
+ // this.fileparent = o.fileparent;
241
+ }
161242
162243 // MOCAP SUPPORT
163244 double tx,ty,tz,rx,ry,rz;
....@@ -300,6 +381,7 @@
300381 }
301382
302383 boolean live = false;
384
+ boolean dontselect = false;
303385 boolean hide = false;
304386 boolean link2master = false; // performs reset support/master at each frame
305387 boolean marked = false; // animation node
....@@ -481,12 +563,14 @@
481563 toParent = LA.newMatrix();
482564 fromParent = LA.newMatrix();
483565 }
566
+
484567 if (toParentMarked == null)
485568 {
486569 if (maxcount != 1)
487570 {
488571 new Exception().printStackTrace();
489572 }
573
+
490574 toParentMarked = LA.newMatrix();
491575 fromParentMarked = LA.newMatrix();
492576 }
....@@ -774,7 +858,7 @@
774858 if (step == 0)
775859 step = 1;
776860 if (maxcount == 0)
777
- maxcount = 2048; // 4;
861
+ maxcount = 128; // 2048; // 4;
778862 // if (acceleration == 0)
779863 // acceleration = 10;
780864 if (delay == 0) // serial
....@@ -797,7 +881,7 @@
797881
798882 if (marked && Globals.isLIVE() && live &&
799883 //TEMP21aug2018
800
- Globals.DrawMode() == iCameraPane.SHADOW &&
884
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
801885 currentframe != Globals.framecount)
802886 {
803887 currentframe = Globals.framecount;
....@@ -809,7 +893,8 @@
809893
810894 boolean changedir = random && Math.random() < 0.01; // && !link2master;
811895
812
- if (transformcount*factor > maxcount || (step == 1 && changedir))
896
+ if (transformcount*factor >= maxcount && (rewind || random) ||
897
+ (step == 1 && changedir))
813898 {
814899 countdown = 1;
815900 delay = speedup?8:1;
....@@ -912,6 +997,11 @@
912997 fromParent = null; // LA.newMatrix();
913998 bRep = null; // new BoundaryRep();
914999
1000
+ if (oname != null && oname.equals("LeftHand"))
1001
+ {
1002
+ name = oname;
1003
+ }
1004
+
9151005 /*
9161006 float hue = (float)Math.random();
9171007 Color col;
....@@ -954,7 +1044,7 @@
9541044
9551045 public Object clone()
9561046 {
957
- return GrafreeD.clone(this);
1047
+ return Grafreed.clone(this);
9581048 }
9591049
9601050 Object3D copyExpand()
....@@ -1470,7 +1560,7 @@
14701560 BoundaryRep.SEUIL = other.material.cameralight;
14711561
14721562 // Set default to 0.1
1473
- BoundaryRep.SEUIL /= 2;
1563
+ BoundaryRep.SEUIL /= 4; // 2;
14741564 System.out.println("SEUIL = " + BoundaryRep.SEUIL);
14751565 }
14761566
....@@ -1729,7 +1819,7 @@
17291819 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17301820 o.bRep = transientrep;
17311821 if (clone)
1732
- o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
1822
+ o.bRep = (BoundaryRep) Grafreed.clone(transientrep);
17331823 o.CreateMaterial();
17341824 o.SetAttributes(this, -1);
17351825 //parent
....@@ -1742,7 +1832,7 @@
17421832 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17431833 o.bRep = bRep;
17441834 if (clone)
1745
- o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
1835
+ o.bRep = (BoundaryRep) Grafreed.clone(bRep);
17461836 o.CreateMaterial();
17471837 //o.overwriteThis(this, -1);
17481838 o.SetAttributes(this, -1);
....@@ -1829,12 +1919,15 @@
18291919 if (obj.name == null)
18301920 continue; // can't be a null one
18311921
1922
+ // Try perfect match first.
18321923 if (n.equals(obj.name))
18331924 {
18341925 theobj = obj;
18351926 count++;
18361927 }
18371928 }
1929
+
1930
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18381931
18391932 if (count != 1)
18401933 for (int i=Size(); --i>=0;)
....@@ -2300,6 +2393,7 @@
23002393 {
23012394 if (newWindow)
23022395 {
2396
+ new Exception().printStackTrace();
23032397 System.exit(0);
23042398 if (parent != null)
23052399 {
....@@ -2476,13 +2570,13 @@
24762570 return retval;
24772571 }
24782572
2479
- void doEditDrag(ClickInfo info)
2573
+ void doEditDrag(ClickInfo info, boolean opposite)
24802574 {
24812575 switch (doSomething)
24822576 {
24832577 case 1: // '\001'
24842578 //super.
2485
- doEditDrag0(info);
2579
+ doEditDrag0(info, opposite);
24862580 break;
24872581
24882582 case 2: // '\002'
....@@ -2495,11 +2589,11 @@
24952589 {
24962590 //sel.hitSomething = childToDrag.hitSomething;
24972591 //childToDrag.doEditDrag(info);
2498
- sel.doEditDrag(info);
2592
+ sel.doEditDrag(info, opposite);
24992593 } else
25002594 {
25012595 //super.
2502
- doEditDrag0(info);
2596
+ doEditDrag0(info, opposite);
25032597 }
25042598 }
25052599 break;
....@@ -2609,6 +2703,18 @@
26092703 void GenNormalsS(boolean crease)
26102704 {
26112705 selection.GenNormals(crease);
2706
+// for (int i=0; i<selection.size(); i++)
2707
+// {
2708
+// Object3D selectee = (Object3D) selection.elementAt(i);
2709
+// selectee.GenNormals(crease);
2710
+// }
2711
+
2712
+ //Touch();
2713
+ }
2714
+
2715
+ void GenNormalsMeshS()
2716
+ {
2717
+ selection.GenNormalsMesh();
26122718 // for (int i=0; i<selection.size(); i++)
26132719 // {
26142720 // Object3D selectee = (Object3D) selection.elementAt(i);
....@@ -2749,6 +2855,24 @@
27492855 if (child == null)
27502856 continue;
27512857 child.GenNormals(crease);
2858
+// Children().release(i);
2859
+ }
2860
+ blockloop = false;
2861
+ }
2862
+
2863
+ void GenNormalsMesh()
2864
+ {
2865
+ if (blockloop)
2866
+ return;
2867
+
2868
+ blockloop = true;
2869
+ GenNormalsMesh0();
2870
+ for (int i = 0; i < Children().Size(); i++)
2871
+ {
2872
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2873
+ if (child == null)
2874
+ continue;
2875
+ child.GenNormalsMesh();
27522876 // Children().release(i);
27532877 }
27542878 blockloop = false;
....@@ -2921,6 +3045,15 @@
29213045 }
29223046 }
29233047
3048
+ void GenNormalsMesh0()
3049
+ {
3050
+ if (bRep != null)
3051
+ {
3052
+ bRep.GenerateNormalsMesh();
3053
+ Touch();
3054
+ }
3055
+ }
3056
+
29243057 void GenNormalsMINE0()
29253058 {
29263059 if (bRep != null)
....@@ -2982,6 +3115,33 @@
29823115 blockloop = false;
29833116 }
29843117
3118
+ void TransformChildren()
3119
+ {
3120
+ if (toParent != null)
3121
+ {
3122
+ for (int i=Size(); --i>=0;)
3123
+ {
3124
+ Object3D v = get(i);
3125
+
3126
+ if (v.toParent == null)
3127
+ {
3128
+ v.toParent = LA.newMatrix();
3129
+ v.fromParent = LA.newMatrix();
3130
+ }
3131
+
3132
+// LA.matConcat(v.toParent, toParent, v.toParent);
3133
+// LA.matConcat(fromParent, v.fromParent, v.fromParent);
3134
+ LA.matConcat(toParent, v.toParent, v.toParent);
3135
+ LA.matConcat(v.fromParent, fromParent, v.fromParent);
3136
+ }
3137
+
3138
+ toParent = null; // LA.matIdentity(toParent);
3139
+ fromParent = null; // LA.matIdentity(fromParent);
3140
+
3141
+ Touch();
3142
+ }
3143
+ }
3144
+
29853145 void TransformGeometry()
29863146 {
29873147 Object3D obj = this;
....@@ -3203,9 +3363,11 @@
32033363
32043364 BoundaryRep sup = bRep.support;
32053365 bRep.support = null;
3206
- BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
3366
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
32073367 // bRep.SplitInTwo(onlyone); // thread...
3208
- temprep.SplitInTwo(reduction34, onlyone);
3368
+
3369
+ while(temprep.SplitInTwo(reduction34, onlyone));
3370
+
32093371 bRep = temprep;
32103372 bRep.support = sup;
32113373 Touch();
....@@ -3342,7 +3504,8 @@
33423504 if (blockloop)
33433505 return;
33443506
3345
- if (marked || (bRep != null && material != null)) // borderline...
3507
+ if (//marked || // does not make sense
3508
+ (bRep != null || material != null)) // borderline...
33463509 live = h;
33473510
33483511 for (int i = 0; i < Size(); i++)
....@@ -3363,7 +3526,8 @@
33633526 return;
33643527
33653528 //if (bRep != null)
3366
- if (marked || (bRep != null && material != null)) // borderline...
3529
+ if (//marked || // does not make sense
3530
+ (bRep != null || material != null)) // borderline...
33673531 link2master = h;
33683532
33693533 for (int i = 0; i < Size(); i++)
....@@ -3383,7 +3547,8 @@
33833547 if (blockloop)
33843548 return;
33853549
3386
- if (marked || (bRep != null && material != null)) // borderline...
3550
+ if (//marked || // does not make sense
3551
+ (bRep != null || material != null)) // borderline...
33873552 hide = h;
33883553
33893554 for (int i = 0; i < Size(); i++)
....@@ -3403,7 +3568,7 @@
34033568 if (blockloop)
34043569 return;
34053570
3406
- if (bRep != null && material != null) // borderline...
3571
+ if (bRep != null || material != null) // borderline...
34073572 marked = h;
34083573
34093574 for (int i = 0; i < Size(); i++)
....@@ -3413,6 +3578,46 @@
34133578 continue;
34143579 blockloop = true;
34153580 child.MarkLeaves(h);
3581
+ blockloop = false;
3582
+ // release(i);
3583
+ }
3584
+ }
3585
+
3586
+ void RewindLeaves(boolean h)
3587
+ {
3588
+ if (blockloop)
3589
+ return;
3590
+
3591
+ if (bRep != null || material != null) // borderline...
3592
+ rewind = h;
3593
+
3594
+ for (int i = 0; i < Size(); i++)
3595
+ {
3596
+ Object3D child = (Object3D) get(i); // reserve(i);
3597
+ if (child == null)
3598
+ continue;
3599
+ blockloop = true;
3600
+ child.RewindLeaves(h);
3601
+ blockloop = false;
3602
+ // release(i);
3603
+ }
3604
+ }
3605
+
3606
+ void RandomLeaves(boolean h)
3607
+ {
3608
+ if (blockloop)
3609
+ return;
3610
+
3611
+ if (bRep != null || material != null) // borderline...
3612
+ random = h;
3613
+
3614
+ for (int i = 0; i < Size(); i++)
3615
+ {
3616
+ Object3D child = (Object3D) get(i); // reserve(i);
3617
+ if (child == null)
3618
+ continue;
3619
+ blockloop = true;
3620
+ child.RandomLeaves(h);
34163621 blockloop = false;
34173622 // release(i);
34183623 }
....@@ -3727,7 +3932,7 @@
37273932 if (child == null)
37283933 continue;
37293934
3730
- if (GrafreeD.RENDERME > 0)
3935
+ if (Grafreed.RENDERME > 0)
37313936 {
37323937 if (child instanceof Merge)
37333938 ((Merge)child).renderme();
....@@ -3878,7 +4083,7 @@
38784083 if (child == null)
38794084 continue;
38804085
3881
- if (GrafreeD.RENDERME > 0)
4086
+ if (Grafreed.RENDERME > 0)
38824087 {
38834088 if (child instanceof Merge)
38844089 ((Merge)child).renderme();
....@@ -4073,7 +4278,7 @@
40734278 if (child == null)
40744279 continue;
40754280
4076
- if (GrafreeD.RENDERME > 0)
4281
+ if (Grafreed.RENDERME > 0)
40774282 {
40784283 if (child instanceof Merge)
40794284 ((Merge)child).renderme();
....@@ -4186,6 +4391,55 @@
41864391 {
41874392 blockloop = true;
41884393 get(i).RepairShadow();
4394
+ blockloop = false;
4395
+ }
4396
+ }
4397
+
4398
+ void RepairSOV()
4399
+ {
4400
+ if (blockloop)
4401
+ return;
4402
+
4403
+ String texname = this.GetPigmentTexture();
4404
+
4405
+ if (texname.startsWith("sov"))
4406
+ {
4407
+ String[] s = texname.split("/");
4408
+
4409
+ String[] sname = s[1].split("Color.pn");
4410
+
4411
+ texname = sname[0];
4412
+
4413
+ if (sname.length > 1)
4414
+ {
4415
+ texname += "Color.jpg";
4416
+ }
4417
+
4418
+ this.SetPigmentTexture("sov/" + texname);
4419
+ }
4420
+
4421
+ texname = this.GetBumpTexture();
4422
+
4423
+ if (texname.startsWith("sov"))
4424
+ {
4425
+ String[] s = texname.split("/");
4426
+
4427
+ String[] sname = s[1].split("Bump.pn");
4428
+
4429
+ texname = sname[0];
4430
+
4431
+ if (sname.length > 1)
4432
+ {
4433
+ texname += "Bump.jpg";
4434
+ }
4435
+
4436
+ this.SetBumpTexture("sov/" + texname);
4437
+ }
4438
+
4439
+ for (int i=0; i<Size(); i++)
4440
+ {
4441
+ blockloop = true;
4442
+ get(i).RepairSOV();
41894443 blockloop = false;
41904444 }
41914445 }
....@@ -4680,7 +4934,7 @@
46804934
46814935 cTreePath SelectLeaf(int indexcount, boolean deselect)
46824936 {
4683
- if (hide)
4937
+ if (hide || dontselect)
46844938 return null;
46854939
46864940 if (count <= 0)
....@@ -4706,7 +4960,7 @@
47064960
47074961 cTreePath Select(int indexcount, boolean deselect)
47084962 {
4709
- if (hide)
4963
+ if (hide || dontselect)
47104964 return null;
47114965
47124966 if (count <= 0)
....@@ -5158,10 +5412,34 @@
51585412
51595413 // System.out.println("Fullname = " + fullname);
51605414
5161
- if (fullname.name.indexOf(":") == -1)
5162
- return fullname.name;
5415
+ // Does not work on Windows due to C:
5416
+// if (fullname.name.indexOf(":") == -1)
5417
+// return fullname.name;
5418
+//
5419
+// return fullname.name.substring(0,fullname.name.indexOf(":"));
51635420
5164
- return fullname.name.substring(0,fullname.name.indexOf(":"));
5421
+ String[] split = fullname.name.split(":");
5422
+
5423
+ if (split.length == 0)
5424
+ {
5425
+ return "";
5426
+ }
5427
+
5428
+ if (split.length <= 2)
5429
+ {
5430
+ if (fullname.name.endsWith(":"))
5431
+ {
5432
+ // Windows
5433
+ return fullname.name.substring(0, fullname.name.length()-1);
5434
+ }
5435
+
5436
+ return split[0];
5437
+ }
5438
+
5439
+ // Windows
5440
+ assert(split.length == 4);
5441
+
5442
+ return split[0] + ":" + split[1];
51655443 }
51665444
51675445 static String GetBump(cTexture fullname)
....@@ -5170,10 +5448,38 @@
51705448 return "";
51715449
51725450 // System.out.println("Fullname = " + fullname);
5173
- if (fullname.name.indexOf(":") == -1)
5174
- return "";
5175
-
5176
- return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5451
+ // Does not work on Windows due to C:
5452
+// if (fullname.name.indexOf(":") == -1)
5453
+// return "";
5454
+//
5455
+// return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5456
+ String[] split = fullname.name.split(":");
5457
+
5458
+ if (split.length == 0)
5459
+ {
5460
+ return "";
5461
+ }
5462
+
5463
+ if (split.length == 1)
5464
+ {
5465
+ return "";
5466
+ }
5467
+
5468
+ if (split.length == 2)
5469
+ {
5470
+ if (fullname.name.endsWith(":"))
5471
+ {
5472
+ // Windows
5473
+ return "";
5474
+ }
5475
+
5476
+ return split[1];
5477
+ }
5478
+
5479
+ // Windows
5480
+ assert(split.length == 4);
5481
+
5482
+ return split[2] + ":" + split[3];
51775483 }
51785484
51795485 String GetPigmentTexture()
....@@ -5247,7 +5553,7 @@
52475553 System.out.print("; textures = " + textures);
52485554 System.out.println("; usedtextures = " + usedtextures);
52495555
5250
- if (GetTextures() == null)
5556
+ if (GetTextures() == null) // What is that??
52515557 GetTextures().name = ":";
52525558
52535559 String texname = tex;
....@@ -5278,6 +5584,43 @@
52785584 child.ResetPigmentTexture();
52795585 blockloop = false;
52805586 }
5587
+ }
5588
+
5589
+ UUID GetUUID()
5590
+ {
5591
+ if (uuid == null)
5592
+ {
5593
+ // Serial
5594
+ uuid = UUID.randomUUID();
5595
+ }
5596
+
5597
+ return uuid;
5598
+ }
5599
+
5600
+ Object3D GetObject(UUID uid)
5601
+ {
5602
+ if (blockloop)
5603
+ return null;
5604
+
5605
+ if (GetUUID().equals(uid))
5606
+ return this;
5607
+
5608
+ int nb = Size();
5609
+ for (int i = 0; i < nb; i++)
5610
+ {
5611
+ Object3D child = (Object3D) get(i);
5612
+
5613
+ if (child == null)
5614
+ continue;
5615
+
5616
+ blockloop = true;
5617
+ Object3D obj = child.GetObject(uid);
5618
+ blockloop = false;
5619
+ if (obj != null)
5620
+ return obj;
5621
+ }
5622
+
5623
+ return null;
52815624 }
52825625
52835626 void SetBumpTexture(String tex)
....@@ -5324,12 +5667,23 @@
53245667 boolean NeedSupport()
53255668 {
53265669 return
5327
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5670
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
53285671 // PROBLEM with CROWD!!
5329
- && (Globals.DrawMode() == iCameraPane.SHADOW || Globals.CROWD);
5672
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
53305673 }
53315674
53325675 static boolean DEBUG_SELECTION = false;
5676
+
5677
+ boolean IsLive()
5678
+ {
5679
+ if (live)
5680
+ return true;
5681
+
5682
+ if (parent == null)
5683
+ return false;
5684
+
5685
+ return parent.IsLive();
5686
+ }
53335687
53345688 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
53355689 {
....@@ -5341,7 +5695,7 @@
53415695 }
53425696
53435697 if (display.DrawMode() == iCameraPane.SELECTION &&
5344
- hide)
5698
+ (hide || dontselect))
53455699 return;
53465700
53475701 if (name != null && name.contains("sclera"))
....@@ -5392,7 +5746,7 @@
53925746 support = support;
53935747
53945748 //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5395
- boolean usecalllists = false; // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5749
+ boolean usecalllists = IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
53965750
53975751 if (!usecalllists && bRep != null && bRep.displaylist > 0)
53985752 {
....@@ -5412,10 +5766,12 @@
54125766 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
54135767
54145768 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5415
- (touched || (bRep != null && bRep.displaylist <= 0)))
5769
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5770
+ (Globals.isLIVE() || touched && (bRep != null && bRep.displaylist <= 0)))
54165771 {
54175772 Globals.lighttouched = true;
54185773 } // all panes...
5774
+
54195775 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
54205776 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
54215777 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5583,7 +5939,28 @@
55835939 tex = GetTextures();
55845940 }
55855941
5586
- display.BindTextures(tex, texres);
5942
+ boolean failedPigment = false;
5943
+ boolean failedBump = false;
5944
+
5945
+ try
5946
+ {
5947
+ display.BindPigmentTexture(tex, texres);
5948
+ }
5949
+ catch (Exception e)
5950
+ {
5951
+ System.err.println("FAILED: " + this);
5952
+ failedPigment = true;
5953
+ }
5954
+
5955
+ try
5956
+ {
5957
+ display.BindBumpTexture(tex, texres);
5958
+ }
5959
+ catch (Exception e)
5960
+ {
5961
+ //System.err.println("FAILED: " + this);
5962
+ failedBump = true;
5963
+ }
55875964
55885965 if (!compiled)
55895966 {
....@@ -5605,7 +5982,11 @@
56055982 }
56065983 }
56075984
5608
- display.ReleaseTextures(tex);
5985
+ if (!failedBump)
5986
+ display.ReleaseBumpTexture(tex);
5987
+
5988
+ if (!failedPigment)
5989
+ display.ReleasePigmentTexture(tex);
56095990
56105991 display.PopMaterial(this, selected);
56115992 }
....@@ -5734,6 +6115,9 @@
57346115
57356116 void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57366117 {
6118
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6119
+ return;
6120
+
57376121 if (hide)
57386122 return;
57396123 // shadow optimisation
....@@ -5858,6 +6242,9 @@
58586242 {
58596243 if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
58606244 return; // no shadow for transparent objects
6245
+
6246
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6247
+ return;
58616248
58626249 if (hide)
58636250 return;
....@@ -6824,7 +7211,7 @@
68247211 spot.translate(32, 32);
68257212 spotw = spot.x + spot.width;
68267213 spoth = spot.y + spot.height;
6827
- info.g.setColor(Color.blue);
7214
+ info.g.setColor(Color.cyan);
68287215 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
68297216 // if (CameraPane.Xmin > spot.x)
68307217 // {
....@@ -6842,11 +7229,12 @@
68427229 // {
68437230 // CameraPane.Ymax = spoth;
68447231 // }
6845
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
6846
- info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7232
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7233
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
68477234 spot.translate(0, -32);
6848
- info.g.setColor(Color.green);
7235
+ info.g.setColor(Color.yellow);
68497236 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7237
+ info.g.setColor(Color.green);
68507238 // if (CameraPane.Xmin > spot.x)
68517239 // {
68527240 // CameraPane.Xmin = spot.x;
....@@ -6898,7 +7286,7 @@
68987286 startX = info.x;
68997287 startY = info.y;
69007288
6901
- hitSomething = 0;
7289
+ hitSomething = -1;
69027290 cVector origin = new cVector();
69037291 //LA.xformPos(origin, toParent, origin);
69047292 Rectangle spot = new Rectangle();
....@@ -6931,7 +7319,7 @@
69317319 }
69327320
69337321 //System.out.println("info.modifiers = " + info.modifiers);
6934
- modified = (info.modifiers & CameraPane.META) != 0;
7322
+ modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
69357323 //System.out.println("modified = " + modified);
69367324 //new Exception().printStackTrace();
69377325 //viewCode = info.pane.renderCamera.viewCode;
....@@ -6959,7 +7347,7 @@
69597347 return true;
69607348 }
69617349
6962
- void doEditDrag0(ClickInfo info)
7350
+ void doEditDrag0(ClickInfo info, boolean opposite)
69637351 {
69647352 if (hitSomething == 0)
69657353 {
....@@ -6974,6 +7362,7 @@
69747362 //System.out.println("hitSomething = " + hitSomething);
69757363
69767364 double scale = 0.005f * info.camera.Distance();
7365
+
69777366 cVector xlate = new cVector();
69787367 //cVector xlate2 = new cVector();
69797368 switch (hitSomething)
....@@ -6986,7 +7375,7 @@
69867375
69877376 scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
69887377
6989
- if (modified)
7378
+ if (modified || opposite)
69907379 {
69917380 //assert(false);
69927381 /*
....@@ -7080,6 +7469,7 @@
70807469
70817470 if (modified)
70827471 {
7472
+ // Rotate 90 degrees
70837473 angle /= (Math.PI / 4);
70847474 angle = Math.floor(angle + 0.5);
70857475 angle *= (Math.PI / 4);
....@@ -7121,24 +7511,27 @@
71217511
71227512 case hitScale: // scale
71237513 double hScale = (double) (info.x - centerPt.x) / 32;
7514
+ double sign = 1;
7515
+ if (hScale < 0)
7516
+ {
7517
+ sign = -1;
7518
+ }
7519
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
71247520 if (hScale < 0.01)
71257521 {
7126
- hScale = 0.01;
7522
+ //hScale = 0.01;
71277523 }
7128
- hScale = Math.pow(hScale, scale * 50);
7129
- if (hScale < 0.01)
7130
- {
7131
- hScale = 0.01;
7132
- }
7524
+
71337525 double vScale = (double) (info.y - centerPt.y) / 32;
7134
- if (vScale < 0.01)
7526
+ sign = 1;
7527
+ if (vScale < 0)
71357528 {
7136
- vScale = 0.01;
7529
+ sign = -1;
71377530 }
7138
- vScale = Math.pow(vScale, scale * 50);
7531
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
71397532 if (vScale < 0.01)
71407533 {
7141
- vScale = 0.01;
7534
+ //vScale = 0.01;
71427535 }
71437536 LA.matCopy(startMat, toParent);
71447537 /**/
....@@ -7149,39 +7542,47 @@
71497542 }
71507543 /**/
71517544
7545
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7546
+
7547
+ if (totalScale < 0.01)
7548
+ {
7549
+ totalScale = 0.01;
7550
+ }
7551
+
71527552 switch (info.pane.RenderCamera().viewCode)
71537553 {
71547554 case 3: // '\001'
7155
- if (modified)
7555
+ if (modified || opposite)
71567556 {
71577557 //LA.matScale(toParent, 1, hScale, vScale);
7158
- LA.matScale(toParent, vScale, 1, 1);
7558
+ LA.matScale(toParent, totalScale, 1, 1);
71597559 } // vScale, 1);
71607560 else
71617561 {
7162
- LA.matScale(toParent, vScale, vScale, vScale);
7562
+ // EXCEPTION!
7563
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
71637564 } // vScale, 1);
71647565 break;
71657566
71667567 case 2: // '\002'
7167
- if (modified)
7568
+ if (modified || opposite)
71687569 {
71697570 //LA.matScale(toParent, hScale, 1, vScale);
7170
- LA.matScale(toParent, 1, vScale, 1);
7571
+ LA.matScale(toParent, 1, totalScale, 1);
71717572 } else
71727573 {
7173
- LA.matScale(toParent, vScale, 1, vScale);
7574
+ LA.matScale(toParent, totalScale, 1, totalScale);
71747575 }
71757576 break;
71767577
71777578 case 1: // '\003'
7178
- if (modified)
7579
+ if (modified || opposite)
71797580 {
71807581 //LA.matScale(toParent, hScale, vScale, 1);
7181
- LA.matScale(toParent, 1, 1, vScale);
7582
+ LA.matScale(toParent, 1, 1, totalScale);
71827583 } else
71837584 {
7184
- LA.matScale(toParent, vScale, vScale, 1);
7585
+ LA.matScale(toParent, totalScale, totalScale, 1);
71857586 }
71867587 break;
71877588 }
....@@ -7314,14 +7715,22 @@
73147715 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
73157716 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
73167717 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7718
+
7719
+ String objname;
7720
+
73177721 if (false) //parent != null)
73187722 {
7319
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7723
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
73207724 } else
73217725 {
7322
- return GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ") ")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ +System.identityHashCode(this);
7726
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
73237727 } // + super.toString();
73247728 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
7729
+
7730
+ if (!Globals.ADVANCED)
7731
+ return objname;
7732
+
7733
+ return objname + " " + System.identityHashCode(this);
73257734 }
73267735
73277736 public int hashCode()
....@@ -7377,6 +7786,7 @@
73777786 objectUI.closeUI();
73787787 if (editWindow != null)
73797788 {
7789
+ editWindow.ctrlPanel.FlushUI();
73807790 editWindow.refreshContents();
73817791 } // ? new
73827792 objectUI = null;
....@@ -7397,7 +7807,7 @@
73977807 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
73987808
73997809 Object3D /*Composite*/ parent;
7400
- Object3D /*Composite*/ fileparent;
7810
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
74017811
74027812 double[][] toParent; // dynamic matrix
74037813 double[][] fromParent;
....@@ -7512,7 +7922,7 @@
75127922 {
75137923 assert(bRep != null);
75147924 if (!(support instanceof GenericJoint)) // support.bRep != null)
7515
- GrafreeD.Assert(support.bRep == bRep.support);
7925
+ Grafreed.Assert(support.bRep == bRep.support);
75167926 }
75177927 else
75187928 {
....@@ -7561,9 +7971,9 @@
75617971 private static cVector edge2 = new cVector();
75627972 //private static cVector norm = new cVector();
75637973 /*transient private*/ int hitSomething;
7564
- private static final int hitCenter = 1;
7565
- private static final int hitScale = 2;
7566
- private static final int hitRotate = 3;
7974
+ static final int hitCenter = 1;
7975
+ static final int hitScale = 2;
7976
+ static final int hitRotate = 3;
75677977 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
75687978 /*transient*/ private Point centerPt;
75697979 /*transient*/ private int startX;