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 GrafreeD.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) GrafreeD.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) GrafreeD.clone(bRep);
1915
+ o.bRep = (BoundaryRep) Grafreed.clone(bRep);
17181916 o.CreateMaterial();
17191917 //o.overwriteThis(this, -1);
17201918 o.SetAttributes(this, -1);
....@@ -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) GrafreeD.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 (GrafreeD.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 (GrafreeD.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 (GrafreeD.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,55 +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.options4[0] = material.cameralight/0.2f;
5523
- display.options4[1] = material.subsurface;
5524
- display.options4[2] = material.sheen;
5525
-
5526
- // if (display.CURRENTANTIALIAS > 0)
5527
- // display.options3[3] /= 4;
5528
-
5529
- /*
5530
- System.out.println("Focus = " + display.options1[0]);
5531
- System.out.println("Aperture = " + display.options1[1]);
5532
- System.out.println("ShadowBlur = " + display.options1[2]);
5533
- System.out.println("Antialiasing = " + display.options1[3]);
5534
- System.out.println("Fog = " + display.options2[0]);
5535
- System.out.println("Intensity = " + display.options2[1]);
5536
- System.out.println("Elevation = " + display.options2[2]);
5537
- /**/
5538
- } else
5539
- {
5540
- material.Draw(display, selected);
5541
- }
5542
- } else
5543
- {
5544
- if (selected && CameraPane.flash)
5545
- {
5546
- display.modelParams4[1] = 100;
5547
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
5548
- }
5549
- }
6140
+ display.PushMaterial(this, selected);
55506141
55516142 //System.out.println("call list " + list);
55526143 //System.out.println();
....@@ -5565,7 +6156,28 @@
55656156 tex = GetTextures();
55666157 }
55676158
5568
- 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
+ }
55696181
55706182 if (!compiled)
55716183 {
....@@ -5581,30 +6193,19 @@
55816193
55826194 // System.err.println("glCallList: " + bRep.displaylist + " for " + this);
55836195 assert(bRep.displaylist != 0);
5584
- gl.glCallList(bRep.displaylist);
6196
+ display.CallList(bRep.displaylist);
55856197 // june 2013 drawSelf(display, root, selected);
55866198 }
55876199 }
55886200 }
55896201
5590
- display.ReleaseTextures(tex);
5591
-
5592
- //if (parent != null && parent.GetMaterial() != null)
5593
- // parent.GetMaterial().Draw(display, parent.IsSelected(this));
5594
- if (material != null)
5595
- {
5596
- materialdepth -= 1;
5597
- if (materialdepth > 0)
5598
- {
5599
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
5600
- materialstack[materialdepth - 1].Draw(display, selectedstack[materialdepth - 1]);
5601
- }
5602
- //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
5603
- } else if (selected && CameraPane.flash && GetMaterial() != null)
5604
- {
5605
- display.modelParams4[1] = GetMaterial().cameralight;
5606
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
5607
- }
6202
+ if (!failedBump)
6203
+ display.ReleaseBumpTexture(tex);
6204
+
6205
+ if (!failedPigment)
6206
+ display.ReleasePigmentTexture(tex);
6207
+
6208
+ display.PopMaterial(this, selected);
56086209 }
56096210
56106211 if (this instanceof Texture || this instanceof TextureNode)
....@@ -5646,7 +6247,7 @@
56466247 // resetMasterNode();
56476248 }
56486249
5649
- void CallList(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
6250
+ void CallList(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
56506251 {
56516252 if (GetBRep() == null)
56526253 {
....@@ -5729,8 +6330,11 @@
57296330 boolean flipV = false; // true;
57306331 int texres = 0; // 0 = low, 1 = normal, 2 = high res texture
57316332
5732
- void drawSelf(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
6333
+ void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57336334 {
6335
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6336
+ return;
6337
+
57346338 if (hide)
57356339 return;
57366340 // shadow optimisation
....@@ -5788,16 +6392,7 @@
57886392 // // ??????????????????????????? Touch();
57896393 // }
57906394
5791
- if (material != null)
5792
- {
5793
- materialstack[materialdepth] = material;
5794
- selectedstack[materialdepth] = selected;
5795
- cStatic.objectstack[materialdepth++] = this;
5796
- //System.out.println("material " + material);
5797
- //Applet3D.tracein("selected ", selected);
5798
- display.vector2buffer = projectedVertices;
5799
- material.Draw(display, selected);
5800
- }
6395
+display.PushMaterial2(this, selected);
58016396
58026397 Object3D child;
58036398 boolean sel;
....@@ -5849,19 +6444,7 @@
58496444 */
58506445 //depth += 1;
58516446
5852
- if (material != null)
5853
- {
5854
- materialdepth -= 1;
5855
- if (materialdepth > 0)
5856
- {
5857
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
5858
- materialstack[materialdepth - 1].Draw(display, selectedstack[materialdepth - 1]);
5859
- }
5860
- //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
5861
- //else
5862
- //material.Draw(display, false);
5863
- }
5864
-
6447
+display.PopMaterial2(this);
58656448 /*
58666449 display.ReleaseTextures(tex);
58676450 */
....@@ -5872,10 +6455,13 @@
58726455
58736456 //static cVector min,max;
58746457
5875
- void DrawNode(CameraPane display, Object3D /*Composite*/ root, boolean selected)
6458
+ void DrawNode(iCameraPane display, Object3D /*Composite*/ root, boolean selected)
58766459 {
5877
- 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)
58786461 return; // no shadow for transparent objects
6462
+
6463
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6464
+ return;
58796465
58806466 if (hide)
58816467 return;
....@@ -5917,11 +6503,12 @@
59176503 return;
59186504 }
59196505
6506
+ //bRep.GenUV(1/material.diffuseness);
59206507 // bRep.lock = true;
59216508
5922
- javax.media.opengl.GL gl = display.GetGL();
6509
+ //javax.media.opengl.GL gl = display.GetGL();
59236510
5924
- if (CameraPane.BOXMODE) // || CameraPane.movingcamera)
6511
+ if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera)
59256512 {
59266513 int fc = bRep.FaceCount();
59276514 int vc = bRep.VertexCount();
....@@ -5936,23 +6523,7 @@
59366523
59376524 bRep.getMinMax(min, max, 100);
59386525
5939
- gl.glBegin(gl.GL_LINES);
5940
-
5941
- gl.glVertex3d(min.x, min.y, min.z);
5942
- gl.glVertex3d(min.x, min.y, max.z);
5943
- gl.glVertex3d(min.x, min.y, min.z);
5944
- gl.glVertex3d(min.x, max.y, min.z);
5945
- gl.glVertex3d(min.x, min.y, min.z);
5946
- gl.glVertex3d(max.x, min.y, min.z);
5947
-
5948
- gl.glVertex3d(max.x, max.y, max.z);
5949
- gl.glVertex3d(min.x, max.y, max.z);
5950
- gl.glVertex3d(max.x, max.y, max.z);
5951
- gl.glVertex3d(max.x, min.y, max.z);
5952
- gl.glVertex3d(max.x, max.y, max.z);
5953
- gl.glVertex3d(max.x, max.y, min.z);
5954
-
5955
- gl.glEnd();
6526
+ display.DrawBox(min, max);
59566527
59576528 return;
59586529 }
....@@ -5996,7 +6567,7 @@
59966567 {
59976568 //throw new Error();
59986569
5999
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
6570
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
60006571
60016572 int[] strips = bRep.getRawIndices();
60026573
....@@ -6006,178 +6577,19 @@
60066577 new Exception().printStackTrace();
60076578 return;
60086579 }
6009
-
6010
- // TRIANGLE STRIP ARRAY
6011
- if (bRep.trimmed)
6580
+
6581
+ if (dontselect)
60126582 {
6013
- float[] v = bRep.getRawVertices();
6014
- float[] n = bRep.getRawNormals();
6015
- float[] c = bRep.getRawColors();
6016
- float[] uv = bRep.getRawUVMap();
6017
-
6018
- int count2 = 0;
6019
- int count3 = 0;
6020
-
6021
- if (n.length > 0)
6022
- {
6023
- for (int i = 0; i < strips.length; i++)
6024
- {
6025
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6026
-
6027
- /*
6028
- boolean locked = false;
6029
- float eps = 0.1f;
6030
- boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
6031
-
6032
- int dot = 0;
6033
-
6034
- if ((dot&1) == 0)
6035
- dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
6036
-
6037
- if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
6038
- gl.glTexCoord2f((float) qv.s, (float) qv.t);
6039
- else
6040
- {
6041
- locked = true;
6042
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6043
- }
6044
- //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6045
- gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
6046
- if (hasnorm)
6047
- {
6048
- //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6049
- gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
6050
- }
6051
-
6052
- if ((dot&4) == 0)
6053
- dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
6054
-
6055
- if (wrap || !locked && (dot&8) != 0)
6056
- gl.glTexCoord2f((float) rv.s, (float) rv.t);
6057
- else
6058
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6059
-
6060
- f.dot = dot;
6061
- */
6062
-
6063
- if (!selectmode)
6064
- {
6065
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6066
- {
6067
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6068
- } else
6069
- {
6070
- gl.glNormal3f(0, 0, 1);
6071
- }
6072
-
6073
- if (c != null)
6074
- //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]);
6075
- {
6076
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6077
- }
6078
- }
6079
- if (flipV)
6080
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6081
- else
6082
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6083
- //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6084
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6085
-
6086
- count2 += 2;
6087
- count3 += 3;
6088
- if (!selectmode)
6089
- {
6090
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6091
- {
6092
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6093
- } else
6094
- {
6095
- gl.glNormal3f(0, 0, 1);
6096
- }
6097
- if (c != null)
6098
- {
6099
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6100
- }
6101
- }
6102
- if (flipV)
6103
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6104
- else
6105
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6106
- //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6107
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6108
-
6109
- count2 += 2;
6110
- count3 += 3;
6111
- for (int j = 0; j < strips[i] - 2; j++)
6112
- {
6113
- //gl.glTexCoord2d(...);
6114
- if (!selectmode)
6115
- {
6116
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6117
- {
6118
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6119
- } else
6120
- {
6121
- gl.glNormal3f(0, 0, 1);
6122
- }
6123
- if (c != null)
6124
- {
6125
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6126
- }
6127
- }
6128
-
6129
- if (flipV)
6130
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6131
- else
6132
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6133
- //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
6134
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6135
- count2 += 2;
6136
- count3 += 3;
6137
- }
6138
-
6139
- gl.glEnd();
6140
- }
6141
- }
6142
-
6143
- assert count3 == v.length;
6583
+ //bRep.GenerateNormalsMINE();
61446584 }
6145
- else // !trimmed
6146
- {
6147
- int count = 0;
6148
- for (int i = 0; i < strips.length; i++)
6149
- {
6150
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6151
-
6152
- Vertex p = bRep.GetVertex(bRep.indices[count++]);
6153
- Vertex q = bRep.GetVertex(bRep.indices[count++]);
6154
-
6155
- drawVertex(gl, p, selectmode);
6156
- drawVertex(gl, q, selectmode);
6157
-
6158
- for (int j = 0; j < strips[i] - 2; j++)
6159
- {
6160
- Vertex r = bRep.GetVertex(bRep.indices[count++]);
6161
-
6162
-// if (j%2 == 0)
6163
-// drawFace(p, q, r, display, null);
6164
-// else
6165
-// drawFace(p, r, q, display, null);
6166
-
6167
-// p = q;
6168
-// q = r;
6169
- drawVertex(gl, r, selectmode);
6170
- }
6171
-
6172
- gl.glEnd();
6173
- }
6174
- }
6585
+
6586
+ display.DrawGeometry(bRep, flipV, selectmode);
61756587 } else // catch (Error e)
61766588 {
61776589 // TRIANGLE ARRAY
61786590 if (IsOpaque()) // Static())
61796591 {
6180
- gl.glBegin(gl.GL_TRIANGLES);
6592
+ display.StartTriangles();
61816593 int facecount = bRep.FaceCount();
61826594 for (int i = 0; i < facecount; i++)
61836595 {
....@@ -6240,9 +6652,9 @@
62406652 // // r.norm.dot(v3) > -0.5)
62416653 // // continue;
62426654
6243
- drawFace(p, q, r, display, face);
6655
+ display.DrawFace(this, p, q, r, face);
62446656 }
6245
- gl.glEnd();
6657
+ display.EndTriangles();
62466658 }
62476659 else
62486660 {
....@@ -6271,8 +6683,8 @@
62716683 //System.out.println("SORT");
62726684
62736685 java.util.Arrays.sort(facescompare);
6274
-
6275
- gl.glBegin(gl.GL_TRIANGLES);
6686
+
6687
+ display.StartTriangles();
62766688 for (int i = 0; i < facecount; i++)
62776689 {
62786690 Face face = bRep.GetFace(facescompare[i].index);
....@@ -6284,13 +6696,14 @@
62846696 Vertex q = bRep.GetVertex(face.q);
62856697 Vertex r = bRep.GetVertex(face.r);
62866698
6287
- drawFace(p, q, r, display, face);
6699
+ display.DrawFace(this, p, q, r, face);
62886700 }
6289
- gl.glEnd();
6701
+ display.EndTriangles();
62906702 }
62916703
62926704 if (false) // live && support != null && support.bRep != null) // debug weights
62936705 {
6706
+ /*
62946707 gl.glDisable(gl.GL_LIGHTING);
62956708 float[] colorV = new float[3];
62966709
....@@ -6369,6 +6782,7 @@
63696782 // gl.glEnd();
63706783 }
63716784 }
6785
+ */
63726786 }
63736787 }
63746788
....@@ -6413,7 +6827,7 @@
64136827 center.add(r);
64146828 center.mul(1.0/3);
64156829
6416
- center.sub(CameraPane.theRenderer.eyeCamera.location);
6830
+ center.sub(Globals.theRenderer.EyeCamera().location);
64176831
64186832 distance = center.dot(center);
64196833 }
....@@ -6424,347 +6838,11 @@
64246838
64256839 transient FaceCompare[] facescompare = null;
64266840
6427
- void SetColor(CameraPane display, Vertex p0)
6428
- {
6429
- if (display.RENDERPROGRAM == 0)
6430
- {
6431
- float r = 0;
6432
- if (bRep != null)
6433
- {
6434
- if (bRep.stripified)
6435
- {
6436
- r = 1;
6437
- }
6438
- }
6439
- float g = 0;
6440
- if (bRep != null)
6441
- {
6442
- if (bRep.trimmed)
6443
- {
6444
- g = 1;
6445
- }
6446
- }
6447
- float b = 0;
6448
- if (support != null && link2master)
6449
- {
6450
- b = 1;
6451
- }
6452
- display.GetGL().glColor3f(r*p0.AO, g*p0.AO, b*p0.AO);
6453
- return;
6454
- }
6455
-
6456
- if (display.drawMode != CameraPane.SHADOW)
6457
- return;
6458
-
6459
- javax.media.opengl.GL gl = display.GetGL();
6460
-// if (true) return;
6461
-// float ao = p.AO;
6462
-//
6463
-// // if (ao == 0 && !bRep.AOdone) // transient problem!
6464
-// // ao = 1;
6465
-//
6466
-// gl.glColor4f(ao, ao, ao, 1);
6467
-
6468
-// CameraPane.selectedpoint.
6469
-// getAverage(cStatic.point1, true);
6470
- if (CameraPane.pointflow == null) // !random) // live)
6471
- {
6472
- return;
6473
- }
6474
-
6475
- cStatic.point1.set(0,0,0);
6476
- LA.xformPos(cStatic.point1, CameraPane.selectedpoint.toParent, cStatic.point1);
6477
-
6478
- cStatic.point1.sub(p0);
6479
-
6480
-
6481
-// if (marked && (p0.vertexlinks == null || support == null || support.bRep == null)) // no position delta?
6482
-// {
6483
-// return;
6484
-// }
6485
-
6486
- //if (true)
6487
- if (cStatic.point1.dot(cStatic.point1) > 0.000001)
6488
- {
6489
- return;
6490
- }
6491
-
6492
- float[] colorV = new float[3];
6493
-
6494
- if (false) // marked)
6495
- {
6496
- // debug rigging weights
6497
- for (int object = 0; object < p0.vertexlinks.length; object++)
6498
- {
6499
- float weight = p0.weights[object] / p0.totalweight;
6500
-
6501
- // if (weight < 0.1)
6502
- // {
6503
- // assert(weight == 0);
6504
- // continue;
6505
- // }
6506
-
6507
- if (p0.vertexlinks[object] == -1)
6508
- continue;
6509
-
6510
- Vertex q = support.bRep.GetVertex(p0.vertexlinks[object]);
6511
-
6512
- int color = //1 << object; //
6513
- //p.vertexlinks.length;
6514
- support.bRep.supports[p0.closestsupport].links[object];
6515
- colorV[2] += (color & 1) * weight;
6516
- colorV[1] += ((color & 2) >> 1) * weight;
6517
- colorV[0] += ((color & 4) >> 2) * weight;
6518
- }
6519
- }
6520
- else
6521
- {
6522
- if (drawingstarted)
6523
- {
6524
- // find next point
6525
- if (bRep.GetVertex(0).faceindices == null)
6526
- {
6527
- bRep.InitFaceIndices();
6528
- }
6529
-
6530
- double ymin = p0.y;
6531
-
6532
- Vertex newp = p0;
6533
-
6534
- for (int fii = 0; fii < p0.faceindices.length; fii++)
6535
- {
6536
- int fi = p0.faceindices[fii];
6537
-
6538
- if (fi == -1)
6539
- break;
6540
-
6541
- Face f = bRep.GetFace(fi);
6542
-
6543
- Vertex p = bRep.GetVertex(f.p);
6544
- Vertex q = bRep.GetVertex(f.q);
6545
- Vertex r = bRep.GetVertex(f.r);
6546
-
6547
- int swap = (int)(Math.random()*3);
6548
-
6549
-// for (int s=swap; --s>=0;)
6550
-// {
6551
-// Vertex t = p;
6552
-// p = q;
6553
-// q = r;
6554
-// r = t;
6555
-// }
6556
- if (ymin > p.y)
6557
- {
6558
- ymin = p.y;
6559
- newp = p;
6560
-// break;
6561
- }
6562
- if (ymin > q.y)
6563
- {
6564
- ymin = q.y;
6565
- newp = q;
6566
-// break;
6567
- }
6568
- if (ymin > r.y)
6569
- {
6570
- ymin = r.y;
6571
- newp = r;
6572
-// break;
6573
- }
6574
- }
6575
-
6576
- CameraPane.selectedpoint.toParent[3][0] = newp.x;
6577
- CameraPane.selectedpoint.toParent[3][1] = newp.y;
6578
- CameraPane.selectedpoint.toParent[3][2] = newp.z;
6579
-
6580
- drawingstarted = false;
6581
-
6582
- // return;
6583
- }
6584
-
6585
- if (false) // CameraPane.DRAW
6586
- {
6587
- p0.AO = colorV[0] = 2;
6588
- colorV[1] = 2;
6589
- colorV[2] = 2;
6590
- }
6591
-
6592
- CameraPane.pointflow.add(p0);
6593
- CameraPane.pointflow.Touch();
6594
- }
6595
-
6596
-// gl.glColor3f(colorV[0], colorV[1], colorV[2]);
6597
-// gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0);
6598
-// gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
6599
- }
6600
-
66016841 void Print(Vertex v)
66026842 {
66036843 //System.err.println("(" + v.x + ", " + v.y + ", " + v.z + ")");
66046844 }
66056845
6606
- void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean selectmode)
6607
- {
6608
- if (!selectmode)
6609
- {
6610
- gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
6611
- gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
6612
-
6613
- if (flipV)
6614
- gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
6615
- else
6616
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6617
- }
6618
-
6619
- gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
6620
- }
6621
-
6622
- void drawFace(Vertex pv, Vertex qv, Vertex rv,
6623
- CameraPane display, Face face)
6624
- {
6625
- if (pv.y == -10000 ||
6626
- qv.y == -10000 ||
6627
- rv.y == -10000)
6628
- return;
6629
-
6630
-// float b = f.nbiterations & 1;
6631
-// float g = (f.nbiterations>>1) & 1;
6632
-// float r = (f.nbiterations>>2) & 1;
6633
-//
6634
-// //if (f.weight == 10000)
6635
-// //{
6636
-// // r = 1; g = b = 0;
6637
-// //}
6638
-// //else
6639
-// //{
6640
-// // assert(f.weight < 10000);
6641
-// r = g = b = (float)bRep.FaceWeight(f)*100;
6642
-// if (r<0)
6643
-// assert(r>=0);
6644
-// //}
6645
-
6646
- javax.media.opengl.GL gl = display.GetGL();
6647
-
6648
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
6649
-
6650
- //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv);
6651
- if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
6652
- {
6653
- //gl.glBegin(gl.GL_TRIANGLES);
6654
- boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
6655
- if (!hasnorm)
6656
- {
6657
- // System.out.println("FUCK!!");
6658
- LA.vecSub(pv/*.pos*/, qv/*.pos*/, v0);
6659
- LA.vecSub(pv/*.pos*/, rv/*.pos*/, v1);
6660
- LA.vecCross(v0, v1, v2);
6661
- LA.vecNormalize(v2);
6662
- gl.glNormal3f((float) v2.x, (float) v2.y, (float) v2.z);
6663
- }
6664
-
6665
- if (hasnorm)
6666
- {
6667
-// if (!pv.norm.normalized())
6668
-// assert(pv.norm.normalized());
6669
-
6670
- //System.out.println("normalp = " + pv.norm.x + ", " + pv.norm.y + ", " + pv.norm.z);
6671
- gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
6672
- }
6673
- gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
6674
- SetColor(display, pv);
6675
- //gl.glColor4f(r, g, b, 1);
6676
- //gl.glColor4f(pv.boundary, pv.boundary, pv.boundary, 1);
6677
- if (flipV)
6678
- gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
6679
- else
6680
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6681
- //System.out.println("vertexp = " + pv.x + ", " + pv.y + ", " + pv.z);
6682
- gl.glVertex3f((float) pv./*pos.*/x, (float) pv./*pos.*/y, (float) pv./*pos.*/z);
6683
-// Print(pv);
6684
- if (hasnorm)
6685
- {
6686
-// assert(qv.norm.normalized());
6687
- //System.out.println("normalq = " + qv.norm.x + ", " + qv.norm.y + ", " + qv.norm.z);
6688
- gl.glNormal3f((float) qv.norm.x, (float) qv.norm.y, (float) qv.norm.z);
6689
- }
6690
- //System.out.println("vertexq = " + qv.s + ", " + qv.t);
6691
- // boolean locked = false;
6692
- // float eps = 0.1f;
6693
- // boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
6694
-
6695
- // int dot = 0; //*/ (int)f.dot;
6696
-
6697
- // if ((dot&1) == 0)
6698
- // dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
6699
-
6700
- // if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
6701
- if (flipV)
6702
- gl.glTexCoord2f((float) qv.s, 1-(float) qv.t);
6703
- else
6704
- gl.glTexCoord2f((float) qv.s, (float) qv.t);
6705
- // else
6706
- // {
6707
- // locked = true;
6708
- // gl.glTexCoord2f((float) pv.s, (float) pv.t);
6709
- // }
6710
- gl.glColor4f(qv.AO, qv.AO, qv.AO, 1);
6711
- SetColor(display, qv);
6712
- //gl.glColor4f(r, g, b, 1);
6713
- //gl.glColor4f(qv.boundary, qv.boundary, qv.boundary, 1);
6714
- //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6715
- gl.glVertex3f((float) qv./*pos.*/x, (float) qv./*pos.*/y, (float) qv./*pos.*/z);
6716
-// Print(qv);
6717
- if (hasnorm)
6718
- {
6719
-// assert(rv.norm.normalized());
6720
- //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6721
- gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
6722
- }
6723
-
6724
- // if ((dot&4) == 0)
6725
- // dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
6726
-
6727
- // if (wrap || !locked && (dot&8) != 0)
6728
- if (flipV)
6729
- gl.glTexCoord2f((float) rv.s, 1-(float) rv.t);
6730
- else
6731
- gl.glTexCoord2f((float) rv.s, (float) rv.t);
6732
- // else
6733
- // gl.glTexCoord2f((float) pv.s, (float) pv.t);
6734
-
6735
- // f.dot = dot;
6736
-
6737
- gl.glColor4f(rv.AO, rv.AO, rv.AO, 1);
6738
- SetColor(display, rv);
6739
- //gl.glColor4f(r, g, b, 1);
6740
- //gl.glColor4f(rv.boundary, rv.boundary, rv.boundary, 1);
6741
- //System.out.println("vertexr = " + rv.x + ", " + rv.y + ", " + rv.z);
6742
- gl.glVertex3f((float) rv./*pos.*/x, (float) rv./*pos.*/y, (float) rv./*pos.*/z);
6743
-// Print(rv);
6744
- //gl.glEnd();
6745
- }
6746
- else
6747
- {
6748
- gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
6749
- gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
6750
- gl.glVertex3f((float) rv.x, (float) rv.y, (float) rv.z);
6751
-
6752
- }
6753
-
6754
- if (false) // (attributes & WIREFRAME) != 0)
6755
- {
6756
- gl.glDisable(gl.GL_LIGHTING);
6757
-
6758
- gl.glBegin(gl.GL_LINE_LOOP);
6759
- gl.glVertex3d(pv./*pos.*/x, pv./*pos.*/y, pv./*pos.*/z);
6760
- gl.glVertex3d(qv./*pos.*/x, qv./*pos.*/y, qv./*pos.*/z);
6761
- gl.glVertex3d(rv./*pos.*/x, rv./*pos.*/y, rv./*pos.*/z);
6762
- gl.glEnd();
6763
-
6764
- gl.glEnable(gl.GL_LIGHTING);
6765
- }
6766
- }
6767
-
67686846 void drawSelf(ClickInfo info, int level, boolean select)
67696847 {
67706848 if (bRep == null)
....@@ -7288,20 +7366,23 @@
72887366 }
72897367 }
72907368
7291
- 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)
72927373 {
7293
- int hc = info.bounds.x + info.bounds.width / 2;
7294
- int vc = info.bounds.y + info.bounds.height / 2;
7295
- 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;
72967377 if (toscreen == null)
72977378 {
7298
- toscreen = new Camera(info.camera.viewCode).toScreen;
7379
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
72997380 }
73007381 cVector vec = in;
73017382 LA.xformPos(in, toscreen, in);
73027383 //System.out.println("Distance = " + info.camera.Distance());
7303
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
7304
- 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();
73057386 outPt.x = hc + (int) vec.x;
73067387 outPt.y = vc - (int) vec.y;
73077388 outRec.x = outPt.x - 3;
....@@ -7309,15 +7390,18 @@
73097390 outRec.width = outRec.height = 6;
73107391 }
73117392
7312
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7393
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7394
+ )
73137395 {
73147396 Point pt = new Point(0, 0);
73157397 Rectangle rec = new Rectangle();
7316
- calcHotSpot(in, info, pt, rec);
7398
+ calcHotSpot(in, //clickInfo,
7399
+ pt, rec);
73177400 return rec;
73187401 }
73197402
7320
- void drawEditHandles0(ClickInfo info, int level)
7403
+ void drawEditHandles0(//ClickInfo clickInfo,
7404
+ int level)
73217405 {
73227406 if (level == 0)
73237407 {
....@@ -7326,98 +7410,104 @@
73267410 {
73277411 cVector origin = new cVector();
73287412 //LA.xformPos(origin, toParent, origin);
7329
- Rectangle spot = calcHotSpot(origin, info);
7413
+ if (this.clickInfo == null)
7414
+ this.clickInfo = new ClickInfo();
7415
+
7416
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
73307417 Rectangle boundary = new Rectangle();
73317418 boundary.x = spot.x - 30;
73327419 boundary.y = spot.y - 30;
73337420 boundary.width = spot.width + 60;
73347421 boundary.height = spot.height + 60;
7335
- info.g.setColor(Color.red);
7422
+ clickInfo.g.setColor(Color.white);
73367423 int spotw = spot.x + spot.width;
73377424 int spoth = spot.y + spot.height;
7338
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7339
- if (CameraPane.Xmin > spot.x)
7340
- {
7341
- CameraPane.Xmin = spot.x;
7342
- }
7343
- if (CameraPane.Xmax < spotw)
7344
- {
7345
- CameraPane.Xmax = spotw;
7346
- }
7347
- if (CameraPane.Ymin > spot.y)
7348
- {
7349
- CameraPane.Ymin = spot.y;
7350
- }
7351
- if (CameraPane.Ymax < spoth)
7352
- {
7353
- CameraPane.Ymax = spoth;
7354
- }
7355
- 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);
73567465 spotw = spot.x + spot.width;
73577466 spoth = spot.y + spot.height;
7358
- info.g.setColor(Color.blue);
7359
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7360
- if (CameraPane.Xmin > spot.x)
7361
- {
7362
- CameraPane.Xmin = spot.x;
7363
- }
7364
- if (CameraPane.Xmax < spotw)
7365
- {
7366
- CameraPane.Xmax = spotw;
7367
- }
7368
- if (CameraPane.Ymin > spot.y)
7369
- {
7370
- CameraPane.Ymin = spot.y;
7371
- }
7372
- if (CameraPane.Ymax < spoth)
7373
- {
7374
- CameraPane.Ymax = spoth;
7375
- }
7376
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7377
- info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7378
- spot.translate(0, -32);
7379
- info.g.setColor(Color.green);
7380
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7381
- if (CameraPane.Xmin > spot.x)
7382
- {
7383
- CameraPane.Xmin = spot.x;
7384
- }
7385
- if (CameraPane.Xmax < spotw)
7386
- {
7387
- CameraPane.Xmax = spotw;
7388
- }
7389
- if (CameraPane.Ymin > spot.y)
7390
- {
7391
- CameraPane.Ymin = spot.y;
7392
- }
7393
- if (CameraPane.Ymax < spoth)
7394
- {
7395
- CameraPane.Ymax = spoth;
7396
- }
7397
- info.g.drawArc(boundary.x, boundary.y,
7398
- 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);
73997488 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
7400
- if (CameraPane.Xmin > boundary.x)
7401
- {
7402
- CameraPane.Xmin = boundary.x;
7403
- }
7404
- if (CameraPane.Xmax < boundary.x + boundary.width)
7405
- {
7406
- CameraPane.Xmax = boundary.x + boundary.width;
7407
- }
7408
- if (CameraPane.Ymin > boundary.y)
7409
- {
7410
- CameraPane.Ymin = boundary.y;
7411
- }
7412
- if (CameraPane.Ymax < boundary.y + boundary.height)
7413
- {
7414
- CameraPane.Ymax = boundary.y + boundary.height;
7415
- }
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
+// }
74167505 return;
74177506 }
74187507 }
74197508
7420
- boolean doEditClick0(ClickInfo info, int level)
7509
+ boolean doEditClick0(//ClickInfo clickInfo,
7510
+ int level)
74217511 {
74227512 if (level == 0)
74237513 {
....@@ -7426,10 +7516,10 @@
74267516
74277517 boolean retval = false;
74287518
7429
- startX = info.x;
7430
- startY = info.y;
7519
+ startX = clickInfo.x;
7520
+ startY = clickInfo.y;
74317521
7432
- hitSomething = 0;
7522
+ hitSomething = -1;
74337523 cVector origin = new cVector();
74347524 //LA.xformPos(origin, toParent, origin);
74357525 Rectangle spot = new Rectangle();
....@@ -7437,22 +7527,53 @@
74377527 {
74387528 centerPt = new Point(0, 0);
74397529 }
7440
- calcHotSpot(origin, info, centerPt, spot);
7441
- if (spot.contains(info.x, info.y))
7530
+ calcHotSpot(origin, //info,
7531
+ centerPt, spot);
7532
+ if (spot.contains(clickInfo.x, clickInfo.y))
74427533 {
74437534 hitSomething = hitCenter;
74447535 retval = true;
74457536 }
74467537 spot.translate(32, 0);
7447
- if (spot.contains(info.x, info.y))
7538
+ if (spot.contains(clickInfo.x, clickInfo.y))
74487539 {
74497540 hitSomething = hitRotate;
74507541 retval = true;
74517542 }
74527543 spot.translate(0, 32);
7453
- 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))
74547547 {
74557548 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
+
74567577 retval = true;
74577578 }
74587579
....@@ -7462,7 +7583,7 @@
74627583 }
74637584
74647585 //System.out.println("info.modifiers = " + info.modifiers);
7465
- modified = (info.modifiers & CameraPane.META) != 0;
7586
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
74667587 //System.out.println("modified = " + modified);
74677588 //new Exception().printStackTrace();
74687589 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7490,7 +7611,8 @@
74907611 return true;
74917612 }
74927613
7493
- void doEditDrag0(ClickInfo info)
7614
+ void doEditDrag0(//ClickInfo info,
7615
+ boolean opposite)
74947616 {
74957617 if (hitSomething == 0)
74967618 {
....@@ -7504,7 +7626,8 @@
75047626
75057627 //System.out.println("hitSomething = " + hitSomething);
75067628
7507
- double scale = 0.005f * info.camera.Distance();
7629
+ double scale = 0.005f * clickInfo.camera.Distance();
7630
+
75087631 cVector xlate = new cVector();
75097632 //cVector xlate2 = new cVector();
75107633 switch (hitSomething)
....@@ -7515,9 +7638,9 @@
75157638
75167639 case hitCenter: // Translate
75177640
7518
- scale *= 0.05f * info.pane.theRenderer.renderCamera.Distance();
7641
+ scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
75197642
7520
- if (modified)
7643
+ if (modified || opposite)
75217644 {
75227645 //assert(false);
75237646 /*
....@@ -7537,8 +7660,8 @@
75377660 toParent[3][i] = xlate.get(i);
75387661 LA.matInvert(toParent, fromParent);
75397662 */
7540
- cVector delta = LA.newVector(0, 0, startY - info.y);
7541
- 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);
75427665
75437666 LA.matCopy(startMat, toParent);
75447667 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7547,7 +7670,7 @@
75477670 } else
75487671 {
75497672 //LA.xformDir(delta, info.camera.fromScreen, delta);
7550
- cVector up = new cVector(info.camera.up);
7673
+ cVector up = new cVector(clickInfo.camera.up);
75517674 cVector away = new cVector();
75527675 //cVector right2 = new cVector();
75537676 //LA.vecCross(up, cVector.Z, right);
....@@ -7563,20 +7686,20 @@
75637686 }
75647687 LA.xformDir(up, ClickInfo.matbuffer, up);
75657688 // if (!CameraPane.LOCALTRANSFORM)
7566
- LA.xformDir(up, info.pane.theRenderer.renderCamera.toScreen, up);
7567
- 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);
75687691 // if (!CameraPane.LOCALTRANSFORM)
7569
- LA.xformDir(away, info.pane.theRenderer.renderCamera.toScreen, away);
7692
+ LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
75707693 //LA.vecCross(up, cVector.Z, right2);
75717694
7572
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7695
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
75737696
75747697 //System.out.println("DELTA0 = " + delta);
75757698 //System.out.println("AWAY = " + info.camera.away);
75767699 //System.out.println("UP = " + info.camera.up);
75777700 if (away.z > 0)
75787701 {
7579
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7702
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
75807703 {
75817704 delta.x = -delta.x;
75827705 } else
....@@ -7591,7 +7714,7 @@
75917714 //System.out.println("DELTA1 = " + delta);
75927715 LA.xformDir(delta, ClickInfo.matbuffer, delta);
75937716 //System.out.println("DELTA2 = " + delta);
7594
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7717
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
75957718 LA.matCopy(startMat, toParent);
75967719 //System.out.println("DELTA3 = " + delta);
75977720 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7601,8 +7724,8 @@
76017724 break;
76027725
76037726 case hitRotate: // rotate
7604
- int dx = info.x - centerPt.x;
7605
- int dy = -(info.y - centerPt.y);
7727
+ int dx = clickInfo.x - centerPt.x;
7728
+ int dy = -(clickInfo.y - centerPt.y);
76067729 double angle = (double) Math.atan2(dx, dy);
76077730 angle = -(1.570796 - angle);
76087731
....@@ -7611,6 +7734,7 @@
76117734
76127735 if (modified)
76137736 {
7737
+ // Rotate 90 degrees
76147738 angle /= (Math.PI / 4);
76157739 angle = Math.floor(angle + 0.5);
76167740 angle *= (Math.PI / 4);
....@@ -7624,7 +7748,7 @@
76247748 }
76257749 /**/
76267750
7627
- switch (info.pane.renderCamera.viewCode)
7751
+ switch (clickInfo.pane.RenderCamera().viewCode)
76287752 {
76297753 case 1: // '\001'
76307754 LA.matZRotate(toParent, angle);
....@@ -7651,26 +7775,30 @@
76517775 break;
76527776
76537777 case hitScale: // scale
7654
- 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);
76557785 if (hScale < 0.01)
76567786 {
7657
- hScale = 0.01;
7787
+ //hScale = 0.01;
76587788 }
7659
- hScale = Math.pow(hScale, scale * 50);
7660
- if (hScale < 0.01)
7789
+
7790
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
7791
+ sign = 1;
7792
+ if (vScale < 0)
76617793 {
7662
- hScale = 0.01;
7794
+ sign = -1;
76637795 }
7664
- double vScale = (double) (info.y - centerPt.y) / 32;
7796
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
76657797 if (vScale < 0.01)
76667798 {
7667
- vScale = 0.01;
7799
+ //vScale = 0.01;
76687800 }
7669
- vScale = Math.pow(vScale, scale * 50);
7670
- if (vScale < 0.01)
7671
- {
7672
- vScale = 0.01;
7673
- }
7801
+
76747802 LA.matCopy(startMat, toParent);
76757803 /**/
76767804 for (int i = 0; i < 3; i++)
....@@ -7680,39 +7808,56 @@
76807808 }
76817809 /**/
76827810
7683
- 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)
76847819 {
76857820 case 3: // '\001'
7686
- if (modified)
7821
+ if (modified || opposite)
76877822 {
7823
+ if (modified && opposite)
7824
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7825
+ else
76887826 //LA.matScale(toParent, 1, hScale, vScale);
7689
- LA.matScale(toParent, vScale, 1, 1);
7827
+ LA.matScale(toParent, totalScale, 1, 1);
76907828 } // vScale, 1);
76917829 else
76927830 {
7693
- LA.matScale(toParent, vScale, vScale, vScale);
7831
+ // EXCEPTION!
7832
+ LA.matScale(toParent, 1, totalScale, totalScale);
76947833 } // vScale, 1);
76957834 break;
76967835
76977836 case 2: // '\002'
7698
- if (modified)
7837
+ if (modified || opposite)
76997838 {
7700
- //LA.matScale(toParent, hScale, 1, vScale);
7701
- 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);
77027844 } else
77037845 {
7704
- LA.matScale(toParent, vScale, 1, vScale);
7846
+ LA.matScale(toParent, totalScale, 1, totalScale);
77057847 }
77067848 break;
77077849
77087850 case 1: // '\003'
7709
- if (modified)
7851
+ if (modified || opposite)
77107852 {
7711
- //LA.matScale(toParent, hScale, vScale, 1);
7712
- 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);
77137858 } else
77147859 {
7715
- LA.matScale(toParent, vScale, vScale, 1);
7860
+ LA.matScale(toParent, totalScale, totalScale, 1);
77167861 }
77177862 break;
77187863 }
....@@ -7733,7 +7878,7 @@
77337878 if (parent == null)
77347879 {
77357880 System.out.println("NULL PARENT");
7736
- new Exception().printStackTrace();
7881
+ //new Exception().printStackTrace();
77377882 } else
77387883 {
77397884 if (parent instanceof BezierPatch)
....@@ -7746,7 +7891,7 @@
77467891 } // NEW ...
77477892
77487893
7749
- info.pane.repaint();
7894
+ clickInfo.pane.repaint();
77507895 }
77517896
77527897 boolean overflow = false;
....@@ -7845,14 +7990,22 @@
78457990 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
78467991 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
78477992 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7993
+
7994
+ String objname;
7995
+
78487996 if (false) //parent != null)
78497997 {
7850
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7998
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
78517999 } else
78528000 {
7853
- 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) ":"") */ "";
78548002 } // + super.toString();
78558003 //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);
78568009 }
78578010
78588011 public int hashCode()
....@@ -7908,6 +8061,7 @@
79088061 objectUI.closeUI();
79098062 if (editWindow != null)
79108063 {
8064
+ editWindow.ctrlPanel.FlushUI();
79118065 editWindow.refreshContents();
79128066 } // ? new
79138067 objectUI = null;
....@@ -7916,6 +8070,10 @@
79168070 {
79178071 editWindow = null;
79188072 } // ?
8073
+ }
8074
+ else
8075
+ {
8076
+ //editWindow.closeUI();
79198077 }
79208078 }
79218079
....@@ -7928,7 +8086,7 @@
79288086 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
79298087
79308088 Object3D /*Composite*/ parent;
7931
- Object3D /*Composite*/ fileparent;
8089
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
79328090
79338091 double[][] toParent; // dynamic matrix
79348092 double[][] fromParent;
....@@ -8043,7 +8201,7 @@
80438201 {
80448202 assert(bRep != null);
80458203 if (!(support instanceof GenericJoint)) // support.bRep != null)
8046
- GrafreeD.Assert(support.bRep == bRep.support);
8204
+ Grafreed.Assert(support.bRep == bRep.support);
80478205 }
80488206 else
80498207 {
....@@ -8074,6 +8232,10 @@
80748232 }
80758233
80768234 transient ObjEditor editWindow;
8235
+ transient ObjEditor manipWindow;
8236
+
8237
+ transient boolean pinned;
8238
+
80778239 transient ObjectUI objectUI;
80788240 public static int povDepth = 0;
80798241 private static cVector tbMin = new cVector();
....@@ -8092,9 +8254,9 @@
80928254 private static cVector edge2 = new cVector();
80938255 //private static cVector norm = new cVector();
80948256 /*transient private*/ int hitSomething;
8095
- private static final int hitCenter = 1;
8096
- private static final int hitScale = 2;
8097
- private static final int hitRotate = 3;
8257
+ static final int hitCenter = 1;
8258
+ static final int hitScale = 2;
8259
+ static final int hitRotate = 3;
80988260 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
80998261 /*transient*/ private Point centerPt;
81008262 /*transient*/ private int startX;
....@@ -8126,6 +8288,8 @@
81268288 {
81278289 Object3D targ = this;
81288290
8291
+ targ.NORMALPUSH = obj.NORMALPUSH;
8292
+
81298293 if (obj.material != null)
81308294 {
81318295 if ((mask&MATERIAL)!=0) // ==(COLOR|MATERIAL))