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,14 +14,45 @@
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;
2342
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
+
2456 void InitOthers()
2557 {
2658 if (projectedVertices == null || projectedVertices.length <= 2)
....@@ -99,64 +131,245 @@
99131
100132 // transient boolean reduced; // for morph reduction
101133
102
-transient com.bulletphysics.linearmath.Transform cache; // for fast merge
103
-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
104136
105
-transient Object3D transientsupport; // for cloning
106
-transient boolean transientlink2master;
137
+ transient Object3D transientsupport; // for cloning
138
+ transient boolean transientlink2master;
107139
108
-void SaveSupports()
109
-{
110
- if (blockloop)
111
- return;
112
-
113
- transientsupport = support;
114
- transientlink2master = link2master;
115
-
116
- support = null;
117
- link2master = false;
118
-
119
- if (bRep != null)
140
+ void SaveSupports()
120141 {
121
- 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
+ }
122165 }
123
-
124
- for (int i = 0; i < Size(); i++)
166
+
167
+ void RestoreSupports()
125168 {
126
- Object3D child = (Object3D) get(i);
127
- if (child == null)
128
- 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
+
129300 blockloop = true;
130
- child.SaveSupports();
301
+
302
+ for (int i=0; i<Size(); i++)
303
+ {
304
+ get(i).TagObjects(o, tag);
305
+ }
306
+
131307 blockloop = false;
132308 }
133
-}
134309
135
-void RestoreSupports()
136
-{
137
- if (blockloop)
138
- return;
310
+ boolean HasTags()
311
+ {
312
+ if (blockloop)
313
+ return false;
139314
140
- support = transientsupport;
141
- link2master = transientlink2master;
142
- transientsupport = null;
143
- transientlink2master = false;
144
-
145
- if (bRep != null)
146
- {
147
- bRep.RestoreSupports();
148
- }
149
-
150
- for (int i = 0; i < Size(); i++)
151
- {
152
- Object3D child = (Object3D) get(i);
153
- if (child == null)
154
- continue;
155315 blockloop = true;
156
- 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
+
157353 blockloop = false;
158354 }
159
-}
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
+ }
160373
161374 // MOCAP SUPPORT
162375 double tx,ty,tz,rx,ry,rz;
....@@ -299,6 +512,8 @@
299512 }
300513
301514 boolean live = false;
515
+ transient boolean keepdontselect;
516
+ boolean dontselect = false;
302517 boolean hide = false;
303518 boolean link2master = false; // performs reset support/master at each frame
304519 boolean marked = false; // animation node
....@@ -366,11 +581,11 @@
366581 }
367582 }
368583
369
- int memorysize;
584
+ transient int memorysize; // needs to be transient, dunno why
370585
371586 int MemorySize()
372587 {
373
- if (true) // memorysize == 0)
588
+ if (memorysize == 0)
374589 {
375590 try
376591 {
....@@ -430,16 +645,16 @@
430645 {
431646 Object3D copy = this;
432647
433
- Camera parentcam = CameraPane.theRenderer.manipCamera;
648
+ Camera parentcam = Globals.theRenderer.ManipCamera();
434649
435
- if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[0])
650
+ if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[0])
436651 {
437
- parentcam = CameraPane.theRenderer.cameras[1];
652
+ parentcam = Globals.theRenderer.Cameras()[1];
438653 }
439654
440
- if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[1])
655
+ if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[1])
441656 {
442
- parentcam = CameraPane.theRenderer.cameras[0];
657
+ parentcam = Globals.theRenderer.Cameras()[0];
443658 }
444659
445660 if (this == parentcam)
....@@ -447,7 +662,7 @@
447662 //assert(this instanceof Camera);
448663
449664 for (int count = parentcam.GetTransformCount(); --count>=0;)
450
- LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.toParent, CameraPane.theRenderer.targetLookAt);
665
+ LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.toParent, Globals.theRenderer.TargetLookAt());
451666 }
452667
453668 copy.marked ^= true;
....@@ -467,7 +682,7 @@
467682 //assert(this instanceof Camera);
468683
469684 for (int count = parentcam.GetTransformCount(); --count>=0;)
470
- LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.fromParent, CameraPane.theRenderer.targetLookAt);
685
+ LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.fromParent, Globals.theRenderer.TargetLookAt());
471686 }
472687
473688 copy.Touch(); // display list issue
....@@ -480,12 +695,14 @@
480695 toParent = LA.newMatrix();
481696 fromParent = LA.newMatrix();
482697 }
698
+
483699 if (toParentMarked == null)
484700 {
485701 if (maxcount != 1)
486702 {
487
- new Exception().printStackTrace();
703
+ //new Exception().printStackTrace();
488704 }
705
+
489706 toParentMarked = LA.newMatrix();
490707 fromParentMarked = LA.newMatrix();
491708 }
....@@ -602,7 +819,7 @@
602819 return;
603820 }
604821
605
- if (CameraPane.fromscript)
822
+ if (Globals.fromscript)
606823 {
607824 transformcount = 0;
608825 return;
....@@ -760,7 +977,7 @@
760977
761978 int GetTransformCount()
762979 {
763
- // marde pour serialization de Texture
980
+ // patch pour serialization de Texture
764981 resetmaxcount();
765982 resettransformcount();
766983 resetstep();
....@@ -773,7 +990,7 @@
773990 if (step == 0)
774991 step = 1;
775992 if (maxcount == 0)
776
- maxcount = 2048; // 4;
993
+ maxcount = 128; // 2048; // 4;
777994 // if (acceleration == 0)
778995 // acceleration = 10;
779996 if (delay == 0) // serial
....@@ -794,12 +1011,12 @@
7941011 // factor = CameraPane.STEP;
7951012 // }
7961013
797
- if (marked && CameraPane.isLIVE() && live &&
1014
+ if (marked && Globals.isLIVE() && live &&
7981015 //TEMP21aug2018
799
- CameraPane.drawMode == CameraPane.SHADOW &&
800
- currentframe != CameraPane.framecount)
1016
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
1017
+ currentframe != Globals.framecount)
8011018 {
802
- currentframe = CameraPane.framecount;
1019
+ currentframe = Globals.framecount;
8031020
8041021 // System.err.println("transformcount = " + transformcount);
8051022 // System.err.println("factor = " + factor);
....@@ -808,7 +1025,8 @@
8081025
8091026 boolean changedir = random && Math.random() < 0.01; // && !link2master;
8101027
811
- if (transformcount*factor > maxcount || (step == 1 && changedir))
1028
+ if (transformcount*factor >= maxcount && (rewind || random) ||
1029
+ (step == 1 && changedir))
8121030 {
8131031 countdown = 1;
8141032 delay = speedup?8:1;
....@@ -880,6 +1098,10 @@
8801098 if (material == null || material.multiply)
8811099 return true;
8821100
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.
8831105 return material.opacity > 0.99;
8841106 }
8851107
....@@ -911,6 +1133,11 @@
9111133 fromParent = null; // LA.newMatrix();
9121134 bRep = null; // new BoundaryRep();
9131135
1136
+ if (oname != null && oname.equals("LeftHand"))
1137
+ {
1138
+ name = oname;
1139
+ }
1140
+
9141141 /*
9151142 float hue = (float)Math.random();
9161143 Color col;
....@@ -953,7 +1180,7 @@
9531180
9541181 public Object clone()
9551182 {
956
- return GrafreeD.clone(this);
1183
+ return Grafreed.clone(this);
9571184 }
9581185
9591186 Object3D copyExpand()
....@@ -1275,6 +1502,7 @@
12751502 toParent = LA.newMatrix();
12761503 fromParent = LA.newMatrix();
12771504 }
1505
+
12781506 LA.matCopy(other.toParent, toParent);
12791507 LA.matCopy(other.fromParent, fromParent);
12801508
....@@ -1469,7 +1697,7 @@
14691697 BoundaryRep.SEUIL = other.material.cameralight;
14701698
14711699 // Set default to 0.1
1472
- BoundaryRep.SEUIL /= 2;
1700
+ BoundaryRep.SEUIL /= 4; // 2;
14731701 System.out.println("SEUIL = " + BoundaryRep.SEUIL);
14741702 }
14751703
....@@ -1728,7 +1956,7 @@
17281956 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17291957 o.bRep = transientrep;
17301958 if (clone)
1731
- o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
1959
+ o.bRep = (BoundaryRep) Grafreed.clone(transientrep);
17321960 o.CreateMaterial();
17331961 o.SetAttributes(this, -1);
17341962 //parent
....@@ -1741,7 +1969,7 @@
17411969 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17421970 o.bRep = bRep;
17431971 if (clone)
1744
- o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
1972
+ o.bRep = (BoundaryRep) Grafreed.clone(bRep);
17451973 o.CreateMaterial();
17461974 //o.overwriteThis(this, -1);
17471975 o.SetAttributes(this, -1);
....@@ -1828,12 +2056,15 @@
18282056 if (obj.name == null)
18292057 continue; // can't be a null one
18302058
2059
+ // Try perfect match first.
18312060 if (n.equals(obj.name))
18322061 {
18332062 theobj = obj;
18342063 count++;
18352064 }
18362065 }
2066
+
2067
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18372068
18382069 if (count != 1)
18392070 for (int i=Size(); --i>=0;)
....@@ -2151,11 +2382,6 @@
21512382
21522383 InitOthers();
21532384
2154
- if (this instanceof Camera)
2155
- {
2156
- material.shift = 90;
2157
- }
2158
-
21592385 material.multiply = multiply;
21602386
21612387 if (multiply)
....@@ -2293,12 +2519,22 @@
22932519 }
22942520 */
22952521 }
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
+ }
22962531 }
22972532
22982533 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
22992534 {
23002535 if (newWindow)
23012536 {
2537
+ new Exception().printStackTrace();
23022538 System.exit(0);
23032539 if (parent != null)
23042540 {
....@@ -2333,6 +2569,14 @@
23332569 {
23342570 editWindow.refreshContents();
23352571 }
2572
+ else
2573
+ {
2574
+ if (manipWindow != null)
2575
+ {
2576
+ manipWindow.refreshContents();
2577
+ }
2578
+ }
2579
+
23362580 //if (parent != null)
23372581 //parent.refreshEditWindow();
23382582 }
....@@ -2412,7 +2656,8 @@
24122656 private static final int editSelf = 1;
24132657 private static final int editChild = 2;
24142658
2415
- void drawEditHandles(ClickInfo info, int level)
2659
+ void drawEditHandles(//ClickInfo info,
2660
+ int level)
24162661 {
24172662 if (level == 0)
24182663 {
....@@ -2420,7 +2665,8 @@
24202665 return;
24212666
24222667 Object3D selectee;
2423
- 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))
24242670 {
24252671 selectee = (Object3D) e.nextElement();
24262672 }
....@@ -2428,19 +2674,22 @@
24282674 } else
24292675 {
24302676 //super.
2431
- drawEditHandles0(info, level + 1);
2677
+ drawEditHandles0(//info,
2678
+ level + 1);
24322679 }
24332680 }
24342681
2435
- boolean doEditClick(ClickInfo info, int level)
2682
+ boolean doEditClick(//ClickInfo info,
2683
+ int level)
24362684 {
24372685 doSomething = 0;
24382686 if (level == 0)
24392687 {
2440
- return doParentClick(info);
2688
+ return doParentClick(); //info);
24412689 }
24422690 if (//super.
2443
- doEditClick0(info, level))
2691
+ doEditClick0(//info,
2692
+ level))
24442693 {
24452694 doSomething = 1;
24462695 return true;
....@@ -2450,7 +2699,7 @@
24502699 }
24512700 }
24522701
2453
- boolean doParentClick(ClickInfo info)
2702
+ boolean doParentClick() //ClickInfo info)
24542703 {
24552704 if (selection == null)
24562705 {
....@@ -2463,7 +2712,8 @@
24632712 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
24642713 {
24652714 Object3D selectee = (Object3D) e.nextElement();
2466
- if (selectee.doEditClick(info, 1))
2715
+ if (selectee.doEditClick(//info,
2716
+ 1))
24672717 {
24682718 childToDrag = selectee;
24692719 doSomething = 2;
....@@ -2475,13 +2725,15 @@
24752725 return retval;
24762726 }
24772727
2478
- void doEditDrag(ClickInfo info)
2728
+ void doEditDrag(//ClickInfo clickInfo,
2729
+ boolean opposite)
24792730 {
24802731 switch (doSomething)
24812732 {
24822733 case 1: // '\001'
24832734 //super.
2484
- doEditDrag0(info);
2735
+ doEditDrag0(//clickInfo,
2736
+ opposite);
24852737 break;
24862738
24872739 case 2: // '\002'
....@@ -2494,11 +2746,13 @@
24942746 {
24952747 //sel.hitSomething = childToDrag.hitSomething;
24962748 //childToDrag.doEditDrag(info);
2497
- sel.doEditDrag(info);
2749
+ sel.doEditDrag(//clickInfo,
2750
+ opposite);
24982751 } else
24992752 {
25002753 //super.
2501
- doEditDrag0(info);
2754
+ doEditDrag0(//clickInfo,
2755
+ opposite);
25022756 }
25032757 }
25042758 break;
....@@ -2516,6 +2770,9 @@
25162770 {
25172771 deselectAll();
25182772 }
2773
+
2774
+ new Exception().printStackTrace();
2775
+
25192776 ClickInfo newInfo = new ClickInfo();
25202777 newInfo.flags = info.flags;
25212778 newInfo.bounds = info.bounds;
....@@ -2608,6 +2865,18 @@
26082865 void GenNormalsS(boolean crease)
26092866 {
26102867 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();
26112880 // for (int i=0; i<selection.size(); i++)
26122881 // {
26132882 // Object3D selectee = (Object3D) selection.elementAt(i);
....@@ -2748,6 +3017,24 @@
27483017 if (child == null)
27493018 continue;
27503019 child.GenNormals(crease);
3020
+// Children().release(i);
3021
+ }
3022
+ blockloop = false;
3023
+ }
3024
+
3025
+ void GenNormalsMesh()
3026
+ {
3027
+ if (blockloop)
3028
+ return;
3029
+
3030
+ blockloop = true;
3031
+ GenNormalsMesh0();
3032
+ for (int i = 0; i < Children().Size(); i++)
3033
+ {
3034
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
3035
+ if (child == null)
3036
+ continue;
3037
+ child.GenNormalsMesh();
27513038 // Children().release(i);
27523039 }
27533040 blockloop = false;
....@@ -2905,7 +3192,8 @@
29053192 {
29063193 if (bRep != null)
29073194 {
2908
- bRep.GenUV();
3195
+ bRep.GenUV(); //1);
3196
+ //bRep.UnfoldUV();
29093197 Touch();
29103198 }
29113199 }
....@@ -2919,11 +3207,20 @@
29193207 }
29203208 }
29213209
3210
+ void GenNormalsMesh0()
3211
+ {
3212
+ if (bRep != null)
3213
+ {
3214
+ bRep.GenerateNormalsMesh();
3215
+ Touch();
3216
+ }
3217
+ }
3218
+
29223219 void GenNormalsMINE0()
29233220 {
29243221 if (bRep != null)
29253222 {
2926
- bRep.GenerateNormalsMINE();
3223
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
29273224 Touch();
29283225 }
29293226 }
....@@ -2980,6 +3277,120 @@
29803277 blockloop = false;
29813278 }
29823279
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
+
29833394 void TransformGeometry()
29843395 {
29853396 Object3D obj = this;
....@@ -3201,9 +3612,11 @@
32013612
32023613 BoundaryRep sup = bRep.support;
32033614 bRep.support = null;
3204
- BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
3615
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
32053616 // bRep.SplitInTwo(onlyone); // thread...
3206
- temprep.SplitInTwo(reduction34, onlyone);
3617
+
3618
+ while(temprep.SplitInTwo(reduction34, onlyone));
3619
+
32073620 bRep = temprep;
32083621 bRep.support = sup;
32093622 Touch();
....@@ -3304,15 +3717,47 @@
33043717
33053718 void ClearMaterials()
33063719 {
3720
+ if (blockloop)
3721
+ return;
3722
+
3723
+ blockloop = true;
3724
+
33073725 ClearMaterial();
3308
- for (int i = 0; i < size(); i++)
3726
+ for (int i = 0; i < Size(); i++)
33093727 {
3310
- Object3D child = (Object3D) reserve(i);
3728
+ Object3D child = (Object3D) get(i);
33113729 if (child == null)
33123730 continue;
33133731 child.ClearMaterials();
3314
- release(i);
33153732 }
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;
33163761 }
33173762
33183763 void FlipV(boolean flip)
....@@ -3340,7 +3785,8 @@
33403785 if (blockloop)
33413786 return;
33423787
3343
- if (marked || (bRep != null && material != null)) // borderline...
3788
+ if (//marked || // does not make sense
3789
+ (bRep != null || material != null)) // borderline...
33443790 live = h;
33453791
33463792 for (int i = 0; i < Size(); i++)
....@@ -3361,7 +3807,8 @@
33613807 return;
33623808
33633809 //if (bRep != null)
3364
- if (marked || (bRep != null && material != null)) // borderline...
3810
+ if (//marked || // does not make sense
3811
+ (bRep != null || material != null)) // borderline...
33653812 link2master = h;
33663813
33673814 for (int i = 0; i < Size(); i++)
....@@ -3381,7 +3828,8 @@
33813828 if (blockloop)
33823829 return;
33833830
3384
- if (marked || (bRep != null && material != null)) // borderline...
3831
+ if (//marked || // does not make sense
3832
+ (bRep != null || material != null)) // borderline...
33853833 hide = h;
33863834
33873835 for (int i = 0; i < Size(); i++)
....@@ -3401,7 +3849,7 @@
34013849 if (blockloop)
34023850 return;
34033851
3404
- if (bRep != null && material != null) // borderline...
3852
+ if (bRep != null || material != null) // borderline...
34053853 marked = h;
34063854
34073855 for (int i = 0; i < Size(); i++)
....@@ -3411,6 +3859,46 @@
34113859 continue;
34123860 blockloop = true;
34133861 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);
34143902 blockloop = false;
34153903 // release(i);
34163904 }
....@@ -3725,7 +4213,7 @@
37254213 if (child == null)
37264214 continue;
37274215
3728
- if (GrafreeD.RENDERME > 0)
4216
+ if (Grafreed.RENDERME > 0)
37294217 {
37304218 if (child instanceof Merge)
37314219 ((Merge)child).renderme();
....@@ -3876,7 +4364,7 @@
38764364 if (child == null)
38774365 continue;
38784366
3879
- if (GrafreeD.RENDERME > 0)
4367
+ if (Grafreed.RENDERME > 0)
38804368 {
38814369 if (child instanceof Merge)
38824370 ((Merge)child).renderme();
....@@ -4071,7 +4559,7 @@
40714559 if (child == null)
40724560 continue;
40734561
4074
- if (GrafreeD.RENDERME > 0)
4562
+ if (Grafreed.RENDERME > 0)
40754563 {
40764564 if (child instanceof Merge)
40774565 ((Merge)child).renderme();
....@@ -4184,6 +4672,55 @@
41844672 {
41854673 blockloop = true;
41864674 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();
41874724 blockloop = false;
41884725 }
41894726 }
....@@ -4678,7 +5215,7 @@
46785215
46795216 cTreePath SelectLeaf(int indexcount, boolean deselect)
46805217 {
4681
- if (hide)
5218
+ if (hide || dontselect)
46825219 return null;
46835220
46845221 if (count <= 0)
....@@ -4702,9 +5239,17 @@
47025239 }
47035240 }
47045241
5242
+ ObjEditor GetWindow()
5243
+ {
5244
+ if (editWindow != null)
5245
+ return editWindow;
5246
+
5247
+ return manipWindow;
5248
+ }
5249
+
47055250 cTreePath Select(int indexcount, boolean deselect)
47065251 {
4707
- if (hide)
5252
+ if (hide || dontselect)
47085253 return null;
47095254
47105255 if (count <= 0)
....@@ -4738,10 +5283,11 @@
47385283 if (leaf != null)
47395284 {
47405285 cTreePath tp = new cTreePath(this, leaf);
4741
- if (editWindow != null)
5286
+ ObjEditor window = GetWindow();
5287
+ if (window != null)
47425288 {
47435289 //System.out.println("editWindow = " + editWindow + " vs " + this);
4744
- editWindow.Select(tp, deselect, true);
5290
+ window.Select(tp, deselect, true);
47455291 }
47465292
47475293 return tp;
....@@ -4758,6 +5304,7 @@
47585304
47595305 if (child == null)
47605306 continue;
5307
+
47615308 if (child.HasTransparency() && child.size() != 0)
47625309 {
47635310 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4767,9 +5314,10 @@
47675314 if (leaf != null)
47685315 {
47695316 cTreePath tp = new cTreePath(this, leaf);
4770
- if (editWindow != null)
5317
+ ObjEditor window = GetWindow();
5318
+ if (window != null)
47715319 {
4772
- editWindow.Select(tp, deselect, true);
5320
+ window.Select(tp, deselect, true);
47735321 }
47745322
47755323 return tp;
....@@ -4854,7 +5402,7 @@
48545402 return globalTransform;
48555403 }
48565404
4857
- void PreprocessOcclusion(CameraPane cp)
5405
+ void PreprocessOcclusion(iCameraPane cp)
48585406 {
48595407 /*
48605408 if (AOdone)
....@@ -5001,7 +5549,8 @@
50015549 } else //
50025550 if (editWindow != null)
50035551 {
5004
- editWindow.cameraView.lighttouched = true;
5552
+ //editWindow.cameraView.lighttouched = true;
5553
+ Globals.lighttouched = true;
50055554 }
50065555 }
50075556
....@@ -5093,6 +5642,51 @@
50935642 blockloop = false;
50945643 }
50955644
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
+
50965690 boolean IsSelected()
50975691 {
50985692 if (parent == null)
....@@ -5153,12 +5747,41 @@
51535747 if (fullname == null)
51545748 return "";
51555749
5750
+ if (fullname.pigment != null)
5751
+ {
5752
+ return fullname.pigment;
5753
+ }
5754
+
51565755 // System.out.println("Fullname = " + fullname);
51575756
5158
- if (fullname.name.indexOf(":") == -1)
5159
- 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(":"));
51605762
5161
- 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];
51625785 }
51635786
51645787 static String GetBump(cTexture fullname)
....@@ -5166,11 +5789,44 @@
51665789 if (fullname == null)
51675790 return "";
51685791
5792
+ if (fullname.bump != null)
5793
+ {
5794
+ return fullname.bump;
5795
+ }
5796
+
51695797 // System.out.println("Fullname = " + fullname);
5170
- if (fullname.name.indexOf(":") == -1)
5171
- return "";
5172
-
5173
- 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];
51745830 }
51755831
51765832 String GetPigmentTexture()
....@@ -5244,7 +5900,7 @@
52445900 System.out.print("; textures = " + textures);
52455901 System.out.println("; usedtextures = " + usedtextures);
52465902
5247
- if (GetTextures() == null)
5903
+ if (GetTextures() == null) // What is that??
52485904 GetTextures().name = ":";
52495905
52505906 String texname = tex;
....@@ -5253,6 +5909,9 @@
52535909 texname = "";
52545910
52555911 GetTextures().name = texname + ":" + GetBump(GetTextures());
5912
+
5913
+ GetTextures().pigment = null;
5914
+
52565915 Touch();
52575916 }
52585917
....@@ -5277,6 +5936,43 @@
52775936 }
52785937 }
52795938
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
+
52805976 void SetBumpTexture(String tex)
52815977 {
52825978 if (GetTextures() == null)
....@@ -5288,6 +5984,8 @@
52885984 texname = "";
52895985
52905986 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
5987
+
5988
+ GetTextures().bump = null;
52915989
52925990 Touch();
52935991 }
....@@ -5313,25 +6011,70 @@
53136011 }
53146012 }
53156013
5316
- 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)
53176047 {
53186048 Draw(display, root, selected, blocked);
53196049 }
53206050
5321
- static cMaterial[] materialstack = new cMaterial[65536];
5322
- static boolean[] selectedstack = new boolean[65536];
5323
- static int materialdepth = 0;
5324
-
53256051 boolean NeedSupport()
53266052 {
53276053 return
5328
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
6054
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
53296055 // PROBLEM with CROWD!!
5330
- && (CameraPane.drawMode == CameraPane.SHADOW || CameraPane.CROWD);
6056
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
53316057 }
53326058
6059
+ static boolean DEBUG_SELECTION = false;
53336060
5334
- 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)
53356078 {
53366079 Invariants(); // june 2013
53376080
....@@ -5340,8 +6083,8 @@
53406083 // System.err.println("Draw " + this + " Frame # " + ((Mocap)((Merge)support).object).frame);
53416084 }
53426085
5343
- if (display.drawMode == CameraPane.SELECTION &&
5344
- hide)
6086
+ if (display.DrawMode() == iCameraPane.SELECTION &&
6087
+ (hide || dontselect))
53456088 return;
53466089
53476090 if (name != null && name.contains("sclera"))
....@@ -5359,7 +6102,7 @@
53596102 if (this instanceof Checker)
53606103 return;
53616104
5362
- if (display.drawMode == display.SHADOW && PASSTEST)
6105
+ if (display.DrawMode() == display.SHADOW && PASSTEST)
53636106 return;
53646107
53656108 if (count <= 0)
....@@ -5367,13 +6110,13 @@
53676110 return;
53686111 }
53696112
5370
- if ((//display.drawMode == CameraPane.SHADOW ||
5371
- display.drawMode == CameraPane.SELECTION || CameraPane.DEBUG_SELECTION) && HasTransparency())
6113
+ if ((//display.DrawMode() == CameraPane.SHADOW ||
6114
+ display.DrawMode() == iCameraPane.SELECTION || display.IsDebugSelection()) && HasTransparency())
53726115 {
53736116 return;
53746117 }
53756118
5376
- javax.media.opengl.GL gl = display.GetGL();
6119
+ //javax.media.opengl.GL gl = display.GetGL();
53776120
53786121 /*
53796122 if (touched)
....@@ -5391,8 +6134,11 @@
53916134 if (support != null)
53926135 support = support;
53936136
5394
- //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5395
- 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.
53966142
53976143 if (!usecalllists && bRep != null && bRep.displaylist > 0)
53986144 {
....@@ -5402,30 +6148,33 @@
54026148 // usecalllists &= !(parent instanceof RandomNode);
54036149 // usecalllists = false;
54046150
5405
- if (GetBRep() != null)
5406
- usecalllists = usecalllists;
6151
+ if (display.DrawMode() == display.SHADOW)
6152
+ //GetBRep() != null)
6153
+ usecalllists = !!usecalllists;
54076154 //System.out.println("draw " + this);
54086155 //new Exception().printStackTrace();
54096156
54106157 boolean compiled = false;
54116158
5412
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
6159
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
54136160
5414
- if (!selectmode && //display.drawMode != display.SELECTION &&
5415
- (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)))
54166164 {
5417
- display.lighttouched = true;
6165
+ Globals.lighttouched = true;
54186166 } // all panes...
5419
- //if (usecalllists && display.drawMode != display.SELECTION && display.drawMode != display.SHADOW &&
5420
- 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 &&
54216170 (touched || (bRep != null && bRep.displaylist <= 0)))
54226171 {
54236172 if (!(this instanceof Composite))
54246173 touched = false;
54256174 //if (displaylist == -1 && usecalllists)
5426
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
6175
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
54276176 {
5428
- bRep.displaylist = gl.glGenLists(1);
6177
+ bRep.displaylist = display.GenList();
54296178 assert(bRep.displaylist != 0);
54306179 // System.err.println("glGenLists: " + bRep.displaylist + " for " + this);
54316180 //System.out.println("\tgen list " + list);
....@@ -5434,21 +6183,23 @@
54346183
54356184 //System.out.println("\tnew list " + list);
54366185 //gl.glDrawBuffer(gl.GL_NONE);
5437
- if (usecalllists)
6186
+ if (usecalllists && bRep.displaylist > 0)
54386187 {
54396188 // System.err.println("new list " + bRep.displaylist + " for " + this);
5440
- gl.glNewList(bRep.displaylist, gl.GL_COMPILE); //_AND_EXECUTE);
6189
+ display.NewList(bRep.displaylist);
54416190 }
6191
+
54426192 CallList(display, root, selected, blocked);
6193
+
54436194 // compiled = true;
5444
- if (usecalllists)
6195
+ if (usecalllists && bRep.displaylist > 0)
54456196 {
54466197 // System.err.println("end list " + bRep.displaylist + " for " + this);
5447
- gl.glEndList();
6198
+ display.EndList();
54486199 }
54496200 //gl.glDrawBuffer(gl.GL_BACK);
54506201 // XXX touched = false;
5451
- display.lighttouched = true; // all panes...
6202
+ Globals.lighttouched = true; // all panes...
54526203 }
54536204
54546205 touched = GetBRep() == null; // this instanceof Composite || this instanceof FileObject; // false;
....@@ -5487,12 +6238,12 @@
54876238
54886239 // frustum culling
54896240 if (CameraPane.FRUSTUM && !blocked && !IsInfinite() && GetBRep() != null // && GetBRep().VertexCount() != 1260 // default grid
5490
- && display.drawMode != CameraPane.SELECTION)
6241
+ && display.DrawMode() != iCameraPane.SELECTION)
54916242 {
5492
- if (display.drawMode == CameraPane.SHADOW)
6243
+ if (display.DrawMode() == iCameraPane.SHADOW)
54936244 {
54946245 if (!link2master // tricky to cull in shadow mode.
5495
- && GetBRep().FrustumCull(this, gl, display.lightCamera, true))
6246
+ && GetBRep().FrustumCull(this, null, display.LightCamera(), true))
54966247 {
54976248 //System.out.print("CULLED");
54986249 culled = true;
....@@ -5500,7 +6251,7 @@
55006251 }
55016252 else
55026253 //GetBRep().getBounds(v0, v1, this);
5503
- if (GetBRep().FrustumCull(this, gl, display.renderCamera, false))
6254
+ if (GetBRep().FrustumCull(this, null, display.RenderCamera(), false))
55046255 culled = true;
55056256
55066257 // LA.xformPos(v0, display.renderCamera.toScreen, v0);
....@@ -5536,11 +6287,12 @@
55366287
55376288
55386289 if (!culled)
5539
- if (display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION)
6290
+ if (display.DrawMode() == display.SELECTION || display.IsDebugSelection())
55406291 {
55416292 if (GetBRep() != null)
55426293 {
5543
- CameraPane.NextIndex(this, gl);
6294
+ display.NextIndex();
6295
+
55446296 // vertex color conflict : gl.glCallList(list);
55456297 DrawNode(display, root, selected);
55466298 if (this instanceof BezierPatch)
....@@ -5562,55 +6314,7 @@
55626314 color[2] /= 2;
55636315 gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT_AND_DIFFUSE, color, 0);
55646316 */
5565
- if (material != null)
5566
- {
5567
- materialstack[materialdepth] = material;
5568
- selectedstack[materialdepth] = selected;
5569
- cStatic.objectstack[materialdepth++] = this;
5570
- //System.out.println("material " + material);
5571
- //Applet3D.tracein(this, selected);
5572
- display.vector2buffer = projectedVertices;
5573
- if (this instanceof Camera)
5574
- {
5575
- display.options1[0] = material.shift;
5576
- //System.out.println("shift " + material.shift);
5577
- display.options1[1] = material.lightarea;
5578
- display.options1[2] = material.shadowbias;
5579
- display.options1[3] = material.aniso;
5580
- display.options1[4] = material.anisoV;
5581
- display.options2[0] = material.opacity;
5582
- display.options2[1] = material.diffuse;
5583
- display.options2[2] = material.factor;
5584
-
5585
- cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
5586
- display.options4[0] = material.cameralight/0.2f;
5587
- display.options4[1] = material.subsurface;
5588
- display.options4[2] = material.sheen;
5589
-
5590
- // if (display.CURRENTANTIALIAS > 0)
5591
- // display.options3[3] /= 4;
5592
-
5593
- /*
5594
- System.out.println("Focus = " + display.options1[0]);
5595
- System.out.println("Aperture = " + display.options1[1]);
5596
- System.out.println("ShadowBlur = " + display.options1[2]);
5597
- System.out.println("Antialiasing = " + display.options1[3]);
5598
- System.out.println("Fog = " + display.options2[0]);
5599
- System.out.println("Intensity = " + display.options2[1]);
5600
- System.out.println("Elevation = " + display.options2[2]);
5601
- /**/
5602
- } else
5603
- {
5604
- material.Draw(display, selected);
5605
- }
5606
- } else
5607
- {
5608
- if (selected && CameraPane.flash)
5609
- {
5610
- display.modelParams4[1] = 100;
5611
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
5612
- }
5613
- }
6317
+ display.PushMaterial(this, selected);
56146318
56156319 //System.out.println("call list " + list);
56166320 //System.out.println();
....@@ -5629,7 +6333,28 @@
56296333 tex = GetTextures();
56306334 }
56316335
5632
- 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
+ }
56336358
56346359 if (!compiled)
56356360 {
....@@ -5645,30 +6370,19 @@
56456370
56466371 // System.err.println("glCallList: " + bRep.displaylist + " for " + this);
56476372 assert(bRep.displaylist != 0);
5648
- gl.glCallList(bRep.displaylist);
6373
+ display.CallList(bRep.displaylist);
56496374 // june 2013 drawSelf(display, root, selected);
56506375 }
56516376 }
56526377 }
56536378
5654
- display.ReleaseTextures(tex);
5655
-
5656
- //if (parent != null && parent.GetMaterial() != null)
5657
- // parent.GetMaterial().Draw(display, parent.IsSelected(this));
5658
- if (material != null)
5659
- {
5660
- materialdepth -= 1;
5661
- if (materialdepth > 0)
5662
- {
5663
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
5664
- materialstack[materialdepth - 1].Draw(display, selectedstack[materialdepth - 1]);
5665
- }
5666
- //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
5667
- } else if (selected && CameraPane.flash && GetMaterial() != null)
5668
- {
5669
- display.modelParams4[1] = GetMaterial().cameralight;
5670
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
5671
- }
6379
+ if (!failedBump)
6380
+ display.ReleaseBumpTexture(tex);
6381
+
6382
+ if (!failedPigment)
6383
+ display.ReleasePigmentTexture(tex);
6384
+
6385
+ display.PopMaterial(this, selected);
56726386 }
56736387
56746388 if (this instanceof Texture || this instanceof TextureNode)
....@@ -5710,7 +6424,7 @@
57106424 // resetMasterNode();
57116425 }
57126426
5713
- void CallList(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
6427
+ void CallList(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57146428 {
57156429 if (GetBRep() == null)
57166430 {
....@@ -5793,8 +6507,11 @@
57936507 boolean flipV = false; // true;
57946508 int texres = 0; // 0 = low, 1 = normal, 2 = high res texture
57956509
5796
- void drawSelf(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
6510
+ void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57976511 {
6512
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6513
+ return;
6514
+
57986515 if (hide)
57996516 return;
58006517 // shadow optimisation
....@@ -5852,16 +6569,7 @@
58526569 // // ??????????????????????????? Touch();
58536570 // }
58546571
5855
- if (material != null)
5856
- {
5857
- materialstack[materialdepth] = material;
5858
- selectedstack[materialdepth] = selected;
5859
- cStatic.objectstack[materialdepth++] = this;
5860
- //System.out.println("material " + material);
5861
- //Applet3D.tracein("selected ", selected);
5862
- display.vector2buffer = projectedVertices;
5863
- material.Draw(display, selected);
5864
- }
6572
+display.PushMaterial2(this, selected);
58656573
58666574 Object3D child;
58676575 boolean sel;
....@@ -5913,19 +6621,7 @@
59136621 */
59146622 //depth += 1;
59156623
5916
- if (material != null)
5917
- {
5918
- materialdepth -= 1;
5919
- if (materialdepth > 0)
5920
- {
5921
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
5922
- materialstack[materialdepth - 1].Draw(display, selectedstack[materialdepth - 1]);
5923
- }
5924
- //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
5925
- //else
5926
- //material.Draw(display, false);
5927
- }
5928
-
6624
+display.PopMaterial2(this);
59296625 /*
59306626 display.ReleaseTextures(tex);
59316627 */
....@@ -5936,10 +6632,13 @@
59366632
59376633 //static cVector min,max;
59386634
5939
- void DrawNode(CameraPane display, Object3D /*Composite*/ root, boolean selected)
6635
+ void DrawNode(iCameraPane display, Object3D /*Composite*/ root, boolean selected)
59406636 {
5941
- 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)
59426638 return; // no shadow for transparent objects
6639
+
6640
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6641
+ return;
59436642
59446643 if (hide)
59456644 return;
....@@ -5981,9 +6680,10 @@
59816680 return;
59826681 }
59836682
6683
+ //bRep.GenUV(1/material.diffuseness);
59846684 // bRep.lock = true;
59856685
5986
- javax.media.opengl.GL gl = display.GetGL();
6686
+ //javax.media.opengl.GL gl = display.GetGL();
59876687
59886688 if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera)
59896689 {
....@@ -6000,23 +6700,7 @@
60006700
60016701 bRep.getMinMax(min, max, 100);
60026702
6003
- gl.glBegin(gl.GL_LINES);
6004
-
6005
- gl.glVertex3d(min.x, min.y, min.z);
6006
- gl.glVertex3d(min.x, min.y, max.z);
6007
- gl.glVertex3d(min.x, min.y, min.z);
6008
- gl.glVertex3d(min.x, max.y, min.z);
6009
- gl.glVertex3d(min.x, min.y, min.z);
6010
- gl.glVertex3d(max.x, min.y, min.z);
6011
-
6012
- gl.glVertex3d(max.x, max.y, max.z);
6013
- gl.glVertex3d(min.x, max.y, max.z);
6014
- gl.glVertex3d(max.x, max.y, max.z);
6015
- gl.glVertex3d(max.x, min.y, max.z);
6016
- gl.glVertex3d(max.x, max.y, max.z);
6017
- gl.glVertex3d(max.x, max.y, min.z);
6018
-
6019
- gl.glEnd();
6703
+ display.DrawBox(min, max);
60206704
60216705 return;
60226706 }
....@@ -6060,7 +6744,7 @@
60606744 {
60616745 //throw new Error();
60626746
6063
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
6747
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
60646748
60656749 int[] strips = bRep.getRawIndices();
60666750
....@@ -6070,178 +6754,19 @@
60706754 new Exception().printStackTrace();
60716755 return;
60726756 }
6073
-
6074
- // TRIANGLE STRIP ARRAY
6075
- if (bRep.trimmed)
6757
+
6758
+ if (dontselect)
60766759 {
6077
- float[] v = bRep.getRawVertices();
6078
- float[] n = bRep.getRawNormals();
6079
- float[] c = bRep.getRawColors();
6080
- float[] uv = bRep.getRawUVMap();
6081
-
6082
- int count2 = 0;
6083
- int count3 = 0;
6084
-
6085
- if (n.length > 0)
6086
- {
6087
- for (int i = 0; i < strips.length; i++)
6088
- {
6089
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6090
-
6091
- /*
6092
- boolean locked = false;
6093
- float eps = 0.1f;
6094
- boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
6095
-
6096
- int dot = 0;
6097
-
6098
- if ((dot&1) == 0)
6099
- dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
6100
-
6101
- if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
6102
- gl.glTexCoord2f((float) qv.s, (float) qv.t);
6103
- else
6104
- {
6105
- locked = true;
6106
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6107
- }
6108
- //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6109
- gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
6110
- if (hasnorm)
6111
- {
6112
- //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6113
- gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
6114
- }
6115
-
6116
- if ((dot&4) == 0)
6117
- dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
6118
-
6119
- if (wrap || !locked && (dot&8) != 0)
6120
- gl.glTexCoord2f((float) rv.s, (float) rv.t);
6121
- else
6122
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6123
-
6124
- f.dot = dot;
6125
- */
6126
-
6127
- if (!selectmode)
6128
- {
6129
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6130
- {
6131
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6132
- } else
6133
- {
6134
- gl.glNormal3f(0, 0, 1);
6135
- }
6136
-
6137
- if (c != null)
6138
- //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]);
6139
- {
6140
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6141
- }
6142
- }
6143
- if (flipV)
6144
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6145
- else
6146
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6147
- //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6148
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6149
-
6150
- count2 += 2;
6151
- count3 += 3;
6152
- if (!selectmode)
6153
- {
6154
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6155
- {
6156
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6157
- } else
6158
- {
6159
- gl.glNormal3f(0, 0, 1);
6160
- }
6161
- if (c != null)
6162
- {
6163
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6164
- }
6165
- }
6166
- if (flipV)
6167
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6168
- else
6169
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6170
- //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6171
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6172
-
6173
- count2 += 2;
6174
- count3 += 3;
6175
- for (int j = 0; j < strips[i] - 2; j++)
6176
- {
6177
- //gl.glTexCoord2d(...);
6178
- if (!selectmode)
6179
- {
6180
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6181
- {
6182
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6183
- } else
6184
- {
6185
- gl.glNormal3f(0, 0, 1);
6186
- }
6187
- if (c != null)
6188
- {
6189
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6190
- }
6191
- }
6192
-
6193
- if (flipV)
6194
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6195
- else
6196
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6197
- //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
6198
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6199
- count2 += 2;
6200
- count3 += 3;
6201
- }
6202
-
6203
- gl.glEnd();
6204
- }
6205
- }
6206
-
6207
- assert count3 == v.length;
6760
+ //bRep.GenerateNormalsMINE();
62086761 }
6209
- else // !trimmed
6210
- {
6211
- int count = 0;
6212
- for (int i = 0; i < strips.length; i++)
6213
- {
6214
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6215
-
6216
- Vertex p = bRep.GetVertex(bRep.indices[count++]);
6217
- Vertex q = bRep.GetVertex(bRep.indices[count++]);
6218
-
6219
- drawVertex(gl, p, selectmode);
6220
- drawVertex(gl, q, selectmode);
6221
-
6222
- for (int j = 0; j < strips[i] - 2; j++)
6223
- {
6224
- Vertex r = bRep.GetVertex(bRep.indices[count++]);
6225
-
6226
-// if (j%2 == 0)
6227
-// drawFace(p, q, r, display, null);
6228
-// else
6229
-// drawFace(p, r, q, display, null);
6230
-
6231
-// p = q;
6232
-// q = r;
6233
- drawVertex(gl, r, selectmode);
6234
- }
6235
-
6236
- gl.glEnd();
6237
- }
6238
- }
6762
+
6763
+ display.DrawGeometry(bRep, flipV, selectmode);
62396764 } else // catch (Error e)
62406765 {
62416766 // TRIANGLE ARRAY
62426767 if (IsOpaque()) // Static())
62436768 {
6244
- gl.glBegin(gl.GL_TRIANGLES);
6769
+ display.StartTriangles();
62456770 int facecount = bRep.FaceCount();
62466771 for (int i = 0; i < facecount; i++)
62476772 {
....@@ -6304,9 +6829,9 @@
63046829 // // r.norm.dot(v3) > -0.5)
63056830 // // continue;
63066831
6307
- drawFace(p, q, r, display, face);
6832
+ display.DrawFace(this, p, q, r, face);
63086833 }
6309
- gl.glEnd();
6834
+ display.EndTriangles();
63106835 }
63116836 else
63126837 {
....@@ -6335,8 +6860,8 @@
63356860 //System.out.println("SORT");
63366861
63376862 java.util.Arrays.sort(facescompare);
6338
-
6339
- gl.glBegin(gl.GL_TRIANGLES);
6863
+
6864
+ display.StartTriangles();
63406865 for (int i = 0; i < facecount; i++)
63416866 {
63426867 Face face = bRep.GetFace(facescompare[i].index);
....@@ -6348,13 +6873,14 @@
63486873 Vertex q = bRep.GetVertex(face.q);
63496874 Vertex r = bRep.GetVertex(face.r);
63506875
6351
- drawFace(p, q, r, display, face);
6876
+ display.DrawFace(this, p, q, r, face);
63526877 }
6353
- gl.glEnd();
6878
+ display.EndTriangles();
63546879 }
63556880
63566881 if (false) // live && support != null && support.bRep != null) // debug weights
63576882 {
6883
+ /*
63586884 gl.glDisable(gl.GL_LIGHTING);
63596885 float[] colorV = new float[3];
63606886
....@@ -6433,6 +6959,7 @@
64336959 // gl.glEnd();
64346960 }
64356961 }
6962
+ */
64366963 }
64376964 }
64386965
....@@ -6477,7 +7004,7 @@
64777004 center.add(r);
64787005 center.mul(1.0/3);
64797006
6480
- center.sub(CameraPane.theRenderer.eyeCamera.location);
7007
+ center.sub(Globals.theRenderer.EyeCamera().location);
64817008
64827009 distance = center.dot(center);
64837010 }
....@@ -6488,390 +7015,11 @@
64887015
64897016 transient FaceCompare[] facescompare = null;
64907017
6491
- void SetColor(CameraPane display, Vertex p0)
6492
- {
6493
- if (display.RENDERPROGRAM == 0)
6494
- {
6495
- float r = 0;
6496
- if (bRep != null)
6497
- {
6498
- if (bRep.stripified)
6499
- {
6500
- r = 1;
6501
- }
6502
- }
6503
- float g = 0;
6504
- if (bRep != null)
6505
- {
6506
- if (bRep.trimmed)
6507
- {
6508
- g = 1;
6509
- }
6510
- }
6511
- float b = 0;
6512
- if (support != null && link2master)
6513
- {
6514
- b = 1;
6515
- }
6516
- display.GetGL().glColor3f(r*p0.AO, g*p0.AO, b*p0.AO);
6517
- return;
6518
- }
6519
-
6520
- if (display.drawMode != CameraPane.SHADOW)
6521
- return;
6522
-
6523
- javax.media.opengl.GL gl = display.GetGL();
6524
-// if (true) return;
6525
-// float ao = p.AO;
6526
-//
6527
-// // if (ao == 0 && !bRep.AOdone) // transient problem!
6528
-// // ao = 1;
6529
-//
6530
-// gl.glColor4f(ao, ao, ao, 1);
6531
-
6532
-// CameraPane.selectedpoint.
6533
-// getAverage(cStatic.point1, true);
6534
- if (CameraPane.pointflow == null) // !random) // live)
6535
- {
6536
- return;
6537
- }
6538
-
6539
- cStatic.point1.set(0,0,0);
6540
- LA.xformPos(cStatic.point1, CameraPane.selectedpoint.toParent, cStatic.point1);
6541
-
6542
- cStatic.point1.sub(p0);
6543
-
6544
-
6545
-// if (marked && (p0.vertexlinks == null || support == null || support.bRep == null)) // no position delta?
6546
-// {
6547
-// return;
6548
-// }
6549
-
6550
- //if (true)
6551
- if (cStatic.point1.dot(cStatic.point1) > 0.000001)
6552
- {
6553
- return;
6554
- }
6555
-
6556
- float[] colorV = new float[3];
6557
-
6558
- if (false) // marked)
6559
- {
6560
- // debug rigging weights
6561
- for (int object = 0; object < p0.vertexlinks.length; object++)
6562
- {
6563
- float weight = p0.weights[object] / p0.totalweight;
6564
-
6565
- // if (weight < 0.1)
6566
- // {
6567
- // assert(weight == 0);
6568
- // continue;
6569
- // }
6570
-
6571
- if (p0.vertexlinks[object] == -1)
6572
- continue;
6573
-
6574
- Vertex q = support.bRep.GetVertex(p0.vertexlinks[object]);
6575
-
6576
- int color = //1 << object; //
6577
- //p.vertexlinks.length;
6578
- support.bRep.supports[p0.closestsupport].links[object];
6579
- colorV[2] += (color & 1) * weight;
6580
- colorV[1] += ((color & 2) >> 1) * weight;
6581
- colorV[0] += ((color & 4) >> 2) * weight;
6582
- }
6583
- }
6584
- else
6585
- {
6586
- if (drawingstarted)
6587
- {
6588
- // find next point
6589
- if (bRep.GetVertex(0).faceindices == null)
6590
- {
6591
- bRep.InitFaceIndices();
6592
- }
6593
-
6594
- double ymin = p0.y;
6595
-
6596
- Vertex newp = p0;
6597
-
6598
- for (int fii = 0; fii < p0.faceindices.length; fii++)
6599
- {
6600
- int fi = p0.faceindices[fii];
6601
-
6602
- if (fi == -1)
6603
- break;
6604
-
6605
- Face f = bRep.GetFace(fi);
6606
-
6607
- Vertex p = bRep.GetVertex(f.p);
6608
- Vertex q = bRep.GetVertex(f.q);
6609
- Vertex r = bRep.GetVertex(f.r);
6610
-
6611
- int swap = (int)(Math.random()*3);
6612
-
6613
-// for (int s=swap; --s>=0;)
6614
-// {
6615
-// Vertex t = p;
6616
-// p = q;
6617
-// q = r;
6618
-// r = t;
6619
-// }
6620
- if (ymin > p.y)
6621
- {
6622
- ymin = p.y;
6623
- newp = p;
6624
-// break;
6625
- }
6626
- if (ymin > q.y)
6627
- {
6628
- ymin = q.y;
6629
- newp = q;
6630
-// break;
6631
- }
6632
- if (ymin > r.y)
6633
- {
6634
- ymin = r.y;
6635
- newp = r;
6636
-// break;
6637
- }
6638
- }
6639
-
6640
- CameraPane.selectedpoint.toParent[3][0] = newp.x;
6641
- CameraPane.selectedpoint.toParent[3][1] = newp.y;
6642
- CameraPane.selectedpoint.toParent[3][2] = newp.z;
6643
-
6644
- drawingstarted = false;
6645
-
6646
- // return;
6647
- }
6648
-
6649
- if (false) // CameraPane.DRAW
6650
- {
6651
- p0.AO = colorV[0] = 2;
6652
- colorV[1] = 2;
6653
- colorV[2] = 2;
6654
- }
6655
-
6656
- CameraPane.pointflow.add(p0);
6657
- CameraPane.pointflow.Touch();
6658
- }
6659
-
6660
-// gl.glColor3f(colorV[0], colorV[1], colorV[2]);
6661
-// gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0);
6662
-// gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
6663
- }
6664
-
66657018 void Print(Vertex v)
66667019 {
66677020 //System.err.println("(" + v.x + ", " + v.y + ", " + v.z + ")");
66687021 }
66697022
6670
- void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean selectmode)
6671
- {
6672
- if (!selectmode)
6673
- {
6674
- gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
6675
- gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
6676
-
6677
- if (flipV)
6678
- gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
6679
- else
6680
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6681
- }
6682
-
6683
- gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
6684
- }
6685
-
6686
- void drawFace(Vertex pv, Vertex qv, Vertex rv,
6687
- CameraPane display, Face face)
6688
- {
6689
- if (pv.y == -10000 ||
6690
- qv.y == -10000 ||
6691
- rv.y == -10000)
6692
- return;
6693
-
6694
-// float b = f.nbiterations & 1;
6695
-// float g = (f.nbiterations>>1) & 1;
6696
-// float r = (f.nbiterations>>2) & 1;
6697
-//
6698
-// //if (f.weight == 10000)
6699
-// //{
6700
-// // r = 1; g = b = 0;
6701
-// //}
6702
-// //else
6703
-// //{
6704
-// // assert(f.weight < 10000);
6705
-// r = g = b = (float)bRep.FaceWeight(f)*100;
6706
-// if (r<0)
6707
-// assert(r>=0);
6708
-// //}
6709
-
6710
- javax.media.opengl.GL gl = display.GetGL();
6711
-
6712
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
6713
-
6714
- //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv);
6715
- if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
6716
- {
6717
- //gl.glBegin(gl.GL_TRIANGLES);
6718
- boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
6719
- if (!hasnorm)
6720
- {
6721
- // System.out.println("FUCK!!");
6722
- LA.vecSub(pv/*.pos*/, qv/*.pos*/, v0);
6723
- LA.vecSub(pv/*.pos*/, rv/*.pos*/, v1);
6724
- LA.vecCross(v0, v1, v2);
6725
- LA.vecNormalize(v2);
6726
- gl.glNormal3f((float) v2.x, (float) v2.y, (float) v2.z);
6727
- }
6728
-
6729
- // P
6730
- float x = (float)pv.x;
6731
- float y = (float)pv.y;
6732
- float z = (float)pv.z;
6733
-
6734
- if (hasnorm)
6735
- {
6736
-// if (!pv.norm.normalized())
6737
-// assert(pv.norm.normalized());
6738
-
6739
- //System.out.println("normalp = " + pv.norm.x + ", " + pv.norm.y + ", " + pv.norm.z);
6740
- float nx = (float)pv.norm.x;
6741
- float ny = (float)pv.norm.y;
6742
- float nz = (float)pv.norm.z;
6743
-
6744
- x += nx * NORMALPUSH;
6745
- y += ny * NORMALPUSH;
6746
- z += nz * NORMALPUSH;
6747
-
6748
- gl.glNormal3f(nx, ny, nz);
6749
- }
6750
- gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
6751
- SetColor(display, pv);
6752
- //gl.glColor4f(r, g, b, 1);
6753
- //gl.glColor4f(pv.boundary, pv.boundary, pv.boundary, 1);
6754
- if (flipV)
6755
- gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
6756
- else
6757
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6758
- //System.out.println("vertexp = " + pv.x + ", " + pv.y + ", " + pv.z);
6759
-
6760
- gl.glVertex3f(x, y, z);
6761
-
6762
- // Q
6763
- x = (float)qv.x;
6764
- y = (float)qv.y;
6765
- z = (float)qv.z;
6766
-
6767
-// Print(pv);
6768
- if (hasnorm)
6769
- {
6770
-// assert(qv.norm.normalized());
6771
- //System.out.println("normalq = " + qv.norm.x + ", " + qv.norm.y + ", " + qv.norm.z);
6772
- float nx = (float)qv.norm.x;
6773
- float ny = (float)qv.norm.y;
6774
- float nz = (float)qv.norm.z;
6775
-
6776
- x += nx * NORMALPUSH;
6777
- y += ny * NORMALPUSH;
6778
- z += nz * NORMALPUSH;
6779
-
6780
- gl.glNormal3f(nx, ny, nz);
6781
- }
6782
- //System.out.println("vertexq = " + qv.s + ", " + qv.t);
6783
- // boolean locked = false;
6784
- // float eps = 0.1f;
6785
- // boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
6786
-
6787
- // int dot = 0; //*/ (int)f.dot;
6788
-
6789
- // if ((dot&1) == 0)
6790
- // dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
6791
-
6792
- // if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
6793
- if (flipV)
6794
- gl.glTexCoord2f((float) qv.s, 1-(float) qv.t);
6795
- else
6796
- gl.glTexCoord2f((float) qv.s, (float) qv.t);
6797
- // else
6798
- // {
6799
- // locked = true;
6800
- // gl.glTexCoord2f((float) pv.s, (float) pv.t);
6801
- // }
6802
- gl.glColor4f(qv.AO, qv.AO, qv.AO, 1);
6803
- SetColor(display, qv);
6804
-
6805
- gl.glVertex3f(x, y, z);
6806
- //gl.glColor4f(r, g, b, 1);
6807
- //gl.glColor4f(qv.boundary, qv.boundary, qv.boundary, 1);
6808
- //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6809
-// Print(qv);
6810
-
6811
- // R
6812
- x = (float)rv.x;
6813
- y = (float)rv.y;
6814
- z = (float)rv.z;
6815
-
6816
- if (hasnorm)
6817
- {
6818
-// assert(rv.norm.normalized());
6819
- //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6820
- float nx = (float)rv.norm.x;
6821
- float ny = (float)rv.norm.y;
6822
- float nz = (float)rv.norm.z;
6823
-
6824
- x += nx * NORMALPUSH;
6825
- y += ny * NORMALPUSH;
6826
- z += nz * NORMALPUSH;
6827
-
6828
- gl.glNormal3f(nx, ny, nz);
6829
- }
6830
-
6831
- // if ((dot&4) == 0)
6832
- // dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
6833
-
6834
- // if (wrap || !locked && (dot&8) != 0)
6835
- if (flipV)
6836
- gl.glTexCoord2f((float) rv.s, 1-(float) rv.t);
6837
- else
6838
- gl.glTexCoord2f((float) rv.s, (float) rv.t);
6839
- // else
6840
- // gl.glTexCoord2f((float) pv.s, (float) pv.t);
6841
-
6842
- // f.dot = dot;
6843
-
6844
- gl.glColor4f(rv.AO, rv.AO, rv.AO, 1);
6845
- SetColor(display, rv);
6846
- //gl.glColor4f(r, g, b, 1);
6847
- //gl.glColor4f(rv.boundary, rv.boundary, rv.boundary, 1);
6848
- //System.out.println("vertexr = " + rv.x + ", " + rv.y + ", " + rv.z);
6849
- gl.glVertex3f(x, y, z);
6850
-// Print(rv);
6851
- //gl.glEnd();
6852
- }
6853
- else
6854
- {
6855
- gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
6856
- gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
6857
- gl.glVertex3f((float) rv.x, (float) rv.y, (float) rv.z);
6858
-
6859
- }
6860
-
6861
- if (false) // (attributes & WIREFRAME) != 0)
6862
- {
6863
- gl.glDisable(gl.GL_LIGHTING);
6864
-
6865
- gl.glBegin(gl.GL_LINE_LOOP);
6866
- gl.glVertex3d(pv./*pos.*/x, pv./*pos.*/y, pv./*pos.*/z);
6867
- gl.glVertex3d(qv./*pos.*/x, qv./*pos.*/y, qv./*pos.*/z);
6868
- gl.glVertex3d(rv./*pos.*/x, rv./*pos.*/y, rv./*pos.*/z);
6869
- gl.glEnd();
6870
-
6871
- gl.glEnable(gl.GL_LIGHTING);
6872
- }
6873
- }
6874
-
68757023 void drawSelf(ClickInfo info, int level, boolean select)
68767024 {
68777025 if (bRep == null)
....@@ -7395,20 +7543,23 @@
73957543 }
73967544 }
73977545
7398
- 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)
73997550 {
7400
- int hc = info.bounds.x + info.bounds.width / 2;
7401
- int vc = info.bounds.y + info.bounds.height / 2;
7402
- 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;
74037554 if (toscreen == null)
74047555 {
7405
- toscreen = new Camera(info.camera.viewCode).toScreen;
7556
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
74067557 }
74077558 cVector vec = in;
74087559 LA.xformPos(in, toscreen, in);
74097560 //System.out.println("Distance = " + info.camera.Distance());
7410
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
7411
- 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();
74127563 outPt.x = hc + (int) vec.x;
74137564 outPt.y = vc - (int) vec.y;
74147565 outRec.x = outPt.x - 3;
....@@ -7416,15 +7567,18 @@
74167567 outRec.width = outRec.height = 6;
74177568 }
74187569
7419
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7570
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7571
+ )
74207572 {
74217573 Point pt = new Point(0, 0);
74227574 Rectangle rec = new Rectangle();
7423
- calcHotSpot(in, info, pt, rec);
7575
+ calcHotSpot(in, //clickInfo,
7576
+ pt, rec);
74247577 return rec;
74257578 }
74267579
7427
- void drawEditHandles0(ClickInfo info, int level)
7580
+ void drawEditHandles0(//ClickInfo clickInfo,
7581
+ int level)
74287582 {
74297583 if (level == 0)
74307584 {
....@@ -7433,98 +7587,104 @@
74337587 {
74347588 cVector origin = new cVector();
74357589 //LA.xformPos(origin, toParent, origin);
7436
- Rectangle spot = calcHotSpot(origin, info);
7590
+ if (this.clickInfo == null)
7591
+ this.clickInfo = new ClickInfo();
7592
+
7593
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
74377594 Rectangle boundary = new Rectangle();
74387595 boundary.x = spot.x - 30;
74397596 boundary.y = spot.y - 30;
74407597 boundary.width = spot.width + 60;
74417598 boundary.height = spot.height + 60;
7442
- info.g.setColor(Color.red);
7599
+ clickInfo.g.setColor(Color.white);
74437600 int spotw = spot.x + spot.width;
74447601 int spoth = spot.y + spot.height;
7445
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7446
- if (CameraPane.Xmin > spot.x)
7447
- {
7448
- CameraPane.Xmin = spot.x;
7449
- }
7450
- if (CameraPane.Xmax < spotw)
7451
- {
7452
- CameraPane.Xmax = spotw;
7453
- }
7454
- if (CameraPane.Ymin > spot.y)
7455
- {
7456
- CameraPane.Ymin = spot.y;
7457
- }
7458
- if (CameraPane.Ymax < spoth)
7459
- {
7460
- CameraPane.Ymax = spoth;
7461
- }
7462
- 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);
74637642 spotw = spot.x + spot.width;
74647643 spoth = spot.y + spot.height;
7465
- info.g.setColor(Color.blue);
7466
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7467
- if (CameraPane.Xmin > spot.x)
7468
- {
7469
- CameraPane.Xmin = spot.x;
7470
- }
7471
- if (CameraPane.Xmax < spotw)
7472
- {
7473
- CameraPane.Xmax = spotw;
7474
- }
7475
- if (CameraPane.Ymin > spot.y)
7476
- {
7477
- CameraPane.Ymin = spot.y;
7478
- }
7479
- if (CameraPane.Ymax < spoth)
7480
- {
7481
- CameraPane.Ymax = spoth;
7482
- }
7483
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7484
- info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7485
- spot.translate(0, -32);
7486
- info.g.setColor(Color.green);
7487
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7488
- if (CameraPane.Xmin > spot.x)
7489
- {
7490
- CameraPane.Xmin = spot.x;
7491
- }
7492
- if (CameraPane.Xmax < spotw)
7493
- {
7494
- CameraPane.Xmax = spotw;
7495
- }
7496
- if (CameraPane.Ymin > spot.y)
7497
- {
7498
- CameraPane.Ymin = spot.y;
7499
- }
7500
- if (CameraPane.Ymax < spoth)
7501
- {
7502
- CameraPane.Ymax = spoth;
7503
- }
7504
- info.g.drawArc(boundary.x, boundary.y,
7505
- 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);
75067665 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
7507
- if (CameraPane.Xmin > boundary.x)
7508
- {
7509
- CameraPane.Xmin = boundary.x;
7510
- }
7511
- if (CameraPane.Xmax < boundary.x + boundary.width)
7512
- {
7513
- CameraPane.Xmax = boundary.x + boundary.width;
7514
- }
7515
- if (CameraPane.Ymin > boundary.y)
7516
- {
7517
- CameraPane.Ymin = boundary.y;
7518
- }
7519
- if (CameraPane.Ymax < boundary.y + boundary.height)
7520
- {
7521
- CameraPane.Ymax = boundary.y + boundary.height;
7522
- }
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
+// }
75237682 return;
75247683 }
75257684 }
75267685
7527
- boolean doEditClick0(ClickInfo info, int level)
7686
+ boolean doEditClick0(//ClickInfo clickInfo,
7687
+ int level)
75287688 {
75297689 if (level == 0)
75307690 {
....@@ -7533,10 +7693,10 @@
75337693
75347694 boolean retval = false;
75357695
7536
- startX = info.x;
7537
- startY = info.y;
7696
+ startX = clickInfo.x;
7697
+ startY = clickInfo.y;
75387698
7539
- hitSomething = 0;
7699
+ hitSomething = -1;
75407700 cVector origin = new cVector();
75417701 //LA.xformPos(origin, toParent, origin);
75427702 Rectangle spot = new Rectangle();
....@@ -7544,22 +7704,53 @@
75447704 {
75457705 centerPt = new Point(0, 0);
75467706 }
7547
- calcHotSpot(origin, info, centerPt, spot);
7548
- if (spot.contains(info.x, info.y))
7707
+ calcHotSpot(origin, //info,
7708
+ centerPt, spot);
7709
+ if (spot.contains(clickInfo.x, clickInfo.y))
75497710 {
75507711 hitSomething = hitCenter;
75517712 retval = true;
75527713 }
75537714 spot.translate(32, 0);
7554
- if (spot.contains(info.x, info.y))
7715
+ if (spot.contains(clickInfo.x, clickInfo.y))
75557716 {
75567717 hitSomething = hitRotate;
75577718 retval = true;
75587719 }
75597720 spot.translate(0, 32);
7560
- 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))
75617724 {
75627725 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
+
75637754 retval = true;
75647755 }
75657756
....@@ -7569,7 +7760,7 @@
75697760 }
75707761
75717762 //System.out.println("info.modifiers = " + info.modifiers);
7572
- modified = (info.modifiers & CameraPane.META) != 0;
7763
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
75737764 //System.out.println("modified = " + modified);
75747765 //new Exception().printStackTrace();
75757766 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7597,7 +7788,8 @@
75977788 return true;
75987789 }
75997790
7600
- void doEditDrag0(ClickInfo info)
7791
+ void doEditDrag0(//ClickInfo info,
7792
+ boolean opposite)
76017793 {
76027794 if (hitSomething == 0)
76037795 {
....@@ -7611,7 +7803,8 @@
76117803
76127804 //System.out.println("hitSomething = " + hitSomething);
76137805
7614
- double scale = 0.005f * info.camera.Distance();
7806
+ double scale = 0.005f * clickInfo.camera.Distance();
7807
+
76157808 cVector xlate = new cVector();
76167809 //cVector xlate2 = new cVector();
76177810 switch (hitSomething)
....@@ -7622,9 +7815,11 @@
76227815
76237816 case hitCenter: // Translate
76247817
7625
- scale *= 0.05f * info.pane.theRenderer.renderCamera.Distance();
7818
+ scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
76267819
7627
- if (modified)
7820
+ // Modified could snap
7821
+ if (//modified ||
7822
+ opposite)
76287823 {
76297824 //assert(false);
76307825 /*
....@@ -7644,8 +7839,8 @@
76447839 toParent[3][i] = xlate.get(i);
76457840 LA.matInvert(toParent, fromParent);
76467841 */
7647
- cVector delta = LA.newVector(0, 0, startY - info.y);
7648
- 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);
76497844
76507845 LA.matCopy(startMat, toParent);
76517846 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7654,7 +7849,7 @@
76547849 } else
76557850 {
76567851 //LA.xformDir(delta, info.camera.fromScreen, delta);
7657
- cVector up = new cVector(info.camera.up);
7852
+ cVector up = new cVector(clickInfo.camera.up);
76587853 cVector away = new cVector();
76597854 //cVector right2 = new cVector();
76607855 //LA.vecCross(up, cVector.Z, right);
....@@ -7670,20 +7865,20 @@
76707865 }
76717866 LA.xformDir(up, ClickInfo.matbuffer, up);
76727867 // if (!CameraPane.LOCALTRANSFORM)
7673
- LA.xformDir(up, info.pane.theRenderer.renderCamera.toScreen, up);
7674
- 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);
76757870 // if (!CameraPane.LOCALTRANSFORM)
7676
- LA.xformDir(away, info.pane.theRenderer.renderCamera.toScreen, away);
7871
+ LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
76777872 //LA.vecCross(up, cVector.Z, right2);
76787873
7679
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7874
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
76807875
76817876 //System.out.println("DELTA0 = " + delta);
76827877 //System.out.println("AWAY = " + info.camera.away);
76837878 //System.out.println("UP = " + info.camera.up);
76847879 if (away.z > 0)
76857880 {
7686
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7881
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
76877882 {
76887883 delta.x = -delta.x;
76897884 } else
....@@ -7698,7 +7893,7 @@
76987893 //System.out.println("DELTA1 = " + delta);
76997894 LA.xformDir(delta, ClickInfo.matbuffer, delta);
77007895 //System.out.println("DELTA2 = " + delta);
7701
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7896
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
77027897 LA.matCopy(startMat, toParent);
77037898 //System.out.println("DELTA3 = " + delta);
77047899 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7708,8 +7903,8 @@
77087903 break;
77097904
77107905 case hitRotate: // rotate
7711
- int dx = info.x - centerPt.x;
7712
- int dy = -(info.y - centerPt.y);
7906
+ int dx = clickInfo.x - centerPt.x;
7907
+ int dy = -(clickInfo.y - centerPt.y);
77137908 double angle = (double) Math.atan2(dx, dy);
77147909 angle = -(1.570796 - angle);
77157910
....@@ -7718,6 +7913,7 @@
77187913
77197914 if (modified)
77207915 {
7916
+ // Rotate 45 degrees
77217917 angle /= (Math.PI / 4);
77227918 angle = Math.floor(angle + 0.5);
77237919 angle *= (Math.PI / 4);
....@@ -7731,7 +7927,7 @@
77317927 }
77327928 /**/
77337929
7734
- switch (info.pane.renderCamera.viewCode)
7930
+ switch (clickInfo.pane.RenderCamera().viewCode)
77357931 {
77367932 case 1: // '\001'
77377933 LA.matZRotate(toParent, angle);
....@@ -7758,26 +7954,30 @@
77587954 break;
77597955
77607956 case hitScale: // scale
7761
- 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);
77627964 if (hScale < 0.01)
77637965 {
7764
- hScale = 0.01;
7966
+ //hScale = 0.01;
77657967 }
7766
- hScale = Math.pow(hScale, scale * 50);
7767
- if (hScale < 0.01)
7968
+
7969
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
7970
+ sign = 1;
7971
+ if (vScale < 0)
77687972 {
7769
- hScale = 0.01;
7973
+ sign = -1;
77707974 }
7771
- double vScale = (double) (info.y - centerPt.y) / 32;
7975
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
77727976 if (vScale < 0.01)
77737977 {
7774
- vScale = 0.01;
7978
+ //vScale = 0.01;
77757979 }
7776
- vScale = Math.pow(vScale, scale * 50);
7777
- if (vScale < 0.01)
7778
- {
7779
- vScale = 0.01;
7780
- }
7980
+
77817981 LA.matCopy(startMat, toParent);
77827982 /**/
77837983 for (int i = 0; i < 3; i++)
....@@ -7787,39 +7987,56 @@
77877987 }
77887988 /**/
77897989
7790
- 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)
77917998 {
77927999 case 3: // '\001'
7793
- if (modified)
8000
+ if (modified || opposite)
77948001 {
8002
+ if (modified) // && opposite)
8003
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
8004
+ else
77958005 //LA.matScale(toParent, 1, hScale, vScale);
7796
- LA.matScale(toParent, vScale, 1, 1);
8006
+ LA.matScale(toParent, totalScale, 1, 1);
77978007 } // vScale, 1);
77988008 else
77998009 {
7800
- LA.matScale(toParent, vScale, vScale, vScale);
8010
+ // EXCEPTION!
8011
+ LA.matScale(toParent, 1, totalScale, totalScale);
78018012 } // vScale, 1);
78028013 break;
78038014
78048015 case 2: // '\002'
7805
- if (modified)
8016
+ if (modified || opposite)
78068017 {
7807
- //LA.matScale(toParent, hScale, 1, vScale);
7808
- 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);
78098023 } else
78108024 {
7811
- LA.matScale(toParent, vScale, 1, vScale);
8025
+ LA.matScale(toParent, totalScale, 1, totalScale);
78128026 }
78138027 break;
78148028
78158029 case 1: // '\003'
7816
- if (modified)
8030
+ if (modified || opposite)
78178031 {
7818
- //LA.matScale(toParent, hScale, vScale, 1);
7819
- 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);
78208037 } else
78218038 {
7822
- LA.matScale(toParent, vScale, vScale, 1);
8039
+ LA.matScale(toParent, totalScale, totalScale, 1);
78238040 }
78248041 break;
78258042 }
....@@ -7853,7 +8070,7 @@
78538070 } // NEW ...
78548071
78558072
7856
- info.pane.repaint();
8073
+ clickInfo.pane.repaint();
78578074 }
78588075
78598076 boolean overflow = false;
....@@ -7952,14 +8169,22 @@
79528169 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
79538170 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
79548171 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
8172
+
8173
+ String objname;
8174
+
79558175 if (false) //parent != null)
79568176 {
7957
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
8177
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
79588178 } else
79598179 {
7960
- 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) ":"") */ "";
79618181 } // + super.toString();
79628182 //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()
79638188 }
79648189
79658190 public int hashCode()
....@@ -8015,6 +8240,7 @@
80158240 objectUI.closeUI();
80168241 if (editWindow != null)
80178242 {
8243
+ editWindow.ctrlPanel.FlushUI();
80188244 editWindow.refreshContents();
80198245 } // ? new
80208246 objectUI = null;
....@@ -8023,6 +8249,10 @@
80238249 {
80248250 editWindow = null;
80258251 } // ?
8252
+ }
8253
+ else
8254
+ {
8255
+ //editWindow.closeUI();
80268256 }
80278257 }
80288258
....@@ -8035,7 +8265,7 @@
80358265 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
80368266
80378267 Object3D /*Composite*/ parent;
8038
- Object3D /*Composite*/ fileparent;
8268
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
80398269
80408270 double[][] toParent; // dynamic matrix
80418271 double[][] fromParent;
....@@ -8150,7 +8380,7 @@
81508380 {
81518381 assert(bRep != null);
81528382 if (!(support instanceof GenericJoint)) // support.bRep != null)
8153
- GrafreeD.Assert(support.bRep == bRep.support);
8383
+ Grafreed.Assert(support.bRep == bRep.support);
81548384 }
81558385 else
81568386 {
....@@ -8181,6 +8411,10 @@
81818411 }
81828412
81838413 transient ObjEditor editWindow;
8414
+ transient ObjEditor manipWindow;
8415
+
8416
+ transient boolean pinned;
8417
+
81848418 transient ObjectUI objectUI;
81858419 public static int povDepth = 0;
81868420 private static cVector tbMin = new cVector();
....@@ -8199,9 +8433,9 @@
81998433 private static cVector edge2 = new cVector();
82008434 //private static cVector norm = new cVector();
82018435 /*transient private*/ int hitSomething;
8202
- private static final int hitCenter = 1;
8203
- private static final int hitScale = 2;
8204
- private static final int hitRotate = 3;
8436
+ static final int hitCenter = 1;
8437
+ static final int hitScale = 2;
8438
+ static final int hitRotate = 3;
82058439 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
82068440 /*transient*/ private Point centerPt;
82078441 /*transient*/ private int startX;