Normand Briere
2019-08-15 24a2a946b35279605e645349bd6b82e9e60aac88
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,42 @@
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
+
2239 ScriptNode scriptnode;
40
+
41
+ void InitOthers()
42
+ {
43
+ if (projectedVertices == null || projectedVertices.length <= 2)
44
+ {
45
+ projectedVertices = new Object3D.cVector2[3];
46
+ }
47
+ for (int i = 0; i < 3; i++)
48
+ {
49
+ projectedVertices[i] = new cVector2(); // Others
50
+ }
51
+ projectedVertices[0].x = 100; // bump
52
+ }
2353
2454 void MinMax(cVector minima, cVector maxima)
2555 {
....@@ -86,64 +116,201 @@
86116
87117 // transient boolean reduced; // for morph reduction
88118
89
-transient com.bulletphysics.linearmath.Transform cache; // for fast merge
90
-transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
119
+ transient com.bulletphysics.linearmath.Transform cache; // for fast merge
120
+ transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
91121
92
-transient Object3D transientsupport; // for cloning
93
-transient boolean transientlink2master;
122
+ transient Object3D transientsupport; // for cloning
123
+ transient boolean transientlink2master;
94124
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)
125
+ void SaveSupports()
107126 {
108
- bRep.SaveSupports();
127
+ if (blockloop)
128
+ return;
129
+
130
+ transientsupport = support;
131
+ transientlink2master = link2master;
132
+
133
+ support = null;
134
+ link2master = false;
135
+
136
+ if (bRep != null)
137
+ {
138
+ bRep.SaveSupports();
139
+ }
140
+
141
+ for (int i = 0; i < Size(); i++)
142
+ {
143
+ Object3D child = (Object3D) get(i);
144
+ if (child == null)
145
+ continue;
146
+ blockloop = true;
147
+ child.SaveSupports();
148
+ blockloop = false;
149
+ }
109150 }
110
-
111
- for (int i = 0; i < Size(); i++)
151
+
152
+ void RestoreSupports()
112153 {
113
- Object3D child = (Object3D) get(i);
114
- if (child == null)
115
- continue;
154
+ if (blockloop)
155
+ return;
156
+
157
+ support = transientsupport;
158
+ link2master = transientlink2master;
159
+ transientsupport = null;
160
+ transientlink2master = false;
161
+
162
+ if (bRep != null)
163
+ {
164
+ bRep.RestoreSupports();
165
+ }
166
+
167
+ for (int i = 0; i < Size(); i++)
168
+ {
169
+ Object3D child = (Object3D) get(i);
170
+ if (child == null)
171
+ continue;
172
+ blockloop = true;
173
+ child.RestoreSupports();
174
+ blockloop = false;
175
+ }
176
+ }
177
+
178
+ void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
179
+ {
180
+ Object3D o;
181
+
182
+ if (hashtable.containsKey(GetUUID()))
183
+ {
184
+ o = hashtable.get(GetUUID());
185
+
186
+ Grafreed.Assert(this.bRep == o.bRep);
187
+ //if (this.bRep != null)
188
+ // assert(this.bRep.support == o.transientrep);
189
+ if (this.support != null)
190
+ assert(this.support.bRep == o.transientrep);
191
+ }
192
+ else
193
+ {
194
+ o = new Object3D("copy of " + this.name);
195
+
196
+ hashtable.put(GetUUID(), o);
197
+ }
198
+
199
+ if (!blockloop)
200
+ {
201
+ blockloop = true;
202
+
203
+ for (int i=0; i<Size(); i++)
204
+ {
205
+ get(i).ExtractBigData(hashtable);
206
+ }
207
+
208
+ blockloop = false;
209
+ }
210
+
211
+ ExtractBigData(o);
212
+ }
213
+
214
+ void ExtractBigData(Object3D o)
215
+ {
216
+ if (o.bRep != null)
217
+ Grafreed.Assert(o.bRep == this.bRep);
218
+
219
+ o.bRep = this.bRep;
220
+// July 2019 if (this.bRep != null)
221
+// {
222
+// o.transientrep = this.bRep.support;
223
+// o.bRep.support = null;
224
+// }
225
+ o.selection = this.selection;
226
+ o.versionlist = this.versionlist;
227
+ o.versionindex = this.versionindex;
228
+
229
+ if (this.support != null)
230
+ {
231
+ if (o.transientrep != null)
232
+ Grafreed.Assert(o.transientrep == this.support.bRep);
233
+
234
+ o.transientrep = this.support.bRep;
235
+ this.support.bRep = null;
236
+ }
237
+
238
+ // o.support = this.support;
239
+ // o.fileparent = this.fileparent;
240
+ // if (this.bRep != null)
241
+ // o.bRep = this.bRep.support;
242
+
243
+ this.bRep = null;
244
+ // if (this.bRep != null)
245
+ // this.bRep.support = null;
246
+ // this.support = null;
247
+ // this.fileparent = null;
248
+ }
249
+
250
+// Object3D GetObject(java.util.UUID uuid)
251
+// {
252
+// if (this.uuid.equals(uuid))
253
+// return this;
254
+//
255
+// if (blockloop)
256
+// return null;
257
+//
258
+// blockloop = true;
259
+//
260
+// for (int i=0; i<Size(); i++)
261
+// {
262
+// Object3D o = get(i).GetObject(uuid);
263
+//
264
+// if (o != null)
265
+// return o;
266
+// }
267
+//
268
+// blockloop = false;
269
+//
270
+// return null;
271
+// }
272
+
273
+ void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
274
+ {
275
+ if (!hashtable.containsKey(GetUUID()))
276
+ return;
277
+
278
+ Object3D o = hashtable.get(GetUUID());
279
+
280
+ RestoreBigData(o);
281
+
282
+ if (blockloop)
283
+ return;
284
+
116285 blockloop = true;
117
- child.SaveSupports();
286
+
287
+ //hashtable.remove(GetUUID());
288
+
289
+ for (int i=0; i<Size(); i++)
290
+ {
291
+ get(i).RestoreBigData(hashtable);
292
+ }
293
+
118294 blockloop = false;
119295 }
120
-}
121296
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)
297
+ void RestoreBigData(Object3D o)
133298 {
134
- bRep.RestoreSupports();
299
+ this.bRep = o.bRep;
300
+ if (this.support != null && o.transientrep != null)
301
+ {
302
+ this.support.bRep = o.transientrep;
303
+ }
304
+
305
+ this.selection = o.selection;
306
+
307
+ this.versionlist = o.versionlist;
308
+ this.versionindex = o.versionindex;
309
+// July 2019 if (this.bRep != null)
310
+// this.bRep.support = o.transientrep;
311
+ // this.support = o.support;
312
+ // this.fileparent = o.fileparent;
135313 }
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
-}
147314
148315 // MOCAP SUPPORT
149316 double tx,ty,tz,rx,ry,rz;
....@@ -285,8 +452,9 @@
285452 return parent.GetName() + "#";
286453 }
287454
288
- boolean timeline = false;
289455 boolean live = false;
456
+ transient boolean keepdontselect;
457
+ boolean dontselect = false;
290458 boolean hide = false;
291459 boolean link2master = false; // performs reset support/master at each frame
292460 boolean marked = false; // animation node
....@@ -296,6 +464,8 @@
296464 boolean random = false;
297465 boolean speedup = false;
298466 boolean rewind = false;
467
+
468
+ float NORMALPUSH = 0;
299469
300470 Object3D support;
301471
....@@ -416,16 +586,16 @@
416586 {
417587 Object3D copy = this;
418588
419
- Camera parentcam = CameraPane.theRenderer.manipCamera;
589
+ Camera parentcam = Globals.theRenderer.ManipCamera();
420590
421
- if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[0])
591
+ if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[0])
422592 {
423
- parentcam = CameraPane.theRenderer.cameras[1];
593
+ parentcam = Globals.theRenderer.Cameras()[1];
424594 }
425595
426
- if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[1])
596
+ if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[1])
427597 {
428
- parentcam = CameraPane.theRenderer.cameras[0];
598
+ parentcam = Globals.theRenderer.Cameras()[0];
429599 }
430600
431601 if (this == parentcam)
....@@ -433,7 +603,7 @@
433603 //assert(this instanceof Camera);
434604
435605 for (int count = parentcam.GetTransformCount(); --count>=0;)
436
- LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.toParent, CameraPane.theRenderer.targetLookAt);
606
+ LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.toParent, Globals.theRenderer.TargetLookAt());
437607 }
438608
439609 copy.marked ^= true;
....@@ -453,7 +623,7 @@
453623 //assert(this instanceof Camera);
454624
455625 for (int count = parentcam.GetTransformCount(); --count>=0;)
456
- LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.fromParent, CameraPane.theRenderer.targetLookAt);
626
+ LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.fromParent, Globals.theRenderer.TargetLookAt());
457627 }
458628
459629 copy.Touch(); // display list issue
....@@ -466,12 +636,14 @@
466636 toParent = LA.newMatrix();
467637 fromParent = LA.newMatrix();
468638 }
639
+
469640 if (toParentMarked == null)
470641 {
471642 if (maxcount != 1)
472643 {
473644 new Exception().printStackTrace();
474645 }
646
+
475647 toParentMarked = LA.newMatrix();
476648 fromParentMarked = LA.newMatrix();
477649 }
....@@ -588,7 +760,7 @@
588760 return;
589761 }
590762
591
- if (CameraPane.fromscript)
763
+ if (Globals.fromscript)
592764 {
593765 transformcount = 0;
594766 return;
....@@ -746,7 +918,7 @@
746918
747919 int GetTransformCount()
748920 {
749
- // marde pour serialization de Texture
921
+ // patch pour serialization de Texture
750922 resetmaxcount();
751923 resettransformcount();
752924 resetstep();
....@@ -759,7 +931,7 @@
759931 if (step == 0)
760932 step = 1;
761933 if (maxcount == 0)
762
- maxcount = 2048; // 4;
934
+ maxcount = 128; // 2048; // 4;
763935 // if (acceleration == 0)
764936 // acceleration = 10;
765937 if (delay == 0) // serial
....@@ -780,9 +952,12 @@
780952 // factor = CameraPane.STEP;
781953 // }
782954
783
- if (marked && CameraPane.isLIVE() && live && CameraPane.drawMode == CameraPane.SHADOW && currentframe != CameraPane.framecount)
955
+ if (marked && Globals.isLIVE() && live &&
956
+ //TEMP21aug2018
957
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
958
+ currentframe != Globals.framecount)
784959 {
785
- currentframe = CameraPane.framecount;
960
+ currentframe = Globals.framecount;
786961
787962 // System.err.println("transformcount = " + transformcount);
788963 // System.err.println("factor = " + factor);
....@@ -791,7 +966,8 @@
791966
792967 boolean changedir = random && Math.random() < 0.01; // && !link2master;
793968
794
- if (transformcount*factor > maxcount || (step == 1 && changedir))
969
+ if (transformcount*factor >= maxcount && (rewind || random) ||
970
+ (step == 1 && changedir))
795971 {
796972 countdown = 1;
797973 delay = speedup?8:1;
....@@ -863,6 +1039,10 @@
8631039 if (material == null || material.multiply)
8641040 return true;
8651041
1042
+ if (projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
1043
+ return false;
1044
+
1045
+ // Transparent objects are dynamic because we have to sort the triangles.
8661046 return material.opacity > 0.99;
8671047 }
8681048
....@@ -894,6 +1074,11 @@
8941074 fromParent = null; // LA.newMatrix();
8951075 bRep = null; // new BoundaryRep();
8961076
1077
+ if (oname != null && oname.equals("LeftHand"))
1078
+ {
1079
+ name = oname;
1080
+ }
1081
+
8971082 /*
8981083 float hue = (float)Math.random();
8991084 Color col;
....@@ -936,7 +1121,7 @@
9361121
9371122 public Object clone()
9381123 {
939
- return GrafreeD.clone(this);
1124
+ return Grafreed.clone(this);
9401125 }
9411126
9421127 Object3D copyExpand()
....@@ -1258,6 +1443,7 @@
12581443 toParent = LA.newMatrix();
12591444 fromParent = LA.newMatrix();
12601445 }
1446
+
12611447 LA.matCopy(other.toParent, toParent);
12621448 LA.matCopy(other.fromParent, fromParent);
12631449
....@@ -1452,7 +1638,7 @@
14521638 BoundaryRep.SEUIL = other.material.cameralight;
14531639
14541640 // Set default to 0.1
1455
- BoundaryRep.SEUIL /= 2;
1641
+ BoundaryRep.SEUIL /= 4; // 2;
14561642 System.out.println("SEUIL = " + BoundaryRep.SEUIL);
14571643 }
14581644
....@@ -1711,7 +1897,7 @@
17111897 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17121898 o.bRep = transientrep;
17131899 if (clone)
1714
- o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
1900
+ o.bRep = (BoundaryRep) Grafreed.clone(transientrep);
17151901 o.CreateMaterial();
17161902 o.SetAttributes(this, -1);
17171903 //parent
....@@ -1724,7 +1910,7 @@
17241910 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17251911 o.bRep = bRep;
17261912 if (clone)
1727
- o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
1913
+ o.bRep = (BoundaryRep) Grafreed.clone(bRep);
17281914 o.CreateMaterial();
17291915 //o.overwriteThis(this, -1);
17301916 o.SetAttributes(this, -1);
....@@ -1811,12 +1997,15 @@
18111997 if (obj.name == null)
18121998 continue; // can't be a null one
18131999
2000
+ // Try perfect match first.
18142001 if (n.equals(obj.name))
18152002 {
18162003 theobj = obj;
18172004 count++;
18182005 }
18192006 }
2007
+
2008
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18202009
18212010 if (count != 1)
18222011 for (int i=Size(); --i>=0;)
....@@ -2131,15 +2320,8 @@
21312320 if (/*parent != null &&*/ material == null)
21322321 {
21332322 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
2323
+
2324
+ InitOthers();
21432325
21442326 if (this instanceof Camera)
21452327 {
....@@ -2283,12 +2465,22 @@
22832465 }
22842466 */
22852467 }
2468
+ else
2469
+ {
2470
+ //((ObjEditor)editWindow).SetupUI2(null);
2471
+ if (objectUI != null)
2472
+ ((ObjEditor)objectUI).pinButton.setSelected(pinned);
2473
+ else
2474
+ //new Exception().printStackTrace();
2475
+ System.err.println("objectUI is null");
2476
+ }
22862477 }
22872478
22882479 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
22892480 {
22902481 if (newWindow)
22912482 {
2483
+ new Exception().printStackTrace();
22922484 System.exit(0);
22932485 if (parent != null)
22942486 {
....@@ -2323,6 +2515,14 @@
23232515 {
23242516 editWindow.refreshContents();
23252517 }
2518
+ else
2519
+ {
2520
+ if (manipWindow != null)
2521
+ {
2522
+ manipWindow.refreshContents();
2523
+ }
2524
+ }
2525
+
23262526 //if (parent != null)
23272527 //parent.refreshEditWindow();
23282528 }
....@@ -2402,7 +2602,8 @@
24022602 private static final int editSelf = 1;
24032603 private static final int editChild = 2;
24042604
2405
- void drawEditHandles(ClickInfo info, int level)
2605
+ void drawEditHandles(//ClickInfo info,
2606
+ int level)
24062607 {
24072608 if (level == 0)
24082609 {
....@@ -2410,7 +2611,8 @@
24102611 return;
24112612
24122613 Object3D selectee;
2413
- for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(info, level + 1))
2614
+ for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(//info,
2615
+ level + 1))
24142616 {
24152617 selectee = (Object3D) e.nextElement();
24162618 }
....@@ -2418,19 +2620,22 @@
24182620 } else
24192621 {
24202622 //super.
2421
- drawEditHandles0(info, level + 1);
2623
+ drawEditHandles0(//info,
2624
+ level + 1);
24222625 }
24232626 }
24242627
2425
- boolean doEditClick(ClickInfo info, int level)
2628
+ boolean doEditClick(//ClickInfo info,
2629
+ int level)
24262630 {
24272631 doSomething = 0;
24282632 if (level == 0)
24292633 {
2430
- return doParentClick(info);
2634
+ return doParentClick(); //info);
24312635 }
24322636 if (//super.
2433
- doEditClick0(info, level))
2637
+ doEditClick0(//info,
2638
+ level))
24342639 {
24352640 doSomething = 1;
24362641 return true;
....@@ -2440,7 +2645,7 @@
24402645 }
24412646 }
24422647
2443
- boolean doParentClick(ClickInfo info)
2648
+ boolean doParentClick() //ClickInfo info)
24442649 {
24452650 if (selection == null)
24462651 {
....@@ -2453,7 +2658,8 @@
24532658 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
24542659 {
24552660 Object3D selectee = (Object3D) e.nextElement();
2456
- if (selectee.doEditClick(info, 1))
2661
+ if (selectee.doEditClick(//info,
2662
+ 1))
24572663 {
24582664 childToDrag = selectee;
24592665 doSomething = 2;
....@@ -2465,13 +2671,15 @@
24652671 return retval;
24662672 }
24672673
2468
- void doEditDrag(ClickInfo info)
2674
+ void doEditDrag(//ClickInfo clickInfo,
2675
+ boolean opposite)
24692676 {
24702677 switch (doSomething)
24712678 {
24722679 case 1: // '\001'
24732680 //super.
2474
- doEditDrag0(info);
2681
+ doEditDrag0(//clickInfo,
2682
+ opposite);
24752683 break;
24762684
24772685 case 2: // '\002'
....@@ -2484,11 +2692,13 @@
24842692 {
24852693 //sel.hitSomething = childToDrag.hitSomething;
24862694 //childToDrag.doEditDrag(info);
2487
- sel.doEditDrag(info);
2695
+ sel.doEditDrag(//clickInfo,
2696
+ opposite);
24882697 } else
24892698 {
24902699 //super.
2491
- doEditDrag0(info);
2700
+ doEditDrag0(//clickInfo,
2701
+ opposite);
24922702 }
24932703 }
24942704 break;
....@@ -2506,6 +2716,9 @@
25062716 {
25072717 deselectAll();
25082718 }
2719
+
2720
+ new Exception().printStackTrace();
2721
+
25092722 ClickInfo newInfo = new ClickInfo();
25102723 newInfo.flags = info.flags;
25112724 newInfo.bounds = info.bounds;
....@@ -2598,6 +2811,18 @@
25982811 void GenNormalsS(boolean crease)
25992812 {
26002813 selection.GenNormals(crease);
2814
+// for (int i=0; i<selection.size(); i++)
2815
+// {
2816
+// Object3D selectee = (Object3D) selection.elementAt(i);
2817
+// selectee.GenNormals(crease);
2818
+// }
2819
+
2820
+ //Touch();
2821
+ }
2822
+
2823
+ void GenNormalsMeshS()
2824
+ {
2825
+ selection.GenNormalsMesh();
26012826 // for (int i=0; i<selection.size(); i++)
26022827 // {
26032828 // Object3D selectee = (Object3D) selection.elementAt(i);
....@@ -2738,6 +2963,24 @@
27382963 if (child == null)
27392964 continue;
27402965 child.GenNormals(crease);
2966
+// Children().release(i);
2967
+ }
2968
+ blockloop = false;
2969
+ }
2970
+
2971
+ void GenNormalsMesh()
2972
+ {
2973
+ if (blockloop)
2974
+ return;
2975
+
2976
+ blockloop = true;
2977
+ GenNormalsMesh0();
2978
+ for (int i = 0; i < Children().Size(); i++)
2979
+ {
2980
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2981
+ if (child == null)
2982
+ continue;
2983
+ child.GenNormalsMesh();
27412984 // Children().release(i);
27422985 }
27432986 blockloop = false;
....@@ -2895,7 +3138,8 @@
28953138 {
28963139 if (bRep != null)
28973140 {
2898
- bRep.GenUV();
3141
+ bRep.GenUV(); //1);
3142
+ //bRep.UnfoldUV();
28993143 Touch();
29003144 }
29013145 }
....@@ -2909,11 +3153,20 @@
29093153 }
29103154 }
29113155
3156
+ void GenNormalsMesh0()
3157
+ {
3158
+ if (bRep != null)
3159
+ {
3160
+ bRep.GenerateNormalsMesh();
3161
+ Touch();
3162
+ }
3163
+ }
3164
+
29123165 void GenNormalsMINE0()
29133166 {
29143167 if (bRep != null)
29153168 {
2916
- bRep.GenerateNormalsMINE();
3169
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
29173170 Touch();
29183171 }
29193172 }
....@@ -2970,6 +3223,33 @@
29703223 blockloop = false;
29713224 }
29723225
3226
+ void TransformChildren()
3227
+ {
3228
+ if (toParent != null)
3229
+ {
3230
+ for (int i=Size(); --i>=0;)
3231
+ {
3232
+ Object3D v = get(i);
3233
+
3234
+ if (v.toParent == null)
3235
+ {
3236
+ v.toParent = LA.newMatrix();
3237
+ v.fromParent = LA.newMatrix();
3238
+ }
3239
+
3240
+// LA.matConcat(v.toParent, toParent, v.toParent);
3241
+// LA.matConcat(fromParent, v.fromParent, v.fromParent);
3242
+ LA.matConcat(toParent, v.toParent, v.toParent);
3243
+ LA.matConcat(v.fromParent, fromParent, v.fromParent);
3244
+ }
3245
+
3246
+ toParent = null; // LA.matIdentity(toParent);
3247
+ fromParent = null; // LA.matIdentity(fromParent);
3248
+
3249
+ Touch();
3250
+ }
3251
+ }
3252
+
29733253 void TransformGeometry()
29743254 {
29753255 Object3D obj = this;
....@@ -3191,9 +3471,11 @@
31913471
31923472 BoundaryRep sup = bRep.support;
31933473 bRep.support = null;
3194
- BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
3474
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
31953475 // bRep.SplitInTwo(onlyone); // thread...
3196
- temprep.SplitInTwo(reduction34, onlyone);
3476
+
3477
+ while(temprep.SplitInTwo(reduction34, onlyone));
3478
+
31973479 bRep = temprep;
31983480 bRep.support = sup;
31993481 Touch();
....@@ -3330,7 +3612,8 @@
33303612 if (blockloop)
33313613 return;
33323614
3333
- if (marked || (bRep != null && material != null)) // borderline...
3615
+ if (//marked || // does not make sense
3616
+ (bRep != null || material != null)) // borderline...
33343617 live = h;
33353618
33363619 for (int i = 0; i < Size(); i++)
....@@ -3351,7 +3634,8 @@
33513634 return;
33523635
33533636 //if (bRep != null)
3354
- if (marked || (bRep != null && material != null)) // borderline...
3637
+ if (//marked || // does not make sense
3638
+ (bRep != null || material != null)) // borderline...
33553639 link2master = h;
33563640
33573641 for (int i = 0; i < Size(); i++)
....@@ -3371,7 +3655,8 @@
33713655 if (blockloop)
33723656 return;
33733657
3374
- if (marked || (bRep != null && material != null)) // borderline...
3658
+ if (//marked || // does not make sense
3659
+ (bRep != null || material != null)) // borderline...
33753660 hide = h;
33763661
33773662 for (int i = 0; i < Size(); i++)
....@@ -3391,7 +3676,7 @@
33913676 if (blockloop)
33923677 return;
33933678
3394
- if (bRep != null && material != null) // borderline...
3679
+ if (bRep != null || material != null) // borderline...
33953680 marked = h;
33963681
33973682 for (int i = 0; i < Size(); i++)
....@@ -3401,6 +3686,46 @@
34013686 continue;
34023687 blockloop = true;
34033688 child.MarkLeaves(h);
3689
+ blockloop = false;
3690
+ // release(i);
3691
+ }
3692
+ }
3693
+
3694
+ void RewindLeaves(boolean h)
3695
+ {
3696
+ if (blockloop)
3697
+ return;
3698
+
3699
+ if (bRep != null || material != null) // borderline...
3700
+ rewind = h;
3701
+
3702
+ for (int i = 0; i < Size(); i++)
3703
+ {
3704
+ Object3D child = (Object3D) get(i); // reserve(i);
3705
+ if (child == null)
3706
+ continue;
3707
+ blockloop = true;
3708
+ child.RewindLeaves(h);
3709
+ blockloop = false;
3710
+ // release(i);
3711
+ }
3712
+ }
3713
+
3714
+ void RandomLeaves(boolean h)
3715
+ {
3716
+ if (blockloop)
3717
+ return;
3718
+
3719
+ if (bRep != null || material != null) // borderline...
3720
+ random = h;
3721
+
3722
+ for (int i = 0; i < Size(); i++)
3723
+ {
3724
+ Object3D child = (Object3D) get(i); // reserve(i);
3725
+ if (child == null)
3726
+ continue;
3727
+ blockloop = true;
3728
+ child.RandomLeaves(h);
34043729 blockloop = false;
34053730 // release(i);
34063731 }
....@@ -3715,7 +4040,7 @@
37154040 if (child == null)
37164041 continue;
37174042
3718
- if (GrafreeD.RENDERME > 0)
4043
+ if (Grafreed.RENDERME > 0)
37194044 {
37204045 if (child instanceof Merge)
37214046 ((Merge)child).renderme();
....@@ -3866,7 +4191,7 @@
38664191 if (child == null)
38674192 continue;
38684193
3869
- if (GrafreeD.RENDERME > 0)
4194
+ if (Grafreed.RENDERME > 0)
38704195 {
38714196 if (child instanceof Merge)
38724197 ((Merge)child).renderme();
....@@ -4061,7 +4386,7 @@
40614386 if (child == null)
40624387 continue;
40634388
4064
- if (GrafreeD.RENDERME > 0)
4389
+ if (Grafreed.RENDERME > 0)
40654390 {
40664391 if (child instanceof Merge)
40674392 ((Merge)child).renderme();
....@@ -4158,6 +4483,71 @@
41584483 }
41594484 blockloop = true;
41604485 get(i).RepairParent();
4486
+ blockloop = false;
4487
+ }
4488
+ }
4489
+
4490
+ void RepairShadow()
4491
+ {
4492
+ if (blockloop)
4493
+ return;
4494
+
4495
+ if (this.material != null)
4496
+ this.InitOthers();
4497
+
4498
+ for (int i=0; i<Size(); i++)
4499
+ {
4500
+ blockloop = true;
4501
+ get(i).RepairShadow();
4502
+ blockloop = false;
4503
+ }
4504
+ }
4505
+
4506
+ void RepairSOV()
4507
+ {
4508
+ if (blockloop)
4509
+ return;
4510
+
4511
+ String texname = this.GetPigmentTexture();
4512
+
4513
+ if (texname.startsWith("sov"))
4514
+ {
4515
+ String[] s = texname.split("/");
4516
+
4517
+ String[] sname = s[1].split("Color.pn");
4518
+
4519
+ texname = sname[0];
4520
+
4521
+ if (sname.length > 1)
4522
+ {
4523
+ texname += "Color.jpg";
4524
+ }
4525
+
4526
+ this.SetPigmentTexture("sov/" + texname);
4527
+ }
4528
+
4529
+ texname = this.GetBumpTexture();
4530
+
4531
+ if (texname.startsWith("sov"))
4532
+ {
4533
+ String[] s = texname.split("/");
4534
+
4535
+ String[] sname = s[1].split("Bump.pn");
4536
+
4537
+ texname = sname[0];
4538
+
4539
+ if (sname.length > 1)
4540
+ {
4541
+ texname += "Bump.jpg";
4542
+ }
4543
+
4544
+ this.SetBumpTexture("sov/" + texname);
4545
+ }
4546
+
4547
+ for (int i=0; i<Size(); i++)
4548
+ {
4549
+ blockloop = true;
4550
+ get(i).RepairSOV();
41614551 blockloop = false;
41624552 }
41634553 }
....@@ -4652,7 +5042,7 @@
46525042
46535043 cTreePath SelectLeaf(int indexcount, boolean deselect)
46545044 {
4655
- if (hide)
5045
+ if (hide || dontselect)
46565046 return null;
46575047
46585048 if (count <= 0)
....@@ -4676,9 +5066,17 @@
46765066 }
46775067 }
46785068
5069
+ ObjEditor GetWindow()
5070
+ {
5071
+ if (editWindow != null)
5072
+ return editWindow;
5073
+
5074
+ return manipWindow;
5075
+ }
5076
+
46795077 cTreePath Select(int indexcount, boolean deselect)
46805078 {
4681
- if (hide)
5079
+ if (hide || dontselect)
46825080 return null;
46835081
46845082 if (count <= 0)
....@@ -4712,10 +5110,11 @@
47125110 if (leaf != null)
47135111 {
47145112 cTreePath tp = new cTreePath(this, leaf);
4715
- if (editWindow != null)
5113
+ ObjEditor window = GetWindow();
5114
+ if (window != null)
47165115 {
47175116 //System.out.println("editWindow = " + editWindow + " vs " + this);
4718
- editWindow.Select(tp, deselect, true);
5117
+ window.Select(tp, deselect, true);
47195118 }
47205119
47215120 return tp;
....@@ -4732,6 +5131,7 @@
47325131
47335132 if (child == null)
47345133 continue;
5134
+
47355135 if (child.HasTransparency() && child.size() != 0)
47365136 {
47375137 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4741,9 +5141,10 @@
47415141 if (leaf != null)
47425142 {
47435143 cTreePath tp = new cTreePath(this, leaf);
4744
- if (editWindow != null)
5144
+ ObjEditor window = GetWindow();
5145
+ if (window != null)
47455146 {
4746
- editWindow.Select(tp, deselect, true);
5147
+ window.Select(tp, deselect, true);
47475148 }
47485149
47495150 return tp;
....@@ -4828,7 +5229,7 @@
48285229 return globalTransform;
48295230 }
48305231
4831
- void PreprocessOcclusion(CameraPane cp)
5232
+ void PreprocessOcclusion(iCameraPane cp)
48325233 {
48335234 /*
48345235 if (AOdone)
....@@ -4975,7 +5376,8 @@
49755376 } else //
49765377 if (editWindow != null)
49775378 {
4978
- editWindow.cameraView.lighttouched = true;
5379
+ //editWindow.cameraView.lighttouched = true;
5380
+ Globals.lighttouched = true;
49795381 }
49805382 }
49815383
....@@ -5067,6 +5469,51 @@
50675469 blockloop = false;
50685470 }
50695471
5472
+ void ResetSelectable()
5473
+ {
5474
+ if (blockloop)
5475
+ return;
5476
+
5477
+ blockloop = true;
5478
+
5479
+ keepdontselect = dontselect;
5480
+ dontselect = true;
5481
+
5482
+ Object3D child;
5483
+ int nb = Size();
5484
+ for (int i = 0; i < nb; i++)
5485
+ {
5486
+ child = (Object3D) get(i);
5487
+ if (child == null)
5488
+ continue;
5489
+ child.ResetSelectable();
5490
+ }
5491
+
5492
+ blockloop = false;
5493
+ }
5494
+
5495
+ void RestoreSelectable()
5496
+ {
5497
+ if (blockloop)
5498
+ return;
5499
+
5500
+ blockloop = true;
5501
+
5502
+ dontselect = keepdontselect;
5503
+
5504
+ Object3D child;
5505
+ int nb = Size();
5506
+ for (int i = 0; i < nb; i++)
5507
+ {
5508
+ child = (Object3D) get(i);
5509
+ if (child == null)
5510
+ continue;
5511
+ child.RestoreSelectable();
5512
+ }
5513
+
5514
+ blockloop = false;
5515
+ }
5516
+
50705517 boolean IsSelected()
50715518 {
50725519 if (parent == null)
....@@ -5127,12 +5574,41 @@
51275574 if (fullname == null)
51285575 return "";
51295576
5577
+ if (fullname.pigment != null)
5578
+ {
5579
+ return fullname.pigment;
5580
+ }
5581
+
51305582 // System.out.println("Fullname = " + fullname);
51315583
5132
- if (fullname.name.indexOf(":") == -1)
5133
- return fullname.name;
5584
+ // Does not work on Windows due to C:
5585
+// if (fullname.name.indexOf(":") == -1)
5586
+// return fullname.name;
5587
+//
5588
+// return fullname.name.substring(0,fullname.name.indexOf(":"));
51345589
5135
- return fullname.name.substring(0,fullname.name.indexOf(":"));
5590
+ String[] split = fullname.name.split(":");
5591
+
5592
+ if (split.length == 0)
5593
+ {
5594
+ return fullname.pigment = "";
5595
+ }
5596
+
5597
+ if (split.length <= 2)
5598
+ {
5599
+ if (fullname.name.endsWith(":"))
5600
+ {
5601
+ // Windows
5602
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
5603
+ }
5604
+
5605
+ return fullname.pigment = split[0];
5606
+ }
5607
+
5608
+ // Windows
5609
+ assert(split.length == 4);
5610
+
5611
+ return fullname.pigment = split[0] + ":" + split[1];
51365612 }
51375613
51385614 static String GetBump(cTexture fullname)
....@@ -5140,11 +5616,44 @@
51405616 if (fullname == null)
51415617 return "";
51425618
5619
+ if (fullname.bump != null)
5620
+ {
5621
+ return fullname.bump;
5622
+ }
5623
+
51435624 // 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());
5625
+ // Does not work on Windows due to C:
5626
+// if (fullname.name.indexOf(":") == -1)
5627
+// return "";
5628
+//
5629
+// return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5630
+ String[] split = fullname.name.split(":");
5631
+
5632
+ if (split.length == 0)
5633
+ {
5634
+ return fullname.bump = "";
5635
+ }
5636
+
5637
+ if (split.length == 1)
5638
+ {
5639
+ return fullname.bump = "";
5640
+ }
5641
+
5642
+ if (split.length == 2)
5643
+ {
5644
+ if (fullname.name.endsWith(":"))
5645
+ {
5646
+ // Windows
5647
+ return fullname.bump = "";
5648
+ }
5649
+
5650
+ return fullname.bump = split[1];
5651
+ }
5652
+
5653
+ // Windows
5654
+ assert(split.length == 4);
5655
+
5656
+ return fullname.bump = split[2] + ":" + split[3];
51485657 }
51495658
51505659 String GetPigmentTexture()
....@@ -5218,7 +5727,7 @@
52185727 System.out.print("; textures = " + textures);
52195728 System.out.println("; usedtextures = " + usedtextures);
52205729
5221
- if (GetTextures() == null)
5730
+ if (GetTextures() == null) // What is that??
52225731 GetTextures().name = ":";
52235732
52245733 String texname = tex;
....@@ -5227,6 +5736,9 @@
52275736 texname = "";
52285737
52295738 GetTextures().name = texname + ":" + GetBump(GetTextures());
5739
+
5740
+ GetTextures().pigment = null;
5741
+
52305742 Touch();
52315743 }
52325744
....@@ -5251,6 +5763,43 @@
52515763 }
52525764 }
52535765
5766
+ UUID GetUUID()
5767
+ {
5768
+ if (uuid == null)
5769
+ {
5770
+ // Serial
5771
+ uuid = UUID.randomUUID();
5772
+ }
5773
+
5774
+ return uuid;
5775
+ }
5776
+
5777
+ Object3D GetObject(UUID uid)
5778
+ {
5779
+ if (blockloop)
5780
+ return null;
5781
+
5782
+ if (GetUUID().equals(uid))
5783
+ return this;
5784
+
5785
+ int nb = Size();
5786
+ for (int i = 0; i < nb; i++)
5787
+ {
5788
+ Object3D child = (Object3D) get(i);
5789
+
5790
+ if (child == null)
5791
+ continue;
5792
+
5793
+ blockloop = true;
5794
+ Object3D obj = child.GetObject(uid);
5795
+ blockloop = false;
5796
+ if (obj != null)
5797
+ return obj;
5798
+ }
5799
+
5800
+ return null;
5801
+ }
5802
+
52545803 void SetBumpTexture(String tex)
52555804 {
52565805 if (GetTextures() == null)
....@@ -5262,6 +5811,8 @@
52625811 texname = "";
52635812
52645813 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
5814
+
5815
+ GetTextures().bump = null;
52655816
52665817 Touch();
52675818 }
....@@ -5287,25 +5838,65 @@
52875838 }
52885839 }
52895840
5290
- void draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5841
+ void EmbedTextures(boolean embed)
5842
+ {
5843
+ if (blockloop)
5844
+ return;
5845
+
5846
+ //if (GetTextures() != null)
5847
+ if (embed)
5848
+ CameraPane.EmbedTextures(GetTextures());
5849
+ else
5850
+ {
5851
+ GetTextures().pigmentdata = null;
5852
+ GetTextures().bumpdata = null;
5853
+ GetTextures().pw = 0;
5854
+ GetTextures().ph = 0;
5855
+ GetTextures().bw = 0;
5856
+ GetTextures().bh = 0;
5857
+ }
5858
+
5859
+ int nb = Size();
5860
+ for (int i = 0; i < nb; i++)
5861
+ {
5862
+ Object3D child = (Object3D) get(i);
5863
+
5864
+ if (child == null)
5865
+ continue;
5866
+
5867
+ blockloop = true;
5868
+ child.EmbedTextures(embed);
5869
+ blockloop = false;
5870
+ }
5871
+ }
5872
+
5873
+ void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
52915874 {
52925875 Draw(display, root, selected, blocked);
52935876 }
52945877
5295
- static cMaterial[] materialstack = new cMaterial[65536];
5296
- static boolean[] selectedstack = new boolean[65536];
5297
- static int materialdepth = 0;
5298
-
52995878 boolean NeedSupport()
53005879 {
53015880 return
5302
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5881
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
53035882 // PROBLEM with CROWD!!
5304
- && (CameraPane.drawMode == CameraPane.SHADOW || CameraPane.CROWD);
5883
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
53055884 }
53065885
5886
+ static boolean DEBUG_SELECTION = false;
53075887
5308
- void Draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5888
+ boolean IsLive()
5889
+ {
5890
+ if (live)
5891
+ return true;
5892
+
5893
+ if (parent == null)
5894
+ return false;
5895
+
5896
+ return parent.IsLive();
5897
+ }
5898
+
5899
+ void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
53095900 {
53105901 Invariants(); // june 2013
53115902
....@@ -5314,8 +5905,8 @@
53145905 // System.err.println("Draw " + this + " Frame # " + ((Mocap)((Merge)support).object).frame);
53155906 }
53165907
5317
- if (display.drawMode == CameraPane.SELECTION &&
5318
- hide)
5908
+ if (display.DrawMode() == iCameraPane.SELECTION &&
5909
+ (hide || dontselect))
53195910 return;
53205911
53215912 if (name != null && name.contains("sclera"))
....@@ -5333,7 +5924,7 @@
53335924 if (this instanceof Checker)
53345925 return;
53355926
5336
- if (display.drawMode == display.SHADOW && PASSTEST)
5927
+ if (display.DrawMode() == display.SHADOW && PASSTEST)
53375928 return;
53385929
53395930 if (count <= 0)
....@@ -5341,13 +5932,13 @@
53415932 return;
53425933 }
53435934
5344
- if ((//display.drawMode == CameraPane.SHADOW ||
5345
- display.drawMode == CameraPane.SELECTION || CameraPane.DEBUG_SELECTION) && HasTransparency())
5935
+ if ((//display.DrawMode() == CameraPane.SHADOW ||
5936
+ display.DrawMode() == iCameraPane.SELECTION || display.IsDebugSelection()) && HasTransparency())
53465937 {
53475938 return;
53485939 }
53495940
5350
- javax.media.opengl.GL gl = display.GetGL();
5941
+ //javax.media.opengl.GL gl = display.GetGL();
53515942
53525943 /*
53535944 if (touched)
....@@ -5365,8 +5956,10 @@
53655956 if (support != null)
53665957 support = support;
53675958
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);
5959
+ boolean usecalllists = !IsLive() && IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5960
+ //boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5961
+
5962
+ //usecalllists &= display.DrawMode() == display.DEFAULT; // Don't compute list in shadow pass.
53705963
53715964 if (!usecalllists && bRep != null && bRep.displaylist > 0)
53725965 {
....@@ -5376,30 +5969,33 @@
53765969 // usecalllists &= !(parent instanceof RandomNode);
53775970 // usecalllists = false;
53785971
5379
- if (GetBRep() != null)
5380
- usecalllists = usecalllists;
5972
+ if (display.DrawMode() == display.SHADOW)
5973
+ //GetBRep() != null)
5974
+ usecalllists = !!usecalllists;
53815975 //System.out.println("draw " + this);
53825976 //new Exception().printStackTrace();
53835977
53845978 boolean compiled = false;
53855979
5386
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
5980
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
53875981
5388
- if (!selectmode && //display.drawMode != display.SELECTION &&
5389
- (touched || (bRep != null && bRep.displaylist <= 0)))
5982
+ if (!selectmode && //display.DrawMode() != display.SELECTION &&
5983
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5984
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
53905985 {
5391
- display.lighttouched = true;
5986
+ Globals.lighttouched = true;
53925987 } // 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 &&
5988
+
5989
+ //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
5990
+ if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
53955991 (touched || (bRep != null && bRep.displaylist <= 0)))
53965992 {
53975993 if (!(this instanceof Composite))
53985994 touched = false;
53995995 //if (displaylist == -1 && usecalllists)
5400
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
5996
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
54015997 {
5402
- bRep.displaylist = gl.glGenLists(1);
5998
+ bRep.displaylist = display.GenList();
54035999 assert(bRep.displaylist != 0);
54046000 // System.err.println("glGenLists: " + bRep.displaylist + " for " + this);
54056001 //System.out.println("\tgen list " + list);
....@@ -5408,21 +6004,23 @@
54086004
54096005 //System.out.println("\tnew list " + list);
54106006 //gl.glDrawBuffer(gl.GL_NONE);
5411
- if (usecalllists)
6007
+ if (usecalllists && bRep.displaylist > 0)
54126008 {
54136009 // System.err.println("new list " + bRep.displaylist + " for " + this);
5414
- gl.glNewList(bRep.displaylist, gl.GL_COMPILE); //_AND_EXECUTE);
6010
+ display.NewList(bRep.displaylist);
54156011 }
6012
+
54166013 CallList(display, root, selected, blocked);
6014
+
54176015 // compiled = true;
5418
- if (usecalllists)
6016
+ if (usecalllists && bRep.displaylist > 0)
54196017 {
54206018 // System.err.println("end list " + bRep.displaylist + " for " + this);
5421
- gl.glEndList();
6019
+ display.EndList();
54226020 }
54236021 //gl.glDrawBuffer(gl.GL_BACK);
54246022 // XXX touched = false;
5425
- display.lighttouched = true; // all panes...
6023
+ Globals.lighttouched = true; // all panes...
54266024 }
54276025
54286026 touched = GetBRep() == null; // this instanceof Composite || this instanceof FileObject; // false;
....@@ -5461,12 +6059,12 @@
54616059
54626060 // frustum culling
54636061 if (CameraPane.FRUSTUM && !blocked && !IsInfinite() && GetBRep() != null // && GetBRep().VertexCount() != 1260 // default grid
5464
- && display.drawMode != CameraPane.SELECTION)
6062
+ && display.DrawMode() != iCameraPane.SELECTION)
54656063 {
5466
- if (display.drawMode == CameraPane.SHADOW)
6064
+ if (display.DrawMode() == iCameraPane.SHADOW)
54676065 {
54686066 if (!link2master // tricky to cull in shadow mode.
5469
- && GetBRep().FrustumCull(this, gl, display.lightCamera, true))
6067
+ && GetBRep().FrustumCull(this, null, display.LightCamera(), true))
54706068 {
54716069 //System.out.print("CULLED");
54726070 culled = true;
....@@ -5474,7 +6072,7 @@
54746072 }
54756073 else
54766074 //GetBRep().getBounds(v0, v1, this);
5477
- if (GetBRep().FrustumCull(this, gl, display.renderCamera, false))
6075
+ if (GetBRep().FrustumCull(this, null, display.RenderCamera(), false))
54786076 culled = true;
54796077
54806078 // LA.xformPos(v0, display.renderCamera.toScreen, v0);
....@@ -5510,11 +6108,12 @@
55106108
55116109
55126110 if (!culled)
5513
- if (display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION)
6111
+ if (display.DrawMode() == display.SELECTION || display.IsDebugSelection())
55146112 {
55156113 if (GetBRep() != null)
55166114 {
5517
- CameraPane.NextIndex(this, gl);
6115
+ display.NextIndex();
6116
+
55186117 // vertex color conflict : gl.glCallList(list);
55196118 DrawNode(display, root, selected);
55206119 if (this instanceof BezierPatch)
....@@ -5536,55 +6135,7 @@
55366135 color[2] /= 2;
55376136 gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT_AND_DIFFUSE, color, 0);
55386137 */
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
- }
6138
+ display.PushMaterial(this, selected);
55886139
55896140 //System.out.println("call list " + list);
55906141 //System.out.println();
....@@ -5603,7 +6154,28 @@
56036154 tex = GetTextures();
56046155 }
56056156
5606
- display.BindTextures(tex, texres);
6157
+ boolean failedPigment = false;
6158
+ boolean failedBump = false;
6159
+
6160
+ try
6161
+ {
6162
+ display.BindPigmentTexture(tex, texres);
6163
+ }
6164
+ catch (Exception e)
6165
+ {
6166
+ System.err.println("FAILED: " + this);
6167
+ failedPigment = true;
6168
+ }
6169
+
6170
+ try
6171
+ {
6172
+ display.BindBumpTexture(tex, texres);
6173
+ }
6174
+ catch (Exception e)
6175
+ {
6176
+ //System.err.println("FAILED: " + this);
6177
+ failedBump = true;
6178
+ }
56076179
56086180 if (!compiled)
56096181 {
....@@ -5619,30 +6191,19 @@
56196191
56206192 // System.err.println("glCallList: " + bRep.displaylist + " for " + this);
56216193 assert(bRep.displaylist != 0);
5622
- gl.glCallList(bRep.displaylist);
6194
+ display.CallList(bRep.displaylist);
56236195 // june 2013 drawSelf(display, root, selected);
56246196 }
56256197 }
56266198 }
56276199
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
- }
6200
+ if (!failedBump)
6201
+ display.ReleaseBumpTexture(tex);
6202
+
6203
+ if (!failedPigment)
6204
+ display.ReleasePigmentTexture(tex);
6205
+
6206
+ display.PopMaterial(this, selected);
56466207 }
56476208
56486209 if (this instanceof Texture || this instanceof TextureNode)
....@@ -5684,7 +6245,7 @@
56846245 // resetMasterNode();
56856246 }
56866247
5687
- void CallList(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
6248
+ void CallList(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
56886249 {
56896250 if (GetBRep() == null)
56906251 {
....@@ -5767,8 +6328,11 @@
57676328 boolean flipV = false; // true;
57686329 int texres = 0; // 0 = low, 1 = normal, 2 = high res texture
57696330
5770
- void drawSelf(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
6331
+ void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57716332 {
6333
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6334
+ return;
6335
+
57726336 if (hide)
57736337 return;
57746338 // shadow optimisation
....@@ -5826,16 +6390,7 @@
58266390 // // ??????????????????????????? Touch();
58276391 // }
58286392
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
- }
6393
+display.PushMaterial2(this, selected);
58396394
58406395 Object3D child;
58416396 boolean sel;
....@@ -5887,19 +6442,7 @@
58876442 */
58886443 //depth += 1;
58896444
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
-
6445
+display.PopMaterial2(this);
59036446 /*
59046447 display.ReleaseTextures(tex);
59056448 */
....@@ -5910,10 +6453,13 @@
59106453
59116454 //static cVector min,max;
59126455
5913
- void DrawNode(CameraPane display, Object3D /*Composite*/ root, boolean selected)
6456
+ void DrawNode(iCameraPane display, Object3D /*Composite*/ root, boolean selected)
59146457 {
5915
- if (display.drawMode == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
6458
+ if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
59166459 return; // no shadow for transparent objects
6460
+
6461
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6462
+ return;
59176463
59186464 if (hide)
59196465 return;
....@@ -5955,11 +6501,12 @@
59556501 return;
59566502 }
59576503
6504
+ //bRep.GenUV(1/material.diffuseness);
59586505 // bRep.lock = true;
59596506
5960
- javax.media.opengl.GL gl = display.GetGL();
6507
+ //javax.media.opengl.GL gl = display.GetGL();
59616508
5962
- if (CameraPane.BOXMODE) // || CameraPane.movingcamera)
6509
+ if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera)
59636510 {
59646511 int fc = bRep.FaceCount();
59656512 int vc = bRep.VertexCount();
....@@ -5974,23 +6521,7 @@
59746521
59756522 bRep.getMinMax(min, max, 100);
59766523
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();
6524
+ display.DrawBox(min, max);
59946525
59956526 return;
59966527 }
....@@ -6034,7 +6565,7 @@
60346565 {
60356566 //throw new Error();
60366567
6037
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
6568
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
60386569
60396570 int[] strips = bRep.getRawIndices();
60406571
....@@ -6044,178 +6575,19 @@
60446575 new Exception().printStackTrace();
60456576 return;
60466577 }
6047
-
6048
- // TRIANGLE STRIP ARRAY
6049
- if (bRep.trimmed)
6578
+
6579
+ if (dontselect)
60506580 {
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;
6581
+ //bRep.GenerateNormalsMINE();
61826582 }
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
- }
6583
+
6584
+ display.DrawGeometry(bRep, flipV, selectmode);
62136585 } else // catch (Error e)
62146586 {
62156587 // TRIANGLE ARRAY
62166588 if (IsOpaque()) // Static())
62176589 {
6218
- gl.glBegin(gl.GL_TRIANGLES);
6590
+ display.StartTriangles();
62196591 int facecount = bRep.FaceCount();
62206592 for (int i = 0; i < facecount; i++)
62216593 {
....@@ -6278,9 +6650,9 @@
62786650 // // r.norm.dot(v3) > -0.5)
62796651 // // continue;
62806652
6281
- drawFace(p, q, r, display, face);
6653
+ display.DrawFace(this, p, q, r, face);
62826654 }
6283
- gl.glEnd();
6655
+ display.EndTriangles();
62846656 }
62856657 else
62866658 {
....@@ -6309,8 +6681,8 @@
63096681 //System.out.println("SORT");
63106682
63116683 java.util.Arrays.sort(facescompare);
6312
-
6313
- gl.glBegin(gl.GL_TRIANGLES);
6684
+
6685
+ display.StartTriangles();
63146686 for (int i = 0; i < facecount; i++)
63156687 {
63166688 Face face = bRep.GetFace(facescompare[i].index);
....@@ -6322,13 +6694,14 @@
63226694 Vertex q = bRep.GetVertex(face.q);
63236695 Vertex r = bRep.GetVertex(face.r);
63246696
6325
- drawFace(p, q, r, display, face);
6697
+ display.DrawFace(this, p, q, r, face);
63266698 }
6327
- gl.glEnd();
6699
+ display.EndTriangles();
63286700 }
63296701
63306702 if (false) // live && support != null && support.bRep != null) // debug weights
63316703 {
6704
+ /*
63326705 gl.glDisable(gl.GL_LIGHTING);
63336706 float[] colorV = new float[3];
63346707
....@@ -6407,6 +6780,7 @@
64076780 // gl.glEnd();
64086781 }
64096782 }
6783
+ */
64106784 }
64116785 }
64126786
....@@ -6451,7 +6825,7 @@
64516825 center.add(r);
64526826 center.mul(1.0/3);
64536827
6454
- center.sub(CameraPane.theRenderer.eyeCamera.location);
6828
+ center.sub(Globals.theRenderer.EyeCamera().location);
64556829
64566830 distance = center.dot(center);
64576831 }
....@@ -6462,347 +6836,11 @@
64626836
64636837 transient FaceCompare[] facescompare = null;
64646838
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
-
66396839 void Print(Vertex v)
66406840 {
66416841 //System.err.println("(" + v.x + ", " + v.y + ", " + v.z + ")");
66426842 }
66436843
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
-
68066844 void drawSelf(ClickInfo info, int level, boolean select)
68076845 {
68086846 if (bRep == null)
....@@ -7326,20 +7364,23 @@
73267364 }
73277365 }
73287366
7329
- protected void calcHotSpot(cVector in, ClickInfo info, Point outPt, Rectangle outRec)
7367
+ static ClickInfo clickInfo = new ClickInfo();
7368
+
7369
+ protected void calcHotSpot(cVector in, //ClickInfo clickInfo,
7370
+ Point outPt, Rectangle outRec)
73307371 {
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;
7372
+ int hc = clickInfo.bounds.x + clickInfo.bounds.width / 2;
7373
+ int vc = clickInfo.bounds.y + clickInfo.bounds.height / 2;
7374
+ double[][] toscreen = clickInfo.toScreen;
73347375 if (toscreen == null)
73357376 {
7336
- toscreen = new Camera(info.camera.viewCode).toScreen;
7377
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
73377378 }
73387379 cVector vec = in;
73397380 LA.xformPos(in, toscreen, in);
73407381 //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();
7382
+ vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
7383
+ vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
73437384 outPt.x = hc + (int) vec.x;
73447385 outPt.y = vc - (int) vec.y;
73457386 outRec.x = outPt.x - 3;
....@@ -7347,15 +7388,18 @@
73477388 outRec.width = outRec.height = 6;
73487389 }
73497390
7350
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7391
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7392
+ )
73517393 {
73527394 Point pt = new Point(0, 0);
73537395 Rectangle rec = new Rectangle();
7354
- calcHotSpot(in, info, pt, rec);
7396
+ calcHotSpot(in, //clickInfo,
7397
+ pt, rec);
73557398 return rec;
73567399 }
73577400
7358
- void drawEditHandles0(ClickInfo info, int level)
7401
+ void drawEditHandles0(//ClickInfo clickInfo,
7402
+ int level)
73597403 {
73607404 if (level == 0)
73617405 {
....@@ -7364,98 +7408,104 @@
73647408 {
73657409 cVector origin = new cVector();
73667410 //LA.xformPos(origin, toParent, origin);
7367
- Rectangle spot = calcHotSpot(origin, info);
7411
+ if (this.clickInfo == null)
7412
+ this.clickInfo = new ClickInfo();
7413
+
7414
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
73687415 Rectangle boundary = new Rectangle();
73697416 boundary.x = spot.x - 30;
73707417 boundary.y = spot.y - 30;
73717418 boundary.width = spot.width + 60;
73727419 boundary.height = spot.height + 60;
7373
- info.g.setColor(Color.red);
7420
+ clickInfo.g.setColor(Color.red);
73747421 int spotw = spot.x + spot.width;
73757422 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);
7423
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7424
+// if (CameraPane.Xmin > spot.x)
7425
+// {
7426
+// CameraPane.Xmin = spot.x;
7427
+// }
7428
+// if (CameraPane.Xmax < spotw)
7429
+// {
7430
+// CameraPane.Xmax = spotw;
7431
+// }
7432
+// if (CameraPane.Ymin > spot.y)
7433
+// {
7434
+// CameraPane.Ymin = spot.y;
7435
+// }
7436
+// if (CameraPane.Ymax < spoth)
7437
+// {
7438
+// CameraPane.Ymax = spoth;
7439
+// }
7440
+// if (CameraPane.Xmin > spot.x)
7441
+// {
7442
+// CameraPane.Xmin = spot.x;
7443
+// }
7444
+// if (CameraPane.Xmax < spotw)
7445
+// {
7446
+// CameraPane.Xmax = spotw;
7447
+// }
7448
+// if (CameraPane.Ymin > spot.y)
7449
+// {
7450
+// CameraPane.Ymin = spot.y;
7451
+// }
7452
+// if (CameraPane.Ymax < spoth)
7453
+// {
7454
+// CameraPane.Ymax = spoth;
7455
+// }
7456
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7457
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
7458
+ spot.translate(32, 0);
7459
+ clickInfo.g.setColor(Color.yellow);
7460
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7461
+
7462
+ spot.translate(32, 64);
73947463 spotw = spot.x + spot.width;
73957464 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);
7465
+ clickInfo.g.setColor(Color.cyan);
7466
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7467
+// if (CameraPane.Xmin > spot.x)
7468
+// {
7469
+// CameraPane.Xmin = spot.x;
7470
+// }
7471
+// if (CameraPane.Xmax < spotw)
7472
+// {
7473
+// CameraPane.Xmax = spotw;
7474
+// }
7475
+// if (CameraPane.Ymin > spot.y)
7476
+// {
7477
+// CameraPane.Ymin = spot.y;
7478
+// }
7479
+// if (CameraPane.Ymax < spoth)
7480
+// {
7481
+// CameraPane.Ymax = spoth;
7482
+// }
7483
+ clickInfo.g.setColor(Color.green);
7484
+ clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
7485
+ (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
74377486 //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
- }
7487
+// if (CameraPane.Xmin > boundary.x)
7488
+// {
7489
+// CameraPane.Xmin = boundary.x;
7490
+// }
7491
+// if (CameraPane.Xmax < boundary.x + boundary.width)
7492
+// {
7493
+// CameraPane.Xmax = boundary.x + boundary.width;
7494
+// }
7495
+// if (CameraPane.Ymin > boundary.y)
7496
+// {
7497
+// CameraPane.Ymin = boundary.y;
7498
+// }
7499
+// if (CameraPane.Ymax < boundary.y + boundary.height)
7500
+// {
7501
+// CameraPane.Ymax = boundary.y + boundary.height;
7502
+// }
74547503 return;
74557504 }
74567505 }
74577506
7458
- boolean doEditClick0(ClickInfo info, int level)
7507
+ boolean doEditClick0(//ClickInfo clickInfo,
7508
+ int level)
74597509 {
74607510 if (level == 0)
74617511 {
....@@ -7464,10 +7514,10 @@
74647514
74657515 boolean retval = false;
74667516
7467
- startX = info.x;
7468
- startY = info.y;
7517
+ startX = clickInfo.x;
7518
+ startY = clickInfo.y;
74697519
7470
- hitSomething = 0;
7520
+ hitSomething = -1;
74717521 cVector origin = new cVector();
74727522 //LA.xformPos(origin, toParent, origin);
74737523 Rectangle spot = new Rectangle();
....@@ -7475,22 +7525,53 @@
74757525 {
74767526 centerPt = new Point(0, 0);
74777527 }
7478
- calcHotSpot(origin, info, centerPt, spot);
7479
- if (spot.contains(info.x, info.y))
7528
+ calcHotSpot(origin, //info,
7529
+ centerPt, spot);
7530
+ if (spot.contains(clickInfo.x, clickInfo.y))
74807531 {
74817532 hitSomething = hitCenter;
74827533 retval = true;
74837534 }
74847535 spot.translate(32, 0);
7485
- if (spot.contains(info.x, info.y))
7536
+ if (spot.contains(clickInfo.x, clickInfo.y))
74867537 {
74877538 hitSomething = hitRotate;
74887539 retval = true;
74897540 }
74907541 spot.translate(0, 32);
7491
- if (spot.contains(info.x, info.y))
7542
+ spot.translate(32, 0);
7543
+ spot.translate(0, 32);
7544
+ if (spot.contains(clickInfo.x, clickInfo.y))
74927545 {
74937546 hitSomething = hitScale;
7547
+
7548
+ double scale = 0.005f * clickInfo.camera.Distance();
7549
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
7550
+ double sign = 1;
7551
+ if (hScale < 0)
7552
+ {
7553
+ sign = -1;
7554
+ }
7555
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
7556
+ if (hScale < 0.01)
7557
+ {
7558
+ //hScale = 0.01;
7559
+ }
7560
+
7561
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
7562
+ sign = 1;
7563
+ if (vScale < 0)
7564
+ {
7565
+ sign = -1;
7566
+ }
7567
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
7568
+ if (vScale < 0.01)
7569
+ {
7570
+ //vScale = 0.01;
7571
+ }
7572
+
7573
+ clickInfo.scale = Math.sqrt(hScale*hScale + vScale*vScale);
7574
+
74947575 retval = true;
74957576 }
74967577
....@@ -7500,7 +7581,7 @@
75007581 }
75017582
75027583 //System.out.println("info.modifiers = " + info.modifiers);
7503
- modified = (info.modifiers & CameraPane.META) != 0;
7584
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
75047585 //System.out.println("modified = " + modified);
75057586 //new Exception().printStackTrace();
75067587 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7528,7 +7609,8 @@
75287609 return true;
75297610 }
75307611
7531
- void doEditDrag0(ClickInfo info)
7612
+ void doEditDrag0(//ClickInfo info,
7613
+ boolean opposite)
75327614 {
75337615 if (hitSomething == 0)
75347616 {
....@@ -7542,7 +7624,8 @@
75427624
75437625 //System.out.println("hitSomething = " + hitSomething);
75447626
7545
- double scale = 0.005f * info.camera.Distance();
7627
+ double scale = 0.005f * clickInfo.camera.Distance();
7628
+
75467629 cVector xlate = new cVector();
75477630 //cVector xlate2 = new cVector();
75487631 switch (hitSomething)
....@@ -7553,9 +7636,9 @@
75537636
75547637 case hitCenter: // Translate
75557638
7556
- scale *= 0.05f * info.pane.theRenderer.renderCamera.Distance();
7639
+ scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
75577640
7558
- if (modified)
7641
+ if (modified || opposite)
75597642 {
75607643 //assert(false);
75617644 /*
....@@ -7575,8 +7658,8 @@
75757658 toParent[3][i] = xlate.get(i);
75767659 LA.matInvert(toParent, fromParent);
75777660 */
7578
- cVector delta = LA.newVector(0, 0, startY - info.y);
7579
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7661
+ cVector delta = LA.newVector(0, 0, startY - clickInfo.y);
7662
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
75807663
75817664 LA.matCopy(startMat, toParent);
75827665 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7585,7 +7668,7 @@
75857668 } else
75867669 {
75877670 //LA.xformDir(delta, info.camera.fromScreen, delta);
7588
- cVector up = new cVector(info.camera.up);
7671
+ cVector up = new cVector(clickInfo.camera.up);
75897672 cVector away = new cVector();
75907673 //cVector right2 = new cVector();
75917674 //LA.vecCross(up, cVector.Z, right);
....@@ -7601,20 +7684,20 @@
76017684 }
76027685 LA.xformDir(up, ClickInfo.matbuffer, up);
76037686 // if (!CameraPane.LOCALTRANSFORM)
7604
- LA.xformDir(up, info.pane.theRenderer.renderCamera.toScreen, up);
7605
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7687
+ LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7688
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
76067689 // if (!CameraPane.LOCALTRANSFORM)
7607
- LA.xformDir(away, info.pane.theRenderer.renderCamera.toScreen, away);
7690
+ LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
76087691 //LA.vecCross(up, cVector.Z, right2);
76097692
7610
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7693
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
76117694
76127695 //System.out.println("DELTA0 = " + delta);
76137696 //System.out.println("AWAY = " + info.camera.away);
76147697 //System.out.println("UP = " + info.camera.up);
76157698 if (away.z > 0)
76167699 {
7617
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7700
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
76187701 {
76197702 delta.x = -delta.x;
76207703 } else
....@@ -7629,7 +7712,7 @@
76297712 //System.out.println("DELTA1 = " + delta);
76307713 LA.xformDir(delta, ClickInfo.matbuffer, delta);
76317714 //System.out.println("DELTA2 = " + delta);
7632
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7715
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
76337716 LA.matCopy(startMat, toParent);
76347717 //System.out.println("DELTA3 = " + delta);
76357718 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7639,8 +7722,8 @@
76397722 break;
76407723
76417724 case hitRotate: // rotate
7642
- int dx = info.x - centerPt.x;
7643
- int dy = -(info.y - centerPt.y);
7725
+ int dx = clickInfo.x - centerPt.x;
7726
+ int dy = -(clickInfo.y - centerPt.y);
76447727 double angle = (double) Math.atan2(dx, dy);
76457728 angle = -(1.570796 - angle);
76467729
....@@ -7649,6 +7732,7 @@
76497732
76507733 if (modified)
76517734 {
7735
+ // Rotate 90 degrees
76527736 angle /= (Math.PI / 4);
76537737 angle = Math.floor(angle + 0.5);
76547738 angle *= (Math.PI / 4);
....@@ -7662,7 +7746,7 @@
76627746 }
76637747 /**/
76647748
7665
- switch (info.pane.renderCamera.viewCode)
7749
+ switch (clickInfo.pane.RenderCamera().viewCode)
76667750 {
76677751 case 1: // '\001'
76687752 LA.matZRotate(toParent, angle);
....@@ -7689,26 +7773,30 @@
76897773 break;
76907774
76917775 case hitScale: // scale
7692
- double hScale = (double) (info.x - centerPt.x) / 32;
7776
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
7777
+ double sign = 1;
7778
+ if (hScale < 0)
7779
+ {
7780
+ sign = -1;
7781
+ }
7782
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
76937783 if (hScale < 0.01)
76947784 {
7695
- hScale = 0.01;
7785
+ //hScale = 0.01;
76967786 }
7697
- hScale = Math.pow(hScale, scale * 50);
7698
- if (hScale < 0.01)
7787
+
7788
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
7789
+ sign = 1;
7790
+ if (vScale < 0)
76997791 {
7700
- hScale = 0.01;
7792
+ sign = -1;
77017793 }
7702
- double vScale = (double) (info.y - centerPt.y) / 32;
7794
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
77037795 if (vScale < 0.01)
77047796 {
7705
- vScale = 0.01;
7797
+ //vScale = 0.01;
77067798 }
7707
- vScale = Math.pow(vScale, scale * 50);
7708
- if (vScale < 0.01)
7709
- {
7710
- vScale = 0.01;
7711
- }
7799
+
77127800 LA.matCopy(startMat, toParent);
77137801 /**/
77147802 for (int i = 0; i < 3; i++)
....@@ -7718,39 +7806,47 @@
77187806 }
77197807 /**/
77207808
7721
- switch (info.pane.renderCamera.viewCode)
7809
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
7810
+
7811
+ if (totalScale < 0.01)
7812
+ {
7813
+ totalScale = 0.01;
7814
+ }
7815
+
7816
+ switch (clickInfo.pane.RenderCamera().viewCode)
77227817 {
77237818 case 3: // '\001'
7724
- if (modified)
7819
+ if (modified || opposite)
77257820 {
77267821 //LA.matScale(toParent, 1, hScale, vScale);
7727
- LA.matScale(toParent, vScale, 1, 1);
7822
+ LA.matScale(toParent, totalScale, 1, 1);
77287823 } // vScale, 1);
77297824 else
77307825 {
7731
- LA.matScale(toParent, vScale, vScale, vScale);
7826
+ // EXCEPTION!
7827
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
77327828 } // vScale, 1);
77337829 break;
77347830
77357831 case 2: // '\002'
7736
- if (modified)
7832
+ if (modified || opposite)
77377833 {
77387834 //LA.matScale(toParent, hScale, 1, vScale);
7739
- LA.matScale(toParent, 1, vScale, 1);
7835
+ LA.matScale(toParent, 1, totalScale, 1);
77407836 } else
77417837 {
7742
- LA.matScale(toParent, vScale, 1, vScale);
7838
+ LA.matScale(toParent, totalScale, 1, totalScale);
77437839 }
77447840 break;
77457841
77467842 case 1: // '\003'
7747
- if (modified)
7843
+ if (modified || opposite)
77487844 {
77497845 //LA.matScale(toParent, hScale, vScale, 1);
7750
- LA.matScale(toParent, 1, 1, vScale);
7846
+ LA.matScale(toParent, 1, 1, totalScale);
77517847 } else
77527848 {
7753
- LA.matScale(toParent, vScale, vScale, 1);
7849
+ LA.matScale(toParent, totalScale, totalScale, 1);
77547850 }
77557851 break;
77567852 }
....@@ -7784,7 +7880,7 @@
77847880 } // NEW ...
77857881
77867882
7787
- info.pane.repaint();
7883
+ clickInfo.pane.repaint();
77887884 }
77897885
77907886 boolean overflow = false;
....@@ -7883,14 +7979,22 @@
78837979 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
78847980 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
78857981 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7982
+
7983
+ String objname;
7984
+
78867985 if (false) //parent != null)
78877986 {
7888
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7987
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
78897988 } else
78907989 {
7891
- return GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ") ")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ +System.identityHashCode(this);
7990
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
78927991 } // + super.toString();
78937992 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
7993
+
7994
+ if (!Globals.ADVANCED)
7995
+ return objname;
7996
+
7997
+ return objname + " " + System.identityHashCode(this);
78947998 }
78957999
78968000 public int hashCode()
....@@ -7946,6 +8050,7 @@
79468050 objectUI.closeUI();
79478051 if (editWindow != null)
79488052 {
8053
+ editWindow.ctrlPanel.FlushUI();
79498054 editWindow.refreshContents();
79508055 } // ? new
79518056 objectUI = null;
....@@ -7954,6 +8059,10 @@
79548059 {
79558060 editWindow = null;
79568061 } // ?
8062
+ }
8063
+ else
8064
+ {
8065
+ //editWindow.closeUI();
79578066 }
79588067 }
79598068
....@@ -7966,7 +8075,7 @@
79668075 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
79678076
79688077 Object3D /*Composite*/ parent;
7969
- Object3D /*Composite*/ fileparent;
8078
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
79708079
79718080 double[][] toParent; // dynamic matrix
79728081 double[][] fromParent;
....@@ -8081,7 +8190,7 @@
80818190 {
80828191 assert(bRep != null);
80838192 if (!(support instanceof GenericJoint)) // support.bRep != null)
8084
- GrafreeD.Assert(support.bRep == bRep.support);
8193
+ Grafreed.Assert(support.bRep == bRep.support);
80858194 }
80868195 else
80878196 {
....@@ -8112,6 +8221,10 @@
81128221 }
81138222
81148223 transient ObjEditor editWindow;
8224
+ transient ObjEditor manipWindow;
8225
+
8226
+ transient boolean pinned;
8227
+
81158228 transient ObjectUI objectUI;
81168229 public static int povDepth = 0;
81178230 private static cVector tbMin = new cVector();
....@@ -8130,9 +8243,9 @@
81308243 private static cVector edge2 = new cVector();
81318244 //private static cVector norm = new cVector();
81328245 /*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;
8246
+ static final int hitCenter = 1;
8247
+ static final int hitScale = 2;
8248
+ static final int hitRotate = 3;
81368249 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
81378250 /*transient*/ private Point centerPt;
81388251 /*transient*/ private int startX;
....@@ -8164,6 +8277,8 @@
81648277 {
81658278 Object3D targ = this;
81668279
8280
+ targ.NORMALPUSH = obj.NORMALPUSH;
8281
+
81678282 if (obj.material != null)
81688283 {
81698284 if ((mask&MATERIAL)!=0) // ==(COLOR|MATERIAL))