Normand Briere
2019-06-23 8088590686a45e71278f9a52bb9cc37943dc0c37
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;
....@@ -2906,7 +3034,8 @@
29063034 {
29073035 if (bRep != null)
29083036 {
2909
- bRep.GenUV();
3037
+ bRep.GenUV(); //1);
3038
+ //bRep.UnfoldUV();
29103039 Touch();
29113040 }
29123041 }
....@@ -2916,6 +3045,15 @@
29163045 if (bRep != null)
29173046 {
29183047 bRep.GenerateNormals(crease);
3048
+ Touch();
3049
+ }
3050
+ }
3051
+
3052
+ void GenNormalsMesh0()
3053
+ {
3054
+ if (bRep != null)
3055
+ {
3056
+ bRep.GenerateNormalsMesh();
29193057 Touch();
29203058 }
29213059 }
....@@ -2981,6 +3119,33 @@
29813119 blockloop = false;
29823120 }
29833121
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
+
29843149 void TransformGeometry()
29853150 {
29863151 Object3D obj = this;
....@@ -3202,9 +3367,11 @@
32023367
32033368 BoundaryRep sup = bRep.support;
32043369 bRep.support = null;
3205
- BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
3370
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
32063371 // bRep.SplitInTwo(onlyone); // thread...
3207
- temprep.SplitInTwo(reduction34, onlyone);
3372
+
3373
+ while(temprep.SplitInTwo(reduction34, onlyone));
3374
+
32083375 bRep = temprep;
32093376 bRep.support = sup;
32103377 Touch();
....@@ -3341,7 +3508,8 @@
33413508 if (blockloop)
33423509 return;
33433510
3344
- if (marked || (bRep != null && material != null)) // borderline...
3511
+ if (//marked || // does not make sense
3512
+ (bRep != null || material != null)) // borderline...
33453513 live = h;
33463514
33473515 for (int i = 0; i < Size(); i++)
....@@ -3362,7 +3530,8 @@
33623530 return;
33633531
33643532 //if (bRep != null)
3365
- if (marked || (bRep != null && material != null)) // borderline...
3533
+ if (//marked || // does not make sense
3534
+ (bRep != null || material != null)) // borderline...
33663535 link2master = h;
33673536
33683537 for (int i = 0; i < Size(); i++)
....@@ -3382,7 +3551,8 @@
33823551 if (blockloop)
33833552 return;
33843553
3385
- if (marked || (bRep != null && material != null)) // borderline...
3554
+ if (//marked || // does not make sense
3555
+ (bRep != null || material != null)) // borderline...
33863556 hide = h;
33873557
33883558 for (int i = 0; i < Size(); i++)
....@@ -3402,7 +3572,7 @@
34023572 if (blockloop)
34033573 return;
34043574
3405
- if (bRep != null && material != null) // borderline...
3575
+ if (bRep != null || material != null) // borderline...
34063576 marked = h;
34073577
34083578 for (int i = 0; i < Size(); i++)
....@@ -3412,6 +3582,46 @@
34123582 continue;
34133583 blockloop = true;
34143584 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);
34153625 blockloop = false;
34163626 // release(i);
34173627 }
....@@ -3726,7 +3936,7 @@
37263936 if (child == null)
37273937 continue;
37283938
3729
- if (GrafreeD.RENDERME > 0)
3939
+ if (Grafreed.RENDERME > 0)
37303940 {
37313941 if (child instanceof Merge)
37323942 ((Merge)child).renderme();
....@@ -3877,7 +4087,7 @@
38774087 if (child == null)
38784088 continue;
38794089
3880
- if (GrafreeD.RENDERME > 0)
4090
+ if (Grafreed.RENDERME > 0)
38814091 {
38824092 if (child instanceof Merge)
38834093 ((Merge)child).renderme();
....@@ -4072,7 +4282,7 @@
40724282 if (child == null)
40734283 continue;
40744284
4075
- if (GrafreeD.RENDERME > 0)
4285
+ if (Grafreed.RENDERME > 0)
40764286 {
40774287 if (child instanceof Merge)
40784288 ((Merge)child).renderme();
....@@ -4185,6 +4395,55 @@
41854395 {
41864396 blockloop = true;
41874397 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();
41884447 blockloop = false;
41894448 }
41904449 }
....@@ -4679,7 +4938,7 @@
46794938
46804939 cTreePath SelectLeaf(int indexcount, boolean deselect)
46814940 {
4682
- if (hide)
4941
+ if (hide || dontselect)
46834942 return null;
46844943
46854944 if (count <= 0)
....@@ -4705,7 +4964,7 @@
47054964
47064965 cTreePath Select(int indexcount, boolean deselect)
47074966 {
4708
- if (hide)
4967
+ if (hide || dontselect)
47094968 return null;
47104969
47114970 if (count <= 0)
....@@ -5157,10 +5416,34 @@
51575416
51585417 // System.out.println("Fullname = " + fullname);
51595418
5160
- if (fullname.name.indexOf(":") == -1)
5161
- 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(":"));
51625424
5163
- 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];
51645447 }
51655448
51665449 static String GetBump(cTexture fullname)
....@@ -5169,10 +5452,38 @@
51695452 return "";
51705453
51715454 // System.out.println("Fullname = " + fullname);
5172
- if (fullname.name.indexOf(":") == -1)
5173
- return "";
5174
-
5175
- 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];
51765487 }
51775488
51785489 String GetPigmentTexture()
....@@ -5246,7 +5557,7 @@
52465557 System.out.print("; textures = " + textures);
52475558 System.out.println("; usedtextures = " + usedtextures);
52485559
5249
- if (GetTextures() == null)
5560
+ if (GetTextures() == null) // What is that??
52505561 GetTextures().name = ":";
52515562
52525563 String texname = tex;
....@@ -5277,6 +5588,43 @@
52775588 child.ResetPigmentTexture();
52785589 blockloop = false;
52795590 }
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;
52805628 }
52815629
52825630 void SetBumpTexture(String tex)
....@@ -5323,12 +5671,23 @@
53235671 boolean NeedSupport()
53245672 {
53255673 return
5326
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5674
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
53275675 // PROBLEM with CROWD!!
5328
- && (Globals.DrawMode() == iCameraPane.SHADOW || Globals.CROWD);
5676
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
53295677 }
53305678
53315679 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
+ }
53325691
53335692 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
53345693 {
....@@ -5340,7 +5699,7 @@
53405699 }
53415700
53425701 if (display.DrawMode() == iCameraPane.SELECTION &&
5343
- hide)
5702
+ (hide || dontselect))
53445703 return;
53455704
53465705 if (name != null && name.contains("sclera"))
....@@ -5391,7 +5750,7 @@
53915750 support = support;
53925751
53935752 //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5394
- 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);
53955754
53965755 if (!usecalllists && bRep != null && bRep.displaylist > 0)
53975756 {
....@@ -5411,10 +5770,12 @@
54115770 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
54125771
54135772 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5414
- (touched || (bRep != null && bRep.displaylist <= 0)))
5773
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5774
+ (Globals.isLIVE() || touched && (bRep != null && bRep.displaylist <= 0)))
54155775 {
54165776 Globals.lighttouched = true;
54175777 } // all panes...
5778
+
54185779 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
54195780 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
54205781 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5582,7 +5943,28 @@
55825943 tex = GetTextures();
55835944 }
55845945
5585
- 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
+ }
55865968
55875969 if (!compiled)
55885970 {
....@@ -5604,7 +5986,11 @@
56045986 }
56055987 }
56065988
5607
- display.ReleaseTextures(tex);
5989
+ if (!failedBump)
5990
+ display.ReleaseBumpTexture(tex);
5991
+
5992
+ if (!failedPigment)
5993
+ display.ReleasePigmentTexture(tex);
56085994
56095995 display.PopMaterial(this, selected);
56105996 }
....@@ -5733,6 +6119,9 @@
57336119
57346120 void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57356121 {
6122
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6123
+ return;
6124
+
57366125 if (hide)
57376126 return;
57386127 // shadow optimisation
....@@ -5858,6 +6247,9 @@
58586247 if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
58596248 return; // no shadow for transparent objects
58606249
6250
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6251
+ return;
6252
+
58616253 if (hide)
58626254 return;
58636255
....@@ -5898,6 +6290,7 @@
58986290 return;
58996291 }
59006292
6293
+ //bRep.GenUV(1/material.diffuseness);
59016294 // bRep.lock = true;
59026295
59036296 //javax.media.opengl.GL gl = display.GetGL();
....@@ -5970,6 +6363,11 @@
59706363 // dec 2012
59716364 new Exception().printStackTrace();
59726365 return;
6366
+ }
6367
+
6368
+ if (dontselect)
6369
+ {
6370
+ //bRep.GenerateNormalsMINE();
59736371 }
59746372
59756373 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -6822,7 +7220,7 @@
68227220 spot.translate(32, 32);
68237221 spotw = spot.x + spot.width;
68247222 spoth = spot.y + spot.height;
6825
- info.g.setColor(Color.blue);
7223
+ info.g.setColor(Color.cyan);
68267224 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
68277225 // if (CameraPane.Xmin > spot.x)
68287226 // {
....@@ -6840,11 +7238,12 @@
68407238 // {
68417239 // CameraPane.Ymax = spoth;
68427240 // }
6843
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
6844
- 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
68457243 spot.translate(0, -32);
6846
- info.g.setColor(Color.green);
7244
+ info.g.setColor(Color.yellow);
68477245 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7246
+ info.g.setColor(Color.green);
68487247 // if (CameraPane.Xmin > spot.x)
68497248 // {
68507249 // CameraPane.Xmin = spot.x;
....@@ -6896,7 +7295,7 @@
68967295 startX = info.x;
68977296 startY = info.y;
68987297
6899
- hitSomething = 0;
7298
+ hitSomething = -1;
69007299 cVector origin = new cVector();
69017300 //LA.xformPos(origin, toParent, origin);
69027301 Rectangle spot = new Rectangle();
....@@ -6929,7 +7328,7 @@
69297328 }
69307329
69317330 //System.out.println("info.modifiers = " + info.modifiers);
6932
- modified = (info.modifiers & CameraPane.META) != 0;
7331
+ modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
69337332 //System.out.println("modified = " + modified);
69347333 //new Exception().printStackTrace();
69357334 //viewCode = info.pane.renderCamera.viewCode;
....@@ -6957,7 +7356,7 @@
69577356 return true;
69587357 }
69597358
6960
- void doEditDrag0(ClickInfo info)
7359
+ void doEditDrag0(ClickInfo info, boolean opposite)
69617360 {
69627361 if (hitSomething == 0)
69637362 {
....@@ -6972,6 +7371,7 @@
69727371 //System.out.println("hitSomething = " + hitSomething);
69737372
69747373 double scale = 0.005f * info.camera.Distance();
7374
+
69757375 cVector xlate = new cVector();
69767376 //cVector xlate2 = new cVector();
69777377 switch (hitSomething)
....@@ -6984,7 +7384,7 @@
69847384
69857385 scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
69867386
6987
- if (modified)
7387
+ if (modified || opposite)
69887388 {
69897389 //assert(false);
69907390 /*
....@@ -7078,6 +7478,7 @@
70787478
70797479 if (modified)
70807480 {
7481
+ // Rotate 90 degrees
70817482 angle /= (Math.PI / 4);
70827483 angle = Math.floor(angle + 0.5);
70837484 angle *= (Math.PI / 4);
....@@ -7119,24 +7520,27 @@
71197520
71207521 case hitScale: // scale
71217522 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);
71227529 if (hScale < 0.01)
71237530 {
7124
- hScale = 0.01;
7531
+ //hScale = 0.01;
71257532 }
7126
- hScale = Math.pow(hScale, scale * 50);
7127
- if (hScale < 0.01)
7128
- {
7129
- hScale = 0.01;
7130
- }
7533
+
71317534 double vScale = (double) (info.y - centerPt.y) / 32;
7132
- if (vScale < 0.01)
7535
+ sign = 1;
7536
+ if (vScale < 0)
71337537 {
7134
- vScale = 0.01;
7538
+ sign = -1;
71357539 }
7136
- vScale = Math.pow(vScale, scale * 50);
7540
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
71377541 if (vScale < 0.01)
71387542 {
7139
- vScale = 0.01;
7543
+ //vScale = 0.01;
71407544 }
71417545 LA.matCopy(startMat, toParent);
71427546 /**/
....@@ -7147,39 +7551,47 @@
71477551 }
71487552 /**/
71497553
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
+
71507561 switch (info.pane.RenderCamera().viewCode)
71517562 {
71527563 case 3: // '\001'
7153
- if (modified)
7564
+ if (modified || opposite)
71547565 {
71557566 //LA.matScale(toParent, 1, hScale, vScale);
7156
- LA.matScale(toParent, vScale, 1, 1);
7567
+ LA.matScale(toParent, totalScale, 1, 1);
71577568 } // vScale, 1);
71587569 else
71597570 {
7160
- LA.matScale(toParent, vScale, vScale, vScale);
7571
+ // EXCEPTION!
7572
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
71617573 } // vScale, 1);
71627574 break;
71637575
71647576 case 2: // '\002'
7165
- if (modified)
7577
+ if (modified || opposite)
71667578 {
71677579 //LA.matScale(toParent, hScale, 1, vScale);
7168
- LA.matScale(toParent, 1, vScale, 1);
7580
+ LA.matScale(toParent, 1, totalScale, 1);
71697581 } else
71707582 {
7171
- LA.matScale(toParent, vScale, 1, vScale);
7583
+ LA.matScale(toParent, totalScale, 1, totalScale);
71727584 }
71737585 break;
71747586
71757587 case 1: // '\003'
7176
- if (modified)
7588
+ if (modified || opposite)
71777589 {
71787590 //LA.matScale(toParent, hScale, vScale, 1);
7179
- LA.matScale(toParent, 1, 1, vScale);
7591
+ LA.matScale(toParent, 1, 1, totalScale);
71807592 } else
71817593 {
7182
- LA.matScale(toParent, vScale, vScale, 1);
7594
+ LA.matScale(toParent, totalScale, totalScale, 1);
71837595 }
71847596 break;
71857597 }
....@@ -7312,14 +7724,22 @@
73127724 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
73137725 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
73147726 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7727
+
7728
+ String objname;
7729
+
73157730 if (false) //parent != null)
73167731 {
7317
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7732
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
73187733 } else
73197734 {
7320
- 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) ":"") */ "";
73217736 } // + super.toString();
73227737 //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);
73237743 }
73247744
73257745 public int hashCode()
....@@ -7375,6 +7795,7 @@
73757795 objectUI.closeUI();
73767796 if (editWindow != null)
73777797 {
7798
+ editWindow.ctrlPanel.FlushUI();
73787799 editWindow.refreshContents();
73797800 } // ? new
73807801 objectUI = null;
....@@ -7383,6 +7804,10 @@
73837804 {
73847805 editWindow = null;
73857806 } // ?
7807
+ }
7808
+ else
7809
+ {
7810
+ //editWindow.closeUI();
73867811 }
73877812 }
73887813
....@@ -7395,7 +7820,7 @@
73957820 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
73967821
73977822 Object3D /*Composite*/ parent;
7398
- Object3D /*Composite*/ fileparent;
7823
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
73997824
74007825 double[][] toParent; // dynamic matrix
74017826 double[][] fromParent;
....@@ -7510,7 +7935,7 @@
75107935 {
75117936 assert(bRep != null);
75127937 if (!(support instanceof GenericJoint)) // support.bRep != null)
7513
- GrafreeD.Assert(support.bRep == bRep.support);
7938
+ Grafreed.Assert(support.bRep == bRep.support);
75147939 }
75157940 else
75167941 {
....@@ -7559,9 +7984,9 @@
75597984 private static cVector edge2 = new cVector();
75607985 //private static cVector norm = new cVector();
75617986 /*transient private*/ int hitSomething;
7562
- private static final int hitCenter = 1;
7563
- private static final int hitScale = 2;
7564
- private static final int hitRotate = 3;
7987
+ static final int hitCenter = 1;
7988
+ static final int hitScale = 2;
7989
+ static final int hitRotate = 3;
75657990 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
75667991 /*transient*/ private Point centerPt;
75677992 /*transient*/ private int startX;