Normand Briere
2019-08-26 6266c8a4b2485b29a7d5bcb217460d7aad3e1c4a
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,57 @@
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
+ int VersionCount()
44
+ {
45
+ int count = 0;
46
+
47
+ for (int i = versionlist.length; --i >= 0;)
48
+ {
49
+ if (versionlist[i] != null)
50
+ count++;
51
+ }
52
+
53
+ return count;
54
+ }
55
+
56
+ void InitOthers()
57
+ {
58
+ if (projectedVertices == null || projectedVertices.length <= 2)
59
+ {
60
+ projectedVertices = new Object3D.cVector2[3];
61
+ }
62
+ for (int i = 0; i < 3; i++)
63
+ {
64
+ projectedVertices[i] = new cVector2(); // Others
65
+ }
66
+ projectedVertices[0].x = 100; // bump
67
+ }
2368
2469 void MinMax(cVector minima, cVector maxima)
2570 {
....@@ -86,64 +131,245 @@
86131
87132 // transient boolean reduced; // for morph reduction
88133
89
-transient com.bulletphysics.linearmath.Transform cache; // for fast merge
90
-transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
134
+ transient com.bulletphysics.linearmath.Transform cache; // for fast merge
135
+ transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
91136
92
-transient Object3D transientsupport; // for cloning
93
-transient boolean transientlink2master;
137
+ transient Object3D transientsupport; // for cloning
138
+ transient boolean transientlink2master;
94139
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)
140
+ void SaveSupports()
107141 {
108
- bRep.SaveSupports();
142
+ if (blockloop)
143
+ return;
144
+
145
+ transientsupport = support;
146
+ transientlink2master = link2master;
147
+
148
+ support = null;
149
+ link2master = false;
150
+
151
+ if (bRep != null)
152
+ {
153
+ bRep.SaveSupports();
154
+ }
155
+
156
+ for (int i = 0; i < Size(); i++)
157
+ {
158
+ Object3D child = (Object3D) get(i);
159
+ if (child == null)
160
+ continue;
161
+ blockloop = true;
162
+ child.SaveSupports();
163
+ blockloop = false;
164
+ }
109165 }
110
-
111
- for (int i = 0; i < Size(); i++)
166
+
167
+ void RestoreSupports()
112168 {
113
- Object3D child = (Object3D) get(i);
114
- if (child == null)
115
- continue;
169
+ if (blockloop)
170
+ return;
171
+
172
+ support = transientsupport;
173
+ link2master = transientlink2master;
174
+ transientsupport = null;
175
+ transientlink2master = false;
176
+
177
+ if (bRep != null)
178
+ {
179
+ bRep.RestoreSupports();
180
+ }
181
+
182
+ for (int i = 0; i < Size(); i++)
183
+ {
184
+ Object3D child = (Object3D) get(i);
185
+ if (child == null)
186
+ continue;
187
+ blockloop = true;
188
+ child.RestoreSupports();
189
+ blockloop = false;
190
+ }
191
+ }
192
+
193
+ void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
194
+ {
195
+ Object3D o;
196
+
197
+ if (hashtable.containsKey(GetUUID()))
198
+ {
199
+ o = hashtable.get(GetUUID());
200
+
201
+ Grafreed.Assert(this.bRep == o.bRep);
202
+ //if (this.bRep != null)
203
+ // assert(this.bRep.support == o.transientrep);
204
+ if (this.support != null)
205
+ assert(this.support.bRep == o.transientrep);
206
+ }
207
+ else
208
+ {
209
+ o = new Object3D("copy of " + this.name);
210
+
211
+ hashtable.put(GetUUID(), o);
212
+ }
213
+
214
+ if (!blockloop)
215
+ {
216
+ blockloop = true;
217
+
218
+ for (int i=0; i<Size(); i++)
219
+ {
220
+ get(i).ExtractBigData(hashtable);
221
+ }
222
+
223
+ blockloop = false;
224
+ }
225
+
226
+ ExtractBigData(o);
227
+ }
228
+
229
+ void ExtractBigData(Object3D o)
230
+ {
231
+ if (o.bRep != null)
232
+ Grafreed.Assert(o.bRep == this.bRep);
233
+
234
+ o.bRep = this.bRep;
235
+// July 2019 if (this.bRep != null)
236
+// {
237
+// o.transientrep = this.bRep.support;
238
+// o.bRep.support = null;
239
+// }
240
+ o.selection = this.selection;
241
+ o.versionlist = this.versionlist;
242
+ o.versionindex = this.versionindex;
243
+
244
+ if (this.support != null)
245
+ {
246
+ if (o.transientrep != null)
247
+ Grafreed.Assert(o.transientrep == this.support.bRep);
248
+
249
+ o.transientrep = this.support.bRep;
250
+ this.support.bRep = null;
251
+ }
252
+
253
+ // o.support = this.support;
254
+ // o.fileparent = this.fileparent;
255
+ // if (this.bRep != null)
256
+ // o.bRep = this.bRep.support;
257
+
258
+ this.bRep = null;
259
+ // if (this.bRep != null)
260
+ // this.bRep.support = null;
261
+ // this.support = null;
262
+ // this.fileparent = null;
263
+ }
264
+
265
+// Object3D GetObject(java.util.UUID uuid)
266
+// {
267
+// if (this.uuid.equals(uuid))
268
+// return this;
269
+//
270
+// if (blockloop)
271
+// return null;
272
+//
273
+// blockloop = true;
274
+//
275
+// for (int i=0; i<Size(); i++)
276
+// {
277
+// Object3D o = get(i).GetObject(uuid);
278
+//
279
+// if (o != null)
280
+// return o;
281
+// }
282
+//
283
+// blockloop = false;
284
+//
285
+// return null;
286
+// }
287
+
288
+ transient boolean tag;
289
+
290
+ void TagObjects(Object3D o, boolean tag)
291
+ {
292
+ if (blockloop)
293
+ return;
294
+
295
+ o.tag = tag;
296
+
297
+ if (o == this)
298
+ return;
299
+
116300 blockloop = true;
117
- child.SaveSupports();
301
+
302
+ for (int i=0; i<Size(); i++)
303
+ {
304
+ get(i).TagObjects(o, tag);
305
+ }
306
+
118307 blockloop = false;
119308 }
120
-}
121309
122
-void RestoreSupports()
123
-{
124
- if (blockloop)
125
- return;
310
+ boolean HasTags()
311
+ {
312
+ if (blockloop)
313
+ return false;
126314
127
- support = transientsupport;
128
- link2master = transientlink2master;
129
- transientsupport = null;
130
- transientlink2master = false;
131
-
132
- if (bRep != null)
133
- {
134
- bRep.RestoreSupports();
135
- }
136
-
137
- for (int i = 0; i < Size(); i++)
138
- {
139
- Object3D child = (Object3D) get(i);
140
- if (child == null)
141
- continue;
142315 blockloop = true;
143
- child.RestoreSupports();
316
+
317
+ boolean hasTags = false;
318
+
319
+ for (int i=0; i<Size(); i++)
320
+ {
321
+ hasTags |= get(i).tag || get(i).HasTags();
322
+
323
+ if (hasTags)
324
+ break;
325
+ }
326
+
327
+ blockloop = false;
328
+
329
+ return hasTags;
330
+ }
331
+
332
+ void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
333
+ {
334
+ if (!hashtable.containsKey(GetUUID()))
335
+ return;
336
+
337
+ Object3D o = hashtable.get(GetUUID());
338
+
339
+ RestoreBigData(o);
340
+
341
+ if (blockloop)
342
+ return;
343
+
344
+ blockloop = true;
345
+
346
+ //hashtable.remove(GetUUID());
347
+
348
+ for (int i=0; i<Size(); i++)
349
+ {
350
+ get(i).RestoreBigData(hashtable);
351
+ }
352
+
144353 blockloop = false;
145354 }
146
-}
355
+
356
+ void RestoreBigData(Object3D o)
357
+ {
358
+ this.bRep = o.bRep;
359
+ if (this.support != null && o.transientrep != null)
360
+ {
361
+ this.support.bRep = o.transientrep;
362
+ }
363
+
364
+ this.selection = o.selection;
365
+
366
+ this.versionlist = o.versionlist;
367
+ this.versionindex = o.versionindex;
368
+// July 2019 if (this.bRep != null)
369
+// this.bRep.support = o.transientrep;
370
+ // this.support = o.support;
371
+ // this.fileparent = o.fileparent;
372
+ }
147373
148374 // MOCAP SUPPORT
149375 double tx,ty,tz,rx,ry,rz;
....@@ -286,6 +512,8 @@
286512 }
287513
288514 boolean live = false;
515
+ transient boolean keepdontselect;
516
+ boolean dontselect = false;
289517 boolean hide = false;
290518 boolean link2master = false; // performs reset support/master at each frame
291519 boolean marked = false; // animation node
....@@ -295,6 +523,8 @@
295523 boolean random = false;
296524 boolean speedup = false;
297525 boolean rewind = false;
526
+
527
+ float NORMALPUSH = 0;
298528
299529 Object3D support;
300530
....@@ -351,11 +581,11 @@
351581 }
352582 }
353583
354
- int memorysize;
584
+ transient int memorysize; // needs to be transient, dunno why
355585
356586 int MemorySize()
357587 {
358
- if (true) // memorysize == 0)
588
+ if (memorysize == 0)
359589 {
360590 try
361591 {
....@@ -415,16 +645,16 @@
415645 {
416646 Object3D copy = this;
417647
418
- Camera parentcam = CameraPane.theRenderer.manipCamera;
648
+ Camera parentcam = Globals.theRenderer.ManipCamera();
419649
420
- if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[0])
650
+ if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[0])
421651 {
422
- parentcam = CameraPane.theRenderer.cameras[1];
652
+ parentcam = Globals.theRenderer.Cameras()[1];
423653 }
424654
425
- if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[1])
655
+ if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[1])
426656 {
427
- parentcam = CameraPane.theRenderer.cameras[0];
657
+ parentcam = Globals.theRenderer.Cameras()[0];
428658 }
429659
430660 if (this == parentcam)
....@@ -432,7 +662,7 @@
432662 //assert(this instanceof Camera);
433663
434664 for (int count = parentcam.GetTransformCount(); --count>=0;)
435
- LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.toParent, CameraPane.theRenderer.targetLookAt);
665
+ LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.toParent, Globals.theRenderer.TargetLookAt());
436666 }
437667
438668 copy.marked ^= true;
....@@ -452,7 +682,7 @@
452682 //assert(this instanceof Camera);
453683
454684 for (int count = parentcam.GetTransformCount(); --count>=0;)
455
- LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.fromParent, CameraPane.theRenderer.targetLookAt);
685
+ LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.fromParent, Globals.theRenderer.TargetLookAt());
456686 }
457687
458688 copy.Touch(); // display list issue
....@@ -465,12 +695,14 @@
465695 toParent = LA.newMatrix();
466696 fromParent = LA.newMatrix();
467697 }
698
+
468699 if (toParentMarked == null)
469700 {
470701 if (maxcount != 1)
471702 {
472
- new Exception().printStackTrace();
703
+ //new Exception().printStackTrace();
473704 }
705
+
474706 toParentMarked = LA.newMatrix();
475707 fromParentMarked = LA.newMatrix();
476708 }
....@@ -587,7 +819,7 @@
587819 return;
588820 }
589821
590
- if (CameraPane.fromscript)
822
+ if (Globals.fromscript)
591823 {
592824 transformcount = 0;
593825 return;
....@@ -745,7 +977,7 @@
745977
746978 int GetTransformCount()
747979 {
748
- // marde pour serialization de Texture
980
+ // patch pour serialization de Texture
749981 resetmaxcount();
750982 resettransformcount();
751983 resetstep();
....@@ -758,7 +990,7 @@
758990 if (step == 0)
759991 step = 1;
760992 if (maxcount == 0)
761
- maxcount = 2048; // 4;
993
+ maxcount = 128; // 2048; // 4;
762994 // if (acceleration == 0)
763995 // acceleration = 10;
764996 if (delay == 0) // serial
....@@ -779,9 +1011,12 @@
7791011 // factor = CameraPane.STEP;
7801012 // }
7811013
782
- if (marked && CameraPane.isLIVE() && live && CameraPane.drawMode == CameraPane.SHADOW && currentframe != CameraPane.framecount)
1014
+ if (marked && Globals.isLIVE() && live &&
1015
+ //TEMP21aug2018
1016
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
1017
+ currentframe != Globals.framecount)
7831018 {
784
- currentframe = CameraPane.framecount;
1019
+ currentframe = Globals.framecount;
7851020
7861021 // System.err.println("transformcount = " + transformcount);
7871022 // System.err.println("factor = " + factor);
....@@ -790,7 +1025,8 @@
7901025
7911026 boolean changedir = random && Math.random() < 0.01; // && !link2master;
7921027
793
- if (transformcount*factor > maxcount || (step == 1 && changedir))
1028
+ if (transformcount*factor >= maxcount && (rewind || random) ||
1029
+ (step == 1 && changedir))
7941030 {
7951031 countdown = 1;
7961032 delay = speedup?8:1;
....@@ -862,6 +1098,10 @@
8621098 if (material == null || material.multiply)
8631099 return true;
8641100
1101
+ if (projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
1102
+ return false;
1103
+
1104
+ // Transparent objects are dynamic because we have to sort the triangles.
8651105 return material.opacity > 0.99;
8661106 }
8671107
....@@ -893,6 +1133,11 @@
8931133 fromParent = null; // LA.newMatrix();
8941134 bRep = null; // new BoundaryRep();
8951135
1136
+ if (oname != null && oname.equals("LeftHand"))
1137
+ {
1138
+ name = oname;
1139
+ }
1140
+
8961141 /*
8971142 float hue = (float)Math.random();
8981143 Color col;
....@@ -935,7 +1180,7 @@
9351180
9361181 public Object clone()
9371182 {
938
- return GrafreeD.clone(this);
1183
+ return Grafreed.clone(this);
9391184 }
9401185
9411186 Object3D copyExpand()
....@@ -1257,6 +1502,7 @@
12571502 toParent = LA.newMatrix();
12581503 fromParent = LA.newMatrix();
12591504 }
1505
+
12601506 LA.matCopy(other.toParent, toParent);
12611507 LA.matCopy(other.fromParent, fromParent);
12621508
....@@ -1451,7 +1697,7 @@
14511697 BoundaryRep.SEUIL = other.material.cameralight;
14521698
14531699 // Set default to 0.1
1454
- BoundaryRep.SEUIL /= 2;
1700
+ BoundaryRep.SEUIL /= 4; // 2;
14551701 System.out.println("SEUIL = " + BoundaryRep.SEUIL);
14561702 }
14571703
....@@ -1710,7 +1956,7 @@
17101956 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17111957 o.bRep = transientrep;
17121958 if (clone)
1713
- o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
1959
+ o.bRep = (BoundaryRep) Grafreed.clone(transientrep);
17141960 o.CreateMaterial();
17151961 o.SetAttributes(this, -1);
17161962 //parent
....@@ -1723,7 +1969,7 @@
17231969 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17241970 o.bRep = bRep;
17251971 if (clone)
1726
- o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
1972
+ o.bRep = (BoundaryRep) Grafreed.clone(bRep);
17271973 o.CreateMaterial();
17281974 //o.overwriteThis(this, -1);
17291975 o.SetAttributes(this, -1);
....@@ -1810,12 +2056,15 @@
18102056 if (obj.name == null)
18112057 continue; // can't be a null one
18122058
2059
+ // Try perfect match first.
18132060 if (n.equals(obj.name))
18142061 {
18152062 theobj = obj;
18162063 count++;
18172064 }
18182065 }
2066
+
2067
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18192068
18202069 if (count != 1)
18212070 for (int i=Size(); --i>=0;)
....@@ -2130,21 +2379,9 @@
21302379 if (/*parent != null &&*/ material == null)
21312380 {
21322381 material = new cMaterial(GetMaterial());
2133
- if (projectedVertices == null || projectedVertices.length <= 2)
2134
- {
2135
- projectedVertices = new Object3D.cVector2[3];
2136
- }
2137
- for (int i = 0; i < 3; i++)
2138
- {
2139
- projectedVertices[i] = new cVector2(); // Others
2140
- }
2141
- projectedVertices[0].x = 100; // bump
21422382
2143
- if (this instanceof Camera)
2144
- {
2145
- material.shift = 90;
2146
- }
2147
-
2383
+ InitOthers();
2384
+
21482385 material.multiply = multiply;
21492386
21502387 if (multiply)
....@@ -2282,12 +2519,22 @@
22822519 }
22832520 */
22842521 }
2522
+ else
2523
+ {
2524
+ //((ObjEditor)editWindow).SetupUI2(null);
2525
+ if (objectUI != null)
2526
+ ((ObjEditor)objectUI).pinButton.setSelected(pinned);
2527
+ else
2528
+ //new Exception().printStackTrace();
2529
+ System.err.println("objectUI is null");
2530
+ }
22852531 }
22862532
22872533 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
22882534 {
22892535 if (newWindow)
22902536 {
2537
+ new Exception().printStackTrace();
22912538 System.exit(0);
22922539 if (parent != null)
22932540 {
....@@ -2322,6 +2569,14 @@
23222569 {
23232570 editWindow.refreshContents();
23242571 }
2572
+ else
2573
+ {
2574
+ if (manipWindow != null)
2575
+ {
2576
+ manipWindow.refreshContents();
2577
+ }
2578
+ }
2579
+
23252580 //if (parent != null)
23262581 //parent.refreshEditWindow();
23272582 }
....@@ -2401,7 +2656,8 @@
24012656 private static final int editSelf = 1;
24022657 private static final int editChild = 2;
24032658
2404
- void drawEditHandles(ClickInfo info, int level)
2659
+ void drawEditHandles(//ClickInfo info,
2660
+ int level)
24052661 {
24062662 if (level == 0)
24072663 {
....@@ -2409,7 +2665,8 @@
24092665 return;
24102666
24112667 Object3D selectee;
2412
- for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(info, level + 1))
2668
+ for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(//info,
2669
+ level + 1))
24132670 {
24142671 selectee = (Object3D) e.nextElement();
24152672 }
....@@ -2417,19 +2674,22 @@
24172674 } else
24182675 {
24192676 //super.
2420
- drawEditHandles0(info, level + 1);
2677
+ drawEditHandles0(//info,
2678
+ level + 1);
24212679 }
24222680 }
24232681
2424
- boolean doEditClick(ClickInfo info, int level)
2682
+ boolean doEditClick(//ClickInfo info,
2683
+ int level)
24252684 {
24262685 doSomething = 0;
24272686 if (level == 0)
24282687 {
2429
- return doParentClick(info);
2688
+ return doParentClick(); //info);
24302689 }
24312690 if (//super.
2432
- doEditClick0(info, level))
2691
+ doEditClick0(//info,
2692
+ level))
24332693 {
24342694 doSomething = 1;
24352695 return true;
....@@ -2439,7 +2699,7 @@
24392699 }
24402700 }
24412701
2442
- boolean doParentClick(ClickInfo info)
2702
+ boolean doParentClick() //ClickInfo info)
24432703 {
24442704 if (selection == null)
24452705 {
....@@ -2452,7 +2712,8 @@
24522712 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
24532713 {
24542714 Object3D selectee = (Object3D) e.nextElement();
2455
- if (selectee.doEditClick(info, 1))
2715
+ if (selectee.doEditClick(//info,
2716
+ 1))
24562717 {
24572718 childToDrag = selectee;
24582719 doSomething = 2;
....@@ -2464,13 +2725,15 @@
24642725 return retval;
24652726 }
24662727
2467
- void doEditDrag(ClickInfo info)
2728
+ void doEditDrag(//ClickInfo clickInfo,
2729
+ boolean opposite)
24682730 {
24692731 switch (doSomething)
24702732 {
24712733 case 1: // '\001'
24722734 //super.
2473
- doEditDrag0(info);
2735
+ doEditDrag0(//clickInfo,
2736
+ opposite);
24742737 break;
24752738
24762739 case 2: // '\002'
....@@ -2483,11 +2746,13 @@
24832746 {
24842747 //sel.hitSomething = childToDrag.hitSomething;
24852748 //childToDrag.doEditDrag(info);
2486
- sel.doEditDrag(info);
2749
+ sel.doEditDrag(//clickInfo,
2750
+ opposite);
24872751 } else
24882752 {
24892753 //super.
2490
- doEditDrag0(info);
2754
+ doEditDrag0(//clickInfo,
2755
+ opposite);
24912756 }
24922757 }
24932758 break;
....@@ -2505,6 +2770,9 @@
25052770 {
25062771 deselectAll();
25072772 }
2773
+
2774
+ new Exception().printStackTrace();
2775
+
25082776 ClickInfo newInfo = new ClickInfo();
25092777 newInfo.flags = info.flags;
25102778 newInfo.bounds = info.bounds;
....@@ -2597,6 +2865,18 @@
25972865 void GenNormalsS(boolean crease)
25982866 {
25992867 selection.GenNormals(crease);
2868
+// for (int i=0; i<selection.size(); i++)
2869
+// {
2870
+// Object3D selectee = (Object3D) selection.elementAt(i);
2871
+// selectee.GenNormals(crease);
2872
+// }
2873
+
2874
+ //Touch();
2875
+ }
2876
+
2877
+ void GenNormalsMeshS()
2878
+ {
2879
+ selection.GenNormalsMesh();
26002880 // for (int i=0; i<selection.size(); i++)
26012881 // {
26022882 // Object3D selectee = (Object3D) selection.elementAt(i);
....@@ -2737,6 +3017,24 @@
27373017 if (child == null)
27383018 continue;
27393019 child.GenNormals(crease);
3020
+// Children().release(i);
3021
+ }
3022
+ blockloop = false;
3023
+ }
3024
+
3025
+ void GenNormalsMesh()
3026
+ {
3027
+ if (blockloop)
3028
+ return;
3029
+
3030
+ blockloop = true;
3031
+ GenNormalsMesh0();
3032
+ for (int i = 0; i < Children().Size(); i++)
3033
+ {
3034
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
3035
+ if (child == null)
3036
+ continue;
3037
+ child.GenNormalsMesh();
27403038 // Children().release(i);
27413039 }
27423040 blockloop = false;
....@@ -2894,7 +3192,8 @@
28943192 {
28953193 if (bRep != null)
28963194 {
2897
- bRep.GenUV();
3195
+ bRep.GenUV(); //1);
3196
+ //bRep.UnfoldUV();
28983197 Touch();
28993198 }
29003199 }
....@@ -2908,11 +3207,20 @@
29083207 }
29093208 }
29103209
3210
+ void GenNormalsMesh0()
3211
+ {
3212
+ if (bRep != null)
3213
+ {
3214
+ bRep.GenerateNormalsMesh();
3215
+ Touch();
3216
+ }
3217
+ }
3218
+
29113219 void GenNormalsMINE0()
29123220 {
29133221 if (bRep != null)
29143222 {
2915
- bRep.GenerateNormalsMINE();
3223
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
29163224 Touch();
29173225 }
29183226 }
....@@ -2969,6 +3277,120 @@
29693277 blockloop = false;
29703278 }
29713279
3280
+ public void ResetTransform(int mask)
3281
+ {
3282
+ Object3D obj = this;
3283
+
3284
+ if (mask == -1)
3285
+ {
3286
+ if (obj instanceof Camera) // jan 2014
3287
+ {
3288
+ LA.matIdentity(obj.toParent);
3289
+ LA.matIdentity(obj.fromParent);
3290
+ }
3291
+ else
3292
+ {
3293
+ obj.toParent = null; // jan 2014 LA.matIdentity(obj.toParent);
3294
+ obj.fromParent = null; // LA.matIdentity(obj.fromParent);
3295
+ }
3296
+ return;
3297
+ }
3298
+
3299
+ if ((mask&2) != 0) // Scale/rotation
3300
+ {
3301
+ obj.toParent[0][0] = obj.toParent[1][1] = obj.toParent[2][2] = 1;
3302
+ obj.toParent[0][1] = obj.toParent[1][0] = obj.toParent[2][0] = 0;
3303
+ obj.toParent[0][2] = obj.toParent[1][2] = obj.toParent[2][1] = 0;
3304
+ obj.fromParent[0][0] = obj.fromParent[1][1] = obj.fromParent[2][2] = 1;
3305
+ obj.fromParent[0][1] = obj.fromParent[1][0] = obj.fromParent[2][0] = 0;
3306
+ obj.fromParent[0][2] = obj.fromParent[1][2] = obj.fromParent[2][1] = 0;
3307
+ }
3308
+ if ((mask&1) != 0) // Translation
3309
+ {
3310
+ if (obj.toParent != null)
3311
+ {
3312
+ obj.toParent[3][0] = obj.toParent[3][1] = obj.toParent[3][2] = 0;
3313
+ obj.fromParent[3][0] = obj.fromParent[3][1] = obj.fromParent[3][2] = 0;
3314
+ }
3315
+ }
3316
+ }
3317
+
3318
+ public void TextureRatioTransform(int axis)
3319
+ {
3320
+ cTexture tex = GetTextures();
3321
+
3322
+ com.sun.opengl.util.texture.TextureData texturedata = null;
3323
+
3324
+ try
3325
+ {
3326
+ texturedata = Globals.theRenderer.GetTextureData(tex, false, texres);
3327
+ }
3328
+ catch (Exception e)
3329
+ {
3330
+ System.err.println("FAIL TextureRatio: " + this);
3331
+ }
3332
+
3333
+ LA.matIdentity(Object3D.mat);
3334
+ Object3D.mat[axis][axis] = (double)texturedata.getWidth() / texturedata.getHeight();
3335
+
3336
+ if (toParent == null)
3337
+ {
3338
+ toParent = LA.newMatrix();
3339
+ fromParent = LA.newMatrix();
3340
+ }
3341
+
3342
+ ResetTransform(2);
3343
+
3344
+ LA.matConcat(Object3D.mat, fromParent, fromParent);
3345
+ LA.matInvert(fromParent, toParent);
3346
+ }
3347
+
3348
+ void TextureRatio(int axis)
3349
+ {
3350
+ if (blockloop)
3351
+ return;
3352
+
3353
+ blockloop = true;
3354
+
3355
+ TextureRatioTransform(axis);
3356
+
3357
+ for (int i=Size(); --i>=0;)
3358
+ {
3359
+ Object3D v = get(i);
3360
+
3361
+ v.TextureRatio(axis);
3362
+ }
3363
+
3364
+ blockloop = false;
3365
+ }
3366
+
3367
+ void TransformChildren()
3368
+ {
3369
+ if (toParent != null)
3370
+ {
3371
+ for (int i=Size(); --i>=0;)
3372
+ {
3373
+ Object3D v = get(i);
3374
+
3375
+ if (v.toParent == null)
3376
+ {
3377
+ v.toParent = LA.newMatrix();
3378
+ v.fromParent = LA.newMatrix();
3379
+ }
3380
+
3381
+// LA.matConcat(v.toParent, toParent, v.toParent);
3382
+// LA.matConcat(fromParent, v.fromParent, v.fromParent);
3383
+ LA.matConcat(toParent, v.toParent, v.toParent);
3384
+ LA.matConcat(v.fromParent, fromParent, v.fromParent);
3385
+ }
3386
+
3387
+ toParent = null; // LA.matIdentity(toParent);
3388
+ fromParent = null; // LA.matIdentity(fromParent);
3389
+
3390
+ Touch();
3391
+ }
3392
+ }
3393
+
29723394 void TransformGeometry()
29733395 {
29743396 Object3D obj = this;
....@@ -3190,9 +3612,11 @@
31903612
31913613 BoundaryRep sup = bRep.support;
31923614 bRep.support = null;
3193
- BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
3615
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
31943616 // bRep.SplitInTwo(onlyone); // thread...
3195
- temprep.SplitInTwo(reduction34, onlyone);
3617
+
3618
+ while(temprep.SplitInTwo(reduction34, onlyone));
3619
+
31963620 bRep = temprep;
31973621 bRep.support = sup;
31983622 Touch();
....@@ -3293,15 +3717,47 @@
32933717
32943718 void ClearMaterials()
32953719 {
3720
+ if (blockloop)
3721
+ return;
3722
+
3723
+ blockloop = true;
3724
+
32963725 ClearMaterial();
3297
- for (int i = 0; i < size(); i++)
3726
+ for (int i = 0; i < Size(); i++)
32983727 {
3299
- Object3D child = (Object3D) reserve(i);
3728
+ Object3D child = (Object3D) get(i);
33003729 if (child == null)
33013730 continue;
33023731 child.ClearMaterials();
3303
- release(i);
33043732 }
3733
+
3734
+ blockloop = false;
3735
+ }
3736
+
3737
+ void ClearVersionList()
3738
+ {
3739
+ this.versionlist = null;
3740
+ this.versionindex = -1;
3741
+ this.versiontable = null;
3742
+ }
3743
+
3744
+ void ClearVersions()
3745
+ {
3746
+ if (blockloop)
3747
+ return;
3748
+
3749
+ blockloop = true;
3750
+
3751
+ ClearVersionList();
3752
+ for (int i = 0; i < Size(); i++)
3753
+ {
3754
+ Object3D child = (Object3D) get(i);
3755
+ if (child == null)
3756
+ continue;
3757
+ child.ClearVersions();
3758
+ }
3759
+
3760
+ blockloop = false;
33053761 }
33063762
33073763 void FlipV(boolean flip)
....@@ -3329,7 +3785,8 @@
33293785 if (blockloop)
33303786 return;
33313787
3332
- if (marked || (bRep != null && material != null)) // borderline...
3788
+ if (//marked || // does not make sense
3789
+ (bRep != null || material != null)) // borderline...
33333790 live = h;
33343791
33353792 for (int i = 0; i < Size(); i++)
....@@ -3350,7 +3807,8 @@
33503807 return;
33513808
33523809 //if (bRep != null)
3353
- if (marked || (bRep != null && material != null)) // borderline...
3810
+ if (//marked || // does not make sense
3811
+ (bRep != null || material != null)) // borderline...
33543812 link2master = h;
33553813
33563814 for (int i = 0; i < Size(); i++)
....@@ -3370,7 +3828,8 @@
33703828 if (blockloop)
33713829 return;
33723830
3373
- if (marked || (bRep != null && material != null)) // borderline...
3831
+ if (//marked || // does not make sense
3832
+ (bRep != null || material != null)) // borderline...
33743833 hide = h;
33753834
33763835 for (int i = 0; i < Size(); i++)
....@@ -3390,7 +3849,7 @@
33903849 if (blockloop)
33913850 return;
33923851
3393
- if (bRep != null && material != null) // borderline...
3852
+ if (bRep != null || material != null) // borderline...
33943853 marked = h;
33953854
33963855 for (int i = 0; i < Size(); i++)
....@@ -3400,6 +3859,46 @@
34003859 continue;
34013860 blockloop = true;
34023861 child.MarkLeaves(h);
3862
+ blockloop = false;
3863
+ // release(i);
3864
+ }
3865
+ }
3866
+
3867
+ void RewindLeaves(boolean h)
3868
+ {
3869
+ if (blockloop)
3870
+ return;
3871
+
3872
+ if (bRep != null || material != null) // borderline...
3873
+ rewind = h;
3874
+
3875
+ for (int i = 0; i < Size(); i++)
3876
+ {
3877
+ Object3D child = (Object3D) get(i); // reserve(i);
3878
+ if (child == null)
3879
+ continue;
3880
+ blockloop = true;
3881
+ child.RewindLeaves(h);
3882
+ blockloop = false;
3883
+ // release(i);
3884
+ }
3885
+ }
3886
+
3887
+ void RandomLeaves(boolean h)
3888
+ {
3889
+ if (blockloop)
3890
+ return;
3891
+
3892
+ if (bRep != null || material != null) // borderline...
3893
+ random = h;
3894
+
3895
+ for (int i = 0; i < Size(); i++)
3896
+ {
3897
+ Object3D child = (Object3D) get(i); // reserve(i);
3898
+ if (child == null)
3899
+ continue;
3900
+ blockloop = true;
3901
+ child.RandomLeaves(h);
34033902 blockloop = false;
34043903 // release(i);
34053904 }
....@@ -3714,7 +4213,7 @@
37144213 if (child == null)
37154214 continue;
37164215
3717
- if (GrafreeD.RENDERME > 0)
4216
+ if (Grafreed.RENDERME > 0)
37184217 {
37194218 if (child instanceof Merge)
37204219 ((Merge)child).renderme();
....@@ -3865,7 +4364,7 @@
38654364 if (child == null)
38664365 continue;
38674366
3868
- if (GrafreeD.RENDERME > 0)
4367
+ if (Grafreed.RENDERME > 0)
38694368 {
38704369 if (child instanceof Merge)
38714370 ((Merge)child).renderme();
....@@ -4060,7 +4559,7 @@
40604559 if (child == null)
40614560 continue;
40624561
4063
- if (GrafreeD.RENDERME > 0)
4562
+ if (Grafreed.RENDERME > 0)
40644563 {
40654564 if (child instanceof Merge)
40664565 ((Merge)child).renderme();
....@@ -4157,6 +4656,71 @@
41574656 }
41584657 blockloop = true;
41594658 get(i).RepairParent();
4659
+ blockloop = false;
4660
+ }
4661
+ }
4662
+
4663
+ void RepairShadow()
4664
+ {
4665
+ if (blockloop)
4666
+ return;
4667
+
4668
+ if (this.material != null)
4669
+ this.InitOthers();
4670
+
4671
+ for (int i=0; i<Size(); i++)
4672
+ {
4673
+ blockloop = true;
4674
+ get(i).RepairShadow();
4675
+ blockloop = false;
4676
+ }
4677
+ }
4678
+
4679
+ void RepairSOV()
4680
+ {
4681
+ if (blockloop)
4682
+ return;
4683
+
4684
+ String texname = this.GetPigmentTexture();
4685
+
4686
+ if (texname.startsWith("sov"))
4687
+ {
4688
+ String[] s = texname.split("/");
4689
+
4690
+ String[] sname = s[1].split("Color.pn");
4691
+
4692
+ texname = sname[0];
4693
+
4694
+ if (sname.length > 1)
4695
+ {
4696
+ texname += "Color.jpg";
4697
+ }
4698
+
4699
+ this.SetPigmentTexture("sov/" + texname);
4700
+ }
4701
+
4702
+ texname = this.GetBumpTexture();
4703
+
4704
+ if (texname.startsWith("sov"))
4705
+ {
4706
+ String[] s = texname.split("/");
4707
+
4708
+ String[] sname = s[1].split("Bump.pn");
4709
+
4710
+ texname = sname[0];
4711
+
4712
+ if (sname.length > 1)
4713
+ {
4714
+ texname += "Bump.jpg";
4715
+ }
4716
+
4717
+ this.SetBumpTexture("sov/" + texname);
4718
+ }
4719
+
4720
+ for (int i=0; i<Size(); i++)
4721
+ {
4722
+ blockloop = true;
4723
+ get(i).RepairSOV();
41604724 blockloop = false;
41614725 }
41624726 }
....@@ -4651,7 +5215,7 @@
46515215
46525216 cTreePath SelectLeaf(int indexcount, boolean deselect)
46535217 {
4654
- if (hide)
5218
+ if (hide || dontselect)
46555219 return null;
46565220
46575221 if (count <= 0)
....@@ -4675,9 +5239,17 @@
46755239 }
46765240 }
46775241
5242
+ ObjEditor GetWindow()
5243
+ {
5244
+ if (editWindow != null)
5245
+ return editWindow;
5246
+
5247
+ return manipWindow;
5248
+ }
5249
+
46785250 cTreePath Select(int indexcount, boolean deselect)
46795251 {
4680
- if (hide)
5252
+ if (hide || dontselect)
46815253 return null;
46825254
46835255 if (count <= 0)
....@@ -4711,10 +5283,11 @@
47115283 if (leaf != null)
47125284 {
47135285 cTreePath tp = new cTreePath(this, leaf);
4714
- if (editWindow != null)
5286
+ ObjEditor window = GetWindow();
5287
+ if (window != null)
47155288 {
47165289 //System.out.println("editWindow = " + editWindow + " vs " + this);
4717
- editWindow.Select(tp, deselect, true);
5290
+ window.Select(tp, deselect, true);
47185291 }
47195292
47205293 return tp;
....@@ -4731,6 +5304,7 @@
47315304
47325305 if (child == null)
47335306 continue;
5307
+
47345308 if (child.HasTransparency() && child.size() != 0)
47355309 {
47365310 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4740,9 +5314,10 @@
47405314 if (leaf != null)
47415315 {
47425316 cTreePath tp = new cTreePath(this, leaf);
4743
- if (editWindow != null)
5317
+ ObjEditor window = GetWindow();
5318
+ if (window != null)
47445319 {
4745
- editWindow.Select(tp, deselect, true);
5320
+ window.Select(tp, deselect, true);
47465321 }
47475322
47485323 return tp;
....@@ -4827,7 +5402,7 @@
48275402 return globalTransform;
48285403 }
48295404
4830
- void PreprocessOcclusion(CameraPane cp)
5405
+ void PreprocessOcclusion(iCameraPane cp)
48315406 {
48325407 /*
48335408 if (AOdone)
....@@ -4974,7 +5549,8 @@
49745549 } else //
49755550 if (editWindow != null)
49765551 {
4977
- editWindow.cameraView.lighttouched = true;
5552
+ //editWindow.cameraView.lighttouched = true;
5553
+ Globals.lighttouched = true;
49785554 }
49795555 }
49805556
....@@ -5066,6 +5642,51 @@
50665642 blockloop = false;
50675643 }
50685644
5645
+ void ResetSelectable()
5646
+ {
5647
+ if (blockloop)
5648
+ return;
5649
+
5650
+ blockloop = true;
5651
+
5652
+ keepdontselect = dontselect;
5653
+ dontselect = true;
5654
+
5655
+ Object3D child;
5656
+ int nb = Size();
5657
+ for (int i = 0; i < nb; i++)
5658
+ {
5659
+ child = (Object3D) get(i);
5660
+ if (child == null)
5661
+ continue;
5662
+ child.ResetSelectable();
5663
+ }
5664
+
5665
+ blockloop = false;
5666
+ }
5667
+
5668
+ void RestoreSelectable()
5669
+ {
5670
+ if (blockloop)
5671
+ return;
5672
+
5673
+ blockloop = true;
5674
+
5675
+ dontselect = keepdontselect;
5676
+
5677
+ Object3D child;
5678
+ int nb = Size();
5679
+ for (int i = 0; i < nb; i++)
5680
+ {
5681
+ child = (Object3D) get(i);
5682
+ if (child == null)
5683
+ continue;
5684
+ child.RestoreSelectable();
5685
+ }
5686
+
5687
+ blockloop = false;
5688
+ }
5689
+
50695690 boolean IsSelected()
50705691 {
50715692 if (parent == null)
....@@ -5126,12 +5747,41 @@
51265747 if (fullname == null)
51275748 return "";
51285749
5750
+ if (fullname.pigment != null)
5751
+ {
5752
+ return fullname.pigment;
5753
+ }
5754
+
51295755 // System.out.println("Fullname = " + fullname);
51305756
5131
- if (fullname.name.indexOf(":") == -1)
5132
- return fullname.name;
5757
+ // Does not work on Windows due to C:
5758
+// if (fullname.name.indexOf(":") == -1)
5759
+// return fullname.name;
5760
+//
5761
+// return fullname.name.substring(0,fullname.name.indexOf(":"));
51335762
5134
- return fullname.name.substring(0,fullname.name.indexOf(":"));
5763
+ String[] split = fullname.name.split(":");
5764
+
5765
+ if (split.length == 0)
5766
+ {
5767
+ return fullname.pigment = "";
5768
+ }
5769
+
5770
+ if (split.length <= 2)
5771
+ {
5772
+ if (fullname.name.endsWith(":"))
5773
+ {
5774
+ // Windows
5775
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
5776
+ }
5777
+
5778
+ return fullname.pigment = split[0];
5779
+ }
5780
+
5781
+ // Windows
5782
+ assert(split.length == 4);
5783
+
5784
+ return fullname.pigment = split[0] + ":" + split[1];
51355785 }
51365786
51375787 static String GetBump(cTexture fullname)
....@@ -5139,11 +5789,44 @@
51395789 if (fullname == null)
51405790 return "";
51415791
5792
+ if (fullname.bump != null)
5793
+ {
5794
+ return fullname.bump;
5795
+ }
5796
+
51425797 // System.out.println("Fullname = " + fullname);
5143
- if (fullname.name.indexOf(":") == -1)
5144
- return "";
5145
-
5146
- return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5798
+ // Does not work on Windows due to C:
5799
+// if (fullname.name.indexOf(":") == -1)
5800
+// return "";
5801
+//
5802
+// return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5803
+ String[] split = fullname.name.split(":");
5804
+
5805
+ if (split.length == 0)
5806
+ {
5807
+ return fullname.bump = "";
5808
+ }
5809
+
5810
+ if (split.length == 1)
5811
+ {
5812
+ return fullname.bump = "";
5813
+ }
5814
+
5815
+ if (split.length == 2)
5816
+ {
5817
+ if (fullname.name.endsWith(":"))
5818
+ {
5819
+ // Windows
5820
+ return fullname.bump = "";
5821
+ }
5822
+
5823
+ return fullname.bump = split[1];
5824
+ }
5825
+
5826
+ // Windows
5827
+ assert(split.length == 4);
5828
+
5829
+ return fullname.bump = split[2] + ":" + split[3];
51475830 }
51485831
51495832 String GetPigmentTexture()
....@@ -5217,7 +5900,7 @@
52175900 System.out.print("; textures = " + textures);
52185901 System.out.println("; usedtextures = " + usedtextures);
52195902
5220
- if (GetTextures() == null)
5903
+ if (GetTextures() == null) // What is that??
52215904 GetTextures().name = ":";
52225905
52235906 String texname = tex;
....@@ -5226,6 +5909,9 @@
52265909 texname = "";
52275910
52285911 GetTextures().name = texname + ":" + GetBump(GetTextures());
5912
+
5913
+ GetTextures().pigment = null;
5914
+
52295915 Touch();
52305916 }
52315917
....@@ -5250,6 +5936,43 @@
52505936 }
52515937 }
52525938
5939
+ UUID GetUUID()
5940
+ {
5941
+ if (uuid == null)
5942
+ {
5943
+ // Serial
5944
+ uuid = UUID.randomUUID();
5945
+ }
5946
+
5947
+ return uuid;
5948
+ }
5949
+
5950
+ Object3D GetObject(UUID uid)
5951
+ {
5952
+ if (blockloop)
5953
+ return null;
5954
+
5955
+ if (GetUUID().equals(uid))
5956
+ return this;
5957
+
5958
+ int nb = Size();
5959
+ for (int i = 0; i < nb; i++)
5960
+ {
5961
+ Object3D child = (Object3D) get(i);
5962
+
5963
+ if (child == null)
5964
+ continue;
5965
+
5966
+ blockloop = true;
5967
+ Object3D obj = child.GetObject(uid);
5968
+ blockloop = false;
5969
+ if (obj != null)
5970
+ return obj;
5971
+ }
5972
+
5973
+ return null;
5974
+ }
5975
+
52535976 void SetBumpTexture(String tex)
52545977 {
52555978 if (GetTextures() == null)
....@@ -5261,6 +5984,8 @@
52615984 texname = "";
52625985
52635986 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
5987
+
5988
+ GetTextures().bump = null;
52645989
52655990 Touch();
52665991 }
....@@ -5286,25 +6011,70 @@
52866011 }
52876012 }
52886013
5289
- void draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
6014
+ void EmbedTextures(boolean embed)
6015
+ {
6016
+ if (blockloop)
6017
+ return;
6018
+
6019
+ //if (GetTextures() != null)
6020
+ if (embed)
6021
+ CameraPane.EmbedTextures(GetTextures());
6022
+ else
6023
+ {
6024
+ GetTextures().pigmentdata = null;
6025
+ GetTextures().bumpdata = null;
6026
+ GetTextures().pw = 0;
6027
+ GetTextures().ph = 0;
6028
+ GetTextures().bw = 0;
6029
+ GetTextures().bh = 0;
6030
+ }
6031
+
6032
+ int nb = Size();
6033
+ for (int i = 0; i < nb; i++)
6034
+ {
6035
+ Object3D child = (Object3D) get(i);
6036
+
6037
+ if (child == null)
6038
+ continue;
6039
+
6040
+ blockloop = true;
6041
+ child.EmbedTextures(embed);
6042
+ blockloop = false;
6043
+ }
6044
+ }
6045
+
6046
+ void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
52906047 {
52916048 Draw(display, root, selected, blocked);
52926049 }
52936050
5294
- static cMaterial[] materialstack = new cMaterial[65536];
5295
- static boolean[] selectedstack = new boolean[65536];
5296
- static int materialdepth = 0;
5297
-
52986051 boolean NeedSupport()
52996052 {
53006053 return
5301
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
6054
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
53026055 // PROBLEM with CROWD!!
5303
- && (CameraPane.drawMode == CameraPane.SHADOW || CameraPane.CROWD);
6056
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
53046057 }
53056058
6059
+ static boolean DEBUG_SELECTION = false;
53066060
5307
- void Draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
6061
+ boolean IsLive()
6062
+ {
6063
+ if (live)
6064
+ return true;
6065
+
6066
+ if (parent == null)
6067
+ return false;
6068
+
6069
+ return parent.IsLive();
6070
+ }
6071
+
6072
+ boolean IsDynamic()
6073
+ {
6074
+ return live && bRep != null;
6075
+ }
6076
+
6077
+ void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
53086078 {
53096079 Invariants(); // june 2013
53106080
....@@ -5313,8 +6083,8 @@
53136083 // System.err.println("Draw " + this + " Frame # " + ((Mocap)((Merge)support).object).frame);
53146084 }
53156085
5316
- if (display.drawMode == CameraPane.SELECTION &&
5317
- hide)
6086
+ if (display.DrawMode() == iCameraPane.SELECTION &&
6087
+ (hide || dontselect))
53186088 return;
53196089
53206090 if (name != null && name.contains("sclera"))
....@@ -5332,7 +6102,7 @@
53326102 if (this instanceof Checker)
53336103 return;
53346104
5335
- if (display.drawMode == display.SHADOW && PASSTEST)
6105
+ if (display.DrawMode() == display.SHADOW && PASSTEST)
53366106 return;
53376107
53386108 if (count <= 0)
....@@ -5340,13 +6110,13 @@
53406110 return;
53416111 }
53426112
5343
- if ((//display.drawMode == CameraPane.SHADOW ||
5344
- display.drawMode == CameraPane.SELECTION || CameraPane.DEBUG_SELECTION) && HasTransparency())
6113
+ if ((//display.DrawMode() == CameraPane.SHADOW ||
6114
+ display.DrawMode() == iCameraPane.SELECTION || display.IsDebugSelection()) && HasTransparency())
53456115 {
53466116 return;
53476117 }
53486118
5349
- javax.media.opengl.GL gl = display.GetGL();
6119
+ //javax.media.opengl.GL gl = display.GetGL();
53506120
53516121 /*
53526122 if (touched)
....@@ -5364,8 +6134,11 @@
53646134 if (support != null)
53656135 support = support;
53666136
5367
- //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5368
- boolean usecalllists = false; // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
6137
+ boolean usecalllists = !IsDynamic() &&
6138
+ IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
6139
+ //boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
6140
+
6141
+ //usecalllists &= display.DrawMode() == display.DEFAULT; // Don't compute list in shadow pass.
53696142
53706143 if (!usecalllists && bRep != null && bRep.displaylist > 0)
53716144 {
....@@ -5375,30 +6148,33 @@
53756148 // usecalllists &= !(parent instanceof RandomNode);
53766149 // usecalllists = false;
53776150
5378
- if (GetBRep() != null)
5379
- usecalllists = usecalllists;
6151
+ if (display.DrawMode() == display.SHADOW)
6152
+ //GetBRep() != null)
6153
+ usecalllists = !!usecalllists;
53806154 //System.out.println("draw " + this);
53816155 //new Exception().printStackTrace();
53826156
53836157 boolean compiled = false;
53846158
5385
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
6159
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
53866160
5387
- if (!selectmode && //display.drawMode != display.SELECTION &&
5388
- (touched || (bRep != null && bRep.displaylist <= 0)))
6161
+ if (!selectmode && //display.DrawMode() != display.SELECTION &&
6162
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
6163
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
53896164 {
5390
- display.lighttouched = true;
6165
+ Globals.lighttouched = true;
53916166 } // all panes...
5392
- //if (usecalllists && display.drawMode != display.SELECTION && display.drawMode != display.SHADOW &&
5393
- if (bRep != null && usecalllists && !selectmode && // june 2013 display.drawMode != display.SHADOW &&
6167
+
6168
+ //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
6169
+ if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
53946170 (touched || (bRep != null && bRep.displaylist <= 0)))
53956171 {
53966172 if (!(this instanceof Composite))
53976173 touched = false;
53986174 //if (displaylist == -1 && usecalllists)
5399
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
6175
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
54006176 {
5401
- bRep.displaylist = gl.glGenLists(1);
6177
+ bRep.displaylist = display.GenList();
54026178 assert(bRep.displaylist != 0);
54036179 // System.err.println("glGenLists: " + bRep.displaylist + " for " + this);
54046180 //System.out.println("\tgen list " + list);
....@@ -5407,21 +6183,23 @@
54076183
54086184 //System.out.println("\tnew list " + list);
54096185 //gl.glDrawBuffer(gl.GL_NONE);
5410
- if (usecalllists)
6186
+ if (usecalllists && bRep.displaylist > 0)
54116187 {
54126188 // System.err.println("new list " + bRep.displaylist + " for " + this);
5413
- gl.glNewList(bRep.displaylist, gl.GL_COMPILE); //_AND_EXECUTE);
6189
+ display.NewList(bRep.displaylist);
54146190 }
6191
+
54156192 CallList(display, root, selected, blocked);
6193
+
54166194 // compiled = true;
5417
- if (usecalllists)
6195
+ if (usecalllists && bRep.displaylist > 0)
54186196 {
54196197 // System.err.println("end list " + bRep.displaylist + " for " + this);
5420
- gl.glEndList();
6198
+ display.EndList();
54216199 }
54226200 //gl.glDrawBuffer(gl.GL_BACK);
54236201 // XXX touched = false;
5424
- display.lighttouched = true; // all panes...
6202
+ Globals.lighttouched = true; // all panes...
54256203 }
54266204
54276205 touched = GetBRep() == null; // this instanceof Composite || this instanceof FileObject; // false;
....@@ -5460,12 +6238,12 @@
54606238
54616239 // frustum culling
54626240 if (CameraPane.FRUSTUM && !blocked && !IsInfinite() && GetBRep() != null // && GetBRep().VertexCount() != 1260 // default grid
5463
- && display.drawMode != CameraPane.SELECTION)
6241
+ && display.DrawMode() != iCameraPane.SELECTION)
54646242 {
5465
- if (display.drawMode == CameraPane.SHADOW)
6243
+ if (display.DrawMode() == iCameraPane.SHADOW)
54666244 {
54676245 if (!link2master // tricky to cull in shadow mode.
5468
- && GetBRep().FrustumCull(this, gl, display.lightCamera, true))
6246
+ && GetBRep().FrustumCull(this, null, display.LightCamera(), true))
54696247 {
54706248 //System.out.print("CULLED");
54716249 culled = true;
....@@ -5473,7 +6251,7 @@
54736251 }
54746252 else
54756253 //GetBRep().getBounds(v0, v1, this);
5476
- if (GetBRep().FrustumCull(this, gl, display.renderCamera, false))
6254
+ if (GetBRep().FrustumCull(this, null, display.RenderCamera(), false))
54776255 culled = true;
54786256
54796257 // LA.xformPos(v0, display.renderCamera.toScreen, v0);
....@@ -5509,11 +6287,12 @@
55096287
55106288
55116289 if (!culled)
5512
- if (display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION)
6290
+ if (display.DrawMode() == display.SELECTION || display.IsDebugSelection())
55136291 {
55146292 if (GetBRep() != null)
55156293 {
5516
- CameraPane.NextIndex(this, gl);
6294
+ display.NextIndex();
6295
+
55176296 // vertex color conflict : gl.glCallList(list);
55186297 DrawNode(display, root, selected);
55196298 if (this instanceof BezierPatch)
....@@ -5535,55 +6314,7 @@
55356314 color[2] /= 2;
55366315 gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT_AND_DIFFUSE, color, 0);
55376316 */
5538
- if (material != null)
5539
- {
5540
- materialstack[materialdepth] = material;
5541
- selectedstack[materialdepth] = selected;
5542
- cStatic.objectstack[materialdepth++] = this;
5543
- //System.out.println("material " + material);
5544
- //Applet3D.tracein(this, selected);
5545
- display.vector2buffer = projectedVertices;
5546
- if (this instanceof Camera)
5547
- {
5548
- display.options1[0] = material.shift;
5549
- //System.out.println("shift " + material.shift);
5550
- display.options1[1] = material.lightarea;
5551
- display.options1[2] = material.shadowbias;
5552
- display.options1[3] = material.aniso;
5553
- display.options1[4] = material.anisoV;
5554
- display.options2[0] = material.opacity;
5555
- display.options2[1] = material.diffuse;
5556
- display.options2[2] = material.factor;
5557
-
5558
- cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
5559
- display.options4[0] = material.cameralight/0.2f;
5560
- display.options4[1] = material.subsurface;
5561
- display.options4[2] = material.sheen;
5562
-
5563
- // if (display.CURRENTANTIALIAS > 0)
5564
- // display.options3[3] /= 4;
5565
-
5566
- /*
5567
- System.out.println("Focus = " + display.options1[0]);
5568
- System.out.println("Aperture = " + display.options1[1]);
5569
- System.out.println("ShadowBlur = " + display.options1[2]);
5570
- System.out.println("Antialiasing = " + display.options1[3]);
5571
- System.out.println("Fog = " + display.options2[0]);
5572
- System.out.println("Intensity = " + display.options2[1]);
5573
- System.out.println("Elevation = " + display.options2[2]);
5574
- /**/
5575
- } else
5576
- {
5577
- material.Draw(display, selected);
5578
- }
5579
- } else
5580
- {
5581
- if (selected && CameraPane.flash)
5582
- {
5583
- display.modelParams4[1] = 100;
5584
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
5585
- }
5586
- }
6317
+ display.PushMaterial(this, selected);
55876318
55886319 //System.out.println("call list " + list);
55896320 //System.out.println();
....@@ -5602,7 +6333,28 @@
56026333 tex = GetTextures();
56036334 }
56046335
5605
- display.BindTextures(tex, texres);
6336
+ boolean failedPigment = false;
6337
+ boolean failedBump = false;
6338
+
6339
+ try
6340
+ {
6341
+ display.BindPigmentTexture(tex, texres);
6342
+ }
6343
+ catch (Exception e)
6344
+ {
6345
+ System.err.println("FAILED: " + this);
6346
+ failedPigment = true;
6347
+ }
6348
+
6349
+ try
6350
+ {
6351
+ display.BindBumpTexture(tex, texres);
6352
+ }
6353
+ catch (Exception e)
6354
+ {
6355
+ //System.err.println("FAILED: " + this);
6356
+ failedBump = true;
6357
+ }
56066358
56076359 if (!compiled)
56086360 {
....@@ -5618,30 +6370,19 @@
56186370
56196371 // System.err.println("glCallList: " + bRep.displaylist + " for " + this);
56206372 assert(bRep.displaylist != 0);
5621
- gl.glCallList(bRep.displaylist);
6373
+ display.CallList(bRep.displaylist);
56226374 // june 2013 drawSelf(display, root, selected);
56236375 }
56246376 }
56256377 }
56266378
5627
- display.ReleaseTextures(tex);
5628
-
5629
- //if (parent != null && parent.GetMaterial() != null)
5630
- // parent.GetMaterial().Draw(display, parent.IsSelected(this));
5631
- if (material != null)
5632
- {
5633
- materialdepth -= 1;
5634
- if (materialdepth > 0)
5635
- {
5636
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
5637
- materialstack[materialdepth - 1].Draw(display, selectedstack[materialdepth - 1]);
5638
- }
5639
- //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
5640
- } else if (selected && CameraPane.flash && GetMaterial() != null)
5641
- {
5642
- display.modelParams4[1] = GetMaterial().cameralight;
5643
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
5644
- }
6379
+ if (!failedBump)
6380
+ display.ReleaseBumpTexture(tex);
6381
+
6382
+ if (!failedPigment)
6383
+ display.ReleasePigmentTexture(tex);
6384
+
6385
+ display.PopMaterial(this, selected);
56456386 }
56466387
56476388 if (this instanceof Texture || this instanceof TextureNode)
....@@ -5683,7 +6424,7 @@
56836424 // resetMasterNode();
56846425 }
56856426
5686
- void CallList(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
6427
+ void CallList(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
56876428 {
56886429 if (GetBRep() == null)
56896430 {
....@@ -5766,8 +6507,11 @@
57666507 boolean flipV = false; // true;
57676508 int texres = 0; // 0 = low, 1 = normal, 2 = high res texture
57686509
5769
- void drawSelf(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
6510
+ void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57706511 {
6512
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6513
+ return;
6514
+
57716515 if (hide)
57726516 return;
57736517 // shadow optimisation
....@@ -5825,16 +6569,7 @@
58256569 // // ??????????????????????????? Touch();
58266570 // }
58276571
5828
- if (material != null)
5829
- {
5830
- materialstack[materialdepth] = material;
5831
- selectedstack[materialdepth] = selected;
5832
- cStatic.objectstack[materialdepth++] = this;
5833
- //System.out.println("material " + material);
5834
- //Applet3D.tracein("selected ", selected);
5835
- display.vector2buffer = projectedVertices;
5836
- material.Draw(display, selected);
5837
- }
6572
+display.PushMaterial2(this, selected);
58386573
58396574 Object3D child;
58406575 boolean sel;
....@@ -5886,19 +6621,7 @@
58866621 */
58876622 //depth += 1;
58886623
5889
- if (material != null)
5890
- {
5891
- materialdepth -= 1;
5892
- if (materialdepth > 0)
5893
- {
5894
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
5895
- materialstack[materialdepth - 1].Draw(display, selectedstack[materialdepth - 1]);
5896
- }
5897
- //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
5898
- //else
5899
- //material.Draw(display, false);
5900
- }
5901
-
6624
+display.PopMaterial2(this);
59026625 /*
59036626 display.ReleaseTextures(tex);
59046627 */
....@@ -5909,10 +6632,13 @@
59096632
59106633 //static cVector min,max;
59116634
5912
- void DrawNode(CameraPane display, Object3D /*Composite*/ root, boolean selected)
6635
+ void DrawNode(iCameraPane display, Object3D /*Composite*/ root, boolean selected)
59136636 {
5914
- if (display.drawMode == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
6637
+ if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
59156638 return; // no shadow for transparent objects
6639
+
6640
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6641
+ return;
59166642
59176643 if (hide)
59186644 return;
....@@ -5954,11 +6680,12 @@
59546680 return;
59556681 }
59566682
6683
+ //bRep.GenUV(1/material.diffuseness);
59576684 // bRep.lock = true;
59586685
5959
- javax.media.opengl.GL gl = display.GetGL();
6686
+ //javax.media.opengl.GL gl = display.GetGL();
59606687
5961
- if (CameraPane.BOXMODE) // || CameraPane.movingcamera)
6688
+ if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera)
59626689 {
59636690 int fc = bRep.FaceCount();
59646691 int vc = bRep.VertexCount();
....@@ -5973,23 +6700,7 @@
59736700
59746701 bRep.getMinMax(min, max, 100);
59756702
5976
- gl.glBegin(gl.GL_LINES);
5977
-
5978
- gl.glVertex3d(min.x, min.y, min.z);
5979
- gl.glVertex3d(min.x, min.y, max.z);
5980
- gl.glVertex3d(min.x, min.y, min.z);
5981
- gl.glVertex3d(min.x, max.y, min.z);
5982
- gl.glVertex3d(min.x, min.y, min.z);
5983
- gl.glVertex3d(max.x, min.y, min.z);
5984
-
5985
- gl.glVertex3d(max.x, max.y, max.z);
5986
- gl.glVertex3d(min.x, max.y, max.z);
5987
- gl.glVertex3d(max.x, max.y, max.z);
5988
- gl.glVertex3d(max.x, min.y, max.z);
5989
- gl.glVertex3d(max.x, max.y, max.z);
5990
- gl.glVertex3d(max.x, max.y, min.z);
5991
-
5992
- gl.glEnd();
6703
+ display.DrawBox(min, max);
59936704
59946705 return;
59956706 }
....@@ -6033,7 +6744,7 @@
60336744 {
60346745 //throw new Error();
60356746
6036
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
6747
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
60376748
60386749 int[] strips = bRep.getRawIndices();
60396750
....@@ -6043,178 +6754,19 @@
60436754 new Exception().printStackTrace();
60446755 return;
60456756 }
6046
-
6047
- // TRIANGLE STRIP ARRAY
6048
- if (bRep.trimmed)
6757
+
6758
+ if (dontselect)
60496759 {
6050
- float[] v = bRep.getRawVertices();
6051
- float[] n = bRep.getRawNormals();
6052
- float[] c = bRep.getRawColors();
6053
- float[] uv = bRep.getRawUVMap();
6054
-
6055
- int count2 = 0;
6056
- int count3 = 0;
6057
-
6058
- if (n.length > 0)
6059
- {
6060
- for (int i = 0; i < strips.length; i++)
6061
- {
6062
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6063
-
6064
- /*
6065
- boolean locked = false;
6066
- float eps = 0.1f;
6067
- boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
6068
-
6069
- int dot = 0;
6070
-
6071
- if ((dot&1) == 0)
6072
- dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
6073
-
6074
- if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
6075
- gl.glTexCoord2f((float) qv.s, (float) qv.t);
6076
- else
6077
- {
6078
- locked = true;
6079
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6080
- }
6081
- //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6082
- gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
6083
- if (hasnorm)
6084
- {
6085
- //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6086
- gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
6087
- }
6088
-
6089
- if ((dot&4) == 0)
6090
- dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
6091
-
6092
- if (wrap || !locked && (dot&8) != 0)
6093
- gl.glTexCoord2f((float) rv.s, (float) rv.t);
6094
- else
6095
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6096
-
6097
- f.dot = dot;
6098
- */
6099
-
6100
- if (!selectmode)
6101
- {
6102
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6103
- {
6104
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6105
- } else
6106
- {
6107
- gl.glNormal3f(0, 0, 1);
6108
- }
6109
-
6110
- if (c != null)
6111
- //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]);
6112
- {
6113
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6114
- }
6115
- }
6116
- if (flipV)
6117
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6118
- else
6119
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6120
- //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6121
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6122
-
6123
- count2 += 2;
6124
- count3 += 3;
6125
- if (!selectmode)
6126
- {
6127
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6128
- {
6129
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6130
- } else
6131
- {
6132
- gl.glNormal3f(0, 0, 1);
6133
- }
6134
- if (c != null)
6135
- {
6136
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6137
- }
6138
- }
6139
- if (flipV)
6140
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6141
- else
6142
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6143
- //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6144
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6145
-
6146
- count2 += 2;
6147
- count3 += 3;
6148
- for (int j = 0; j < strips[i] - 2; j++)
6149
- {
6150
- //gl.glTexCoord2d(...);
6151
- if (!selectmode)
6152
- {
6153
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6154
- {
6155
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6156
- } else
6157
- {
6158
- gl.glNormal3f(0, 0, 1);
6159
- }
6160
- if (c != null)
6161
- {
6162
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6163
- }
6164
- }
6165
-
6166
- if (flipV)
6167
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6168
- else
6169
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6170
- //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
6171
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6172
- count2 += 2;
6173
- count3 += 3;
6174
- }
6175
-
6176
- gl.glEnd();
6177
- }
6178
- }
6179
-
6180
- assert count3 == v.length;
6760
+ //bRep.GenerateNormalsMINE();
61816761 }
6182
- else // !trimmed
6183
- {
6184
- int count = 0;
6185
- for (int i = 0; i < strips.length; i++)
6186
- {
6187
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6188
-
6189
- Vertex p = bRep.GetVertex(bRep.indices[count++]);
6190
- Vertex q = bRep.GetVertex(bRep.indices[count++]);
6191
-
6192
- drawVertex(gl, p, selectmode);
6193
- drawVertex(gl, q, selectmode);
6194
-
6195
- for (int j = 0; j < strips[i] - 2; j++)
6196
- {
6197
- Vertex r = bRep.GetVertex(bRep.indices[count++]);
6198
-
6199
-// if (j%2 == 0)
6200
-// drawFace(p, q, r, display, null);
6201
-// else
6202
-// drawFace(p, r, q, display, null);
6203
-
6204
-// p = q;
6205
-// q = r;
6206
- drawVertex(gl, r, selectmode);
6207
- }
6208
-
6209
- gl.glEnd();
6210
- }
6211
- }
6762
+
6763
+ display.DrawGeometry(bRep, flipV, selectmode);
62126764 } else // catch (Error e)
62136765 {
62146766 // TRIANGLE ARRAY
62156767 if (IsOpaque()) // Static())
62166768 {
6217
- gl.glBegin(gl.GL_TRIANGLES);
6769
+ display.StartTriangles();
62186770 int facecount = bRep.FaceCount();
62196771 for (int i = 0; i < facecount; i++)
62206772 {
....@@ -6277,9 +6829,9 @@
62776829 // // r.norm.dot(v3) > -0.5)
62786830 // // continue;
62796831
6280
- drawFace(p, q, r, display, face);
6832
+ display.DrawFace(this, p, q, r, face);
62816833 }
6282
- gl.glEnd();
6834
+ display.EndTriangles();
62836835 }
62846836 else
62856837 {
....@@ -6308,8 +6860,8 @@
63086860 //System.out.println("SORT");
63096861
63106862 java.util.Arrays.sort(facescompare);
6311
-
6312
- gl.glBegin(gl.GL_TRIANGLES);
6863
+
6864
+ display.StartTriangles();
63136865 for (int i = 0; i < facecount; i++)
63146866 {
63156867 Face face = bRep.GetFace(facescompare[i].index);
....@@ -6321,13 +6873,14 @@
63216873 Vertex q = bRep.GetVertex(face.q);
63226874 Vertex r = bRep.GetVertex(face.r);
63236875
6324
- drawFace(p, q, r, display, face);
6876
+ display.DrawFace(this, p, q, r, face);
63256877 }
6326
- gl.glEnd();
6878
+ display.EndTriangles();
63276879 }
63286880
63296881 if (false) // live && support != null && support.bRep != null) // debug weights
63306882 {
6883
+ /*
63316884 gl.glDisable(gl.GL_LIGHTING);
63326885 float[] colorV = new float[3];
63336886
....@@ -6406,6 +6959,7 @@
64066959 // gl.glEnd();
64076960 }
64086961 }
6962
+ */
64096963 }
64106964 }
64116965
....@@ -6450,7 +7004,7 @@
64507004 center.add(r);
64517005 center.mul(1.0/3);
64527006
6453
- center.sub(CameraPane.theRenderer.eyeCamera.location);
7007
+ center.sub(Globals.theRenderer.EyeCamera().location);
64547008
64557009 distance = center.dot(center);
64567010 }
....@@ -6461,347 +7015,11 @@
64617015
64627016 transient FaceCompare[] facescompare = null;
64637017
6464
- void SetColor(CameraPane display, Vertex p0)
6465
- {
6466
- if (display.RENDERPROGRAM == 0)
6467
- {
6468
- float r = 0;
6469
- if (bRep != null)
6470
- {
6471
- if (bRep.stripified)
6472
- {
6473
- r = 1;
6474
- }
6475
- }
6476
- float g = 0;
6477
- if (bRep != null)
6478
- {
6479
- if (bRep.trimmed)
6480
- {
6481
- g = 1;
6482
- }
6483
- }
6484
- float b = 0;
6485
- if (support != null && link2master)
6486
- {
6487
- b = 1;
6488
- }
6489
- display.GetGL().glColor3f(r*p0.AO, g*p0.AO, b*p0.AO);
6490
- return;
6491
- }
6492
-
6493
- if (display.drawMode != CameraPane.SHADOW)
6494
- return;
6495
-
6496
- javax.media.opengl.GL gl = display.GetGL();
6497
-// if (true) return;
6498
-// float ao = p.AO;
6499
-//
6500
-// // if (ao == 0 && !bRep.AOdone) // transient problem!
6501
-// // ao = 1;
6502
-//
6503
-// gl.glColor4f(ao, ao, ao, 1);
6504
-
6505
-// CameraPane.selectedpoint.
6506
-// getAverage(cStatic.point1, true);
6507
- if (CameraPane.pointflow == null) // !random) // live)
6508
- {
6509
- return;
6510
- }
6511
-
6512
- cStatic.point1.set(0,0,0);
6513
- LA.xformPos(cStatic.point1, CameraPane.selectedpoint.toParent, cStatic.point1);
6514
-
6515
- cStatic.point1.sub(p0);
6516
-
6517
-
6518
-// if (marked && (p0.vertexlinks == null || support == null || support.bRep == null)) // no position delta?
6519
-// {
6520
-// return;
6521
-// }
6522
-
6523
- //if (true)
6524
- if (cStatic.point1.dot(cStatic.point1) > 0.000001)
6525
- {
6526
- return;
6527
- }
6528
-
6529
- float[] colorV = new float[3];
6530
-
6531
- if (false) // marked)
6532
- {
6533
- // debug rigging weights
6534
- for (int object = 0; object < p0.vertexlinks.length; object++)
6535
- {
6536
- float weight = p0.weights[object] / p0.totalweight;
6537
-
6538
- // if (weight < 0.1)
6539
- // {
6540
- // assert(weight == 0);
6541
- // continue;
6542
- // }
6543
-
6544
- if (p0.vertexlinks[object] == -1)
6545
- continue;
6546
-
6547
- Vertex q = support.bRep.GetVertex(p0.vertexlinks[object]);
6548
-
6549
- int color = //1 << object; //
6550
- //p.vertexlinks.length;
6551
- support.bRep.supports[p0.closestsupport].links[object];
6552
- colorV[2] += (color & 1) * weight;
6553
- colorV[1] += ((color & 2) >> 1) * weight;
6554
- colorV[0] += ((color & 4) >> 2) * weight;
6555
- }
6556
- }
6557
- else
6558
- {
6559
- if (drawingstarted)
6560
- {
6561
- // find next point
6562
- if (bRep.GetVertex(0).faceindices == null)
6563
- {
6564
- bRep.InitFaceIndices();
6565
- }
6566
-
6567
- double ymin = p0.y;
6568
-
6569
- Vertex newp = p0;
6570
-
6571
- for (int fii = 0; fii < p0.faceindices.length; fii++)
6572
- {
6573
- int fi = p0.faceindices[fii];
6574
-
6575
- if (fi == -1)
6576
- break;
6577
-
6578
- Face f = bRep.GetFace(fi);
6579
-
6580
- Vertex p = bRep.GetVertex(f.p);
6581
- Vertex q = bRep.GetVertex(f.q);
6582
- Vertex r = bRep.GetVertex(f.r);
6583
-
6584
- int swap = (int)(Math.random()*3);
6585
-
6586
-// for (int s=swap; --s>=0;)
6587
-// {
6588
-// Vertex t = p;
6589
-// p = q;
6590
-// q = r;
6591
-// r = t;
6592
-// }
6593
- if (ymin > p.y)
6594
- {
6595
- ymin = p.y;
6596
- newp = p;
6597
-// break;
6598
- }
6599
- if (ymin > q.y)
6600
- {
6601
- ymin = q.y;
6602
- newp = q;
6603
-// break;
6604
- }
6605
- if (ymin > r.y)
6606
- {
6607
- ymin = r.y;
6608
- newp = r;
6609
-// break;
6610
- }
6611
- }
6612
-
6613
- CameraPane.selectedpoint.toParent[3][0] = newp.x;
6614
- CameraPane.selectedpoint.toParent[3][1] = newp.y;
6615
- CameraPane.selectedpoint.toParent[3][2] = newp.z;
6616
-
6617
- drawingstarted = false;
6618
-
6619
- // return;
6620
- }
6621
-
6622
- if (false) // CameraPane.DRAW
6623
- {
6624
- p0.AO = colorV[0] = 2;
6625
- colorV[1] = 2;
6626
- colorV[2] = 2;
6627
- }
6628
-
6629
- CameraPane.pointflow.add(p0);
6630
- CameraPane.pointflow.Touch();
6631
- }
6632
-
6633
-// gl.glColor3f(colorV[0], colorV[1], colorV[2]);
6634
-// gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0);
6635
-// gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
6636
- }
6637
-
66387018 void Print(Vertex v)
66397019 {
66407020 //System.err.println("(" + v.x + ", " + v.y + ", " + v.z + ")");
66417021 }
66427022
6643
- void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean selectmode)
6644
- {
6645
- if (!selectmode)
6646
- {
6647
- gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
6648
- gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
6649
-
6650
- if (flipV)
6651
- gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
6652
- else
6653
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6654
- }
6655
-
6656
- gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
6657
- }
6658
-
6659
- void drawFace(Vertex pv, Vertex qv, Vertex rv,
6660
- CameraPane display, Face face)
6661
- {
6662
- if (pv.y == -10000 ||
6663
- qv.y == -10000 ||
6664
- rv.y == -10000)
6665
- return;
6666
-
6667
-// float b = f.nbiterations & 1;
6668
-// float g = (f.nbiterations>>1) & 1;
6669
-// float r = (f.nbiterations>>2) & 1;
6670
-//
6671
-// //if (f.weight == 10000)
6672
-// //{
6673
-// // r = 1; g = b = 0;
6674
-// //}
6675
-// //else
6676
-// //{
6677
-// // assert(f.weight < 10000);
6678
-// r = g = b = (float)bRep.FaceWeight(f)*100;
6679
-// if (r<0)
6680
-// assert(r>=0);
6681
-// //}
6682
-
6683
- javax.media.opengl.GL gl = display.GetGL();
6684
-
6685
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
6686
-
6687
- //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv);
6688
- if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
6689
- {
6690
- //gl.glBegin(gl.GL_TRIANGLES);
6691
- boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
6692
- if (!hasnorm)
6693
- {
6694
- // System.out.println("FUCK!!");
6695
- LA.vecSub(pv/*.pos*/, qv/*.pos*/, v0);
6696
- LA.vecSub(pv/*.pos*/, rv/*.pos*/, v1);
6697
- LA.vecCross(v0, v1, v2);
6698
- LA.vecNormalize(v2);
6699
- gl.glNormal3f((float) v2.x, (float) v2.y, (float) v2.z);
6700
- }
6701
-
6702
- if (hasnorm)
6703
- {
6704
-// if (!pv.norm.normalized())
6705
-// assert(pv.norm.normalized());
6706
-
6707
- //System.out.println("normalp = " + pv.norm.x + ", " + pv.norm.y + ", " + pv.norm.z);
6708
- gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
6709
- }
6710
- gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
6711
- SetColor(display, pv);
6712
- //gl.glColor4f(r, g, b, 1);
6713
- //gl.glColor4f(pv.boundary, pv.boundary, pv.boundary, 1);
6714
- if (flipV)
6715
- gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
6716
- else
6717
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6718
- //System.out.println("vertexp = " + pv.x + ", " + pv.y + ", " + pv.z);
6719
- gl.glVertex3f((float) pv./*pos.*/x, (float) pv./*pos.*/y, (float) pv./*pos.*/z);
6720
-// Print(pv);
6721
- if (hasnorm)
6722
- {
6723
-// assert(qv.norm.normalized());
6724
- //System.out.println("normalq = " + qv.norm.x + ", " + qv.norm.y + ", " + qv.norm.z);
6725
- gl.glNormal3f((float) qv.norm.x, (float) qv.norm.y, (float) qv.norm.z);
6726
- }
6727
- //System.out.println("vertexq = " + qv.s + ", " + qv.t);
6728
- // boolean locked = false;
6729
- // float eps = 0.1f;
6730
- // boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
6731
-
6732
- // int dot = 0; //*/ (int)f.dot;
6733
-
6734
- // if ((dot&1) == 0)
6735
- // dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
6736
-
6737
- // if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
6738
- if (flipV)
6739
- gl.glTexCoord2f((float) qv.s, 1-(float) qv.t);
6740
- else
6741
- gl.glTexCoord2f((float) qv.s, (float) qv.t);
6742
- // else
6743
- // {
6744
- // locked = true;
6745
- // gl.glTexCoord2f((float) pv.s, (float) pv.t);
6746
- // }
6747
- gl.glColor4f(qv.AO, qv.AO, qv.AO, 1);
6748
- SetColor(display, qv);
6749
- //gl.glColor4f(r, g, b, 1);
6750
- //gl.glColor4f(qv.boundary, qv.boundary, qv.boundary, 1);
6751
- //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6752
- gl.glVertex3f((float) qv./*pos.*/x, (float) qv./*pos.*/y, (float) qv./*pos.*/z);
6753
-// Print(qv);
6754
- if (hasnorm)
6755
- {
6756
-// assert(rv.norm.normalized());
6757
- //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6758
- gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
6759
- }
6760
-
6761
- // if ((dot&4) == 0)
6762
- // dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
6763
-
6764
- // if (wrap || !locked && (dot&8) != 0)
6765
- if (flipV)
6766
- gl.glTexCoord2f((float) rv.s, 1-(float) rv.t);
6767
- else
6768
- gl.glTexCoord2f((float) rv.s, (float) rv.t);
6769
- // else
6770
- // gl.glTexCoord2f((float) pv.s, (float) pv.t);
6771
-
6772
- // f.dot = dot;
6773
-
6774
- gl.glColor4f(rv.AO, rv.AO, rv.AO, 1);
6775
- SetColor(display, rv);
6776
- //gl.glColor4f(r, g, b, 1);
6777
- //gl.glColor4f(rv.boundary, rv.boundary, rv.boundary, 1);
6778
- //System.out.println("vertexr = " + rv.x + ", " + rv.y + ", " + rv.z);
6779
- gl.glVertex3f((float) rv./*pos.*/x, (float) rv./*pos.*/y, (float) rv./*pos.*/z);
6780
-// Print(rv);
6781
- //gl.glEnd();
6782
- }
6783
- else
6784
- {
6785
- gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
6786
- gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
6787
- gl.glVertex3f((float) rv.x, (float) rv.y, (float) rv.z);
6788
-
6789
- }
6790
-
6791
- if (false) // (attributes & WIREFRAME) != 0)
6792
- {
6793
- gl.glDisable(gl.GL_LIGHTING);
6794
-
6795
- gl.glBegin(gl.GL_LINE_LOOP);
6796
- gl.glVertex3d(pv./*pos.*/x, pv./*pos.*/y, pv./*pos.*/z);
6797
- gl.glVertex3d(qv./*pos.*/x, qv./*pos.*/y, qv./*pos.*/z);
6798
- gl.glVertex3d(rv./*pos.*/x, rv./*pos.*/y, rv./*pos.*/z);
6799
- gl.glEnd();
6800
-
6801
- gl.glEnable(gl.GL_LIGHTING);
6802
- }
6803
- }
6804
-
68057023 void drawSelf(ClickInfo info, int level, boolean select)
68067024 {
68077025 if (bRep == null)
....@@ -7325,20 +7543,23 @@
73257543 }
73267544 }
73277545
7328
- protected void calcHotSpot(cVector in, ClickInfo info, Point outPt, Rectangle outRec)
7546
+ static ClickInfo clickInfo = new ClickInfo();
7547
+
7548
+ protected void calcHotSpot(cVector in, //ClickInfo clickInfo,
7549
+ Point outPt, Rectangle outRec)
73297550 {
7330
- int hc = info.bounds.x + info.bounds.width / 2;
7331
- int vc = info.bounds.y + info.bounds.height / 2;
7332
- double[][] toscreen = info.toScreen;
7551
+ int hc = clickInfo.bounds.x + clickInfo.bounds.width / 2;
7552
+ int vc = clickInfo.bounds.y + clickInfo.bounds.height / 2;
7553
+ double[][] toscreen = clickInfo.toScreen;
73337554 if (toscreen == null)
73347555 {
7335
- toscreen = new Camera(info.camera.viewCode).toScreen;
7556
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
73367557 }
73377558 cVector vec = in;
73387559 LA.xformPos(in, toscreen, in);
73397560 //System.out.println("Distance = " + info.camera.Distance());
7340
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
7341
- vec.y *= 100 * info.camera.SCALE / info.camera.Distance();
7561
+ vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
7562
+ vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
73427563 outPt.x = hc + (int) vec.x;
73437564 outPt.y = vc - (int) vec.y;
73447565 outRec.x = outPt.x - 3;
....@@ -7346,15 +7567,18 @@
73467567 outRec.width = outRec.height = 6;
73477568 }
73487569
7349
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7570
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7571
+ )
73507572 {
73517573 Point pt = new Point(0, 0);
73527574 Rectangle rec = new Rectangle();
7353
- calcHotSpot(in, info, pt, rec);
7575
+ calcHotSpot(in, //clickInfo,
7576
+ pt, rec);
73547577 return rec;
73557578 }
73567579
7357
- void drawEditHandles0(ClickInfo info, int level)
7580
+ void drawEditHandles0(//ClickInfo clickInfo,
7581
+ int level)
73587582 {
73597583 if (level == 0)
73607584 {
....@@ -7363,98 +7587,104 @@
73637587 {
73647588 cVector origin = new cVector();
73657589 //LA.xformPos(origin, toParent, origin);
7366
- Rectangle spot = calcHotSpot(origin, info);
7590
+ if (this.clickInfo == null)
7591
+ this.clickInfo = new ClickInfo();
7592
+
7593
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
73677594 Rectangle boundary = new Rectangle();
73687595 boundary.x = spot.x - 30;
73697596 boundary.y = spot.y - 30;
73707597 boundary.width = spot.width + 60;
73717598 boundary.height = spot.height + 60;
7372
- info.g.setColor(Color.red);
7599
+ clickInfo.g.setColor(Color.white);
73737600 int spotw = spot.x + spot.width;
73747601 int spoth = spot.y + spot.height;
7375
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7376
- if (CameraPane.Xmin > spot.x)
7377
- {
7378
- CameraPane.Xmin = spot.x;
7379
- }
7380
- if (CameraPane.Xmax < spotw)
7381
- {
7382
- CameraPane.Xmax = spotw;
7383
- }
7384
- if (CameraPane.Ymin > spot.y)
7385
- {
7386
- CameraPane.Ymin = spot.y;
7387
- }
7388
- if (CameraPane.Ymax < spoth)
7389
- {
7390
- CameraPane.Ymax = spoth;
7391
- }
7392
- spot.translate(32, 32);
7602
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7603
+// if (CameraPane.Xmin > spot.x)
7604
+// {
7605
+// CameraPane.Xmin = spot.x;
7606
+// }
7607
+// if (CameraPane.Xmax < spotw)
7608
+// {
7609
+// CameraPane.Xmax = spotw;
7610
+// }
7611
+// if (CameraPane.Ymin > spot.y)
7612
+// {
7613
+// CameraPane.Ymin = spot.y;
7614
+// }
7615
+// if (CameraPane.Ymax < spoth)
7616
+// {
7617
+// CameraPane.Ymax = spoth;
7618
+// }
7619
+// if (CameraPane.Xmin > spot.x)
7620
+// {
7621
+// CameraPane.Xmin = spot.x;
7622
+// }
7623
+// if (CameraPane.Xmax < spotw)
7624
+// {
7625
+// CameraPane.Xmax = spotw;
7626
+// }
7627
+// if (CameraPane.Ymin > spot.y)
7628
+// {
7629
+// CameraPane.Ymin = spot.y;
7630
+// }
7631
+// if (CameraPane.Ymax < spoth)
7632
+// {
7633
+// CameraPane.Ymax = spoth;
7634
+// }
7635
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7636
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
7637
+ spot.translate(32, 0);
7638
+ clickInfo.g.setColor(Color.yellow);
7639
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7640
+
7641
+ spot.translate(32, 64);
73937642 spotw = spot.x + spot.width;
73947643 spoth = spot.y + spot.height;
7395
- info.g.setColor(Color.blue);
7396
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7397
- if (CameraPane.Xmin > spot.x)
7398
- {
7399
- CameraPane.Xmin = spot.x;
7400
- }
7401
- if (CameraPane.Xmax < spotw)
7402
- {
7403
- CameraPane.Xmax = spotw;
7404
- }
7405
- if (CameraPane.Ymin > spot.y)
7406
- {
7407
- CameraPane.Ymin = spot.y;
7408
- }
7409
- if (CameraPane.Ymax < spoth)
7410
- {
7411
- CameraPane.Ymax = spoth;
7412
- }
7413
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7414
- info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7415
- spot.translate(0, -32);
7416
- info.g.setColor(Color.green);
7417
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7418
- if (CameraPane.Xmin > spot.x)
7419
- {
7420
- CameraPane.Xmin = spot.x;
7421
- }
7422
- if (CameraPane.Xmax < spotw)
7423
- {
7424
- CameraPane.Xmax = spotw;
7425
- }
7426
- if (CameraPane.Ymin > spot.y)
7427
- {
7428
- CameraPane.Ymin = spot.y;
7429
- }
7430
- if (CameraPane.Ymax < spoth)
7431
- {
7432
- CameraPane.Ymax = spoth;
7433
- }
7434
- info.g.drawArc(boundary.x, boundary.y,
7435
- boundary.width, boundary.height, 0, 360);
7644
+ clickInfo.g.setColor(Color.cyan);
7645
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7646
+// if (CameraPane.Xmin > spot.x)
7647
+// {
7648
+// CameraPane.Xmin = spot.x;
7649
+// }
7650
+// if (CameraPane.Xmax < spotw)
7651
+// {
7652
+// CameraPane.Xmax = spotw;
7653
+// }
7654
+// if (CameraPane.Ymin > spot.y)
7655
+// {
7656
+// CameraPane.Ymin = spot.y;
7657
+// }
7658
+// if (CameraPane.Ymax < spoth)
7659
+// {
7660
+// CameraPane.Ymax = spoth;
7661
+// }
7662
+ clickInfo.g.setColor(Color.green);
7663
+ clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
7664
+ (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
74367665 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
7437
- if (CameraPane.Xmin > boundary.x)
7438
- {
7439
- CameraPane.Xmin = boundary.x;
7440
- }
7441
- if (CameraPane.Xmax < boundary.x + boundary.width)
7442
- {
7443
- CameraPane.Xmax = boundary.x + boundary.width;
7444
- }
7445
- if (CameraPane.Ymin > boundary.y)
7446
- {
7447
- CameraPane.Ymin = boundary.y;
7448
- }
7449
- if (CameraPane.Ymax < boundary.y + boundary.height)
7450
- {
7451
- CameraPane.Ymax = boundary.y + boundary.height;
7452
- }
7666
+// if (CameraPane.Xmin > boundary.x)
7667
+// {
7668
+// CameraPane.Xmin = boundary.x;
7669
+// }
7670
+// if (CameraPane.Xmax < boundary.x + boundary.width)
7671
+// {
7672
+// CameraPane.Xmax = boundary.x + boundary.width;
7673
+// }
7674
+// if (CameraPane.Ymin > boundary.y)
7675
+// {
7676
+// CameraPane.Ymin = boundary.y;
7677
+// }
7678
+// if (CameraPane.Ymax < boundary.y + boundary.height)
7679
+// {
7680
+// CameraPane.Ymax = boundary.y + boundary.height;
7681
+// }
74537682 return;
74547683 }
74557684 }
74567685
7457
- boolean doEditClick0(ClickInfo info, int level)
7686
+ boolean doEditClick0(//ClickInfo clickInfo,
7687
+ int level)
74587688 {
74597689 if (level == 0)
74607690 {
....@@ -7463,10 +7693,10 @@
74637693
74647694 boolean retval = false;
74657695
7466
- startX = info.x;
7467
- startY = info.y;
7696
+ startX = clickInfo.x;
7697
+ startY = clickInfo.y;
74687698
7469
- hitSomething = 0;
7699
+ hitSomething = -1;
74707700 cVector origin = new cVector();
74717701 //LA.xformPos(origin, toParent, origin);
74727702 Rectangle spot = new Rectangle();
....@@ -7474,22 +7704,53 @@
74747704 {
74757705 centerPt = new Point(0, 0);
74767706 }
7477
- calcHotSpot(origin, info, centerPt, spot);
7478
- if (spot.contains(info.x, info.y))
7707
+ calcHotSpot(origin, //info,
7708
+ centerPt, spot);
7709
+ if (spot.contains(clickInfo.x, clickInfo.y))
74797710 {
74807711 hitSomething = hitCenter;
74817712 retval = true;
74827713 }
74837714 spot.translate(32, 0);
7484
- if (spot.contains(info.x, info.y))
7715
+ if (spot.contains(clickInfo.x, clickInfo.y))
74857716 {
74867717 hitSomething = hitRotate;
74877718 retval = true;
74887719 }
74897720 spot.translate(0, 32);
7490
- if (spot.contains(info.x, info.y))
7721
+ spot.translate(32, 0);
7722
+ spot.translate(0, 32);
7723
+ if (spot.contains(clickInfo.x, clickInfo.y))
74917724 {
74927725 hitSomething = hitScale;
7726
+
7727
+ double scale = 0.005f * clickInfo.camera.Distance();
7728
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
7729
+ double sign = 1;
7730
+ if (hScale < 0)
7731
+ {
7732
+ sign = -1;
7733
+ }
7734
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
7735
+ if (hScale < 0.01)
7736
+ {
7737
+ //hScale = 0.01;
7738
+ }
7739
+
7740
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
7741
+ sign = 1;
7742
+ if (vScale < 0)
7743
+ {
7744
+ sign = -1;
7745
+ }
7746
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
7747
+ if (vScale < 0.01)
7748
+ {
7749
+ //vScale = 0.01;
7750
+ }
7751
+
7752
+ clickInfo.scale = Math.sqrt(hScale*hScale + vScale*vScale);
7753
+
74937754 retval = true;
74947755 }
74957756
....@@ -7499,7 +7760,7 @@
74997760 }
75007761
75017762 //System.out.println("info.modifiers = " + info.modifiers);
7502
- modified = (info.modifiers & CameraPane.META) != 0;
7763
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
75037764 //System.out.println("modified = " + modified);
75047765 //new Exception().printStackTrace();
75057766 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7527,7 +7788,8 @@
75277788 return true;
75287789 }
75297790
7530
- void doEditDrag0(ClickInfo info)
7791
+ void doEditDrag0(//ClickInfo info,
7792
+ boolean opposite)
75317793 {
75327794 if (hitSomething == 0)
75337795 {
....@@ -7541,7 +7803,8 @@
75417803
75427804 //System.out.println("hitSomething = " + hitSomething);
75437805
7544
- double scale = 0.005f * info.camera.Distance();
7806
+ double scale = 0.005f * clickInfo.camera.Distance();
7807
+
75457808 cVector xlate = new cVector();
75467809 //cVector xlate2 = new cVector();
75477810 switch (hitSomething)
....@@ -7552,9 +7815,11 @@
75527815
75537816 case hitCenter: // Translate
75547817
7555
- scale *= 0.05f * info.pane.theRenderer.renderCamera.Distance();
7818
+ scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
75567819
7557
- if (modified)
7820
+ // Modified could snap
7821
+ if (//modified ||
7822
+ opposite)
75587823 {
75597824 //assert(false);
75607825 /*
....@@ -7574,8 +7839,8 @@
75747839 toParent[3][i] = xlate.get(i);
75757840 LA.matInvert(toParent, fromParent);
75767841 */
7577
- cVector delta = LA.newVector(0, 0, startY - info.y);
7578
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7842
+ cVector delta = LA.newVector(0, 0, startY - clickInfo.y);
7843
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
75797844
75807845 LA.matCopy(startMat, toParent);
75817846 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7584,7 +7849,7 @@
75847849 } else
75857850 {
75867851 //LA.xformDir(delta, info.camera.fromScreen, delta);
7587
- cVector up = new cVector(info.camera.up);
7852
+ cVector up = new cVector(clickInfo.camera.up);
75887853 cVector away = new cVector();
75897854 //cVector right2 = new cVector();
75907855 //LA.vecCross(up, cVector.Z, right);
....@@ -7600,20 +7865,20 @@
76007865 }
76017866 LA.xformDir(up, ClickInfo.matbuffer, up);
76027867 // if (!CameraPane.LOCALTRANSFORM)
7603
- LA.xformDir(up, info.pane.theRenderer.renderCamera.toScreen, up);
7604
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7868
+ LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7869
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
76057870 // if (!CameraPane.LOCALTRANSFORM)
7606
- LA.xformDir(away, info.pane.theRenderer.renderCamera.toScreen, away);
7871
+ LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
76077872 //LA.vecCross(up, cVector.Z, right2);
76087873
7609
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7874
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
76107875
76117876 //System.out.println("DELTA0 = " + delta);
76127877 //System.out.println("AWAY = " + info.camera.away);
76137878 //System.out.println("UP = " + info.camera.up);
76147879 if (away.z > 0)
76157880 {
7616
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7881
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
76177882 {
76187883 delta.x = -delta.x;
76197884 } else
....@@ -7628,7 +7893,7 @@
76287893 //System.out.println("DELTA1 = " + delta);
76297894 LA.xformDir(delta, ClickInfo.matbuffer, delta);
76307895 //System.out.println("DELTA2 = " + delta);
7631
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7896
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
76327897 LA.matCopy(startMat, toParent);
76337898 //System.out.println("DELTA3 = " + delta);
76347899 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7638,8 +7903,8 @@
76387903 break;
76397904
76407905 case hitRotate: // rotate
7641
- int dx = info.x - centerPt.x;
7642
- int dy = -(info.y - centerPt.y);
7906
+ int dx = clickInfo.x - centerPt.x;
7907
+ int dy = -(clickInfo.y - centerPt.y);
76437908 double angle = (double) Math.atan2(dx, dy);
76447909 angle = -(1.570796 - angle);
76457910
....@@ -7648,6 +7913,7 @@
76487913
76497914 if (modified)
76507915 {
7916
+ // Rotate 45 degrees
76517917 angle /= (Math.PI / 4);
76527918 angle = Math.floor(angle + 0.5);
76537919 angle *= (Math.PI / 4);
....@@ -7661,7 +7927,7 @@
76617927 }
76627928 /**/
76637929
7664
- switch (info.pane.renderCamera.viewCode)
7930
+ switch (clickInfo.pane.RenderCamera().viewCode)
76657931 {
76667932 case 1: // '\001'
76677933 LA.matZRotate(toParent, angle);
....@@ -7688,26 +7954,30 @@
76887954 break;
76897955
76907956 case hitScale: // scale
7691
- double hScale = (double) (info.x - centerPt.x) / 32;
7957
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
7958
+ double sign = 1;
7959
+ if (hScale < 0)
7960
+ {
7961
+ sign = -1;
7962
+ }
7963
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
76927964 if (hScale < 0.01)
76937965 {
7694
- hScale = 0.01;
7966
+ //hScale = 0.01;
76957967 }
7696
- hScale = Math.pow(hScale, scale * 50);
7697
- if (hScale < 0.01)
7968
+
7969
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
7970
+ sign = 1;
7971
+ if (vScale < 0)
76987972 {
7699
- hScale = 0.01;
7973
+ sign = -1;
77007974 }
7701
- double vScale = (double) (info.y - centerPt.y) / 32;
7975
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
77027976 if (vScale < 0.01)
77037977 {
7704
- vScale = 0.01;
7978
+ //vScale = 0.01;
77057979 }
7706
- vScale = Math.pow(vScale, scale * 50);
7707
- if (vScale < 0.01)
7708
- {
7709
- vScale = 0.01;
7710
- }
7980
+
77117981 LA.matCopy(startMat, toParent);
77127982 /**/
77137983 for (int i = 0; i < 3; i++)
....@@ -7717,39 +7987,56 @@
77177987 }
77187988 /**/
77197989
7720
- switch (info.pane.renderCamera.viewCode)
7990
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
7991
+
7992
+ if (totalScale < 0.01)
7993
+ {
7994
+ totalScale = 0.01;
7995
+ }
7996
+
7997
+ switch (clickInfo.pane.RenderCamera().viewCode)
77217998 {
77227999 case 3: // '\001'
7723
- if (modified)
8000
+ if (modified || opposite)
77248001 {
8002
+ if (modified) // && opposite)
8003
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
8004
+ else
77258005 //LA.matScale(toParent, 1, hScale, vScale);
7726
- LA.matScale(toParent, vScale, 1, 1);
8006
+ LA.matScale(toParent, totalScale, 1, 1);
77278007 } // vScale, 1);
77288008 else
77298009 {
7730
- LA.matScale(toParent, vScale, vScale, vScale);
8010
+ // EXCEPTION!
8011
+ LA.matScale(toParent, 1, totalScale, totalScale);
77318012 } // vScale, 1);
77328013 break;
77338014
77348015 case 2: // '\002'
7735
- if (modified)
8016
+ if (modified || opposite)
77368017 {
7737
- //LA.matScale(toParent, hScale, 1, vScale);
7738
- LA.matScale(toParent, 1, vScale, 1);
8018
+ if (modified) // && opposite)
8019
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
8020
+ else
8021
+ //LA.matScale(toParent, hScale, 1, vScale);
8022
+ LA.matScale(toParent, 1, totalScale, 1);
77398023 } else
77408024 {
7741
- LA.matScale(toParent, vScale, 1, vScale);
8025
+ LA.matScale(toParent, totalScale, 1, totalScale);
77428026 }
77438027 break;
77448028
77458029 case 1: // '\003'
7746
- if (modified)
8030
+ if (modified || opposite)
77478031 {
7748
- //LA.matScale(toParent, hScale, vScale, 1);
7749
- LA.matScale(toParent, 1, 1, vScale);
8032
+ if (modified) // && opposite)
8033
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
8034
+ else
8035
+ //LA.matScale(toParent, hScale, vScale, 1);
8036
+ LA.matScale(toParent, 1, 1, totalScale);
77508037 } else
77518038 {
7752
- LA.matScale(toParent, vScale, vScale, 1);
8039
+ LA.matScale(toParent, totalScale, totalScale, 1);
77538040 }
77548041 break;
77558042 }
....@@ -7783,7 +8070,7 @@
77838070 } // NEW ...
77848071
77858072
7786
- info.pane.repaint();
8073
+ clickInfo.pane.repaint();
77878074 }
77888075
77898076 boolean overflow = false;
....@@ -7882,14 +8169,22 @@
78828169 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
78838170 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
78848171 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
8172
+
8173
+ String objname;
8174
+
78858175 if (false) //parent != null)
78868176 {
7887
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
8177
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
78888178 } else
78898179 {
7890
- return GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ") ")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ +System.identityHashCode(this);
8180
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
78918181 } // + super.toString();
78928182 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
8183
+
8184
+// if (!Globals.ADVANCED)
8185
+// return objname;
8186
+
8187
+ return objname + " " + System.identityHashCode(this); // + GetUUID()
78938188 }
78948189
78958190 public int hashCode()
....@@ -7945,6 +8240,7 @@
79458240 objectUI.closeUI();
79468241 if (editWindow != null)
79478242 {
8243
+ editWindow.ctrlPanel.FlushUI();
79488244 editWindow.refreshContents();
79498245 } // ? new
79508246 objectUI = null;
....@@ -7953,6 +8249,10 @@
79538249 {
79548250 editWindow = null;
79558251 } // ?
8252
+ }
8253
+ else
8254
+ {
8255
+ //editWindow.closeUI();
79568256 }
79578257 }
79588258
....@@ -7965,7 +8265,7 @@
79658265 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
79668266
79678267 Object3D /*Composite*/ parent;
7968
- Object3D /*Composite*/ fileparent;
8268
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
79698269
79708270 double[][] toParent; // dynamic matrix
79718271 double[][] fromParent;
....@@ -8080,7 +8380,7 @@
80808380 {
80818381 assert(bRep != null);
80828382 if (!(support instanceof GenericJoint)) // support.bRep != null)
8083
- GrafreeD.Assert(support.bRep == bRep.support);
8383
+ Grafreed.Assert(support.bRep == bRep.support);
80848384 }
80858385 else
80868386 {
....@@ -8111,6 +8411,10 @@
81118411 }
81128412
81138413 transient ObjEditor editWindow;
8414
+ transient ObjEditor manipWindow;
8415
+
8416
+ transient boolean pinned;
8417
+
81148418 transient ObjectUI objectUI;
81158419 public static int povDepth = 0;
81168420 private static cVector tbMin = new cVector();
....@@ -8129,9 +8433,9 @@
81298433 private static cVector edge2 = new cVector();
81308434 //private static cVector norm = new cVector();
81318435 /*transient private*/ int hitSomething;
8132
- private static final int hitCenter = 1;
8133
- private static final int hitScale = 2;
8134
- private static final int hitRotate = 3;
8436
+ static final int hitCenter = 1;
8437
+ static final int hitScale = 2;
8438
+ static final int hitRotate = 3;
81358439 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
81368440 /*transient*/ private Point centerPt;
81378441 /*transient*/ private int startX;
....@@ -8163,6 +8467,8 @@
81638467 {
81648468 Object3D targ = this;
81658469
8470
+ targ.NORMALPUSH = obj.NORMALPUSH;
8471
+
81668472 if (obj.material != null)
81678473 {
81688474 if ((mask&MATERIAL)!=0) // ==(COLOR|MATERIAL))