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;
....@@ -760,7 +885,7 @@
760885
761886 int GetTransformCount()
762887 {
763
- // marde pour serialization de Texture
888
+ // patch pour serialization de Texture
764889 resetmaxcount();
765890 resettransformcount();
766891 resetstep();
....@@ -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
....@@ -794,12 +919,12 @@
794919 // factor = CameraPane.STEP;
795920 // }
796921
797
- if (marked && CameraPane.isLIVE() && live &&
922
+ if (marked && Globals.isLIVE() && live &&
798923 //TEMP21aug2018
799
- CameraPane.drawMode == CameraPane.SHADOW &&
800
- currentframe != CameraPane.framecount)
924
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
925
+ currentframe != Globals.framecount)
801926 {
802
- currentframe = CameraPane.framecount;
927
+ currentframe = Globals.framecount;
803928
804929 // System.err.println("transformcount = " + transformcount);
805930 // System.err.println("factor = " + factor);
....@@ -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)
....@@ -5001,7 +5322,8 @@
50015322 } else //
50025323 if (editWindow != null)
50035324 {
5004
- editWindow.cameraView.lighttouched = true;
5325
+ //editWindow.cameraView.lighttouched = true;
5326
+ Globals.lighttouched = true;
50055327 }
50065328 }
50075329
....@@ -5155,10 +5477,34 @@
51555477
51565478 // System.out.println("Fullname = " + fullname);
51575479
5158
- if (fullname.name.indexOf(":") == -1)
5159
- 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(":"));
51605485
5161
- 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];
51625508 }
51635509
51645510 static String GetBump(cTexture fullname)
....@@ -5167,10 +5513,38 @@
51675513 return "";
51685514
51695515 // System.out.println("Fullname = " + fullname);
5170
- if (fullname.name.indexOf(":") == -1)
5171
- return "";
5172
-
5173
- 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];
51745548 }
51755549
51765550 String GetPigmentTexture()
....@@ -5244,7 +5618,7 @@
52445618 System.out.print("; textures = " + textures);
52455619 System.out.println("; usedtextures = " + usedtextures);
52465620
5247
- if (GetTextures() == null)
5621
+ if (GetTextures() == null) // What is that??
52485622 GetTextures().name = ":";
52495623
52505624 String texname = tex;
....@@ -5275,6 +5649,43 @@
52755649 child.ResetPigmentTexture();
52765650 blockloop = false;
52775651 }
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;
52785689 }
52795690
52805691 void SetBumpTexture(String tex)
....@@ -5313,25 +5724,33 @@
53135724 }
53145725 }
53155726
5316
- void draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5727
+ void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
53175728 {
53185729 Draw(display, root, selected, blocked);
53195730 }
53205731
5321
- static cMaterial[] materialstack = new cMaterial[65536];
5322
- static boolean[] selectedstack = new boolean[65536];
5323
- static int materialdepth = 0;
5324
-
53255732 boolean NeedSupport()
53265733 {
53275734 return
5328
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5735
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
53295736 // PROBLEM with CROWD!!
5330
- && (CameraPane.drawMode == CameraPane.SHADOW || CameraPane.CROWD);
5737
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
53315738 }
53325739
5740
+ static boolean DEBUG_SELECTION = false;
53335741
5334
- void Draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5742
+ boolean IsLive()
5743
+ {
5744
+ if (live)
5745
+ return true;
5746
+
5747
+ if (parent == null)
5748
+ return false;
5749
+
5750
+ return parent.IsLive();
5751
+ }
5752
+
5753
+ void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
53355754 {
53365755 Invariants(); // june 2013
53375756
....@@ -5340,8 +5759,8 @@
53405759 // System.err.println("Draw " + this + " Frame # " + ((Mocap)((Merge)support).object).frame);
53415760 }
53425761
5343
- if (display.drawMode == CameraPane.SELECTION &&
5344
- hide)
5762
+ if (display.DrawMode() == iCameraPane.SELECTION &&
5763
+ (hide || dontselect))
53455764 return;
53465765
53475766 if (name != null && name.contains("sclera"))
....@@ -5359,7 +5778,7 @@
53595778 if (this instanceof Checker)
53605779 return;
53615780
5362
- if (display.drawMode == display.SHADOW && PASSTEST)
5781
+ if (display.DrawMode() == display.SHADOW && PASSTEST)
53635782 return;
53645783
53655784 if (count <= 0)
....@@ -5367,13 +5786,13 @@
53675786 return;
53685787 }
53695788
5370
- if ((//display.drawMode == CameraPane.SHADOW ||
5371
- display.drawMode == CameraPane.SELECTION || CameraPane.DEBUG_SELECTION) && HasTransparency())
5789
+ if ((//display.DrawMode() == CameraPane.SHADOW ||
5790
+ display.DrawMode() == iCameraPane.SELECTION || display.IsDebugSelection()) && HasTransparency())
53725791 {
53735792 return;
53745793 }
53755794
5376
- javax.media.opengl.GL gl = display.GetGL();
5795
+ //javax.media.opengl.GL gl = display.GetGL();
53775796
53785797 /*
53795798 if (touched)
....@@ -5392,7 +5811,7 @@
53925811 support = support;
53935812
53945813 //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5395
- boolean usecalllists = false; // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5814
+ boolean usecalllists = !IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
53965815
53975816 if (!usecalllists && bRep != null && bRep.displaylist > 0)
53985817 {
....@@ -5409,15 +5828,17 @@
54095828
54105829 boolean compiled = false;
54115830
5412
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
5831
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
54135832
5414
- if (!selectmode && //display.drawMode != display.SELECTION &&
5415
- (touched || (bRep != null && bRep.displaylist <= 0)))
5833
+ if (!selectmode && //display.DrawMode() != display.SELECTION &&
5834
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5835
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
54165836 {
5417
- display.lighttouched = true;
5837
+ Globals.lighttouched = true;
54185838 } // all panes...
5419
- //if (usecalllists && display.drawMode != display.SELECTION && display.drawMode != display.SHADOW &&
5420
- if (bRep != null && usecalllists && !selectmode && // june 2013 display.drawMode != display.SHADOW &&
5839
+
5840
+ //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
5841
+ if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
54215842 (touched || (bRep != null && bRep.displaylist <= 0)))
54225843 {
54235844 if (!(this instanceof Composite))
....@@ -5425,7 +5846,7 @@
54255846 //if (displaylist == -1 && usecalllists)
54265847 if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
54275848 {
5428
- bRep.displaylist = gl.glGenLists(1);
5849
+ bRep.displaylist = display.GenList();
54295850 assert(bRep.displaylist != 0);
54305851 // System.err.println("glGenLists: " + bRep.displaylist + " for " + this);
54315852 //System.out.println("\tgen list " + list);
....@@ -5437,18 +5858,20 @@
54375858 if (usecalllists)
54385859 {
54395860 // System.err.println("new list " + bRep.displaylist + " for " + this);
5440
- gl.glNewList(bRep.displaylist, gl.GL_COMPILE); //_AND_EXECUTE);
5861
+ display.NewList(bRep.displaylist);
54415862 }
5863
+
54425864 CallList(display, root, selected, blocked);
5865
+
54435866 // compiled = true;
54445867 if (usecalllists)
54455868 {
54465869 // System.err.println("end list " + bRep.displaylist + " for " + this);
5447
- gl.glEndList();
5870
+ display.EndList();
54485871 }
54495872 //gl.glDrawBuffer(gl.GL_BACK);
54505873 // XXX touched = false;
5451
- display.lighttouched = true; // all panes...
5874
+ Globals.lighttouched = true; // all panes...
54525875 }
54535876
54545877 touched = GetBRep() == null; // this instanceof Composite || this instanceof FileObject; // false;
....@@ -5487,12 +5910,12 @@
54875910
54885911 // frustum culling
54895912 if (CameraPane.FRUSTUM && !blocked && !IsInfinite() && GetBRep() != null // && GetBRep().VertexCount() != 1260 // default grid
5490
- && display.drawMode != CameraPane.SELECTION)
5913
+ && display.DrawMode() != iCameraPane.SELECTION)
54915914 {
5492
- if (display.drawMode == CameraPane.SHADOW)
5915
+ if (display.DrawMode() == iCameraPane.SHADOW)
54935916 {
54945917 if (!link2master // tricky to cull in shadow mode.
5495
- && GetBRep().FrustumCull(this, gl, display.lightCamera, true))
5918
+ && GetBRep().FrustumCull(this, null, display.LightCamera(), true))
54965919 {
54975920 //System.out.print("CULLED");
54985921 culled = true;
....@@ -5500,7 +5923,7 @@
55005923 }
55015924 else
55025925 //GetBRep().getBounds(v0, v1, this);
5503
- if (GetBRep().FrustumCull(this, gl, display.renderCamera, false))
5926
+ if (GetBRep().FrustumCull(this, null, display.RenderCamera(), false))
55045927 culled = true;
55055928
55065929 // LA.xformPos(v0, display.renderCamera.toScreen, v0);
....@@ -5536,11 +5959,12 @@
55365959
55375960
55385961 if (!culled)
5539
- if (display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION)
5962
+ if (display.DrawMode() == display.SELECTION || display.IsDebugSelection())
55405963 {
55415964 if (GetBRep() != null)
55425965 {
5543
- CameraPane.NextIndex(this, gl);
5966
+ display.NextIndex();
5967
+
55445968 // vertex color conflict : gl.glCallList(list);
55455969 DrawNode(display, root, selected);
55465970 if (this instanceof BezierPatch)
....@@ -5562,55 +5986,7 @@
55625986 color[2] /= 2;
55635987 gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT_AND_DIFFUSE, color, 0);
55645988 */
5565
- if (material != null)
5566
- {
5567
- materialstack[materialdepth] = material;
5568
- selectedstack[materialdepth] = selected;
5569
- cStatic.objectstack[materialdepth++] = this;
5570
- //System.out.println("material " + material);
5571
- //Applet3D.tracein(this, selected);
5572
- display.vector2buffer = projectedVertices;
5573
- if (this instanceof Camera)
5574
- {
5575
- display.options1[0] = material.shift;
5576
- //System.out.println("shift " + material.shift);
5577
- display.options1[1] = material.lightarea;
5578
- display.options1[2] = material.shadowbias;
5579
- display.options1[3] = material.aniso;
5580
- display.options1[4] = material.anisoV;
5581
- display.options2[0] = material.opacity;
5582
- display.options2[1] = material.diffuse;
5583
- display.options2[2] = material.factor;
5584
-
5585
- cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
5586
- display.options4[0] = material.cameralight/0.2f;
5587
- display.options4[1] = material.subsurface;
5588
- display.options4[2] = material.sheen;
5589
-
5590
- // if (display.CURRENTANTIALIAS > 0)
5591
- // display.options3[3] /= 4;
5592
-
5593
- /*
5594
- System.out.println("Focus = " + display.options1[0]);
5595
- System.out.println("Aperture = " + display.options1[1]);
5596
- System.out.println("ShadowBlur = " + display.options1[2]);
5597
- System.out.println("Antialiasing = " + display.options1[3]);
5598
- System.out.println("Fog = " + display.options2[0]);
5599
- System.out.println("Intensity = " + display.options2[1]);
5600
- System.out.println("Elevation = " + display.options2[2]);
5601
- /**/
5602
- } else
5603
- {
5604
- material.Draw(display, selected);
5605
- }
5606
- } else
5607
- {
5608
- if (selected && CameraPane.flash)
5609
- {
5610
- display.modelParams4[1] = 100;
5611
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
5612
- }
5613
- }
5989
+ display.PushMaterial(this, selected);
56145990
56155991 //System.out.println("call list " + list);
56165992 //System.out.println();
....@@ -5629,7 +6005,28 @@
56296005 tex = GetTextures();
56306006 }
56316007
5632
- 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
+ }
56336030
56346031 if (!compiled)
56356032 {
....@@ -5645,30 +6042,19 @@
56456042
56466043 // System.err.println("glCallList: " + bRep.displaylist + " for " + this);
56476044 assert(bRep.displaylist != 0);
5648
- gl.glCallList(bRep.displaylist);
6045
+ display.CallList(bRep.displaylist);
56496046 // june 2013 drawSelf(display, root, selected);
56506047 }
56516048 }
56526049 }
56536050
5654
- display.ReleaseTextures(tex);
5655
-
5656
- //if (parent != null && parent.GetMaterial() != null)
5657
- // parent.GetMaterial().Draw(display, parent.IsSelected(this));
5658
- if (material != null)
5659
- {
5660
- materialdepth -= 1;
5661
- if (materialdepth > 0)
5662
- {
5663
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
5664
- materialstack[materialdepth - 1].Draw(display, selectedstack[materialdepth - 1]);
5665
- }
5666
- //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
5667
- } else if (selected && CameraPane.flash && GetMaterial() != null)
5668
- {
5669
- display.modelParams4[1] = GetMaterial().cameralight;
5670
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
5671
- }
6051
+ if (!failedBump)
6052
+ display.ReleaseBumpTexture(tex);
6053
+
6054
+ if (!failedPigment)
6055
+ display.ReleasePigmentTexture(tex);
6056
+
6057
+ display.PopMaterial(this, selected);
56726058 }
56736059
56746060 if (this instanceof Texture || this instanceof TextureNode)
....@@ -5710,7 +6096,7 @@
57106096 // resetMasterNode();
57116097 }
57126098
5713
- void CallList(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
6099
+ void CallList(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57146100 {
57156101 if (GetBRep() == null)
57166102 {
....@@ -5793,8 +6179,11 @@
57936179 boolean flipV = false; // true;
57946180 int texres = 0; // 0 = low, 1 = normal, 2 = high res texture
57956181
5796
- void drawSelf(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
6182
+ void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57976183 {
6184
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6185
+ return;
6186
+
57986187 if (hide)
57996188 return;
58006189 // shadow optimisation
....@@ -5852,16 +6241,7 @@
58526241 // // ??????????????????????????? Touch();
58536242 // }
58546243
5855
- if (material != null)
5856
- {
5857
- materialstack[materialdepth] = material;
5858
- selectedstack[materialdepth] = selected;
5859
- cStatic.objectstack[materialdepth++] = this;
5860
- //System.out.println("material " + material);
5861
- //Applet3D.tracein("selected ", selected);
5862
- display.vector2buffer = projectedVertices;
5863
- material.Draw(display, selected);
5864
- }
6244
+display.PushMaterial2(this, selected);
58656245
58666246 Object3D child;
58676247 boolean sel;
....@@ -5913,19 +6293,7 @@
59136293 */
59146294 //depth += 1;
59156295
5916
- if (material != null)
5917
- {
5918
- materialdepth -= 1;
5919
- if (materialdepth > 0)
5920
- {
5921
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
5922
- materialstack[materialdepth - 1].Draw(display, selectedstack[materialdepth - 1]);
5923
- }
5924
- //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
5925
- //else
5926
- //material.Draw(display, false);
5927
- }
5928
-
6296
+display.PopMaterial2(this);
59296297 /*
59306298 display.ReleaseTextures(tex);
59316299 */
....@@ -5936,10 +6304,13 @@
59366304
59376305 //static cVector min,max;
59386306
5939
- void DrawNode(CameraPane display, Object3D /*Composite*/ root, boolean selected)
6307
+ void DrawNode(iCameraPane display, Object3D /*Composite*/ root, boolean selected)
59406308 {
5941
- if (display.drawMode == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
6309
+ if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
59426310 return; // no shadow for transparent objects
6311
+
6312
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6313
+ return;
59436314
59446315 if (hide)
59456316 return;
....@@ -5981,9 +6352,10 @@
59816352 return;
59826353 }
59836354
6355
+ //bRep.GenUV(1/material.diffuseness);
59846356 // bRep.lock = true;
59856357
5986
- javax.media.opengl.GL gl = display.GetGL();
6358
+ //javax.media.opengl.GL gl = display.GetGL();
59876359
59886360 if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera)
59896361 {
....@@ -6000,23 +6372,7 @@
60006372
60016373 bRep.getMinMax(min, max, 100);
60026374
6003
- gl.glBegin(gl.GL_LINES);
6004
-
6005
- gl.glVertex3d(min.x, min.y, min.z);
6006
- gl.glVertex3d(min.x, min.y, max.z);
6007
- gl.glVertex3d(min.x, min.y, min.z);
6008
- gl.glVertex3d(min.x, max.y, min.z);
6009
- gl.glVertex3d(min.x, min.y, min.z);
6010
- gl.glVertex3d(max.x, min.y, min.z);
6011
-
6012
- gl.glVertex3d(max.x, max.y, max.z);
6013
- gl.glVertex3d(min.x, max.y, max.z);
6014
- gl.glVertex3d(max.x, max.y, max.z);
6015
- gl.glVertex3d(max.x, min.y, max.z);
6016
- gl.glVertex3d(max.x, max.y, max.z);
6017
- gl.glVertex3d(max.x, max.y, min.z);
6018
-
6019
- gl.glEnd();
6375
+ display.DrawBox(min, max);
60206376
60216377 return;
60226378 }
....@@ -6060,7 +6416,7 @@
60606416 {
60616417 //throw new Error();
60626418
6063
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
6419
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
60646420
60656421 int[] strips = bRep.getRawIndices();
60666422
....@@ -6070,178 +6426,19 @@
60706426 new Exception().printStackTrace();
60716427 return;
60726428 }
6073
-
6074
- // TRIANGLE STRIP ARRAY
6075
- if (bRep.trimmed)
6429
+
6430
+ if (dontselect)
60766431 {
6077
- float[] v = bRep.getRawVertices();
6078
- float[] n = bRep.getRawNormals();
6079
- float[] c = bRep.getRawColors();
6080
- float[] uv = bRep.getRawUVMap();
6081
-
6082
- int count2 = 0;
6083
- int count3 = 0;
6084
-
6085
- if (n.length > 0)
6086
- {
6087
- for (int i = 0; i < strips.length; i++)
6088
- {
6089
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6090
-
6091
- /*
6092
- boolean locked = false;
6093
- float eps = 0.1f;
6094
- boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
6095
-
6096
- int dot = 0;
6097
-
6098
- if ((dot&1) == 0)
6099
- dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
6100
-
6101
- if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
6102
- gl.glTexCoord2f((float) qv.s, (float) qv.t);
6103
- else
6104
- {
6105
- locked = true;
6106
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6107
- }
6108
- //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6109
- gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
6110
- if (hasnorm)
6111
- {
6112
- //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6113
- gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
6114
- }
6115
-
6116
- if ((dot&4) == 0)
6117
- dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
6118
-
6119
- if (wrap || !locked && (dot&8) != 0)
6120
- gl.glTexCoord2f((float) rv.s, (float) rv.t);
6121
- else
6122
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6123
-
6124
- f.dot = dot;
6125
- */
6126
-
6127
- if (!selectmode)
6128
- {
6129
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6130
- {
6131
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6132
- } else
6133
- {
6134
- gl.glNormal3f(0, 0, 1);
6135
- }
6136
-
6137
- if (c != null)
6138
- //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]);
6139
- {
6140
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6141
- }
6142
- }
6143
- if (flipV)
6144
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6145
- else
6146
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6147
- //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6148
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6149
-
6150
- count2 += 2;
6151
- count3 += 3;
6152
- if (!selectmode)
6153
- {
6154
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6155
- {
6156
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6157
- } else
6158
- {
6159
- gl.glNormal3f(0, 0, 1);
6160
- }
6161
- if (c != null)
6162
- {
6163
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6164
- }
6165
- }
6166
- if (flipV)
6167
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6168
- else
6169
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6170
- //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6171
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6172
-
6173
- count2 += 2;
6174
- count3 += 3;
6175
- for (int j = 0; j < strips[i] - 2; j++)
6176
- {
6177
- //gl.glTexCoord2d(...);
6178
- if (!selectmode)
6179
- {
6180
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6181
- {
6182
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6183
- } else
6184
- {
6185
- gl.glNormal3f(0, 0, 1);
6186
- }
6187
- if (c != null)
6188
- {
6189
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6190
- }
6191
- }
6192
-
6193
- if (flipV)
6194
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6195
- else
6196
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6197
- //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
6198
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6199
- count2 += 2;
6200
- count3 += 3;
6201
- }
6202
-
6203
- gl.glEnd();
6204
- }
6205
- }
6206
-
6207
- assert count3 == v.length;
6432
+ //bRep.GenerateNormalsMINE();
62086433 }
6209
- else // !trimmed
6210
- {
6211
- int count = 0;
6212
- for (int i = 0; i < strips.length; i++)
6213
- {
6214
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6215
-
6216
- Vertex p = bRep.GetVertex(bRep.indices[count++]);
6217
- Vertex q = bRep.GetVertex(bRep.indices[count++]);
6218
-
6219
- drawVertex(gl, p, selectmode);
6220
- drawVertex(gl, q, selectmode);
6221
-
6222
- for (int j = 0; j < strips[i] - 2; j++)
6223
- {
6224
- Vertex r = bRep.GetVertex(bRep.indices[count++]);
6225
-
6226
-// if (j%2 == 0)
6227
-// drawFace(p, q, r, display, null);
6228
-// else
6229
-// drawFace(p, r, q, display, null);
6230
-
6231
-// p = q;
6232
-// q = r;
6233
- drawVertex(gl, r, selectmode);
6234
- }
6235
-
6236
- gl.glEnd();
6237
- }
6238
- }
6434
+
6435
+ display.DrawGeometry(bRep, flipV, selectmode);
62396436 } else // catch (Error e)
62406437 {
62416438 // TRIANGLE ARRAY
62426439 if (IsOpaque()) // Static())
62436440 {
6244
- gl.glBegin(gl.GL_TRIANGLES);
6441
+ display.StartTriangles();
62456442 int facecount = bRep.FaceCount();
62466443 for (int i = 0; i < facecount; i++)
62476444 {
....@@ -6304,9 +6501,9 @@
63046501 // // r.norm.dot(v3) > -0.5)
63056502 // // continue;
63066503
6307
- drawFace(p, q, r, display, face);
6504
+ display.DrawFace(this, p, q, r, face);
63086505 }
6309
- gl.glEnd();
6506
+ display.EndTriangles();
63106507 }
63116508 else
63126509 {
....@@ -6335,8 +6532,8 @@
63356532 //System.out.println("SORT");
63366533
63376534 java.util.Arrays.sort(facescompare);
6338
-
6339
- gl.glBegin(gl.GL_TRIANGLES);
6535
+
6536
+ display.StartTriangles();
63406537 for (int i = 0; i < facecount; i++)
63416538 {
63426539 Face face = bRep.GetFace(facescompare[i].index);
....@@ -6348,13 +6545,14 @@
63486545 Vertex q = bRep.GetVertex(face.q);
63496546 Vertex r = bRep.GetVertex(face.r);
63506547
6351
- drawFace(p, q, r, display, face);
6548
+ display.DrawFace(this, p, q, r, face);
63526549 }
6353
- gl.glEnd();
6550
+ display.EndTriangles();
63546551 }
63556552
63566553 if (false) // live && support != null && support.bRep != null) // debug weights
63576554 {
6555
+ /*
63586556 gl.glDisable(gl.GL_LIGHTING);
63596557 float[] colorV = new float[3];
63606558
....@@ -6433,6 +6631,7 @@
64336631 // gl.glEnd();
64346632 }
64356633 }
6634
+ */
64366635 }
64376636 }
64386637
....@@ -6477,7 +6676,7 @@
64776676 center.add(r);
64786677 center.mul(1.0/3);
64796678
6480
- center.sub(CameraPane.theRenderer.eyeCamera.location);
6679
+ center.sub(Globals.theRenderer.EyeCamera().location);
64816680
64826681 distance = center.dot(center);
64836682 }
....@@ -6488,390 +6687,11 @@
64886687
64896688 transient FaceCompare[] facescompare = null;
64906689
6491
- void SetColor(CameraPane display, Vertex p0)
6492
- {
6493
- if (display.RENDERPROGRAM == 0)
6494
- {
6495
- float r = 0;
6496
- if (bRep != null)
6497
- {
6498
- if (bRep.stripified)
6499
- {
6500
- r = 1;
6501
- }
6502
- }
6503
- float g = 0;
6504
- if (bRep != null)
6505
- {
6506
- if (bRep.trimmed)
6507
- {
6508
- g = 1;
6509
- }
6510
- }
6511
- float b = 0;
6512
- if (support != null && link2master)
6513
- {
6514
- b = 1;
6515
- }
6516
- display.GetGL().glColor3f(r*p0.AO, g*p0.AO, b*p0.AO);
6517
- return;
6518
- }
6519
-
6520
- if (display.drawMode != CameraPane.SHADOW)
6521
- return;
6522
-
6523
- javax.media.opengl.GL gl = display.GetGL();
6524
-// if (true) return;
6525
-// float ao = p.AO;
6526
-//
6527
-// // if (ao == 0 && !bRep.AOdone) // transient problem!
6528
-// // ao = 1;
6529
-//
6530
-// gl.glColor4f(ao, ao, ao, 1);
6531
-
6532
-// CameraPane.selectedpoint.
6533
-// getAverage(cStatic.point1, true);
6534
- if (CameraPane.pointflow == null) // !random) // live)
6535
- {
6536
- return;
6537
- }
6538
-
6539
- cStatic.point1.set(0,0,0);
6540
- LA.xformPos(cStatic.point1, CameraPane.selectedpoint.toParent, cStatic.point1);
6541
-
6542
- cStatic.point1.sub(p0);
6543
-
6544
-
6545
-// if (marked && (p0.vertexlinks == null || support == null || support.bRep == null)) // no position delta?
6546
-// {
6547
-// return;
6548
-// }
6549
-
6550
- //if (true)
6551
- if (cStatic.point1.dot(cStatic.point1) > 0.000001)
6552
- {
6553
- return;
6554
- }
6555
-
6556
- float[] colorV = new float[3];
6557
-
6558
- if (false) // marked)
6559
- {
6560
- // debug rigging weights
6561
- for (int object = 0; object < p0.vertexlinks.length; object++)
6562
- {
6563
- float weight = p0.weights[object] / p0.totalweight;
6564
-
6565
- // if (weight < 0.1)
6566
- // {
6567
- // assert(weight == 0);
6568
- // continue;
6569
- // }
6570
-
6571
- if (p0.vertexlinks[object] == -1)
6572
- continue;
6573
-
6574
- Vertex q = support.bRep.GetVertex(p0.vertexlinks[object]);
6575
-
6576
- int color = //1 << object; //
6577
- //p.vertexlinks.length;
6578
- support.bRep.supports[p0.closestsupport].links[object];
6579
- colorV[2] += (color & 1) * weight;
6580
- colorV[1] += ((color & 2) >> 1) * weight;
6581
- colorV[0] += ((color & 4) >> 2) * weight;
6582
- }
6583
- }
6584
- else
6585
- {
6586
- if (drawingstarted)
6587
- {
6588
- // find next point
6589
- if (bRep.GetVertex(0).faceindices == null)
6590
- {
6591
- bRep.InitFaceIndices();
6592
- }
6593
-
6594
- double ymin = p0.y;
6595
-
6596
- Vertex newp = p0;
6597
-
6598
- for (int fii = 0; fii < p0.faceindices.length; fii++)
6599
- {
6600
- int fi = p0.faceindices[fii];
6601
-
6602
- if (fi == -1)
6603
- break;
6604
-
6605
- Face f = bRep.GetFace(fi);
6606
-
6607
- Vertex p = bRep.GetVertex(f.p);
6608
- Vertex q = bRep.GetVertex(f.q);
6609
- Vertex r = bRep.GetVertex(f.r);
6610
-
6611
- int swap = (int)(Math.random()*3);
6612
-
6613
-// for (int s=swap; --s>=0;)
6614
-// {
6615
-// Vertex t = p;
6616
-// p = q;
6617
-// q = r;
6618
-// r = t;
6619
-// }
6620
- if (ymin > p.y)
6621
- {
6622
- ymin = p.y;
6623
- newp = p;
6624
-// break;
6625
- }
6626
- if (ymin > q.y)
6627
- {
6628
- ymin = q.y;
6629
- newp = q;
6630
-// break;
6631
- }
6632
- if (ymin > r.y)
6633
- {
6634
- ymin = r.y;
6635
- newp = r;
6636
-// break;
6637
- }
6638
- }
6639
-
6640
- CameraPane.selectedpoint.toParent[3][0] = newp.x;
6641
- CameraPane.selectedpoint.toParent[3][1] = newp.y;
6642
- CameraPane.selectedpoint.toParent[3][2] = newp.z;
6643
-
6644
- drawingstarted = false;
6645
-
6646
- // return;
6647
- }
6648
-
6649
- if (false) // CameraPane.DRAW
6650
- {
6651
- p0.AO = colorV[0] = 2;
6652
- colorV[1] = 2;
6653
- colorV[2] = 2;
6654
- }
6655
-
6656
- CameraPane.pointflow.add(p0);
6657
- CameraPane.pointflow.Touch();
6658
- }
6659
-
6660
-// gl.glColor3f(colorV[0], colorV[1], colorV[2]);
6661
-// gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0);
6662
-// gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
6663
- }
6664
-
66656690 void Print(Vertex v)
66666691 {
66676692 //System.err.println("(" + v.x + ", " + v.y + ", " + v.z + ")");
66686693 }
66696694
6670
- void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean selectmode)
6671
- {
6672
- if (!selectmode)
6673
- {
6674
- gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
6675
- gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
6676
-
6677
- if (flipV)
6678
- gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
6679
- else
6680
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6681
- }
6682
-
6683
- gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
6684
- }
6685
-
6686
- void drawFace(Vertex pv, Vertex qv, Vertex rv,
6687
- CameraPane display, Face face)
6688
- {
6689
- if (pv.y == -10000 ||
6690
- qv.y == -10000 ||
6691
- rv.y == -10000)
6692
- return;
6693
-
6694
-// float b = f.nbiterations & 1;
6695
-// float g = (f.nbiterations>>1) & 1;
6696
-// float r = (f.nbiterations>>2) & 1;
6697
-//
6698
-// //if (f.weight == 10000)
6699
-// //{
6700
-// // r = 1; g = b = 0;
6701
-// //}
6702
-// //else
6703
-// //{
6704
-// // assert(f.weight < 10000);
6705
-// r = g = b = (float)bRep.FaceWeight(f)*100;
6706
-// if (r<0)
6707
-// assert(r>=0);
6708
-// //}
6709
-
6710
- javax.media.opengl.GL gl = display.GetGL();
6711
-
6712
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
6713
-
6714
- //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv);
6715
- if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
6716
- {
6717
- //gl.glBegin(gl.GL_TRIANGLES);
6718
- boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
6719
- if (!hasnorm)
6720
- {
6721
- // System.out.println("FUCK!!");
6722
- LA.vecSub(pv/*.pos*/, qv/*.pos*/, v0);
6723
- LA.vecSub(pv/*.pos*/, rv/*.pos*/, v1);
6724
- LA.vecCross(v0, v1, v2);
6725
- LA.vecNormalize(v2);
6726
- gl.glNormal3f((float) v2.x, (float) v2.y, (float) v2.z);
6727
- }
6728
-
6729
- // P
6730
- float x = (float)pv.x;
6731
- float y = (float)pv.y;
6732
- float z = (float)pv.z;
6733
-
6734
- if (hasnorm)
6735
- {
6736
-// if (!pv.norm.normalized())
6737
-// assert(pv.norm.normalized());
6738
-
6739
- //System.out.println("normalp = " + pv.norm.x + ", " + pv.norm.y + ", " + pv.norm.z);
6740
- float nx = (float)pv.norm.x;
6741
- float ny = (float)pv.norm.y;
6742
- float nz = (float)pv.norm.z;
6743
-
6744
- x += nx * NORMALPUSH;
6745
- y += ny * NORMALPUSH;
6746
- z += nz * NORMALPUSH;
6747
-
6748
- gl.glNormal3f(nx, ny, nz);
6749
- }
6750
- gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
6751
- SetColor(display, pv);
6752
- //gl.glColor4f(r, g, b, 1);
6753
- //gl.glColor4f(pv.boundary, pv.boundary, pv.boundary, 1);
6754
- if (flipV)
6755
- gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
6756
- else
6757
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6758
- //System.out.println("vertexp = " + pv.x + ", " + pv.y + ", " + pv.z);
6759
-
6760
- gl.glVertex3f(x, y, z);
6761
-
6762
- // Q
6763
- x = (float)qv.x;
6764
- y = (float)qv.y;
6765
- z = (float)qv.z;
6766
-
6767
-// Print(pv);
6768
- if (hasnorm)
6769
- {
6770
-// assert(qv.norm.normalized());
6771
- //System.out.println("normalq = " + qv.norm.x + ", " + qv.norm.y + ", " + qv.norm.z);
6772
- float nx = (float)qv.norm.x;
6773
- float ny = (float)qv.norm.y;
6774
- float nz = (float)qv.norm.z;
6775
-
6776
- x += nx * NORMALPUSH;
6777
- y += ny * NORMALPUSH;
6778
- z += nz * NORMALPUSH;
6779
-
6780
- gl.glNormal3f(nx, ny, nz);
6781
- }
6782
- //System.out.println("vertexq = " + qv.s + ", " + qv.t);
6783
- // boolean locked = false;
6784
- // float eps = 0.1f;
6785
- // boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
6786
-
6787
- // int dot = 0; //*/ (int)f.dot;
6788
-
6789
- // if ((dot&1) == 0)
6790
- // dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
6791
-
6792
- // if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
6793
- if (flipV)
6794
- gl.glTexCoord2f((float) qv.s, 1-(float) qv.t);
6795
- else
6796
- gl.glTexCoord2f((float) qv.s, (float) qv.t);
6797
- // else
6798
- // {
6799
- // locked = true;
6800
- // gl.glTexCoord2f((float) pv.s, (float) pv.t);
6801
- // }
6802
- gl.glColor4f(qv.AO, qv.AO, qv.AO, 1);
6803
- SetColor(display, qv);
6804
-
6805
- gl.glVertex3f(x, y, z);
6806
- //gl.glColor4f(r, g, b, 1);
6807
- //gl.glColor4f(qv.boundary, qv.boundary, qv.boundary, 1);
6808
- //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6809
-// Print(qv);
6810
-
6811
- // R
6812
- x = (float)rv.x;
6813
- y = (float)rv.y;
6814
- z = (float)rv.z;
6815
-
6816
- if (hasnorm)
6817
- {
6818
-// assert(rv.norm.normalized());
6819
- //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6820
- float nx = (float)rv.norm.x;
6821
- float ny = (float)rv.norm.y;
6822
- float nz = (float)rv.norm.z;
6823
-
6824
- x += nx * NORMALPUSH;
6825
- y += ny * NORMALPUSH;
6826
- z += nz * NORMALPUSH;
6827
-
6828
- gl.glNormal3f(nx, ny, nz);
6829
- }
6830
-
6831
- // if ((dot&4) == 0)
6832
- // dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
6833
-
6834
- // if (wrap || !locked && (dot&8) != 0)
6835
- if (flipV)
6836
- gl.glTexCoord2f((float) rv.s, 1-(float) rv.t);
6837
- else
6838
- gl.glTexCoord2f((float) rv.s, (float) rv.t);
6839
- // else
6840
- // gl.glTexCoord2f((float) pv.s, (float) pv.t);
6841
-
6842
- // f.dot = dot;
6843
-
6844
- gl.glColor4f(rv.AO, rv.AO, rv.AO, 1);
6845
- SetColor(display, rv);
6846
- //gl.glColor4f(r, g, b, 1);
6847
- //gl.glColor4f(rv.boundary, rv.boundary, rv.boundary, 1);
6848
- //System.out.println("vertexr = " + rv.x + ", " + rv.y + ", " + rv.z);
6849
- gl.glVertex3f(x, y, z);
6850
-// Print(rv);
6851
- //gl.glEnd();
6852
- }
6853
- else
6854
- {
6855
- gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
6856
- gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
6857
- gl.glVertex3f((float) rv.x, (float) rv.y, (float) rv.z);
6858
-
6859
- }
6860
-
6861
- if (false) // (attributes & WIREFRAME) != 0)
6862
- {
6863
- gl.glDisable(gl.GL_LIGHTING);
6864
-
6865
- gl.glBegin(gl.GL_LINE_LOOP);
6866
- gl.glVertex3d(pv./*pos.*/x, pv./*pos.*/y, pv./*pos.*/z);
6867
- gl.glVertex3d(qv./*pos.*/x, qv./*pos.*/y, qv./*pos.*/z);
6868
- gl.glVertex3d(rv./*pos.*/x, rv./*pos.*/y, rv./*pos.*/z);
6869
- gl.glEnd();
6870
-
6871
- gl.glEnable(gl.GL_LIGHTING);
6872
- }
6873
- }
6874
-
68756695 void drawSelf(ClickInfo info, int level, boolean select)
68766696 {
68776697 if (bRep == null)
....@@ -7443,83 +7263,84 @@
74437263 int spotw = spot.x + spot.width;
74447264 int spoth = spot.y + spot.height;
74457265 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7446
- if (CameraPane.Xmin > spot.x)
7447
- {
7448
- CameraPane.Xmin = spot.x;
7449
- }
7450
- if (CameraPane.Xmax < spotw)
7451
- {
7452
- CameraPane.Xmax = spotw;
7453
- }
7454
- if (CameraPane.Ymin > spot.y)
7455
- {
7456
- CameraPane.Ymin = spot.y;
7457
- }
7458
- if (CameraPane.Ymax < spoth)
7459
- {
7460
- CameraPane.Ymax = spoth;
7461
- }
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
+// }
74627282 spot.translate(32, 32);
74637283 spotw = spot.x + spot.width;
74647284 spoth = spot.y + spot.height;
7465
- info.g.setColor(Color.blue);
7285
+ info.g.setColor(Color.cyan);
74667286 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7467
- if (CameraPane.Xmin > spot.x)
7468
- {
7469
- CameraPane.Xmin = spot.x;
7470
- }
7471
- if (CameraPane.Xmax < spotw)
7472
- {
7473
- CameraPane.Xmax = spotw;
7474
- }
7475
- if (CameraPane.Ymin > spot.y)
7476
- {
7477
- CameraPane.Ymin = spot.y;
7478
- }
7479
- if (CameraPane.Ymax < spoth)
7480
- {
7481
- CameraPane.Ymax = spoth;
7482
- }
7483
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7484
- 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
74857305 spot.translate(0, -32);
7486
- info.g.setColor(Color.green);
7306
+ info.g.setColor(Color.yellow);
74877307 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7488
- if (CameraPane.Xmin > spot.x)
7489
- {
7490
- CameraPane.Xmin = spot.x;
7491
- }
7492
- if (CameraPane.Xmax < spotw)
7493
- {
7494
- CameraPane.Xmax = spotw;
7495
- }
7496
- if (CameraPane.Ymin > spot.y)
7497
- {
7498
- CameraPane.Ymin = spot.y;
7499
- }
7500
- if (CameraPane.Ymax < spoth)
7501
- {
7502
- CameraPane.Ymax = spoth;
7503
- }
7504
- info.g.drawArc(boundary.x, boundary.y,
7505
- 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);
75067327 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
7507
- if (CameraPane.Xmin > boundary.x)
7508
- {
7509
- CameraPane.Xmin = boundary.x;
7510
- }
7511
- if (CameraPane.Xmax < boundary.x + boundary.width)
7512
- {
7513
- CameraPane.Xmax = boundary.x + boundary.width;
7514
- }
7515
- if (CameraPane.Ymin > boundary.y)
7516
- {
7517
- CameraPane.Ymin = boundary.y;
7518
- }
7519
- if (CameraPane.Ymax < boundary.y + boundary.height)
7520
- {
7521
- CameraPane.Ymax = boundary.y + boundary.height;
7522
- }
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
+// }
75237344 return;
75247345 }
75257346 }
....@@ -7536,7 +7357,7 @@
75367357 startX = info.x;
75377358 startY = info.y;
75387359
7539
- hitSomething = 0;
7360
+ hitSomething = -1;
75407361 cVector origin = new cVector();
75417362 //LA.xformPos(origin, toParent, origin);
75427363 Rectangle spot = new Rectangle();
....@@ -7569,7 +7390,7 @@
75697390 }
75707391
75717392 //System.out.println("info.modifiers = " + info.modifiers);
7572
- modified = (info.modifiers & CameraPane.META) != 0;
7393
+ modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
75737394 //System.out.println("modified = " + modified);
75747395 //new Exception().printStackTrace();
75757396 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7597,7 +7418,7 @@
75977418 return true;
75987419 }
75997420
7600
- void doEditDrag0(ClickInfo info)
7421
+ void doEditDrag0(ClickInfo info, boolean opposite)
76017422 {
76027423 if (hitSomething == 0)
76037424 {
....@@ -7612,6 +7433,7 @@
76127433 //System.out.println("hitSomething = " + hitSomething);
76137434
76147435 double scale = 0.005f * info.camera.Distance();
7436
+
76157437 cVector xlate = new cVector();
76167438 //cVector xlate2 = new cVector();
76177439 switch (hitSomething)
....@@ -7622,9 +7444,9 @@
76227444
76237445 case hitCenter: // Translate
76247446
7625
- scale *= 0.05f * info.pane.theRenderer.renderCamera.Distance();
7447
+ scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
76267448
7627
- if (modified)
7449
+ if (modified || opposite)
76287450 {
76297451 //assert(false);
76307452 /*
....@@ -7670,10 +7492,10 @@
76707492 }
76717493 LA.xformDir(up, ClickInfo.matbuffer, up);
76727494 // if (!CameraPane.LOCALTRANSFORM)
7673
- LA.xformDir(up, info.pane.theRenderer.renderCamera.toScreen, up);
7495
+ LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
76747496 LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
76757497 // if (!CameraPane.LOCALTRANSFORM)
7676
- LA.xformDir(away, info.pane.theRenderer.renderCamera.toScreen, away);
7498
+ LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
76777499 //LA.vecCross(up, cVector.Z, right2);
76787500
76797501 cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
....@@ -7718,6 +7540,7 @@
77187540
77197541 if (modified)
77207542 {
7543
+ // Rotate 90 degrees
77217544 angle /= (Math.PI / 4);
77227545 angle = Math.floor(angle + 0.5);
77237546 angle *= (Math.PI / 4);
....@@ -7731,7 +7554,7 @@
77317554 }
77327555 /**/
77337556
7734
- switch (info.pane.renderCamera.viewCode)
7557
+ switch (info.pane.RenderCamera().viewCode)
77357558 {
77367559 case 1: // '\001'
77377560 LA.matZRotate(toParent, angle);
....@@ -7759,24 +7582,27 @@
77597582
77607583 case hitScale: // scale
77617584 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);
77627591 if (hScale < 0.01)
77637592 {
7764
- hScale = 0.01;
7593
+ //hScale = 0.01;
77657594 }
7766
- hScale = Math.pow(hScale, scale * 50);
7767
- if (hScale < 0.01)
7768
- {
7769
- hScale = 0.01;
7770
- }
7595
+
77717596 double vScale = (double) (info.y - centerPt.y) / 32;
7772
- if (vScale < 0.01)
7597
+ sign = 1;
7598
+ if (vScale < 0)
77737599 {
7774
- vScale = 0.01;
7600
+ sign = -1;
77757601 }
7776
- vScale = Math.pow(vScale, scale * 50);
7602
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
77777603 if (vScale < 0.01)
77787604 {
7779
- vScale = 0.01;
7605
+ //vScale = 0.01;
77807606 }
77817607 LA.matCopy(startMat, toParent);
77827608 /**/
....@@ -7787,39 +7613,47 @@
77877613 }
77887614 /**/
77897615
7790
- 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)
77917624 {
77927625 case 3: // '\001'
7793
- if (modified)
7626
+ if (modified || opposite)
77947627 {
77957628 //LA.matScale(toParent, 1, hScale, vScale);
7796
- LA.matScale(toParent, vScale, 1, 1);
7629
+ LA.matScale(toParent, totalScale, 1, 1);
77977630 } // vScale, 1);
77987631 else
77997632 {
7800
- LA.matScale(toParent, vScale, vScale, vScale);
7633
+ // EXCEPTION!
7634
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
78017635 } // vScale, 1);
78027636 break;
78037637
78047638 case 2: // '\002'
7805
- if (modified)
7639
+ if (modified || opposite)
78067640 {
78077641 //LA.matScale(toParent, hScale, 1, vScale);
7808
- LA.matScale(toParent, 1, vScale, 1);
7642
+ LA.matScale(toParent, 1, totalScale, 1);
78097643 } else
78107644 {
7811
- LA.matScale(toParent, vScale, 1, vScale);
7645
+ LA.matScale(toParent, totalScale, 1, totalScale);
78127646 }
78137647 break;
78147648
78157649 case 1: // '\003'
7816
- if (modified)
7650
+ if (modified || opposite)
78177651 {
78187652 //LA.matScale(toParent, hScale, vScale, 1);
7819
- LA.matScale(toParent, 1, 1, vScale);
7653
+ LA.matScale(toParent, 1, 1, totalScale);
78207654 } else
78217655 {
7822
- LA.matScale(toParent, vScale, vScale, 1);
7656
+ LA.matScale(toParent, totalScale, totalScale, 1);
78237657 }
78247658 break;
78257659 }
....@@ -7952,14 +7786,22 @@
79527786 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
79537787 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
79547788 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7789
+
7790
+ String objname;
7791
+
79557792 if (false) //parent != null)
79567793 {
7957
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7794
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
79587795 } else
79597796 {
7960
- 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) ":"") */ "";
79617798 } // + super.toString();
79627799 //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);
79637805 }
79647806
79657807 public int hashCode()
....@@ -8015,6 +7857,7 @@
80157857 objectUI.closeUI();
80167858 if (editWindow != null)
80177859 {
7860
+ editWindow.ctrlPanel.FlushUI();
80187861 editWindow.refreshContents();
80197862 } // ? new
80207863 objectUI = null;
....@@ -8023,6 +7866,10 @@
80237866 {
80247867 editWindow = null;
80257868 } // ?
7869
+ }
7870
+ else
7871
+ {
7872
+ //editWindow.closeUI();
80267873 }
80277874 }
80287875
....@@ -8035,7 +7882,7 @@
80357882 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
80367883
80377884 Object3D /*Composite*/ parent;
8038
- Object3D /*Composite*/ fileparent;
7885
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
80397886
80407887 double[][] toParent; // dynamic matrix
80417888 double[][] fromParent;
....@@ -8150,7 +7997,7 @@
81507997 {
81517998 assert(bRep != null);
81527999 if (!(support instanceof GenericJoint)) // support.bRep != null)
8153
- GrafreeD.Assert(support.bRep == bRep.support);
8000
+ Grafreed.Assert(support.bRep == bRep.support);
81548001 }
81558002 else
81568003 {
....@@ -8181,6 +8028,10 @@
81818028 }
81828029
81838030 transient ObjEditor editWindow;
8031
+ transient ObjEditor manipWindow;
8032
+
8033
+ transient boolean pinned;
8034
+
81848035 transient ObjectUI objectUI;
81858036 public static int povDepth = 0;
81868037 private static cVector tbMin = new cVector();
....@@ -8199,9 +8050,9 @@
81998050 private static cVector edge2 = new cVector();
82008051 //private static cVector norm = new cVector();
82018052 /*transient private*/ int hitSomething;
8202
- private static final int hitCenter = 1;
8203
- private static final int hitScale = 2;
8204
- private static final int hitRotate = 3;
8053
+ static final int hitCenter = 1;
8054
+ static final int hitScale = 2;
8055
+ static final int hitRotate = 3;
82058056 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
82068057 /*transient*/ private Point centerPt;
82078058 /*transient*/ private int startX;