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,7 +581,7 @@
351581 }
352582 }
353583
354
- int memorysize;
584
+ transient int memorysize; // needs to be transient, dunno why
355585
356586 int MemorySize()
357587 {
....@@ -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
....@@ -1446,7 +1692,16 @@
14461692 // if (other == null)
14471693 // return;
14481694
1449
- System.out.println("Link support this = " + this + "; other = " + other);
1695
+ if (other != null)
1696
+ {
1697
+ BoundaryRep.SEUIL = other.material.cameralight;
1698
+
1699
+ // Set default to 0.1
1700
+ BoundaryRep.SEUIL /= 4; // 2;
1701
+ System.out.println("SEUIL = " + BoundaryRep.SEUIL);
1702
+ }
1703
+
1704
+ System.out.println("Link this = " + this + "; support = " + other);
14501705
14511706 //if (bRep != null)
14521707 // bRep.linkVerticesThis(other.bRep);
....@@ -1701,7 +1956,7 @@
17011956 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17021957 o.bRep = transientrep;
17031958 if (clone)
1704
- o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
1959
+ o.bRep = (BoundaryRep) Grafreed.clone(transientrep);
17051960 o.CreateMaterial();
17061961 o.SetAttributes(this, -1);
17071962 //parent
....@@ -1714,7 +1969,7 @@
17141969 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17151970 o.bRep = bRep;
17161971 if (clone)
1717
- o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
1972
+ o.bRep = (BoundaryRep) Grafreed.clone(bRep);
17181973 o.CreateMaterial();
17191974 //o.overwriteThis(this, -1);
17201975 o.SetAttributes(this, -1);
....@@ -1801,12 +2056,15 @@
18012056 if (obj.name == null)
18022057 continue; // can't be a null one
18032058
2059
+ // Try perfect match first.
18042060 if (n.equals(obj.name))
18052061 {
18062062 theobj = obj;
18072063 count++;
18082064 }
18092065 }
2066
+
2067
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18102068
18112069 if (count != 1)
18122070 for (int i=Size(); --i>=0;)
....@@ -1816,8 +2074,9 @@
18162074 if (obj.name == null)
18172075 continue; // can't be a null one
18182076
1819
- //if (n.contains(obj.name)) // dec 2013 name.split(":")[0])) // Poser generates a count
1820
- if (n.startsWith(obj.name))
2077
+ String name = obj.name.split(":")[0]; // Poser generates a count
2078
+ //if (n.startsWith(obj.name))
2079
+ if (n.contains(name))
18212080 {
18222081 theobj = obj;
18232082 count++;
....@@ -2120,21 +2379,9 @@
21202379 if (/*parent != null &&*/ material == null)
21212380 {
21222381 material = new cMaterial(GetMaterial());
2123
- if (projectedVertices == null || projectedVertices.length <= 2)
2124
- {
2125
- projectedVertices = new Object3D.cVector2[3];
2126
- }
2127
- for (int i = 0; i < 3; i++)
2128
- {
2129
- projectedVertices[i] = new cVector2(); // Others
2130
- }
2131
- projectedVertices[0].x = 100; // bump
21322382
2133
- if (this instanceof Camera)
2134
- {
2135
- material.shift = 90;
2136
- }
2137
-
2383
+ InitOthers();
2384
+
21382385 material.multiply = multiply;
21392386
21402387 if (multiply)
....@@ -2272,12 +2519,22 @@
22722519 }
22732520 */
22742521 }
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
+ }
22752531 }
22762532
22772533 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
22782534 {
22792535 if (newWindow)
22802536 {
2537
+ new Exception().printStackTrace();
22812538 System.exit(0);
22822539 if (parent != null)
22832540 {
....@@ -2312,6 +2569,14 @@
23122569 {
23132570 editWindow.refreshContents();
23142571 }
2572
+ else
2573
+ {
2574
+ if (manipWindow != null)
2575
+ {
2576
+ manipWindow.refreshContents();
2577
+ }
2578
+ }
2579
+
23152580 //if (parent != null)
23162581 //parent.refreshEditWindow();
23172582 }
....@@ -2391,7 +2656,8 @@
23912656 private static final int editSelf = 1;
23922657 private static final int editChild = 2;
23932658
2394
- void drawEditHandles(ClickInfo info, int level)
2659
+ void drawEditHandles(//ClickInfo info,
2660
+ int level)
23952661 {
23962662 if (level == 0)
23972663 {
....@@ -2399,7 +2665,8 @@
23992665 return;
24002666
24012667 Object3D selectee;
2402
- 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))
24032670 {
24042671 selectee = (Object3D) e.nextElement();
24052672 }
....@@ -2407,19 +2674,22 @@
24072674 } else
24082675 {
24092676 //super.
2410
- drawEditHandles0(info, level + 1);
2677
+ drawEditHandles0(//info,
2678
+ level + 1);
24112679 }
24122680 }
24132681
2414
- boolean doEditClick(ClickInfo info, int level)
2682
+ boolean doEditClick(//ClickInfo info,
2683
+ int level)
24152684 {
24162685 doSomething = 0;
24172686 if (level == 0)
24182687 {
2419
- return doParentClick(info);
2688
+ return doParentClick(); //info);
24202689 }
24212690 if (//super.
2422
- doEditClick0(info, level))
2691
+ doEditClick0(//info,
2692
+ level))
24232693 {
24242694 doSomething = 1;
24252695 return true;
....@@ -2429,7 +2699,7 @@
24292699 }
24302700 }
24312701
2432
- boolean doParentClick(ClickInfo info)
2702
+ boolean doParentClick() //ClickInfo info)
24332703 {
24342704 if (selection == null)
24352705 {
....@@ -2442,7 +2712,8 @@
24422712 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
24432713 {
24442714 Object3D selectee = (Object3D) e.nextElement();
2445
- if (selectee.doEditClick(info, 1))
2715
+ if (selectee.doEditClick(//info,
2716
+ 1))
24462717 {
24472718 childToDrag = selectee;
24482719 doSomething = 2;
....@@ -2454,13 +2725,15 @@
24542725 return retval;
24552726 }
24562727
2457
- void doEditDrag(ClickInfo info)
2728
+ void doEditDrag(//ClickInfo clickInfo,
2729
+ boolean opposite)
24582730 {
24592731 switch (doSomething)
24602732 {
24612733 case 1: // '\001'
24622734 //super.
2463
- doEditDrag0(info);
2735
+ doEditDrag0(//clickInfo,
2736
+ opposite);
24642737 break;
24652738
24662739 case 2: // '\002'
....@@ -2473,11 +2746,13 @@
24732746 {
24742747 //sel.hitSomething = childToDrag.hitSomething;
24752748 //childToDrag.doEditDrag(info);
2476
- sel.doEditDrag(info);
2749
+ sel.doEditDrag(//clickInfo,
2750
+ opposite);
24772751 } else
24782752 {
24792753 //super.
2480
- doEditDrag0(info);
2754
+ doEditDrag0(//clickInfo,
2755
+ opposite);
24812756 }
24822757 }
24832758 break;
....@@ -2495,6 +2770,9 @@
24952770 {
24962771 deselectAll();
24972772 }
2773
+
2774
+ new Exception().printStackTrace();
2775
+
24982776 ClickInfo newInfo = new ClickInfo();
24992777 newInfo.flags = info.flags;
25002778 newInfo.bounds = info.bounds;
....@@ -2587,6 +2865,18 @@
25872865 void GenNormalsS(boolean crease)
25882866 {
25892867 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();
25902880 // for (int i=0; i<selection.size(); i++)
25912881 // {
25922882 // Object3D selectee = (Object3D) selection.elementAt(i);
....@@ -2732,6 +3022,42 @@
27323022 blockloop = false;
27333023 }
27343024
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();
3038
+// Children().release(i);
3039
+ }
3040
+ blockloop = false;
3041
+ }
3042
+
3043
+ void GenNormalsMINE()
3044
+ {
3045
+ if (blockloop)
3046
+ return;
3047
+
3048
+ blockloop = true;
3049
+ GenNormalsMINE0();
3050
+ for (int i = 0; i < Children().Size(); i++)
3051
+ {
3052
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
3053
+ if (child == null)
3054
+ continue;
3055
+ child.GenNormalsMINE();
3056
+// Children().release(i);
3057
+ }
3058
+ blockloop = false;
3059
+ }
3060
+
27353061 void ClearColors()
27363062 {
27373063 if (blockloop)
....@@ -2866,7 +3192,8 @@
28663192 {
28673193 if (bRep != null)
28683194 {
2869
- bRep.GenUV();
3195
+ bRep.GenUV(); //1);
3196
+ //bRep.UnfoldUV();
28703197 Touch();
28713198 }
28723199 }
....@@ -2876,6 +3203,24 @@
28763203 if (bRep != null)
28773204 {
28783205 bRep.GenerateNormals(crease);
3206
+ Touch();
3207
+ }
3208
+ }
3209
+
3210
+ void GenNormalsMesh0()
3211
+ {
3212
+ if (bRep != null)
3213
+ {
3214
+ bRep.GenerateNormalsMesh();
3215
+ Touch();
3216
+ }
3217
+ }
3218
+
3219
+ void GenNormalsMINE0()
3220
+ {
3221
+ if (bRep != null)
3222
+ {
3223
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
28793224 Touch();
28803225 }
28813226 }
....@@ -2932,6 +3277,120 @@
29323277 blockloop = false;
29333278 }
29343279
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
+
29353394 void TransformGeometry()
29363395 {
29373396 Object3D obj = this;
....@@ -3153,9 +3612,11 @@
31533612
31543613 BoundaryRep sup = bRep.support;
31553614 bRep.support = null;
3156
- BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
3615
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
31573616 // bRep.SplitInTwo(onlyone); // thread...
3158
- temprep.SplitInTwo(reduction34, onlyone);
3617
+
3618
+ while(temprep.SplitInTwo(reduction34, onlyone));
3619
+
31593620 bRep = temprep;
31603621 bRep.support = sup;
31613622 Touch();
....@@ -3256,15 +3717,47 @@
32563717
32573718 void ClearMaterials()
32583719 {
3720
+ if (blockloop)
3721
+ return;
3722
+
3723
+ blockloop = true;
3724
+
32593725 ClearMaterial();
3260
- for (int i = 0; i < size(); i++)
3726
+ for (int i = 0; i < Size(); i++)
32613727 {
3262
- Object3D child = (Object3D) reserve(i);
3728
+ Object3D child = (Object3D) get(i);
32633729 if (child == null)
32643730 continue;
32653731 child.ClearMaterials();
3266
- release(i);
32673732 }
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;
32683761 }
32693762
32703763 void FlipV(boolean flip)
....@@ -3292,7 +3785,8 @@
32923785 if (blockloop)
32933786 return;
32943787
3295
- if (marked || (bRep != null && material != null)) // borderline...
3788
+ if (//marked || // does not make sense
3789
+ (bRep != null || material != null)) // borderline...
32963790 live = h;
32973791
32983792 for (int i = 0; i < Size(); i++)
....@@ -3313,7 +3807,8 @@
33133807 return;
33143808
33153809 //if (bRep != null)
3316
- if (marked || (bRep != null && material != null)) // borderline...
3810
+ if (//marked || // does not make sense
3811
+ (bRep != null || material != null)) // borderline...
33173812 link2master = h;
33183813
33193814 for (int i = 0; i < Size(); i++)
....@@ -3333,7 +3828,8 @@
33333828 if (blockloop)
33343829 return;
33353830
3336
- if (marked || (bRep != null && material != null)) // borderline...
3831
+ if (//marked || // does not make sense
3832
+ (bRep != null || material != null)) // borderline...
33373833 hide = h;
33383834
33393835 for (int i = 0; i < Size(); i++)
....@@ -3353,7 +3849,7 @@
33533849 if (blockloop)
33543850 return;
33553851
3356
- if (bRep != null && material != null) // borderline...
3852
+ if (bRep != null || material != null) // borderline...
33573853 marked = h;
33583854
33593855 for (int i = 0; i < Size(); i++)
....@@ -3363,6 +3859,46 @@
33633859 continue;
33643860 blockloop = true;
33653861 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);
33663902 blockloop = false;
33673903 // release(i);
33683904 }
....@@ -3677,7 +4213,7 @@
36774213 if (child == null)
36784214 continue;
36794215
3680
- if (GrafreeD.RENDERME > 0)
4216
+ if (Grafreed.RENDERME > 0)
36814217 {
36824218 if (child instanceof Merge)
36834219 ((Merge)child).renderme();
....@@ -3828,7 +4364,7 @@
38284364 if (child == null)
38294365 continue;
38304366
3831
- if (GrafreeD.RENDERME > 0)
4367
+ if (Grafreed.RENDERME > 0)
38324368 {
38334369 if (child instanceof Merge)
38344370 ((Merge)child).renderme();
....@@ -4023,7 +4559,7 @@
40234559 if (child == null)
40244560 continue;
40254561
4026
- if (GrafreeD.RENDERME > 0)
4562
+ if (Grafreed.RENDERME > 0)
40274563 {
40284564 if (child instanceof Merge)
40294565 ((Merge)child).renderme();
....@@ -4111,7 +4647,7 @@
41114647 if (blockloop)
41124648 return;
41134649
4114
- for (int i=0; i<size(); i++)
4650
+ for (int i=0; i<Size(); i++)
41154651 {
41164652 if (get(i).parent != this)
41174653 {
....@@ -4120,6 +4656,71 @@
41204656 }
41214657 blockloop = true;
41224658 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();
41234724 blockloop = false;
41244725 }
41254726 }
....@@ -4614,7 +5215,7 @@
46145215
46155216 cTreePath SelectLeaf(int indexcount, boolean deselect)
46165217 {
4617
- if (hide)
5218
+ if (hide || dontselect)
46185219 return null;
46195220
46205221 if (count <= 0)
....@@ -4638,9 +5239,17 @@
46385239 }
46395240 }
46405241
5242
+ ObjEditor GetWindow()
5243
+ {
5244
+ if (editWindow != null)
5245
+ return editWindow;
5246
+
5247
+ return manipWindow;
5248
+ }
5249
+
46415250 cTreePath Select(int indexcount, boolean deselect)
46425251 {
4643
- if (hide)
5252
+ if (hide || dontselect)
46445253 return null;
46455254
46465255 if (count <= 0)
....@@ -4674,10 +5283,11 @@
46745283 if (leaf != null)
46755284 {
46765285 cTreePath tp = new cTreePath(this, leaf);
4677
- if (editWindow != null)
5286
+ ObjEditor window = GetWindow();
5287
+ if (window != null)
46785288 {
46795289 //System.out.println("editWindow = " + editWindow + " vs " + this);
4680
- editWindow.Select(tp, deselect, true);
5290
+ window.Select(tp, deselect, true);
46815291 }
46825292
46835293 return tp;
....@@ -4694,6 +5304,7 @@
46945304
46955305 if (child == null)
46965306 continue;
5307
+
46975308 if (child.HasTransparency() && child.size() != 0)
46985309 {
46995310 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4703,9 +5314,10 @@
47035314 if (leaf != null)
47045315 {
47055316 cTreePath tp = new cTreePath(this, leaf);
4706
- if (editWindow != null)
5317
+ ObjEditor window = GetWindow();
5318
+ if (window != null)
47075319 {
4708
- editWindow.Select(tp, deselect, true);
5320
+ window.Select(tp, deselect, true);
47095321 }
47105322
47115323 return tp;
....@@ -4790,7 +5402,7 @@
47905402 return globalTransform;
47915403 }
47925404
4793
- void PreprocessOcclusion(CameraPane cp)
5405
+ void PreprocessOcclusion(iCameraPane cp)
47945406 {
47955407 /*
47965408 if (AOdone)
....@@ -4937,7 +5549,8 @@
49375549 } else //
49385550 if (editWindow != null)
49395551 {
4940
- editWindow.cameraView.lighttouched = true;
5552
+ //editWindow.cameraView.lighttouched = true;
5553
+ Globals.lighttouched = true;
49415554 }
49425555 }
49435556
....@@ -5029,6 +5642,51 @@
50295642 blockloop = false;
50305643 }
50315644
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
+
50325690 boolean IsSelected()
50335691 {
50345692 if (parent == null)
....@@ -5089,12 +5747,41 @@
50895747 if (fullname == null)
50905748 return "";
50915749
5750
+ if (fullname.pigment != null)
5751
+ {
5752
+ return fullname.pigment;
5753
+ }
5754
+
50925755 // System.out.println("Fullname = " + fullname);
50935756
5094
- if (fullname.name.indexOf(":") == -1)
5095
- 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(":"));
50965762
5097
- 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];
50985785 }
50995786
51005787 static String GetBump(cTexture fullname)
....@@ -5102,11 +5789,44 @@
51025789 if (fullname == null)
51035790 return "";
51045791
5792
+ if (fullname.bump != null)
5793
+ {
5794
+ return fullname.bump;
5795
+ }
5796
+
51055797 // System.out.println("Fullname = " + fullname);
5106
- if (fullname.name.indexOf(":") == -1)
5107
- return "";
5108
-
5109
- return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
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];
51105830 }
51115831
51125832 String GetPigmentTexture()
....@@ -5180,7 +5900,7 @@
51805900 System.out.print("; textures = " + textures);
51815901 System.out.println("; usedtextures = " + usedtextures);
51825902
5183
- if (GetTextures() == null)
5903
+ if (GetTextures() == null) // What is that??
51845904 GetTextures().name = ":";
51855905
51865906 String texname = tex;
....@@ -5189,6 +5909,9 @@
51895909 texname = "";
51905910
51915911 GetTextures().name = texname + ":" + GetBump(GetTextures());
5912
+
5913
+ GetTextures().pigment = null;
5914
+
51925915 Touch();
51935916 }
51945917
....@@ -5213,6 +5936,43 @@
52135936 }
52145937 }
52155938
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
+
52165976 void SetBumpTexture(String tex)
52175977 {
52185978 if (GetTextures() == null)
....@@ -5224,6 +5984,8 @@
52245984 texname = "";
52255985
52265986 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
5987
+
5988
+ GetTextures().bump = null;
52275989
52285990 Touch();
52295991 }
....@@ -5249,25 +6011,70 @@
52496011 }
52506012 }
52516013
5252
- 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)
52536047 {
52546048 Draw(display, root, selected, blocked);
52556049 }
52566050
5257
- static cMaterial[] materialstack = new cMaterial[65536];
5258
- static boolean[] selectedstack = new boolean[65536];
5259
- static int materialdepth = 0;
5260
-
52616051 boolean NeedSupport()
52626052 {
52636053 return
5264
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
6054
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
52656055 // PROBLEM with CROWD!!
5266
- && (CameraPane.drawMode == CameraPane.SHADOW || CameraPane.CROWD);
6056
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
52676057 }
52686058
6059
+ static boolean DEBUG_SELECTION = false;
52696060
5270
- 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)
52716078 {
52726079 Invariants(); // june 2013
52736080
....@@ -5276,8 +6083,8 @@
52766083 // System.err.println("Draw " + this + " Frame # " + ((Mocap)((Merge)support).object).frame);
52776084 }
52786085
5279
- if (display.drawMode == CameraPane.SELECTION &&
5280
- hide)
6086
+ if (display.DrawMode() == iCameraPane.SELECTION &&
6087
+ (hide || dontselect))
52816088 return;
52826089
52836090 if (name != null && name.contains("sclera"))
....@@ -5295,7 +6102,7 @@
52956102 if (this instanceof Checker)
52966103 return;
52976104
5298
- if (display.drawMode == display.SHADOW && PASSTEST)
6105
+ if (display.DrawMode() == display.SHADOW && PASSTEST)
52996106 return;
53006107
53016108 if (count <= 0)
....@@ -5303,13 +6110,13 @@
53036110 return;
53046111 }
53056112
5306
- if ((//display.drawMode == CameraPane.SHADOW ||
5307
- display.drawMode == CameraPane.SELECTION || CameraPane.DEBUG_SELECTION) && HasTransparency())
6113
+ if ((//display.DrawMode() == CameraPane.SHADOW ||
6114
+ display.DrawMode() == iCameraPane.SELECTION || display.IsDebugSelection()) && HasTransparency())
53086115 {
53096116 return;
53106117 }
53116118
5312
- javax.media.opengl.GL gl = display.GetGL();
6119
+ //javax.media.opengl.GL gl = display.GetGL();
53136120
53146121 /*
53156122 if (touched)
....@@ -5327,8 +6134,11 @@
53276134 if (support != null)
53286135 support = support;
53296136
5330
- //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5331
- boolean usecalllists = false; // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
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.
53326142
53336143 if (!usecalllists && bRep != null && bRep.displaylist > 0)
53346144 {
....@@ -5338,30 +6148,33 @@
53386148 // usecalllists &= !(parent instanceof RandomNode);
53396149 // usecalllists = false;
53406150
5341
- if (GetBRep() != null)
5342
- usecalllists = usecalllists;
6151
+ if (display.DrawMode() == display.SHADOW)
6152
+ //GetBRep() != null)
6153
+ usecalllists = !!usecalllists;
53436154 //System.out.println("draw " + this);
53446155 //new Exception().printStackTrace();
53456156
53466157 boolean compiled = false;
53476158
5348
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
6159
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
53496160
5350
- if (!selectmode && //display.drawMode != display.SELECTION &&
5351
- (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)))
53526164 {
5353
- display.lighttouched = true;
6165
+ Globals.lighttouched = true;
53546166 } // all panes...
5355
- //if (usecalllists && display.drawMode != display.SELECTION && display.drawMode != display.SHADOW &&
5356
- if (bRep != null && usecalllists && !selectmode && // june 2013 display.drawMode != display.SHADOW &&
6167
+
6168
+ //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
6169
+ if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
53576170 (touched || (bRep != null && bRep.displaylist <= 0)))
53586171 {
53596172 if (!(this instanceof Composite))
53606173 touched = false;
53616174 //if (displaylist == -1 && usecalllists)
5362
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
6175
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
53636176 {
5364
- bRep.displaylist = gl.glGenLists(1);
6177
+ bRep.displaylist = display.GenList();
53656178 assert(bRep.displaylist != 0);
53666179 // System.err.println("glGenLists: " + bRep.displaylist + " for " + this);
53676180 //System.out.println("\tgen list " + list);
....@@ -5370,21 +6183,23 @@
53706183
53716184 //System.out.println("\tnew list " + list);
53726185 //gl.glDrawBuffer(gl.GL_NONE);
5373
- if (usecalllists)
6186
+ if (usecalllists && bRep.displaylist > 0)
53746187 {
53756188 // System.err.println("new list " + bRep.displaylist + " for " + this);
5376
- gl.glNewList(bRep.displaylist, gl.GL_COMPILE); //_AND_EXECUTE);
6189
+ display.NewList(bRep.displaylist);
53776190 }
6191
+
53786192 CallList(display, root, selected, blocked);
6193
+
53796194 // compiled = true;
5380
- if (usecalllists)
6195
+ if (usecalllists && bRep.displaylist > 0)
53816196 {
53826197 // System.err.println("end list " + bRep.displaylist + " for " + this);
5383
- gl.glEndList();
6198
+ display.EndList();
53846199 }
53856200 //gl.glDrawBuffer(gl.GL_BACK);
53866201 // XXX touched = false;
5387
- display.lighttouched = true; // all panes...
6202
+ Globals.lighttouched = true; // all panes...
53886203 }
53896204
53906205 touched = GetBRep() == null; // this instanceof Composite || this instanceof FileObject; // false;
....@@ -5423,12 +6238,12 @@
54236238
54246239 // frustum culling
54256240 if (CameraPane.FRUSTUM && !blocked && !IsInfinite() && GetBRep() != null // && GetBRep().VertexCount() != 1260 // default grid
5426
- && display.drawMode != CameraPane.SELECTION)
6241
+ && display.DrawMode() != iCameraPane.SELECTION)
54276242 {
5428
- if (display.drawMode == CameraPane.SHADOW)
6243
+ if (display.DrawMode() == iCameraPane.SHADOW)
54296244 {
54306245 if (!link2master // tricky to cull in shadow mode.
5431
- && GetBRep().FrustumCull(this, gl, display.lightCamera, true))
6246
+ && GetBRep().FrustumCull(this, null, display.LightCamera(), true))
54326247 {
54336248 //System.out.print("CULLED");
54346249 culled = true;
....@@ -5436,7 +6251,7 @@
54366251 }
54376252 else
54386253 //GetBRep().getBounds(v0, v1, this);
5439
- if (GetBRep().FrustumCull(this, gl, display.renderCamera, false))
6254
+ if (GetBRep().FrustumCull(this, null, display.RenderCamera(), false))
54406255 culled = true;
54416256
54426257 // LA.xformPos(v0, display.renderCamera.toScreen, v0);
....@@ -5472,11 +6287,12 @@
54726287
54736288
54746289 if (!culled)
5475
- if (display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION)
6290
+ if (display.DrawMode() == display.SELECTION || display.IsDebugSelection())
54766291 {
54776292 if (GetBRep() != null)
54786293 {
5479
- CameraPane.NextIndex(this, gl);
6294
+ display.NextIndex();
6295
+
54806296 // vertex color conflict : gl.glCallList(list);
54816297 DrawNode(display, root, selected);
54826298 if (this instanceof BezierPatch)
....@@ -5498,55 +6314,7 @@
54986314 color[2] /= 2;
54996315 gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT_AND_DIFFUSE, color, 0);
55006316 */
5501
- if (material != null)
5502
- {
5503
- materialstack[materialdepth] = material;
5504
- selectedstack[materialdepth] = selected;
5505
- cStatic.objectstack[materialdepth++] = this;
5506
- //System.out.println("material " + material);
5507
- //Applet3D.tracein(this, selected);
5508
- display.vector2buffer = projectedVertices;
5509
- if (this instanceof Camera)
5510
- {
5511
- display.options1[0] = material.shift;
5512
- //System.out.println("shift " + material.shift);
5513
- display.options1[1] = material.lightarea;
5514
- display.options1[2] = material.shadowbias;
5515
- display.options1[3] = material.aniso;
5516
- display.options1[4] = material.anisoV;
5517
- display.options2[0] = material.opacity;
5518
- display.options2[1] = material.diffuse;
5519
- display.options2[2] = material.factor;
5520
-
5521
- cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
5522
- display.options4[0] = material.cameralight/0.2f;
5523
- display.options4[1] = material.subsurface;
5524
- display.options4[2] = material.sheen;
5525
-
5526
- // if (display.CURRENTANTIALIAS > 0)
5527
- // display.options3[3] /= 4;
5528
-
5529
- /*
5530
- System.out.println("Focus = " + display.options1[0]);
5531
- System.out.println("Aperture = " + display.options1[1]);
5532
- System.out.println("ShadowBlur = " + display.options1[2]);
5533
- System.out.println("Antialiasing = " + display.options1[3]);
5534
- System.out.println("Fog = " + display.options2[0]);
5535
- System.out.println("Intensity = " + display.options2[1]);
5536
- System.out.println("Elevation = " + display.options2[2]);
5537
- /**/
5538
- } else
5539
- {
5540
- material.Draw(display, selected);
5541
- }
5542
- } else
5543
- {
5544
- if (selected && CameraPane.flash)
5545
- {
5546
- display.modelParams4[1] = 100;
5547
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
5548
- }
5549
- }
6317
+ display.PushMaterial(this, selected);
55506318
55516319 //System.out.println("call list " + list);
55526320 //System.out.println();
....@@ -5565,7 +6333,28 @@
55656333 tex = GetTextures();
55666334 }
55676335
5568
- 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
+ }
55696358
55706359 if (!compiled)
55716360 {
....@@ -5581,30 +6370,19 @@
55816370
55826371 // System.err.println("glCallList: " + bRep.displaylist + " for " + this);
55836372 assert(bRep.displaylist != 0);
5584
- gl.glCallList(bRep.displaylist);
6373
+ display.CallList(bRep.displaylist);
55856374 // june 2013 drawSelf(display, root, selected);
55866375 }
55876376 }
55886377 }
55896378
5590
- display.ReleaseTextures(tex);
5591
-
5592
- //if (parent != null && parent.GetMaterial() != null)
5593
- // parent.GetMaterial().Draw(display, parent.IsSelected(this));
5594
- if (material != null)
5595
- {
5596
- materialdepth -= 1;
5597
- if (materialdepth > 0)
5598
- {
5599
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
5600
- materialstack[materialdepth - 1].Draw(display, selectedstack[materialdepth - 1]);
5601
- }
5602
- //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
5603
- } else if (selected && CameraPane.flash && GetMaterial() != null)
5604
- {
5605
- display.modelParams4[1] = GetMaterial().cameralight;
5606
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
5607
- }
6379
+ if (!failedBump)
6380
+ display.ReleaseBumpTexture(tex);
6381
+
6382
+ if (!failedPigment)
6383
+ display.ReleasePigmentTexture(tex);
6384
+
6385
+ display.PopMaterial(this, selected);
56086386 }
56096387
56106388 if (this instanceof Texture || this instanceof TextureNode)
....@@ -5646,7 +6424,7 @@
56466424 // resetMasterNode();
56476425 }
56486426
5649
- void CallList(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
6427
+ void CallList(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
56506428 {
56516429 if (GetBRep() == null)
56526430 {
....@@ -5729,8 +6507,11 @@
57296507 boolean flipV = false; // true;
57306508 int texres = 0; // 0 = low, 1 = normal, 2 = high res texture
57316509
5732
- void drawSelf(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
6510
+ void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57336511 {
6512
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6513
+ return;
6514
+
57346515 if (hide)
57356516 return;
57366517 // shadow optimisation
....@@ -5788,16 +6569,7 @@
57886569 // // ??????????????????????????? Touch();
57896570 // }
57906571
5791
- if (material != null)
5792
- {
5793
- materialstack[materialdepth] = material;
5794
- selectedstack[materialdepth] = selected;
5795
- cStatic.objectstack[materialdepth++] = this;
5796
- //System.out.println("material " + material);
5797
- //Applet3D.tracein("selected ", selected);
5798
- display.vector2buffer = projectedVertices;
5799
- material.Draw(display, selected);
5800
- }
6572
+display.PushMaterial2(this, selected);
58016573
58026574 Object3D child;
58036575 boolean sel;
....@@ -5849,19 +6621,7 @@
58496621 */
58506622 //depth += 1;
58516623
5852
- if (material != null)
5853
- {
5854
- materialdepth -= 1;
5855
- if (materialdepth > 0)
5856
- {
5857
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
5858
- materialstack[materialdepth - 1].Draw(display, selectedstack[materialdepth - 1]);
5859
- }
5860
- //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
5861
- //else
5862
- //material.Draw(display, false);
5863
- }
5864
-
6624
+display.PopMaterial2(this);
58656625 /*
58666626 display.ReleaseTextures(tex);
58676627 */
....@@ -5872,10 +6632,13 @@
58726632
58736633 //static cVector min,max;
58746634
5875
- void DrawNode(CameraPane display, Object3D /*Composite*/ root, boolean selected)
6635
+ void DrawNode(iCameraPane display, Object3D /*Composite*/ root, boolean selected)
58766636 {
5877
- 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)
58786638 return; // no shadow for transparent objects
6639
+
6640
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6641
+ return;
58796642
58806643 if (hide)
58816644 return;
....@@ -5917,11 +6680,12 @@
59176680 return;
59186681 }
59196682
6683
+ //bRep.GenUV(1/material.diffuseness);
59206684 // bRep.lock = true;
59216685
5922
- javax.media.opengl.GL gl = display.GetGL();
6686
+ //javax.media.opengl.GL gl = display.GetGL();
59236687
5924
- if (CameraPane.BOXMODE) // || CameraPane.movingcamera)
6688
+ if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera)
59256689 {
59266690 int fc = bRep.FaceCount();
59276691 int vc = bRep.VertexCount();
....@@ -5936,23 +6700,7 @@
59366700
59376701 bRep.getMinMax(min, max, 100);
59386702
5939
- gl.glBegin(gl.GL_LINES);
5940
-
5941
- gl.glVertex3d(min.x, min.y, min.z);
5942
- gl.glVertex3d(min.x, min.y, max.z);
5943
- gl.glVertex3d(min.x, min.y, min.z);
5944
- gl.glVertex3d(min.x, max.y, min.z);
5945
- gl.glVertex3d(min.x, min.y, min.z);
5946
- gl.glVertex3d(max.x, min.y, min.z);
5947
-
5948
- gl.glVertex3d(max.x, max.y, max.z);
5949
- gl.glVertex3d(min.x, max.y, max.z);
5950
- gl.glVertex3d(max.x, max.y, max.z);
5951
- gl.glVertex3d(max.x, min.y, max.z);
5952
- gl.glVertex3d(max.x, max.y, max.z);
5953
- gl.glVertex3d(max.x, max.y, min.z);
5954
-
5955
- gl.glEnd();
6703
+ display.DrawBox(min, max);
59566704
59576705 return;
59586706 }
....@@ -5996,7 +6744,7 @@
59966744 {
59976745 //throw new Error();
59986746
5999
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
6747
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
60006748
60016749 int[] strips = bRep.getRawIndices();
60026750
....@@ -6006,178 +6754,19 @@
60066754 new Exception().printStackTrace();
60076755 return;
60086756 }
6009
-
6010
- // TRIANGLE STRIP ARRAY
6011
- if (bRep.trimmed)
6757
+
6758
+ if (dontselect)
60126759 {
6013
- float[] v = bRep.getRawVertices();
6014
- float[] n = bRep.getRawNormals();
6015
- float[] c = bRep.getRawColors();
6016
- float[] uv = bRep.getRawUVMap();
6017
-
6018
- int count2 = 0;
6019
- int count3 = 0;
6020
-
6021
- if (n.length > 0)
6022
- {
6023
- for (int i = 0; i < strips.length; i++)
6024
- {
6025
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6026
-
6027
- /*
6028
- boolean locked = false;
6029
- float eps = 0.1f;
6030
- boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
6031
-
6032
- int dot = 0;
6033
-
6034
- if ((dot&1) == 0)
6035
- dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
6036
-
6037
- if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
6038
- gl.glTexCoord2f((float) qv.s, (float) qv.t);
6039
- else
6040
- {
6041
- locked = true;
6042
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6043
- }
6044
- //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6045
- gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
6046
- if (hasnorm)
6047
- {
6048
- //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6049
- gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
6050
- }
6051
-
6052
- if ((dot&4) == 0)
6053
- dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
6054
-
6055
- if (wrap || !locked && (dot&8) != 0)
6056
- gl.glTexCoord2f((float) rv.s, (float) rv.t);
6057
- else
6058
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6059
-
6060
- f.dot = dot;
6061
- */
6062
-
6063
- if (!selectmode)
6064
- {
6065
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6066
- {
6067
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6068
- } else
6069
- {
6070
- gl.glNormal3f(0, 0, 1);
6071
- }
6072
-
6073
- if (c != null)
6074
- //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]);
6075
- {
6076
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6077
- }
6078
- }
6079
- if (flipV)
6080
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6081
- else
6082
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6083
- //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6084
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6085
-
6086
- count2 += 2;
6087
- count3 += 3;
6088
- if (!selectmode)
6089
- {
6090
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6091
- {
6092
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6093
- } else
6094
- {
6095
- gl.glNormal3f(0, 0, 1);
6096
- }
6097
- if (c != null)
6098
- {
6099
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6100
- }
6101
- }
6102
- if (flipV)
6103
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6104
- else
6105
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6106
- //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6107
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6108
-
6109
- count2 += 2;
6110
- count3 += 3;
6111
- for (int j = 0; j < strips[i] - 2; j++)
6112
- {
6113
- //gl.glTexCoord2d(...);
6114
- if (!selectmode)
6115
- {
6116
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6117
- {
6118
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6119
- } else
6120
- {
6121
- gl.glNormal3f(0, 0, 1);
6122
- }
6123
- if (c != null)
6124
- {
6125
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6126
- }
6127
- }
6128
-
6129
- if (flipV)
6130
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6131
- else
6132
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6133
- //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
6134
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6135
- count2 += 2;
6136
- count3 += 3;
6137
- }
6138
-
6139
- gl.glEnd();
6140
- }
6141
- }
6142
-
6143
- assert count3 == v.length;
6760
+ //bRep.GenerateNormalsMINE();
61446761 }
6145
- else // !trimmed
6146
- {
6147
- int count = 0;
6148
- for (int i = 0; i < strips.length; i++)
6149
- {
6150
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6151
-
6152
- Vertex p = bRep.GetVertex(bRep.indices[count++]);
6153
- Vertex q = bRep.GetVertex(bRep.indices[count++]);
6154
-
6155
- drawVertex(gl, p, selectmode);
6156
- drawVertex(gl, q, selectmode);
6157
-
6158
- for (int j = 0; j < strips[i] - 2; j++)
6159
- {
6160
- Vertex r = bRep.GetVertex(bRep.indices[count++]);
6161
-
6162
-// if (j%2 == 0)
6163
-// drawFace(p, q, r, display, null);
6164
-// else
6165
-// drawFace(p, r, q, display, null);
6166
-
6167
-// p = q;
6168
-// q = r;
6169
- drawVertex(gl, r, selectmode);
6170
- }
6171
-
6172
- gl.glEnd();
6173
- }
6174
- }
6762
+
6763
+ display.DrawGeometry(bRep, flipV, selectmode);
61756764 } else // catch (Error e)
61766765 {
61776766 // TRIANGLE ARRAY
61786767 if (IsOpaque()) // Static())
61796768 {
6180
- gl.glBegin(gl.GL_TRIANGLES);
6769
+ display.StartTriangles();
61816770 int facecount = bRep.FaceCount();
61826771 for (int i = 0; i < facecount; i++)
61836772 {
....@@ -6240,9 +6829,9 @@
62406829 // // r.norm.dot(v3) > -0.5)
62416830 // // continue;
62426831
6243
- drawFace(p, q, r, display, face);
6832
+ display.DrawFace(this, p, q, r, face);
62446833 }
6245
- gl.glEnd();
6834
+ display.EndTriangles();
62466835 }
62476836 else
62486837 {
....@@ -6271,8 +6860,8 @@
62716860 //System.out.println("SORT");
62726861
62736862 java.util.Arrays.sort(facescompare);
6274
-
6275
- gl.glBegin(gl.GL_TRIANGLES);
6863
+
6864
+ display.StartTriangles();
62766865 for (int i = 0; i < facecount; i++)
62776866 {
62786867 Face face = bRep.GetFace(facescompare[i].index);
....@@ -6284,13 +6873,14 @@
62846873 Vertex q = bRep.GetVertex(face.q);
62856874 Vertex r = bRep.GetVertex(face.r);
62866875
6287
- drawFace(p, q, r, display, face);
6876
+ display.DrawFace(this, p, q, r, face);
62886877 }
6289
- gl.glEnd();
6878
+ display.EndTriangles();
62906879 }
62916880
62926881 if (false) // live && support != null && support.bRep != null) // debug weights
62936882 {
6883
+ /*
62946884 gl.glDisable(gl.GL_LIGHTING);
62956885 float[] colorV = new float[3];
62966886
....@@ -6369,6 +6959,7 @@
63696959 // gl.glEnd();
63706960 }
63716961 }
6962
+ */
63726963 }
63736964 }
63746965
....@@ -6413,7 +7004,7 @@
64137004 center.add(r);
64147005 center.mul(1.0/3);
64157006
6416
- center.sub(CameraPane.theRenderer.eyeCamera.location);
7007
+ center.sub(Globals.theRenderer.EyeCamera().location);
64177008
64187009 distance = center.dot(center);
64197010 }
....@@ -6424,347 +7015,11 @@
64247015
64257016 transient FaceCompare[] facescompare = null;
64267017
6427
- void SetColor(CameraPane display, Vertex p0)
6428
- {
6429
- if (display.RENDERPROGRAM == 0)
6430
- {
6431
- float r = 0;
6432
- if (bRep != null)
6433
- {
6434
- if (bRep.stripified)
6435
- {
6436
- r = 1;
6437
- }
6438
- }
6439
- float g = 0;
6440
- if (bRep != null)
6441
- {
6442
- if (bRep.trimmed)
6443
- {
6444
- g = 1;
6445
- }
6446
- }
6447
- float b = 0;
6448
- if (support != null && link2master)
6449
- {
6450
- b = 1;
6451
- }
6452
- display.GetGL().glColor3f(r*p0.AO, g*p0.AO, b*p0.AO);
6453
- return;
6454
- }
6455
-
6456
- if (display.drawMode != CameraPane.SHADOW)
6457
- return;
6458
-
6459
- javax.media.opengl.GL gl = display.GetGL();
6460
-// if (true) return;
6461
-// float ao = p.AO;
6462
-//
6463
-// // if (ao == 0 && !bRep.AOdone) // transient problem!
6464
-// // ao = 1;
6465
-//
6466
-// gl.glColor4f(ao, ao, ao, 1);
6467
-
6468
-// CameraPane.selectedpoint.
6469
-// getAverage(cStatic.point1, true);
6470
- if (CameraPane.pointflow == null) // !random) // live)
6471
- {
6472
- return;
6473
- }
6474
-
6475
- cStatic.point1.set(0,0,0);
6476
- LA.xformPos(cStatic.point1, CameraPane.selectedpoint.toParent, cStatic.point1);
6477
-
6478
- cStatic.point1.sub(p0);
6479
-
6480
-
6481
-// if (marked && (p0.vertexlinks == null || support == null || support.bRep == null)) // no position delta?
6482
-// {
6483
-// return;
6484
-// }
6485
-
6486
- //if (true)
6487
- if (cStatic.point1.dot(cStatic.point1) > 0.000001)
6488
- {
6489
- return;
6490
- }
6491
-
6492
- float[] colorV = new float[3];
6493
-
6494
- if (false) // marked)
6495
- {
6496
- // debug rigging weights
6497
- for (int object = 0; object < p0.vertexlinks.length; object++)
6498
- {
6499
- float weight = p0.weights[object] / p0.totalweight;
6500
-
6501
- // if (weight < 0.1)
6502
- // {
6503
- // assert(weight == 0);
6504
- // continue;
6505
- // }
6506
-
6507
- if (p0.vertexlinks[object] == -1)
6508
- continue;
6509
-
6510
- Vertex q = support.bRep.GetVertex(p0.vertexlinks[object]);
6511
-
6512
- int color = //1 << object; //
6513
- //p.vertexlinks.length;
6514
- support.bRep.supports[p0.closestsupport].links[object];
6515
- colorV[2] += (color & 1) * weight;
6516
- colorV[1] += ((color & 2) >> 1) * weight;
6517
- colorV[0] += ((color & 4) >> 2) * weight;
6518
- }
6519
- }
6520
- else
6521
- {
6522
- if (drawingstarted)
6523
- {
6524
- // find next point
6525
- if (bRep.GetVertex(0).faceindices == null)
6526
- {
6527
- bRep.InitFaceIndices();
6528
- }
6529
-
6530
- double ymin = p0.y;
6531
-
6532
- Vertex newp = p0;
6533
-
6534
- for (int fii = 0; fii < p0.faceindices.length; fii++)
6535
- {
6536
- int fi = p0.faceindices[fii];
6537
-
6538
- if (fi == -1)
6539
- break;
6540
-
6541
- Face f = bRep.GetFace(fi);
6542
-
6543
- Vertex p = bRep.GetVertex(f.p);
6544
- Vertex q = bRep.GetVertex(f.q);
6545
- Vertex r = bRep.GetVertex(f.r);
6546
-
6547
- int swap = (int)(Math.random()*3);
6548
-
6549
-// for (int s=swap; --s>=0;)
6550
-// {
6551
-// Vertex t = p;
6552
-// p = q;
6553
-// q = r;
6554
-// r = t;
6555
-// }
6556
- if (ymin > p.y)
6557
- {
6558
- ymin = p.y;
6559
- newp = p;
6560
-// break;
6561
- }
6562
- if (ymin > q.y)
6563
- {
6564
- ymin = q.y;
6565
- newp = q;
6566
-// break;
6567
- }
6568
- if (ymin > r.y)
6569
- {
6570
- ymin = r.y;
6571
- newp = r;
6572
-// break;
6573
- }
6574
- }
6575
-
6576
- CameraPane.selectedpoint.toParent[3][0] = newp.x;
6577
- CameraPane.selectedpoint.toParent[3][1] = newp.y;
6578
- CameraPane.selectedpoint.toParent[3][2] = newp.z;
6579
-
6580
- drawingstarted = false;
6581
-
6582
- // return;
6583
- }
6584
-
6585
- if (false) // CameraPane.DRAW
6586
- {
6587
- p0.AO = colorV[0] = 2;
6588
- colorV[1] = 2;
6589
- colorV[2] = 2;
6590
- }
6591
-
6592
- CameraPane.pointflow.add(p0);
6593
- CameraPane.pointflow.Touch();
6594
- }
6595
-
6596
-// gl.glColor3f(colorV[0], colorV[1], colorV[2]);
6597
-// gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0);
6598
-// gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
6599
- }
6600
-
66017018 void Print(Vertex v)
66027019 {
66037020 //System.err.println("(" + v.x + ", " + v.y + ", " + v.z + ")");
66047021 }
66057022
6606
- void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean selectmode)
6607
- {
6608
- if (!selectmode)
6609
- {
6610
- gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
6611
- gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
6612
-
6613
- if (flipV)
6614
- gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
6615
- else
6616
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6617
- }
6618
-
6619
- gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
6620
- }
6621
-
6622
- void drawFace(Vertex pv, Vertex qv, Vertex rv,
6623
- CameraPane display, Face face)
6624
- {
6625
- if (pv.y == -10000 ||
6626
- qv.y == -10000 ||
6627
- rv.y == -10000)
6628
- return;
6629
-
6630
-// float b = f.nbiterations & 1;
6631
-// float g = (f.nbiterations>>1) & 1;
6632
-// float r = (f.nbiterations>>2) & 1;
6633
-//
6634
-// //if (f.weight == 10000)
6635
-// //{
6636
-// // r = 1; g = b = 0;
6637
-// //}
6638
-// //else
6639
-// //{
6640
-// // assert(f.weight < 10000);
6641
-// r = g = b = (float)bRep.FaceWeight(f)*100;
6642
-// if (r<0)
6643
-// assert(r>=0);
6644
-// //}
6645
-
6646
- javax.media.opengl.GL gl = display.GetGL();
6647
-
6648
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
6649
-
6650
- //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv);
6651
- if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
6652
- {
6653
- //gl.glBegin(gl.GL_TRIANGLES);
6654
- boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
6655
- if (!hasnorm)
6656
- {
6657
- // System.out.println("FUCK!!");
6658
- LA.vecSub(pv/*.pos*/, qv/*.pos*/, v0);
6659
- LA.vecSub(pv/*.pos*/, rv/*.pos*/, v1);
6660
- LA.vecCross(v0, v1, v2);
6661
- LA.vecNormalize(v2);
6662
- gl.glNormal3f((float) v2.x, (float) v2.y, (float) v2.z);
6663
- }
6664
-
6665
- if (hasnorm)
6666
- {
6667
-// if (!pv.norm.normalized())
6668
-// assert(pv.norm.normalized());
6669
-
6670
- //System.out.println("normalp = " + pv.norm.x + ", " + pv.norm.y + ", " + pv.norm.z);
6671
- gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
6672
- }
6673
- gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
6674
- SetColor(display, pv);
6675
- //gl.glColor4f(r, g, b, 1);
6676
- //gl.glColor4f(pv.boundary, pv.boundary, pv.boundary, 1);
6677
- if (flipV)
6678
- gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
6679
- else
6680
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6681
- //System.out.println("vertexp = " + pv.x + ", " + pv.y + ", " + pv.z);
6682
- gl.glVertex3f((float) pv./*pos.*/x, (float) pv./*pos.*/y, (float) pv./*pos.*/z);
6683
-// Print(pv);
6684
- if (hasnorm)
6685
- {
6686
-// assert(qv.norm.normalized());
6687
- //System.out.println("normalq = " + qv.norm.x + ", " + qv.norm.y + ", " + qv.norm.z);
6688
- gl.glNormal3f((float) qv.norm.x, (float) qv.norm.y, (float) qv.norm.z);
6689
- }
6690
- //System.out.println("vertexq = " + qv.s + ", " + qv.t);
6691
- // boolean locked = false;
6692
- // float eps = 0.1f;
6693
- // boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
6694
-
6695
- // int dot = 0; //*/ (int)f.dot;
6696
-
6697
- // if ((dot&1) == 0)
6698
- // dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
6699
-
6700
- // if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
6701
- if (flipV)
6702
- gl.glTexCoord2f((float) qv.s, 1-(float) qv.t);
6703
- else
6704
- gl.glTexCoord2f((float) qv.s, (float) qv.t);
6705
- // else
6706
- // {
6707
- // locked = true;
6708
- // gl.glTexCoord2f((float) pv.s, (float) pv.t);
6709
- // }
6710
- gl.glColor4f(qv.AO, qv.AO, qv.AO, 1);
6711
- SetColor(display, qv);
6712
- //gl.glColor4f(r, g, b, 1);
6713
- //gl.glColor4f(qv.boundary, qv.boundary, qv.boundary, 1);
6714
- //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6715
- gl.glVertex3f((float) qv./*pos.*/x, (float) qv./*pos.*/y, (float) qv./*pos.*/z);
6716
-// Print(qv);
6717
- if (hasnorm)
6718
- {
6719
-// assert(rv.norm.normalized());
6720
- //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6721
- gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
6722
- }
6723
-
6724
- // if ((dot&4) == 0)
6725
- // dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
6726
-
6727
- // if (wrap || !locked && (dot&8) != 0)
6728
- if (flipV)
6729
- gl.glTexCoord2f((float) rv.s, 1-(float) rv.t);
6730
- else
6731
- gl.glTexCoord2f((float) rv.s, (float) rv.t);
6732
- // else
6733
- // gl.glTexCoord2f((float) pv.s, (float) pv.t);
6734
-
6735
- // f.dot = dot;
6736
-
6737
- gl.glColor4f(rv.AO, rv.AO, rv.AO, 1);
6738
- SetColor(display, rv);
6739
- //gl.glColor4f(r, g, b, 1);
6740
- //gl.glColor4f(rv.boundary, rv.boundary, rv.boundary, 1);
6741
- //System.out.println("vertexr = " + rv.x + ", " + rv.y + ", " + rv.z);
6742
- gl.glVertex3f((float) rv./*pos.*/x, (float) rv./*pos.*/y, (float) rv./*pos.*/z);
6743
-// Print(rv);
6744
- //gl.glEnd();
6745
- }
6746
- else
6747
- {
6748
- gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
6749
- gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
6750
- gl.glVertex3f((float) rv.x, (float) rv.y, (float) rv.z);
6751
-
6752
- }
6753
-
6754
- if (false) // (attributes & WIREFRAME) != 0)
6755
- {
6756
- gl.glDisable(gl.GL_LIGHTING);
6757
-
6758
- gl.glBegin(gl.GL_LINE_LOOP);
6759
- gl.glVertex3d(pv./*pos.*/x, pv./*pos.*/y, pv./*pos.*/z);
6760
- gl.glVertex3d(qv./*pos.*/x, qv./*pos.*/y, qv./*pos.*/z);
6761
- gl.glVertex3d(rv./*pos.*/x, rv./*pos.*/y, rv./*pos.*/z);
6762
- gl.glEnd();
6763
-
6764
- gl.glEnable(gl.GL_LIGHTING);
6765
- }
6766
- }
6767
-
67687023 void drawSelf(ClickInfo info, int level, boolean select)
67697024 {
67707025 if (bRep == null)
....@@ -7288,20 +7543,23 @@
72887543 }
72897544 }
72907545
7291
- 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)
72927550 {
7293
- int hc = info.bounds.x + info.bounds.width / 2;
7294
- int vc = info.bounds.y + info.bounds.height / 2;
7295
- double[][] toscreen = info.toScreen;
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;
72967554 if (toscreen == null)
72977555 {
7298
- toscreen = new Camera(info.camera.viewCode).toScreen;
7556
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
72997557 }
73007558 cVector vec = in;
73017559 LA.xformPos(in, toscreen, in);
73027560 //System.out.println("Distance = " + info.camera.Distance());
7303
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
7304
- vec.y *= 100 * info.camera.SCALE / info.camera.Distance();
7561
+ vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
7562
+ vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
73057563 outPt.x = hc + (int) vec.x;
73067564 outPt.y = vc - (int) vec.y;
73077565 outRec.x = outPt.x - 3;
....@@ -7309,15 +7567,18 @@
73097567 outRec.width = outRec.height = 6;
73107568 }
73117569
7312
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7570
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7571
+ )
73137572 {
73147573 Point pt = new Point(0, 0);
73157574 Rectangle rec = new Rectangle();
7316
- calcHotSpot(in, info, pt, rec);
7575
+ calcHotSpot(in, //clickInfo,
7576
+ pt, rec);
73177577 return rec;
73187578 }
73197579
7320
- void drawEditHandles0(ClickInfo info, int level)
7580
+ void drawEditHandles0(//ClickInfo clickInfo,
7581
+ int level)
73217582 {
73227583 if (level == 0)
73237584 {
....@@ -7326,98 +7587,104 @@
73267587 {
73277588 cVector origin = new cVector();
73287589 //LA.xformPos(origin, toParent, origin);
7329
- Rectangle spot = calcHotSpot(origin, info);
7590
+ if (this.clickInfo == null)
7591
+ this.clickInfo = new ClickInfo();
7592
+
7593
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
73307594 Rectangle boundary = new Rectangle();
73317595 boundary.x = spot.x - 30;
73327596 boundary.y = spot.y - 30;
73337597 boundary.width = spot.width + 60;
73347598 boundary.height = spot.height + 60;
7335
- info.g.setColor(Color.red);
7599
+ clickInfo.g.setColor(Color.white);
73367600 int spotw = spot.x + spot.width;
73377601 int spoth = spot.y + spot.height;
7338
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7339
- if (CameraPane.Xmin > spot.x)
7340
- {
7341
- CameraPane.Xmin = spot.x;
7342
- }
7343
- if (CameraPane.Xmax < spotw)
7344
- {
7345
- CameraPane.Xmax = spotw;
7346
- }
7347
- if (CameraPane.Ymin > spot.y)
7348
- {
7349
- CameraPane.Ymin = spot.y;
7350
- }
7351
- if (CameraPane.Ymax < spoth)
7352
- {
7353
- CameraPane.Ymax = spoth;
7354
- }
7355
- spot.translate(32, 32);
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);
73567642 spotw = spot.x + spot.width;
73577643 spoth = spot.y + spot.height;
7358
- info.g.setColor(Color.blue);
7359
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7360
- if (CameraPane.Xmin > spot.x)
7361
- {
7362
- CameraPane.Xmin = spot.x;
7363
- }
7364
- if (CameraPane.Xmax < spotw)
7365
- {
7366
- CameraPane.Xmax = spotw;
7367
- }
7368
- if (CameraPane.Ymin > spot.y)
7369
- {
7370
- CameraPane.Ymin = spot.y;
7371
- }
7372
- if (CameraPane.Ymax < spoth)
7373
- {
7374
- CameraPane.Ymax = spoth;
7375
- }
7376
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7377
- info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7378
- spot.translate(0, -32);
7379
- info.g.setColor(Color.green);
7380
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7381
- if (CameraPane.Xmin > spot.x)
7382
- {
7383
- CameraPane.Xmin = spot.x;
7384
- }
7385
- if (CameraPane.Xmax < spotw)
7386
- {
7387
- CameraPane.Xmax = spotw;
7388
- }
7389
- if (CameraPane.Ymin > spot.y)
7390
- {
7391
- CameraPane.Ymin = spot.y;
7392
- }
7393
- if (CameraPane.Ymax < spoth)
7394
- {
7395
- CameraPane.Ymax = spoth;
7396
- }
7397
- info.g.drawArc(boundary.x, boundary.y,
7398
- boundary.width, boundary.height, 0, 360);
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);
73997665 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
7400
- if (CameraPane.Xmin > boundary.x)
7401
- {
7402
- CameraPane.Xmin = boundary.x;
7403
- }
7404
- if (CameraPane.Xmax < boundary.x + boundary.width)
7405
- {
7406
- CameraPane.Xmax = boundary.x + boundary.width;
7407
- }
7408
- if (CameraPane.Ymin > boundary.y)
7409
- {
7410
- CameraPane.Ymin = boundary.y;
7411
- }
7412
- if (CameraPane.Ymax < boundary.y + boundary.height)
7413
- {
7414
- CameraPane.Ymax = boundary.y + boundary.height;
7415
- }
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
+// }
74167682 return;
74177683 }
74187684 }
74197685
7420
- boolean doEditClick0(ClickInfo info, int level)
7686
+ boolean doEditClick0(//ClickInfo clickInfo,
7687
+ int level)
74217688 {
74227689 if (level == 0)
74237690 {
....@@ -7426,10 +7693,10 @@
74267693
74277694 boolean retval = false;
74287695
7429
- startX = info.x;
7430
- startY = info.y;
7696
+ startX = clickInfo.x;
7697
+ startY = clickInfo.y;
74317698
7432
- hitSomething = 0;
7699
+ hitSomething = -1;
74337700 cVector origin = new cVector();
74347701 //LA.xformPos(origin, toParent, origin);
74357702 Rectangle spot = new Rectangle();
....@@ -7437,22 +7704,53 @@
74377704 {
74387705 centerPt = new Point(0, 0);
74397706 }
7440
- calcHotSpot(origin, info, centerPt, spot);
7441
- if (spot.contains(info.x, info.y))
7707
+ calcHotSpot(origin, //info,
7708
+ centerPt, spot);
7709
+ if (spot.contains(clickInfo.x, clickInfo.y))
74427710 {
74437711 hitSomething = hitCenter;
74447712 retval = true;
74457713 }
74467714 spot.translate(32, 0);
7447
- if (spot.contains(info.x, info.y))
7715
+ if (spot.contains(clickInfo.x, clickInfo.y))
74487716 {
74497717 hitSomething = hitRotate;
74507718 retval = true;
74517719 }
74527720 spot.translate(0, 32);
7453
- 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))
74547724 {
74557725 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
+
74567754 retval = true;
74577755 }
74587756
....@@ -7462,7 +7760,7 @@
74627760 }
74637761
74647762 //System.out.println("info.modifiers = " + info.modifiers);
7465
- modified = (info.modifiers & CameraPane.META) != 0;
7763
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
74667764 //System.out.println("modified = " + modified);
74677765 //new Exception().printStackTrace();
74687766 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7490,7 +7788,8 @@
74907788 return true;
74917789 }
74927790
7493
- void doEditDrag0(ClickInfo info)
7791
+ void doEditDrag0(//ClickInfo info,
7792
+ boolean opposite)
74947793 {
74957794 if (hitSomething == 0)
74967795 {
....@@ -7504,7 +7803,8 @@
75047803
75057804 //System.out.println("hitSomething = " + hitSomething);
75067805
7507
- double scale = 0.005f * info.camera.Distance();
7806
+ double scale = 0.005f * clickInfo.camera.Distance();
7807
+
75087808 cVector xlate = new cVector();
75097809 //cVector xlate2 = new cVector();
75107810 switch (hitSomething)
....@@ -7515,9 +7815,11 @@
75157815
75167816 case hitCenter: // Translate
75177817
7518
- scale *= 0.05f * info.pane.theRenderer.renderCamera.Distance();
7818
+ scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
75197819
7520
- if (modified)
7820
+ // Modified could snap
7821
+ if (//modified ||
7822
+ opposite)
75217823 {
75227824 //assert(false);
75237825 /*
....@@ -7537,8 +7839,8 @@
75377839 toParent[3][i] = xlate.get(i);
75387840 LA.matInvert(toParent, fromParent);
75397841 */
7540
- cVector delta = LA.newVector(0, 0, startY - info.y);
7541
- 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);
75427844
75437845 LA.matCopy(startMat, toParent);
75447846 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7547,7 +7849,7 @@
75477849 } else
75487850 {
75497851 //LA.xformDir(delta, info.camera.fromScreen, delta);
7550
- cVector up = new cVector(info.camera.up);
7852
+ cVector up = new cVector(clickInfo.camera.up);
75517853 cVector away = new cVector();
75527854 //cVector right2 = new cVector();
75537855 //LA.vecCross(up, cVector.Z, right);
....@@ -7563,20 +7865,20 @@
75637865 }
75647866 LA.xformDir(up, ClickInfo.matbuffer, up);
75657867 // if (!CameraPane.LOCALTRANSFORM)
7566
- LA.xformDir(up, info.pane.theRenderer.renderCamera.toScreen, up);
7567
- 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);
75687870 // if (!CameraPane.LOCALTRANSFORM)
7569
- LA.xformDir(away, info.pane.theRenderer.renderCamera.toScreen, away);
7871
+ LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
75707872 //LA.vecCross(up, cVector.Z, right2);
75717873
7572
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7874
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
75737875
75747876 //System.out.println("DELTA0 = " + delta);
75757877 //System.out.println("AWAY = " + info.camera.away);
75767878 //System.out.println("UP = " + info.camera.up);
75777879 if (away.z > 0)
75787880 {
7579
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7881
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
75807882 {
75817883 delta.x = -delta.x;
75827884 } else
....@@ -7591,7 +7893,7 @@
75917893 //System.out.println("DELTA1 = " + delta);
75927894 LA.xformDir(delta, ClickInfo.matbuffer, delta);
75937895 //System.out.println("DELTA2 = " + delta);
7594
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7896
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
75957897 LA.matCopy(startMat, toParent);
75967898 //System.out.println("DELTA3 = " + delta);
75977899 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7601,8 +7903,8 @@
76017903 break;
76027904
76037905 case hitRotate: // rotate
7604
- int dx = info.x - centerPt.x;
7605
- int dy = -(info.y - centerPt.y);
7906
+ int dx = clickInfo.x - centerPt.x;
7907
+ int dy = -(clickInfo.y - centerPt.y);
76067908 double angle = (double) Math.atan2(dx, dy);
76077909 angle = -(1.570796 - angle);
76087910
....@@ -7611,6 +7913,7 @@
76117913
76127914 if (modified)
76137915 {
7916
+ // Rotate 45 degrees
76147917 angle /= (Math.PI / 4);
76157918 angle = Math.floor(angle + 0.5);
76167919 angle *= (Math.PI / 4);
....@@ -7624,7 +7927,7 @@
76247927 }
76257928 /**/
76267929
7627
- switch (info.pane.renderCamera.viewCode)
7930
+ switch (clickInfo.pane.RenderCamera().viewCode)
76287931 {
76297932 case 1: // '\001'
76307933 LA.matZRotate(toParent, angle);
....@@ -7651,26 +7954,30 @@
76517954 break;
76527955
76537956 case hitScale: // scale
7654
- 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);
76557964 if (hScale < 0.01)
76567965 {
7657
- hScale = 0.01;
7966
+ //hScale = 0.01;
76587967 }
7659
- hScale = Math.pow(hScale, scale * 50);
7660
- if (hScale < 0.01)
7968
+
7969
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
7970
+ sign = 1;
7971
+ if (vScale < 0)
76617972 {
7662
- hScale = 0.01;
7973
+ sign = -1;
76637974 }
7664
- double vScale = (double) (info.y - centerPt.y) / 32;
7975
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
76657976 if (vScale < 0.01)
76667977 {
7667
- vScale = 0.01;
7978
+ //vScale = 0.01;
76687979 }
7669
- vScale = Math.pow(vScale, scale * 50);
7670
- if (vScale < 0.01)
7671
- {
7672
- vScale = 0.01;
7673
- }
7980
+
76747981 LA.matCopy(startMat, toParent);
76757982 /**/
76767983 for (int i = 0; i < 3; i++)
....@@ -7680,39 +7987,56 @@
76807987 }
76817988 /**/
76827989
7683
- 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)
76847998 {
76857999 case 3: // '\001'
7686
- if (modified)
8000
+ if (modified || opposite)
76878001 {
8002
+ if (modified) // && opposite)
8003
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
8004
+ else
76888005 //LA.matScale(toParent, 1, hScale, vScale);
7689
- LA.matScale(toParent, vScale, 1, 1);
8006
+ LA.matScale(toParent, totalScale, 1, 1);
76908007 } // vScale, 1);
76918008 else
76928009 {
7693
- LA.matScale(toParent, vScale, vScale, vScale);
8010
+ // EXCEPTION!
8011
+ LA.matScale(toParent, 1, totalScale, totalScale);
76948012 } // vScale, 1);
76958013 break;
76968014
76978015 case 2: // '\002'
7698
- if (modified)
8016
+ if (modified || opposite)
76998017 {
7700
- //LA.matScale(toParent, hScale, 1, vScale);
7701
- 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);
77028023 } else
77038024 {
7704
- LA.matScale(toParent, vScale, 1, vScale);
8025
+ LA.matScale(toParent, totalScale, 1, totalScale);
77058026 }
77068027 break;
77078028
77088029 case 1: // '\003'
7709
- if (modified)
8030
+ if (modified || opposite)
77108031 {
7711
- //LA.matScale(toParent, hScale, vScale, 1);
7712
- 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);
77138037 } else
77148038 {
7715
- LA.matScale(toParent, vScale, vScale, 1);
8039
+ LA.matScale(toParent, totalScale, totalScale, 1);
77168040 }
77178041 break;
77188042 }
....@@ -7733,7 +8057,7 @@
77338057 if (parent == null)
77348058 {
77358059 System.out.println("NULL PARENT");
7736
- new Exception().printStackTrace();
8060
+ //new Exception().printStackTrace();
77378061 } else
77388062 {
77398063 if (parent instanceof BezierPatch)
....@@ -7746,7 +8070,7 @@
77468070 } // NEW ...
77478071
77488072
7749
- info.pane.repaint();
8073
+ clickInfo.pane.repaint();
77508074 }
77518075
77528076 boolean overflow = false;
....@@ -7845,14 +8169,22 @@
78458169 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
78468170 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
78478171 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
8172
+
8173
+ String objname;
8174
+
78488175 if (false) //parent != null)
78498176 {
7850
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
8177
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
78518178 } else
78528179 {
7853
- 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) ":"") */ "";
78548181 } // + super.toString();
78558182 //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()
78568188 }
78578189
78588190 public int hashCode()
....@@ -7908,6 +8240,7 @@
79088240 objectUI.closeUI();
79098241 if (editWindow != null)
79108242 {
8243
+ editWindow.ctrlPanel.FlushUI();
79118244 editWindow.refreshContents();
79128245 } // ? new
79138246 objectUI = null;
....@@ -7916,6 +8249,10 @@
79168249 {
79178250 editWindow = null;
79188251 } // ?
8252
+ }
8253
+ else
8254
+ {
8255
+ //editWindow.closeUI();
79198256 }
79208257 }
79218258
....@@ -7928,7 +8265,7 @@
79288265 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
79298266
79308267 Object3D /*Composite*/ parent;
7931
- Object3D /*Composite*/ fileparent;
8268
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
79328269
79338270 double[][] toParent; // dynamic matrix
79348271 double[][] fromParent;
....@@ -8043,7 +8380,7 @@
80438380 {
80448381 assert(bRep != null);
80458382 if (!(support instanceof GenericJoint)) // support.bRep != null)
8046
- GrafreeD.Assert(support.bRep == bRep.support);
8383
+ Grafreed.Assert(support.bRep == bRep.support);
80478384 }
80488385 else
80498386 {
....@@ -8074,6 +8411,10 @@
80748411 }
80758412
80768413 transient ObjEditor editWindow;
8414
+ transient ObjEditor manipWindow;
8415
+
8416
+ transient boolean pinned;
8417
+
80778418 transient ObjectUI objectUI;
80788419 public static int povDepth = 0;
80798420 private static cVector tbMin = new cVector();
....@@ -8092,9 +8433,9 @@
80928433 private static cVector edge2 = new cVector();
80938434 //private static cVector norm = new cVector();
80948435 /*transient private*/ int hitSomething;
8095
- private static final int hitCenter = 1;
8096
- private static final int hitScale = 2;
8097
- private static final int hitRotate = 3;
8436
+ static final int hitCenter = 1;
8437
+ static final int hitScale = 2;
8438
+ static final int hitRotate = 3;
80988439 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
80998440 /*transient*/ private Point centerPt;
81008441 /*transient*/ private int startX;
....@@ -8126,6 +8467,8 @@
81268467 {
81278468 Object3D targ = this;
81288469
8470
+ targ.NORMALPUSH = obj.NORMALPUSH;
8471
+
81298472 if (obj.material != null)
81308473 {
81318474 if ((mask&MATERIAL)!=0) // ==(COLOR|MATERIAL))