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,13 +14,38 @@
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;
36
+
37
+ void InitOthers()
38
+ {
39
+ if (projectedVertices == null || projectedVertices.length <= 2)
40
+ {
41
+ projectedVertices = new Object3D.cVector2[3];
42
+ }
43
+ for (int i = 0; i < 3; i++)
44
+ {
45
+ projectedVertices[i] = new cVector2(); // Others
46
+ }
47
+ projectedVertices[0].x = 100; // bump
48
+ }
2349
2450 void MinMax(cVector minima, cVector maxima)
2551 {
....@@ -86,64 +112,173 @@
86112
87113 // transient boolean reduced; // for morph reduction
88114
89
-transient com.bulletphysics.linearmath.Transform cache; // for fast merge
90
-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
91117
92
-transient Object3D transientsupport; // for cloning
93
-transient boolean transientlink2master;
118
+ transient Object3D transientsupport; // for cloning
119
+ transient boolean transientlink2master;
94120
95
-void SaveSupports()
96
-{
97
- if (blockloop)
98
- return;
99
-
100
- transientsupport = support;
101
- transientlink2master = link2master;
102
-
103
- support = null;
104
- link2master = false;
105
-
106
- if (bRep != null)
121
+ void SaveSupports()
107122 {
108
- 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
+ }
109146 }
110
-
111
- for (int i = 0; i < Size(); i++)
147
+
148
+ void RestoreSupports()
112149 {
113
- Object3D child = (Object3D) get(i);
114
- if (child == null)
115
- 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
+
116256 blockloop = true;
117
- child.SaveSupports();
257
+
258
+ //hashtable.remove(GetUUID());
259
+
260
+ for (int i=0; i<Size(); i++)
261
+ {
262
+ get(i).RestoreBigData(hashtable);
263
+ }
264
+
118265 blockloop = false;
119266 }
120
-}
121267
122
-void RestoreSupports()
123
-{
124
- if (blockloop)
125
- return;
126
-
127
- support = transientsupport;
128
- link2master = transientlink2master;
129
- transientsupport = null;
130
- transientlink2master = false;
131
-
132
- if (bRep != null)
268
+ void RestoreBigData(Object3D o)
133269 {
134
- 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;
135281 }
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.RestoreSupports();
144
- blockloop = false;
145
- }
146
-}
147282
148283 // MOCAP SUPPORT
149284 double tx,ty,tz,rx,ry,rz;
....@@ -285,8 +420,8 @@
285420 return parent.GetName() + "#";
286421 }
287422
288
- boolean timeline = false;
289423 boolean live = false;
424
+ boolean dontselect = false;
290425 boolean hide = false;
291426 boolean link2master = false; // performs reset support/master at each frame
292427 boolean marked = false; // animation node
....@@ -296,6 +431,8 @@
296431 boolean random = false;
297432 boolean speedup = false;
298433 boolean rewind = false;
434
+
435
+ float NORMALPUSH = 0;
299436
300437 Object3D support;
301438
....@@ -416,16 +553,16 @@
416553 {
417554 Object3D copy = this;
418555
419
- Camera parentcam = CameraPane.theRenderer.manipCamera;
556
+ Camera parentcam = Globals.theRenderer.ManipCamera();
420557
421
- if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[0])
558
+ if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[0])
422559 {
423
- parentcam = CameraPane.theRenderer.cameras[1];
560
+ parentcam = Globals.theRenderer.Cameras()[1];
424561 }
425562
426
- if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[1])
563
+ if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[1])
427564 {
428
- parentcam = CameraPane.theRenderer.cameras[0];
565
+ parentcam = Globals.theRenderer.Cameras()[0];
429566 }
430567
431568 if (this == parentcam)
....@@ -433,7 +570,7 @@
433570 //assert(this instanceof Camera);
434571
435572 for (int count = parentcam.GetTransformCount(); --count>=0;)
436
- LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.toParent, CameraPane.theRenderer.targetLookAt);
573
+ LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.toParent, Globals.theRenderer.TargetLookAt());
437574 }
438575
439576 copy.marked ^= true;
....@@ -453,7 +590,7 @@
453590 //assert(this instanceof Camera);
454591
455592 for (int count = parentcam.GetTransformCount(); --count>=0;)
456
- LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.fromParent, CameraPane.theRenderer.targetLookAt);
593
+ LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.fromParent, Globals.theRenderer.TargetLookAt());
457594 }
458595
459596 copy.Touch(); // display list issue
....@@ -466,12 +603,14 @@
466603 toParent = LA.newMatrix();
467604 fromParent = LA.newMatrix();
468605 }
606
+
469607 if (toParentMarked == null)
470608 {
471609 if (maxcount != 1)
472610 {
473611 new Exception().printStackTrace();
474612 }
613
+
475614 toParentMarked = LA.newMatrix();
476615 fromParentMarked = LA.newMatrix();
477616 }
....@@ -588,7 +727,7 @@
588727 return;
589728 }
590729
591
- if (CameraPane.fromscript)
730
+ if (Globals.fromscript)
592731 {
593732 transformcount = 0;
594733 return;
....@@ -746,7 +885,7 @@
746885
747886 int GetTransformCount()
748887 {
749
- // marde pour serialization de Texture
888
+ // patch pour serialization de Texture
750889 resetmaxcount();
751890 resettransformcount();
752891 resetstep();
....@@ -759,7 +898,7 @@
759898 if (step == 0)
760899 step = 1;
761900 if (maxcount == 0)
762
- maxcount = 2048; // 4;
901
+ maxcount = 128; // 2048; // 4;
763902 // if (acceleration == 0)
764903 // acceleration = 10;
765904 if (delay == 0) // serial
....@@ -780,9 +919,12 @@
780919 // factor = CameraPane.STEP;
781920 // }
782921
783
- if (marked && CameraPane.isLIVE() && live && CameraPane.drawMode == CameraPane.SHADOW && currentframe != CameraPane.framecount)
922
+ if (marked && Globals.isLIVE() && live &&
923
+ //TEMP21aug2018
924
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
925
+ currentframe != Globals.framecount)
784926 {
785
- currentframe = CameraPane.framecount;
927
+ currentframe = Globals.framecount;
786928
787929 // System.err.println("transformcount = " + transformcount);
788930 // System.err.println("factor = " + factor);
....@@ -791,7 +933,8 @@
791933
792934 boolean changedir = random && Math.random() < 0.01; // && !link2master;
793935
794
- if (transformcount*factor > maxcount || (step == 1 && changedir))
936
+ if (transformcount*factor >= maxcount && (rewind || random) ||
937
+ (step == 1 && changedir))
795938 {
796939 countdown = 1;
797940 delay = speedup?8:1;
....@@ -863,6 +1006,7 @@
8631006 if (material == null || material.multiply)
8641007 return true;
8651008
1009
+ // Transparent objects are dynamic because we have to sort the triangles.
8661010 return material.opacity > 0.99;
8671011 }
8681012
....@@ -894,6 +1038,11 @@
8941038 fromParent = null; // LA.newMatrix();
8951039 bRep = null; // new BoundaryRep();
8961040
1041
+ if (oname != null && oname.equals("LeftHand"))
1042
+ {
1043
+ name = oname;
1044
+ }
1045
+
8971046 /*
8981047 float hue = (float)Math.random();
8991048 Color col;
....@@ -936,7 +1085,7 @@
9361085
9371086 public Object clone()
9381087 {
939
- return GrafreeD.clone(this);
1088
+ return Grafreed.clone(this);
9401089 }
9411090
9421091 Object3D copyExpand()
....@@ -1258,6 +1407,7 @@
12581407 toParent = LA.newMatrix();
12591408 fromParent = LA.newMatrix();
12601409 }
1410
+
12611411 LA.matCopy(other.toParent, toParent);
12621412 LA.matCopy(other.fromParent, fromParent);
12631413
....@@ -1452,7 +1602,7 @@
14521602 BoundaryRep.SEUIL = other.material.cameralight;
14531603
14541604 // Set default to 0.1
1455
- BoundaryRep.SEUIL /= 2;
1605
+ BoundaryRep.SEUIL /= 4; // 2;
14561606 System.out.println("SEUIL = " + BoundaryRep.SEUIL);
14571607 }
14581608
....@@ -1711,7 +1861,7 @@
17111861 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17121862 o.bRep = transientrep;
17131863 if (clone)
1714
- o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
1864
+ o.bRep = (BoundaryRep) Grafreed.clone(transientrep);
17151865 o.CreateMaterial();
17161866 o.SetAttributes(this, -1);
17171867 //parent
....@@ -1724,7 +1874,7 @@
17241874 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17251875 o.bRep = bRep;
17261876 if (clone)
1727
- o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
1877
+ o.bRep = (BoundaryRep) Grafreed.clone(bRep);
17281878 o.CreateMaterial();
17291879 //o.overwriteThis(this, -1);
17301880 o.SetAttributes(this, -1);
....@@ -1811,12 +1961,15 @@
18111961 if (obj.name == null)
18121962 continue; // can't be a null one
18131963
1964
+ // Try perfect match first.
18141965 if (n.equals(obj.name))
18151966 {
18161967 theobj = obj;
18171968 count++;
18181969 }
18191970 }
1971
+
1972
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18201973
18211974 if (count != 1)
18221975 for (int i=Size(); --i>=0;)
....@@ -2131,15 +2284,8 @@
21312284 if (/*parent != null &&*/ material == null)
21322285 {
21332286 material = new cMaterial(GetMaterial());
2134
- if (projectedVertices == null || projectedVertices.length <= 2)
2135
- {
2136
- projectedVertices = new Object3D.cVector2[3];
2137
- }
2138
- for (int i = 0; i < 3; i++)
2139
- {
2140
- projectedVertices[i] = new cVector2(); // Others
2141
- }
2142
- projectedVertices[0].x = 100; // bump
2287
+
2288
+ InitOthers();
21432289
21442290 if (this instanceof Camera)
21452291 {
....@@ -2283,12 +2429,17 @@
22832429 }
22842430 */
22852431 }
2432
+ else
2433
+ {
2434
+ //((ObjEditor)editWindow).SetupUI2(null);
2435
+ }
22862436 }
22872437
22882438 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
22892439 {
22902440 if (newWindow)
22912441 {
2442
+ new Exception().printStackTrace();
22922443 System.exit(0);
22932444 if (parent != null)
22942445 {
....@@ -2323,6 +2474,14 @@
23232474 {
23242475 editWindow.refreshContents();
23252476 }
2477
+ else
2478
+ {
2479
+ if (manipWindow != null)
2480
+ {
2481
+ manipWindow.refreshContents();
2482
+ }
2483
+ }
2484
+
23262485 //if (parent != null)
23272486 //parent.refreshEditWindow();
23282487 }
....@@ -2465,13 +2624,13 @@
24652624 return retval;
24662625 }
24672626
2468
- void doEditDrag(ClickInfo info)
2627
+ void doEditDrag(ClickInfo info, boolean opposite)
24692628 {
24702629 switch (doSomething)
24712630 {
24722631 case 1: // '\001'
24732632 //super.
2474
- doEditDrag0(info);
2633
+ doEditDrag0(info, opposite);
24752634 break;
24762635
24772636 case 2: // '\002'
....@@ -2484,11 +2643,11 @@
24842643 {
24852644 //sel.hitSomething = childToDrag.hitSomething;
24862645 //childToDrag.doEditDrag(info);
2487
- sel.doEditDrag(info);
2646
+ sel.doEditDrag(info, opposite);
24882647 } else
24892648 {
24902649 //super.
2491
- doEditDrag0(info);
2650
+ doEditDrag0(info, opposite);
24922651 }
24932652 }
24942653 break;
....@@ -2598,6 +2757,18 @@
25982757 void GenNormalsS(boolean crease)
25992758 {
26002759 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();
26012772 // for (int i=0; i<selection.size(); i++)
26022773 // {
26032774 // Object3D selectee = (Object3D) selection.elementAt(i);
....@@ -2738,6 +2909,24 @@
27382909 if (child == null)
27392910 continue;
27402911 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();
27412930 // Children().release(i);
27422931 }
27432932 blockloop = false;
....@@ -2895,7 +3084,8 @@
28953084 {
28963085 if (bRep != null)
28973086 {
2898
- bRep.GenUV();
3087
+ bRep.GenUV(); //1);
3088
+ //bRep.UnfoldUV();
28993089 Touch();
29003090 }
29013091 }
....@@ -2905,6 +3095,15 @@
29053095 if (bRep != null)
29063096 {
29073097 bRep.GenerateNormals(crease);
3098
+ Touch();
3099
+ }
3100
+ }
3101
+
3102
+ void GenNormalsMesh0()
3103
+ {
3104
+ if (bRep != null)
3105
+ {
3106
+ bRep.GenerateNormalsMesh();
29083107 Touch();
29093108 }
29103109 }
....@@ -2970,6 +3169,33 @@
29703169 blockloop = false;
29713170 }
29723171
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
+
29733199 void TransformGeometry()
29743200 {
29753201 Object3D obj = this;
....@@ -3191,9 +3417,11 @@
31913417
31923418 BoundaryRep sup = bRep.support;
31933419 bRep.support = null;
3194
- BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
3420
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
31953421 // bRep.SplitInTwo(onlyone); // thread...
3196
- temprep.SplitInTwo(reduction34, onlyone);
3422
+
3423
+ while(temprep.SplitInTwo(reduction34, onlyone));
3424
+
31973425 bRep = temprep;
31983426 bRep.support = sup;
31993427 Touch();
....@@ -3330,7 +3558,8 @@
33303558 if (blockloop)
33313559 return;
33323560
3333
- if (marked || (bRep != null && material != null)) // borderline...
3561
+ if (//marked || // does not make sense
3562
+ (bRep != null || material != null)) // borderline...
33343563 live = h;
33353564
33363565 for (int i = 0; i < Size(); i++)
....@@ -3351,7 +3580,8 @@
33513580 return;
33523581
33533582 //if (bRep != null)
3354
- if (marked || (bRep != null && material != null)) // borderline...
3583
+ if (//marked || // does not make sense
3584
+ (bRep != null || material != null)) // borderline...
33553585 link2master = h;
33563586
33573587 for (int i = 0; i < Size(); i++)
....@@ -3371,7 +3601,8 @@
33713601 if (blockloop)
33723602 return;
33733603
3374
- if (marked || (bRep != null && material != null)) // borderline...
3604
+ if (//marked || // does not make sense
3605
+ (bRep != null || material != null)) // borderline...
33753606 hide = h;
33763607
33773608 for (int i = 0; i < Size(); i++)
....@@ -3391,7 +3622,7 @@
33913622 if (blockloop)
33923623 return;
33933624
3394
- if (bRep != null && material != null) // borderline...
3625
+ if (bRep != null || material != null) // borderline...
33953626 marked = h;
33963627
33973628 for (int i = 0; i < Size(); i++)
....@@ -3401,6 +3632,46 @@
34013632 continue;
34023633 blockloop = true;
34033634 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);
34043675 blockloop = false;
34053676 // release(i);
34063677 }
....@@ -3715,7 +3986,7 @@
37153986 if (child == null)
37163987 continue;
37173988
3718
- if (GrafreeD.RENDERME > 0)
3989
+ if (Grafreed.RENDERME > 0)
37193990 {
37203991 if (child instanceof Merge)
37213992 ((Merge)child).renderme();
....@@ -3866,7 +4137,7 @@
38664137 if (child == null)
38674138 continue;
38684139
3869
- if (GrafreeD.RENDERME > 0)
4140
+ if (Grafreed.RENDERME > 0)
38704141 {
38714142 if (child instanceof Merge)
38724143 ((Merge)child).renderme();
....@@ -4061,7 +4332,7 @@
40614332 if (child == null)
40624333 continue;
40634334
4064
- if (GrafreeD.RENDERME > 0)
4335
+ if (Grafreed.RENDERME > 0)
40654336 {
40664337 if (child instanceof Merge)
40674338 ((Merge)child).renderme();
....@@ -4158,6 +4429,71 @@
41584429 }
41594430 blockloop = true;
41604431 get(i).RepairParent();
4432
+ blockloop = false;
4433
+ }
4434
+ }
4435
+
4436
+ void RepairShadow()
4437
+ {
4438
+ if (blockloop)
4439
+ return;
4440
+
4441
+ if (this.material != null)
4442
+ this.InitOthers();
4443
+
4444
+ for (int i=0; i<Size(); i++)
4445
+ {
4446
+ blockloop = true;
4447
+ 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();
41614497 blockloop = false;
41624498 }
41634499 }
....@@ -4652,7 +4988,7 @@
46524988
46534989 cTreePath SelectLeaf(int indexcount, boolean deselect)
46544990 {
4655
- if (hide)
4991
+ if (hide || dontselect)
46564992 return null;
46574993
46584994 if (count <= 0)
....@@ -4676,9 +5012,17 @@
46765012 }
46775013 }
46785014
5015
+ ObjEditor GetWindow()
5016
+ {
5017
+ if (editWindow != null)
5018
+ return editWindow;
5019
+
5020
+ return manipWindow;
5021
+ }
5022
+
46795023 cTreePath Select(int indexcount, boolean deselect)
46805024 {
4681
- if (hide)
5025
+ if (hide || dontselect)
46825026 return null;
46835027
46845028 if (count <= 0)
....@@ -4712,10 +5056,11 @@
47125056 if (leaf != null)
47135057 {
47145058 cTreePath tp = new cTreePath(this, leaf);
4715
- if (editWindow != null)
5059
+ ObjEditor window = GetWindow();
5060
+ if (window != null)
47165061 {
47175062 //System.out.println("editWindow = " + editWindow + " vs " + this);
4718
- editWindow.Select(tp, deselect, true);
5063
+ window.Select(tp, deselect, true);
47195064 }
47205065
47215066 return tp;
....@@ -4732,6 +5077,7 @@
47325077
47335078 if (child == null)
47345079 continue;
5080
+
47355081 if (child.HasTransparency() && child.size() != 0)
47365082 {
47375083 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4741,9 +5087,10 @@
47415087 if (leaf != null)
47425088 {
47435089 cTreePath tp = new cTreePath(this, leaf);
4744
- if (editWindow != null)
5090
+ ObjEditor window = GetWindow();
5091
+ if (window != null)
47455092 {
4746
- editWindow.Select(tp, deselect, true);
5093
+ window.Select(tp, deselect, true);
47475094 }
47485095
47495096 return tp;
....@@ -4828,7 +5175,7 @@
48285175 return globalTransform;
48295176 }
48305177
4831
- void PreprocessOcclusion(CameraPane cp)
5178
+ void PreprocessOcclusion(iCameraPane cp)
48325179 {
48335180 /*
48345181 if (AOdone)
....@@ -4975,7 +5322,8 @@
49755322 } else //
49765323 if (editWindow != null)
49775324 {
4978
- editWindow.cameraView.lighttouched = true;
5325
+ //editWindow.cameraView.lighttouched = true;
5326
+ Globals.lighttouched = true;
49795327 }
49805328 }
49815329
....@@ -5129,10 +5477,34 @@
51295477
51305478 // System.out.println("Fullname = " + fullname);
51315479
5132
- if (fullname.name.indexOf(":") == -1)
5133
- 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(":"));
51345485
5135
- 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];
51365508 }
51375509
51385510 static String GetBump(cTexture fullname)
....@@ -5141,10 +5513,38 @@
51415513 return "";
51425514
51435515 // System.out.println("Fullname = " + fullname);
5144
- if (fullname.name.indexOf(":") == -1)
5145
- return "";
5146
-
5147
- 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];
51485548 }
51495549
51505550 String GetPigmentTexture()
....@@ -5218,7 +5618,7 @@
52185618 System.out.print("; textures = " + textures);
52195619 System.out.println("; usedtextures = " + usedtextures);
52205620
5221
- if (GetTextures() == null)
5621
+ if (GetTextures() == null) // What is that??
52225622 GetTextures().name = ":";
52235623
52245624 String texname = tex;
....@@ -5249,6 +5649,43 @@
52495649 child.ResetPigmentTexture();
52505650 blockloop = false;
52515651 }
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;
52525689 }
52535690
52545691 void SetBumpTexture(String tex)
....@@ -5287,25 +5724,33 @@
52875724 }
52885725 }
52895726
5290
- void draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5727
+ void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
52915728 {
52925729 Draw(display, root, selected, blocked);
52935730 }
52945731
5295
- static cMaterial[] materialstack = new cMaterial[65536];
5296
- static boolean[] selectedstack = new boolean[65536];
5297
- static int materialdepth = 0;
5298
-
52995732 boolean NeedSupport()
53005733 {
53015734 return
5302
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5735
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
53035736 // PROBLEM with CROWD!!
5304
- && (CameraPane.drawMode == CameraPane.SHADOW || CameraPane.CROWD);
5737
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
53055738 }
53065739
5740
+ static boolean DEBUG_SELECTION = false;
53075741
5308
- 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)
53095754 {
53105755 Invariants(); // june 2013
53115756
....@@ -5314,8 +5759,8 @@
53145759 // System.err.println("Draw " + this + " Frame # " + ((Mocap)((Merge)support).object).frame);
53155760 }
53165761
5317
- if (display.drawMode == CameraPane.SELECTION &&
5318
- hide)
5762
+ if (display.DrawMode() == iCameraPane.SELECTION &&
5763
+ (hide || dontselect))
53195764 return;
53205765
53215766 if (name != null && name.contains("sclera"))
....@@ -5333,7 +5778,7 @@
53335778 if (this instanceof Checker)
53345779 return;
53355780
5336
- if (display.drawMode == display.SHADOW && PASSTEST)
5781
+ if (display.DrawMode() == display.SHADOW && PASSTEST)
53375782 return;
53385783
53395784 if (count <= 0)
....@@ -5341,13 +5786,13 @@
53415786 return;
53425787 }
53435788
5344
- if ((//display.drawMode == CameraPane.SHADOW ||
5345
- display.drawMode == CameraPane.SELECTION || CameraPane.DEBUG_SELECTION) && HasTransparency())
5789
+ if ((//display.DrawMode() == CameraPane.SHADOW ||
5790
+ display.DrawMode() == iCameraPane.SELECTION || display.IsDebugSelection()) && HasTransparency())
53465791 {
53475792 return;
53485793 }
53495794
5350
- javax.media.opengl.GL gl = display.GetGL();
5795
+ //javax.media.opengl.GL gl = display.GetGL();
53515796
53525797 /*
53535798 if (touched)
....@@ -5366,7 +5811,7 @@
53665811 support = support;
53675812
53685813 //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5369
- 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);
53705815
53715816 if (!usecalllists && bRep != null && bRep.displaylist > 0)
53725817 {
....@@ -5383,15 +5828,17 @@
53835828
53845829 boolean compiled = false;
53855830
5386
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
5831
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
53875832
5388
- if (!selectmode && //display.drawMode != display.SELECTION &&
5389
- (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)))
53905836 {
5391
- display.lighttouched = true;
5837
+ Globals.lighttouched = true;
53925838 } // all panes...
5393
- //if (usecalllists && display.drawMode != display.SELECTION && display.drawMode != display.SHADOW &&
5394
- 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 &&
53955842 (touched || (bRep != null && bRep.displaylist <= 0)))
53965843 {
53975844 if (!(this instanceof Composite))
....@@ -5399,7 +5846,7 @@
53995846 //if (displaylist == -1 && usecalllists)
54005847 if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
54015848 {
5402
- bRep.displaylist = gl.glGenLists(1);
5849
+ bRep.displaylist = display.GenList();
54035850 assert(bRep.displaylist != 0);
54045851 // System.err.println("glGenLists: " + bRep.displaylist + " for " + this);
54055852 //System.out.println("\tgen list " + list);
....@@ -5411,18 +5858,20 @@
54115858 if (usecalllists)
54125859 {
54135860 // System.err.println("new list " + bRep.displaylist + " for " + this);
5414
- gl.glNewList(bRep.displaylist, gl.GL_COMPILE); //_AND_EXECUTE);
5861
+ display.NewList(bRep.displaylist);
54155862 }
5863
+
54165864 CallList(display, root, selected, blocked);
5865
+
54175866 // compiled = true;
54185867 if (usecalllists)
54195868 {
54205869 // System.err.println("end list " + bRep.displaylist + " for " + this);
5421
- gl.glEndList();
5870
+ display.EndList();
54225871 }
54235872 //gl.glDrawBuffer(gl.GL_BACK);
54245873 // XXX touched = false;
5425
- display.lighttouched = true; // all panes...
5874
+ Globals.lighttouched = true; // all panes...
54265875 }
54275876
54285877 touched = GetBRep() == null; // this instanceof Composite || this instanceof FileObject; // false;
....@@ -5461,12 +5910,12 @@
54615910
54625911 // frustum culling
54635912 if (CameraPane.FRUSTUM && !blocked && !IsInfinite() && GetBRep() != null // && GetBRep().VertexCount() != 1260 // default grid
5464
- && display.drawMode != CameraPane.SELECTION)
5913
+ && display.DrawMode() != iCameraPane.SELECTION)
54655914 {
5466
- if (display.drawMode == CameraPane.SHADOW)
5915
+ if (display.DrawMode() == iCameraPane.SHADOW)
54675916 {
54685917 if (!link2master // tricky to cull in shadow mode.
5469
- && GetBRep().FrustumCull(this, gl, display.lightCamera, true))
5918
+ && GetBRep().FrustumCull(this, null, display.LightCamera(), true))
54705919 {
54715920 //System.out.print("CULLED");
54725921 culled = true;
....@@ -5474,7 +5923,7 @@
54745923 }
54755924 else
54765925 //GetBRep().getBounds(v0, v1, this);
5477
- if (GetBRep().FrustumCull(this, gl, display.renderCamera, false))
5926
+ if (GetBRep().FrustumCull(this, null, display.RenderCamera(), false))
54785927 culled = true;
54795928
54805929 // LA.xformPos(v0, display.renderCamera.toScreen, v0);
....@@ -5510,11 +5959,12 @@
55105959
55115960
55125961 if (!culled)
5513
- if (display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION)
5962
+ if (display.DrawMode() == display.SELECTION || display.IsDebugSelection())
55145963 {
55155964 if (GetBRep() != null)
55165965 {
5517
- CameraPane.NextIndex(this, gl);
5966
+ display.NextIndex();
5967
+
55185968 // vertex color conflict : gl.glCallList(list);
55195969 DrawNode(display, root, selected);
55205970 if (this instanceof BezierPatch)
....@@ -5536,55 +5986,7 @@
55365986 color[2] /= 2;
55375987 gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT_AND_DIFFUSE, color, 0);
55385988 */
5539
- if (material != null)
5540
- {
5541
- materialstack[materialdepth] = material;
5542
- selectedstack[materialdepth] = selected;
5543
- cStatic.objectstack[materialdepth++] = this;
5544
- //System.out.println("material " + material);
5545
- //Applet3D.tracein(this, selected);
5546
- display.vector2buffer = projectedVertices;
5547
- if (this instanceof Camera)
5548
- {
5549
- display.options1[0] = material.shift;
5550
- //System.out.println("shift " + material.shift);
5551
- display.options1[1] = material.lightarea;
5552
- display.options1[2] = material.shadowbias;
5553
- display.options1[3] = material.aniso;
5554
- display.options1[4] = material.anisoV;
5555
- display.options2[0] = material.opacity;
5556
- display.options2[1] = material.diffuse;
5557
- display.options2[2] = material.factor;
5558
-
5559
- cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
5560
- display.options4[0] = material.cameralight/0.2f;
5561
- display.options4[1] = material.subsurface;
5562
- display.options4[2] = material.sheen;
5563
-
5564
- // if (display.CURRENTANTIALIAS > 0)
5565
- // display.options3[3] /= 4;
5566
-
5567
- /*
5568
- System.out.println("Focus = " + display.options1[0]);
5569
- System.out.println("Aperture = " + display.options1[1]);
5570
- System.out.println("ShadowBlur = " + display.options1[2]);
5571
- System.out.println("Antialiasing = " + display.options1[3]);
5572
- System.out.println("Fog = " + display.options2[0]);
5573
- System.out.println("Intensity = " + display.options2[1]);
5574
- System.out.println("Elevation = " + display.options2[2]);
5575
- /**/
5576
- } else
5577
- {
5578
- material.Draw(display, selected);
5579
- }
5580
- } else
5581
- {
5582
- if (selected && CameraPane.flash)
5583
- {
5584
- display.modelParams4[1] = 100;
5585
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
5586
- }
5587
- }
5989
+ display.PushMaterial(this, selected);
55885990
55895991 //System.out.println("call list " + list);
55905992 //System.out.println();
....@@ -5603,7 +6005,28 @@
56036005 tex = GetTextures();
56046006 }
56056007
5606
- 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
+ }
56076030
56086031 if (!compiled)
56096032 {
....@@ -5619,30 +6042,19 @@
56196042
56206043 // System.err.println("glCallList: " + bRep.displaylist + " for " + this);
56216044 assert(bRep.displaylist != 0);
5622
- gl.glCallList(bRep.displaylist);
6045
+ display.CallList(bRep.displaylist);
56236046 // june 2013 drawSelf(display, root, selected);
56246047 }
56256048 }
56266049 }
56276050
5628
- display.ReleaseTextures(tex);
5629
-
5630
- //if (parent != null && parent.GetMaterial() != null)
5631
- // parent.GetMaterial().Draw(display, parent.IsSelected(this));
5632
- if (material != null)
5633
- {
5634
- materialdepth -= 1;
5635
- if (materialdepth > 0)
5636
- {
5637
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
5638
- materialstack[materialdepth - 1].Draw(display, selectedstack[materialdepth - 1]);
5639
- }
5640
- //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
5641
- } else if (selected && CameraPane.flash && GetMaterial() != null)
5642
- {
5643
- display.modelParams4[1] = GetMaterial().cameralight;
5644
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
5645
- }
6051
+ if (!failedBump)
6052
+ display.ReleaseBumpTexture(tex);
6053
+
6054
+ if (!failedPigment)
6055
+ display.ReleasePigmentTexture(tex);
6056
+
6057
+ display.PopMaterial(this, selected);
56466058 }
56476059
56486060 if (this instanceof Texture || this instanceof TextureNode)
....@@ -5684,7 +6096,7 @@
56846096 // resetMasterNode();
56856097 }
56866098
5687
- void CallList(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
6099
+ void CallList(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
56886100 {
56896101 if (GetBRep() == null)
56906102 {
....@@ -5767,8 +6179,11 @@
57676179 boolean flipV = false; // true;
57686180 int texres = 0; // 0 = low, 1 = normal, 2 = high res texture
57696181
5770
- void drawSelf(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
6182
+ void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57716183 {
6184
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6185
+ return;
6186
+
57726187 if (hide)
57736188 return;
57746189 // shadow optimisation
....@@ -5826,16 +6241,7 @@
58266241 // // ??????????????????????????? Touch();
58276242 // }
58286243
5829
- if (material != null)
5830
- {
5831
- materialstack[materialdepth] = material;
5832
- selectedstack[materialdepth] = selected;
5833
- cStatic.objectstack[materialdepth++] = this;
5834
- //System.out.println("material " + material);
5835
- //Applet3D.tracein("selected ", selected);
5836
- display.vector2buffer = projectedVertices;
5837
- material.Draw(display, selected);
5838
- }
6244
+display.PushMaterial2(this, selected);
58396245
58406246 Object3D child;
58416247 boolean sel;
....@@ -5887,19 +6293,7 @@
58876293 */
58886294 //depth += 1;
58896295
5890
- if (material != null)
5891
- {
5892
- materialdepth -= 1;
5893
- if (materialdepth > 0)
5894
- {
5895
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
5896
- materialstack[materialdepth - 1].Draw(display, selectedstack[materialdepth - 1]);
5897
- }
5898
- //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
5899
- //else
5900
- //material.Draw(display, false);
5901
- }
5902
-
6296
+display.PopMaterial2(this);
59036297 /*
59046298 display.ReleaseTextures(tex);
59056299 */
....@@ -5910,10 +6304,13 @@
59106304
59116305 //static cVector min,max;
59126306
5913
- void DrawNode(CameraPane display, Object3D /*Composite*/ root, boolean selected)
6307
+ void DrawNode(iCameraPane display, Object3D /*Composite*/ root, boolean selected)
59146308 {
5915
- 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)
59166310 return; // no shadow for transparent objects
6311
+
6312
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6313
+ return;
59176314
59186315 if (hide)
59196316 return;
....@@ -5955,11 +6352,12 @@
59556352 return;
59566353 }
59576354
6355
+ //bRep.GenUV(1/material.diffuseness);
59586356 // bRep.lock = true;
59596357
5960
- javax.media.opengl.GL gl = display.GetGL();
6358
+ //javax.media.opengl.GL gl = display.GetGL();
59616359
5962
- if (CameraPane.BOXMODE) // || CameraPane.movingcamera)
6360
+ if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera)
59636361 {
59646362 int fc = bRep.FaceCount();
59656363 int vc = bRep.VertexCount();
....@@ -5974,23 +6372,7 @@
59746372
59756373 bRep.getMinMax(min, max, 100);
59766374
5977
- gl.glBegin(gl.GL_LINES);
5978
-
5979
- gl.glVertex3d(min.x, min.y, min.z);
5980
- gl.glVertex3d(min.x, min.y, max.z);
5981
- gl.glVertex3d(min.x, min.y, min.z);
5982
- gl.glVertex3d(min.x, max.y, min.z);
5983
- gl.glVertex3d(min.x, min.y, min.z);
5984
- gl.glVertex3d(max.x, min.y, min.z);
5985
-
5986
- gl.glVertex3d(max.x, max.y, max.z);
5987
- gl.glVertex3d(min.x, max.y, max.z);
5988
- gl.glVertex3d(max.x, max.y, max.z);
5989
- gl.glVertex3d(max.x, min.y, max.z);
5990
- gl.glVertex3d(max.x, max.y, max.z);
5991
- gl.glVertex3d(max.x, max.y, min.z);
5992
-
5993
- gl.glEnd();
6375
+ display.DrawBox(min, max);
59946376
59956377 return;
59966378 }
....@@ -6034,7 +6416,7 @@
60346416 {
60356417 //throw new Error();
60366418
6037
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
6419
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
60386420
60396421 int[] strips = bRep.getRawIndices();
60406422
....@@ -6044,178 +6426,19 @@
60446426 new Exception().printStackTrace();
60456427 return;
60466428 }
6047
-
6048
- // TRIANGLE STRIP ARRAY
6049
- if (bRep.trimmed)
6429
+
6430
+ if (dontselect)
60506431 {
6051
- float[] v = bRep.getRawVertices();
6052
- float[] n = bRep.getRawNormals();
6053
- float[] c = bRep.getRawColors();
6054
- float[] uv = bRep.getRawUVMap();
6055
-
6056
- int count2 = 0;
6057
- int count3 = 0;
6058
-
6059
- if (n.length > 0)
6060
- {
6061
- for (int i = 0; i < strips.length; i++)
6062
- {
6063
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6064
-
6065
- /*
6066
- boolean locked = false;
6067
- float eps = 0.1f;
6068
- boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
6069
-
6070
- int dot = 0;
6071
-
6072
- if ((dot&1) == 0)
6073
- dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
6074
-
6075
- if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
6076
- gl.glTexCoord2f((float) qv.s, (float) qv.t);
6077
- else
6078
- {
6079
- locked = true;
6080
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6081
- }
6082
- //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6083
- gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
6084
- if (hasnorm)
6085
- {
6086
- //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6087
- gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
6088
- }
6089
-
6090
- if ((dot&4) == 0)
6091
- dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
6092
-
6093
- if (wrap || !locked && (dot&8) != 0)
6094
- gl.glTexCoord2f((float) rv.s, (float) rv.t);
6095
- else
6096
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6097
-
6098
- f.dot = dot;
6099
- */
6100
-
6101
- if (!selectmode)
6102
- {
6103
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6104
- {
6105
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6106
- } else
6107
- {
6108
- gl.glNormal3f(0, 0, 1);
6109
- }
6110
-
6111
- if (c != null)
6112
- //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]);
6113
- {
6114
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6115
- }
6116
- }
6117
- if (flipV)
6118
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6119
- else
6120
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6121
- //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6122
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6123
-
6124
- count2 += 2;
6125
- count3 += 3;
6126
- if (!selectmode)
6127
- {
6128
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6129
- {
6130
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6131
- } else
6132
- {
6133
- gl.glNormal3f(0, 0, 1);
6134
- }
6135
- if (c != null)
6136
- {
6137
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6138
- }
6139
- }
6140
- if (flipV)
6141
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6142
- else
6143
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6144
- //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6145
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6146
-
6147
- count2 += 2;
6148
- count3 += 3;
6149
- for (int j = 0; j < strips[i] - 2; j++)
6150
- {
6151
- //gl.glTexCoord2d(...);
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
-
6167
- if (flipV)
6168
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6169
- else
6170
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6171
- //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
6172
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6173
- count2 += 2;
6174
- count3 += 3;
6175
- }
6176
-
6177
- gl.glEnd();
6178
- }
6179
- }
6180
-
6181
- assert count3 == v.length;
6432
+ //bRep.GenerateNormalsMINE();
61826433 }
6183
- else // !trimmed
6184
- {
6185
- int count = 0;
6186
- for (int i = 0; i < strips.length; i++)
6187
- {
6188
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6189
-
6190
- Vertex p = bRep.GetVertex(bRep.indices[count++]);
6191
- Vertex q = bRep.GetVertex(bRep.indices[count++]);
6192
-
6193
- drawVertex(gl, p, selectmode);
6194
- drawVertex(gl, q, selectmode);
6195
-
6196
- for (int j = 0; j < strips[i] - 2; j++)
6197
- {
6198
- Vertex r = bRep.GetVertex(bRep.indices[count++]);
6199
-
6200
-// if (j%2 == 0)
6201
-// drawFace(p, q, r, display, null);
6202
-// else
6203
-// drawFace(p, r, q, display, null);
6204
-
6205
-// p = q;
6206
-// q = r;
6207
- drawVertex(gl, r, selectmode);
6208
- }
6209
-
6210
- gl.glEnd();
6211
- }
6212
- }
6434
+
6435
+ display.DrawGeometry(bRep, flipV, selectmode);
62136436 } else // catch (Error e)
62146437 {
62156438 // TRIANGLE ARRAY
62166439 if (IsOpaque()) // Static())
62176440 {
6218
- gl.glBegin(gl.GL_TRIANGLES);
6441
+ display.StartTriangles();
62196442 int facecount = bRep.FaceCount();
62206443 for (int i = 0; i < facecount; i++)
62216444 {
....@@ -6278,9 +6501,9 @@
62786501 // // r.norm.dot(v3) > -0.5)
62796502 // // continue;
62806503
6281
- drawFace(p, q, r, display, face);
6504
+ display.DrawFace(this, p, q, r, face);
62826505 }
6283
- gl.glEnd();
6506
+ display.EndTriangles();
62846507 }
62856508 else
62866509 {
....@@ -6309,8 +6532,8 @@
63096532 //System.out.println("SORT");
63106533
63116534 java.util.Arrays.sort(facescompare);
6312
-
6313
- gl.glBegin(gl.GL_TRIANGLES);
6535
+
6536
+ display.StartTriangles();
63146537 for (int i = 0; i < facecount; i++)
63156538 {
63166539 Face face = bRep.GetFace(facescompare[i].index);
....@@ -6322,13 +6545,14 @@
63226545 Vertex q = bRep.GetVertex(face.q);
63236546 Vertex r = bRep.GetVertex(face.r);
63246547
6325
- drawFace(p, q, r, display, face);
6548
+ display.DrawFace(this, p, q, r, face);
63266549 }
6327
- gl.glEnd();
6550
+ display.EndTriangles();
63286551 }
63296552
63306553 if (false) // live && support != null && support.bRep != null) // debug weights
63316554 {
6555
+ /*
63326556 gl.glDisable(gl.GL_LIGHTING);
63336557 float[] colorV = new float[3];
63346558
....@@ -6407,6 +6631,7 @@
64076631 // gl.glEnd();
64086632 }
64096633 }
6634
+ */
64106635 }
64116636 }
64126637
....@@ -6451,7 +6676,7 @@
64516676 center.add(r);
64526677 center.mul(1.0/3);
64536678
6454
- center.sub(CameraPane.theRenderer.eyeCamera.location);
6679
+ center.sub(Globals.theRenderer.EyeCamera().location);
64556680
64566681 distance = center.dot(center);
64576682 }
....@@ -6462,347 +6687,11 @@
64626687
64636688 transient FaceCompare[] facescompare = null;
64646689
6465
- void SetColor(CameraPane display, Vertex p0)
6466
- {
6467
- if (display.RENDERPROGRAM == 0)
6468
- {
6469
- float r = 0;
6470
- if (bRep != null)
6471
- {
6472
- if (bRep.stripified)
6473
- {
6474
- r = 1;
6475
- }
6476
- }
6477
- float g = 0;
6478
- if (bRep != null)
6479
- {
6480
- if (bRep.trimmed)
6481
- {
6482
- g = 1;
6483
- }
6484
- }
6485
- float b = 0;
6486
- if (support != null && link2master)
6487
- {
6488
- b = 1;
6489
- }
6490
- display.GetGL().glColor3f(r*p0.AO, g*p0.AO, b*p0.AO);
6491
- return;
6492
- }
6493
-
6494
- if (display.drawMode != CameraPane.SHADOW)
6495
- return;
6496
-
6497
- javax.media.opengl.GL gl = display.GetGL();
6498
-// if (true) return;
6499
-// float ao = p.AO;
6500
-//
6501
-// // if (ao == 0 && !bRep.AOdone) // transient problem!
6502
-// // ao = 1;
6503
-//
6504
-// gl.glColor4f(ao, ao, ao, 1);
6505
-
6506
-// CameraPane.selectedpoint.
6507
-// getAverage(cStatic.point1, true);
6508
- if (CameraPane.pointflow == null) // !random) // live)
6509
- {
6510
- return;
6511
- }
6512
-
6513
- cStatic.point1.set(0,0,0);
6514
- LA.xformPos(cStatic.point1, CameraPane.selectedpoint.toParent, cStatic.point1);
6515
-
6516
- cStatic.point1.sub(p0);
6517
-
6518
-
6519
-// if (marked && (p0.vertexlinks == null || support == null || support.bRep == null)) // no position delta?
6520
-// {
6521
-// return;
6522
-// }
6523
-
6524
- //if (true)
6525
- if (cStatic.point1.dot(cStatic.point1) > 0.000001)
6526
- {
6527
- return;
6528
- }
6529
-
6530
- float[] colorV = new float[3];
6531
-
6532
- if (false) // marked)
6533
- {
6534
- // debug rigging weights
6535
- for (int object = 0; object < p0.vertexlinks.length; object++)
6536
- {
6537
- float weight = p0.weights[object] / p0.totalweight;
6538
-
6539
- // if (weight < 0.1)
6540
- // {
6541
- // assert(weight == 0);
6542
- // continue;
6543
- // }
6544
-
6545
- if (p0.vertexlinks[object] == -1)
6546
- continue;
6547
-
6548
- Vertex q = support.bRep.GetVertex(p0.vertexlinks[object]);
6549
-
6550
- int color = //1 << object; //
6551
- //p.vertexlinks.length;
6552
- support.bRep.supports[p0.closestsupport].links[object];
6553
- colorV[2] += (color & 1) * weight;
6554
- colorV[1] += ((color & 2) >> 1) * weight;
6555
- colorV[0] += ((color & 4) >> 2) * weight;
6556
- }
6557
- }
6558
- else
6559
- {
6560
- if (drawingstarted)
6561
- {
6562
- // find next point
6563
- if (bRep.GetVertex(0).faceindices == null)
6564
- {
6565
- bRep.InitFaceIndices();
6566
- }
6567
-
6568
- double ymin = p0.y;
6569
-
6570
- Vertex newp = p0;
6571
-
6572
- for (int fii = 0; fii < p0.faceindices.length; fii++)
6573
- {
6574
- int fi = p0.faceindices[fii];
6575
-
6576
- if (fi == -1)
6577
- break;
6578
-
6579
- Face f = bRep.GetFace(fi);
6580
-
6581
- Vertex p = bRep.GetVertex(f.p);
6582
- Vertex q = bRep.GetVertex(f.q);
6583
- Vertex r = bRep.GetVertex(f.r);
6584
-
6585
- int swap = (int)(Math.random()*3);
6586
-
6587
-// for (int s=swap; --s>=0;)
6588
-// {
6589
-// Vertex t = p;
6590
-// p = q;
6591
-// q = r;
6592
-// r = t;
6593
-// }
6594
- if (ymin > p.y)
6595
- {
6596
- ymin = p.y;
6597
- newp = p;
6598
-// break;
6599
- }
6600
- if (ymin > q.y)
6601
- {
6602
- ymin = q.y;
6603
- newp = q;
6604
-// break;
6605
- }
6606
- if (ymin > r.y)
6607
- {
6608
- ymin = r.y;
6609
- newp = r;
6610
-// break;
6611
- }
6612
- }
6613
-
6614
- CameraPane.selectedpoint.toParent[3][0] = newp.x;
6615
- CameraPane.selectedpoint.toParent[3][1] = newp.y;
6616
- CameraPane.selectedpoint.toParent[3][2] = newp.z;
6617
-
6618
- drawingstarted = false;
6619
-
6620
- // return;
6621
- }
6622
-
6623
- if (false) // CameraPane.DRAW
6624
- {
6625
- p0.AO = colorV[0] = 2;
6626
- colorV[1] = 2;
6627
- colorV[2] = 2;
6628
- }
6629
-
6630
- CameraPane.pointflow.add(p0);
6631
- CameraPane.pointflow.Touch();
6632
- }
6633
-
6634
-// gl.glColor3f(colorV[0], colorV[1], colorV[2]);
6635
-// gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0);
6636
-// gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
6637
- }
6638
-
66396690 void Print(Vertex v)
66406691 {
66416692 //System.err.println("(" + v.x + ", " + v.y + ", " + v.z + ")");
66426693 }
66436694
6644
- void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean selectmode)
6645
- {
6646
- if (!selectmode)
6647
- {
6648
- gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
6649
- gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
6650
-
6651
- if (flipV)
6652
- gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
6653
- else
6654
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6655
- }
6656
-
6657
- gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
6658
- }
6659
-
6660
- void drawFace(Vertex pv, Vertex qv, Vertex rv,
6661
- CameraPane display, Face face)
6662
- {
6663
- if (pv.y == -10000 ||
6664
- qv.y == -10000 ||
6665
- rv.y == -10000)
6666
- return;
6667
-
6668
-// float b = f.nbiterations & 1;
6669
-// float g = (f.nbiterations>>1) & 1;
6670
-// float r = (f.nbiterations>>2) & 1;
6671
-//
6672
-// //if (f.weight == 10000)
6673
-// //{
6674
-// // r = 1; g = b = 0;
6675
-// //}
6676
-// //else
6677
-// //{
6678
-// // assert(f.weight < 10000);
6679
-// r = g = b = (float)bRep.FaceWeight(f)*100;
6680
-// if (r<0)
6681
-// assert(r>=0);
6682
-// //}
6683
-
6684
- javax.media.opengl.GL gl = display.GetGL();
6685
-
6686
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
6687
-
6688
- //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv);
6689
- if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
6690
- {
6691
- //gl.glBegin(gl.GL_TRIANGLES);
6692
- boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
6693
- if (!hasnorm)
6694
- {
6695
- // System.out.println("FUCK!!");
6696
- LA.vecSub(pv/*.pos*/, qv/*.pos*/, v0);
6697
- LA.vecSub(pv/*.pos*/, rv/*.pos*/, v1);
6698
- LA.vecCross(v0, v1, v2);
6699
- LA.vecNormalize(v2);
6700
- gl.glNormal3f((float) v2.x, (float) v2.y, (float) v2.z);
6701
- }
6702
-
6703
- if (hasnorm)
6704
- {
6705
-// if (!pv.norm.normalized())
6706
-// assert(pv.norm.normalized());
6707
-
6708
- //System.out.println("normalp = " + pv.norm.x + ", " + pv.norm.y + ", " + pv.norm.z);
6709
- gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
6710
- }
6711
- gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
6712
- SetColor(display, pv);
6713
- //gl.glColor4f(r, g, b, 1);
6714
- //gl.glColor4f(pv.boundary, pv.boundary, pv.boundary, 1);
6715
- if (flipV)
6716
- gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
6717
- else
6718
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6719
- //System.out.println("vertexp = " + pv.x + ", " + pv.y + ", " + pv.z);
6720
- gl.glVertex3f((float) pv./*pos.*/x, (float) pv./*pos.*/y, (float) pv./*pos.*/z);
6721
-// Print(pv);
6722
- if (hasnorm)
6723
- {
6724
-// assert(qv.norm.normalized());
6725
- //System.out.println("normalq = " + qv.norm.x + ", " + qv.norm.y + ", " + qv.norm.z);
6726
- gl.glNormal3f((float) qv.norm.x, (float) qv.norm.y, (float) qv.norm.z);
6727
- }
6728
- //System.out.println("vertexq = " + qv.s + ", " + qv.t);
6729
- // boolean locked = false;
6730
- // float eps = 0.1f;
6731
- // boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
6732
-
6733
- // int dot = 0; //*/ (int)f.dot;
6734
-
6735
- // if ((dot&1) == 0)
6736
- // dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
6737
-
6738
- // if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
6739
- if (flipV)
6740
- gl.glTexCoord2f((float) qv.s, 1-(float) qv.t);
6741
- else
6742
- gl.glTexCoord2f((float) qv.s, (float) qv.t);
6743
- // else
6744
- // {
6745
- // locked = true;
6746
- // gl.glTexCoord2f((float) pv.s, (float) pv.t);
6747
- // }
6748
- gl.glColor4f(qv.AO, qv.AO, qv.AO, 1);
6749
- SetColor(display, qv);
6750
- //gl.glColor4f(r, g, b, 1);
6751
- //gl.glColor4f(qv.boundary, qv.boundary, qv.boundary, 1);
6752
- //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6753
- gl.glVertex3f((float) qv./*pos.*/x, (float) qv./*pos.*/y, (float) qv./*pos.*/z);
6754
-// Print(qv);
6755
- if (hasnorm)
6756
- {
6757
-// assert(rv.norm.normalized());
6758
- //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6759
- gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
6760
- }
6761
-
6762
- // if ((dot&4) == 0)
6763
- // dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
6764
-
6765
- // if (wrap || !locked && (dot&8) != 0)
6766
- if (flipV)
6767
- gl.glTexCoord2f((float) rv.s, 1-(float) rv.t);
6768
- else
6769
- gl.glTexCoord2f((float) rv.s, (float) rv.t);
6770
- // else
6771
- // gl.glTexCoord2f((float) pv.s, (float) pv.t);
6772
-
6773
- // f.dot = dot;
6774
-
6775
- gl.glColor4f(rv.AO, rv.AO, rv.AO, 1);
6776
- SetColor(display, rv);
6777
- //gl.glColor4f(r, g, b, 1);
6778
- //gl.glColor4f(rv.boundary, rv.boundary, rv.boundary, 1);
6779
- //System.out.println("vertexr = " + rv.x + ", " + rv.y + ", " + rv.z);
6780
- gl.glVertex3f((float) rv./*pos.*/x, (float) rv./*pos.*/y, (float) rv./*pos.*/z);
6781
-// Print(rv);
6782
- //gl.glEnd();
6783
- }
6784
- else
6785
- {
6786
- gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
6787
- gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
6788
- gl.glVertex3f((float) rv.x, (float) rv.y, (float) rv.z);
6789
-
6790
- }
6791
-
6792
- if (false) // (attributes & WIREFRAME) != 0)
6793
- {
6794
- gl.glDisable(gl.GL_LIGHTING);
6795
-
6796
- gl.glBegin(gl.GL_LINE_LOOP);
6797
- gl.glVertex3d(pv./*pos.*/x, pv./*pos.*/y, pv./*pos.*/z);
6798
- gl.glVertex3d(qv./*pos.*/x, qv./*pos.*/y, qv./*pos.*/z);
6799
- gl.glVertex3d(rv./*pos.*/x, rv./*pos.*/y, rv./*pos.*/z);
6800
- gl.glEnd();
6801
-
6802
- gl.glEnable(gl.GL_LIGHTING);
6803
- }
6804
- }
6805
-
68066695 void drawSelf(ClickInfo info, int level, boolean select)
68076696 {
68086697 if (bRep == null)
....@@ -7374,83 +7263,84 @@
73747263 int spotw = spot.x + spot.width;
73757264 int spoth = spot.y + spot.height;
73767265 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7377
- if (CameraPane.Xmin > spot.x)
7378
- {
7379
- CameraPane.Xmin = spot.x;
7380
- }
7381
- if (CameraPane.Xmax < spotw)
7382
- {
7383
- CameraPane.Xmax = spotw;
7384
- }
7385
- if (CameraPane.Ymin > spot.y)
7386
- {
7387
- CameraPane.Ymin = spot.y;
7388
- }
7389
- if (CameraPane.Ymax < spoth)
7390
- {
7391
- CameraPane.Ymax = spoth;
7392
- }
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
+// }
73937282 spot.translate(32, 32);
73947283 spotw = spot.x + spot.width;
73957284 spoth = spot.y + spot.height;
7396
- info.g.setColor(Color.blue);
7285
+ info.g.setColor(Color.cyan);
73977286 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7398
- if (CameraPane.Xmin > spot.x)
7399
- {
7400
- CameraPane.Xmin = spot.x;
7401
- }
7402
- if (CameraPane.Xmax < spotw)
7403
- {
7404
- CameraPane.Xmax = spotw;
7405
- }
7406
- if (CameraPane.Ymin > spot.y)
7407
- {
7408
- CameraPane.Ymin = spot.y;
7409
- }
7410
- if (CameraPane.Ymax < spoth)
7411
- {
7412
- CameraPane.Ymax = spoth;
7413
- }
7414
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7415
- 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
74167305 spot.translate(0, -32);
7417
- info.g.setColor(Color.green);
7306
+ info.g.setColor(Color.yellow);
74187307 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7419
- if (CameraPane.Xmin > spot.x)
7420
- {
7421
- CameraPane.Xmin = spot.x;
7422
- }
7423
- if (CameraPane.Xmax < spotw)
7424
- {
7425
- CameraPane.Xmax = spotw;
7426
- }
7427
- if (CameraPane.Ymin > spot.y)
7428
- {
7429
- CameraPane.Ymin = spot.y;
7430
- }
7431
- if (CameraPane.Ymax < spoth)
7432
- {
7433
- CameraPane.Ymax = spoth;
7434
- }
7435
- info.g.drawArc(boundary.x, boundary.y,
7436
- 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);
74377327 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
7438
- if (CameraPane.Xmin > boundary.x)
7439
- {
7440
- CameraPane.Xmin = boundary.x;
7441
- }
7442
- if (CameraPane.Xmax < boundary.x + boundary.width)
7443
- {
7444
- CameraPane.Xmax = boundary.x + boundary.width;
7445
- }
7446
- if (CameraPane.Ymin > boundary.y)
7447
- {
7448
- CameraPane.Ymin = boundary.y;
7449
- }
7450
- if (CameraPane.Ymax < boundary.y + boundary.height)
7451
- {
7452
- CameraPane.Ymax = boundary.y + boundary.height;
7453
- }
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
+// }
74547344 return;
74557345 }
74567346 }
....@@ -7467,7 +7357,7 @@
74677357 startX = info.x;
74687358 startY = info.y;
74697359
7470
- hitSomething = 0;
7360
+ hitSomething = -1;
74717361 cVector origin = new cVector();
74727362 //LA.xformPos(origin, toParent, origin);
74737363 Rectangle spot = new Rectangle();
....@@ -7500,7 +7390,7 @@
75007390 }
75017391
75027392 //System.out.println("info.modifiers = " + info.modifiers);
7503
- modified = (info.modifiers & CameraPane.META) != 0;
7393
+ modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
75047394 //System.out.println("modified = " + modified);
75057395 //new Exception().printStackTrace();
75067396 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7528,7 +7418,7 @@
75287418 return true;
75297419 }
75307420
7531
- void doEditDrag0(ClickInfo info)
7421
+ void doEditDrag0(ClickInfo info, boolean opposite)
75327422 {
75337423 if (hitSomething == 0)
75347424 {
....@@ -7543,6 +7433,7 @@
75437433 //System.out.println("hitSomething = " + hitSomething);
75447434
75457435 double scale = 0.005f * info.camera.Distance();
7436
+
75467437 cVector xlate = new cVector();
75477438 //cVector xlate2 = new cVector();
75487439 switch (hitSomething)
....@@ -7553,9 +7444,9 @@
75537444
75547445 case hitCenter: // Translate
75557446
7556
- scale *= 0.05f * info.pane.theRenderer.renderCamera.Distance();
7447
+ scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
75577448
7558
- if (modified)
7449
+ if (modified || opposite)
75597450 {
75607451 //assert(false);
75617452 /*
....@@ -7601,10 +7492,10 @@
76017492 }
76027493 LA.xformDir(up, ClickInfo.matbuffer, up);
76037494 // if (!CameraPane.LOCALTRANSFORM)
7604
- LA.xformDir(up, info.pane.theRenderer.renderCamera.toScreen, up);
7495
+ LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
76057496 LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
76067497 // if (!CameraPane.LOCALTRANSFORM)
7607
- LA.xformDir(away, info.pane.theRenderer.renderCamera.toScreen, away);
7498
+ LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
76087499 //LA.vecCross(up, cVector.Z, right2);
76097500
76107501 cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
....@@ -7649,6 +7540,7 @@
76497540
76507541 if (modified)
76517542 {
7543
+ // Rotate 90 degrees
76527544 angle /= (Math.PI / 4);
76537545 angle = Math.floor(angle + 0.5);
76547546 angle *= (Math.PI / 4);
....@@ -7662,7 +7554,7 @@
76627554 }
76637555 /**/
76647556
7665
- switch (info.pane.renderCamera.viewCode)
7557
+ switch (info.pane.RenderCamera().viewCode)
76667558 {
76677559 case 1: // '\001'
76687560 LA.matZRotate(toParent, angle);
....@@ -7690,24 +7582,27 @@
76907582
76917583 case hitScale: // scale
76927584 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);
76937591 if (hScale < 0.01)
76947592 {
7695
- hScale = 0.01;
7593
+ //hScale = 0.01;
76967594 }
7697
- hScale = Math.pow(hScale, scale * 50);
7698
- if (hScale < 0.01)
7699
- {
7700
- hScale = 0.01;
7701
- }
7595
+
77027596 double vScale = (double) (info.y - centerPt.y) / 32;
7703
- if (vScale < 0.01)
7597
+ sign = 1;
7598
+ if (vScale < 0)
77047599 {
7705
- vScale = 0.01;
7600
+ sign = -1;
77067601 }
7707
- vScale = Math.pow(vScale, scale * 50);
7602
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
77087603 if (vScale < 0.01)
77097604 {
7710
- vScale = 0.01;
7605
+ //vScale = 0.01;
77117606 }
77127607 LA.matCopy(startMat, toParent);
77137608 /**/
....@@ -7718,39 +7613,47 @@
77187613 }
77197614 /**/
77207615
7721
- 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)
77227624 {
77237625 case 3: // '\001'
7724
- if (modified)
7626
+ if (modified || opposite)
77257627 {
77267628 //LA.matScale(toParent, 1, hScale, vScale);
7727
- LA.matScale(toParent, vScale, 1, 1);
7629
+ LA.matScale(toParent, totalScale, 1, 1);
77287630 } // vScale, 1);
77297631 else
77307632 {
7731
- LA.matScale(toParent, vScale, vScale, vScale);
7633
+ // EXCEPTION!
7634
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
77327635 } // vScale, 1);
77337636 break;
77347637
77357638 case 2: // '\002'
7736
- if (modified)
7639
+ if (modified || opposite)
77377640 {
77387641 //LA.matScale(toParent, hScale, 1, vScale);
7739
- LA.matScale(toParent, 1, vScale, 1);
7642
+ LA.matScale(toParent, 1, totalScale, 1);
77407643 } else
77417644 {
7742
- LA.matScale(toParent, vScale, 1, vScale);
7645
+ LA.matScale(toParent, totalScale, 1, totalScale);
77437646 }
77447647 break;
77457648
77467649 case 1: // '\003'
7747
- if (modified)
7650
+ if (modified || opposite)
77487651 {
77497652 //LA.matScale(toParent, hScale, vScale, 1);
7750
- LA.matScale(toParent, 1, 1, vScale);
7653
+ LA.matScale(toParent, 1, 1, totalScale);
77517654 } else
77527655 {
7753
- LA.matScale(toParent, vScale, vScale, 1);
7656
+ LA.matScale(toParent, totalScale, totalScale, 1);
77547657 }
77557658 break;
77567659 }
....@@ -7883,14 +7786,22 @@
78837786 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
78847787 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
78857788 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7789
+
7790
+ String objname;
7791
+
78867792 if (false) //parent != null)
78877793 {
7888
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7794
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
78897795 } else
78907796 {
7891
- 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) ":"") */ "";
78927798 } // + super.toString();
78937799 //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);
78947805 }
78957806
78967807 public int hashCode()
....@@ -7946,6 +7857,7 @@
79467857 objectUI.closeUI();
79477858 if (editWindow != null)
79487859 {
7860
+ editWindow.ctrlPanel.FlushUI();
79497861 editWindow.refreshContents();
79507862 } // ? new
79517863 objectUI = null;
....@@ -7954,6 +7866,10 @@
79547866 {
79557867 editWindow = null;
79567868 } // ?
7869
+ }
7870
+ else
7871
+ {
7872
+ //editWindow.closeUI();
79577873 }
79587874 }
79597875
....@@ -7966,7 +7882,7 @@
79667882 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
79677883
79687884 Object3D /*Composite*/ parent;
7969
- Object3D /*Composite*/ fileparent;
7885
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
79707886
79717887 double[][] toParent; // dynamic matrix
79727888 double[][] fromParent;
....@@ -8081,7 +7997,7 @@
80817997 {
80827998 assert(bRep != null);
80837999 if (!(support instanceof GenericJoint)) // support.bRep != null)
8084
- GrafreeD.Assert(support.bRep == bRep.support);
8000
+ Grafreed.Assert(support.bRep == bRep.support);
80858001 }
80868002 else
80878003 {
....@@ -8112,6 +8028,10 @@
81128028 }
81138029
81148030 transient ObjEditor editWindow;
8031
+ transient ObjEditor manipWindow;
8032
+
8033
+ transient boolean pinned;
8034
+
81158035 transient ObjectUI objectUI;
81168036 public static int povDepth = 0;
81178037 private static cVector tbMin = new cVector();
....@@ -8130,9 +8050,9 @@
81308050 private static cVector edge2 = new cVector();
81318051 //private static cVector norm = new cVector();
81328052 /*transient private*/ int hitSomething;
8133
- private static final int hitCenter = 1;
8134
- private static final int hitScale = 2;
8135
- private static final int hitRotate = 3;
8053
+ static final int hitCenter = 1;
8054
+ static final int hitScale = 2;
8055
+ static final int hitRotate = 3;
81368056 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
81378057 /*transient*/ private Point centerPt;
81388058 /*transient*/ private int startX;
....@@ -8164,6 +8084,8 @@
81648084 {
81658085 Object3D targ = this;
81668086
8087
+ targ.NORMALPUSH = obj.NORMALPUSH;
8088
+
81678089 if (obj.material != null)
81688090 {
81698091 if ((mask&MATERIAL)!=0) // ==(COLOR|MATERIAL))