Normand Briere
2019-07-14 bc829f47837b5a001f911542140b0b8e63c2bb0c
Object3D.java
....@@ -14,11 +14,20 @@
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;
24
+
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
+ //
2231
2332 ScriptNode scriptnode;
2433
....@@ -100,64 +109,170 @@
100109
101110 // transient boolean reduced; // for morph reduction
102111
103
-transient com.bulletphysics.linearmath.Transform cache; // for fast merge
104
-transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
112
+ transient com.bulletphysics.linearmath.Transform cache; // for fast merge
113
+ transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
105114
106
-transient Object3D transientsupport; // for cloning
107
-transient boolean transientlink2master;
115
+ transient Object3D transientsupport; // for cloning
116
+ transient boolean transientlink2master;
108117
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)
118
+ void SaveSupports()
121119 {
122
- bRep.SaveSupports();
120
+ if (blockloop)
121
+ return;
122
+
123
+ transientsupport = support;
124
+ transientlink2master = link2master;
125
+
126
+ support = null;
127
+ link2master = false;
128
+
129
+ if (bRep != null)
130
+ {
131
+ bRep.SaveSupports();
132
+ }
133
+
134
+ for (int i = 0; i < Size(); i++)
135
+ {
136
+ Object3D child = (Object3D) get(i);
137
+ if (child == null)
138
+ continue;
139
+ blockloop = true;
140
+ child.SaveSupports();
141
+ blockloop = false;
142
+ }
123143 }
124
-
125
- for (int i = 0; i < Size(); i++)
144
+
145
+ void RestoreSupports()
126146 {
127
- Object3D child = (Object3D) get(i);
128
- if (child == null)
129
- continue;
147
+ if (blockloop)
148
+ return;
149
+
150
+ support = transientsupport;
151
+ link2master = transientlink2master;
152
+ transientsupport = null;
153
+ transientlink2master = false;
154
+
155
+ if (bRep != null)
156
+ {
157
+ bRep.RestoreSupports();
158
+ }
159
+
160
+ for (int i = 0; i < Size(); i++)
161
+ {
162
+ Object3D child = (Object3D) get(i);
163
+ if (child == null)
164
+ continue;
165
+ blockloop = true;
166
+ child.RestoreSupports();
167
+ blockloop = false;
168
+ }
169
+ }
170
+
171
+ void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
172
+ {
173
+ Object3D o;
174
+
175
+ if (hashtable.containsKey(GetUUID()))
176
+ {
177
+ o = hashtable.get(GetUUID());
178
+
179
+ Grafreed.Assert(this.bRep == o.bRep);
180
+ //if (this.bRep != null)
181
+ // assert(this.bRep.support == o.transientrep);
182
+ if (this.support != null)
183
+ assert(this.support.bRep == o.transientrep);
184
+ }
185
+ else
186
+ {
187
+ o = new Object3D("copy of " + this.name);
188
+
189
+ hashtable.put(GetUUID(), o);
190
+ }
191
+
192
+ if (!blockloop)
193
+ {
194
+ blockloop = true;
195
+
196
+ for (int i=0; i<Size(); i++)
197
+ {
198
+ get(i).ExtractBigData(hashtable);
199
+ }
200
+
201
+ blockloop = false;
202
+ }
203
+
204
+ ExtractBigData(o);
205
+ }
206
+
207
+ void ExtractBigData(Object3D o)
208
+ {
209
+ if (o.bRep != null)
210
+ Grafreed.Assert(o.bRep == this.bRep);
211
+
212
+ o.bRep = this.bRep;
213
+// July 2019 if (this.bRep != null)
214
+// {
215
+// o.transientrep = this.bRep.support;
216
+// o.bRep.support = null;
217
+// }
218
+
219
+ if (this.support != null)
220
+ {
221
+ if (o.transientrep != null)
222
+ Grafreed.Assert(o.transientrep == this.support.bRep);
223
+
224
+ o.transientrep = this.support.bRep;
225
+ this.support.bRep = null;
226
+ }
227
+
228
+ // o.support = this.support;
229
+ // o.fileparent = this.fileparent;
230
+ // if (this.bRep != null)
231
+ // o.bRep = this.bRep.support;
232
+
233
+ this.bRep = null;
234
+ // if (this.bRep != null)
235
+ // this.bRep.support = null;
236
+ // this.support = null;
237
+ // this.fileparent = null;
238
+ }
239
+
240
+ void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
241
+ {
242
+ if (!hashtable.containsKey(GetUUID()))
243
+ return;
244
+
245
+ Object3D o = hashtable.get(GetUUID());
246
+
247
+ RestoreBigData(o);
248
+
249
+ if (blockloop)
250
+ return;
251
+
130252 blockloop = true;
131
- child.SaveSupports();
253
+
254
+ //hashtable.remove(GetUUID());
255
+
256
+ for (int i=0; i<Size(); i++)
257
+ {
258
+ get(i).RestoreBigData(hashtable);
259
+ }
260
+
132261 blockloop = false;
133262 }
134
-}
135263
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)
264
+ void RestoreBigData(Object3D o)
147265 {
148
- bRep.RestoreSupports();
266
+ this.bRep = o.bRep;
267
+ if (this.support != null && o.transientrep != null)
268
+ {
269
+ this.support.bRep = o.transientrep;
270
+ }
271
+// July 2019 if (this.bRep != null)
272
+// this.bRep.support = o.transientrep;
273
+ // this.support = o.support;
274
+ // this.fileparent = o.fileparent;
149275 }
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
-}
161276
162277 // MOCAP SUPPORT
163278 double tx,ty,tz,rx,ry,rz;
....@@ -300,6 +415,7 @@
300415 }
301416
302417 boolean live = false;
418
+ boolean dontselect = false;
303419 boolean hide = false;
304420 boolean link2master = false; // performs reset support/master at each frame
305421 boolean marked = false; // animation node
....@@ -481,12 +597,14 @@
481597 toParent = LA.newMatrix();
482598 fromParent = LA.newMatrix();
483599 }
600
+
484601 if (toParentMarked == null)
485602 {
486603 if (maxcount != 1)
487604 {
488605 new Exception().printStackTrace();
489606 }
607
+
490608 toParentMarked = LA.newMatrix();
491609 fromParentMarked = LA.newMatrix();
492610 }
....@@ -774,7 +892,7 @@
774892 if (step == 0)
775893 step = 1;
776894 if (maxcount == 0)
777
- maxcount = 2048; // 4;
895
+ maxcount = 128; // 2048; // 4;
778896 // if (acceleration == 0)
779897 // acceleration = 10;
780898 if (delay == 0) // serial
....@@ -797,7 +915,7 @@
797915
798916 if (marked && Globals.isLIVE() && live &&
799917 //TEMP21aug2018
800
- Globals.DrawMode() == iCameraPane.SHADOW &&
918
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
801919 currentframe != Globals.framecount)
802920 {
803921 currentframe = Globals.framecount;
....@@ -809,7 +927,8 @@
809927
810928 boolean changedir = random && Math.random() < 0.01; // && !link2master;
811929
812
- if (transformcount*factor > maxcount || (step == 1 && changedir))
930
+ if (transformcount*factor >= maxcount && (rewind || random) ||
931
+ (step == 1 && changedir))
813932 {
814933 countdown = 1;
815934 delay = speedup?8:1;
....@@ -881,6 +1000,7 @@
8811000 if (material == null || material.multiply)
8821001 return true;
8831002
1003
+ // Transparent objects are dynamic because we have to sort the triangles.
8841004 return material.opacity > 0.99;
8851005 }
8861006
....@@ -912,6 +1032,11 @@
9121032 fromParent = null; // LA.newMatrix();
9131033 bRep = null; // new BoundaryRep();
9141034
1035
+ if (oname != null && oname.equals("LeftHand"))
1036
+ {
1037
+ name = oname;
1038
+ }
1039
+
9151040 /*
9161041 float hue = (float)Math.random();
9171042 Color col;
....@@ -954,7 +1079,7 @@
9541079
9551080 public Object clone()
9561081 {
957
- return GrafreeD.clone(this);
1082
+ return Grafreed.clone(this);
9581083 }
9591084
9601085 Object3D copyExpand()
....@@ -1276,6 +1401,7 @@
12761401 toParent = LA.newMatrix();
12771402 fromParent = LA.newMatrix();
12781403 }
1404
+
12791405 LA.matCopy(other.toParent, toParent);
12801406 LA.matCopy(other.fromParent, fromParent);
12811407
....@@ -1470,7 +1596,7 @@
14701596 BoundaryRep.SEUIL = other.material.cameralight;
14711597
14721598 // Set default to 0.1
1473
- BoundaryRep.SEUIL /= 2;
1599
+ BoundaryRep.SEUIL /= 4; // 2;
14741600 System.out.println("SEUIL = " + BoundaryRep.SEUIL);
14751601 }
14761602
....@@ -1729,7 +1855,7 @@
17291855 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17301856 o.bRep = transientrep;
17311857 if (clone)
1732
- o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
1858
+ o.bRep = (BoundaryRep) Grafreed.clone(transientrep);
17331859 o.CreateMaterial();
17341860 o.SetAttributes(this, -1);
17351861 //parent
....@@ -1742,7 +1868,7 @@
17421868 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17431869 o.bRep = bRep;
17441870 if (clone)
1745
- o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
1871
+ o.bRep = (BoundaryRep) Grafreed.clone(bRep);
17461872 o.CreateMaterial();
17471873 //o.overwriteThis(this, -1);
17481874 o.SetAttributes(this, -1);
....@@ -1829,12 +1955,15 @@
18291955 if (obj.name == null)
18301956 continue; // can't be a null one
18311957
1958
+ // Try perfect match first.
18321959 if (n.equals(obj.name))
18331960 {
18341961 theobj = obj;
18351962 count++;
18361963 }
18371964 }
1965
+
1966
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18381967
18391968 if (count != 1)
18401969 for (int i=Size(); --i>=0;)
....@@ -2294,12 +2423,17 @@
22942423 }
22952424 */
22962425 }
2426
+ else
2427
+ {
2428
+ //((ObjEditor)editWindow).SetupUI2(null);
2429
+ }
22972430 }
22982431
22992432 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
23002433 {
23012434 if (newWindow)
23022435 {
2436
+ new Exception().printStackTrace();
23032437 System.exit(0);
23042438 if (parent != null)
23052439 {
....@@ -2334,6 +2468,14 @@
23342468 {
23352469 editWindow.refreshContents();
23362470 }
2471
+ else
2472
+ {
2473
+ if (manipWindow != null)
2474
+ {
2475
+ manipWindow.refreshContents();
2476
+ }
2477
+ }
2478
+
23372479 //if (parent != null)
23382480 //parent.refreshEditWindow();
23392481 }
....@@ -2476,13 +2618,13 @@
24762618 return retval;
24772619 }
24782620
2479
- void doEditDrag(ClickInfo info)
2621
+ void doEditDrag(ClickInfo info, boolean opposite)
24802622 {
24812623 switch (doSomething)
24822624 {
24832625 case 1: // '\001'
24842626 //super.
2485
- doEditDrag0(info);
2627
+ doEditDrag0(info, opposite);
24862628 break;
24872629
24882630 case 2: // '\002'
....@@ -2495,11 +2637,11 @@
24952637 {
24962638 //sel.hitSomething = childToDrag.hitSomething;
24972639 //childToDrag.doEditDrag(info);
2498
- sel.doEditDrag(info);
2640
+ sel.doEditDrag(info, opposite);
24992641 } else
25002642 {
25012643 //super.
2502
- doEditDrag0(info);
2644
+ doEditDrag0(info, opposite);
25032645 }
25042646 }
25052647 break;
....@@ -2609,6 +2751,18 @@
26092751 void GenNormalsS(boolean crease)
26102752 {
26112753 selection.GenNormals(crease);
2754
+// for (int i=0; i<selection.size(); i++)
2755
+// {
2756
+// Object3D selectee = (Object3D) selection.elementAt(i);
2757
+// selectee.GenNormals(crease);
2758
+// }
2759
+
2760
+ //Touch();
2761
+ }
2762
+
2763
+ void GenNormalsMeshS()
2764
+ {
2765
+ selection.GenNormalsMesh();
26122766 // for (int i=0; i<selection.size(); i++)
26132767 // {
26142768 // Object3D selectee = (Object3D) selection.elementAt(i);
....@@ -2749,6 +2903,24 @@
27492903 if (child == null)
27502904 continue;
27512905 child.GenNormals(crease);
2906
+// Children().release(i);
2907
+ }
2908
+ blockloop = false;
2909
+ }
2910
+
2911
+ void GenNormalsMesh()
2912
+ {
2913
+ if (blockloop)
2914
+ return;
2915
+
2916
+ blockloop = true;
2917
+ GenNormalsMesh0();
2918
+ for (int i = 0; i < Children().Size(); i++)
2919
+ {
2920
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2921
+ if (child == null)
2922
+ continue;
2923
+ child.GenNormalsMesh();
27522924 // Children().release(i);
27532925 }
27542926 blockloop = false;
....@@ -2921,6 +3093,15 @@
29213093 }
29223094 }
29233095
3096
+ void GenNormalsMesh0()
3097
+ {
3098
+ if (bRep != null)
3099
+ {
3100
+ bRep.GenerateNormalsMesh();
3101
+ Touch();
3102
+ }
3103
+ }
3104
+
29243105 void GenNormalsMINE0()
29253106 {
29263107 if (bRep != null)
....@@ -2982,6 +3163,33 @@
29823163 blockloop = false;
29833164 }
29843165
3166
+ void TransformChildren()
3167
+ {
3168
+ if (toParent != null)
3169
+ {
3170
+ for (int i=Size(); --i>=0;)
3171
+ {
3172
+ Object3D v = get(i);
3173
+
3174
+ if (v.toParent == null)
3175
+ {
3176
+ v.toParent = LA.newMatrix();
3177
+ v.fromParent = LA.newMatrix();
3178
+ }
3179
+
3180
+// LA.matConcat(v.toParent, toParent, v.toParent);
3181
+// LA.matConcat(fromParent, v.fromParent, v.fromParent);
3182
+ LA.matConcat(toParent, v.toParent, v.toParent);
3183
+ LA.matConcat(v.fromParent, fromParent, v.fromParent);
3184
+ }
3185
+
3186
+ toParent = null; // LA.matIdentity(toParent);
3187
+ fromParent = null; // LA.matIdentity(fromParent);
3188
+
3189
+ Touch();
3190
+ }
3191
+ }
3192
+
29853193 void TransformGeometry()
29863194 {
29873195 Object3D obj = this;
....@@ -3203,9 +3411,11 @@
32033411
32043412 BoundaryRep sup = bRep.support;
32053413 bRep.support = null;
3206
- BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
3414
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
32073415 // bRep.SplitInTwo(onlyone); // thread...
3208
- temprep.SplitInTwo(reduction34, onlyone);
3416
+
3417
+ while(temprep.SplitInTwo(reduction34, onlyone));
3418
+
32093419 bRep = temprep;
32103420 bRep.support = sup;
32113421 Touch();
....@@ -3342,7 +3552,8 @@
33423552 if (blockloop)
33433553 return;
33443554
3345
- if (marked || (bRep != null && material != null)) // borderline...
3555
+ if (//marked || // does not make sense
3556
+ (bRep != null || material != null)) // borderline...
33463557 live = h;
33473558
33483559 for (int i = 0; i < Size(); i++)
....@@ -3363,7 +3574,8 @@
33633574 return;
33643575
33653576 //if (bRep != null)
3366
- if (marked || (bRep != null && material != null)) // borderline...
3577
+ if (//marked || // does not make sense
3578
+ (bRep != null || material != null)) // borderline...
33673579 link2master = h;
33683580
33693581 for (int i = 0; i < Size(); i++)
....@@ -3383,7 +3595,8 @@
33833595 if (blockloop)
33843596 return;
33853597
3386
- if (marked || (bRep != null && material != null)) // borderline...
3598
+ if (//marked || // does not make sense
3599
+ (bRep != null || material != null)) // borderline...
33873600 hide = h;
33883601
33893602 for (int i = 0; i < Size(); i++)
....@@ -3403,7 +3616,7 @@
34033616 if (blockloop)
34043617 return;
34053618
3406
- if (bRep != null && material != null) // borderline...
3619
+ if (bRep != null || material != null) // borderline...
34073620 marked = h;
34083621
34093622 for (int i = 0; i < Size(); i++)
....@@ -3413,6 +3626,46 @@
34133626 continue;
34143627 blockloop = true;
34153628 child.MarkLeaves(h);
3629
+ blockloop = false;
3630
+ // release(i);
3631
+ }
3632
+ }
3633
+
3634
+ void RewindLeaves(boolean h)
3635
+ {
3636
+ if (blockloop)
3637
+ return;
3638
+
3639
+ if (bRep != null || material != null) // borderline...
3640
+ rewind = h;
3641
+
3642
+ for (int i = 0; i < Size(); i++)
3643
+ {
3644
+ Object3D child = (Object3D) get(i); // reserve(i);
3645
+ if (child == null)
3646
+ continue;
3647
+ blockloop = true;
3648
+ child.RewindLeaves(h);
3649
+ blockloop = false;
3650
+ // release(i);
3651
+ }
3652
+ }
3653
+
3654
+ void RandomLeaves(boolean h)
3655
+ {
3656
+ if (blockloop)
3657
+ return;
3658
+
3659
+ if (bRep != null || material != null) // borderline...
3660
+ random = h;
3661
+
3662
+ for (int i = 0; i < Size(); i++)
3663
+ {
3664
+ Object3D child = (Object3D) get(i); // reserve(i);
3665
+ if (child == null)
3666
+ continue;
3667
+ blockloop = true;
3668
+ child.RandomLeaves(h);
34163669 blockloop = false;
34173670 // release(i);
34183671 }
....@@ -3727,7 +3980,7 @@
37273980 if (child == null)
37283981 continue;
37293982
3730
- if (GrafreeD.RENDERME > 0)
3983
+ if (Grafreed.RENDERME > 0)
37313984 {
37323985 if (child instanceof Merge)
37333986 ((Merge)child).renderme();
....@@ -3878,7 +4131,7 @@
38784131 if (child == null)
38794132 continue;
38804133
3881
- if (GrafreeD.RENDERME > 0)
4134
+ if (Grafreed.RENDERME > 0)
38824135 {
38834136 if (child instanceof Merge)
38844137 ((Merge)child).renderme();
....@@ -4073,7 +4326,7 @@
40734326 if (child == null)
40744327 continue;
40754328
4076
- if (GrafreeD.RENDERME > 0)
4329
+ if (Grafreed.RENDERME > 0)
40774330 {
40784331 if (child instanceof Merge)
40794332 ((Merge)child).renderme();
....@@ -4186,6 +4439,55 @@
41864439 {
41874440 blockloop = true;
41884441 get(i).RepairShadow();
4442
+ blockloop = false;
4443
+ }
4444
+ }
4445
+
4446
+ void RepairSOV()
4447
+ {
4448
+ if (blockloop)
4449
+ return;
4450
+
4451
+ String texname = this.GetPigmentTexture();
4452
+
4453
+ if (texname.startsWith("sov"))
4454
+ {
4455
+ String[] s = texname.split("/");
4456
+
4457
+ String[] sname = s[1].split("Color.pn");
4458
+
4459
+ texname = sname[0];
4460
+
4461
+ if (sname.length > 1)
4462
+ {
4463
+ texname += "Color.jpg";
4464
+ }
4465
+
4466
+ this.SetPigmentTexture("sov/" + texname);
4467
+ }
4468
+
4469
+ texname = this.GetBumpTexture();
4470
+
4471
+ if (texname.startsWith("sov"))
4472
+ {
4473
+ String[] s = texname.split("/");
4474
+
4475
+ String[] sname = s[1].split("Bump.pn");
4476
+
4477
+ texname = sname[0];
4478
+
4479
+ if (sname.length > 1)
4480
+ {
4481
+ texname += "Bump.jpg";
4482
+ }
4483
+
4484
+ this.SetBumpTexture("sov/" + texname);
4485
+ }
4486
+
4487
+ for (int i=0; i<Size(); i++)
4488
+ {
4489
+ blockloop = true;
4490
+ get(i).RepairSOV();
41894491 blockloop = false;
41904492 }
41914493 }
....@@ -4680,7 +4982,7 @@
46804982
46814983 cTreePath SelectLeaf(int indexcount, boolean deselect)
46824984 {
4683
- if (hide)
4985
+ if (hide || dontselect)
46844986 return null;
46854987
46864988 if (count <= 0)
....@@ -4704,9 +5006,17 @@
47045006 }
47055007 }
47065008
5009
+ ObjEditor GetWindow()
5010
+ {
5011
+ if (editWindow != null)
5012
+ return editWindow;
5013
+
5014
+ return manipWindow;
5015
+ }
5016
+
47075017 cTreePath Select(int indexcount, boolean deselect)
47085018 {
4709
- if (hide)
5019
+ if (hide || dontselect)
47105020 return null;
47115021
47125022 if (count <= 0)
....@@ -4740,10 +5050,11 @@
47405050 if (leaf != null)
47415051 {
47425052 cTreePath tp = new cTreePath(this, leaf);
4743
- if (editWindow != null)
5053
+ ObjEditor window = GetWindow();
5054
+ if (window != null)
47445055 {
47455056 //System.out.println("editWindow = " + editWindow + " vs " + this);
4746
- editWindow.Select(tp, deselect, true);
5057
+ window.Select(tp, deselect, true);
47475058 }
47485059
47495060 return tp;
....@@ -4760,6 +5071,7 @@
47605071
47615072 if (child == null)
47625073 continue;
5074
+
47635075 if (child.HasTransparency() && child.size() != 0)
47645076 {
47655077 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4769,9 +5081,10 @@
47695081 if (leaf != null)
47705082 {
47715083 cTreePath tp = new cTreePath(this, leaf);
4772
- if (editWindow != null)
5084
+ ObjEditor window = GetWindow();
5085
+ if (window != null)
47735086 {
4774
- editWindow.Select(tp, deselect, true);
5087
+ window.Select(tp, deselect, true);
47755088 }
47765089
47775090 return tp;
....@@ -5158,10 +5471,34 @@
51585471
51595472 // System.out.println("Fullname = " + fullname);
51605473
5161
- if (fullname.name.indexOf(":") == -1)
5162
- return fullname.name;
5474
+ // Does not work on Windows due to C:
5475
+// if (fullname.name.indexOf(":") == -1)
5476
+// return fullname.name;
5477
+//
5478
+// return fullname.name.substring(0,fullname.name.indexOf(":"));
51635479
5164
- return fullname.name.substring(0,fullname.name.indexOf(":"));
5480
+ String[] split = fullname.name.split(":");
5481
+
5482
+ if (split.length == 0)
5483
+ {
5484
+ return "";
5485
+ }
5486
+
5487
+ if (split.length <= 2)
5488
+ {
5489
+ if (fullname.name.endsWith(":"))
5490
+ {
5491
+ // Windows
5492
+ return fullname.name.substring(0, fullname.name.length()-1);
5493
+ }
5494
+
5495
+ return split[0];
5496
+ }
5497
+
5498
+ // Windows
5499
+ assert(split.length == 4);
5500
+
5501
+ return split[0] + ":" + split[1];
51655502 }
51665503
51675504 static String GetBump(cTexture fullname)
....@@ -5170,10 +5507,38 @@
51705507 return "";
51715508
51725509 // 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());
5510
+ // Does not work on Windows due to C:
5511
+// if (fullname.name.indexOf(":") == -1)
5512
+// return "";
5513
+//
5514
+// return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5515
+ String[] split = fullname.name.split(":");
5516
+
5517
+ if (split.length == 0)
5518
+ {
5519
+ return "";
5520
+ }
5521
+
5522
+ if (split.length == 1)
5523
+ {
5524
+ return "";
5525
+ }
5526
+
5527
+ if (split.length == 2)
5528
+ {
5529
+ if (fullname.name.endsWith(":"))
5530
+ {
5531
+ // Windows
5532
+ return "";
5533
+ }
5534
+
5535
+ return split[1];
5536
+ }
5537
+
5538
+ // Windows
5539
+ assert(split.length == 4);
5540
+
5541
+ return split[2] + ":" + split[3];
51775542 }
51785543
51795544 String GetPigmentTexture()
....@@ -5247,7 +5612,7 @@
52475612 System.out.print("; textures = " + textures);
52485613 System.out.println("; usedtextures = " + usedtextures);
52495614
5250
- if (GetTextures() == null)
5615
+ if (GetTextures() == null) // What is that??
52515616 GetTextures().name = ":";
52525617
52535618 String texname = tex;
....@@ -5278,6 +5643,43 @@
52785643 child.ResetPigmentTexture();
52795644 blockloop = false;
52805645 }
5646
+ }
5647
+
5648
+ UUID GetUUID()
5649
+ {
5650
+ if (uuid == null)
5651
+ {
5652
+ // Serial
5653
+ uuid = UUID.randomUUID();
5654
+ }
5655
+
5656
+ return uuid;
5657
+ }
5658
+
5659
+ Object3D GetObject(UUID uid)
5660
+ {
5661
+ if (blockloop)
5662
+ return null;
5663
+
5664
+ if (GetUUID().equals(uid))
5665
+ return this;
5666
+
5667
+ int nb = Size();
5668
+ for (int i = 0; i < nb; i++)
5669
+ {
5670
+ Object3D child = (Object3D) get(i);
5671
+
5672
+ if (child == null)
5673
+ continue;
5674
+
5675
+ blockloop = true;
5676
+ Object3D obj = child.GetObject(uid);
5677
+ blockloop = false;
5678
+ if (obj != null)
5679
+ return obj;
5680
+ }
5681
+
5682
+ return null;
52815683 }
52825684
52835685 void SetBumpTexture(String tex)
....@@ -5324,12 +5726,23 @@
53245726 boolean NeedSupport()
53255727 {
53265728 return
5327
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5729
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
53285730 // PROBLEM with CROWD!!
5329
- && (Globals.DrawMode() == iCameraPane.SHADOW || Globals.CROWD);
5731
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
53305732 }
53315733
53325734 static boolean DEBUG_SELECTION = false;
5735
+
5736
+ boolean IsLive()
5737
+ {
5738
+ if (live)
5739
+ return true;
5740
+
5741
+ if (parent == null)
5742
+ return false;
5743
+
5744
+ return parent.IsLive();
5745
+ }
53335746
53345747 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
53355748 {
....@@ -5341,7 +5754,7 @@
53415754 }
53425755
53435756 if (display.DrawMode() == iCameraPane.SELECTION &&
5344
- hide)
5757
+ (hide || dontselect))
53455758 return;
53465759
53475760 if (name != null && name.contains("sclera"))
....@@ -5392,7 +5805,7 @@
53925805 support = support;
53935806
53945807 //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);
5808
+ boolean usecalllists = !IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
53965809
53975810 if (!usecalllists && bRep != null && bRep.displaylist > 0)
53985811 {
....@@ -5412,10 +5825,12 @@
54125825 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
54135826
54145827 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5415
- (touched || (bRep != null && bRep.displaylist <= 0)))
5828
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5829
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
54165830 {
54175831 Globals.lighttouched = true;
54185832 } // all panes...
5833
+
54195834 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
54205835 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
54215836 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5543,6 +5958,7 @@
55435958 if (GetBRep() != null)
55445959 {
55455960 display.NextIndex();
5961
+
55465962 // vertex color conflict : gl.glCallList(list);
55475963 DrawNode(display, root, selected);
55485964 if (this instanceof BezierPatch)
....@@ -5583,7 +5999,28 @@
55835999 tex = GetTextures();
55846000 }
55856001
5586
- display.BindTextures(tex, texres);
6002
+ boolean failedPigment = false;
6003
+ boolean failedBump = false;
6004
+
6005
+ try
6006
+ {
6007
+ display.BindPigmentTexture(tex, texres);
6008
+ }
6009
+ catch (Exception e)
6010
+ {
6011
+ System.err.println("FAILED: " + this);
6012
+ failedPigment = true;
6013
+ }
6014
+
6015
+ try
6016
+ {
6017
+ display.BindBumpTexture(tex, texres);
6018
+ }
6019
+ catch (Exception e)
6020
+ {
6021
+ //System.err.println("FAILED: " + this);
6022
+ failedBump = true;
6023
+ }
55876024
55886025 if (!compiled)
55896026 {
....@@ -5605,7 +6042,11 @@
56056042 }
56066043 }
56076044
5608
- display.ReleaseTextures(tex);
6045
+ if (!failedBump)
6046
+ display.ReleaseBumpTexture(tex);
6047
+
6048
+ if (!failedPigment)
6049
+ display.ReleasePigmentTexture(tex);
56096050
56106051 display.PopMaterial(this, selected);
56116052 }
....@@ -5734,6 +6175,9 @@
57346175
57356176 void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57366177 {
6178
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6179
+ return;
6180
+
57376181 if (hide)
57386182 return;
57396183 // shadow optimisation
....@@ -5859,6 +6303,9 @@
58596303 if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
58606304 return; // no shadow for transparent objects
58616305
6306
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6307
+ return;
6308
+
58626309 if (hide)
58636310 return;
58646311
....@@ -5972,6 +6419,11 @@
59726419 // dec 2012
59736420 new Exception().printStackTrace();
59746421 return;
6422
+ }
6423
+
6424
+ if (dontselect)
6425
+ {
6426
+ //bRep.GenerateNormalsMINE();
59756427 }
59766428
59776429 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -6824,7 +7276,7 @@
68247276 spot.translate(32, 32);
68257277 spotw = spot.x + spot.width;
68267278 spoth = spot.y + spot.height;
6827
- info.g.setColor(Color.blue);
7279
+ info.g.setColor(Color.cyan);
68287280 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
68297281 // if (CameraPane.Xmin > spot.x)
68307282 // {
....@@ -6842,11 +7294,12 @@
68427294 // {
68437295 // CameraPane.Ymax = spoth;
68447296 // }
6845
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
6846
- info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7297
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7298
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
68477299 spot.translate(0, -32);
6848
- info.g.setColor(Color.green);
7300
+ info.g.setColor(Color.yellow);
68497301 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7302
+ info.g.setColor(Color.green);
68507303 // if (CameraPane.Xmin > spot.x)
68517304 // {
68527305 // CameraPane.Xmin = spot.x;
....@@ -6863,8 +7316,8 @@
68637316 // {
68647317 // CameraPane.Ymax = spoth;
68657318 // }
6866
- info.g.drawArc(boundary.x, boundary.y,
6867
- boundary.width, boundary.height, 0, 360);
7319
+ info.g.drawArc(boundary.x + info.DX, boundary.y + info.DY,
7320
+ (int)(boundary.width * info.W), (int)(boundary.height * info.W), 0, 360);
68687321 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
68697322 // if (CameraPane.Xmin > boundary.x)
68707323 // {
....@@ -6898,7 +7351,7 @@
68987351 startX = info.x;
68997352 startY = info.y;
69007353
6901
- hitSomething = 0;
7354
+ hitSomething = -1;
69027355 cVector origin = new cVector();
69037356 //LA.xformPos(origin, toParent, origin);
69047357 Rectangle spot = new Rectangle();
....@@ -6931,7 +7384,7 @@
69317384 }
69327385
69337386 //System.out.println("info.modifiers = " + info.modifiers);
6934
- modified = (info.modifiers & CameraPane.META) != 0;
7387
+ modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
69357388 //System.out.println("modified = " + modified);
69367389 //new Exception().printStackTrace();
69377390 //viewCode = info.pane.renderCamera.viewCode;
....@@ -6959,7 +7412,7 @@
69597412 return true;
69607413 }
69617414
6962
- void doEditDrag0(ClickInfo info)
7415
+ void doEditDrag0(ClickInfo info, boolean opposite)
69637416 {
69647417 if (hitSomething == 0)
69657418 {
....@@ -6974,6 +7427,7 @@
69747427 //System.out.println("hitSomething = " + hitSomething);
69757428
69767429 double scale = 0.005f * info.camera.Distance();
7430
+
69777431 cVector xlate = new cVector();
69787432 //cVector xlate2 = new cVector();
69797433 switch (hitSomething)
....@@ -6986,7 +7440,7 @@
69867440
69877441 scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
69887442
6989
- if (modified)
7443
+ if (modified || opposite)
69907444 {
69917445 //assert(false);
69927446 /*
....@@ -7080,6 +7534,7 @@
70807534
70817535 if (modified)
70827536 {
7537
+ // Rotate 90 degrees
70837538 angle /= (Math.PI / 4);
70847539 angle = Math.floor(angle + 0.5);
70857540 angle *= (Math.PI / 4);
....@@ -7121,24 +7576,27 @@
71217576
71227577 case hitScale: // scale
71237578 double hScale = (double) (info.x - centerPt.x) / 32;
7579
+ double sign = 1;
7580
+ if (hScale < 0)
7581
+ {
7582
+ sign = -1;
7583
+ }
7584
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
71247585 if (hScale < 0.01)
71257586 {
7126
- hScale = 0.01;
7587
+ //hScale = 0.01;
71277588 }
7128
- hScale = Math.pow(hScale, scale * 50);
7129
- if (hScale < 0.01)
7130
- {
7131
- hScale = 0.01;
7132
- }
7589
+
71337590 double vScale = (double) (info.y - centerPt.y) / 32;
7134
- if (vScale < 0.01)
7591
+ sign = 1;
7592
+ if (vScale < 0)
71357593 {
7136
- vScale = 0.01;
7594
+ sign = -1;
71377595 }
7138
- vScale = Math.pow(vScale, scale * 50);
7596
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
71397597 if (vScale < 0.01)
71407598 {
7141
- vScale = 0.01;
7599
+ //vScale = 0.01;
71427600 }
71437601 LA.matCopy(startMat, toParent);
71447602 /**/
....@@ -7149,39 +7607,47 @@
71497607 }
71507608 /**/
71517609
7610
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7611
+
7612
+ if (totalScale < 0.01)
7613
+ {
7614
+ totalScale = 0.01;
7615
+ }
7616
+
71527617 switch (info.pane.RenderCamera().viewCode)
71537618 {
71547619 case 3: // '\001'
7155
- if (modified)
7620
+ if (modified || opposite)
71567621 {
71577622 //LA.matScale(toParent, 1, hScale, vScale);
7158
- LA.matScale(toParent, vScale, 1, 1);
7623
+ LA.matScale(toParent, totalScale, 1, 1);
71597624 } // vScale, 1);
71607625 else
71617626 {
7162
- LA.matScale(toParent, vScale, vScale, vScale);
7627
+ // EXCEPTION!
7628
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
71637629 } // vScale, 1);
71647630 break;
71657631
71667632 case 2: // '\002'
7167
- if (modified)
7633
+ if (modified || opposite)
71687634 {
71697635 //LA.matScale(toParent, hScale, 1, vScale);
7170
- LA.matScale(toParent, 1, vScale, 1);
7636
+ LA.matScale(toParent, 1, totalScale, 1);
71717637 } else
71727638 {
7173
- LA.matScale(toParent, vScale, 1, vScale);
7639
+ LA.matScale(toParent, totalScale, 1, totalScale);
71747640 }
71757641 break;
71767642
71777643 case 1: // '\003'
7178
- if (modified)
7644
+ if (modified || opposite)
71797645 {
71807646 //LA.matScale(toParent, hScale, vScale, 1);
7181
- LA.matScale(toParent, 1, 1, vScale);
7647
+ LA.matScale(toParent, 1, 1, totalScale);
71827648 } else
71837649 {
7184
- LA.matScale(toParent, vScale, vScale, 1);
7650
+ LA.matScale(toParent, totalScale, totalScale, 1);
71857651 }
71867652 break;
71877653 }
....@@ -7314,14 +7780,22 @@
73147780 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
73157781 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
73167782 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7783
+
7784
+ String objname;
7785
+
73177786 if (false) //parent != null)
73187787 {
7319
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7788
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
73207789 } else
73217790 {
7322
- return GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ") ")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ +System.identityHashCode(this);
7791
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
73237792 } // + super.toString();
73247793 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
7794
+
7795
+ if (!Globals.ADVANCED)
7796
+ return objname;
7797
+
7798
+ return objname + " " + System.identityHashCode(this);
73257799 }
73267800
73277801 public int hashCode()
....@@ -7377,6 +7851,7 @@
73777851 objectUI.closeUI();
73787852 if (editWindow != null)
73797853 {
7854
+ editWindow.ctrlPanel.FlushUI();
73807855 editWindow.refreshContents();
73817856 } // ? new
73827857 objectUI = null;
....@@ -7385,6 +7860,10 @@
73857860 {
73867861 editWindow = null;
73877862 } // ?
7863
+ }
7864
+ else
7865
+ {
7866
+ //editWindow.closeUI();
73887867 }
73897868 }
73907869
....@@ -7397,7 +7876,7 @@
73977876 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
73987877
73997878 Object3D /*Composite*/ parent;
7400
- Object3D /*Composite*/ fileparent;
7879
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
74017880
74027881 double[][] toParent; // dynamic matrix
74037882 double[][] fromParent;
....@@ -7512,7 +7991,7 @@
75127991 {
75137992 assert(bRep != null);
75147993 if (!(support instanceof GenericJoint)) // support.bRep != null)
7515
- GrafreeD.Assert(support.bRep == bRep.support);
7994
+ Grafreed.Assert(support.bRep == bRep.support);
75167995 }
75177996 else
75187997 {
....@@ -7543,6 +8022,10 @@
75438022 }
75448023
75458024 transient ObjEditor editWindow;
8025
+ transient ObjEditor manipWindow;
8026
+
8027
+ transient boolean pinned;
8028
+
75468029 transient ObjectUI objectUI;
75478030 public static int povDepth = 0;
75488031 private static cVector tbMin = new cVector();
....@@ -7561,9 +8044,9 @@
75618044 private static cVector edge2 = new cVector();
75628045 //private static cVector norm = new cVector();
75638046 /*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;
8047
+ static final int hitCenter = 1;
8048
+ static final int hitScale = 2;
8049
+ static final int hitRotate = 3;
75678050 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
75688051 /*transient*/ private Point centerPt;
75698052 /*transient*/ private int startX;