Normand Briere
2019-08-17 5892f05411c3d4dce2d8a59e0966dc2e1843a971
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,44 @@
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
+ // Use GetUUID for backward compatibility with null.
26
+ private UUID uuid = UUID.randomUUID();
27
+
28
+ // TEMPORARY for mocap undo. No need to be transient.
29
+ mocap.reader.BVHReader.BVHResult savebvh;
30
+ Object3D saveskeleton;
31
+ //
32
+
33
+ String skyboxname;
34
+ String skyboxext;
35
+
36
+ Object3D versionlist[];
37
+ int versionindex = -1;
38
+
39
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable; // = new java.util.Hashtable<java.util.UUID, Object3D>();
40
+
2241 ScriptNode scriptnode;
42
+
43
+ void InitOthers()
44
+ {
45
+ if (projectedVertices == null || projectedVertices.length <= 2)
46
+ {
47
+ projectedVertices = new Object3D.cVector2[3];
48
+ }
49
+ for (int i = 0; i < 3; i++)
50
+ {
51
+ projectedVertices[i] = new cVector2(); // Others
52
+ }
53
+ projectedVertices[0].x = 100; // bump
54
+ }
2355
2456 void MinMax(cVector minima, cVector maxima)
2557 {
....@@ -86,64 +118,201 @@
86118
87119 // transient boolean reduced; // for morph reduction
88120
89
-transient com.bulletphysics.linearmath.Transform cache; // for fast merge
90
-transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
121
+ transient com.bulletphysics.linearmath.Transform cache; // for fast merge
122
+ transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
91123
92
-transient Object3D transientsupport; // for cloning
93
-transient boolean transientlink2master;
124
+ transient Object3D transientsupport; // for cloning
125
+ transient boolean transientlink2master;
94126
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)
127
+ void SaveSupports()
107128 {
108
- bRep.SaveSupports();
129
+ if (blockloop)
130
+ return;
131
+
132
+ transientsupport = support;
133
+ transientlink2master = link2master;
134
+
135
+ support = null;
136
+ link2master = false;
137
+
138
+ if (bRep != null)
139
+ {
140
+ bRep.SaveSupports();
141
+ }
142
+
143
+ for (int i = 0; i < Size(); i++)
144
+ {
145
+ Object3D child = (Object3D) get(i);
146
+ if (child == null)
147
+ continue;
148
+ blockloop = true;
149
+ child.SaveSupports();
150
+ blockloop = false;
151
+ }
109152 }
110
-
111
- for (int i = 0; i < Size(); i++)
153
+
154
+ void RestoreSupports()
112155 {
113
- Object3D child = (Object3D) get(i);
114
- if (child == null)
115
- continue;
156
+ if (blockloop)
157
+ return;
158
+
159
+ support = transientsupport;
160
+ link2master = transientlink2master;
161
+ transientsupport = null;
162
+ transientlink2master = false;
163
+
164
+ if (bRep != null)
165
+ {
166
+ bRep.RestoreSupports();
167
+ }
168
+
169
+ for (int i = 0; i < Size(); i++)
170
+ {
171
+ Object3D child = (Object3D) get(i);
172
+ if (child == null)
173
+ continue;
174
+ blockloop = true;
175
+ child.RestoreSupports();
176
+ blockloop = false;
177
+ }
178
+ }
179
+
180
+ void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
181
+ {
182
+ Object3D o;
183
+
184
+ if (hashtable.containsKey(GetUUID()))
185
+ {
186
+ o = hashtable.get(GetUUID());
187
+
188
+ Grafreed.Assert(this.bRep == o.bRep);
189
+ //if (this.bRep != null)
190
+ // assert(this.bRep.support == o.transientrep);
191
+ if (this.support != null)
192
+ assert(this.support.bRep == o.transientrep);
193
+ }
194
+ else
195
+ {
196
+ o = new Object3D("copy of " + this.name);
197
+
198
+ hashtable.put(GetUUID(), o);
199
+ }
200
+
201
+ if (!blockloop)
202
+ {
203
+ blockloop = true;
204
+
205
+ for (int i=0; i<Size(); i++)
206
+ {
207
+ get(i).ExtractBigData(hashtable);
208
+ }
209
+
210
+ blockloop = false;
211
+ }
212
+
213
+ ExtractBigData(o);
214
+ }
215
+
216
+ void ExtractBigData(Object3D o)
217
+ {
218
+ if (o.bRep != null)
219
+ Grafreed.Assert(o.bRep == this.bRep);
220
+
221
+ o.bRep = this.bRep;
222
+// July 2019 if (this.bRep != null)
223
+// {
224
+// o.transientrep = this.bRep.support;
225
+// o.bRep.support = null;
226
+// }
227
+ o.selection = this.selection;
228
+ o.versionlist = this.versionlist;
229
+ o.versionindex = this.versionindex;
230
+
231
+ if (this.support != null)
232
+ {
233
+ if (o.transientrep != null)
234
+ Grafreed.Assert(o.transientrep == this.support.bRep);
235
+
236
+ o.transientrep = this.support.bRep;
237
+ this.support.bRep = null;
238
+ }
239
+
240
+ // o.support = this.support;
241
+ // o.fileparent = this.fileparent;
242
+ // if (this.bRep != null)
243
+ // o.bRep = this.bRep.support;
244
+
245
+ this.bRep = null;
246
+ // if (this.bRep != null)
247
+ // this.bRep.support = null;
248
+ // this.support = null;
249
+ // this.fileparent = null;
250
+ }
251
+
252
+// Object3D GetObject(java.util.UUID uuid)
253
+// {
254
+// if (this.uuid.equals(uuid))
255
+// return this;
256
+//
257
+// if (blockloop)
258
+// return null;
259
+//
260
+// blockloop = true;
261
+//
262
+// for (int i=0; i<Size(); i++)
263
+// {
264
+// Object3D o = get(i).GetObject(uuid);
265
+//
266
+// if (o != null)
267
+// return o;
268
+// }
269
+//
270
+// blockloop = false;
271
+//
272
+// return null;
273
+// }
274
+
275
+ void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
276
+ {
277
+ if (!hashtable.containsKey(GetUUID()))
278
+ return;
279
+
280
+ Object3D o = hashtable.get(GetUUID());
281
+
282
+ RestoreBigData(o);
283
+
284
+ if (blockloop)
285
+ return;
286
+
116287 blockloop = true;
117
- child.SaveSupports();
288
+
289
+ //hashtable.remove(GetUUID());
290
+
291
+ for (int i=0; i<Size(); i++)
292
+ {
293
+ get(i).RestoreBigData(hashtable);
294
+ }
295
+
118296 blockloop = false;
119297 }
120
-}
121298
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)
299
+ void RestoreBigData(Object3D o)
133300 {
134
- bRep.RestoreSupports();
301
+ this.bRep = o.bRep;
302
+ if (this.support != null && o.transientrep != null)
303
+ {
304
+ this.support.bRep = o.transientrep;
305
+ }
306
+
307
+ this.selection = o.selection;
308
+
309
+ this.versionlist = o.versionlist;
310
+ this.versionindex = o.versionindex;
311
+// July 2019 if (this.bRep != null)
312
+// this.bRep.support = o.transientrep;
313
+ // this.support = o.support;
314
+ // this.fileparent = o.fileparent;
135315 }
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
-}
147316
148317 // MOCAP SUPPORT
149318 double tx,ty,tz,rx,ry,rz;
....@@ -286,6 +455,8 @@
286455 }
287456
288457 boolean live = false;
458
+ transient boolean keepdontselect;
459
+ boolean dontselect = false;
289460 boolean hide = false;
290461 boolean link2master = false; // performs reset support/master at each frame
291462 boolean marked = false; // animation node
....@@ -295,6 +466,8 @@
295466 boolean random = false;
296467 boolean speedup = false;
297468 boolean rewind = false;
469
+
470
+ float NORMALPUSH = 0;
298471
299472 Object3D support;
300473
....@@ -355,7 +528,7 @@
355528
356529 int MemorySize()
357530 {
358
- if (memorysize == 0)
531
+ if (true) // memorysize == 0)
359532 {
360533 try
361534 {
....@@ -415,16 +588,16 @@
415588 {
416589 Object3D copy = this;
417590
418
- Camera parentcam = CameraPane.theRenderer.manipCamera;
591
+ Camera parentcam = Globals.theRenderer.ManipCamera();
419592
420
- if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[0])
593
+ if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[0])
421594 {
422
- parentcam = CameraPane.theRenderer.cameras[1];
595
+ parentcam = Globals.theRenderer.Cameras()[1];
423596 }
424597
425
- if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[1])
598
+ if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[1])
426599 {
427
- parentcam = CameraPane.theRenderer.cameras[0];
600
+ parentcam = Globals.theRenderer.Cameras()[0];
428601 }
429602
430603 if (this == parentcam)
....@@ -432,7 +605,7 @@
432605 //assert(this instanceof Camera);
433606
434607 for (int count = parentcam.GetTransformCount(); --count>=0;)
435
- LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.toParent, CameraPane.theRenderer.targetLookAt);
608
+ LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.toParent, Globals.theRenderer.TargetLookAt());
436609 }
437610
438611 copy.marked ^= true;
....@@ -452,7 +625,7 @@
452625 //assert(this instanceof Camera);
453626
454627 for (int count = parentcam.GetTransformCount(); --count>=0;)
455
- LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.fromParent, CameraPane.theRenderer.targetLookAt);
628
+ LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.fromParent, Globals.theRenderer.TargetLookAt());
456629 }
457630
458631 copy.Touch(); // display list issue
....@@ -465,12 +638,14 @@
465638 toParent = LA.newMatrix();
466639 fromParent = LA.newMatrix();
467640 }
641
+
468642 if (toParentMarked == null)
469643 {
470644 if (maxcount != 1)
471645 {
472646 new Exception().printStackTrace();
473647 }
648
+
474649 toParentMarked = LA.newMatrix();
475650 fromParentMarked = LA.newMatrix();
476651 }
....@@ -587,7 +762,7 @@
587762 return;
588763 }
589764
590
- if (CameraPane.fromscript)
765
+ if (Globals.fromscript)
591766 {
592767 transformcount = 0;
593768 return;
....@@ -745,7 +920,7 @@
745920
746921 int GetTransformCount()
747922 {
748
- // marde pour serialization de Texture
923
+ // patch pour serialization de Texture
749924 resetmaxcount();
750925 resettransformcount();
751926 resetstep();
....@@ -758,7 +933,7 @@
758933 if (step == 0)
759934 step = 1;
760935 if (maxcount == 0)
761
- maxcount = 2048; // 4;
936
+ maxcount = 128; // 2048; // 4;
762937 // if (acceleration == 0)
763938 // acceleration = 10;
764939 if (delay == 0) // serial
....@@ -779,9 +954,12 @@
779954 // factor = CameraPane.STEP;
780955 // }
781956
782
- if (marked && CameraPane.isLIVE() && live && CameraPane.drawMode == CameraPane.SHADOW && currentframe != CameraPane.framecount)
957
+ if (marked && Globals.isLIVE() && live &&
958
+ //TEMP21aug2018
959
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
960
+ currentframe != Globals.framecount)
783961 {
784
- currentframe = CameraPane.framecount;
962
+ currentframe = Globals.framecount;
785963
786964 // System.err.println("transformcount = " + transformcount);
787965 // System.err.println("factor = " + factor);
....@@ -790,7 +968,8 @@
790968
791969 boolean changedir = random && Math.random() < 0.01; // && !link2master;
792970
793
- if (transformcount*factor > maxcount || (step == 1 && changedir))
971
+ if (transformcount*factor >= maxcount && (rewind || random) ||
972
+ (step == 1 && changedir))
794973 {
795974 countdown = 1;
796975 delay = speedup?8:1;
....@@ -862,6 +1041,10 @@
8621041 if (material == null || material.multiply)
8631042 return true;
8641043
1044
+ if (projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
1045
+ return false;
1046
+
1047
+ // Transparent objects are dynamic because we have to sort the triangles.
8651048 return material.opacity > 0.99;
8661049 }
8671050
....@@ -893,6 +1076,11 @@
8931076 fromParent = null; // LA.newMatrix();
8941077 bRep = null; // new BoundaryRep();
8951078
1079
+ if (oname != null && oname.equals("LeftHand"))
1080
+ {
1081
+ name = oname;
1082
+ }
1083
+
8961084 /*
8971085 float hue = (float)Math.random();
8981086 Color col;
....@@ -935,7 +1123,7 @@
9351123
9361124 public Object clone()
9371125 {
938
- return GraphreeD.clone(this);
1126
+ return Grafreed.clone(this);
9391127 }
9401128
9411129 Object3D copyExpand()
....@@ -1257,6 +1445,7 @@
12571445 toParent = LA.newMatrix();
12581446 fromParent = LA.newMatrix();
12591447 }
1448
+
12601449 LA.matCopy(other.toParent, toParent);
12611450 LA.matCopy(other.fromParent, fromParent);
12621451
....@@ -1446,7 +1635,16 @@
14461635 // if (other == null)
14471636 // return;
14481637
1449
- System.out.println("Link support this = " + this + "; other = " + other);
1638
+ if (other != null)
1639
+ {
1640
+ BoundaryRep.SEUIL = other.material.cameralight;
1641
+
1642
+ // Set default to 0.1
1643
+ BoundaryRep.SEUIL /= 4; // 2;
1644
+ System.out.println("SEUIL = " + BoundaryRep.SEUIL);
1645
+ }
1646
+
1647
+ System.out.println("Link this = " + this + "; support = " + other);
14501648
14511649 //if (bRep != null)
14521650 // bRep.linkVerticesThis(other.bRep);
....@@ -1701,7 +1899,7 @@
17011899 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17021900 o.bRep = transientrep;
17031901 if (clone)
1704
- o.bRep = (BoundaryRep) GraphreeD.clone(transientrep);
1902
+ o.bRep = (BoundaryRep) Grafreed.clone(transientrep);
17051903 o.CreateMaterial();
17061904 o.SetAttributes(this, -1);
17071905 //parent
....@@ -1714,7 +1912,7 @@
17141912 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17151913 o.bRep = bRep;
17161914 if (clone)
1717
- o.bRep = (BoundaryRep) GraphreeD.clone(bRep);
1915
+ o.bRep = (BoundaryRep) Grafreed.clone(bRep);
17181916 o.CreateMaterial();
17191917 //o.overwriteThis(this, -1);
17201918 o.SetAttributes(this, -1);
....@@ -1756,7 +1954,7 @@
17561954 // {
17571955 // assert(bRep == null);
17581956 // Object3D o = new Object3D("Geometry:" + this.name);
1759
-// o.bRep = (BoundaryRep) GraphreeD.clone(transientrep);
1957
+// o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
17601958 // o.CreateMaterial();
17611959 // parent.addChild(o);
17621960 // }
....@@ -1765,7 +1963,7 @@
17651963 // {
17661964 // assert(transientrep == null);
17671965 // Object3D o = new Object3D("Geometry:" + this.name);
1768
-// o.bRep = (BoundaryRep) GraphreeD.clone(bRep);
1966
+// o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
17691967 // o.CreateMaterial();
17701968 // parent.addChild(o);
17711969 // }
....@@ -1801,12 +1999,15 @@
18011999 if (obj.name == null)
18022000 continue; // can't be a null one
18032001
2002
+ // Try perfect match first.
18042003 if (n.equals(obj.name))
18052004 {
18062005 theobj = obj;
18072006 count++;
18082007 }
18092008 }
2009
+
2010
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18102011
18112012 if (count != 1)
18122013 for (int i=Size(); --i>=0;)
....@@ -1816,8 +2017,9 @@
18162017 if (obj.name == null)
18172018 continue; // can't be a null one
18182019
1819
- //if (n.contains(obj.name)) // dec 2013 name.split(":")[0])) // Poser generates a count
1820
- if (n.startsWith(obj.name))
2020
+ String name = obj.name.split(":")[0]; // Poser generates a count
2021
+ //if (n.startsWith(obj.name))
2022
+ if (n.contains(name))
18212023 {
18222024 theobj = obj;
18232025 count++;
....@@ -2120,15 +2322,8 @@
21202322 if (/*parent != null &&*/ material == null)
21212323 {
21222324 material = new cMaterial(GetMaterial());
2123
- if (projectedVertices == null || projectedVertices.length <= 2)
2124
- {
2125
- projectedVertices = new Object3D.cVector2[3];
2126
- }
2127
- for (int i = 0; i < 3; i++)
2128
- {
2129
- projectedVertices[i] = new cVector2(); // Others
2130
- }
2131
- projectedVertices[0].x = 100; // bump
2325
+
2326
+ InitOthers();
21322327
21332328 if (this instanceof Camera)
21342329 {
....@@ -2272,12 +2467,22 @@
22722467 }
22732468 */
22742469 }
2470
+ else
2471
+ {
2472
+ //((ObjEditor)editWindow).SetupUI2(null);
2473
+ if (objectUI != null)
2474
+ ((ObjEditor)objectUI).pinButton.setSelected(pinned);
2475
+ else
2476
+ //new Exception().printStackTrace();
2477
+ System.err.println("objectUI is null");
2478
+ }
22752479 }
22762480
22772481 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
22782482 {
22792483 if (newWindow)
22802484 {
2485
+ new Exception().printStackTrace();
22812486 System.exit(0);
22822487 if (parent != null)
22832488 {
....@@ -2312,6 +2517,14 @@
23122517 {
23132518 editWindow.refreshContents();
23142519 }
2520
+ else
2521
+ {
2522
+ if (manipWindow != null)
2523
+ {
2524
+ manipWindow.refreshContents();
2525
+ }
2526
+ }
2527
+
23152528 //if (parent != null)
23162529 //parent.refreshEditWindow();
23172530 }
....@@ -2391,7 +2604,8 @@
23912604 private static final int editSelf = 1;
23922605 private static final int editChild = 2;
23932606
2394
- void drawEditHandles(ClickInfo info, int level)
2607
+ void drawEditHandles(//ClickInfo info,
2608
+ int level)
23952609 {
23962610 if (level == 0)
23972611 {
....@@ -2399,7 +2613,8 @@
23992613 return;
24002614
24012615 Object3D selectee;
2402
- for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(info, level + 1))
2616
+ for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(//info,
2617
+ level + 1))
24032618 {
24042619 selectee = (Object3D) e.nextElement();
24052620 }
....@@ -2407,19 +2622,22 @@
24072622 } else
24082623 {
24092624 //super.
2410
- drawEditHandles0(info, level + 1);
2625
+ drawEditHandles0(//info,
2626
+ level + 1);
24112627 }
24122628 }
24132629
2414
- boolean doEditClick(ClickInfo info, int level)
2630
+ boolean doEditClick(//ClickInfo info,
2631
+ int level)
24152632 {
24162633 doSomething = 0;
24172634 if (level == 0)
24182635 {
2419
- return doParentClick(info);
2636
+ return doParentClick(); //info);
24202637 }
24212638 if (//super.
2422
- doEditClick0(info, level))
2639
+ doEditClick0(//info,
2640
+ level))
24232641 {
24242642 doSomething = 1;
24252643 return true;
....@@ -2429,7 +2647,7 @@
24292647 }
24302648 }
24312649
2432
- boolean doParentClick(ClickInfo info)
2650
+ boolean doParentClick() //ClickInfo info)
24332651 {
24342652 if (selection == null)
24352653 {
....@@ -2442,7 +2660,8 @@
24422660 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
24432661 {
24442662 Object3D selectee = (Object3D) e.nextElement();
2445
- if (selectee.doEditClick(info, 1))
2663
+ if (selectee.doEditClick(//info,
2664
+ 1))
24462665 {
24472666 childToDrag = selectee;
24482667 doSomething = 2;
....@@ -2454,13 +2673,15 @@
24542673 return retval;
24552674 }
24562675
2457
- void doEditDrag(ClickInfo info)
2676
+ void doEditDrag(//ClickInfo clickInfo,
2677
+ boolean opposite)
24582678 {
24592679 switch (doSomething)
24602680 {
24612681 case 1: // '\001'
24622682 //super.
2463
- doEditDrag0(info);
2683
+ doEditDrag0(//clickInfo,
2684
+ opposite);
24642685 break;
24652686
24662687 case 2: // '\002'
....@@ -2473,11 +2694,13 @@
24732694 {
24742695 //sel.hitSomething = childToDrag.hitSomething;
24752696 //childToDrag.doEditDrag(info);
2476
- sel.doEditDrag(info);
2697
+ sel.doEditDrag(//clickInfo,
2698
+ opposite);
24772699 } else
24782700 {
24792701 //super.
2480
- doEditDrag0(info);
2702
+ doEditDrag0(//clickInfo,
2703
+ opposite);
24812704 }
24822705 }
24832706 break;
....@@ -2495,6 +2718,9 @@
24952718 {
24962719 deselectAll();
24972720 }
2721
+
2722
+ new Exception().printStackTrace();
2723
+
24982724 ClickInfo newInfo = new ClickInfo();
24992725 newInfo.flags = info.flags;
25002726 newInfo.bounds = info.bounds;
....@@ -2587,6 +2813,18 @@
25872813 void GenNormalsS(boolean crease)
25882814 {
25892815 selection.GenNormals(crease);
2816
+// for (int i=0; i<selection.size(); i++)
2817
+// {
2818
+// Object3D selectee = (Object3D) selection.elementAt(i);
2819
+// selectee.GenNormals(crease);
2820
+// }
2821
+
2822
+ //Touch();
2823
+ }
2824
+
2825
+ void GenNormalsMeshS()
2826
+ {
2827
+ selection.GenNormalsMesh();
25902828 // for (int i=0; i<selection.size(); i++)
25912829 // {
25922830 // Object3D selectee = (Object3D) selection.elementAt(i);
....@@ -2732,6 +2970,42 @@
27322970 blockloop = false;
27332971 }
27342972
2973
+ void GenNormalsMesh()
2974
+ {
2975
+ if (blockloop)
2976
+ return;
2977
+
2978
+ blockloop = true;
2979
+ GenNormalsMesh0();
2980
+ for (int i = 0; i < Children().Size(); i++)
2981
+ {
2982
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2983
+ if (child == null)
2984
+ continue;
2985
+ child.GenNormalsMesh();
2986
+// Children().release(i);
2987
+ }
2988
+ blockloop = false;
2989
+ }
2990
+
2991
+ void GenNormalsMINE()
2992
+ {
2993
+ if (blockloop)
2994
+ return;
2995
+
2996
+ blockloop = true;
2997
+ GenNormalsMINE0();
2998
+ for (int i = 0; i < Children().Size(); i++)
2999
+ {
3000
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
3001
+ if (child == null)
3002
+ continue;
3003
+ child.GenNormalsMINE();
3004
+// Children().release(i);
3005
+ }
3006
+ blockloop = false;
3007
+ }
3008
+
27353009 void ClearColors()
27363010 {
27373011 if (blockloop)
....@@ -2866,7 +3140,8 @@
28663140 {
28673141 if (bRep != null)
28683142 {
2869
- bRep.GenUV();
3143
+ bRep.GenUV(); //1);
3144
+ //bRep.UnfoldUV();
28703145 Touch();
28713146 }
28723147 }
....@@ -2876,6 +3151,24 @@
28763151 if (bRep != null)
28773152 {
28783153 bRep.GenerateNormals(crease);
3154
+ Touch();
3155
+ }
3156
+ }
3157
+
3158
+ void GenNormalsMesh0()
3159
+ {
3160
+ if (bRep != null)
3161
+ {
3162
+ bRep.GenerateNormalsMesh();
3163
+ Touch();
3164
+ }
3165
+ }
3166
+
3167
+ void GenNormalsMINE0()
3168
+ {
3169
+ if (bRep != null)
3170
+ {
3171
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
28793172 Touch();
28803173 }
28813174 }
....@@ -2932,6 +3225,33 @@
29323225 blockloop = false;
29333226 }
29343227
3228
+ void TransformChildren()
3229
+ {
3230
+ if (toParent != null)
3231
+ {
3232
+ for (int i=Size(); --i>=0;)
3233
+ {
3234
+ Object3D v = get(i);
3235
+
3236
+ if (v.toParent == null)
3237
+ {
3238
+ v.toParent = LA.newMatrix();
3239
+ v.fromParent = LA.newMatrix();
3240
+ }
3241
+
3242
+// LA.matConcat(v.toParent, toParent, v.toParent);
3243
+// LA.matConcat(fromParent, v.fromParent, v.fromParent);
3244
+ LA.matConcat(toParent, v.toParent, v.toParent);
3245
+ LA.matConcat(v.fromParent, fromParent, v.fromParent);
3246
+ }
3247
+
3248
+ toParent = null; // LA.matIdentity(toParent);
3249
+ fromParent = null; // LA.matIdentity(fromParent);
3250
+
3251
+ Touch();
3252
+ }
3253
+ }
3254
+
29353255 void TransformGeometry()
29363256 {
29373257 Object3D obj = this;
....@@ -3153,9 +3473,11 @@
31533473
31543474 BoundaryRep sup = bRep.support;
31553475 bRep.support = null;
3156
- BoundaryRep temprep = (BoundaryRep) GraphreeD.clone(bRep);
3476
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
31573477 // bRep.SplitInTwo(onlyone); // thread...
3158
- temprep.SplitInTwo(reduction34, onlyone);
3478
+
3479
+ while(temprep.SplitInTwo(reduction34, onlyone));
3480
+
31593481 bRep = temprep;
31603482 bRep.support = sup;
31613483 Touch();
....@@ -3292,7 +3614,8 @@
32923614 if (blockloop)
32933615 return;
32943616
3295
- if (marked || (bRep != null && material != null)) // borderline...
3617
+ if (//marked || // does not make sense
3618
+ (bRep != null || material != null)) // borderline...
32963619 live = h;
32973620
32983621 for (int i = 0; i < Size(); i++)
....@@ -3313,7 +3636,8 @@
33133636 return;
33143637
33153638 //if (bRep != null)
3316
- if (marked || (bRep != null && material != null)) // borderline...
3639
+ if (//marked || // does not make sense
3640
+ (bRep != null || material != null)) // borderline...
33173641 link2master = h;
33183642
33193643 for (int i = 0; i < Size(); i++)
....@@ -3333,7 +3657,8 @@
33333657 if (blockloop)
33343658 return;
33353659
3336
- if (marked || (bRep != null && material != null)) // borderline...
3660
+ if (//marked || // does not make sense
3661
+ (bRep != null || material != null)) // borderline...
33373662 hide = h;
33383663
33393664 for (int i = 0; i < Size(); i++)
....@@ -3353,7 +3678,7 @@
33533678 if (blockloop)
33543679 return;
33553680
3356
- if (bRep != null && material != null) // borderline...
3681
+ if (bRep != null || material != null) // borderline...
33573682 marked = h;
33583683
33593684 for (int i = 0; i < Size(); i++)
....@@ -3363,6 +3688,46 @@
33633688 continue;
33643689 blockloop = true;
33653690 child.MarkLeaves(h);
3691
+ blockloop = false;
3692
+ // release(i);
3693
+ }
3694
+ }
3695
+
3696
+ void RewindLeaves(boolean h)
3697
+ {
3698
+ if (blockloop)
3699
+ return;
3700
+
3701
+ if (bRep != null || material != null) // borderline...
3702
+ rewind = h;
3703
+
3704
+ for (int i = 0; i < Size(); i++)
3705
+ {
3706
+ Object3D child = (Object3D) get(i); // reserve(i);
3707
+ if (child == null)
3708
+ continue;
3709
+ blockloop = true;
3710
+ child.RewindLeaves(h);
3711
+ blockloop = false;
3712
+ // release(i);
3713
+ }
3714
+ }
3715
+
3716
+ void RandomLeaves(boolean h)
3717
+ {
3718
+ if (blockloop)
3719
+ return;
3720
+
3721
+ if (bRep != null || material != null) // borderline...
3722
+ random = h;
3723
+
3724
+ for (int i = 0; i < Size(); i++)
3725
+ {
3726
+ Object3D child = (Object3D) get(i); // reserve(i);
3727
+ if (child == null)
3728
+ continue;
3729
+ blockloop = true;
3730
+ child.RandomLeaves(h);
33663731 blockloop = false;
33673732 // release(i);
33683733 }
....@@ -3677,7 +4042,7 @@
36774042 if (child == null)
36784043 continue;
36794044
3680
- if (GraphreeD.RENDERME > 0)
4045
+ if (Grafreed.RENDERME > 0)
36814046 {
36824047 if (child instanceof Merge)
36834048 ((Merge)child).renderme();
....@@ -3717,7 +4082,7 @@
37174082
37184083 boolean getCentroid(cVector centroid, boolean xform)
37194084 {
3720
- assert(false);
4085
+// for speaker assert(false);
37214086 if (blockloop)
37224087 return false;
37234088
....@@ -3828,7 +4193,7 @@
38284193 if (child == null)
38294194 continue;
38304195
3831
- if (GraphreeD.RENDERME > 0)
4196
+ if (Grafreed.RENDERME > 0)
38324197 {
38334198 if (child instanceof Merge)
38344199 ((Merge)child).renderme();
....@@ -4023,7 +4388,7 @@
40234388 if (child == null)
40244389 continue;
40254390
4026
- if (GraphreeD.RENDERME > 0)
4391
+ if (Grafreed.RENDERME > 0)
40274392 {
40284393 if (child instanceof Merge)
40294394 ((Merge)child).renderme();
....@@ -4111,7 +4476,7 @@
41114476 if (blockloop)
41124477 return;
41134478
4114
- for (int i=0; i<size(); i++)
4479
+ for (int i=0; i<Size(); i++)
41154480 {
41164481 if (get(i).parent != this)
41174482 {
....@@ -4120,6 +4485,71 @@
41204485 }
41214486 blockloop = true;
41224487 get(i).RepairParent();
4488
+ blockloop = false;
4489
+ }
4490
+ }
4491
+
4492
+ void RepairShadow()
4493
+ {
4494
+ if (blockloop)
4495
+ return;
4496
+
4497
+ if (this.material != null)
4498
+ this.InitOthers();
4499
+
4500
+ for (int i=0; i<Size(); i++)
4501
+ {
4502
+ blockloop = true;
4503
+ get(i).RepairShadow();
4504
+ blockloop = false;
4505
+ }
4506
+ }
4507
+
4508
+ void RepairSOV()
4509
+ {
4510
+ if (blockloop)
4511
+ return;
4512
+
4513
+ String texname = this.GetPigmentTexture();
4514
+
4515
+ if (texname.startsWith("sov"))
4516
+ {
4517
+ String[] s = texname.split("/");
4518
+
4519
+ String[] sname = s[1].split("Color.pn");
4520
+
4521
+ texname = sname[0];
4522
+
4523
+ if (sname.length > 1)
4524
+ {
4525
+ texname += "Color.jpg";
4526
+ }
4527
+
4528
+ this.SetPigmentTexture("sov/" + texname);
4529
+ }
4530
+
4531
+ texname = this.GetBumpTexture();
4532
+
4533
+ if (texname.startsWith("sov"))
4534
+ {
4535
+ String[] s = texname.split("/");
4536
+
4537
+ String[] sname = s[1].split("Bump.pn");
4538
+
4539
+ texname = sname[0];
4540
+
4541
+ if (sname.length > 1)
4542
+ {
4543
+ texname += "Bump.jpg";
4544
+ }
4545
+
4546
+ this.SetBumpTexture("sov/" + texname);
4547
+ }
4548
+
4549
+ for (int i=0; i<Size(); i++)
4550
+ {
4551
+ blockloop = true;
4552
+ get(i).RepairSOV();
41234553 blockloop = false;
41244554 }
41254555 }
....@@ -4515,16 +4945,28 @@
45154945
45164946 Object3D GetFileRoot()
45174947 {
4948
+ if (overflow)
4949
+ return null;
4950
+
4951
+ overflow = true;
4952
+
4953
+ Object3D pfr = null;
4954
+
45184955 if (parent == null && fileparent == null)
4519
- return this;
4956
+ pfr = this;
45204957
45214958 if (parent == null && fileparent != null) // V4.gfd???
4522
- return fileparent;
4959
+ pfr = fileparent;
45234960
4524
- if (parent == null)
4525
- return this;
4961
+ if (pfr == null && parent == null)
4962
+ pfr = this;
45264963
4527
- return parent.GetFileRoot();
4964
+ if (pfr == null)
4965
+ pfr = parent.GetFileRoot();
4966
+
4967
+ overflow = false;
4968
+
4969
+ return pfr;
45284970 }
45294971
45304972 cTreePath GetPath()
....@@ -4602,7 +5044,7 @@
46025044
46035045 cTreePath SelectLeaf(int indexcount, boolean deselect)
46045046 {
4605
- if (hide)
5047
+ if (hide || dontselect)
46065048 return null;
46075049
46085050 if (count <= 0)
....@@ -4626,9 +5068,17 @@
46265068 }
46275069 }
46285070
5071
+ ObjEditor GetWindow()
5072
+ {
5073
+ if (editWindow != null)
5074
+ return editWindow;
5075
+
5076
+ return manipWindow;
5077
+ }
5078
+
46295079 cTreePath Select(int indexcount, boolean deselect)
46305080 {
4631
- if (hide)
5081
+ if (hide || dontselect)
46325082 return null;
46335083
46345084 if (count <= 0)
....@@ -4662,10 +5112,11 @@
46625112 if (leaf != null)
46635113 {
46645114 cTreePath tp = new cTreePath(this, leaf);
4665
- if (editWindow != null)
5115
+ ObjEditor window = GetWindow();
5116
+ if (window != null)
46665117 {
46675118 //System.out.println("editWindow = " + editWindow + " vs " + this);
4668
- editWindow.Select(tp, deselect, true);
5119
+ window.Select(tp, deselect, true);
46695120 }
46705121
46715122 return tp;
....@@ -4682,6 +5133,7 @@
46825133
46835134 if (child == null)
46845135 continue;
5136
+
46855137 if (child.HasTransparency() && child.size() != 0)
46865138 {
46875139 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4691,9 +5143,10 @@
46915143 if (leaf != null)
46925144 {
46935145 cTreePath tp = new cTreePath(this, leaf);
4694
- if (editWindow != null)
5146
+ ObjEditor window = GetWindow();
5147
+ if (window != null)
46955148 {
4696
- editWindow.Select(tp, deselect, true);
5149
+ window.Select(tp, deselect, true);
46975150 }
46985151
46995152 return tp;
....@@ -4778,7 +5231,7 @@
47785231 return globalTransform;
47795232 }
47805233
4781
- void PreprocessOcclusion(CameraPane cp)
5234
+ void PreprocessOcclusion(iCameraPane cp)
47825235 {
47835236 /*
47845237 if (AOdone)
....@@ -4925,7 +5378,8 @@
49255378 } else //
49265379 if (editWindow != null)
49275380 {
4928
- editWindow.cameraView.lighttouched = true;
5381
+ //editWindow.cameraView.lighttouched = true;
5382
+ Globals.lighttouched = true;
49295383 }
49305384 }
49315385
....@@ -5017,6 +5471,51 @@
50175471 blockloop = false;
50185472 }
50195473
5474
+ void ResetSelectable()
5475
+ {
5476
+ if (blockloop)
5477
+ return;
5478
+
5479
+ blockloop = true;
5480
+
5481
+ keepdontselect = dontselect;
5482
+ dontselect = true;
5483
+
5484
+ Object3D child;
5485
+ int nb = Size();
5486
+ for (int i = 0; i < nb; i++)
5487
+ {
5488
+ child = (Object3D) get(i);
5489
+ if (child == null)
5490
+ continue;
5491
+ child.ResetSelectable();
5492
+ }
5493
+
5494
+ blockloop = false;
5495
+ }
5496
+
5497
+ void RestoreSelectable()
5498
+ {
5499
+ if (blockloop)
5500
+ return;
5501
+
5502
+ blockloop = true;
5503
+
5504
+ dontselect = keepdontselect;
5505
+
5506
+ Object3D child;
5507
+ int nb = Size();
5508
+ for (int i = 0; i < nb; i++)
5509
+ {
5510
+ child = (Object3D) get(i);
5511
+ if (child == null)
5512
+ continue;
5513
+ child.RestoreSelectable();
5514
+ }
5515
+
5516
+ blockloop = false;
5517
+ }
5518
+
50205519 boolean IsSelected()
50215520 {
50225521 if (parent == null)
....@@ -5077,12 +5576,41 @@
50775576 if (fullname == null)
50785577 return "";
50795578
5579
+ if (fullname.pigment != null)
5580
+ {
5581
+ return fullname.pigment;
5582
+ }
5583
+
50805584 // System.out.println("Fullname = " + fullname);
50815585
5082
- if (fullname.name.indexOf(":") == -1)
5083
- return fullname.name;
5586
+ // Does not work on Windows due to C:
5587
+// if (fullname.name.indexOf(":") == -1)
5588
+// return fullname.name;
5589
+//
5590
+// return fullname.name.substring(0,fullname.name.indexOf(":"));
50845591
5085
- return fullname.name.substring(0,fullname.name.indexOf(":"));
5592
+ String[] split = fullname.name.split(":");
5593
+
5594
+ if (split.length == 0)
5595
+ {
5596
+ return fullname.pigment = "";
5597
+ }
5598
+
5599
+ if (split.length <= 2)
5600
+ {
5601
+ if (fullname.name.endsWith(":"))
5602
+ {
5603
+ // Windows
5604
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
5605
+ }
5606
+
5607
+ return fullname.pigment = split[0];
5608
+ }
5609
+
5610
+ // Windows
5611
+ assert(split.length == 4);
5612
+
5613
+ return fullname.pigment = split[0] + ":" + split[1];
50865614 }
50875615
50885616 static String GetBump(cTexture fullname)
....@@ -5090,11 +5618,44 @@
50905618 if (fullname == null)
50915619 return "";
50925620
5621
+ if (fullname.bump != null)
5622
+ {
5623
+ return fullname.bump;
5624
+ }
5625
+
50935626 // System.out.println("Fullname = " + fullname);
5094
- if (fullname.name.indexOf(":") == -1)
5095
- return "";
5096
-
5097
- return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5627
+ // Does not work on Windows due to C:
5628
+// if (fullname.name.indexOf(":") == -1)
5629
+// return "";
5630
+//
5631
+// return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5632
+ String[] split = fullname.name.split(":");
5633
+
5634
+ if (split.length == 0)
5635
+ {
5636
+ return fullname.bump = "";
5637
+ }
5638
+
5639
+ if (split.length == 1)
5640
+ {
5641
+ return fullname.bump = "";
5642
+ }
5643
+
5644
+ if (split.length == 2)
5645
+ {
5646
+ if (fullname.name.endsWith(":"))
5647
+ {
5648
+ // Windows
5649
+ return fullname.bump = "";
5650
+ }
5651
+
5652
+ return fullname.bump = split[1];
5653
+ }
5654
+
5655
+ // Windows
5656
+ assert(split.length == 4);
5657
+
5658
+ return fullname.bump = split[2] + ":" + split[3];
50985659 }
50995660
51005661 String GetPigmentTexture()
....@@ -5168,7 +5729,7 @@
51685729 System.out.print("; textures = " + textures);
51695730 System.out.println("; usedtextures = " + usedtextures);
51705731
5171
- if (GetTextures() == null)
5732
+ if (GetTextures() == null) // What is that??
51725733 GetTextures().name = ":";
51735734
51745735 String texname = tex;
....@@ -5177,6 +5738,9 @@
51775738 texname = "";
51785739
51795740 GetTextures().name = texname + ":" + GetBump(GetTextures());
5741
+
5742
+ GetTextures().pigment = null;
5743
+
51805744 Touch();
51815745 }
51825746
....@@ -5201,6 +5765,43 @@
52015765 }
52025766 }
52035767
5768
+ UUID GetUUID()
5769
+ {
5770
+ if (uuid == null)
5771
+ {
5772
+ // Serial
5773
+ uuid = UUID.randomUUID();
5774
+ }
5775
+
5776
+ return uuid;
5777
+ }
5778
+
5779
+ Object3D GetObject(UUID uid)
5780
+ {
5781
+ if (blockloop)
5782
+ return null;
5783
+
5784
+ if (GetUUID().equals(uid))
5785
+ return this;
5786
+
5787
+ int nb = Size();
5788
+ for (int i = 0; i < nb; i++)
5789
+ {
5790
+ Object3D child = (Object3D) get(i);
5791
+
5792
+ if (child == null)
5793
+ continue;
5794
+
5795
+ blockloop = true;
5796
+ Object3D obj = child.GetObject(uid);
5797
+ blockloop = false;
5798
+ if (obj != null)
5799
+ return obj;
5800
+ }
5801
+
5802
+ return null;
5803
+ }
5804
+
52045805 void SetBumpTexture(String tex)
52055806 {
52065807 if (GetTextures() == null)
....@@ -5212,6 +5813,8 @@
52125813 texname = "";
52135814
52145815 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
5816
+
5817
+ GetTextures().bump = null;
52155818
52165819 Touch();
52175820 }
....@@ -5237,25 +5840,65 @@
52375840 }
52385841 }
52395842
5240
- void draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5843
+ void EmbedTextures(boolean embed)
5844
+ {
5845
+ if (blockloop)
5846
+ return;
5847
+
5848
+ //if (GetTextures() != null)
5849
+ if (embed)
5850
+ CameraPane.EmbedTextures(GetTextures());
5851
+ else
5852
+ {
5853
+ GetTextures().pigmentdata = null;
5854
+ GetTextures().bumpdata = null;
5855
+ GetTextures().pw = 0;
5856
+ GetTextures().ph = 0;
5857
+ GetTextures().bw = 0;
5858
+ GetTextures().bh = 0;
5859
+ }
5860
+
5861
+ int nb = Size();
5862
+ for (int i = 0; i < nb; i++)
5863
+ {
5864
+ Object3D child = (Object3D) get(i);
5865
+
5866
+ if (child == null)
5867
+ continue;
5868
+
5869
+ blockloop = true;
5870
+ child.EmbedTextures(embed);
5871
+ blockloop = false;
5872
+ }
5873
+ }
5874
+
5875
+ void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
52415876 {
52425877 Draw(display, root, selected, blocked);
52435878 }
52445879
5245
- static cMaterial[] materialstack = new cMaterial[65536];
5246
- static boolean[] selectedstack = new boolean[65536];
5247
- static int materialdepth = 0;
5248
-
52495880 boolean NeedSupport()
52505881 {
52515882 return
5252
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5883
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
52535884 // PROBLEM with CROWD!!
5254
- && (CameraPane.drawMode == CameraPane.SHADOW || CameraPane.CROWD);
5885
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
52555886 }
52565887
5888
+ static boolean DEBUG_SELECTION = false;
52575889
5258
- void Draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5890
+ boolean IsLive()
5891
+ {
5892
+ if (live)
5893
+ return true;
5894
+
5895
+ if (parent == null)
5896
+ return false;
5897
+
5898
+ return parent.IsLive();
5899
+ }
5900
+
5901
+ void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
52595902 {
52605903 Invariants(); // june 2013
52615904
....@@ -5264,8 +5907,8 @@
52645907 // System.err.println("Draw " + this + " Frame # " + ((Mocap)((Merge)support).object).frame);
52655908 }
52665909
5267
- if (display.drawMode == CameraPane.SELECTION &&
5268
- hide)
5910
+ if (display.DrawMode() == iCameraPane.SELECTION &&
5911
+ (hide || dontselect))
52695912 return;
52705913
52715914 if (name != null && name.contains("sclera"))
....@@ -5280,10 +5923,10 @@
52805923 if (name != null && name.contains("sclera"))
52815924 name = name;
52825925
5283
- if (this instanceof CheckerIG)
5926
+ if (this instanceof Checker)
52845927 return;
52855928
5286
- if (display.drawMode == display.SHADOW && PASSTEST)
5929
+ if (display.DrawMode() == display.SHADOW && PASSTEST)
52875930 return;
52885931
52895932 if (count <= 0)
....@@ -5291,13 +5934,13 @@
52915934 return;
52925935 }
52935936
5294
- if ((//display.drawMode == CameraPane.SHADOW ||
5295
- display.drawMode == CameraPane.SELECTION || CameraPane.DEBUG_SELECTION) && HasTransparency())
5937
+ if ((//display.DrawMode() == CameraPane.SHADOW ||
5938
+ display.DrawMode() == iCameraPane.SELECTION || display.IsDebugSelection()) && HasTransparency())
52965939 {
52975940 return;
52985941 }
52995942
5300
- javax.media.opengl.GL gl = display.GetGL();
5943
+ //javax.media.opengl.GL gl = display.GetGL();
53015944
53025945 /*
53035946 if (touched)
....@@ -5315,8 +5958,10 @@
53155958 if (support != null)
53165959 support = support;
53175960
5318
- //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5319
- boolean usecalllists = false; // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5961
+ boolean usecalllists = !IsLive() && IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5962
+ //boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5963
+
5964
+ //usecalllists &= display.DrawMode() == display.DEFAULT; // Don't compute list in shadow pass.
53205965
53215966 if (!usecalllists && bRep != null && bRep.displaylist > 0)
53225967 {
....@@ -5326,30 +5971,33 @@
53265971 // usecalllists &= !(parent instanceof RandomNode);
53275972 // usecalllists = false;
53285973
5329
- if (GetBRep() != null)
5330
- usecalllists = usecalllists;
5974
+ if (display.DrawMode() == display.SHADOW)
5975
+ //GetBRep() != null)
5976
+ usecalllists = !!usecalllists;
53315977 //System.out.println("draw " + this);
53325978 //new Exception().printStackTrace();
53335979
53345980 boolean compiled = false;
53355981
5336
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
5982
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
53375983
5338
- if (!selectmode && //display.drawMode != display.SELECTION &&
5339
- (touched || (bRep != null && bRep.displaylist <= 0)))
5984
+ if (!selectmode && //display.DrawMode() != display.SELECTION &&
5985
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5986
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
53405987 {
5341
- display.lighttouched = true;
5988
+ Globals.lighttouched = true;
53425989 } // all panes...
5343
- //if (usecalllists && display.drawMode != display.SELECTION && display.drawMode != display.SHADOW &&
5344
- if (bRep != null && usecalllists && !selectmode && // june 2013 display.drawMode != display.SHADOW &&
5990
+
5991
+ //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
5992
+ if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
53455993 (touched || (bRep != null && bRep.displaylist <= 0)))
53465994 {
53475995 if (!(this instanceof Composite))
53485996 touched = false;
53495997 //if (displaylist == -1 && usecalllists)
5350
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
5998
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
53515999 {
5352
- bRep.displaylist = gl.glGenLists(1);
6000
+ bRep.displaylist = display.GenList();
53536001 assert(bRep.displaylist != 0);
53546002 // System.err.println("glGenLists: " + bRep.displaylist + " for " + this);
53556003 //System.out.println("\tgen list " + list);
....@@ -5358,21 +6006,23 @@
53586006
53596007 //System.out.println("\tnew list " + list);
53606008 //gl.glDrawBuffer(gl.GL_NONE);
5361
- if (usecalllists)
6009
+ if (usecalllists && bRep.displaylist > 0)
53626010 {
53636011 // System.err.println("new list " + bRep.displaylist + " for " + this);
5364
- gl.glNewList(bRep.displaylist, gl.GL_COMPILE); //_AND_EXECUTE);
6012
+ display.NewList(bRep.displaylist);
53656013 }
6014
+
53666015 CallList(display, root, selected, blocked);
6016
+
53676017 // compiled = true;
5368
- if (usecalllists)
6018
+ if (usecalllists && bRep.displaylist > 0)
53696019 {
53706020 // System.err.println("end list " + bRep.displaylist + " for " + this);
5371
- gl.glEndList();
6021
+ display.EndList();
53726022 }
53736023 //gl.glDrawBuffer(gl.GL_BACK);
53746024 // XXX touched = false;
5375
- display.lighttouched = true; // all panes...
6025
+ Globals.lighttouched = true; // all panes...
53766026 }
53776027
53786028 touched = GetBRep() == null; // this instanceof Composite || this instanceof FileObject; // false;
....@@ -5411,12 +6061,12 @@
54116061
54126062 // frustum culling
54136063 if (CameraPane.FRUSTUM && !blocked && !IsInfinite() && GetBRep() != null // && GetBRep().VertexCount() != 1260 // default grid
5414
- && display.drawMode != CameraPane.SELECTION)
6064
+ && display.DrawMode() != iCameraPane.SELECTION)
54156065 {
5416
- if (display.drawMode == CameraPane.SHADOW)
6066
+ if (display.DrawMode() == iCameraPane.SHADOW)
54176067 {
54186068 if (!link2master // tricky to cull in shadow mode.
5419
- && GetBRep().FrustumCull(this, gl, display.lightCamera, true))
6069
+ && GetBRep().FrustumCull(this, null, display.LightCamera(), true))
54206070 {
54216071 //System.out.print("CULLED");
54226072 culled = true;
....@@ -5424,7 +6074,7 @@
54246074 }
54256075 else
54266076 //GetBRep().getBounds(v0, v1, this);
5427
- if (GetBRep().FrustumCull(this, gl, display.renderCamera, false))
6077
+ if (GetBRep().FrustumCull(this, null, display.RenderCamera(), false))
54286078 culled = true;
54296079
54306080 // LA.xformPos(v0, display.renderCamera.toScreen, v0);
....@@ -5460,11 +6110,12 @@
54606110
54616111
54626112 if (!culled)
5463
- if (display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION)
6113
+ if (display.DrawMode() == display.SELECTION || display.IsDebugSelection())
54646114 {
54656115 if (GetBRep() != null)
54666116 {
5467
- CameraPane.NextIndex(this, gl);
6117
+ display.NextIndex();
6118
+
54686119 // vertex color conflict : gl.glCallList(list);
54696120 DrawNode(display, root, selected);
54706121 if (this instanceof BezierPatch)
....@@ -5486,53 +6137,7 @@
54866137 color[2] /= 2;
54876138 gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT_AND_DIFFUSE, color, 0);
54886139 */
5489
- if (material != null)
5490
- {
5491
- materialstack[materialdepth] = material;
5492
- selectedstack[materialdepth] = selected;
5493
- cStatic.objectstack[materialdepth++] = this;
5494
- //System.out.println("material " + material);
5495
- //Applet3D.tracein(this, selected);
5496
- display.vector2buffer = projectedVertices;
5497
- if (this instanceof Camera)
5498
- {
5499
- display.options1[0] = material.shift;
5500
- //System.out.println("shift " + material.shift);
5501
- display.options1[1] = material.lightarea;
5502
- display.options1[2] = material.shadowbias;
5503
- display.options1[3] = material.aniso;
5504
- display.options1[4] = material.anisoV;
5505
- display.options2[0] = material.opacity;
5506
- display.options2[1] = material.diffuse;
5507
- display.options2[2] = material.factor;
5508
-
5509
- cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
5510
- display.options3[3] = material.cameralight/0.2f;
5511
-
5512
- // if (display.CURRENTANTIALIAS > 0)
5513
- // display.options3[3] /= 4;
5514
-
5515
- /*
5516
- System.out.println("Focus = " + display.options1[0]);
5517
- System.out.println("Aperture = " + display.options1[1]);
5518
- System.out.println("ShadowBlur = " + display.options1[2]);
5519
- System.out.println("Antialiasing = " + display.options1[3]);
5520
- System.out.println("Fog = " + display.options2[0]);
5521
- System.out.println("Intensity = " + display.options2[1]);
5522
- System.out.println("Elevation = " + display.options2[2]);
5523
- /**/
5524
- } else
5525
- {
5526
- material.Draw(display, selected);
5527
- }
5528
- } else
5529
- {
5530
- if (selected && CameraPane.flash)
5531
- {
5532
- display.modelParams4[1] = 100;
5533
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
5534
- }
5535
- }
6140
+ display.PushMaterial(this, selected);
55366141
55376142 //System.out.println("call list " + list);
55386143 //System.out.println();
....@@ -5551,7 +6156,28 @@
55516156 tex = GetTextures();
55526157 }
55536158
5554
- display.BindTextures(tex, texres);
6159
+ boolean failedPigment = false;
6160
+ boolean failedBump = false;
6161
+
6162
+ try
6163
+ {
6164
+ display.BindPigmentTexture(tex, texres);
6165
+ }
6166
+ catch (Exception e)
6167
+ {
6168
+ System.err.println("FAILED: " + this);
6169
+ failedPigment = true;
6170
+ }
6171
+
6172
+ try
6173
+ {
6174
+ display.BindBumpTexture(tex, texres);
6175
+ }
6176
+ catch (Exception e)
6177
+ {
6178
+ //System.err.println("FAILED: " + this);
6179
+ failedBump = true;
6180
+ }
55556181
55566182 if (!compiled)
55576183 {
....@@ -5567,30 +6193,19 @@
55676193
55686194 // System.err.println("glCallList: " + bRep.displaylist + " for " + this);
55696195 assert(bRep.displaylist != 0);
5570
- gl.glCallList(bRep.displaylist);
6196
+ display.CallList(bRep.displaylist);
55716197 // june 2013 drawSelf(display, root, selected);
55726198 }
55736199 }
55746200 }
55756201
5576
- display.ReleaseTextures(tex);
5577
-
5578
- //if (parent != null && parent.GetMaterial() != null)
5579
- // parent.GetMaterial().Draw(display, parent.IsSelected(this));
5580
- if (material != null)
5581
- {
5582
- materialdepth -= 1;
5583
- if (materialdepth > 0)
5584
- {
5585
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
5586
- materialstack[materialdepth - 1].Draw(display, selectedstack[materialdepth - 1]);
5587
- }
5588
- //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
5589
- } else if (selected && CameraPane.flash && GetMaterial() != null)
5590
- {
5591
- display.modelParams4[1] = GetMaterial().cameralight;
5592
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
5593
- }
6202
+ if (!failedBump)
6203
+ display.ReleaseBumpTexture(tex);
6204
+
6205
+ if (!failedPigment)
6206
+ display.ReleasePigmentTexture(tex);
6207
+
6208
+ display.PopMaterial(this, selected);
55946209 }
55956210
55966211 if (this instanceof Texture || this instanceof TextureNode)
....@@ -5632,7 +6247,7 @@
56326247 // resetMasterNode();
56336248 }
56346249
5635
- void CallList(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
6250
+ void CallList(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
56366251 {
56376252 if (GetBRep() == null)
56386253 {
....@@ -5715,8 +6330,11 @@
57156330 boolean flipV = false; // true;
57166331 int texres = 0; // 0 = low, 1 = normal, 2 = high res texture
57176332
5718
- void drawSelf(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
6333
+ void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57196334 {
6335
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6336
+ return;
6337
+
57206338 if (hide)
57216339 return;
57226340 // shadow optimisation
....@@ -5774,16 +6392,7 @@
57746392 // // ??????????????????????????? Touch();
57756393 // }
57766394
5777
- if (material != null)
5778
- {
5779
- materialstack[materialdepth] = material;
5780
- selectedstack[materialdepth] = selected;
5781
- cStatic.objectstack[materialdepth++] = this;
5782
- //System.out.println("material " + material);
5783
- //Applet3D.tracein("selected ", selected);
5784
- display.vector2buffer = projectedVertices;
5785
- material.Draw(display, selected);
5786
- }
6395
+display.PushMaterial2(this, selected);
57876396
57886397 Object3D child;
57896398 boolean sel;
....@@ -5807,12 +6416,12 @@
58076416 if (!child.HasTransparency())
58086417 {
58096418 sel = root != null && root.selection != null && root.selection.indexOf(child) != -1;
5810
- // GraphreeD.tracein("draw ", child);
6419
+ // GrafreeD.tracein("draw ", child);
58116420 boolean wasblocked = blockdraw;
58126421 blockdraw = true;
58136422 child.draw(display, root, selected || sel, wasblocked || blocked); // || child.IsSelected());
58146423 blockdraw = false;
5815
- // GraphreeD.traceout("draw ", child);
6424
+ // GrafreeD.traceout("draw ", child);
58166425 }
58176426
58186427 release(i);
....@@ -5835,19 +6444,7 @@
58356444 */
58366445 //depth += 1;
58376446
5838
- if (material != null)
5839
- {
5840
- materialdepth -= 1;
5841
- if (materialdepth > 0)
5842
- {
5843
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
5844
- materialstack[materialdepth - 1].Draw(display, selectedstack[materialdepth - 1]);
5845
- }
5846
- //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
5847
- //else
5848
- //material.Draw(display, false);
5849
- }
5850
-
6447
+display.PopMaterial2(this);
58516448 /*
58526449 display.ReleaseTextures(tex);
58536450 */
....@@ -5858,10 +6455,13 @@
58586455
58596456 //static cVector min,max;
58606457
5861
- void DrawNode(CameraPane display, Object3D /*Composite*/ root, boolean selected)
6458
+ void DrawNode(iCameraPane display, Object3D /*Composite*/ root, boolean selected)
58626459 {
5863
- if (display.drawMode == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
6460
+ if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
58646461 return; // no shadow for transparent objects
6462
+
6463
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6464
+ return;
58656465
58666466 if (hide)
58676467 return;
....@@ -5903,11 +6503,12 @@
59036503 return;
59046504 }
59056505
6506
+ //bRep.GenUV(1/material.diffuseness);
59066507 // bRep.lock = true;
59076508
5908
- javax.media.opengl.GL gl = display.GetGL();
6509
+ //javax.media.opengl.GL gl = display.GetGL();
59096510
5910
- if (CameraPane.BOXMODE) // || CameraPane.movingcamera)
6511
+ if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera)
59116512 {
59126513 int fc = bRep.FaceCount();
59136514 int vc = bRep.VertexCount();
....@@ -5922,23 +6523,7 @@
59226523
59236524 bRep.getMinMax(min, max, 100);
59246525
5925
- gl.glBegin(gl.GL_LINES);
5926
-
5927
- gl.glVertex3d(min.x, min.y, min.z);
5928
- gl.glVertex3d(min.x, min.y, max.z);
5929
- gl.glVertex3d(min.x, min.y, min.z);
5930
- gl.glVertex3d(min.x, max.y, min.z);
5931
- gl.glVertex3d(min.x, min.y, min.z);
5932
- gl.glVertex3d(max.x, min.y, min.z);
5933
-
5934
- gl.glVertex3d(max.x, max.y, max.z);
5935
- gl.glVertex3d(min.x, max.y, max.z);
5936
- gl.glVertex3d(max.x, max.y, max.z);
5937
- gl.glVertex3d(max.x, min.y, max.z);
5938
- gl.glVertex3d(max.x, max.y, max.z);
5939
- gl.glVertex3d(max.x, max.y, min.z);
5940
-
5941
- gl.glEnd();
6526
+ display.DrawBox(min, max);
59426527
59436528 return;
59446529 }
....@@ -5982,7 +6567,7 @@
59826567 {
59836568 //throw new Error();
59846569
5985
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
6570
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
59866571
59876572 int[] strips = bRep.getRawIndices();
59886573
....@@ -5992,178 +6577,19 @@
59926577 new Exception().printStackTrace();
59936578 return;
59946579 }
5995
-
5996
- // TRIANGLE STRIP ARRAY
5997
- if (bRep.trimmed)
6580
+
6581
+ if (dontselect)
59986582 {
5999
- float[] v = bRep.getRawVertices();
6000
- float[] n = bRep.getRawNormals();
6001
- float[] c = bRep.getRawColors();
6002
- float[] uv = bRep.getRawUVMap();
6003
-
6004
- int count2 = 0;
6005
- int count3 = 0;
6006
-
6007
- if (n.length > 0)
6008
- {
6009
- for (int i = 0; i < strips.length; i++)
6010
- {
6011
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6012
-
6013
- /*
6014
- boolean locked = false;
6015
- float eps = 0.1f;
6016
- boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
6017
-
6018
- int dot = 0;
6019
-
6020
- if ((dot&1) == 0)
6021
- dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
6022
-
6023
- if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
6024
- gl.glTexCoord2f((float) qv.s, (float) qv.t);
6025
- else
6026
- {
6027
- locked = true;
6028
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6029
- }
6030
- //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6031
- gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
6032
- if (hasnorm)
6033
- {
6034
- //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6035
- gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
6036
- }
6037
-
6038
- if ((dot&4) == 0)
6039
- dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
6040
-
6041
- if (wrap || !locked && (dot&8) != 0)
6042
- gl.glTexCoord2f((float) rv.s, (float) rv.t);
6043
- else
6044
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6045
-
6046
- f.dot = dot;
6047
- */
6048
-
6049
- if (!selectmode)
6050
- {
6051
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6052
- {
6053
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6054
- } else
6055
- {
6056
- gl.glNormal3f(0, 0, 1);
6057
- }
6058
-
6059
- if (c != null)
6060
- //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]);
6061
- {
6062
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6063
- }
6064
- }
6065
- if (flipV)
6066
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6067
- else
6068
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6069
- //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6070
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6071
-
6072
- count2 += 2;
6073
- count3 += 3;
6074
- if (!selectmode)
6075
- {
6076
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6077
- {
6078
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6079
- } else
6080
- {
6081
- gl.glNormal3f(0, 0, 1);
6082
- }
6083
- if (c != null)
6084
- {
6085
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6086
- }
6087
- }
6088
- if (flipV)
6089
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6090
- else
6091
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6092
- //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6093
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6094
-
6095
- count2 += 2;
6096
- count3 += 3;
6097
- for (int j = 0; j < strips[i] - 2; j++)
6098
- {
6099
- //gl.glTexCoord2d(...);
6100
- if (!selectmode)
6101
- {
6102
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6103
- {
6104
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6105
- } else
6106
- {
6107
- gl.glNormal3f(0, 0, 1);
6108
- }
6109
- if (c != null)
6110
- {
6111
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6112
- }
6113
- }
6114
-
6115
- if (flipV)
6116
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6117
- else
6118
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6119
- //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
6120
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6121
- count2 += 2;
6122
- count3 += 3;
6123
- }
6124
-
6125
- gl.glEnd();
6126
- }
6127
- }
6128
-
6129
- assert count3 == v.length;
6583
+ //bRep.GenerateNormalsMINE();
61306584 }
6131
- else // !trimmed
6132
- {
6133
- int count = 0;
6134
- for (int i = 0; i < strips.length; i++)
6135
- {
6136
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6137
-
6138
- Vertex p = bRep.GetVertex(bRep.indices[count++]);
6139
- Vertex q = bRep.GetVertex(bRep.indices[count++]);
6140
-
6141
- drawVertex(gl, p, selectmode);
6142
- drawVertex(gl, q, selectmode);
6143
-
6144
- for (int j = 0; j < strips[i] - 2; j++)
6145
- {
6146
- Vertex r = bRep.GetVertex(bRep.indices[count++]);
6147
-
6148
-// if (j%2 == 0)
6149
-// drawFace(p, q, r, display, null);
6150
-// else
6151
-// drawFace(p, r, q, display, null);
6152
-
6153
-// p = q;
6154
-// q = r;
6155
- drawVertex(gl, r, selectmode);
6156
- }
6157
-
6158
- gl.glEnd();
6159
- }
6160
- }
6585
+
6586
+ display.DrawGeometry(bRep, flipV, selectmode);
61616587 } else // catch (Error e)
61626588 {
61636589 // TRIANGLE ARRAY
61646590 if (IsOpaque()) // Static())
61656591 {
6166
- gl.glBegin(gl.GL_TRIANGLES);
6592
+ display.StartTriangles();
61676593 int facecount = bRep.FaceCount();
61686594 for (int i = 0; i < facecount; i++)
61696595 {
....@@ -6226,9 +6652,9 @@
62266652 // // r.norm.dot(v3) > -0.5)
62276653 // // continue;
62286654
6229
- drawFace(p, q, r, display, face);
6655
+ display.DrawFace(this, p, q, r, face);
62306656 }
6231
- gl.glEnd();
6657
+ display.EndTriangles();
62326658 }
62336659 else
62346660 {
....@@ -6257,8 +6683,8 @@
62576683 //System.out.println("SORT");
62586684
62596685 java.util.Arrays.sort(facescompare);
6260
-
6261
- gl.glBegin(gl.GL_TRIANGLES);
6686
+
6687
+ display.StartTriangles();
62626688 for (int i = 0; i < facecount; i++)
62636689 {
62646690 Face face = bRep.GetFace(facescompare[i].index);
....@@ -6270,13 +6696,14 @@
62706696 Vertex q = bRep.GetVertex(face.q);
62716697 Vertex r = bRep.GetVertex(face.r);
62726698
6273
- drawFace(p, q, r, display, face);
6699
+ display.DrawFace(this, p, q, r, face);
62746700 }
6275
- gl.glEnd();
6701
+ display.EndTriangles();
62766702 }
62776703
62786704 if (false) // live && support != null && support.bRep != null) // debug weights
62796705 {
6706
+ /*
62806707 gl.glDisable(gl.GL_LIGHTING);
62816708 float[] colorV = new float[3];
62826709
....@@ -6355,6 +6782,7 @@
63556782 // gl.glEnd();
63566783 }
63576784 }
6785
+ */
63586786 }
63596787 }
63606788
....@@ -6399,7 +6827,7 @@
63996827 center.add(r);
64006828 center.mul(1.0/3);
64016829
6402
- center.sub(CameraPane.theRenderer.eyeCamera.location);
6830
+ center.sub(Globals.theRenderer.EyeCamera().location);
64036831
64046832 distance = center.dot(center);
64056833 }
....@@ -6410,347 +6838,11 @@
64106838
64116839 transient FaceCompare[] facescompare = null;
64126840
6413
- void SetColor(CameraPane display, Vertex p0)
6414
- {
6415
- if (display.RENDERPROGRAM == 0)
6416
- {
6417
- float r = 0;
6418
- if (bRep != null)
6419
- {
6420
- if (bRep.stripified)
6421
- {
6422
- r = 1;
6423
- }
6424
- }
6425
- float g = 0;
6426
- if (bRep != null)
6427
- {
6428
- if (bRep.trimmed)
6429
- {
6430
- g = 1;
6431
- }
6432
- }
6433
- float b = 0;
6434
- if (support != null && link2master)
6435
- {
6436
- b = 1;
6437
- }
6438
- display.GetGL().glColor3f(r*p0.AO, g*p0.AO, b*p0.AO);
6439
- return;
6440
- }
6441
-
6442
- if (display.drawMode != CameraPane.SHADOW)
6443
- return;
6444
-
6445
- javax.media.opengl.GL gl = display.GetGL();
6446
-// if (true) return;
6447
-// float ao = p.AO;
6448
-//
6449
-// // if (ao == 0 && !bRep.AOdone) // transient problem!
6450
-// // ao = 1;
6451
-//
6452
-// gl.glColor4f(ao, ao, ao, 1);
6453
-
6454
-// CameraPane.selectedpoint.
6455
-// getAverage(cStatic.point1, true);
6456
- if (CameraPane.pointflow == null) // !random) // live)
6457
- {
6458
- return;
6459
- }
6460
-
6461
- cStatic.point1.set(0,0,0);
6462
- LA.xformPos(cStatic.point1, CameraPane.selectedpoint.toParent, cStatic.point1);
6463
-
6464
- cStatic.point1.sub(p0);
6465
-
6466
-
6467
-// if (marked && (p0.vertexlinks == null || support == null || support.bRep == null)) // no position delta?
6468
-// {
6469
-// return;
6470
-// }
6471
-
6472
- //if (true)
6473
- if (cStatic.point1.dot(cStatic.point1) > 0.000001)
6474
- {
6475
- return;
6476
- }
6477
-
6478
- float[] colorV = new float[3];
6479
-
6480
- if (false) // marked)
6481
- {
6482
- // debug rigging weights
6483
- for (int object = 0; object < p0.vertexlinks.length; object++)
6484
- {
6485
- float weight = p0.weights[object] / p0.totalweight;
6486
-
6487
- // if (weight < 0.1)
6488
- // {
6489
- // assert(weight == 0);
6490
- // continue;
6491
- // }
6492
-
6493
- if (p0.vertexlinks[object] == -1)
6494
- continue;
6495
-
6496
- Vertex q = support.bRep.GetVertex(p0.vertexlinks[object]);
6497
-
6498
- int color = //1 << object; //
6499
- //p.vertexlinks.length;
6500
- support.bRep.supports[p0.closestsupport].links[object];
6501
- colorV[2] += (color & 1) * weight;
6502
- colorV[1] += ((color & 2) >> 1) * weight;
6503
- colorV[0] += ((color & 4) >> 2) * weight;
6504
- }
6505
- }
6506
- else
6507
- {
6508
- if (drawingstarted)
6509
- {
6510
- // find next point
6511
- if (bRep.GetVertex(0).faceindices == null)
6512
- {
6513
- bRep.InitFaceIndices();
6514
- }
6515
-
6516
- double ymin = p0.y;
6517
-
6518
- Vertex newp = p0;
6519
-
6520
- for (int fii = 0; fii < p0.faceindices.length; fii++)
6521
- {
6522
- int fi = p0.faceindices[fii];
6523
-
6524
- if (fi == -1)
6525
- break;
6526
-
6527
- Face f = bRep.GetFace(fi);
6528
-
6529
- Vertex p = bRep.GetVertex(f.p);
6530
- Vertex q = bRep.GetVertex(f.q);
6531
- Vertex r = bRep.GetVertex(f.r);
6532
-
6533
- int swap = (int)(Math.random()*3);
6534
-
6535
-// for (int s=swap; --s>=0;)
6536
-// {
6537
-// Vertex t = p;
6538
-// p = q;
6539
-// q = r;
6540
-// r = t;
6541
-// }
6542
- if (ymin > p.y)
6543
- {
6544
- ymin = p.y;
6545
- newp = p;
6546
-// break;
6547
- }
6548
- if (ymin > q.y)
6549
- {
6550
- ymin = q.y;
6551
- newp = q;
6552
-// break;
6553
- }
6554
- if (ymin > r.y)
6555
- {
6556
- ymin = r.y;
6557
- newp = r;
6558
-// break;
6559
- }
6560
- }
6561
-
6562
- CameraPane.selectedpoint.toParent[3][0] = newp.x;
6563
- CameraPane.selectedpoint.toParent[3][1] = newp.y;
6564
- CameraPane.selectedpoint.toParent[3][2] = newp.z;
6565
-
6566
- drawingstarted = false;
6567
-
6568
- // return;
6569
- }
6570
-
6571
- if (false) // CameraPane.DRAW
6572
- {
6573
- p0.AO = colorV[0] = 2;
6574
- colorV[1] = 2;
6575
- colorV[2] = 2;
6576
- }
6577
-
6578
- CameraPane.pointflow.add(p0);
6579
- CameraPane.pointflow.Touch();
6580
- }
6581
-
6582
-// gl.glColor3f(colorV[0], colorV[1], colorV[2]);
6583
-// gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0);
6584
-// gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
6585
- }
6586
-
65876841 void Print(Vertex v)
65886842 {
65896843 //System.err.println("(" + v.x + ", " + v.y + ", " + v.z + ")");
65906844 }
65916845
6592
- void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean selectmode)
6593
- {
6594
- if (!selectmode)
6595
- {
6596
- gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
6597
- gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
6598
-
6599
- if (flipV)
6600
- gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
6601
- else
6602
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6603
- }
6604
-
6605
- gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
6606
- }
6607
-
6608
- void drawFace(Vertex pv, Vertex qv, Vertex rv,
6609
- CameraPane display, Face face)
6610
- {
6611
- if (pv.y == -10000 ||
6612
- qv.y == -10000 ||
6613
- rv.y == -10000)
6614
- return;
6615
-
6616
-// float b = f.nbiterations & 1;
6617
-// float g = (f.nbiterations>>1) & 1;
6618
-// float r = (f.nbiterations>>2) & 1;
6619
-//
6620
-// //if (f.weight == 10000)
6621
-// //{
6622
-// // r = 1; g = b = 0;
6623
-// //}
6624
-// //else
6625
-// //{
6626
-// // assert(f.weight < 10000);
6627
-// r = g = b = (float)bRep.FaceWeight(f)*100;
6628
-// if (r<0)
6629
-// assert(r>=0);
6630
-// //}
6631
-
6632
- javax.media.opengl.GL gl = display.GetGL();
6633
-
6634
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
6635
-
6636
- //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv);
6637
- if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
6638
- {
6639
- //gl.glBegin(gl.GL_TRIANGLES);
6640
- boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
6641
- if (!hasnorm)
6642
- {
6643
- // System.out.println("FUCK!!");
6644
- LA.vecSub(pv/*.pos*/, qv/*.pos*/, v0);
6645
- LA.vecSub(pv/*.pos*/, rv/*.pos*/, v1);
6646
- LA.vecCross(v0, v1, v2);
6647
- LA.vecNormalize(v2);
6648
- gl.glNormal3f((float) v2.x, (float) v2.y, (float) v2.z);
6649
- }
6650
-
6651
- if (hasnorm)
6652
- {
6653
-// if (!pv.norm.normalized())
6654
-// assert(pv.norm.normalized());
6655
-
6656
- //System.out.println("normalp = " + pv.norm.x + ", " + pv.norm.y + ", " + pv.norm.z);
6657
- gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
6658
- }
6659
- gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
6660
- SetColor(display, pv);
6661
- //gl.glColor4f(r, g, b, 1);
6662
- //gl.glColor4f(pv.boundary, pv.boundary, pv.boundary, 1);
6663
- if (flipV)
6664
- gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
6665
- else
6666
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6667
- //System.out.println("vertexp = " + pv.x + ", " + pv.y + ", " + pv.z);
6668
- gl.glVertex3f((float) pv./*pos.*/x, (float) pv./*pos.*/y, (float) pv./*pos.*/z);
6669
-// Print(pv);
6670
- if (hasnorm)
6671
- {
6672
-// assert(qv.norm.normalized());
6673
- //System.out.println("normalq = " + qv.norm.x + ", " + qv.norm.y + ", " + qv.norm.z);
6674
- gl.glNormal3f((float) qv.norm.x, (float) qv.norm.y, (float) qv.norm.z);
6675
- }
6676
- //System.out.println("vertexq = " + qv.s + ", " + qv.t);
6677
- // boolean locked = false;
6678
- // float eps = 0.1f;
6679
- // boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
6680
-
6681
- // int dot = 0; //*/ (int)f.dot;
6682
-
6683
- // if ((dot&1) == 0)
6684
- // dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
6685
-
6686
- // if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
6687
- if (flipV)
6688
- gl.glTexCoord2f((float) qv.s, 1-(float) qv.t);
6689
- else
6690
- gl.glTexCoord2f((float) qv.s, (float) qv.t);
6691
- // else
6692
- // {
6693
- // locked = true;
6694
- // gl.glTexCoord2f((float) pv.s, (float) pv.t);
6695
- // }
6696
- gl.glColor4f(qv.AO, qv.AO, qv.AO, 1);
6697
- SetColor(display, qv);
6698
- //gl.glColor4f(r, g, b, 1);
6699
- //gl.glColor4f(qv.boundary, qv.boundary, qv.boundary, 1);
6700
- //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6701
- gl.glVertex3f((float) qv./*pos.*/x, (float) qv./*pos.*/y, (float) qv./*pos.*/z);
6702
-// Print(qv);
6703
- if (hasnorm)
6704
- {
6705
-// assert(rv.norm.normalized());
6706
- //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6707
- gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
6708
- }
6709
-
6710
- // if ((dot&4) == 0)
6711
- // dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
6712
-
6713
- // if (wrap || !locked && (dot&8) != 0)
6714
- if (flipV)
6715
- gl.glTexCoord2f((float) rv.s, 1-(float) rv.t);
6716
- else
6717
- gl.glTexCoord2f((float) rv.s, (float) rv.t);
6718
- // else
6719
- // gl.glTexCoord2f((float) pv.s, (float) pv.t);
6720
-
6721
- // f.dot = dot;
6722
-
6723
- gl.glColor4f(rv.AO, rv.AO, rv.AO, 1);
6724
- SetColor(display, rv);
6725
- //gl.glColor4f(r, g, b, 1);
6726
- //gl.glColor4f(rv.boundary, rv.boundary, rv.boundary, 1);
6727
- //System.out.println("vertexr = " + rv.x + ", " + rv.y + ", " + rv.z);
6728
- gl.glVertex3f((float) rv./*pos.*/x, (float) rv./*pos.*/y, (float) rv./*pos.*/z);
6729
-// Print(rv);
6730
- //gl.glEnd();
6731
- }
6732
- else
6733
- {
6734
- gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
6735
- gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
6736
- gl.glVertex3f((float) rv.x, (float) rv.y, (float) rv.z);
6737
-
6738
- }
6739
-
6740
- if (false) // (attributes & WIREFRAME) != 0)
6741
- {
6742
- gl.glDisable(gl.GL_LIGHTING);
6743
-
6744
- gl.glBegin(gl.GL_LINE_LOOP);
6745
- gl.glVertex3d(pv./*pos.*/x, pv./*pos.*/y, pv./*pos.*/z);
6746
- gl.glVertex3d(qv./*pos.*/x, qv./*pos.*/y, qv./*pos.*/z);
6747
- gl.glVertex3d(rv./*pos.*/x, rv./*pos.*/y, rv./*pos.*/z);
6748
- gl.glEnd();
6749
-
6750
- gl.glEnable(gl.GL_LIGHTING);
6751
- }
6752
- }
6753
-
67546846 void drawSelf(ClickInfo info, int level, boolean select)
67556847 {
67566848 if (bRep == null)
....@@ -7274,20 +7366,23 @@
72747366 }
72757367 }
72767368
7277
- protected void calcHotSpot(cVector in, ClickInfo info, Point outPt, Rectangle outRec)
7369
+ static ClickInfo clickInfo = new ClickInfo();
7370
+
7371
+ protected void calcHotSpot(cVector in, //ClickInfo clickInfo,
7372
+ Point outPt, Rectangle outRec)
72787373 {
7279
- int hc = info.bounds.x + info.bounds.width / 2;
7280
- int vc = info.bounds.y + info.bounds.height / 2;
7281
- double[][] toscreen = info.toScreen;
7374
+ int hc = clickInfo.bounds.x + clickInfo.bounds.width / 2;
7375
+ int vc = clickInfo.bounds.y + clickInfo.bounds.height / 2;
7376
+ double[][] toscreen = clickInfo.toScreen;
72827377 if (toscreen == null)
72837378 {
7284
- toscreen = new Camera(info.camera.viewCode).toScreen;
7379
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
72857380 }
72867381 cVector vec = in;
72877382 LA.xformPos(in, toscreen, in);
72887383 //System.out.println("Distance = " + info.camera.Distance());
7289
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
7290
- vec.y *= 100 * info.camera.SCALE / info.camera.Distance();
7384
+ vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
7385
+ vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
72917386 outPt.x = hc + (int) vec.x;
72927387 outPt.y = vc - (int) vec.y;
72937388 outRec.x = outPt.x - 3;
....@@ -7295,15 +7390,18 @@
72957390 outRec.width = outRec.height = 6;
72967391 }
72977392
7298
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7393
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7394
+ )
72997395 {
73007396 Point pt = new Point(0, 0);
73017397 Rectangle rec = new Rectangle();
7302
- calcHotSpot(in, info, pt, rec);
7398
+ calcHotSpot(in, //clickInfo,
7399
+ pt, rec);
73037400 return rec;
73047401 }
73057402
7306
- void drawEditHandles0(ClickInfo info, int level)
7403
+ void drawEditHandles0(//ClickInfo clickInfo,
7404
+ int level)
73077405 {
73087406 if (level == 0)
73097407 {
....@@ -7312,98 +7410,104 @@
73127410 {
73137411 cVector origin = new cVector();
73147412 //LA.xformPos(origin, toParent, origin);
7315
- Rectangle spot = calcHotSpot(origin, info);
7413
+ if (this.clickInfo == null)
7414
+ this.clickInfo = new ClickInfo();
7415
+
7416
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
73167417 Rectangle boundary = new Rectangle();
73177418 boundary.x = spot.x - 30;
73187419 boundary.y = spot.y - 30;
73197420 boundary.width = spot.width + 60;
73207421 boundary.height = spot.height + 60;
7321
- info.g.setColor(Color.red);
7422
+ clickInfo.g.setColor(Color.white);
73227423 int spotw = spot.x + spot.width;
73237424 int spoth = spot.y + spot.height;
7324
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7325
- if (CameraPane.Xmin > spot.x)
7326
- {
7327
- CameraPane.Xmin = spot.x;
7328
- }
7329
- if (CameraPane.Xmax < spotw)
7330
- {
7331
- CameraPane.Xmax = spotw;
7332
- }
7333
- if (CameraPane.Ymin > spot.y)
7334
- {
7335
- CameraPane.Ymin = spot.y;
7336
- }
7337
- if (CameraPane.Ymax < spoth)
7338
- {
7339
- CameraPane.Ymax = spoth;
7340
- }
7341
- spot.translate(32, 32);
7425
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7426
+// if (CameraPane.Xmin > spot.x)
7427
+// {
7428
+// CameraPane.Xmin = spot.x;
7429
+// }
7430
+// if (CameraPane.Xmax < spotw)
7431
+// {
7432
+// CameraPane.Xmax = spotw;
7433
+// }
7434
+// if (CameraPane.Ymin > spot.y)
7435
+// {
7436
+// CameraPane.Ymin = spot.y;
7437
+// }
7438
+// if (CameraPane.Ymax < spoth)
7439
+// {
7440
+// CameraPane.Ymax = spoth;
7441
+// }
7442
+// if (CameraPane.Xmin > spot.x)
7443
+// {
7444
+// CameraPane.Xmin = spot.x;
7445
+// }
7446
+// if (CameraPane.Xmax < spotw)
7447
+// {
7448
+// CameraPane.Xmax = spotw;
7449
+// }
7450
+// if (CameraPane.Ymin > spot.y)
7451
+// {
7452
+// CameraPane.Ymin = spot.y;
7453
+// }
7454
+// if (CameraPane.Ymax < spoth)
7455
+// {
7456
+// CameraPane.Ymax = spoth;
7457
+// }
7458
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7459
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
7460
+ spot.translate(32, 0);
7461
+ clickInfo.g.setColor(Color.yellow);
7462
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7463
+
7464
+ spot.translate(32, 64);
73427465 spotw = spot.x + spot.width;
73437466 spoth = spot.y + spot.height;
7344
- info.g.setColor(Color.blue);
7345
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7346
- if (CameraPane.Xmin > spot.x)
7347
- {
7348
- CameraPane.Xmin = spot.x;
7349
- }
7350
- if (CameraPane.Xmax < spotw)
7351
- {
7352
- CameraPane.Xmax = spotw;
7353
- }
7354
- if (CameraPane.Ymin > spot.y)
7355
- {
7356
- CameraPane.Ymin = spot.y;
7357
- }
7358
- if (CameraPane.Ymax < spoth)
7359
- {
7360
- CameraPane.Ymax = spoth;
7361
- }
7362
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7363
- info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7364
- spot.translate(0, -32);
7365
- info.g.setColor(Color.green);
7366
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7367
- if (CameraPane.Xmin > spot.x)
7368
- {
7369
- CameraPane.Xmin = spot.x;
7370
- }
7371
- if (CameraPane.Xmax < spotw)
7372
- {
7373
- CameraPane.Xmax = spotw;
7374
- }
7375
- if (CameraPane.Ymin > spot.y)
7376
- {
7377
- CameraPane.Ymin = spot.y;
7378
- }
7379
- if (CameraPane.Ymax < spoth)
7380
- {
7381
- CameraPane.Ymax = spoth;
7382
- }
7383
- info.g.drawArc(boundary.x, boundary.y,
7384
- boundary.width, boundary.height, 0, 360);
7467
+ clickInfo.g.setColor(Color.cyan);
7468
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7469
+// if (CameraPane.Xmin > spot.x)
7470
+// {
7471
+// CameraPane.Xmin = spot.x;
7472
+// }
7473
+// if (CameraPane.Xmax < spotw)
7474
+// {
7475
+// CameraPane.Xmax = spotw;
7476
+// }
7477
+// if (CameraPane.Ymin > spot.y)
7478
+// {
7479
+// CameraPane.Ymin = spot.y;
7480
+// }
7481
+// if (CameraPane.Ymax < spoth)
7482
+// {
7483
+// CameraPane.Ymax = spoth;
7484
+// }
7485
+ clickInfo.g.setColor(Color.green);
7486
+ clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
7487
+ (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
73857488 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
7386
- if (CameraPane.Xmin > boundary.x)
7387
- {
7388
- CameraPane.Xmin = boundary.x;
7389
- }
7390
- if (CameraPane.Xmax < boundary.x + boundary.width)
7391
- {
7392
- CameraPane.Xmax = boundary.x + boundary.width;
7393
- }
7394
- if (CameraPane.Ymin > boundary.y)
7395
- {
7396
- CameraPane.Ymin = boundary.y;
7397
- }
7398
- if (CameraPane.Ymax < boundary.y + boundary.height)
7399
- {
7400
- CameraPane.Ymax = boundary.y + boundary.height;
7401
- }
7489
+// if (CameraPane.Xmin > boundary.x)
7490
+// {
7491
+// CameraPane.Xmin = boundary.x;
7492
+// }
7493
+// if (CameraPane.Xmax < boundary.x + boundary.width)
7494
+// {
7495
+// CameraPane.Xmax = boundary.x + boundary.width;
7496
+// }
7497
+// if (CameraPane.Ymin > boundary.y)
7498
+// {
7499
+// CameraPane.Ymin = boundary.y;
7500
+// }
7501
+// if (CameraPane.Ymax < boundary.y + boundary.height)
7502
+// {
7503
+// CameraPane.Ymax = boundary.y + boundary.height;
7504
+// }
74027505 return;
74037506 }
74047507 }
74057508
7406
- boolean doEditClick0(ClickInfo info, int level)
7509
+ boolean doEditClick0(//ClickInfo clickInfo,
7510
+ int level)
74077511 {
74087512 if (level == 0)
74097513 {
....@@ -7412,10 +7516,10 @@
74127516
74137517 boolean retval = false;
74147518
7415
- startX = info.x;
7416
- startY = info.y;
7519
+ startX = clickInfo.x;
7520
+ startY = clickInfo.y;
74177521
7418
- hitSomething = 0;
7522
+ hitSomething = -1;
74197523 cVector origin = new cVector();
74207524 //LA.xformPos(origin, toParent, origin);
74217525 Rectangle spot = new Rectangle();
....@@ -7423,22 +7527,53 @@
74237527 {
74247528 centerPt = new Point(0, 0);
74257529 }
7426
- calcHotSpot(origin, info, centerPt, spot);
7427
- if (spot.contains(info.x, info.y))
7530
+ calcHotSpot(origin, //info,
7531
+ centerPt, spot);
7532
+ if (spot.contains(clickInfo.x, clickInfo.y))
74287533 {
74297534 hitSomething = hitCenter;
74307535 retval = true;
74317536 }
74327537 spot.translate(32, 0);
7433
- if (spot.contains(info.x, info.y))
7538
+ if (spot.contains(clickInfo.x, clickInfo.y))
74347539 {
74357540 hitSomething = hitRotate;
74367541 retval = true;
74377542 }
74387543 spot.translate(0, 32);
7439
- if (spot.contains(info.x, info.y))
7544
+ spot.translate(32, 0);
7545
+ spot.translate(0, 32);
7546
+ if (spot.contains(clickInfo.x, clickInfo.y))
74407547 {
74417548 hitSomething = hitScale;
7549
+
7550
+ double scale = 0.005f * clickInfo.camera.Distance();
7551
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
7552
+ double sign = 1;
7553
+ if (hScale < 0)
7554
+ {
7555
+ sign = -1;
7556
+ }
7557
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
7558
+ if (hScale < 0.01)
7559
+ {
7560
+ //hScale = 0.01;
7561
+ }
7562
+
7563
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
7564
+ sign = 1;
7565
+ if (vScale < 0)
7566
+ {
7567
+ sign = -1;
7568
+ }
7569
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
7570
+ if (vScale < 0.01)
7571
+ {
7572
+ //vScale = 0.01;
7573
+ }
7574
+
7575
+ clickInfo.scale = Math.sqrt(hScale*hScale + vScale*vScale);
7576
+
74427577 retval = true;
74437578 }
74447579
....@@ -7448,7 +7583,7 @@
74487583 }
74497584
74507585 //System.out.println("info.modifiers = " + info.modifiers);
7451
- modified = (info.modifiers & CameraPane.META) != 0;
7586
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
74527587 //System.out.println("modified = " + modified);
74537588 //new Exception().printStackTrace();
74547589 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7476,7 +7611,8 @@
74767611 return true;
74777612 }
74787613
7479
- void doEditDrag0(ClickInfo info)
7614
+ void doEditDrag0(//ClickInfo info,
7615
+ boolean opposite)
74807616 {
74817617 if (hitSomething == 0)
74827618 {
....@@ -7490,7 +7626,8 @@
74907626
74917627 //System.out.println("hitSomething = " + hitSomething);
74927628
7493
- double scale = 0.005f * info.camera.Distance();
7629
+ double scale = 0.005f * clickInfo.camera.Distance();
7630
+
74947631 cVector xlate = new cVector();
74957632 //cVector xlate2 = new cVector();
74967633 switch (hitSomething)
....@@ -7501,9 +7638,9 @@
75017638
75027639 case hitCenter: // Translate
75037640
7504
- scale *= 0.05f * info.pane.theRenderer.renderCamera.Distance();
7641
+ scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
75057642
7506
- if (modified)
7643
+ if (modified || opposite)
75077644 {
75087645 //assert(false);
75097646 /*
....@@ -7523,8 +7660,8 @@
75237660 toParent[3][i] = xlate.get(i);
75247661 LA.matInvert(toParent, fromParent);
75257662 */
7526
- cVector delta = LA.newVector(0, 0, startY - info.y);
7527
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7663
+ cVector delta = LA.newVector(0, 0, startY - clickInfo.y);
7664
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
75287665
75297666 LA.matCopy(startMat, toParent);
75307667 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7533,7 +7670,7 @@
75337670 } else
75347671 {
75357672 //LA.xformDir(delta, info.camera.fromScreen, delta);
7536
- cVector up = new cVector(info.camera.up);
7673
+ cVector up = new cVector(clickInfo.camera.up);
75377674 cVector away = new cVector();
75387675 //cVector right2 = new cVector();
75397676 //LA.vecCross(up, cVector.Z, right);
....@@ -7549,20 +7686,20 @@
75497686 }
75507687 LA.xformDir(up, ClickInfo.matbuffer, up);
75517688 // if (!CameraPane.LOCALTRANSFORM)
7552
- LA.xformDir(up, info.pane.theRenderer.renderCamera.toScreen, up);
7553
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7689
+ LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7690
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
75547691 // if (!CameraPane.LOCALTRANSFORM)
7555
- LA.xformDir(away, info.pane.theRenderer.renderCamera.toScreen, away);
7692
+ LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
75567693 //LA.vecCross(up, cVector.Z, right2);
75577694
7558
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7695
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
75597696
75607697 //System.out.println("DELTA0 = " + delta);
75617698 //System.out.println("AWAY = " + info.camera.away);
75627699 //System.out.println("UP = " + info.camera.up);
75637700 if (away.z > 0)
75647701 {
7565
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7702
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
75667703 {
75677704 delta.x = -delta.x;
75687705 } else
....@@ -7577,7 +7714,7 @@
75777714 //System.out.println("DELTA1 = " + delta);
75787715 LA.xformDir(delta, ClickInfo.matbuffer, delta);
75797716 //System.out.println("DELTA2 = " + delta);
7580
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7717
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
75817718 LA.matCopy(startMat, toParent);
75827719 //System.out.println("DELTA3 = " + delta);
75837720 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7587,8 +7724,8 @@
75877724 break;
75887725
75897726 case hitRotate: // rotate
7590
- int dx = info.x - centerPt.x;
7591
- int dy = -(info.y - centerPt.y);
7727
+ int dx = clickInfo.x - centerPt.x;
7728
+ int dy = -(clickInfo.y - centerPt.y);
75927729 double angle = (double) Math.atan2(dx, dy);
75937730 angle = -(1.570796 - angle);
75947731
....@@ -7597,6 +7734,7 @@
75977734
75987735 if (modified)
75997736 {
7737
+ // Rotate 90 degrees
76007738 angle /= (Math.PI / 4);
76017739 angle = Math.floor(angle + 0.5);
76027740 angle *= (Math.PI / 4);
....@@ -7610,7 +7748,7 @@
76107748 }
76117749 /**/
76127750
7613
- switch (info.pane.renderCamera.viewCode)
7751
+ switch (clickInfo.pane.RenderCamera().viewCode)
76147752 {
76157753 case 1: // '\001'
76167754 LA.matZRotate(toParent, angle);
....@@ -7637,26 +7775,30 @@
76377775 break;
76387776
76397777 case hitScale: // scale
7640
- double hScale = (double) (info.x - centerPt.x) / 32;
7778
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
7779
+ double sign = 1;
7780
+ if (hScale < 0)
7781
+ {
7782
+ sign = -1;
7783
+ }
7784
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
76417785 if (hScale < 0.01)
76427786 {
7643
- hScale = 0.01;
7787
+ //hScale = 0.01;
76447788 }
7645
- hScale = Math.pow(hScale, scale * 50);
7646
- if (hScale < 0.01)
7789
+
7790
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
7791
+ sign = 1;
7792
+ if (vScale < 0)
76477793 {
7648
- hScale = 0.01;
7794
+ sign = -1;
76497795 }
7650
- double vScale = (double) (info.y - centerPt.y) / 32;
7796
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
76517797 if (vScale < 0.01)
76527798 {
7653
- vScale = 0.01;
7799
+ //vScale = 0.01;
76547800 }
7655
- vScale = Math.pow(vScale, scale * 50);
7656
- if (vScale < 0.01)
7657
- {
7658
- vScale = 0.01;
7659
- }
7801
+
76607802 LA.matCopy(startMat, toParent);
76617803 /**/
76627804 for (int i = 0; i < 3; i++)
....@@ -7666,39 +7808,56 @@
76667808 }
76677809 /**/
76687810
7669
- switch (info.pane.renderCamera.viewCode)
7811
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
7812
+
7813
+ if (totalScale < 0.01)
7814
+ {
7815
+ totalScale = 0.01;
7816
+ }
7817
+
7818
+ switch (clickInfo.pane.RenderCamera().viewCode)
76707819 {
76717820 case 3: // '\001'
7672
- if (modified)
7821
+ if (modified || opposite)
76737822 {
7823
+ if (modified && opposite)
7824
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7825
+ else
76747826 //LA.matScale(toParent, 1, hScale, vScale);
7675
- LA.matScale(toParent, vScale, 1, 1);
7827
+ LA.matScale(toParent, totalScale, 1, 1);
76767828 } // vScale, 1);
76777829 else
76787830 {
7679
- LA.matScale(toParent, vScale, vScale, vScale);
7831
+ // EXCEPTION!
7832
+ LA.matScale(toParent, 1, totalScale, totalScale);
76807833 } // vScale, 1);
76817834 break;
76827835
76837836 case 2: // '\002'
7684
- if (modified)
7837
+ if (modified || opposite)
76857838 {
7686
- //LA.matScale(toParent, hScale, 1, vScale);
7687
- LA.matScale(toParent, 1, vScale, 1);
7839
+ if (modified && opposite)
7840
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7841
+ else
7842
+ //LA.matScale(toParent, hScale, 1, vScale);
7843
+ LA.matScale(toParent, 1, totalScale, 1);
76887844 } else
76897845 {
7690
- LA.matScale(toParent, vScale, 1, vScale);
7846
+ LA.matScale(toParent, totalScale, 1, totalScale);
76917847 }
76927848 break;
76937849
76947850 case 1: // '\003'
7695
- if (modified)
7851
+ if (modified || opposite)
76967852 {
7697
- //LA.matScale(toParent, hScale, vScale, 1);
7698
- LA.matScale(toParent, 1, 1, vScale);
7853
+ if (modified && opposite)
7854
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7855
+ else
7856
+ //LA.matScale(toParent, hScale, vScale, 1);
7857
+ LA.matScale(toParent, 1, 1, totalScale);
76997858 } else
77007859 {
7701
- LA.matScale(toParent, vScale, vScale, 1);
7860
+ LA.matScale(toParent, totalScale, totalScale, 1);
77027861 }
77037862 break;
77047863 }
....@@ -7719,7 +7878,7 @@
77197878 if (parent == null)
77207879 {
77217880 System.out.println("NULL PARENT");
7722
- new Exception().printStackTrace();
7881
+ //new Exception().printStackTrace();
77237882 } else
77247883 {
77257884 if (parent instanceof BezierPatch)
....@@ -7732,11 +7891,18 @@
77327891 } // NEW ...
77337892
77347893
7735
- info.pane.repaint();
7894
+ clickInfo.pane.repaint();
77367895 }
77377896
7897
+ boolean overflow = false;
7898
+
77387899 void TransformToWorld(cVector out) // , cVector out)
77397900 {
7901
+ if (overflow)
7902
+ return;
7903
+
7904
+ overflow = true;
7905
+
77407906 // june 2013 ??? assert (in == out);
77417907 cVector in = out;
77427908 if (toParent != null && !(this instanceof Texture || this instanceof TextureNode))
....@@ -7753,6 +7919,8 @@
77537919 {
77547920 (parent!=null?parent:fileparent).TransformToWorld(out); //, out);
77557921 }
7922
+
7923
+ overflow = false;
77567924 }
77577925
77587926 void TransformToLocal(cVector out) //, cVector out)
....@@ -7822,14 +7990,22 @@
78227990 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
78237991 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
78247992 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7993
+
7994
+ String objname;
7995
+
78257996 if (false) //parent != null)
78267997 {
7827
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7998
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
78287999 } else
78298000 {
7830
- return GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ") ")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ +System.identityHashCode(this);
8001
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
78318002 } // + super.toString();
78328003 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
8004
+
8005
+ if (!Globals.ADVANCED)
8006
+ return objname;
8007
+
8008
+ return objname + " " + System.identityHashCode(this);
78338009 }
78348010
78358011 public int hashCode()
....@@ -7885,6 +8061,7 @@
78858061 objectUI.closeUI();
78868062 if (editWindow != null)
78878063 {
8064
+ editWindow.ctrlPanel.FlushUI();
78888065 editWindow.refreshContents();
78898066 } // ? new
78908067 objectUI = null;
....@@ -7893,6 +8070,10 @@
78938070 {
78948071 editWindow = null;
78958072 } // ?
8073
+ }
8074
+ else
8075
+ {
8076
+ //editWindow.closeUI();
78968077 }
78978078 }
78988079
....@@ -7905,7 +8086,7 @@
79058086 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
79068087
79078088 Object3D /*Composite*/ parent;
7908
- Object3D /*Composite*/ fileparent;
8089
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
79098090
79108091 double[][] toParent; // dynamic matrix
79118092 double[][] fromParent;
....@@ -7995,19 +8176,22 @@
79958176 max = new cVector();
79968177 }
79978178
7998
- Object3D sourcenode = GetFileRoot();
7999
-
8000
- if (!sourcenode.name.contains("rclab"))
8179
+ if (false) // Can crawl!!
80018180 {
8002
- getBounds(min, max, true);
8181
+ Object3D sourcenode = GetFileRoot();
80038182
8004
- if (min.y != Double.POSITIVE_INFINITY && min.y > 2)
8183
+ if (sourcenode != null && !sourcenode.name.contains("rclab"))
80058184 {
8006
-// sourcenode.getBounds(min, max, true);
8007
- sourcenode.getBounds(v0, v1, true);
8008
-// sourcenode.toParent = sourcenode.toParent;
8009
-// get(0).toParent = get(0).toParent;
8010
-// sourcenode.GlobalTransform();
8185
+ getBounds(min, max, true);
8186
+
8187
+ if (min.y != Double.POSITIVE_INFINITY && min.y > 2)
8188
+ {
8189
+ // sourcenode.getBounds(min, max, true);
8190
+ sourcenode.getBounds(v0, v1, true);
8191
+ // sourcenode.toParent = sourcenode.toParent;
8192
+ // get(0).toParent = get(0).toParent;
8193
+ // sourcenode.GlobalTransform();
8194
+ }
80118195 }
80128196 }
80138197
....@@ -8016,7 +8200,8 @@
80168200 if (support != null)
80178201 {
80188202 assert(bRep != null);
8019
- GraphreeD.Assert(support.bRep == bRep.support);
8203
+ if (!(support instanceof GenericJoint)) // support.bRep != null)
8204
+ Grafreed.Assert(support.bRep == bRep.support);
80208205 }
80218206 else
80228207 {
....@@ -8047,6 +8232,10 @@
80478232 }
80488233
80498234 transient ObjEditor editWindow;
8235
+ transient ObjEditor manipWindow;
8236
+
8237
+ transient boolean pinned;
8238
+
80508239 transient ObjectUI objectUI;
80518240 public static int povDepth = 0;
80528241 private static cVector tbMin = new cVector();
....@@ -8065,9 +8254,9 @@
80658254 private static cVector edge2 = new cVector();
80668255 //private static cVector norm = new cVector();
80678256 /*transient private*/ int hitSomething;
8068
- private static final int hitCenter = 1;
8069
- private static final int hitScale = 2;
8070
- private static final int hitRotate = 3;
8257
+ static final int hitCenter = 1;
8258
+ static final int hitScale = 2;
8259
+ static final int hitRotate = 3;
80718260 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
80728261 /*transient*/ private Point centerPt;
80738262 /*transient*/ private int startX;
....@@ -8099,6 +8288,8 @@
80998288 {
81008289 Object3D targ = this;
81018290
8291
+ targ.NORMALPUSH = obj.NORMALPUSH;
8292
+
81028293 if (obj.material != null)
81038294 {
81048295 if ((mask&MATERIAL)!=0) // ==(COLOR|MATERIAL))