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;
....@@ -286,6 +455,8 @@
286455 }
287456
288457 boolean live = false;
458
+ transient boolean keepdontselect;
459
+ boolean dontselect = false;
289460 boolean hide = false;
290461 boolean link2master = false; // performs reset support/master at each frame
291462 boolean marked = false; // animation node
....@@ -295,6 +466,8 @@
295466 boolean random = false;
296467 boolean speedup = false;
297468 boolean rewind = false;
469
+
470
+ float NORMALPUSH = 0;
298471
299472 Object3D support;
300473
....@@ -415,16 +588,16 @@
415588 {
416589 Object3D copy = this;
417590
418
- Camera parentcam = CameraPane.theRenderer.manipCamera;
591
+ Camera parentcam = Globals.theRenderer.ManipCamera();
419592
420
- if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[0])
593
+ if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[0])
421594 {
422
- parentcam = CameraPane.theRenderer.cameras[1];
595
+ parentcam = Globals.theRenderer.Cameras()[1];
423596 }
424597
425
- if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[1])
598
+ if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[1])
426599 {
427
- parentcam = CameraPane.theRenderer.cameras[0];
600
+ parentcam = Globals.theRenderer.Cameras()[0];
428601 }
429602
430603 if (this == parentcam)
....@@ -432,7 +605,7 @@
432605 //assert(this instanceof Camera);
433606
434607 for (int count = parentcam.GetTransformCount(); --count>=0;)
435
- LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.toParent, CameraPane.theRenderer.targetLookAt);
608
+ LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.toParent, Globals.theRenderer.TargetLookAt());
436609 }
437610
438611 copy.marked ^= true;
....@@ -452,7 +625,7 @@
452625 //assert(this instanceof Camera);
453626
454627 for (int count = parentcam.GetTransformCount(); --count>=0;)
455
- LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.fromParent, CameraPane.theRenderer.targetLookAt);
628
+ LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.fromParent, Globals.theRenderer.TargetLookAt());
456629 }
457630
458631 copy.Touch(); // display list issue
....@@ -465,12 +638,14 @@
465638 toParent = LA.newMatrix();
466639 fromParent = LA.newMatrix();
467640 }
641
+
468642 if (toParentMarked == null)
469643 {
470644 if (maxcount != 1)
471645 {
472646 new Exception().printStackTrace();
473647 }
648
+
474649 toParentMarked = LA.newMatrix();
475650 fromParentMarked = LA.newMatrix();
476651 }
....@@ -587,7 +762,7 @@
587762 return;
588763 }
589764
590
- if (CameraPane.fromscript)
765
+ if (Globals.fromscript)
591766 {
592767 transformcount = 0;
593768 return;
....@@ -745,7 +920,7 @@
745920
746921 int GetTransformCount()
747922 {
748
- // marde pour serialization de Texture
923
+ // patch pour serialization de Texture
749924 resetmaxcount();
750925 resettransformcount();
751926 resetstep();
....@@ -758,7 +933,7 @@
758933 if (step == 0)
759934 step = 1;
760935 if (maxcount == 0)
761
- maxcount = 2048; // 4;
936
+ maxcount = 128; // 2048; // 4;
762937 // if (acceleration == 0)
763938 // acceleration = 10;
764939 if (delay == 0) // serial
....@@ -779,9 +954,12 @@
779954 // factor = CameraPane.STEP;
780955 // }
781956
782
- 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)
783961 {
784
- currentframe = CameraPane.framecount;
962
+ currentframe = Globals.framecount;
785963
786964 // System.err.println("transformcount = " + transformcount);
787965 // System.err.println("factor = " + factor);
....@@ -790,7 +968,8 @@
790968
791969 boolean changedir = random && Math.random() < 0.01; // && !link2master;
792970
793
- if (transformcount*factor > maxcount || (step == 1 && changedir))
971
+ if (transformcount*factor >= maxcount && (rewind || random) ||
972
+ (step == 1 && changedir))
794973 {
795974 countdown = 1;
796975 delay = speedup?8:1;
....@@ -862,6 +1041,10 @@
8621041 if (material == null || material.multiply)
8631042 return true;
8641043
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.
8651048 return material.opacity > 0.99;
8661049 }
8671050
....@@ -893,6 +1076,11 @@
8931076 fromParent = null; // LA.newMatrix();
8941077 bRep = null; // new BoundaryRep();
8951078
1079
+ if (oname != null && oname.equals("LeftHand"))
1080
+ {
1081
+ name = oname;
1082
+ }
1083
+
8961084 /*
8971085 float hue = (float)Math.random();
8981086 Color col;
....@@ -935,7 +1123,7 @@
9351123
9361124 public Object clone()
9371125 {
938
- return GrafreeD.clone(this);
1126
+ return Grafreed.clone(this);
9391127 }
9401128
9411129 Object3D copyExpand()
....@@ -1257,6 +1445,7 @@
12571445 toParent = LA.newMatrix();
12581446 fromParent = LA.newMatrix();
12591447 }
1448
+
12601449 LA.matCopy(other.toParent, toParent);
12611450 LA.matCopy(other.fromParent, fromParent);
12621451
....@@ -1451,7 +1640,7 @@
14511640 BoundaryRep.SEUIL = other.material.cameralight;
14521641
14531642 // Set default to 0.1
1454
- BoundaryRep.SEUIL /= 2;
1643
+ BoundaryRep.SEUIL /= 4; // 2;
14551644 System.out.println("SEUIL = " + BoundaryRep.SEUIL);
14561645 }
14571646
....@@ -1710,7 +1899,7 @@
17101899 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17111900 o.bRep = transientrep;
17121901 if (clone)
1713
- o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
1902
+ o.bRep = (BoundaryRep) Grafreed.clone(transientrep);
17141903 o.CreateMaterial();
17151904 o.SetAttributes(this, -1);
17161905 //parent
....@@ -1723,7 +1912,7 @@
17231912 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17241913 o.bRep = bRep;
17251914 if (clone)
1726
- o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
1915
+ o.bRep = (BoundaryRep) Grafreed.clone(bRep);
17271916 o.CreateMaterial();
17281917 //o.overwriteThis(this, -1);
17291918 o.SetAttributes(this, -1);
....@@ -1810,12 +1999,15 @@
18101999 if (obj.name == null)
18112000 continue; // can't be a null one
18122001
2002
+ // Try perfect match first.
18132003 if (n.equals(obj.name))
18142004 {
18152005 theobj = obj;
18162006 count++;
18172007 }
18182008 }
2009
+
2010
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18192011
18202012 if (count != 1)
18212013 for (int i=Size(); --i>=0;)
....@@ -2130,15 +2322,8 @@
21302322 if (/*parent != null &&*/ material == null)
21312323 {
21322324 material = new cMaterial(GetMaterial());
2133
- if (projectedVertices == null || projectedVertices.length <= 2)
2134
- {
2135
- projectedVertices = new Object3D.cVector2[3];
2136
- }
2137
- for (int i = 0; i < 3; i++)
2138
- {
2139
- projectedVertices[i] = new cVector2(); // Others
2140
- }
2141
- projectedVertices[0].x = 100; // bump
2325
+
2326
+ InitOthers();
21422327
21432328 if (this instanceof Camera)
21442329 {
....@@ -2282,12 +2467,22 @@
22822467 }
22832468 */
22842469 }
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
+ }
22852479 }
22862480
22872481 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
22882482 {
22892483 if (newWindow)
22902484 {
2485
+ new Exception().printStackTrace();
22912486 System.exit(0);
22922487 if (parent != null)
22932488 {
....@@ -2322,6 +2517,14 @@
23222517 {
23232518 editWindow.refreshContents();
23242519 }
2520
+ else
2521
+ {
2522
+ if (manipWindow != null)
2523
+ {
2524
+ manipWindow.refreshContents();
2525
+ }
2526
+ }
2527
+
23252528 //if (parent != null)
23262529 //parent.refreshEditWindow();
23272530 }
....@@ -2401,7 +2604,8 @@
24012604 private static final int editSelf = 1;
24022605 private static final int editChild = 2;
24032606
2404
- void drawEditHandles(ClickInfo info, int level)
2607
+ void drawEditHandles(//ClickInfo info,
2608
+ int level)
24052609 {
24062610 if (level == 0)
24072611 {
....@@ -2409,7 +2613,8 @@
24092613 return;
24102614
24112615 Object3D selectee;
2412
- 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))
24132618 {
24142619 selectee = (Object3D) e.nextElement();
24152620 }
....@@ -2417,19 +2622,22 @@
24172622 } else
24182623 {
24192624 //super.
2420
- drawEditHandles0(info, level + 1);
2625
+ drawEditHandles0(//info,
2626
+ level + 1);
24212627 }
24222628 }
24232629
2424
- boolean doEditClick(ClickInfo info, int level)
2630
+ boolean doEditClick(//ClickInfo info,
2631
+ int level)
24252632 {
24262633 doSomething = 0;
24272634 if (level == 0)
24282635 {
2429
- return doParentClick(info);
2636
+ return doParentClick(); //info);
24302637 }
24312638 if (//super.
2432
- doEditClick0(info, level))
2639
+ doEditClick0(//info,
2640
+ level))
24332641 {
24342642 doSomething = 1;
24352643 return true;
....@@ -2439,7 +2647,7 @@
24392647 }
24402648 }
24412649
2442
- boolean doParentClick(ClickInfo info)
2650
+ boolean doParentClick() //ClickInfo info)
24432651 {
24442652 if (selection == null)
24452653 {
....@@ -2452,7 +2660,8 @@
24522660 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
24532661 {
24542662 Object3D selectee = (Object3D) e.nextElement();
2455
- if (selectee.doEditClick(info, 1))
2663
+ if (selectee.doEditClick(//info,
2664
+ 1))
24562665 {
24572666 childToDrag = selectee;
24582667 doSomething = 2;
....@@ -2464,13 +2673,15 @@
24642673 return retval;
24652674 }
24662675
2467
- void doEditDrag(ClickInfo info)
2676
+ void doEditDrag(//ClickInfo clickInfo,
2677
+ boolean opposite)
24682678 {
24692679 switch (doSomething)
24702680 {
24712681 case 1: // '\001'
24722682 //super.
2473
- doEditDrag0(info);
2683
+ doEditDrag0(//clickInfo,
2684
+ opposite);
24742685 break;
24752686
24762687 case 2: // '\002'
....@@ -2483,11 +2694,13 @@
24832694 {
24842695 //sel.hitSomething = childToDrag.hitSomething;
24852696 //childToDrag.doEditDrag(info);
2486
- sel.doEditDrag(info);
2697
+ sel.doEditDrag(//clickInfo,
2698
+ opposite);
24872699 } else
24882700 {
24892701 //super.
2490
- doEditDrag0(info);
2702
+ doEditDrag0(//clickInfo,
2703
+ opposite);
24912704 }
24922705 }
24932706 break;
....@@ -2505,6 +2718,9 @@
25052718 {
25062719 deselectAll();
25072720 }
2721
+
2722
+ new Exception().printStackTrace();
2723
+
25082724 ClickInfo newInfo = new ClickInfo();
25092725 newInfo.flags = info.flags;
25102726 newInfo.bounds = info.bounds;
....@@ -2597,6 +2813,18 @@
25972813 void GenNormalsS(boolean crease)
25982814 {
25992815 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();
26002828 // for (int i=0; i<selection.size(); i++)
26012829 // {
26022830 // Object3D selectee = (Object3D) selection.elementAt(i);
....@@ -2737,6 +2965,24 @@
27372965 if (child == null)
27382966 continue;
27392967 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();
27402986 // Children().release(i);
27412987 }
27422988 blockloop = false;
....@@ -2894,7 +3140,8 @@
28943140 {
28953141 if (bRep != null)
28963142 {
2897
- bRep.GenUV();
3143
+ bRep.GenUV(); //1);
3144
+ //bRep.UnfoldUV();
28983145 Touch();
28993146 }
29003147 }
....@@ -2908,11 +3155,20 @@
29083155 }
29093156 }
29103157
3158
+ void GenNormalsMesh0()
3159
+ {
3160
+ if (bRep != null)
3161
+ {
3162
+ bRep.GenerateNormalsMesh();
3163
+ Touch();
3164
+ }
3165
+ }
3166
+
29113167 void GenNormalsMINE0()
29123168 {
29133169 if (bRep != null)
29143170 {
2915
- bRep.GenerateNormalsMINE();
3171
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
29163172 Touch();
29173173 }
29183174 }
....@@ -2969,6 +3225,33 @@
29693225 blockloop = false;
29703226 }
29713227
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
+
29723255 void TransformGeometry()
29733256 {
29743257 Object3D obj = this;
....@@ -3190,9 +3473,11 @@
31903473
31913474 BoundaryRep sup = bRep.support;
31923475 bRep.support = null;
3193
- BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
3476
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
31943477 // bRep.SplitInTwo(onlyone); // thread...
3195
- temprep.SplitInTwo(reduction34, onlyone);
3478
+
3479
+ while(temprep.SplitInTwo(reduction34, onlyone));
3480
+
31963481 bRep = temprep;
31973482 bRep.support = sup;
31983483 Touch();
....@@ -3329,7 +3614,8 @@
33293614 if (blockloop)
33303615 return;
33313616
3332
- if (marked || (bRep != null && material != null)) // borderline...
3617
+ if (//marked || // does not make sense
3618
+ (bRep != null || material != null)) // borderline...
33333619 live = h;
33343620
33353621 for (int i = 0; i < Size(); i++)
....@@ -3350,7 +3636,8 @@
33503636 return;
33513637
33523638 //if (bRep != null)
3353
- if (marked || (bRep != null && material != null)) // borderline...
3639
+ if (//marked || // does not make sense
3640
+ (bRep != null || material != null)) // borderline...
33543641 link2master = h;
33553642
33563643 for (int i = 0; i < Size(); i++)
....@@ -3370,7 +3657,8 @@
33703657 if (blockloop)
33713658 return;
33723659
3373
- if (marked || (bRep != null && material != null)) // borderline...
3660
+ if (//marked || // does not make sense
3661
+ (bRep != null || material != null)) // borderline...
33743662 hide = h;
33753663
33763664 for (int i = 0; i < Size(); i++)
....@@ -3390,7 +3678,7 @@
33903678 if (blockloop)
33913679 return;
33923680
3393
- if (bRep != null && material != null) // borderline...
3681
+ if (bRep != null || material != null) // borderline...
33943682 marked = h;
33953683
33963684 for (int i = 0; i < Size(); i++)
....@@ -3400,6 +3688,46 @@
34003688 continue;
34013689 blockloop = true;
34023690 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);
34033731 blockloop = false;
34043732 // release(i);
34053733 }
....@@ -3714,7 +4042,7 @@
37144042 if (child == null)
37154043 continue;
37164044
3717
- if (GrafreeD.RENDERME > 0)
4045
+ if (Grafreed.RENDERME > 0)
37184046 {
37194047 if (child instanceof Merge)
37204048 ((Merge)child).renderme();
....@@ -3865,7 +4193,7 @@
38654193 if (child == null)
38664194 continue;
38674195
3868
- if (GrafreeD.RENDERME > 0)
4196
+ if (Grafreed.RENDERME > 0)
38694197 {
38704198 if (child instanceof Merge)
38714199 ((Merge)child).renderme();
....@@ -4060,7 +4388,7 @@
40604388 if (child == null)
40614389 continue;
40624390
4063
- if (GrafreeD.RENDERME > 0)
4391
+ if (Grafreed.RENDERME > 0)
40644392 {
40654393 if (child instanceof Merge)
40664394 ((Merge)child).renderme();
....@@ -4157,6 +4485,71 @@
41574485 }
41584486 blockloop = true;
41594487 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();
41604553 blockloop = false;
41614554 }
41624555 }
....@@ -4651,7 +5044,7 @@
46515044
46525045 cTreePath SelectLeaf(int indexcount, boolean deselect)
46535046 {
4654
- if (hide)
5047
+ if (hide || dontselect)
46555048 return null;
46565049
46575050 if (count <= 0)
....@@ -4675,9 +5068,17 @@
46755068 }
46765069 }
46775070
5071
+ ObjEditor GetWindow()
5072
+ {
5073
+ if (editWindow != null)
5074
+ return editWindow;
5075
+
5076
+ return manipWindow;
5077
+ }
5078
+
46785079 cTreePath Select(int indexcount, boolean deselect)
46795080 {
4680
- if (hide)
5081
+ if (hide || dontselect)
46815082 return null;
46825083
46835084 if (count <= 0)
....@@ -4711,10 +5112,11 @@
47115112 if (leaf != null)
47125113 {
47135114 cTreePath tp = new cTreePath(this, leaf);
4714
- if (editWindow != null)
5115
+ ObjEditor window = GetWindow();
5116
+ if (window != null)
47155117 {
47165118 //System.out.println("editWindow = " + editWindow + " vs " + this);
4717
- editWindow.Select(tp, deselect, true);
5119
+ window.Select(tp, deselect, true);
47185120 }
47195121
47205122 return tp;
....@@ -4731,6 +5133,7 @@
47315133
47325134 if (child == null)
47335135 continue;
5136
+
47345137 if (child.HasTransparency() && child.size() != 0)
47355138 {
47365139 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4740,9 +5143,10 @@
47405143 if (leaf != null)
47415144 {
47425145 cTreePath tp = new cTreePath(this, leaf);
4743
- if (editWindow != null)
5146
+ ObjEditor window = GetWindow();
5147
+ if (window != null)
47445148 {
4745
- editWindow.Select(tp, deselect, true);
5149
+ window.Select(tp, deselect, true);
47465150 }
47475151
47485152 return tp;
....@@ -4827,7 +5231,7 @@
48275231 return globalTransform;
48285232 }
48295233
4830
- void PreprocessOcclusion(CameraPane cp)
5234
+ void PreprocessOcclusion(iCameraPane cp)
48315235 {
48325236 /*
48335237 if (AOdone)
....@@ -4974,7 +5378,8 @@
49745378 } else //
49755379 if (editWindow != null)
49765380 {
4977
- editWindow.cameraView.lighttouched = true;
5381
+ //editWindow.cameraView.lighttouched = true;
5382
+ Globals.lighttouched = true;
49785383 }
49795384 }
49805385
....@@ -5066,6 +5471,51 @@
50665471 blockloop = false;
50675472 }
50685473
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
+
50695519 boolean IsSelected()
50705520 {
50715521 if (parent == null)
....@@ -5126,12 +5576,41 @@
51265576 if (fullname == null)
51275577 return "";
51285578
5579
+ if (fullname.pigment != null)
5580
+ {
5581
+ return fullname.pigment;
5582
+ }
5583
+
51295584 // System.out.println("Fullname = " + fullname);
51305585
5131
- if (fullname.name.indexOf(":") == -1)
5132
- 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(":"));
51335591
5134
- 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];
51355614 }
51365615
51375616 static String GetBump(cTexture fullname)
....@@ -5139,11 +5618,44 @@
51395618 if (fullname == null)
51405619 return "";
51415620
5621
+ if (fullname.bump != null)
5622
+ {
5623
+ return fullname.bump;
5624
+ }
5625
+
51425626 // System.out.println("Fullname = " + fullname);
5143
- if (fullname.name.indexOf(":") == -1)
5144
- return "";
5145
-
5146
- return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
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];
51475659 }
51485660
51495661 String GetPigmentTexture()
....@@ -5217,7 +5729,7 @@
52175729 System.out.print("; textures = " + textures);
52185730 System.out.println("; usedtextures = " + usedtextures);
52195731
5220
- if (GetTextures() == null)
5732
+ if (GetTextures() == null) // What is that??
52215733 GetTextures().name = ":";
52225734
52235735 String texname = tex;
....@@ -5226,6 +5738,9 @@
52265738 texname = "";
52275739
52285740 GetTextures().name = texname + ":" + GetBump(GetTextures());
5741
+
5742
+ GetTextures().pigment = null;
5743
+
52295744 Touch();
52305745 }
52315746
....@@ -5250,6 +5765,43 @@
52505765 }
52515766 }
52525767
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
+
52535805 void SetBumpTexture(String tex)
52545806 {
52555807 if (GetTextures() == null)
....@@ -5261,6 +5813,8 @@
52615813 texname = "";
52625814
52635815 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
5816
+
5817
+ GetTextures().bump = null;
52645818
52655819 Touch();
52665820 }
....@@ -5286,25 +5840,65 @@
52865840 }
52875841 }
52885842
5289
- 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)
52905876 {
52915877 Draw(display, root, selected, blocked);
52925878 }
52935879
5294
- static cMaterial[] materialstack = new cMaterial[65536];
5295
- static boolean[] selectedstack = new boolean[65536];
5296
- static int materialdepth = 0;
5297
-
52985880 boolean NeedSupport()
52995881 {
53005882 return
5301
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5883
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
53025884 // PROBLEM with CROWD!!
5303
- && (CameraPane.drawMode == CameraPane.SHADOW || CameraPane.CROWD);
5885
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
53045886 }
53055887
5888
+ static boolean DEBUG_SELECTION = false;
53065889
5307
- 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)
53085902 {
53095903 Invariants(); // june 2013
53105904
....@@ -5313,8 +5907,8 @@
53135907 // System.err.println("Draw " + this + " Frame # " + ((Mocap)((Merge)support).object).frame);
53145908 }
53155909
5316
- if (display.drawMode == CameraPane.SELECTION &&
5317
- hide)
5910
+ if (display.DrawMode() == iCameraPane.SELECTION &&
5911
+ (hide || dontselect))
53185912 return;
53195913
53205914 if (name != null && name.contains("sclera"))
....@@ -5332,7 +5926,7 @@
53325926 if (this instanceof Checker)
53335927 return;
53345928
5335
- if (display.drawMode == display.SHADOW && PASSTEST)
5929
+ if (display.DrawMode() == display.SHADOW && PASSTEST)
53365930 return;
53375931
53385932 if (count <= 0)
....@@ -5340,13 +5934,13 @@
53405934 return;
53415935 }
53425936
5343
- if ((//display.drawMode == CameraPane.SHADOW ||
5344
- display.drawMode == CameraPane.SELECTION || CameraPane.DEBUG_SELECTION) && HasTransparency())
5937
+ if ((//display.DrawMode() == CameraPane.SHADOW ||
5938
+ display.DrawMode() == iCameraPane.SELECTION || display.IsDebugSelection()) && HasTransparency())
53455939 {
53465940 return;
53475941 }
53485942
5349
- javax.media.opengl.GL gl = display.GetGL();
5943
+ //javax.media.opengl.GL gl = display.GetGL();
53505944
53515945 /*
53525946 if (touched)
....@@ -5364,8 +5958,10 @@
53645958 if (support != null)
53655959 support = support;
53665960
5367
- //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5368
- boolean usecalllists = false; // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
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.
53695965
53705966 if (!usecalllists && bRep != null && bRep.displaylist > 0)
53715967 {
....@@ -5375,30 +5971,33 @@
53755971 // usecalllists &= !(parent instanceof RandomNode);
53765972 // usecalllists = false;
53775973
5378
- if (GetBRep() != null)
5379
- usecalllists = usecalllists;
5974
+ if (display.DrawMode() == display.SHADOW)
5975
+ //GetBRep() != null)
5976
+ usecalllists = !!usecalllists;
53805977 //System.out.println("draw " + this);
53815978 //new Exception().printStackTrace();
53825979
53835980 boolean compiled = false;
53845981
5385
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
5982
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
53865983
5387
- if (!selectmode && //display.drawMode != display.SELECTION &&
5388
- (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)))
53895987 {
5390
- display.lighttouched = true;
5988
+ Globals.lighttouched = true;
53915989 } // all panes...
5392
- //if (usecalllists && display.drawMode != display.SELECTION && display.drawMode != display.SHADOW &&
5393
- if (bRep != null && usecalllists && !selectmode && // june 2013 display.drawMode != display.SHADOW &&
5990
+
5991
+ //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
5992
+ if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
53945993 (touched || (bRep != null && bRep.displaylist <= 0)))
53955994 {
53965995 if (!(this instanceof Composite))
53975996 touched = false;
53985997 //if (displaylist == -1 && usecalllists)
5399
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
5998
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
54005999 {
5401
- bRep.displaylist = gl.glGenLists(1);
6000
+ bRep.displaylist = display.GenList();
54026001 assert(bRep.displaylist != 0);
54036002 // System.err.println("glGenLists: " + bRep.displaylist + " for " + this);
54046003 //System.out.println("\tgen list " + list);
....@@ -5407,21 +6006,23 @@
54076006
54086007 //System.out.println("\tnew list " + list);
54096008 //gl.glDrawBuffer(gl.GL_NONE);
5410
- if (usecalllists)
6009
+ if (usecalllists && bRep.displaylist > 0)
54116010 {
54126011 // System.err.println("new list " + bRep.displaylist + " for " + this);
5413
- gl.glNewList(bRep.displaylist, gl.GL_COMPILE); //_AND_EXECUTE);
6012
+ display.NewList(bRep.displaylist);
54146013 }
6014
+
54156015 CallList(display, root, selected, blocked);
6016
+
54166017 // compiled = true;
5417
- if (usecalllists)
6018
+ if (usecalllists && bRep.displaylist > 0)
54186019 {
54196020 // System.err.println("end list " + bRep.displaylist + " for " + this);
5420
- gl.glEndList();
6021
+ display.EndList();
54216022 }
54226023 //gl.glDrawBuffer(gl.GL_BACK);
54236024 // XXX touched = false;
5424
- display.lighttouched = true; // all panes...
6025
+ Globals.lighttouched = true; // all panes...
54256026 }
54266027
54276028 touched = GetBRep() == null; // this instanceof Composite || this instanceof FileObject; // false;
....@@ -5460,12 +6061,12 @@
54606061
54616062 // frustum culling
54626063 if (CameraPane.FRUSTUM && !blocked && !IsInfinite() && GetBRep() != null // && GetBRep().VertexCount() != 1260 // default grid
5463
- && display.drawMode != CameraPane.SELECTION)
6064
+ && display.DrawMode() != iCameraPane.SELECTION)
54646065 {
5465
- if (display.drawMode == CameraPane.SHADOW)
6066
+ if (display.DrawMode() == iCameraPane.SHADOW)
54666067 {
54676068 if (!link2master // tricky to cull in shadow mode.
5468
- && GetBRep().FrustumCull(this, gl, display.lightCamera, true))
6069
+ && GetBRep().FrustumCull(this, null, display.LightCamera(), true))
54696070 {
54706071 //System.out.print("CULLED");
54716072 culled = true;
....@@ -5473,7 +6074,7 @@
54736074 }
54746075 else
54756076 //GetBRep().getBounds(v0, v1, this);
5476
- if (GetBRep().FrustumCull(this, gl, display.renderCamera, false))
6077
+ if (GetBRep().FrustumCull(this, null, display.RenderCamera(), false))
54776078 culled = true;
54786079
54796080 // LA.xformPos(v0, display.renderCamera.toScreen, v0);
....@@ -5509,11 +6110,12 @@
55096110
55106111
55116112 if (!culled)
5512
- if (display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION)
6113
+ if (display.DrawMode() == display.SELECTION || display.IsDebugSelection())
55136114 {
55146115 if (GetBRep() != null)
55156116 {
5516
- CameraPane.NextIndex(this, gl);
6117
+ display.NextIndex();
6118
+
55176119 // vertex color conflict : gl.glCallList(list);
55186120 DrawNode(display, root, selected);
55196121 if (this instanceof BezierPatch)
....@@ -5535,55 +6137,7 @@
55356137 color[2] /= 2;
55366138 gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT_AND_DIFFUSE, color, 0);
55376139 */
5538
- if (material != null)
5539
- {
5540
- materialstack[materialdepth] = material;
5541
- selectedstack[materialdepth] = selected;
5542
- cStatic.objectstack[materialdepth++] = this;
5543
- //System.out.println("material " + material);
5544
- //Applet3D.tracein(this, selected);
5545
- display.vector2buffer = projectedVertices;
5546
- if (this instanceof Camera)
5547
- {
5548
- display.options1[0] = material.shift;
5549
- //System.out.println("shift " + material.shift);
5550
- display.options1[1] = material.lightarea;
5551
- display.options1[2] = material.shadowbias;
5552
- display.options1[3] = material.aniso;
5553
- display.options1[4] = material.anisoV;
5554
- display.options2[0] = material.opacity;
5555
- display.options2[1] = material.diffuse;
5556
- display.options2[2] = material.factor;
5557
-
5558
- cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
5559
- display.options4[0] = material.cameralight/0.2f;
5560
- display.options4[1] = material.subsurface;
5561
- display.options4[2] = material.sheen;
5562
-
5563
- // if (display.CURRENTANTIALIAS > 0)
5564
- // display.options3[3] /= 4;
5565
-
5566
- /*
5567
- System.out.println("Focus = " + display.options1[0]);
5568
- System.out.println("Aperture = " + display.options1[1]);
5569
- System.out.println("ShadowBlur = " + display.options1[2]);
5570
- System.out.println("Antialiasing = " + display.options1[3]);
5571
- System.out.println("Fog = " + display.options2[0]);
5572
- System.out.println("Intensity = " + display.options2[1]);
5573
- System.out.println("Elevation = " + display.options2[2]);
5574
- /**/
5575
- } else
5576
- {
5577
- material.Draw(display, selected);
5578
- }
5579
- } else
5580
- {
5581
- if (selected && CameraPane.flash)
5582
- {
5583
- display.modelParams4[1] = 100;
5584
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
5585
- }
5586
- }
6140
+ display.PushMaterial(this, selected);
55876141
55886142 //System.out.println("call list " + list);
55896143 //System.out.println();
....@@ -5602,7 +6156,28 @@
56026156 tex = GetTextures();
56036157 }
56046158
5605
- 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
+ }
56066181
56076182 if (!compiled)
56086183 {
....@@ -5618,30 +6193,19 @@
56186193
56196194 // System.err.println("glCallList: " + bRep.displaylist + " for " + this);
56206195 assert(bRep.displaylist != 0);
5621
- gl.glCallList(bRep.displaylist);
6196
+ display.CallList(bRep.displaylist);
56226197 // june 2013 drawSelf(display, root, selected);
56236198 }
56246199 }
56256200 }
56266201
5627
- display.ReleaseTextures(tex);
5628
-
5629
- //if (parent != null && parent.GetMaterial() != null)
5630
- // parent.GetMaterial().Draw(display, parent.IsSelected(this));
5631
- if (material != null)
5632
- {
5633
- materialdepth -= 1;
5634
- if (materialdepth > 0)
5635
- {
5636
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
5637
- materialstack[materialdepth - 1].Draw(display, selectedstack[materialdepth - 1]);
5638
- }
5639
- //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
5640
- } else if (selected && CameraPane.flash && GetMaterial() != null)
5641
- {
5642
- display.modelParams4[1] = GetMaterial().cameralight;
5643
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
5644
- }
6202
+ if (!failedBump)
6203
+ display.ReleaseBumpTexture(tex);
6204
+
6205
+ if (!failedPigment)
6206
+ display.ReleasePigmentTexture(tex);
6207
+
6208
+ display.PopMaterial(this, selected);
56456209 }
56466210
56476211 if (this instanceof Texture || this instanceof TextureNode)
....@@ -5683,7 +6247,7 @@
56836247 // resetMasterNode();
56846248 }
56856249
5686
- void CallList(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
6250
+ void CallList(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
56876251 {
56886252 if (GetBRep() == null)
56896253 {
....@@ -5766,8 +6330,11 @@
57666330 boolean flipV = false; // true;
57676331 int texres = 0; // 0 = low, 1 = normal, 2 = high res texture
57686332
5769
- void drawSelf(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
6333
+ void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57706334 {
6335
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6336
+ return;
6337
+
57716338 if (hide)
57726339 return;
57736340 // shadow optimisation
....@@ -5825,16 +6392,7 @@
58256392 // // ??????????????????????????? Touch();
58266393 // }
58276394
5828
- if (material != null)
5829
- {
5830
- materialstack[materialdepth] = material;
5831
- selectedstack[materialdepth] = selected;
5832
- cStatic.objectstack[materialdepth++] = this;
5833
- //System.out.println("material " + material);
5834
- //Applet3D.tracein("selected ", selected);
5835
- display.vector2buffer = projectedVertices;
5836
- material.Draw(display, selected);
5837
- }
6395
+display.PushMaterial2(this, selected);
58386396
58396397 Object3D child;
58406398 boolean sel;
....@@ -5886,19 +6444,7 @@
58866444 */
58876445 //depth += 1;
58886446
5889
- if (material != null)
5890
- {
5891
- materialdepth -= 1;
5892
- if (materialdepth > 0)
5893
- {
5894
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
5895
- materialstack[materialdepth - 1].Draw(display, selectedstack[materialdepth - 1]);
5896
- }
5897
- //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
5898
- //else
5899
- //material.Draw(display, false);
5900
- }
5901
-
6447
+display.PopMaterial2(this);
59026448 /*
59036449 display.ReleaseTextures(tex);
59046450 */
....@@ -5909,10 +6455,13 @@
59096455
59106456 //static cVector min,max;
59116457
5912
- void DrawNode(CameraPane display, Object3D /*Composite*/ root, boolean selected)
6458
+ void DrawNode(iCameraPane display, Object3D /*Composite*/ root, boolean selected)
59136459 {
5914
- 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)
59156461 return; // no shadow for transparent objects
6462
+
6463
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6464
+ return;
59166465
59176466 if (hide)
59186467 return;
....@@ -5954,11 +6503,12 @@
59546503 return;
59556504 }
59566505
6506
+ //bRep.GenUV(1/material.diffuseness);
59576507 // bRep.lock = true;
59586508
5959
- javax.media.opengl.GL gl = display.GetGL();
6509
+ //javax.media.opengl.GL gl = display.GetGL();
59606510
5961
- if (CameraPane.BOXMODE) // || CameraPane.movingcamera)
6511
+ if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera)
59626512 {
59636513 int fc = bRep.FaceCount();
59646514 int vc = bRep.VertexCount();
....@@ -5973,23 +6523,7 @@
59736523
59746524 bRep.getMinMax(min, max, 100);
59756525
5976
- gl.glBegin(gl.GL_LINES);
5977
-
5978
- gl.glVertex3d(min.x, min.y, min.z);
5979
- gl.glVertex3d(min.x, min.y, max.z);
5980
- gl.glVertex3d(min.x, min.y, min.z);
5981
- gl.glVertex3d(min.x, max.y, min.z);
5982
- gl.glVertex3d(min.x, min.y, min.z);
5983
- gl.glVertex3d(max.x, min.y, min.z);
5984
-
5985
- gl.glVertex3d(max.x, max.y, max.z);
5986
- gl.glVertex3d(min.x, max.y, max.z);
5987
- gl.glVertex3d(max.x, max.y, max.z);
5988
- gl.glVertex3d(max.x, min.y, max.z);
5989
- gl.glVertex3d(max.x, max.y, max.z);
5990
- gl.glVertex3d(max.x, max.y, min.z);
5991
-
5992
- gl.glEnd();
6526
+ display.DrawBox(min, max);
59936527
59946528 return;
59956529 }
....@@ -6033,7 +6567,7 @@
60336567 {
60346568 //throw new Error();
60356569
6036
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
6570
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
60376571
60386572 int[] strips = bRep.getRawIndices();
60396573
....@@ -6043,178 +6577,19 @@
60436577 new Exception().printStackTrace();
60446578 return;
60456579 }
6046
-
6047
- // TRIANGLE STRIP ARRAY
6048
- if (bRep.trimmed)
6580
+
6581
+ if (dontselect)
60496582 {
6050
- float[] v = bRep.getRawVertices();
6051
- float[] n = bRep.getRawNormals();
6052
- float[] c = bRep.getRawColors();
6053
- float[] uv = bRep.getRawUVMap();
6054
-
6055
- int count2 = 0;
6056
- int count3 = 0;
6057
-
6058
- if (n.length > 0)
6059
- {
6060
- for (int i = 0; i < strips.length; i++)
6061
- {
6062
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6063
-
6064
- /*
6065
- boolean locked = false;
6066
- float eps = 0.1f;
6067
- boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
6068
-
6069
- int dot = 0;
6070
-
6071
- if ((dot&1) == 0)
6072
- dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
6073
-
6074
- if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
6075
- gl.glTexCoord2f((float) qv.s, (float) qv.t);
6076
- else
6077
- {
6078
- locked = true;
6079
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6080
- }
6081
- //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6082
- gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
6083
- if (hasnorm)
6084
- {
6085
- //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6086
- gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
6087
- }
6088
-
6089
- if ((dot&4) == 0)
6090
- dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
6091
-
6092
- if (wrap || !locked && (dot&8) != 0)
6093
- gl.glTexCoord2f((float) rv.s, (float) rv.t);
6094
- else
6095
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6096
-
6097
- f.dot = dot;
6098
- */
6099
-
6100
- if (!selectmode)
6101
- {
6102
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6103
- {
6104
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6105
- } else
6106
- {
6107
- gl.glNormal3f(0, 0, 1);
6108
- }
6109
-
6110
- if (c != null)
6111
- //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]);
6112
- {
6113
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6114
- }
6115
- }
6116
- if (flipV)
6117
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6118
- else
6119
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6120
- //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6121
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6122
-
6123
- count2 += 2;
6124
- count3 += 3;
6125
- if (!selectmode)
6126
- {
6127
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6128
- {
6129
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6130
- } else
6131
- {
6132
- gl.glNormal3f(0, 0, 1);
6133
- }
6134
- if (c != null)
6135
- {
6136
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6137
- }
6138
- }
6139
- if (flipV)
6140
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6141
- else
6142
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6143
- //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6144
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6145
-
6146
- count2 += 2;
6147
- count3 += 3;
6148
- for (int j = 0; j < strips[i] - 2; j++)
6149
- {
6150
- //gl.glTexCoord2d(...);
6151
- if (!selectmode)
6152
- {
6153
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6154
- {
6155
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6156
- } else
6157
- {
6158
- gl.glNormal3f(0, 0, 1);
6159
- }
6160
- if (c != null)
6161
- {
6162
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6163
- }
6164
- }
6165
-
6166
- if (flipV)
6167
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6168
- else
6169
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6170
- //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
6171
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6172
- count2 += 2;
6173
- count3 += 3;
6174
- }
6175
-
6176
- gl.glEnd();
6177
- }
6178
- }
6179
-
6180
- assert count3 == v.length;
6583
+ //bRep.GenerateNormalsMINE();
61816584 }
6182
- else // !trimmed
6183
- {
6184
- int count = 0;
6185
- for (int i = 0; i < strips.length; i++)
6186
- {
6187
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6188
-
6189
- Vertex p = bRep.GetVertex(bRep.indices[count++]);
6190
- Vertex q = bRep.GetVertex(bRep.indices[count++]);
6191
-
6192
- drawVertex(gl, p, selectmode);
6193
- drawVertex(gl, q, selectmode);
6194
-
6195
- for (int j = 0; j < strips[i] - 2; j++)
6196
- {
6197
- Vertex r = bRep.GetVertex(bRep.indices[count++]);
6198
-
6199
-// if (j%2 == 0)
6200
-// drawFace(p, q, r, display, null);
6201
-// else
6202
-// drawFace(p, r, q, display, null);
6203
-
6204
-// p = q;
6205
-// q = r;
6206
- drawVertex(gl, r, selectmode);
6207
- }
6208
-
6209
- gl.glEnd();
6210
- }
6211
- }
6585
+
6586
+ display.DrawGeometry(bRep, flipV, selectmode);
62126587 } else // catch (Error e)
62136588 {
62146589 // TRIANGLE ARRAY
62156590 if (IsOpaque()) // Static())
62166591 {
6217
- gl.glBegin(gl.GL_TRIANGLES);
6592
+ display.StartTriangles();
62186593 int facecount = bRep.FaceCount();
62196594 for (int i = 0; i < facecount; i++)
62206595 {
....@@ -6277,9 +6652,9 @@
62776652 // // r.norm.dot(v3) > -0.5)
62786653 // // continue;
62796654
6280
- drawFace(p, q, r, display, face);
6655
+ display.DrawFace(this, p, q, r, face);
62816656 }
6282
- gl.glEnd();
6657
+ display.EndTriangles();
62836658 }
62846659 else
62856660 {
....@@ -6308,8 +6683,8 @@
63086683 //System.out.println("SORT");
63096684
63106685 java.util.Arrays.sort(facescompare);
6311
-
6312
- gl.glBegin(gl.GL_TRIANGLES);
6686
+
6687
+ display.StartTriangles();
63136688 for (int i = 0; i < facecount; i++)
63146689 {
63156690 Face face = bRep.GetFace(facescompare[i].index);
....@@ -6321,13 +6696,14 @@
63216696 Vertex q = bRep.GetVertex(face.q);
63226697 Vertex r = bRep.GetVertex(face.r);
63236698
6324
- drawFace(p, q, r, display, face);
6699
+ display.DrawFace(this, p, q, r, face);
63256700 }
6326
- gl.glEnd();
6701
+ display.EndTriangles();
63276702 }
63286703
63296704 if (false) // live && support != null && support.bRep != null) // debug weights
63306705 {
6706
+ /*
63316707 gl.glDisable(gl.GL_LIGHTING);
63326708 float[] colorV = new float[3];
63336709
....@@ -6406,6 +6782,7 @@
64066782 // gl.glEnd();
64076783 }
64086784 }
6785
+ */
64096786 }
64106787 }
64116788
....@@ -6450,7 +6827,7 @@
64506827 center.add(r);
64516828 center.mul(1.0/3);
64526829
6453
- center.sub(CameraPane.theRenderer.eyeCamera.location);
6830
+ center.sub(Globals.theRenderer.EyeCamera().location);
64546831
64556832 distance = center.dot(center);
64566833 }
....@@ -6461,347 +6838,11 @@
64616838
64626839 transient FaceCompare[] facescompare = null;
64636840
6464
- void SetColor(CameraPane display, Vertex p0)
6465
- {
6466
- if (display.RENDERPROGRAM == 0)
6467
- {
6468
- float r = 0;
6469
- if (bRep != null)
6470
- {
6471
- if (bRep.stripified)
6472
- {
6473
- r = 1;
6474
- }
6475
- }
6476
- float g = 0;
6477
- if (bRep != null)
6478
- {
6479
- if (bRep.trimmed)
6480
- {
6481
- g = 1;
6482
- }
6483
- }
6484
- float b = 0;
6485
- if (support != null && link2master)
6486
- {
6487
- b = 1;
6488
- }
6489
- display.GetGL().glColor3f(r*p0.AO, g*p0.AO, b*p0.AO);
6490
- return;
6491
- }
6492
-
6493
- if (display.drawMode != CameraPane.SHADOW)
6494
- return;
6495
-
6496
- javax.media.opengl.GL gl = display.GetGL();
6497
-// if (true) return;
6498
-// float ao = p.AO;
6499
-//
6500
-// // if (ao == 0 && !bRep.AOdone) // transient problem!
6501
-// // ao = 1;
6502
-//
6503
-// gl.glColor4f(ao, ao, ao, 1);
6504
-
6505
-// CameraPane.selectedpoint.
6506
-// getAverage(cStatic.point1, true);
6507
- if (CameraPane.pointflow == null) // !random) // live)
6508
- {
6509
- return;
6510
- }
6511
-
6512
- cStatic.point1.set(0,0,0);
6513
- LA.xformPos(cStatic.point1, CameraPane.selectedpoint.toParent, cStatic.point1);
6514
-
6515
- cStatic.point1.sub(p0);
6516
-
6517
-
6518
-// if (marked && (p0.vertexlinks == null || support == null || support.bRep == null)) // no position delta?
6519
-// {
6520
-// return;
6521
-// }
6522
-
6523
- //if (true)
6524
- if (cStatic.point1.dot(cStatic.point1) > 0.000001)
6525
- {
6526
- return;
6527
- }
6528
-
6529
- float[] colorV = new float[3];
6530
-
6531
- if (false) // marked)
6532
- {
6533
- // debug rigging weights
6534
- for (int object = 0; object < p0.vertexlinks.length; object++)
6535
- {
6536
- float weight = p0.weights[object] / p0.totalweight;
6537
-
6538
- // if (weight < 0.1)
6539
- // {
6540
- // assert(weight == 0);
6541
- // continue;
6542
- // }
6543
-
6544
- if (p0.vertexlinks[object] == -1)
6545
- continue;
6546
-
6547
- Vertex q = support.bRep.GetVertex(p0.vertexlinks[object]);
6548
-
6549
- int color = //1 << object; //
6550
- //p.vertexlinks.length;
6551
- support.bRep.supports[p0.closestsupport].links[object];
6552
- colorV[2] += (color & 1) * weight;
6553
- colorV[1] += ((color & 2) >> 1) * weight;
6554
- colorV[0] += ((color & 4) >> 2) * weight;
6555
- }
6556
- }
6557
- else
6558
- {
6559
- if (drawingstarted)
6560
- {
6561
- // find next point
6562
- if (bRep.GetVertex(0).faceindices == null)
6563
- {
6564
- bRep.InitFaceIndices();
6565
- }
6566
-
6567
- double ymin = p0.y;
6568
-
6569
- Vertex newp = p0;
6570
-
6571
- for (int fii = 0; fii < p0.faceindices.length; fii++)
6572
- {
6573
- int fi = p0.faceindices[fii];
6574
-
6575
- if (fi == -1)
6576
- break;
6577
-
6578
- Face f = bRep.GetFace(fi);
6579
-
6580
- Vertex p = bRep.GetVertex(f.p);
6581
- Vertex q = bRep.GetVertex(f.q);
6582
- Vertex r = bRep.GetVertex(f.r);
6583
-
6584
- int swap = (int)(Math.random()*3);
6585
-
6586
-// for (int s=swap; --s>=0;)
6587
-// {
6588
-// Vertex t = p;
6589
-// p = q;
6590
-// q = r;
6591
-// r = t;
6592
-// }
6593
- if (ymin > p.y)
6594
- {
6595
- ymin = p.y;
6596
- newp = p;
6597
-// break;
6598
- }
6599
- if (ymin > q.y)
6600
- {
6601
- ymin = q.y;
6602
- newp = q;
6603
-// break;
6604
- }
6605
- if (ymin > r.y)
6606
- {
6607
- ymin = r.y;
6608
- newp = r;
6609
-// break;
6610
- }
6611
- }
6612
-
6613
- CameraPane.selectedpoint.toParent[3][0] = newp.x;
6614
- CameraPane.selectedpoint.toParent[3][1] = newp.y;
6615
- CameraPane.selectedpoint.toParent[3][2] = newp.z;
6616
-
6617
- drawingstarted = false;
6618
-
6619
- // return;
6620
- }
6621
-
6622
- if (false) // CameraPane.DRAW
6623
- {
6624
- p0.AO = colorV[0] = 2;
6625
- colorV[1] = 2;
6626
- colorV[2] = 2;
6627
- }
6628
-
6629
- CameraPane.pointflow.add(p0);
6630
- CameraPane.pointflow.Touch();
6631
- }
6632
-
6633
-// gl.glColor3f(colorV[0], colorV[1], colorV[2]);
6634
-// gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0);
6635
-// gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
6636
- }
6637
-
66386841 void Print(Vertex v)
66396842 {
66406843 //System.err.println("(" + v.x + ", " + v.y + ", " + v.z + ")");
66416844 }
66426845
6643
- void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean selectmode)
6644
- {
6645
- if (!selectmode)
6646
- {
6647
- gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
6648
- gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
6649
-
6650
- if (flipV)
6651
- gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
6652
- else
6653
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6654
- }
6655
-
6656
- gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
6657
- }
6658
-
6659
- void drawFace(Vertex pv, Vertex qv, Vertex rv,
6660
- CameraPane display, Face face)
6661
- {
6662
- if (pv.y == -10000 ||
6663
- qv.y == -10000 ||
6664
- rv.y == -10000)
6665
- return;
6666
-
6667
-// float b = f.nbiterations & 1;
6668
-// float g = (f.nbiterations>>1) & 1;
6669
-// float r = (f.nbiterations>>2) & 1;
6670
-//
6671
-// //if (f.weight == 10000)
6672
-// //{
6673
-// // r = 1; g = b = 0;
6674
-// //}
6675
-// //else
6676
-// //{
6677
-// // assert(f.weight < 10000);
6678
-// r = g = b = (float)bRep.FaceWeight(f)*100;
6679
-// if (r<0)
6680
-// assert(r>=0);
6681
-// //}
6682
-
6683
- javax.media.opengl.GL gl = display.GetGL();
6684
-
6685
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
6686
-
6687
- //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv);
6688
- if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
6689
- {
6690
- //gl.glBegin(gl.GL_TRIANGLES);
6691
- boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
6692
- if (!hasnorm)
6693
- {
6694
- // System.out.println("FUCK!!");
6695
- LA.vecSub(pv/*.pos*/, qv/*.pos*/, v0);
6696
- LA.vecSub(pv/*.pos*/, rv/*.pos*/, v1);
6697
- LA.vecCross(v0, v1, v2);
6698
- LA.vecNormalize(v2);
6699
- gl.glNormal3f((float) v2.x, (float) v2.y, (float) v2.z);
6700
- }
6701
-
6702
- if (hasnorm)
6703
- {
6704
-// if (!pv.norm.normalized())
6705
-// assert(pv.norm.normalized());
6706
-
6707
- //System.out.println("normalp = " + pv.norm.x + ", " + pv.norm.y + ", " + pv.norm.z);
6708
- gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
6709
- }
6710
- gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
6711
- SetColor(display, pv);
6712
- //gl.glColor4f(r, g, b, 1);
6713
- //gl.glColor4f(pv.boundary, pv.boundary, pv.boundary, 1);
6714
- if (flipV)
6715
- gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
6716
- else
6717
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6718
- //System.out.println("vertexp = " + pv.x + ", " + pv.y + ", " + pv.z);
6719
- gl.glVertex3f((float) pv./*pos.*/x, (float) pv./*pos.*/y, (float) pv./*pos.*/z);
6720
-// Print(pv);
6721
- if (hasnorm)
6722
- {
6723
-// assert(qv.norm.normalized());
6724
- //System.out.println("normalq = " + qv.norm.x + ", " + qv.norm.y + ", " + qv.norm.z);
6725
- gl.glNormal3f((float) qv.norm.x, (float) qv.norm.y, (float) qv.norm.z);
6726
- }
6727
- //System.out.println("vertexq = " + qv.s + ", " + qv.t);
6728
- // boolean locked = false;
6729
- // float eps = 0.1f;
6730
- // boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
6731
-
6732
- // int dot = 0; //*/ (int)f.dot;
6733
-
6734
- // if ((dot&1) == 0)
6735
- // dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
6736
-
6737
- // if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
6738
- if (flipV)
6739
- gl.glTexCoord2f((float) qv.s, 1-(float) qv.t);
6740
- else
6741
- gl.glTexCoord2f((float) qv.s, (float) qv.t);
6742
- // else
6743
- // {
6744
- // locked = true;
6745
- // gl.glTexCoord2f((float) pv.s, (float) pv.t);
6746
- // }
6747
- gl.glColor4f(qv.AO, qv.AO, qv.AO, 1);
6748
- SetColor(display, qv);
6749
- //gl.glColor4f(r, g, b, 1);
6750
- //gl.glColor4f(qv.boundary, qv.boundary, qv.boundary, 1);
6751
- //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6752
- gl.glVertex3f((float) qv./*pos.*/x, (float) qv./*pos.*/y, (float) qv./*pos.*/z);
6753
-// Print(qv);
6754
- if (hasnorm)
6755
- {
6756
-// assert(rv.norm.normalized());
6757
- //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6758
- gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
6759
- }
6760
-
6761
- // if ((dot&4) == 0)
6762
- // dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
6763
-
6764
- // if (wrap || !locked && (dot&8) != 0)
6765
- if (flipV)
6766
- gl.glTexCoord2f((float) rv.s, 1-(float) rv.t);
6767
- else
6768
- gl.glTexCoord2f((float) rv.s, (float) rv.t);
6769
- // else
6770
- // gl.glTexCoord2f((float) pv.s, (float) pv.t);
6771
-
6772
- // f.dot = dot;
6773
-
6774
- gl.glColor4f(rv.AO, rv.AO, rv.AO, 1);
6775
- SetColor(display, rv);
6776
- //gl.glColor4f(r, g, b, 1);
6777
- //gl.glColor4f(rv.boundary, rv.boundary, rv.boundary, 1);
6778
- //System.out.println("vertexr = " + rv.x + ", " + rv.y + ", " + rv.z);
6779
- gl.glVertex3f((float) rv./*pos.*/x, (float) rv./*pos.*/y, (float) rv./*pos.*/z);
6780
-// Print(rv);
6781
- //gl.glEnd();
6782
- }
6783
- else
6784
- {
6785
- gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
6786
- gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
6787
- gl.glVertex3f((float) rv.x, (float) rv.y, (float) rv.z);
6788
-
6789
- }
6790
-
6791
- if (false) // (attributes & WIREFRAME) != 0)
6792
- {
6793
- gl.glDisable(gl.GL_LIGHTING);
6794
-
6795
- gl.glBegin(gl.GL_LINE_LOOP);
6796
- gl.glVertex3d(pv./*pos.*/x, pv./*pos.*/y, pv./*pos.*/z);
6797
- gl.glVertex3d(qv./*pos.*/x, qv./*pos.*/y, qv./*pos.*/z);
6798
- gl.glVertex3d(rv./*pos.*/x, rv./*pos.*/y, rv./*pos.*/z);
6799
- gl.glEnd();
6800
-
6801
- gl.glEnable(gl.GL_LIGHTING);
6802
- }
6803
- }
6804
-
68056846 void drawSelf(ClickInfo info, int level, boolean select)
68066847 {
68076848 if (bRep == null)
....@@ -7325,20 +7366,23 @@
73257366 }
73267367 }
73277368
7328
- 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)
73297373 {
7330
- int hc = info.bounds.x + info.bounds.width / 2;
7331
- int vc = info.bounds.y + info.bounds.height / 2;
7332
- double[][] toscreen = info.toScreen;
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;
73337377 if (toscreen == null)
73347378 {
7335
- toscreen = new Camera(info.camera.viewCode).toScreen;
7379
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
73367380 }
73377381 cVector vec = in;
73387382 LA.xformPos(in, toscreen, in);
73397383 //System.out.println("Distance = " + info.camera.Distance());
7340
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
7341
- vec.y *= 100 * info.camera.SCALE / info.camera.Distance();
7384
+ vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
7385
+ vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
73427386 outPt.x = hc + (int) vec.x;
73437387 outPt.y = vc - (int) vec.y;
73447388 outRec.x = outPt.x - 3;
....@@ -7346,15 +7390,18 @@
73467390 outRec.width = outRec.height = 6;
73477391 }
73487392
7349
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7393
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7394
+ )
73507395 {
73517396 Point pt = new Point(0, 0);
73527397 Rectangle rec = new Rectangle();
7353
- calcHotSpot(in, info, pt, rec);
7398
+ calcHotSpot(in, //clickInfo,
7399
+ pt, rec);
73547400 return rec;
73557401 }
73567402
7357
- void drawEditHandles0(ClickInfo info, int level)
7403
+ void drawEditHandles0(//ClickInfo clickInfo,
7404
+ int level)
73587405 {
73597406 if (level == 0)
73607407 {
....@@ -7363,98 +7410,104 @@
73637410 {
73647411 cVector origin = new cVector();
73657412 //LA.xformPos(origin, toParent, origin);
7366
- Rectangle spot = calcHotSpot(origin, info);
7413
+ if (this.clickInfo == null)
7414
+ this.clickInfo = new ClickInfo();
7415
+
7416
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
73677417 Rectangle boundary = new Rectangle();
73687418 boundary.x = spot.x - 30;
73697419 boundary.y = spot.y - 30;
73707420 boundary.width = spot.width + 60;
73717421 boundary.height = spot.height + 60;
7372
- info.g.setColor(Color.red);
7422
+ clickInfo.g.setColor(Color.white);
73737423 int spotw = spot.x + spot.width;
73747424 int spoth = spot.y + spot.height;
7375
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7376
- if (CameraPane.Xmin > spot.x)
7377
- {
7378
- CameraPane.Xmin = spot.x;
7379
- }
7380
- if (CameraPane.Xmax < spotw)
7381
- {
7382
- CameraPane.Xmax = spotw;
7383
- }
7384
- if (CameraPane.Ymin > spot.y)
7385
- {
7386
- CameraPane.Ymin = spot.y;
7387
- }
7388
- if (CameraPane.Ymax < spoth)
7389
- {
7390
- CameraPane.Ymax = spoth;
7391
- }
7392
- spot.translate(32, 32);
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);
73937465 spotw = spot.x + spot.width;
73947466 spoth = spot.y + spot.height;
7395
- info.g.setColor(Color.blue);
7396
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7397
- if (CameraPane.Xmin > spot.x)
7398
- {
7399
- CameraPane.Xmin = spot.x;
7400
- }
7401
- if (CameraPane.Xmax < spotw)
7402
- {
7403
- CameraPane.Xmax = spotw;
7404
- }
7405
- if (CameraPane.Ymin > spot.y)
7406
- {
7407
- CameraPane.Ymin = spot.y;
7408
- }
7409
- if (CameraPane.Ymax < spoth)
7410
- {
7411
- CameraPane.Ymax = spoth;
7412
- }
7413
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7414
- info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7415
- spot.translate(0, -32);
7416
- info.g.setColor(Color.green);
7417
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7418
- if (CameraPane.Xmin > spot.x)
7419
- {
7420
- CameraPane.Xmin = spot.x;
7421
- }
7422
- if (CameraPane.Xmax < spotw)
7423
- {
7424
- CameraPane.Xmax = spotw;
7425
- }
7426
- if (CameraPane.Ymin > spot.y)
7427
- {
7428
- CameraPane.Ymin = spot.y;
7429
- }
7430
- if (CameraPane.Ymax < spoth)
7431
- {
7432
- CameraPane.Ymax = spoth;
7433
- }
7434
- info.g.drawArc(boundary.x, boundary.y,
7435
- boundary.width, boundary.height, 0, 360);
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);
74367488 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
7437
- if (CameraPane.Xmin > boundary.x)
7438
- {
7439
- CameraPane.Xmin = boundary.x;
7440
- }
7441
- if (CameraPane.Xmax < boundary.x + boundary.width)
7442
- {
7443
- CameraPane.Xmax = boundary.x + boundary.width;
7444
- }
7445
- if (CameraPane.Ymin > boundary.y)
7446
- {
7447
- CameraPane.Ymin = boundary.y;
7448
- }
7449
- if (CameraPane.Ymax < boundary.y + boundary.height)
7450
- {
7451
- CameraPane.Ymax = boundary.y + boundary.height;
7452
- }
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
+// }
74537505 return;
74547506 }
74557507 }
74567508
7457
- boolean doEditClick0(ClickInfo info, int level)
7509
+ boolean doEditClick0(//ClickInfo clickInfo,
7510
+ int level)
74587511 {
74597512 if (level == 0)
74607513 {
....@@ -7463,10 +7516,10 @@
74637516
74647517 boolean retval = false;
74657518
7466
- startX = info.x;
7467
- startY = info.y;
7519
+ startX = clickInfo.x;
7520
+ startY = clickInfo.y;
74687521
7469
- hitSomething = 0;
7522
+ hitSomething = -1;
74707523 cVector origin = new cVector();
74717524 //LA.xformPos(origin, toParent, origin);
74727525 Rectangle spot = new Rectangle();
....@@ -7474,22 +7527,53 @@
74747527 {
74757528 centerPt = new Point(0, 0);
74767529 }
7477
- calcHotSpot(origin, info, centerPt, spot);
7478
- if (spot.contains(info.x, info.y))
7530
+ calcHotSpot(origin, //info,
7531
+ centerPt, spot);
7532
+ if (spot.contains(clickInfo.x, clickInfo.y))
74797533 {
74807534 hitSomething = hitCenter;
74817535 retval = true;
74827536 }
74837537 spot.translate(32, 0);
7484
- if (spot.contains(info.x, info.y))
7538
+ if (spot.contains(clickInfo.x, clickInfo.y))
74857539 {
74867540 hitSomething = hitRotate;
74877541 retval = true;
74887542 }
74897543 spot.translate(0, 32);
7490
- 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))
74917547 {
74927548 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
+
74937577 retval = true;
74947578 }
74957579
....@@ -7499,7 +7583,7 @@
74997583 }
75007584
75017585 //System.out.println("info.modifiers = " + info.modifiers);
7502
- modified = (info.modifiers & CameraPane.META) != 0;
7586
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
75037587 //System.out.println("modified = " + modified);
75047588 //new Exception().printStackTrace();
75057589 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7527,7 +7611,8 @@
75277611 return true;
75287612 }
75297613
7530
- void doEditDrag0(ClickInfo info)
7614
+ void doEditDrag0(//ClickInfo info,
7615
+ boolean opposite)
75317616 {
75327617 if (hitSomething == 0)
75337618 {
....@@ -7541,7 +7626,8 @@
75417626
75427627 //System.out.println("hitSomething = " + hitSomething);
75437628
7544
- double scale = 0.005f * info.camera.Distance();
7629
+ double scale = 0.005f * clickInfo.camera.Distance();
7630
+
75457631 cVector xlate = new cVector();
75467632 //cVector xlate2 = new cVector();
75477633 switch (hitSomething)
....@@ -7552,9 +7638,9 @@
75527638
75537639 case hitCenter: // Translate
75547640
7555
- scale *= 0.05f * info.pane.theRenderer.renderCamera.Distance();
7641
+ scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
75567642
7557
- if (modified)
7643
+ if (modified || opposite)
75587644 {
75597645 //assert(false);
75607646 /*
....@@ -7574,8 +7660,8 @@
75747660 toParent[3][i] = xlate.get(i);
75757661 LA.matInvert(toParent, fromParent);
75767662 */
7577
- cVector delta = LA.newVector(0, 0, startY - info.y);
7578
- 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);
75797665
75807666 LA.matCopy(startMat, toParent);
75817667 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7584,7 +7670,7 @@
75847670 } else
75857671 {
75867672 //LA.xformDir(delta, info.camera.fromScreen, delta);
7587
- cVector up = new cVector(info.camera.up);
7673
+ cVector up = new cVector(clickInfo.camera.up);
75887674 cVector away = new cVector();
75897675 //cVector right2 = new cVector();
75907676 //LA.vecCross(up, cVector.Z, right);
....@@ -7600,20 +7686,20 @@
76007686 }
76017687 LA.xformDir(up, ClickInfo.matbuffer, up);
76027688 // if (!CameraPane.LOCALTRANSFORM)
7603
- LA.xformDir(up, info.pane.theRenderer.renderCamera.toScreen, up);
7604
- 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);
76057691 // if (!CameraPane.LOCALTRANSFORM)
7606
- LA.xformDir(away, info.pane.theRenderer.renderCamera.toScreen, away);
7692
+ LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
76077693 //LA.vecCross(up, cVector.Z, right2);
76087694
7609
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7695
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
76107696
76117697 //System.out.println("DELTA0 = " + delta);
76127698 //System.out.println("AWAY = " + info.camera.away);
76137699 //System.out.println("UP = " + info.camera.up);
76147700 if (away.z > 0)
76157701 {
7616
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7702
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
76177703 {
76187704 delta.x = -delta.x;
76197705 } else
....@@ -7628,7 +7714,7 @@
76287714 //System.out.println("DELTA1 = " + delta);
76297715 LA.xformDir(delta, ClickInfo.matbuffer, delta);
76307716 //System.out.println("DELTA2 = " + delta);
7631
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7717
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
76327718 LA.matCopy(startMat, toParent);
76337719 //System.out.println("DELTA3 = " + delta);
76347720 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7638,8 +7724,8 @@
76387724 break;
76397725
76407726 case hitRotate: // rotate
7641
- int dx = info.x - centerPt.x;
7642
- int dy = -(info.y - centerPt.y);
7727
+ int dx = clickInfo.x - centerPt.x;
7728
+ int dy = -(clickInfo.y - centerPt.y);
76437729 double angle = (double) Math.atan2(dx, dy);
76447730 angle = -(1.570796 - angle);
76457731
....@@ -7648,6 +7734,7 @@
76487734
76497735 if (modified)
76507736 {
7737
+ // Rotate 90 degrees
76517738 angle /= (Math.PI / 4);
76527739 angle = Math.floor(angle + 0.5);
76537740 angle *= (Math.PI / 4);
....@@ -7661,7 +7748,7 @@
76617748 }
76627749 /**/
76637750
7664
- switch (info.pane.renderCamera.viewCode)
7751
+ switch (clickInfo.pane.RenderCamera().viewCode)
76657752 {
76667753 case 1: // '\001'
76677754 LA.matZRotate(toParent, angle);
....@@ -7688,26 +7775,30 @@
76887775 break;
76897776
76907777 case hitScale: // scale
7691
- 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);
76927785 if (hScale < 0.01)
76937786 {
7694
- hScale = 0.01;
7787
+ //hScale = 0.01;
76957788 }
7696
- hScale = Math.pow(hScale, scale * 50);
7697
- if (hScale < 0.01)
7789
+
7790
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
7791
+ sign = 1;
7792
+ if (vScale < 0)
76987793 {
7699
- hScale = 0.01;
7794
+ sign = -1;
77007795 }
7701
- double vScale = (double) (info.y - centerPt.y) / 32;
7796
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
77027797 if (vScale < 0.01)
77037798 {
7704
- vScale = 0.01;
7799
+ //vScale = 0.01;
77057800 }
7706
- vScale = Math.pow(vScale, scale * 50);
7707
- if (vScale < 0.01)
7708
- {
7709
- vScale = 0.01;
7710
- }
7801
+
77117802 LA.matCopy(startMat, toParent);
77127803 /**/
77137804 for (int i = 0; i < 3; i++)
....@@ -7717,39 +7808,56 @@
77177808 }
77187809 /**/
77197810
7720
- 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)
77217819 {
77227820 case 3: // '\001'
7723
- if (modified)
7821
+ if (modified || opposite)
77247822 {
7823
+ if (modified && opposite)
7824
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7825
+ else
77257826 //LA.matScale(toParent, 1, hScale, vScale);
7726
- LA.matScale(toParent, vScale, 1, 1);
7827
+ LA.matScale(toParent, totalScale, 1, 1);
77277828 } // vScale, 1);
77287829 else
77297830 {
7730
- LA.matScale(toParent, vScale, vScale, vScale);
7831
+ // EXCEPTION!
7832
+ LA.matScale(toParent, 1, totalScale, totalScale);
77317833 } // vScale, 1);
77327834 break;
77337835
77347836 case 2: // '\002'
7735
- if (modified)
7837
+ if (modified || opposite)
77367838 {
7737
- //LA.matScale(toParent, hScale, 1, vScale);
7738
- 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);
77397844 } else
77407845 {
7741
- LA.matScale(toParent, vScale, 1, vScale);
7846
+ LA.matScale(toParent, totalScale, 1, totalScale);
77427847 }
77437848 break;
77447849
77457850 case 1: // '\003'
7746
- if (modified)
7851
+ if (modified || opposite)
77477852 {
7748
- //LA.matScale(toParent, hScale, vScale, 1);
7749
- 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);
77507858 } else
77517859 {
7752
- LA.matScale(toParent, vScale, vScale, 1);
7860
+ LA.matScale(toParent, totalScale, totalScale, 1);
77537861 }
77547862 break;
77557863 }
....@@ -7783,7 +7891,7 @@
77837891 } // NEW ...
77847892
77857893
7786
- info.pane.repaint();
7894
+ clickInfo.pane.repaint();
77877895 }
77887896
77897897 boolean overflow = false;
....@@ -7882,14 +7990,22 @@
78827990 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
78837991 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
78847992 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7993
+
7994
+ String objname;
7995
+
78857996 if (false) //parent != null)
78867997 {
7887
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7998
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
78887999 } else
78898000 {
7890
- 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) ":"") */ "";
78918002 } // + super.toString();
78928003 //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);
78938009 }
78948010
78958011 public int hashCode()
....@@ -7945,6 +8061,7 @@
79458061 objectUI.closeUI();
79468062 if (editWindow != null)
79478063 {
8064
+ editWindow.ctrlPanel.FlushUI();
79488065 editWindow.refreshContents();
79498066 } // ? new
79508067 objectUI = null;
....@@ -7953,6 +8070,10 @@
79538070 {
79548071 editWindow = null;
79558072 } // ?
8073
+ }
8074
+ else
8075
+ {
8076
+ //editWindow.closeUI();
79568077 }
79578078 }
79588079
....@@ -7965,7 +8086,7 @@
79658086 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
79668087
79678088 Object3D /*Composite*/ parent;
7968
- Object3D /*Composite*/ fileparent;
8089
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
79698090
79708091 double[][] toParent; // dynamic matrix
79718092 double[][] fromParent;
....@@ -8080,7 +8201,7 @@
80808201 {
80818202 assert(bRep != null);
80828203 if (!(support instanceof GenericJoint)) // support.bRep != null)
8083
- GrafreeD.Assert(support.bRep == bRep.support);
8204
+ Grafreed.Assert(support.bRep == bRep.support);
80848205 }
80858206 else
80868207 {
....@@ -8111,6 +8232,10 @@
81118232 }
81128233
81138234 transient ObjEditor editWindow;
8235
+ transient ObjEditor manipWindow;
8236
+
8237
+ transient boolean pinned;
8238
+
81148239 transient ObjectUI objectUI;
81158240 public static int povDepth = 0;
81168241 private static cVector tbMin = new cVector();
....@@ -8129,9 +8254,9 @@
81298254 private static cVector edge2 = new cVector();
81308255 //private static cVector norm = new cVector();
81318256 /*transient private*/ int hitSomething;
8132
- private static final int hitCenter = 1;
8133
- private static final int hitScale = 2;
8134
- private static final int hitRotate = 3;
8257
+ static final int hitCenter = 1;
8258
+ static final int hitScale = 2;
8259
+ static final int hitRotate = 3;
81358260 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
81368261 /*transient*/ private Point centerPt;
81378262 /*transient*/ private int startX;
....@@ -8163,6 +8288,8 @@
81638288 {
81648289 Object3D targ = this;
81658290
8291
+ targ.NORMALPUSH = obj.NORMALPUSH;
8292
+
81668293 if (obj.material != null)
81678294 {
81688295 if ((mask&MATERIAL)!=0) // ==(COLOR|MATERIAL))