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();
....@@ -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 }
....@@ -4614,7 +5044,7 @@
46145044
46155045 cTreePath SelectLeaf(int indexcount, boolean deselect)
46165046 {
4617
- if (hide)
5047
+ if (hide || dontselect)
46185048 return null;
46195049
46205050 if (count <= 0)
....@@ -4638,9 +5068,17 @@
46385068 }
46395069 }
46405070
5071
+ ObjEditor GetWindow()
5072
+ {
5073
+ if (editWindow != null)
5074
+ return editWindow;
5075
+
5076
+ return manipWindow;
5077
+ }
5078
+
46415079 cTreePath Select(int indexcount, boolean deselect)
46425080 {
4643
- if (hide)
5081
+ if (hide || dontselect)
46445082 return null;
46455083
46465084 if (count <= 0)
....@@ -4674,10 +5112,11 @@
46745112 if (leaf != null)
46755113 {
46765114 cTreePath tp = new cTreePath(this, leaf);
4677
- if (editWindow != null)
5115
+ ObjEditor window = GetWindow();
5116
+ if (window != null)
46785117 {
46795118 //System.out.println("editWindow = " + editWindow + " vs " + this);
4680
- editWindow.Select(tp, deselect, true);
5119
+ window.Select(tp, deselect, true);
46815120 }
46825121
46835122 return tp;
....@@ -4694,6 +5133,7 @@
46945133
46955134 if (child == null)
46965135 continue;
5136
+
46975137 if (child.HasTransparency() && child.size() != 0)
46985138 {
46995139 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4703,9 +5143,10 @@
47035143 if (leaf != null)
47045144 {
47055145 cTreePath tp = new cTreePath(this, leaf);
4706
- if (editWindow != null)
5146
+ ObjEditor window = GetWindow();
5147
+ if (window != null)
47075148 {
4708
- editWindow.Select(tp, deselect, true);
5149
+ window.Select(tp, deselect, true);
47095150 }
47105151
47115152 return tp;
....@@ -4790,7 +5231,7 @@
47905231 return globalTransform;
47915232 }
47925233
4793
- void PreprocessOcclusion(CameraPane cp)
5234
+ void PreprocessOcclusion(iCameraPane cp)
47945235 {
47955236 /*
47965237 if (AOdone)
....@@ -4937,7 +5378,8 @@
49375378 } else //
49385379 if (editWindow != null)
49395380 {
4940
- editWindow.cameraView.lighttouched = true;
5381
+ //editWindow.cameraView.lighttouched = true;
5382
+ Globals.lighttouched = true;
49415383 }
49425384 }
49435385
....@@ -5029,6 +5471,51 @@
50295471 blockloop = false;
50305472 }
50315473
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
+
50325519 boolean IsSelected()
50335520 {
50345521 if (parent == null)
....@@ -5089,12 +5576,41 @@
50895576 if (fullname == null)
50905577 return "";
50915578
5579
+ if (fullname.pigment != null)
5580
+ {
5581
+ return fullname.pigment;
5582
+ }
5583
+
50925584 // System.out.println("Fullname = " + fullname);
50935585
5094
- if (fullname.name.indexOf(":") == -1)
5095
- 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(":"));
50965591
5097
- 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];
50985614 }
50995615
51005616 static String GetBump(cTexture fullname)
....@@ -5102,11 +5618,44 @@
51025618 if (fullname == null)
51035619 return "";
51045620
5621
+ if (fullname.bump != null)
5622
+ {
5623
+ return fullname.bump;
5624
+ }
5625
+
51055626 // System.out.println("Fullname = " + fullname);
5106
- if (fullname.name.indexOf(":") == -1)
5107
- return "";
5108
-
5109
- 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];
51105659 }
51115660
51125661 String GetPigmentTexture()
....@@ -5180,7 +5729,7 @@
51805729 System.out.print("; textures = " + textures);
51815730 System.out.println("; usedtextures = " + usedtextures);
51825731
5183
- if (GetTextures() == null)
5732
+ if (GetTextures() == null) // What is that??
51845733 GetTextures().name = ":";
51855734
51865735 String texname = tex;
....@@ -5189,6 +5738,9 @@
51895738 texname = "";
51905739
51915740 GetTextures().name = texname + ":" + GetBump(GetTextures());
5741
+
5742
+ GetTextures().pigment = null;
5743
+
51925744 Touch();
51935745 }
51945746
....@@ -5213,6 +5765,43 @@
52135765 }
52145766 }
52155767
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
+
52165805 void SetBumpTexture(String tex)
52175806 {
52185807 if (GetTextures() == null)
....@@ -5224,6 +5813,8 @@
52245813 texname = "";
52255814
52265815 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
5816
+
5817
+ GetTextures().bump = null;
52275818
52285819 Touch();
52295820 }
....@@ -5249,25 +5840,65 @@
52495840 }
52505841 }
52515842
5252
- 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)
52535876 {
52545877 Draw(display, root, selected, blocked);
52555878 }
52565879
5257
- static cMaterial[] materialstack = new cMaterial[65536];
5258
- static boolean[] selectedstack = new boolean[65536];
5259
- static int materialdepth = 0;
5260
-
52615880 boolean NeedSupport()
52625881 {
52635882 return
5264
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5883
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
52655884 // PROBLEM with CROWD!!
5266
- && (CameraPane.drawMode == CameraPane.SHADOW || CameraPane.CROWD);
5885
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
52675886 }
52685887
5888
+ static boolean DEBUG_SELECTION = false;
52695889
5270
- 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)
52715902 {
52725903 Invariants(); // june 2013
52735904
....@@ -5276,8 +5907,8 @@
52765907 // System.err.println("Draw " + this + " Frame # " + ((Mocap)((Merge)support).object).frame);
52775908 }
52785909
5279
- if (display.drawMode == CameraPane.SELECTION &&
5280
- hide)
5910
+ if (display.DrawMode() == iCameraPane.SELECTION &&
5911
+ (hide || dontselect))
52815912 return;
52825913
52835914 if (name != null && name.contains("sclera"))
....@@ -5295,7 +5926,7 @@
52955926 if (this instanceof Checker)
52965927 return;
52975928
5298
- if (display.drawMode == display.SHADOW && PASSTEST)
5929
+ if (display.DrawMode() == display.SHADOW && PASSTEST)
52995930 return;
53005931
53015932 if (count <= 0)
....@@ -5303,13 +5934,13 @@
53035934 return;
53045935 }
53055936
5306
- if ((//display.drawMode == CameraPane.SHADOW ||
5307
- display.drawMode == CameraPane.SELECTION || CameraPane.DEBUG_SELECTION) && HasTransparency())
5937
+ if ((//display.DrawMode() == CameraPane.SHADOW ||
5938
+ display.DrawMode() == iCameraPane.SELECTION || display.IsDebugSelection()) && HasTransparency())
53085939 {
53095940 return;
53105941 }
53115942
5312
- javax.media.opengl.GL gl = display.GetGL();
5943
+ //javax.media.opengl.GL gl = display.GetGL();
53135944
53145945 /*
53155946 if (touched)
....@@ -5327,8 +5958,10 @@
53275958 if (support != null)
53285959 support = support;
53295960
5330
- //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5331
- 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.
53325965
53335966 if (!usecalllists && bRep != null && bRep.displaylist > 0)
53345967 {
....@@ -5338,30 +5971,33 @@
53385971 // usecalllists &= !(parent instanceof RandomNode);
53395972 // usecalllists = false;
53405973
5341
- if (GetBRep() != null)
5342
- usecalllists = usecalllists;
5974
+ if (display.DrawMode() == display.SHADOW)
5975
+ //GetBRep() != null)
5976
+ usecalllists = !!usecalllists;
53435977 //System.out.println("draw " + this);
53445978 //new Exception().printStackTrace();
53455979
53465980 boolean compiled = false;
53475981
5348
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
5982
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
53495983
5350
- if (!selectmode && //display.drawMode != display.SELECTION &&
5351
- (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)))
53525987 {
5353
- display.lighttouched = true;
5988
+ Globals.lighttouched = true;
53545989 } // all panes...
5355
- //if (usecalllists && display.drawMode != display.SELECTION && display.drawMode != display.SHADOW &&
5356
- 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 &&
53575993 (touched || (bRep != null && bRep.displaylist <= 0)))
53585994 {
53595995 if (!(this instanceof Composite))
53605996 touched = false;
53615997 //if (displaylist == -1 && usecalllists)
5362
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
5998
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
53635999 {
5364
- bRep.displaylist = gl.glGenLists(1);
6000
+ bRep.displaylist = display.GenList();
53656001 assert(bRep.displaylist != 0);
53666002 // System.err.println("glGenLists: " + bRep.displaylist + " for " + this);
53676003 //System.out.println("\tgen list " + list);
....@@ -5370,21 +6006,23 @@
53706006
53716007 //System.out.println("\tnew list " + list);
53726008 //gl.glDrawBuffer(gl.GL_NONE);
5373
- if (usecalllists)
6009
+ if (usecalllists && bRep.displaylist > 0)
53746010 {
53756011 // System.err.println("new list " + bRep.displaylist + " for " + this);
5376
- gl.glNewList(bRep.displaylist, gl.GL_COMPILE); //_AND_EXECUTE);
6012
+ display.NewList(bRep.displaylist);
53776013 }
6014
+
53786015 CallList(display, root, selected, blocked);
6016
+
53796017 // compiled = true;
5380
- if (usecalllists)
6018
+ if (usecalllists && bRep.displaylist > 0)
53816019 {
53826020 // System.err.println("end list " + bRep.displaylist + " for " + this);
5383
- gl.glEndList();
6021
+ display.EndList();
53846022 }
53856023 //gl.glDrawBuffer(gl.GL_BACK);
53866024 // XXX touched = false;
5387
- display.lighttouched = true; // all panes...
6025
+ Globals.lighttouched = true; // all panes...
53886026 }
53896027
53906028 touched = GetBRep() == null; // this instanceof Composite || this instanceof FileObject; // false;
....@@ -5423,12 +6061,12 @@
54236061
54246062 // frustum culling
54256063 if (CameraPane.FRUSTUM && !blocked && !IsInfinite() && GetBRep() != null // && GetBRep().VertexCount() != 1260 // default grid
5426
- && display.drawMode != CameraPane.SELECTION)
6064
+ && display.DrawMode() != iCameraPane.SELECTION)
54276065 {
5428
- if (display.drawMode == CameraPane.SHADOW)
6066
+ if (display.DrawMode() == iCameraPane.SHADOW)
54296067 {
54306068 if (!link2master // tricky to cull in shadow mode.
5431
- && GetBRep().FrustumCull(this, gl, display.lightCamera, true))
6069
+ && GetBRep().FrustumCull(this, null, display.LightCamera(), true))
54326070 {
54336071 //System.out.print("CULLED");
54346072 culled = true;
....@@ -5436,7 +6074,7 @@
54366074 }
54376075 else
54386076 //GetBRep().getBounds(v0, v1, this);
5439
- if (GetBRep().FrustumCull(this, gl, display.renderCamera, false))
6077
+ if (GetBRep().FrustumCull(this, null, display.RenderCamera(), false))
54406078 culled = true;
54416079
54426080 // LA.xformPos(v0, display.renderCamera.toScreen, v0);
....@@ -5472,11 +6110,12 @@
54726110
54736111
54746112 if (!culled)
5475
- if (display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION)
6113
+ if (display.DrawMode() == display.SELECTION || display.IsDebugSelection())
54766114 {
54776115 if (GetBRep() != null)
54786116 {
5479
- CameraPane.NextIndex(this, gl);
6117
+ display.NextIndex();
6118
+
54806119 // vertex color conflict : gl.glCallList(list);
54816120 DrawNode(display, root, selected);
54826121 if (this instanceof BezierPatch)
....@@ -5498,53 +6137,7 @@
54986137 color[2] /= 2;
54996138 gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT_AND_DIFFUSE, color, 0);
55006139 */
5501
- if (material != null)
5502
- {
5503
- materialstack[materialdepth] = material;
5504
- selectedstack[materialdepth] = selected;
5505
- cStatic.objectstack[materialdepth++] = this;
5506
- //System.out.println("material " + material);
5507
- //Applet3D.tracein(this, selected);
5508
- display.vector2buffer = projectedVertices;
5509
- if (this instanceof Camera)
5510
- {
5511
- display.options1[0] = material.shift;
5512
- //System.out.println("shift " + material.shift);
5513
- display.options1[1] = material.lightarea;
5514
- display.options1[2] = material.shadowbias;
5515
- display.options1[3] = material.aniso;
5516
- display.options1[4] = material.anisoV;
5517
- display.options2[0] = material.opacity;
5518
- display.options2[1] = material.diffuse;
5519
- display.options2[2] = material.factor;
5520
-
5521
- cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
5522
- display.options3[3] = material.cameralight/0.2f;
5523
-
5524
- // if (display.CURRENTANTIALIAS > 0)
5525
- // display.options3[3] /= 4;
5526
-
5527
- /*
5528
- System.out.println("Focus = " + display.options1[0]);
5529
- System.out.println("Aperture = " + display.options1[1]);
5530
- System.out.println("ShadowBlur = " + display.options1[2]);
5531
- System.out.println("Antialiasing = " + display.options1[3]);
5532
- System.out.println("Fog = " + display.options2[0]);
5533
- System.out.println("Intensity = " + display.options2[1]);
5534
- System.out.println("Elevation = " + display.options2[2]);
5535
- /**/
5536
- } else
5537
- {
5538
- material.Draw(display, selected);
5539
- }
5540
- } else
5541
- {
5542
- if (selected && CameraPane.flash)
5543
- {
5544
- display.modelParams4[1] = 100;
5545
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
5546
- }
5547
- }
6140
+ display.PushMaterial(this, selected);
55486141
55496142 //System.out.println("call list " + list);
55506143 //System.out.println();
....@@ -5563,7 +6156,28 @@
55636156 tex = GetTextures();
55646157 }
55656158
5566
- 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
+ }
55676181
55686182 if (!compiled)
55696183 {
....@@ -5579,30 +6193,19 @@
55796193
55806194 // System.err.println("glCallList: " + bRep.displaylist + " for " + this);
55816195 assert(bRep.displaylist != 0);
5582
- gl.glCallList(bRep.displaylist);
6196
+ display.CallList(bRep.displaylist);
55836197 // june 2013 drawSelf(display, root, selected);
55846198 }
55856199 }
55866200 }
55876201
5588
- display.ReleaseTextures(tex);
5589
-
5590
- //if (parent != null && parent.GetMaterial() != null)
5591
- // parent.GetMaterial().Draw(display, parent.IsSelected(this));
5592
- if (material != null)
5593
- {
5594
- materialdepth -= 1;
5595
- if (materialdepth > 0)
5596
- {
5597
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
5598
- materialstack[materialdepth - 1].Draw(display, selectedstack[materialdepth - 1]);
5599
- }
5600
- //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
5601
- } else if (selected && CameraPane.flash && GetMaterial() != null)
5602
- {
5603
- display.modelParams4[1] = GetMaterial().cameralight;
5604
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
5605
- }
6202
+ if (!failedBump)
6203
+ display.ReleaseBumpTexture(tex);
6204
+
6205
+ if (!failedPigment)
6206
+ display.ReleasePigmentTexture(tex);
6207
+
6208
+ display.PopMaterial(this, selected);
56066209 }
56076210
56086211 if (this instanceof Texture || this instanceof TextureNode)
....@@ -5644,7 +6247,7 @@
56446247 // resetMasterNode();
56456248 }
56466249
5647
- void CallList(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
6250
+ void CallList(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
56486251 {
56496252 if (GetBRep() == null)
56506253 {
....@@ -5727,8 +6330,11 @@
57276330 boolean flipV = false; // true;
57286331 int texres = 0; // 0 = low, 1 = normal, 2 = high res texture
57296332
5730
- void drawSelf(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
6333
+ void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57316334 {
6335
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6336
+ return;
6337
+
57326338 if (hide)
57336339 return;
57346340 // shadow optimisation
....@@ -5786,16 +6392,7 @@
57866392 // // ??????????????????????????? Touch();
57876393 // }
57886394
5789
- if (material != null)
5790
- {
5791
- materialstack[materialdepth] = material;
5792
- selectedstack[materialdepth] = selected;
5793
- cStatic.objectstack[materialdepth++] = this;
5794
- //System.out.println("material " + material);
5795
- //Applet3D.tracein("selected ", selected);
5796
- display.vector2buffer = projectedVertices;
5797
- material.Draw(display, selected);
5798
- }
6395
+display.PushMaterial2(this, selected);
57996396
58006397 Object3D child;
58016398 boolean sel;
....@@ -5819,12 +6416,12 @@
58196416 if (!child.HasTransparency())
58206417 {
58216418 sel = root != null && root.selection != null && root.selection.indexOf(child) != -1;
5822
- // GraphreeD.tracein("draw ", child);
6419
+ // GrafreeD.tracein("draw ", child);
58236420 boolean wasblocked = blockdraw;
58246421 blockdraw = true;
58256422 child.draw(display, root, selected || sel, wasblocked || blocked); // || child.IsSelected());
58266423 blockdraw = false;
5827
- // GraphreeD.traceout("draw ", child);
6424
+ // GrafreeD.traceout("draw ", child);
58286425 }
58296426
58306427 release(i);
....@@ -5847,19 +6444,7 @@
58476444 */
58486445 //depth += 1;
58496446
5850
- if (material != null)
5851
- {
5852
- materialdepth -= 1;
5853
- if (materialdepth > 0)
5854
- {
5855
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
5856
- materialstack[materialdepth - 1].Draw(display, selectedstack[materialdepth - 1]);
5857
- }
5858
- //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
5859
- //else
5860
- //material.Draw(display, false);
5861
- }
5862
-
6447
+display.PopMaterial2(this);
58636448 /*
58646449 display.ReleaseTextures(tex);
58656450 */
....@@ -5870,10 +6455,13 @@
58706455
58716456 //static cVector min,max;
58726457
5873
- void DrawNode(CameraPane display, Object3D /*Composite*/ root, boolean selected)
6458
+ void DrawNode(iCameraPane display, Object3D /*Composite*/ root, boolean selected)
58746459 {
5875
- 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)
58766461 return; // no shadow for transparent objects
6462
+
6463
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6464
+ return;
58776465
58786466 if (hide)
58796467 return;
....@@ -5915,11 +6503,12 @@
59156503 return;
59166504 }
59176505
6506
+ //bRep.GenUV(1/material.diffuseness);
59186507 // bRep.lock = true;
59196508
5920
- javax.media.opengl.GL gl = display.GetGL();
6509
+ //javax.media.opengl.GL gl = display.GetGL();
59216510
5922
- if (CameraPane.BOXMODE) // || CameraPane.movingcamera)
6511
+ if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera)
59236512 {
59246513 int fc = bRep.FaceCount();
59256514 int vc = bRep.VertexCount();
....@@ -5934,23 +6523,7 @@
59346523
59356524 bRep.getMinMax(min, max, 100);
59366525
5937
- gl.glBegin(gl.GL_LINES);
5938
-
5939
- gl.glVertex3d(min.x, min.y, min.z);
5940
- gl.glVertex3d(min.x, min.y, max.z);
5941
- gl.glVertex3d(min.x, min.y, min.z);
5942
- gl.glVertex3d(min.x, max.y, min.z);
5943
- gl.glVertex3d(min.x, min.y, min.z);
5944
- gl.glVertex3d(max.x, min.y, min.z);
5945
-
5946
- gl.glVertex3d(max.x, max.y, max.z);
5947
- gl.glVertex3d(min.x, max.y, max.z);
5948
- gl.glVertex3d(max.x, max.y, max.z);
5949
- gl.glVertex3d(max.x, min.y, max.z);
5950
- gl.glVertex3d(max.x, max.y, max.z);
5951
- gl.glVertex3d(max.x, max.y, min.z);
5952
-
5953
- gl.glEnd();
6526
+ display.DrawBox(min, max);
59546527
59556528 return;
59566529 }
....@@ -5994,7 +6567,7 @@
59946567 {
59956568 //throw new Error();
59966569
5997
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
6570
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
59986571
59996572 int[] strips = bRep.getRawIndices();
60006573
....@@ -6004,178 +6577,19 @@
60046577 new Exception().printStackTrace();
60056578 return;
60066579 }
6007
-
6008
- // TRIANGLE STRIP ARRAY
6009
- if (bRep.trimmed)
6580
+
6581
+ if (dontselect)
60106582 {
6011
- float[] v = bRep.getRawVertices();
6012
- float[] n = bRep.getRawNormals();
6013
- float[] c = bRep.getRawColors();
6014
- float[] uv = bRep.getRawUVMap();
6015
-
6016
- int count2 = 0;
6017
- int count3 = 0;
6018
-
6019
- if (n.length > 0)
6020
- {
6021
- for (int i = 0; i < strips.length; i++)
6022
- {
6023
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6024
-
6025
- /*
6026
- boolean locked = false;
6027
- float eps = 0.1f;
6028
- boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
6029
-
6030
- int dot = 0;
6031
-
6032
- if ((dot&1) == 0)
6033
- dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
6034
-
6035
- if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
6036
- gl.glTexCoord2f((float) qv.s, (float) qv.t);
6037
- else
6038
- {
6039
- locked = true;
6040
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6041
- }
6042
- //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6043
- gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
6044
- if (hasnorm)
6045
- {
6046
- //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6047
- gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
6048
- }
6049
-
6050
- if ((dot&4) == 0)
6051
- dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
6052
-
6053
- if (wrap || !locked && (dot&8) != 0)
6054
- gl.glTexCoord2f((float) rv.s, (float) rv.t);
6055
- else
6056
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6057
-
6058
- f.dot = dot;
6059
- */
6060
-
6061
- if (!selectmode)
6062
- {
6063
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6064
- {
6065
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6066
- } else
6067
- {
6068
- gl.glNormal3f(0, 0, 1);
6069
- }
6070
-
6071
- if (c != null)
6072
- //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]);
6073
- {
6074
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6075
- }
6076
- }
6077
- if (flipV)
6078
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6079
- else
6080
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6081
- //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6082
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6083
-
6084
- count2 += 2;
6085
- count3 += 3;
6086
- if (!selectmode)
6087
- {
6088
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6089
- {
6090
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6091
- } else
6092
- {
6093
- gl.glNormal3f(0, 0, 1);
6094
- }
6095
- if (c != null)
6096
- {
6097
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6098
- }
6099
- }
6100
- if (flipV)
6101
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6102
- else
6103
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6104
- //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6105
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6106
-
6107
- count2 += 2;
6108
- count3 += 3;
6109
- for (int j = 0; j < strips[i] - 2; j++)
6110
- {
6111
- //gl.glTexCoord2d(...);
6112
- if (!selectmode)
6113
- {
6114
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6115
- {
6116
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6117
- } else
6118
- {
6119
- gl.glNormal3f(0, 0, 1);
6120
- }
6121
- if (c != null)
6122
- {
6123
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6124
- }
6125
- }
6126
-
6127
- if (flipV)
6128
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6129
- else
6130
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6131
- //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
6132
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6133
- count2 += 2;
6134
- count3 += 3;
6135
- }
6136
-
6137
- gl.glEnd();
6138
- }
6139
- }
6140
-
6141
- assert count3 == v.length;
6583
+ //bRep.GenerateNormalsMINE();
61426584 }
6143
- else // !trimmed
6144
- {
6145
- int count = 0;
6146
- for (int i = 0; i < strips.length; i++)
6147
- {
6148
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6149
-
6150
- Vertex p = bRep.GetVertex(bRep.indices[count++]);
6151
- Vertex q = bRep.GetVertex(bRep.indices[count++]);
6152
-
6153
- drawVertex(gl, p, selectmode);
6154
- drawVertex(gl, q, selectmode);
6155
-
6156
- for (int j = 0; j < strips[i] - 2; j++)
6157
- {
6158
- Vertex r = bRep.GetVertex(bRep.indices[count++]);
6159
-
6160
-// if (j%2 == 0)
6161
-// drawFace(p, q, r, display, null);
6162
-// else
6163
-// drawFace(p, r, q, display, null);
6164
-
6165
-// p = q;
6166
-// q = r;
6167
- drawVertex(gl, r, selectmode);
6168
- }
6169
-
6170
- gl.glEnd();
6171
- }
6172
- }
6585
+
6586
+ display.DrawGeometry(bRep, flipV, selectmode);
61736587 } else // catch (Error e)
61746588 {
61756589 // TRIANGLE ARRAY
61766590 if (IsOpaque()) // Static())
61776591 {
6178
- gl.glBegin(gl.GL_TRIANGLES);
6592
+ display.StartTriangles();
61796593 int facecount = bRep.FaceCount();
61806594 for (int i = 0; i < facecount; i++)
61816595 {
....@@ -6238,9 +6652,9 @@
62386652 // // r.norm.dot(v3) > -0.5)
62396653 // // continue;
62406654
6241
- drawFace(p, q, r, display, face);
6655
+ display.DrawFace(this, p, q, r, face);
62426656 }
6243
- gl.glEnd();
6657
+ display.EndTriangles();
62446658 }
62456659 else
62466660 {
....@@ -6269,8 +6683,8 @@
62696683 //System.out.println("SORT");
62706684
62716685 java.util.Arrays.sort(facescompare);
6272
-
6273
- gl.glBegin(gl.GL_TRIANGLES);
6686
+
6687
+ display.StartTriangles();
62746688 for (int i = 0; i < facecount; i++)
62756689 {
62766690 Face face = bRep.GetFace(facescompare[i].index);
....@@ -6282,13 +6696,14 @@
62826696 Vertex q = bRep.GetVertex(face.q);
62836697 Vertex r = bRep.GetVertex(face.r);
62846698
6285
- drawFace(p, q, r, display, face);
6699
+ display.DrawFace(this, p, q, r, face);
62866700 }
6287
- gl.glEnd();
6701
+ display.EndTriangles();
62886702 }
62896703
62906704 if (false) // live && support != null && support.bRep != null) // debug weights
62916705 {
6706
+ /*
62926707 gl.glDisable(gl.GL_LIGHTING);
62936708 float[] colorV = new float[3];
62946709
....@@ -6367,6 +6782,7 @@
63676782 // gl.glEnd();
63686783 }
63696784 }
6785
+ */
63706786 }
63716787 }
63726788
....@@ -6411,7 +6827,7 @@
64116827 center.add(r);
64126828 center.mul(1.0/3);
64136829
6414
- center.sub(CameraPane.theRenderer.eyeCamera.location);
6830
+ center.sub(Globals.theRenderer.EyeCamera().location);
64156831
64166832 distance = center.dot(center);
64176833 }
....@@ -6422,347 +6838,11 @@
64226838
64236839 transient FaceCompare[] facescompare = null;
64246840
6425
- void SetColor(CameraPane display, Vertex p0)
6426
- {
6427
- if (display.RENDERPROGRAM == 0)
6428
- {
6429
- float r = 0;
6430
- if (bRep != null)
6431
- {
6432
- if (bRep.stripified)
6433
- {
6434
- r = 1;
6435
- }
6436
- }
6437
- float g = 0;
6438
- if (bRep != null)
6439
- {
6440
- if (bRep.trimmed)
6441
- {
6442
- g = 1;
6443
- }
6444
- }
6445
- float b = 0;
6446
- if (support != null && link2master)
6447
- {
6448
- b = 1;
6449
- }
6450
- display.GetGL().glColor3f(r*p0.AO, g*p0.AO, b*p0.AO);
6451
- return;
6452
- }
6453
-
6454
- if (display.drawMode != CameraPane.SHADOW)
6455
- return;
6456
-
6457
- javax.media.opengl.GL gl = display.GetGL();
6458
-// if (true) return;
6459
-// float ao = p.AO;
6460
-//
6461
-// // if (ao == 0 && !bRep.AOdone) // transient problem!
6462
-// // ao = 1;
6463
-//
6464
-// gl.glColor4f(ao, ao, ao, 1);
6465
-
6466
-// CameraPane.selectedpoint.
6467
-// getAverage(cStatic.point1, true);
6468
- if (CameraPane.pointflow == null) // !random) // live)
6469
- {
6470
- return;
6471
- }
6472
-
6473
- cStatic.point1.set(0,0,0);
6474
- LA.xformPos(cStatic.point1, CameraPane.selectedpoint.toParent, cStatic.point1);
6475
-
6476
- cStatic.point1.sub(p0);
6477
-
6478
-
6479
-// if (marked && (p0.vertexlinks == null || support == null || support.bRep == null)) // no position delta?
6480
-// {
6481
-// return;
6482
-// }
6483
-
6484
- //if (true)
6485
- if (cStatic.point1.dot(cStatic.point1) > 0.000001)
6486
- {
6487
- return;
6488
- }
6489
-
6490
- float[] colorV = new float[3];
6491
-
6492
- if (false) // marked)
6493
- {
6494
- // debug rigging weights
6495
- for (int object = 0; object < p0.vertexlinks.length; object++)
6496
- {
6497
- float weight = p0.weights[object] / p0.totalweight;
6498
-
6499
- // if (weight < 0.1)
6500
- // {
6501
- // assert(weight == 0);
6502
- // continue;
6503
- // }
6504
-
6505
- if (p0.vertexlinks[object] == -1)
6506
- continue;
6507
-
6508
- Vertex q = support.bRep.GetVertex(p0.vertexlinks[object]);
6509
-
6510
- int color = //1 << object; //
6511
- //p.vertexlinks.length;
6512
- support.bRep.supports[p0.closestsupport].links[object];
6513
- colorV[2] += (color & 1) * weight;
6514
- colorV[1] += ((color & 2) >> 1) * weight;
6515
- colorV[0] += ((color & 4) >> 2) * weight;
6516
- }
6517
- }
6518
- else
6519
- {
6520
- if (drawingstarted)
6521
- {
6522
- // find next point
6523
- if (bRep.GetVertex(0).faceindices == null)
6524
- {
6525
- bRep.InitFaceIndices();
6526
- }
6527
-
6528
- double ymin = p0.y;
6529
-
6530
- Vertex newp = p0;
6531
-
6532
- for (int fii = 0; fii < p0.faceindices.length; fii++)
6533
- {
6534
- int fi = p0.faceindices[fii];
6535
-
6536
- if (fi == -1)
6537
- break;
6538
-
6539
- Face f = bRep.GetFace(fi);
6540
-
6541
- Vertex p = bRep.GetVertex(f.p);
6542
- Vertex q = bRep.GetVertex(f.q);
6543
- Vertex r = bRep.GetVertex(f.r);
6544
-
6545
- int swap = (int)(Math.random()*3);
6546
-
6547
-// for (int s=swap; --s>=0;)
6548
-// {
6549
-// Vertex t = p;
6550
-// p = q;
6551
-// q = r;
6552
-// r = t;
6553
-// }
6554
- if (ymin > p.y)
6555
- {
6556
- ymin = p.y;
6557
- newp = p;
6558
-// break;
6559
- }
6560
- if (ymin > q.y)
6561
- {
6562
- ymin = q.y;
6563
- newp = q;
6564
-// break;
6565
- }
6566
- if (ymin > r.y)
6567
- {
6568
- ymin = r.y;
6569
- newp = r;
6570
-// break;
6571
- }
6572
- }
6573
-
6574
- CameraPane.selectedpoint.toParent[3][0] = newp.x;
6575
- CameraPane.selectedpoint.toParent[3][1] = newp.y;
6576
- CameraPane.selectedpoint.toParent[3][2] = newp.z;
6577
-
6578
- drawingstarted = false;
6579
-
6580
- // return;
6581
- }
6582
-
6583
- if (false) // CameraPane.DRAW
6584
- {
6585
- p0.AO = colorV[0] = 2;
6586
- colorV[1] = 2;
6587
- colorV[2] = 2;
6588
- }
6589
-
6590
- CameraPane.pointflow.add(p0);
6591
- CameraPane.pointflow.Touch();
6592
- }
6593
-
6594
-// gl.glColor3f(colorV[0], colorV[1], colorV[2]);
6595
-// gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0);
6596
-// gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
6597
- }
6598
-
65996841 void Print(Vertex v)
66006842 {
66016843 //System.err.println("(" + v.x + ", " + v.y + ", " + v.z + ")");
66026844 }
66036845
6604
- void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean selectmode)
6605
- {
6606
- if (!selectmode)
6607
- {
6608
- gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
6609
- gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
6610
-
6611
- if (flipV)
6612
- gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
6613
- else
6614
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6615
- }
6616
-
6617
- gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
6618
- }
6619
-
6620
- void drawFace(Vertex pv, Vertex qv, Vertex rv,
6621
- CameraPane display, Face face)
6622
- {
6623
- if (pv.y == -10000 ||
6624
- qv.y == -10000 ||
6625
- rv.y == -10000)
6626
- return;
6627
-
6628
-// float b = f.nbiterations & 1;
6629
-// float g = (f.nbiterations>>1) & 1;
6630
-// float r = (f.nbiterations>>2) & 1;
6631
-//
6632
-// //if (f.weight == 10000)
6633
-// //{
6634
-// // r = 1; g = b = 0;
6635
-// //}
6636
-// //else
6637
-// //{
6638
-// // assert(f.weight < 10000);
6639
-// r = g = b = (float)bRep.FaceWeight(f)*100;
6640
-// if (r<0)
6641
-// assert(r>=0);
6642
-// //}
6643
-
6644
- javax.media.opengl.GL gl = display.GetGL();
6645
-
6646
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
6647
-
6648
- //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv);
6649
- if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
6650
- {
6651
- //gl.glBegin(gl.GL_TRIANGLES);
6652
- boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
6653
- if (!hasnorm)
6654
- {
6655
- // System.out.println("FUCK!!");
6656
- LA.vecSub(pv/*.pos*/, qv/*.pos*/, v0);
6657
- LA.vecSub(pv/*.pos*/, rv/*.pos*/, v1);
6658
- LA.vecCross(v0, v1, v2);
6659
- LA.vecNormalize(v2);
6660
- gl.glNormal3f((float) v2.x, (float) v2.y, (float) v2.z);
6661
- }
6662
-
6663
- if (hasnorm)
6664
- {
6665
-// if (!pv.norm.normalized())
6666
-// assert(pv.norm.normalized());
6667
-
6668
- //System.out.println("normalp = " + pv.norm.x + ", " + pv.norm.y + ", " + pv.norm.z);
6669
- gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
6670
- }
6671
- gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
6672
- SetColor(display, pv);
6673
- //gl.glColor4f(r, g, b, 1);
6674
- //gl.glColor4f(pv.boundary, pv.boundary, pv.boundary, 1);
6675
- if (flipV)
6676
- gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
6677
- else
6678
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6679
- //System.out.println("vertexp = " + pv.x + ", " + pv.y + ", " + pv.z);
6680
- gl.glVertex3f((float) pv./*pos.*/x, (float) pv./*pos.*/y, (float) pv./*pos.*/z);
6681
-// Print(pv);
6682
- if (hasnorm)
6683
- {
6684
-// assert(qv.norm.normalized());
6685
- //System.out.println("normalq = " + qv.norm.x + ", " + qv.norm.y + ", " + qv.norm.z);
6686
- gl.glNormal3f((float) qv.norm.x, (float) qv.norm.y, (float) qv.norm.z);
6687
- }
6688
- //System.out.println("vertexq = " + qv.s + ", " + qv.t);
6689
- // boolean locked = false;
6690
- // float eps = 0.1f;
6691
- // boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
6692
-
6693
- // int dot = 0; //*/ (int)f.dot;
6694
-
6695
- // if ((dot&1) == 0)
6696
- // dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
6697
-
6698
- // if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
6699
- if (flipV)
6700
- gl.glTexCoord2f((float) qv.s, 1-(float) qv.t);
6701
- else
6702
- gl.glTexCoord2f((float) qv.s, (float) qv.t);
6703
- // else
6704
- // {
6705
- // locked = true;
6706
- // gl.glTexCoord2f((float) pv.s, (float) pv.t);
6707
- // }
6708
- gl.glColor4f(qv.AO, qv.AO, qv.AO, 1);
6709
- SetColor(display, qv);
6710
- //gl.glColor4f(r, g, b, 1);
6711
- //gl.glColor4f(qv.boundary, qv.boundary, qv.boundary, 1);
6712
- //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6713
- gl.glVertex3f((float) qv./*pos.*/x, (float) qv./*pos.*/y, (float) qv./*pos.*/z);
6714
-// Print(qv);
6715
- if (hasnorm)
6716
- {
6717
-// assert(rv.norm.normalized());
6718
- //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6719
- gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
6720
- }
6721
-
6722
- // if ((dot&4) == 0)
6723
- // dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
6724
-
6725
- // if (wrap || !locked && (dot&8) != 0)
6726
- if (flipV)
6727
- gl.glTexCoord2f((float) rv.s, 1-(float) rv.t);
6728
- else
6729
- gl.glTexCoord2f((float) rv.s, (float) rv.t);
6730
- // else
6731
- // gl.glTexCoord2f((float) pv.s, (float) pv.t);
6732
-
6733
- // f.dot = dot;
6734
-
6735
- gl.glColor4f(rv.AO, rv.AO, rv.AO, 1);
6736
- SetColor(display, rv);
6737
- //gl.glColor4f(r, g, b, 1);
6738
- //gl.glColor4f(rv.boundary, rv.boundary, rv.boundary, 1);
6739
- //System.out.println("vertexr = " + rv.x + ", " + rv.y + ", " + rv.z);
6740
- gl.glVertex3f((float) rv./*pos.*/x, (float) rv./*pos.*/y, (float) rv./*pos.*/z);
6741
-// Print(rv);
6742
- //gl.glEnd();
6743
- }
6744
- else
6745
- {
6746
- gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
6747
- gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
6748
- gl.glVertex3f((float) rv.x, (float) rv.y, (float) rv.z);
6749
-
6750
- }
6751
-
6752
- if (false) // (attributes & WIREFRAME) != 0)
6753
- {
6754
- gl.glDisable(gl.GL_LIGHTING);
6755
-
6756
- gl.glBegin(gl.GL_LINE_LOOP);
6757
- gl.glVertex3d(pv./*pos.*/x, pv./*pos.*/y, pv./*pos.*/z);
6758
- gl.glVertex3d(qv./*pos.*/x, qv./*pos.*/y, qv./*pos.*/z);
6759
- gl.glVertex3d(rv./*pos.*/x, rv./*pos.*/y, rv./*pos.*/z);
6760
- gl.glEnd();
6761
-
6762
- gl.glEnable(gl.GL_LIGHTING);
6763
- }
6764
- }
6765
-
67666846 void drawSelf(ClickInfo info, int level, boolean select)
67676847 {
67686848 if (bRep == null)
....@@ -7286,20 +7366,23 @@
72867366 }
72877367 }
72887368
7289
- 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)
72907373 {
7291
- int hc = info.bounds.x + info.bounds.width / 2;
7292
- int vc = info.bounds.y + info.bounds.height / 2;
7293
- 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;
72947377 if (toscreen == null)
72957378 {
7296
- toscreen = new Camera(info.camera.viewCode).toScreen;
7379
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
72977380 }
72987381 cVector vec = in;
72997382 LA.xformPos(in, toscreen, in);
73007383 //System.out.println("Distance = " + info.camera.Distance());
7301
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
7302
- 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();
73037386 outPt.x = hc + (int) vec.x;
73047387 outPt.y = vc - (int) vec.y;
73057388 outRec.x = outPt.x - 3;
....@@ -7307,15 +7390,18 @@
73077390 outRec.width = outRec.height = 6;
73087391 }
73097392
7310
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7393
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7394
+ )
73117395 {
73127396 Point pt = new Point(0, 0);
73137397 Rectangle rec = new Rectangle();
7314
- calcHotSpot(in, info, pt, rec);
7398
+ calcHotSpot(in, //clickInfo,
7399
+ pt, rec);
73157400 return rec;
73167401 }
73177402
7318
- void drawEditHandles0(ClickInfo info, int level)
7403
+ void drawEditHandles0(//ClickInfo clickInfo,
7404
+ int level)
73197405 {
73207406 if (level == 0)
73217407 {
....@@ -7324,98 +7410,104 @@
73247410 {
73257411 cVector origin = new cVector();
73267412 //LA.xformPos(origin, toParent, origin);
7327
- Rectangle spot = calcHotSpot(origin, info);
7413
+ if (this.clickInfo == null)
7414
+ this.clickInfo = new ClickInfo();
7415
+
7416
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
73287417 Rectangle boundary = new Rectangle();
73297418 boundary.x = spot.x - 30;
73307419 boundary.y = spot.y - 30;
73317420 boundary.width = spot.width + 60;
73327421 boundary.height = spot.height + 60;
7333
- info.g.setColor(Color.red);
7422
+ clickInfo.g.setColor(Color.white);
73347423 int spotw = spot.x + spot.width;
73357424 int spoth = spot.y + spot.height;
7336
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7337
- if (CameraPane.Xmin > spot.x)
7338
- {
7339
- CameraPane.Xmin = spot.x;
7340
- }
7341
- if (CameraPane.Xmax < spotw)
7342
- {
7343
- CameraPane.Xmax = spotw;
7344
- }
7345
- if (CameraPane.Ymin > spot.y)
7346
- {
7347
- CameraPane.Ymin = spot.y;
7348
- }
7349
- if (CameraPane.Ymax < spoth)
7350
- {
7351
- CameraPane.Ymax = spoth;
7352
- }
7353
- 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);
73547465 spotw = spot.x + spot.width;
73557466 spoth = spot.y + spot.height;
7356
- info.g.setColor(Color.blue);
7357
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7358
- if (CameraPane.Xmin > spot.x)
7359
- {
7360
- CameraPane.Xmin = spot.x;
7361
- }
7362
- if (CameraPane.Xmax < spotw)
7363
- {
7364
- CameraPane.Xmax = spotw;
7365
- }
7366
- if (CameraPane.Ymin > spot.y)
7367
- {
7368
- CameraPane.Ymin = spot.y;
7369
- }
7370
- if (CameraPane.Ymax < spoth)
7371
- {
7372
- CameraPane.Ymax = spoth;
7373
- }
7374
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7375
- info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7376
- spot.translate(0, -32);
7377
- info.g.setColor(Color.green);
7378
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7379
- if (CameraPane.Xmin > spot.x)
7380
- {
7381
- CameraPane.Xmin = spot.x;
7382
- }
7383
- if (CameraPane.Xmax < spotw)
7384
- {
7385
- CameraPane.Xmax = spotw;
7386
- }
7387
- if (CameraPane.Ymin > spot.y)
7388
- {
7389
- CameraPane.Ymin = spot.y;
7390
- }
7391
- if (CameraPane.Ymax < spoth)
7392
- {
7393
- CameraPane.Ymax = spoth;
7394
- }
7395
- info.g.drawArc(boundary.x, boundary.y,
7396
- 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);
73977488 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
7398
- if (CameraPane.Xmin > boundary.x)
7399
- {
7400
- CameraPane.Xmin = boundary.x;
7401
- }
7402
- if (CameraPane.Xmax < boundary.x + boundary.width)
7403
- {
7404
- CameraPane.Xmax = boundary.x + boundary.width;
7405
- }
7406
- if (CameraPane.Ymin > boundary.y)
7407
- {
7408
- CameraPane.Ymin = boundary.y;
7409
- }
7410
- if (CameraPane.Ymax < boundary.y + boundary.height)
7411
- {
7412
- CameraPane.Ymax = boundary.y + boundary.height;
7413
- }
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
+// }
74147505 return;
74157506 }
74167507 }
74177508
7418
- boolean doEditClick0(ClickInfo info, int level)
7509
+ boolean doEditClick0(//ClickInfo clickInfo,
7510
+ int level)
74197511 {
74207512 if (level == 0)
74217513 {
....@@ -7424,10 +7516,10 @@
74247516
74257517 boolean retval = false;
74267518
7427
- startX = info.x;
7428
- startY = info.y;
7519
+ startX = clickInfo.x;
7520
+ startY = clickInfo.y;
74297521
7430
- hitSomething = 0;
7522
+ hitSomething = -1;
74317523 cVector origin = new cVector();
74327524 //LA.xformPos(origin, toParent, origin);
74337525 Rectangle spot = new Rectangle();
....@@ -7435,22 +7527,53 @@
74357527 {
74367528 centerPt = new Point(0, 0);
74377529 }
7438
- calcHotSpot(origin, info, centerPt, spot);
7439
- if (spot.contains(info.x, info.y))
7530
+ calcHotSpot(origin, //info,
7531
+ centerPt, spot);
7532
+ if (spot.contains(clickInfo.x, clickInfo.y))
74407533 {
74417534 hitSomething = hitCenter;
74427535 retval = true;
74437536 }
74447537 spot.translate(32, 0);
7445
- if (spot.contains(info.x, info.y))
7538
+ if (spot.contains(clickInfo.x, clickInfo.y))
74467539 {
74477540 hitSomething = hitRotate;
74487541 retval = true;
74497542 }
74507543 spot.translate(0, 32);
7451
- 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))
74527547 {
74537548 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
+
74547577 retval = true;
74557578 }
74567579
....@@ -7460,7 +7583,7 @@
74607583 }
74617584
74627585 //System.out.println("info.modifiers = " + info.modifiers);
7463
- modified = (info.modifiers & CameraPane.META) != 0;
7586
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
74647587 //System.out.println("modified = " + modified);
74657588 //new Exception().printStackTrace();
74667589 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7488,7 +7611,8 @@
74887611 return true;
74897612 }
74907613
7491
- void doEditDrag0(ClickInfo info)
7614
+ void doEditDrag0(//ClickInfo info,
7615
+ boolean opposite)
74927616 {
74937617 if (hitSomething == 0)
74947618 {
....@@ -7502,7 +7626,8 @@
75027626
75037627 //System.out.println("hitSomething = " + hitSomething);
75047628
7505
- double scale = 0.005f * info.camera.Distance();
7629
+ double scale = 0.005f * clickInfo.camera.Distance();
7630
+
75067631 cVector xlate = new cVector();
75077632 //cVector xlate2 = new cVector();
75087633 switch (hitSomething)
....@@ -7513,9 +7638,9 @@
75137638
75147639 case hitCenter: // Translate
75157640
7516
- scale *= 0.05f * info.pane.theRenderer.renderCamera.Distance();
7641
+ scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
75177642
7518
- if (modified)
7643
+ if (modified || opposite)
75197644 {
75207645 //assert(false);
75217646 /*
....@@ -7535,8 +7660,8 @@
75357660 toParent[3][i] = xlate.get(i);
75367661 LA.matInvert(toParent, fromParent);
75377662 */
7538
- cVector delta = LA.newVector(0, 0, startY - info.y);
7539
- 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);
75407665
75417666 LA.matCopy(startMat, toParent);
75427667 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7545,7 +7670,7 @@
75457670 } else
75467671 {
75477672 //LA.xformDir(delta, info.camera.fromScreen, delta);
7548
- cVector up = new cVector(info.camera.up);
7673
+ cVector up = new cVector(clickInfo.camera.up);
75497674 cVector away = new cVector();
75507675 //cVector right2 = new cVector();
75517676 //LA.vecCross(up, cVector.Z, right);
....@@ -7561,20 +7686,20 @@
75617686 }
75627687 LA.xformDir(up, ClickInfo.matbuffer, up);
75637688 // if (!CameraPane.LOCALTRANSFORM)
7564
- LA.xformDir(up, info.pane.theRenderer.renderCamera.toScreen, up);
7565
- 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);
75667691 // if (!CameraPane.LOCALTRANSFORM)
7567
- LA.xformDir(away, info.pane.theRenderer.renderCamera.toScreen, away);
7692
+ LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
75687693 //LA.vecCross(up, cVector.Z, right2);
75697694
7570
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7695
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
75717696
75727697 //System.out.println("DELTA0 = " + delta);
75737698 //System.out.println("AWAY = " + info.camera.away);
75747699 //System.out.println("UP = " + info.camera.up);
75757700 if (away.z > 0)
75767701 {
7577
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7702
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
75787703 {
75797704 delta.x = -delta.x;
75807705 } else
....@@ -7589,7 +7714,7 @@
75897714 //System.out.println("DELTA1 = " + delta);
75907715 LA.xformDir(delta, ClickInfo.matbuffer, delta);
75917716 //System.out.println("DELTA2 = " + delta);
7592
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7717
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
75937718 LA.matCopy(startMat, toParent);
75947719 //System.out.println("DELTA3 = " + delta);
75957720 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7599,8 +7724,8 @@
75997724 break;
76007725
76017726 case hitRotate: // rotate
7602
- int dx = info.x - centerPt.x;
7603
- int dy = -(info.y - centerPt.y);
7727
+ int dx = clickInfo.x - centerPt.x;
7728
+ int dy = -(clickInfo.y - centerPt.y);
76047729 double angle = (double) Math.atan2(dx, dy);
76057730 angle = -(1.570796 - angle);
76067731
....@@ -7609,6 +7734,7 @@
76097734
76107735 if (modified)
76117736 {
7737
+ // Rotate 90 degrees
76127738 angle /= (Math.PI / 4);
76137739 angle = Math.floor(angle + 0.5);
76147740 angle *= (Math.PI / 4);
....@@ -7622,7 +7748,7 @@
76227748 }
76237749 /**/
76247750
7625
- switch (info.pane.renderCamera.viewCode)
7751
+ switch (clickInfo.pane.RenderCamera().viewCode)
76267752 {
76277753 case 1: // '\001'
76287754 LA.matZRotate(toParent, angle);
....@@ -7649,26 +7775,30 @@
76497775 break;
76507776
76517777 case hitScale: // scale
7652
- 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);
76537785 if (hScale < 0.01)
76547786 {
7655
- hScale = 0.01;
7787
+ //hScale = 0.01;
76567788 }
7657
- hScale = Math.pow(hScale, scale * 50);
7658
- if (hScale < 0.01)
7789
+
7790
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
7791
+ sign = 1;
7792
+ if (vScale < 0)
76597793 {
7660
- hScale = 0.01;
7794
+ sign = -1;
76617795 }
7662
- double vScale = (double) (info.y - centerPt.y) / 32;
7796
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
76637797 if (vScale < 0.01)
76647798 {
7665
- vScale = 0.01;
7799
+ //vScale = 0.01;
76667800 }
7667
- vScale = Math.pow(vScale, scale * 50);
7668
- if (vScale < 0.01)
7669
- {
7670
- vScale = 0.01;
7671
- }
7801
+
76727802 LA.matCopy(startMat, toParent);
76737803 /**/
76747804 for (int i = 0; i < 3; i++)
....@@ -7678,39 +7808,56 @@
76787808 }
76797809 /**/
76807810
7681
- 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)
76827819 {
76837820 case 3: // '\001'
7684
- if (modified)
7821
+ if (modified || opposite)
76857822 {
7823
+ if (modified && opposite)
7824
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7825
+ else
76867826 //LA.matScale(toParent, 1, hScale, vScale);
7687
- LA.matScale(toParent, vScale, 1, 1);
7827
+ LA.matScale(toParent, totalScale, 1, 1);
76887828 } // vScale, 1);
76897829 else
76907830 {
7691
- LA.matScale(toParent, vScale, vScale, vScale);
7831
+ // EXCEPTION!
7832
+ LA.matScale(toParent, 1, totalScale, totalScale);
76927833 } // vScale, 1);
76937834 break;
76947835
76957836 case 2: // '\002'
7696
- if (modified)
7837
+ if (modified || opposite)
76977838 {
7698
- //LA.matScale(toParent, hScale, 1, vScale);
7699
- 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);
77007844 } else
77017845 {
7702
- LA.matScale(toParent, vScale, 1, vScale);
7846
+ LA.matScale(toParent, totalScale, 1, totalScale);
77037847 }
77047848 break;
77057849
77067850 case 1: // '\003'
7707
- if (modified)
7851
+ if (modified || opposite)
77087852 {
7709
- //LA.matScale(toParent, hScale, vScale, 1);
7710
- 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);
77117858 } else
77127859 {
7713
- LA.matScale(toParent, vScale, vScale, 1);
7860
+ LA.matScale(toParent, totalScale, totalScale, 1);
77147861 }
77157862 break;
77167863 }
....@@ -7731,7 +7878,7 @@
77317878 if (parent == null)
77327879 {
77337880 System.out.println("NULL PARENT");
7734
- new Exception().printStackTrace();
7881
+ //new Exception().printStackTrace();
77357882 } else
77367883 {
77377884 if (parent instanceof BezierPatch)
....@@ -7744,7 +7891,7 @@
77447891 } // NEW ...
77457892
77467893
7747
- info.pane.repaint();
7894
+ clickInfo.pane.repaint();
77487895 }
77497896
77507897 boolean overflow = false;
....@@ -7843,14 +7990,22 @@
78437990 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
78447991 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
78457992 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7993
+
7994
+ String objname;
7995
+
78467996 if (false) //parent != null)
78477997 {
7848
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7998
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
78497999 } else
78508000 {
7851
- 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) ":"") */ "";
78528002 } // + super.toString();
78538003 //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);
78548009 }
78558010
78568011 public int hashCode()
....@@ -7906,6 +8061,7 @@
79068061 objectUI.closeUI();
79078062 if (editWindow != null)
79088063 {
8064
+ editWindow.ctrlPanel.FlushUI();
79098065 editWindow.refreshContents();
79108066 } // ? new
79118067 objectUI = null;
....@@ -7914,6 +8070,10 @@
79148070 {
79158071 editWindow = null;
79168072 } // ?
8073
+ }
8074
+ else
8075
+ {
8076
+ //editWindow.closeUI();
79178077 }
79188078 }
79198079
....@@ -7926,7 +8086,7 @@
79268086 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
79278087
79288088 Object3D /*Composite*/ parent;
7929
- Object3D /*Composite*/ fileparent;
8089
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
79308090
79318091 double[][] toParent; // dynamic matrix
79328092 double[][] fromParent;
....@@ -8041,7 +8201,7 @@
80418201 {
80428202 assert(bRep != null);
80438203 if (!(support instanceof GenericJoint)) // support.bRep != null)
8044
- GraphreeD.Assert(support.bRep == bRep.support);
8204
+ Grafreed.Assert(support.bRep == bRep.support);
80458205 }
80468206 else
80478207 {
....@@ -8072,6 +8232,10 @@
80728232 }
80738233
80748234 transient ObjEditor editWindow;
8235
+ transient ObjEditor manipWindow;
8236
+
8237
+ transient boolean pinned;
8238
+
80758239 transient ObjectUI objectUI;
80768240 public static int povDepth = 0;
80778241 private static cVector tbMin = new cVector();
....@@ -8090,9 +8254,9 @@
80908254 private static cVector edge2 = new cVector();
80918255 //private static cVector norm = new cVector();
80928256 /*transient private*/ int hitSomething;
8093
- private static final int hitCenter = 1;
8094
- private static final int hitScale = 2;
8095
- private static final int hitRotate = 3;
8257
+ static final int hitCenter = 1;
8258
+ static final int hitScale = 2;
8259
+ static final int hitRotate = 3;
80968260 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
80978261 /*transient*/ private Point centerPt;
80988262 /*transient*/ private int startX;
....@@ -8124,6 +8288,8 @@
81248288 {
81258289 Object3D targ = this;
81268290
8291
+ targ.NORMALPUSH = obj.NORMALPUSH;
8292
+
81278293 if (obj.material != null)
81288294 {
81298295 if ((mask&MATERIAL)!=0) // ==(COLOR|MATERIAL))