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;
....@@ -2906,7 +3089,8 @@
29063089 {
29073090 if (bRep != null)
29083091 {
2909
- bRep.GenUV();
3092
+ bRep.GenUV(); //1);
3093
+ //bRep.UnfoldUV();
29103094 Touch();
29113095 }
29123096 }
....@@ -2916,6 +3100,15 @@
29163100 if (bRep != null)
29173101 {
29183102 bRep.GenerateNormals(crease);
3103
+ Touch();
3104
+ }
3105
+ }
3106
+
3107
+ void GenNormalsMesh0()
3108
+ {
3109
+ if (bRep != null)
3110
+ {
3111
+ bRep.GenerateNormalsMesh();
29193112 Touch();
29203113 }
29213114 }
....@@ -2981,6 +3174,33 @@
29813174 blockloop = false;
29823175 }
29833176
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
+
29843204 void TransformGeometry()
29853205 {
29863206 Object3D obj = this;
....@@ -3202,9 +3422,11 @@
32023422
32033423 BoundaryRep sup = bRep.support;
32043424 bRep.support = null;
3205
- BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
3425
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
32063426 // bRep.SplitInTwo(onlyone); // thread...
3207
- temprep.SplitInTwo(reduction34, onlyone);
3427
+
3428
+ while(temprep.SplitInTwo(reduction34, onlyone));
3429
+
32083430 bRep = temprep;
32093431 bRep.support = sup;
32103432 Touch();
....@@ -3341,7 +3563,8 @@
33413563 if (blockloop)
33423564 return;
33433565
3344
- if (marked || (bRep != null && material != null)) // borderline...
3566
+ if (//marked || // does not make sense
3567
+ (bRep != null || material != null)) // borderline...
33453568 live = h;
33463569
33473570 for (int i = 0; i < Size(); i++)
....@@ -3362,7 +3585,8 @@
33623585 return;
33633586
33643587 //if (bRep != null)
3365
- if (marked || (bRep != null && material != null)) // borderline...
3588
+ if (//marked || // does not make sense
3589
+ (bRep != null || material != null)) // borderline...
33663590 link2master = h;
33673591
33683592 for (int i = 0; i < Size(); i++)
....@@ -3382,7 +3606,8 @@
33823606 if (blockloop)
33833607 return;
33843608
3385
- if (marked || (bRep != null && material != null)) // borderline...
3609
+ if (//marked || // does not make sense
3610
+ (bRep != null || material != null)) // borderline...
33863611 hide = h;
33873612
33883613 for (int i = 0; i < Size(); i++)
....@@ -3402,7 +3627,7 @@
34023627 if (blockloop)
34033628 return;
34043629
3405
- if (bRep != null && material != null) // borderline...
3630
+ if (bRep != null || material != null) // borderline...
34063631 marked = h;
34073632
34083633 for (int i = 0; i < Size(); i++)
....@@ -3412,6 +3637,46 @@
34123637 continue;
34133638 blockloop = true;
34143639 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);
34153680 blockloop = false;
34163681 // release(i);
34173682 }
....@@ -3726,7 +3991,7 @@
37263991 if (child == null)
37273992 continue;
37283993
3729
- if (GrafreeD.RENDERME > 0)
3994
+ if (Grafreed.RENDERME > 0)
37303995 {
37313996 if (child instanceof Merge)
37323997 ((Merge)child).renderme();
....@@ -3877,7 +4142,7 @@
38774142 if (child == null)
38784143 continue;
38794144
3880
- if (GrafreeD.RENDERME > 0)
4145
+ if (Grafreed.RENDERME > 0)
38814146 {
38824147 if (child instanceof Merge)
38834148 ((Merge)child).renderme();
....@@ -4072,7 +4337,7 @@
40724337 if (child == null)
40734338 continue;
40744339
4075
- if (GrafreeD.RENDERME > 0)
4340
+ if (Grafreed.RENDERME > 0)
40764341 {
40774342 if (child instanceof Merge)
40784343 ((Merge)child).renderme();
....@@ -4185,6 +4450,55 @@
41854450 {
41864451 blockloop = true;
41874452 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();
41884502 blockloop = false;
41894503 }
41904504 }
....@@ -4679,7 +4993,7 @@
46794993
46804994 cTreePath SelectLeaf(int indexcount, boolean deselect)
46814995 {
4682
- if (hide)
4996
+ if (hide || dontselect)
46834997 return null;
46844998
46854999 if (count <= 0)
....@@ -4703,9 +5017,17 @@
47035017 }
47045018 }
47055019
5020
+ ObjEditor GetWindow()
5021
+ {
5022
+ if (editWindow != null)
5023
+ return editWindow;
5024
+
5025
+ return manipWindow;
5026
+ }
5027
+
47065028 cTreePath Select(int indexcount, boolean deselect)
47075029 {
4708
- if (hide)
5030
+ if (hide || dontselect)
47095031 return null;
47105032
47115033 if (count <= 0)
....@@ -4739,10 +5061,11 @@
47395061 if (leaf != null)
47405062 {
47415063 cTreePath tp = new cTreePath(this, leaf);
4742
- if (editWindow != null)
5064
+ ObjEditor window = GetWindow();
5065
+ if (window != null)
47435066 {
47445067 //System.out.println("editWindow = " + editWindow + " vs " + this);
4745
- editWindow.Select(tp, deselect, true);
5068
+ window.Select(tp, deselect, true);
47465069 }
47475070
47485071 return tp;
....@@ -4759,6 +5082,7 @@
47595082
47605083 if (child == null)
47615084 continue;
5085
+
47625086 if (child.HasTransparency() && child.size() != 0)
47635087 {
47645088 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4768,9 +5092,10 @@
47685092 if (leaf != null)
47695093 {
47705094 cTreePath tp = new cTreePath(this, leaf);
4771
- if (editWindow != null)
5095
+ ObjEditor window = GetWindow();
5096
+ if (window != null)
47725097 {
4773
- editWindow.Select(tp, deselect, true);
5098
+ window.Select(tp, deselect, true);
47745099 }
47755100
47765101 return tp;
....@@ -5157,10 +5482,34 @@
51575482
51585483 // System.out.println("Fullname = " + fullname);
51595484
5160
- if (fullname.name.indexOf(":") == -1)
5161
- 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(":"));
51625490
5163
- 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];
51645513 }
51655514
51665515 static String GetBump(cTexture fullname)
....@@ -5169,10 +5518,38 @@
51695518 return "";
51705519
51715520 // System.out.println("Fullname = " + fullname);
5172
- if (fullname.name.indexOf(":") == -1)
5173
- return "";
5174
-
5175
- return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
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];
51765553 }
51775554
51785555 String GetPigmentTexture()
....@@ -5246,7 +5623,7 @@
52465623 System.out.print("; textures = " + textures);
52475624 System.out.println("; usedtextures = " + usedtextures);
52485625
5249
- if (GetTextures() == null)
5626
+ if (GetTextures() == null) // What is that??
52505627 GetTextures().name = ":";
52515628
52525629 String texname = tex;
....@@ -5277,6 +5654,43 @@
52775654 child.ResetPigmentTexture();
52785655 blockloop = false;
52795656 }
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;
52805694 }
52815695
52825696 void SetBumpTexture(String tex)
....@@ -5323,12 +5737,23 @@
53235737 boolean NeedSupport()
53245738 {
53255739 return
5326
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5740
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
53275741 // PROBLEM with CROWD!!
5328
- && (Globals.DrawMode() == iCameraPane.SHADOW || Globals.CROWD);
5742
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
53295743 }
53305744
53315745 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
+ }
53325757
53335758 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
53345759 {
....@@ -5340,7 +5765,7 @@
53405765 }
53415766
53425767 if (display.DrawMode() == iCameraPane.SELECTION &&
5343
- hide)
5768
+ (hide || dontselect))
53445769 return;
53455770
53465771 if (name != null && name.contains("sclera"))
....@@ -5391,7 +5816,7 @@
53915816 support = support;
53925817
53935818 //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5394
- boolean usecalllists = false; // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5819
+ boolean usecalllists = !IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
53955820
53965821 if (!usecalllists && bRep != null && bRep.displaylist > 0)
53975822 {
....@@ -5411,10 +5836,12 @@
54115836 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
54125837
54135838 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5414
- (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)))
54155841 {
54165842 Globals.lighttouched = true;
54175843 } // all panes...
5844
+
54185845 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
54195846 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
54205847 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5542,6 +5969,7 @@
55425969 if (GetBRep() != null)
55435970 {
55445971 display.NextIndex();
5972
+
55455973 // vertex color conflict : gl.glCallList(list);
55465974 DrawNode(display, root, selected);
55475975 if (this instanceof BezierPatch)
....@@ -5582,7 +6010,28 @@
55826010 tex = GetTextures();
55836011 }
55846012
5585
- 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
+ }
55866035
55876036 if (!compiled)
55886037 {
....@@ -5604,7 +6053,11 @@
56046053 }
56056054 }
56066055
5607
- display.ReleaseTextures(tex);
6056
+ if (!failedBump)
6057
+ display.ReleaseBumpTexture(tex);
6058
+
6059
+ if (!failedPigment)
6060
+ display.ReleasePigmentTexture(tex);
56086061
56096062 display.PopMaterial(this, selected);
56106063 }
....@@ -5733,6 +6186,9 @@
57336186
57346187 void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57356188 {
6189
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6190
+ return;
6191
+
57366192 if (hide)
57376193 return;
57386194 // shadow optimisation
....@@ -5858,6 +6314,9 @@
58586314 if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
58596315 return; // no shadow for transparent objects
58606316
6317
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6318
+ return;
6319
+
58616320 if (hide)
58626321 return;
58636322
....@@ -5898,6 +6357,7 @@
58986357 return;
58996358 }
59006359
6360
+ //bRep.GenUV(1/material.diffuseness);
59016361 // bRep.lock = true;
59026362
59036363 //javax.media.opengl.GL gl = display.GetGL();
....@@ -5970,6 +6430,11 @@
59706430 // dec 2012
59716431 new Exception().printStackTrace();
59726432 return;
6433
+ }
6434
+
6435
+ if (dontselect)
6436
+ {
6437
+ //bRep.GenerateNormalsMINE();
59736438 }
59746439
59756440 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -6822,7 +7287,7 @@
68227287 spot.translate(32, 32);
68237288 spotw = spot.x + spot.width;
68247289 spoth = spot.y + spot.height;
6825
- info.g.setColor(Color.blue);
7290
+ info.g.setColor(Color.cyan);
68267291 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
68277292 // if (CameraPane.Xmin > spot.x)
68287293 // {
....@@ -6840,11 +7305,12 @@
68407305 // {
68417306 // CameraPane.Ymax = spoth;
68427307 // }
6843
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
6844
- 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
68457310 spot.translate(0, -32);
6846
- info.g.setColor(Color.green);
7311
+ info.g.setColor(Color.yellow);
68477312 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7313
+ info.g.setColor(Color.green);
68487314 // if (CameraPane.Xmin > spot.x)
68497315 // {
68507316 // CameraPane.Xmin = spot.x;
....@@ -6861,8 +7327,8 @@
68617327 // {
68627328 // CameraPane.Ymax = spoth;
68637329 // }
6864
- info.g.drawArc(boundary.x, boundary.y,
6865
- 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);
68667332 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
68677333 // if (CameraPane.Xmin > boundary.x)
68687334 // {
....@@ -6896,7 +7362,7 @@
68967362 startX = info.x;
68977363 startY = info.y;
68987364
6899
- hitSomething = 0;
7365
+ hitSomething = -1;
69007366 cVector origin = new cVector();
69017367 //LA.xformPos(origin, toParent, origin);
69027368 Rectangle spot = new Rectangle();
....@@ -6929,7 +7395,7 @@
69297395 }
69307396
69317397 //System.out.println("info.modifiers = " + info.modifiers);
6932
- modified = (info.modifiers & CameraPane.META) != 0;
7398
+ modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
69337399 //System.out.println("modified = " + modified);
69347400 //new Exception().printStackTrace();
69357401 //viewCode = info.pane.renderCamera.viewCode;
....@@ -6957,7 +7423,7 @@
69577423 return true;
69587424 }
69597425
6960
- void doEditDrag0(ClickInfo info)
7426
+ void doEditDrag0(ClickInfo info, boolean opposite)
69617427 {
69627428 if (hitSomething == 0)
69637429 {
....@@ -6972,6 +7438,7 @@
69727438 //System.out.println("hitSomething = " + hitSomething);
69737439
69747440 double scale = 0.005f * info.camera.Distance();
7441
+
69757442 cVector xlate = new cVector();
69767443 //cVector xlate2 = new cVector();
69777444 switch (hitSomething)
....@@ -6984,7 +7451,7 @@
69847451
69857452 scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
69867453
6987
- if (modified)
7454
+ if (modified || opposite)
69887455 {
69897456 //assert(false);
69907457 /*
....@@ -7078,6 +7545,7 @@
70787545
70797546 if (modified)
70807547 {
7548
+ // Rotate 90 degrees
70817549 angle /= (Math.PI / 4);
70827550 angle = Math.floor(angle + 0.5);
70837551 angle *= (Math.PI / 4);
....@@ -7119,24 +7587,27 @@
71197587
71207588 case hitScale: // scale
71217589 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);
71227596 if (hScale < 0.01)
71237597 {
7124
- hScale = 0.01;
7598
+ //hScale = 0.01;
71257599 }
7126
- hScale = Math.pow(hScale, scale * 50);
7127
- if (hScale < 0.01)
7128
- {
7129
- hScale = 0.01;
7130
- }
7600
+
71317601 double vScale = (double) (info.y - centerPt.y) / 32;
7132
- if (vScale < 0.01)
7602
+ sign = 1;
7603
+ if (vScale < 0)
71337604 {
7134
- vScale = 0.01;
7605
+ sign = -1;
71357606 }
7136
- vScale = Math.pow(vScale, scale * 50);
7607
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
71377608 if (vScale < 0.01)
71387609 {
7139
- vScale = 0.01;
7610
+ //vScale = 0.01;
71407611 }
71417612 LA.matCopy(startMat, toParent);
71427613 /**/
....@@ -7147,39 +7618,47 @@
71477618 }
71487619 /**/
71497620
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
+
71507628 switch (info.pane.RenderCamera().viewCode)
71517629 {
71527630 case 3: // '\001'
7153
- if (modified)
7631
+ if (modified || opposite)
71547632 {
71557633 //LA.matScale(toParent, 1, hScale, vScale);
7156
- LA.matScale(toParent, vScale, 1, 1);
7634
+ LA.matScale(toParent, totalScale, 1, 1);
71577635 } // vScale, 1);
71587636 else
71597637 {
7160
- LA.matScale(toParent, vScale, vScale, vScale);
7638
+ // EXCEPTION!
7639
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
71617640 } // vScale, 1);
71627641 break;
71637642
71647643 case 2: // '\002'
7165
- if (modified)
7644
+ if (modified || opposite)
71667645 {
71677646 //LA.matScale(toParent, hScale, 1, vScale);
7168
- LA.matScale(toParent, 1, vScale, 1);
7647
+ LA.matScale(toParent, 1, totalScale, 1);
71697648 } else
71707649 {
7171
- LA.matScale(toParent, vScale, 1, vScale);
7650
+ LA.matScale(toParent, totalScale, 1, totalScale);
71727651 }
71737652 break;
71747653
71757654 case 1: // '\003'
7176
- if (modified)
7655
+ if (modified || opposite)
71777656 {
71787657 //LA.matScale(toParent, hScale, vScale, 1);
7179
- LA.matScale(toParent, 1, 1, vScale);
7658
+ LA.matScale(toParent, 1, 1, totalScale);
71807659 } else
71817660 {
7182
- LA.matScale(toParent, vScale, vScale, 1);
7661
+ LA.matScale(toParent, totalScale, totalScale, 1);
71837662 }
71847663 break;
71857664 }
....@@ -7312,14 +7791,22 @@
73127791 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
73137792 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
73147793 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7794
+
7795
+ String objname;
7796
+
73157797 if (false) //parent != null)
73167798 {
7317
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7799
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
73187800 } else
73197801 {
7320
- 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) ":"") */ "";
73217803 } // + super.toString();
73227804 //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);
73237810 }
73247811
73257812 public int hashCode()
....@@ -7375,6 +7862,7 @@
73757862 objectUI.closeUI();
73767863 if (editWindow != null)
73777864 {
7865
+ editWindow.ctrlPanel.FlushUI();
73787866 editWindow.refreshContents();
73797867 } // ? new
73807868 objectUI = null;
....@@ -7383,6 +7871,10 @@
73837871 {
73847872 editWindow = null;
73857873 } // ?
7874
+ }
7875
+ else
7876
+ {
7877
+ //editWindow.closeUI();
73867878 }
73877879 }
73887880
....@@ -7395,7 +7887,7 @@
73957887 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
73967888
73977889 Object3D /*Composite*/ parent;
7398
- Object3D /*Composite*/ fileparent;
7890
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
73997891
74007892 double[][] toParent; // dynamic matrix
74017893 double[][] fromParent;
....@@ -7510,7 +8002,7 @@
75108002 {
75118003 assert(bRep != null);
75128004 if (!(support instanceof GenericJoint)) // support.bRep != null)
7513
- GrafreeD.Assert(support.bRep == bRep.support);
8005
+ Grafreed.Assert(support.bRep == bRep.support);
75148006 }
75158007 else
75168008 {
....@@ -7541,6 +8033,10 @@
75418033 }
75428034
75438035 transient ObjEditor editWindow;
8036
+ transient ObjEditor manipWindow;
8037
+
8038
+ transient boolean pinned;
8039
+
75448040 transient ObjectUI objectUI;
75458041 public static int povDepth = 0;
75468042 private static cVector tbMin = new cVector();
....@@ -7559,9 +8055,9 @@
75598055 private static cVector edge2 = new cVector();
75608056 //private static cVector norm = new cVector();
75618057 /*transient private*/ int hitSomething;
7562
- private static final int hitCenter = 1;
7563
- private static final int hitScale = 2;
7564
- private static final int hitRotate = 3;
8058
+ static final int hitCenter = 1;
8059
+ static final int hitScale = 2;
8060
+ static final int hitRotate = 3;
75658061 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
75668062 /*transient*/ private Point centerPt;
75678063 /*transient*/ private int startX;