Normand Briere
2019-07-17 a5580a47d246c1272b10adba68070f6e13da5e41
Object3D.java
....@@ -14,12 +14,24 @@
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;
2224
25
+ private UUID uuid = UUID.randomUUID();
26
+
27
+ // TEMPORARY for mocap undo. No need to be transient.
28
+ mocap.reader.BVHReader.BVHResult savebvh;
29
+ Object3D saveskeleton;
30
+ //
31
+
32
+ byte[] versions[] = new byte[100][];
33
+ int versionindex = -1;
34
+
2335 ScriptNode scriptnode;
2436
2537 void InitOthers()
....@@ -100,64 +112,173 @@
100112
101113 // transient boolean reduced; // for morph reduction
102114
103
-transient com.bulletphysics.linearmath.Transform cache; // for fast merge
104
-transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
115
+ transient com.bulletphysics.linearmath.Transform cache; // for fast merge
116
+ transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
105117
106
-transient Object3D transientsupport; // for cloning
107
-transient boolean transientlink2master;
118
+ transient Object3D transientsupport; // for cloning
119
+ transient boolean transientlink2master;
108120
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)
121
+ void SaveSupports()
121122 {
122
- bRep.SaveSupports();
123
+ if (blockloop)
124
+ return;
125
+
126
+ transientsupport = support;
127
+ transientlink2master = link2master;
128
+
129
+ support = null;
130
+ link2master = false;
131
+
132
+ if (bRep != null)
133
+ {
134
+ bRep.SaveSupports();
135
+ }
136
+
137
+ for (int i = 0; i < Size(); i++)
138
+ {
139
+ Object3D child = (Object3D) get(i);
140
+ if (child == null)
141
+ continue;
142
+ blockloop = true;
143
+ child.SaveSupports();
144
+ blockloop = false;
145
+ }
123146 }
124
-
125
- for (int i = 0; i < Size(); i++)
147
+
148
+ void RestoreSupports()
126149 {
127
- Object3D child = (Object3D) get(i);
128
- if (child == null)
129
- continue;
150
+ if (blockloop)
151
+ return;
152
+
153
+ support = transientsupport;
154
+ link2master = transientlink2master;
155
+ transientsupport = null;
156
+ transientlink2master = false;
157
+
158
+ if (bRep != null)
159
+ {
160
+ bRep.RestoreSupports();
161
+ }
162
+
163
+ for (int i = 0; i < Size(); i++)
164
+ {
165
+ Object3D child = (Object3D) get(i);
166
+ if (child == null)
167
+ continue;
168
+ blockloop = true;
169
+ child.RestoreSupports();
170
+ blockloop = false;
171
+ }
172
+ }
173
+
174
+ void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
175
+ {
176
+ Object3D o;
177
+
178
+ if (hashtable.containsKey(GetUUID()))
179
+ {
180
+ o = hashtable.get(GetUUID());
181
+
182
+ Grafreed.Assert(this.bRep == o.bRep);
183
+ //if (this.bRep != null)
184
+ // assert(this.bRep.support == o.transientrep);
185
+ if (this.support != null)
186
+ assert(this.support.bRep == o.transientrep);
187
+ }
188
+ else
189
+ {
190
+ o = new Object3D("copy of " + this.name);
191
+
192
+ hashtable.put(GetUUID(), o);
193
+ }
194
+
195
+ if (!blockloop)
196
+ {
197
+ blockloop = true;
198
+
199
+ for (int i=0; i<Size(); i++)
200
+ {
201
+ get(i).ExtractBigData(hashtable);
202
+ }
203
+
204
+ blockloop = false;
205
+ }
206
+
207
+ ExtractBigData(o);
208
+ }
209
+
210
+ void ExtractBigData(Object3D o)
211
+ {
212
+ if (o.bRep != null)
213
+ Grafreed.Assert(o.bRep == this.bRep);
214
+
215
+ o.bRep = this.bRep;
216
+// July 2019 if (this.bRep != null)
217
+// {
218
+// o.transientrep = this.bRep.support;
219
+// o.bRep.support = null;
220
+// }
221
+ o.selection = this.selection;
222
+
223
+ if (this.support != null)
224
+ {
225
+ if (o.transientrep != null)
226
+ Grafreed.Assert(o.transientrep == this.support.bRep);
227
+
228
+ o.transientrep = this.support.bRep;
229
+ this.support.bRep = null;
230
+ }
231
+
232
+ // o.support = this.support;
233
+ // o.fileparent = this.fileparent;
234
+ // if (this.bRep != null)
235
+ // o.bRep = this.bRep.support;
236
+
237
+ this.bRep = null;
238
+ // if (this.bRep != null)
239
+ // this.bRep.support = null;
240
+ // this.support = null;
241
+ // this.fileparent = null;
242
+ }
243
+
244
+ void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
245
+ {
246
+ if (!hashtable.containsKey(GetUUID()))
247
+ return;
248
+
249
+ Object3D o = hashtable.get(GetUUID());
250
+
251
+ RestoreBigData(o);
252
+
253
+ if (blockloop)
254
+ return;
255
+
130256 blockloop = true;
131
- child.SaveSupports();
257
+
258
+ //hashtable.remove(GetUUID());
259
+
260
+ for (int i=0; i<Size(); i++)
261
+ {
262
+ get(i).RestoreBigData(hashtable);
263
+ }
264
+
132265 blockloop = false;
133266 }
134
-}
135267
136
-void RestoreSupports()
137
-{
138
- if (blockloop)
139
- return;
140
-
141
- support = transientsupport;
142
- link2master = transientlink2master;
143
- transientsupport = null;
144
- transientlink2master = false;
145
-
146
- if (bRep != null)
268
+ void RestoreBigData(Object3D o)
147269 {
148
- bRep.RestoreSupports();
270
+ this.bRep = o.bRep;
271
+ if (this.support != null && o.transientrep != null)
272
+ {
273
+ this.support.bRep = o.transientrep;
274
+ }
275
+
276
+ this.selection = o.selection;
277
+// July 2019 if (this.bRep != null)
278
+// this.bRep.support = o.transientrep;
279
+ // this.support = o.support;
280
+ // this.fileparent = o.fileparent;
149281 }
150
-
151
- for (int i = 0; i < Size(); i++)
152
- {
153
- Object3D child = (Object3D) get(i);
154
- if (child == null)
155
- continue;
156
- blockloop = true;
157
- child.RestoreSupports();
158
- blockloop = false;
159
- }
160
-}
161282
162283 // MOCAP SUPPORT
163284 double tx,ty,tz,rx,ry,rz;
....@@ -300,6 +421,7 @@
300421 }
301422
302423 boolean live = false;
424
+ boolean dontselect = false;
303425 boolean hide = false;
304426 boolean link2master = false; // performs reset support/master at each frame
305427 boolean marked = false; // animation node
....@@ -481,12 +603,14 @@
481603 toParent = LA.newMatrix();
482604 fromParent = LA.newMatrix();
483605 }
606
+
484607 if (toParentMarked == null)
485608 {
486609 if (maxcount != 1)
487610 {
488611 new Exception().printStackTrace();
489612 }
613
+
490614 toParentMarked = LA.newMatrix();
491615 fromParentMarked = LA.newMatrix();
492616 }
....@@ -774,7 +898,7 @@
774898 if (step == 0)
775899 step = 1;
776900 if (maxcount == 0)
777
- maxcount = 2048; // 4;
901
+ maxcount = 128; // 2048; // 4;
778902 // if (acceleration == 0)
779903 // acceleration = 10;
780904 if (delay == 0) // serial
....@@ -797,7 +921,7 @@
797921
798922 if (marked && Globals.isLIVE() && live &&
799923 //TEMP21aug2018
800
- Globals.DrawMode() == iCameraPane.SHADOW &&
924
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
801925 currentframe != Globals.framecount)
802926 {
803927 currentframe = Globals.framecount;
....@@ -809,7 +933,8 @@
809933
810934 boolean changedir = random && Math.random() < 0.01; // && !link2master;
811935
812
- if (transformcount*factor > maxcount || (step == 1 && changedir))
936
+ if (transformcount*factor >= maxcount && (rewind || random) ||
937
+ (step == 1 && changedir))
813938 {
814939 countdown = 1;
815940 delay = speedup?8:1;
....@@ -881,6 +1006,7 @@
8811006 if (material == null || material.multiply)
8821007 return true;
8831008
1009
+ // Transparent objects are dynamic because we have to sort the triangles.
8841010 return material.opacity > 0.99;
8851011 }
8861012
....@@ -912,6 +1038,11 @@
9121038 fromParent = null; // LA.newMatrix();
9131039 bRep = null; // new BoundaryRep();
9141040
1041
+ if (oname != null && oname.equals("LeftHand"))
1042
+ {
1043
+ name = oname;
1044
+ }
1045
+
9151046 /*
9161047 float hue = (float)Math.random();
9171048 Color col;
....@@ -954,7 +1085,7 @@
9541085
9551086 public Object clone()
9561087 {
957
- return GrafreeD.clone(this);
1088
+ return Grafreed.clone(this);
9581089 }
9591090
9601091 Object3D copyExpand()
....@@ -1276,6 +1407,7 @@
12761407 toParent = LA.newMatrix();
12771408 fromParent = LA.newMatrix();
12781409 }
1410
+
12791411 LA.matCopy(other.toParent, toParent);
12801412 LA.matCopy(other.fromParent, fromParent);
12811413
....@@ -1470,7 +1602,7 @@
14701602 BoundaryRep.SEUIL = other.material.cameralight;
14711603
14721604 // Set default to 0.1
1473
- BoundaryRep.SEUIL /= 2;
1605
+ BoundaryRep.SEUIL /= 4; // 2;
14741606 System.out.println("SEUIL = " + BoundaryRep.SEUIL);
14751607 }
14761608
....@@ -1729,7 +1861,7 @@
17291861 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17301862 o.bRep = transientrep;
17311863 if (clone)
1732
- o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
1864
+ o.bRep = (BoundaryRep) Grafreed.clone(transientrep);
17331865 o.CreateMaterial();
17341866 o.SetAttributes(this, -1);
17351867 //parent
....@@ -1742,7 +1874,7 @@
17421874 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17431875 o.bRep = bRep;
17441876 if (clone)
1745
- o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
1877
+ o.bRep = (BoundaryRep) Grafreed.clone(bRep);
17461878 o.CreateMaterial();
17471879 //o.overwriteThis(this, -1);
17481880 o.SetAttributes(this, -1);
....@@ -1829,12 +1961,15 @@
18291961 if (obj.name == null)
18301962 continue; // can't be a null one
18311963
1964
+ // Try perfect match first.
18321965 if (n.equals(obj.name))
18331966 {
18341967 theobj = obj;
18351968 count++;
18361969 }
18371970 }
1971
+
1972
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18381973
18391974 if (count != 1)
18401975 for (int i=Size(); --i>=0;)
....@@ -2294,6 +2429,10 @@
22942429 }
22952430 */
22962431 }
2432
+ else
2433
+ {
2434
+ //((ObjEditor)editWindow).SetupUI2(null);
2435
+ }
22972436 }
22982437
22992438 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
....@@ -2335,6 +2474,14 @@
23352474 {
23362475 editWindow.refreshContents();
23372476 }
2477
+ else
2478
+ {
2479
+ if (manipWindow != null)
2480
+ {
2481
+ manipWindow.refreshContents();
2482
+ }
2483
+ }
2484
+
23382485 //if (parent != null)
23392486 //parent.refreshEditWindow();
23402487 }
....@@ -2477,13 +2624,13 @@
24772624 return retval;
24782625 }
24792626
2480
- void doEditDrag(ClickInfo info)
2627
+ void doEditDrag(ClickInfo info, boolean opposite)
24812628 {
24822629 switch (doSomething)
24832630 {
24842631 case 1: // '\001'
24852632 //super.
2486
- doEditDrag0(info);
2633
+ doEditDrag0(info, opposite);
24872634 break;
24882635
24892636 case 2: // '\002'
....@@ -2496,11 +2643,11 @@
24962643 {
24972644 //sel.hitSomething = childToDrag.hitSomething;
24982645 //childToDrag.doEditDrag(info);
2499
- sel.doEditDrag(info);
2646
+ sel.doEditDrag(info, opposite);
25002647 } else
25012648 {
25022649 //super.
2503
- doEditDrag0(info);
2650
+ doEditDrag0(info, opposite);
25042651 }
25052652 }
25062653 break;
....@@ -2610,6 +2757,18 @@
26102757 void GenNormalsS(boolean crease)
26112758 {
26122759 selection.GenNormals(crease);
2760
+// for (int i=0; i<selection.size(); i++)
2761
+// {
2762
+// Object3D selectee = (Object3D) selection.elementAt(i);
2763
+// selectee.GenNormals(crease);
2764
+// }
2765
+
2766
+ //Touch();
2767
+ }
2768
+
2769
+ void GenNormalsMeshS()
2770
+ {
2771
+ selection.GenNormalsMesh();
26132772 // for (int i=0; i<selection.size(); i++)
26142773 // {
26152774 // Object3D selectee = (Object3D) selection.elementAt(i);
....@@ -2750,6 +2909,24 @@
27502909 if (child == null)
27512910 continue;
27522911 child.GenNormals(crease);
2912
+// Children().release(i);
2913
+ }
2914
+ blockloop = false;
2915
+ }
2916
+
2917
+ void GenNormalsMesh()
2918
+ {
2919
+ if (blockloop)
2920
+ return;
2921
+
2922
+ blockloop = true;
2923
+ GenNormalsMesh0();
2924
+ for (int i = 0; i < Children().Size(); i++)
2925
+ {
2926
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2927
+ if (child == null)
2928
+ continue;
2929
+ child.GenNormalsMesh();
27532930 // Children().release(i);
27542931 }
27552932 blockloop = false;
....@@ -2922,6 +3099,15 @@
29223099 }
29233100 }
29243101
3102
+ void GenNormalsMesh0()
3103
+ {
3104
+ if (bRep != null)
3105
+ {
3106
+ bRep.GenerateNormalsMesh();
3107
+ Touch();
3108
+ }
3109
+ }
3110
+
29253111 void GenNormalsMINE0()
29263112 {
29273113 if (bRep != null)
....@@ -2983,6 +3169,33 @@
29833169 blockloop = false;
29843170 }
29853171
3172
+ void TransformChildren()
3173
+ {
3174
+ if (toParent != null)
3175
+ {
3176
+ for (int i=Size(); --i>=0;)
3177
+ {
3178
+ Object3D v = get(i);
3179
+
3180
+ if (v.toParent == null)
3181
+ {
3182
+ v.toParent = LA.newMatrix();
3183
+ v.fromParent = LA.newMatrix();
3184
+ }
3185
+
3186
+// LA.matConcat(v.toParent, toParent, v.toParent);
3187
+// LA.matConcat(fromParent, v.fromParent, v.fromParent);
3188
+ LA.matConcat(toParent, v.toParent, v.toParent);
3189
+ LA.matConcat(v.fromParent, fromParent, v.fromParent);
3190
+ }
3191
+
3192
+ toParent = null; // LA.matIdentity(toParent);
3193
+ fromParent = null; // LA.matIdentity(fromParent);
3194
+
3195
+ Touch();
3196
+ }
3197
+ }
3198
+
29863199 void TransformGeometry()
29873200 {
29883201 Object3D obj = this;
....@@ -3204,9 +3417,11 @@
32043417
32053418 BoundaryRep sup = bRep.support;
32063419 bRep.support = null;
3207
- BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
3420
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
32083421 // bRep.SplitInTwo(onlyone); // thread...
3209
- temprep.SplitInTwo(reduction34, onlyone);
3422
+
3423
+ while(temprep.SplitInTwo(reduction34, onlyone));
3424
+
32103425 bRep = temprep;
32113426 bRep.support = sup;
32123427 Touch();
....@@ -3343,7 +3558,8 @@
33433558 if (blockloop)
33443559 return;
33453560
3346
- if (marked || (bRep != null && material != null)) // borderline...
3561
+ if (//marked || // does not make sense
3562
+ (bRep != null || material != null)) // borderline...
33473563 live = h;
33483564
33493565 for (int i = 0; i < Size(); i++)
....@@ -3364,7 +3580,8 @@
33643580 return;
33653581
33663582 //if (bRep != null)
3367
- if (marked || (bRep != null && material != null)) // borderline...
3583
+ if (//marked || // does not make sense
3584
+ (bRep != null || material != null)) // borderline...
33683585 link2master = h;
33693586
33703587 for (int i = 0; i < Size(); i++)
....@@ -3384,7 +3601,8 @@
33843601 if (blockloop)
33853602 return;
33863603
3387
- if (marked || (bRep != null && material != null)) // borderline...
3604
+ if (//marked || // does not make sense
3605
+ (bRep != null || material != null)) // borderline...
33883606 hide = h;
33893607
33903608 for (int i = 0; i < Size(); i++)
....@@ -3404,7 +3622,7 @@
34043622 if (blockloop)
34053623 return;
34063624
3407
- if (bRep != null && material != null) // borderline...
3625
+ if (bRep != null || material != null) // borderline...
34083626 marked = h;
34093627
34103628 for (int i = 0; i < Size(); i++)
....@@ -3414,6 +3632,46 @@
34143632 continue;
34153633 blockloop = true;
34163634 child.MarkLeaves(h);
3635
+ blockloop = false;
3636
+ // release(i);
3637
+ }
3638
+ }
3639
+
3640
+ void RewindLeaves(boolean h)
3641
+ {
3642
+ if (blockloop)
3643
+ return;
3644
+
3645
+ if (bRep != null || material != null) // borderline...
3646
+ rewind = h;
3647
+
3648
+ for (int i = 0; i < Size(); i++)
3649
+ {
3650
+ Object3D child = (Object3D) get(i); // reserve(i);
3651
+ if (child == null)
3652
+ continue;
3653
+ blockloop = true;
3654
+ child.RewindLeaves(h);
3655
+ blockloop = false;
3656
+ // release(i);
3657
+ }
3658
+ }
3659
+
3660
+ void RandomLeaves(boolean h)
3661
+ {
3662
+ if (blockloop)
3663
+ return;
3664
+
3665
+ if (bRep != null || material != null) // borderline...
3666
+ random = h;
3667
+
3668
+ for (int i = 0; i < Size(); i++)
3669
+ {
3670
+ Object3D child = (Object3D) get(i); // reserve(i);
3671
+ if (child == null)
3672
+ continue;
3673
+ blockloop = true;
3674
+ child.RandomLeaves(h);
34173675 blockloop = false;
34183676 // release(i);
34193677 }
....@@ -3728,7 +3986,7 @@
37283986 if (child == null)
37293987 continue;
37303988
3731
- if (GrafreeD.RENDERME > 0)
3989
+ if (Grafreed.RENDERME > 0)
37323990 {
37333991 if (child instanceof Merge)
37343992 ((Merge)child).renderme();
....@@ -3879,7 +4137,7 @@
38794137 if (child == null)
38804138 continue;
38814139
3882
- if (GrafreeD.RENDERME > 0)
4140
+ if (Grafreed.RENDERME > 0)
38834141 {
38844142 if (child instanceof Merge)
38854143 ((Merge)child).renderme();
....@@ -4074,7 +4332,7 @@
40744332 if (child == null)
40754333 continue;
40764334
4077
- if (GrafreeD.RENDERME > 0)
4335
+ if (Grafreed.RENDERME > 0)
40784336 {
40794337 if (child instanceof Merge)
40804338 ((Merge)child).renderme();
....@@ -4187,6 +4445,55 @@
41874445 {
41884446 blockloop = true;
41894447 get(i).RepairShadow();
4448
+ blockloop = false;
4449
+ }
4450
+ }
4451
+
4452
+ void RepairSOV()
4453
+ {
4454
+ if (blockloop)
4455
+ return;
4456
+
4457
+ String texname = this.GetPigmentTexture();
4458
+
4459
+ if (texname.startsWith("sov"))
4460
+ {
4461
+ String[] s = texname.split("/");
4462
+
4463
+ String[] sname = s[1].split("Color.pn");
4464
+
4465
+ texname = sname[0];
4466
+
4467
+ if (sname.length > 1)
4468
+ {
4469
+ texname += "Color.jpg";
4470
+ }
4471
+
4472
+ this.SetPigmentTexture("sov/" + texname);
4473
+ }
4474
+
4475
+ texname = this.GetBumpTexture();
4476
+
4477
+ if (texname.startsWith("sov"))
4478
+ {
4479
+ String[] s = texname.split("/");
4480
+
4481
+ String[] sname = s[1].split("Bump.pn");
4482
+
4483
+ texname = sname[0];
4484
+
4485
+ if (sname.length > 1)
4486
+ {
4487
+ texname += "Bump.jpg";
4488
+ }
4489
+
4490
+ this.SetBumpTexture("sov/" + texname);
4491
+ }
4492
+
4493
+ for (int i=0; i<Size(); i++)
4494
+ {
4495
+ blockloop = true;
4496
+ get(i).RepairSOV();
41904497 blockloop = false;
41914498 }
41924499 }
....@@ -4681,7 +4988,7 @@
46814988
46824989 cTreePath SelectLeaf(int indexcount, boolean deselect)
46834990 {
4684
- if (hide)
4991
+ if (hide || dontselect)
46854992 return null;
46864993
46874994 if (count <= 0)
....@@ -4705,9 +5012,17 @@
47055012 }
47065013 }
47075014
5015
+ ObjEditor GetWindow()
5016
+ {
5017
+ if (editWindow != null)
5018
+ return editWindow;
5019
+
5020
+ return manipWindow;
5021
+ }
5022
+
47085023 cTreePath Select(int indexcount, boolean deselect)
47095024 {
4710
- if (hide)
5025
+ if (hide || dontselect)
47115026 return null;
47125027
47135028 if (count <= 0)
....@@ -4741,10 +5056,11 @@
47415056 if (leaf != null)
47425057 {
47435058 cTreePath tp = new cTreePath(this, leaf);
4744
- if (editWindow != null)
5059
+ ObjEditor window = GetWindow();
5060
+ if (window != null)
47455061 {
47465062 //System.out.println("editWindow = " + editWindow + " vs " + this);
4747
- editWindow.Select(tp, deselect, true);
5063
+ window.Select(tp, deselect, true);
47485064 }
47495065
47505066 return tp;
....@@ -4761,6 +5077,7 @@
47615077
47625078 if (child == null)
47635079 continue;
5080
+
47645081 if (child.HasTransparency() && child.size() != 0)
47655082 {
47665083 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4770,9 +5087,10 @@
47705087 if (leaf != null)
47715088 {
47725089 cTreePath tp = new cTreePath(this, leaf);
4773
- if (editWindow != null)
5090
+ ObjEditor window = GetWindow();
5091
+ if (window != null)
47745092 {
4775
- editWindow.Select(tp, deselect, true);
5093
+ window.Select(tp, deselect, true);
47765094 }
47775095
47785096 return tp;
....@@ -5333,6 +5651,43 @@
53335651 }
53345652 }
53355653
5654
+ UUID GetUUID()
5655
+ {
5656
+ if (uuid == null)
5657
+ {
5658
+ // Serial
5659
+ uuid = UUID.randomUUID();
5660
+ }
5661
+
5662
+ return uuid;
5663
+ }
5664
+
5665
+ Object3D GetObject(UUID uid)
5666
+ {
5667
+ if (blockloop)
5668
+ return null;
5669
+
5670
+ if (GetUUID().equals(uid))
5671
+ return this;
5672
+
5673
+ int nb = Size();
5674
+ for (int i = 0; i < nb; i++)
5675
+ {
5676
+ Object3D child = (Object3D) get(i);
5677
+
5678
+ if (child == null)
5679
+ continue;
5680
+
5681
+ blockloop = true;
5682
+ Object3D obj = child.GetObject(uid);
5683
+ blockloop = false;
5684
+ if (obj != null)
5685
+ return obj;
5686
+ }
5687
+
5688
+ return null;
5689
+ }
5690
+
53365691 void SetBumpTexture(String tex)
53375692 {
53385693 if (GetTextures() == null)
....@@ -5377,12 +5732,23 @@
53775732 boolean NeedSupport()
53785733 {
53795734 return
5380
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5735
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
53815736 // PROBLEM with CROWD!!
5382
- && (Globals.DrawMode() == iCameraPane.SHADOW || Globals.CROWD);
5737
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
53835738 }
53845739
53855740 static boolean DEBUG_SELECTION = false;
5741
+
5742
+ boolean IsLive()
5743
+ {
5744
+ if (live)
5745
+ return true;
5746
+
5747
+ if (parent == null)
5748
+ return false;
5749
+
5750
+ return parent.IsLive();
5751
+ }
53865752
53875753 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
53885754 {
....@@ -5394,7 +5760,7 @@
53945760 }
53955761
53965762 if (display.DrawMode() == iCameraPane.SELECTION &&
5397
- hide)
5763
+ (hide || dontselect))
53985764 return;
53995765
54005766 if (name != null && name.contains("sclera"))
....@@ -5445,7 +5811,7 @@
54455811 support = support;
54465812
54475813 //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5448
- boolean usecalllists = false; // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5814
+ boolean usecalllists = !IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
54495815
54505816 if (!usecalllists && bRep != null && bRep.displaylist > 0)
54515817 {
....@@ -5465,10 +5831,12 @@
54655831 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
54665832
54675833 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5468
- (touched || (bRep != null && bRep.displaylist <= 0)))
5834
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5835
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
54695836 {
54705837 Globals.lighttouched = true;
54715838 } // all panes...
5839
+
54725840 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
54735841 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
54745842 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5596,6 +5964,7 @@
55965964 if (GetBRep() != null)
55975965 {
55985966 display.NextIndex();
5967
+
55995968 // vertex color conflict : gl.glCallList(list);
56005969 DrawNode(display, root, selected);
56015970 if (this instanceof BezierPatch)
....@@ -5636,7 +6005,28 @@
56366005 tex = GetTextures();
56376006 }
56386007
5639
- display.BindTextures(tex, texres);
6008
+ boolean failedPigment = false;
6009
+ boolean failedBump = false;
6010
+
6011
+ try
6012
+ {
6013
+ display.BindPigmentTexture(tex, texres);
6014
+ }
6015
+ catch (Exception e)
6016
+ {
6017
+ System.err.println("FAILED: " + this);
6018
+ failedPigment = true;
6019
+ }
6020
+
6021
+ try
6022
+ {
6023
+ display.BindBumpTexture(tex, texres);
6024
+ }
6025
+ catch (Exception e)
6026
+ {
6027
+ //System.err.println("FAILED: " + this);
6028
+ failedBump = true;
6029
+ }
56406030
56416031 if (!compiled)
56426032 {
....@@ -5658,7 +6048,11 @@
56586048 }
56596049 }
56606050
5661
- display.ReleaseTextures(tex);
6051
+ if (!failedBump)
6052
+ display.ReleaseBumpTexture(tex);
6053
+
6054
+ if (!failedPigment)
6055
+ display.ReleasePigmentTexture(tex);
56626056
56636057 display.PopMaterial(this, selected);
56646058 }
....@@ -5787,6 +6181,9 @@
57876181
57886182 void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57896183 {
6184
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6185
+ return;
6186
+
57906187 if (hide)
57916188 return;
57926189 // shadow optimisation
....@@ -5912,6 +6309,9 @@
59126309 if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
59136310 return; // no shadow for transparent objects
59146311
6312
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6313
+ return;
6314
+
59156315 if (hide)
59166316 return;
59176317
....@@ -6025,6 +6425,11 @@
60256425 // dec 2012
60266426 new Exception().printStackTrace();
60276427 return;
6428
+ }
6429
+
6430
+ if (dontselect)
6431
+ {
6432
+ //bRep.GenerateNormalsMINE();
60286433 }
60296434
60306435 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -6877,7 +7282,7 @@
68777282 spot.translate(32, 32);
68787283 spotw = spot.x + spot.width;
68797284 spoth = spot.y + spot.height;
6880
- info.g.setColor(Color.blue);
7285
+ info.g.setColor(Color.cyan);
68817286 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
68827287 // if (CameraPane.Xmin > spot.x)
68837288 // {
....@@ -6895,11 +7300,12 @@
68957300 // {
68967301 // CameraPane.Ymax = spoth;
68977302 // }
6898
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
6899
- info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7303
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7304
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
69007305 spot.translate(0, -32);
6901
- info.g.setColor(Color.green);
7306
+ info.g.setColor(Color.yellow);
69027307 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7308
+ info.g.setColor(Color.green);
69037309 // if (CameraPane.Xmin > spot.x)
69047310 // {
69057311 // CameraPane.Xmin = spot.x;
....@@ -6916,8 +7322,8 @@
69167322 // {
69177323 // CameraPane.Ymax = spoth;
69187324 // }
6919
- info.g.drawArc(boundary.x, boundary.y,
6920
- boundary.width, boundary.height, 0, 360);
7325
+ info.g.drawArc(boundary.x + info.DX, boundary.y + info.DY,
7326
+ (int)(boundary.width * info.W), (int)(boundary.height * info.W), 0, 360);
69217327 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
69227328 // if (CameraPane.Xmin > boundary.x)
69237329 // {
....@@ -6951,7 +7357,7 @@
69517357 startX = info.x;
69527358 startY = info.y;
69537359
6954
- hitSomething = 0;
7360
+ hitSomething = -1;
69557361 cVector origin = new cVector();
69567362 //LA.xformPos(origin, toParent, origin);
69577363 Rectangle spot = new Rectangle();
....@@ -6984,7 +7390,7 @@
69847390 }
69857391
69867392 //System.out.println("info.modifiers = " + info.modifiers);
6987
- modified = (info.modifiers & CameraPane.META) != 0;
7393
+ modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
69887394 //System.out.println("modified = " + modified);
69897395 //new Exception().printStackTrace();
69907396 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7012,7 +7418,7 @@
70127418 return true;
70137419 }
70147420
7015
- void doEditDrag0(ClickInfo info)
7421
+ void doEditDrag0(ClickInfo info, boolean opposite)
70167422 {
70177423 if (hitSomething == 0)
70187424 {
....@@ -7027,6 +7433,7 @@
70277433 //System.out.println("hitSomething = " + hitSomething);
70287434
70297435 double scale = 0.005f * info.camera.Distance();
7436
+
70307437 cVector xlate = new cVector();
70317438 //cVector xlate2 = new cVector();
70327439 switch (hitSomething)
....@@ -7039,7 +7446,7 @@
70397446
70407447 scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
70417448
7042
- if (modified)
7449
+ if (modified || opposite)
70437450 {
70447451 //assert(false);
70457452 /*
....@@ -7133,6 +7540,7 @@
71337540
71347541 if (modified)
71357542 {
7543
+ // Rotate 90 degrees
71367544 angle /= (Math.PI / 4);
71377545 angle = Math.floor(angle + 0.5);
71387546 angle *= (Math.PI / 4);
....@@ -7174,24 +7582,27 @@
71747582
71757583 case hitScale: // scale
71767584 double hScale = (double) (info.x - centerPt.x) / 32;
7585
+ double sign = 1;
7586
+ if (hScale < 0)
7587
+ {
7588
+ sign = -1;
7589
+ }
7590
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
71777591 if (hScale < 0.01)
71787592 {
7179
- hScale = 0.01;
7593
+ //hScale = 0.01;
71807594 }
7181
- hScale = Math.pow(hScale, scale * 50);
7182
- if (hScale < 0.01)
7183
- {
7184
- hScale = 0.01;
7185
- }
7595
+
71867596 double vScale = (double) (info.y - centerPt.y) / 32;
7187
- if (vScale < 0.01)
7597
+ sign = 1;
7598
+ if (vScale < 0)
71887599 {
7189
- vScale = 0.01;
7600
+ sign = -1;
71907601 }
7191
- vScale = Math.pow(vScale, scale * 50);
7602
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
71927603 if (vScale < 0.01)
71937604 {
7194
- vScale = 0.01;
7605
+ //vScale = 0.01;
71957606 }
71967607 LA.matCopy(startMat, toParent);
71977608 /**/
....@@ -7202,39 +7613,47 @@
72027613 }
72037614 /**/
72047615
7616
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7617
+
7618
+ if (totalScale < 0.01)
7619
+ {
7620
+ totalScale = 0.01;
7621
+ }
7622
+
72057623 switch (info.pane.RenderCamera().viewCode)
72067624 {
72077625 case 3: // '\001'
7208
- if (modified)
7626
+ if (modified || opposite)
72097627 {
72107628 //LA.matScale(toParent, 1, hScale, vScale);
7211
- LA.matScale(toParent, vScale, 1, 1);
7629
+ LA.matScale(toParent, totalScale, 1, 1);
72127630 } // vScale, 1);
72137631 else
72147632 {
7215
- LA.matScale(toParent, vScale, vScale, vScale);
7633
+ // EXCEPTION!
7634
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
72167635 } // vScale, 1);
72177636 break;
72187637
72197638 case 2: // '\002'
7220
- if (modified)
7639
+ if (modified || opposite)
72217640 {
72227641 //LA.matScale(toParent, hScale, 1, vScale);
7223
- LA.matScale(toParent, 1, vScale, 1);
7642
+ LA.matScale(toParent, 1, totalScale, 1);
72247643 } else
72257644 {
7226
- LA.matScale(toParent, vScale, 1, vScale);
7645
+ LA.matScale(toParent, totalScale, 1, totalScale);
72277646 }
72287647 break;
72297648
72307649 case 1: // '\003'
7231
- if (modified)
7650
+ if (modified || opposite)
72327651 {
72337652 //LA.matScale(toParent, hScale, vScale, 1);
7234
- LA.matScale(toParent, 1, 1, vScale);
7653
+ LA.matScale(toParent, 1, 1, totalScale);
72357654 } else
72367655 {
7237
- LA.matScale(toParent, vScale, vScale, 1);
7656
+ LA.matScale(toParent, totalScale, totalScale, 1);
72387657 }
72397658 break;
72407659 }
....@@ -7367,14 +7786,22 @@
73677786 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
73687787 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
73697788 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7789
+
7790
+ String objname;
7791
+
73707792 if (false) //parent != null)
73717793 {
7372
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7794
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
73737795 } else
73747796 {
7375
- return GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ") ")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ +System.identityHashCode(this);
7797
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
73767798 } // + super.toString();
73777799 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
7800
+
7801
+ if (!Globals.ADVANCED)
7802
+ return objname;
7803
+
7804
+ return objname + " " + System.identityHashCode(this);
73787805 }
73797806
73807807 public int hashCode()
....@@ -7440,6 +7867,10 @@
74407867 editWindow = null;
74417868 } // ?
74427869 }
7870
+ else
7871
+ {
7872
+ //editWindow.closeUI();
7873
+ }
74437874 }
74447875
74457876 boolean root; // patch for edit windows
....@@ -7451,7 +7882,7 @@
74517882 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
74527883
74537884 Object3D /*Composite*/ parent;
7454
- Object3D /*Composite*/ fileparent;
7885
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
74557886
74567887 double[][] toParent; // dynamic matrix
74577888 double[][] fromParent;
....@@ -7566,7 +7997,7 @@
75667997 {
75677998 assert(bRep != null);
75687999 if (!(support instanceof GenericJoint)) // support.bRep != null)
7569
- GrafreeD.Assert(support.bRep == bRep.support);
8000
+ Grafreed.Assert(support.bRep == bRep.support);
75708001 }
75718002 else
75728003 {
....@@ -7597,6 +8028,10 @@
75978028 }
75988029
75998030 transient ObjEditor editWindow;
8031
+ transient ObjEditor manipWindow;
8032
+
8033
+ transient boolean pinned;
8034
+
76008035 transient ObjectUI objectUI;
76018036 public static int povDepth = 0;
76028037 private static cVector tbMin = new cVector();
....@@ -7615,9 +8050,9 @@
76158050 private static cVector edge2 = new cVector();
76168051 //private static cVector norm = new cVector();
76178052 /*transient private*/ int hitSomething;
7618
- private static final int hitCenter = 1;
7619
- private static final int hitScale = 2;
7620
- private static final int hitRotate = 3;
8053
+ static final int hitCenter = 1;
8054
+ static final int hitScale = 2;
8055
+ static final int hitRotate = 3;
76218056 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
76228057 /*transient*/ private Point centerPt;
76238058 /*transient*/ private int startX;