Normand Briere
2019-07-17 a5580a47d246c1272b10adba68070f6e13da5e41
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[] = new byte[100][];
33
+ int versionindex = -1;
34
+
2235 ScriptNode scriptnode;
2336
2437 void InitOthers()
....@@ -99,64 +112,173 @@
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
+
223
+ if (this.support != null)
224
+ {
225
+ if (o.transientrep != null)
226
+ Grafreed.Assert(o.transientrep == this.support.bRep);
227
+
228
+ o.transientrep = this.support.bRep;
229
+ this.support.bRep = null;
230
+ }
231
+
232
+ // o.support = this.support;
233
+ // o.fileparent = this.fileparent;
234
+ // if (this.bRep != null)
235
+ // o.bRep = this.bRep.support;
236
+
237
+ this.bRep = null;
238
+ // if (this.bRep != null)
239
+ // this.bRep.support = null;
240
+ // this.support = null;
241
+ // this.fileparent = null;
242
+ }
243
+
244
+ void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
245
+ {
246
+ if (!hashtable.containsKey(GetUUID()))
247
+ return;
248
+
249
+ Object3D o = hashtable.get(GetUUID());
250
+
251
+ RestoreBigData(o);
252
+
253
+ if (blockloop)
254
+ return;
255
+
129256 blockloop = true;
130
- child.SaveSupports();
257
+
258
+ //hashtable.remove(GetUUID());
259
+
260
+ for (int i=0; i<Size(); i++)
261
+ {
262
+ get(i).RestoreBigData(hashtable);
263
+ }
264
+
131265 blockloop = false;
132266 }
133
-}
134267
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)
268
+ void RestoreBigData(Object3D o)
146269 {
147
- bRep.RestoreSupports();
270
+ this.bRep = o.bRep;
271
+ if (this.support != null && o.transientrep != null)
272
+ {
273
+ this.support.bRep = o.transientrep;
274
+ }
275
+
276
+ this.selection = o.selection;
277
+// July 2019 if (this.bRep != null)
278
+// this.bRep.support = o.transientrep;
279
+ // this.support = o.support;
280
+ // this.fileparent = o.fileparent;
148281 }
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
-}
160282
161283 // MOCAP SUPPORT
162284 double tx,ty,tz,rx,ry,rz;
....@@ -299,6 +421,7 @@
299421 }
300422
301423 boolean live = false;
424
+ boolean dontselect = false;
302425 boolean hide = false;
303426 boolean link2master = false; // performs reset support/master at each frame
304427 boolean marked = false; // animation node
....@@ -430,16 +553,16 @@
430553 {
431554 Object3D copy = this;
432555
433
- Camera parentcam = CameraPane.theRenderer.manipCamera;
556
+ Camera parentcam = Globals.theRenderer.ManipCamera();
434557
435
- if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[0])
558
+ if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[0])
436559 {
437
- parentcam = CameraPane.theRenderer.cameras[1];
560
+ parentcam = Globals.theRenderer.Cameras()[1];
438561 }
439562
440
- if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[1])
563
+ if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[1])
441564 {
442
- parentcam = CameraPane.theRenderer.cameras[0];
565
+ parentcam = Globals.theRenderer.Cameras()[0];
443566 }
444567
445568 if (this == parentcam)
....@@ -447,7 +570,7 @@
447570 //assert(this instanceof Camera);
448571
449572 for (int count = parentcam.GetTransformCount(); --count>=0;)
450
- LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.toParent, CameraPane.theRenderer.targetLookAt);
573
+ LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.toParent, Globals.theRenderer.TargetLookAt());
451574 }
452575
453576 copy.marked ^= true;
....@@ -467,7 +590,7 @@
467590 //assert(this instanceof Camera);
468591
469592 for (int count = parentcam.GetTransformCount(); --count>=0;)
470
- LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.fromParent, CameraPane.theRenderer.targetLookAt);
593
+ LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.fromParent, Globals.theRenderer.TargetLookAt());
471594 }
472595
473596 copy.Touch(); // display list issue
....@@ -480,12 +603,14 @@
480603 toParent = LA.newMatrix();
481604 fromParent = LA.newMatrix();
482605 }
606
+
483607 if (toParentMarked == null)
484608 {
485609 if (maxcount != 1)
486610 {
487611 new Exception().printStackTrace();
488612 }
613
+
489614 toParentMarked = LA.newMatrix();
490615 fromParentMarked = LA.newMatrix();
491616 }
....@@ -602,7 +727,7 @@
602727 return;
603728 }
604729
605
- if (CameraPane.fromscript)
730
+ if (Globals.fromscript)
606731 {
607732 transformcount = 0;
608733 return;
....@@ -773,7 +898,7 @@
773898 if (step == 0)
774899 step = 1;
775900 if (maxcount == 0)
776
- maxcount = 2048; // 4;
901
+ maxcount = 128; // 2048; // 4;
777902 // if (acceleration == 0)
778903 // acceleration = 10;
779904 if (delay == 0) // serial
....@@ -796,7 +921,7 @@
796921
797922 if (marked && Globals.isLIVE() && live &&
798923 //TEMP21aug2018
799
- Globals.DrawMode() == iCameraPane.SHADOW &&
924
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
800925 currentframe != Globals.framecount)
801926 {
802927 currentframe = Globals.framecount;
....@@ -808,7 +933,8 @@
808933
809934 boolean changedir = random && Math.random() < 0.01; // && !link2master;
810935
811
- if (transformcount*factor > maxcount || (step == 1 && changedir))
936
+ if (transformcount*factor >= maxcount && (rewind || random) ||
937
+ (step == 1 && changedir))
812938 {
813939 countdown = 1;
814940 delay = speedup?8:1;
....@@ -880,6 +1006,7 @@
8801006 if (material == null || material.multiply)
8811007 return true;
8821008
1009
+ // Transparent objects are dynamic because we have to sort the triangles.
8831010 return material.opacity > 0.99;
8841011 }
8851012
....@@ -911,6 +1038,11 @@
9111038 fromParent = null; // LA.newMatrix();
9121039 bRep = null; // new BoundaryRep();
9131040
1041
+ if (oname != null && oname.equals("LeftHand"))
1042
+ {
1043
+ name = oname;
1044
+ }
1045
+
9141046 /*
9151047 float hue = (float)Math.random();
9161048 Color col;
....@@ -953,7 +1085,7 @@
9531085
9541086 public Object clone()
9551087 {
956
- return GrafreeD.clone(this);
1088
+ return Grafreed.clone(this);
9571089 }
9581090
9591091 Object3D copyExpand()
....@@ -1275,6 +1407,7 @@
12751407 toParent = LA.newMatrix();
12761408 fromParent = LA.newMatrix();
12771409 }
1410
+
12781411 LA.matCopy(other.toParent, toParent);
12791412 LA.matCopy(other.fromParent, fromParent);
12801413
....@@ -1469,7 +1602,7 @@
14691602 BoundaryRep.SEUIL = other.material.cameralight;
14701603
14711604 // Set default to 0.1
1472
- BoundaryRep.SEUIL /= 2;
1605
+ BoundaryRep.SEUIL /= 4; // 2;
14731606 System.out.println("SEUIL = " + BoundaryRep.SEUIL);
14741607 }
14751608
....@@ -1728,7 +1861,7 @@
17281861 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17291862 o.bRep = transientrep;
17301863 if (clone)
1731
- o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
1864
+ o.bRep = (BoundaryRep) Grafreed.clone(transientrep);
17321865 o.CreateMaterial();
17331866 o.SetAttributes(this, -1);
17341867 //parent
....@@ -1741,7 +1874,7 @@
17411874 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17421875 o.bRep = bRep;
17431876 if (clone)
1744
- o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
1877
+ o.bRep = (BoundaryRep) Grafreed.clone(bRep);
17451878 o.CreateMaterial();
17461879 //o.overwriteThis(this, -1);
17471880 o.SetAttributes(this, -1);
....@@ -1828,12 +1961,15 @@
18281961 if (obj.name == null)
18291962 continue; // can't be a null one
18301963
1964
+ // Try perfect match first.
18311965 if (n.equals(obj.name))
18321966 {
18331967 theobj = obj;
18341968 count++;
18351969 }
18361970 }
1971
+
1972
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18371973
18381974 if (count != 1)
18391975 for (int i=Size(); --i>=0;)
....@@ -2293,12 +2429,17 @@
22932429 }
22942430 */
22952431 }
2432
+ else
2433
+ {
2434
+ //((ObjEditor)editWindow).SetupUI2(null);
2435
+ }
22962436 }
22972437
22982438 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
22992439 {
23002440 if (newWindow)
23012441 {
2442
+ new Exception().printStackTrace();
23022443 System.exit(0);
23032444 if (parent != null)
23042445 {
....@@ -2333,6 +2474,14 @@
23332474 {
23342475 editWindow.refreshContents();
23352476 }
2477
+ else
2478
+ {
2479
+ if (manipWindow != null)
2480
+ {
2481
+ manipWindow.refreshContents();
2482
+ }
2483
+ }
2484
+
23362485 //if (parent != null)
23372486 //parent.refreshEditWindow();
23382487 }
....@@ -2475,13 +2624,13 @@
24752624 return retval;
24762625 }
24772626
2478
- void doEditDrag(ClickInfo info)
2627
+ void doEditDrag(ClickInfo info, boolean opposite)
24792628 {
24802629 switch (doSomething)
24812630 {
24822631 case 1: // '\001'
24832632 //super.
2484
- doEditDrag0(info);
2633
+ doEditDrag0(info, opposite);
24852634 break;
24862635
24872636 case 2: // '\002'
....@@ -2494,11 +2643,11 @@
24942643 {
24952644 //sel.hitSomething = childToDrag.hitSomething;
24962645 //childToDrag.doEditDrag(info);
2497
- sel.doEditDrag(info);
2646
+ sel.doEditDrag(info, opposite);
24982647 } else
24992648 {
25002649 //super.
2501
- doEditDrag0(info);
2650
+ doEditDrag0(info, opposite);
25022651 }
25032652 }
25042653 break;
....@@ -2608,6 +2757,18 @@
26082757 void GenNormalsS(boolean crease)
26092758 {
26102759 selection.GenNormals(crease);
2760
+// for (int i=0; i<selection.size(); i++)
2761
+// {
2762
+// Object3D selectee = (Object3D) selection.elementAt(i);
2763
+// selectee.GenNormals(crease);
2764
+// }
2765
+
2766
+ //Touch();
2767
+ }
2768
+
2769
+ void GenNormalsMeshS()
2770
+ {
2771
+ selection.GenNormalsMesh();
26112772 // for (int i=0; i<selection.size(); i++)
26122773 // {
26132774 // Object3D selectee = (Object3D) selection.elementAt(i);
....@@ -2748,6 +2909,24 @@
27482909 if (child == null)
27492910 continue;
27502911 child.GenNormals(crease);
2912
+// Children().release(i);
2913
+ }
2914
+ blockloop = false;
2915
+ }
2916
+
2917
+ void GenNormalsMesh()
2918
+ {
2919
+ if (blockloop)
2920
+ return;
2921
+
2922
+ blockloop = true;
2923
+ GenNormalsMesh0();
2924
+ for (int i = 0; i < Children().Size(); i++)
2925
+ {
2926
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2927
+ if (child == null)
2928
+ continue;
2929
+ child.GenNormalsMesh();
27512930 // Children().release(i);
27522931 }
27532932 blockloop = false;
....@@ -2905,7 +3084,8 @@
29053084 {
29063085 if (bRep != null)
29073086 {
2908
- bRep.GenUV();
3087
+ bRep.GenUV(); //1);
3088
+ //bRep.UnfoldUV();
29093089 Touch();
29103090 }
29113091 }
....@@ -2915,6 +3095,15 @@
29153095 if (bRep != null)
29163096 {
29173097 bRep.GenerateNormals(crease);
3098
+ Touch();
3099
+ }
3100
+ }
3101
+
3102
+ void GenNormalsMesh0()
3103
+ {
3104
+ if (bRep != null)
3105
+ {
3106
+ bRep.GenerateNormalsMesh();
29183107 Touch();
29193108 }
29203109 }
....@@ -2980,6 +3169,33 @@
29803169 blockloop = false;
29813170 }
29823171
3172
+ void TransformChildren()
3173
+ {
3174
+ if (toParent != null)
3175
+ {
3176
+ for (int i=Size(); --i>=0;)
3177
+ {
3178
+ Object3D v = get(i);
3179
+
3180
+ if (v.toParent == null)
3181
+ {
3182
+ v.toParent = LA.newMatrix();
3183
+ v.fromParent = LA.newMatrix();
3184
+ }
3185
+
3186
+// LA.matConcat(v.toParent, toParent, v.toParent);
3187
+// LA.matConcat(fromParent, v.fromParent, v.fromParent);
3188
+ LA.matConcat(toParent, v.toParent, v.toParent);
3189
+ LA.matConcat(v.fromParent, fromParent, v.fromParent);
3190
+ }
3191
+
3192
+ toParent = null; // LA.matIdentity(toParent);
3193
+ fromParent = null; // LA.matIdentity(fromParent);
3194
+
3195
+ Touch();
3196
+ }
3197
+ }
3198
+
29833199 void TransformGeometry()
29843200 {
29853201 Object3D obj = this;
....@@ -3201,9 +3417,11 @@
32013417
32023418 BoundaryRep sup = bRep.support;
32033419 bRep.support = null;
3204
- BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
3420
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
32053421 // bRep.SplitInTwo(onlyone); // thread...
3206
- temprep.SplitInTwo(reduction34, onlyone);
3422
+
3423
+ while(temprep.SplitInTwo(reduction34, onlyone));
3424
+
32073425 bRep = temprep;
32083426 bRep.support = sup;
32093427 Touch();
....@@ -3340,7 +3558,8 @@
33403558 if (blockloop)
33413559 return;
33423560
3343
- if (marked || (bRep != null && material != null)) // borderline...
3561
+ if (//marked || // does not make sense
3562
+ (bRep != null || material != null)) // borderline...
33443563 live = h;
33453564
33463565 for (int i = 0; i < Size(); i++)
....@@ -3361,7 +3580,8 @@
33613580 return;
33623581
33633582 //if (bRep != null)
3364
- if (marked || (bRep != null && material != null)) // borderline...
3583
+ if (//marked || // does not make sense
3584
+ (bRep != null || material != null)) // borderline...
33653585 link2master = h;
33663586
33673587 for (int i = 0; i < Size(); i++)
....@@ -3381,7 +3601,8 @@
33813601 if (blockloop)
33823602 return;
33833603
3384
- if (marked || (bRep != null && material != null)) // borderline...
3604
+ if (//marked || // does not make sense
3605
+ (bRep != null || material != null)) // borderline...
33853606 hide = h;
33863607
33873608 for (int i = 0; i < Size(); i++)
....@@ -3401,7 +3622,7 @@
34013622 if (blockloop)
34023623 return;
34033624
3404
- if (bRep != null && material != null) // borderline...
3625
+ if (bRep != null || material != null) // borderline...
34053626 marked = h;
34063627
34073628 for (int i = 0; i < Size(); i++)
....@@ -3411,6 +3632,46 @@
34113632 continue;
34123633 blockloop = true;
34133634 child.MarkLeaves(h);
3635
+ blockloop = false;
3636
+ // release(i);
3637
+ }
3638
+ }
3639
+
3640
+ void RewindLeaves(boolean h)
3641
+ {
3642
+ if (blockloop)
3643
+ return;
3644
+
3645
+ if (bRep != null || material != null) // borderline...
3646
+ rewind = h;
3647
+
3648
+ for (int i = 0; i < Size(); i++)
3649
+ {
3650
+ Object3D child = (Object3D) get(i); // reserve(i);
3651
+ if (child == null)
3652
+ continue;
3653
+ blockloop = true;
3654
+ child.RewindLeaves(h);
3655
+ blockloop = false;
3656
+ // release(i);
3657
+ }
3658
+ }
3659
+
3660
+ void RandomLeaves(boolean h)
3661
+ {
3662
+ if (blockloop)
3663
+ return;
3664
+
3665
+ if (bRep != null || material != null) // borderline...
3666
+ random = h;
3667
+
3668
+ for (int i = 0; i < Size(); i++)
3669
+ {
3670
+ Object3D child = (Object3D) get(i); // reserve(i);
3671
+ if (child == null)
3672
+ continue;
3673
+ blockloop = true;
3674
+ child.RandomLeaves(h);
34143675 blockloop = false;
34153676 // release(i);
34163677 }
....@@ -3725,7 +3986,7 @@
37253986 if (child == null)
37263987 continue;
37273988
3728
- if (GrafreeD.RENDERME > 0)
3989
+ if (Grafreed.RENDERME > 0)
37293990 {
37303991 if (child instanceof Merge)
37313992 ((Merge)child).renderme();
....@@ -3876,7 +4137,7 @@
38764137 if (child == null)
38774138 continue;
38784139
3879
- if (GrafreeD.RENDERME > 0)
4140
+ if (Grafreed.RENDERME > 0)
38804141 {
38814142 if (child instanceof Merge)
38824143 ((Merge)child).renderme();
....@@ -4071,7 +4332,7 @@
40714332 if (child == null)
40724333 continue;
40734334
4074
- if (GrafreeD.RENDERME > 0)
4335
+ if (Grafreed.RENDERME > 0)
40754336 {
40764337 if (child instanceof Merge)
40774338 ((Merge)child).renderme();
....@@ -4184,6 +4445,55 @@
41844445 {
41854446 blockloop = true;
41864447 get(i).RepairShadow();
4448
+ blockloop = false;
4449
+ }
4450
+ }
4451
+
4452
+ void RepairSOV()
4453
+ {
4454
+ if (blockloop)
4455
+ return;
4456
+
4457
+ String texname = this.GetPigmentTexture();
4458
+
4459
+ if (texname.startsWith("sov"))
4460
+ {
4461
+ String[] s = texname.split("/");
4462
+
4463
+ String[] sname = s[1].split("Color.pn");
4464
+
4465
+ texname = sname[0];
4466
+
4467
+ if (sname.length > 1)
4468
+ {
4469
+ texname += "Color.jpg";
4470
+ }
4471
+
4472
+ this.SetPigmentTexture("sov/" + texname);
4473
+ }
4474
+
4475
+ texname = this.GetBumpTexture();
4476
+
4477
+ if (texname.startsWith("sov"))
4478
+ {
4479
+ String[] s = texname.split("/");
4480
+
4481
+ String[] sname = s[1].split("Bump.pn");
4482
+
4483
+ texname = sname[0];
4484
+
4485
+ if (sname.length > 1)
4486
+ {
4487
+ texname += "Bump.jpg";
4488
+ }
4489
+
4490
+ this.SetBumpTexture("sov/" + texname);
4491
+ }
4492
+
4493
+ for (int i=0; i<Size(); i++)
4494
+ {
4495
+ blockloop = true;
4496
+ get(i).RepairSOV();
41874497 blockloop = false;
41884498 }
41894499 }
....@@ -4678,7 +4988,7 @@
46784988
46794989 cTreePath SelectLeaf(int indexcount, boolean deselect)
46804990 {
4681
- if (hide)
4991
+ if (hide || dontselect)
46824992 return null;
46834993
46844994 if (count <= 0)
....@@ -4702,9 +5012,17 @@
47025012 }
47035013 }
47045014
5015
+ ObjEditor GetWindow()
5016
+ {
5017
+ if (editWindow != null)
5018
+ return editWindow;
5019
+
5020
+ return manipWindow;
5021
+ }
5022
+
47055023 cTreePath Select(int indexcount, boolean deselect)
47065024 {
4707
- if (hide)
5025
+ if (hide || dontselect)
47085026 return null;
47095027
47105028 if (count <= 0)
....@@ -4738,10 +5056,11 @@
47385056 if (leaf != null)
47395057 {
47405058 cTreePath tp = new cTreePath(this, leaf);
4741
- if (editWindow != null)
5059
+ ObjEditor window = GetWindow();
5060
+ if (window != null)
47425061 {
47435062 //System.out.println("editWindow = " + editWindow + " vs " + this);
4744
- editWindow.Select(tp, deselect, true);
5063
+ window.Select(tp, deselect, true);
47455064 }
47465065
47475066 return tp;
....@@ -4758,6 +5077,7 @@
47585077
47595078 if (child == null)
47605079 continue;
5080
+
47615081 if (child.HasTransparency() && child.size() != 0)
47625082 {
47635083 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4767,9 +5087,10 @@
47675087 if (leaf != null)
47685088 {
47695089 cTreePath tp = new cTreePath(this, leaf);
4770
- if (editWindow != null)
5090
+ ObjEditor window = GetWindow();
5091
+ if (window != null)
47715092 {
4772
- editWindow.Select(tp, deselect, true);
5093
+ window.Select(tp, deselect, true);
47735094 }
47745095
47755096 return tp;
....@@ -4854,7 +5175,7 @@
48545175 return globalTransform;
48555176 }
48565177
4857
- void PreprocessOcclusion(CameraPane cp)
5178
+ void PreprocessOcclusion(iCameraPane cp)
48585179 {
48595180 /*
48605181 if (AOdone)
....@@ -5156,10 +5477,34 @@
51565477
51575478 // System.out.println("Fullname = " + fullname);
51585479
5159
- if (fullname.name.indexOf(":") == -1)
5160
- return fullname.name;
5480
+ // Does not work on Windows due to C:
5481
+// if (fullname.name.indexOf(":") == -1)
5482
+// return fullname.name;
5483
+//
5484
+// return fullname.name.substring(0,fullname.name.indexOf(":"));
51615485
5162
- return fullname.name.substring(0,fullname.name.indexOf(":"));
5486
+ String[] split = fullname.name.split(":");
5487
+
5488
+ if (split.length == 0)
5489
+ {
5490
+ return "";
5491
+ }
5492
+
5493
+ if (split.length <= 2)
5494
+ {
5495
+ if (fullname.name.endsWith(":"))
5496
+ {
5497
+ // Windows
5498
+ return fullname.name.substring(0, fullname.name.length()-1);
5499
+ }
5500
+
5501
+ return split[0];
5502
+ }
5503
+
5504
+ // Windows
5505
+ assert(split.length == 4);
5506
+
5507
+ return split[0] + ":" + split[1];
51635508 }
51645509
51655510 static String GetBump(cTexture fullname)
....@@ -5168,10 +5513,38 @@
51685513 return "";
51695514
51705515 // 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());
5516
+ // Does not work on Windows due to C:
5517
+// if (fullname.name.indexOf(":") == -1)
5518
+// return "";
5519
+//
5520
+// return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5521
+ String[] split = fullname.name.split(":");
5522
+
5523
+ if (split.length == 0)
5524
+ {
5525
+ return "";
5526
+ }
5527
+
5528
+ if (split.length == 1)
5529
+ {
5530
+ return "";
5531
+ }
5532
+
5533
+ if (split.length == 2)
5534
+ {
5535
+ if (fullname.name.endsWith(":"))
5536
+ {
5537
+ // Windows
5538
+ return "";
5539
+ }
5540
+
5541
+ return split[1];
5542
+ }
5543
+
5544
+ // Windows
5545
+ assert(split.length == 4);
5546
+
5547
+ return split[2] + ":" + split[3];
51755548 }
51765549
51775550 String GetPigmentTexture()
....@@ -5245,7 +5618,7 @@
52455618 System.out.print("; textures = " + textures);
52465619 System.out.println("; usedtextures = " + usedtextures);
52475620
5248
- if (GetTextures() == null)
5621
+ if (GetTextures() == null) // What is that??
52495622 GetTextures().name = ":";
52505623
52515624 String texname = tex;
....@@ -5276,6 +5649,43 @@
52765649 child.ResetPigmentTexture();
52775650 blockloop = false;
52785651 }
5652
+ }
5653
+
5654
+ UUID GetUUID()
5655
+ {
5656
+ if (uuid == null)
5657
+ {
5658
+ // Serial
5659
+ uuid = UUID.randomUUID();
5660
+ }
5661
+
5662
+ return uuid;
5663
+ }
5664
+
5665
+ Object3D GetObject(UUID uid)
5666
+ {
5667
+ if (blockloop)
5668
+ return null;
5669
+
5670
+ if (GetUUID().equals(uid))
5671
+ return this;
5672
+
5673
+ int nb = Size();
5674
+ for (int i = 0; i < nb; i++)
5675
+ {
5676
+ Object3D child = (Object3D) get(i);
5677
+
5678
+ if (child == null)
5679
+ continue;
5680
+
5681
+ blockloop = true;
5682
+ Object3D obj = child.GetObject(uid);
5683
+ blockloop = false;
5684
+ if (obj != null)
5685
+ return obj;
5686
+ }
5687
+
5688
+ return null;
52795689 }
52805690
52815691 void SetBumpTexture(String tex)
....@@ -5322,11 +5732,23 @@
53225732 boolean NeedSupport()
53235733 {
53245734 return
5325
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5735
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
53265736 // PROBLEM with CROWD!!
5327
- && (Globals.DrawMode() == iCameraPane.SHADOW || Globals.CROWD);
5737
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
53285738 }
53295739
5740
+ static boolean DEBUG_SELECTION = false;
5741
+
5742
+ boolean IsLive()
5743
+ {
5744
+ if (live)
5745
+ return true;
5746
+
5747
+ if (parent == null)
5748
+ return false;
5749
+
5750
+ return parent.IsLive();
5751
+ }
53305752
53315753 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
53325754 {
....@@ -5338,7 +5760,7 @@
53385760 }
53395761
53405762 if (display.DrawMode() == iCameraPane.SELECTION &&
5341
- hide)
5763
+ (hide || dontselect))
53425764 return;
53435765
53445766 if (name != null && name.contains("sclera"))
....@@ -5365,12 +5787,12 @@
53655787 }
53665788
53675789 if ((//display.DrawMode() == CameraPane.SHADOW ||
5368
- display.DrawMode() == CameraPane.SELECTION || CameraPane.DEBUG_SELECTION) && HasTransparency())
5790
+ display.DrawMode() == iCameraPane.SELECTION || display.IsDebugSelection()) && HasTransparency())
53695791 {
53705792 return;
53715793 }
53725794
5373
- javax.media.opengl.GL gl = display.GetGL();
5795
+ //javax.media.opengl.GL gl = display.GetGL();
53745796
53755797 /*
53765798 if (touched)
....@@ -5389,7 +5811,7 @@
53895811 support = support;
53905812
53915813 //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);
5814
+ boolean usecalllists = !IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
53935815
53945816 if (!usecalllists && bRep != null && bRep.displaylist > 0)
53955817 {
....@@ -5406,13 +5828,15 @@
54065828
54075829 boolean compiled = false;
54085830
5409
- boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION;
5831
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
54105832
54115833 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5412
- (touched || (bRep != null && bRep.displaylist <= 0)))
5834
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5835
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
54135836 {
54145837 Globals.lighttouched = true;
54155838 } // all panes...
5839
+
54165840 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
54175841 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
54185842 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5422,7 +5846,7 @@
54225846 //if (displaylist == -1 && usecalllists)
54235847 if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
54245848 {
5425
- bRep.displaylist = gl.glGenLists(1);
5849
+ bRep.displaylist = display.GenList();
54265850 assert(bRep.displaylist != 0);
54275851 // System.err.println("glGenLists: " + bRep.displaylist + " for " + this);
54285852 //System.out.println("\tgen list " + list);
....@@ -5434,14 +5858,16 @@
54345858 if (usecalllists)
54355859 {
54365860 // System.err.println("new list " + bRep.displaylist + " for " + this);
5437
- gl.glNewList(bRep.displaylist, gl.GL_COMPILE); //_AND_EXECUTE);
5861
+ display.NewList(bRep.displaylist);
54385862 }
5863
+
54395864 CallList(display, root, selected, blocked);
5865
+
54405866 // compiled = true;
54415867 if (usecalllists)
54425868 {
54435869 // System.err.println("end list " + bRep.displaylist + " for " + this);
5444
- gl.glEndList();
5870
+ display.EndList();
54455871 }
54465872 //gl.glDrawBuffer(gl.GL_BACK);
54475873 // XXX touched = false;
....@@ -5484,12 +5910,12 @@
54845910
54855911 // frustum culling
54865912 if (CameraPane.FRUSTUM && !blocked && !IsInfinite() && GetBRep() != null // && GetBRep().VertexCount() != 1260 // default grid
5487
- && display.DrawMode() != CameraPane.SELECTION)
5913
+ && display.DrawMode() != iCameraPane.SELECTION)
54885914 {
5489
- if (display.DrawMode() == CameraPane.SHADOW)
5915
+ if (display.DrawMode() == iCameraPane.SHADOW)
54905916 {
54915917 if (!link2master // tricky to cull in shadow mode.
5492
- && GetBRep().FrustumCull(this, gl, display.LightCamera(), true))
5918
+ && GetBRep().FrustumCull(this, null, display.LightCamera(), true))
54935919 {
54945920 //System.out.print("CULLED");
54955921 culled = true;
....@@ -5497,7 +5923,7 @@
54975923 }
54985924 else
54995925 //GetBRep().getBounds(v0, v1, this);
5500
- if (GetBRep().FrustumCull(this, gl, display.RenderCamera(), false))
5926
+ if (GetBRep().FrustumCull(this, null, display.RenderCamera(), false))
55015927 culled = true;
55025928
55035929 // LA.xformPos(v0, display.renderCamera.toScreen, v0);
....@@ -5533,11 +5959,12 @@
55335959
55345960
55355961 if (!culled)
5536
- if (display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION)
5962
+ if (display.DrawMode() == display.SELECTION || display.IsDebugSelection())
55375963 {
55385964 if (GetBRep() != null)
55395965 {
5540
- CameraPane.NextIndex(this, gl);
5966
+ display.NextIndex();
5967
+
55415968 // vertex color conflict : gl.glCallList(list);
55425969 DrawNode(display, root, selected);
55435970 if (this instanceof BezierPatch)
....@@ -5578,7 +6005,28 @@
55786005 tex = GetTextures();
55796006 }
55806007
5581
- display.BindTextures(tex, texres);
6008
+ boolean failedPigment = false;
6009
+ boolean failedBump = false;
6010
+
6011
+ try
6012
+ {
6013
+ display.BindPigmentTexture(tex, texres);
6014
+ }
6015
+ catch (Exception e)
6016
+ {
6017
+ System.err.println("FAILED: " + this);
6018
+ failedPigment = true;
6019
+ }
6020
+
6021
+ try
6022
+ {
6023
+ display.BindBumpTexture(tex, texres);
6024
+ }
6025
+ catch (Exception e)
6026
+ {
6027
+ //System.err.println("FAILED: " + this);
6028
+ failedBump = true;
6029
+ }
55826030
55836031 if (!compiled)
55846032 {
....@@ -5594,13 +6042,17 @@
55946042
55956043 // System.err.println("glCallList: " + bRep.displaylist + " for " + this);
55966044 assert(bRep.displaylist != 0);
5597
- gl.glCallList(bRep.displaylist);
6045
+ display.CallList(bRep.displaylist);
55986046 // june 2013 drawSelf(display, root, selected);
55996047 }
56006048 }
56016049 }
56026050
5603
- display.ReleaseTextures(tex);
6051
+ if (!failedBump)
6052
+ display.ReleaseBumpTexture(tex);
6053
+
6054
+ if (!failedPigment)
6055
+ display.ReleasePigmentTexture(tex);
56046056
56056057 display.PopMaterial(this, selected);
56066058 }
....@@ -5729,6 +6181,9 @@
57296181
57306182 void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57316183 {
6184
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6185
+ return;
6186
+
57326187 if (hide)
57336188 return;
57346189 // shadow optimisation
....@@ -5854,6 +6309,9 @@
58546309 if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
58556310 return; // no shadow for transparent objects
58566311
6312
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6313
+ return;
6314
+
58576315 if (hide)
58586316 return;
58596317
....@@ -5894,9 +6352,10 @@
58946352 return;
58956353 }
58966354
6355
+ //bRep.GenUV(1/material.diffuseness);
58976356 // bRep.lock = true;
58986357
5899
- javax.media.opengl.GL gl = display.GetGL();
6358
+ //javax.media.opengl.GL gl = display.GetGL();
59006359
59016360 if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera)
59026361 {
....@@ -5913,23 +6372,7 @@
59136372
59146373 bRep.getMinMax(min, max, 100);
59156374
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();
6375
+ display.DrawBox(min, max);
59336376
59346377 return;
59356378 }
....@@ -5973,7 +6416,7 @@
59736416 {
59746417 //throw new Error();
59756418
5976
- boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION;
6419
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
59776420
59786421 int[] strips = bRep.getRawIndices();
59796422
....@@ -5983,178 +6426,19 @@
59836426 new Exception().printStackTrace();
59846427 return;
59856428 }
5986
-
5987
- // TRIANGLE STRIP ARRAY
5988
- if (bRep.trimmed)
6429
+
6430
+ if (dontselect)
59896431 {
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;
6432
+ //bRep.GenerateNormalsMINE();
61216433 }
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
- }
6434
+
6435
+ display.DrawGeometry(bRep, flipV, selectmode);
61526436 } else // catch (Error e)
61536437 {
61546438 // TRIANGLE ARRAY
61556439 if (IsOpaque()) // Static())
61566440 {
6157
- gl.glBegin(gl.GL_TRIANGLES);
6441
+ display.StartTriangles();
61586442 int facecount = bRep.FaceCount();
61596443 for (int i = 0; i < facecount; i++)
61606444 {
....@@ -6219,7 +6503,7 @@
62196503
62206504 display.DrawFace(this, p, q, r, face);
62216505 }
6222
- gl.glEnd();
6506
+ display.EndTriangles();
62236507 }
62246508 else
62256509 {
....@@ -6248,8 +6532,8 @@
62486532 //System.out.println("SORT");
62496533
62506534 java.util.Arrays.sort(facescompare);
6251
-
6252
- gl.glBegin(gl.GL_TRIANGLES);
6535
+
6536
+ display.StartTriangles();
62536537 for (int i = 0; i < facecount; i++)
62546538 {
62556539 Face face = bRep.GetFace(facescompare[i].index);
....@@ -6263,11 +6547,12 @@
62636547
62646548 display.DrawFace(this, p, q, r, face);
62656549 }
6266
- gl.glEnd();
6550
+ display.EndTriangles();
62676551 }
62686552
62696553 if (false) // live && support != null && support.bRep != null) // debug weights
62706554 {
6555
+ /*
62716556 gl.glDisable(gl.GL_LIGHTING);
62726557 float[] colorV = new float[3];
62736558
....@@ -6346,6 +6631,7 @@
63466631 // gl.glEnd();
63476632 }
63486633 }
6634
+ */
63496635 }
63506636 }
63516637
....@@ -6390,7 +6676,7 @@
63906676 center.add(r);
63916677 center.mul(1.0/3);
63926678
6393
- center.sub(CameraPane.theRenderer.eyeCamera.location);
6679
+ center.sub(Globals.theRenderer.EyeCamera().location);
63946680
63956681 distance = center.dot(center);
63966682 }
....@@ -6404,22 +6690,6 @@
64046690 void Print(Vertex v)
64056691 {
64066692 //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);
64236693 }
64246694
64256695 void drawSelf(ClickInfo info, int level, boolean select)
....@@ -6993,83 +7263,84 @@
69937263 int spotw = spot.x + spot.width;
69947264 int spoth = spot.y + spot.height;
69957265 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
- }
7266
+// if (CameraPane.Xmin > spot.x)
7267
+// {
7268
+// CameraPane.Xmin = spot.x;
7269
+// }
7270
+// if (CameraPane.Xmax < spotw)
7271
+// {
7272
+// CameraPane.Xmax = spotw;
7273
+// }
7274
+// if (CameraPane.Ymin > spot.y)
7275
+// {
7276
+// CameraPane.Ymin = spot.y;
7277
+// }
7278
+// if (CameraPane.Ymax < spoth)
7279
+// {
7280
+// CameraPane.Ymax = spoth;
7281
+// }
70127282 spot.translate(32, 32);
70137283 spotw = spot.x + spot.width;
70147284 spoth = spot.y + spot.height;
7015
- info.g.setColor(Color.blue);
7285
+ info.g.setColor(Color.cyan);
70167286 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);
7287
+// if (CameraPane.Xmin > spot.x)
7288
+// {
7289
+// CameraPane.Xmin = spot.x;
7290
+// }
7291
+// if (CameraPane.Xmax < spotw)
7292
+// {
7293
+// CameraPane.Xmax = spotw;
7294
+// }
7295
+// if (CameraPane.Ymin > spot.y)
7296
+// {
7297
+// CameraPane.Ymin = spot.y;
7298
+// }
7299
+// if (CameraPane.Ymax < spoth)
7300
+// {
7301
+// CameraPane.Ymax = spoth;
7302
+// }
7303
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7304
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
70357305 spot.translate(0, -32);
7036
- info.g.setColor(Color.green);
7306
+ info.g.setColor(Color.yellow);
70377307 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);
7308
+ info.g.setColor(Color.green);
7309
+// if (CameraPane.Xmin > spot.x)
7310
+// {
7311
+// CameraPane.Xmin = spot.x;
7312
+// }
7313
+// if (CameraPane.Xmax < spotw)
7314
+// {
7315
+// CameraPane.Xmax = spotw;
7316
+// }
7317
+// if (CameraPane.Ymin > spot.y)
7318
+// {
7319
+// CameraPane.Ymin = spot.y;
7320
+// }
7321
+// if (CameraPane.Ymax < spoth)
7322
+// {
7323
+// CameraPane.Ymax = spoth;
7324
+// }
7325
+ info.g.drawArc(boundary.x + info.DX, boundary.y + info.DY,
7326
+ (int)(boundary.width * info.W), (int)(boundary.height * info.W), 0, 360);
70567327 //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
- }
7328
+// if (CameraPane.Xmin > boundary.x)
7329
+// {
7330
+// CameraPane.Xmin = boundary.x;
7331
+// }
7332
+// if (CameraPane.Xmax < boundary.x + boundary.width)
7333
+// {
7334
+// CameraPane.Xmax = boundary.x + boundary.width;
7335
+// }
7336
+// if (CameraPane.Ymin > boundary.y)
7337
+// {
7338
+// CameraPane.Ymin = boundary.y;
7339
+// }
7340
+// if (CameraPane.Ymax < boundary.y + boundary.height)
7341
+// {
7342
+// CameraPane.Ymax = boundary.y + boundary.height;
7343
+// }
70737344 return;
70747345 }
70757346 }
....@@ -7086,7 +7357,7 @@
70867357 startX = info.x;
70877358 startY = info.y;
70887359
7089
- hitSomething = 0;
7360
+ hitSomething = -1;
70907361 cVector origin = new cVector();
70917362 //LA.xformPos(origin, toParent, origin);
70927363 Rectangle spot = new Rectangle();
....@@ -7119,7 +7390,7 @@
71197390 }
71207391
71217392 //System.out.println("info.modifiers = " + info.modifiers);
7122
- modified = (info.modifiers & CameraPane.META) != 0;
7393
+ modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
71237394 //System.out.println("modified = " + modified);
71247395 //new Exception().printStackTrace();
71257396 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7147,7 +7418,7 @@
71477418 return true;
71487419 }
71497420
7150
- void doEditDrag0(ClickInfo info)
7421
+ void doEditDrag0(ClickInfo info, boolean opposite)
71517422 {
71527423 if (hitSomething == 0)
71537424 {
....@@ -7162,6 +7433,7 @@
71627433 //System.out.println("hitSomething = " + hitSomething);
71637434
71647435 double scale = 0.005f * info.camera.Distance();
7436
+
71657437 cVector xlate = new cVector();
71667438 //cVector xlate2 = new cVector();
71677439 switch (hitSomething)
....@@ -7172,9 +7444,9 @@
71727444
71737445 case hitCenter: // Translate
71747446
7175
- scale *= 0.05f * info.pane.theRenderer.renderCamera.Distance();
7447
+ scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
71767448
7177
- if (modified)
7449
+ if (modified || opposite)
71787450 {
71797451 //assert(false);
71807452 /*
....@@ -7220,10 +7492,10 @@
72207492 }
72217493 LA.xformDir(up, ClickInfo.matbuffer, up);
72227494 // if (!CameraPane.LOCALTRANSFORM)
7223
- LA.xformDir(up, info.pane.theRenderer.renderCamera.toScreen, up);
7495
+ LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
72247496 LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
72257497 // if (!CameraPane.LOCALTRANSFORM)
7226
- LA.xformDir(away, info.pane.theRenderer.renderCamera.toScreen, away);
7498
+ LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
72277499 //LA.vecCross(up, cVector.Z, right2);
72287500
72297501 cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
....@@ -7268,6 +7540,7 @@
72687540
72697541 if (modified)
72707542 {
7543
+ // Rotate 90 degrees
72717544 angle /= (Math.PI / 4);
72727545 angle = Math.floor(angle + 0.5);
72737546 angle *= (Math.PI / 4);
....@@ -7281,7 +7554,7 @@
72817554 }
72827555 /**/
72837556
7284
- switch (info.pane.renderCamera.viewCode)
7557
+ switch (info.pane.RenderCamera().viewCode)
72857558 {
72867559 case 1: // '\001'
72877560 LA.matZRotate(toParent, angle);
....@@ -7309,24 +7582,27 @@
73097582
73107583 case hitScale: // scale
73117584 double hScale = (double) (info.x - centerPt.x) / 32;
7585
+ double sign = 1;
7586
+ if (hScale < 0)
7587
+ {
7588
+ sign = -1;
7589
+ }
7590
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
73127591 if (hScale < 0.01)
73137592 {
7314
- hScale = 0.01;
7593
+ //hScale = 0.01;
73157594 }
7316
- hScale = Math.pow(hScale, scale * 50);
7317
- if (hScale < 0.01)
7318
- {
7319
- hScale = 0.01;
7320
- }
7595
+
73217596 double vScale = (double) (info.y - centerPt.y) / 32;
7322
- if (vScale < 0.01)
7597
+ sign = 1;
7598
+ if (vScale < 0)
73237599 {
7324
- vScale = 0.01;
7600
+ sign = -1;
73257601 }
7326
- vScale = Math.pow(vScale, scale * 50);
7602
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
73277603 if (vScale < 0.01)
73287604 {
7329
- vScale = 0.01;
7605
+ //vScale = 0.01;
73307606 }
73317607 LA.matCopy(startMat, toParent);
73327608 /**/
....@@ -7337,39 +7613,47 @@
73377613 }
73387614 /**/
73397615
7340
- switch (info.pane.renderCamera.viewCode)
7616
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7617
+
7618
+ if (totalScale < 0.01)
7619
+ {
7620
+ totalScale = 0.01;
7621
+ }
7622
+
7623
+ switch (info.pane.RenderCamera().viewCode)
73417624 {
73427625 case 3: // '\001'
7343
- if (modified)
7626
+ if (modified || opposite)
73447627 {
73457628 //LA.matScale(toParent, 1, hScale, vScale);
7346
- LA.matScale(toParent, vScale, 1, 1);
7629
+ LA.matScale(toParent, totalScale, 1, 1);
73477630 } // vScale, 1);
73487631 else
73497632 {
7350
- LA.matScale(toParent, vScale, vScale, vScale);
7633
+ // EXCEPTION!
7634
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
73517635 } // vScale, 1);
73527636 break;
73537637
73547638 case 2: // '\002'
7355
- if (modified)
7639
+ if (modified || opposite)
73567640 {
73577641 //LA.matScale(toParent, hScale, 1, vScale);
7358
- LA.matScale(toParent, 1, vScale, 1);
7642
+ LA.matScale(toParent, 1, totalScale, 1);
73597643 } else
73607644 {
7361
- LA.matScale(toParent, vScale, 1, vScale);
7645
+ LA.matScale(toParent, totalScale, 1, totalScale);
73627646 }
73637647 break;
73647648
73657649 case 1: // '\003'
7366
- if (modified)
7650
+ if (modified || opposite)
73677651 {
73687652 //LA.matScale(toParent, hScale, vScale, 1);
7369
- LA.matScale(toParent, 1, 1, vScale);
7653
+ LA.matScale(toParent, 1, 1, totalScale);
73707654 } else
73717655 {
7372
- LA.matScale(toParent, vScale, vScale, 1);
7656
+ LA.matScale(toParent, totalScale, totalScale, 1);
73737657 }
73747658 break;
73757659 }
....@@ -7502,14 +7786,22 @@
75027786 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
75037787 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
75047788 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7789
+
7790
+ String objname;
7791
+
75057792 if (false) //parent != null)
75067793 {
7507
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7794
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
75087795 } else
75097796 {
7510
- return GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ") ")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ +System.identityHashCode(this);
7797
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
75117798 } // + super.toString();
75127799 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
7800
+
7801
+ if (!Globals.ADVANCED)
7802
+ return objname;
7803
+
7804
+ return objname + " " + System.identityHashCode(this);
75137805 }
75147806
75157807 public int hashCode()
....@@ -7565,6 +7857,7 @@
75657857 objectUI.closeUI();
75667858 if (editWindow != null)
75677859 {
7860
+ editWindow.ctrlPanel.FlushUI();
75687861 editWindow.refreshContents();
75697862 } // ? new
75707863 objectUI = null;
....@@ -7573,6 +7866,10 @@
75737866 {
75747867 editWindow = null;
75757868 } // ?
7869
+ }
7870
+ else
7871
+ {
7872
+ //editWindow.closeUI();
75767873 }
75777874 }
75787875
....@@ -7585,7 +7882,7 @@
75857882 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
75867883
75877884 Object3D /*Composite*/ parent;
7588
- Object3D /*Composite*/ fileparent;
7885
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
75897886
75907887 double[][] toParent; // dynamic matrix
75917888 double[][] fromParent;
....@@ -7700,7 +7997,7 @@
77007997 {
77017998 assert(bRep != null);
77027999 if (!(support instanceof GenericJoint)) // support.bRep != null)
7703
- GrafreeD.Assert(support.bRep == bRep.support);
8000
+ Grafreed.Assert(support.bRep == bRep.support);
77048001 }
77058002 else
77068003 {
....@@ -7731,6 +8028,10 @@
77318028 }
77328029
77338030 transient ObjEditor editWindow;
8031
+ transient ObjEditor manipWindow;
8032
+
8033
+ transient boolean pinned;
8034
+
77348035 transient ObjectUI objectUI;
77358036 public static int povDepth = 0;
77368037 private static cVector tbMin = new cVector();
....@@ -7749,9 +8050,9 @@
77498050 private static cVector edge2 = new cVector();
77508051 //private static cVector norm = new cVector();
77518052 /*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;
8053
+ static final int hitCenter = 1;
8054
+ static final int hitScale = 2;
8055
+ static final int hitRotate = 3;
77558056 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
77568057 /*transient*/ private Point centerPt;
77578058 /*transient*/ private int startX;