Normand Briere
2019-06-23 f1382bc839a74ef1d1534c61ea94e53cf54716df
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;)
....@@ -2294,12 +2387,17 @@
22942387 }
22952388 */
22962389 }
2390
+ else
2391
+ {
2392
+ //((ObjEditor)editWindow).SetupUI2(null);
2393
+ }
22972394 }
22982395
22992396 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
23002397 {
23012398 if (newWindow)
23022399 {
2400
+ new Exception().printStackTrace();
23032401 System.exit(0);
23042402 if (parent != null)
23052403 {
....@@ -2476,13 +2574,13 @@
24762574 return retval;
24772575 }
24782576
2479
- void doEditDrag(ClickInfo info)
2577
+ void doEditDrag(ClickInfo info, boolean opposite)
24802578 {
24812579 switch (doSomething)
24822580 {
24832581 case 1: // '\001'
24842582 //super.
2485
- doEditDrag0(info);
2583
+ doEditDrag0(info, opposite);
24862584 break;
24872585
24882586 case 2: // '\002'
....@@ -2495,11 +2593,11 @@
24952593 {
24962594 //sel.hitSomething = childToDrag.hitSomething;
24972595 //childToDrag.doEditDrag(info);
2498
- sel.doEditDrag(info);
2596
+ sel.doEditDrag(info, opposite);
24992597 } else
25002598 {
25012599 //super.
2502
- doEditDrag0(info);
2600
+ doEditDrag0(info, opposite);
25032601 }
25042602 }
25052603 break;
....@@ -2609,6 +2707,18 @@
26092707 void GenNormalsS(boolean crease)
26102708 {
26112709 selection.GenNormals(crease);
2710
+// for (int i=0; i<selection.size(); i++)
2711
+// {
2712
+// Object3D selectee = (Object3D) selection.elementAt(i);
2713
+// selectee.GenNormals(crease);
2714
+// }
2715
+
2716
+ //Touch();
2717
+ }
2718
+
2719
+ void GenNormalsMeshS()
2720
+ {
2721
+ selection.GenNormalsMesh();
26122722 // for (int i=0; i<selection.size(); i++)
26132723 // {
26142724 // Object3D selectee = (Object3D) selection.elementAt(i);
....@@ -2749,6 +2859,24 @@
27492859 if (child == null)
27502860 continue;
27512861 child.GenNormals(crease);
2862
+// Children().release(i);
2863
+ }
2864
+ blockloop = false;
2865
+ }
2866
+
2867
+ void GenNormalsMesh()
2868
+ {
2869
+ if (blockloop)
2870
+ return;
2871
+
2872
+ blockloop = true;
2873
+ GenNormalsMesh0();
2874
+ for (int i = 0; i < Children().Size(); i++)
2875
+ {
2876
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2877
+ if (child == null)
2878
+ continue;
2879
+ child.GenNormalsMesh();
27522880 // Children().release(i);
27532881 }
27542882 blockloop = false;
....@@ -2921,6 +3049,15 @@
29213049 }
29223050 }
29233051
3052
+ void GenNormalsMesh0()
3053
+ {
3054
+ if (bRep != null)
3055
+ {
3056
+ bRep.GenerateNormalsMesh();
3057
+ Touch();
3058
+ }
3059
+ }
3060
+
29243061 void GenNormalsMINE0()
29253062 {
29263063 if (bRep != null)
....@@ -2982,6 +3119,33 @@
29823119 blockloop = false;
29833120 }
29843121
3122
+ void TransformChildren()
3123
+ {
3124
+ if (toParent != null)
3125
+ {
3126
+ for (int i=Size(); --i>=0;)
3127
+ {
3128
+ Object3D v = get(i);
3129
+
3130
+ if (v.toParent == null)
3131
+ {
3132
+ v.toParent = LA.newMatrix();
3133
+ v.fromParent = LA.newMatrix();
3134
+ }
3135
+
3136
+// LA.matConcat(v.toParent, toParent, v.toParent);
3137
+// LA.matConcat(fromParent, v.fromParent, v.fromParent);
3138
+ LA.matConcat(toParent, v.toParent, v.toParent);
3139
+ LA.matConcat(v.fromParent, fromParent, v.fromParent);
3140
+ }
3141
+
3142
+ toParent = null; // LA.matIdentity(toParent);
3143
+ fromParent = null; // LA.matIdentity(fromParent);
3144
+
3145
+ Touch();
3146
+ }
3147
+ }
3148
+
29853149 void TransformGeometry()
29863150 {
29873151 Object3D obj = this;
....@@ -3203,9 +3367,11 @@
32033367
32043368 BoundaryRep sup = bRep.support;
32053369 bRep.support = null;
3206
- BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
3370
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
32073371 // bRep.SplitInTwo(onlyone); // thread...
3208
- temprep.SplitInTwo(reduction34, onlyone);
3372
+
3373
+ while(temprep.SplitInTwo(reduction34, onlyone));
3374
+
32093375 bRep = temprep;
32103376 bRep.support = sup;
32113377 Touch();
....@@ -3342,7 +3508,8 @@
33423508 if (blockloop)
33433509 return;
33443510
3345
- if (marked || (bRep != null && material != null)) // borderline...
3511
+ if (//marked || // does not make sense
3512
+ (bRep != null || material != null)) // borderline...
33463513 live = h;
33473514
33483515 for (int i = 0; i < Size(); i++)
....@@ -3363,7 +3530,8 @@
33633530 return;
33643531
33653532 //if (bRep != null)
3366
- if (marked || (bRep != null && material != null)) // borderline...
3533
+ if (//marked || // does not make sense
3534
+ (bRep != null || material != null)) // borderline...
33673535 link2master = h;
33683536
33693537 for (int i = 0; i < Size(); i++)
....@@ -3383,7 +3551,8 @@
33833551 if (blockloop)
33843552 return;
33853553
3386
- if (marked || (bRep != null && material != null)) // borderline...
3554
+ if (//marked || // does not make sense
3555
+ (bRep != null || material != null)) // borderline...
33873556 hide = h;
33883557
33893558 for (int i = 0; i < Size(); i++)
....@@ -3403,7 +3572,7 @@
34033572 if (blockloop)
34043573 return;
34053574
3406
- if (bRep != null && material != null) // borderline...
3575
+ if (bRep != null || material != null) // borderline...
34073576 marked = h;
34083577
34093578 for (int i = 0; i < Size(); i++)
....@@ -3413,6 +3582,46 @@
34133582 continue;
34143583 blockloop = true;
34153584 child.MarkLeaves(h);
3585
+ blockloop = false;
3586
+ // release(i);
3587
+ }
3588
+ }
3589
+
3590
+ void RewindLeaves(boolean h)
3591
+ {
3592
+ if (blockloop)
3593
+ return;
3594
+
3595
+ if (bRep != null || material != null) // borderline...
3596
+ rewind = h;
3597
+
3598
+ for (int i = 0; i < Size(); i++)
3599
+ {
3600
+ Object3D child = (Object3D) get(i); // reserve(i);
3601
+ if (child == null)
3602
+ continue;
3603
+ blockloop = true;
3604
+ child.RewindLeaves(h);
3605
+ blockloop = false;
3606
+ // release(i);
3607
+ }
3608
+ }
3609
+
3610
+ void RandomLeaves(boolean h)
3611
+ {
3612
+ if (blockloop)
3613
+ return;
3614
+
3615
+ if (bRep != null || material != null) // borderline...
3616
+ random = h;
3617
+
3618
+ for (int i = 0; i < Size(); i++)
3619
+ {
3620
+ Object3D child = (Object3D) get(i); // reserve(i);
3621
+ if (child == null)
3622
+ continue;
3623
+ blockloop = true;
3624
+ child.RandomLeaves(h);
34163625 blockloop = false;
34173626 // release(i);
34183627 }
....@@ -3727,7 +3936,7 @@
37273936 if (child == null)
37283937 continue;
37293938
3730
- if (GrafreeD.RENDERME > 0)
3939
+ if (Grafreed.RENDERME > 0)
37313940 {
37323941 if (child instanceof Merge)
37333942 ((Merge)child).renderme();
....@@ -3878,7 +4087,7 @@
38784087 if (child == null)
38794088 continue;
38804089
3881
- if (GrafreeD.RENDERME > 0)
4090
+ if (Grafreed.RENDERME > 0)
38824091 {
38834092 if (child instanceof Merge)
38844093 ((Merge)child).renderme();
....@@ -4073,7 +4282,7 @@
40734282 if (child == null)
40744283 continue;
40754284
4076
- if (GrafreeD.RENDERME > 0)
4285
+ if (Grafreed.RENDERME > 0)
40774286 {
40784287 if (child instanceof Merge)
40794288 ((Merge)child).renderme();
....@@ -4186,6 +4395,55 @@
41864395 {
41874396 blockloop = true;
41884397 get(i).RepairShadow();
4398
+ blockloop = false;
4399
+ }
4400
+ }
4401
+
4402
+ void RepairSOV()
4403
+ {
4404
+ if (blockloop)
4405
+ return;
4406
+
4407
+ String texname = this.GetPigmentTexture();
4408
+
4409
+ if (texname.startsWith("sov"))
4410
+ {
4411
+ String[] s = texname.split("/");
4412
+
4413
+ String[] sname = s[1].split("Color.pn");
4414
+
4415
+ texname = sname[0];
4416
+
4417
+ if (sname.length > 1)
4418
+ {
4419
+ texname += "Color.jpg";
4420
+ }
4421
+
4422
+ this.SetPigmentTexture("sov/" + texname);
4423
+ }
4424
+
4425
+ texname = this.GetBumpTexture();
4426
+
4427
+ if (texname.startsWith("sov"))
4428
+ {
4429
+ String[] s = texname.split("/");
4430
+
4431
+ String[] sname = s[1].split("Bump.pn");
4432
+
4433
+ texname = sname[0];
4434
+
4435
+ if (sname.length > 1)
4436
+ {
4437
+ texname += "Bump.jpg";
4438
+ }
4439
+
4440
+ this.SetBumpTexture("sov/" + texname);
4441
+ }
4442
+
4443
+ for (int i=0; i<Size(); i++)
4444
+ {
4445
+ blockloop = true;
4446
+ get(i).RepairSOV();
41894447 blockloop = false;
41904448 }
41914449 }
....@@ -4680,7 +4938,7 @@
46804938
46814939 cTreePath SelectLeaf(int indexcount, boolean deselect)
46824940 {
4683
- if (hide)
4941
+ if (hide || dontselect)
46844942 return null;
46854943
46864944 if (count <= 0)
....@@ -4706,7 +4964,7 @@
47064964
47074965 cTreePath Select(int indexcount, boolean deselect)
47084966 {
4709
- if (hide)
4967
+ if (hide || dontselect)
47104968 return null;
47114969
47124970 if (count <= 0)
....@@ -5158,10 +5416,34 @@
51585416
51595417 // System.out.println("Fullname = " + fullname);
51605418
5161
- if (fullname.name.indexOf(":") == -1)
5162
- return fullname.name;
5419
+ // Does not work on Windows due to C:
5420
+// if (fullname.name.indexOf(":") == -1)
5421
+// return fullname.name;
5422
+//
5423
+// return fullname.name.substring(0,fullname.name.indexOf(":"));
51635424
5164
- return fullname.name.substring(0,fullname.name.indexOf(":"));
5425
+ String[] split = fullname.name.split(":");
5426
+
5427
+ if (split.length == 0)
5428
+ {
5429
+ return "";
5430
+ }
5431
+
5432
+ if (split.length <= 2)
5433
+ {
5434
+ if (fullname.name.endsWith(":"))
5435
+ {
5436
+ // Windows
5437
+ return fullname.name.substring(0, fullname.name.length()-1);
5438
+ }
5439
+
5440
+ return split[0];
5441
+ }
5442
+
5443
+ // Windows
5444
+ assert(split.length == 4);
5445
+
5446
+ return split[0] + ":" + split[1];
51655447 }
51665448
51675449 static String GetBump(cTexture fullname)
....@@ -5170,10 +5452,38 @@
51705452 return "";
51715453
51725454 // 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());
5455
+ // Does not work on Windows due to C:
5456
+// if (fullname.name.indexOf(":") == -1)
5457
+// return "";
5458
+//
5459
+// return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5460
+ String[] split = fullname.name.split(":");
5461
+
5462
+ if (split.length == 0)
5463
+ {
5464
+ return "";
5465
+ }
5466
+
5467
+ if (split.length == 1)
5468
+ {
5469
+ return "";
5470
+ }
5471
+
5472
+ if (split.length == 2)
5473
+ {
5474
+ if (fullname.name.endsWith(":"))
5475
+ {
5476
+ // Windows
5477
+ return "";
5478
+ }
5479
+
5480
+ return split[1];
5481
+ }
5482
+
5483
+ // Windows
5484
+ assert(split.length == 4);
5485
+
5486
+ return split[2] + ":" + split[3];
51775487 }
51785488
51795489 String GetPigmentTexture()
....@@ -5247,7 +5557,7 @@
52475557 System.out.print("; textures = " + textures);
52485558 System.out.println("; usedtextures = " + usedtextures);
52495559
5250
- if (GetTextures() == null)
5560
+ if (GetTextures() == null) // What is that??
52515561 GetTextures().name = ":";
52525562
52535563 String texname = tex;
....@@ -5278,6 +5588,43 @@
52785588 child.ResetPigmentTexture();
52795589 blockloop = false;
52805590 }
5591
+ }
5592
+
5593
+ UUID GetUUID()
5594
+ {
5595
+ if (uuid == null)
5596
+ {
5597
+ // Serial
5598
+ uuid = UUID.randomUUID();
5599
+ }
5600
+
5601
+ return uuid;
5602
+ }
5603
+
5604
+ Object3D GetObject(UUID uid)
5605
+ {
5606
+ if (blockloop)
5607
+ return null;
5608
+
5609
+ if (GetUUID().equals(uid))
5610
+ return this;
5611
+
5612
+ int nb = Size();
5613
+ for (int i = 0; i < nb; i++)
5614
+ {
5615
+ Object3D child = (Object3D) get(i);
5616
+
5617
+ if (child == null)
5618
+ continue;
5619
+
5620
+ blockloop = true;
5621
+ Object3D obj = child.GetObject(uid);
5622
+ blockloop = false;
5623
+ if (obj != null)
5624
+ return obj;
5625
+ }
5626
+
5627
+ return null;
52815628 }
52825629
52835630 void SetBumpTexture(String tex)
....@@ -5324,12 +5671,23 @@
53245671 boolean NeedSupport()
53255672 {
53265673 return
5327
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5674
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
53285675 // PROBLEM with CROWD!!
5329
- && (Globals.DrawMode() == iCameraPane.SHADOW || Globals.CROWD);
5676
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
53305677 }
53315678
53325679 static boolean DEBUG_SELECTION = false;
5680
+
5681
+ boolean IsLive()
5682
+ {
5683
+ if (live)
5684
+ return true;
5685
+
5686
+ if (parent == null)
5687
+ return false;
5688
+
5689
+ return parent.IsLive();
5690
+ }
53335691
53345692 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
53355693 {
....@@ -5341,7 +5699,7 @@
53415699 }
53425700
53435701 if (display.DrawMode() == iCameraPane.SELECTION &&
5344
- hide)
5702
+ (hide || dontselect))
53455703 return;
53465704
53475705 if (name != null && name.contains("sclera"))
....@@ -5392,7 +5750,7 @@
53925750 support = support;
53935751
53945752 //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);
5753
+ boolean usecalllists = IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
53965754
53975755 if (!usecalllists && bRep != null && bRep.displaylist > 0)
53985756 {
....@@ -5412,10 +5770,12 @@
54125770 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
54135771
54145772 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5415
- (touched || (bRep != null && bRep.displaylist <= 0)))
5773
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5774
+ (Globals.isLIVE() || touched && (bRep != null && bRep.displaylist <= 0)))
54165775 {
54175776 Globals.lighttouched = true;
54185777 } // all panes...
5778
+
54195779 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
54205780 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
54215781 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5583,7 +5943,28 @@
55835943 tex = GetTextures();
55845944 }
55855945
5586
- display.BindTextures(tex, texres);
5946
+ boolean failedPigment = false;
5947
+ boolean failedBump = false;
5948
+
5949
+ try
5950
+ {
5951
+ display.BindPigmentTexture(tex, texres);
5952
+ }
5953
+ catch (Exception e)
5954
+ {
5955
+ System.err.println("FAILED: " + this);
5956
+ failedPigment = true;
5957
+ }
5958
+
5959
+ try
5960
+ {
5961
+ display.BindBumpTexture(tex, texres);
5962
+ }
5963
+ catch (Exception e)
5964
+ {
5965
+ //System.err.println("FAILED: " + this);
5966
+ failedBump = true;
5967
+ }
55875968
55885969 if (!compiled)
55895970 {
....@@ -5605,7 +5986,11 @@
56055986 }
56065987 }
56075988
5608
- display.ReleaseTextures(tex);
5989
+ if (!failedBump)
5990
+ display.ReleaseBumpTexture(tex);
5991
+
5992
+ if (!failedPigment)
5993
+ display.ReleasePigmentTexture(tex);
56095994
56105995 display.PopMaterial(this, selected);
56115996 }
....@@ -5734,6 +6119,9 @@
57346119
57356120 void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57366121 {
6122
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6123
+ return;
6124
+
57376125 if (hide)
57386126 return;
57396127 // shadow optimisation
....@@ -5859,6 +6247,9 @@
58596247 if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
58606248 return; // no shadow for transparent objects
58616249
6250
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6251
+ return;
6252
+
58626253 if (hide)
58636254 return;
58646255
....@@ -5972,6 +6363,11 @@
59726363 // dec 2012
59736364 new Exception().printStackTrace();
59746365 return;
6366
+ }
6367
+
6368
+ if (dontselect)
6369
+ {
6370
+ //bRep.GenerateNormalsMINE();
59756371 }
59766372
59776373 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -6824,7 +7220,7 @@
68247220 spot.translate(32, 32);
68257221 spotw = spot.x + spot.width;
68267222 spoth = spot.y + spot.height;
6827
- info.g.setColor(Color.blue);
7223
+ info.g.setColor(Color.cyan);
68287224 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
68297225 // if (CameraPane.Xmin > spot.x)
68307226 // {
....@@ -6842,11 +7238,12 @@
68427238 // {
68437239 // CameraPane.Ymax = spoth;
68447240 // }
6845
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
6846
- info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7241
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7242
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
68477243 spot.translate(0, -32);
6848
- info.g.setColor(Color.green);
7244
+ info.g.setColor(Color.yellow);
68497245 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7246
+ info.g.setColor(Color.green);
68507247 // if (CameraPane.Xmin > spot.x)
68517248 // {
68527249 // CameraPane.Xmin = spot.x;
....@@ -6898,7 +7295,7 @@
68987295 startX = info.x;
68997296 startY = info.y;
69007297
6901
- hitSomething = 0;
7298
+ hitSomething = -1;
69027299 cVector origin = new cVector();
69037300 //LA.xformPos(origin, toParent, origin);
69047301 Rectangle spot = new Rectangle();
....@@ -6931,7 +7328,7 @@
69317328 }
69327329
69337330 //System.out.println("info.modifiers = " + info.modifiers);
6934
- modified = (info.modifiers & CameraPane.META) != 0;
7331
+ modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
69357332 //System.out.println("modified = " + modified);
69367333 //new Exception().printStackTrace();
69377334 //viewCode = info.pane.renderCamera.viewCode;
....@@ -6959,7 +7356,7 @@
69597356 return true;
69607357 }
69617358
6962
- void doEditDrag0(ClickInfo info)
7359
+ void doEditDrag0(ClickInfo info, boolean opposite)
69637360 {
69647361 if (hitSomething == 0)
69657362 {
....@@ -6974,6 +7371,7 @@
69747371 //System.out.println("hitSomething = " + hitSomething);
69757372
69767373 double scale = 0.005f * info.camera.Distance();
7374
+
69777375 cVector xlate = new cVector();
69787376 //cVector xlate2 = new cVector();
69797377 switch (hitSomething)
....@@ -6986,7 +7384,7 @@
69867384
69877385 scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
69887386
6989
- if (modified)
7387
+ if (modified || opposite)
69907388 {
69917389 //assert(false);
69927390 /*
....@@ -7080,6 +7478,7 @@
70807478
70817479 if (modified)
70827480 {
7481
+ // Rotate 90 degrees
70837482 angle /= (Math.PI / 4);
70847483 angle = Math.floor(angle + 0.5);
70857484 angle *= (Math.PI / 4);
....@@ -7121,24 +7520,27 @@
71217520
71227521 case hitScale: // scale
71237522 double hScale = (double) (info.x - centerPt.x) / 32;
7523
+ double sign = 1;
7524
+ if (hScale < 0)
7525
+ {
7526
+ sign = -1;
7527
+ }
7528
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
71247529 if (hScale < 0.01)
71257530 {
7126
- hScale = 0.01;
7531
+ //hScale = 0.01;
71277532 }
7128
- hScale = Math.pow(hScale, scale * 50);
7129
- if (hScale < 0.01)
7130
- {
7131
- hScale = 0.01;
7132
- }
7533
+
71337534 double vScale = (double) (info.y - centerPt.y) / 32;
7134
- if (vScale < 0.01)
7535
+ sign = 1;
7536
+ if (vScale < 0)
71357537 {
7136
- vScale = 0.01;
7538
+ sign = -1;
71377539 }
7138
- vScale = Math.pow(vScale, scale * 50);
7540
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
71397541 if (vScale < 0.01)
71407542 {
7141
- vScale = 0.01;
7543
+ //vScale = 0.01;
71427544 }
71437545 LA.matCopy(startMat, toParent);
71447546 /**/
....@@ -7149,39 +7551,47 @@
71497551 }
71507552 /**/
71517553
7554
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7555
+
7556
+ if (totalScale < 0.01)
7557
+ {
7558
+ totalScale = 0.01;
7559
+ }
7560
+
71527561 switch (info.pane.RenderCamera().viewCode)
71537562 {
71547563 case 3: // '\001'
7155
- if (modified)
7564
+ if (modified || opposite)
71567565 {
71577566 //LA.matScale(toParent, 1, hScale, vScale);
7158
- LA.matScale(toParent, vScale, 1, 1);
7567
+ LA.matScale(toParent, totalScale, 1, 1);
71597568 } // vScale, 1);
71607569 else
71617570 {
7162
- LA.matScale(toParent, vScale, vScale, vScale);
7571
+ // EXCEPTION!
7572
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
71637573 } // vScale, 1);
71647574 break;
71657575
71667576 case 2: // '\002'
7167
- if (modified)
7577
+ if (modified || opposite)
71687578 {
71697579 //LA.matScale(toParent, hScale, 1, vScale);
7170
- LA.matScale(toParent, 1, vScale, 1);
7580
+ LA.matScale(toParent, 1, totalScale, 1);
71717581 } else
71727582 {
7173
- LA.matScale(toParent, vScale, 1, vScale);
7583
+ LA.matScale(toParent, totalScale, 1, totalScale);
71747584 }
71757585 break;
71767586
71777587 case 1: // '\003'
7178
- if (modified)
7588
+ if (modified || opposite)
71797589 {
71807590 //LA.matScale(toParent, hScale, vScale, 1);
7181
- LA.matScale(toParent, 1, 1, vScale);
7591
+ LA.matScale(toParent, 1, 1, totalScale);
71827592 } else
71837593 {
7184
- LA.matScale(toParent, vScale, vScale, 1);
7594
+ LA.matScale(toParent, totalScale, totalScale, 1);
71857595 }
71867596 break;
71877597 }
....@@ -7314,14 +7724,22 @@
73147724 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
73157725 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
73167726 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7727
+
7728
+ String objname;
7729
+
73177730 if (false) //parent != null)
73187731 {
7319
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7732
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
73207733 } else
73217734 {
7322
- return GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ") ")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ +System.identityHashCode(this);
7735
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
73237736 } // + super.toString();
73247737 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
7738
+
7739
+ if (!Globals.ADVANCED)
7740
+ return objname;
7741
+
7742
+ return objname + " " + System.identityHashCode(this);
73257743 }
73267744
73277745 public int hashCode()
....@@ -7377,6 +7795,7 @@
73777795 objectUI.closeUI();
73787796 if (editWindow != null)
73797797 {
7798
+ editWindow.ctrlPanel.FlushUI();
73807799 editWindow.refreshContents();
73817800 } // ? new
73827801 objectUI = null;
....@@ -7385,6 +7804,10 @@
73857804 {
73867805 editWindow = null;
73877806 } // ?
7807
+ }
7808
+ else
7809
+ {
7810
+ //editWindow.closeUI();
73887811 }
73897812 }
73907813
....@@ -7397,7 +7820,7 @@
73977820 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
73987821
73997822 Object3D /*Composite*/ parent;
7400
- Object3D /*Composite*/ fileparent;
7823
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
74017824
74027825 double[][] toParent; // dynamic matrix
74037826 double[][] fromParent;
....@@ -7512,7 +7935,7 @@
75127935 {
75137936 assert(bRep != null);
75147937 if (!(support instanceof GenericJoint)) // support.bRep != null)
7515
- GrafreeD.Assert(support.bRep == bRep.support);
7938
+ Grafreed.Assert(support.bRep == bRep.support);
75167939 }
75177940 else
75187941 {
....@@ -7561,9 +7984,9 @@
75617984 private static cVector edge2 = new cVector();
75627985 //private static cVector norm = new cVector();
75637986 /*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;
7987
+ static final int hitCenter = 1;
7988
+ static final int hitScale = 2;
7989
+ static final int hitRotate = 3;
75677990 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
75687991 /*transient*/ private Point centerPt;
75697992 /*transient*/ private int startX;