Normand Briere
2019-07-22 c570e1e38f2ff8622a71f81436654bad01cfdd5b
Object3D.java
....@@ -5,6 +5,7 @@
55 import java.util.Vector;
66
77 import javax.media.j3d.Transform3D;
8
+import javax.media.opengl.GL;
89 import javax.vecmath.Vector3d;
910
1011 import javax.imageio.ImageIO;
....@@ -13,12 +14,24 @@
1314 import //weka.core.
1415 matrix.Matrix;
1516
17
+import java.util.UUID;
18
+
1619 //import net.sourceforge.sizeof.SizeOf;
1720 public class Object3D extends Vector<Object3D> implements java.io.Serializable, iSendInfo //, aurelienribon.tweenengine.TweenAccessor<Object3D>
1821 {
1922 //static final long serialVersionUID = -607422624994562685L;
2023 static final long serialVersionUID = 5022536242724664900L;
2124
25
+ private UUID uuid = UUID.randomUUID();
26
+
27
+ // TEMPORARY for mocap undo. No need to be transient.
28
+ mocap.reader.BVHReader.BVHResult savebvh;
29
+ Object3D saveskeleton;
30
+ //
31
+
32
+ byte[] versions[];
33
+ int versionindex = -1;
34
+
2235 ScriptNode scriptnode;
2336
2437 void InitOthers()
....@@ -99,64 +112,178 @@
99112
100113 // transient boolean reduced; // for morph reduction
101114
102
-transient com.bulletphysics.linearmath.Transform cache; // for fast merge
103
-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
104117
105
-transient Object3D transientsupport; // for cloning
106
-transient boolean transientlink2master;
118
+ transient Object3D transientsupport; // for cloning
119
+ transient boolean transientlink2master;
107120
108
-void SaveSupports()
109
-{
110
- if (blockloop)
111
- return;
112
-
113
- transientsupport = support;
114
- transientlink2master = link2master;
115
-
116
- support = null;
117
- link2master = false;
118
-
119
- if (bRep != null)
121
+ void SaveSupports()
120122 {
121
- 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
+ }
122146 }
123
-
124
- for (int i = 0; i < Size(); i++)
147
+
148
+ void RestoreSupports()
125149 {
126
- Object3D child = (Object3D) get(i);
127
- if (child == null)
128
- 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
+
129258 blockloop = true;
130
- child.SaveSupports();
259
+
260
+ //hashtable.remove(GetUUID());
261
+
262
+ for (int i=0; i<Size(); i++)
263
+ {
264
+ get(i).RestoreBigData(hashtable);
265
+ }
266
+
131267 blockloop = false;
132268 }
133
-}
134269
135
-void RestoreSupports()
136
-{
137
- if (blockloop)
138
- return;
139
-
140
- support = transientsupport;
141
- link2master = transientlink2master;
142
- transientsupport = null;
143
- transientlink2master = false;
144
-
145
- if (bRep != null)
270
+ void RestoreBigData(Object3D o)
146271 {
147
- 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;
148286 }
149
-
150
- for (int i = 0; i < Size(); i++)
151
- {
152
- Object3D child = (Object3D) get(i);
153
- if (child == null)
154
- continue;
155
- blockloop = true;
156
- child.RestoreSupports();
157
- blockloop = false;
158
- }
159
-}
160287
161288 // MOCAP SUPPORT
162289 double tx,ty,tz,rx,ry,rz;
....@@ -299,6 +426,8 @@
299426 }
300427
301428 boolean live = false;
429
+ transient boolean keepdontselect;
430
+ boolean dontselect = false;
302431 boolean hide = false;
303432 boolean link2master = false; // performs reset support/master at each frame
304433 boolean marked = false; // animation node
....@@ -430,16 +559,16 @@
430559 {
431560 Object3D copy = this;
432561
433
- Camera parentcam = CameraPane.theRenderer.manipCamera;
562
+ Camera parentcam = Globals.theRenderer.ManipCamera();
434563
435
- if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[0])
564
+ if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[0])
436565 {
437
- parentcam = CameraPane.theRenderer.cameras[1];
566
+ parentcam = Globals.theRenderer.Cameras()[1];
438567 }
439568
440
- if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[1])
569
+ if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[1])
441570 {
442
- parentcam = CameraPane.theRenderer.cameras[0];
571
+ parentcam = Globals.theRenderer.Cameras()[0];
443572 }
444573
445574 if (this == parentcam)
....@@ -447,7 +576,7 @@
447576 //assert(this instanceof Camera);
448577
449578 for (int count = parentcam.GetTransformCount(); --count>=0;)
450
- LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.toParent, CameraPane.theRenderer.targetLookAt);
579
+ LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.toParent, Globals.theRenderer.TargetLookAt());
451580 }
452581
453582 copy.marked ^= true;
....@@ -467,7 +596,7 @@
467596 //assert(this instanceof Camera);
468597
469598 for (int count = parentcam.GetTransformCount(); --count>=0;)
470
- LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.fromParent, CameraPane.theRenderer.targetLookAt);
599
+ LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.fromParent, Globals.theRenderer.TargetLookAt());
471600 }
472601
473602 copy.Touch(); // display list issue
....@@ -480,12 +609,14 @@
480609 toParent = LA.newMatrix();
481610 fromParent = LA.newMatrix();
482611 }
612
+
483613 if (toParentMarked == null)
484614 {
485615 if (maxcount != 1)
486616 {
487617 new Exception().printStackTrace();
488618 }
619
+
489620 toParentMarked = LA.newMatrix();
490621 fromParentMarked = LA.newMatrix();
491622 }
....@@ -602,7 +733,7 @@
602733 return;
603734 }
604735
605
- if (CameraPane.fromscript)
736
+ if (Globals.fromscript)
606737 {
607738 transformcount = 0;
608739 return;
....@@ -773,7 +904,7 @@
773904 if (step == 0)
774905 step = 1;
775906 if (maxcount == 0)
776
- maxcount = 2048; // 4;
907
+ maxcount = 128; // 2048; // 4;
777908 // if (acceleration == 0)
778909 // acceleration = 10;
779910 if (delay == 0) // serial
....@@ -796,7 +927,7 @@
796927
797928 if (marked && Globals.isLIVE() && live &&
798929 //TEMP21aug2018
799
- Globals.DrawMode() == iCameraPane.SHADOW &&
930
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
800931 currentframe != Globals.framecount)
801932 {
802933 currentframe = Globals.framecount;
....@@ -808,7 +939,8 @@
808939
809940 boolean changedir = random && Math.random() < 0.01; // && !link2master;
810941
811
- if (transformcount*factor > maxcount || (step == 1 && changedir))
942
+ if (transformcount*factor >= maxcount && (rewind || random) ||
943
+ (step == 1 && changedir))
812944 {
813945 countdown = 1;
814946 delay = speedup?8:1;
....@@ -880,6 +1012,7 @@
8801012 if (material == null || material.multiply)
8811013 return true;
8821014
1015
+ // Transparent objects are dynamic because we have to sort the triangles.
8831016 return material.opacity > 0.99;
8841017 }
8851018
....@@ -911,6 +1044,11 @@
9111044 fromParent = null; // LA.newMatrix();
9121045 bRep = null; // new BoundaryRep();
9131046
1047
+ if (oname != null && oname.equals("LeftHand"))
1048
+ {
1049
+ name = oname;
1050
+ }
1051
+
9141052 /*
9151053 float hue = (float)Math.random();
9161054 Color col;
....@@ -953,7 +1091,7 @@
9531091
9541092 public Object clone()
9551093 {
956
- return GrafreeD.clone(this);
1094
+ return Grafreed.clone(this);
9571095 }
9581096
9591097 Object3D copyExpand()
....@@ -1275,6 +1413,7 @@
12751413 toParent = LA.newMatrix();
12761414 fromParent = LA.newMatrix();
12771415 }
1416
+
12781417 LA.matCopy(other.toParent, toParent);
12791418 LA.matCopy(other.fromParent, fromParent);
12801419
....@@ -1469,7 +1608,7 @@
14691608 BoundaryRep.SEUIL = other.material.cameralight;
14701609
14711610 // Set default to 0.1
1472
- BoundaryRep.SEUIL /= 2;
1611
+ BoundaryRep.SEUIL /= 4; // 2;
14731612 System.out.println("SEUIL = " + BoundaryRep.SEUIL);
14741613 }
14751614
....@@ -1728,7 +1867,7 @@
17281867 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17291868 o.bRep = transientrep;
17301869 if (clone)
1731
- o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
1870
+ o.bRep = (BoundaryRep) Grafreed.clone(transientrep);
17321871 o.CreateMaterial();
17331872 o.SetAttributes(this, -1);
17341873 //parent
....@@ -1741,7 +1880,7 @@
17411880 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17421881 o.bRep = bRep;
17431882 if (clone)
1744
- o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
1883
+ o.bRep = (BoundaryRep) Grafreed.clone(bRep);
17451884 o.CreateMaterial();
17461885 //o.overwriteThis(this, -1);
17471886 o.SetAttributes(this, -1);
....@@ -1828,12 +1967,15 @@
18281967 if (obj.name == null)
18291968 continue; // can't be a null one
18301969
1970
+ // Try perfect match first.
18311971 if (n.equals(obj.name))
18321972 {
18331973 theobj = obj;
18341974 count++;
18351975 }
18361976 }
1977
+
1978
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18371979
18381980 if (count != 1)
18391981 for (int i=Size(); --i>=0;)
....@@ -2293,12 +2435,17 @@
22932435 }
22942436 */
22952437 }
2438
+ else
2439
+ {
2440
+ //((ObjEditor)editWindow).SetupUI2(null);
2441
+ }
22962442 }
22972443
22982444 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
22992445 {
23002446 if (newWindow)
23012447 {
2448
+ new Exception().printStackTrace();
23022449 System.exit(0);
23032450 if (parent != null)
23042451 {
....@@ -2333,6 +2480,14 @@
23332480 {
23342481 editWindow.refreshContents();
23352482 }
2483
+ else
2484
+ {
2485
+ if (manipWindow != null)
2486
+ {
2487
+ manipWindow.refreshContents();
2488
+ }
2489
+ }
2490
+
23362491 //if (parent != null)
23372492 //parent.refreshEditWindow();
23382493 }
....@@ -2475,13 +2630,13 @@
24752630 return retval;
24762631 }
24772632
2478
- void doEditDrag(ClickInfo info)
2633
+ void doEditDrag(ClickInfo info, boolean opposite)
24792634 {
24802635 switch (doSomething)
24812636 {
24822637 case 1: // '\001'
24832638 //super.
2484
- doEditDrag0(info);
2639
+ doEditDrag0(info, opposite);
24852640 break;
24862641
24872642 case 2: // '\002'
....@@ -2494,11 +2649,11 @@
24942649 {
24952650 //sel.hitSomething = childToDrag.hitSomething;
24962651 //childToDrag.doEditDrag(info);
2497
- sel.doEditDrag(info);
2652
+ sel.doEditDrag(info, opposite);
24982653 } else
24992654 {
25002655 //super.
2501
- doEditDrag0(info);
2656
+ doEditDrag0(info, opposite);
25022657 }
25032658 }
25042659 break;
....@@ -2608,6 +2763,18 @@
26082763 void GenNormalsS(boolean crease)
26092764 {
26102765 selection.GenNormals(crease);
2766
+// for (int i=0; i<selection.size(); i++)
2767
+// {
2768
+// Object3D selectee = (Object3D) selection.elementAt(i);
2769
+// selectee.GenNormals(crease);
2770
+// }
2771
+
2772
+ //Touch();
2773
+ }
2774
+
2775
+ void GenNormalsMeshS()
2776
+ {
2777
+ selection.GenNormalsMesh();
26112778 // for (int i=0; i<selection.size(); i++)
26122779 // {
26132780 // Object3D selectee = (Object3D) selection.elementAt(i);
....@@ -2748,6 +2915,24 @@
27482915 if (child == null)
27492916 continue;
27502917 child.GenNormals(crease);
2918
+// Children().release(i);
2919
+ }
2920
+ blockloop = false;
2921
+ }
2922
+
2923
+ void GenNormalsMesh()
2924
+ {
2925
+ if (blockloop)
2926
+ return;
2927
+
2928
+ blockloop = true;
2929
+ GenNormalsMesh0();
2930
+ for (int i = 0; i < Children().Size(); i++)
2931
+ {
2932
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2933
+ if (child == null)
2934
+ continue;
2935
+ child.GenNormalsMesh();
27512936 // Children().release(i);
27522937 }
27532938 blockloop = false;
....@@ -2905,7 +3090,8 @@
29053090 {
29063091 if (bRep != null)
29073092 {
2908
- bRep.GenUV();
3093
+ bRep.GenUV(); //1);
3094
+ //bRep.UnfoldUV();
29093095 Touch();
29103096 }
29113097 }
....@@ -2919,11 +3105,20 @@
29193105 }
29203106 }
29213107
3108
+ void GenNormalsMesh0()
3109
+ {
3110
+ if (bRep != null)
3111
+ {
3112
+ bRep.GenerateNormalsMesh();
3113
+ Touch();
3114
+ }
3115
+ }
3116
+
29223117 void GenNormalsMINE0()
29233118 {
29243119 if (bRep != null)
29253120 {
2926
- bRep.GenerateNormalsMINE();
3121
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
29273122 Touch();
29283123 }
29293124 }
....@@ -2980,6 +3175,33 @@
29803175 blockloop = false;
29813176 }
29823177
3178
+ void TransformChildren()
3179
+ {
3180
+ if (toParent != null)
3181
+ {
3182
+ for (int i=Size(); --i>=0;)
3183
+ {
3184
+ Object3D v = get(i);
3185
+
3186
+ if (v.toParent == null)
3187
+ {
3188
+ v.toParent = LA.newMatrix();
3189
+ v.fromParent = LA.newMatrix();
3190
+ }
3191
+
3192
+// LA.matConcat(v.toParent, toParent, v.toParent);
3193
+// LA.matConcat(fromParent, v.fromParent, v.fromParent);
3194
+ LA.matConcat(toParent, v.toParent, v.toParent);
3195
+ LA.matConcat(v.fromParent, fromParent, v.fromParent);
3196
+ }
3197
+
3198
+ toParent = null; // LA.matIdentity(toParent);
3199
+ fromParent = null; // LA.matIdentity(fromParent);
3200
+
3201
+ Touch();
3202
+ }
3203
+ }
3204
+
29833205 void TransformGeometry()
29843206 {
29853207 Object3D obj = this;
....@@ -3201,9 +3423,11 @@
32013423
32023424 BoundaryRep sup = bRep.support;
32033425 bRep.support = null;
3204
- BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
3426
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
32053427 // bRep.SplitInTwo(onlyone); // thread...
3206
- temprep.SplitInTwo(reduction34, onlyone);
3428
+
3429
+ while(temprep.SplitInTwo(reduction34, onlyone));
3430
+
32073431 bRep = temprep;
32083432 bRep.support = sup;
32093433 Touch();
....@@ -3340,7 +3564,8 @@
33403564 if (blockloop)
33413565 return;
33423566
3343
- if (marked || (bRep != null && material != null)) // borderline...
3567
+ if (//marked || // does not make sense
3568
+ (bRep != null || material != null)) // borderline...
33443569 live = h;
33453570
33463571 for (int i = 0; i < Size(); i++)
....@@ -3361,7 +3586,8 @@
33613586 return;
33623587
33633588 //if (bRep != null)
3364
- if (marked || (bRep != null && material != null)) // borderline...
3589
+ if (//marked || // does not make sense
3590
+ (bRep != null || material != null)) // borderline...
33653591 link2master = h;
33663592
33673593 for (int i = 0; i < Size(); i++)
....@@ -3381,7 +3607,8 @@
33813607 if (blockloop)
33823608 return;
33833609
3384
- if (marked || (bRep != null && material != null)) // borderline...
3610
+ if (//marked || // does not make sense
3611
+ (bRep != null || material != null)) // borderline...
33853612 hide = h;
33863613
33873614 for (int i = 0; i < Size(); i++)
....@@ -3401,7 +3628,7 @@
34013628 if (blockloop)
34023629 return;
34033630
3404
- if (bRep != null && material != null) // borderline...
3631
+ if (bRep != null || material != null) // borderline...
34053632 marked = h;
34063633
34073634 for (int i = 0; i < Size(); i++)
....@@ -3411,6 +3638,46 @@
34113638 continue;
34123639 blockloop = true;
34133640 child.MarkLeaves(h);
3641
+ blockloop = false;
3642
+ // release(i);
3643
+ }
3644
+ }
3645
+
3646
+ void RewindLeaves(boolean h)
3647
+ {
3648
+ if (blockloop)
3649
+ return;
3650
+
3651
+ if (bRep != null || material != null) // borderline...
3652
+ rewind = h;
3653
+
3654
+ for (int i = 0; i < Size(); i++)
3655
+ {
3656
+ Object3D child = (Object3D) get(i); // reserve(i);
3657
+ if (child == null)
3658
+ continue;
3659
+ blockloop = true;
3660
+ child.RewindLeaves(h);
3661
+ blockloop = false;
3662
+ // release(i);
3663
+ }
3664
+ }
3665
+
3666
+ void RandomLeaves(boolean h)
3667
+ {
3668
+ if (blockloop)
3669
+ return;
3670
+
3671
+ if (bRep != null || material != null) // borderline...
3672
+ random = h;
3673
+
3674
+ for (int i = 0; i < Size(); i++)
3675
+ {
3676
+ Object3D child = (Object3D) get(i); // reserve(i);
3677
+ if (child == null)
3678
+ continue;
3679
+ blockloop = true;
3680
+ child.RandomLeaves(h);
34143681 blockloop = false;
34153682 // release(i);
34163683 }
....@@ -3725,7 +3992,7 @@
37253992 if (child == null)
37263993 continue;
37273994
3728
- if (GrafreeD.RENDERME > 0)
3995
+ if (Grafreed.RENDERME > 0)
37293996 {
37303997 if (child instanceof Merge)
37313998 ((Merge)child).renderme();
....@@ -3876,7 +4143,7 @@
38764143 if (child == null)
38774144 continue;
38784145
3879
- if (GrafreeD.RENDERME > 0)
4146
+ if (Grafreed.RENDERME > 0)
38804147 {
38814148 if (child instanceof Merge)
38824149 ((Merge)child).renderme();
....@@ -4071,7 +4338,7 @@
40714338 if (child == null)
40724339 continue;
40734340
4074
- if (GrafreeD.RENDERME > 0)
4341
+ if (Grafreed.RENDERME > 0)
40754342 {
40764343 if (child instanceof Merge)
40774344 ((Merge)child).renderme();
....@@ -4184,6 +4451,55 @@
41844451 {
41854452 blockloop = true;
41864453 get(i).RepairShadow();
4454
+ blockloop = false;
4455
+ }
4456
+ }
4457
+
4458
+ void RepairSOV()
4459
+ {
4460
+ if (blockloop)
4461
+ return;
4462
+
4463
+ String texname = this.GetPigmentTexture();
4464
+
4465
+ if (texname.startsWith("sov"))
4466
+ {
4467
+ String[] s = texname.split("/");
4468
+
4469
+ String[] sname = s[1].split("Color.pn");
4470
+
4471
+ texname = sname[0];
4472
+
4473
+ if (sname.length > 1)
4474
+ {
4475
+ texname += "Color.jpg";
4476
+ }
4477
+
4478
+ this.SetPigmentTexture("sov/" + texname);
4479
+ }
4480
+
4481
+ texname = this.GetBumpTexture();
4482
+
4483
+ if (texname.startsWith("sov"))
4484
+ {
4485
+ String[] s = texname.split("/");
4486
+
4487
+ String[] sname = s[1].split("Bump.pn");
4488
+
4489
+ texname = sname[0];
4490
+
4491
+ if (sname.length > 1)
4492
+ {
4493
+ texname += "Bump.jpg";
4494
+ }
4495
+
4496
+ this.SetBumpTexture("sov/" + texname);
4497
+ }
4498
+
4499
+ for (int i=0; i<Size(); i++)
4500
+ {
4501
+ blockloop = true;
4502
+ get(i).RepairSOV();
41874503 blockloop = false;
41884504 }
41894505 }
....@@ -4678,7 +4994,7 @@
46784994
46794995 cTreePath SelectLeaf(int indexcount, boolean deselect)
46804996 {
4681
- if (hide)
4997
+ if (hide || dontselect)
46824998 return null;
46834999
46845000 if (count <= 0)
....@@ -4702,9 +5018,17 @@
47025018 }
47035019 }
47045020
5021
+ ObjEditor GetWindow()
5022
+ {
5023
+ if (editWindow != null)
5024
+ return editWindow;
5025
+
5026
+ return manipWindow;
5027
+ }
5028
+
47055029 cTreePath Select(int indexcount, boolean deselect)
47065030 {
4707
- if (hide)
5031
+ if (hide || dontselect)
47085032 return null;
47095033
47105034 if (count <= 0)
....@@ -4738,10 +5062,11 @@
47385062 if (leaf != null)
47395063 {
47405064 cTreePath tp = new cTreePath(this, leaf);
4741
- if (editWindow != null)
5065
+ ObjEditor window = GetWindow();
5066
+ if (window != null)
47425067 {
47435068 //System.out.println("editWindow = " + editWindow + " vs " + this);
4744
- editWindow.Select(tp, deselect, true);
5069
+ window.Select(tp, deselect, true);
47455070 }
47465071
47475072 return tp;
....@@ -4758,6 +5083,7 @@
47585083
47595084 if (child == null)
47605085 continue;
5086
+
47615087 if (child.HasTransparency() && child.size() != 0)
47625088 {
47635089 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4767,9 +5093,10 @@
47675093 if (leaf != null)
47685094 {
47695095 cTreePath tp = new cTreePath(this, leaf);
4770
- if (editWindow != null)
5096
+ ObjEditor window = GetWindow();
5097
+ if (window != null)
47715098 {
4772
- editWindow.Select(tp, deselect, true);
5099
+ window.Select(tp, deselect, true);
47735100 }
47745101
47755102 return tp;
....@@ -4854,7 +5181,7 @@
48545181 return globalTransform;
48555182 }
48565183
4857
- void PreprocessOcclusion(CameraPane cp)
5184
+ void PreprocessOcclusion(iCameraPane cp)
48585185 {
48595186 /*
48605187 if (AOdone)
....@@ -5094,6 +5421,51 @@
50945421 blockloop = false;
50955422 }
50965423
5424
+ void ResetSelectable()
5425
+ {
5426
+ if (blockloop)
5427
+ return;
5428
+
5429
+ blockloop = true;
5430
+
5431
+ keepdontselect = dontselect;
5432
+ dontselect = true;
5433
+
5434
+ Object3D child;
5435
+ int nb = Size();
5436
+ for (int i = 0; i < nb; i++)
5437
+ {
5438
+ child = (Object3D) get(i);
5439
+ if (child == null)
5440
+ continue;
5441
+ child.ResetSelectable();
5442
+ }
5443
+
5444
+ blockloop = false;
5445
+ }
5446
+
5447
+ void RestoreSelectable()
5448
+ {
5449
+ if (blockloop)
5450
+ return;
5451
+
5452
+ blockloop = true;
5453
+
5454
+ dontselect = keepdontselect;
5455
+
5456
+ Object3D child;
5457
+ int nb = Size();
5458
+ for (int i = 0; i < nb; i++)
5459
+ {
5460
+ child = (Object3D) get(i);
5461
+ if (child == null)
5462
+ continue;
5463
+ child.RestoreSelectable();
5464
+ }
5465
+
5466
+ blockloop = false;
5467
+ }
5468
+
50975469 boolean IsSelected()
50985470 {
50995471 if (parent == null)
....@@ -5156,10 +5528,34 @@
51565528
51575529 // System.out.println("Fullname = " + fullname);
51585530
5159
- if (fullname.name.indexOf(":") == -1)
5160
- return fullname.name;
5531
+ // Does not work on Windows due to C:
5532
+// if (fullname.name.indexOf(":") == -1)
5533
+// return fullname.name;
5534
+//
5535
+// return fullname.name.substring(0,fullname.name.indexOf(":"));
51615536
5162
- return fullname.name.substring(0,fullname.name.indexOf(":"));
5537
+ String[] split = fullname.name.split(":");
5538
+
5539
+ if (split.length == 0)
5540
+ {
5541
+ return "";
5542
+ }
5543
+
5544
+ if (split.length <= 2)
5545
+ {
5546
+ if (fullname.name.endsWith(":"))
5547
+ {
5548
+ // Windows
5549
+ return fullname.name.substring(0, fullname.name.length()-1);
5550
+ }
5551
+
5552
+ return split[0];
5553
+ }
5554
+
5555
+ // Windows
5556
+ assert(split.length == 4);
5557
+
5558
+ return split[0] + ":" + split[1];
51635559 }
51645560
51655561 static String GetBump(cTexture fullname)
....@@ -5168,10 +5564,38 @@
51685564 return "";
51695565
51705566 // System.out.println("Fullname = " + fullname);
5171
- if (fullname.name.indexOf(":") == -1)
5172
- return "";
5173
-
5174
- return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5567
+ // Does not work on Windows due to C:
5568
+// if (fullname.name.indexOf(":") == -1)
5569
+// return "";
5570
+//
5571
+// return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5572
+ String[] split = fullname.name.split(":");
5573
+
5574
+ if (split.length == 0)
5575
+ {
5576
+ return "";
5577
+ }
5578
+
5579
+ if (split.length == 1)
5580
+ {
5581
+ return "";
5582
+ }
5583
+
5584
+ if (split.length == 2)
5585
+ {
5586
+ if (fullname.name.endsWith(":"))
5587
+ {
5588
+ // Windows
5589
+ return "";
5590
+ }
5591
+
5592
+ return split[1];
5593
+ }
5594
+
5595
+ // Windows
5596
+ assert(split.length == 4);
5597
+
5598
+ return split[2] + ":" + split[3];
51755599 }
51765600
51775601 String GetPigmentTexture()
....@@ -5245,7 +5669,7 @@
52455669 System.out.print("; textures = " + textures);
52465670 System.out.println("; usedtextures = " + usedtextures);
52475671
5248
- if (GetTextures() == null)
5672
+ if (GetTextures() == null) // What is that??
52495673 GetTextures().name = ":";
52505674
52515675 String texname = tex;
....@@ -5276,6 +5700,43 @@
52765700 child.ResetPigmentTexture();
52775701 blockloop = false;
52785702 }
5703
+ }
5704
+
5705
+ UUID GetUUID()
5706
+ {
5707
+ if (uuid == null)
5708
+ {
5709
+ // Serial
5710
+ uuid = UUID.randomUUID();
5711
+ }
5712
+
5713
+ return uuid;
5714
+ }
5715
+
5716
+ Object3D GetObject(UUID uid)
5717
+ {
5718
+ if (blockloop)
5719
+ return null;
5720
+
5721
+ if (GetUUID().equals(uid))
5722
+ return this;
5723
+
5724
+ int nb = Size();
5725
+ for (int i = 0; i < nb; i++)
5726
+ {
5727
+ Object3D child = (Object3D) get(i);
5728
+
5729
+ if (child == null)
5730
+ continue;
5731
+
5732
+ blockloop = true;
5733
+ Object3D obj = child.GetObject(uid);
5734
+ blockloop = false;
5735
+ if (obj != null)
5736
+ return obj;
5737
+ }
5738
+
5739
+ return null;
52795740 }
52805741
52815742 void SetBumpTexture(String tex)
....@@ -5314,6 +5775,38 @@
53145775 }
53155776 }
53165777
5778
+ void EmbedTextures(boolean embed)
5779
+ {
5780
+ if (blockloop)
5781
+ return;
5782
+
5783
+ //if (GetTextures() != null)
5784
+ if (embed)
5785
+ CameraPane.EmbedTextures(GetTextures());
5786
+ else
5787
+ {
5788
+ GetTextures().pigmentdata = null;
5789
+ GetTextures().bumpdata = null;
5790
+ GetTextures().pw = 0;
5791
+ GetTextures().ph = 0;
5792
+ GetTextures().bw = 0;
5793
+ GetTextures().bh = 0;
5794
+ }
5795
+
5796
+ int nb = Size();
5797
+ for (int i = 0; i < nb; i++)
5798
+ {
5799
+ Object3D child = (Object3D) get(i);
5800
+
5801
+ if (child == null)
5802
+ continue;
5803
+
5804
+ blockloop = true;
5805
+ child.EmbedTextures(embed);
5806
+ blockloop = false;
5807
+ }
5808
+ }
5809
+
53175810 void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
53185811 {
53195812 Draw(display, root, selected, blocked);
....@@ -5322,11 +5815,23 @@
53225815 boolean NeedSupport()
53235816 {
53245817 return
5325
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5818
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
53265819 // PROBLEM with CROWD!!
5327
- && (Globals.DrawMode() == iCameraPane.SHADOW || Globals.CROWD);
5820
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
53285821 }
53295822
5823
+ static boolean DEBUG_SELECTION = false;
5824
+
5825
+ boolean IsLive()
5826
+ {
5827
+ if (live)
5828
+ return true;
5829
+
5830
+ if (parent == null)
5831
+ return false;
5832
+
5833
+ return parent.IsLive();
5834
+ }
53305835
53315836 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
53325837 {
....@@ -5338,7 +5843,7 @@
53385843 }
53395844
53405845 if (display.DrawMode() == iCameraPane.SELECTION &&
5341
- hide)
5846
+ (hide || dontselect))
53425847 return;
53435848
53445849 if (name != null && name.contains("sclera"))
....@@ -5365,12 +5870,12 @@
53655870 }
53665871
53675872 if ((//display.DrawMode() == CameraPane.SHADOW ||
5368
- display.DrawMode() == CameraPane.SELECTION || CameraPane.DEBUG_SELECTION) && HasTransparency())
5873
+ display.DrawMode() == iCameraPane.SELECTION || display.IsDebugSelection()) && HasTransparency())
53695874 {
53705875 return;
53715876 }
53725877
5373
- javax.media.opengl.GL gl = display.GetGL();
5878
+ //javax.media.opengl.GL gl = display.GetGL();
53745879
53755880 /*
53765881 if (touched)
....@@ -5389,7 +5894,7 @@
53895894 support = support;
53905895
53915896 //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5392
- boolean usecalllists = false; // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5897
+ boolean usecalllists = !IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
53935898
53945899 if (!usecalllists && bRep != null && bRep.displaylist > 0)
53955900 {
....@@ -5406,13 +5911,15 @@
54065911
54075912 boolean compiled = false;
54085913
5409
- boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION;
5914
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
54105915
54115916 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5412
- (touched || (bRep != null && bRep.displaylist <= 0)))
5917
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5918
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
54135919 {
54145920 Globals.lighttouched = true;
54155921 } // all panes...
5922
+
54165923 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
54175924 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
54185925 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5422,7 +5929,7 @@
54225929 //if (displaylist == -1 && usecalllists)
54235930 if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
54245931 {
5425
- bRep.displaylist = gl.glGenLists(1);
5932
+ bRep.displaylist = display.GenList();
54265933 assert(bRep.displaylist != 0);
54275934 // System.err.println("glGenLists: " + bRep.displaylist + " for " + this);
54285935 //System.out.println("\tgen list " + list);
....@@ -5434,14 +5941,16 @@
54345941 if (usecalllists)
54355942 {
54365943 // System.err.println("new list " + bRep.displaylist + " for " + this);
5437
- gl.glNewList(bRep.displaylist, gl.GL_COMPILE); //_AND_EXECUTE);
5944
+ display.NewList(bRep.displaylist);
54385945 }
5946
+
54395947 CallList(display, root, selected, blocked);
5948
+
54405949 // compiled = true;
54415950 if (usecalllists)
54425951 {
54435952 // System.err.println("end list " + bRep.displaylist + " for " + this);
5444
- gl.glEndList();
5953
+ display.EndList();
54455954 }
54465955 //gl.glDrawBuffer(gl.GL_BACK);
54475956 // XXX touched = false;
....@@ -5484,12 +5993,12 @@
54845993
54855994 // frustum culling
54865995 if (CameraPane.FRUSTUM && !blocked && !IsInfinite() && GetBRep() != null // && GetBRep().VertexCount() != 1260 // default grid
5487
- && display.DrawMode() != CameraPane.SELECTION)
5996
+ && display.DrawMode() != iCameraPane.SELECTION)
54885997 {
5489
- if (display.DrawMode() == CameraPane.SHADOW)
5998
+ if (display.DrawMode() == iCameraPane.SHADOW)
54905999 {
54916000 if (!link2master // tricky to cull in shadow mode.
5492
- && GetBRep().FrustumCull(this, gl, display.LightCamera(), true))
6001
+ && GetBRep().FrustumCull(this, null, display.LightCamera(), true))
54936002 {
54946003 //System.out.print("CULLED");
54956004 culled = true;
....@@ -5497,7 +6006,7 @@
54976006 }
54986007 else
54996008 //GetBRep().getBounds(v0, v1, this);
5500
- if (GetBRep().FrustumCull(this, gl, display.RenderCamera(), false))
6009
+ if (GetBRep().FrustumCull(this, null, display.RenderCamera(), false))
55016010 culled = true;
55026011
55036012 // LA.xformPos(v0, display.renderCamera.toScreen, v0);
....@@ -5533,11 +6042,12 @@
55336042
55346043
55356044 if (!culled)
5536
- if (display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION)
6045
+ if (display.DrawMode() == display.SELECTION || display.IsDebugSelection())
55376046 {
55386047 if (GetBRep() != null)
55396048 {
5540
- CameraPane.NextIndex(this, gl);
6049
+ display.NextIndex();
6050
+
55416051 // vertex color conflict : gl.glCallList(list);
55426052 DrawNode(display, root, selected);
55436053 if (this instanceof BezierPatch)
....@@ -5578,7 +6088,28 @@
55786088 tex = GetTextures();
55796089 }
55806090
5581
- display.BindTextures(tex, texres);
6091
+ boolean failedPigment = false;
6092
+ boolean failedBump = false;
6093
+
6094
+ try
6095
+ {
6096
+ display.BindPigmentTexture(tex, texres);
6097
+ }
6098
+ catch (Exception e)
6099
+ {
6100
+ System.err.println("FAILED: " + this);
6101
+ failedPigment = true;
6102
+ }
6103
+
6104
+ try
6105
+ {
6106
+ display.BindBumpTexture(tex, texres);
6107
+ }
6108
+ catch (Exception e)
6109
+ {
6110
+ //System.err.println("FAILED: " + this);
6111
+ failedBump = true;
6112
+ }
55826113
55836114 if (!compiled)
55846115 {
....@@ -5594,13 +6125,17 @@
55946125
55956126 // System.err.println("glCallList: " + bRep.displaylist + " for " + this);
55966127 assert(bRep.displaylist != 0);
5597
- gl.glCallList(bRep.displaylist);
6128
+ display.CallList(bRep.displaylist);
55986129 // june 2013 drawSelf(display, root, selected);
55996130 }
56006131 }
56016132 }
56026133
5603
- display.ReleaseTextures(tex);
6134
+ if (!failedBump)
6135
+ display.ReleaseBumpTexture(tex);
6136
+
6137
+ if (!failedPigment)
6138
+ display.ReleasePigmentTexture(tex);
56046139
56056140 display.PopMaterial(this, selected);
56066141 }
....@@ -5729,6 +6264,9 @@
57296264
57306265 void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57316266 {
6267
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6268
+ return;
6269
+
57326270 if (hide)
57336271 return;
57346272 // shadow optimisation
....@@ -5854,6 +6392,9 @@
58546392 if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
58556393 return; // no shadow for transparent objects
58566394
6395
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6396
+ return;
6397
+
58576398 if (hide)
58586399 return;
58596400
....@@ -5894,9 +6435,10 @@
58946435 return;
58956436 }
58966437
6438
+ //bRep.GenUV(1/material.diffuseness);
58976439 // bRep.lock = true;
58986440
5899
- javax.media.opengl.GL gl = display.GetGL();
6441
+ //javax.media.opengl.GL gl = display.GetGL();
59006442
59016443 if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera)
59026444 {
....@@ -5913,23 +6455,7 @@
59136455
59146456 bRep.getMinMax(min, max, 100);
59156457
5916
- gl.glBegin(gl.GL_LINES);
5917
-
5918
- gl.glVertex3d(min.x, min.y, min.z);
5919
- gl.glVertex3d(min.x, min.y, max.z);
5920
- gl.glVertex3d(min.x, min.y, min.z);
5921
- gl.glVertex3d(min.x, max.y, min.z);
5922
- gl.glVertex3d(min.x, min.y, min.z);
5923
- gl.glVertex3d(max.x, min.y, min.z);
5924
-
5925
- gl.glVertex3d(max.x, max.y, max.z);
5926
- gl.glVertex3d(min.x, max.y, max.z);
5927
- gl.glVertex3d(max.x, max.y, max.z);
5928
- gl.glVertex3d(max.x, min.y, max.z);
5929
- gl.glVertex3d(max.x, max.y, max.z);
5930
- gl.glVertex3d(max.x, max.y, min.z);
5931
-
5932
- gl.glEnd();
6458
+ display.DrawBox(min, max);
59336459
59346460 return;
59356461 }
....@@ -5973,7 +6499,7 @@
59736499 {
59746500 //throw new Error();
59756501
5976
- boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION;
6502
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
59776503
59786504 int[] strips = bRep.getRawIndices();
59796505
....@@ -5983,178 +6509,19 @@
59836509 new Exception().printStackTrace();
59846510 return;
59856511 }
5986
-
5987
- // TRIANGLE STRIP ARRAY
5988
- if (bRep.trimmed)
6512
+
6513
+ if (dontselect)
59896514 {
5990
- float[] v = bRep.getRawVertices();
5991
- float[] n = bRep.getRawNormals();
5992
- float[] c = bRep.getRawColors();
5993
- float[] uv = bRep.getRawUVMap();
5994
-
5995
- int count2 = 0;
5996
- int count3 = 0;
5997
-
5998
- if (n.length > 0)
5999
- {
6000
- for (int i = 0; i < strips.length; i++)
6001
- {
6002
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6003
-
6004
- /*
6005
- boolean locked = false;
6006
- float eps = 0.1f;
6007
- boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
6008
-
6009
- int dot = 0;
6010
-
6011
- if ((dot&1) == 0)
6012
- dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
6013
-
6014
- if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
6015
- gl.glTexCoord2f((float) qv.s, (float) qv.t);
6016
- else
6017
- {
6018
- locked = true;
6019
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6020
- }
6021
- //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6022
- gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
6023
- if (hasnorm)
6024
- {
6025
- //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6026
- gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
6027
- }
6028
-
6029
- if ((dot&4) == 0)
6030
- dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
6031
-
6032
- if (wrap || !locked && (dot&8) != 0)
6033
- gl.glTexCoord2f((float) rv.s, (float) rv.t);
6034
- else
6035
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6036
-
6037
- f.dot = dot;
6038
- */
6039
-
6040
- if (!selectmode)
6041
- {
6042
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6043
- {
6044
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6045
- } else
6046
- {
6047
- gl.glNormal3f(0, 0, 1);
6048
- }
6049
-
6050
- if (c != null)
6051
- //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]);
6052
- {
6053
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6054
- }
6055
- }
6056
- if (flipV)
6057
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6058
- else
6059
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6060
- //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6061
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6062
-
6063
- count2 += 2;
6064
- count3 += 3;
6065
- if (!selectmode)
6066
- {
6067
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6068
- {
6069
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6070
- } else
6071
- {
6072
- gl.glNormal3f(0, 0, 1);
6073
- }
6074
- if (c != null)
6075
- {
6076
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6077
- }
6078
- }
6079
- if (flipV)
6080
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6081
- else
6082
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6083
- //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6084
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6085
-
6086
- count2 += 2;
6087
- count3 += 3;
6088
- for (int j = 0; j < strips[i] - 2; j++)
6089
- {
6090
- //gl.glTexCoord2d(...);
6091
- if (!selectmode)
6092
- {
6093
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6094
- {
6095
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6096
- } else
6097
- {
6098
- gl.glNormal3f(0, 0, 1);
6099
- }
6100
- if (c != null)
6101
- {
6102
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6103
- }
6104
- }
6105
-
6106
- if (flipV)
6107
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6108
- else
6109
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6110
- //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
6111
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6112
- count2 += 2;
6113
- count3 += 3;
6114
- }
6115
-
6116
- gl.glEnd();
6117
- }
6118
- }
6119
-
6120
- assert count3 == v.length;
6515
+ //bRep.GenerateNormalsMINE();
61216516 }
6122
- else // !trimmed
6123
- {
6124
- int count = 0;
6125
- for (int i = 0; i < strips.length; i++)
6126
- {
6127
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6128
-
6129
- Vertex p = bRep.GetVertex(bRep.indices[count++]);
6130
- Vertex q = bRep.GetVertex(bRep.indices[count++]);
6131
-
6132
- drawVertex(gl, p, selectmode);
6133
- drawVertex(gl, q, selectmode);
6134
-
6135
- for (int j = 0; j < strips[i] - 2; j++)
6136
- {
6137
- Vertex r = bRep.GetVertex(bRep.indices[count++]);
6138
-
6139
-// if (j%2 == 0)
6140
-// drawFace(p, q, r, display, null);
6141
-// else
6142
-// drawFace(p, r, q, display, null);
6143
-
6144
-// p = q;
6145
-// q = r;
6146
- drawVertex(gl, r, selectmode);
6147
- }
6148
-
6149
- gl.glEnd();
6150
- }
6151
- }
6517
+
6518
+ display.DrawGeometry(bRep, flipV, selectmode);
61526519 } else // catch (Error e)
61536520 {
61546521 // TRIANGLE ARRAY
61556522 if (IsOpaque()) // Static())
61566523 {
6157
- gl.glBegin(gl.GL_TRIANGLES);
6524
+ display.StartTriangles();
61586525 int facecount = bRep.FaceCount();
61596526 for (int i = 0; i < facecount; i++)
61606527 {
....@@ -6219,7 +6586,7 @@
62196586
62206587 display.DrawFace(this, p, q, r, face);
62216588 }
6222
- gl.glEnd();
6589
+ display.EndTriangles();
62236590 }
62246591 else
62256592 {
....@@ -6248,8 +6615,8 @@
62486615 //System.out.println("SORT");
62496616
62506617 java.util.Arrays.sort(facescompare);
6251
-
6252
- gl.glBegin(gl.GL_TRIANGLES);
6618
+
6619
+ display.StartTriangles();
62536620 for (int i = 0; i < facecount; i++)
62546621 {
62556622 Face face = bRep.GetFace(facescompare[i].index);
....@@ -6263,11 +6630,12 @@
62636630
62646631 display.DrawFace(this, p, q, r, face);
62656632 }
6266
- gl.glEnd();
6633
+ display.EndTriangles();
62676634 }
62686635
62696636 if (false) // live && support != null && support.bRep != null) // debug weights
62706637 {
6638
+ /*
62716639 gl.glDisable(gl.GL_LIGHTING);
62726640 float[] colorV = new float[3];
62736641
....@@ -6346,6 +6714,7 @@
63466714 // gl.glEnd();
63476715 }
63486716 }
6717
+ */
63496718 }
63506719 }
63516720
....@@ -6390,7 +6759,7 @@
63906759 center.add(r);
63916760 center.mul(1.0/3);
63926761
6393
- center.sub(CameraPane.theRenderer.eyeCamera.location);
6762
+ center.sub(Globals.theRenderer.EyeCamera().location);
63946763
63956764 distance = center.dot(center);
63966765 }
....@@ -6404,22 +6773,6 @@
64046773 void Print(Vertex v)
64056774 {
64066775 //System.err.println("(" + v.x + ", " + v.y + ", " + v.z + ")");
6407
- }
6408
-
6409
- void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean selectmode)
6410
- {
6411
- if (!selectmode)
6412
- {
6413
- gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
6414
- gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
6415
-
6416
- if (flipV)
6417
- gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
6418
- else
6419
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6420
- }
6421
-
6422
- gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
64236776 }
64246777
64256778 void drawSelf(ClickInfo info, int level, boolean select)
....@@ -6993,83 +7346,84 @@
69937346 int spotw = spot.x + spot.width;
69947347 int spoth = spot.y + spot.height;
69957348 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
6996
- if (CameraPane.Xmin > spot.x)
6997
- {
6998
- CameraPane.Xmin = spot.x;
6999
- }
7000
- if (CameraPane.Xmax < spotw)
7001
- {
7002
- CameraPane.Xmax = spotw;
7003
- }
7004
- if (CameraPane.Ymin > spot.y)
7005
- {
7006
- CameraPane.Ymin = spot.y;
7007
- }
7008
- if (CameraPane.Ymax < spoth)
7009
- {
7010
- CameraPane.Ymax = spoth;
7011
- }
7349
+// if (CameraPane.Xmin > spot.x)
7350
+// {
7351
+// CameraPane.Xmin = spot.x;
7352
+// }
7353
+// if (CameraPane.Xmax < spotw)
7354
+// {
7355
+// CameraPane.Xmax = spotw;
7356
+// }
7357
+// if (CameraPane.Ymin > spot.y)
7358
+// {
7359
+// CameraPane.Ymin = spot.y;
7360
+// }
7361
+// if (CameraPane.Ymax < spoth)
7362
+// {
7363
+// CameraPane.Ymax = spoth;
7364
+// }
70127365 spot.translate(32, 32);
70137366 spotw = spot.x + spot.width;
70147367 spoth = spot.y + spot.height;
7015
- info.g.setColor(Color.blue);
7368
+ info.g.setColor(Color.cyan);
70167369 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7017
- if (CameraPane.Xmin > spot.x)
7018
- {
7019
- CameraPane.Xmin = spot.x;
7020
- }
7021
- if (CameraPane.Xmax < spotw)
7022
- {
7023
- CameraPane.Xmax = spotw;
7024
- }
7025
- if (CameraPane.Ymin > spot.y)
7026
- {
7027
- CameraPane.Ymin = spot.y;
7028
- }
7029
- if (CameraPane.Ymax < spoth)
7030
- {
7031
- CameraPane.Ymax = spoth;
7032
- }
7033
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7034
- info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7370
+// if (CameraPane.Xmin > spot.x)
7371
+// {
7372
+// CameraPane.Xmin = spot.x;
7373
+// }
7374
+// if (CameraPane.Xmax < spotw)
7375
+// {
7376
+// CameraPane.Xmax = spotw;
7377
+// }
7378
+// if (CameraPane.Ymin > spot.y)
7379
+// {
7380
+// CameraPane.Ymin = spot.y;
7381
+// }
7382
+// if (CameraPane.Ymax < spoth)
7383
+// {
7384
+// CameraPane.Ymax = spoth;
7385
+// }
7386
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7387
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
70357388 spot.translate(0, -32);
7036
- info.g.setColor(Color.green);
7389
+ info.g.setColor(Color.yellow);
70377390 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7038
- if (CameraPane.Xmin > spot.x)
7039
- {
7040
- CameraPane.Xmin = spot.x;
7041
- }
7042
- if (CameraPane.Xmax < spotw)
7043
- {
7044
- CameraPane.Xmax = spotw;
7045
- }
7046
- if (CameraPane.Ymin > spot.y)
7047
- {
7048
- CameraPane.Ymin = spot.y;
7049
- }
7050
- if (CameraPane.Ymax < spoth)
7051
- {
7052
- CameraPane.Ymax = spoth;
7053
- }
7054
- info.g.drawArc(boundary.x, boundary.y,
7055
- boundary.width, boundary.height, 0, 360);
7391
+ info.g.setColor(Color.green);
7392
+// if (CameraPane.Xmin > spot.x)
7393
+// {
7394
+// CameraPane.Xmin = spot.x;
7395
+// }
7396
+// if (CameraPane.Xmax < spotw)
7397
+// {
7398
+// CameraPane.Xmax = spotw;
7399
+// }
7400
+// if (CameraPane.Ymin > spot.y)
7401
+// {
7402
+// CameraPane.Ymin = spot.y;
7403
+// }
7404
+// if (CameraPane.Ymax < spoth)
7405
+// {
7406
+// CameraPane.Ymax = spoth;
7407
+// }
7408
+ info.g.drawArc(boundary.x + info.DX, boundary.y + info.DY,
7409
+ (int)(boundary.width * info.W), (int)(boundary.height * info.W), 0, 360);
70567410 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
7057
- if (CameraPane.Xmin > boundary.x)
7058
- {
7059
- CameraPane.Xmin = boundary.x;
7060
- }
7061
- if (CameraPane.Xmax < boundary.x + boundary.width)
7062
- {
7063
- CameraPane.Xmax = boundary.x + boundary.width;
7064
- }
7065
- if (CameraPane.Ymin > boundary.y)
7066
- {
7067
- CameraPane.Ymin = boundary.y;
7068
- }
7069
- if (CameraPane.Ymax < boundary.y + boundary.height)
7070
- {
7071
- CameraPane.Ymax = boundary.y + boundary.height;
7072
- }
7411
+// if (CameraPane.Xmin > boundary.x)
7412
+// {
7413
+// CameraPane.Xmin = boundary.x;
7414
+// }
7415
+// if (CameraPane.Xmax < boundary.x + boundary.width)
7416
+// {
7417
+// CameraPane.Xmax = boundary.x + boundary.width;
7418
+// }
7419
+// if (CameraPane.Ymin > boundary.y)
7420
+// {
7421
+// CameraPane.Ymin = boundary.y;
7422
+// }
7423
+// if (CameraPane.Ymax < boundary.y + boundary.height)
7424
+// {
7425
+// CameraPane.Ymax = boundary.y + boundary.height;
7426
+// }
70737427 return;
70747428 }
70757429 }
....@@ -7086,7 +7440,7 @@
70867440 startX = info.x;
70877441 startY = info.y;
70887442
7089
- hitSomething = 0;
7443
+ hitSomething = -1;
70907444 cVector origin = new cVector();
70917445 //LA.xformPos(origin, toParent, origin);
70927446 Rectangle spot = new Rectangle();
....@@ -7119,7 +7473,7 @@
71197473 }
71207474
71217475 //System.out.println("info.modifiers = " + info.modifiers);
7122
- modified = (info.modifiers & CameraPane.META) != 0;
7476
+ modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
71237477 //System.out.println("modified = " + modified);
71247478 //new Exception().printStackTrace();
71257479 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7147,7 +7501,7 @@
71477501 return true;
71487502 }
71497503
7150
- void doEditDrag0(ClickInfo info)
7504
+ void doEditDrag0(ClickInfo info, boolean opposite)
71517505 {
71527506 if (hitSomething == 0)
71537507 {
....@@ -7162,6 +7516,7 @@
71627516 //System.out.println("hitSomething = " + hitSomething);
71637517
71647518 double scale = 0.005f * info.camera.Distance();
7519
+
71657520 cVector xlate = new cVector();
71667521 //cVector xlate2 = new cVector();
71677522 switch (hitSomething)
....@@ -7172,9 +7527,9 @@
71727527
71737528 case hitCenter: // Translate
71747529
7175
- scale *= 0.05f * info.pane.theRenderer.renderCamera.Distance();
7530
+ scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
71767531
7177
- if (modified)
7532
+ if (modified || opposite)
71787533 {
71797534 //assert(false);
71807535 /*
....@@ -7220,10 +7575,10 @@
72207575 }
72217576 LA.xformDir(up, ClickInfo.matbuffer, up);
72227577 // if (!CameraPane.LOCALTRANSFORM)
7223
- LA.xformDir(up, info.pane.theRenderer.renderCamera.toScreen, up);
7578
+ LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
72247579 LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
72257580 // if (!CameraPane.LOCALTRANSFORM)
7226
- LA.xformDir(away, info.pane.theRenderer.renderCamera.toScreen, away);
7581
+ LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
72277582 //LA.vecCross(up, cVector.Z, right2);
72287583
72297584 cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
....@@ -7268,6 +7623,7 @@
72687623
72697624 if (modified)
72707625 {
7626
+ // Rotate 90 degrees
72717627 angle /= (Math.PI / 4);
72727628 angle = Math.floor(angle + 0.5);
72737629 angle *= (Math.PI / 4);
....@@ -7281,7 +7637,7 @@
72817637 }
72827638 /**/
72837639
7284
- switch (info.pane.renderCamera.viewCode)
7640
+ switch (info.pane.RenderCamera().viewCode)
72857641 {
72867642 case 1: // '\001'
72877643 LA.matZRotate(toParent, angle);
....@@ -7309,24 +7665,27 @@
73097665
73107666 case hitScale: // scale
73117667 double hScale = (double) (info.x - centerPt.x) / 32;
7668
+ double sign = 1;
7669
+ if (hScale < 0)
7670
+ {
7671
+ sign = -1;
7672
+ }
7673
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
73127674 if (hScale < 0.01)
73137675 {
7314
- hScale = 0.01;
7676
+ //hScale = 0.01;
73157677 }
7316
- hScale = Math.pow(hScale, scale * 50);
7317
- if (hScale < 0.01)
7318
- {
7319
- hScale = 0.01;
7320
- }
7678
+
73217679 double vScale = (double) (info.y - centerPt.y) / 32;
7322
- if (vScale < 0.01)
7680
+ sign = 1;
7681
+ if (vScale < 0)
73237682 {
7324
- vScale = 0.01;
7683
+ sign = -1;
73257684 }
7326
- vScale = Math.pow(vScale, scale * 50);
7685
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
73277686 if (vScale < 0.01)
73287687 {
7329
- vScale = 0.01;
7688
+ //vScale = 0.01;
73307689 }
73317690 LA.matCopy(startMat, toParent);
73327691 /**/
....@@ -7337,39 +7696,47 @@
73377696 }
73387697 /**/
73397698
7340
- switch (info.pane.renderCamera.viewCode)
7699
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7700
+
7701
+ if (totalScale < 0.01)
7702
+ {
7703
+ totalScale = 0.01;
7704
+ }
7705
+
7706
+ switch (info.pane.RenderCamera().viewCode)
73417707 {
73427708 case 3: // '\001'
7343
- if (modified)
7709
+ if (modified || opposite)
73447710 {
73457711 //LA.matScale(toParent, 1, hScale, vScale);
7346
- LA.matScale(toParent, vScale, 1, 1);
7712
+ LA.matScale(toParent, totalScale, 1, 1);
73477713 } // vScale, 1);
73487714 else
73497715 {
7350
- LA.matScale(toParent, vScale, vScale, vScale);
7716
+ // EXCEPTION!
7717
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
73517718 } // vScale, 1);
73527719 break;
73537720
73547721 case 2: // '\002'
7355
- if (modified)
7722
+ if (modified || opposite)
73567723 {
73577724 //LA.matScale(toParent, hScale, 1, vScale);
7358
- LA.matScale(toParent, 1, vScale, 1);
7725
+ LA.matScale(toParent, 1, totalScale, 1);
73597726 } else
73607727 {
7361
- LA.matScale(toParent, vScale, 1, vScale);
7728
+ LA.matScale(toParent, totalScale, 1, totalScale);
73627729 }
73637730 break;
73647731
73657732 case 1: // '\003'
7366
- if (modified)
7733
+ if (modified || opposite)
73677734 {
73687735 //LA.matScale(toParent, hScale, vScale, 1);
7369
- LA.matScale(toParent, 1, 1, vScale);
7736
+ LA.matScale(toParent, 1, 1, totalScale);
73707737 } else
73717738 {
7372
- LA.matScale(toParent, vScale, vScale, 1);
7739
+ LA.matScale(toParent, totalScale, totalScale, 1);
73737740 }
73747741 break;
73757742 }
....@@ -7502,14 +7869,22 @@
75027869 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
75037870 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
75047871 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7872
+
7873
+ String objname;
7874
+
75057875 if (false) //parent != null)
75067876 {
7507
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7877
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
75087878 } else
75097879 {
7510
- return GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ") ")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ +System.identityHashCode(this);
7880
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
75117881 } // + super.toString();
75127882 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
7883
+
7884
+ if (!Globals.ADVANCED)
7885
+ return objname;
7886
+
7887
+ return objname + " " + System.identityHashCode(this);
75137888 }
75147889
75157890 public int hashCode()
....@@ -7565,6 +7940,7 @@
75657940 objectUI.closeUI();
75667941 if (editWindow != null)
75677942 {
7943
+ editWindow.ctrlPanel.FlushUI();
75687944 editWindow.refreshContents();
75697945 } // ? new
75707946 objectUI = null;
....@@ -7573,6 +7949,10 @@
75737949 {
75747950 editWindow = null;
75757951 } // ?
7952
+ }
7953
+ else
7954
+ {
7955
+ //editWindow.closeUI();
75767956 }
75777957 }
75787958
....@@ -7585,7 +7965,7 @@
75857965 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
75867966
75877967 Object3D /*Composite*/ parent;
7588
- Object3D /*Composite*/ fileparent;
7968
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
75897969
75907970 double[][] toParent; // dynamic matrix
75917971 double[][] fromParent;
....@@ -7700,7 +8080,7 @@
77008080 {
77018081 assert(bRep != null);
77028082 if (!(support instanceof GenericJoint)) // support.bRep != null)
7703
- GrafreeD.Assert(support.bRep == bRep.support);
8083
+ Grafreed.Assert(support.bRep == bRep.support);
77048084 }
77058085 else
77068086 {
....@@ -7731,6 +8111,10 @@
77318111 }
77328112
77338113 transient ObjEditor editWindow;
8114
+ transient ObjEditor manipWindow;
8115
+
8116
+ transient boolean pinned;
8117
+
77348118 transient ObjectUI objectUI;
77358119 public static int povDepth = 0;
77368120 private static cVector tbMin = new cVector();
....@@ -7749,9 +8133,9 @@
77498133 private static cVector edge2 = new cVector();
77508134 //private static cVector norm = new cVector();
77518135 /*transient private*/ int hitSomething;
7752
- private static final int hitCenter = 1;
7753
- private static final int hitScale = 2;
7754
- private static final int hitRotate = 3;
8136
+ static final int hitCenter = 1;
8137
+ static final int hitScale = 2;
8138
+ static final int hitRotate = 3;
77558139 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
77568140 /*transient*/ private Point centerPt;
77578141 /*transient*/ private int startX;