Normand Briere
2019-07-25 f2b6a33fdf84a06b958f9cb9d667a2eff3063d8b
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,12 +14,24 @@
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
+ private UUID uuid = UUID.randomUUID();
26
+
27
+ // TEMPORARY for mocap undo. No need to be transient.
28
+ mocap.reader.BVHReader.BVHResult savebvh;
29
+ Object3D saveskeleton;
30
+ //
31
+
32
+ byte[] versions[];
33
+ int versionindex = -1;
34
+
2235 ScriptNode scriptnode;
2336
2437 void InitOthers()
....@@ -99,64 +112,178 @@
99112
100113 // transient boolean reduced; // for morph reduction
101114
102
-transient com.bulletphysics.linearmath.Transform cache; // for fast merge
103
-transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
115
+ transient com.bulletphysics.linearmath.Transform cache; // for fast merge
116
+ transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
104117
105
-transient Object3D transientsupport; // for cloning
106
-transient boolean transientlink2master;
118
+ transient Object3D transientsupport; // for cloning
119
+ transient boolean transientlink2master;
107120
108
-void SaveSupports()
109
-{
110
- if (blockloop)
111
- return;
112
-
113
- transientsupport = support;
114
- transientlink2master = link2master;
115
-
116
- support = null;
117
- link2master = false;
118
-
119
- if (bRep != null)
121
+ void SaveSupports()
120122 {
121
- bRep.SaveSupports();
123
+ if (blockloop)
124
+ return;
125
+
126
+ transientsupport = support;
127
+ transientlink2master = link2master;
128
+
129
+ support = null;
130
+ link2master = false;
131
+
132
+ if (bRep != null)
133
+ {
134
+ bRep.SaveSupports();
135
+ }
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.SaveSupports();
144
+ blockloop = false;
145
+ }
122146 }
123
-
124
- for (int i = 0; i < Size(); i++)
147
+
148
+ void RestoreSupports()
125149 {
126
- Object3D child = (Object3D) get(i);
127
- if (child == null)
128
- continue;
150
+ if (blockloop)
151
+ return;
152
+
153
+ support = transientsupport;
154
+ link2master = transientlink2master;
155
+ transientsupport = null;
156
+ transientlink2master = false;
157
+
158
+ if (bRep != null)
159
+ {
160
+ bRep.RestoreSupports();
161
+ }
162
+
163
+ for (int i = 0; i < Size(); i++)
164
+ {
165
+ Object3D child = (Object3D) get(i);
166
+ if (child == null)
167
+ continue;
168
+ blockloop = true;
169
+ child.RestoreSupports();
170
+ blockloop = false;
171
+ }
172
+ }
173
+
174
+ void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
175
+ {
176
+ Object3D o;
177
+
178
+ if (hashtable.containsKey(GetUUID()))
179
+ {
180
+ o = hashtable.get(GetUUID());
181
+
182
+ Grafreed.Assert(this.bRep == o.bRep);
183
+ //if (this.bRep != null)
184
+ // assert(this.bRep.support == o.transientrep);
185
+ if (this.support != null)
186
+ assert(this.support.bRep == o.transientrep);
187
+ }
188
+ else
189
+ {
190
+ o = new Object3D("copy of " + this.name);
191
+
192
+ hashtable.put(GetUUID(), o);
193
+ }
194
+
195
+ if (!blockloop)
196
+ {
197
+ blockloop = true;
198
+
199
+ for (int i=0; i<Size(); i++)
200
+ {
201
+ get(i).ExtractBigData(hashtable);
202
+ }
203
+
204
+ blockloop = false;
205
+ }
206
+
207
+ ExtractBigData(o);
208
+ }
209
+
210
+ void ExtractBigData(Object3D o)
211
+ {
212
+ if (o.bRep != null)
213
+ Grafreed.Assert(o.bRep == this.bRep);
214
+
215
+ o.bRep = this.bRep;
216
+// July 2019 if (this.bRep != null)
217
+// {
218
+// o.transientrep = this.bRep.support;
219
+// o.bRep.support = null;
220
+// }
221
+ o.selection = this.selection;
222
+ o.versions = this.versions;
223
+ o.versionindex = this.versionindex;
224
+
225
+ if (this.support != null)
226
+ {
227
+ if (o.transientrep != null)
228
+ Grafreed.Assert(o.transientrep == this.support.bRep);
229
+
230
+ o.transientrep = this.support.bRep;
231
+ this.support.bRep = null;
232
+ }
233
+
234
+ // o.support = this.support;
235
+ // o.fileparent = this.fileparent;
236
+ // if (this.bRep != null)
237
+ // o.bRep = this.bRep.support;
238
+
239
+ this.bRep = null;
240
+ // if (this.bRep != null)
241
+ // this.bRep.support = null;
242
+ // this.support = null;
243
+ // this.fileparent = null;
244
+ }
245
+
246
+ void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
247
+ {
248
+ if (!hashtable.containsKey(GetUUID()))
249
+ return;
250
+
251
+ Object3D o = hashtable.get(GetUUID());
252
+
253
+ RestoreBigData(o);
254
+
255
+ if (blockloop)
256
+ return;
257
+
129258 blockloop = true;
130
- child.SaveSupports();
259
+
260
+ //hashtable.remove(GetUUID());
261
+
262
+ for (int i=0; i<Size(); i++)
263
+ {
264
+ get(i).RestoreBigData(hashtable);
265
+ }
266
+
131267 blockloop = false;
132268 }
133
-}
134269
135
-void RestoreSupports()
136
-{
137
- if (blockloop)
138
- return;
139
-
140
- support = transientsupport;
141
- link2master = transientlink2master;
142
- transientsupport = null;
143
- transientlink2master = false;
144
-
145
- if (bRep != null)
270
+ void RestoreBigData(Object3D o)
146271 {
147
- bRep.RestoreSupports();
272
+ this.bRep = o.bRep;
273
+ if (this.support != null && o.transientrep != null)
274
+ {
275
+ this.support.bRep = o.transientrep;
276
+ }
277
+
278
+ this.selection = o.selection;
279
+
280
+ this.versions = o.versions;
281
+ this.versionindex = o.versionindex;
282
+// July 2019 if (this.bRep != null)
283
+// this.bRep.support = o.transientrep;
284
+ // this.support = o.support;
285
+ // this.fileparent = o.fileparent;
148286 }
149
-
150
- for (int i = 0; i < Size(); i++)
151
- {
152
- Object3D child = (Object3D) get(i);
153
- if (child == null)
154
- continue;
155
- blockloop = true;
156
- child.RestoreSupports();
157
- blockloop = false;
158
- }
159
-}
160287
161288 // MOCAP SUPPORT
162289 double tx,ty,tz,rx,ry,rz;
....@@ -299,6 +426,8 @@
299426 }
300427
301428 boolean live = false;
429
+ transient boolean keepdontselect;
430
+ boolean dontselect = false;
302431 boolean hide = false;
303432 boolean link2master = false; // performs reset support/master at each frame
304433 boolean marked = false; // animation node
....@@ -430,16 +559,16 @@
430559 {
431560 Object3D copy = this;
432561
433
- Camera parentcam = CameraPane.theRenderer.manipCamera;
562
+ Camera parentcam = Globals.theRenderer.ManipCamera();
434563
435
- if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[0])
564
+ if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[0])
436565 {
437
- parentcam = CameraPane.theRenderer.cameras[1];
566
+ parentcam = Globals.theRenderer.Cameras()[1];
438567 }
439568
440
- if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[1])
569
+ if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[1])
441570 {
442
- parentcam = CameraPane.theRenderer.cameras[0];
571
+ parentcam = Globals.theRenderer.Cameras()[0];
443572 }
444573
445574 if (this == parentcam)
....@@ -447,7 +576,7 @@
447576 //assert(this instanceof Camera);
448577
449578 for (int count = parentcam.GetTransformCount(); --count>=0;)
450
- LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.toParent, CameraPane.theRenderer.targetLookAt);
579
+ LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.toParent, Globals.theRenderer.TargetLookAt());
451580 }
452581
453582 copy.marked ^= true;
....@@ -467,7 +596,7 @@
467596 //assert(this instanceof Camera);
468597
469598 for (int count = parentcam.GetTransformCount(); --count>=0;)
470
- LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.fromParent, CameraPane.theRenderer.targetLookAt);
599
+ LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.fromParent, Globals.theRenderer.TargetLookAt());
471600 }
472601
473602 copy.Touch(); // display list issue
....@@ -480,12 +609,14 @@
480609 toParent = LA.newMatrix();
481610 fromParent = LA.newMatrix();
482611 }
612
+
483613 if (toParentMarked == null)
484614 {
485615 if (maxcount != 1)
486616 {
487617 new Exception().printStackTrace();
488618 }
619
+
489620 toParentMarked = LA.newMatrix();
490621 fromParentMarked = LA.newMatrix();
491622 }
....@@ -602,7 +733,7 @@
602733 return;
603734 }
604735
605
- if (CameraPane.fromscript)
736
+ if (Globals.fromscript)
606737 {
607738 transformcount = 0;
608739 return;
....@@ -760,7 +891,7 @@
760891
761892 int GetTransformCount()
762893 {
763
- // marde pour serialization de Texture
894
+ // patch pour serialization de Texture
764895 resetmaxcount();
765896 resettransformcount();
766897 resetstep();
....@@ -773,7 +904,7 @@
773904 if (step == 0)
774905 step = 1;
775906 if (maxcount == 0)
776
- maxcount = 2048; // 4;
907
+ maxcount = 128; // 2048; // 4;
777908 // if (acceleration == 0)
778909 // acceleration = 10;
779910 if (delay == 0) // serial
....@@ -794,12 +925,12 @@
794925 // factor = CameraPane.STEP;
795926 // }
796927
797
- if (marked && CameraPane.isLIVE() && live &&
928
+ if (marked && Globals.isLIVE() && live &&
798929 //TEMP21aug2018
799
- CameraPane.drawMode == CameraPane.SHADOW &&
800
- currentframe != CameraPane.framecount)
930
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
931
+ currentframe != Globals.framecount)
801932 {
802
- currentframe = CameraPane.framecount;
933
+ currentframe = Globals.framecount;
803934
804935 // System.err.println("transformcount = " + transformcount);
805936 // System.err.println("factor = " + factor);
....@@ -808,7 +939,8 @@
808939
809940 boolean changedir = random && Math.random() < 0.01; // && !link2master;
810941
811
- if (transformcount*factor > maxcount || (step == 1 && changedir))
942
+ if (transformcount*factor >= maxcount && (rewind || random) ||
943
+ (step == 1 && changedir))
812944 {
813945 countdown = 1;
814946 delay = speedup?8:1;
....@@ -880,6 +1012,7 @@
8801012 if (material == null || material.multiply)
8811013 return true;
8821014
1015
+ // Transparent objects are dynamic because we have to sort the triangles.
8831016 return material.opacity > 0.99;
8841017 }
8851018
....@@ -911,6 +1044,11 @@
9111044 fromParent = null; // LA.newMatrix();
9121045 bRep = null; // new BoundaryRep();
9131046
1047
+ if (oname != null && oname.equals("LeftHand"))
1048
+ {
1049
+ name = oname;
1050
+ }
1051
+
9141052 /*
9151053 float hue = (float)Math.random();
9161054 Color col;
....@@ -953,7 +1091,7 @@
9531091
9541092 public Object clone()
9551093 {
956
- return GrafreeD.clone(this);
1094
+ return Grafreed.clone(this);
9571095 }
9581096
9591097 Object3D copyExpand()
....@@ -1275,6 +1413,7 @@
12751413 toParent = LA.newMatrix();
12761414 fromParent = LA.newMatrix();
12771415 }
1416
+
12781417 LA.matCopy(other.toParent, toParent);
12791418 LA.matCopy(other.fromParent, fromParent);
12801419
....@@ -1469,7 +1608,7 @@
14691608 BoundaryRep.SEUIL = other.material.cameralight;
14701609
14711610 // Set default to 0.1
1472
- BoundaryRep.SEUIL /= 2;
1611
+ BoundaryRep.SEUIL /= 4; // 2;
14731612 System.out.println("SEUIL = " + BoundaryRep.SEUIL);
14741613 }
14751614
....@@ -1728,7 +1867,7 @@
17281867 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17291868 o.bRep = transientrep;
17301869 if (clone)
1731
- o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
1870
+ o.bRep = (BoundaryRep) Grafreed.clone(transientrep);
17321871 o.CreateMaterial();
17331872 o.SetAttributes(this, -1);
17341873 //parent
....@@ -1741,7 +1880,7 @@
17411880 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17421881 o.bRep = bRep;
17431882 if (clone)
1744
- o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
1883
+ o.bRep = (BoundaryRep) Grafreed.clone(bRep);
17451884 o.CreateMaterial();
17461885 //o.overwriteThis(this, -1);
17471886 o.SetAttributes(this, -1);
....@@ -1828,12 +1967,15 @@
18281967 if (obj.name == null)
18291968 continue; // can't be a null one
18301969
1970
+ // Try perfect match first.
18311971 if (n.equals(obj.name))
18321972 {
18331973 theobj = obj;
18341974 count++;
18351975 }
18361976 }
1977
+
1978
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18371979
18381980 if (count != 1)
18391981 for (int i=Size(); --i>=0;)
....@@ -2293,12 +2435,17 @@
22932435 }
22942436 */
22952437 }
2438
+ else
2439
+ {
2440
+ //((ObjEditor)editWindow).SetupUI2(null);
2441
+ }
22962442 }
22972443
22982444 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
22992445 {
23002446 if (newWindow)
23012447 {
2448
+ new Exception().printStackTrace();
23022449 System.exit(0);
23032450 if (parent != null)
23042451 {
....@@ -2333,6 +2480,14 @@
23332480 {
23342481 editWindow.refreshContents();
23352482 }
2483
+ else
2484
+ {
2485
+ if (manipWindow != null)
2486
+ {
2487
+ manipWindow.refreshContents();
2488
+ }
2489
+ }
2490
+
23362491 //if (parent != null)
23372492 //parent.refreshEditWindow();
23382493 }
....@@ -2412,7 +2567,8 @@
24122567 private static final int editSelf = 1;
24132568 private static final int editChild = 2;
24142569
2415
- void drawEditHandles(ClickInfo info, int level)
2570
+ void drawEditHandles(//ClickInfo info,
2571
+ int level)
24162572 {
24172573 if (level == 0)
24182574 {
....@@ -2420,7 +2576,8 @@
24202576 return;
24212577
24222578 Object3D selectee;
2423
- for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(info, level + 1))
2579
+ for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(//info,
2580
+ level + 1))
24242581 {
24252582 selectee = (Object3D) e.nextElement();
24262583 }
....@@ -2428,19 +2585,22 @@
24282585 } else
24292586 {
24302587 //super.
2431
- drawEditHandles0(info, level + 1);
2588
+ drawEditHandles0(//info,
2589
+ level + 1);
24322590 }
24332591 }
24342592
2435
- boolean doEditClick(ClickInfo info, int level)
2593
+ boolean doEditClick(//ClickInfo info,
2594
+ int level)
24362595 {
24372596 doSomething = 0;
24382597 if (level == 0)
24392598 {
2440
- return doParentClick(info);
2599
+ return doParentClick(); //info);
24412600 }
24422601 if (//super.
2443
- doEditClick0(info, level))
2602
+ doEditClick0(//info,
2603
+ level))
24442604 {
24452605 doSomething = 1;
24462606 return true;
....@@ -2450,7 +2610,7 @@
24502610 }
24512611 }
24522612
2453
- boolean doParentClick(ClickInfo info)
2613
+ boolean doParentClick() //ClickInfo info)
24542614 {
24552615 if (selection == null)
24562616 {
....@@ -2463,7 +2623,8 @@
24632623 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
24642624 {
24652625 Object3D selectee = (Object3D) e.nextElement();
2466
- if (selectee.doEditClick(info, 1))
2626
+ if (selectee.doEditClick(//info,
2627
+ 1))
24672628 {
24682629 childToDrag = selectee;
24692630 doSomething = 2;
....@@ -2475,13 +2636,15 @@
24752636 return retval;
24762637 }
24772638
2478
- void doEditDrag(ClickInfo info)
2639
+ void doEditDrag(//ClickInfo clickInfo,
2640
+ boolean opposite)
24792641 {
24802642 switch (doSomething)
24812643 {
24822644 case 1: // '\001'
24832645 //super.
2484
- doEditDrag0(info);
2646
+ doEditDrag0(//clickInfo,
2647
+ opposite);
24852648 break;
24862649
24872650 case 2: // '\002'
....@@ -2494,11 +2657,13 @@
24942657 {
24952658 //sel.hitSomething = childToDrag.hitSomething;
24962659 //childToDrag.doEditDrag(info);
2497
- sel.doEditDrag(info);
2660
+ sel.doEditDrag(//clickInfo,
2661
+ opposite);
24982662 } else
24992663 {
25002664 //super.
2501
- doEditDrag0(info);
2665
+ doEditDrag0(//clickInfo,
2666
+ opposite);
25022667 }
25032668 }
25042669 break;
....@@ -2516,6 +2681,9 @@
25162681 {
25172682 deselectAll();
25182683 }
2684
+
2685
+ new Exception().printStackTrace();
2686
+
25192687 ClickInfo newInfo = new ClickInfo();
25202688 newInfo.flags = info.flags;
25212689 newInfo.bounds = info.bounds;
....@@ -2608,6 +2776,18 @@
26082776 void GenNormalsS(boolean crease)
26092777 {
26102778 selection.GenNormals(crease);
2779
+// for (int i=0; i<selection.size(); i++)
2780
+// {
2781
+// Object3D selectee = (Object3D) selection.elementAt(i);
2782
+// selectee.GenNormals(crease);
2783
+// }
2784
+
2785
+ //Touch();
2786
+ }
2787
+
2788
+ void GenNormalsMeshS()
2789
+ {
2790
+ selection.GenNormalsMesh();
26112791 // for (int i=0; i<selection.size(); i++)
26122792 // {
26132793 // Object3D selectee = (Object3D) selection.elementAt(i);
....@@ -2748,6 +2928,24 @@
27482928 if (child == null)
27492929 continue;
27502930 child.GenNormals(crease);
2931
+// Children().release(i);
2932
+ }
2933
+ blockloop = false;
2934
+ }
2935
+
2936
+ void GenNormalsMesh()
2937
+ {
2938
+ if (blockloop)
2939
+ return;
2940
+
2941
+ blockloop = true;
2942
+ GenNormalsMesh0();
2943
+ for (int i = 0; i < Children().Size(); i++)
2944
+ {
2945
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2946
+ if (child == null)
2947
+ continue;
2948
+ child.GenNormalsMesh();
27512949 // Children().release(i);
27522950 }
27532951 blockloop = false;
....@@ -2905,7 +3103,8 @@
29053103 {
29063104 if (bRep != null)
29073105 {
2908
- bRep.GenUV();
3106
+ bRep.GenUV(); //1);
3107
+ //bRep.UnfoldUV();
29093108 Touch();
29103109 }
29113110 }
....@@ -2919,11 +3118,20 @@
29193118 }
29203119 }
29213120
3121
+ void GenNormalsMesh0()
3122
+ {
3123
+ if (bRep != null)
3124
+ {
3125
+ bRep.GenerateNormalsMesh();
3126
+ Touch();
3127
+ }
3128
+ }
3129
+
29223130 void GenNormalsMINE0()
29233131 {
29243132 if (bRep != null)
29253133 {
2926
- bRep.GenerateNormalsMINE();
3134
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
29273135 Touch();
29283136 }
29293137 }
....@@ -2980,6 +3188,33 @@
29803188 blockloop = false;
29813189 }
29823190
3191
+ void TransformChildren()
3192
+ {
3193
+ if (toParent != null)
3194
+ {
3195
+ for (int i=Size(); --i>=0;)
3196
+ {
3197
+ Object3D v = get(i);
3198
+
3199
+ if (v.toParent == null)
3200
+ {
3201
+ v.toParent = LA.newMatrix();
3202
+ v.fromParent = LA.newMatrix();
3203
+ }
3204
+
3205
+// LA.matConcat(v.toParent, toParent, v.toParent);
3206
+// LA.matConcat(fromParent, v.fromParent, v.fromParent);
3207
+ LA.matConcat(toParent, v.toParent, v.toParent);
3208
+ LA.matConcat(v.fromParent, fromParent, v.fromParent);
3209
+ }
3210
+
3211
+ toParent = null; // LA.matIdentity(toParent);
3212
+ fromParent = null; // LA.matIdentity(fromParent);
3213
+
3214
+ Touch();
3215
+ }
3216
+ }
3217
+
29833218 void TransformGeometry()
29843219 {
29853220 Object3D obj = this;
....@@ -3201,9 +3436,11 @@
32013436
32023437 BoundaryRep sup = bRep.support;
32033438 bRep.support = null;
3204
- BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
3439
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
32053440 // bRep.SplitInTwo(onlyone); // thread...
3206
- temprep.SplitInTwo(reduction34, onlyone);
3441
+
3442
+ while(temprep.SplitInTwo(reduction34, onlyone));
3443
+
32073444 bRep = temprep;
32083445 bRep.support = sup;
32093446 Touch();
....@@ -3340,7 +3577,8 @@
33403577 if (blockloop)
33413578 return;
33423579
3343
- if (marked || (bRep != null && material != null)) // borderline...
3580
+ if (//marked || // does not make sense
3581
+ (bRep != null || material != null)) // borderline...
33443582 live = h;
33453583
33463584 for (int i = 0; i < Size(); i++)
....@@ -3361,7 +3599,8 @@
33613599 return;
33623600
33633601 //if (bRep != null)
3364
- if (marked || (bRep != null && material != null)) // borderline...
3602
+ if (//marked || // does not make sense
3603
+ (bRep != null || material != null)) // borderline...
33653604 link2master = h;
33663605
33673606 for (int i = 0; i < Size(); i++)
....@@ -3381,7 +3620,8 @@
33813620 if (blockloop)
33823621 return;
33833622
3384
- if (marked || (bRep != null && material != null)) // borderline...
3623
+ if (//marked || // does not make sense
3624
+ (bRep != null || material != null)) // borderline...
33853625 hide = h;
33863626
33873627 for (int i = 0; i < Size(); i++)
....@@ -3401,7 +3641,7 @@
34013641 if (blockloop)
34023642 return;
34033643
3404
- if (bRep != null && material != null) // borderline...
3644
+ if (bRep != null || material != null) // borderline...
34053645 marked = h;
34063646
34073647 for (int i = 0; i < Size(); i++)
....@@ -3411,6 +3651,46 @@
34113651 continue;
34123652 blockloop = true;
34133653 child.MarkLeaves(h);
3654
+ blockloop = false;
3655
+ // release(i);
3656
+ }
3657
+ }
3658
+
3659
+ void RewindLeaves(boolean h)
3660
+ {
3661
+ if (blockloop)
3662
+ return;
3663
+
3664
+ if (bRep != null || material != null) // borderline...
3665
+ rewind = h;
3666
+
3667
+ for (int i = 0; i < Size(); i++)
3668
+ {
3669
+ Object3D child = (Object3D) get(i); // reserve(i);
3670
+ if (child == null)
3671
+ continue;
3672
+ blockloop = true;
3673
+ child.RewindLeaves(h);
3674
+ blockloop = false;
3675
+ // release(i);
3676
+ }
3677
+ }
3678
+
3679
+ void RandomLeaves(boolean h)
3680
+ {
3681
+ if (blockloop)
3682
+ return;
3683
+
3684
+ if (bRep != null || material != null) // borderline...
3685
+ random = h;
3686
+
3687
+ for (int i = 0; i < Size(); i++)
3688
+ {
3689
+ Object3D child = (Object3D) get(i); // reserve(i);
3690
+ if (child == null)
3691
+ continue;
3692
+ blockloop = true;
3693
+ child.RandomLeaves(h);
34143694 blockloop = false;
34153695 // release(i);
34163696 }
....@@ -3725,7 +4005,7 @@
37254005 if (child == null)
37264006 continue;
37274007
3728
- if (GrafreeD.RENDERME > 0)
4008
+ if (Grafreed.RENDERME > 0)
37294009 {
37304010 if (child instanceof Merge)
37314011 ((Merge)child).renderme();
....@@ -3876,7 +4156,7 @@
38764156 if (child == null)
38774157 continue;
38784158
3879
- if (GrafreeD.RENDERME > 0)
4159
+ if (Grafreed.RENDERME > 0)
38804160 {
38814161 if (child instanceof Merge)
38824162 ((Merge)child).renderme();
....@@ -4071,7 +4351,7 @@
40714351 if (child == null)
40724352 continue;
40734353
4074
- if (GrafreeD.RENDERME > 0)
4354
+ if (Grafreed.RENDERME > 0)
40754355 {
40764356 if (child instanceof Merge)
40774357 ((Merge)child).renderme();
....@@ -4184,6 +4464,55 @@
41844464 {
41854465 blockloop = true;
41864466 get(i).RepairShadow();
4467
+ blockloop = false;
4468
+ }
4469
+ }
4470
+
4471
+ void RepairSOV()
4472
+ {
4473
+ if (blockloop)
4474
+ return;
4475
+
4476
+ String texname = this.GetPigmentTexture();
4477
+
4478
+ if (texname.startsWith("sov"))
4479
+ {
4480
+ String[] s = texname.split("/");
4481
+
4482
+ String[] sname = s[1].split("Color.pn");
4483
+
4484
+ texname = sname[0];
4485
+
4486
+ if (sname.length > 1)
4487
+ {
4488
+ texname += "Color.jpg";
4489
+ }
4490
+
4491
+ this.SetPigmentTexture("sov/" + texname);
4492
+ }
4493
+
4494
+ texname = this.GetBumpTexture();
4495
+
4496
+ if (texname.startsWith("sov"))
4497
+ {
4498
+ String[] s = texname.split("/");
4499
+
4500
+ String[] sname = s[1].split("Bump.pn");
4501
+
4502
+ texname = sname[0];
4503
+
4504
+ if (sname.length > 1)
4505
+ {
4506
+ texname += "Bump.jpg";
4507
+ }
4508
+
4509
+ this.SetBumpTexture("sov/" + texname);
4510
+ }
4511
+
4512
+ for (int i=0; i<Size(); i++)
4513
+ {
4514
+ blockloop = true;
4515
+ get(i).RepairSOV();
41874516 blockloop = false;
41884517 }
41894518 }
....@@ -4678,7 +5007,7 @@
46785007
46795008 cTreePath SelectLeaf(int indexcount, boolean deselect)
46805009 {
4681
- if (hide)
5010
+ if (hide || dontselect)
46825011 return null;
46835012
46845013 if (count <= 0)
....@@ -4702,9 +5031,17 @@
47025031 }
47035032 }
47045033
5034
+ ObjEditor GetWindow()
5035
+ {
5036
+ if (editWindow != null)
5037
+ return editWindow;
5038
+
5039
+ return manipWindow;
5040
+ }
5041
+
47055042 cTreePath Select(int indexcount, boolean deselect)
47065043 {
4707
- if (hide)
5044
+ if (hide || dontselect)
47085045 return null;
47095046
47105047 if (count <= 0)
....@@ -4738,10 +5075,11 @@
47385075 if (leaf != null)
47395076 {
47405077 cTreePath tp = new cTreePath(this, leaf);
4741
- if (editWindow != null)
5078
+ ObjEditor window = GetWindow();
5079
+ if (window != null)
47425080 {
47435081 //System.out.println("editWindow = " + editWindow + " vs " + this);
4744
- editWindow.Select(tp, deselect, true);
5082
+ window.Select(tp, deselect, true);
47455083 }
47465084
47475085 return tp;
....@@ -4758,6 +5096,7 @@
47585096
47595097 if (child == null)
47605098 continue;
5099
+
47615100 if (child.HasTransparency() && child.size() != 0)
47625101 {
47635102 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4767,9 +5106,10 @@
47675106 if (leaf != null)
47685107 {
47695108 cTreePath tp = new cTreePath(this, leaf);
4770
- if (editWindow != null)
5109
+ ObjEditor window = GetWindow();
5110
+ if (window != null)
47715111 {
4772
- editWindow.Select(tp, deselect, true);
5112
+ window.Select(tp, deselect, true);
47735113 }
47745114
47755115 return tp;
....@@ -4854,7 +5194,7 @@
48545194 return globalTransform;
48555195 }
48565196
4857
- void PreprocessOcclusion(CameraPane cp)
5197
+ void PreprocessOcclusion(iCameraPane cp)
48585198 {
48595199 /*
48605200 if (AOdone)
....@@ -5001,7 +5341,8 @@
50015341 } else //
50025342 if (editWindow != null)
50035343 {
5004
- editWindow.cameraView.lighttouched = true;
5344
+ //editWindow.cameraView.lighttouched = true;
5345
+ Globals.lighttouched = true;
50055346 }
50065347 }
50075348
....@@ -5093,6 +5434,51 @@
50935434 blockloop = false;
50945435 }
50955436
5437
+ void ResetSelectable()
5438
+ {
5439
+ if (blockloop)
5440
+ return;
5441
+
5442
+ blockloop = true;
5443
+
5444
+ keepdontselect = dontselect;
5445
+ dontselect = true;
5446
+
5447
+ Object3D child;
5448
+ int nb = Size();
5449
+ for (int i = 0; i < nb; i++)
5450
+ {
5451
+ child = (Object3D) get(i);
5452
+ if (child == null)
5453
+ continue;
5454
+ child.ResetSelectable();
5455
+ }
5456
+
5457
+ blockloop = false;
5458
+ }
5459
+
5460
+ void RestoreSelectable()
5461
+ {
5462
+ if (blockloop)
5463
+ return;
5464
+
5465
+ blockloop = true;
5466
+
5467
+ dontselect = keepdontselect;
5468
+
5469
+ Object3D child;
5470
+ int nb = Size();
5471
+ for (int i = 0; i < nb; i++)
5472
+ {
5473
+ child = (Object3D) get(i);
5474
+ if (child == null)
5475
+ continue;
5476
+ child.RestoreSelectable();
5477
+ }
5478
+
5479
+ blockloop = false;
5480
+ }
5481
+
50965482 boolean IsSelected()
50975483 {
50985484 if (parent == null)
....@@ -5155,10 +5541,34 @@
51555541
51565542 // System.out.println("Fullname = " + fullname);
51575543
5158
- if (fullname.name.indexOf(":") == -1)
5159
- return fullname.name;
5544
+ // Does not work on Windows due to C:
5545
+// if (fullname.name.indexOf(":") == -1)
5546
+// return fullname.name;
5547
+//
5548
+// return fullname.name.substring(0,fullname.name.indexOf(":"));
51605549
5161
- return fullname.name.substring(0,fullname.name.indexOf(":"));
5550
+ String[] split = fullname.name.split(":");
5551
+
5552
+ if (split.length == 0)
5553
+ {
5554
+ return "";
5555
+ }
5556
+
5557
+ if (split.length <= 2)
5558
+ {
5559
+ if (fullname.name.endsWith(":"))
5560
+ {
5561
+ // Windows
5562
+ return fullname.name.substring(0, fullname.name.length()-1);
5563
+ }
5564
+
5565
+ return split[0];
5566
+ }
5567
+
5568
+ // Windows
5569
+ assert(split.length == 4);
5570
+
5571
+ return split[0] + ":" + split[1];
51625572 }
51635573
51645574 static String GetBump(cTexture fullname)
....@@ -5167,10 +5577,38 @@
51675577 return "";
51685578
51695579 // System.out.println("Fullname = " + fullname);
5170
- if (fullname.name.indexOf(":") == -1)
5171
- return "";
5172
-
5173
- return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5580
+ // Does not work on Windows due to C:
5581
+// if (fullname.name.indexOf(":") == -1)
5582
+// return "";
5583
+//
5584
+// return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5585
+ String[] split = fullname.name.split(":");
5586
+
5587
+ if (split.length == 0)
5588
+ {
5589
+ return "";
5590
+ }
5591
+
5592
+ if (split.length == 1)
5593
+ {
5594
+ return "";
5595
+ }
5596
+
5597
+ if (split.length == 2)
5598
+ {
5599
+ if (fullname.name.endsWith(":"))
5600
+ {
5601
+ // Windows
5602
+ return "";
5603
+ }
5604
+
5605
+ return split[1];
5606
+ }
5607
+
5608
+ // Windows
5609
+ assert(split.length == 4);
5610
+
5611
+ return split[2] + ":" + split[3];
51745612 }
51755613
51765614 String GetPigmentTexture()
....@@ -5244,7 +5682,7 @@
52445682 System.out.print("; textures = " + textures);
52455683 System.out.println("; usedtextures = " + usedtextures);
52465684
5247
- if (GetTextures() == null)
5685
+ if (GetTextures() == null) // What is that??
52485686 GetTextures().name = ":";
52495687
52505688 String texname = tex;
....@@ -5275,6 +5713,43 @@
52755713 child.ResetPigmentTexture();
52765714 blockloop = false;
52775715 }
5716
+ }
5717
+
5718
+ UUID GetUUID()
5719
+ {
5720
+ if (uuid == null)
5721
+ {
5722
+ // Serial
5723
+ uuid = UUID.randomUUID();
5724
+ }
5725
+
5726
+ return uuid;
5727
+ }
5728
+
5729
+ Object3D GetObject(UUID uid)
5730
+ {
5731
+ if (blockloop)
5732
+ return null;
5733
+
5734
+ if (GetUUID().equals(uid))
5735
+ return this;
5736
+
5737
+ int nb = Size();
5738
+ for (int i = 0; i < nb; i++)
5739
+ {
5740
+ Object3D child = (Object3D) get(i);
5741
+
5742
+ if (child == null)
5743
+ continue;
5744
+
5745
+ blockloop = true;
5746
+ Object3D obj = child.GetObject(uid);
5747
+ blockloop = false;
5748
+ if (obj != null)
5749
+ return obj;
5750
+ }
5751
+
5752
+ return null;
52785753 }
52795754
52805755 void SetBumpTexture(String tex)
....@@ -5313,25 +5788,65 @@
53135788 }
53145789 }
53155790
5316
- void draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5791
+ void EmbedTextures(boolean embed)
5792
+ {
5793
+ if (blockloop)
5794
+ return;
5795
+
5796
+ //if (GetTextures() != null)
5797
+ if (embed)
5798
+ CameraPane.EmbedTextures(GetTextures());
5799
+ else
5800
+ {
5801
+ GetTextures().pigmentdata = null;
5802
+ GetTextures().bumpdata = null;
5803
+ GetTextures().pw = 0;
5804
+ GetTextures().ph = 0;
5805
+ GetTextures().bw = 0;
5806
+ GetTextures().bh = 0;
5807
+ }
5808
+
5809
+ int nb = Size();
5810
+ for (int i = 0; i < nb; i++)
5811
+ {
5812
+ Object3D child = (Object3D) get(i);
5813
+
5814
+ if (child == null)
5815
+ continue;
5816
+
5817
+ blockloop = true;
5818
+ child.EmbedTextures(embed);
5819
+ blockloop = false;
5820
+ }
5821
+ }
5822
+
5823
+ void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
53175824 {
53185825 Draw(display, root, selected, blocked);
53195826 }
53205827
5321
- static cMaterial[] materialstack = new cMaterial[65536];
5322
- static boolean[] selectedstack = new boolean[65536];
5323
- static int materialdepth = 0;
5324
-
53255828 boolean NeedSupport()
53265829 {
53275830 return
5328
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5831
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
53295832 // PROBLEM with CROWD!!
5330
- && (CameraPane.drawMode == CameraPane.SHADOW || CameraPane.CROWD);
5833
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
53315834 }
53325835
5836
+ static boolean DEBUG_SELECTION = false;
53335837
5334
- void Draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5838
+ boolean IsLive()
5839
+ {
5840
+ if (live)
5841
+ return true;
5842
+
5843
+ if (parent == null)
5844
+ return false;
5845
+
5846
+ return parent.IsLive();
5847
+ }
5848
+
5849
+ void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
53355850 {
53365851 Invariants(); // june 2013
53375852
....@@ -5340,8 +5855,8 @@
53405855 // System.err.println("Draw " + this + " Frame # " + ((Mocap)((Merge)support).object).frame);
53415856 }
53425857
5343
- if (display.drawMode == CameraPane.SELECTION &&
5344
- hide)
5858
+ if (display.DrawMode() == iCameraPane.SELECTION &&
5859
+ (hide || dontselect))
53455860 return;
53465861
53475862 if (name != null && name.contains("sclera"))
....@@ -5359,7 +5874,7 @@
53595874 if (this instanceof Checker)
53605875 return;
53615876
5362
- if (display.drawMode == display.SHADOW && PASSTEST)
5877
+ if (display.DrawMode() == display.SHADOW && PASSTEST)
53635878 return;
53645879
53655880 if (count <= 0)
....@@ -5367,13 +5882,13 @@
53675882 return;
53685883 }
53695884
5370
- if ((//display.drawMode == CameraPane.SHADOW ||
5371
- display.drawMode == CameraPane.SELECTION || CameraPane.DEBUG_SELECTION) && HasTransparency())
5885
+ if ((//display.DrawMode() == CameraPane.SHADOW ||
5886
+ display.DrawMode() == iCameraPane.SELECTION || display.IsDebugSelection()) && HasTransparency())
53725887 {
53735888 return;
53745889 }
53755890
5376
- javax.media.opengl.GL gl = display.GetGL();
5891
+ //javax.media.opengl.GL gl = display.GetGL();
53775892
53785893 /*
53795894 if (touched)
....@@ -5392,7 +5907,7 @@
53925907 support = support;
53935908
53945909 //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5395
- boolean usecalllists = false; // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5910
+ boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
53965911
53975912 if (!usecalllists && bRep != null && bRep.displaylist > 0)
53985913 {
....@@ -5409,15 +5924,17 @@
54095924
54105925 boolean compiled = false;
54115926
5412
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
5927
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
54135928
5414
- if (!selectmode && //display.drawMode != display.SELECTION &&
5415
- (touched || (bRep != null && bRep.displaylist <= 0)))
5929
+ if (!selectmode && //display.DrawMode() != display.SELECTION &&
5930
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5931
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
54165932 {
5417
- display.lighttouched = true;
5933
+ Globals.lighttouched = true;
54185934 } // all panes...
5419
- //if (usecalllists && display.drawMode != display.SELECTION && display.drawMode != display.SHADOW &&
5420
- if (bRep != null && usecalllists && !selectmode && // june 2013 display.drawMode != display.SHADOW &&
5935
+
5936
+ //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
5937
+ if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
54215938 (touched || (bRep != null && bRep.displaylist <= 0)))
54225939 {
54235940 if (!(this instanceof Composite))
....@@ -5425,7 +5942,7 @@
54255942 //if (displaylist == -1 && usecalllists)
54265943 if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
54275944 {
5428
- bRep.displaylist = gl.glGenLists(1);
5945
+ bRep.displaylist = display.GenList();
54295946 assert(bRep.displaylist != 0);
54305947 // System.err.println("glGenLists: " + bRep.displaylist + " for " + this);
54315948 //System.out.println("\tgen list " + list);
....@@ -5437,18 +5954,20 @@
54375954 if (usecalllists)
54385955 {
54395956 // System.err.println("new list " + bRep.displaylist + " for " + this);
5440
- gl.glNewList(bRep.displaylist, gl.GL_COMPILE); //_AND_EXECUTE);
5957
+ display.NewList(bRep.displaylist);
54415958 }
5959
+
54425960 CallList(display, root, selected, blocked);
5961
+
54435962 // compiled = true;
54445963 if (usecalllists)
54455964 {
54465965 // System.err.println("end list " + bRep.displaylist + " for " + this);
5447
- gl.glEndList();
5966
+ display.EndList();
54485967 }
54495968 //gl.glDrawBuffer(gl.GL_BACK);
54505969 // XXX touched = false;
5451
- display.lighttouched = true; // all panes...
5970
+ Globals.lighttouched = true; // all panes...
54525971 }
54535972
54545973 touched = GetBRep() == null; // this instanceof Composite || this instanceof FileObject; // false;
....@@ -5487,12 +6006,12 @@
54876006
54886007 // frustum culling
54896008 if (CameraPane.FRUSTUM && !blocked && !IsInfinite() && GetBRep() != null // && GetBRep().VertexCount() != 1260 // default grid
5490
- && display.drawMode != CameraPane.SELECTION)
6009
+ && display.DrawMode() != iCameraPane.SELECTION)
54916010 {
5492
- if (display.drawMode == CameraPane.SHADOW)
6011
+ if (display.DrawMode() == iCameraPane.SHADOW)
54936012 {
54946013 if (!link2master // tricky to cull in shadow mode.
5495
- && GetBRep().FrustumCull(this, gl, display.lightCamera, true))
6014
+ && GetBRep().FrustumCull(this, null, display.LightCamera(), true))
54966015 {
54976016 //System.out.print("CULLED");
54986017 culled = true;
....@@ -5500,7 +6019,7 @@
55006019 }
55016020 else
55026021 //GetBRep().getBounds(v0, v1, this);
5503
- if (GetBRep().FrustumCull(this, gl, display.renderCamera, false))
6022
+ if (GetBRep().FrustumCull(this, null, display.RenderCamera(), false))
55046023 culled = true;
55056024
55066025 // LA.xformPos(v0, display.renderCamera.toScreen, v0);
....@@ -5536,11 +6055,12 @@
55366055
55376056
55386057 if (!culled)
5539
- if (display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION)
6058
+ if (display.DrawMode() == display.SELECTION || display.IsDebugSelection())
55406059 {
55416060 if (GetBRep() != null)
55426061 {
5543
- CameraPane.NextIndex(this, gl);
6062
+ display.NextIndex();
6063
+
55446064 // vertex color conflict : gl.glCallList(list);
55456065 DrawNode(display, root, selected);
55466066 if (this instanceof BezierPatch)
....@@ -5562,55 +6082,7 @@
55626082 color[2] /= 2;
55636083 gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT_AND_DIFFUSE, color, 0);
55646084 */
5565
- if (material != null)
5566
- {
5567
- materialstack[materialdepth] = material;
5568
- selectedstack[materialdepth] = selected;
5569
- cStatic.objectstack[materialdepth++] = this;
5570
- //System.out.println("material " + material);
5571
- //Applet3D.tracein(this, selected);
5572
- display.vector2buffer = projectedVertices;
5573
- if (this instanceof Camera)
5574
- {
5575
- display.options1[0] = material.shift;
5576
- //System.out.println("shift " + material.shift);
5577
- display.options1[1] = material.lightarea;
5578
- display.options1[2] = material.shadowbias;
5579
- display.options1[3] = material.aniso;
5580
- display.options1[4] = material.anisoV;
5581
- display.options2[0] = material.opacity;
5582
- display.options2[1] = material.diffuse;
5583
- display.options2[2] = material.factor;
5584
-
5585
- cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
5586
- display.options4[0] = material.cameralight/0.2f;
5587
- display.options4[1] = material.subsurface;
5588
- display.options4[2] = material.sheen;
5589
-
5590
- // if (display.CURRENTANTIALIAS > 0)
5591
- // display.options3[3] /= 4;
5592
-
5593
- /*
5594
- System.out.println("Focus = " + display.options1[0]);
5595
- System.out.println("Aperture = " + display.options1[1]);
5596
- System.out.println("ShadowBlur = " + display.options1[2]);
5597
- System.out.println("Antialiasing = " + display.options1[3]);
5598
- System.out.println("Fog = " + display.options2[0]);
5599
- System.out.println("Intensity = " + display.options2[1]);
5600
- System.out.println("Elevation = " + display.options2[2]);
5601
- /**/
5602
- } else
5603
- {
5604
- material.Draw(display, selected);
5605
- }
5606
- } else
5607
- {
5608
- if (selected && CameraPane.flash)
5609
- {
5610
- display.modelParams4[1] = 100;
5611
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
5612
- }
5613
- }
6085
+ display.PushMaterial(this, selected);
56146086
56156087 //System.out.println("call list " + list);
56166088 //System.out.println();
....@@ -5629,7 +6101,28 @@
56296101 tex = GetTextures();
56306102 }
56316103
5632
- display.BindTextures(tex, texres);
6104
+ boolean failedPigment = false;
6105
+ boolean failedBump = false;
6106
+
6107
+ try
6108
+ {
6109
+ display.BindPigmentTexture(tex, texres);
6110
+ }
6111
+ catch (Exception e)
6112
+ {
6113
+ System.err.println("FAILED: " + this);
6114
+ failedPigment = true;
6115
+ }
6116
+
6117
+ try
6118
+ {
6119
+ display.BindBumpTexture(tex, texres);
6120
+ }
6121
+ catch (Exception e)
6122
+ {
6123
+ //System.err.println("FAILED: " + this);
6124
+ failedBump = true;
6125
+ }
56336126
56346127 if (!compiled)
56356128 {
....@@ -5645,30 +6138,19 @@
56456138
56466139 // System.err.println("glCallList: " + bRep.displaylist + " for " + this);
56476140 assert(bRep.displaylist != 0);
5648
- gl.glCallList(bRep.displaylist);
6141
+ display.CallList(bRep.displaylist);
56496142 // june 2013 drawSelf(display, root, selected);
56506143 }
56516144 }
56526145 }
56536146
5654
- display.ReleaseTextures(tex);
5655
-
5656
- //if (parent != null && parent.GetMaterial() != null)
5657
- // parent.GetMaterial().Draw(display, parent.IsSelected(this));
5658
- if (material != null)
5659
- {
5660
- materialdepth -= 1;
5661
- if (materialdepth > 0)
5662
- {
5663
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
5664
- materialstack[materialdepth - 1].Draw(display, selectedstack[materialdepth - 1]);
5665
- }
5666
- //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
5667
- } else if (selected && CameraPane.flash && GetMaterial() != null)
5668
- {
5669
- display.modelParams4[1] = GetMaterial().cameralight;
5670
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
5671
- }
6147
+ if (!failedBump)
6148
+ display.ReleaseBumpTexture(tex);
6149
+
6150
+ if (!failedPigment)
6151
+ display.ReleasePigmentTexture(tex);
6152
+
6153
+ display.PopMaterial(this, selected);
56726154 }
56736155
56746156 if (this instanceof Texture || this instanceof TextureNode)
....@@ -5710,7 +6192,7 @@
57106192 // resetMasterNode();
57116193 }
57126194
5713
- void CallList(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
6195
+ void CallList(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57146196 {
57156197 if (GetBRep() == null)
57166198 {
....@@ -5793,8 +6275,11 @@
57936275 boolean flipV = false; // true;
57946276 int texres = 0; // 0 = low, 1 = normal, 2 = high res texture
57956277
5796
- void drawSelf(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
6278
+ void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57976279 {
6280
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6281
+ return;
6282
+
57986283 if (hide)
57996284 return;
58006285 // shadow optimisation
....@@ -5852,16 +6337,7 @@
58526337 // // ??????????????????????????? Touch();
58536338 // }
58546339
5855
- if (material != null)
5856
- {
5857
- materialstack[materialdepth] = material;
5858
- selectedstack[materialdepth] = selected;
5859
- cStatic.objectstack[materialdepth++] = this;
5860
- //System.out.println("material " + material);
5861
- //Applet3D.tracein("selected ", selected);
5862
- display.vector2buffer = projectedVertices;
5863
- material.Draw(display, selected);
5864
- }
6340
+display.PushMaterial2(this, selected);
58656341
58666342 Object3D child;
58676343 boolean sel;
....@@ -5913,19 +6389,7 @@
59136389 */
59146390 //depth += 1;
59156391
5916
- if (material != null)
5917
- {
5918
- materialdepth -= 1;
5919
- if (materialdepth > 0)
5920
- {
5921
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
5922
- materialstack[materialdepth - 1].Draw(display, selectedstack[materialdepth - 1]);
5923
- }
5924
- //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
5925
- //else
5926
- //material.Draw(display, false);
5927
- }
5928
-
6392
+display.PopMaterial2(this);
59296393 /*
59306394 display.ReleaseTextures(tex);
59316395 */
....@@ -5936,10 +6400,13 @@
59366400
59376401 //static cVector min,max;
59386402
5939
- void DrawNode(CameraPane display, Object3D /*Composite*/ root, boolean selected)
6403
+ void DrawNode(iCameraPane display, Object3D /*Composite*/ root, boolean selected)
59406404 {
5941
- if (display.drawMode == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
6405
+ if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
59426406 return; // no shadow for transparent objects
6407
+
6408
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6409
+ return;
59436410
59446411 if (hide)
59456412 return;
....@@ -5981,9 +6448,10 @@
59816448 return;
59826449 }
59836450
6451
+ //bRep.GenUV(1/material.diffuseness);
59846452 // bRep.lock = true;
59856453
5986
- javax.media.opengl.GL gl = display.GetGL();
6454
+ //javax.media.opengl.GL gl = display.GetGL();
59876455
59886456 if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera)
59896457 {
....@@ -6000,23 +6468,7 @@
60006468
60016469 bRep.getMinMax(min, max, 100);
60026470
6003
- gl.glBegin(gl.GL_LINES);
6004
-
6005
- gl.glVertex3d(min.x, min.y, min.z);
6006
- gl.glVertex3d(min.x, min.y, max.z);
6007
- gl.glVertex3d(min.x, min.y, min.z);
6008
- gl.glVertex3d(min.x, max.y, min.z);
6009
- gl.glVertex3d(min.x, min.y, min.z);
6010
- gl.glVertex3d(max.x, min.y, min.z);
6011
-
6012
- gl.glVertex3d(max.x, max.y, max.z);
6013
- gl.glVertex3d(min.x, max.y, max.z);
6014
- gl.glVertex3d(max.x, max.y, max.z);
6015
- gl.glVertex3d(max.x, min.y, max.z);
6016
- gl.glVertex3d(max.x, max.y, max.z);
6017
- gl.glVertex3d(max.x, max.y, min.z);
6018
-
6019
- gl.glEnd();
6471
+ display.DrawBox(min, max);
60206472
60216473 return;
60226474 }
....@@ -6060,7 +6512,7 @@
60606512 {
60616513 //throw new Error();
60626514
6063
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
6515
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
60646516
60656517 int[] strips = bRep.getRawIndices();
60666518
....@@ -6070,178 +6522,19 @@
60706522 new Exception().printStackTrace();
60716523 return;
60726524 }
6073
-
6074
- // TRIANGLE STRIP ARRAY
6075
- if (bRep.trimmed)
6525
+
6526
+ if (dontselect)
60766527 {
6077
- float[] v = bRep.getRawVertices();
6078
- float[] n = bRep.getRawNormals();
6079
- float[] c = bRep.getRawColors();
6080
- float[] uv = bRep.getRawUVMap();
6081
-
6082
- int count2 = 0;
6083
- int count3 = 0;
6084
-
6085
- if (n.length > 0)
6086
- {
6087
- for (int i = 0; i < strips.length; i++)
6088
- {
6089
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6090
-
6091
- /*
6092
- boolean locked = false;
6093
- float eps = 0.1f;
6094
- boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
6095
-
6096
- int dot = 0;
6097
-
6098
- if ((dot&1) == 0)
6099
- dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
6100
-
6101
- if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
6102
- gl.glTexCoord2f((float) qv.s, (float) qv.t);
6103
- else
6104
- {
6105
- locked = true;
6106
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6107
- }
6108
- //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6109
- gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
6110
- if (hasnorm)
6111
- {
6112
- //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6113
- gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
6114
- }
6115
-
6116
- if ((dot&4) == 0)
6117
- dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
6118
-
6119
- if (wrap || !locked && (dot&8) != 0)
6120
- gl.glTexCoord2f((float) rv.s, (float) rv.t);
6121
- else
6122
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6123
-
6124
- f.dot = dot;
6125
- */
6126
-
6127
- if (!selectmode)
6128
- {
6129
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6130
- {
6131
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6132
- } else
6133
- {
6134
- gl.glNormal3f(0, 0, 1);
6135
- }
6136
-
6137
- if (c != null)
6138
- //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]);
6139
- {
6140
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6141
- }
6142
- }
6143
- if (flipV)
6144
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6145
- else
6146
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6147
- //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6148
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6149
-
6150
- count2 += 2;
6151
- count3 += 3;
6152
- if (!selectmode)
6153
- {
6154
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6155
- {
6156
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6157
- } else
6158
- {
6159
- gl.glNormal3f(0, 0, 1);
6160
- }
6161
- if (c != null)
6162
- {
6163
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6164
- }
6165
- }
6166
- if (flipV)
6167
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6168
- else
6169
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6170
- //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6171
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6172
-
6173
- count2 += 2;
6174
- count3 += 3;
6175
- for (int j = 0; j < strips[i] - 2; j++)
6176
- {
6177
- //gl.glTexCoord2d(...);
6178
- if (!selectmode)
6179
- {
6180
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6181
- {
6182
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6183
- } else
6184
- {
6185
- gl.glNormal3f(0, 0, 1);
6186
- }
6187
- if (c != null)
6188
- {
6189
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6190
- }
6191
- }
6192
-
6193
- if (flipV)
6194
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6195
- else
6196
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6197
- //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
6198
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6199
- count2 += 2;
6200
- count3 += 3;
6201
- }
6202
-
6203
- gl.glEnd();
6204
- }
6205
- }
6206
-
6207
- assert count3 == v.length;
6528
+ //bRep.GenerateNormalsMINE();
62086529 }
6209
- else // !trimmed
6210
- {
6211
- int count = 0;
6212
- for (int i = 0; i < strips.length; i++)
6213
- {
6214
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6215
-
6216
- Vertex p = bRep.GetVertex(bRep.indices[count++]);
6217
- Vertex q = bRep.GetVertex(bRep.indices[count++]);
6218
-
6219
- drawVertex(gl, p, selectmode);
6220
- drawVertex(gl, q, selectmode);
6221
-
6222
- for (int j = 0; j < strips[i] - 2; j++)
6223
- {
6224
- Vertex r = bRep.GetVertex(bRep.indices[count++]);
6225
-
6226
-// if (j%2 == 0)
6227
-// drawFace(p, q, r, display, null);
6228
-// else
6229
-// drawFace(p, r, q, display, null);
6230
-
6231
-// p = q;
6232
-// q = r;
6233
- drawVertex(gl, r, selectmode);
6234
- }
6235
-
6236
- gl.glEnd();
6237
- }
6238
- }
6530
+
6531
+ display.DrawGeometry(bRep, flipV, selectmode);
62396532 } else // catch (Error e)
62406533 {
62416534 // TRIANGLE ARRAY
62426535 if (IsOpaque()) // Static())
62436536 {
6244
- gl.glBegin(gl.GL_TRIANGLES);
6537
+ display.StartTriangles();
62456538 int facecount = bRep.FaceCount();
62466539 for (int i = 0; i < facecount; i++)
62476540 {
....@@ -6304,9 +6597,9 @@
63046597 // // r.norm.dot(v3) > -0.5)
63056598 // // continue;
63066599
6307
- drawFace(p, q, r, display, face);
6600
+ display.DrawFace(this, p, q, r, face);
63086601 }
6309
- gl.glEnd();
6602
+ display.EndTriangles();
63106603 }
63116604 else
63126605 {
....@@ -6335,8 +6628,8 @@
63356628 //System.out.println("SORT");
63366629
63376630 java.util.Arrays.sort(facescompare);
6338
-
6339
- gl.glBegin(gl.GL_TRIANGLES);
6631
+
6632
+ display.StartTriangles();
63406633 for (int i = 0; i < facecount; i++)
63416634 {
63426635 Face face = bRep.GetFace(facescompare[i].index);
....@@ -6348,13 +6641,14 @@
63486641 Vertex q = bRep.GetVertex(face.q);
63496642 Vertex r = bRep.GetVertex(face.r);
63506643
6351
- drawFace(p, q, r, display, face);
6644
+ display.DrawFace(this, p, q, r, face);
63526645 }
6353
- gl.glEnd();
6646
+ display.EndTriangles();
63546647 }
63556648
63566649 if (false) // live && support != null && support.bRep != null) // debug weights
63576650 {
6651
+ /*
63586652 gl.glDisable(gl.GL_LIGHTING);
63596653 float[] colorV = new float[3];
63606654
....@@ -6433,6 +6727,7 @@
64336727 // gl.glEnd();
64346728 }
64356729 }
6730
+ */
64366731 }
64376732 }
64386733
....@@ -6477,7 +6772,7 @@
64776772 center.add(r);
64786773 center.mul(1.0/3);
64796774
6480
- center.sub(CameraPane.theRenderer.eyeCamera.location);
6775
+ center.sub(Globals.theRenderer.EyeCamera().location);
64816776
64826777 distance = center.dot(center);
64836778 }
....@@ -6488,390 +6783,11 @@
64886783
64896784 transient FaceCompare[] facescompare = null;
64906785
6491
- void SetColor(CameraPane display, Vertex p0)
6492
- {
6493
- if (display.RENDERPROGRAM == 0)
6494
- {
6495
- float r = 0;
6496
- if (bRep != null)
6497
- {
6498
- if (bRep.stripified)
6499
- {
6500
- r = 1;
6501
- }
6502
- }
6503
- float g = 0;
6504
- if (bRep != null)
6505
- {
6506
- if (bRep.trimmed)
6507
- {
6508
- g = 1;
6509
- }
6510
- }
6511
- float b = 0;
6512
- if (support != null && link2master)
6513
- {
6514
- b = 1;
6515
- }
6516
- display.GetGL().glColor3f(r*p0.AO, g*p0.AO, b*p0.AO);
6517
- return;
6518
- }
6519
-
6520
- if (display.drawMode != CameraPane.SHADOW)
6521
- return;
6522
-
6523
- javax.media.opengl.GL gl = display.GetGL();
6524
-// if (true) return;
6525
-// float ao = p.AO;
6526
-//
6527
-// // if (ao == 0 && !bRep.AOdone) // transient problem!
6528
-// // ao = 1;
6529
-//
6530
-// gl.glColor4f(ao, ao, ao, 1);
6531
-
6532
-// CameraPane.selectedpoint.
6533
-// getAverage(cStatic.point1, true);
6534
- if (CameraPane.pointflow == null) // !random) // live)
6535
- {
6536
- return;
6537
- }
6538
-
6539
- cStatic.point1.set(0,0,0);
6540
- LA.xformPos(cStatic.point1, CameraPane.selectedpoint.toParent, cStatic.point1);
6541
-
6542
- cStatic.point1.sub(p0);
6543
-
6544
-
6545
-// if (marked && (p0.vertexlinks == null || support == null || support.bRep == null)) // no position delta?
6546
-// {
6547
-// return;
6548
-// }
6549
-
6550
- //if (true)
6551
- if (cStatic.point1.dot(cStatic.point1) > 0.000001)
6552
- {
6553
- return;
6554
- }
6555
-
6556
- float[] colorV = new float[3];
6557
-
6558
- if (false) // marked)
6559
- {
6560
- // debug rigging weights
6561
- for (int object = 0; object < p0.vertexlinks.length; object++)
6562
- {
6563
- float weight = p0.weights[object] / p0.totalweight;
6564
-
6565
- // if (weight < 0.1)
6566
- // {
6567
- // assert(weight == 0);
6568
- // continue;
6569
- // }
6570
-
6571
- if (p0.vertexlinks[object] == -1)
6572
- continue;
6573
-
6574
- Vertex q = support.bRep.GetVertex(p0.vertexlinks[object]);
6575
-
6576
- int color = //1 << object; //
6577
- //p.vertexlinks.length;
6578
- support.bRep.supports[p0.closestsupport].links[object];
6579
- colorV[2] += (color & 1) * weight;
6580
- colorV[1] += ((color & 2) >> 1) * weight;
6581
- colorV[0] += ((color & 4) >> 2) * weight;
6582
- }
6583
- }
6584
- else
6585
- {
6586
- if (drawingstarted)
6587
- {
6588
- // find next point
6589
- if (bRep.GetVertex(0).faceindices == null)
6590
- {
6591
- bRep.InitFaceIndices();
6592
- }
6593
-
6594
- double ymin = p0.y;
6595
-
6596
- Vertex newp = p0;
6597
-
6598
- for (int fii = 0; fii < p0.faceindices.length; fii++)
6599
- {
6600
- int fi = p0.faceindices[fii];
6601
-
6602
- if (fi == -1)
6603
- break;
6604
-
6605
- Face f = bRep.GetFace(fi);
6606
-
6607
- Vertex p = bRep.GetVertex(f.p);
6608
- Vertex q = bRep.GetVertex(f.q);
6609
- Vertex r = bRep.GetVertex(f.r);
6610
-
6611
- int swap = (int)(Math.random()*3);
6612
-
6613
-// for (int s=swap; --s>=0;)
6614
-// {
6615
-// Vertex t = p;
6616
-// p = q;
6617
-// q = r;
6618
-// r = t;
6619
-// }
6620
- if (ymin > p.y)
6621
- {
6622
- ymin = p.y;
6623
- newp = p;
6624
-// break;
6625
- }
6626
- if (ymin > q.y)
6627
- {
6628
- ymin = q.y;
6629
- newp = q;
6630
-// break;
6631
- }
6632
- if (ymin > r.y)
6633
- {
6634
- ymin = r.y;
6635
- newp = r;
6636
-// break;
6637
- }
6638
- }
6639
-
6640
- CameraPane.selectedpoint.toParent[3][0] = newp.x;
6641
- CameraPane.selectedpoint.toParent[3][1] = newp.y;
6642
- CameraPane.selectedpoint.toParent[3][2] = newp.z;
6643
-
6644
- drawingstarted = false;
6645
-
6646
- // return;
6647
- }
6648
-
6649
- if (false) // CameraPane.DRAW
6650
- {
6651
- p0.AO = colorV[0] = 2;
6652
- colorV[1] = 2;
6653
- colorV[2] = 2;
6654
- }
6655
-
6656
- CameraPane.pointflow.add(p0);
6657
- CameraPane.pointflow.Touch();
6658
- }
6659
-
6660
-// gl.glColor3f(colorV[0], colorV[1], colorV[2]);
6661
-// gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0);
6662
-// gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
6663
- }
6664
-
66656786 void Print(Vertex v)
66666787 {
66676788 //System.err.println("(" + v.x + ", " + v.y + ", " + v.z + ")");
66686789 }
66696790
6670
- void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean selectmode)
6671
- {
6672
- if (!selectmode)
6673
- {
6674
- gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
6675
- gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
6676
-
6677
- if (flipV)
6678
- gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
6679
- else
6680
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6681
- }
6682
-
6683
- gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
6684
- }
6685
-
6686
- void drawFace(Vertex pv, Vertex qv, Vertex rv,
6687
- CameraPane display, Face face)
6688
- {
6689
- if (pv.y == -10000 ||
6690
- qv.y == -10000 ||
6691
- rv.y == -10000)
6692
- return;
6693
-
6694
-// float b = f.nbiterations & 1;
6695
-// float g = (f.nbiterations>>1) & 1;
6696
-// float r = (f.nbiterations>>2) & 1;
6697
-//
6698
-// //if (f.weight == 10000)
6699
-// //{
6700
-// // r = 1; g = b = 0;
6701
-// //}
6702
-// //else
6703
-// //{
6704
-// // assert(f.weight < 10000);
6705
-// r = g = b = (float)bRep.FaceWeight(f)*100;
6706
-// if (r<0)
6707
-// assert(r>=0);
6708
-// //}
6709
-
6710
- javax.media.opengl.GL gl = display.GetGL();
6711
-
6712
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
6713
-
6714
- //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv);
6715
- if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
6716
- {
6717
- //gl.glBegin(gl.GL_TRIANGLES);
6718
- boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
6719
- if (!hasnorm)
6720
- {
6721
- // System.out.println("FUCK!!");
6722
- LA.vecSub(pv/*.pos*/, qv/*.pos*/, v0);
6723
- LA.vecSub(pv/*.pos*/, rv/*.pos*/, v1);
6724
- LA.vecCross(v0, v1, v2);
6725
- LA.vecNormalize(v2);
6726
- gl.glNormal3f((float) v2.x, (float) v2.y, (float) v2.z);
6727
- }
6728
-
6729
- // P
6730
- float x = (float)pv.x;
6731
- float y = (float)pv.y;
6732
- float z = (float)pv.z;
6733
-
6734
- if (hasnorm)
6735
- {
6736
-// if (!pv.norm.normalized())
6737
-// assert(pv.norm.normalized());
6738
-
6739
- //System.out.println("normalp = " + pv.norm.x + ", " + pv.norm.y + ", " + pv.norm.z);
6740
- float nx = (float)pv.norm.x;
6741
- float ny = (float)pv.norm.y;
6742
- float nz = (float)pv.norm.z;
6743
-
6744
- x += nx * NORMALPUSH;
6745
- y += ny * NORMALPUSH;
6746
- z += nz * NORMALPUSH;
6747
-
6748
- gl.glNormal3f(nx, ny, nz);
6749
- }
6750
- gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
6751
- SetColor(display, pv);
6752
- //gl.glColor4f(r, g, b, 1);
6753
- //gl.glColor4f(pv.boundary, pv.boundary, pv.boundary, 1);
6754
- if (flipV)
6755
- gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
6756
- else
6757
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6758
- //System.out.println("vertexp = " + pv.x + ", " + pv.y + ", " + pv.z);
6759
-
6760
- gl.glVertex3f(x, y, z);
6761
-
6762
- // Q
6763
- x = (float)qv.x;
6764
- y = (float)qv.y;
6765
- z = (float)qv.z;
6766
-
6767
-// Print(pv);
6768
- if (hasnorm)
6769
- {
6770
-// assert(qv.norm.normalized());
6771
- //System.out.println("normalq = " + qv.norm.x + ", " + qv.norm.y + ", " + qv.norm.z);
6772
- float nx = (float)qv.norm.x;
6773
- float ny = (float)qv.norm.y;
6774
- float nz = (float)qv.norm.z;
6775
-
6776
- x += nx * NORMALPUSH;
6777
- y += ny * NORMALPUSH;
6778
- z += nz * NORMALPUSH;
6779
-
6780
- gl.glNormal3f(nx, ny, nz);
6781
- }
6782
- //System.out.println("vertexq = " + qv.s + ", " + qv.t);
6783
- // boolean locked = false;
6784
- // float eps = 0.1f;
6785
- // boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
6786
-
6787
- // int dot = 0; //*/ (int)f.dot;
6788
-
6789
- // if ((dot&1) == 0)
6790
- // dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
6791
-
6792
- // if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
6793
- if (flipV)
6794
- gl.glTexCoord2f((float) qv.s, 1-(float) qv.t);
6795
- else
6796
- gl.glTexCoord2f((float) qv.s, (float) qv.t);
6797
- // else
6798
- // {
6799
- // locked = true;
6800
- // gl.glTexCoord2f((float) pv.s, (float) pv.t);
6801
- // }
6802
- gl.glColor4f(qv.AO, qv.AO, qv.AO, 1);
6803
- SetColor(display, qv);
6804
-
6805
- gl.glVertex3f(x, y, z);
6806
- //gl.glColor4f(r, g, b, 1);
6807
- //gl.glColor4f(qv.boundary, qv.boundary, qv.boundary, 1);
6808
- //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6809
-// Print(qv);
6810
-
6811
- // R
6812
- x = (float)rv.x;
6813
- y = (float)rv.y;
6814
- z = (float)rv.z;
6815
-
6816
- if (hasnorm)
6817
- {
6818
-// assert(rv.norm.normalized());
6819
- //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6820
- float nx = (float)rv.norm.x;
6821
- float ny = (float)rv.norm.y;
6822
- float nz = (float)rv.norm.z;
6823
-
6824
- x += nx * NORMALPUSH;
6825
- y += ny * NORMALPUSH;
6826
- z += nz * NORMALPUSH;
6827
-
6828
- gl.glNormal3f(nx, ny, nz);
6829
- }
6830
-
6831
- // if ((dot&4) == 0)
6832
- // dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
6833
-
6834
- // if (wrap || !locked && (dot&8) != 0)
6835
- if (flipV)
6836
- gl.glTexCoord2f((float) rv.s, 1-(float) rv.t);
6837
- else
6838
- gl.glTexCoord2f((float) rv.s, (float) rv.t);
6839
- // else
6840
- // gl.glTexCoord2f((float) pv.s, (float) pv.t);
6841
-
6842
- // f.dot = dot;
6843
-
6844
- gl.glColor4f(rv.AO, rv.AO, rv.AO, 1);
6845
- SetColor(display, rv);
6846
- //gl.glColor4f(r, g, b, 1);
6847
- //gl.glColor4f(rv.boundary, rv.boundary, rv.boundary, 1);
6848
- //System.out.println("vertexr = " + rv.x + ", " + rv.y + ", " + rv.z);
6849
- gl.glVertex3f(x, y, z);
6850
-// Print(rv);
6851
- //gl.glEnd();
6852
- }
6853
- else
6854
- {
6855
- gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
6856
- gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
6857
- gl.glVertex3f((float) rv.x, (float) rv.y, (float) rv.z);
6858
-
6859
- }
6860
-
6861
- if (false) // (attributes & WIREFRAME) != 0)
6862
- {
6863
- gl.glDisable(gl.GL_LIGHTING);
6864
-
6865
- gl.glBegin(gl.GL_LINE_LOOP);
6866
- gl.glVertex3d(pv./*pos.*/x, pv./*pos.*/y, pv./*pos.*/z);
6867
- gl.glVertex3d(qv./*pos.*/x, qv./*pos.*/y, qv./*pos.*/z);
6868
- gl.glVertex3d(rv./*pos.*/x, rv./*pos.*/y, rv./*pos.*/z);
6869
- gl.glEnd();
6870
-
6871
- gl.glEnable(gl.GL_LIGHTING);
6872
- }
6873
- }
6874
-
68756791 void drawSelf(ClickInfo info, int level, boolean select)
68766792 {
68776793 if (bRep == null)
....@@ -7395,20 +7311,23 @@
73957311 }
73967312 }
73977313
7398
- protected void calcHotSpot(cVector in, ClickInfo info, Point outPt, Rectangle outRec)
7314
+ static ClickInfo clickInfo = new ClickInfo();
7315
+
7316
+ protected void calcHotSpot(cVector in, //ClickInfo clickInfo,
7317
+ Point outPt, Rectangle outRec)
73997318 {
7400
- int hc = info.bounds.x + info.bounds.width / 2;
7401
- int vc = info.bounds.y + info.bounds.height / 2;
7402
- double[][] toscreen = info.toScreen;
7319
+ int hc = clickInfo.bounds.x + clickInfo.bounds.width / 2;
7320
+ int vc = clickInfo.bounds.y + clickInfo.bounds.height / 2;
7321
+ double[][] toscreen = clickInfo.toScreen;
74037322 if (toscreen == null)
74047323 {
7405
- toscreen = new Camera(info.camera.viewCode).toScreen;
7324
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
74067325 }
74077326 cVector vec = in;
74087327 LA.xformPos(in, toscreen, in);
74097328 //System.out.println("Distance = " + info.camera.Distance());
7410
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
7411
- vec.y *= 100 * info.camera.SCALE / info.camera.Distance();
7329
+ vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
7330
+ vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
74127331 outPt.x = hc + (int) vec.x;
74137332 outPt.y = vc - (int) vec.y;
74147333 outRec.x = outPt.x - 3;
....@@ -7416,15 +7335,18 @@
74167335 outRec.width = outRec.height = 6;
74177336 }
74187337
7419
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7338
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7339
+ )
74207340 {
74217341 Point pt = new Point(0, 0);
74227342 Rectangle rec = new Rectangle();
7423
- calcHotSpot(in, info, pt, rec);
7343
+ calcHotSpot(in, //clickInfo,
7344
+ pt, rec);
74247345 return rec;
74257346 }
74267347
7427
- void drawEditHandles0(ClickInfo info, int level)
7348
+ void drawEditHandles0(//ClickInfo clickInfo,
7349
+ int level)
74287350 {
74297351 if (level == 0)
74307352 {
....@@ -7433,98 +7355,103 @@
74337355 {
74347356 cVector origin = new cVector();
74357357 //LA.xformPos(origin, toParent, origin);
7436
- Rectangle spot = calcHotSpot(origin, info);
7358
+ if (this.clickInfo == null)
7359
+ this.clickInfo = new ClickInfo();
7360
+
7361
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
74377362 Rectangle boundary = new Rectangle();
74387363 boundary.x = spot.x - 30;
74397364 boundary.y = spot.y - 30;
74407365 boundary.width = spot.width + 60;
74417366 boundary.height = spot.height + 60;
7442
- info.g.setColor(Color.red);
7367
+ clickInfo.g.setColor(Color.red);
74437368 int spotw = spot.x + spot.width;
74447369 int spoth = spot.y + spot.height;
7445
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7446
- if (CameraPane.Xmin > spot.x)
7447
- {
7448
- CameraPane.Xmin = spot.x;
7449
- }
7450
- if (CameraPane.Xmax < spotw)
7451
- {
7452
- CameraPane.Xmax = spotw;
7453
- }
7454
- if (CameraPane.Ymin > spot.y)
7455
- {
7456
- CameraPane.Ymin = spot.y;
7457
- }
7458
- if (CameraPane.Ymax < spoth)
7459
- {
7460
- CameraPane.Ymax = spoth;
7461
- }
7370
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7371
+// if (CameraPane.Xmin > spot.x)
7372
+// {
7373
+// CameraPane.Xmin = spot.x;
7374
+// }
7375
+// if (CameraPane.Xmax < spotw)
7376
+// {
7377
+// CameraPane.Xmax = spotw;
7378
+// }
7379
+// if (CameraPane.Ymin > spot.y)
7380
+// {
7381
+// CameraPane.Ymin = spot.y;
7382
+// }
7383
+// if (CameraPane.Ymax < spoth)
7384
+// {
7385
+// CameraPane.Ymax = spoth;
7386
+// }
74627387 spot.translate(32, 32);
74637388 spotw = spot.x + spot.width;
74647389 spoth = spot.y + spot.height;
7465
- info.g.setColor(Color.blue);
7466
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7467
- if (CameraPane.Xmin > spot.x)
7468
- {
7469
- CameraPane.Xmin = spot.x;
7470
- }
7471
- if (CameraPane.Xmax < spotw)
7472
- {
7473
- CameraPane.Xmax = spotw;
7474
- }
7475
- if (CameraPane.Ymin > spot.y)
7476
- {
7477
- CameraPane.Ymin = spot.y;
7478
- }
7479
- if (CameraPane.Ymax < spoth)
7480
- {
7481
- CameraPane.Ymax = spoth;
7482
- }
7483
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7484
- info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7390
+ clickInfo.g.setColor(Color.cyan);
7391
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7392
+// if (CameraPane.Xmin > spot.x)
7393
+// {
7394
+// CameraPane.Xmin = spot.x;
7395
+// }
7396
+// if (CameraPane.Xmax < spotw)
7397
+// {
7398
+// CameraPane.Xmax = spotw;
7399
+// }
7400
+// if (CameraPane.Ymin > spot.y)
7401
+// {
7402
+// CameraPane.Ymin = spot.y;
7403
+// }
7404
+// if (CameraPane.Ymax < spoth)
7405
+// {
7406
+// CameraPane.Ymax = spoth;
7407
+// }
7408
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7409
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
74857410 spot.translate(0, -32);
7486
- info.g.setColor(Color.green);
7487
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7488
- if (CameraPane.Xmin > spot.x)
7489
- {
7490
- CameraPane.Xmin = spot.x;
7491
- }
7492
- if (CameraPane.Xmax < spotw)
7493
- {
7494
- CameraPane.Xmax = spotw;
7495
- }
7496
- if (CameraPane.Ymin > spot.y)
7497
- {
7498
- CameraPane.Ymin = spot.y;
7499
- }
7500
- if (CameraPane.Ymax < spoth)
7501
- {
7502
- CameraPane.Ymax = spoth;
7503
- }
7504
- info.g.drawArc(boundary.x, boundary.y,
7505
- boundary.width, boundary.height, 0, 360);
7411
+ clickInfo.g.setColor(Color.yellow);
7412
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7413
+ clickInfo.g.setColor(Color.green);
7414
+// if (CameraPane.Xmin > spot.x)
7415
+// {
7416
+// CameraPane.Xmin = spot.x;
7417
+// }
7418
+// if (CameraPane.Xmax < spotw)
7419
+// {
7420
+// CameraPane.Xmax = spotw;
7421
+// }
7422
+// if (CameraPane.Ymin > spot.y)
7423
+// {
7424
+// CameraPane.Ymin = spot.y;
7425
+// }
7426
+// if (CameraPane.Ymax < spoth)
7427
+// {
7428
+// CameraPane.Ymax = spoth;
7429
+// }
7430
+ clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
7431
+ (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
75067432 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
7507
- if (CameraPane.Xmin > boundary.x)
7508
- {
7509
- CameraPane.Xmin = boundary.x;
7510
- }
7511
- if (CameraPane.Xmax < boundary.x + boundary.width)
7512
- {
7513
- CameraPane.Xmax = boundary.x + boundary.width;
7514
- }
7515
- if (CameraPane.Ymin > boundary.y)
7516
- {
7517
- CameraPane.Ymin = boundary.y;
7518
- }
7519
- if (CameraPane.Ymax < boundary.y + boundary.height)
7520
- {
7521
- CameraPane.Ymax = boundary.y + boundary.height;
7522
- }
7433
+// if (CameraPane.Xmin > boundary.x)
7434
+// {
7435
+// CameraPane.Xmin = boundary.x;
7436
+// }
7437
+// if (CameraPane.Xmax < boundary.x + boundary.width)
7438
+// {
7439
+// CameraPane.Xmax = boundary.x + boundary.width;
7440
+// }
7441
+// if (CameraPane.Ymin > boundary.y)
7442
+// {
7443
+// CameraPane.Ymin = boundary.y;
7444
+// }
7445
+// if (CameraPane.Ymax < boundary.y + boundary.height)
7446
+// {
7447
+// CameraPane.Ymax = boundary.y + boundary.height;
7448
+// }
75237449 return;
75247450 }
75257451 }
75267452
7527
- boolean doEditClick0(ClickInfo info, int level)
7453
+ boolean doEditClick0(//ClickInfo clickInfo,
7454
+ int level)
75287455 {
75297456 if (level == 0)
75307457 {
....@@ -7533,10 +7460,10 @@
75337460
75347461 boolean retval = false;
75357462
7536
- startX = info.x;
7537
- startY = info.y;
7463
+ startX = clickInfo.x;
7464
+ startY = clickInfo.y;
75387465
7539
- hitSomething = 0;
7466
+ hitSomething = -1;
75407467 cVector origin = new cVector();
75417468 //LA.xformPos(origin, toParent, origin);
75427469 Rectangle spot = new Rectangle();
....@@ -7544,22 +7471,51 @@
75447471 {
75457472 centerPt = new Point(0, 0);
75467473 }
7547
- calcHotSpot(origin, info, centerPt, spot);
7548
- if (spot.contains(info.x, info.y))
7474
+ calcHotSpot(origin, //info,
7475
+ centerPt, spot);
7476
+ if (spot.contains(clickInfo.x, clickInfo.y))
75497477 {
75507478 hitSomething = hitCenter;
75517479 retval = true;
75527480 }
75537481 spot.translate(32, 0);
7554
- if (spot.contains(info.x, info.y))
7482
+ if (spot.contains(clickInfo.x, clickInfo.y))
75557483 {
75567484 hitSomething = hitRotate;
75577485 retval = true;
75587486 }
75597487 spot.translate(0, 32);
7560
- if (spot.contains(info.x, info.y))
7488
+ if (spot.contains(clickInfo.x, clickInfo.y))
75617489 {
75627490 hitSomething = hitScale;
7491
+
7492
+ double scale = 0.005f * clickInfo.camera.Distance();
7493
+ double hScale = (double) (clickInfo.x /*- centerPt.x*/) / 32;
7494
+ double sign = 1;
7495
+ if (hScale < 0)
7496
+ {
7497
+ sign = -1;
7498
+ }
7499
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
7500
+ if (hScale < 0.01)
7501
+ {
7502
+ //hScale = 0.01;
7503
+ }
7504
+
7505
+ double vScale = (double) (clickInfo.y /*- centerPt.y*/) / 32;
7506
+ sign = 1;
7507
+ if (vScale < 0)
7508
+ {
7509
+ sign = -1;
7510
+ }
7511
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
7512
+ if (vScale < 0.01)
7513
+ {
7514
+ //vScale = 0.01;
7515
+ }
7516
+
7517
+ clickInfo.scale = Math.sqrt(hScale*hScale + vScale*vScale);
7518
+
75637519 retval = true;
75647520 }
75657521
....@@ -7569,7 +7525,7 @@
75697525 }
75707526
75717527 //System.out.println("info.modifiers = " + info.modifiers);
7572
- modified = (info.modifiers & CameraPane.META) != 0;
7528
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
75737529 //System.out.println("modified = " + modified);
75747530 //new Exception().printStackTrace();
75757531 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7597,7 +7553,8 @@
75977553 return true;
75987554 }
75997555
7600
- void doEditDrag0(ClickInfo info)
7556
+ void doEditDrag0(//ClickInfo info,
7557
+ boolean opposite)
76017558 {
76027559 if (hitSomething == 0)
76037560 {
....@@ -7611,7 +7568,8 @@
76117568
76127569 //System.out.println("hitSomething = " + hitSomething);
76137570
7614
- double scale = 0.005f * info.camera.Distance();
7571
+ double scale = 0.005f * clickInfo.camera.Distance();
7572
+
76157573 cVector xlate = new cVector();
76167574 //cVector xlate2 = new cVector();
76177575 switch (hitSomething)
....@@ -7622,9 +7580,9 @@
76227580
76237581 case hitCenter: // Translate
76247582
7625
- scale *= 0.05f * info.pane.theRenderer.renderCamera.Distance();
7583
+ scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
76267584
7627
- if (modified)
7585
+ if (modified || opposite)
76287586 {
76297587 //assert(false);
76307588 /*
....@@ -7644,8 +7602,8 @@
76447602 toParent[3][i] = xlate.get(i);
76457603 LA.matInvert(toParent, fromParent);
76467604 */
7647
- cVector delta = LA.newVector(0, 0, startY - info.y);
7648
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7605
+ cVector delta = LA.newVector(0, 0, startY - clickInfo.y);
7606
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
76497607
76507608 LA.matCopy(startMat, toParent);
76517609 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7654,7 +7612,7 @@
76547612 } else
76557613 {
76567614 //LA.xformDir(delta, info.camera.fromScreen, delta);
7657
- cVector up = new cVector(info.camera.up);
7615
+ cVector up = new cVector(clickInfo.camera.up);
76587616 cVector away = new cVector();
76597617 //cVector right2 = new cVector();
76607618 //LA.vecCross(up, cVector.Z, right);
....@@ -7670,20 +7628,20 @@
76707628 }
76717629 LA.xformDir(up, ClickInfo.matbuffer, up);
76727630 // if (!CameraPane.LOCALTRANSFORM)
7673
- LA.xformDir(up, info.pane.theRenderer.renderCamera.toScreen, up);
7674
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7631
+ LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7632
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
76757633 // if (!CameraPane.LOCALTRANSFORM)
7676
- LA.xformDir(away, info.pane.theRenderer.renderCamera.toScreen, away);
7634
+ LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
76777635 //LA.vecCross(up, cVector.Z, right2);
76787636
7679
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7637
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
76807638
76817639 //System.out.println("DELTA0 = " + delta);
76827640 //System.out.println("AWAY = " + info.camera.away);
76837641 //System.out.println("UP = " + info.camera.up);
76847642 if (away.z > 0)
76857643 {
7686
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7644
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
76877645 {
76887646 delta.x = -delta.x;
76897647 } else
....@@ -7698,7 +7656,7 @@
76987656 //System.out.println("DELTA1 = " + delta);
76997657 LA.xformDir(delta, ClickInfo.matbuffer, delta);
77007658 //System.out.println("DELTA2 = " + delta);
7701
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7659
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
77027660 LA.matCopy(startMat, toParent);
77037661 //System.out.println("DELTA3 = " + delta);
77047662 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7708,8 +7666,8 @@
77087666 break;
77097667
77107668 case hitRotate: // rotate
7711
- int dx = info.x - centerPt.x;
7712
- int dy = -(info.y - centerPt.y);
7669
+ int dx = clickInfo.x - centerPt.x;
7670
+ int dy = -(clickInfo.y - centerPt.y);
77137671 double angle = (double) Math.atan2(dx, dy);
77147672 angle = -(1.570796 - angle);
77157673
....@@ -7718,6 +7676,7 @@
77187676
77197677 if (modified)
77207678 {
7679
+ // Rotate 90 degrees
77217680 angle /= (Math.PI / 4);
77227681 angle = Math.floor(angle + 0.5);
77237682 angle *= (Math.PI / 4);
....@@ -7731,7 +7690,7 @@
77317690 }
77327691 /**/
77337692
7734
- switch (info.pane.renderCamera.viewCode)
7693
+ switch (clickInfo.pane.RenderCamera().viewCode)
77357694 {
77367695 case 1: // '\001'
77377696 LA.matZRotate(toParent, angle);
....@@ -7758,26 +7717,30 @@
77587717 break;
77597718
77607719 case hitScale: // scale
7761
- double hScale = (double) (info.x - centerPt.x) / 32;
7720
+ double hScale = (double) (clickInfo.x /*- centerPt.x*/) / 32;
7721
+ double sign = 1;
7722
+ if (hScale < 0)
7723
+ {
7724
+ sign = -1;
7725
+ }
7726
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
77627727 if (hScale < 0.01)
77637728 {
7764
- hScale = 0.01;
7729
+ //hScale = 0.01;
77657730 }
7766
- hScale = Math.pow(hScale, scale * 50);
7767
- if (hScale < 0.01)
7731
+
7732
+ double vScale = (double) (clickInfo.y /*- centerPt.y*/) / 32;
7733
+ sign = 1;
7734
+ if (vScale < 0)
77687735 {
7769
- hScale = 0.01;
7736
+ sign = -1;
77707737 }
7771
- double vScale = (double) (info.y - centerPt.y) / 32;
7738
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
77727739 if (vScale < 0.01)
77737740 {
7774
- vScale = 0.01;
7741
+ //vScale = 0.01;
77757742 }
7776
- vScale = Math.pow(vScale, scale * 50);
7777
- if (vScale < 0.01)
7778
- {
7779
- vScale = 0.01;
7780
- }
7743
+
77817744 LA.matCopy(startMat, toParent);
77827745 /**/
77837746 for (int i = 0; i < 3; i++)
....@@ -7787,39 +7750,47 @@
77877750 }
77887751 /**/
77897752
7790
- switch (info.pane.renderCamera.viewCode)
7753
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
7754
+
7755
+ if (totalScale < 0.01)
7756
+ {
7757
+ totalScale = 0.01;
7758
+ }
7759
+
7760
+ switch (clickInfo.pane.RenderCamera().viewCode)
77917761 {
77927762 case 3: // '\001'
7793
- if (modified)
7763
+ if (modified || opposite)
77947764 {
77957765 //LA.matScale(toParent, 1, hScale, vScale);
7796
- LA.matScale(toParent, vScale, 1, 1);
7766
+ LA.matScale(toParent, totalScale, 1, 1);
77977767 } // vScale, 1);
77987768 else
77997769 {
7800
- LA.matScale(toParent, vScale, vScale, vScale);
7770
+ // EXCEPTION!
7771
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
78017772 } // vScale, 1);
78027773 break;
78037774
78047775 case 2: // '\002'
7805
- if (modified)
7776
+ if (modified || opposite)
78067777 {
78077778 //LA.matScale(toParent, hScale, 1, vScale);
7808
- LA.matScale(toParent, 1, vScale, 1);
7779
+ LA.matScale(toParent, 1, totalScale, 1);
78097780 } else
78107781 {
7811
- LA.matScale(toParent, vScale, 1, vScale);
7782
+ LA.matScale(toParent, totalScale, 1, totalScale);
78127783 }
78137784 break;
78147785
78157786 case 1: // '\003'
7816
- if (modified)
7787
+ if (modified || opposite)
78177788 {
78187789 //LA.matScale(toParent, hScale, vScale, 1);
7819
- LA.matScale(toParent, 1, 1, vScale);
7790
+ LA.matScale(toParent, 1, 1, totalScale);
78207791 } else
78217792 {
7822
- LA.matScale(toParent, vScale, vScale, 1);
7793
+ LA.matScale(toParent, totalScale, totalScale, 1);
78237794 }
78247795 break;
78257796 }
....@@ -7853,7 +7824,7 @@
78537824 } // NEW ...
78547825
78557826
7856
- info.pane.repaint();
7827
+ clickInfo.pane.repaint();
78577828 }
78587829
78597830 boolean overflow = false;
....@@ -7952,14 +7923,22 @@
79527923 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
79537924 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
79547925 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7926
+
7927
+ String objname;
7928
+
79557929 if (false) //parent != null)
79567930 {
7957
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7931
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
79587932 } else
79597933 {
7960
- return GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ") ")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ +System.identityHashCode(this);
7934
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
79617935 } // + super.toString();
79627936 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
7937
+
7938
+ if (!Globals.ADVANCED)
7939
+ return objname;
7940
+
7941
+ return objname + " " + System.identityHashCode(this);
79637942 }
79647943
79657944 public int hashCode()
....@@ -8015,6 +7994,7 @@
80157994 objectUI.closeUI();
80167995 if (editWindow != null)
80177996 {
7997
+ editWindow.ctrlPanel.FlushUI();
80187998 editWindow.refreshContents();
80197999 } // ? new
80208000 objectUI = null;
....@@ -8023,6 +8003,10 @@
80238003 {
80248004 editWindow = null;
80258005 } // ?
8006
+ }
8007
+ else
8008
+ {
8009
+ //editWindow.closeUI();
80268010 }
80278011 }
80288012
....@@ -8035,7 +8019,7 @@
80358019 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
80368020
80378021 Object3D /*Composite*/ parent;
8038
- Object3D /*Composite*/ fileparent;
8022
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
80398023
80408024 double[][] toParent; // dynamic matrix
80418025 double[][] fromParent;
....@@ -8150,7 +8134,7 @@
81508134 {
81518135 assert(bRep != null);
81528136 if (!(support instanceof GenericJoint)) // support.bRep != null)
8153
- GrafreeD.Assert(support.bRep == bRep.support);
8137
+ Grafreed.Assert(support.bRep == bRep.support);
81548138 }
81558139 else
81568140 {
....@@ -8181,6 +8165,10 @@
81818165 }
81828166
81838167 transient ObjEditor editWindow;
8168
+ transient ObjEditor manipWindow;
8169
+
8170
+ transient boolean pinned;
8171
+
81848172 transient ObjectUI objectUI;
81858173 public static int povDepth = 0;
81868174 private static cVector tbMin = new cVector();
....@@ -8199,9 +8187,9 @@
81998187 private static cVector edge2 = new cVector();
82008188 //private static cVector norm = new cVector();
82018189 /*transient private*/ int hitSomething;
8202
- private static final int hitCenter = 1;
8203
- private static final int hitScale = 2;
8204
- private static final int hitRotate = 3;
8190
+ static final int hitCenter = 1;
8191
+ static final int hitScale = 2;
8192
+ static final int hitRotate = 3;
82058193 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
82068194 /*transient*/ private Point centerPt;
82078195 /*transient*/ private int startX;