Normand Briere
2019-08-17 5892f05411c3d4dce2d8a59e0966dc2e1843a971
Object3D.java
....@@ -5,6 +5,7 @@
55 import java.util.Vector;
66
77 import javax.media.j3d.Transform3D;
8
+import javax.media.opengl.GL;
89 import javax.vecmath.Vector3d;
910
1011 import javax.imageio.ImageIO;
....@@ -13,13 +14,44 @@
1314 import //weka.core.
1415 matrix.Matrix;
1516
17
+import java.util.UUID;
18
+
1619 //import net.sourceforge.sizeof.SizeOf;
1720 public class Object3D extends Vector<Object3D> implements java.io.Serializable, iSendInfo //, aurelienribon.tweenengine.TweenAccessor<Object3D>
1821 {
1922 //static final long serialVersionUID = -607422624994562685L;
2023 static final long serialVersionUID = 5022536242724664900L;
2124
25
+ // Use GetUUID for backward compatibility with null.
26
+ private UUID uuid = UUID.randomUUID();
27
+
28
+ // TEMPORARY for mocap undo. No need to be transient.
29
+ mocap.reader.BVHReader.BVHResult savebvh;
30
+ Object3D saveskeleton;
31
+ //
32
+
33
+ String skyboxname;
34
+ String skyboxext;
35
+
36
+ Object3D versionlist[];
37
+ int versionindex = -1;
38
+
39
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable; // = new java.util.Hashtable<java.util.UUID, Object3D>();
40
+
2241 ScriptNode scriptnode;
42
+
43
+ void InitOthers()
44
+ {
45
+ if (projectedVertices == null || projectedVertices.length <= 2)
46
+ {
47
+ projectedVertices = new Object3D.cVector2[3];
48
+ }
49
+ for (int i = 0; i < 3; i++)
50
+ {
51
+ projectedVertices[i] = new cVector2(); // Others
52
+ }
53
+ projectedVertices[0].x = 100; // bump
54
+ }
2355
2456 void MinMax(cVector minima, cVector maxima)
2557 {
....@@ -86,64 +118,201 @@
86118
87119 // transient boolean reduced; // for morph reduction
88120
89
-transient com.bulletphysics.linearmath.Transform cache; // for fast merge
90
-transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
121
+ transient com.bulletphysics.linearmath.Transform cache; // for fast merge
122
+ transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
91123
92
-transient Object3D transientsupport; // for cloning
93
-transient boolean transientlink2master;
124
+ transient Object3D transientsupport; // for cloning
125
+ transient boolean transientlink2master;
94126
95
-void SaveSupports()
96
-{
97
- if (blockloop)
98
- return;
99
-
100
- transientsupport = support;
101
- transientlink2master = link2master;
102
-
103
- support = null;
104
- link2master = false;
105
-
106
- if (bRep != null)
127
+ void SaveSupports()
107128 {
108
- bRep.SaveSupports();
129
+ if (blockloop)
130
+ return;
131
+
132
+ transientsupport = support;
133
+ transientlink2master = link2master;
134
+
135
+ support = null;
136
+ link2master = false;
137
+
138
+ if (bRep != null)
139
+ {
140
+ bRep.SaveSupports();
141
+ }
142
+
143
+ for (int i = 0; i < Size(); i++)
144
+ {
145
+ Object3D child = (Object3D) get(i);
146
+ if (child == null)
147
+ continue;
148
+ blockloop = true;
149
+ child.SaveSupports();
150
+ blockloop = false;
151
+ }
109152 }
110
-
111
- for (int i = 0; i < Size(); i++)
153
+
154
+ void RestoreSupports()
112155 {
113
- Object3D child = (Object3D) get(i);
114
- if (child == null)
115
- continue;
156
+ if (blockloop)
157
+ return;
158
+
159
+ support = transientsupport;
160
+ link2master = transientlink2master;
161
+ transientsupport = null;
162
+ transientlink2master = false;
163
+
164
+ if (bRep != null)
165
+ {
166
+ bRep.RestoreSupports();
167
+ }
168
+
169
+ for (int i = 0; i < Size(); i++)
170
+ {
171
+ Object3D child = (Object3D) get(i);
172
+ if (child == null)
173
+ continue;
174
+ blockloop = true;
175
+ child.RestoreSupports();
176
+ blockloop = false;
177
+ }
178
+ }
179
+
180
+ void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
181
+ {
182
+ Object3D o;
183
+
184
+ if (hashtable.containsKey(GetUUID()))
185
+ {
186
+ o = hashtable.get(GetUUID());
187
+
188
+ Grafreed.Assert(this.bRep == o.bRep);
189
+ //if (this.bRep != null)
190
+ // assert(this.bRep.support == o.transientrep);
191
+ if (this.support != null)
192
+ assert(this.support.bRep == o.transientrep);
193
+ }
194
+ else
195
+ {
196
+ o = new Object3D("copy of " + this.name);
197
+
198
+ hashtable.put(GetUUID(), o);
199
+ }
200
+
201
+ if (!blockloop)
202
+ {
203
+ blockloop = true;
204
+
205
+ for (int i=0; i<Size(); i++)
206
+ {
207
+ get(i).ExtractBigData(hashtable);
208
+ }
209
+
210
+ blockloop = false;
211
+ }
212
+
213
+ ExtractBigData(o);
214
+ }
215
+
216
+ void ExtractBigData(Object3D o)
217
+ {
218
+ if (o.bRep != null)
219
+ Grafreed.Assert(o.bRep == this.bRep);
220
+
221
+ o.bRep = this.bRep;
222
+// July 2019 if (this.bRep != null)
223
+// {
224
+// o.transientrep = this.bRep.support;
225
+// o.bRep.support = null;
226
+// }
227
+ o.selection = this.selection;
228
+ o.versionlist = this.versionlist;
229
+ o.versionindex = this.versionindex;
230
+
231
+ if (this.support != null)
232
+ {
233
+ if (o.transientrep != null)
234
+ Grafreed.Assert(o.transientrep == this.support.bRep);
235
+
236
+ o.transientrep = this.support.bRep;
237
+ this.support.bRep = null;
238
+ }
239
+
240
+ // o.support = this.support;
241
+ // o.fileparent = this.fileparent;
242
+ // if (this.bRep != null)
243
+ // o.bRep = this.bRep.support;
244
+
245
+ this.bRep = null;
246
+ // if (this.bRep != null)
247
+ // this.bRep.support = null;
248
+ // this.support = null;
249
+ // this.fileparent = null;
250
+ }
251
+
252
+// Object3D GetObject(java.util.UUID uuid)
253
+// {
254
+// if (this.uuid.equals(uuid))
255
+// return this;
256
+//
257
+// if (blockloop)
258
+// return null;
259
+//
260
+// blockloop = true;
261
+//
262
+// for (int i=0; i<Size(); i++)
263
+// {
264
+// Object3D o = get(i).GetObject(uuid);
265
+//
266
+// if (o != null)
267
+// return o;
268
+// }
269
+//
270
+// blockloop = false;
271
+//
272
+// return null;
273
+// }
274
+
275
+ void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
276
+ {
277
+ if (!hashtable.containsKey(GetUUID()))
278
+ return;
279
+
280
+ Object3D o = hashtable.get(GetUUID());
281
+
282
+ RestoreBigData(o);
283
+
284
+ if (blockloop)
285
+ return;
286
+
116287 blockloop = true;
117
- child.SaveSupports();
288
+
289
+ //hashtable.remove(GetUUID());
290
+
291
+ for (int i=0; i<Size(); i++)
292
+ {
293
+ get(i).RestoreBigData(hashtable);
294
+ }
295
+
118296 blockloop = false;
119297 }
120
-}
121298
122
-void RestoreSupports()
123
-{
124
- if (blockloop)
125
- return;
126
-
127
- support = transientsupport;
128
- link2master = transientlink2master;
129
- transientsupport = null;
130
- transientlink2master = false;
131
-
132
- if (bRep != null)
299
+ void RestoreBigData(Object3D o)
133300 {
134
- bRep.RestoreSupports();
301
+ this.bRep = o.bRep;
302
+ if (this.support != null && o.transientrep != null)
303
+ {
304
+ this.support.bRep = o.transientrep;
305
+ }
306
+
307
+ this.selection = o.selection;
308
+
309
+ this.versionlist = o.versionlist;
310
+ this.versionindex = o.versionindex;
311
+// July 2019 if (this.bRep != null)
312
+// this.bRep.support = o.transientrep;
313
+ // this.support = o.support;
314
+ // this.fileparent = o.fileparent;
135315 }
136
-
137
- for (int i = 0; i < Size(); i++)
138
- {
139
- Object3D child = (Object3D) get(i);
140
- if (child == null)
141
- continue;
142
- blockloop = true;
143
- child.RestoreSupports();
144
- blockloop = false;
145
- }
146
-}
147316
148317 // MOCAP SUPPORT
149318 double tx,ty,tz,rx,ry,rz;
....@@ -285,8 +454,9 @@
285454 return parent.GetName() + "#";
286455 }
287456
288
- boolean timeline = false;
289457 boolean live = false;
458
+ transient boolean keepdontselect;
459
+ boolean dontselect = false;
290460 boolean hide = false;
291461 boolean link2master = false; // performs reset support/master at each frame
292462 boolean marked = false; // animation node
....@@ -296,6 +466,8 @@
296466 boolean random = false;
297467 boolean speedup = false;
298468 boolean rewind = false;
469
+
470
+ float NORMALPUSH = 0;
299471
300472 Object3D support;
301473
....@@ -416,16 +588,16 @@
416588 {
417589 Object3D copy = this;
418590
419
- Camera parentcam = CameraPane.theRenderer.manipCamera;
591
+ Camera parentcam = Globals.theRenderer.ManipCamera();
420592
421
- if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[0])
593
+ if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[0])
422594 {
423
- parentcam = CameraPane.theRenderer.cameras[1];
595
+ parentcam = Globals.theRenderer.Cameras()[1];
424596 }
425597
426
- if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[1])
598
+ if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[1])
427599 {
428
- parentcam = CameraPane.theRenderer.cameras[0];
600
+ parentcam = Globals.theRenderer.Cameras()[0];
429601 }
430602
431603 if (this == parentcam)
....@@ -433,7 +605,7 @@
433605 //assert(this instanceof Camera);
434606
435607 for (int count = parentcam.GetTransformCount(); --count>=0;)
436
- LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.toParent, CameraPane.theRenderer.targetLookAt);
608
+ LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.toParent, Globals.theRenderer.TargetLookAt());
437609 }
438610
439611 copy.marked ^= true;
....@@ -453,7 +625,7 @@
453625 //assert(this instanceof Camera);
454626
455627 for (int count = parentcam.GetTransformCount(); --count>=0;)
456
- LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.fromParent, CameraPane.theRenderer.targetLookAt);
628
+ LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.fromParent, Globals.theRenderer.TargetLookAt());
457629 }
458630
459631 copy.Touch(); // display list issue
....@@ -466,12 +638,14 @@
466638 toParent = LA.newMatrix();
467639 fromParent = LA.newMatrix();
468640 }
641
+
469642 if (toParentMarked == null)
470643 {
471644 if (maxcount != 1)
472645 {
473646 new Exception().printStackTrace();
474647 }
648
+
475649 toParentMarked = LA.newMatrix();
476650 fromParentMarked = LA.newMatrix();
477651 }
....@@ -588,7 +762,7 @@
588762 return;
589763 }
590764
591
- if (CameraPane.fromscript)
765
+ if (Globals.fromscript)
592766 {
593767 transformcount = 0;
594768 return;
....@@ -746,7 +920,7 @@
746920
747921 int GetTransformCount()
748922 {
749
- // marde pour serialization de Texture
923
+ // patch pour serialization de Texture
750924 resetmaxcount();
751925 resettransformcount();
752926 resetstep();
....@@ -759,7 +933,7 @@
759933 if (step == 0)
760934 step = 1;
761935 if (maxcount == 0)
762
- maxcount = 2048; // 4;
936
+ maxcount = 128; // 2048; // 4;
763937 // if (acceleration == 0)
764938 // acceleration = 10;
765939 if (delay == 0) // serial
....@@ -780,9 +954,12 @@
780954 // factor = CameraPane.STEP;
781955 // }
782956
783
- if (marked && CameraPane.isLIVE() && live && CameraPane.drawMode == CameraPane.SHADOW && currentframe != CameraPane.framecount)
957
+ if (marked && Globals.isLIVE() && live &&
958
+ //TEMP21aug2018
959
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
960
+ currentframe != Globals.framecount)
784961 {
785
- currentframe = CameraPane.framecount;
962
+ currentframe = Globals.framecount;
786963
787964 // System.err.println("transformcount = " + transformcount);
788965 // System.err.println("factor = " + factor);
....@@ -791,7 +968,8 @@
791968
792969 boolean changedir = random && Math.random() < 0.01; // && !link2master;
793970
794
- if (transformcount*factor > maxcount || (step == 1 && changedir))
971
+ if (transformcount*factor >= maxcount && (rewind || random) ||
972
+ (step == 1 && changedir))
795973 {
796974 countdown = 1;
797975 delay = speedup?8:1;
....@@ -863,6 +1041,10 @@
8631041 if (material == null || material.multiply)
8641042 return true;
8651043
1044
+ if (projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
1045
+ return false;
1046
+
1047
+ // Transparent objects are dynamic because we have to sort the triangles.
8661048 return material.opacity > 0.99;
8671049 }
8681050
....@@ -894,6 +1076,11 @@
8941076 fromParent = null; // LA.newMatrix();
8951077 bRep = null; // new BoundaryRep();
8961078
1079
+ if (oname != null && oname.equals("LeftHand"))
1080
+ {
1081
+ name = oname;
1082
+ }
1083
+
8971084 /*
8981085 float hue = (float)Math.random();
8991086 Color col;
....@@ -936,7 +1123,7 @@
9361123
9371124 public Object clone()
9381125 {
939
- return GrafreeD.clone(this);
1126
+ return Grafreed.clone(this);
9401127 }
9411128
9421129 Object3D copyExpand()
....@@ -1258,6 +1445,7 @@
12581445 toParent = LA.newMatrix();
12591446 fromParent = LA.newMatrix();
12601447 }
1448
+
12611449 LA.matCopy(other.toParent, toParent);
12621450 LA.matCopy(other.fromParent, fromParent);
12631451
....@@ -1452,7 +1640,7 @@
14521640 BoundaryRep.SEUIL = other.material.cameralight;
14531641
14541642 // Set default to 0.1
1455
- BoundaryRep.SEUIL /= 2;
1643
+ BoundaryRep.SEUIL /= 4; // 2;
14561644 System.out.println("SEUIL = " + BoundaryRep.SEUIL);
14571645 }
14581646
....@@ -1711,7 +1899,7 @@
17111899 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17121900 o.bRep = transientrep;
17131901 if (clone)
1714
- o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
1902
+ o.bRep = (BoundaryRep) Grafreed.clone(transientrep);
17151903 o.CreateMaterial();
17161904 o.SetAttributes(this, -1);
17171905 //parent
....@@ -1724,7 +1912,7 @@
17241912 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17251913 o.bRep = bRep;
17261914 if (clone)
1727
- o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
1915
+ o.bRep = (BoundaryRep) Grafreed.clone(bRep);
17281916 o.CreateMaterial();
17291917 //o.overwriteThis(this, -1);
17301918 o.SetAttributes(this, -1);
....@@ -1811,12 +1999,15 @@
18111999 if (obj.name == null)
18122000 continue; // can't be a null one
18132001
2002
+ // Try perfect match first.
18142003 if (n.equals(obj.name))
18152004 {
18162005 theobj = obj;
18172006 count++;
18182007 }
18192008 }
2009
+
2010
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18202011
18212012 if (count != 1)
18222013 for (int i=Size(); --i>=0;)
....@@ -2131,15 +2322,8 @@
21312322 if (/*parent != null &&*/ material == null)
21322323 {
21332324 material = new cMaterial(GetMaterial());
2134
- if (projectedVertices == null || projectedVertices.length <= 2)
2135
- {
2136
- projectedVertices = new Object3D.cVector2[3];
2137
- }
2138
- for (int i = 0; i < 3; i++)
2139
- {
2140
- projectedVertices[i] = new cVector2(); // Others
2141
- }
2142
- projectedVertices[0].x = 100; // bump
2325
+
2326
+ InitOthers();
21432327
21442328 if (this instanceof Camera)
21452329 {
....@@ -2283,12 +2467,22 @@
22832467 }
22842468 */
22852469 }
2470
+ else
2471
+ {
2472
+ //((ObjEditor)editWindow).SetupUI2(null);
2473
+ if (objectUI != null)
2474
+ ((ObjEditor)objectUI).pinButton.setSelected(pinned);
2475
+ else
2476
+ //new Exception().printStackTrace();
2477
+ System.err.println("objectUI is null");
2478
+ }
22862479 }
22872480
22882481 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
22892482 {
22902483 if (newWindow)
22912484 {
2485
+ new Exception().printStackTrace();
22922486 System.exit(0);
22932487 if (parent != null)
22942488 {
....@@ -2323,6 +2517,14 @@
23232517 {
23242518 editWindow.refreshContents();
23252519 }
2520
+ else
2521
+ {
2522
+ if (manipWindow != null)
2523
+ {
2524
+ manipWindow.refreshContents();
2525
+ }
2526
+ }
2527
+
23262528 //if (parent != null)
23272529 //parent.refreshEditWindow();
23282530 }
....@@ -2402,7 +2604,8 @@
24022604 private static final int editSelf = 1;
24032605 private static final int editChild = 2;
24042606
2405
- void drawEditHandles(ClickInfo info, int level)
2607
+ void drawEditHandles(//ClickInfo info,
2608
+ int level)
24062609 {
24072610 if (level == 0)
24082611 {
....@@ -2410,7 +2613,8 @@
24102613 return;
24112614
24122615 Object3D selectee;
2413
- for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(info, level + 1))
2616
+ for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(//info,
2617
+ level + 1))
24142618 {
24152619 selectee = (Object3D) e.nextElement();
24162620 }
....@@ -2418,19 +2622,22 @@
24182622 } else
24192623 {
24202624 //super.
2421
- drawEditHandles0(info, level + 1);
2625
+ drawEditHandles0(//info,
2626
+ level + 1);
24222627 }
24232628 }
24242629
2425
- boolean doEditClick(ClickInfo info, int level)
2630
+ boolean doEditClick(//ClickInfo info,
2631
+ int level)
24262632 {
24272633 doSomething = 0;
24282634 if (level == 0)
24292635 {
2430
- return doParentClick(info);
2636
+ return doParentClick(); //info);
24312637 }
24322638 if (//super.
2433
- doEditClick0(info, level))
2639
+ doEditClick0(//info,
2640
+ level))
24342641 {
24352642 doSomething = 1;
24362643 return true;
....@@ -2440,7 +2647,7 @@
24402647 }
24412648 }
24422649
2443
- boolean doParentClick(ClickInfo info)
2650
+ boolean doParentClick() //ClickInfo info)
24442651 {
24452652 if (selection == null)
24462653 {
....@@ -2453,7 +2660,8 @@
24532660 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
24542661 {
24552662 Object3D selectee = (Object3D) e.nextElement();
2456
- if (selectee.doEditClick(info, 1))
2663
+ if (selectee.doEditClick(//info,
2664
+ 1))
24572665 {
24582666 childToDrag = selectee;
24592667 doSomething = 2;
....@@ -2465,13 +2673,15 @@
24652673 return retval;
24662674 }
24672675
2468
- void doEditDrag(ClickInfo info)
2676
+ void doEditDrag(//ClickInfo clickInfo,
2677
+ boolean opposite)
24692678 {
24702679 switch (doSomething)
24712680 {
24722681 case 1: // '\001'
24732682 //super.
2474
- doEditDrag0(info);
2683
+ doEditDrag0(//clickInfo,
2684
+ opposite);
24752685 break;
24762686
24772687 case 2: // '\002'
....@@ -2484,11 +2694,13 @@
24842694 {
24852695 //sel.hitSomething = childToDrag.hitSomething;
24862696 //childToDrag.doEditDrag(info);
2487
- sel.doEditDrag(info);
2697
+ sel.doEditDrag(//clickInfo,
2698
+ opposite);
24882699 } else
24892700 {
24902701 //super.
2491
- doEditDrag0(info);
2702
+ doEditDrag0(//clickInfo,
2703
+ opposite);
24922704 }
24932705 }
24942706 break;
....@@ -2506,6 +2718,9 @@
25062718 {
25072719 deselectAll();
25082720 }
2721
+
2722
+ new Exception().printStackTrace();
2723
+
25092724 ClickInfo newInfo = new ClickInfo();
25102725 newInfo.flags = info.flags;
25112726 newInfo.bounds = info.bounds;
....@@ -2598,6 +2813,18 @@
25982813 void GenNormalsS(boolean crease)
25992814 {
26002815 selection.GenNormals(crease);
2816
+// for (int i=0; i<selection.size(); i++)
2817
+// {
2818
+// Object3D selectee = (Object3D) selection.elementAt(i);
2819
+// selectee.GenNormals(crease);
2820
+// }
2821
+
2822
+ //Touch();
2823
+ }
2824
+
2825
+ void GenNormalsMeshS()
2826
+ {
2827
+ selection.GenNormalsMesh();
26012828 // for (int i=0; i<selection.size(); i++)
26022829 // {
26032830 // Object3D selectee = (Object3D) selection.elementAt(i);
....@@ -2738,6 +2965,24 @@
27382965 if (child == null)
27392966 continue;
27402967 child.GenNormals(crease);
2968
+// Children().release(i);
2969
+ }
2970
+ blockloop = false;
2971
+ }
2972
+
2973
+ void GenNormalsMesh()
2974
+ {
2975
+ if (blockloop)
2976
+ return;
2977
+
2978
+ blockloop = true;
2979
+ GenNormalsMesh0();
2980
+ for (int i = 0; i < Children().Size(); i++)
2981
+ {
2982
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2983
+ if (child == null)
2984
+ continue;
2985
+ child.GenNormalsMesh();
27412986 // Children().release(i);
27422987 }
27432988 blockloop = false;
....@@ -2895,7 +3140,8 @@
28953140 {
28963141 if (bRep != null)
28973142 {
2898
- bRep.GenUV();
3143
+ bRep.GenUV(); //1);
3144
+ //bRep.UnfoldUV();
28993145 Touch();
29003146 }
29013147 }
....@@ -2909,11 +3155,20 @@
29093155 }
29103156 }
29113157
3158
+ void GenNormalsMesh0()
3159
+ {
3160
+ if (bRep != null)
3161
+ {
3162
+ bRep.GenerateNormalsMesh();
3163
+ Touch();
3164
+ }
3165
+ }
3166
+
29123167 void GenNormalsMINE0()
29133168 {
29143169 if (bRep != null)
29153170 {
2916
- bRep.GenerateNormalsMINE();
3171
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
29173172 Touch();
29183173 }
29193174 }
....@@ -2970,6 +3225,33 @@
29703225 blockloop = false;
29713226 }
29723227
3228
+ void TransformChildren()
3229
+ {
3230
+ if (toParent != null)
3231
+ {
3232
+ for (int i=Size(); --i>=0;)
3233
+ {
3234
+ Object3D v = get(i);
3235
+
3236
+ if (v.toParent == null)
3237
+ {
3238
+ v.toParent = LA.newMatrix();
3239
+ v.fromParent = LA.newMatrix();
3240
+ }
3241
+
3242
+// LA.matConcat(v.toParent, toParent, v.toParent);
3243
+// LA.matConcat(fromParent, v.fromParent, v.fromParent);
3244
+ LA.matConcat(toParent, v.toParent, v.toParent);
3245
+ LA.matConcat(v.fromParent, fromParent, v.fromParent);
3246
+ }
3247
+
3248
+ toParent = null; // LA.matIdentity(toParent);
3249
+ fromParent = null; // LA.matIdentity(fromParent);
3250
+
3251
+ Touch();
3252
+ }
3253
+ }
3254
+
29733255 void TransformGeometry()
29743256 {
29753257 Object3D obj = this;
....@@ -3191,9 +3473,11 @@
31913473
31923474 BoundaryRep sup = bRep.support;
31933475 bRep.support = null;
3194
- BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
3476
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
31953477 // bRep.SplitInTwo(onlyone); // thread...
3196
- temprep.SplitInTwo(reduction34, onlyone);
3478
+
3479
+ while(temprep.SplitInTwo(reduction34, onlyone));
3480
+
31973481 bRep = temprep;
31983482 bRep.support = sup;
31993483 Touch();
....@@ -3330,7 +3614,8 @@
33303614 if (blockloop)
33313615 return;
33323616
3333
- if (marked || (bRep != null && material != null)) // borderline...
3617
+ if (//marked || // does not make sense
3618
+ (bRep != null || material != null)) // borderline...
33343619 live = h;
33353620
33363621 for (int i = 0; i < Size(); i++)
....@@ -3351,7 +3636,8 @@
33513636 return;
33523637
33533638 //if (bRep != null)
3354
- if (marked || (bRep != null && material != null)) // borderline...
3639
+ if (//marked || // does not make sense
3640
+ (bRep != null || material != null)) // borderline...
33553641 link2master = h;
33563642
33573643 for (int i = 0; i < Size(); i++)
....@@ -3371,7 +3657,8 @@
33713657 if (blockloop)
33723658 return;
33733659
3374
- if (marked || (bRep != null && material != null)) // borderline...
3660
+ if (//marked || // does not make sense
3661
+ (bRep != null || material != null)) // borderline...
33753662 hide = h;
33763663
33773664 for (int i = 0; i < Size(); i++)
....@@ -3391,7 +3678,7 @@
33913678 if (blockloop)
33923679 return;
33933680
3394
- if (bRep != null && material != null) // borderline...
3681
+ if (bRep != null || material != null) // borderline...
33953682 marked = h;
33963683
33973684 for (int i = 0; i < Size(); i++)
....@@ -3401,6 +3688,46 @@
34013688 continue;
34023689 blockloop = true;
34033690 child.MarkLeaves(h);
3691
+ blockloop = false;
3692
+ // release(i);
3693
+ }
3694
+ }
3695
+
3696
+ void RewindLeaves(boolean h)
3697
+ {
3698
+ if (blockloop)
3699
+ return;
3700
+
3701
+ if (bRep != null || material != null) // borderline...
3702
+ rewind = h;
3703
+
3704
+ for (int i = 0; i < Size(); i++)
3705
+ {
3706
+ Object3D child = (Object3D) get(i); // reserve(i);
3707
+ if (child == null)
3708
+ continue;
3709
+ blockloop = true;
3710
+ child.RewindLeaves(h);
3711
+ blockloop = false;
3712
+ // release(i);
3713
+ }
3714
+ }
3715
+
3716
+ void RandomLeaves(boolean h)
3717
+ {
3718
+ if (blockloop)
3719
+ return;
3720
+
3721
+ if (bRep != null || material != null) // borderline...
3722
+ random = h;
3723
+
3724
+ for (int i = 0; i < Size(); i++)
3725
+ {
3726
+ Object3D child = (Object3D) get(i); // reserve(i);
3727
+ if (child == null)
3728
+ continue;
3729
+ blockloop = true;
3730
+ child.RandomLeaves(h);
34043731 blockloop = false;
34053732 // release(i);
34063733 }
....@@ -3715,7 +4042,7 @@
37154042 if (child == null)
37164043 continue;
37174044
3718
- if (GrafreeD.RENDERME > 0)
4045
+ if (Grafreed.RENDERME > 0)
37194046 {
37204047 if (child instanceof Merge)
37214048 ((Merge)child).renderme();
....@@ -3866,7 +4193,7 @@
38664193 if (child == null)
38674194 continue;
38684195
3869
- if (GrafreeD.RENDERME > 0)
4196
+ if (Grafreed.RENDERME > 0)
38704197 {
38714198 if (child instanceof Merge)
38724199 ((Merge)child).renderme();
....@@ -4061,7 +4388,7 @@
40614388 if (child == null)
40624389 continue;
40634390
4064
- if (GrafreeD.RENDERME > 0)
4391
+ if (Grafreed.RENDERME > 0)
40654392 {
40664393 if (child instanceof Merge)
40674394 ((Merge)child).renderme();
....@@ -4158,6 +4485,71 @@
41584485 }
41594486 blockloop = true;
41604487 get(i).RepairParent();
4488
+ blockloop = false;
4489
+ }
4490
+ }
4491
+
4492
+ void RepairShadow()
4493
+ {
4494
+ if (blockloop)
4495
+ return;
4496
+
4497
+ if (this.material != null)
4498
+ this.InitOthers();
4499
+
4500
+ for (int i=0; i<Size(); i++)
4501
+ {
4502
+ blockloop = true;
4503
+ get(i).RepairShadow();
4504
+ blockloop = false;
4505
+ }
4506
+ }
4507
+
4508
+ void RepairSOV()
4509
+ {
4510
+ if (blockloop)
4511
+ return;
4512
+
4513
+ String texname = this.GetPigmentTexture();
4514
+
4515
+ if (texname.startsWith("sov"))
4516
+ {
4517
+ String[] s = texname.split("/");
4518
+
4519
+ String[] sname = s[1].split("Color.pn");
4520
+
4521
+ texname = sname[0];
4522
+
4523
+ if (sname.length > 1)
4524
+ {
4525
+ texname += "Color.jpg";
4526
+ }
4527
+
4528
+ this.SetPigmentTexture("sov/" + texname);
4529
+ }
4530
+
4531
+ texname = this.GetBumpTexture();
4532
+
4533
+ if (texname.startsWith("sov"))
4534
+ {
4535
+ String[] s = texname.split("/");
4536
+
4537
+ String[] sname = s[1].split("Bump.pn");
4538
+
4539
+ texname = sname[0];
4540
+
4541
+ if (sname.length > 1)
4542
+ {
4543
+ texname += "Bump.jpg";
4544
+ }
4545
+
4546
+ this.SetBumpTexture("sov/" + texname);
4547
+ }
4548
+
4549
+ for (int i=0; i<Size(); i++)
4550
+ {
4551
+ blockloop = true;
4552
+ get(i).RepairSOV();
41614553 blockloop = false;
41624554 }
41634555 }
....@@ -4652,7 +5044,7 @@
46525044
46535045 cTreePath SelectLeaf(int indexcount, boolean deselect)
46545046 {
4655
- if (hide)
5047
+ if (hide || dontselect)
46565048 return null;
46575049
46585050 if (count <= 0)
....@@ -4676,9 +5068,17 @@
46765068 }
46775069 }
46785070
5071
+ ObjEditor GetWindow()
5072
+ {
5073
+ if (editWindow != null)
5074
+ return editWindow;
5075
+
5076
+ return manipWindow;
5077
+ }
5078
+
46795079 cTreePath Select(int indexcount, boolean deselect)
46805080 {
4681
- if (hide)
5081
+ if (hide || dontselect)
46825082 return null;
46835083
46845084 if (count <= 0)
....@@ -4712,10 +5112,11 @@
47125112 if (leaf != null)
47135113 {
47145114 cTreePath tp = new cTreePath(this, leaf);
4715
- if (editWindow != null)
5115
+ ObjEditor window = GetWindow();
5116
+ if (window != null)
47165117 {
47175118 //System.out.println("editWindow = " + editWindow + " vs " + this);
4718
- editWindow.Select(tp, deselect, true);
5119
+ window.Select(tp, deselect, true);
47195120 }
47205121
47215122 return tp;
....@@ -4732,6 +5133,7 @@
47325133
47335134 if (child == null)
47345135 continue;
5136
+
47355137 if (child.HasTransparency() && child.size() != 0)
47365138 {
47375139 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4741,9 +5143,10 @@
47415143 if (leaf != null)
47425144 {
47435145 cTreePath tp = new cTreePath(this, leaf);
4744
- if (editWindow != null)
5146
+ ObjEditor window = GetWindow();
5147
+ if (window != null)
47455148 {
4746
- editWindow.Select(tp, deselect, true);
5149
+ window.Select(tp, deselect, true);
47475150 }
47485151
47495152 return tp;
....@@ -4828,7 +5231,7 @@
48285231 return globalTransform;
48295232 }
48305233
4831
- void PreprocessOcclusion(CameraPane cp)
5234
+ void PreprocessOcclusion(iCameraPane cp)
48325235 {
48335236 /*
48345237 if (AOdone)
....@@ -4975,7 +5378,8 @@
49755378 } else //
49765379 if (editWindow != null)
49775380 {
4978
- editWindow.cameraView.lighttouched = true;
5381
+ //editWindow.cameraView.lighttouched = true;
5382
+ Globals.lighttouched = true;
49795383 }
49805384 }
49815385
....@@ -5067,6 +5471,51 @@
50675471 blockloop = false;
50685472 }
50695473
5474
+ void ResetSelectable()
5475
+ {
5476
+ if (blockloop)
5477
+ return;
5478
+
5479
+ blockloop = true;
5480
+
5481
+ keepdontselect = dontselect;
5482
+ dontselect = true;
5483
+
5484
+ Object3D child;
5485
+ int nb = Size();
5486
+ for (int i = 0; i < nb; i++)
5487
+ {
5488
+ child = (Object3D) get(i);
5489
+ if (child == null)
5490
+ continue;
5491
+ child.ResetSelectable();
5492
+ }
5493
+
5494
+ blockloop = false;
5495
+ }
5496
+
5497
+ void RestoreSelectable()
5498
+ {
5499
+ if (blockloop)
5500
+ return;
5501
+
5502
+ blockloop = true;
5503
+
5504
+ dontselect = keepdontselect;
5505
+
5506
+ Object3D child;
5507
+ int nb = Size();
5508
+ for (int i = 0; i < nb; i++)
5509
+ {
5510
+ child = (Object3D) get(i);
5511
+ if (child == null)
5512
+ continue;
5513
+ child.RestoreSelectable();
5514
+ }
5515
+
5516
+ blockloop = false;
5517
+ }
5518
+
50705519 boolean IsSelected()
50715520 {
50725521 if (parent == null)
....@@ -5127,12 +5576,41 @@
51275576 if (fullname == null)
51285577 return "";
51295578
5579
+ if (fullname.pigment != null)
5580
+ {
5581
+ return fullname.pigment;
5582
+ }
5583
+
51305584 // System.out.println("Fullname = " + fullname);
51315585
5132
- if (fullname.name.indexOf(":") == -1)
5133
- return fullname.name;
5586
+ // Does not work on Windows due to C:
5587
+// if (fullname.name.indexOf(":") == -1)
5588
+// return fullname.name;
5589
+//
5590
+// return fullname.name.substring(0,fullname.name.indexOf(":"));
51345591
5135
- return fullname.name.substring(0,fullname.name.indexOf(":"));
5592
+ String[] split = fullname.name.split(":");
5593
+
5594
+ if (split.length == 0)
5595
+ {
5596
+ return fullname.pigment = "";
5597
+ }
5598
+
5599
+ if (split.length <= 2)
5600
+ {
5601
+ if (fullname.name.endsWith(":"))
5602
+ {
5603
+ // Windows
5604
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
5605
+ }
5606
+
5607
+ return fullname.pigment = split[0];
5608
+ }
5609
+
5610
+ // Windows
5611
+ assert(split.length == 4);
5612
+
5613
+ return fullname.pigment = split[0] + ":" + split[1];
51365614 }
51375615
51385616 static String GetBump(cTexture fullname)
....@@ -5140,11 +5618,44 @@
51405618 if (fullname == null)
51415619 return "";
51425620
5621
+ if (fullname.bump != null)
5622
+ {
5623
+ return fullname.bump;
5624
+ }
5625
+
51435626 // System.out.println("Fullname = " + fullname);
5144
- if (fullname.name.indexOf(":") == -1)
5145
- return "";
5146
-
5147
- return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5627
+ // Does not work on Windows due to C:
5628
+// if (fullname.name.indexOf(":") == -1)
5629
+// return "";
5630
+//
5631
+// return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5632
+ String[] split = fullname.name.split(":");
5633
+
5634
+ if (split.length == 0)
5635
+ {
5636
+ return fullname.bump = "";
5637
+ }
5638
+
5639
+ if (split.length == 1)
5640
+ {
5641
+ return fullname.bump = "";
5642
+ }
5643
+
5644
+ if (split.length == 2)
5645
+ {
5646
+ if (fullname.name.endsWith(":"))
5647
+ {
5648
+ // Windows
5649
+ return fullname.bump = "";
5650
+ }
5651
+
5652
+ return fullname.bump = split[1];
5653
+ }
5654
+
5655
+ // Windows
5656
+ assert(split.length == 4);
5657
+
5658
+ return fullname.bump = split[2] + ":" + split[3];
51485659 }
51495660
51505661 String GetPigmentTexture()
....@@ -5218,7 +5729,7 @@
52185729 System.out.print("; textures = " + textures);
52195730 System.out.println("; usedtextures = " + usedtextures);
52205731
5221
- if (GetTextures() == null)
5732
+ if (GetTextures() == null) // What is that??
52225733 GetTextures().name = ":";
52235734
52245735 String texname = tex;
....@@ -5227,6 +5738,9 @@
52275738 texname = "";
52285739
52295740 GetTextures().name = texname + ":" + GetBump(GetTextures());
5741
+
5742
+ GetTextures().pigment = null;
5743
+
52305744 Touch();
52315745 }
52325746
....@@ -5251,6 +5765,43 @@
52515765 }
52525766 }
52535767
5768
+ UUID GetUUID()
5769
+ {
5770
+ if (uuid == null)
5771
+ {
5772
+ // Serial
5773
+ uuid = UUID.randomUUID();
5774
+ }
5775
+
5776
+ return uuid;
5777
+ }
5778
+
5779
+ Object3D GetObject(UUID uid)
5780
+ {
5781
+ if (blockloop)
5782
+ return null;
5783
+
5784
+ if (GetUUID().equals(uid))
5785
+ return this;
5786
+
5787
+ int nb = Size();
5788
+ for (int i = 0; i < nb; i++)
5789
+ {
5790
+ Object3D child = (Object3D) get(i);
5791
+
5792
+ if (child == null)
5793
+ continue;
5794
+
5795
+ blockloop = true;
5796
+ Object3D obj = child.GetObject(uid);
5797
+ blockloop = false;
5798
+ if (obj != null)
5799
+ return obj;
5800
+ }
5801
+
5802
+ return null;
5803
+ }
5804
+
52545805 void SetBumpTexture(String tex)
52555806 {
52565807 if (GetTextures() == null)
....@@ -5262,6 +5813,8 @@
52625813 texname = "";
52635814
52645815 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
5816
+
5817
+ GetTextures().bump = null;
52655818
52665819 Touch();
52675820 }
....@@ -5287,25 +5840,65 @@
52875840 }
52885841 }
52895842
5290
- void draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5843
+ void EmbedTextures(boolean embed)
5844
+ {
5845
+ if (blockloop)
5846
+ return;
5847
+
5848
+ //if (GetTextures() != null)
5849
+ if (embed)
5850
+ CameraPane.EmbedTextures(GetTextures());
5851
+ else
5852
+ {
5853
+ GetTextures().pigmentdata = null;
5854
+ GetTextures().bumpdata = null;
5855
+ GetTextures().pw = 0;
5856
+ GetTextures().ph = 0;
5857
+ GetTextures().bw = 0;
5858
+ GetTextures().bh = 0;
5859
+ }
5860
+
5861
+ int nb = Size();
5862
+ for (int i = 0; i < nb; i++)
5863
+ {
5864
+ Object3D child = (Object3D) get(i);
5865
+
5866
+ if (child == null)
5867
+ continue;
5868
+
5869
+ blockloop = true;
5870
+ child.EmbedTextures(embed);
5871
+ blockloop = false;
5872
+ }
5873
+ }
5874
+
5875
+ void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
52915876 {
52925877 Draw(display, root, selected, blocked);
52935878 }
52945879
5295
- static cMaterial[] materialstack = new cMaterial[65536];
5296
- static boolean[] selectedstack = new boolean[65536];
5297
- static int materialdepth = 0;
5298
-
52995880 boolean NeedSupport()
53005881 {
53015882 return
5302
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5883
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
53035884 // PROBLEM with CROWD!!
5304
- && (CameraPane.drawMode == CameraPane.SHADOW || CameraPane.CROWD);
5885
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
53055886 }
53065887
5888
+ static boolean DEBUG_SELECTION = false;
53075889
5308
- void Draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5890
+ boolean IsLive()
5891
+ {
5892
+ if (live)
5893
+ return true;
5894
+
5895
+ if (parent == null)
5896
+ return false;
5897
+
5898
+ return parent.IsLive();
5899
+ }
5900
+
5901
+ void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
53095902 {
53105903 Invariants(); // june 2013
53115904
....@@ -5314,8 +5907,8 @@
53145907 // System.err.println("Draw " + this + " Frame # " + ((Mocap)((Merge)support).object).frame);
53155908 }
53165909
5317
- if (display.drawMode == CameraPane.SELECTION &&
5318
- hide)
5910
+ if (display.DrawMode() == iCameraPane.SELECTION &&
5911
+ (hide || dontselect))
53195912 return;
53205913
53215914 if (name != null && name.contains("sclera"))
....@@ -5333,7 +5926,7 @@
53335926 if (this instanceof Checker)
53345927 return;
53355928
5336
- if (display.drawMode == display.SHADOW && PASSTEST)
5929
+ if (display.DrawMode() == display.SHADOW && PASSTEST)
53375930 return;
53385931
53395932 if (count <= 0)
....@@ -5341,13 +5934,13 @@
53415934 return;
53425935 }
53435936
5344
- if ((//display.drawMode == CameraPane.SHADOW ||
5345
- display.drawMode == CameraPane.SELECTION || CameraPane.DEBUG_SELECTION) && HasTransparency())
5937
+ if ((//display.DrawMode() == CameraPane.SHADOW ||
5938
+ display.DrawMode() == iCameraPane.SELECTION || display.IsDebugSelection()) && HasTransparency())
53465939 {
53475940 return;
53485941 }
53495942
5350
- javax.media.opengl.GL gl = display.GetGL();
5943
+ //javax.media.opengl.GL gl = display.GetGL();
53515944
53525945 /*
53535946 if (touched)
....@@ -5365,8 +5958,10 @@
53655958 if (support != null)
53665959 support = support;
53675960
5368
- //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5369
- boolean usecalllists = false; // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5961
+ boolean usecalllists = !IsLive() && IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5962
+ //boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5963
+
5964
+ //usecalllists &= display.DrawMode() == display.DEFAULT; // Don't compute list in shadow pass.
53705965
53715966 if (!usecalllists && bRep != null && bRep.displaylist > 0)
53725967 {
....@@ -5376,30 +5971,33 @@
53765971 // usecalllists &= !(parent instanceof RandomNode);
53775972 // usecalllists = false;
53785973
5379
- if (GetBRep() != null)
5380
- usecalllists = usecalllists;
5974
+ if (display.DrawMode() == display.SHADOW)
5975
+ //GetBRep() != null)
5976
+ usecalllists = !!usecalllists;
53815977 //System.out.println("draw " + this);
53825978 //new Exception().printStackTrace();
53835979
53845980 boolean compiled = false;
53855981
5386
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
5982
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
53875983
5388
- if (!selectmode && //display.drawMode != display.SELECTION &&
5389
- (touched || (bRep != null && bRep.displaylist <= 0)))
5984
+ if (!selectmode && //display.DrawMode() != display.SELECTION &&
5985
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5986
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
53905987 {
5391
- display.lighttouched = true;
5988
+ Globals.lighttouched = true;
53925989 } // all panes...
5393
- //if (usecalllists && display.drawMode != display.SELECTION && display.drawMode != display.SHADOW &&
5394
- if (bRep != null && usecalllists && !selectmode && // june 2013 display.drawMode != display.SHADOW &&
5990
+
5991
+ //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
5992
+ if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
53955993 (touched || (bRep != null && bRep.displaylist <= 0)))
53965994 {
53975995 if (!(this instanceof Composite))
53985996 touched = false;
53995997 //if (displaylist == -1 && usecalllists)
5400
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
5998
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
54015999 {
5402
- bRep.displaylist = gl.glGenLists(1);
6000
+ bRep.displaylist = display.GenList();
54036001 assert(bRep.displaylist != 0);
54046002 // System.err.println("glGenLists: " + bRep.displaylist + " for " + this);
54056003 //System.out.println("\tgen list " + list);
....@@ -5408,21 +6006,23 @@
54086006
54096007 //System.out.println("\tnew list " + list);
54106008 //gl.glDrawBuffer(gl.GL_NONE);
5411
- if (usecalllists)
6009
+ if (usecalllists && bRep.displaylist > 0)
54126010 {
54136011 // System.err.println("new list " + bRep.displaylist + " for " + this);
5414
- gl.glNewList(bRep.displaylist, gl.GL_COMPILE); //_AND_EXECUTE);
6012
+ display.NewList(bRep.displaylist);
54156013 }
6014
+
54166015 CallList(display, root, selected, blocked);
6016
+
54176017 // compiled = true;
5418
- if (usecalllists)
6018
+ if (usecalllists && bRep.displaylist > 0)
54196019 {
54206020 // System.err.println("end list " + bRep.displaylist + " for " + this);
5421
- gl.glEndList();
6021
+ display.EndList();
54226022 }
54236023 //gl.glDrawBuffer(gl.GL_BACK);
54246024 // XXX touched = false;
5425
- display.lighttouched = true; // all panes...
6025
+ Globals.lighttouched = true; // all panes...
54266026 }
54276027
54286028 touched = GetBRep() == null; // this instanceof Composite || this instanceof FileObject; // false;
....@@ -5461,12 +6061,12 @@
54616061
54626062 // frustum culling
54636063 if (CameraPane.FRUSTUM && !blocked && !IsInfinite() && GetBRep() != null // && GetBRep().VertexCount() != 1260 // default grid
5464
- && display.drawMode != CameraPane.SELECTION)
6064
+ && display.DrawMode() != iCameraPane.SELECTION)
54656065 {
5466
- if (display.drawMode == CameraPane.SHADOW)
6066
+ if (display.DrawMode() == iCameraPane.SHADOW)
54676067 {
54686068 if (!link2master // tricky to cull in shadow mode.
5469
- && GetBRep().FrustumCull(this, gl, display.lightCamera, true))
6069
+ && GetBRep().FrustumCull(this, null, display.LightCamera(), true))
54706070 {
54716071 //System.out.print("CULLED");
54726072 culled = true;
....@@ -5474,7 +6074,7 @@
54746074 }
54756075 else
54766076 //GetBRep().getBounds(v0, v1, this);
5477
- if (GetBRep().FrustumCull(this, gl, display.renderCamera, false))
6077
+ if (GetBRep().FrustumCull(this, null, display.RenderCamera(), false))
54786078 culled = true;
54796079
54806080 // LA.xformPos(v0, display.renderCamera.toScreen, v0);
....@@ -5510,11 +6110,12 @@
55106110
55116111
55126112 if (!culled)
5513
- if (display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION)
6113
+ if (display.DrawMode() == display.SELECTION || display.IsDebugSelection())
55146114 {
55156115 if (GetBRep() != null)
55166116 {
5517
- CameraPane.NextIndex(this, gl);
6117
+ display.NextIndex();
6118
+
55186119 // vertex color conflict : gl.glCallList(list);
55196120 DrawNode(display, root, selected);
55206121 if (this instanceof BezierPatch)
....@@ -5536,55 +6137,7 @@
55366137 color[2] /= 2;
55376138 gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT_AND_DIFFUSE, color, 0);
55386139 */
5539
- if (material != null)
5540
- {
5541
- materialstack[materialdepth] = material;
5542
- selectedstack[materialdepth] = selected;
5543
- cStatic.objectstack[materialdepth++] = this;
5544
- //System.out.println("material " + material);
5545
- //Applet3D.tracein(this, selected);
5546
- display.vector2buffer = projectedVertices;
5547
- if (this instanceof Camera)
5548
- {
5549
- display.options1[0] = material.shift;
5550
- //System.out.println("shift " + material.shift);
5551
- display.options1[1] = material.lightarea;
5552
- display.options1[2] = material.shadowbias;
5553
- display.options1[3] = material.aniso;
5554
- display.options1[4] = material.anisoV;
5555
- display.options2[0] = material.opacity;
5556
- display.options2[1] = material.diffuse;
5557
- display.options2[2] = material.factor;
5558
-
5559
- cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
5560
- display.options4[0] = material.cameralight/0.2f;
5561
- display.options4[1] = material.subsurface;
5562
- display.options4[2] = material.sheen;
5563
-
5564
- // if (display.CURRENTANTIALIAS > 0)
5565
- // display.options3[3] /= 4;
5566
-
5567
- /*
5568
- System.out.println("Focus = " + display.options1[0]);
5569
- System.out.println("Aperture = " + display.options1[1]);
5570
- System.out.println("ShadowBlur = " + display.options1[2]);
5571
- System.out.println("Antialiasing = " + display.options1[3]);
5572
- System.out.println("Fog = " + display.options2[0]);
5573
- System.out.println("Intensity = " + display.options2[1]);
5574
- System.out.println("Elevation = " + display.options2[2]);
5575
- /**/
5576
- } else
5577
- {
5578
- material.Draw(display, selected);
5579
- }
5580
- } else
5581
- {
5582
- if (selected && CameraPane.flash)
5583
- {
5584
- display.modelParams4[1] = 100;
5585
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
5586
- }
5587
- }
6140
+ display.PushMaterial(this, selected);
55886141
55896142 //System.out.println("call list " + list);
55906143 //System.out.println();
....@@ -5603,7 +6156,28 @@
56036156 tex = GetTextures();
56046157 }
56056158
5606
- display.BindTextures(tex, texres);
6159
+ boolean failedPigment = false;
6160
+ boolean failedBump = false;
6161
+
6162
+ try
6163
+ {
6164
+ display.BindPigmentTexture(tex, texres);
6165
+ }
6166
+ catch (Exception e)
6167
+ {
6168
+ System.err.println("FAILED: " + this);
6169
+ failedPigment = true;
6170
+ }
6171
+
6172
+ try
6173
+ {
6174
+ display.BindBumpTexture(tex, texres);
6175
+ }
6176
+ catch (Exception e)
6177
+ {
6178
+ //System.err.println("FAILED: " + this);
6179
+ failedBump = true;
6180
+ }
56076181
56086182 if (!compiled)
56096183 {
....@@ -5619,30 +6193,19 @@
56196193
56206194 // System.err.println("glCallList: " + bRep.displaylist + " for " + this);
56216195 assert(bRep.displaylist != 0);
5622
- gl.glCallList(bRep.displaylist);
6196
+ display.CallList(bRep.displaylist);
56236197 // june 2013 drawSelf(display, root, selected);
56246198 }
56256199 }
56266200 }
56276201
5628
- display.ReleaseTextures(tex);
5629
-
5630
- //if (parent != null && parent.GetMaterial() != null)
5631
- // parent.GetMaterial().Draw(display, parent.IsSelected(this));
5632
- if (material != null)
5633
- {
5634
- materialdepth -= 1;
5635
- if (materialdepth > 0)
5636
- {
5637
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
5638
- materialstack[materialdepth - 1].Draw(display, selectedstack[materialdepth - 1]);
5639
- }
5640
- //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
5641
- } else if (selected && CameraPane.flash && GetMaterial() != null)
5642
- {
5643
- display.modelParams4[1] = GetMaterial().cameralight;
5644
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
5645
- }
6202
+ if (!failedBump)
6203
+ display.ReleaseBumpTexture(tex);
6204
+
6205
+ if (!failedPigment)
6206
+ display.ReleasePigmentTexture(tex);
6207
+
6208
+ display.PopMaterial(this, selected);
56466209 }
56476210
56486211 if (this instanceof Texture || this instanceof TextureNode)
....@@ -5684,7 +6247,7 @@
56846247 // resetMasterNode();
56856248 }
56866249
5687
- void CallList(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
6250
+ void CallList(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
56886251 {
56896252 if (GetBRep() == null)
56906253 {
....@@ -5767,8 +6330,11 @@
57676330 boolean flipV = false; // true;
57686331 int texres = 0; // 0 = low, 1 = normal, 2 = high res texture
57696332
5770
- void drawSelf(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
6333
+ void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57716334 {
6335
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6336
+ return;
6337
+
57726338 if (hide)
57736339 return;
57746340 // shadow optimisation
....@@ -5826,16 +6392,7 @@
58266392 // // ??????????????????????????? Touch();
58276393 // }
58286394
5829
- if (material != null)
5830
- {
5831
- materialstack[materialdepth] = material;
5832
- selectedstack[materialdepth] = selected;
5833
- cStatic.objectstack[materialdepth++] = this;
5834
- //System.out.println("material " + material);
5835
- //Applet3D.tracein("selected ", selected);
5836
- display.vector2buffer = projectedVertices;
5837
- material.Draw(display, selected);
5838
- }
6395
+display.PushMaterial2(this, selected);
58396396
58406397 Object3D child;
58416398 boolean sel;
....@@ -5887,19 +6444,7 @@
58876444 */
58886445 //depth += 1;
58896446
5890
- if (material != null)
5891
- {
5892
- materialdepth -= 1;
5893
- if (materialdepth > 0)
5894
- {
5895
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
5896
- materialstack[materialdepth - 1].Draw(display, selectedstack[materialdepth - 1]);
5897
- }
5898
- //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
5899
- //else
5900
- //material.Draw(display, false);
5901
- }
5902
-
6447
+display.PopMaterial2(this);
59036448 /*
59046449 display.ReleaseTextures(tex);
59056450 */
....@@ -5910,10 +6455,13 @@
59106455
59116456 //static cVector min,max;
59126457
5913
- void DrawNode(CameraPane display, Object3D /*Composite*/ root, boolean selected)
6458
+ void DrawNode(iCameraPane display, Object3D /*Composite*/ root, boolean selected)
59146459 {
5915
- if (display.drawMode == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
6460
+ if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
59166461 return; // no shadow for transparent objects
6462
+
6463
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6464
+ return;
59176465
59186466 if (hide)
59196467 return;
....@@ -5955,11 +6503,12 @@
59556503 return;
59566504 }
59576505
6506
+ //bRep.GenUV(1/material.diffuseness);
59586507 // bRep.lock = true;
59596508
5960
- javax.media.opengl.GL gl = display.GetGL();
6509
+ //javax.media.opengl.GL gl = display.GetGL();
59616510
5962
- if (CameraPane.BOXMODE) // || CameraPane.movingcamera)
6511
+ if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera)
59636512 {
59646513 int fc = bRep.FaceCount();
59656514 int vc = bRep.VertexCount();
....@@ -5974,23 +6523,7 @@
59746523
59756524 bRep.getMinMax(min, max, 100);
59766525
5977
- gl.glBegin(gl.GL_LINES);
5978
-
5979
- gl.glVertex3d(min.x, min.y, min.z);
5980
- gl.glVertex3d(min.x, min.y, max.z);
5981
- gl.glVertex3d(min.x, min.y, min.z);
5982
- gl.glVertex3d(min.x, max.y, min.z);
5983
- gl.glVertex3d(min.x, min.y, min.z);
5984
- gl.glVertex3d(max.x, min.y, min.z);
5985
-
5986
- gl.glVertex3d(max.x, max.y, max.z);
5987
- gl.glVertex3d(min.x, max.y, max.z);
5988
- gl.glVertex3d(max.x, max.y, max.z);
5989
- gl.glVertex3d(max.x, min.y, max.z);
5990
- gl.glVertex3d(max.x, max.y, max.z);
5991
- gl.glVertex3d(max.x, max.y, min.z);
5992
-
5993
- gl.glEnd();
6526
+ display.DrawBox(min, max);
59946527
59956528 return;
59966529 }
....@@ -6034,7 +6567,7 @@
60346567 {
60356568 //throw new Error();
60366569
6037
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
6570
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
60386571
60396572 int[] strips = bRep.getRawIndices();
60406573
....@@ -6044,178 +6577,19 @@
60446577 new Exception().printStackTrace();
60456578 return;
60466579 }
6047
-
6048
- // TRIANGLE STRIP ARRAY
6049
- if (bRep.trimmed)
6580
+
6581
+ if (dontselect)
60506582 {
6051
- float[] v = bRep.getRawVertices();
6052
- float[] n = bRep.getRawNormals();
6053
- float[] c = bRep.getRawColors();
6054
- float[] uv = bRep.getRawUVMap();
6055
-
6056
- int count2 = 0;
6057
- int count3 = 0;
6058
-
6059
- if (n.length > 0)
6060
- {
6061
- for (int i = 0; i < strips.length; i++)
6062
- {
6063
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6064
-
6065
- /*
6066
- boolean locked = false;
6067
- float eps = 0.1f;
6068
- boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
6069
-
6070
- int dot = 0;
6071
-
6072
- if ((dot&1) == 0)
6073
- dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
6074
-
6075
- if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
6076
- gl.glTexCoord2f((float) qv.s, (float) qv.t);
6077
- else
6078
- {
6079
- locked = true;
6080
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6081
- }
6082
- //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6083
- gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
6084
- if (hasnorm)
6085
- {
6086
- //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6087
- gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
6088
- }
6089
-
6090
- if ((dot&4) == 0)
6091
- dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
6092
-
6093
- if (wrap || !locked && (dot&8) != 0)
6094
- gl.glTexCoord2f((float) rv.s, (float) rv.t);
6095
- else
6096
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6097
-
6098
- f.dot = dot;
6099
- */
6100
-
6101
- if (!selectmode)
6102
- {
6103
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6104
- {
6105
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6106
- } else
6107
- {
6108
- gl.glNormal3f(0, 0, 1);
6109
- }
6110
-
6111
- if (c != null)
6112
- //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]);
6113
- {
6114
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6115
- }
6116
- }
6117
- if (flipV)
6118
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6119
- else
6120
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6121
- //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6122
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6123
-
6124
- count2 += 2;
6125
- count3 += 3;
6126
- if (!selectmode)
6127
- {
6128
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6129
- {
6130
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6131
- } else
6132
- {
6133
- gl.glNormal3f(0, 0, 1);
6134
- }
6135
- if (c != null)
6136
- {
6137
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6138
- }
6139
- }
6140
- if (flipV)
6141
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6142
- else
6143
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6144
- //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6145
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6146
-
6147
- count2 += 2;
6148
- count3 += 3;
6149
- for (int j = 0; j < strips[i] - 2; j++)
6150
- {
6151
- //gl.glTexCoord2d(...);
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
-
6167
- if (flipV)
6168
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6169
- else
6170
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6171
- //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
6172
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6173
- count2 += 2;
6174
- count3 += 3;
6175
- }
6176
-
6177
- gl.glEnd();
6178
- }
6179
- }
6180
-
6181
- assert count3 == v.length;
6583
+ //bRep.GenerateNormalsMINE();
61826584 }
6183
- else // !trimmed
6184
- {
6185
- int count = 0;
6186
- for (int i = 0; i < strips.length; i++)
6187
- {
6188
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6189
-
6190
- Vertex p = bRep.GetVertex(bRep.indices[count++]);
6191
- Vertex q = bRep.GetVertex(bRep.indices[count++]);
6192
-
6193
- drawVertex(gl, p, selectmode);
6194
- drawVertex(gl, q, selectmode);
6195
-
6196
- for (int j = 0; j < strips[i] - 2; j++)
6197
- {
6198
- Vertex r = bRep.GetVertex(bRep.indices[count++]);
6199
-
6200
-// if (j%2 == 0)
6201
-// drawFace(p, q, r, display, null);
6202
-// else
6203
-// drawFace(p, r, q, display, null);
6204
-
6205
-// p = q;
6206
-// q = r;
6207
- drawVertex(gl, r, selectmode);
6208
- }
6209
-
6210
- gl.glEnd();
6211
- }
6212
- }
6585
+
6586
+ display.DrawGeometry(bRep, flipV, selectmode);
62136587 } else // catch (Error e)
62146588 {
62156589 // TRIANGLE ARRAY
62166590 if (IsOpaque()) // Static())
62176591 {
6218
- gl.glBegin(gl.GL_TRIANGLES);
6592
+ display.StartTriangles();
62196593 int facecount = bRep.FaceCount();
62206594 for (int i = 0; i < facecount; i++)
62216595 {
....@@ -6278,9 +6652,9 @@
62786652 // // r.norm.dot(v3) > -0.5)
62796653 // // continue;
62806654
6281
- drawFace(p, q, r, display, face);
6655
+ display.DrawFace(this, p, q, r, face);
62826656 }
6283
- gl.glEnd();
6657
+ display.EndTriangles();
62846658 }
62856659 else
62866660 {
....@@ -6309,8 +6683,8 @@
63096683 //System.out.println("SORT");
63106684
63116685 java.util.Arrays.sort(facescompare);
6312
-
6313
- gl.glBegin(gl.GL_TRIANGLES);
6686
+
6687
+ display.StartTriangles();
63146688 for (int i = 0; i < facecount; i++)
63156689 {
63166690 Face face = bRep.GetFace(facescompare[i].index);
....@@ -6322,13 +6696,14 @@
63226696 Vertex q = bRep.GetVertex(face.q);
63236697 Vertex r = bRep.GetVertex(face.r);
63246698
6325
- drawFace(p, q, r, display, face);
6699
+ display.DrawFace(this, p, q, r, face);
63266700 }
6327
- gl.glEnd();
6701
+ display.EndTriangles();
63286702 }
63296703
63306704 if (false) // live && support != null && support.bRep != null) // debug weights
63316705 {
6706
+ /*
63326707 gl.glDisable(gl.GL_LIGHTING);
63336708 float[] colorV = new float[3];
63346709
....@@ -6407,6 +6782,7 @@
64076782 // gl.glEnd();
64086783 }
64096784 }
6785
+ */
64106786 }
64116787 }
64126788
....@@ -6451,7 +6827,7 @@
64516827 center.add(r);
64526828 center.mul(1.0/3);
64536829
6454
- center.sub(CameraPane.theRenderer.eyeCamera.location);
6830
+ center.sub(Globals.theRenderer.EyeCamera().location);
64556831
64566832 distance = center.dot(center);
64576833 }
....@@ -6462,347 +6838,11 @@
64626838
64636839 transient FaceCompare[] facescompare = null;
64646840
6465
- void SetColor(CameraPane display, Vertex p0)
6466
- {
6467
- if (display.RENDERPROGRAM == 0)
6468
- {
6469
- float r = 0;
6470
- if (bRep != null)
6471
- {
6472
- if (bRep.stripified)
6473
- {
6474
- r = 1;
6475
- }
6476
- }
6477
- float g = 0;
6478
- if (bRep != null)
6479
- {
6480
- if (bRep.trimmed)
6481
- {
6482
- g = 1;
6483
- }
6484
- }
6485
- float b = 0;
6486
- if (support != null && link2master)
6487
- {
6488
- b = 1;
6489
- }
6490
- display.GetGL().glColor3f(r*p0.AO, g*p0.AO, b*p0.AO);
6491
- return;
6492
- }
6493
-
6494
- if (display.drawMode != CameraPane.SHADOW)
6495
- return;
6496
-
6497
- javax.media.opengl.GL gl = display.GetGL();
6498
-// if (true) return;
6499
-// float ao = p.AO;
6500
-//
6501
-// // if (ao == 0 && !bRep.AOdone) // transient problem!
6502
-// // ao = 1;
6503
-//
6504
-// gl.glColor4f(ao, ao, ao, 1);
6505
-
6506
-// CameraPane.selectedpoint.
6507
-// getAverage(cStatic.point1, true);
6508
- if (CameraPane.pointflow == null) // !random) // live)
6509
- {
6510
- return;
6511
- }
6512
-
6513
- cStatic.point1.set(0,0,0);
6514
- LA.xformPos(cStatic.point1, CameraPane.selectedpoint.toParent, cStatic.point1);
6515
-
6516
- cStatic.point1.sub(p0);
6517
-
6518
-
6519
-// if (marked && (p0.vertexlinks == null || support == null || support.bRep == null)) // no position delta?
6520
-// {
6521
-// return;
6522
-// }
6523
-
6524
- //if (true)
6525
- if (cStatic.point1.dot(cStatic.point1) > 0.000001)
6526
- {
6527
- return;
6528
- }
6529
-
6530
- float[] colorV = new float[3];
6531
-
6532
- if (false) // marked)
6533
- {
6534
- // debug rigging weights
6535
- for (int object = 0; object < p0.vertexlinks.length; object++)
6536
- {
6537
- float weight = p0.weights[object] / p0.totalweight;
6538
-
6539
- // if (weight < 0.1)
6540
- // {
6541
- // assert(weight == 0);
6542
- // continue;
6543
- // }
6544
-
6545
- if (p0.vertexlinks[object] == -1)
6546
- continue;
6547
-
6548
- Vertex q = support.bRep.GetVertex(p0.vertexlinks[object]);
6549
-
6550
- int color = //1 << object; //
6551
- //p.vertexlinks.length;
6552
- support.bRep.supports[p0.closestsupport].links[object];
6553
- colorV[2] += (color & 1) * weight;
6554
- colorV[1] += ((color & 2) >> 1) * weight;
6555
- colorV[0] += ((color & 4) >> 2) * weight;
6556
- }
6557
- }
6558
- else
6559
- {
6560
- if (drawingstarted)
6561
- {
6562
- // find next point
6563
- if (bRep.GetVertex(0).faceindices == null)
6564
- {
6565
- bRep.InitFaceIndices();
6566
- }
6567
-
6568
- double ymin = p0.y;
6569
-
6570
- Vertex newp = p0;
6571
-
6572
- for (int fii = 0; fii < p0.faceindices.length; fii++)
6573
- {
6574
- int fi = p0.faceindices[fii];
6575
-
6576
- if (fi == -1)
6577
- break;
6578
-
6579
- Face f = bRep.GetFace(fi);
6580
-
6581
- Vertex p = bRep.GetVertex(f.p);
6582
- Vertex q = bRep.GetVertex(f.q);
6583
- Vertex r = bRep.GetVertex(f.r);
6584
-
6585
- int swap = (int)(Math.random()*3);
6586
-
6587
-// for (int s=swap; --s>=0;)
6588
-// {
6589
-// Vertex t = p;
6590
-// p = q;
6591
-// q = r;
6592
-// r = t;
6593
-// }
6594
- if (ymin > p.y)
6595
- {
6596
- ymin = p.y;
6597
- newp = p;
6598
-// break;
6599
- }
6600
- if (ymin > q.y)
6601
- {
6602
- ymin = q.y;
6603
- newp = q;
6604
-// break;
6605
- }
6606
- if (ymin > r.y)
6607
- {
6608
- ymin = r.y;
6609
- newp = r;
6610
-// break;
6611
- }
6612
- }
6613
-
6614
- CameraPane.selectedpoint.toParent[3][0] = newp.x;
6615
- CameraPane.selectedpoint.toParent[3][1] = newp.y;
6616
- CameraPane.selectedpoint.toParent[3][2] = newp.z;
6617
-
6618
- drawingstarted = false;
6619
-
6620
- // return;
6621
- }
6622
-
6623
- if (false) // CameraPane.DRAW
6624
- {
6625
- p0.AO = colorV[0] = 2;
6626
- colorV[1] = 2;
6627
- colorV[2] = 2;
6628
- }
6629
-
6630
- CameraPane.pointflow.add(p0);
6631
- CameraPane.pointflow.Touch();
6632
- }
6633
-
6634
-// gl.glColor3f(colorV[0], colorV[1], colorV[2]);
6635
-// gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0);
6636
-// gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
6637
- }
6638
-
66396841 void Print(Vertex v)
66406842 {
66416843 //System.err.println("(" + v.x + ", " + v.y + ", " + v.z + ")");
66426844 }
66436845
6644
- void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean selectmode)
6645
- {
6646
- if (!selectmode)
6647
- {
6648
- gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
6649
- gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
6650
-
6651
- if (flipV)
6652
- gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
6653
- else
6654
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6655
- }
6656
-
6657
- gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
6658
- }
6659
-
6660
- void drawFace(Vertex pv, Vertex qv, Vertex rv,
6661
- CameraPane display, Face face)
6662
- {
6663
- if (pv.y == -10000 ||
6664
- qv.y == -10000 ||
6665
- rv.y == -10000)
6666
- return;
6667
-
6668
-// float b = f.nbiterations & 1;
6669
-// float g = (f.nbiterations>>1) & 1;
6670
-// float r = (f.nbiterations>>2) & 1;
6671
-//
6672
-// //if (f.weight == 10000)
6673
-// //{
6674
-// // r = 1; g = b = 0;
6675
-// //}
6676
-// //else
6677
-// //{
6678
-// // assert(f.weight < 10000);
6679
-// r = g = b = (float)bRep.FaceWeight(f)*100;
6680
-// if (r<0)
6681
-// assert(r>=0);
6682
-// //}
6683
-
6684
- javax.media.opengl.GL gl = display.GetGL();
6685
-
6686
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
6687
-
6688
- //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv);
6689
- if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
6690
- {
6691
- //gl.glBegin(gl.GL_TRIANGLES);
6692
- boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
6693
- if (!hasnorm)
6694
- {
6695
- // System.out.println("FUCK!!");
6696
- LA.vecSub(pv/*.pos*/, qv/*.pos*/, v0);
6697
- LA.vecSub(pv/*.pos*/, rv/*.pos*/, v1);
6698
- LA.vecCross(v0, v1, v2);
6699
- LA.vecNormalize(v2);
6700
- gl.glNormal3f((float) v2.x, (float) v2.y, (float) v2.z);
6701
- }
6702
-
6703
- if (hasnorm)
6704
- {
6705
-// if (!pv.norm.normalized())
6706
-// assert(pv.norm.normalized());
6707
-
6708
- //System.out.println("normalp = " + pv.norm.x + ", " + pv.norm.y + ", " + pv.norm.z);
6709
- gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
6710
- }
6711
- gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
6712
- SetColor(display, pv);
6713
- //gl.glColor4f(r, g, b, 1);
6714
- //gl.glColor4f(pv.boundary, pv.boundary, pv.boundary, 1);
6715
- if (flipV)
6716
- gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
6717
- else
6718
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6719
- //System.out.println("vertexp = " + pv.x + ", " + pv.y + ", " + pv.z);
6720
- gl.glVertex3f((float) pv./*pos.*/x, (float) pv./*pos.*/y, (float) pv./*pos.*/z);
6721
-// Print(pv);
6722
- if (hasnorm)
6723
- {
6724
-// assert(qv.norm.normalized());
6725
- //System.out.println("normalq = " + qv.norm.x + ", " + qv.norm.y + ", " + qv.norm.z);
6726
- gl.glNormal3f((float) qv.norm.x, (float) qv.norm.y, (float) qv.norm.z);
6727
- }
6728
- //System.out.println("vertexq = " + qv.s + ", " + qv.t);
6729
- // boolean locked = false;
6730
- // float eps = 0.1f;
6731
- // boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
6732
-
6733
- // int dot = 0; //*/ (int)f.dot;
6734
-
6735
- // if ((dot&1) == 0)
6736
- // dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
6737
-
6738
- // if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
6739
- if (flipV)
6740
- gl.glTexCoord2f((float) qv.s, 1-(float) qv.t);
6741
- else
6742
- gl.glTexCoord2f((float) qv.s, (float) qv.t);
6743
- // else
6744
- // {
6745
- // locked = true;
6746
- // gl.glTexCoord2f((float) pv.s, (float) pv.t);
6747
- // }
6748
- gl.glColor4f(qv.AO, qv.AO, qv.AO, 1);
6749
- SetColor(display, qv);
6750
- //gl.glColor4f(r, g, b, 1);
6751
- //gl.glColor4f(qv.boundary, qv.boundary, qv.boundary, 1);
6752
- //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6753
- gl.glVertex3f((float) qv./*pos.*/x, (float) qv./*pos.*/y, (float) qv./*pos.*/z);
6754
-// Print(qv);
6755
- if (hasnorm)
6756
- {
6757
-// assert(rv.norm.normalized());
6758
- //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6759
- gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
6760
- }
6761
-
6762
- // if ((dot&4) == 0)
6763
- // dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
6764
-
6765
- // if (wrap || !locked && (dot&8) != 0)
6766
- if (flipV)
6767
- gl.glTexCoord2f((float) rv.s, 1-(float) rv.t);
6768
- else
6769
- gl.glTexCoord2f((float) rv.s, (float) rv.t);
6770
- // else
6771
- // gl.glTexCoord2f((float) pv.s, (float) pv.t);
6772
-
6773
- // f.dot = dot;
6774
-
6775
- gl.glColor4f(rv.AO, rv.AO, rv.AO, 1);
6776
- SetColor(display, rv);
6777
- //gl.glColor4f(r, g, b, 1);
6778
- //gl.glColor4f(rv.boundary, rv.boundary, rv.boundary, 1);
6779
- //System.out.println("vertexr = " + rv.x + ", " + rv.y + ", " + rv.z);
6780
- gl.glVertex3f((float) rv./*pos.*/x, (float) rv./*pos.*/y, (float) rv./*pos.*/z);
6781
-// Print(rv);
6782
- //gl.glEnd();
6783
- }
6784
- else
6785
- {
6786
- gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
6787
- gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
6788
- gl.glVertex3f((float) rv.x, (float) rv.y, (float) rv.z);
6789
-
6790
- }
6791
-
6792
- if (false) // (attributes & WIREFRAME) != 0)
6793
- {
6794
- gl.glDisable(gl.GL_LIGHTING);
6795
-
6796
- gl.glBegin(gl.GL_LINE_LOOP);
6797
- gl.glVertex3d(pv./*pos.*/x, pv./*pos.*/y, pv./*pos.*/z);
6798
- gl.glVertex3d(qv./*pos.*/x, qv./*pos.*/y, qv./*pos.*/z);
6799
- gl.glVertex3d(rv./*pos.*/x, rv./*pos.*/y, rv./*pos.*/z);
6800
- gl.glEnd();
6801
-
6802
- gl.glEnable(gl.GL_LIGHTING);
6803
- }
6804
- }
6805
-
68066846 void drawSelf(ClickInfo info, int level, boolean select)
68076847 {
68086848 if (bRep == null)
....@@ -7326,20 +7366,23 @@
73267366 }
73277367 }
73287368
7329
- protected void calcHotSpot(cVector in, ClickInfo info, Point outPt, Rectangle outRec)
7369
+ static ClickInfo clickInfo = new ClickInfo();
7370
+
7371
+ protected void calcHotSpot(cVector in, //ClickInfo clickInfo,
7372
+ Point outPt, Rectangle outRec)
73307373 {
7331
- int hc = info.bounds.x + info.bounds.width / 2;
7332
- int vc = info.bounds.y + info.bounds.height / 2;
7333
- double[][] toscreen = info.toScreen;
7374
+ int hc = clickInfo.bounds.x + clickInfo.bounds.width / 2;
7375
+ int vc = clickInfo.bounds.y + clickInfo.bounds.height / 2;
7376
+ double[][] toscreen = clickInfo.toScreen;
73347377 if (toscreen == null)
73357378 {
7336
- toscreen = new Camera(info.camera.viewCode).toScreen;
7379
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
73377380 }
73387381 cVector vec = in;
73397382 LA.xformPos(in, toscreen, in);
73407383 //System.out.println("Distance = " + info.camera.Distance());
7341
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
7342
- vec.y *= 100 * info.camera.SCALE / info.camera.Distance();
7384
+ vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
7385
+ vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
73437386 outPt.x = hc + (int) vec.x;
73447387 outPt.y = vc - (int) vec.y;
73457388 outRec.x = outPt.x - 3;
....@@ -7347,15 +7390,18 @@
73477390 outRec.width = outRec.height = 6;
73487391 }
73497392
7350
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7393
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7394
+ )
73517395 {
73527396 Point pt = new Point(0, 0);
73537397 Rectangle rec = new Rectangle();
7354
- calcHotSpot(in, info, pt, rec);
7398
+ calcHotSpot(in, //clickInfo,
7399
+ pt, rec);
73557400 return rec;
73567401 }
73577402
7358
- void drawEditHandles0(ClickInfo info, int level)
7403
+ void drawEditHandles0(//ClickInfo clickInfo,
7404
+ int level)
73597405 {
73607406 if (level == 0)
73617407 {
....@@ -7364,98 +7410,104 @@
73647410 {
73657411 cVector origin = new cVector();
73667412 //LA.xformPos(origin, toParent, origin);
7367
- Rectangle spot = calcHotSpot(origin, info);
7413
+ if (this.clickInfo == null)
7414
+ this.clickInfo = new ClickInfo();
7415
+
7416
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
73687417 Rectangle boundary = new Rectangle();
73697418 boundary.x = spot.x - 30;
73707419 boundary.y = spot.y - 30;
73717420 boundary.width = spot.width + 60;
73727421 boundary.height = spot.height + 60;
7373
- info.g.setColor(Color.red);
7422
+ clickInfo.g.setColor(Color.white);
73747423 int spotw = spot.x + spot.width;
73757424 int spoth = spot.y + spot.height;
7376
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7377
- if (CameraPane.Xmin > spot.x)
7378
- {
7379
- CameraPane.Xmin = spot.x;
7380
- }
7381
- if (CameraPane.Xmax < spotw)
7382
- {
7383
- CameraPane.Xmax = spotw;
7384
- }
7385
- if (CameraPane.Ymin > spot.y)
7386
- {
7387
- CameraPane.Ymin = spot.y;
7388
- }
7389
- if (CameraPane.Ymax < spoth)
7390
- {
7391
- CameraPane.Ymax = spoth;
7392
- }
7393
- spot.translate(32, 32);
7425
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7426
+// if (CameraPane.Xmin > spot.x)
7427
+// {
7428
+// CameraPane.Xmin = spot.x;
7429
+// }
7430
+// if (CameraPane.Xmax < spotw)
7431
+// {
7432
+// CameraPane.Xmax = spotw;
7433
+// }
7434
+// if (CameraPane.Ymin > spot.y)
7435
+// {
7436
+// CameraPane.Ymin = spot.y;
7437
+// }
7438
+// if (CameraPane.Ymax < spoth)
7439
+// {
7440
+// CameraPane.Ymax = spoth;
7441
+// }
7442
+// if (CameraPane.Xmin > spot.x)
7443
+// {
7444
+// CameraPane.Xmin = spot.x;
7445
+// }
7446
+// if (CameraPane.Xmax < spotw)
7447
+// {
7448
+// CameraPane.Xmax = spotw;
7449
+// }
7450
+// if (CameraPane.Ymin > spot.y)
7451
+// {
7452
+// CameraPane.Ymin = spot.y;
7453
+// }
7454
+// if (CameraPane.Ymax < spoth)
7455
+// {
7456
+// CameraPane.Ymax = spoth;
7457
+// }
7458
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7459
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
7460
+ spot.translate(32, 0);
7461
+ clickInfo.g.setColor(Color.yellow);
7462
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7463
+
7464
+ spot.translate(32, 64);
73947465 spotw = spot.x + spot.width;
73957466 spoth = spot.y + spot.height;
7396
- info.g.setColor(Color.blue);
7397
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7398
- if (CameraPane.Xmin > spot.x)
7399
- {
7400
- CameraPane.Xmin = spot.x;
7401
- }
7402
- if (CameraPane.Xmax < spotw)
7403
- {
7404
- CameraPane.Xmax = spotw;
7405
- }
7406
- if (CameraPane.Ymin > spot.y)
7407
- {
7408
- CameraPane.Ymin = spot.y;
7409
- }
7410
- if (CameraPane.Ymax < spoth)
7411
- {
7412
- CameraPane.Ymax = spoth;
7413
- }
7414
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7415
- info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7416
- spot.translate(0, -32);
7417
- info.g.setColor(Color.green);
7418
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7419
- if (CameraPane.Xmin > spot.x)
7420
- {
7421
- CameraPane.Xmin = spot.x;
7422
- }
7423
- if (CameraPane.Xmax < spotw)
7424
- {
7425
- CameraPane.Xmax = spotw;
7426
- }
7427
- if (CameraPane.Ymin > spot.y)
7428
- {
7429
- CameraPane.Ymin = spot.y;
7430
- }
7431
- if (CameraPane.Ymax < spoth)
7432
- {
7433
- CameraPane.Ymax = spoth;
7434
- }
7435
- info.g.drawArc(boundary.x, boundary.y,
7436
- boundary.width, boundary.height, 0, 360);
7467
+ clickInfo.g.setColor(Color.cyan);
7468
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7469
+// if (CameraPane.Xmin > spot.x)
7470
+// {
7471
+// CameraPane.Xmin = spot.x;
7472
+// }
7473
+// if (CameraPane.Xmax < spotw)
7474
+// {
7475
+// CameraPane.Xmax = spotw;
7476
+// }
7477
+// if (CameraPane.Ymin > spot.y)
7478
+// {
7479
+// CameraPane.Ymin = spot.y;
7480
+// }
7481
+// if (CameraPane.Ymax < spoth)
7482
+// {
7483
+// CameraPane.Ymax = spoth;
7484
+// }
7485
+ clickInfo.g.setColor(Color.green);
7486
+ clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
7487
+ (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
74377488 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
7438
- if (CameraPane.Xmin > boundary.x)
7439
- {
7440
- CameraPane.Xmin = boundary.x;
7441
- }
7442
- if (CameraPane.Xmax < boundary.x + boundary.width)
7443
- {
7444
- CameraPane.Xmax = boundary.x + boundary.width;
7445
- }
7446
- if (CameraPane.Ymin > boundary.y)
7447
- {
7448
- CameraPane.Ymin = boundary.y;
7449
- }
7450
- if (CameraPane.Ymax < boundary.y + boundary.height)
7451
- {
7452
- CameraPane.Ymax = boundary.y + boundary.height;
7453
- }
7489
+// if (CameraPane.Xmin > boundary.x)
7490
+// {
7491
+// CameraPane.Xmin = boundary.x;
7492
+// }
7493
+// if (CameraPane.Xmax < boundary.x + boundary.width)
7494
+// {
7495
+// CameraPane.Xmax = boundary.x + boundary.width;
7496
+// }
7497
+// if (CameraPane.Ymin > boundary.y)
7498
+// {
7499
+// CameraPane.Ymin = boundary.y;
7500
+// }
7501
+// if (CameraPane.Ymax < boundary.y + boundary.height)
7502
+// {
7503
+// CameraPane.Ymax = boundary.y + boundary.height;
7504
+// }
74547505 return;
74557506 }
74567507 }
74577508
7458
- boolean doEditClick0(ClickInfo info, int level)
7509
+ boolean doEditClick0(//ClickInfo clickInfo,
7510
+ int level)
74597511 {
74607512 if (level == 0)
74617513 {
....@@ -7464,10 +7516,10 @@
74647516
74657517 boolean retval = false;
74667518
7467
- startX = info.x;
7468
- startY = info.y;
7519
+ startX = clickInfo.x;
7520
+ startY = clickInfo.y;
74697521
7470
- hitSomething = 0;
7522
+ hitSomething = -1;
74717523 cVector origin = new cVector();
74727524 //LA.xformPos(origin, toParent, origin);
74737525 Rectangle spot = new Rectangle();
....@@ -7475,22 +7527,53 @@
74757527 {
74767528 centerPt = new Point(0, 0);
74777529 }
7478
- calcHotSpot(origin, info, centerPt, spot);
7479
- if (spot.contains(info.x, info.y))
7530
+ calcHotSpot(origin, //info,
7531
+ centerPt, spot);
7532
+ if (spot.contains(clickInfo.x, clickInfo.y))
74807533 {
74817534 hitSomething = hitCenter;
74827535 retval = true;
74837536 }
74847537 spot.translate(32, 0);
7485
- if (spot.contains(info.x, info.y))
7538
+ if (spot.contains(clickInfo.x, clickInfo.y))
74867539 {
74877540 hitSomething = hitRotate;
74887541 retval = true;
74897542 }
74907543 spot.translate(0, 32);
7491
- if (spot.contains(info.x, info.y))
7544
+ spot.translate(32, 0);
7545
+ spot.translate(0, 32);
7546
+ if (spot.contains(clickInfo.x, clickInfo.y))
74927547 {
74937548 hitSomething = hitScale;
7549
+
7550
+ double scale = 0.005f * clickInfo.camera.Distance();
7551
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
7552
+ double sign = 1;
7553
+ if (hScale < 0)
7554
+ {
7555
+ sign = -1;
7556
+ }
7557
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
7558
+ if (hScale < 0.01)
7559
+ {
7560
+ //hScale = 0.01;
7561
+ }
7562
+
7563
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
7564
+ sign = 1;
7565
+ if (vScale < 0)
7566
+ {
7567
+ sign = -1;
7568
+ }
7569
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
7570
+ if (vScale < 0.01)
7571
+ {
7572
+ //vScale = 0.01;
7573
+ }
7574
+
7575
+ clickInfo.scale = Math.sqrt(hScale*hScale + vScale*vScale);
7576
+
74947577 retval = true;
74957578 }
74967579
....@@ -7500,7 +7583,7 @@
75007583 }
75017584
75027585 //System.out.println("info.modifiers = " + info.modifiers);
7503
- modified = (info.modifiers & CameraPane.META) != 0;
7586
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
75047587 //System.out.println("modified = " + modified);
75057588 //new Exception().printStackTrace();
75067589 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7528,7 +7611,8 @@
75287611 return true;
75297612 }
75307613
7531
- void doEditDrag0(ClickInfo info)
7614
+ void doEditDrag0(//ClickInfo info,
7615
+ boolean opposite)
75327616 {
75337617 if (hitSomething == 0)
75347618 {
....@@ -7542,7 +7626,8 @@
75427626
75437627 //System.out.println("hitSomething = " + hitSomething);
75447628
7545
- double scale = 0.005f * info.camera.Distance();
7629
+ double scale = 0.005f * clickInfo.camera.Distance();
7630
+
75467631 cVector xlate = new cVector();
75477632 //cVector xlate2 = new cVector();
75487633 switch (hitSomething)
....@@ -7553,9 +7638,9 @@
75537638
75547639 case hitCenter: // Translate
75557640
7556
- scale *= 0.05f * info.pane.theRenderer.renderCamera.Distance();
7641
+ scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
75577642
7558
- if (modified)
7643
+ if (modified || opposite)
75597644 {
75607645 //assert(false);
75617646 /*
....@@ -7575,8 +7660,8 @@
75757660 toParent[3][i] = xlate.get(i);
75767661 LA.matInvert(toParent, fromParent);
75777662 */
7578
- cVector delta = LA.newVector(0, 0, startY - info.y);
7579
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7663
+ cVector delta = LA.newVector(0, 0, startY - clickInfo.y);
7664
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
75807665
75817666 LA.matCopy(startMat, toParent);
75827667 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7585,7 +7670,7 @@
75857670 } else
75867671 {
75877672 //LA.xformDir(delta, info.camera.fromScreen, delta);
7588
- cVector up = new cVector(info.camera.up);
7673
+ cVector up = new cVector(clickInfo.camera.up);
75897674 cVector away = new cVector();
75907675 //cVector right2 = new cVector();
75917676 //LA.vecCross(up, cVector.Z, right);
....@@ -7601,20 +7686,20 @@
76017686 }
76027687 LA.xformDir(up, ClickInfo.matbuffer, up);
76037688 // if (!CameraPane.LOCALTRANSFORM)
7604
- LA.xformDir(up, info.pane.theRenderer.renderCamera.toScreen, up);
7605
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7689
+ LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7690
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
76067691 // if (!CameraPane.LOCALTRANSFORM)
7607
- LA.xformDir(away, info.pane.theRenderer.renderCamera.toScreen, away);
7692
+ LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
76087693 //LA.vecCross(up, cVector.Z, right2);
76097694
7610
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7695
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
76117696
76127697 //System.out.println("DELTA0 = " + delta);
76137698 //System.out.println("AWAY = " + info.camera.away);
76147699 //System.out.println("UP = " + info.camera.up);
76157700 if (away.z > 0)
76167701 {
7617
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7702
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
76187703 {
76197704 delta.x = -delta.x;
76207705 } else
....@@ -7629,7 +7714,7 @@
76297714 //System.out.println("DELTA1 = " + delta);
76307715 LA.xformDir(delta, ClickInfo.matbuffer, delta);
76317716 //System.out.println("DELTA2 = " + delta);
7632
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7717
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
76337718 LA.matCopy(startMat, toParent);
76347719 //System.out.println("DELTA3 = " + delta);
76357720 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7639,8 +7724,8 @@
76397724 break;
76407725
76417726 case hitRotate: // rotate
7642
- int dx = info.x - centerPt.x;
7643
- int dy = -(info.y - centerPt.y);
7727
+ int dx = clickInfo.x - centerPt.x;
7728
+ int dy = -(clickInfo.y - centerPt.y);
76447729 double angle = (double) Math.atan2(dx, dy);
76457730 angle = -(1.570796 - angle);
76467731
....@@ -7649,6 +7734,7 @@
76497734
76507735 if (modified)
76517736 {
7737
+ // Rotate 90 degrees
76527738 angle /= (Math.PI / 4);
76537739 angle = Math.floor(angle + 0.5);
76547740 angle *= (Math.PI / 4);
....@@ -7662,7 +7748,7 @@
76627748 }
76637749 /**/
76647750
7665
- switch (info.pane.renderCamera.viewCode)
7751
+ switch (clickInfo.pane.RenderCamera().viewCode)
76667752 {
76677753 case 1: // '\001'
76687754 LA.matZRotate(toParent, angle);
....@@ -7689,26 +7775,30 @@
76897775 break;
76907776
76917777 case hitScale: // scale
7692
- double hScale = (double) (info.x - centerPt.x) / 32;
7778
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
7779
+ double sign = 1;
7780
+ if (hScale < 0)
7781
+ {
7782
+ sign = -1;
7783
+ }
7784
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
76937785 if (hScale < 0.01)
76947786 {
7695
- hScale = 0.01;
7787
+ //hScale = 0.01;
76967788 }
7697
- hScale = Math.pow(hScale, scale * 50);
7698
- if (hScale < 0.01)
7789
+
7790
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
7791
+ sign = 1;
7792
+ if (vScale < 0)
76997793 {
7700
- hScale = 0.01;
7794
+ sign = -1;
77017795 }
7702
- double vScale = (double) (info.y - centerPt.y) / 32;
7796
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
77037797 if (vScale < 0.01)
77047798 {
7705
- vScale = 0.01;
7799
+ //vScale = 0.01;
77067800 }
7707
- vScale = Math.pow(vScale, scale * 50);
7708
- if (vScale < 0.01)
7709
- {
7710
- vScale = 0.01;
7711
- }
7801
+
77127802 LA.matCopy(startMat, toParent);
77137803 /**/
77147804 for (int i = 0; i < 3; i++)
....@@ -7718,39 +7808,56 @@
77187808 }
77197809 /**/
77207810
7721
- switch (info.pane.renderCamera.viewCode)
7811
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
7812
+
7813
+ if (totalScale < 0.01)
7814
+ {
7815
+ totalScale = 0.01;
7816
+ }
7817
+
7818
+ switch (clickInfo.pane.RenderCamera().viewCode)
77227819 {
77237820 case 3: // '\001'
7724
- if (modified)
7821
+ if (modified || opposite)
77257822 {
7823
+ if (modified && opposite)
7824
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7825
+ else
77267826 //LA.matScale(toParent, 1, hScale, vScale);
7727
- LA.matScale(toParent, vScale, 1, 1);
7827
+ LA.matScale(toParent, totalScale, 1, 1);
77287828 } // vScale, 1);
77297829 else
77307830 {
7731
- LA.matScale(toParent, vScale, vScale, vScale);
7831
+ // EXCEPTION!
7832
+ LA.matScale(toParent, 1, totalScale, totalScale);
77327833 } // vScale, 1);
77337834 break;
77347835
77357836 case 2: // '\002'
7736
- if (modified)
7837
+ if (modified || opposite)
77377838 {
7738
- //LA.matScale(toParent, hScale, 1, vScale);
7739
- LA.matScale(toParent, 1, vScale, 1);
7839
+ if (modified && opposite)
7840
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7841
+ else
7842
+ //LA.matScale(toParent, hScale, 1, vScale);
7843
+ LA.matScale(toParent, 1, totalScale, 1);
77407844 } else
77417845 {
7742
- LA.matScale(toParent, vScale, 1, vScale);
7846
+ LA.matScale(toParent, totalScale, 1, totalScale);
77437847 }
77447848 break;
77457849
77467850 case 1: // '\003'
7747
- if (modified)
7851
+ if (modified || opposite)
77487852 {
7749
- //LA.matScale(toParent, hScale, vScale, 1);
7750
- LA.matScale(toParent, 1, 1, vScale);
7853
+ if (modified && opposite)
7854
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7855
+ else
7856
+ //LA.matScale(toParent, hScale, vScale, 1);
7857
+ LA.matScale(toParent, 1, 1, totalScale);
77517858 } else
77527859 {
7753
- LA.matScale(toParent, vScale, vScale, 1);
7860
+ LA.matScale(toParent, totalScale, totalScale, 1);
77547861 }
77557862 break;
77567863 }
....@@ -7784,7 +7891,7 @@
77847891 } // NEW ...
77857892
77867893
7787
- info.pane.repaint();
7894
+ clickInfo.pane.repaint();
77887895 }
77897896
77907897 boolean overflow = false;
....@@ -7883,14 +7990,22 @@
78837990 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
78847991 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
78857992 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7993
+
7994
+ String objname;
7995
+
78867996 if (false) //parent != null)
78877997 {
7888
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7998
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
78897999 } else
78908000 {
7891
- return GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ") ")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ +System.identityHashCode(this);
8001
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
78928002 } // + super.toString();
78938003 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
8004
+
8005
+ if (!Globals.ADVANCED)
8006
+ return objname;
8007
+
8008
+ return objname + " " + System.identityHashCode(this);
78948009 }
78958010
78968011 public int hashCode()
....@@ -7946,6 +8061,7 @@
79468061 objectUI.closeUI();
79478062 if (editWindow != null)
79488063 {
8064
+ editWindow.ctrlPanel.FlushUI();
79498065 editWindow.refreshContents();
79508066 } // ? new
79518067 objectUI = null;
....@@ -7954,6 +8070,10 @@
79548070 {
79558071 editWindow = null;
79568072 } // ?
8073
+ }
8074
+ else
8075
+ {
8076
+ //editWindow.closeUI();
79578077 }
79588078 }
79598079
....@@ -7966,7 +8086,7 @@
79668086 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
79678087
79688088 Object3D /*Composite*/ parent;
7969
- Object3D /*Composite*/ fileparent;
8089
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
79708090
79718091 double[][] toParent; // dynamic matrix
79728092 double[][] fromParent;
....@@ -8081,7 +8201,7 @@
80818201 {
80828202 assert(bRep != null);
80838203 if (!(support instanceof GenericJoint)) // support.bRep != null)
8084
- GrafreeD.Assert(support.bRep == bRep.support);
8204
+ Grafreed.Assert(support.bRep == bRep.support);
80858205 }
80868206 else
80878207 {
....@@ -8112,6 +8232,10 @@
81128232 }
81138233
81148234 transient ObjEditor editWindow;
8235
+ transient ObjEditor manipWindow;
8236
+
8237
+ transient boolean pinned;
8238
+
81158239 transient ObjectUI objectUI;
81168240 public static int povDepth = 0;
81178241 private static cVector tbMin = new cVector();
....@@ -8130,9 +8254,9 @@
81308254 private static cVector edge2 = new cVector();
81318255 //private static cVector norm = new cVector();
81328256 /*transient private*/ int hitSomething;
8133
- private static final int hitCenter = 1;
8134
- private static final int hitScale = 2;
8135
- private static final int hitRotate = 3;
8257
+ static final int hitCenter = 1;
8258
+ static final int hitScale = 2;
8259
+ static final int hitRotate = 3;
81368260 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
81378261 /*transient*/ private Point centerPt;
81388262 /*transient*/ private int startX;
....@@ -8164,6 +8288,8 @@
81648288 {
81658289 Object3D targ = this;
81668290
8291
+ targ.NORMALPUSH = obj.NORMALPUSH;
8292
+
81678293 if (obj.material != null)
81688294 {
81698295 if ((mask&MATERIAL)!=0) // ==(COLOR|MATERIAL))