Normand Briere
2019-08-17 ecc1309a04b527c62ffe97e814daf050dbd025cd
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,11 +14,29 @@
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;
24
+
25
+ // Use GetUUID for backward compatibility with null.
26
+ private UUID uuid = UUID.randomUUID();
27
+
28
+ // TEMPORARY for mocap undo. No need to be transient.
29
+ mocap.reader.BVHReader.BVHResult savebvh;
30
+ Object3D saveskeleton;
31
+ //
32
+
33
+ String skyboxname;
34
+ String skyboxext;
35
+
36
+ Object3D versionlist[];
37
+ int versionindex = -1;
38
+
39
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable; // = new java.util.Hashtable<java.util.UUID, Object3D>();
2140
2241 ScriptNode scriptnode;
2342
....@@ -99,64 +118,201 @@
99118
100119 // transient boolean reduced; // for morph reduction
101120
102
-transient com.bulletphysics.linearmath.Transform cache; // for fast merge
103
-transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
121
+ transient com.bulletphysics.linearmath.Transform cache; // for fast merge
122
+ transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
104123
105
-transient Object3D transientsupport; // for cloning
106
-transient boolean transientlink2master;
124
+ transient Object3D transientsupport; // for cloning
125
+ transient boolean transientlink2master;
107126
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)
127
+ void SaveSupports()
120128 {
121
- bRep.SaveSupports();
129
+ if (blockloop)
130
+ return;
131
+
132
+ transientsupport = support;
133
+ transientlink2master = link2master;
134
+
135
+ support = null;
136
+ link2master = false;
137
+
138
+ if (bRep != null)
139
+ {
140
+ bRep.SaveSupports();
141
+ }
142
+
143
+ for (int i = 0; i < Size(); i++)
144
+ {
145
+ Object3D child = (Object3D) get(i);
146
+ if (child == null)
147
+ continue;
148
+ blockloop = true;
149
+ child.SaveSupports();
150
+ blockloop = false;
151
+ }
122152 }
123
-
124
- for (int i = 0; i < Size(); i++)
153
+
154
+ void RestoreSupports()
125155 {
126
- Object3D child = (Object3D) get(i);
127
- if (child == null)
128
- continue;
156
+ if (blockloop)
157
+ return;
158
+
159
+ support = transientsupport;
160
+ link2master = transientlink2master;
161
+ transientsupport = null;
162
+ transientlink2master = false;
163
+
164
+ if (bRep != null)
165
+ {
166
+ bRep.RestoreSupports();
167
+ }
168
+
169
+ for (int i = 0; i < Size(); i++)
170
+ {
171
+ Object3D child = (Object3D) get(i);
172
+ if (child == null)
173
+ continue;
174
+ blockloop = true;
175
+ child.RestoreSupports();
176
+ blockloop = false;
177
+ }
178
+ }
179
+
180
+ void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
181
+ {
182
+ Object3D o;
183
+
184
+ if (hashtable.containsKey(GetUUID()))
185
+ {
186
+ o = hashtable.get(GetUUID());
187
+
188
+ Grafreed.Assert(this.bRep == o.bRep);
189
+ //if (this.bRep != null)
190
+ // assert(this.bRep.support == o.transientrep);
191
+ if (this.support != null)
192
+ assert(this.support.bRep == o.transientrep);
193
+ }
194
+ else
195
+ {
196
+ o = new Object3D("copy of " + this.name);
197
+
198
+ hashtable.put(GetUUID(), o);
199
+ }
200
+
201
+ if (!blockloop)
202
+ {
203
+ blockloop = true;
204
+
205
+ for (int i=0; i<Size(); i++)
206
+ {
207
+ get(i).ExtractBigData(hashtable);
208
+ }
209
+
210
+ blockloop = false;
211
+ }
212
+
213
+ ExtractBigData(o);
214
+ }
215
+
216
+ void ExtractBigData(Object3D o)
217
+ {
218
+ if (o.bRep != null)
219
+ Grafreed.Assert(o.bRep == this.bRep);
220
+
221
+ o.bRep = this.bRep;
222
+// July 2019 if (this.bRep != null)
223
+// {
224
+// o.transientrep = this.bRep.support;
225
+// o.bRep.support = null;
226
+// }
227
+ o.selection = this.selection;
228
+ o.versionlist = this.versionlist;
229
+ o.versionindex = this.versionindex;
230
+
231
+ if (this.support != null)
232
+ {
233
+ if (o.transientrep != null)
234
+ Grafreed.Assert(o.transientrep == this.support.bRep);
235
+
236
+ o.transientrep = this.support.bRep;
237
+ this.support.bRep = null;
238
+ }
239
+
240
+ // o.support = this.support;
241
+ // o.fileparent = this.fileparent;
242
+ // if (this.bRep != null)
243
+ // o.bRep = this.bRep.support;
244
+
245
+ this.bRep = null;
246
+ // if (this.bRep != null)
247
+ // this.bRep.support = null;
248
+ // this.support = null;
249
+ // this.fileparent = null;
250
+ }
251
+
252
+// Object3D GetObject(java.util.UUID uuid)
253
+// {
254
+// if (this.uuid.equals(uuid))
255
+// return this;
256
+//
257
+// if (blockloop)
258
+// return null;
259
+//
260
+// blockloop = true;
261
+//
262
+// for (int i=0; i<Size(); i++)
263
+// {
264
+// Object3D o = get(i).GetObject(uuid);
265
+//
266
+// if (o != null)
267
+// return o;
268
+// }
269
+//
270
+// blockloop = false;
271
+//
272
+// return null;
273
+// }
274
+
275
+ void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
276
+ {
277
+ if (!hashtable.containsKey(GetUUID()))
278
+ return;
279
+
280
+ Object3D o = hashtable.get(GetUUID());
281
+
282
+ RestoreBigData(o);
283
+
284
+ if (blockloop)
285
+ return;
286
+
129287 blockloop = true;
130
- child.SaveSupports();
288
+
289
+ //hashtable.remove(GetUUID());
290
+
291
+ for (int i=0; i<Size(); i++)
292
+ {
293
+ get(i).RestoreBigData(hashtable);
294
+ }
295
+
131296 blockloop = false;
132297 }
133
-}
134298
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)
299
+ void RestoreBigData(Object3D o)
146300 {
147
- bRep.RestoreSupports();
301
+ this.bRep = o.bRep;
302
+ if (this.support != null && o.transientrep != null)
303
+ {
304
+ this.support.bRep = o.transientrep;
305
+ }
306
+
307
+ this.selection = o.selection;
308
+
309
+ this.versionlist = o.versionlist;
310
+ this.versionindex = o.versionindex;
311
+// July 2019 if (this.bRep != null)
312
+// this.bRep.support = o.transientrep;
313
+ // this.support = o.support;
314
+ // this.fileparent = o.fileparent;
148315 }
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
-}
160316
161317 // MOCAP SUPPORT
162318 double tx,ty,tz,rx,ry,rz;
....@@ -299,6 +455,8 @@
299455 }
300456
301457 boolean live = false;
458
+ transient boolean keepdontselect;
459
+ boolean dontselect = false;
302460 boolean hide = false;
303461 boolean link2master = false; // performs reset support/master at each frame
304462 boolean marked = false; // animation node
....@@ -430,16 +588,16 @@
430588 {
431589 Object3D copy = this;
432590
433
- Camera parentcam = CameraPane.theRenderer.ManipCamera();
591
+ Camera parentcam = Globals.theRenderer.ManipCamera();
434592
435
- if (CameraPane.theRenderer.ManipCamera() == CameraPane.theRenderer.Cameras()[0])
593
+ if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[0])
436594 {
437
- parentcam = CameraPane.theRenderer.Cameras()[1];
595
+ parentcam = Globals.theRenderer.Cameras()[1];
438596 }
439597
440
- if (CameraPane.theRenderer.ManipCamera() == CameraPane.theRenderer.Cameras()[1])
598
+ if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[1])
441599 {
442
- parentcam = CameraPane.theRenderer.Cameras()[0];
600
+ parentcam = Globals.theRenderer.Cameras()[0];
443601 }
444602
445603 if (this == parentcam)
....@@ -447,7 +605,7 @@
447605 //assert(this instanceof Camera);
448606
449607 for (int count = parentcam.GetTransformCount(); --count>=0;)
450
- LA.xformPos(CameraPane.theRenderer.TargetLookAt(), parentcam.toParent, CameraPane.theRenderer.TargetLookAt());
608
+ LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.toParent, Globals.theRenderer.TargetLookAt());
451609 }
452610
453611 copy.marked ^= true;
....@@ -467,7 +625,7 @@
467625 //assert(this instanceof Camera);
468626
469627 for (int count = parentcam.GetTransformCount(); --count>=0;)
470
- LA.xformPos(CameraPane.theRenderer.TargetLookAt(), parentcam.fromParent, CameraPane.theRenderer.TargetLookAt());
628
+ LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.fromParent, Globals.theRenderer.TargetLookAt());
471629 }
472630
473631 copy.Touch(); // display list issue
....@@ -480,12 +638,14 @@
480638 toParent = LA.newMatrix();
481639 fromParent = LA.newMatrix();
482640 }
641
+
483642 if (toParentMarked == null)
484643 {
485644 if (maxcount != 1)
486645 {
487646 new Exception().printStackTrace();
488647 }
648
+
489649 toParentMarked = LA.newMatrix();
490650 fromParentMarked = LA.newMatrix();
491651 }
....@@ -773,7 +933,7 @@
773933 if (step == 0)
774934 step = 1;
775935 if (maxcount == 0)
776
- maxcount = 2048; // 4;
936
+ maxcount = 128; // 2048; // 4;
777937 // if (acceleration == 0)
778938 // acceleration = 10;
779939 if (delay == 0) // serial
....@@ -796,7 +956,7 @@
796956
797957 if (marked && Globals.isLIVE() && live &&
798958 //TEMP21aug2018
799
- Globals.DrawMode() == iCameraPane.SHADOW &&
959
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
800960 currentframe != Globals.framecount)
801961 {
802962 currentframe = Globals.framecount;
....@@ -808,7 +968,8 @@
808968
809969 boolean changedir = random && Math.random() < 0.01; // && !link2master;
810970
811
- if (transformcount*factor > maxcount || (step == 1 && changedir))
971
+ if (transformcount*factor >= maxcount && (rewind || random) ||
972
+ (step == 1 && changedir))
812973 {
813974 countdown = 1;
814975 delay = speedup?8:1;
....@@ -880,6 +1041,10 @@
8801041 if (material == null || material.multiply)
8811042 return true;
8821043
1044
+ if (projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
1045
+ return false;
1046
+
1047
+ // Transparent objects are dynamic because we have to sort the triangles.
8831048 return material.opacity > 0.99;
8841049 }
8851050
....@@ -911,6 +1076,11 @@
9111076 fromParent = null; // LA.newMatrix();
9121077 bRep = null; // new BoundaryRep();
9131078
1079
+ if (oname != null && oname.equals("LeftHand"))
1080
+ {
1081
+ name = oname;
1082
+ }
1083
+
9141084 /*
9151085 float hue = (float)Math.random();
9161086 Color col;
....@@ -953,7 +1123,7 @@
9531123
9541124 public Object clone()
9551125 {
956
- return GrafreeD.clone(this);
1126
+ return Grafreed.clone(this);
9571127 }
9581128
9591129 Object3D copyExpand()
....@@ -1275,6 +1445,7 @@
12751445 toParent = LA.newMatrix();
12761446 fromParent = LA.newMatrix();
12771447 }
1448
+
12781449 LA.matCopy(other.toParent, toParent);
12791450 LA.matCopy(other.fromParent, fromParent);
12801451
....@@ -1469,7 +1640,7 @@
14691640 BoundaryRep.SEUIL = other.material.cameralight;
14701641
14711642 // Set default to 0.1
1472
- BoundaryRep.SEUIL /= 2;
1643
+ BoundaryRep.SEUIL /= 4; // 2;
14731644 System.out.println("SEUIL = " + BoundaryRep.SEUIL);
14741645 }
14751646
....@@ -1728,7 +1899,7 @@
17281899 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17291900 o.bRep = transientrep;
17301901 if (clone)
1731
- o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
1902
+ o.bRep = (BoundaryRep) Grafreed.clone(transientrep);
17321903 o.CreateMaterial();
17331904 o.SetAttributes(this, -1);
17341905 //parent
....@@ -1741,7 +1912,7 @@
17411912 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17421913 o.bRep = bRep;
17431914 if (clone)
1744
- o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
1915
+ o.bRep = (BoundaryRep) Grafreed.clone(bRep);
17451916 o.CreateMaterial();
17461917 //o.overwriteThis(this, -1);
17471918 o.SetAttributes(this, -1);
....@@ -1828,12 +1999,15 @@
18281999 if (obj.name == null)
18292000 continue; // can't be a null one
18302001
2002
+ // Try perfect match first.
18312003 if (n.equals(obj.name))
18322004 {
18332005 theobj = obj;
18342006 count++;
18352007 }
18362008 }
2009
+
2010
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18372011
18382012 if (count != 1)
18392013 for (int i=Size(); --i>=0;)
....@@ -2293,12 +2467,22 @@
22932467 }
22942468 */
22952469 }
2470
+ else
2471
+ {
2472
+ //((ObjEditor)editWindow).SetupUI2(null);
2473
+ if (objectUI != null)
2474
+ ((ObjEditor)objectUI).pinButton.setSelected(pinned);
2475
+ else
2476
+ //new Exception().printStackTrace();
2477
+ System.err.println("objectUI is null");
2478
+ }
22962479 }
22972480
22982481 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
22992482 {
23002483 if (newWindow)
23012484 {
2485
+ new Exception().printStackTrace();
23022486 System.exit(0);
23032487 if (parent != null)
23042488 {
....@@ -2333,6 +2517,14 @@
23332517 {
23342518 editWindow.refreshContents();
23352519 }
2520
+ else
2521
+ {
2522
+ if (manipWindow != null)
2523
+ {
2524
+ manipWindow.refreshContents();
2525
+ }
2526
+ }
2527
+
23362528 //if (parent != null)
23372529 //parent.refreshEditWindow();
23382530 }
....@@ -2412,7 +2604,8 @@
24122604 private static final int editSelf = 1;
24132605 private static final int editChild = 2;
24142606
2415
- void drawEditHandles(ClickInfo info, int level)
2607
+ void drawEditHandles(//ClickInfo info,
2608
+ int level)
24162609 {
24172610 if (level == 0)
24182611 {
....@@ -2420,7 +2613,8 @@
24202613 return;
24212614
24222615 Object3D selectee;
2423
- for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(info, level + 1))
2616
+ for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(//info,
2617
+ level + 1))
24242618 {
24252619 selectee = (Object3D) e.nextElement();
24262620 }
....@@ -2428,19 +2622,22 @@
24282622 } else
24292623 {
24302624 //super.
2431
- drawEditHandles0(info, level + 1);
2625
+ drawEditHandles0(//info,
2626
+ level + 1);
24322627 }
24332628 }
24342629
2435
- boolean doEditClick(ClickInfo info, int level)
2630
+ boolean doEditClick(//ClickInfo info,
2631
+ int level)
24362632 {
24372633 doSomething = 0;
24382634 if (level == 0)
24392635 {
2440
- return doParentClick(info);
2636
+ return doParentClick(); //info);
24412637 }
24422638 if (//super.
2443
- doEditClick0(info, level))
2639
+ doEditClick0(//info,
2640
+ level))
24442641 {
24452642 doSomething = 1;
24462643 return true;
....@@ -2450,7 +2647,7 @@
24502647 }
24512648 }
24522649
2453
- boolean doParentClick(ClickInfo info)
2650
+ boolean doParentClick() //ClickInfo info)
24542651 {
24552652 if (selection == null)
24562653 {
....@@ -2463,7 +2660,8 @@
24632660 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
24642661 {
24652662 Object3D selectee = (Object3D) e.nextElement();
2466
- if (selectee.doEditClick(info, 1))
2663
+ if (selectee.doEditClick(//info,
2664
+ 1))
24672665 {
24682666 childToDrag = selectee;
24692667 doSomething = 2;
....@@ -2475,13 +2673,15 @@
24752673 return retval;
24762674 }
24772675
2478
- void doEditDrag(ClickInfo info)
2676
+ void doEditDrag(//ClickInfo clickInfo,
2677
+ boolean opposite)
24792678 {
24802679 switch (doSomething)
24812680 {
24822681 case 1: // '\001'
24832682 //super.
2484
- doEditDrag0(info);
2683
+ doEditDrag0(//clickInfo,
2684
+ opposite);
24852685 break;
24862686
24872687 case 2: // '\002'
....@@ -2494,11 +2694,13 @@
24942694 {
24952695 //sel.hitSomething = childToDrag.hitSomething;
24962696 //childToDrag.doEditDrag(info);
2497
- sel.doEditDrag(info);
2697
+ sel.doEditDrag(//clickInfo,
2698
+ opposite);
24982699 } else
24992700 {
25002701 //super.
2501
- doEditDrag0(info);
2702
+ doEditDrag0(//clickInfo,
2703
+ opposite);
25022704 }
25032705 }
25042706 break;
....@@ -2516,6 +2718,9 @@
25162718 {
25172719 deselectAll();
25182720 }
2721
+
2722
+ new Exception().printStackTrace();
2723
+
25192724 ClickInfo newInfo = new ClickInfo();
25202725 newInfo.flags = info.flags;
25212726 newInfo.bounds = info.bounds;
....@@ -2608,6 +2813,18 @@
26082813 void GenNormalsS(boolean crease)
26092814 {
26102815 selection.GenNormals(crease);
2816
+// for (int i=0; i<selection.size(); i++)
2817
+// {
2818
+// Object3D selectee = (Object3D) selection.elementAt(i);
2819
+// selectee.GenNormals(crease);
2820
+// }
2821
+
2822
+ //Touch();
2823
+ }
2824
+
2825
+ void GenNormalsMeshS()
2826
+ {
2827
+ selection.GenNormalsMesh();
26112828 // for (int i=0; i<selection.size(); i++)
26122829 // {
26132830 // Object3D selectee = (Object3D) selection.elementAt(i);
....@@ -2748,6 +2965,24 @@
27482965 if (child == null)
27492966 continue;
27502967 child.GenNormals(crease);
2968
+// Children().release(i);
2969
+ }
2970
+ blockloop = false;
2971
+ }
2972
+
2973
+ void GenNormalsMesh()
2974
+ {
2975
+ if (blockloop)
2976
+ return;
2977
+
2978
+ blockloop = true;
2979
+ GenNormalsMesh0();
2980
+ for (int i = 0; i < Children().Size(); i++)
2981
+ {
2982
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2983
+ if (child == null)
2984
+ continue;
2985
+ child.GenNormalsMesh();
27512986 // Children().release(i);
27522987 }
27532988 blockloop = false;
....@@ -2905,7 +3140,8 @@
29053140 {
29063141 if (bRep != null)
29073142 {
2908
- bRep.GenUV();
3143
+ bRep.GenUV(); //1);
3144
+ //bRep.UnfoldUV();
29093145 Touch();
29103146 }
29113147 }
....@@ -2919,11 +3155,20 @@
29193155 }
29203156 }
29213157
3158
+ void GenNormalsMesh0()
3159
+ {
3160
+ if (bRep != null)
3161
+ {
3162
+ bRep.GenerateNormalsMesh();
3163
+ Touch();
3164
+ }
3165
+ }
3166
+
29223167 void GenNormalsMINE0()
29233168 {
29243169 if (bRep != null)
29253170 {
2926
- bRep.GenerateNormalsMINE();
3171
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
29273172 Touch();
29283173 }
29293174 }
....@@ -2980,6 +3225,33 @@
29803225 blockloop = false;
29813226 }
29823227
3228
+ void TransformChildren()
3229
+ {
3230
+ if (toParent != null)
3231
+ {
3232
+ for (int i=Size(); --i>=0;)
3233
+ {
3234
+ Object3D v = get(i);
3235
+
3236
+ if (v.toParent == null)
3237
+ {
3238
+ v.toParent = LA.newMatrix();
3239
+ v.fromParent = LA.newMatrix();
3240
+ }
3241
+
3242
+// LA.matConcat(v.toParent, toParent, v.toParent);
3243
+// LA.matConcat(fromParent, v.fromParent, v.fromParent);
3244
+ LA.matConcat(toParent, v.toParent, v.toParent);
3245
+ LA.matConcat(v.fromParent, fromParent, v.fromParent);
3246
+ }
3247
+
3248
+ toParent = null; // LA.matIdentity(toParent);
3249
+ fromParent = null; // LA.matIdentity(fromParent);
3250
+
3251
+ Touch();
3252
+ }
3253
+ }
3254
+
29833255 void TransformGeometry()
29843256 {
29853257 Object3D obj = this;
....@@ -3201,9 +3473,11 @@
32013473
32023474 BoundaryRep sup = bRep.support;
32033475 bRep.support = null;
3204
- BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
3476
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
32053477 // bRep.SplitInTwo(onlyone); // thread...
3206
- temprep.SplitInTwo(reduction34, onlyone);
3478
+
3479
+ while(temprep.SplitInTwo(reduction34, onlyone));
3480
+
32073481 bRep = temprep;
32083482 bRep.support = sup;
32093483 Touch();
....@@ -3340,7 +3614,8 @@
33403614 if (blockloop)
33413615 return;
33423616
3343
- if (marked || (bRep != null && material != null)) // borderline...
3617
+ if (//marked || // does not make sense
3618
+ (bRep != null || material != null)) // borderline...
33443619 live = h;
33453620
33463621 for (int i = 0; i < Size(); i++)
....@@ -3361,7 +3636,8 @@
33613636 return;
33623637
33633638 //if (bRep != null)
3364
- if (marked || (bRep != null && material != null)) // borderline...
3639
+ if (//marked || // does not make sense
3640
+ (bRep != null || material != null)) // borderline...
33653641 link2master = h;
33663642
33673643 for (int i = 0; i < Size(); i++)
....@@ -3381,7 +3657,8 @@
33813657 if (blockloop)
33823658 return;
33833659
3384
- if (marked || (bRep != null && material != null)) // borderline...
3660
+ if (//marked || // does not make sense
3661
+ (bRep != null || material != null)) // borderline...
33853662 hide = h;
33863663
33873664 for (int i = 0; i < Size(); i++)
....@@ -3401,7 +3678,7 @@
34013678 if (blockloop)
34023679 return;
34033680
3404
- if (bRep != null && material != null) // borderline...
3681
+ if (bRep != null || material != null) // borderline...
34053682 marked = h;
34063683
34073684 for (int i = 0; i < Size(); i++)
....@@ -3411,6 +3688,46 @@
34113688 continue;
34123689 blockloop = true;
34133690 child.MarkLeaves(h);
3691
+ blockloop = false;
3692
+ // release(i);
3693
+ }
3694
+ }
3695
+
3696
+ void RewindLeaves(boolean h)
3697
+ {
3698
+ if (blockloop)
3699
+ return;
3700
+
3701
+ if (bRep != null || material != null) // borderline...
3702
+ rewind = h;
3703
+
3704
+ for (int i = 0; i < Size(); i++)
3705
+ {
3706
+ Object3D child = (Object3D) get(i); // reserve(i);
3707
+ if (child == null)
3708
+ continue;
3709
+ blockloop = true;
3710
+ child.RewindLeaves(h);
3711
+ blockloop = false;
3712
+ // release(i);
3713
+ }
3714
+ }
3715
+
3716
+ void RandomLeaves(boolean h)
3717
+ {
3718
+ if (blockloop)
3719
+ return;
3720
+
3721
+ if (bRep != null || material != null) // borderline...
3722
+ random = h;
3723
+
3724
+ for (int i = 0; i < Size(); i++)
3725
+ {
3726
+ Object3D child = (Object3D) get(i); // reserve(i);
3727
+ if (child == null)
3728
+ continue;
3729
+ blockloop = true;
3730
+ child.RandomLeaves(h);
34143731 blockloop = false;
34153732 // release(i);
34163733 }
....@@ -3725,7 +4042,7 @@
37254042 if (child == null)
37264043 continue;
37274044
3728
- if (GrafreeD.RENDERME > 0)
4045
+ if (Grafreed.RENDERME > 0)
37294046 {
37304047 if (child instanceof Merge)
37314048 ((Merge)child).renderme();
....@@ -3876,7 +4193,7 @@
38764193 if (child == null)
38774194 continue;
38784195
3879
- if (GrafreeD.RENDERME > 0)
4196
+ if (Grafreed.RENDERME > 0)
38804197 {
38814198 if (child instanceof Merge)
38824199 ((Merge)child).renderme();
....@@ -4071,7 +4388,7 @@
40714388 if (child == null)
40724389 continue;
40734390
4074
- if (GrafreeD.RENDERME > 0)
4391
+ if (Grafreed.RENDERME > 0)
40754392 {
40764393 if (child instanceof Merge)
40774394 ((Merge)child).renderme();
....@@ -4184,6 +4501,55 @@
41844501 {
41854502 blockloop = true;
41864503 get(i).RepairShadow();
4504
+ blockloop = false;
4505
+ }
4506
+ }
4507
+
4508
+ void RepairSOV()
4509
+ {
4510
+ if (blockloop)
4511
+ return;
4512
+
4513
+ String texname = this.GetPigmentTexture();
4514
+
4515
+ if (texname.startsWith("sov"))
4516
+ {
4517
+ String[] s = texname.split("/");
4518
+
4519
+ String[] sname = s[1].split("Color.pn");
4520
+
4521
+ texname = sname[0];
4522
+
4523
+ if (sname.length > 1)
4524
+ {
4525
+ texname += "Color.jpg";
4526
+ }
4527
+
4528
+ this.SetPigmentTexture("sov/" + texname);
4529
+ }
4530
+
4531
+ texname = this.GetBumpTexture();
4532
+
4533
+ if (texname.startsWith("sov"))
4534
+ {
4535
+ String[] s = texname.split("/");
4536
+
4537
+ String[] sname = s[1].split("Bump.pn");
4538
+
4539
+ texname = sname[0];
4540
+
4541
+ if (sname.length > 1)
4542
+ {
4543
+ texname += "Bump.jpg";
4544
+ }
4545
+
4546
+ this.SetBumpTexture("sov/" + texname);
4547
+ }
4548
+
4549
+ for (int i=0; i<Size(); i++)
4550
+ {
4551
+ blockloop = true;
4552
+ get(i).RepairSOV();
41874553 blockloop = false;
41884554 }
41894555 }
....@@ -4678,7 +5044,7 @@
46785044
46795045 cTreePath SelectLeaf(int indexcount, boolean deselect)
46805046 {
4681
- if (hide)
5047
+ if (hide || dontselect)
46825048 return null;
46835049
46845050 if (count <= 0)
....@@ -4702,9 +5068,17 @@
47025068 }
47035069 }
47045070
5071
+ ObjEditor GetWindow()
5072
+ {
5073
+ if (editWindow != null)
5074
+ return editWindow;
5075
+
5076
+ return manipWindow;
5077
+ }
5078
+
47055079 cTreePath Select(int indexcount, boolean deselect)
47065080 {
4707
- if (hide)
5081
+ if (hide || dontselect)
47085082 return null;
47095083
47105084 if (count <= 0)
....@@ -4738,10 +5112,11 @@
47385112 if (leaf != null)
47395113 {
47405114 cTreePath tp = new cTreePath(this, leaf);
4741
- if (editWindow != null)
5115
+ ObjEditor window = GetWindow();
5116
+ if (window != null)
47425117 {
47435118 //System.out.println("editWindow = " + editWindow + " vs " + this);
4744
- editWindow.Select(tp, deselect, true);
5119
+ window.Select(tp, deselect, true);
47455120 }
47465121
47475122 return tp;
....@@ -4758,6 +5133,7 @@
47585133
47595134 if (child == null)
47605135 continue;
5136
+
47615137 if (child.HasTransparency() && child.size() != 0)
47625138 {
47635139 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4767,9 +5143,10 @@
47675143 if (leaf != null)
47685144 {
47695145 cTreePath tp = new cTreePath(this, leaf);
4770
- if (editWindow != null)
5146
+ ObjEditor window = GetWindow();
5147
+ if (window != null)
47715148 {
4772
- editWindow.Select(tp, deselect, true);
5149
+ window.Select(tp, deselect, true);
47735150 }
47745151
47755152 return tp;
....@@ -5094,6 +5471,51 @@
50945471 blockloop = false;
50955472 }
50965473
5474
+ void ResetSelectable()
5475
+ {
5476
+ if (blockloop)
5477
+ return;
5478
+
5479
+ blockloop = true;
5480
+
5481
+ keepdontselect = dontselect;
5482
+ dontselect = true;
5483
+
5484
+ Object3D child;
5485
+ int nb = Size();
5486
+ for (int i = 0; i < nb; i++)
5487
+ {
5488
+ child = (Object3D) get(i);
5489
+ if (child == null)
5490
+ continue;
5491
+ child.ResetSelectable();
5492
+ }
5493
+
5494
+ blockloop = false;
5495
+ }
5496
+
5497
+ void RestoreSelectable()
5498
+ {
5499
+ if (blockloop)
5500
+ return;
5501
+
5502
+ blockloop = true;
5503
+
5504
+ dontselect = keepdontselect;
5505
+
5506
+ Object3D child;
5507
+ int nb = Size();
5508
+ for (int i = 0; i < nb; i++)
5509
+ {
5510
+ child = (Object3D) get(i);
5511
+ if (child == null)
5512
+ continue;
5513
+ child.RestoreSelectable();
5514
+ }
5515
+
5516
+ blockloop = false;
5517
+ }
5518
+
50975519 boolean IsSelected()
50985520 {
50995521 if (parent == null)
....@@ -5154,12 +5576,41 @@
51545576 if (fullname == null)
51555577 return "";
51565578
5579
+ if (fullname.pigment != null)
5580
+ {
5581
+ return fullname.pigment;
5582
+ }
5583
+
51575584 // System.out.println("Fullname = " + fullname);
51585585
5159
- if (fullname.name.indexOf(":") == -1)
5160
- return fullname.name;
5586
+ // Does not work on Windows due to C:
5587
+// if (fullname.name.indexOf(":") == -1)
5588
+// return fullname.name;
5589
+//
5590
+// return fullname.name.substring(0,fullname.name.indexOf(":"));
51615591
5162
- return fullname.name.substring(0,fullname.name.indexOf(":"));
5592
+ String[] split = fullname.name.split(":");
5593
+
5594
+ if (split.length == 0)
5595
+ {
5596
+ return fullname.pigment = "";
5597
+ }
5598
+
5599
+ if (split.length <= 2)
5600
+ {
5601
+ if (fullname.name.endsWith(":"))
5602
+ {
5603
+ // Windows
5604
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
5605
+ }
5606
+
5607
+ return fullname.pigment = split[0];
5608
+ }
5609
+
5610
+ // Windows
5611
+ assert(split.length == 4);
5612
+
5613
+ return fullname.pigment = split[0] + ":" + split[1];
51635614 }
51645615
51655616 static String GetBump(cTexture fullname)
....@@ -5167,11 +5618,44 @@
51675618 if (fullname == null)
51685619 return "";
51695620
5621
+ if (fullname.bump != null)
5622
+ {
5623
+ return fullname.bump;
5624
+ }
5625
+
51705626 // System.out.println("Fullname = " + fullname);
5171
- if (fullname.name.indexOf(":") == -1)
5172
- return "";
5173
-
5174
- return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5627
+ // Does not work on Windows due to C:
5628
+// if (fullname.name.indexOf(":") == -1)
5629
+// return "";
5630
+//
5631
+// return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5632
+ String[] split = fullname.name.split(":");
5633
+
5634
+ if (split.length == 0)
5635
+ {
5636
+ return fullname.bump = "";
5637
+ }
5638
+
5639
+ if (split.length == 1)
5640
+ {
5641
+ return fullname.bump = "";
5642
+ }
5643
+
5644
+ if (split.length == 2)
5645
+ {
5646
+ if (fullname.name.endsWith(":"))
5647
+ {
5648
+ // Windows
5649
+ return fullname.bump = "";
5650
+ }
5651
+
5652
+ return fullname.bump = split[1];
5653
+ }
5654
+
5655
+ // Windows
5656
+ assert(split.length == 4);
5657
+
5658
+ return fullname.bump = split[2] + ":" + split[3];
51755659 }
51765660
51775661 String GetPigmentTexture()
....@@ -5245,7 +5729,7 @@
52455729 System.out.print("; textures = " + textures);
52465730 System.out.println("; usedtextures = " + usedtextures);
52475731
5248
- if (GetTextures() == null)
5732
+ if (GetTextures() == null) // What is that??
52495733 GetTextures().name = ":";
52505734
52515735 String texname = tex;
....@@ -5254,6 +5738,9 @@
52545738 texname = "";
52555739
52565740 GetTextures().name = texname + ":" + GetBump(GetTextures());
5741
+
5742
+ GetTextures().pigment = null;
5743
+
52575744 Touch();
52585745 }
52595746
....@@ -5278,6 +5765,43 @@
52785765 }
52795766 }
52805767
5768
+ UUID GetUUID()
5769
+ {
5770
+ if (uuid == null)
5771
+ {
5772
+ // Serial
5773
+ uuid = UUID.randomUUID();
5774
+ }
5775
+
5776
+ return uuid;
5777
+ }
5778
+
5779
+ Object3D GetObject(UUID uid)
5780
+ {
5781
+ if (blockloop)
5782
+ return null;
5783
+
5784
+ if (GetUUID().equals(uid))
5785
+ return this;
5786
+
5787
+ int nb = Size();
5788
+ for (int i = 0; i < nb; i++)
5789
+ {
5790
+ Object3D child = (Object3D) get(i);
5791
+
5792
+ if (child == null)
5793
+ continue;
5794
+
5795
+ blockloop = true;
5796
+ Object3D obj = child.GetObject(uid);
5797
+ blockloop = false;
5798
+ if (obj != null)
5799
+ return obj;
5800
+ }
5801
+
5802
+ return null;
5803
+ }
5804
+
52815805 void SetBumpTexture(String tex)
52825806 {
52835807 if (GetTextures() == null)
....@@ -5289,6 +5813,8 @@
52895813 texname = "";
52905814
52915815 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
5816
+
5817
+ GetTextures().bump = null;
52925818
52935819 Touch();
52945820 }
....@@ -5314,6 +5840,38 @@
53145840 }
53155841 }
53165842
5843
+ void EmbedTextures(boolean embed)
5844
+ {
5845
+ if (blockloop)
5846
+ return;
5847
+
5848
+ //if (GetTextures() != null)
5849
+ if (embed)
5850
+ CameraPane.EmbedTextures(GetTextures());
5851
+ else
5852
+ {
5853
+ GetTextures().pigmentdata = null;
5854
+ GetTextures().bumpdata = null;
5855
+ GetTextures().pw = 0;
5856
+ GetTextures().ph = 0;
5857
+ GetTextures().bw = 0;
5858
+ GetTextures().bh = 0;
5859
+ }
5860
+
5861
+ int nb = Size();
5862
+ for (int i = 0; i < nb; i++)
5863
+ {
5864
+ Object3D child = (Object3D) get(i);
5865
+
5866
+ if (child == null)
5867
+ continue;
5868
+
5869
+ blockloop = true;
5870
+ child.EmbedTextures(embed);
5871
+ blockloop = false;
5872
+ }
5873
+ }
5874
+
53175875 void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
53185876 {
53195877 Draw(display, root, selected, blocked);
....@@ -5322,12 +5880,23 @@
53225880 boolean NeedSupport()
53235881 {
53245882 return
5325
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5883
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
53265884 // PROBLEM with CROWD!!
5327
- && (Globals.DrawMode() == iCameraPane.SHADOW || Globals.CROWD);
5885
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
53285886 }
53295887
53305888 static boolean DEBUG_SELECTION = false;
5889
+
5890
+ boolean IsLive()
5891
+ {
5892
+ if (live)
5893
+ return true;
5894
+
5895
+ if (parent == null)
5896
+ return false;
5897
+
5898
+ return parent.IsLive();
5899
+ }
53315900
53325901 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
53335902 {
....@@ -5339,7 +5908,7 @@
53395908 }
53405909
53415910 if (display.DrawMode() == iCameraPane.SELECTION &&
5342
- hide)
5911
+ (hide || dontselect))
53435912 return;
53445913
53455914 if (name != null && name.contains("sclera"))
....@@ -5371,7 +5940,7 @@
53715940 return;
53725941 }
53735942
5374
- javax.media.opengl.GL gl = display.GetGL();
5943
+ //javax.media.opengl.GL gl = display.GetGL();
53755944
53765945 /*
53775946 if (touched)
....@@ -5389,8 +5958,10 @@
53895958 if (support != null)
53905959 support = support;
53915960
5392
- //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5393
- boolean usecalllists = false; // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5961
+ boolean usecalllists = !IsLive() && IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5962
+ //boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5963
+
5964
+ //usecalllists &= display.DrawMode() == display.DEFAULT; // Don't compute list in shadow pass.
53945965
53955966 if (!usecalllists && bRep != null && bRep.displaylist > 0)
53965967 {
....@@ -5400,8 +5971,9 @@
54005971 // usecalllists &= !(parent instanceof RandomNode);
54015972 // usecalllists = false;
54025973
5403
- if (GetBRep() != null)
5404
- usecalllists = usecalllists;
5974
+ if (display.DrawMode() == display.SHADOW)
5975
+ //GetBRep() != null)
5976
+ usecalllists = !!usecalllists;
54055977 //System.out.println("draw " + this);
54065978 //new Exception().printStackTrace();
54075979
....@@ -5410,10 +5982,12 @@
54105982 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
54115983
54125984 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5413
- (touched || (bRep != null && bRep.displaylist <= 0)))
5985
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5986
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
54145987 {
54155988 Globals.lighttouched = true;
54165989 } // all panes...
5990
+
54175991 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
54185992 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
54195993 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5421,9 +5995,9 @@
54215995 if (!(this instanceof Composite))
54225996 touched = false;
54235997 //if (displaylist == -1 && usecalllists)
5424
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
5998
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
54255999 {
5426
- bRep.displaylist = gl.glGenLists(1);
6000
+ bRep.displaylist = display.GenList();
54276001 assert(bRep.displaylist != 0);
54286002 // System.err.println("glGenLists: " + bRep.displaylist + " for " + this);
54296003 //System.out.println("\tgen list " + list);
....@@ -5432,17 +6006,19 @@
54326006
54336007 //System.out.println("\tnew list " + list);
54346008 //gl.glDrawBuffer(gl.GL_NONE);
5435
- if (usecalllists)
6009
+ if (usecalllists && bRep.displaylist > 0)
54366010 {
54376011 // System.err.println("new list " + bRep.displaylist + " for " + this);
5438
- gl.glNewList(bRep.displaylist, gl.GL_COMPILE); //_AND_EXECUTE);
6012
+ display.NewList(bRep.displaylist);
54396013 }
6014
+
54406015 CallList(display, root, selected, blocked);
6016
+
54416017 // compiled = true;
5442
- if (usecalllists)
6018
+ if (usecalllists && bRep.displaylist > 0)
54436019 {
54446020 // System.err.println("end list " + bRep.displaylist + " for " + this);
5445
- gl.glEndList();
6021
+ display.EndList();
54466022 }
54476023 //gl.glDrawBuffer(gl.GL_BACK);
54486024 // XXX touched = false;
....@@ -5490,7 +6066,7 @@
54906066 if (display.DrawMode() == iCameraPane.SHADOW)
54916067 {
54926068 if (!link2master // tricky to cull in shadow mode.
5493
- && GetBRep().FrustumCull(this, gl, display.LightCamera(), true))
6069
+ && GetBRep().FrustumCull(this, null, display.LightCamera(), true))
54946070 {
54956071 //System.out.print("CULLED");
54966072 culled = true;
....@@ -5498,7 +6074,7 @@
54986074 }
54996075 else
55006076 //GetBRep().getBounds(v0, v1, this);
5501
- if (GetBRep().FrustumCull(this, gl, display.RenderCamera(), false))
6077
+ if (GetBRep().FrustumCull(this, null, display.RenderCamera(), false))
55026078 culled = true;
55036079
55046080 // LA.xformPos(v0, display.renderCamera.toScreen, v0);
....@@ -5538,7 +6114,8 @@
55386114 {
55396115 if (GetBRep() != null)
55406116 {
5541
- CameraPane.NextIndex(this, gl);
6117
+ display.NextIndex();
6118
+
55426119 // vertex color conflict : gl.glCallList(list);
55436120 DrawNode(display, root, selected);
55446121 if (this instanceof BezierPatch)
....@@ -5579,7 +6156,28 @@
55796156 tex = GetTextures();
55806157 }
55816158
5582
- display.BindTextures(tex, texres);
6159
+ boolean failedPigment = false;
6160
+ boolean failedBump = false;
6161
+
6162
+ try
6163
+ {
6164
+ display.BindPigmentTexture(tex, texres);
6165
+ }
6166
+ catch (Exception e)
6167
+ {
6168
+ System.err.println("FAILED: " + this);
6169
+ failedPigment = true;
6170
+ }
6171
+
6172
+ try
6173
+ {
6174
+ display.BindBumpTexture(tex, texres);
6175
+ }
6176
+ catch (Exception e)
6177
+ {
6178
+ //System.err.println("FAILED: " + this);
6179
+ failedBump = true;
6180
+ }
55836181
55846182 if (!compiled)
55856183 {
....@@ -5595,13 +6193,17 @@
55956193
55966194 // System.err.println("glCallList: " + bRep.displaylist + " for " + this);
55976195 assert(bRep.displaylist != 0);
5598
- gl.glCallList(bRep.displaylist);
6196
+ display.CallList(bRep.displaylist);
55996197 // june 2013 drawSelf(display, root, selected);
56006198 }
56016199 }
56026200 }
56036201
5604
- display.ReleaseTextures(tex);
6202
+ if (!failedBump)
6203
+ display.ReleaseBumpTexture(tex);
6204
+
6205
+ if (!failedPigment)
6206
+ display.ReleasePigmentTexture(tex);
56056207
56066208 display.PopMaterial(this, selected);
56076209 }
....@@ -5730,6 +6332,9 @@
57306332
57316333 void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57326334 {
6335
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6336
+ return;
6337
+
57336338 if (hide)
57346339 return;
57356340 // shadow optimisation
....@@ -5855,6 +6460,9 @@
58556460 if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
58566461 return; // no shadow for transparent objects
58576462
6463
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6464
+ return;
6465
+
58586466 if (hide)
58596467 return;
58606468
....@@ -5895,9 +6503,10 @@
58956503 return;
58966504 }
58976505
6506
+ //bRep.GenUV(1/material.diffuseness);
58986507 // bRep.lock = true;
58996508
5900
- javax.media.opengl.GL gl = display.GetGL();
6509
+ //javax.media.opengl.GL gl = display.GetGL();
59016510
59026511 if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera)
59036512 {
....@@ -5914,23 +6523,7 @@
59146523
59156524 bRep.getMinMax(min, max, 100);
59166525
5917
- gl.glBegin(gl.GL_LINES);
5918
-
5919
- gl.glVertex3d(min.x, min.y, min.z);
5920
- gl.glVertex3d(min.x, min.y, max.z);
5921
- gl.glVertex3d(min.x, min.y, min.z);
5922
- gl.glVertex3d(min.x, max.y, min.z);
5923
- gl.glVertex3d(min.x, min.y, min.z);
5924
- gl.glVertex3d(max.x, min.y, min.z);
5925
-
5926
- gl.glVertex3d(max.x, max.y, max.z);
5927
- gl.glVertex3d(min.x, max.y, max.z);
5928
- gl.glVertex3d(max.x, max.y, max.z);
5929
- gl.glVertex3d(max.x, min.y, max.z);
5930
- gl.glVertex3d(max.x, max.y, max.z);
5931
- gl.glVertex3d(max.x, max.y, min.z);
5932
-
5933
- gl.glEnd();
6526
+ display.DrawBox(min, max);
59346527
59356528 return;
59366529 }
....@@ -5984,178 +6577,19 @@
59846577 new Exception().printStackTrace();
59856578 return;
59866579 }
5987
-
5988
- // TRIANGLE STRIP ARRAY
5989
- if (bRep.trimmed)
6580
+
6581
+ if (dontselect)
59906582 {
5991
- float[] v = bRep.getRawVertices();
5992
- float[] n = bRep.getRawNormals();
5993
- float[] c = bRep.getRawColors();
5994
- float[] uv = bRep.getRawUVMap();
5995
-
5996
- int count2 = 0;
5997
- int count3 = 0;
5998
-
5999
- if (n.length > 0)
6000
- {
6001
- for (int i = 0; i < strips.length; i++)
6002
- {
6003
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6004
-
6005
- /*
6006
- boolean locked = false;
6007
- float eps = 0.1f;
6008
- boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
6009
-
6010
- int dot = 0;
6011
-
6012
- if ((dot&1) == 0)
6013
- dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
6014
-
6015
- if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
6016
- gl.glTexCoord2f((float) qv.s, (float) qv.t);
6017
- else
6018
- {
6019
- locked = true;
6020
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6021
- }
6022
- //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6023
- gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
6024
- if (hasnorm)
6025
- {
6026
- //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6027
- gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
6028
- }
6029
-
6030
- if ((dot&4) == 0)
6031
- dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
6032
-
6033
- if (wrap || !locked && (dot&8) != 0)
6034
- gl.glTexCoord2f((float) rv.s, (float) rv.t);
6035
- else
6036
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6037
-
6038
- f.dot = dot;
6039
- */
6040
-
6041
- if (!selectmode)
6042
- {
6043
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6044
- {
6045
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6046
- } else
6047
- {
6048
- gl.glNormal3f(0, 0, 1);
6049
- }
6050
-
6051
- if (c != null)
6052
- //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]);
6053
- {
6054
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6055
- }
6056
- }
6057
- if (flipV)
6058
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6059
- else
6060
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6061
- //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6062
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6063
-
6064
- count2 += 2;
6065
- count3 += 3;
6066
- if (!selectmode)
6067
- {
6068
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6069
- {
6070
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6071
- } else
6072
- {
6073
- gl.glNormal3f(0, 0, 1);
6074
- }
6075
- if (c != null)
6076
- {
6077
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6078
- }
6079
- }
6080
- if (flipV)
6081
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6082
- else
6083
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6084
- //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6085
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6086
-
6087
- count2 += 2;
6088
- count3 += 3;
6089
- for (int j = 0; j < strips[i] - 2; j++)
6090
- {
6091
- //gl.glTexCoord2d(...);
6092
- if (!selectmode)
6093
- {
6094
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6095
- {
6096
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6097
- } else
6098
- {
6099
- gl.glNormal3f(0, 0, 1);
6100
- }
6101
- if (c != null)
6102
- {
6103
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6104
- }
6105
- }
6106
-
6107
- if (flipV)
6108
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6109
- else
6110
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6111
- //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
6112
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6113
- count2 += 2;
6114
- count3 += 3;
6115
- }
6116
-
6117
- gl.glEnd();
6118
- }
6119
- }
6120
-
6121
- assert count3 == v.length;
6583
+ //bRep.GenerateNormalsMINE();
61226584 }
6123
- else // !trimmed
6124
- {
6125
- int count = 0;
6126
- for (int i = 0; i < strips.length; i++)
6127
- {
6128
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6129
-
6130
- Vertex p = bRep.GetVertex(bRep.indices[count++]);
6131
- Vertex q = bRep.GetVertex(bRep.indices[count++]);
6132
-
6133
- drawVertex(gl, p, selectmode);
6134
- drawVertex(gl, q, selectmode);
6135
-
6136
- for (int j = 0; j < strips[i] - 2; j++)
6137
- {
6138
- Vertex r = bRep.GetVertex(bRep.indices[count++]);
6139
-
6140
-// if (j%2 == 0)
6141
-// drawFace(p, q, r, display, null);
6142
-// else
6143
-// drawFace(p, r, q, display, null);
6144
-
6145
-// p = q;
6146
-// q = r;
6147
- drawVertex(gl, r, selectmode);
6148
- }
6149
-
6150
- gl.glEnd();
6151
- }
6152
- }
6585
+
6586
+ display.DrawGeometry(bRep, flipV, selectmode);
61536587 } else // catch (Error e)
61546588 {
61556589 // TRIANGLE ARRAY
61566590 if (IsOpaque()) // Static())
61576591 {
6158
- gl.glBegin(gl.GL_TRIANGLES);
6592
+ display.StartTriangles();
61596593 int facecount = bRep.FaceCount();
61606594 for (int i = 0; i < facecount; i++)
61616595 {
....@@ -6220,7 +6654,7 @@
62206654
62216655 display.DrawFace(this, p, q, r, face);
62226656 }
6223
- gl.glEnd();
6657
+ display.EndTriangles();
62246658 }
62256659 else
62266660 {
....@@ -6249,8 +6683,8 @@
62496683 //System.out.println("SORT");
62506684
62516685 java.util.Arrays.sort(facescompare);
6252
-
6253
- gl.glBegin(gl.GL_TRIANGLES);
6686
+
6687
+ display.StartTriangles();
62546688 for (int i = 0; i < facecount; i++)
62556689 {
62566690 Face face = bRep.GetFace(facescompare[i].index);
....@@ -6264,11 +6698,12 @@
62646698
62656699 display.DrawFace(this, p, q, r, face);
62666700 }
6267
- gl.glEnd();
6701
+ display.EndTriangles();
62686702 }
62696703
62706704 if (false) // live && support != null && support.bRep != null) // debug weights
62716705 {
6706
+ /*
62726707 gl.glDisable(gl.GL_LIGHTING);
62736708 float[] colorV = new float[3];
62746709
....@@ -6347,6 +6782,7 @@
63476782 // gl.glEnd();
63486783 }
63496784 }
6785
+ */
63506786 }
63516787 }
63526788
....@@ -6391,7 +6827,7 @@
63916827 center.add(r);
63926828 center.mul(1.0/3);
63936829
6394
- center.sub(CameraPane.theRenderer.eyeCamera.location);
6830
+ center.sub(Globals.theRenderer.EyeCamera().location);
63956831
63966832 distance = center.dot(center);
63976833 }
....@@ -6405,22 +6841,6 @@
64056841 void Print(Vertex v)
64066842 {
64076843 //System.err.println("(" + v.x + ", " + v.y + ", " + v.z + ")");
6408
- }
6409
-
6410
- void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean selectmode)
6411
- {
6412
- if (!selectmode)
6413
- {
6414
- gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
6415
- gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
6416
-
6417
- if (flipV)
6418
- gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
6419
- else
6420
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6421
- }
6422
-
6423
- gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
64246844 }
64256845
64266846 void drawSelf(ClickInfo info, int level, boolean select)
....@@ -6946,20 +7366,23 @@
69467366 }
69477367 }
69487368
6949
- protected void calcHotSpot(cVector in, ClickInfo info, Point outPt, Rectangle outRec)
7369
+ static ClickInfo clickInfo = new ClickInfo();
7370
+
7371
+ protected void calcHotSpot(cVector in, //ClickInfo clickInfo,
7372
+ Point outPt, Rectangle outRec)
69507373 {
6951
- int hc = info.bounds.x + info.bounds.width / 2;
6952
- int vc = info.bounds.y + info.bounds.height / 2;
6953
- double[][] toscreen = info.toScreen;
7374
+ int hc = clickInfo.bounds.x + clickInfo.bounds.width / 2;
7375
+ int vc = clickInfo.bounds.y + clickInfo.bounds.height / 2;
7376
+ double[][] toscreen = clickInfo.toScreen;
69547377 if (toscreen == null)
69557378 {
6956
- toscreen = new Camera(info.camera.viewCode).toScreen;
7379
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
69577380 }
69587381 cVector vec = in;
69597382 LA.xformPos(in, toscreen, in);
69607383 //System.out.println("Distance = " + info.camera.Distance());
6961
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
6962
- vec.y *= 100 * info.camera.SCALE / info.camera.Distance();
7384
+ vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
7385
+ vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
69637386 outPt.x = hc + (int) vec.x;
69647387 outPt.y = vc - (int) vec.y;
69657388 outRec.x = outPt.x - 3;
....@@ -6967,15 +7390,18 @@
69677390 outRec.width = outRec.height = 6;
69687391 }
69697392
6970
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7393
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7394
+ )
69717395 {
69727396 Point pt = new Point(0, 0);
69737397 Rectangle rec = new Rectangle();
6974
- calcHotSpot(in, info, pt, rec);
7398
+ calcHotSpot(in, //clickInfo,
7399
+ pt, rec);
69757400 return rec;
69767401 }
69777402
6978
- void drawEditHandles0(ClickInfo info, int level)
7403
+ void drawEditHandles0(//ClickInfo clickInfo,
7404
+ int level)
69797405 {
69807406 if (level == 0)
69817407 {
....@@ -6984,16 +7410,19 @@
69847410 {
69857411 cVector origin = new cVector();
69867412 //LA.xformPos(origin, toParent, origin);
6987
- Rectangle spot = calcHotSpot(origin, info);
7413
+ if (this.clickInfo == null)
7414
+ this.clickInfo = new ClickInfo();
7415
+
7416
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
69887417 Rectangle boundary = new Rectangle();
69897418 boundary.x = spot.x - 30;
69907419 boundary.y = spot.y - 30;
69917420 boundary.width = spot.width + 60;
69927421 boundary.height = spot.height + 60;
6993
- info.g.setColor(Color.red);
7422
+ clickInfo.g.setColor(Color.white);
69947423 int spotw = spot.x + spot.width;
69957424 int spoth = spot.y + spot.height;
6996
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7425
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
69977426 // if (CameraPane.Xmin > spot.x)
69987427 // {
69997428 // CameraPane.Xmin = spot.x;
....@@ -7010,11 +7439,33 @@
70107439 // {
70117440 // CameraPane.Ymax = spoth;
70127441 // }
7013
- spot.translate(32, 32);
7442
+// if (CameraPane.Xmin > spot.x)
7443
+// {
7444
+// CameraPane.Xmin = spot.x;
7445
+// }
7446
+// if (CameraPane.Xmax < spotw)
7447
+// {
7448
+// CameraPane.Xmax = spotw;
7449
+// }
7450
+// if (CameraPane.Ymin > spot.y)
7451
+// {
7452
+// CameraPane.Ymin = spot.y;
7453
+// }
7454
+// if (CameraPane.Ymax < spoth)
7455
+// {
7456
+// CameraPane.Ymax = spoth;
7457
+// }
7458
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7459
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
7460
+ spot.translate(32, 0);
7461
+ clickInfo.g.setColor(Color.yellow);
7462
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7463
+
7464
+ spot.translate(32, 64);
70147465 spotw = spot.x + spot.width;
70157466 spoth = spot.y + spot.height;
7016
- info.g.setColor(Color.blue);
7017
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7467
+ clickInfo.g.setColor(Color.cyan);
7468
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
70187469 // if (CameraPane.Xmin > spot.x)
70197470 // {
70207471 // CameraPane.Xmin = spot.x;
....@@ -7031,29 +7482,9 @@
70317482 // {
70327483 // CameraPane.Ymax = spoth;
70337484 // }
7034
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7035
- info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7036
- spot.translate(0, -32);
7037
- info.g.setColor(Color.green);
7038
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7039
-// if (CameraPane.Xmin > spot.x)
7040
-// {
7041
-// CameraPane.Xmin = spot.x;
7042
-// }
7043
-// if (CameraPane.Xmax < spotw)
7044
-// {
7045
-// CameraPane.Xmax = spotw;
7046
-// }
7047
-// if (CameraPane.Ymin > spot.y)
7048
-// {
7049
-// CameraPane.Ymin = spot.y;
7050
-// }
7051
-// if (CameraPane.Ymax < spoth)
7052
-// {
7053
-// CameraPane.Ymax = spoth;
7054
-// }
7055
- info.g.drawArc(boundary.x, boundary.y,
7056
- boundary.width, boundary.height, 0, 360);
7485
+ clickInfo.g.setColor(Color.green);
7486
+ clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
7487
+ (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
70577488 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
70587489 // if (CameraPane.Xmin > boundary.x)
70597490 // {
....@@ -7075,7 +7506,8 @@
70757506 }
70767507 }
70777508
7078
- boolean doEditClick0(ClickInfo info, int level)
7509
+ boolean doEditClick0(//ClickInfo clickInfo,
7510
+ int level)
70797511 {
70807512 if (level == 0)
70817513 {
....@@ -7084,10 +7516,10 @@
70847516
70857517 boolean retval = false;
70867518
7087
- startX = info.x;
7088
- startY = info.y;
7519
+ startX = clickInfo.x;
7520
+ startY = clickInfo.y;
70897521
7090
- hitSomething = 0;
7522
+ hitSomething = -1;
70917523 cVector origin = new cVector();
70927524 //LA.xformPos(origin, toParent, origin);
70937525 Rectangle spot = new Rectangle();
....@@ -7095,22 +7527,53 @@
70957527 {
70967528 centerPt = new Point(0, 0);
70977529 }
7098
- calcHotSpot(origin, info, centerPt, spot);
7099
- if (spot.contains(info.x, info.y))
7530
+ calcHotSpot(origin, //info,
7531
+ centerPt, spot);
7532
+ if (spot.contains(clickInfo.x, clickInfo.y))
71007533 {
71017534 hitSomething = hitCenter;
71027535 retval = true;
71037536 }
71047537 spot.translate(32, 0);
7105
- if (spot.contains(info.x, info.y))
7538
+ if (spot.contains(clickInfo.x, clickInfo.y))
71067539 {
71077540 hitSomething = hitRotate;
71087541 retval = true;
71097542 }
71107543 spot.translate(0, 32);
7111
- if (spot.contains(info.x, info.y))
7544
+ spot.translate(32, 0);
7545
+ spot.translate(0, 32);
7546
+ if (spot.contains(clickInfo.x, clickInfo.y))
71127547 {
71137548 hitSomething = hitScale;
7549
+
7550
+ double scale = 0.005f * clickInfo.camera.Distance();
7551
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
7552
+ double sign = 1;
7553
+ if (hScale < 0)
7554
+ {
7555
+ sign = -1;
7556
+ }
7557
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
7558
+ if (hScale < 0.01)
7559
+ {
7560
+ //hScale = 0.01;
7561
+ }
7562
+
7563
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
7564
+ sign = 1;
7565
+ if (vScale < 0)
7566
+ {
7567
+ sign = -1;
7568
+ }
7569
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
7570
+ if (vScale < 0.01)
7571
+ {
7572
+ //vScale = 0.01;
7573
+ }
7574
+
7575
+ clickInfo.scale = Math.sqrt(hScale*hScale + vScale*vScale);
7576
+
71147577 retval = true;
71157578 }
71167579
....@@ -7120,7 +7583,7 @@
71207583 }
71217584
71227585 //System.out.println("info.modifiers = " + info.modifiers);
7123
- modified = (info.modifiers & CameraPane.META) != 0;
7586
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
71247587 //System.out.println("modified = " + modified);
71257588 //new Exception().printStackTrace();
71267589 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7148,7 +7611,8 @@
71487611 return true;
71497612 }
71507613
7151
- void doEditDrag0(ClickInfo info)
7614
+ void doEditDrag0(//ClickInfo info,
7615
+ boolean opposite)
71527616 {
71537617 if (hitSomething == 0)
71547618 {
....@@ -7162,7 +7626,8 @@
71627626
71637627 //System.out.println("hitSomething = " + hitSomething);
71647628
7165
- double scale = 0.005f * info.camera.Distance();
7629
+ double scale = 0.005f * clickInfo.camera.Distance();
7630
+
71667631 cVector xlate = new cVector();
71677632 //cVector xlate2 = new cVector();
71687633 switch (hitSomething)
....@@ -7173,9 +7638,9 @@
71737638
71747639 case hitCenter: // Translate
71757640
7176
- scale *= 0.05f * info.pane.theRenderer.renderCamera.Distance();
7641
+ scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
71777642
7178
- if (modified)
7643
+ if (modified || opposite)
71797644 {
71807645 //assert(false);
71817646 /*
....@@ -7195,8 +7660,8 @@
71957660 toParent[3][i] = xlate.get(i);
71967661 LA.matInvert(toParent, fromParent);
71977662 */
7198
- cVector delta = LA.newVector(0, 0, startY - info.y);
7199
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7663
+ cVector delta = LA.newVector(0, 0, startY - clickInfo.y);
7664
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
72007665
72017666 LA.matCopy(startMat, toParent);
72027667 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7205,7 +7670,7 @@
72057670 } else
72067671 {
72077672 //LA.xformDir(delta, info.camera.fromScreen, delta);
7208
- cVector up = new cVector(info.camera.up);
7673
+ cVector up = new cVector(clickInfo.camera.up);
72097674 cVector away = new cVector();
72107675 //cVector right2 = new cVector();
72117676 //LA.vecCross(up, cVector.Z, right);
....@@ -7221,20 +7686,20 @@
72217686 }
72227687 LA.xformDir(up, ClickInfo.matbuffer, up);
72237688 // if (!CameraPane.LOCALTRANSFORM)
7224
- LA.xformDir(up, info.pane.theRenderer.renderCamera.toScreen, up);
7225
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7689
+ LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7690
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
72267691 // if (!CameraPane.LOCALTRANSFORM)
7227
- LA.xformDir(away, info.pane.theRenderer.renderCamera.toScreen, away);
7692
+ LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
72287693 //LA.vecCross(up, cVector.Z, right2);
72297694
7230
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7695
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
72317696
72327697 //System.out.println("DELTA0 = " + delta);
72337698 //System.out.println("AWAY = " + info.camera.away);
72347699 //System.out.println("UP = " + info.camera.up);
72357700 if (away.z > 0)
72367701 {
7237
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7702
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
72387703 {
72397704 delta.x = -delta.x;
72407705 } else
....@@ -7249,7 +7714,7 @@
72497714 //System.out.println("DELTA1 = " + delta);
72507715 LA.xformDir(delta, ClickInfo.matbuffer, delta);
72517716 //System.out.println("DELTA2 = " + delta);
7252
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7717
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
72537718 LA.matCopy(startMat, toParent);
72547719 //System.out.println("DELTA3 = " + delta);
72557720 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7259,8 +7724,8 @@
72597724 break;
72607725
72617726 case hitRotate: // rotate
7262
- int dx = info.x - centerPt.x;
7263
- int dy = -(info.y - centerPt.y);
7727
+ int dx = clickInfo.x - centerPt.x;
7728
+ int dy = -(clickInfo.y - centerPt.y);
72647729 double angle = (double) Math.atan2(dx, dy);
72657730 angle = -(1.570796 - angle);
72667731
....@@ -7269,6 +7734,7 @@
72697734
72707735 if (modified)
72717736 {
7737
+ // Rotate 90 degrees
72727738 angle /= (Math.PI / 4);
72737739 angle = Math.floor(angle + 0.5);
72747740 angle *= (Math.PI / 4);
....@@ -7282,7 +7748,7 @@
72827748 }
72837749 /**/
72847750
7285
- switch (info.pane.renderCamera.viewCode)
7751
+ switch (clickInfo.pane.RenderCamera().viewCode)
72867752 {
72877753 case 1: // '\001'
72887754 LA.matZRotate(toParent, angle);
....@@ -7309,26 +7775,30 @@
73097775 break;
73107776
73117777 case hitScale: // scale
7312
- double hScale = (double) (info.x - centerPt.x) / 32;
7778
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
7779
+ double sign = 1;
7780
+ if (hScale < 0)
7781
+ {
7782
+ sign = -1;
7783
+ }
7784
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
73137785 if (hScale < 0.01)
73147786 {
7315
- hScale = 0.01;
7787
+ //hScale = 0.01;
73167788 }
7317
- hScale = Math.pow(hScale, scale * 50);
7318
- if (hScale < 0.01)
7789
+
7790
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
7791
+ sign = 1;
7792
+ if (vScale < 0)
73197793 {
7320
- hScale = 0.01;
7794
+ sign = -1;
73217795 }
7322
- double vScale = (double) (info.y - centerPt.y) / 32;
7796
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
73237797 if (vScale < 0.01)
73247798 {
7325
- vScale = 0.01;
7799
+ //vScale = 0.01;
73267800 }
7327
- vScale = Math.pow(vScale, scale * 50);
7328
- if (vScale < 0.01)
7329
- {
7330
- vScale = 0.01;
7331
- }
7801
+
73327802 LA.matCopy(startMat, toParent);
73337803 /**/
73347804 for (int i = 0; i < 3; i++)
....@@ -7338,39 +7808,56 @@
73387808 }
73397809 /**/
73407810
7341
- switch (info.pane.renderCamera.viewCode)
7811
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
7812
+
7813
+ if (totalScale < 0.01)
7814
+ {
7815
+ totalScale = 0.01;
7816
+ }
7817
+
7818
+ switch (clickInfo.pane.RenderCamera().viewCode)
73427819 {
73437820 case 3: // '\001'
7344
- if (modified)
7821
+ if (modified || opposite)
73457822 {
7823
+ if (modified && opposite)
7824
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7825
+ else
73467826 //LA.matScale(toParent, 1, hScale, vScale);
7347
- LA.matScale(toParent, vScale, 1, 1);
7827
+ LA.matScale(toParent, totalScale, 1, 1);
73487828 } // vScale, 1);
73497829 else
73507830 {
7351
- LA.matScale(toParent, vScale, vScale, vScale);
7831
+ // EXCEPTION!
7832
+ LA.matScale(toParent, 1, totalScale, totalScale);
73527833 } // vScale, 1);
73537834 break;
73547835
73557836 case 2: // '\002'
7356
- if (modified)
7837
+ if (modified || opposite)
73577838 {
7358
- //LA.matScale(toParent, hScale, 1, vScale);
7359
- LA.matScale(toParent, 1, vScale, 1);
7839
+ if (modified && opposite)
7840
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7841
+ else
7842
+ //LA.matScale(toParent, hScale, 1, vScale);
7843
+ LA.matScale(toParent, 1, totalScale, 1);
73607844 } else
73617845 {
7362
- LA.matScale(toParent, vScale, 1, vScale);
7846
+ LA.matScale(toParent, totalScale, 1, totalScale);
73637847 }
73647848 break;
73657849
73667850 case 1: // '\003'
7367
- if (modified)
7851
+ if (modified || opposite)
73687852 {
7369
- //LA.matScale(toParent, hScale, vScale, 1);
7370
- LA.matScale(toParent, 1, 1, vScale);
7853
+ if (modified && opposite)
7854
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7855
+ else
7856
+ //LA.matScale(toParent, hScale, vScale, 1);
7857
+ LA.matScale(toParent, 1, 1, totalScale);
73717858 } else
73727859 {
7373
- LA.matScale(toParent, vScale, vScale, 1);
7860
+ LA.matScale(toParent, totalScale, totalScale, 1);
73747861 }
73757862 break;
73767863 }
....@@ -7404,7 +7891,7 @@
74047891 } // NEW ...
74057892
74067893
7407
- info.pane.repaint();
7894
+ clickInfo.pane.repaint();
74087895 }
74097896
74107897 boolean overflow = false;
....@@ -7503,14 +7990,22 @@
75037990 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
75047991 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
75057992 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7993
+
7994
+ String objname;
7995
+
75067996 if (false) //parent != null)
75077997 {
7508
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7998
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
75097999 } else
75108000 {
7511
- return GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ") ")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ +System.identityHashCode(this);
8001
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
75128002 } // + super.toString();
75138003 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
8004
+
8005
+ if (!Globals.ADVANCED)
8006
+ return objname;
8007
+
8008
+ return objname + " " + System.identityHashCode(this);
75148009 }
75158010
75168011 public int hashCode()
....@@ -7566,6 +8061,7 @@
75668061 objectUI.closeUI();
75678062 if (editWindow != null)
75688063 {
8064
+ editWindow.ctrlPanel.FlushUI();
75698065 editWindow.refreshContents();
75708066 } // ? new
75718067 objectUI = null;
....@@ -7574,6 +8070,10 @@
75748070 {
75758071 editWindow = null;
75768072 } // ?
8073
+ }
8074
+ else
8075
+ {
8076
+ //editWindow.closeUI();
75778077 }
75788078 }
75798079
....@@ -7586,7 +8086,7 @@
75868086 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
75878087
75888088 Object3D /*Composite*/ parent;
7589
- Object3D /*Composite*/ fileparent;
8089
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
75908090
75918091 double[][] toParent; // dynamic matrix
75928092 double[][] fromParent;
....@@ -7701,7 +8201,7 @@
77018201 {
77028202 assert(bRep != null);
77038203 if (!(support instanceof GenericJoint)) // support.bRep != null)
7704
- GrafreeD.Assert(support.bRep == bRep.support);
8204
+ Grafreed.Assert(support.bRep == bRep.support);
77058205 }
77068206 else
77078207 {
....@@ -7732,6 +8232,10 @@
77328232 }
77338233
77348234 transient ObjEditor editWindow;
8235
+ transient ObjEditor manipWindow;
8236
+
8237
+ transient boolean pinned;
8238
+
77358239 transient ObjectUI objectUI;
77368240 public static int povDepth = 0;
77378241 private static cVector tbMin = new cVector();
....@@ -7750,9 +8254,9 @@
77508254 private static cVector edge2 = new cVector();
77518255 //private static cVector norm = new cVector();
77528256 /*transient private*/ int hitSomething;
7753
- private static final int hitCenter = 1;
7754
- private static final int hitScale = 2;
7755
- private static final int hitRotate = 3;
8257
+ static final int hitCenter = 1;
8258
+ static final int hitScale = 2;
8259
+ static final int hitRotate = 3;
77568260 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
77578261 /*transient*/ private Point centerPt;
77588262 /*transient*/ private int startX;