Normand Briere
2019-07-18 d7a17c35c443e2cb6c09eaa3cfeaf590a571faa1
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,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,7 @@
300426 }
301427
302428 boolean live = false;
429
+ boolean dontselect = false;
303430 boolean hide = false;
304431 boolean link2master = false; // performs reset support/master at each frame
305432 boolean marked = false; // animation node
....@@ -481,12 +608,14 @@
481608 toParent = LA.newMatrix();
482609 fromParent = LA.newMatrix();
483610 }
611
+
484612 if (toParentMarked == null)
485613 {
486614 if (maxcount != 1)
487615 {
488616 new Exception().printStackTrace();
489617 }
618
+
490619 toParentMarked = LA.newMatrix();
491620 fromParentMarked = LA.newMatrix();
492621 }
....@@ -774,7 +903,7 @@
774903 if (step == 0)
775904 step = 1;
776905 if (maxcount == 0)
777
- maxcount = 2048; // 4;
906
+ maxcount = 128; // 2048; // 4;
778907 // if (acceleration == 0)
779908 // acceleration = 10;
780909 if (delay == 0) // serial
....@@ -797,7 +926,7 @@
797926
798927 if (marked && Globals.isLIVE() && live &&
799928 //TEMP21aug2018
800
- Globals.DrawMode() == iCameraPane.SHADOW &&
929
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
801930 currentframe != Globals.framecount)
802931 {
803932 currentframe = Globals.framecount;
....@@ -809,7 +938,8 @@
809938
810939 boolean changedir = random && Math.random() < 0.01; // && !link2master;
811940
812
- if (transformcount*factor > maxcount || (step == 1 && changedir))
941
+ if (transformcount*factor >= maxcount && (rewind || random) ||
942
+ (step == 1 && changedir))
813943 {
814944 countdown = 1;
815945 delay = speedup?8:1;
....@@ -881,6 +1011,7 @@
8811011 if (material == null || material.multiply)
8821012 return true;
8831013
1014
+ // Transparent objects are dynamic because we have to sort the triangles.
8841015 return material.opacity > 0.99;
8851016 }
8861017
....@@ -912,6 +1043,11 @@
9121043 fromParent = null; // LA.newMatrix();
9131044 bRep = null; // new BoundaryRep();
9141045
1046
+ if (oname != null && oname.equals("LeftHand"))
1047
+ {
1048
+ name = oname;
1049
+ }
1050
+
9151051 /*
9161052 float hue = (float)Math.random();
9171053 Color col;
....@@ -954,7 +1090,7 @@
9541090
9551091 public Object clone()
9561092 {
957
- return GrafreeD.clone(this);
1093
+ return Grafreed.clone(this);
9581094 }
9591095
9601096 Object3D copyExpand()
....@@ -1276,6 +1412,7 @@
12761412 toParent = LA.newMatrix();
12771413 fromParent = LA.newMatrix();
12781414 }
1415
+
12791416 LA.matCopy(other.toParent, toParent);
12801417 LA.matCopy(other.fromParent, fromParent);
12811418
....@@ -1470,7 +1607,7 @@
14701607 BoundaryRep.SEUIL = other.material.cameralight;
14711608
14721609 // Set default to 0.1
1473
- BoundaryRep.SEUIL /= 2;
1610
+ BoundaryRep.SEUIL /= 4; // 2;
14741611 System.out.println("SEUIL = " + BoundaryRep.SEUIL);
14751612 }
14761613
....@@ -1729,7 +1866,7 @@
17291866 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17301867 o.bRep = transientrep;
17311868 if (clone)
1732
- o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
1869
+ o.bRep = (BoundaryRep) Grafreed.clone(transientrep);
17331870 o.CreateMaterial();
17341871 o.SetAttributes(this, -1);
17351872 //parent
....@@ -1742,7 +1879,7 @@
17421879 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17431880 o.bRep = bRep;
17441881 if (clone)
1745
- o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
1882
+ o.bRep = (BoundaryRep) Grafreed.clone(bRep);
17461883 o.CreateMaterial();
17471884 //o.overwriteThis(this, -1);
17481885 o.SetAttributes(this, -1);
....@@ -1829,12 +1966,15 @@
18291966 if (obj.name == null)
18301967 continue; // can't be a null one
18311968
1969
+ // Try perfect match first.
18321970 if (n.equals(obj.name))
18331971 {
18341972 theobj = obj;
18351973 count++;
18361974 }
18371975 }
1976
+
1977
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18381978
18391979 if (count != 1)
18401980 for (int i=Size(); --i>=0;)
....@@ -2294,12 +2434,17 @@
22942434 }
22952435 */
22962436 }
2437
+ else
2438
+ {
2439
+ //((ObjEditor)editWindow).SetupUI2(null);
2440
+ }
22972441 }
22982442
22992443 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
23002444 {
23012445 if (newWindow)
23022446 {
2447
+ new Exception().printStackTrace();
23032448 System.exit(0);
23042449 if (parent != null)
23052450 {
....@@ -2334,6 +2479,14 @@
23342479 {
23352480 editWindow.refreshContents();
23362481 }
2482
+ else
2483
+ {
2484
+ if (manipWindow != null)
2485
+ {
2486
+ manipWindow.refreshContents();
2487
+ }
2488
+ }
2489
+
23372490 //if (parent != null)
23382491 //parent.refreshEditWindow();
23392492 }
....@@ -2476,13 +2629,13 @@
24762629 return retval;
24772630 }
24782631
2479
- void doEditDrag(ClickInfo info)
2632
+ void doEditDrag(ClickInfo info, boolean opposite)
24802633 {
24812634 switch (doSomething)
24822635 {
24832636 case 1: // '\001'
24842637 //super.
2485
- doEditDrag0(info);
2638
+ doEditDrag0(info, opposite);
24862639 break;
24872640
24882641 case 2: // '\002'
....@@ -2495,11 +2648,11 @@
24952648 {
24962649 //sel.hitSomething = childToDrag.hitSomething;
24972650 //childToDrag.doEditDrag(info);
2498
- sel.doEditDrag(info);
2651
+ sel.doEditDrag(info, opposite);
24992652 } else
25002653 {
25012654 //super.
2502
- doEditDrag0(info);
2655
+ doEditDrag0(info, opposite);
25032656 }
25042657 }
25052658 break;
....@@ -2609,6 +2762,18 @@
26092762 void GenNormalsS(boolean crease)
26102763 {
26112764 selection.GenNormals(crease);
2765
+// for (int i=0; i<selection.size(); i++)
2766
+// {
2767
+// Object3D selectee = (Object3D) selection.elementAt(i);
2768
+// selectee.GenNormals(crease);
2769
+// }
2770
+
2771
+ //Touch();
2772
+ }
2773
+
2774
+ void GenNormalsMeshS()
2775
+ {
2776
+ selection.GenNormalsMesh();
26122777 // for (int i=0; i<selection.size(); i++)
26132778 // {
26142779 // Object3D selectee = (Object3D) selection.elementAt(i);
....@@ -2749,6 +2914,24 @@
27492914 if (child == null)
27502915 continue;
27512916 child.GenNormals(crease);
2917
+// Children().release(i);
2918
+ }
2919
+ blockloop = false;
2920
+ }
2921
+
2922
+ void GenNormalsMesh()
2923
+ {
2924
+ if (blockloop)
2925
+ return;
2926
+
2927
+ blockloop = true;
2928
+ GenNormalsMesh0();
2929
+ for (int i = 0; i < Children().Size(); i++)
2930
+ {
2931
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2932
+ if (child == null)
2933
+ continue;
2934
+ child.GenNormalsMesh();
27522935 // Children().release(i);
27532936 }
27542937 blockloop = false;
....@@ -2921,6 +3104,15 @@
29213104 }
29223105 }
29233106
3107
+ void GenNormalsMesh0()
3108
+ {
3109
+ if (bRep != null)
3110
+ {
3111
+ bRep.GenerateNormalsMesh();
3112
+ Touch();
3113
+ }
3114
+ }
3115
+
29243116 void GenNormalsMINE0()
29253117 {
29263118 if (bRep != null)
....@@ -2982,6 +3174,33 @@
29823174 blockloop = false;
29833175 }
29843176
3177
+ void TransformChildren()
3178
+ {
3179
+ if (toParent != null)
3180
+ {
3181
+ for (int i=Size(); --i>=0;)
3182
+ {
3183
+ Object3D v = get(i);
3184
+
3185
+ if (v.toParent == null)
3186
+ {
3187
+ v.toParent = LA.newMatrix();
3188
+ v.fromParent = LA.newMatrix();
3189
+ }
3190
+
3191
+// LA.matConcat(v.toParent, toParent, v.toParent);
3192
+// LA.matConcat(fromParent, v.fromParent, v.fromParent);
3193
+ LA.matConcat(toParent, v.toParent, v.toParent);
3194
+ LA.matConcat(v.fromParent, fromParent, v.fromParent);
3195
+ }
3196
+
3197
+ toParent = null; // LA.matIdentity(toParent);
3198
+ fromParent = null; // LA.matIdentity(fromParent);
3199
+
3200
+ Touch();
3201
+ }
3202
+ }
3203
+
29853204 void TransformGeometry()
29863205 {
29873206 Object3D obj = this;
....@@ -3203,9 +3422,11 @@
32033422
32043423 BoundaryRep sup = bRep.support;
32053424 bRep.support = null;
3206
- BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
3425
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
32073426 // bRep.SplitInTwo(onlyone); // thread...
3208
- temprep.SplitInTwo(reduction34, onlyone);
3427
+
3428
+ while(temprep.SplitInTwo(reduction34, onlyone));
3429
+
32093430 bRep = temprep;
32103431 bRep.support = sup;
32113432 Touch();
....@@ -3342,7 +3563,8 @@
33423563 if (blockloop)
33433564 return;
33443565
3345
- if (marked || (bRep != null && material != null)) // borderline...
3566
+ if (//marked || // does not make sense
3567
+ (bRep != null || material != null)) // borderline...
33463568 live = h;
33473569
33483570 for (int i = 0; i < Size(); i++)
....@@ -3363,7 +3585,8 @@
33633585 return;
33643586
33653587 //if (bRep != null)
3366
- if (marked || (bRep != null && material != null)) // borderline...
3588
+ if (//marked || // does not make sense
3589
+ (bRep != null || material != null)) // borderline...
33673590 link2master = h;
33683591
33693592 for (int i = 0; i < Size(); i++)
....@@ -3383,7 +3606,8 @@
33833606 if (blockloop)
33843607 return;
33853608
3386
- if (marked || (bRep != null && material != null)) // borderline...
3609
+ if (//marked || // does not make sense
3610
+ (bRep != null || material != null)) // borderline...
33873611 hide = h;
33883612
33893613 for (int i = 0; i < Size(); i++)
....@@ -3403,7 +3627,7 @@
34033627 if (blockloop)
34043628 return;
34053629
3406
- if (bRep != null && material != null) // borderline...
3630
+ if (bRep != null || material != null) // borderline...
34073631 marked = h;
34083632
34093633 for (int i = 0; i < Size(); i++)
....@@ -3413,6 +3637,46 @@
34133637 continue;
34143638 blockloop = true;
34153639 child.MarkLeaves(h);
3640
+ blockloop = false;
3641
+ // release(i);
3642
+ }
3643
+ }
3644
+
3645
+ void RewindLeaves(boolean h)
3646
+ {
3647
+ if (blockloop)
3648
+ return;
3649
+
3650
+ if (bRep != null || material != null) // borderline...
3651
+ rewind = h;
3652
+
3653
+ for (int i = 0; i < Size(); i++)
3654
+ {
3655
+ Object3D child = (Object3D) get(i); // reserve(i);
3656
+ if (child == null)
3657
+ continue;
3658
+ blockloop = true;
3659
+ child.RewindLeaves(h);
3660
+ blockloop = false;
3661
+ // release(i);
3662
+ }
3663
+ }
3664
+
3665
+ void RandomLeaves(boolean h)
3666
+ {
3667
+ if (blockloop)
3668
+ return;
3669
+
3670
+ if (bRep != null || material != null) // borderline...
3671
+ random = h;
3672
+
3673
+ for (int i = 0; i < Size(); i++)
3674
+ {
3675
+ Object3D child = (Object3D) get(i); // reserve(i);
3676
+ if (child == null)
3677
+ continue;
3678
+ blockloop = true;
3679
+ child.RandomLeaves(h);
34163680 blockloop = false;
34173681 // release(i);
34183682 }
....@@ -3727,7 +3991,7 @@
37273991 if (child == null)
37283992 continue;
37293993
3730
- if (GrafreeD.RENDERME > 0)
3994
+ if (Grafreed.RENDERME > 0)
37313995 {
37323996 if (child instanceof Merge)
37333997 ((Merge)child).renderme();
....@@ -3878,7 +4142,7 @@
38784142 if (child == null)
38794143 continue;
38804144
3881
- if (GrafreeD.RENDERME > 0)
4145
+ if (Grafreed.RENDERME > 0)
38824146 {
38834147 if (child instanceof Merge)
38844148 ((Merge)child).renderme();
....@@ -4073,7 +4337,7 @@
40734337 if (child == null)
40744338 continue;
40754339
4076
- if (GrafreeD.RENDERME > 0)
4340
+ if (Grafreed.RENDERME > 0)
40774341 {
40784342 if (child instanceof Merge)
40794343 ((Merge)child).renderme();
....@@ -4186,6 +4450,55 @@
41864450 {
41874451 blockloop = true;
41884452 get(i).RepairShadow();
4453
+ blockloop = false;
4454
+ }
4455
+ }
4456
+
4457
+ void RepairSOV()
4458
+ {
4459
+ if (blockloop)
4460
+ return;
4461
+
4462
+ String texname = this.GetPigmentTexture();
4463
+
4464
+ if (texname.startsWith("sov"))
4465
+ {
4466
+ String[] s = texname.split("/");
4467
+
4468
+ String[] sname = s[1].split("Color.pn");
4469
+
4470
+ texname = sname[0];
4471
+
4472
+ if (sname.length > 1)
4473
+ {
4474
+ texname += "Color.jpg";
4475
+ }
4476
+
4477
+ this.SetPigmentTexture("sov/" + texname);
4478
+ }
4479
+
4480
+ texname = this.GetBumpTexture();
4481
+
4482
+ if (texname.startsWith("sov"))
4483
+ {
4484
+ String[] s = texname.split("/");
4485
+
4486
+ String[] sname = s[1].split("Bump.pn");
4487
+
4488
+ texname = sname[0];
4489
+
4490
+ if (sname.length > 1)
4491
+ {
4492
+ texname += "Bump.jpg";
4493
+ }
4494
+
4495
+ this.SetBumpTexture("sov/" + texname);
4496
+ }
4497
+
4498
+ for (int i=0; i<Size(); i++)
4499
+ {
4500
+ blockloop = true;
4501
+ get(i).RepairSOV();
41894502 blockloop = false;
41904503 }
41914504 }
....@@ -4680,7 +4993,7 @@
46804993
46814994 cTreePath SelectLeaf(int indexcount, boolean deselect)
46824995 {
4683
- if (hide)
4996
+ if (hide || dontselect)
46844997 return null;
46854998
46864999 if (count <= 0)
....@@ -4704,9 +5017,17 @@
47045017 }
47055018 }
47065019
5020
+ ObjEditor GetWindow()
5021
+ {
5022
+ if (editWindow != null)
5023
+ return editWindow;
5024
+
5025
+ return manipWindow;
5026
+ }
5027
+
47075028 cTreePath Select(int indexcount, boolean deselect)
47085029 {
4709
- if (hide)
5030
+ if (hide || dontselect)
47105031 return null;
47115032
47125033 if (count <= 0)
....@@ -4740,10 +5061,11 @@
47405061 if (leaf != null)
47415062 {
47425063 cTreePath tp = new cTreePath(this, leaf);
4743
- if (editWindow != null)
5064
+ ObjEditor window = GetWindow();
5065
+ if (window != null)
47445066 {
47455067 //System.out.println("editWindow = " + editWindow + " vs " + this);
4746
- editWindow.Select(tp, deselect, true);
5068
+ window.Select(tp, deselect, true);
47475069 }
47485070
47495071 return tp;
....@@ -4760,6 +5082,7 @@
47605082
47615083 if (child == null)
47625084 continue;
5085
+
47635086 if (child.HasTransparency() && child.size() != 0)
47645087 {
47655088 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4769,9 +5092,10 @@
47695092 if (leaf != null)
47705093 {
47715094 cTreePath tp = new cTreePath(this, leaf);
4772
- if (editWindow != null)
5095
+ ObjEditor window = GetWindow();
5096
+ if (window != null)
47735097 {
4774
- editWindow.Select(tp, deselect, true);
5098
+ window.Select(tp, deselect, true);
47755099 }
47765100
47775101 return tp;
....@@ -5158,10 +5482,34 @@
51585482
51595483 // System.out.println("Fullname = " + fullname);
51605484
5161
- if (fullname.name.indexOf(":") == -1)
5162
- return fullname.name;
5485
+ // Does not work on Windows due to C:
5486
+// if (fullname.name.indexOf(":") == -1)
5487
+// return fullname.name;
5488
+//
5489
+// return fullname.name.substring(0,fullname.name.indexOf(":"));
51635490
5164
- return fullname.name.substring(0,fullname.name.indexOf(":"));
5491
+ String[] split = fullname.name.split(":");
5492
+
5493
+ if (split.length == 0)
5494
+ {
5495
+ return "";
5496
+ }
5497
+
5498
+ if (split.length <= 2)
5499
+ {
5500
+ if (fullname.name.endsWith(":"))
5501
+ {
5502
+ // Windows
5503
+ return fullname.name.substring(0, fullname.name.length()-1);
5504
+ }
5505
+
5506
+ return split[0];
5507
+ }
5508
+
5509
+ // Windows
5510
+ assert(split.length == 4);
5511
+
5512
+ return split[0] + ":" + split[1];
51655513 }
51665514
51675515 static String GetBump(cTexture fullname)
....@@ -5170,10 +5518,38 @@
51705518 return "";
51715519
51725520 // 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());
5521
+ // Does not work on Windows due to C:
5522
+// if (fullname.name.indexOf(":") == -1)
5523
+// return "";
5524
+//
5525
+// return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5526
+ String[] split = fullname.name.split(":");
5527
+
5528
+ if (split.length == 0)
5529
+ {
5530
+ return "";
5531
+ }
5532
+
5533
+ if (split.length == 1)
5534
+ {
5535
+ return "";
5536
+ }
5537
+
5538
+ if (split.length == 2)
5539
+ {
5540
+ if (fullname.name.endsWith(":"))
5541
+ {
5542
+ // Windows
5543
+ return "";
5544
+ }
5545
+
5546
+ return split[1];
5547
+ }
5548
+
5549
+ // Windows
5550
+ assert(split.length == 4);
5551
+
5552
+ return split[2] + ":" + split[3];
51775553 }
51785554
51795555 String GetPigmentTexture()
....@@ -5247,7 +5623,7 @@
52475623 System.out.print("; textures = " + textures);
52485624 System.out.println("; usedtextures = " + usedtextures);
52495625
5250
- if (GetTextures() == null)
5626
+ if (GetTextures() == null) // What is that??
52515627 GetTextures().name = ":";
52525628
52535629 String texname = tex;
....@@ -5278,6 +5654,43 @@
52785654 child.ResetPigmentTexture();
52795655 blockloop = false;
52805656 }
5657
+ }
5658
+
5659
+ UUID GetUUID()
5660
+ {
5661
+ if (uuid == null)
5662
+ {
5663
+ // Serial
5664
+ uuid = UUID.randomUUID();
5665
+ }
5666
+
5667
+ return uuid;
5668
+ }
5669
+
5670
+ Object3D GetObject(UUID uid)
5671
+ {
5672
+ if (blockloop)
5673
+ return null;
5674
+
5675
+ if (GetUUID().equals(uid))
5676
+ return this;
5677
+
5678
+ int nb = Size();
5679
+ for (int i = 0; i < nb; i++)
5680
+ {
5681
+ Object3D child = (Object3D) get(i);
5682
+
5683
+ if (child == null)
5684
+ continue;
5685
+
5686
+ blockloop = true;
5687
+ Object3D obj = child.GetObject(uid);
5688
+ blockloop = false;
5689
+ if (obj != null)
5690
+ return obj;
5691
+ }
5692
+
5693
+ return null;
52815694 }
52825695
52835696 void SetBumpTexture(String tex)
....@@ -5324,12 +5737,23 @@
53245737 boolean NeedSupport()
53255738 {
53265739 return
5327
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5740
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
53285741 // PROBLEM with CROWD!!
5329
- && (Globals.DrawMode() == iCameraPane.SHADOW || Globals.CROWD);
5742
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
53305743 }
53315744
53325745 static boolean DEBUG_SELECTION = false;
5746
+
5747
+ boolean IsLive()
5748
+ {
5749
+ if (live)
5750
+ return true;
5751
+
5752
+ if (parent == null)
5753
+ return false;
5754
+
5755
+ return parent.IsLive();
5756
+ }
53335757
53345758 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
53355759 {
....@@ -5341,7 +5765,7 @@
53415765 }
53425766
53435767 if (display.DrawMode() == iCameraPane.SELECTION &&
5344
- hide)
5768
+ (hide || dontselect))
53455769 return;
53465770
53475771 if (name != null && name.contains("sclera"))
....@@ -5392,7 +5816,7 @@
53925816 support = support;
53935817
53945818 //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);
5819
+ boolean usecalllists = !IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
53965820
53975821 if (!usecalllists && bRep != null && bRep.displaylist > 0)
53985822 {
....@@ -5412,10 +5836,12 @@
54125836 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
54135837
54145838 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5415
- (touched || (bRep != null && bRep.displaylist <= 0)))
5839
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5840
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
54165841 {
54175842 Globals.lighttouched = true;
54185843 } // all panes...
5844
+
54195845 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
54205846 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
54215847 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5543,6 +5969,7 @@
55435969 if (GetBRep() != null)
55445970 {
55455971 display.NextIndex();
5972
+
55465973 // vertex color conflict : gl.glCallList(list);
55475974 DrawNode(display, root, selected);
55485975 if (this instanceof BezierPatch)
....@@ -5583,7 +6010,28 @@
55836010 tex = GetTextures();
55846011 }
55856012
5586
- display.BindTextures(tex, texres);
6013
+ boolean failedPigment = false;
6014
+ boolean failedBump = false;
6015
+
6016
+ try
6017
+ {
6018
+ display.BindPigmentTexture(tex, texres);
6019
+ }
6020
+ catch (Exception e)
6021
+ {
6022
+ System.err.println("FAILED: " + this);
6023
+ failedPigment = true;
6024
+ }
6025
+
6026
+ try
6027
+ {
6028
+ display.BindBumpTexture(tex, texres);
6029
+ }
6030
+ catch (Exception e)
6031
+ {
6032
+ //System.err.println("FAILED: " + this);
6033
+ failedBump = true;
6034
+ }
55876035
55886036 if (!compiled)
55896037 {
....@@ -5605,7 +6053,11 @@
56056053 }
56066054 }
56076055
5608
- display.ReleaseTextures(tex);
6056
+ if (!failedBump)
6057
+ display.ReleaseBumpTexture(tex);
6058
+
6059
+ if (!failedPigment)
6060
+ display.ReleasePigmentTexture(tex);
56096061
56106062 display.PopMaterial(this, selected);
56116063 }
....@@ -5734,6 +6186,9 @@
57346186
57356187 void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57366188 {
6189
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6190
+ return;
6191
+
57376192 if (hide)
57386193 return;
57396194 // shadow optimisation
....@@ -5859,6 +6314,9 @@
58596314 if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
58606315 return; // no shadow for transparent objects
58616316
6317
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6318
+ return;
6319
+
58626320 if (hide)
58636321 return;
58646322
....@@ -5972,6 +6430,11 @@
59726430 // dec 2012
59736431 new Exception().printStackTrace();
59746432 return;
6433
+ }
6434
+
6435
+ if (dontselect)
6436
+ {
6437
+ //bRep.GenerateNormalsMINE();
59756438 }
59766439
59776440 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -6824,7 +7287,7 @@
68247287 spot.translate(32, 32);
68257288 spotw = spot.x + spot.width;
68267289 spoth = spot.y + spot.height;
6827
- info.g.setColor(Color.blue);
7290
+ info.g.setColor(Color.cyan);
68287291 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
68297292 // if (CameraPane.Xmin > spot.x)
68307293 // {
....@@ -6842,11 +7305,12 @@
68427305 // {
68437306 // CameraPane.Ymax = spoth;
68447307 // }
6845
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
6846
- info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7308
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7309
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
68477310 spot.translate(0, -32);
6848
- info.g.setColor(Color.green);
7311
+ info.g.setColor(Color.yellow);
68497312 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7313
+ info.g.setColor(Color.green);
68507314 // if (CameraPane.Xmin > spot.x)
68517315 // {
68527316 // CameraPane.Xmin = spot.x;
....@@ -6863,8 +7327,8 @@
68637327 // {
68647328 // CameraPane.Ymax = spoth;
68657329 // }
6866
- info.g.drawArc(boundary.x, boundary.y,
6867
- boundary.width, boundary.height, 0, 360);
7330
+ info.g.drawArc(boundary.x + info.DX, boundary.y + info.DY,
7331
+ (int)(boundary.width * info.W), (int)(boundary.height * info.W), 0, 360);
68687332 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
68697333 // if (CameraPane.Xmin > boundary.x)
68707334 // {
....@@ -6898,7 +7362,7 @@
68987362 startX = info.x;
68997363 startY = info.y;
69007364
6901
- hitSomething = 0;
7365
+ hitSomething = -1;
69027366 cVector origin = new cVector();
69037367 //LA.xformPos(origin, toParent, origin);
69047368 Rectangle spot = new Rectangle();
....@@ -6931,7 +7395,7 @@
69317395 }
69327396
69337397 //System.out.println("info.modifiers = " + info.modifiers);
6934
- modified = (info.modifiers & CameraPane.META) != 0;
7398
+ modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
69357399 //System.out.println("modified = " + modified);
69367400 //new Exception().printStackTrace();
69377401 //viewCode = info.pane.renderCamera.viewCode;
....@@ -6959,7 +7423,7 @@
69597423 return true;
69607424 }
69617425
6962
- void doEditDrag0(ClickInfo info)
7426
+ void doEditDrag0(ClickInfo info, boolean opposite)
69637427 {
69647428 if (hitSomething == 0)
69657429 {
....@@ -6974,6 +7438,7 @@
69747438 //System.out.println("hitSomething = " + hitSomething);
69757439
69767440 double scale = 0.005f * info.camera.Distance();
7441
+
69777442 cVector xlate = new cVector();
69787443 //cVector xlate2 = new cVector();
69797444 switch (hitSomething)
....@@ -6986,7 +7451,7 @@
69867451
69877452 scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
69887453
6989
- if (modified)
7454
+ if (modified || opposite)
69907455 {
69917456 //assert(false);
69927457 /*
....@@ -7080,6 +7545,7 @@
70807545
70817546 if (modified)
70827547 {
7548
+ // Rotate 90 degrees
70837549 angle /= (Math.PI / 4);
70847550 angle = Math.floor(angle + 0.5);
70857551 angle *= (Math.PI / 4);
....@@ -7121,24 +7587,27 @@
71217587
71227588 case hitScale: // scale
71237589 double hScale = (double) (info.x - centerPt.x) / 32;
7590
+ double sign = 1;
7591
+ if (hScale < 0)
7592
+ {
7593
+ sign = -1;
7594
+ }
7595
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
71247596 if (hScale < 0.01)
71257597 {
7126
- hScale = 0.01;
7598
+ //hScale = 0.01;
71277599 }
7128
- hScale = Math.pow(hScale, scale * 50);
7129
- if (hScale < 0.01)
7130
- {
7131
- hScale = 0.01;
7132
- }
7600
+
71337601 double vScale = (double) (info.y - centerPt.y) / 32;
7134
- if (vScale < 0.01)
7602
+ sign = 1;
7603
+ if (vScale < 0)
71357604 {
7136
- vScale = 0.01;
7605
+ sign = -1;
71377606 }
7138
- vScale = Math.pow(vScale, scale * 50);
7607
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
71397608 if (vScale < 0.01)
71407609 {
7141
- vScale = 0.01;
7610
+ //vScale = 0.01;
71427611 }
71437612 LA.matCopy(startMat, toParent);
71447613 /**/
....@@ -7149,39 +7618,47 @@
71497618 }
71507619 /**/
71517620
7621
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7622
+
7623
+ if (totalScale < 0.01)
7624
+ {
7625
+ totalScale = 0.01;
7626
+ }
7627
+
71527628 switch (info.pane.RenderCamera().viewCode)
71537629 {
71547630 case 3: // '\001'
7155
- if (modified)
7631
+ if (modified || opposite)
71567632 {
71577633 //LA.matScale(toParent, 1, hScale, vScale);
7158
- LA.matScale(toParent, vScale, 1, 1);
7634
+ LA.matScale(toParent, totalScale, 1, 1);
71597635 } // vScale, 1);
71607636 else
71617637 {
7162
- LA.matScale(toParent, vScale, vScale, vScale);
7638
+ // EXCEPTION!
7639
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
71637640 } // vScale, 1);
71647641 break;
71657642
71667643 case 2: // '\002'
7167
- if (modified)
7644
+ if (modified || opposite)
71687645 {
71697646 //LA.matScale(toParent, hScale, 1, vScale);
7170
- LA.matScale(toParent, 1, vScale, 1);
7647
+ LA.matScale(toParent, 1, totalScale, 1);
71717648 } else
71727649 {
7173
- LA.matScale(toParent, vScale, 1, vScale);
7650
+ LA.matScale(toParent, totalScale, 1, totalScale);
71747651 }
71757652 break;
71767653
71777654 case 1: // '\003'
7178
- if (modified)
7655
+ if (modified || opposite)
71797656 {
71807657 //LA.matScale(toParent, hScale, vScale, 1);
7181
- LA.matScale(toParent, 1, 1, vScale);
7658
+ LA.matScale(toParent, 1, 1, totalScale);
71827659 } else
71837660 {
7184
- LA.matScale(toParent, vScale, vScale, 1);
7661
+ LA.matScale(toParent, totalScale, totalScale, 1);
71857662 }
71867663 break;
71877664 }
....@@ -7314,14 +7791,22 @@
73147791 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
73157792 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
73167793 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7794
+
7795
+ String objname;
7796
+
73177797 if (false) //parent != null)
73187798 {
7319
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7799
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
73207800 } else
73217801 {
7322
- return GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ") ")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ +System.identityHashCode(this);
7802
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
73237803 } // + super.toString();
73247804 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
7805
+
7806
+ if (!Globals.ADVANCED)
7807
+ return objname;
7808
+
7809
+ return objname + " " + System.identityHashCode(this);
73257810 }
73267811
73277812 public int hashCode()
....@@ -7377,6 +7862,7 @@
73777862 objectUI.closeUI();
73787863 if (editWindow != null)
73797864 {
7865
+ editWindow.ctrlPanel.FlushUI();
73807866 editWindow.refreshContents();
73817867 } // ? new
73827868 objectUI = null;
....@@ -7385,6 +7871,10 @@
73857871 {
73867872 editWindow = null;
73877873 } // ?
7874
+ }
7875
+ else
7876
+ {
7877
+ //editWindow.closeUI();
73887878 }
73897879 }
73907880
....@@ -7397,7 +7887,7 @@
73977887 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
73987888
73997889 Object3D /*Composite*/ parent;
7400
- Object3D /*Composite*/ fileparent;
7890
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
74017891
74027892 double[][] toParent; // dynamic matrix
74037893 double[][] fromParent;
....@@ -7512,7 +8002,7 @@
75128002 {
75138003 assert(bRep != null);
75148004 if (!(support instanceof GenericJoint)) // support.bRep != null)
7515
- GrafreeD.Assert(support.bRep == bRep.support);
8005
+ Grafreed.Assert(support.bRep == bRep.support);
75168006 }
75178007 else
75188008 {
....@@ -7543,6 +8033,10 @@
75438033 }
75448034
75458035 transient ObjEditor editWindow;
8036
+ transient ObjEditor manipWindow;
8037
+
8038
+ transient boolean pinned;
8039
+
75468040 transient ObjectUI objectUI;
75478041 public static int povDepth = 0;
75488042 private static cVector tbMin = new cVector();
....@@ -7561,9 +8055,9 @@
75618055 private static cVector edge2 = new cVector();
75628056 //private static cVector norm = new cVector();
75638057 /*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;
8058
+ static final int hitCenter = 1;
8059
+ static final int hitScale = 2;
8060
+ static final int hitRotate = 3;
75678061 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
75688062 /*transient*/ private Point centerPt;
75698063 /*transient*/ private int startX;