Normand Briere
2019-07-22 c570e1e38f2ff8622a71f81436654bad01cfdd5b
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[];
33
+ int versionindex = -1;
34
+
2335 ScriptNode scriptnode;
2436
2537 void InitOthers()
....@@ -100,64 +112,178 @@
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
+ o.versions = this.versions;
223
+ o.versionindex = this.versionindex;
224
+
225
+ if (this.support != null)
226
+ {
227
+ if (o.transientrep != null)
228
+ Grafreed.Assert(o.transientrep == this.support.bRep);
229
+
230
+ o.transientrep = this.support.bRep;
231
+ this.support.bRep = null;
232
+ }
233
+
234
+ // o.support = this.support;
235
+ // o.fileparent = this.fileparent;
236
+ // if (this.bRep != null)
237
+ // o.bRep = this.bRep.support;
238
+
239
+ this.bRep = null;
240
+ // if (this.bRep != null)
241
+ // this.bRep.support = null;
242
+ // this.support = null;
243
+ // this.fileparent = null;
244
+ }
245
+
246
+ void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
247
+ {
248
+ if (!hashtable.containsKey(GetUUID()))
249
+ return;
250
+
251
+ Object3D o = hashtable.get(GetUUID());
252
+
253
+ RestoreBigData(o);
254
+
255
+ if (blockloop)
256
+ return;
257
+
130258 blockloop = true;
131
- child.SaveSupports();
259
+
260
+ //hashtable.remove(GetUUID());
261
+
262
+ for (int i=0; i<Size(); i++)
263
+ {
264
+ get(i).RestoreBigData(hashtable);
265
+ }
266
+
132267 blockloop = false;
133268 }
134
-}
135269
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)
270
+ void RestoreBigData(Object3D o)
147271 {
148
- bRep.RestoreSupports();
272
+ this.bRep = o.bRep;
273
+ if (this.support != null && o.transientrep != null)
274
+ {
275
+ this.support.bRep = o.transientrep;
276
+ }
277
+
278
+ this.selection = o.selection;
279
+
280
+ this.versions = o.versions;
281
+ this.versionindex = o.versionindex;
282
+// July 2019 if (this.bRep != null)
283
+// this.bRep.support = o.transientrep;
284
+ // this.support = o.support;
285
+ // this.fileparent = o.fileparent;
149286 }
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
-}
161287
162288 // MOCAP SUPPORT
163289 double tx,ty,tz,rx,ry,rz;
....@@ -300,6 +426,8 @@
300426 }
301427
302428 boolean live = false;
429
+ transient boolean keepdontselect;
430
+ boolean dontselect = false;
303431 boolean hide = false;
304432 boolean link2master = false; // performs reset support/master at each frame
305433 boolean marked = false; // animation node
....@@ -481,12 +609,14 @@
481609 toParent = LA.newMatrix();
482610 fromParent = LA.newMatrix();
483611 }
612
+
484613 if (toParentMarked == null)
485614 {
486615 if (maxcount != 1)
487616 {
488617 new Exception().printStackTrace();
489618 }
619
+
490620 toParentMarked = LA.newMatrix();
491621 fromParentMarked = LA.newMatrix();
492622 }
....@@ -774,7 +904,7 @@
774904 if (step == 0)
775905 step = 1;
776906 if (maxcount == 0)
777
- maxcount = 2048; // 4;
907
+ maxcount = 128; // 2048; // 4;
778908 // if (acceleration == 0)
779909 // acceleration = 10;
780910 if (delay == 0) // serial
....@@ -797,7 +927,7 @@
797927
798928 if (marked && Globals.isLIVE() && live &&
799929 //TEMP21aug2018
800
- Globals.DrawMode() == iCameraPane.SHADOW &&
930
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
801931 currentframe != Globals.framecount)
802932 {
803933 currentframe = Globals.framecount;
....@@ -809,7 +939,8 @@
809939
810940 boolean changedir = random && Math.random() < 0.01; // && !link2master;
811941
812
- if (transformcount*factor > maxcount || (step == 1 && changedir))
942
+ if (transformcount*factor >= maxcount && (rewind || random) ||
943
+ (step == 1 && changedir))
813944 {
814945 countdown = 1;
815946 delay = speedup?8:1;
....@@ -881,6 +1012,7 @@
8811012 if (material == null || material.multiply)
8821013 return true;
8831014
1015
+ // Transparent objects are dynamic because we have to sort the triangles.
8841016 return material.opacity > 0.99;
8851017 }
8861018
....@@ -912,6 +1044,11 @@
9121044 fromParent = null; // LA.newMatrix();
9131045 bRep = null; // new BoundaryRep();
9141046
1047
+ if (oname != null && oname.equals("LeftHand"))
1048
+ {
1049
+ name = oname;
1050
+ }
1051
+
9151052 /*
9161053 float hue = (float)Math.random();
9171054 Color col;
....@@ -954,7 +1091,7 @@
9541091
9551092 public Object clone()
9561093 {
957
- return GrafreeD.clone(this);
1094
+ return Grafreed.clone(this);
9581095 }
9591096
9601097 Object3D copyExpand()
....@@ -1276,6 +1413,7 @@
12761413 toParent = LA.newMatrix();
12771414 fromParent = LA.newMatrix();
12781415 }
1416
+
12791417 LA.matCopy(other.toParent, toParent);
12801418 LA.matCopy(other.fromParent, fromParent);
12811419
....@@ -1470,7 +1608,7 @@
14701608 BoundaryRep.SEUIL = other.material.cameralight;
14711609
14721610 // Set default to 0.1
1473
- BoundaryRep.SEUIL /= 2;
1611
+ BoundaryRep.SEUIL /= 4; // 2;
14741612 System.out.println("SEUIL = " + BoundaryRep.SEUIL);
14751613 }
14761614
....@@ -1729,7 +1867,7 @@
17291867 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17301868 o.bRep = transientrep;
17311869 if (clone)
1732
- o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
1870
+ o.bRep = (BoundaryRep) Grafreed.clone(transientrep);
17331871 o.CreateMaterial();
17341872 o.SetAttributes(this, -1);
17351873 //parent
....@@ -1742,7 +1880,7 @@
17421880 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17431881 o.bRep = bRep;
17441882 if (clone)
1745
- o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
1883
+ o.bRep = (BoundaryRep) Grafreed.clone(bRep);
17461884 o.CreateMaterial();
17471885 //o.overwriteThis(this, -1);
17481886 o.SetAttributes(this, -1);
....@@ -1829,12 +1967,15 @@
18291967 if (obj.name == null)
18301968 continue; // can't be a null one
18311969
1970
+ // Try perfect match first.
18321971 if (n.equals(obj.name))
18331972 {
18341973 theobj = obj;
18351974 count++;
18361975 }
18371976 }
1977
+
1978
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18381979
18391980 if (count != 1)
18401981 for (int i=Size(); --i>=0;)
....@@ -2294,12 +2435,17 @@
22942435 }
22952436 */
22962437 }
2438
+ else
2439
+ {
2440
+ //((ObjEditor)editWindow).SetupUI2(null);
2441
+ }
22972442 }
22982443
22992444 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
23002445 {
23012446 if (newWindow)
23022447 {
2448
+ new Exception().printStackTrace();
23032449 System.exit(0);
23042450 if (parent != null)
23052451 {
....@@ -2334,6 +2480,14 @@
23342480 {
23352481 editWindow.refreshContents();
23362482 }
2483
+ else
2484
+ {
2485
+ if (manipWindow != null)
2486
+ {
2487
+ manipWindow.refreshContents();
2488
+ }
2489
+ }
2490
+
23372491 //if (parent != null)
23382492 //parent.refreshEditWindow();
23392493 }
....@@ -2476,13 +2630,13 @@
24762630 return retval;
24772631 }
24782632
2479
- void doEditDrag(ClickInfo info)
2633
+ void doEditDrag(ClickInfo info, boolean opposite)
24802634 {
24812635 switch (doSomething)
24822636 {
24832637 case 1: // '\001'
24842638 //super.
2485
- doEditDrag0(info);
2639
+ doEditDrag0(info, opposite);
24862640 break;
24872641
24882642 case 2: // '\002'
....@@ -2495,11 +2649,11 @@
24952649 {
24962650 //sel.hitSomething = childToDrag.hitSomething;
24972651 //childToDrag.doEditDrag(info);
2498
- sel.doEditDrag(info);
2652
+ sel.doEditDrag(info, opposite);
24992653 } else
25002654 {
25012655 //super.
2502
- doEditDrag0(info);
2656
+ doEditDrag0(info, opposite);
25032657 }
25042658 }
25052659 break;
....@@ -2609,6 +2763,18 @@
26092763 void GenNormalsS(boolean crease)
26102764 {
26112765 selection.GenNormals(crease);
2766
+// for (int i=0; i<selection.size(); i++)
2767
+// {
2768
+// Object3D selectee = (Object3D) selection.elementAt(i);
2769
+// selectee.GenNormals(crease);
2770
+// }
2771
+
2772
+ //Touch();
2773
+ }
2774
+
2775
+ void GenNormalsMeshS()
2776
+ {
2777
+ selection.GenNormalsMesh();
26122778 // for (int i=0; i<selection.size(); i++)
26132779 // {
26142780 // Object3D selectee = (Object3D) selection.elementAt(i);
....@@ -2749,6 +2915,24 @@
27492915 if (child == null)
27502916 continue;
27512917 child.GenNormals(crease);
2918
+// Children().release(i);
2919
+ }
2920
+ blockloop = false;
2921
+ }
2922
+
2923
+ void GenNormalsMesh()
2924
+ {
2925
+ if (blockloop)
2926
+ return;
2927
+
2928
+ blockloop = true;
2929
+ GenNormalsMesh0();
2930
+ for (int i = 0; i < Children().Size(); i++)
2931
+ {
2932
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2933
+ if (child == null)
2934
+ continue;
2935
+ child.GenNormalsMesh();
27522936 // Children().release(i);
27532937 }
27542938 blockloop = false;
....@@ -2906,7 +3090,8 @@
29063090 {
29073091 if (bRep != null)
29083092 {
2909
- bRep.GenUV();
3093
+ bRep.GenUV(); //1);
3094
+ //bRep.UnfoldUV();
29103095 Touch();
29113096 }
29123097 }
....@@ -2920,11 +3105,20 @@
29203105 }
29213106 }
29223107
3108
+ void GenNormalsMesh0()
3109
+ {
3110
+ if (bRep != null)
3111
+ {
3112
+ bRep.GenerateNormalsMesh();
3113
+ Touch();
3114
+ }
3115
+ }
3116
+
29233117 void GenNormalsMINE0()
29243118 {
29253119 if (bRep != null)
29263120 {
2927
- bRep.GenerateNormalsMINE();
3121
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
29283122 Touch();
29293123 }
29303124 }
....@@ -2981,6 +3175,33 @@
29813175 blockloop = false;
29823176 }
29833177
3178
+ void TransformChildren()
3179
+ {
3180
+ if (toParent != null)
3181
+ {
3182
+ for (int i=Size(); --i>=0;)
3183
+ {
3184
+ Object3D v = get(i);
3185
+
3186
+ if (v.toParent == null)
3187
+ {
3188
+ v.toParent = LA.newMatrix();
3189
+ v.fromParent = LA.newMatrix();
3190
+ }
3191
+
3192
+// LA.matConcat(v.toParent, toParent, v.toParent);
3193
+// LA.matConcat(fromParent, v.fromParent, v.fromParent);
3194
+ LA.matConcat(toParent, v.toParent, v.toParent);
3195
+ LA.matConcat(v.fromParent, fromParent, v.fromParent);
3196
+ }
3197
+
3198
+ toParent = null; // LA.matIdentity(toParent);
3199
+ fromParent = null; // LA.matIdentity(fromParent);
3200
+
3201
+ Touch();
3202
+ }
3203
+ }
3204
+
29843205 void TransformGeometry()
29853206 {
29863207 Object3D obj = this;
....@@ -3202,9 +3423,11 @@
32023423
32033424 BoundaryRep sup = bRep.support;
32043425 bRep.support = null;
3205
- BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
3426
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
32063427 // bRep.SplitInTwo(onlyone); // thread...
3207
- temprep.SplitInTwo(reduction34, onlyone);
3428
+
3429
+ while(temprep.SplitInTwo(reduction34, onlyone));
3430
+
32083431 bRep = temprep;
32093432 bRep.support = sup;
32103433 Touch();
....@@ -3341,7 +3564,8 @@
33413564 if (blockloop)
33423565 return;
33433566
3344
- if (marked || (bRep != null && material != null)) // borderline...
3567
+ if (//marked || // does not make sense
3568
+ (bRep != null || material != null)) // borderline...
33453569 live = h;
33463570
33473571 for (int i = 0; i < Size(); i++)
....@@ -3362,7 +3586,8 @@
33623586 return;
33633587
33643588 //if (bRep != null)
3365
- if (marked || (bRep != null && material != null)) // borderline...
3589
+ if (//marked || // does not make sense
3590
+ (bRep != null || material != null)) // borderline...
33663591 link2master = h;
33673592
33683593 for (int i = 0; i < Size(); i++)
....@@ -3382,7 +3607,8 @@
33823607 if (blockloop)
33833608 return;
33843609
3385
- if (marked || (bRep != null && material != null)) // borderline...
3610
+ if (//marked || // does not make sense
3611
+ (bRep != null || material != null)) // borderline...
33863612 hide = h;
33873613
33883614 for (int i = 0; i < Size(); i++)
....@@ -3402,7 +3628,7 @@
34023628 if (blockloop)
34033629 return;
34043630
3405
- if (bRep != null && material != null) // borderline...
3631
+ if (bRep != null || material != null) // borderline...
34063632 marked = h;
34073633
34083634 for (int i = 0; i < Size(); i++)
....@@ -3412,6 +3638,46 @@
34123638 continue;
34133639 blockloop = true;
34143640 child.MarkLeaves(h);
3641
+ blockloop = false;
3642
+ // release(i);
3643
+ }
3644
+ }
3645
+
3646
+ void RewindLeaves(boolean h)
3647
+ {
3648
+ if (blockloop)
3649
+ return;
3650
+
3651
+ if (bRep != null || material != null) // borderline...
3652
+ rewind = h;
3653
+
3654
+ for (int i = 0; i < Size(); i++)
3655
+ {
3656
+ Object3D child = (Object3D) get(i); // reserve(i);
3657
+ if (child == null)
3658
+ continue;
3659
+ blockloop = true;
3660
+ child.RewindLeaves(h);
3661
+ blockloop = false;
3662
+ // release(i);
3663
+ }
3664
+ }
3665
+
3666
+ void RandomLeaves(boolean h)
3667
+ {
3668
+ if (blockloop)
3669
+ return;
3670
+
3671
+ if (bRep != null || material != null) // borderline...
3672
+ random = h;
3673
+
3674
+ for (int i = 0; i < Size(); i++)
3675
+ {
3676
+ Object3D child = (Object3D) get(i); // reserve(i);
3677
+ if (child == null)
3678
+ continue;
3679
+ blockloop = true;
3680
+ child.RandomLeaves(h);
34153681 blockloop = false;
34163682 // release(i);
34173683 }
....@@ -3726,7 +3992,7 @@
37263992 if (child == null)
37273993 continue;
37283994
3729
- if (GrafreeD.RENDERME > 0)
3995
+ if (Grafreed.RENDERME > 0)
37303996 {
37313997 if (child instanceof Merge)
37323998 ((Merge)child).renderme();
....@@ -3877,7 +4143,7 @@
38774143 if (child == null)
38784144 continue;
38794145
3880
- if (GrafreeD.RENDERME > 0)
4146
+ if (Grafreed.RENDERME > 0)
38814147 {
38824148 if (child instanceof Merge)
38834149 ((Merge)child).renderme();
....@@ -4072,7 +4338,7 @@
40724338 if (child == null)
40734339 continue;
40744340
4075
- if (GrafreeD.RENDERME > 0)
4341
+ if (Grafreed.RENDERME > 0)
40764342 {
40774343 if (child instanceof Merge)
40784344 ((Merge)child).renderme();
....@@ -4185,6 +4451,55 @@
41854451 {
41864452 blockloop = true;
41874453 get(i).RepairShadow();
4454
+ blockloop = false;
4455
+ }
4456
+ }
4457
+
4458
+ void RepairSOV()
4459
+ {
4460
+ if (blockloop)
4461
+ return;
4462
+
4463
+ String texname = this.GetPigmentTexture();
4464
+
4465
+ if (texname.startsWith("sov"))
4466
+ {
4467
+ String[] s = texname.split("/");
4468
+
4469
+ String[] sname = s[1].split("Color.pn");
4470
+
4471
+ texname = sname[0];
4472
+
4473
+ if (sname.length > 1)
4474
+ {
4475
+ texname += "Color.jpg";
4476
+ }
4477
+
4478
+ this.SetPigmentTexture("sov/" + texname);
4479
+ }
4480
+
4481
+ texname = this.GetBumpTexture();
4482
+
4483
+ if (texname.startsWith("sov"))
4484
+ {
4485
+ String[] s = texname.split("/");
4486
+
4487
+ String[] sname = s[1].split("Bump.pn");
4488
+
4489
+ texname = sname[0];
4490
+
4491
+ if (sname.length > 1)
4492
+ {
4493
+ texname += "Bump.jpg";
4494
+ }
4495
+
4496
+ this.SetBumpTexture("sov/" + texname);
4497
+ }
4498
+
4499
+ for (int i=0; i<Size(); i++)
4500
+ {
4501
+ blockloop = true;
4502
+ get(i).RepairSOV();
41884503 blockloop = false;
41894504 }
41904505 }
....@@ -4679,7 +4994,7 @@
46794994
46804995 cTreePath SelectLeaf(int indexcount, boolean deselect)
46814996 {
4682
- if (hide)
4997
+ if (hide || dontselect)
46834998 return null;
46844999
46855000 if (count <= 0)
....@@ -4703,9 +5018,17 @@
47035018 }
47045019 }
47055020
5021
+ ObjEditor GetWindow()
5022
+ {
5023
+ if (editWindow != null)
5024
+ return editWindow;
5025
+
5026
+ return manipWindow;
5027
+ }
5028
+
47065029 cTreePath Select(int indexcount, boolean deselect)
47075030 {
4708
- if (hide)
5031
+ if (hide || dontselect)
47095032 return null;
47105033
47115034 if (count <= 0)
....@@ -4739,10 +5062,11 @@
47395062 if (leaf != null)
47405063 {
47415064 cTreePath tp = new cTreePath(this, leaf);
4742
- if (editWindow != null)
5065
+ ObjEditor window = GetWindow();
5066
+ if (window != null)
47435067 {
47445068 //System.out.println("editWindow = " + editWindow + " vs " + this);
4745
- editWindow.Select(tp, deselect, true);
5069
+ window.Select(tp, deselect, true);
47465070 }
47475071
47485072 return tp;
....@@ -4759,6 +5083,7 @@
47595083
47605084 if (child == null)
47615085 continue;
5086
+
47625087 if (child.HasTransparency() && child.size() != 0)
47635088 {
47645089 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4768,9 +5093,10 @@
47685093 if (leaf != null)
47695094 {
47705095 cTreePath tp = new cTreePath(this, leaf);
4771
- if (editWindow != null)
5096
+ ObjEditor window = GetWindow();
5097
+ if (window != null)
47725098 {
4773
- editWindow.Select(tp, deselect, true);
5099
+ window.Select(tp, deselect, true);
47745100 }
47755101
47765102 return tp;
....@@ -5095,6 +5421,51 @@
50955421 blockloop = false;
50965422 }
50975423
5424
+ void ResetSelectable()
5425
+ {
5426
+ if (blockloop)
5427
+ return;
5428
+
5429
+ blockloop = true;
5430
+
5431
+ keepdontselect = dontselect;
5432
+ dontselect = true;
5433
+
5434
+ Object3D child;
5435
+ int nb = Size();
5436
+ for (int i = 0; i < nb; i++)
5437
+ {
5438
+ child = (Object3D) get(i);
5439
+ if (child == null)
5440
+ continue;
5441
+ child.ResetSelectable();
5442
+ }
5443
+
5444
+ blockloop = false;
5445
+ }
5446
+
5447
+ void RestoreSelectable()
5448
+ {
5449
+ if (blockloop)
5450
+ return;
5451
+
5452
+ blockloop = true;
5453
+
5454
+ dontselect = keepdontselect;
5455
+
5456
+ Object3D child;
5457
+ int nb = Size();
5458
+ for (int i = 0; i < nb; i++)
5459
+ {
5460
+ child = (Object3D) get(i);
5461
+ if (child == null)
5462
+ continue;
5463
+ child.RestoreSelectable();
5464
+ }
5465
+
5466
+ blockloop = false;
5467
+ }
5468
+
50985469 boolean IsSelected()
50995470 {
51005471 if (parent == null)
....@@ -5157,10 +5528,34 @@
51575528
51585529 // System.out.println("Fullname = " + fullname);
51595530
5160
- if (fullname.name.indexOf(":") == -1)
5161
- return fullname.name;
5531
+ // Does not work on Windows due to C:
5532
+// if (fullname.name.indexOf(":") == -1)
5533
+// return fullname.name;
5534
+//
5535
+// return fullname.name.substring(0,fullname.name.indexOf(":"));
51625536
5163
- return fullname.name.substring(0,fullname.name.indexOf(":"));
5537
+ String[] split = fullname.name.split(":");
5538
+
5539
+ if (split.length == 0)
5540
+ {
5541
+ return "";
5542
+ }
5543
+
5544
+ if (split.length <= 2)
5545
+ {
5546
+ if (fullname.name.endsWith(":"))
5547
+ {
5548
+ // Windows
5549
+ return fullname.name.substring(0, fullname.name.length()-1);
5550
+ }
5551
+
5552
+ return split[0];
5553
+ }
5554
+
5555
+ // Windows
5556
+ assert(split.length == 4);
5557
+
5558
+ return split[0] + ":" + split[1];
51645559 }
51655560
51665561 static String GetBump(cTexture fullname)
....@@ -5169,10 +5564,38 @@
51695564 return "";
51705565
51715566 // 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());
5567
+ // Does not work on Windows due to C:
5568
+// if (fullname.name.indexOf(":") == -1)
5569
+// return "";
5570
+//
5571
+// return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5572
+ String[] split = fullname.name.split(":");
5573
+
5574
+ if (split.length == 0)
5575
+ {
5576
+ return "";
5577
+ }
5578
+
5579
+ if (split.length == 1)
5580
+ {
5581
+ return "";
5582
+ }
5583
+
5584
+ if (split.length == 2)
5585
+ {
5586
+ if (fullname.name.endsWith(":"))
5587
+ {
5588
+ // Windows
5589
+ return "";
5590
+ }
5591
+
5592
+ return split[1];
5593
+ }
5594
+
5595
+ // Windows
5596
+ assert(split.length == 4);
5597
+
5598
+ return split[2] + ":" + split[3];
51765599 }
51775600
51785601 String GetPigmentTexture()
....@@ -5246,7 +5669,7 @@
52465669 System.out.print("; textures = " + textures);
52475670 System.out.println("; usedtextures = " + usedtextures);
52485671
5249
- if (GetTextures() == null)
5672
+ if (GetTextures() == null) // What is that??
52505673 GetTextures().name = ":";
52515674
52525675 String texname = tex;
....@@ -5277,6 +5700,43 @@
52775700 child.ResetPigmentTexture();
52785701 blockloop = false;
52795702 }
5703
+ }
5704
+
5705
+ UUID GetUUID()
5706
+ {
5707
+ if (uuid == null)
5708
+ {
5709
+ // Serial
5710
+ uuid = UUID.randomUUID();
5711
+ }
5712
+
5713
+ return uuid;
5714
+ }
5715
+
5716
+ Object3D GetObject(UUID uid)
5717
+ {
5718
+ if (blockloop)
5719
+ return null;
5720
+
5721
+ if (GetUUID().equals(uid))
5722
+ return this;
5723
+
5724
+ int nb = Size();
5725
+ for (int i = 0; i < nb; i++)
5726
+ {
5727
+ Object3D child = (Object3D) get(i);
5728
+
5729
+ if (child == null)
5730
+ continue;
5731
+
5732
+ blockloop = true;
5733
+ Object3D obj = child.GetObject(uid);
5734
+ blockloop = false;
5735
+ if (obj != null)
5736
+ return obj;
5737
+ }
5738
+
5739
+ return null;
52805740 }
52815741
52825742 void SetBumpTexture(String tex)
....@@ -5315,6 +5775,38 @@
53155775 }
53165776 }
53175777
5778
+ void EmbedTextures(boolean embed)
5779
+ {
5780
+ if (blockloop)
5781
+ return;
5782
+
5783
+ //if (GetTextures() != null)
5784
+ if (embed)
5785
+ CameraPane.EmbedTextures(GetTextures());
5786
+ else
5787
+ {
5788
+ GetTextures().pigmentdata = null;
5789
+ GetTextures().bumpdata = null;
5790
+ GetTextures().pw = 0;
5791
+ GetTextures().ph = 0;
5792
+ GetTextures().bw = 0;
5793
+ GetTextures().bh = 0;
5794
+ }
5795
+
5796
+ int nb = Size();
5797
+ for (int i = 0; i < nb; i++)
5798
+ {
5799
+ Object3D child = (Object3D) get(i);
5800
+
5801
+ if (child == null)
5802
+ continue;
5803
+
5804
+ blockloop = true;
5805
+ child.EmbedTextures(embed);
5806
+ blockloop = false;
5807
+ }
5808
+ }
5809
+
53185810 void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
53195811 {
53205812 Draw(display, root, selected, blocked);
....@@ -5323,12 +5815,23 @@
53235815 boolean NeedSupport()
53245816 {
53255817 return
5326
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5818
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
53275819 // PROBLEM with CROWD!!
5328
- && (Globals.DrawMode() == iCameraPane.SHADOW || Globals.CROWD);
5820
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
53295821 }
53305822
53315823 static boolean DEBUG_SELECTION = false;
5824
+
5825
+ boolean IsLive()
5826
+ {
5827
+ if (live)
5828
+ return true;
5829
+
5830
+ if (parent == null)
5831
+ return false;
5832
+
5833
+ return parent.IsLive();
5834
+ }
53325835
53335836 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
53345837 {
....@@ -5340,7 +5843,7 @@
53405843 }
53415844
53425845 if (display.DrawMode() == iCameraPane.SELECTION &&
5343
- hide)
5846
+ (hide || dontselect))
53445847 return;
53455848
53465849 if (name != null && name.contains("sclera"))
....@@ -5391,7 +5894,7 @@
53915894 support = support;
53925895
53935896 //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);
5897
+ boolean usecalllists = !IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
53955898
53965899 if (!usecalllists && bRep != null && bRep.displaylist > 0)
53975900 {
....@@ -5411,10 +5914,12 @@
54115914 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
54125915
54135916 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5414
- (touched || (bRep != null && bRep.displaylist <= 0)))
5917
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5918
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
54155919 {
54165920 Globals.lighttouched = true;
54175921 } // all panes...
5922
+
54185923 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
54195924 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
54205925 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5542,6 +6047,7 @@
55426047 if (GetBRep() != null)
55436048 {
55446049 display.NextIndex();
6050
+
55456051 // vertex color conflict : gl.glCallList(list);
55466052 DrawNode(display, root, selected);
55476053 if (this instanceof BezierPatch)
....@@ -5582,7 +6088,28 @@
55826088 tex = GetTextures();
55836089 }
55846090
5585
- display.BindTextures(tex, texres);
6091
+ boolean failedPigment = false;
6092
+ boolean failedBump = false;
6093
+
6094
+ try
6095
+ {
6096
+ display.BindPigmentTexture(tex, texres);
6097
+ }
6098
+ catch (Exception e)
6099
+ {
6100
+ System.err.println("FAILED: " + this);
6101
+ failedPigment = true;
6102
+ }
6103
+
6104
+ try
6105
+ {
6106
+ display.BindBumpTexture(tex, texres);
6107
+ }
6108
+ catch (Exception e)
6109
+ {
6110
+ //System.err.println("FAILED: " + this);
6111
+ failedBump = true;
6112
+ }
55866113
55876114 if (!compiled)
55886115 {
....@@ -5604,7 +6131,11 @@
56046131 }
56056132 }
56066133
5607
- display.ReleaseTextures(tex);
6134
+ if (!failedBump)
6135
+ display.ReleaseBumpTexture(tex);
6136
+
6137
+ if (!failedPigment)
6138
+ display.ReleasePigmentTexture(tex);
56086139
56096140 display.PopMaterial(this, selected);
56106141 }
....@@ -5733,6 +6264,9 @@
57336264
57346265 void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57356266 {
6267
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6268
+ return;
6269
+
57366270 if (hide)
57376271 return;
57386272 // shadow optimisation
....@@ -5858,6 +6392,9 @@
58586392 if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
58596393 return; // no shadow for transparent objects
58606394
6395
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6396
+ return;
6397
+
58616398 if (hide)
58626399 return;
58636400
....@@ -5898,6 +6435,7 @@
58986435 return;
58996436 }
59006437
6438
+ //bRep.GenUV(1/material.diffuseness);
59016439 // bRep.lock = true;
59026440
59036441 //javax.media.opengl.GL gl = display.GetGL();
....@@ -5970,6 +6508,11 @@
59706508 // dec 2012
59716509 new Exception().printStackTrace();
59726510 return;
6511
+ }
6512
+
6513
+ if (dontselect)
6514
+ {
6515
+ //bRep.GenerateNormalsMINE();
59736516 }
59746517
59756518 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -6822,7 +7365,7 @@
68227365 spot.translate(32, 32);
68237366 spotw = spot.x + spot.width;
68247367 spoth = spot.y + spot.height;
6825
- info.g.setColor(Color.blue);
7368
+ info.g.setColor(Color.cyan);
68267369 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
68277370 // if (CameraPane.Xmin > spot.x)
68287371 // {
....@@ -6840,11 +7383,12 @@
68407383 // {
68417384 // CameraPane.Ymax = spoth;
68427385 // }
6843
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
6844
- info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7386
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7387
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
68457388 spot.translate(0, -32);
6846
- info.g.setColor(Color.green);
7389
+ info.g.setColor(Color.yellow);
68477390 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7391
+ info.g.setColor(Color.green);
68487392 // if (CameraPane.Xmin > spot.x)
68497393 // {
68507394 // CameraPane.Xmin = spot.x;
....@@ -6861,8 +7405,8 @@
68617405 // {
68627406 // CameraPane.Ymax = spoth;
68637407 // }
6864
- info.g.drawArc(boundary.x, boundary.y,
6865
- boundary.width, boundary.height, 0, 360);
7408
+ info.g.drawArc(boundary.x + info.DX, boundary.y + info.DY,
7409
+ (int)(boundary.width * info.W), (int)(boundary.height * info.W), 0, 360);
68667410 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
68677411 // if (CameraPane.Xmin > boundary.x)
68687412 // {
....@@ -6896,7 +7440,7 @@
68967440 startX = info.x;
68977441 startY = info.y;
68987442
6899
- hitSomething = 0;
7443
+ hitSomething = -1;
69007444 cVector origin = new cVector();
69017445 //LA.xformPos(origin, toParent, origin);
69027446 Rectangle spot = new Rectangle();
....@@ -6929,7 +7473,7 @@
69297473 }
69307474
69317475 //System.out.println("info.modifiers = " + info.modifiers);
6932
- modified = (info.modifiers & CameraPane.META) != 0;
7476
+ modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
69337477 //System.out.println("modified = " + modified);
69347478 //new Exception().printStackTrace();
69357479 //viewCode = info.pane.renderCamera.viewCode;
....@@ -6957,7 +7501,7 @@
69577501 return true;
69587502 }
69597503
6960
- void doEditDrag0(ClickInfo info)
7504
+ void doEditDrag0(ClickInfo info, boolean opposite)
69617505 {
69627506 if (hitSomething == 0)
69637507 {
....@@ -6972,6 +7516,7 @@
69727516 //System.out.println("hitSomething = " + hitSomething);
69737517
69747518 double scale = 0.005f * info.camera.Distance();
7519
+
69757520 cVector xlate = new cVector();
69767521 //cVector xlate2 = new cVector();
69777522 switch (hitSomething)
....@@ -6984,7 +7529,7 @@
69847529
69857530 scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
69867531
6987
- if (modified)
7532
+ if (modified || opposite)
69887533 {
69897534 //assert(false);
69907535 /*
....@@ -7078,6 +7623,7 @@
70787623
70797624 if (modified)
70807625 {
7626
+ // Rotate 90 degrees
70817627 angle /= (Math.PI / 4);
70827628 angle = Math.floor(angle + 0.5);
70837629 angle *= (Math.PI / 4);
....@@ -7119,24 +7665,27 @@
71197665
71207666 case hitScale: // scale
71217667 double hScale = (double) (info.x - centerPt.x) / 32;
7668
+ double sign = 1;
7669
+ if (hScale < 0)
7670
+ {
7671
+ sign = -1;
7672
+ }
7673
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
71227674 if (hScale < 0.01)
71237675 {
7124
- hScale = 0.01;
7676
+ //hScale = 0.01;
71257677 }
7126
- hScale = Math.pow(hScale, scale * 50);
7127
- if (hScale < 0.01)
7128
- {
7129
- hScale = 0.01;
7130
- }
7678
+
71317679 double vScale = (double) (info.y - centerPt.y) / 32;
7132
- if (vScale < 0.01)
7680
+ sign = 1;
7681
+ if (vScale < 0)
71337682 {
7134
- vScale = 0.01;
7683
+ sign = -1;
71357684 }
7136
- vScale = Math.pow(vScale, scale * 50);
7685
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
71377686 if (vScale < 0.01)
71387687 {
7139
- vScale = 0.01;
7688
+ //vScale = 0.01;
71407689 }
71417690 LA.matCopy(startMat, toParent);
71427691 /**/
....@@ -7147,39 +7696,47 @@
71477696 }
71487697 /**/
71497698
7699
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7700
+
7701
+ if (totalScale < 0.01)
7702
+ {
7703
+ totalScale = 0.01;
7704
+ }
7705
+
71507706 switch (info.pane.RenderCamera().viewCode)
71517707 {
71527708 case 3: // '\001'
7153
- if (modified)
7709
+ if (modified || opposite)
71547710 {
71557711 //LA.matScale(toParent, 1, hScale, vScale);
7156
- LA.matScale(toParent, vScale, 1, 1);
7712
+ LA.matScale(toParent, totalScale, 1, 1);
71577713 } // vScale, 1);
71587714 else
71597715 {
7160
- LA.matScale(toParent, vScale, vScale, vScale);
7716
+ // EXCEPTION!
7717
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
71617718 } // vScale, 1);
71627719 break;
71637720
71647721 case 2: // '\002'
7165
- if (modified)
7722
+ if (modified || opposite)
71667723 {
71677724 //LA.matScale(toParent, hScale, 1, vScale);
7168
- LA.matScale(toParent, 1, vScale, 1);
7725
+ LA.matScale(toParent, 1, totalScale, 1);
71697726 } else
71707727 {
7171
- LA.matScale(toParent, vScale, 1, vScale);
7728
+ LA.matScale(toParent, totalScale, 1, totalScale);
71727729 }
71737730 break;
71747731
71757732 case 1: // '\003'
7176
- if (modified)
7733
+ if (modified || opposite)
71777734 {
71787735 //LA.matScale(toParent, hScale, vScale, 1);
7179
- LA.matScale(toParent, 1, 1, vScale);
7736
+ LA.matScale(toParent, 1, 1, totalScale);
71807737 } else
71817738 {
7182
- LA.matScale(toParent, vScale, vScale, 1);
7739
+ LA.matScale(toParent, totalScale, totalScale, 1);
71837740 }
71847741 break;
71857742 }
....@@ -7312,14 +7869,22 @@
73127869 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
73137870 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
73147871 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7872
+
7873
+ String objname;
7874
+
73157875 if (false) //parent != null)
73167876 {
7317
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7877
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
73187878 } else
73197879 {
7320
- return GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ") ")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ +System.identityHashCode(this);
7880
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
73217881 } // + super.toString();
73227882 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
7883
+
7884
+ if (!Globals.ADVANCED)
7885
+ return objname;
7886
+
7887
+ return objname + " " + System.identityHashCode(this);
73237888 }
73247889
73257890 public int hashCode()
....@@ -7375,6 +7940,7 @@
73757940 objectUI.closeUI();
73767941 if (editWindow != null)
73777942 {
7943
+ editWindow.ctrlPanel.FlushUI();
73787944 editWindow.refreshContents();
73797945 } // ? new
73807946 objectUI = null;
....@@ -7383,6 +7949,10 @@
73837949 {
73847950 editWindow = null;
73857951 } // ?
7952
+ }
7953
+ else
7954
+ {
7955
+ //editWindow.closeUI();
73867956 }
73877957 }
73887958
....@@ -7395,7 +7965,7 @@
73957965 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
73967966
73977967 Object3D /*Composite*/ parent;
7398
- Object3D /*Composite*/ fileparent;
7968
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
73997969
74007970 double[][] toParent; // dynamic matrix
74017971 double[][] fromParent;
....@@ -7510,7 +8080,7 @@
75108080 {
75118081 assert(bRep != null);
75128082 if (!(support instanceof GenericJoint)) // support.bRep != null)
7513
- GrafreeD.Assert(support.bRep == bRep.support);
8083
+ Grafreed.Assert(support.bRep == bRep.support);
75148084 }
75158085 else
75168086 {
....@@ -7541,6 +8111,10 @@
75418111 }
75428112
75438113 transient ObjEditor editWindow;
8114
+ transient ObjEditor manipWindow;
8115
+
8116
+ transient boolean pinned;
8117
+
75448118 transient ObjectUI objectUI;
75458119 public static int povDepth = 0;
75468120 private static cVector tbMin = new cVector();
....@@ -7559,9 +8133,9 @@
75598133 private static cVector edge2 = new cVector();
75608134 //private static cVector norm = new cVector();
75618135 /*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;
8136
+ static final int hitCenter = 1;
8137
+ static final int hitScale = 2;
8138
+ static final int hitRotate = 3;
75658139 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
75668140 /*transient*/ private Point centerPt;
75678141 /*transient*/ private int startX;