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;
....@@ -2906,7 +3084,8 @@
29063084 {
29073085 if (bRep != null)
29083086 {
2909
- bRep.GenUV();
3087
+ bRep.GenUV(); //1);
3088
+ //bRep.UnfoldUV();
29103089 Touch();
29113090 }
29123091 }
....@@ -2916,6 +3095,15 @@
29163095 if (bRep != null)
29173096 {
29183097 bRep.GenerateNormals(crease);
3098
+ Touch();
3099
+ }
3100
+ }
3101
+
3102
+ void GenNormalsMesh0()
3103
+ {
3104
+ if (bRep != null)
3105
+ {
3106
+ bRep.GenerateNormalsMesh();
29193107 Touch();
29203108 }
29213109 }
....@@ -2981,6 +3169,33 @@
29813169 blockloop = false;
29823170 }
29833171
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
+
29843199 void TransformGeometry()
29853200 {
29863201 Object3D obj = this;
....@@ -3202,9 +3417,11 @@
32023417
32033418 BoundaryRep sup = bRep.support;
32043419 bRep.support = null;
3205
- BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
3420
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
32063421 // bRep.SplitInTwo(onlyone); // thread...
3207
- temprep.SplitInTwo(reduction34, onlyone);
3422
+
3423
+ while(temprep.SplitInTwo(reduction34, onlyone));
3424
+
32083425 bRep = temprep;
32093426 bRep.support = sup;
32103427 Touch();
....@@ -3341,7 +3558,8 @@
33413558 if (blockloop)
33423559 return;
33433560
3344
- if (marked || (bRep != null && material != null)) // borderline...
3561
+ if (//marked || // does not make sense
3562
+ (bRep != null || material != null)) // borderline...
33453563 live = h;
33463564
33473565 for (int i = 0; i < Size(); i++)
....@@ -3362,7 +3580,8 @@
33623580 return;
33633581
33643582 //if (bRep != null)
3365
- if (marked || (bRep != null && material != null)) // borderline...
3583
+ if (//marked || // does not make sense
3584
+ (bRep != null || material != null)) // borderline...
33663585 link2master = h;
33673586
33683587 for (int i = 0; i < Size(); i++)
....@@ -3382,7 +3601,8 @@
33823601 if (blockloop)
33833602 return;
33843603
3385
- if (marked || (bRep != null && material != null)) // borderline...
3604
+ if (//marked || // does not make sense
3605
+ (bRep != null || material != null)) // borderline...
33863606 hide = h;
33873607
33883608 for (int i = 0; i < Size(); i++)
....@@ -3402,7 +3622,7 @@
34023622 if (blockloop)
34033623 return;
34043624
3405
- if (bRep != null && material != null) // borderline...
3625
+ if (bRep != null || material != null) // borderline...
34063626 marked = h;
34073627
34083628 for (int i = 0; i < Size(); i++)
....@@ -3412,6 +3632,46 @@
34123632 continue;
34133633 blockloop = true;
34143634 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);
34153675 blockloop = false;
34163676 // release(i);
34173677 }
....@@ -3726,7 +3986,7 @@
37263986 if (child == null)
37273987 continue;
37283988
3729
- if (GrafreeD.RENDERME > 0)
3989
+ if (Grafreed.RENDERME > 0)
37303990 {
37313991 if (child instanceof Merge)
37323992 ((Merge)child).renderme();
....@@ -3877,7 +4137,7 @@
38774137 if (child == null)
38784138 continue;
38794139
3880
- if (GrafreeD.RENDERME > 0)
4140
+ if (Grafreed.RENDERME > 0)
38814141 {
38824142 if (child instanceof Merge)
38834143 ((Merge)child).renderme();
....@@ -4072,7 +4332,7 @@
40724332 if (child == null)
40734333 continue;
40744334
4075
- if (GrafreeD.RENDERME > 0)
4335
+ if (Grafreed.RENDERME > 0)
40764336 {
40774337 if (child instanceof Merge)
40784338 ((Merge)child).renderme();
....@@ -4185,6 +4445,55 @@
41854445 {
41864446 blockloop = true;
41874447 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();
41884497 blockloop = false;
41894498 }
41904499 }
....@@ -4679,7 +4988,7 @@
46794988
46804989 cTreePath SelectLeaf(int indexcount, boolean deselect)
46814990 {
4682
- if (hide)
4991
+ if (hide || dontselect)
46834992 return null;
46844993
46854994 if (count <= 0)
....@@ -4703,9 +5012,17 @@
47035012 }
47045013 }
47055014
5015
+ ObjEditor GetWindow()
5016
+ {
5017
+ if (editWindow != null)
5018
+ return editWindow;
5019
+
5020
+ return manipWindow;
5021
+ }
5022
+
47065023 cTreePath Select(int indexcount, boolean deselect)
47075024 {
4708
- if (hide)
5025
+ if (hide || dontselect)
47095026 return null;
47105027
47115028 if (count <= 0)
....@@ -4739,10 +5056,11 @@
47395056 if (leaf != null)
47405057 {
47415058 cTreePath tp = new cTreePath(this, leaf);
4742
- if (editWindow != null)
5059
+ ObjEditor window = GetWindow();
5060
+ if (window != null)
47435061 {
47445062 //System.out.println("editWindow = " + editWindow + " vs " + this);
4745
- editWindow.Select(tp, deselect, true);
5063
+ window.Select(tp, deselect, true);
47465064 }
47475065
47485066 return tp;
....@@ -4759,6 +5077,7 @@
47595077
47605078 if (child == null)
47615079 continue;
5080
+
47625081 if (child.HasTransparency() && child.size() != 0)
47635082 {
47645083 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4768,9 +5087,10 @@
47685087 if (leaf != null)
47695088 {
47705089 cTreePath tp = new cTreePath(this, leaf);
4771
- if (editWindow != null)
5090
+ ObjEditor window = GetWindow();
5091
+ if (window != null)
47725092 {
4773
- editWindow.Select(tp, deselect, true);
5093
+ window.Select(tp, deselect, true);
47745094 }
47755095
47765096 return tp;
....@@ -5157,10 +5477,34 @@
51575477
51585478 // System.out.println("Fullname = " + fullname);
51595479
5160
- if (fullname.name.indexOf(":") == -1)
5161
- 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(":"));
51625485
5163
- 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];
51645508 }
51655509
51665510 static String GetBump(cTexture fullname)
....@@ -5169,10 +5513,38 @@
51695513 return "";
51705514
51715515 // 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());
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];
51765548 }
51775549
51785550 String GetPigmentTexture()
....@@ -5246,7 +5618,7 @@
52465618 System.out.print("; textures = " + textures);
52475619 System.out.println("; usedtextures = " + usedtextures);
52485620
5249
- if (GetTextures() == null)
5621
+ if (GetTextures() == null) // What is that??
52505622 GetTextures().name = ":";
52515623
52525624 String texname = tex;
....@@ -5277,6 +5649,43 @@
52775649 child.ResetPigmentTexture();
52785650 blockloop = false;
52795651 }
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;
52805689 }
52815690
52825691 void SetBumpTexture(String tex)
....@@ -5323,12 +5732,23 @@
53235732 boolean NeedSupport()
53245733 {
53255734 return
5326
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5735
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
53275736 // PROBLEM with CROWD!!
5328
- && (Globals.DrawMode() == iCameraPane.SHADOW || Globals.CROWD);
5737
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
53295738 }
53305739
53315740 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
+ }
53325752
53335753 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
53345754 {
....@@ -5340,7 +5760,7 @@
53405760 }
53415761
53425762 if (display.DrawMode() == iCameraPane.SELECTION &&
5343
- hide)
5763
+ (hide || dontselect))
53445764 return;
53455765
53465766 if (name != null && name.contains("sclera"))
....@@ -5391,7 +5811,7 @@
53915811 support = support;
53925812
53935813 //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);
5814
+ boolean usecalllists = !IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
53955815
53965816 if (!usecalllists && bRep != null && bRep.displaylist > 0)
53975817 {
....@@ -5411,10 +5831,12 @@
54115831 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
54125832
54135833 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5414
- (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)))
54155836 {
54165837 Globals.lighttouched = true;
54175838 } // all panes...
5839
+
54185840 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
54195841 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
54205842 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5542,6 +5964,7 @@
55425964 if (GetBRep() != null)
55435965 {
55445966 display.NextIndex();
5967
+
55455968 // vertex color conflict : gl.glCallList(list);
55465969 DrawNode(display, root, selected);
55475970 if (this instanceof BezierPatch)
....@@ -5582,7 +6005,28 @@
55826005 tex = GetTextures();
55836006 }
55846007
5585
- 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
+ }
55866030
55876031 if (!compiled)
55886032 {
....@@ -5604,7 +6048,11 @@
56046048 }
56056049 }
56066050
5607
- display.ReleaseTextures(tex);
6051
+ if (!failedBump)
6052
+ display.ReleaseBumpTexture(tex);
6053
+
6054
+ if (!failedPigment)
6055
+ display.ReleasePigmentTexture(tex);
56086056
56096057 display.PopMaterial(this, selected);
56106058 }
....@@ -5733,6 +6181,9 @@
57336181
57346182 void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57356183 {
6184
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6185
+ return;
6186
+
57366187 if (hide)
57376188 return;
57386189 // shadow optimisation
....@@ -5858,6 +6309,9 @@
58586309 if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
58596310 return; // no shadow for transparent objects
58606311
6312
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6313
+ return;
6314
+
58616315 if (hide)
58626316 return;
58636317
....@@ -5898,6 +6352,7 @@
58986352 return;
58996353 }
59006354
6355
+ //bRep.GenUV(1/material.diffuseness);
59016356 // bRep.lock = true;
59026357
59036358 //javax.media.opengl.GL gl = display.GetGL();
....@@ -5970,6 +6425,11 @@
59706425 // dec 2012
59716426 new Exception().printStackTrace();
59726427 return;
6428
+ }
6429
+
6430
+ if (dontselect)
6431
+ {
6432
+ //bRep.GenerateNormalsMINE();
59736433 }
59746434
59756435 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -6822,7 +7282,7 @@
68227282 spot.translate(32, 32);
68237283 spotw = spot.x + spot.width;
68247284 spoth = spot.y + spot.height;
6825
- info.g.setColor(Color.blue);
7285
+ info.g.setColor(Color.cyan);
68267286 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
68277287 // if (CameraPane.Xmin > spot.x)
68287288 // {
....@@ -6840,11 +7300,12 @@
68407300 // {
68417301 // CameraPane.Ymax = spoth;
68427302 // }
6843
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
6844
- 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
68457305 spot.translate(0, -32);
6846
- info.g.setColor(Color.green);
7306
+ info.g.setColor(Color.yellow);
68477307 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7308
+ info.g.setColor(Color.green);
68487309 // if (CameraPane.Xmin > spot.x)
68497310 // {
68507311 // CameraPane.Xmin = spot.x;
....@@ -6861,8 +7322,8 @@
68617322 // {
68627323 // CameraPane.Ymax = spoth;
68637324 // }
6864
- info.g.drawArc(boundary.x, boundary.y,
6865
- 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);
68667327 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
68677328 // if (CameraPane.Xmin > boundary.x)
68687329 // {
....@@ -6896,7 +7357,7 @@
68967357 startX = info.x;
68977358 startY = info.y;
68987359
6899
- hitSomething = 0;
7360
+ hitSomething = -1;
69007361 cVector origin = new cVector();
69017362 //LA.xformPos(origin, toParent, origin);
69027363 Rectangle spot = new Rectangle();
....@@ -6929,7 +7390,7 @@
69297390 }
69307391
69317392 //System.out.println("info.modifiers = " + info.modifiers);
6932
- modified = (info.modifiers & CameraPane.META) != 0;
7393
+ modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
69337394 //System.out.println("modified = " + modified);
69347395 //new Exception().printStackTrace();
69357396 //viewCode = info.pane.renderCamera.viewCode;
....@@ -6957,7 +7418,7 @@
69577418 return true;
69587419 }
69597420
6960
- void doEditDrag0(ClickInfo info)
7421
+ void doEditDrag0(ClickInfo info, boolean opposite)
69617422 {
69627423 if (hitSomething == 0)
69637424 {
....@@ -6972,6 +7433,7 @@
69727433 //System.out.println("hitSomething = " + hitSomething);
69737434
69747435 double scale = 0.005f * info.camera.Distance();
7436
+
69757437 cVector xlate = new cVector();
69767438 //cVector xlate2 = new cVector();
69777439 switch (hitSomething)
....@@ -6984,7 +7446,7 @@
69847446
69857447 scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
69867448
6987
- if (modified)
7449
+ if (modified || opposite)
69887450 {
69897451 //assert(false);
69907452 /*
....@@ -7078,6 +7540,7 @@
70787540
70797541 if (modified)
70807542 {
7543
+ // Rotate 90 degrees
70817544 angle /= (Math.PI / 4);
70827545 angle = Math.floor(angle + 0.5);
70837546 angle *= (Math.PI / 4);
....@@ -7119,24 +7582,27 @@
71197582
71207583 case hitScale: // scale
71217584 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);
71227591 if (hScale < 0.01)
71237592 {
7124
- hScale = 0.01;
7593
+ //hScale = 0.01;
71257594 }
7126
- hScale = Math.pow(hScale, scale * 50);
7127
- if (hScale < 0.01)
7128
- {
7129
- hScale = 0.01;
7130
- }
7595
+
71317596 double vScale = (double) (info.y - centerPt.y) / 32;
7132
- if (vScale < 0.01)
7597
+ sign = 1;
7598
+ if (vScale < 0)
71337599 {
7134
- vScale = 0.01;
7600
+ sign = -1;
71357601 }
7136
- vScale = Math.pow(vScale, scale * 50);
7602
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
71377603 if (vScale < 0.01)
71387604 {
7139
- vScale = 0.01;
7605
+ //vScale = 0.01;
71407606 }
71417607 LA.matCopy(startMat, toParent);
71427608 /**/
....@@ -7147,39 +7613,47 @@
71477613 }
71487614 /**/
71497615
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
+
71507623 switch (info.pane.RenderCamera().viewCode)
71517624 {
71527625 case 3: // '\001'
7153
- if (modified)
7626
+ if (modified || opposite)
71547627 {
71557628 //LA.matScale(toParent, 1, hScale, vScale);
7156
- LA.matScale(toParent, vScale, 1, 1);
7629
+ LA.matScale(toParent, totalScale, 1, 1);
71577630 } // vScale, 1);
71587631 else
71597632 {
7160
- LA.matScale(toParent, vScale, vScale, vScale);
7633
+ // EXCEPTION!
7634
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
71617635 } // vScale, 1);
71627636 break;
71637637
71647638 case 2: // '\002'
7165
- if (modified)
7639
+ if (modified || opposite)
71667640 {
71677641 //LA.matScale(toParent, hScale, 1, vScale);
7168
- LA.matScale(toParent, 1, vScale, 1);
7642
+ LA.matScale(toParent, 1, totalScale, 1);
71697643 } else
71707644 {
7171
- LA.matScale(toParent, vScale, 1, vScale);
7645
+ LA.matScale(toParent, totalScale, 1, totalScale);
71727646 }
71737647 break;
71747648
71757649 case 1: // '\003'
7176
- if (modified)
7650
+ if (modified || opposite)
71777651 {
71787652 //LA.matScale(toParent, hScale, vScale, 1);
7179
- LA.matScale(toParent, 1, 1, vScale);
7653
+ LA.matScale(toParent, 1, 1, totalScale);
71807654 } else
71817655 {
7182
- LA.matScale(toParent, vScale, vScale, 1);
7656
+ LA.matScale(toParent, totalScale, totalScale, 1);
71837657 }
71847658 break;
71857659 }
....@@ -7312,14 +7786,22 @@
73127786 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
73137787 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
73147788 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7789
+
7790
+ String objname;
7791
+
73157792 if (false) //parent != null)
73167793 {
7317
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7794
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
73187795 } else
73197796 {
7320
- 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) ":"") */ "";
73217798 } // + super.toString();
73227799 //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);
73237805 }
73247806
73257807 public int hashCode()
....@@ -7375,6 +7857,7 @@
73757857 objectUI.closeUI();
73767858 if (editWindow != null)
73777859 {
7860
+ editWindow.ctrlPanel.FlushUI();
73787861 editWindow.refreshContents();
73797862 } // ? new
73807863 objectUI = null;
....@@ -7383,6 +7866,10 @@
73837866 {
73847867 editWindow = null;
73857868 } // ?
7869
+ }
7870
+ else
7871
+ {
7872
+ //editWindow.closeUI();
73867873 }
73877874 }
73887875
....@@ -7395,7 +7882,7 @@
73957882 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
73967883
73977884 Object3D /*Composite*/ parent;
7398
- Object3D /*Composite*/ fileparent;
7885
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
73997886
74007887 double[][] toParent; // dynamic matrix
74017888 double[][] fromParent;
....@@ -7510,7 +7997,7 @@
75107997 {
75117998 assert(bRep != null);
75127999 if (!(support instanceof GenericJoint)) // support.bRep != null)
7513
- GrafreeD.Assert(support.bRep == bRep.support);
8000
+ Grafreed.Assert(support.bRep == bRep.support);
75148001 }
75158002 else
75168003 {
....@@ -7541,6 +8028,10 @@
75418028 }
75428029
75438030 transient ObjEditor editWindow;
8031
+ transient ObjEditor manipWindow;
8032
+
8033
+ transient boolean pinned;
8034
+
75448035 transient ObjectUI objectUI;
75458036 public static int povDepth = 0;
75468037 private static cVector tbMin = new cVector();
....@@ -7559,9 +8050,9 @@
75598050 private static cVector edge2 = new cVector();
75608051 //private static cVector norm = new cVector();
75618052 /*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;
8053
+ static final int hitCenter = 1;
8054
+ static final int hitScale = 2;
8055
+ static final int hitRotate = 3;
75658056 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
75668057 /*transient*/ private Point centerPt;
75678058 /*transient*/ private int startX;