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,12 +2429,17 @@
22942429 }
22952430 */
22962431 }
2432
+ else
2433
+ {
2434
+ //((ObjEditor)editWindow).SetupUI2(null);
2435
+ }
22972436 }
22982437
22992438 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
23002439 {
23012440 if (newWindow)
23022441 {
2442
+ new Exception().printStackTrace();
23032443 System.exit(0);
23042444 if (parent != null)
23052445 {
....@@ -2334,6 +2474,14 @@
23342474 {
23352475 editWindow.refreshContents();
23362476 }
2477
+ else
2478
+ {
2479
+ if (manipWindow != null)
2480
+ {
2481
+ manipWindow.refreshContents();
2482
+ }
2483
+ }
2484
+
23372485 //if (parent != null)
23382486 //parent.refreshEditWindow();
23392487 }
....@@ -2476,13 +2624,13 @@
24762624 return retval;
24772625 }
24782626
2479
- void doEditDrag(ClickInfo info)
2627
+ void doEditDrag(ClickInfo info, boolean opposite)
24802628 {
24812629 switch (doSomething)
24822630 {
24832631 case 1: // '\001'
24842632 //super.
2485
- doEditDrag0(info);
2633
+ doEditDrag0(info, opposite);
24862634 break;
24872635
24882636 case 2: // '\002'
....@@ -2495,11 +2643,11 @@
24952643 {
24962644 //sel.hitSomething = childToDrag.hitSomething;
24972645 //childToDrag.doEditDrag(info);
2498
- sel.doEditDrag(info);
2646
+ sel.doEditDrag(info, opposite);
24992647 } else
25002648 {
25012649 //super.
2502
- doEditDrag0(info);
2650
+ doEditDrag0(info, opposite);
25032651 }
25042652 }
25052653 break;
....@@ -2609,6 +2757,18 @@
26092757 void GenNormalsS(boolean crease)
26102758 {
26112759 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();
26122772 // for (int i=0; i<selection.size(); i++)
26132773 // {
26142774 // Object3D selectee = (Object3D) selection.elementAt(i);
....@@ -2749,6 +2909,24 @@
27492909 if (child == null)
27502910 continue;
27512911 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();
27522930 // Children().release(i);
27532931 }
27542932 blockloop = false;
....@@ -2921,6 +3099,15 @@
29213099 }
29223100 }
29233101
3102
+ void GenNormalsMesh0()
3103
+ {
3104
+ if (bRep != null)
3105
+ {
3106
+ bRep.GenerateNormalsMesh();
3107
+ Touch();
3108
+ }
3109
+ }
3110
+
29243111 void GenNormalsMINE0()
29253112 {
29263113 if (bRep != null)
....@@ -2982,6 +3169,33 @@
29823169 blockloop = false;
29833170 }
29843171
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
+
29853199 void TransformGeometry()
29863200 {
29873201 Object3D obj = this;
....@@ -3203,9 +3417,11 @@
32033417
32043418 BoundaryRep sup = bRep.support;
32053419 bRep.support = null;
3206
- BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
3420
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
32073421 // bRep.SplitInTwo(onlyone); // thread...
3208
- temprep.SplitInTwo(reduction34, onlyone);
3422
+
3423
+ while(temprep.SplitInTwo(reduction34, onlyone));
3424
+
32093425 bRep = temprep;
32103426 bRep.support = sup;
32113427 Touch();
....@@ -3342,7 +3558,8 @@
33423558 if (blockloop)
33433559 return;
33443560
3345
- if (marked || (bRep != null && material != null)) // borderline...
3561
+ if (//marked || // does not make sense
3562
+ (bRep != null || material != null)) // borderline...
33463563 live = h;
33473564
33483565 for (int i = 0; i < Size(); i++)
....@@ -3363,7 +3580,8 @@
33633580 return;
33643581
33653582 //if (bRep != null)
3366
- if (marked || (bRep != null && material != null)) // borderline...
3583
+ if (//marked || // does not make sense
3584
+ (bRep != null || material != null)) // borderline...
33673585 link2master = h;
33683586
33693587 for (int i = 0; i < Size(); i++)
....@@ -3383,7 +3601,8 @@
33833601 if (blockloop)
33843602 return;
33853603
3386
- if (marked || (bRep != null && material != null)) // borderline...
3604
+ if (//marked || // does not make sense
3605
+ (bRep != null || material != null)) // borderline...
33873606 hide = h;
33883607
33893608 for (int i = 0; i < Size(); i++)
....@@ -3403,7 +3622,7 @@
34033622 if (blockloop)
34043623 return;
34053624
3406
- if (bRep != null && material != null) // borderline...
3625
+ if (bRep != null || material != null) // borderline...
34073626 marked = h;
34083627
34093628 for (int i = 0; i < Size(); i++)
....@@ -3413,6 +3632,46 @@
34133632 continue;
34143633 blockloop = true;
34153634 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);
34163675 blockloop = false;
34173676 // release(i);
34183677 }
....@@ -3727,7 +3986,7 @@
37273986 if (child == null)
37283987 continue;
37293988
3730
- if (GrafreeD.RENDERME > 0)
3989
+ if (Grafreed.RENDERME > 0)
37313990 {
37323991 if (child instanceof Merge)
37333992 ((Merge)child).renderme();
....@@ -3878,7 +4137,7 @@
38784137 if (child == null)
38794138 continue;
38804139
3881
- if (GrafreeD.RENDERME > 0)
4140
+ if (Grafreed.RENDERME > 0)
38824141 {
38834142 if (child instanceof Merge)
38844143 ((Merge)child).renderme();
....@@ -4073,7 +4332,7 @@
40734332 if (child == null)
40744333 continue;
40754334
4076
- if (GrafreeD.RENDERME > 0)
4335
+ if (Grafreed.RENDERME > 0)
40774336 {
40784337 if (child instanceof Merge)
40794338 ((Merge)child).renderme();
....@@ -4186,6 +4445,55 @@
41864445 {
41874446 blockloop = true;
41884447 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();
41894497 blockloop = false;
41904498 }
41914499 }
....@@ -4680,7 +4988,7 @@
46804988
46814989 cTreePath SelectLeaf(int indexcount, boolean deselect)
46824990 {
4683
- if (hide)
4991
+ if (hide || dontselect)
46844992 return null;
46854993
46864994 if (count <= 0)
....@@ -4704,9 +5012,17 @@
47045012 }
47055013 }
47065014
5015
+ ObjEditor GetWindow()
5016
+ {
5017
+ if (editWindow != null)
5018
+ return editWindow;
5019
+
5020
+ return manipWindow;
5021
+ }
5022
+
47075023 cTreePath Select(int indexcount, boolean deselect)
47085024 {
4709
- if (hide)
5025
+ if (hide || dontselect)
47105026 return null;
47115027
47125028 if (count <= 0)
....@@ -4740,10 +5056,11 @@
47405056 if (leaf != null)
47415057 {
47425058 cTreePath tp = new cTreePath(this, leaf);
4743
- if (editWindow != null)
5059
+ ObjEditor window = GetWindow();
5060
+ if (window != null)
47445061 {
47455062 //System.out.println("editWindow = " + editWindow + " vs " + this);
4746
- editWindow.Select(tp, deselect, true);
5063
+ window.Select(tp, deselect, true);
47475064 }
47485065
47495066 return tp;
....@@ -4760,6 +5077,7 @@
47605077
47615078 if (child == null)
47625079 continue;
5080
+
47635081 if (child.HasTransparency() && child.size() != 0)
47645082 {
47655083 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4769,9 +5087,10 @@
47695087 if (leaf != null)
47705088 {
47715089 cTreePath tp = new cTreePath(this, leaf);
4772
- if (editWindow != null)
5090
+ ObjEditor window = GetWindow();
5091
+ if (window != null)
47735092 {
4774
- editWindow.Select(tp, deselect, true);
5093
+ window.Select(tp, deselect, true);
47755094 }
47765095
47775096 return tp;
....@@ -5158,10 +5477,34 @@
51585477
51595478 // System.out.println("Fullname = " + fullname);
51605479
5161
- if (fullname.name.indexOf(":") == -1)
5162
- return fullname.name;
5480
+ // Does not work on Windows due to C:
5481
+// if (fullname.name.indexOf(":") == -1)
5482
+// return fullname.name;
5483
+//
5484
+// return fullname.name.substring(0,fullname.name.indexOf(":"));
51635485
5164
- return fullname.name.substring(0,fullname.name.indexOf(":"));
5486
+ String[] split = fullname.name.split(":");
5487
+
5488
+ if (split.length == 0)
5489
+ {
5490
+ return "";
5491
+ }
5492
+
5493
+ if (split.length <= 2)
5494
+ {
5495
+ if (fullname.name.endsWith(":"))
5496
+ {
5497
+ // Windows
5498
+ return fullname.name.substring(0, fullname.name.length()-1);
5499
+ }
5500
+
5501
+ return split[0];
5502
+ }
5503
+
5504
+ // Windows
5505
+ assert(split.length == 4);
5506
+
5507
+ return split[0] + ":" + split[1];
51655508 }
51665509
51675510 static String GetBump(cTexture fullname)
....@@ -5170,10 +5513,38 @@
51705513 return "";
51715514
51725515 // 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());
5516
+ // Does not work on Windows due to C:
5517
+// if (fullname.name.indexOf(":") == -1)
5518
+// return "";
5519
+//
5520
+// return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5521
+ String[] split = fullname.name.split(":");
5522
+
5523
+ if (split.length == 0)
5524
+ {
5525
+ return "";
5526
+ }
5527
+
5528
+ if (split.length == 1)
5529
+ {
5530
+ return "";
5531
+ }
5532
+
5533
+ if (split.length == 2)
5534
+ {
5535
+ if (fullname.name.endsWith(":"))
5536
+ {
5537
+ // Windows
5538
+ return "";
5539
+ }
5540
+
5541
+ return split[1];
5542
+ }
5543
+
5544
+ // Windows
5545
+ assert(split.length == 4);
5546
+
5547
+ return split[2] + ":" + split[3];
51775548 }
51785549
51795550 String GetPigmentTexture()
....@@ -5247,7 +5618,7 @@
52475618 System.out.print("; textures = " + textures);
52485619 System.out.println("; usedtextures = " + usedtextures);
52495620
5250
- if (GetTextures() == null)
5621
+ if (GetTextures() == null) // What is that??
52515622 GetTextures().name = ":";
52525623
52535624 String texname = tex;
....@@ -5278,6 +5649,43 @@
52785649 child.ResetPigmentTexture();
52795650 blockloop = false;
52805651 }
5652
+ }
5653
+
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;
52815689 }
52825690
52835691 void SetBumpTexture(String tex)
....@@ -5324,12 +5732,23 @@
53245732 boolean NeedSupport()
53255733 {
53265734 return
5327
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5735
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
53285736 // PROBLEM with CROWD!!
5329
- && (Globals.DrawMode() == iCameraPane.SHADOW || Globals.CROWD);
5737
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
53305738 }
53315739
53325740 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
+ }
53335752
53345753 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
53355754 {
....@@ -5341,7 +5760,7 @@
53415760 }
53425761
53435762 if (display.DrawMode() == iCameraPane.SELECTION &&
5344
- hide)
5763
+ (hide || dontselect))
53455764 return;
53465765
53475766 if (name != null && name.contains("sclera"))
....@@ -5392,7 +5811,7 @@
53925811 support = support;
53935812
53945813 //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);
5814
+ boolean usecalllists = !IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
53965815
53975816 if (!usecalllists && bRep != null && bRep.displaylist > 0)
53985817 {
....@@ -5412,10 +5831,12 @@
54125831 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
54135832
54145833 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5415
- (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)))
54165836 {
54175837 Globals.lighttouched = true;
54185838 } // all panes...
5839
+
54195840 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
54205841 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
54215842 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5543,6 +5964,7 @@
55435964 if (GetBRep() != null)
55445965 {
55455966 display.NextIndex();
5967
+
55465968 // vertex color conflict : gl.glCallList(list);
55475969 DrawNode(display, root, selected);
55485970 if (this instanceof BezierPatch)
....@@ -5583,7 +6005,28 @@
55836005 tex = GetTextures();
55846006 }
55856007
5586
- 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
+ }
55876030
55886031 if (!compiled)
55896032 {
....@@ -5605,7 +6048,11 @@
56056048 }
56066049 }
56076050
5608
- display.ReleaseTextures(tex);
6051
+ if (!failedBump)
6052
+ display.ReleaseBumpTexture(tex);
6053
+
6054
+ if (!failedPigment)
6055
+ display.ReleasePigmentTexture(tex);
56096056
56106057 display.PopMaterial(this, selected);
56116058 }
....@@ -5734,6 +6181,9 @@
57346181
57356182 void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57366183 {
6184
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6185
+ return;
6186
+
57376187 if (hide)
57386188 return;
57396189 // shadow optimisation
....@@ -5859,6 +6309,9 @@
58596309 if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
58606310 return; // no shadow for transparent objects
58616311
6312
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6313
+ return;
6314
+
58626315 if (hide)
58636316 return;
58646317
....@@ -5972,6 +6425,11 @@
59726425 // dec 2012
59736426 new Exception().printStackTrace();
59746427 return;
6428
+ }
6429
+
6430
+ if (dontselect)
6431
+ {
6432
+ //bRep.GenerateNormalsMINE();
59756433 }
59766434
59776435 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -6824,7 +7282,7 @@
68247282 spot.translate(32, 32);
68257283 spotw = spot.x + spot.width;
68267284 spoth = spot.y + spot.height;
6827
- info.g.setColor(Color.blue);
7285
+ info.g.setColor(Color.cyan);
68287286 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
68297287 // if (CameraPane.Xmin > spot.x)
68307288 // {
....@@ -6842,11 +7300,12 @@
68427300 // {
68437301 // CameraPane.Ymax = spoth;
68447302 // }
6845
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
6846
- 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
68477305 spot.translate(0, -32);
6848
- info.g.setColor(Color.green);
7306
+ info.g.setColor(Color.yellow);
68497307 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7308
+ info.g.setColor(Color.green);
68507309 // if (CameraPane.Xmin > spot.x)
68517310 // {
68527311 // CameraPane.Xmin = spot.x;
....@@ -6863,8 +7322,8 @@
68637322 // {
68647323 // CameraPane.Ymax = spoth;
68657324 // }
6866
- info.g.drawArc(boundary.x, boundary.y,
6867
- 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);
68687327 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
68697328 // if (CameraPane.Xmin > boundary.x)
68707329 // {
....@@ -6898,7 +7357,7 @@
68987357 startX = info.x;
68997358 startY = info.y;
69007359
6901
- hitSomething = 0;
7360
+ hitSomething = -1;
69027361 cVector origin = new cVector();
69037362 //LA.xformPos(origin, toParent, origin);
69047363 Rectangle spot = new Rectangle();
....@@ -6931,7 +7390,7 @@
69317390 }
69327391
69337392 //System.out.println("info.modifiers = " + info.modifiers);
6934
- modified = (info.modifiers & CameraPane.META) != 0;
7393
+ modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
69357394 //System.out.println("modified = " + modified);
69367395 //new Exception().printStackTrace();
69377396 //viewCode = info.pane.renderCamera.viewCode;
....@@ -6959,7 +7418,7 @@
69597418 return true;
69607419 }
69617420
6962
- void doEditDrag0(ClickInfo info)
7421
+ void doEditDrag0(ClickInfo info, boolean opposite)
69637422 {
69647423 if (hitSomething == 0)
69657424 {
....@@ -6974,6 +7433,7 @@
69747433 //System.out.println("hitSomething = " + hitSomething);
69757434
69767435 double scale = 0.005f * info.camera.Distance();
7436
+
69777437 cVector xlate = new cVector();
69787438 //cVector xlate2 = new cVector();
69797439 switch (hitSomething)
....@@ -6986,7 +7446,7 @@
69867446
69877447 scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
69887448
6989
- if (modified)
7449
+ if (modified || opposite)
69907450 {
69917451 //assert(false);
69927452 /*
....@@ -7080,6 +7540,7 @@
70807540
70817541 if (modified)
70827542 {
7543
+ // Rotate 90 degrees
70837544 angle /= (Math.PI / 4);
70847545 angle = Math.floor(angle + 0.5);
70857546 angle *= (Math.PI / 4);
....@@ -7121,24 +7582,27 @@
71217582
71227583 case hitScale: // scale
71237584 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);
71247591 if (hScale < 0.01)
71257592 {
7126
- hScale = 0.01;
7593
+ //hScale = 0.01;
71277594 }
7128
- hScale = Math.pow(hScale, scale * 50);
7129
- if (hScale < 0.01)
7130
- {
7131
- hScale = 0.01;
7132
- }
7595
+
71337596 double vScale = (double) (info.y - centerPt.y) / 32;
7134
- if (vScale < 0.01)
7597
+ sign = 1;
7598
+ if (vScale < 0)
71357599 {
7136
- vScale = 0.01;
7600
+ sign = -1;
71377601 }
7138
- vScale = Math.pow(vScale, scale * 50);
7602
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
71397603 if (vScale < 0.01)
71407604 {
7141
- vScale = 0.01;
7605
+ //vScale = 0.01;
71427606 }
71437607 LA.matCopy(startMat, toParent);
71447608 /**/
....@@ -7149,39 +7613,47 @@
71497613 }
71507614 /**/
71517615
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
+
71527623 switch (info.pane.RenderCamera().viewCode)
71537624 {
71547625 case 3: // '\001'
7155
- if (modified)
7626
+ if (modified || opposite)
71567627 {
71577628 //LA.matScale(toParent, 1, hScale, vScale);
7158
- LA.matScale(toParent, vScale, 1, 1);
7629
+ LA.matScale(toParent, totalScale, 1, 1);
71597630 } // vScale, 1);
71607631 else
71617632 {
7162
- LA.matScale(toParent, vScale, vScale, vScale);
7633
+ // EXCEPTION!
7634
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
71637635 } // vScale, 1);
71647636 break;
71657637
71667638 case 2: // '\002'
7167
- if (modified)
7639
+ if (modified || opposite)
71687640 {
71697641 //LA.matScale(toParent, hScale, 1, vScale);
7170
- LA.matScale(toParent, 1, vScale, 1);
7642
+ LA.matScale(toParent, 1, totalScale, 1);
71717643 } else
71727644 {
7173
- LA.matScale(toParent, vScale, 1, vScale);
7645
+ LA.matScale(toParent, totalScale, 1, totalScale);
71747646 }
71757647 break;
71767648
71777649 case 1: // '\003'
7178
- if (modified)
7650
+ if (modified || opposite)
71797651 {
71807652 //LA.matScale(toParent, hScale, vScale, 1);
7181
- LA.matScale(toParent, 1, 1, vScale);
7653
+ LA.matScale(toParent, 1, 1, totalScale);
71827654 } else
71837655 {
7184
- LA.matScale(toParent, vScale, vScale, 1);
7656
+ LA.matScale(toParent, totalScale, totalScale, 1);
71857657 }
71867658 break;
71877659 }
....@@ -7314,14 +7786,22 @@
73147786 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
73157787 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
73167788 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7789
+
7790
+ String objname;
7791
+
73177792 if (false) //parent != null)
73187793 {
7319
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7794
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
73207795 } else
73217796 {
7322
- 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) ":"") */ "";
73237798 } // + super.toString();
73247799 //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);
73257805 }
73267806
73277807 public int hashCode()
....@@ -7377,6 +7857,7 @@
73777857 objectUI.closeUI();
73787858 if (editWindow != null)
73797859 {
7860
+ editWindow.ctrlPanel.FlushUI();
73807861 editWindow.refreshContents();
73817862 } // ? new
73827863 objectUI = null;
....@@ -7385,6 +7866,10 @@
73857866 {
73867867 editWindow = null;
73877868 } // ?
7869
+ }
7870
+ else
7871
+ {
7872
+ //editWindow.closeUI();
73887873 }
73897874 }
73907875
....@@ -7397,7 +7882,7 @@
73977882 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
73987883
73997884 Object3D /*Composite*/ parent;
7400
- Object3D /*Composite*/ fileparent;
7885
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
74017886
74027887 double[][] toParent; // dynamic matrix
74037888 double[][] fromParent;
....@@ -7512,7 +7997,7 @@
75127997 {
75137998 assert(bRep != null);
75147999 if (!(support instanceof GenericJoint)) // support.bRep != null)
7515
- GrafreeD.Assert(support.bRep == bRep.support);
8000
+ Grafreed.Assert(support.bRep == bRep.support);
75168001 }
75178002 else
75188003 {
....@@ -7543,6 +8028,10 @@
75438028 }
75448029
75458030 transient ObjEditor editWindow;
8031
+ transient ObjEditor manipWindow;
8032
+
8033
+ transient boolean pinned;
8034
+
75468035 transient ObjectUI objectUI;
75478036 public static int povDepth = 0;
75488037 private static cVector tbMin = new cVector();
....@@ -7561,9 +8050,9 @@
75618050 private static cVector edge2 = new cVector();
75628051 //private static cVector norm = new cVector();
75638052 /*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;
8053
+ static final int hitCenter = 1;
8054
+ static final int hitScale = 2;
8055
+ static final int hitRotate = 3;
75678056 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
75688057 /*transient*/ private Point centerPt;
75698058 /*transient*/ private int startX;