Normand Briere
2019-06-30 cfd7a643cb5a445016ddb15595158ecc59b184fd
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
28
+ mocap.reader.BVHReader.BVHResult bvh;
29
+ Object3D skeleton;
30
+ //
2231
2332 ScriptNode scriptnode;
2433
....@@ -100,64 +109,143 @@
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
+ if (hashtable.containsKey(GetUUID()))
174
+ {
175
+ Object3D o = hashtable.get(GetUUID());
176
+
177
+ Grafreed.Assert(this.bRep == o.bRep);
178
+ if (this.bRep != null)
179
+ assert(this.bRep.support == o.transientrep);
180
+
181
+ return;
182
+ }
183
+
184
+ Object3D o = new Object3D("copy of " + this.name);
185
+
186
+ hashtable.put(GetUUID(), o);
187
+
188
+ for (int i=0; i<Size(); i++)
189
+ {
190
+ get(i).ExtractBigData(hashtable);
191
+ }
192
+
193
+ ExtractBigData(o);
194
+ }
195
+
196
+ void ExtractBigData(Object3D o)
197
+ {
198
+ o.bRep = this.bRep;
199
+ if (this.bRep != null)
200
+ {
201
+ o.transientrep = this.bRep.support;
202
+ o.bRep.support = null;
203
+ }
204
+
205
+ // o.support = this.support;
206
+ // o.fileparent = this.fileparent;
207
+ // if (this.bRep != null)
208
+ // o.bRep = this.bRep.support;
209
+
210
+ this.bRep = null;
211
+ // if (this.bRep != null)
212
+ // this.bRep.support = null;
213
+ // this.support = null;
214
+ // this.fileparent = null;
215
+ }
216
+
217
+ void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
218
+ {
219
+ if (!hashtable.containsKey(GetUUID()))
220
+ return;
221
+
222
+ if (blockloop)
223
+ return;
224
+
130225 blockloop = true;
131
- child.SaveSupports();
226
+
227
+ Object3D o = hashtable.get(GetUUID());
228
+
229
+ RestoreBigData(o);
230
+
231
+ //hashtable.remove(GetUUID());
232
+
233
+ for (int i=0; i<Size(); i++)
234
+ {
235
+ get(i).RestoreBigData(hashtable);
236
+ }
237
+
132238 blockloop = false;
133239 }
134
-}
135240
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)
241
+ void RestoreBigData(Object3D o)
147242 {
148
- bRep.RestoreSupports();
243
+ this.bRep = o.bRep;
244
+ if (this.bRep != null)
245
+ this.bRep.support = o.transientrep;
246
+ // this.support = o.support;
247
+ // this.fileparent = o.fileparent;
149248 }
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
-}
161249
162250 // MOCAP SUPPORT
163251 double tx,ty,tz,rx,ry,rz;
....@@ -300,6 +388,7 @@
300388 }
301389
302390 boolean live = false;
391
+ boolean dontselect = false;
303392 boolean hide = false;
304393 boolean link2master = false; // performs reset support/master at each frame
305394 boolean marked = false; // animation node
....@@ -481,12 +570,14 @@
481570 toParent = LA.newMatrix();
482571 fromParent = LA.newMatrix();
483572 }
573
+
484574 if (toParentMarked == null)
485575 {
486576 if (maxcount != 1)
487577 {
488578 new Exception().printStackTrace();
489579 }
580
+
490581 toParentMarked = LA.newMatrix();
491582 fromParentMarked = LA.newMatrix();
492583 }
....@@ -774,7 +865,7 @@
774865 if (step == 0)
775866 step = 1;
776867 if (maxcount == 0)
777
- maxcount = 2048; // 4;
868
+ maxcount = 128; // 2048; // 4;
778869 // if (acceleration == 0)
779870 // acceleration = 10;
780871 if (delay == 0) // serial
....@@ -797,7 +888,7 @@
797888
798889 if (marked && Globals.isLIVE() && live &&
799890 //TEMP21aug2018
800
- Globals.DrawMode() == iCameraPane.SHADOW &&
891
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
801892 currentframe != Globals.framecount)
802893 {
803894 currentframe = Globals.framecount;
....@@ -809,7 +900,8 @@
809900
810901 boolean changedir = random && Math.random() < 0.01; // && !link2master;
811902
812
- if (transformcount*factor > maxcount || (step == 1 && changedir))
903
+ if (transformcount*factor >= maxcount && (rewind || random) ||
904
+ (step == 1 && changedir))
813905 {
814906 countdown = 1;
815907 delay = speedup?8:1;
....@@ -881,6 +973,7 @@
881973 if (material == null || material.multiply)
882974 return true;
883975
976
+ // Transparent objects are dynamic because we have to sort the triangles.
884977 return material.opacity > 0.99;
885978 }
886979
....@@ -912,6 +1005,11 @@
9121005 fromParent = null; // LA.newMatrix();
9131006 bRep = null; // new BoundaryRep();
9141007
1008
+ if (oname != null && oname.equals("LeftHand"))
1009
+ {
1010
+ name = oname;
1011
+ }
1012
+
9151013 /*
9161014 float hue = (float)Math.random();
9171015 Color col;
....@@ -954,7 +1052,7 @@
9541052
9551053 public Object clone()
9561054 {
957
- return GrafreeD.clone(this);
1055
+ return Grafreed.clone(this);
9581056 }
9591057
9601058 Object3D copyExpand()
....@@ -1470,7 +1568,7 @@
14701568 BoundaryRep.SEUIL = other.material.cameralight;
14711569
14721570 // Set default to 0.1
1473
- BoundaryRep.SEUIL /= 2;
1571
+ BoundaryRep.SEUIL /= 4; // 2;
14741572 System.out.println("SEUIL = " + BoundaryRep.SEUIL);
14751573 }
14761574
....@@ -1729,7 +1827,7 @@
17291827 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17301828 o.bRep = transientrep;
17311829 if (clone)
1732
- o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
1830
+ o.bRep = (BoundaryRep) Grafreed.clone(transientrep);
17331831 o.CreateMaterial();
17341832 o.SetAttributes(this, -1);
17351833 //parent
....@@ -1742,7 +1840,7 @@
17421840 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17431841 o.bRep = bRep;
17441842 if (clone)
1745
- o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
1843
+ o.bRep = (BoundaryRep) Grafreed.clone(bRep);
17461844 o.CreateMaterial();
17471845 //o.overwriteThis(this, -1);
17481846 o.SetAttributes(this, -1);
....@@ -1829,12 +1927,15 @@
18291927 if (obj.name == null)
18301928 continue; // can't be a null one
18311929
1930
+ // Try perfect match first.
18321931 if (n.equals(obj.name))
18331932 {
18341933 theobj = obj;
18351934 count++;
18361935 }
18371936 }
1937
+
1938
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18381939
18391940 if (count != 1)
18401941 for (int i=Size(); --i>=0;)
....@@ -2294,12 +2395,17 @@
22942395 }
22952396 */
22962397 }
2398
+ else
2399
+ {
2400
+ //((ObjEditor)editWindow).SetupUI2(null);
2401
+ }
22972402 }
22982403
22992404 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
23002405 {
23012406 if (newWindow)
23022407 {
2408
+ new Exception().printStackTrace();
23032409 System.exit(0);
23042410 if (parent != null)
23052411 {
....@@ -2334,6 +2440,14 @@
23342440 {
23352441 editWindow.refreshContents();
23362442 }
2443
+ else
2444
+ {
2445
+ if (manipWindow != null)
2446
+ {
2447
+ manipWindow.refreshContents();
2448
+ }
2449
+ }
2450
+
23372451 //if (parent != null)
23382452 //parent.refreshEditWindow();
23392453 }
....@@ -2476,13 +2590,13 @@
24762590 return retval;
24772591 }
24782592
2479
- void doEditDrag(ClickInfo info)
2593
+ void doEditDrag(ClickInfo info, boolean opposite)
24802594 {
24812595 switch (doSomething)
24822596 {
24832597 case 1: // '\001'
24842598 //super.
2485
- doEditDrag0(info);
2599
+ doEditDrag0(info, opposite);
24862600 break;
24872601
24882602 case 2: // '\002'
....@@ -2495,11 +2609,11 @@
24952609 {
24962610 //sel.hitSomething = childToDrag.hitSomething;
24972611 //childToDrag.doEditDrag(info);
2498
- sel.doEditDrag(info);
2612
+ sel.doEditDrag(info, opposite);
24992613 } else
25002614 {
25012615 //super.
2502
- doEditDrag0(info);
2616
+ doEditDrag0(info, opposite);
25032617 }
25042618 }
25052619 break;
....@@ -2609,6 +2723,18 @@
26092723 void GenNormalsS(boolean crease)
26102724 {
26112725 selection.GenNormals(crease);
2726
+// for (int i=0; i<selection.size(); i++)
2727
+// {
2728
+// Object3D selectee = (Object3D) selection.elementAt(i);
2729
+// selectee.GenNormals(crease);
2730
+// }
2731
+
2732
+ //Touch();
2733
+ }
2734
+
2735
+ void GenNormalsMeshS()
2736
+ {
2737
+ selection.GenNormalsMesh();
26122738 // for (int i=0; i<selection.size(); i++)
26132739 // {
26142740 // Object3D selectee = (Object3D) selection.elementAt(i);
....@@ -2749,6 +2875,24 @@
27492875 if (child == null)
27502876 continue;
27512877 child.GenNormals(crease);
2878
+// Children().release(i);
2879
+ }
2880
+ blockloop = false;
2881
+ }
2882
+
2883
+ void GenNormalsMesh()
2884
+ {
2885
+ if (blockloop)
2886
+ return;
2887
+
2888
+ blockloop = true;
2889
+ GenNormalsMesh0();
2890
+ for (int i = 0; i < Children().Size(); i++)
2891
+ {
2892
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2893
+ if (child == null)
2894
+ continue;
2895
+ child.GenNormalsMesh();
27522896 // Children().release(i);
27532897 }
27542898 blockloop = false;
....@@ -2921,6 +3065,15 @@
29213065 }
29223066 }
29233067
3068
+ void GenNormalsMesh0()
3069
+ {
3070
+ if (bRep != null)
3071
+ {
3072
+ bRep.GenerateNormalsMesh();
3073
+ Touch();
3074
+ }
3075
+ }
3076
+
29243077 void GenNormalsMINE0()
29253078 {
29263079 if (bRep != null)
....@@ -2982,6 +3135,33 @@
29823135 blockloop = false;
29833136 }
29843137
3138
+ void TransformChildren()
3139
+ {
3140
+ if (toParent != null)
3141
+ {
3142
+ for (int i=Size(); --i>=0;)
3143
+ {
3144
+ Object3D v = get(i);
3145
+
3146
+ if (v.toParent == null)
3147
+ {
3148
+ v.toParent = LA.newMatrix();
3149
+ v.fromParent = LA.newMatrix();
3150
+ }
3151
+
3152
+// LA.matConcat(v.toParent, toParent, v.toParent);
3153
+// LA.matConcat(fromParent, v.fromParent, v.fromParent);
3154
+ LA.matConcat(toParent, v.toParent, v.toParent);
3155
+ LA.matConcat(v.fromParent, fromParent, v.fromParent);
3156
+ }
3157
+
3158
+ toParent = null; // LA.matIdentity(toParent);
3159
+ fromParent = null; // LA.matIdentity(fromParent);
3160
+
3161
+ Touch();
3162
+ }
3163
+ }
3164
+
29853165 void TransformGeometry()
29863166 {
29873167 Object3D obj = this;
....@@ -3203,9 +3383,11 @@
32033383
32043384 BoundaryRep sup = bRep.support;
32053385 bRep.support = null;
3206
- BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
3386
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
32073387 // bRep.SplitInTwo(onlyone); // thread...
3208
- temprep.SplitInTwo(reduction34, onlyone);
3388
+
3389
+ while(temprep.SplitInTwo(reduction34, onlyone));
3390
+
32093391 bRep = temprep;
32103392 bRep.support = sup;
32113393 Touch();
....@@ -3342,7 +3524,8 @@
33423524 if (blockloop)
33433525 return;
33443526
3345
- if (marked || (bRep != null && material != null)) // borderline...
3527
+ if (//marked || // does not make sense
3528
+ (bRep != null || material != null)) // borderline...
33463529 live = h;
33473530
33483531 for (int i = 0; i < Size(); i++)
....@@ -3363,7 +3546,8 @@
33633546 return;
33643547
33653548 //if (bRep != null)
3366
- if (marked || (bRep != null && material != null)) // borderline...
3549
+ if (//marked || // does not make sense
3550
+ (bRep != null || material != null)) // borderline...
33673551 link2master = h;
33683552
33693553 for (int i = 0; i < Size(); i++)
....@@ -3383,7 +3567,8 @@
33833567 if (blockloop)
33843568 return;
33853569
3386
- if (marked || (bRep != null && material != null)) // borderline...
3570
+ if (//marked || // does not make sense
3571
+ (bRep != null || material != null)) // borderline...
33873572 hide = h;
33883573
33893574 for (int i = 0; i < Size(); i++)
....@@ -3403,7 +3588,7 @@
34033588 if (blockloop)
34043589 return;
34053590
3406
- if (bRep != null && material != null) // borderline...
3591
+ if (bRep != null || material != null) // borderline...
34073592 marked = h;
34083593
34093594 for (int i = 0; i < Size(); i++)
....@@ -3413,6 +3598,46 @@
34133598 continue;
34143599 blockloop = true;
34153600 child.MarkLeaves(h);
3601
+ blockloop = false;
3602
+ // release(i);
3603
+ }
3604
+ }
3605
+
3606
+ void RewindLeaves(boolean h)
3607
+ {
3608
+ if (blockloop)
3609
+ return;
3610
+
3611
+ if (bRep != null || material != null) // borderline...
3612
+ rewind = h;
3613
+
3614
+ for (int i = 0; i < Size(); i++)
3615
+ {
3616
+ Object3D child = (Object3D) get(i); // reserve(i);
3617
+ if (child == null)
3618
+ continue;
3619
+ blockloop = true;
3620
+ child.RewindLeaves(h);
3621
+ blockloop = false;
3622
+ // release(i);
3623
+ }
3624
+ }
3625
+
3626
+ void RandomLeaves(boolean h)
3627
+ {
3628
+ if (blockloop)
3629
+ return;
3630
+
3631
+ if (bRep != null || material != null) // borderline...
3632
+ random = h;
3633
+
3634
+ for (int i = 0; i < Size(); i++)
3635
+ {
3636
+ Object3D child = (Object3D) get(i); // reserve(i);
3637
+ if (child == null)
3638
+ continue;
3639
+ blockloop = true;
3640
+ child.RandomLeaves(h);
34163641 blockloop = false;
34173642 // release(i);
34183643 }
....@@ -3727,7 +3952,7 @@
37273952 if (child == null)
37283953 continue;
37293954
3730
- if (GrafreeD.RENDERME > 0)
3955
+ if (Grafreed.RENDERME > 0)
37313956 {
37323957 if (child instanceof Merge)
37333958 ((Merge)child).renderme();
....@@ -3878,7 +4103,7 @@
38784103 if (child == null)
38794104 continue;
38804105
3881
- if (GrafreeD.RENDERME > 0)
4106
+ if (Grafreed.RENDERME > 0)
38824107 {
38834108 if (child instanceof Merge)
38844109 ((Merge)child).renderme();
....@@ -4073,7 +4298,7 @@
40734298 if (child == null)
40744299 continue;
40754300
4076
- if (GrafreeD.RENDERME > 0)
4301
+ if (Grafreed.RENDERME > 0)
40774302 {
40784303 if (child instanceof Merge)
40794304 ((Merge)child).renderme();
....@@ -4186,6 +4411,55 @@
41864411 {
41874412 blockloop = true;
41884413 get(i).RepairShadow();
4414
+ blockloop = false;
4415
+ }
4416
+ }
4417
+
4418
+ void RepairSOV()
4419
+ {
4420
+ if (blockloop)
4421
+ return;
4422
+
4423
+ String texname = this.GetPigmentTexture();
4424
+
4425
+ if (texname.startsWith("sov"))
4426
+ {
4427
+ String[] s = texname.split("/");
4428
+
4429
+ String[] sname = s[1].split("Color.pn");
4430
+
4431
+ texname = sname[0];
4432
+
4433
+ if (sname.length > 1)
4434
+ {
4435
+ texname += "Color.jpg";
4436
+ }
4437
+
4438
+ this.SetPigmentTexture("sov/" + texname);
4439
+ }
4440
+
4441
+ texname = this.GetBumpTexture();
4442
+
4443
+ if (texname.startsWith("sov"))
4444
+ {
4445
+ String[] s = texname.split("/");
4446
+
4447
+ String[] sname = s[1].split("Bump.pn");
4448
+
4449
+ texname = sname[0];
4450
+
4451
+ if (sname.length > 1)
4452
+ {
4453
+ texname += "Bump.jpg";
4454
+ }
4455
+
4456
+ this.SetBumpTexture("sov/" + texname);
4457
+ }
4458
+
4459
+ for (int i=0; i<Size(); i++)
4460
+ {
4461
+ blockloop = true;
4462
+ get(i).RepairSOV();
41894463 blockloop = false;
41904464 }
41914465 }
....@@ -4680,7 +4954,7 @@
46804954
46814955 cTreePath SelectLeaf(int indexcount, boolean deselect)
46824956 {
4683
- if (hide)
4957
+ if (hide || dontselect)
46844958 return null;
46854959
46864960 if (count <= 0)
....@@ -4704,9 +4978,17 @@
47044978 }
47054979 }
47064980
4981
+ ObjEditor GetWindow()
4982
+ {
4983
+ if (editWindow != null)
4984
+ return editWindow;
4985
+
4986
+ return manipWindow;
4987
+ }
4988
+
47074989 cTreePath Select(int indexcount, boolean deselect)
47084990 {
4709
- if (hide)
4991
+ if (hide || dontselect)
47104992 return null;
47114993
47124994 if (count <= 0)
....@@ -4740,10 +5022,11 @@
47405022 if (leaf != null)
47415023 {
47425024 cTreePath tp = new cTreePath(this, leaf);
4743
- if (editWindow != null)
5025
+ ObjEditor window = GetWindow();
5026
+ if (window != null)
47445027 {
47455028 //System.out.println("editWindow = " + editWindow + " vs " + this);
4746
- editWindow.Select(tp, deselect, true);
5029
+ window.Select(tp, deselect, true);
47475030 }
47485031
47495032 return tp;
....@@ -4760,6 +5043,7 @@
47605043
47615044 if (child == null)
47625045 continue;
5046
+
47635047 if (child.HasTransparency() && child.size() != 0)
47645048 {
47655049 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4769,9 +5053,10 @@
47695053 if (leaf != null)
47705054 {
47715055 cTreePath tp = new cTreePath(this, leaf);
4772
- if (editWindow != null)
5056
+ ObjEditor window = GetWindow();
5057
+ if (window != null)
47735058 {
4774
- editWindow.Select(tp, deselect, true);
5059
+ window.Select(tp, deselect, true);
47755060 }
47765061
47775062 return tp;
....@@ -5158,10 +5443,34 @@
51585443
51595444 // System.out.println("Fullname = " + fullname);
51605445
5161
- if (fullname.name.indexOf(":") == -1)
5162
- return fullname.name;
5446
+ // Does not work on Windows due to C:
5447
+// if (fullname.name.indexOf(":") == -1)
5448
+// return fullname.name;
5449
+//
5450
+// return fullname.name.substring(0,fullname.name.indexOf(":"));
51635451
5164
- return fullname.name.substring(0,fullname.name.indexOf(":"));
5452
+ String[] split = fullname.name.split(":");
5453
+
5454
+ if (split.length == 0)
5455
+ {
5456
+ return "";
5457
+ }
5458
+
5459
+ if (split.length <= 2)
5460
+ {
5461
+ if (fullname.name.endsWith(":"))
5462
+ {
5463
+ // Windows
5464
+ return fullname.name.substring(0, fullname.name.length()-1);
5465
+ }
5466
+
5467
+ return split[0];
5468
+ }
5469
+
5470
+ // Windows
5471
+ assert(split.length == 4);
5472
+
5473
+ return split[0] + ":" + split[1];
51655474 }
51665475
51675476 static String GetBump(cTexture fullname)
....@@ -5170,10 +5479,38 @@
51705479 return "";
51715480
51725481 // 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());
5482
+ // Does not work on Windows due to C:
5483
+// if (fullname.name.indexOf(":") == -1)
5484
+// return "";
5485
+//
5486
+// return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5487
+ String[] split = fullname.name.split(":");
5488
+
5489
+ if (split.length == 0)
5490
+ {
5491
+ return "";
5492
+ }
5493
+
5494
+ if (split.length == 1)
5495
+ {
5496
+ return "";
5497
+ }
5498
+
5499
+ if (split.length == 2)
5500
+ {
5501
+ if (fullname.name.endsWith(":"))
5502
+ {
5503
+ // Windows
5504
+ return "";
5505
+ }
5506
+
5507
+ return split[1];
5508
+ }
5509
+
5510
+ // Windows
5511
+ assert(split.length == 4);
5512
+
5513
+ return split[2] + ":" + split[3];
51775514 }
51785515
51795516 String GetPigmentTexture()
....@@ -5247,7 +5584,7 @@
52475584 System.out.print("; textures = " + textures);
52485585 System.out.println("; usedtextures = " + usedtextures);
52495586
5250
- if (GetTextures() == null)
5587
+ if (GetTextures() == null) // What is that??
52515588 GetTextures().name = ":";
52525589
52535590 String texname = tex;
....@@ -5278,6 +5615,43 @@
52785615 child.ResetPigmentTexture();
52795616 blockloop = false;
52805617 }
5618
+ }
5619
+
5620
+ UUID GetUUID()
5621
+ {
5622
+ if (uuid == null)
5623
+ {
5624
+ // Serial
5625
+ uuid = UUID.randomUUID();
5626
+ }
5627
+
5628
+ return uuid;
5629
+ }
5630
+
5631
+ Object3D GetObject(UUID uid)
5632
+ {
5633
+ if (blockloop)
5634
+ return null;
5635
+
5636
+ if (GetUUID().equals(uid))
5637
+ return this;
5638
+
5639
+ int nb = Size();
5640
+ for (int i = 0; i < nb; i++)
5641
+ {
5642
+ Object3D child = (Object3D) get(i);
5643
+
5644
+ if (child == null)
5645
+ continue;
5646
+
5647
+ blockloop = true;
5648
+ Object3D obj = child.GetObject(uid);
5649
+ blockloop = false;
5650
+ if (obj != null)
5651
+ return obj;
5652
+ }
5653
+
5654
+ return null;
52815655 }
52825656
52835657 void SetBumpTexture(String tex)
....@@ -5324,12 +5698,23 @@
53245698 boolean NeedSupport()
53255699 {
53265700 return
5327
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5701
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
53285702 // PROBLEM with CROWD!!
5329
- && (Globals.DrawMode() == iCameraPane.SHADOW || Globals.CROWD);
5703
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
53305704 }
53315705
53325706 static boolean DEBUG_SELECTION = false;
5707
+
5708
+ boolean IsLive()
5709
+ {
5710
+ if (live)
5711
+ return true;
5712
+
5713
+ if (parent == null)
5714
+ return false;
5715
+
5716
+ return parent.IsLive();
5717
+ }
53335718
53345719 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
53355720 {
....@@ -5341,7 +5726,7 @@
53415726 }
53425727
53435728 if (display.DrawMode() == iCameraPane.SELECTION &&
5344
- hide)
5729
+ (hide || dontselect))
53455730 return;
53465731
53475732 if (name != null && name.contains("sclera"))
....@@ -5392,7 +5777,7 @@
53925777 support = support;
53935778
53945779 //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);
5780
+ boolean usecalllists = !IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
53965781
53975782 if (!usecalllists && bRep != null && bRep.displaylist > 0)
53985783 {
....@@ -5412,10 +5797,12 @@
54125797 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
54135798
54145799 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5415
- (touched || (bRep != null && bRep.displaylist <= 0)))
5800
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5801
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
54165802 {
54175803 Globals.lighttouched = true;
54185804 } // all panes...
5805
+
54195806 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
54205807 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
54215808 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5543,6 +5930,7 @@
55435930 if (GetBRep() != null)
55445931 {
55455932 display.NextIndex();
5933
+
55465934 // vertex color conflict : gl.glCallList(list);
55475935 DrawNode(display, root, selected);
55485936 if (this instanceof BezierPatch)
....@@ -5583,7 +5971,28 @@
55835971 tex = GetTextures();
55845972 }
55855973
5586
- display.BindTextures(tex, texres);
5974
+ boolean failedPigment = false;
5975
+ boolean failedBump = false;
5976
+
5977
+ try
5978
+ {
5979
+ display.BindPigmentTexture(tex, texres);
5980
+ }
5981
+ catch (Exception e)
5982
+ {
5983
+ System.err.println("FAILED: " + this);
5984
+ failedPigment = true;
5985
+ }
5986
+
5987
+ try
5988
+ {
5989
+ display.BindBumpTexture(tex, texres);
5990
+ }
5991
+ catch (Exception e)
5992
+ {
5993
+ //System.err.println("FAILED: " + this);
5994
+ failedBump = true;
5995
+ }
55875996
55885997 if (!compiled)
55895998 {
....@@ -5605,7 +6014,11 @@
56056014 }
56066015 }
56076016
5608
- display.ReleaseTextures(tex);
6017
+ if (!failedBump)
6018
+ display.ReleaseBumpTexture(tex);
6019
+
6020
+ if (!failedPigment)
6021
+ display.ReleasePigmentTexture(tex);
56096022
56106023 display.PopMaterial(this, selected);
56116024 }
....@@ -5734,6 +6147,9 @@
57346147
57356148 void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57366149 {
6150
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6151
+ return;
6152
+
57376153 if (hide)
57386154 return;
57396155 // shadow optimisation
....@@ -5859,6 +6275,9 @@
58596275 if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
58606276 return; // no shadow for transparent objects
58616277
6278
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6279
+ return;
6280
+
58626281 if (hide)
58636282 return;
58646283
....@@ -5972,6 +6391,11 @@
59726391 // dec 2012
59736392 new Exception().printStackTrace();
59746393 return;
6394
+ }
6395
+
6396
+ if (dontselect)
6397
+ {
6398
+ //bRep.GenerateNormalsMINE();
59756399 }
59766400
59776401 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -6824,7 +7248,7 @@
68247248 spot.translate(32, 32);
68257249 spotw = spot.x + spot.width;
68267250 spoth = spot.y + spot.height;
6827
- info.g.setColor(Color.blue);
7251
+ info.g.setColor(Color.cyan);
68287252 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
68297253 // if (CameraPane.Xmin > spot.x)
68307254 // {
....@@ -6842,11 +7266,12 @@
68427266 // {
68437267 // CameraPane.Ymax = spoth;
68447268 // }
6845
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
6846
- info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7269
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7270
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
68477271 spot.translate(0, -32);
6848
- info.g.setColor(Color.green);
7272
+ info.g.setColor(Color.yellow);
68497273 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7274
+ info.g.setColor(Color.green);
68507275 // if (CameraPane.Xmin > spot.x)
68517276 // {
68527277 // CameraPane.Xmin = spot.x;
....@@ -6898,7 +7323,7 @@
68987323 startX = info.x;
68997324 startY = info.y;
69007325
6901
- hitSomething = 0;
7326
+ hitSomething = -1;
69027327 cVector origin = new cVector();
69037328 //LA.xformPos(origin, toParent, origin);
69047329 Rectangle spot = new Rectangle();
....@@ -6931,7 +7356,7 @@
69317356 }
69327357
69337358 //System.out.println("info.modifiers = " + info.modifiers);
6934
- modified = (info.modifiers & CameraPane.META) != 0;
7359
+ modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
69357360 //System.out.println("modified = " + modified);
69367361 //new Exception().printStackTrace();
69377362 //viewCode = info.pane.renderCamera.viewCode;
....@@ -6959,7 +7384,7 @@
69597384 return true;
69607385 }
69617386
6962
- void doEditDrag0(ClickInfo info)
7387
+ void doEditDrag0(ClickInfo info, boolean opposite)
69637388 {
69647389 if (hitSomething == 0)
69657390 {
....@@ -6974,6 +7399,7 @@
69747399 //System.out.println("hitSomething = " + hitSomething);
69757400
69767401 double scale = 0.005f * info.camera.Distance();
7402
+
69777403 cVector xlate = new cVector();
69787404 //cVector xlate2 = new cVector();
69797405 switch (hitSomething)
....@@ -6986,7 +7412,7 @@
69867412
69877413 scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
69887414
6989
- if (modified)
7415
+ if (modified || opposite)
69907416 {
69917417 //assert(false);
69927418 /*
....@@ -7080,6 +7506,7 @@
70807506
70817507 if (modified)
70827508 {
7509
+ // Rotate 90 degrees
70837510 angle /= (Math.PI / 4);
70847511 angle = Math.floor(angle + 0.5);
70857512 angle *= (Math.PI / 4);
....@@ -7121,24 +7548,27 @@
71217548
71227549 case hitScale: // scale
71237550 double hScale = (double) (info.x - centerPt.x) / 32;
7551
+ double sign = 1;
7552
+ if (hScale < 0)
7553
+ {
7554
+ sign = -1;
7555
+ }
7556
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
71247557 if (hScale < 0.01)
71257558 {
7126
- hScale = 0.01;
7559
+ //hScale = 0.01;
71277560 }
7128
- hScale = Math.pow(hScale, scale * 50);
7129
- if (hScale < 0.01)
7130
- {
7131
- hScale = 0.01;
7132
- }
7561
+
71337562 double vScale = (double) (info.y - centerPt.y) / 32;
7134
- if (vScale < 0.01)
7563
+ sign = 1;
7564
+ if (vScale < 0)
71357565 {
7136
- vScale = 0.01;
7566
+ sign = -1;
71377567 }
7138
- vScale = Math.pow(vScale, scale * 50);
7568
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
71397569 if (vScale < 0.01)
71407570 {
7141
- vScale = 0.01;
7571
+ //vScale = 0.01;
71427572 }
71437573 LA.matCopy(startMat, toParent);
71447574 /**/
....@@ -7149,39 +7579,47 @@
71497579 }
71507580 /**/
71517581
7582
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7583
+
7584
+ if (totalScale < 0.01)
7585
+ {
7586
+ totalScale = 0.01;
7587
+ }
7588
+
71527589 switch (info.pane.RenderCamera().viewCode)
71537590 {
71547591 case 3: // '\001'
7155
- if (modified)
7592
+ if (modified || opposite)
71567593 {
71577594 //LA.matScale(toParent, 1, hScale, vScale);
7158
- LA.matScale(toParent, vScale, 1, 1);
7595
+ LA.matScale(toParent, totalScale, 1, 1);
71597596 } // vScale, 1);
71607597 else
71617598 {
7162
- LA.matScale(toParent, vScale, vScale, vScale);
7599
+ // EXCEPTION!
7600
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
71637601 } // vScale, 1);
71647602 break;
71657603
71667604 case 2: // '\002'
7167
- if (modified)
7605
+ if (modified || opposite)
71687606 {
71697607 //LA.matScale(toParent, hScale, 1, vScale);
7170
- LA.matScale(toParent, 1, vScale, 1);
7608
+ LA.matScale(toParent, 1, totalScale, 1);
71717609 } else
71727610 {
7173
- LA.matScale(toParent, vScale, 1, vScale);
7611
+ LA.matScale(toParent, totalScale, 1, totalScale);
71747612 }
71757613 break;
71767614
71777615 case 1: // '\003'
7178
- if (modified)
7616
+ if (modified || opposite)
71797617 {
71807618 //LA.matScale(toParent, hScale, vScale, 1);
7181
- LA.matScale(toParent, 1, 1, vScale);
7619
+ LA.matScale(toParent, 1, 1, totalScale);
71827620 } else
71837621 {
7184
- LA.matScale(toParent, vScale, vScale, 1);
7622
+ LA.matScale(toParent, totalScale, totalScale, 1);
71857623 }
71867624 break;
71877625 }
....@@ -7314,14 +7752,22 @@
73147752 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
73157753 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
73167754 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7755
+
7756
+ String objname;
7757
+
73177758 if (false) //parent != null)
73187759 {
7319
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7760
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
73207761 } else
73217762 {
7322
- return GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ") ")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ +System.identityHashCode(this);
7763
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
73237764 } // + super.toString();
73247765 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
7766
+
7767
+ if (!Globals.ADVANCED)
7768
+ return objname;
7769
+
7770
+ return objname + " " + System.identityHashCode(this);
73257771 }
73267772
73277773 public int hashCode()
....@@ -7377,6 +7823,7 @@
73777823 objectUI.closeUI();
73787824 if (editWindow != null)
73797825 {
7826
+ editWindow.ctrlPanel.FlushUI();
73807827 editWindow.refreshContents();
73817828 } // ? new
73827829 objectUI = null;
....@@ -7385,6 +7832,10 @@
73857832 {
73867833 editWindow = null;
73877834 } // ?
7835
+ }
7836
+ else
7837
+ {
7838
+ //editWindow.closeUI();
73887839 }
73897840 }
73907841
....@@ -7397,7 +7848,7 @@
73977848 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
73987849
73997850 Object3D /*Composite*/ parent;
7400
- Object3D /*Composite*/ fileparent;
7851
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
74017852
74027853 double[][] toParent; // dynamic matrix
74037854 double[][] fromParent;
....@@ -7512,7 +7963,7 @@
75127963 {
75137964 assert(bRep != null);
75147965 if (!(support instanceof GenericJoint)) // support.bRep != null)
7515
- GrafreeD.Assert(support.bRep == bRep.support);
7966
+ Grafreed.Assert(support.bRep == bRep.support);
75167967 }
75177968 else
75187969 {
....@@ -7543,6 +7994,10 @@
75437994 }
75447995
75457996 transient ObjEditor editWindow;
7997
+ transient ObjEditor manipWindow;
7998
+
7999
+ transient boolean pinned;
8000
+
75468001 transient ObjectUI objectUI;
75478002 public static int povDepth = 0;
75488003 private static cVector tbMin = new cVector();
....@@ -7561,9 +8016,9 @@
75618016 private static cVector edge2 = new cVector();
75628017 //private static cVector norm = new cVector();
75638018 /*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;
8019
+ static final int hitCenter = 1;
8020
+ static final int hitScale = 2;
8021
+ static final int hitRotate = 3;
75678022 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
75688023 /*transient*/ private Point centerPt;
75698024 /*transient*/ private int startX;