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 GraphreeD.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) GraphreeD.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) GraphreeD.clone(bRep);
1972
+ o.bRep = (BoundaryRep) Grafreed.clone(bRep);
17181973 o.CreateMaterial();
17191974 //o.overwriteThis(this, -1);
17201975 o.SetAttributes(this, -1);
....@@ -1756,7 +2011,7 @@
17562011 // {
17572012 // assert(bRep == null);
17582013 // Object3D o = new Object3D("Geometry:" + this.name);
1759
-// o.bRep = (BoundaryRep) GraphreeD.clone(transientrep);
2014
+// o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
17602015 // o.CreateMaterial();
17612016 // parent.addChild(o);
17622017 // }
....@@ -1765,7 +2020,7 @@
17652020 // {
17662021 // assert(transientrep == null);
17672022 // Object3D o = new Object3D("Geometry:" + this.name);
1768
-// o.bRep = (BoundaryRep) GraphreeD.clone(bRep);
2023
+// o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
17692024 // o.CreateMaterial();
17702025 // parent.addChild(o);
17712026 // }
....@@ -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) GraphreeD.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 (GraphreeD.RENDERME > 0)
4216
+ if (Grafreed.RENDERME > 0)
36814217 {
36824218 if (child instanceof Merge)
36834219 ((Merge)child).renderme();
....@@ -3717,7 +4253,7 @@
37174253
37184254 boolean getCentroid(cVector centroid, boolean xform)
37194255 {
3720
- assert(false);
4256
+// for speaker assert(false);
37214257 if (blockloop)
37224258 return false;
37234259
....@@ -3828,7 +4364,7 @@
38284364 if (child == null)
38294365 continue;
38304366
3831
- if (GraphreeD.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 (GraphreeD.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 }
....@@ -4515,16 +5116,28 @@
45155116
45165117 Object3D GetFileRoot()
45175118 {
5119
+ if (overflow)
5120
+ return null;
5121
+
5122
+ overflow = true;
5123
+
5124
+ Object3D pfr = null;
5125
+
45185126 if (parent == null && fileparent == null)
4519
- return this;
5127
+ pfr = this;
45205128
45215129 if (parent == null && fileparent != null) // V4.gfd???
4522
- return fileparent;
5130
+ pfr = fileparent;
45235131
4524
- if (parent == null)
4525
- return this;
5132
+ if (pfr == null && parent == null)
5133
+ pfr = this;
45265134
4527
- return parent.GetFileRoot();
5135
+ if (pfr == null)
5136
+ pfr = parent.GetFileRoot();
5137
+
5138
+ overflow = false;
5139
+
5140
+ return pfr;
45285141 }
45295142
45305143 cTreePath GetPath()
....@@ -4602,7 +5215,7 @@
46025215
46035216 cTreePath SelectLeaf(int indexcount, boolean deselect)
46045217 {
4605
- if (hide)
5218
+ if (hide || dontselect)
46065219 return null;
46075220
46085221 if (count <= 0)
....@@ -4626,9 +5239,17 @@
46265239 }
46275240 }
46285241
5242
+ ObjEditor GetWindow()
5243
+ {
5244
+ if (editWindow != null)
5245
+ return editWindow;
5246
+
5247
+ return manipWindow;
5248
+ }
5249
+
46295250 cTreePath Select(int indexcount, boolean deselect)
46305251 {
4631
- if (hide)
5252
+ if (hide || dontselect)
46325253 return null;
46335254
46345255 if (count <= 0)
....@@ -4662,10 +5283,11 @@
46625283 if (leaf != null)
46635284 {
46645285 cTreePath tp = new cTreePath(this, leaf);
4665
- if (editWindow != null)
5286
+ ObjEditor window = GetWindow();
5287
+ if (window != null)
46665288 {
46675289 //System.out.println("editWindow = " + editWindow + " vs " + this);
4668
- editWindow.Select(tp, deselect, true);
5290
+ window.Select(tp, deselect, true);
46695291 }
46705292
46715293 return tp;
....@@ -4682,6 +5304,7 @@
46825304
46835305 if (child == null)
46845306 continue;
5307
+
46855308 if (child.HasTransparency() && child.size() != 0)
46865309 {
46875310 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4691,9 +5314,10 @@
46915314 if (leaf != null)
46925315 {
46935316 cTreePath tp = new cTreePath(this, leaf);
4694
- if (editWindow != null)
5317
+ ObjEditor window = GetWindow();
5318
+ if (window != null)
46955319 {
4696
- editWindow.Select(tp, deselect, true);
5320
+ window.Select(tp, deselect, true);
46975321 }
46985322
46995323 return tp;
....@@ -4778,7 +5402,7 @@
47785402 return globalTransform;
47795403 }
47805404
4781
- void PreprocessOcclusion(CameraPane cp)
5405
+ void PreprocessOcclusion(iCameraPane cp)
47825406 {
47835407 /*
47845408 if (AOdone)
....@@ -4925,7 +5549,8 @@
49255549 } else //
49265550 if (editWindow != null)
49275551 {
4928
- editWindow.cameraView.lighttouched = true;
5552
+ //editWindow.cameraView.lighttouched = true;
5553
+ Globals.lighttouched = true;
49295554 }
49305555 }
49315556
....@@ -5017,6 +5642,51 @@
50175642 blockloop = false;
50185643 }
50195644
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
+
50205690 boolean IsSelected()
50215691 {
50225692 if (parent == null)
....@@ -5077,12 +5747,41 @@
50775747 if (fullname == null)
50785748 return "";
50795749
5750
+ if (fullname.pigment != null)
5751
+ {
5752
+ return fullname.pigment;
5753
+ }
5754
+
50805755 // System.out.println("Fullname = " + fullname);
50815756
5082
- if (fullname.name.indexOf(":") == -1)
5083
- 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(":"));
50845762
5085
- 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];
50865785 }
50875786
50885787 static String GetBump(cTexture fullname)
....@@ -5090,11 +5789,44 @@
50905789 if (fullname == null)
50915790 return "";
50925791
5792
+ if (fullname.bump != null)
5793
+ {
5794
+ return fullname.bump;
5795
+ }
5796
+
50935797 // System.out.println("Fullname = " + fullname);
5094
- if (fullname.name.indexOf(":") == -1)
5095
- return "";
5096
-
5097
- return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
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];
50985830 }
50995831
51005832 String GetPigmentTexture()
....@@ -5168,7 +5900,7 @@
51685900 System.out.print("; textures = " + textures);
51695901 System.out.println("; usedtextures = " + usedtextures);
51705902
5171
- if (GetTextures() == null)
5903
+ if (GetTextures() == null) // What is that??
51725904 GetTextures().name = ":";
51735905
51745906 String texname = tex;
....@@ -5177,6 +5909,9 @@
51775909 texname = "";
51785910
51795911 GetTextures().name = texname + ":" + GetBump(GetTextures());
5912
+
5913
+ GetTextures().pigment = null;
5914
+
51805915 Touch();
51815916 }
51825917
....@@ -5201,6 +5936,43 @@
52015936 }
52025937 }
52035938
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
+
52045976 void SetBumpTexture(String tex)
52055977 {
52065978 if (GetTextures() == null)
....@@ -5212,6 +5984,8 @@
52125984 texname = "";
52135985
52145986 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
5987
+
5988
+ GetTextures().bump = null;
52155989
52165990 Touch();
52175991 }
....@@ -5237,25 +6011,70 @@
52376011 }
52386012 }
52396013
5240
- 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)
52416047 {
52426048 Draw(display, root, selected, blocked);
52436049 }
52446050
5245
- static cMaterial[] materialstack = new cMaterial[65536];
5246
- static boolean[] selectedstack = new boolean[65536];
5247
- static int materialdepth = 0;
5248
-
52496051 boolean NeedSupport()
52506052 {
52516053 return
5252
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
6054
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
52536055 // PROBLEM with CROWD!!
5254
- && (CameraPane.drawMode == CameraPane.SHADOW || CameraPane.CROWD);
6056
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
52556057 }
52566058
6059
+ static boolean DEBUG_SELECTION = false;
52576060
5258
- 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)
52596078 {
52606079 Invariants(); // june 2013
52616080
....@@ -5264,8 +6083,8 @@
52646083 // System.err.println("Draw " + this + " Frame # " + ((Mocap)((Merge)support).object).frame);
52656084 }
52666085
5267
- if (display.drawMode == CameraPane.SELECTION &&
5268
- hide)
6086
+ if (display.DrawMode() == iCameraPane.SELECTION &&
6087
+ (hide || dontselect))
52696088 return;
52706089
52716090 if (name != null && name.contains("sclera"))
....@@ -5280,10 +6099,10 @@
52806099 if (name != null && name.contains("sclera"))
52816100 name = name;
52826101
5283
- if (this instanceof CheckerIG)
6102
+ if (this instanceof Checker)
52846103 return;
52856104
5286
- if (display.drawMode == display.SHADOW && PASSTEST)
6105
+ if (display.DrawMode() == display.SHADOW && PASSTEST)
52876106 return;
52886107
52896108 if (count <= 0)
....@@ -5291,13 +6110,13 @@
52916110 return;
52926111 }
52936112
5294
- if ((//display.drawMode == CameraPane.SHADOW ||
5295
- display.drawMode == CameraPane.SELECTION || CameraPane.DEBUG_SELECTION) && HasTransparency())
6113
+ if ((//display.DrawMode() == CameraPane.SHADOW ||
6114
+ display.DrawMode() == iCameraPane.SELECTION || display.IsDebugSelection()) && HasTransparency())
52966115 {
52976116 return;
52986117 }
52996118
5300
- javax.media.opengl.GL gl = display.GetGL();
6119
+ //javax.media.opengl.GL gl = display.GetGL();
53016120
53026121 /*
53036122 if (touched)
....@@ -5315,8 +6134,11 @@
53156134 if (support != null)
53166135 support = support;
53176136
5318
- //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5319
- boolean usecalllists = false; // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
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.
53206142
53216143 if (!usecalllists && bRep != null && bRep.displaylist > 0)
53226144 {
....@@ -5326,30 +6148,33 @@
53266148 // usecalllists &= !(parent instanceof RandomNode);
53276149 // usecalllists = false;
53286150
5329
- if (GetBRep() != null)
5330
- usecalllists = usecalllists;
6151
+ if (display.DrawMode() == display.SHADOW)
6152
+ //GetBRep() != null)
6153
+ usecalllists = !!usecalllists;
53316154 //System.out.println("draw " + this);
53326155 //new Exception().printStackTrace();
53336156
53346157 boolean compiled = false;
53356158
5336
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
6159
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
53376160
5338
- if (!selectmode && //display.drawMode != display.SELECTION &&
5339
- (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)))
53406164 {
5341
- display.lighttouched = true;
6165
+ Globals.lighttouched = true;
53426166 } // all panes...
5343
- //if (usecalllists && display.drawMode != display.SELECTION && display.drawMode != display.SHADOW &&
5344
- if (bRep != null && usecalllists && !selectmode && // june 2013 display.drawMode != display.SHADOW &&
6167
+
6168
+ //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
6169
+ if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
53456170 (touched || (bRep != null && bRep.displaylist <= 0)))
53466171 {
53476172 if (!(this instanceof Composite))
53486173 touched = false;
53496174 //if (displaylist == -1 && usecalllists)
5350
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
6175
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
53516176 {
5352
- bRep.displaylist = gl.glGenLists(1);
6177
+ bRep.displaylist = display.GenList();
53536178 assert(bRep.displaylist != 0);
53546179 // System.err.println("glGenLists: " + bRep.displaylist + " for " + this);
53556180 //System.out.println("\tgen list " + list);
....@@ -5358,21 +6183,23 @@
53586183
53596184 //System.out.println("\tnew list " + list);
53606185 //gl.glDrawBuffer(gl.GL_NONE);
5361
- if (usecalllists)
6186
+ if (usecalllists && bRep.displaylist > 0)
53626187 {
53636188 // System.err.println("new list " + bRep.displaylist + " for " + this);
5364
- gl.glNewList(bRep.displaylist, gl.GL_COMPILE); //_AND_EXECUTE);
6189
+ display.NewList(bRep.displaylist);
53656190 }
6191
+
53666192 CallList(display, root, selected, blocked);
6193
+
53676194 // compiled = true;
5368
- if (usecalllists)
6195
+ if (usecalllists && bRep.displaylist > 0)
53696196 {
53706197 // System.err.println("end list " + bRep.displaylist + " for " + this);
5371
- gl.glEndList();
6198
+ display.EndList();
53726199 }
53736200 //gl.glDrawBuffer(gl.GL_BACK);
53746201 // XXX touched = false;
5375
- display.lighttouched = true; // all panes...
6202
+ Globals.lighttouched = true; // all panes...
53766203 }
53776204
53786205 touched = GetBRep() == null; // this instanceof Composite || this instanceof FileObject; // false;
....@@ -5411,12 +6238,12 @@
54116238
54126239 // frustum culling
54136240 if (CameraPane.FRUSTUM && !blocked && !IsInfinite() && GetBRep() != null // && GetBRep().VertexCount() != 1260 // default grid
5414
- && display.drawMode != CameraPane.SELECTION)
6241
+ && display.DrawMode() != iCameraPane.SELECTION)
54156242 {
5416
- if (display.drawMode == CameraPane.SHADOW)
6243
+ if (display.DrawMode() == iCameraPane.SHADOW)
54176244 {
54186245 if (!link2master // tricky to cull in shadow mode.
5419
- && GetBRep().FrustumCull(this, gl, display.lightCamera, true))
6246
+ && GetBRep().FrustumCull(this, null, display.LightCamera(), true))
54206247 {
54216248 //System.out.print("CULLED");
54226249 culled = true;
....@@ -5424,7 +6251,7 @@
54246251 }
54256252 else
54266253 //GetBRep().getBounds(v0, v1, this);
5427
- if (GetBRep().FrustumCull(this, gl, display.renderCamera, false))
6254
+ if (GetBRep().FrustumCull(this, null, display.RenderCamera(), false))
54286255 culled = true;
54296256
54306257 // LA.xformPos(v0, display.renderCamera.toScreen, v0);
....@@ -5460,11 +6287,12 @@
54606287
54616288
54626289 if (!culled)
5463
- if (display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION)
6290
+ if (display.DrawMode() == display.SELECTION || display.IsDebugSelection())
54646291 {
54656292 if (GetBRep() != null)
54666293 {
5467
- CameraPane.NextIndex(this, gl);
6294
+ display.NextIndex();
6295
+
54686296 // vertex color conflict : gl.glCallList(list);
54696297 DrawNode(display, root, selected);
54706298 if (this instanceof BezierPatch)
....@@ -5486,53 +6314,7 @@
54866314 color[2] /= 2;
54876315 gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT_AND_DIFFUSE, color, 0);
54886316 */
5489
- if (material != null)
5490
- {
5491
- materialstack[materialdepth] = material;
5492
- selectedstack[materialdepth] = selected;
5493
- cStatic.objectstack[materialdepth++] = this;
5494
- //System.out.println("material " + material);
5495
- //Applet3D.tracein(this, selected);
5496
- display.vector2buffer = projectedVertices;
5497
- if (this instanceof Camera)
5498
- {
5499
- display.options1[0] = material.shift;
5500
- //System.out.println("shift " + material.shift);
5501
- display.options1[1] = material.lightarea;
5502
- display.options1[2] = material.shadowbias;
5503
- display.options1[3] = material.aniso;
5504
- display.options1[4] = material.anisoV;
5505
- display.options2[0] = material.opacity;
5506
- display.options2[1] = material.diffuse;
5507
- display.options2[2] = material.factor;
5508
-
5509
- cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
5510
- display.options3[3] = material.cameralight/0.2f;
5511
-
5512
- // if (display.CURRENTANTIALIAS > 0)
5513
- // display.options3[3] /= 4;
5514
-
5515
- /*
5516
- System.out.println("Focus = " + display.options1[0]);
5517
- System.out.println("Aperture = " + display.options1[1]);
5518
- System.out.println("ShadowBlur = " + display.options1[2]);
5519
- System.out.println("Antialiasing = " + display.options1[3]);
5520
- System.out.println("Fog = " + display.options2[0]);
5521
- System.out.println("Intensity = " + display.options2[1]);
5522
- System.out.println("Elevation = " + display.options2[2]);
5523
- /**/
5524
- } else
5525
- {
5526
- material.Draw(display, selected);
5527
- }
5528
- } else
5529
- {
5530
- if (selected && CameraPane.flash)
5531
- {
5532
- display.modelParams4[1] = 100;
5533
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
5534
- }
5535
- }
6317
+ display.PushMaterial(this, selected);
55366318
55376319 //System.out.println("call list " + list);
55386320 //System.out.println();
....@@ -5551,7 +6333,28 @@
55516333 tex = GetTextures();
55526334 }
55536335
5554
- 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
+ }
55556358
55566359 if (!compiled)
55576360 {
....@@ -5567,30 +6370,19 @@
55676370
55686371 // System.err.println("glCallList: " + bRep.displaylist + " for " + this);
55696372 assert(bRep.displaylist != 0);
5570
- gl.glCallList(bRep.displaylist);
6373
+ display.CallList(bRep.displaylist);
55716374 // june 2013 drawSelf(display, root, selected);
55726375 }
55736376 }
55746377 }
55756378
5576
- display.ReleaseTextures(tex);
5577
-
5578
- //if (parent != null && parent.GetMaterial() != null)
5579
- // parent.GetMaterial().Draw(display, parent.IsSelected(this));
5580
- if (material != null)
5581
- {
5582
- materialdepth -= 1;
5583
- if (materialdepth > 0)
5584
- {
5585
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
5586
- materialstack[materialdepth - 1].Draw(display, selectedstack[materialdepth - 1]);
5587
- }
5588
- //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
5589
- } else if (selected && CameraPane.flash && GetMaterial() != null)
5590
- {
5591
- display.modelParams4[1] = GetMaterial().cameralight;
5592
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
5593
- }
6379
+ if (!failedBump)
6380
+ display.ReleaseBumpTexture(tex);
6381
+
6382
+ if (!failedPigment)
6383
+ display.ReleasePigmentTexture(tex);
6384
+
6385
+ display.PopMaterial(this, selected);
55946386 }
55956387
55966388 if (this instanceof Texture || this instanceof TextureNode)
....@@ -5632,7 +6424,7 @@
56326424 // resetMasterNode();
56336425 }
56346426
5635
- void CallList(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
6427
+ void CallList(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
56366428 {
56376429 if (GetBRep() == null)
56386430 {
....@@ -5715,8 +6507,11 @@
57156507 boolean flipV = false; // true;
57166508 int texres = 0; // 0 = low, 1 = normal, 2 = high res texture
57176509
5718
- void drawSelf(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
6510
+ void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57196511 {
6512
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6513
+ return;
6514
+
57206515 if (hide)
57216516 return;
57226517 // shadow optimisation
....@@ -5774,16 +6569,7 @@
57746569 // // ??????????????????????????? Touch();
57756570 // }
57766571
5777
- if (material != null)
5778
- {
5779
- materialstack[materialdepth] = material;
5780
- selectedstack[materialdepth] = selected;
5781
- cStatic.objectstack[materialdepth++] = this;
5782
- //System.out.println("material " + material);
5783
- //Applet3D.tracein("selected ", selected);
5784
- display.vector2buffer = projectedVertices;
5785
- material.Draw(display, selected);
5786
- }
6572
+display.PushMaterial2(this, selected);
57876573
57886574 Object3D child;
57896575 boolean sel;
....@@ -5807,12 +6593,12 @@
58076593 if (!child.HasTransparency())
58086594 {
58096595 sel = root != null && root.selection != null && root.selection.indexOf(child) != -1;
5810
- // GraphreeD.tracein("draw ", child);
6596
+ // GrafreeD.tracein("draw ", child);
58116597 boolean wasblocked = blockdraw;
58126598 blockdraw = true;
58136599 child.draw(display, root, selected || sel, wasblocked || blocked); // || child.IsSelected());
58146600 blockdraw = false;
5815
- // GraphreeD.traceout("draw ", child);
6601
+ // GrafreeD.traceout("draw ", child);
58166602 }
58176603
58186604 release(i);
....@@ -5835,19 +6621,7 @@
58356621 */
58366622 //depth += 1;
58376623
5838
- if (material != null)
5839
- {
5840
- materialdepth -= 1;
5841
- if (materialdepth > 0)
5842
- {
5843
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
5844
- materialstack[materialdepth - 1].Draw(display, selectedstack[materialdepth - 1]);
5845
- }
5846
- //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
5847
- //else
5848
- //material.Draw(display, false);
5849
- }
5850
-
6624
+display.PopMaterial2(this);
58516625 /*
58526626 display.ReleaseTextures(tex);
58536627 */
....@@ -5858,10 +6632,13 @@
58586632
58596633 //static cVector min,max;
58606634
5861
- void DrawNode(CameraPane display, Object3D /*Composite*/ root, boolean selected)
6635
+ void DrawNode(iCameraPane display, Object3D /*Composite*/ root, boolean selected)
58626636 {
5863
- 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)
58646638 return; // no shadow for transparent objects
6639
+
6640
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6641
+ return;
58656642
58666643 if (hide)
58676644 return;
....@@ -5903,11 +6680,12 @@
59036680 return;
59046681 }
59056682
6683
+ //bRep.GenUV(1/material.diffuseness);
59066684 // bRep.lock = true;
59076685
5908
- javax.media.opengl.GL gl = display.GetGL();
6686
+ //javax.media.opengl.GL gl = display.GetGL();
59096687
5910
- if (CameraPane.BOXMODE) // || CameraPane.movingcamera)
6688
+ if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera)
59116689 {
59126690 int fc = bRep.FaceCount();
59136691 int vc = bRep.VertexCount();
....@@ -5922,23 +6700,7 @@
59226700
59236701 bRep.getMinMax(min, max, 100);
59246702
5925
- gl.glBegin(gl.GL_LINES);
5926
-
5927
- gl.glVertex3d(min.x, min.y, min.z);
5928
- gl.glVertex3d(min.x, min.y, max.z);
5929
- gl.glVertex3d(min.x, min.y, min.z);
5930
- gl.glVertex3d(min.x, max.y, min.z);
5931
- gl.glVertex3d(min.x, min.y, min.z);
5932
- gl.glVertex3d(max.x, min.y, min.z);
5933
-
5934
- gl.glVertex3d(max.x, max.y, max.z);
5935
- gl.glVertex3d(min.x, max.y, max.z);
5936
- gl.glVertex3d(max.x, max.y, max.z);
5937
- gl.glVertex3d(max.x, min.y, max.z);
5938
- gl.glVertex3d(max.x, max.y, max.z);
5939
- gl.glVertex3d(max.x, max.y, min.z);
5940
-
5941
- gl.glEnd();
6703
+ display.DrawBox(min, max);
59426704
59436705 return;
59446706 }
....@@ -5982,7 +6744,7 @@
59826744 {
59836745 //throw new Error();
59846746
5985
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
6747
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
59866748
59876749 int[] strips = bRep.getRawIndices();
59886750
....@@ -5992,178 +6754,19 @@
59926754 new Exception().printStackTrace();
59936755 return;
59946756 }
5995
-
5996
- // TRIANGLE STRIP ARRAY
5997
- if (bRep.trimmed)
6757
+
6758
+ if (dontselect)
59986759 {
5999
- float[] v = bRep.getRawVertices();
6000
- float[] n = bRep.getRawNormals();
6001
- float[] c = bRep.getRawColors();
6002
- float[] uv = bRep.getRawUVMap();
6003
-
6004
- int count2 = 0;
6005
- int count3 = 0;
6006
-
6007
- if (n.length > 0)
6008
- {
6009
- for (int i = 0; i < strips.length; i++)
6010
- {
6011
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6012
-
6013
- /*
6014
- boolean locked = false;
6015
- float eps = 0.1f;
6016
- boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
6017
-
6018
- int dot = 0;
6019
-
6020
- if ((dot&1) == 0)
6021
- dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
6022
-
6023
- if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
6024
- gl.glTexCoord2f((float) qv.s, (float) qv.t);
6025
- else
6026
- {
6027
- locked = true;
6028
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6029
- }
6030
- //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6031
- gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
6032
- if (hasnorm)
6033
- {
6034
- //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6035
- gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
6036
- }
6037
-
6038
- if ((dot&4) == 0)
6039
- dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
6040
-
6041
- if (wrap || !locked && (dot&8) != 0)
6042
- gl.glTexCoord2f((float) rv.s, (float) rv.t);
6043
- else
6044
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6045
-
6046
- f.dot = dot;
6047
- */
6048
-
6049
- if (!selectmode)
6050
- {
6051
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6052
- {
6053
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6054
- } else
6055
- {
6056
- gl.glNormal3f(0, 0, 1);
6057
- }
6058
-
6059
- if (c != null)
6060
- //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]);
6061
- {
6062
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6063
- }
6064
- }
6065
- if (flipV)
6066
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6067
- else
6068
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6069
- //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6070
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6071
-
6072
- count2 += 2;
6073
- count3 += 3;
6074
- if (!selectmode)
6075
- {
6076
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6077
- {
6078
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6079
- } else
6080
- {
6081
- gl.glNormal3f(0, 0, 1);
6082
- }
6083
- if (c != null)
6084
- {
6085
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6086
- }
6087
- }
6088
- if (flipV)
6089
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6090
- else
6091
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6092
- //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6093
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6094
-
6095
- count2 += 2;
6096
- count3 += 3;
6097
- for (int j = 0; j < strips[i] - 2; j++)
6098
- {
6099
- //gl.glTexCoord2d(...);
6100
- if (!selectmode)
6101
- {
6102
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6103
- {
6104
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6105
- } else
6106
- {
6107
- gl.glNormal3f(0, 0, 1);
6108
- }
6109
- if (c != null)
6110
- {
6111
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6112
- }
6113
- }
6114
-
6115
- if (flipV)
6116
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6117
- else
6118
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6119
- //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
6120
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6121
- count2 += 2;
6122
- count3 += 3;
6123
- }
6124
-
6125
- gl.glEnd();
6126
- }
6127
- }
6128
-
6129
- assert count3 == v.length;
6760
+ //bRep.GenerateNormalsMINE();
61306761 }
6131
- else // !trimmed
6132
- {
6133
- int count = 0;
6134
- for (int i = 0; i < strips.length; i++)
6135
- {
6136
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6137
-
6138
- Vertex p = bRep.GetVertex(bRep.indices[count++]);
6139
- Vertex q = bRep.GetVertex(bRep.indices[count++]);
6140
-
6141
- drawVertex(gl, p, selectmode);
6142
- drawVertex(gl, q, selectmode);
6143
-
6144
- for (int j = 0; j < strips[i] - 2; j++)
6145
- {
6146
- Vertex r = bRep.GetVertex(bRep.indices[count++]);
6147
-
6148
-// if (j%2 == 0)
6149
-// drawFace(p, q, r, display, null);
6150
-// else
6151
-// drawFace(p, r, q, display, null);
6152
-
6153
-// p = q;
6154
-// q = r;
6155
- drawVertex(gl, r, selectmode);
6156
- }
6157
-
6158
- gl.glEnd();
6159
- }
6160
- }
6762
+
6763
+ display.DrawGeometry(bRep, flipV, selectmode);
61616764 } else // catch (Error e)
61626765 {
61636766 // TRIANGLE ARRAY
61646767 if (IsOpaque()) // Static())
61656768 {
6166
- gl.glBegin(gl.GL_TRIANGLES);
6769
+ display.StartTriangles();
61676770 int facecount = bRep.FaceCount();
61686771 for (int i = 0; i < facecount; i++)
61696772 {
....@@ -6226,9 +6829,9 @@
62266829 // // r.norm.dot(v3) > -0.5)
62276830 // // continue;
62286831
6229
- drawFace(p, q, r, display, face);
6832
+ display.DrawFace(this, p, q, r, face);
62306833 }
6231
- gl.glEnd();
6834
+ display.EndTriangles();
62326835 }
62336836 else
62346837 {
....@@ -6257,8 +6860,8 @@
62576860 //System.out.println("SORT");
62586861
62596862 java.util.Arrays.sort(facescompare);
6260
-
6261
- gl.glBegin(gl.GL_TRIANGLES);
6863
+
6864
+ display.StartTriangles();
62626865 for (int i = 0; i < facecount; i++)
62636866 {
62646867 Face face = bRep.GetFace(facescompare[i].index);
....@@ -6270,13 +6873,14 @@
62706873 Vertex q = bRep.GetVertex(face.q);
62716874 Vertex r = bRep.GetVertex(face.r);
62726875
6273
- drawFace(p, q, r, display, face);
6876
+ display.DrawFace(this, p, q, r, face);
62746877 }
6275
- gl.glEnd();
6878
+ display.EndTriangles();
62766879 }
62776880
62786881 if (false) // live && support != null && support.bRep != null) // debug weights
62796882 {
6883
+ /*
62806884 gl.glDisable(gl.GL_LIGHTING);
62816885 float[] colorV = new float[3];
62826886
....@@ -6355,6 +6959,7 @@
63556959 // gl.glEnd();
63566960 }
63576961 }
6962
+ */
63586963 }
63596964 }
63606965
....@@ -6399,7 +7004,7 @@
63997004 center.add(r);
64007005 center.mul(1.0/3);
64017006
6402
- center.sub(CameraPane.theRenderer.eyeCamera.location);
7007
+ center.sub(Globals.theRenderer.EyeCamera().location);
64037008
64047009 distance = center.dot(center);
64057010 }
....@@ -6410,347 +7015,11 @@
64107015
64117016 transient FaceCompare[] facescompare = null;
64127017
6413
- void SetColor(CameraPane display, Vertex p0)
6414
- {
6415
- if (display.RENDERPROGRAM == 0)
6416
- {
6417
- float r = 0;
6418
- if (bRep != null)
6419
- {
6420
- if (bRep.stripified)
6421
- {
6422
- r = 1;
6423
- }
6424
- }
6425
- float g = 0;
6426
- if (bRep != null)
6427
- {
6428
- if (bRep.trimmed)
6429
- {
6430
- g = 1;
6431
- }
6432
- }
6433
- float b = 0;
6434
- if (support != null && link2master)
6435
- {
6436
- b = 1;
6437
- }
6438
- display.GetGL().glColor3f(r*p0.AO, g*p0.AO, b*p0.AO);
6439
- return;
6440
- }
6441
-
6442
- if (display.drawMode != CameraPane.SHADOW)
6443
- return;
6444
-
6445
- javax.media.opengl.GL gl = display.GetGL();
6446
-// if (true) return;
6447
-// float ao = p.AO;
6448
-//
6449
-// // if (ao == 0 && !bRep.AOdone) // transient problem!
6450
-// // ao = 1;
6451
-//
6452
-// gl.glColor4f(ao, ao, ao, 1);
6453
-
6454
-// CameraPane.selectedpoint.
6455
-// getAverage(cStatic.point1, true);
6456
- if (CameraPane.pointflow == null) // !random) // live)
6457
- {
6458
- return;
6459
- }
6460
-
6461
- cStatic.point1.set(0,0,0);
6462
- LA.xformPos(cStatic.point1, CameraPane.selectedpoint.toParent, cStatic.point1);
6463
-
6464
- cStatic.point1.sub(p0);
6465
-
6466
-
6467
-// if (marked && (p0.vertexlinks == null || support == null || support.bRep == null)) // no position delta?
6468
-// {
6469
-// return;
6470
-// }
6471
-
6472
- //if (true)
6473
- if (cStatic.point1.dot(cStatic.point1) > 0.000001)
6474
- {
6475
- return;
6476
- }
6477
-
6478
- float[] colorV = new float[3];
6479
-
6480
- if (false) // marked)
6481
- {
6482
- // debug rigging weights
6483
- for (int object = 0; object < p0.vertexlinks.length; object++)
6484
- {
6485
- float weight = p0.weights[object] / p0.totalweight;
6486
-
6487
- // if (weight < 0.1)
6488
- // {
6489
- // assert(weight == 0);
6490
- // continue;
6491
- // }
6492
-
6493
- if (p0.vertexlinks[object] == -1)
6494
- continue;
6495
-
6496
- Vertex q = support.bRep.GetVertex(p0.vertexlinks[object]);
6497
-
6498
- int color = //1 << object; //
6499
- //p.vertexlinks.length;
6500
- support.bRep.supports[p0.closestsupport].links[object];
6501
- colorV[2] += (color & 1) * weight;
6502
- colorV[1] += ((color & 2) >> 1) * weight;
6503
- colorV[0] += ((color & 4) >> 2) * weight;
6504
- }
6505
- }
6506
- else
6507
- {
6508
- if (drawingstarted)
6509
- {
6510
- // find next point
6511
- if (bRep.GetVertex(0).faceindices == null)
6512
- {
6513
- bRep.InitFaceIndices();
6514
- }
6515
-
6516
- double ymin = p0.y;
6517
-
6518
- Vertex newp = p0;
6519
-
6520
- for (int fii = 0; fii < p0.faceindices.length; fii++)
6521
- {
6522
- int fi = p0.faceindices[fii];
6523
-
6524
- if (fi == -1)
6525
- break;
6526
-
6527
- Face f = bRep.GetFace(fi);
6528
-
6529
- Vertex p = bRep.GetVertex(f.p);
6530
- Vertex q = bRep.GetVertex(f.q);
6531
- Vertex r = bRep.GetVertex(f.r);
6532
-
6533
- int swap = (int)(Math.random()*3);
6534
-
6535
-// for (int s=swap; --s>=0;)
6536
-// {
6537
-// Vertex t = p;
6538
-// p = q;
6539
-// q = r;
6540
-// r = t;
6541
-// }
6542
- if (ymin > p.y)
6543
- {
6544
- ymin = p.y;
6545
- newp = p;
6546
-// break;
6547
- }
6548
- if (ymin > q.y)
6549
- {
6550
- ymin = q.y;
6551
- newp = q;
6552
-// break;
6553
- }
6554
- if (ymin > r.y)
6555
- {
6556
- ymin = r.y;
6557
- newp = r;
6558
-// break;
6559
- }
6560
- }
6561
-
6562
- CameraPane.selectedpoint.toParent[3][0] = newp.x;
6563
- CameraPane.selectedpoint.toParent[3][1] = newp.y;
6564
- CameraPane.selectedpoint.toParent[3][2] = newp.z;
6565
-
6566
- drawingstarted = false;
6567
-
6568
- // return;
6569
- }
6570
-
6571
- if (false) // CameraPane.DRAW
6572
- {
6573
- p0.AO = colorV[0] = 2;
6574
- colorV[1] = 2;
6575
- colorV[2] = 2;
6576
- }
6577
-
6578
- CameraPane.pointflow.add(p0);
6579
- CameraPane.pointflow.Touch();
6580
- }
6581
-
6582
-// gl.glColor3f(colorV[0], colorV[1], colorV[2]);
6583
-// gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0);
6584
-// gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
6585
- }
6586
-
65877018 void Print(Vertex v)
65887019 {
65897020 //System.err.println("(" + v.x + ", " + v.y + ", " + v.z + ")");
65907021 }
65917022
6592
- void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean selectmode)
6593
- {
6594
- if (!selectmode)
6595
- {
6596
- gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
6597
- gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
6598
-
6599
- if (flipV)
6600
- gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
6601
- else
6602
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6603
- }
6604
-
6605
- gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
6606
- }
6607
-
6608
- void drawFace(Vertex pv, Vertex qv, Vertex rv,
6609
- CameraPane display, Face face)
6610
- {
6611
- if (pv.y == -10000 ||
6612
- qv.y == -10000 ||
6613
- rv.y == -10000)
6614
- return;
6615
-
6616
-// float b = f.nbiterations & 1;
6617
-// float g = (f.nbiterations>>1) & 1;
6618
-// float r = (f.nbiterations>>2) & 1;
6619
-//
6620
-// //if (f.weight == 10000)
6621
-// //{
6622
-// // r = 1; g = b = 0;
6623
-// //}
6624
-// //else
6625
-// //{
6626
-// // assert(f.weight < 10000);
6627
-// r = g = b = (float)bRep.FaceWeight(f)*100;
6628
-// if (r<0)
6629
-// assert(r>=0);
6630
-// //}
6631
-
6632
- javax.media.opengl.GL gl = display.GetGL();
6633
-
6634
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
6635
-
6636
- //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv);
6637
- if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
6638
- {
6639
- //gl.glBegin(gl.GL_TRIANGLES);
6640
- boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
6641
- if (!hasnorm)
6642
- {
6643
- // System.out.println("FUCK!!");
6644
- LA.vecSub(pv/*.pos*/, qv/*.pos*/, v0);
6645
- LA.vecSub(pv/*.pos*/, rv/*.pos*/, v1);
6646
- LA.vecCross(v0, v1, v2);
6647
- LA.vecNormalize(v2);
6648
- gl.glNormal3f((float) v2.x, (float) v2.y, (float) v2.z);
6649
- }
6650
-
6651
- if (hasnorm)
6652
- {
6653
-// if (!pv.norm.normalized())
6654
-// assert(pv.norm.normalized());
6655
-
6656
- //System.out.println("normalp = " + pv.norm.x + ", " + pv.norm.y + ", " + pv.norm.z);
6657
- gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
6658
- }
6659
- gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
6660
- SetColor(display, pv);
6661
- //gl.glColor4f(r, g, b, 1);
6662
- //gl.glColor4f(pv.boundary, pv.boundary, pv.boundary, 1);
6663
- if (flipV)
6664
- gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
6665
- else
6666
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6667
- //System.out.println("vertexp = " + pv.x + ", " + pv.y + ", " + pv.z);
6668
- gl.glVertex3f((float) pv./*pos.*/x, (float) pv./*pos.*/y, (float) pv./*pos.*/z);
6669
-// Print(pv);
6670
- if (hasnorm)
6671
- {
6672
-// assert(qv.norm.normalized());
6673
- //System.out.println("normalq = " + qv.norm.x + ", " + qv.norm.y + ", " + qv.norm.z);
6674
- gl.glNormal3f((float) qv.norm.x, (float) qv.norm.y, (float) qv.norm.z);
6675
- }
6676
- //System.out.println("vertexq = " + qv.s + ", " + qv.t);
6677
- // boolean locked = false;
6678
- // float eps = 0.1f;
6679
- // boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
6680
-
6681
- // int dot = 0; //*/ (int)f.dot;
6682
-
6683
- // if ((dot&1) == 0)
6684
- // dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
6685
-
6686
- // if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
6687
- if (flipV)
6688
- gl.glTexCoord2f((float) qv.s, 1-(float) qv.t);
6689
- else
6690
- gl.glTexCoord2f((float) qv.s, (float) qv.t);
6691
- // else
6692
- // {
6693
- // locked = true;
6694
- // gl.glTexCoord2f((float) pv.s, (float) pv.t);
6695
- // }
6696
- gl.glColor4f(qv.AO, qv.AO, qv.AO, 1);
6697
- SetColor(display, qv);
6698
- //gl.glColor4f(r, g, b, 1);
6699
- //gl.glColor4f(qv.boundary, qv.boundary, qv.boundary, 1);
6700
- //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6701
- gl.glVertex3f((float) qv./*pos.*/x, (float) qv./*pos.*/y, (float) qv./*pos.*/z);
6702
-// Print(qv);
6703
- if (hasnorm)
6704
- {
6705
-// assert(rv.norm.normalized());
6706
- //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6707
- gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
6708
- }
6709
-
6710
- // if ((dot&4) == 0)
6711
- // dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
6712
-
6713
- // if (wrap || !locked && (dot&8) != 0)
6714
- if (flipV)
6715
- gl.glTexCoord2f((float) rv.s, 1-(float) rv.t);
6716
- else
6717
- gl.glTexCoord2f((float) rv.s, (float) rv.t);
6718
- // else
6719
- // gl.glTexCoord2f((float) pv.s, (float) pv.t);
6720
-
6721
- // f.dot = dot;
6722
-
6723
- gl.glColor4f(rv.AO, rv.AO, rv.AO, 1);
6724
- SetColor(display, rv);
6725
- //gl.glColor4f(r, g, b, 1);
6726
- //gl.glColor4f(rv.boundary, rv.boundary, rv.boundary, 1);
6727
- //System.out.println("vertexr = " + rv.x + ", " + rv.y + ", " + rv.z);
6728
- gl.glVertex3f((float) rv./*pos.*/x, (float) rv./*pos.*/y, (float) rv./*pos.*/z);
6729
-// Print(rv);
6730
- //gl.glEnd();
6731
- }
6732
- else
6733
- {
6734
- gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
6735
- gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
6736
- gl.glVertex3f((float) rv.x, (float) rv.y, (float) rv.z);
6737
-
6738
- }
6739
-
6740
- if (false) // (attributes & WIREFRAME) != 0)
6741
- {
6742
- gl.glDisable(gl.GL_LIGHTING);
6743
-
6744
- gl.glBegin(gl.GL_LINE_LOOP);
6745
- gl.glVertex3d(pv./*pos.*/x, pv./*pos.*/y, pv./*pos.*/z);
6746
- gl.glVertex3d(qv./*pos.*/x, qv./*pos.*/y, qv./*pos.*/z);
6747
- gl.glVertex3d(rv./*pos.*/x, rv./*pos.*/y, rv./*pos.*/z);
6748
- gl.glEnd();
6749
-
6750
- gl.glEnable(gl.GL_LIGHTING);
6751
- }
6752
- }
6753
-
67547023 void drawSelf(ClickInfo info, int level, boolean select)
67557024 {
67567025 if (bRep == null)
....@@ -7274,20 +7543,23 @@
72747543 }
72757544 }
72767545
7277
- 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)
72787550 {
7279
- int hc = info.bounds.x + info.bounds.width / 2;
7280
- int vc = info.bounds.y + info.bounds.height / 2;
7281
- double[][] toscreen = info.toScreen;
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;
72827554 if (toscreen == null)
72837555 {
7284
- toscreen = new Camera(info.camera.viewCode).toScreen;
7556
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
72857557 }
72867558 cVector vec = in;
72877559 LA.xformPos(in, toscreen, in);
72887560 //System.out.println("Distance = " + info.camera.Distance());
7289
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
7290
- vec.y *= 100 * info.camera.SCALE / info.camera.Distance();
7561
+ vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
7562
+ vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
72917563 outPt.x = hc + (int) vec.x;
72927564 outPt.y = vc - (int) vec.y;
72937565 outRec.x = outPt.x - 3;
....@@ -7295,15 +7567,18 @@
72957567 outRec.width = outRec.height = 6;
72967568 }
72977569
7298
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7570
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7571
+ )
72997572 {
73007573 Point pt = new Point(0, 0);
73017574 Rectangle rec = new Rectangle();
7302
- calcHotSpot(in, info, pt, rec);
7575
+ calcHotSpot(in, //clickInfo,
7576
+ pt, rec);
73037577 return rec;
73047578 }
73057579
7306
- void drawEditHandles0(ClickInfo info, int level)
7580
+ void drawEditHandles0(//ClickInfo clickInfo,
7581
+ int level)
73077582 {
73087583 if (level == 0)
73097584 {
....@@ -7312,98 +7587,104 @@
73127587 {
73137588 cVector origin = new cVector();
73147589 //LA.xformPos(origin, toParent, origin);
7315
- Rectangle spot = calcHotSpot(origin, info);
7590
+ if (this.clickInfo == null)
7591
+ this.clickInfo = new ClickInfo();
7592
+
7593
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
73167594 Rectangle boundary = new Rectangle();
73177595 boundary.x = spot.x - 30;
73187596 boundary.y = spot.y - 30;
73197597 boundary.width = spot.width + 60;
73207598 boundary.height = spot.height + 60;
7321
- info.g.setColor(Color.red);
7599
+ clickInfo.g.setColor(Color.white);
73227600 int spotw = spot.x + spot.width;
73237601 int spoth = spot.y + spot.height;
7324
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7325
- if (CameraPane.Xmin > spot.x)
7326
- {
7327
- CameraPane.Xmin = spot.x;
7328
- }
7329
- if (CameraPane.Xmax < spotw)
7330
- {
7331
- CameraPane.Xmax = spotw;
7332
- }
7333
- if (CameraPane.Ymin > spot.y)
7334
- {
7335
- CameraPane.Ymin = spot.y;
7336
- }
7337
- if (CameraPane.Ymax < spoth)
7338
- {
7339
- CameraPane.Ymax = spoth;
7340
- }
7341
- spot.translate(32, 32);
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);
73427642 spotw = spot.x + spot.width;
73437643 spoth = spot.y + spot.height;
7344
- info.g.setColor(Color.blue);
7345
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7346
- if (CameraPane.Xmin > spot.x)
7347
- {
7348
- CameraPane.Xmin = spot.x;
7349
- }
7350
- if (CameraPane.Xmax < spotw)
7351
- {
7352
- CameraPane.Xmax = spotw;
7353
- }
7354
- if (CameraPane.Ymin > spot.y)
7355
- {
7356
- CameraPane.Ymin = spot.y;
7357
- }
7358
- if (CameraPane.Ymax < spoth)
7359
- {
7360
- CameraPane.Ymax = spoth;
7361
- }
7362
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7363
- info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7364
- spot.translate(0, -32);
7365
- info.g.setColor(Color.green);
7366
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7367
- if (CameraPane.Xmin > spot.x)
7368
- {
7369
- CameraPane.Xmin = spot.x;
7370
- }
7371
- if (CameraPane.Xmax < spotw)
7372
- {
7373
- CameraPane.Xmax = spotw;
7374
- }
7375
- if (CameraPane.Ymin > spot.y)
7376
- {
7377
- CameraPane.Ymin = spot.y;
7378
- }
7379
- if (CameraPane.Ymax < spoth)
7380
- {
7381
- CameraPane.Ymax = spoth;
7382
- }
7383
- info.g.drawArc(boundary.x, boundary.y,
7384
- boundary.width, boundary.height, 0, 360);
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);
73857665 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
7386
- if (CameraPane.Xmin > boundary.x)
7387
- {
7388
- CameraPane.Xmin = boundary.x;
7389
- }
7390
- if (CameraPane.Xmax < boundary.x + boundary.width)
7391
- {
7392
- CameraPane.Xmax = boundary.x + boundary.width;
7393
- }
7394
- if (CameraPane.Ymin > boundary.y)
7395
- {
7396
- CameraPane.Ymin = boundary.y;
7397
- }
7398
- if (CameraPane.Ymax < boundary.y + boundary.height)
7399
- {
7400
- CameraPane.Ymax = boundary.y + boundary.height;
7401
- }
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
+// }
74027682 return;
74037683 }
74047684 }
74057685
7406
- boolean doEditClick0(ClickInfo info, int level)
7686
+ boolean doEditClick0(//ClickInfo clickInfo,
7687
+ int level)
74077688 {
74087689 if (level == 0)
74097690 {
....@@ -7412,10 +7693,10 @@
74127693
74137694 boolean retval = false;
74147695
7415
- startX = info.x;
7416
- startY = info.y;
7696
+ startX = clickInfo.x;
7697
+ startY = clickInfo.y;
74177698
7418
- hitSomething = 0;
7699
+ hitSomething = -1;
74197700 cVector origin = new cVector();
74207701 //LA.xformPos(origin, toParent, origin);
74217702 Rectangle spot = new Rectangle();
....@@ -7423,22 +7704,53 @@
74237704 {
74247705 centerPt = new Point(0, 0);
74257706 }
7426
- calcHotSpot(origin, info, centerPt, spot);
7427
- if (spot.contains(info.x, info.y))
7707
+ calcHotSpot(origin, //info,
7708
+ centerPt, spot);
7709
+ if (spot.contains(clickInfo.x, clickInfo.y))
74287710 {
74297711 hitSomething = hitCenter;
74307712 retval = true;
74317713 }
74327714 spot.translate(32, 0);
7433
- if (spot.contains(info.x, info.y))
7715
+ if (spot.contains(clickInfo.x, clickInfo.y))
74347716 {
74357717 hitSomething = hitRotate;
74367718 retval = true;
74377719 }
74387720 spot.translate(0, 32);
7439
- 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))
74407724 {
74417725 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
+
74427754 retval = true;
74437755 }
74447756
....@@ -7448,7 +7760,7 @@
74487760 }
74497761
74507762 //System.out.println("info.modifiers = " + info.modifiers);
7451
- modified = (info.modifiers & CameraPane.META) != 0;
7763
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
74527764 //System.out.println("modified = " + modified);
74537765 //new Exception().printStackTrace();
74547766 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7476,7 +7788,8 @@
74767788 return true;
74777789 }
74787790
7479
- void doEditDrag0(ClickInfo info)
7791
+ void doEditDrag0(//ClickInfo info,
7792
+ boolean opposite)
74807793 {
74817794 if (hitSomething == 0)
74827795 {
....@@ -7490,7 +7803,8 @@
74907803
74917804 //System.out.println("hitSomething = " + hitSomething);
74927805
7493
- double scale = 0.005f * info.camera.Distance();
7806
+ double scale = 0.005f * clickInfo.camera.Distance();
7807
+
74947808 cVector xlate = new cVector();
74957809 //cVector xlate2 = new cVector();
74967810 switch (hitSomething)
....@@ -7501,9 +7815,11 @@
75017815
75027816 case hitCenter: // Translate
75037817
7504
- scale *= 0.05f * info.pane.theRenderer.renderCamera.Distance();
7818
+ scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
75057819
7506
- if (modified)
7820
+ // Modified could snap
7821
+ if (//modified ||
7822
+ opposite)
75077823 {
75087824 //assert(false);
75097825 /*
....@@ -7523,8 +7839,8 @@
75237839 toParent[3][i] = xlate.get(i);
75247840 LA.matInvert(toParent, fromParent);
75257841 */
7526
- cVector delta = LA.newVector(0, 0, startY - info.y);
7527
- 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);
75287844
75297845 LA.matCopy(startMat, toParent);
75307846 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7533,7 +7849,7 @@
75337849 } else
75347850 {
75357851 //LA.xformDir(delta, info.camera.fromScreen, delta);
7536
- cVector up = new cVector(info.camera.up);
7852
+ cVector up = new cVector(clickInfo.camera.up);
75377853 cVector away = new cVector();
75387854 //cVector right2 = new cVector();
75397855 //LA.vecCross(up, cVector.Z, right);
....@@ -7549,20 +7865,20 @@
75497865 }
75507866 LA.xformDir(up, ClickInfo.matbuffer, up);
75517867 // if (!CameraPane.LOCALTRANSFORM)
7552
- LA.xformDir(up, info.pane.theRenderer.renderCamera.toScreen, up);
7553
- 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);
75547870 // if (!CameraPane.LOCALTRANSFORM)
7555
- LA.xformDir(away, info.pane.theRenderer.renderCamera.toScreen, away);
7871
+ LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
75567872 //LA.vecCross(up, cVector.Z, right2);
75577873
7558
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7874
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
75597875
75607876 //System.out.println("DELTA0 = " + delta);
75617877 //System.out.println("AWAY = " + info.camera.away);
75627878 //System.out.println("UP = " + info.camera.up);
75637879 if (away.z > 0)
75647880 {
7565
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7881
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
75667882 {
75677883 delta.x = -delta.x;
75687884 } else
....@@ -7577,7 +7893,7 @@
75777893 //System.out.println("DELTA1 = " + delta);
75787894 LA.xformDir(delta, ClickInfo.matbuffer, delta);
75797895 //System.out.println("DELTA2 = " + delta);
7580
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7896
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
75817897 LA.matCopy(startMat, toParent);
75827898 //System.out.println("DELTA3 = " + delta);
75837899 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7587,8 +7903,8 @@
75877903 break;
75887904
75897905 case hitRotate: // rotate
7590
- int dx = info.x - centerPt.x;
7591
- int dy = -(info.y - centerPt.y);
7906
+ int dx = clickInfo.x - centerPt.x;
7907
+ int dy = -(clickInfo.y - centerPt.y);
75927908 double angle = (double) Math.atan2(dx, dy);
75937909 angle = -(1.570796 - angle);
75947910
....@@ -7597,6 +7913,7 @@
75977913
75987914 if (modified)
75997915 {
7916
+ // Rotate 45 degrees
76007917 angle /= (Math.PI / 4);
76017918 angle = Math.floor(angle + 0.5);
76027919 angle *= (Math.PI / 4);
....@@ -7610,7 +7927,7 @@
76107927 }
76117928 /**/
76127929
7613
- switch (info.pane.renderCamera.viewCode)
7930
+ switch (clickInfo.pane.RenderCamera().viewCode)
76147931 {
76157932 case 1: // '\001'
76167933 LA.matZRotate(toParent, angle);
....@@ -7637,26 +7954,30 @@
76377954 break;
76387955
76397956 case hitScale: // scale
7640
- 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);
76417964 if (hScale < 0.01)
76427965 {
7643
- hScale = 0.01;
7966
+ //hScale = 0.01;
76447967 }
7645
- hScale = Math.pow(hScale, scale * 50);
7646
- if (hScale < 0.01)
7968
+
7969
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
7970
+ sign = 1;
7971
+ if (vScale < 0)
76477972 {
7648
- hScale = 0.01;
7973
+ sign = -1;
76497974 }
7650
- double vScale = (double) (info.y - centerPt.y) / 32;
7975
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
76517976 if (vScale < 0.01)
76527977 {
7653
- vScale = 0.01;
7978
+ //vScale = 0.01;
76547979 }
7655
- vScale = Math.pow(vScale, scale * 50);
7656
- if (vScale < 0.01)
7657
- {
7658
- vScale = 0.01;
7659
- }
7980
+
76607981 LA.matCopy(startMat, toParent);
76617982 /**/
76627983 for (int i = 0; i < 3; i++)
....@@ -7666,39 +7987,56 @@
76667987 }
76677988 /**/
76687989
7669
- 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)
76707998 {
76717999 case 3: // '\001'
7672
- if (modified)
8000
+ if (modified || opposite)
76738001 {
8002
+ if (modified) // && opposite)
8003
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
8004
+ else
76748005 //LA.matScale(toParent, 1, hScale, vScale);
7675
- LA.matScale(toParent, vScale, 1, 1);
8006
+ LA.matScale(toParent, totalScale, 1, 1);
76768007 } // vScale, 1);
76778008 else
76788009 {
7679
- LA.matScale(toParent, vScale, vScale, vScale);
8010
+ // EXCEPTION!
8011
+ LA.matScale(toParent, 1, totalScale, totalScale);
76808012 } // vScale, 1);
76818013 break;
76828014
76838015 case 2: // '\002'
7684
- if (modified)
8016
+ if (modified || opposite)
76858017 {
7686
- //LA.matScale(toParent, hScale, 1, vScale);
7687
- 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);
76888023 } else
76898024 {
7690
- LA.matScale(toParent, vScale, 1, vScale);
8025
+ LA.matScale(toParent, totalScale, 1, totalScale);
76918026 }
76928027 break;
76938028
76948029 case 1: // '\003'
7695
- if (modified)
8030
+ if (modified || opposite)
76968031 {
7697
- //LA.matScale(toParent, hScale, vScale, 1);
7698
- 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);
76998037 } else
77008038 {
7701
- LA.matScale(toParent, vScale, vScale, 1);
8039
+ LA.matScale(toParent, totalScale, totalScale, 1);
77028040 }
77038041 break;
77048042 }
....@@ -7719,7 +8057,7 @@
77198057 if (parent == null)
77208058 {
77218059 System.out.println("NULL PARENT");
7722
- new Exception().printStackTrace();
8060
+ //new Exception().printStackTrace();
77238061 } else
77248062 {
77258063 if (parent instanceof BezierPatch)
....@@ -7732,11 +8070,18 @@
77328070 } // NEW ...
77338071
77348072
7735
- info.pane.repaint();
8073
+ clickInfo.pane.repaint();
77368074 }
77378075
8076
+ boolean overflow = false;
8077
+
77388078 void TransformToWorld(cVector out) // , cVector out)
77398079 {
8080
+ if (overflow)
8081
+ return;
8082
+
8083
+ overflow = true;
8084
+
77408085 // june 2013 ??? assert (in == out);
77418086 cVector in = out;
77428087 if (toParent != null && !(this instanceof Texture || this instanceof TextureNode))
....@@ -7753,6 +8098,8 @@
77538098 {
77548099 (parent!=null?parent:fileparent).TransformToWorld(out); //, out);
77558100 }
8101
+
8102
+ overflow = false;
77568103 }
77578104
77588105 void TransformToLocal(cVector out) //, cVector out)
....@@ -7822,14 +8169,22 @@
78228169 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
78238170 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
78248171 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
8172
+
8173
+ String objname;
8174
+
78258175 if (false) //parent != null)
78268176 {
7827
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
8177
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
78288178 } else
78298179 {
7830
- 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) ":"") */ "";
78318181 } // + super.toString();
78328182 //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()
78338188 }
78348189
78358190 public int hashCode()
....@@ -7885,6 +8240,7 @@
78858240 objectUI.closeUI();
78868241 if (editWindow != null)
78878242 {
8243
+ editWindow.ctrlPanel.FlushUI();
78888244 editWindow.refreshContents();
78898245 } // ? new
78908246 objectUI = null;
....@@ -7893,6 +8249,10 @@
78938249 {
78948250 editWindow = null;
78958251 } // ?
8252
+ }
8253
+ else
8254
+ {
8255
+ //editWindow.closeUI();
78968256 }
78978257 }
78988258
....@@ -7905,7 +8265,7 @@
79058265 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
79068266
79078267 Object3D /*Composite*/ parent;
7908
- Object3D /*Composite*/ fileparent;
8268
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
79098269
79108270 double[][] toParent; // dynamic matrix
79118271 double[][] fromParent;
....@@ -7995,19 +8355,22 @@
79958355 max = new cVector();
79968356 }
79978357
7998
- Object3D sourcenode = GetFileRoot();
7999
-
8000
- if (!sourcenode.name.contains("rclab"))
8358
+ if (false) // Can crawl!!
80018359 {
8002
- getBounds(min, max, true);
8360
+ Object3D sourcenode = GetFileRoot();
80038361
8004
- if (min.y != Double.POSITIVE_INFINITY && min.y > 2)
8362
+ if (sourcenode != null && !sourcenode.name.contains("rclab"))
80058363 {
8006
-// sourcenode.getBounds(min, max, true);
8007
- sourcenode.getBounds(v0, v1, true);
8008
-// sourcenode.toParent = sourcenode.toParent;
8009
-// get(0).toParent = get(0).toParent;
8010
-// sourcenode.GlobalTransform();
8364
+ getBounds(min, max, true);
8365
+
8366
+ if (min.y != Double.POSITIVE_INFINITY && min.y > 2)
8367
+ {
8368
+ // sourcenode.getBounds(min, max, true);
8369
+ sourcenode.getBounds(v0, v1, true);
8370
+ // sourcenode.toParent = sourcenode.toParent;
8371
+ // get(0).toParent = get(0).toParent;
8372
+ // sourcenode.GlobalTransform();
8373
+ }
80118374 }
80128375 }
80138376
....@@ -8016,7 +8379,8 @@
80168379 if (support != null)
80178380 {
80188381 assert(bRep != null);
8019
- GraphreeD.Assert(support.bRep == bRep.support);
8382
+ if (!(support instanceof GenericJoint)) // support.bRep != null)
8383
+ Grafreed.Assert(support.bRep == bRep.support);
80208384 }
80218385 else
80228386 {
....@@ -8047,6 +8411,10 @@
80478411 }
80488412
80498413 transient ObjEditor editWindow;
8414
+ transient ObjEditor manipWindow;
8415
+
8416
+ transient boolean pinned;
8417
+
80508418 transient ObjectUI objectUI;
80518419 public static int povDepth = 0;
80528420 private static cVector tbMin = new cVector();
....@@ -8065,9 +8433,9 @@
80658433 private static cVector edge2 = new cVector();
80668434 //private static cVector norm = new cVector();
80678435 /*transient private*/ int hitSomething;
8068
- private static final int hitCenter = 1;
8069
- private static final int hitScale = 2;
8070
- private static final int hitRotate = 3;
8436
+ static final int hitCenter = 1;
8437
+ static final int hitScale = 2;
8438
+ static final int hitRotate = 3;
80718439 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
80728440 /*transient*/ private Point centerPt;
80738441 /*transient*/ private int startX;
....@@ -8099,6 +8467,8 @@
80998467 {
81008468 Object3D targ = this;
81018469
8470
+ targ.NORMALPUSH = obj.NORMALPUSH;
8471
+
81028472 if (obj.material != null)
81038473 {
81048474 if ((mask&MATERIAL)!=0) // ==(COLOR|MATERIAL))