Normand Briere
2019-06-13 4629090fafbef256abd0686a85ee12042d658868
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,20 @@
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
+ private UUID uuid = UUID.randomUUID();
26
+
27
+ // TEMPORARY for mocap undo
28
+ mocap.reader.BVHReader.BVHResult bvh;
29
+ Object3D skeleton;
30
+ //
2131
2232 ScriptNode scriptnode;
2333
....@@ -99,64 +109,136 @@
99109
100110 // transient boolean reduced; // for morph reduction
101111
102
-transient com.bulletphysics.linearmath.Transform cache; // for fast merge
103
-transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
112
+ transient com.bulletphysics.linearmath.Transform cache; // for fast merge
113
+ transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
104114
105
-transient Object3D transientsupport; // for cloning
106
-transient boolean transientlink2master;
115
+ transient Object3D transientsupport; // for cloning
116
+ transient boolean transientlink2master;
107117
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)
118
+ void SaveSupports()
120119 {
121
- bRep.SaveSupports();
122
- }
123
-
124
- for (int i = 0; i < Size(); i++)
125
- {
126
- Object3D child = (Object3D) get(i);
127
- if (child == null)
128
- continue;
129
- blockloop = true;
130
- child.SaveSupports();
131
- blockloop = false;
132
- }
133
-}
120
+ if (blockloop)
121
+ return;
134122
135
-void RestoreSupports()
136
-{
137
- if (blockloop)
138
- return;
123
+ transientsupport = support;
124
+ transientlink2master = link2master;
139125
140
- support = transientsupport;
141
- link2master = transientlink2master;
142
- transientsupport = null;
143
- transientlink2master = false;
144
-
145
- if (bRep != null)
146
- {
147
- bRep.RestoreSupports();
126
+ support = null;
127
+ link2master = false;
128
+
129
+ if (bRep != null)
130
+ {
131
+ bRep.SaveSupports();
132
+ }
133
+
134
+ for (int i = 0; i < Size(); i++)
135
+ {
136
+ Object3D child = (Object3D) get(i);
137
+ if (child == null)
138
+ continue;
139
+ blockloop = true;
140
+ child.SaveSupports();
141
+ blockloop = false;
142
+ }
148143 }
149
-
150
- for (int i = 0; i < Size(); i++)
144
+
145
+ void RestoreSupports()
151146 {
152
- Object3D child = (Object3D) get(i);
153
- if (child == null)
154
- continue;
155
- blockloop = true;
156
- child.RestoreSupports();
157
- blockloop = false;
147
+ if (blockloop)
148
+ return;
149
+
150
+ support = transientsupport;
151
+ link2master = transientlink2master;
152
+ transientsupport = null;
153
+ transientlink2master = false;
154
+
155
+ if (bRep != null)
156
+ {
157
+ bRep.RestoreSupports();
158
+ }
159
+
160
+ for (int i = 0; i < Size(); i++)
161
+ {
162
+ Object3D child = (Object3D) get(i);
163
+ if (child == null)
164
+ continue;
165
+ blockloop = true;
166
+ child.RestoreSupports();
167
+ blockloop = false;
168
+ }
158169 }
159
-}
170
+
171
+ void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
172
+ {
173
+ if (hashtable.containsKey(GetUUID()))
174
+ {
175
+ Object3D o = hashtable.get(GetUUID());
176
+
177
+ assert(this.bRep == o.bRep);
178
+ if (this.bRep != null)
179
+ assert(this.bRep.support == o.transientrep);
180
+
181
+ return;
182
+ }
183
+
184
+ Object3D o = new Object3D();
185
+
186
+ hashtable.put(GetUUID(), o);
187
+
188
+ for (int i=0; i<Size(); i++)
189
+ {
190
+ get(i).ExtractBigData(hashtable);
191
+ }
192
+
193
+ ExtractBigData(o);
194
+ }
195
+
196
+ void ExtractBigData(Object3D o)
197
+ {
198
+ o.bRep = this.bRep;
199
+ if (this.bRep != null)
200
+ {
201
+ o.transientrep = this.bRep.support;
202
+ o.bRep.support = null;
203
+ }
204
+
205
+ // o.support = this.support;
206
+ // o.fileparent = this.fileparent;
207
+ // if (this.bRep != null)
208
+ // o.bRep = this.bRep.support;
209
+
210
+ this.bRep = null;
211
+ // if (this.bRep != null)
212
+ // this.bRep.support = null;
213
+ // this.support = null;
214
+ // this.fileparent = null;
215
+ }
216
+
217
+ void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
218
+ {
219
+ if (!hashtable.containsKey(GetUUID()))
220
+ return;
221
+
222
+ Object3D o = hashtable.get(GetUUID());
223
+
224
+ RestoreBigData(o);
225
+
226
+ hashtable.remove(GetUUID());
227
+
228
+ for (int i=0; i<Size(); i++)
229
+ {
230
+ get(i).RestoreBigData(hashtable);
231
+ }
232
+ }
233
+
234
+ void RestoreBigData(Object3D o)
235
+ {
236
+ this.bRep = o.bRep;
237
+ if (this.bRep != null)
238
+ this.bRep.support = o.transientrep;
239
+ // this.support = o.support;
240
+ // this.fileparent = o.fileparent;
241
+ }
160242
161243 // MOCAP SUPPORT
162244 double tx,ty,tz,rx,ry,rz;
....@@ -299,6 +381,7 @@
299381 }
300382
301383 boolean live = false;
384
+ boolean dontselect = false;
302385 boolean hide = false;
303386 boolean link2master = false; // performs reset support/master at each frame
304387 boolean marked = false; // animation node
....@@ -430,16 +513,16 @@
430513 {
431514 Object3D copy = this;
432515
433
- Camera parentcam = CameraPane.theRenderer.manipCamera;
516
+ Camera parentcam = Globals.theRenderer.ManipCamera();
434517
435
- if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[0])
518
+ if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[0])
436519 {
437
- parentcam = CameraPane.theRenderer.cameras[1];
520
+ parentcam = Globals.theRenderer.Cameras()[1];
438521 }
439522
440
- if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[1])
523
+ if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[1])
441524 {
442
- parentcam = CameraPane.theRenderer.cameras[0];
525
+ parentcam = Globals.theRenderer.Cameras()[0];
443526 }
444527
445528 if (this == parentcam)
....@@ -447,7 +530,7 @@
447530 //assert(this instanceof Camera);
448531
449532 for (int count = parentcam.GetTransformCount(); --count>=0;)
450
- LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.toParent, CameraPane.theRenderer.targetLookAt);
533
+ LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.toParent, Globals.theRenderer.TargetLookAt());
451534 }
452535
453536 copy.marked ^= true;
....@@ -467,7 +550,7 @@
467550 //assert(this instanceof Camera);
468551
469552 for (int count = parentcam.GetTransformCount(); --count>=0;)
470
- LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.fromParent, CameraPane.theRenderer.targetLookAt);
553
+ LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.fromParent, Globals.theRenderer.TargetLookAt());
471554 }
472555
473556 copy.Touch(); // display list issue
....@@ -602,7 +685,7 @@
602685 return;
603686 }
604687
605
- if (CameraPane.fromscript)
688
+ if (Globals.fromscript)
606689 {
607690 transformcount = 0;
608691 return;
....@@ -773,7 +856,7 @@
773856 if (step == 0)
774857 step = 1;
775858 if (maxcount == 0)
776
- maxcount = 2048; // 4;
859
+ maxcount = 128; // 2048; // 4;
777860 // if (acceleration == 0)
778861 // acceleration = 10;
779862 if (delay == 0) // serial
....@@ -796,7 +879,7 @@
796879
797880 if (marked && Globals.isLIVE() && live &&
798881 //TEMP21aug2018
799
- Globals.DrawMode() == iCameraPane.SHADOW &&
882
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
800883 currentframe != Globals.framecount)
801884 {
802885 currentframe = Globals.framecount;
....@@ -911,6 +994,11 @@
911994 fromParent = null; // LA.newMatrix();
912995 bRep = null; // new BoundaryRep();
913996
997
+ if (oname != null && oname.equals("LeftHand"))
998
+ {
999
+ name = oname;
1000
+ }
1001
+
9141002 /*
9151003 float hue = (float)Math.random();
9161004 Color col;
....@@ -953,7 +1041,7 @@
9531041
9541042 public Object clone()
9551043 {
956
- return GrafreeD.clone(this);
1044
+ return Grafreed.clone(this);
9571045 }
9581046
9591047 Object3D copyExpand()
....@@ -1469,7 +1557,7 @@
14691557 BoundaryRep.SEUIL = other.material.cameralight;
14701558
14711559 // Set default to 0.1
1472
- BoundaryRep.SEUIL /= 2;
1560
+ BoundaryRep.SEUIL /= 4; // 2;
14731561 System.out.println("SEUIL = " + BoundaryRep.SEUIL);
14741562 }
14751563
....@@ -1728,7 +1816,7 @@
17281816 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17291817 o.bRep = transientrep;
17301818 if (clone)
1731
- o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
1819
+ o.bRep = (BoundaryRep) Grafreed.clone(transientrep);
17321820 o.CreateMaterial();
17331821 o.SetAttributes(this, -1);
17341822 //parent
....@@ -1741,7 +1829,7 @@
17411829 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17421830 o.bRep = bRep;
17431831 if (clone)
1744
- o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
1832
+ o.bRep = (BoundaryRep) Grafreed.clone(bRep);
17451833 o.CreateMaterial();
17461834 //o.overwriteThis(this, -1);
17471835 o.SetAttributes(this, -1);
....@@ -1828,12 +1916,15 @@
18281916 if (obj.name == null)
18291917 continue; // can't be a null one
18301918
1919
+ // Try perfect match first.
18311920 if (n.equals(obj.name))
18321921 {
18331922 theobj = obj;
18341923 count++;
18351924 }
18361925 }
1926
+
1927
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18371928
18381929 if (count != 1)
18391930 for (int i=Size(); --i>=0;)
....@@ -2299,6 +2390,7 @@
22992390 {
23002391 if (newWindow)
23012392 {
2393
+ new Exception().printStackTrace();
23022394 System.exit(0);
23032395 if (parent != null)
23042396 {
....@@ -2475,13 +2567,13 @@
24752567 return retval;
24762568 }
24772569
2478
- void doEditDrag(ClickInfo info)
2570
+ void doEditDrag(ClickInfo info, boolean opposite)
24792571 {
24802572 switch (doSomething)
24812573 {
24822574 case 1: // '\001'
24832575 //super.
2484
- doEditDrag0(info);
2576
+ doEditDrag0(info, opposite);
24852577 break;
24862578
24872579 case 2: // '\002'
....@@ -2494,11 +2586,11 @@
24942586 {
24952587 //sel.hitSomething = childToDrag.hitSomething;
24962588 //childToDrag.doEditDrag(info);
2497
- sel.doEditDrag(info);
2589
+ sel.doEditDrag(info, opposite);
24982590 } else
24992591 {
25002592 //super.
2501
- doEditDrag0(info);
2593
+ doEditDrag0(info, opposite);
25022594 }
25032595 }
25042596 break;
....@@ -2608,6 +2700,18 @@
26082700 void GenNormalsS(boolean crease)
26092701 {
26102702 selection.GenNormals(crease);
2703
+// for (int i=0; i<selection.size(); i++)
2704
+// {
2705
+// Object3D selectee = (Object3D) selection.elementAt(i);
2706
+// selectee.GenNormals(crease);
2707
+// }
2708
+
2709
+ //Touch();
2710
+ }
2711
+
2712
+ void GenNormalsMeshS()
2713
+ {
2714
+ selection.GenNormalsMesh();
26112715 // for (int i=0; i<selection.size(); i++)
26122716 // {
26132717 // Object3D selectee = (Object3D) selection.elementAt(i);
....@@ -2748,6 +2852,24 @@
27482852 if (child == null)
27492853 continue;
27502854 child.GenNormals(crease);
2855
+// Children().release(i);
2856
+ }
2857
+ blockloop = false;
2858
+ }
2859
+
2860
+ void GenNormalsMesh()
2861
+ {
2862
+ if (blockloop)
2863
+ return;
2864
+
2865
+ blockloop = true;
2866
+ GenNormalsMesh0();
2867
+ for (int i = 0; i < Children().Size(); i++)
2868
+ {
2869
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2870
+ if (child == null)
2871
+ continue;
2872
+ child.GenNormalsMesh();
27512873 // Children().release(i);
27522874 }
27532875 blockloop = false;
....@@ -2905,7 +3027,8 @@
29053027 {
29063028 if (bRep != null)
29073029 {
2908
- bRep.GenUV();
3030
+ bRep.GenUV(); //1);
3031
+ //bRep.UnfoldUV();
29093032 Touch();
29103033 }
29113034 }
....@@ -2915,6 +3038,15 @@
29153038 if (bRep != null)
29163039 {
29173040 bRep.GenerateNormals(crease);
3041
+ Touch();
3042
+ }
3043
+ }
3044
+
3045
+ void GenNormalsMesh0()
3046
+ {
3047
+ if (bRep != null)
3048
+ {
3049
+ bRep.GenerateNormalsMesh();
29183050 Touch();
29193051 }
29203052 }
....@@ -2980,6 +3112,33 @@
29803112 blockloop = false;
29813113 }
29823114
3115
+ void TransformChildren()
3116
+ {
3117
+ if (toParent != null)
3118
+ {
3119
+ for (int i=Size(); --i>=0;)
3120
+ {
3121
+ Object3D v = get(i);
3122
+
3123
+ if (v.toParent == null)
3124
+ {
3125
+ v.toParent = LA.newMatrix();
3126
+ v.fromParent = LA.newMatrix();
3127
+ }
3128
+
3129
+// LA.matConcat(v.toParent, toParent, v.toParent);
3130
+// LA.matConcat(fromParent, v.fromParent, v.fromParent);
3131
+ LA.matConcat(toParent, v.toParent, v.toParent);
3132
+ LA.matConcat(v.fromParent, fromParent, v.fromParent);
3133
+ }
3134
+
3135
+ toParent = null; // LA.matIdentity(toParent);
3136
+ fromParent = null; // LA.matIdentity(fromParent);
3137
+
3138
+ Touch();
3139
+ }
3140
+ }
3141
+
29833142 void TransformGeometry()
29843143 {
29853144 Object3D obj = this;
....@@ -3201,9 +3360,11 @@
32013360
32023361 BoundaryRep sup = bRep.support;
32033362 bRep.support = null;
3204
- BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
3363
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
32053364 // bRep.SplitInTwo(onlyone); // thread...
3206
- temprep.SplitInTwo(reduction34, onlyone);
3365
+
3366
+ while(temprep.SplitInTwo(reduction34, onlyone));
3367
+
32073368 bRep = temprep;
32083369 bRep.support = sup;
32093370 Touch();
....@@ -3725,7 +3886,7 @@
37253886 if (child == null)
37263887 continue;
37273888
3728
- if (GrafreeD.RENDERME > 0)
3889
+ if (Grafreed.RENDERME > 0)
37293890 {
37303891 if (child instanceof Merge)
37313892 ((Merge)child).renderme();
....@@ -3876,7 +4037,7 @@
38764037 if (child == null)
38774038 continue;
38784039
3879
- if (GrafreeD.RENDERME > 0)
4040
+ if (Grafreed.RENDERME > 0)
38804041 {
38814042 if (child instanceof Merge)
38824043 ((Merge)child).renderme();
....@@ -4071,7 +4232,7 @@
40714232 if (child == null)
40724233 continue;
40734234
4074
- if (GrafreeD.RENDERME > 0)
4235
+ if (Grafreed.RENDERME > 0)
40754236 {
40764237 if (child instanceof Merge)
40774238 ((Merge)child).renderme();
....@@ -4678,7 +4839,7 @@
46784839
46794840 cTreePath SelectLeaf(int indexcount, boolean deselect)
46804841 {
4681
- if (hide)
4842
+ if (hide || dontselect)
46824843 return null;
46834844
46844845 if (count <= 0)
....@@ -4704,7 +4865,7 @@
47044865
47054866 cTreePath Select(int indexcount, boolean deselect)
47064867 {
4707
- if (hide)
4868
+ if (hide || dontselect)
47084869 return null;
47094870
47104871 if (count <= 0)
....@@ -4854,7 +5015,7 @@
48545015 return globalTransform;
48555016 }
48565017
4857
- void PreprocessOcclusion(CameraPane cp)
5018
+ void PreprocessOcclusion(iCameraPane cp)
48585019 {
48595020 /*
48605021 if (AOdone)
....@@ -5156,10 +5317,34 @@
51565317
51575318 // System.out.println("Fullname = " + fullname);
51585319
5159
- if (fullname.name.indexOf(":") == -1)
5160
- return fullname.name;
5320
+ // Does not work on Windows due to C:
5321
+// if (fullname.name.indexOf(":") == -1)
5322
+// return fullname.name;
5323
+//
5324
+// return fullname.name.substring(0,fullname.name.indexOf(":"));
51615325
5162
- return fullname.name.substring(0,fullname.name.indexOf(":"));
5326
+ String[] split = fullname.name.split(":");
5327
+
5328
+ if (split.length == 0)
5329
+ {
5330
+ return "";
5331
+ }
5332
+
5333
+ if (split.length <= 2)
5334
+ {
5335
+ if (fullname.name.endsWith(":"))
5336
+ {
5337
+ // Windows
5338
+ return fullname.name.substring(0, fullname.name.length()-1);
5339
+ }
5340
+
5341
+ return split[0];
5342
+ }
5343
+
5344
+ // Windows
5345
+ assert(split.length == 4);
5346
+
5347
+ return split[0] + ":" + split[1];
51635348 }
51645349
51655350 static String GetBump(cTexture fullname)
....@@ -5168,10 +5353,38 @@
51685353 return "";
51695354
51705355 // 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());
5356
+ // Does not work on Windows due to C:
5357
+// if (fullname.name.indexOf(":") == -1)
5358
+// return "";
5359
+//
5360
+// return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5361
+ String[] split = fullname.name.split(":");
5362
+
5363
+ if (split.length == 0)
5364
+ {
5365
+ return "";
5366
+ }
5367
+
5368
+ if (split.length == 1)
5369
+ {
5370
+ return "";
5371
+ }
5372
+
5373
+ if (split.length == 2)
5374
+ {
5375
+ if (fullname.name.endsWith(":"))
5376
+ {
5377
+ // Windows
5378
+ return "";
5379
+ }
5380
+
5381
+ return split[1];
5382
+ }
5383
+
5384
+ // Windows
5385
+ assert(split.length == 4);
5386
+
5387
+ return split[2] + ":" + split[3];
51755388 }
51765389
51775390 String GetPigmentTexture()
....@@ -5245,7 +5458,7 @@
52455458 System.out.print("; textures = " + textures);
52465459 System.out.println("; usedtextures = " + usedtextures);
52475460
5248
- if (GetTextures() == null)
5461
+ if (GetTextures() == null) // What is that??
52495462 GetTextures().name = ":";
52505463
52515464 String texname = tex;
....@@ -5276,6 +5489,43 @@
52765489 child.ResetPigmentTexture();
52775490 blockloop = false;
52785491 }
5492
+ }
5493
+
5494
+ UUID GetUUID()
5495
+ {
5496
+ if (uuid == null)
5497
+ {
5498
+ // Serial
5499
+ uuid = UUID.randomUUID();
5500
+ }
5501
+
5502
+ return uuid;
5503
+ }
5504
+
5505
+ Object3D GetObject(UUID uid)
5506
+ {
5507
+ if (blockloop)
5508
+ return null;
5509
+
5510
+ if (GetUUID().equals(uid))
5511
+ return this;
5512
+
5513
+ int nb = Size();
5514
+ for (int i = 0; i < nb; i++)
5515
+ {
5516
+ Object3D child = (Object3D) get(i);
5517
+
5518
+ if (child == null)
5519
+ continue;
5520
+
5521
+ blockloop = true;
5522
+ Object3D obj = child.GetObject(uid);
5523
+ blockloop = false;
5524
+ if (obj != null)
5525
+ return obj;
5526
+ }
5527
+
5528
+ return null;
52795529 }
52805530
52815531 void SetBumpTexture(String tex)
....@@ -5322,11 +5572,12 @@
53225572 boolean NeedSupport()
53235573 {
53245574 return
5325
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5575
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null
53265576 // PROBLEM with CROWD!!
5327
- && (Globals.DrawMode() == iCameraPane.SHADOW || Globals.CROWD);
5577
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
53285578 }
53295579
5580
+ static boolean DEBUG_SELECTION = false;
53305581
53315582 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
53325583 {
....@@ -5338,7 +5589,7 @@
53385589 }
53395590
53405591 if (display.DrawMode() == iCameraPane.SELECTION &&
5341
- hide)
5592
+ (hide || dontselect))
53425593 return;
53435594
53445595 if (name != null && name.contains("sclera"))
....@@ -5365,12 +5616,12 @@
53655616 }
53665617
53675618 if ((//display.DrawMode() == CameraPane.SHADOW ||
5368
- display.DrawMode() == CameraPane.SELECTION || CameraPane.DEBUG_SELECTION) && HasTransparency())
5619
+ display.DrawMode() == iCameraPane.SELECTION || display.IsDebugSelection()) && HasTransparency())
53695620 {
53705621 return;
53715622 }
53725623
5373
- javax.media.opengl.GL gl = display.GetGL();
5624
+ //javax.media.opengl.GL gl = display.GetGL();
53745625
53755626 /*
53765627 if (touched)
....@@ -5406,7 +5657,7 @@
54065657
54075658 boolean compiled = false;
54085659
5409
- boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION;
5660
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
54105661
54115662 if (!selectmode && //display.DrawMode() != display.SELECTION &&
54125663 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5422,7 +5673,7 @@
54225673 //if (displaylist == -1 && usecalllists)
54235674 if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
54245675 {
5425
- bRep.displaylist = gl.glGenLists(1);
5676
+ bRep.displaylist = display.GenList();
54265677 assert(bRep.displaylist != 0);
54275678 // System.err.println("glGenLists: " + bRep.displaylist + " for " + this);
54285679 //System.out.println("\tgen list " + list);
....@@ -5434,14 +5685,16 @@
54345685 if (usecalllists)
54355686 {
54365687 // System.err.println("new list " + bRep.displaylist + " for " + this);
5437
- gl.glNewList(bRep.displaylist, gl.GL_COMPILE); //_AND_EXECUTE);
5688
+ display.NewList(bRep.displaylist);
54385689 }
5690
+
54395691 CallList(display, root, selected, blocked);
5692
+
54405693 // compiled = true;
54415694 if (usecalllists)
54425695 {
54435696 // System.err.println("end list " + bRep.displaylist + " for " + this);
5444
- gl.glEndList();
5697
+ display.EndList();
54455698 }
54465699 //gl.glDrawBuffer(gl.GL_BACK);
54475700 // XXX touched = false;
....@@ -5484,12 +5737,12 @@
54845737
54855738 // frustum culling
54865739 if (CameraPane.FRUSTUM && !blocked && !IsInfinite() && GetBRep() != null // && GetBRep().VertexCount() != 1260 // default grid
5487
- && display.DrawMode() != CameraPane.SELECTION)
5740
+ && display.DrawMode() != iCameraPane.SELECTION)
54885741 {
5489
- if (display.DrawMode() == CameraPane.SHADOW)
5742
+ if (display.DrawMode() == iCameraPane.SHADOW)
54905743 {
54915744 if (!link2master // tricky to cull in shadow mode.
5492
- && GetBRep().FrustumCull(this, gl, display.LightCamera(), true))
5745
+ && GetBRep().FrustumCull(this, null, display.LightCamera(), true))
54935746 {
54945747 //System.out.print("CULLED");
54955748 culled = true;
....@@ -5497,7 +5750,7 @@
54975750 }
54985751 else
54995752 //GetBRep().getBounds(v0, v1, this);
5500
- if (GetBRep().FrustumCull(this, gl, display.RenderCamera(), false))
5753
+ if (GetBRep().FrustumCull(this, null, display.RenderCamera(), false))
55015754 culled = true;
55025755
55035756 // LA.xformPos(v0, display.renderCamera.toScreen, v0);
....@@ -5533,11 +5786,11 @@
55335786
55345787
55355788 if (!culled)
5536
- if (display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION)
5789
+ if (display.DrawMode() == display.SELECTION || display.IsDebugSelection())
55375790 {
55385791 if (GetBRep() != null)
55395792 {
5540
- CameraPane.NextIndex(this, gl);
5793
+ display.NextIndex();
55415794 // vertex color conflict : gl.glCallList(list);
55425795 DrawNode(display, root, selected);
55435796 if (this instanceof BezierPatch)
....@@ -5578,7 +5831,17 @@
55785831 tex = GetTextures();
55795832 }
55805833
5581
- display.BindTextures(tex, texres);
5834
+ boolean failed = false;
5835
+
5836
+ try
5837
+ {
5838
+ display.BindTextures(tex, texres);
5839
+ }
5840
+ catch (Exception e)
5841
+ {
5842
+ System.err.println("FAILED: " + this);
5843
+ failed = true;
5844
+ }
55825845
55835846 if (!compiled)
55845847 {
....@@ -5594,13 +5857,14 @@
55945857
55955858 // System.err.println("glCallList: " + bRep.displaylist + " for " + this);
55965859 assert(bRep.displaylist != 0);
5597
- gl.glCallList(bRep.displaylist);
5860
+ display.CallList(bRep.displaylist);
55985861 // june 2013 drawSelf(display, root, selected);
55995862 }
56005863 }
56015864 }
56025865
5603
- display.ReleaseTextures(tex);
5866
+ if (!failed)
5867
+ display.ReleaseTextures(tex);
56045868
56055869 display.PopMaterial(this, selected);
56065870 }
....@@ -5729,6 +5993,9 @@
57295993
57305994 void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57315995 {
5996
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
5997
+ return;
5998
+
57325999 if (hide)
57336000 return;
57346001 // shadow optimisation
....@@ -5854,6 +6121,9 @@
58546121 if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
58556122 return; // no shadow for transparent objects
58566123
6124
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6125
+ return;
6126
+
58576127 if (hide)
58586128 return;
58596129
....@@ -5894,9 +6164,10 @@
58946164 return;
58956165 }
58966166
6167
+ //bRep.GenUV(1/material.diffuseness);
58976168 // bRep.lock = true;
58986169
5899
- javax.media.opengl.GL gl = display.GetGL();
6170
+ //javax.media.opengl.GL gl = display.GetGL();
59006171
59016172 if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera)
59026173 {
....@@ -5913,23 +6184,7 @@
59136184
59146185 bRep.getMinMax(min, max, 100);
59156186
5916
- gl.glBegin(gl.GL_LINES);
5917
-
5918
- gl.glVertex3d(min.x, min.y, min.z);
5919
- gl.glVertex3d(min.x, min.y, max.z);
5920
- gl.glVertex3d(min.x, min.y, min.z);
5921
- gl.glVertex3d(min.x, max.y, min.z);
5922
- gl.glVertex3d(min.x, min.y, min.z);
5923
- gl.glVertex3d(max.x, min.y, min.z);
5924
-
5925
- gl.glVertex3d(max.x, max.y, max.z);
5926
- gl.glVertex3d(min.x, max.y, max.z);
5927
- gl.glVertex3d(max.x, max.y, max.z);
5928
- gl.glVertex3d(max.x, min.y, max.z);
5929
- gl.glVertex3d(max.x, max.y, max.z);
5930
- gl.glVertex3d(max.x, max.y, min.z);
5931
-
5932
- gl.glEnd();
6187
+ display.DrawBox(min, max);
59336188
59346189 return;
59356190 }
....@@ -5973,7 +6228,7 @@
59736228 {
59746229 //throw new Error();
59756230
5976
- boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION;
6231
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
59776232
59786233 int[] strips = bRep.getRawIndices();
59796234
....@@ -5983,178 +6238,14 @@
59836238 new Exception().printStackTrace();
59846239 return;
59856240 }
5986
-
5987
- // TRIANGLE STRIP ARRAY
5988
- if (bRep.trimmed)
5989
- {
5990
- float[] v = bRep.getRawVertices();
5991
- float[] n = bRep.getRawNormals();
5992
- float[] c = bRep.getRawColors();
5993
- float[] uv = bRep.getRawUVMap();
5994
-
5995
- int count2 = 0;
5996
- int count3 = 0;
5997
-
5998
- if (n.length > 0)
5999
- {
6000
- for (int i = 0; i < strips.length; i++)
6001
- {
6002
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6003
-
6004
- /*
6005
- boolean locked = false;
6006
- float eps = 0.1f;
6007
- boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
6008
-
6009
- int dot = 0;
6010
-
6011
- if ((dot&1) == 0)
6012
- dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
6013
-
6014
- if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
6015
- gl.glTexCoord2f((float) qv.s, (float) qv.t);
6016
- else
6017
- {
6018
- locked = true;
6019
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6020
- }
6021
- //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6022
- gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
6023
- if (hasnorm)
6024
- {
6025
- //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6026
- gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
6027
- }
6028
-
6029
- if ((dot&4) == 0)
6030
- dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
6031
-
6032
- if (wrap || !locked && (dot&8) != 0)
6033
- gl.glTexCoord2f((float) rv.s, (float) rv.t);
6034
- else
6035
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6036
-
6037
- f.dot = dot;
6038
- */
6039
-
6040
- if (!selectmode)
6041
- {
6042
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6043
- {
6044
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6045
- } else
6046
- {
6047
- gl.glNormal3f(0, 0, 1);
6048
- }
6049
-
6050
- if (c != null)
6051
- //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]);
6052
- {
6053
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6054
- }
6055
- }
6056
- if (flipV)
6057
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6058
- else
6059
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6060
- //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6061
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6062
-
6063
- count2 += 2;
6064
- count3 += 3;
6065
- if (!selectmode)
6066
- {
6067
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6068
- {
6069
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6070
- } else
6071
- {
6072
- gl.glNormal3f(0, 0, 1);
6073
- }
6074
- if (c != null)
6075
- {
6076
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6077
- }
6078
- }
6079
- if (flipV)
6080
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6081
- else
6082
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6083
- //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6084
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6085
-
6086
- count2 += 2;
6087
- count3 += 3;
6088
- for (int j = 0; j < strips[i] - 2; j++)
6089
- {
6090
- //gl.glTexCoord2d(...);
6091
- if (!selectmode)
6092
- {
6093
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6094
- {
6095
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6096
- } else
6097
- {
6098
- gl.glNormal3f(0, 0, 1);
6099
- }
6100
- if (c != null)
6101
- {
6102
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6103
- }
6104
- }
6105
-
6106
- if (flipV)
6107
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6108
- else
6109
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6110
- //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
6111
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6112
- count2 += 2;
6113
- count3 += 3;
6114
- }
6115
-
6116
- gl.glEnd();
6117
- }
6118
- }
6119
-
6120
- assert count3 == v.length;
6121
- }
6122
- else // !trimmed
6123
- {
6124
- int count = 0;
6125
- for (int i = 0; i < strips.length; i++)
6126
- {
6127
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6128
-
6129
- Vertex p = bRep.GetVertex(bRep.indices[count++]);
6130
- Vertex q = bRep.GetVertex(bRep.indices[count++]);
6131
-
6132
- drawVertex(gl, p, selectmode);
6133
- drawVertex(gl, q, selectmode);
6134
-
6135
- for (int j = 0; j < strips[i] - 2; j++)
6136
- {
6137
- Vertex r = bRep.GetVertex(bRep.indices[count++]);
6138
-
6139
-// if (j%2 == 0)
6140
-// drawFace(p, q, r, display, null);
6141
-// else
6142
-// drawFace(p, r, q, display, null);
6143
-
6144
-// p = q;
6145
-// q = r;
6146
- drawVertex(gl, r, selectmode);
6147
- }
6148
-
6149
- gl.glEnd();
6150
- }
6151
- }
6241
+
6242
+ display.DrawGeometry(bRep, flipV, selectmode);
61526243 } else // catch (Error e)
61536244 {
61546245 // TRIANGLE ARRAY
61556246 if (IsOpaque()) // Static())
61566247 {
6157
- gl.glBegin(gl.GL_TRIANGLES);
6248
+ display.StartTriangles();
61586249 int facecount = bRep.FaceCount();
61596250 for (int i = 0; i < facecount; i++)
61606251 {
....@@ -6219,7 +6310,7 @@
62196310
62206311 display.DrawFace(this, p, q, r, face);
62216312 }
6222
- gl.glEnd();
6313
+ display.EndTriangles();
62236314 }
62246315 else
62256316 {
....@@ -6248,8 +6339,8 @@
62486339 //System.out.println("SORT");
62496340
62506341 java.util.Arrays.sort(facescompare);
6251
-
6252
- gl.glBegin(gl.GL_TRIANGLES);
6342
+
6343
+ display.StartTriangles();
62536344 for (int i = 0; i < facecount; i++)
62546345 {
62556346 Face face = bRep.GetFace(facescompare[i].index);
....@@ -6263,11 +6354,12 @@
62636354
62646355 display.DrawFace(this, p, q, r, face);
62656356 }
6266
- gl.glEnd();
6357
+ display.EndTriangles();
62676358 }
62686359
62696360 if (false) // live && support != null && support.bRep != null) // debug weights
62706361 {
6362
+ /*
62716363 gl.glDisable(gl.GL_LIGHTING);
62726364 float[] colorV = new float[3];
62736365
....@@ -6346,6 +6438,7 @@
63466438 // gl.glEnd();
63476439 }
63486440 }
6441
+ */
63496442 }
63506443 }
63516444
....@@ -6390,7 +6483,7 @@
63906483 center.add(r);
63916484 center.mul(1.0/3);
63926485
6393
- center.sub(CameraPane.theRenderer.eyeCamera.location);
6486
+ center.sub(Globals.theRenderer.EyeCamera().location);
63946487
63956488 distance = center.dot(center);
63966489 }
....@@ -6404,22 +6497,6 @@
64046497 void Print(Vertex v)
64056498 {
64066499 //System.err.println("(" + v.x + ", " + v.y + ", " + v.z + ")");
6407
- }
6408
-
6409
- void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean selectmode)
6410
- {
6411
- if (!selectmode)
6412
- {
6413
- gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
6414
- gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
6415
-
6416
- if (flipV)
6417
- gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
6418
- else
6419
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6420
- }
6421
-
6422
- gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
64236500 }
64246501
64256502 void drawSelf(ClickInfo info, int level, boolean select)
....@@ -6993,83 +7070,83 @@
69937070 int spotw = spot.x + spot.width;
69947071 int spoth = spot.y + spot.height;
69957072 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
6996
- if (CameraPane.Xmin > spot.x)
6997
- {
6998
- CameraPane.Xmin = spot.x;
6999
- }
7000
- if (CameraPane.Xmax < spotw)
7001
- {
7002
- CameraPane.Xmax = spotw;
7003
- }
7004
- if (CameraPane.Ymin > spot.y)
7005
- {
7006
- CameraPane.Ymin = spot.y;
7007
- }
7008
- if (CameraPane.Ymax < spoth)
7009
- {
7010
- CameraPane.Ymax = spoth;
7011
- }
7073
+// if (CameraPane.Xmin > spot.x)
7074
+// {
7075
+// CameraPane.Xmin = spot.x;
7076
+// }
7077
+// if (CameraPane.Xmax < spotw)
7078
+// {
7079
+// CameraPane.Xmax = spotw;
7080
+// }
7081
+// if (CameraPane.Ymin > spot.y)
7082
+// {
7083
+// CameraPane.Ymin = spot.y;
7084
+// }
7085
+// if (CameraPane.Ymax < spoth)
7086
+// {
7087
+// CameraPane.Ymax = spoth;
7088
+// }
70127089 spot.translate(32, 32);
70137090 spotw = spot.x + spot.width;
70147091 spoth = spot.y + spot.height;
70157092 info.g.setColor(Color.blue);
70167093 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7017
- if (CameraPane.Xmin > spot.x)
7018
- {
7019
- CameraPane.Xmin = spot.x;
7020
- }
7021
- if (CameraPane.Xmax < spotw)
7022
- {
7023
- CameraPane.Xmax = spotw;
7024
- }
7025
- if (CameraPane.Ymin > spot.y)
7026
- {
7027
- CameraPane.Ymin = spot.y;
7028
- }
7029
- if (CameraPane.Ymax < spoth)
7030
- {
7031
- CameraPane.Ymax = spoth;
7032
- }
7033
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7034
- info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7094
+// if (CameraPane.Xmin > spot.x)
7095
+// {
7096
+// CameraPane.Xmin = spot.x;
7097
+// }
7098
+// if (CameraPane.Xmax < spotw)
7099
+// {
7100
+// CameraPane.Xmax = spotw;
7101
+// }
7102
+// if (CameraPane.Ymin > spot.y)
7103
+// {
7104
+// CameraPane.Ymin = spot.y;
7105
+// }
7106
+// if (CameraPane.Ymax < spoth)
7107
+// {
7108
+// CameraPane.Ymax = spoth;
7109
+// }
7110
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7111
+ //info.g.drawLine(spotw, spoth, spotw - 15, spoth);
70357112 spot.translate(0, -32);
70367113 info.g.setColor(Color.green);
70377114 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7038
- if (CameraPane.Xmin > spot.x)
7039
- {
7040
- CameraPane.Xmin = spot.x;
7041
- }
7042
- if (CameraPane.Xmax < spotw)
7043
- {
7044
- CameraPane.Xmax = spotw;
7045
- }
7046
- if (CameraPane.Ymin > spot.y)
7047
- {
7048
- CameraPane.Ymin = spot.y;
7049
- }
7050
- if (CameraPane.Ymax < spoth)
7051
- {
7052
- CameraPane.Ymax = spoth;
7053
- }
7115
+// if (CameraPane.Xmin > spot.x)
7116
+// {
7117
+// CameraPane.Xmin = spot.x;
7118
+// }
7119
+// if (CameraPane.Xmax < spotw)
7120
+// {
7121
+// CameraPane.Xmax = spotw;
7122
+// }
7123
+// if (CameraPane.Ymin > spot.y)
7124
+// {
7125
+// CameraPane.Ymin = spot.y;
7126
+// }
7127
+// if (CameraPane.Ymax < spoth)
7128
+// {
7129
+// CameraPane.Ymax = spoth;
7130
+// }
70547131 info.g.drawArc(boundary.x, boundary.y,
70557132 boundary.width, boundary.height, 0, 360);
70567133 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
7057
- if (CameraPane.Xmin > boundary.x)
7058
- {
7059
- CameraPane.Xmin = boundary.x;
7060
- }
7061
- if (CameraPane.Xmax < boundary.x + boundary.width)
7062
- {
7063
- CameraPane.Xmax = boundary.x + boundary.width;
7064
- }
7065
- if (CameraPane.Ymin > boundary.y)
7066
- {
7067
- CameraPane.Ymin = boundary.y;
7068
- }
7069
- if (CameraPane.Ymax < boundary.y + boundary.height)
7070
- {
7071
- CameraPane.Ymax = boundary.y + boundary.height;
7072
- }
7134
+// if (CameraPane.Xmin > boundary.x)
7135
+// {
7136
+// CameraPane.Xmin = boundary.x;
7137
+// }
7138
+// if (CameraPane.Xmax < boundary.x + boundary.width)
7139
+// {
7140
+// CameraPane.Xmax = boundary.x + boundary.width;
7141
+// }
7142
+// if (CameraPane.Ymin > boundary.y)
7143
+// {
7144
+// CameraPane.Ymin = boundary.y;
7145
+// }
7146
+// if (CameraPane.Ymax < boundary.y + boundary.height)
7147
+// {
7148
+// CameraPane.Ymax = boundary.y + boundary.height;
7149
+// }
70737150 return;
70747151 }
70757152 }
....@@ -7086,7 +7163,7 @@
70867163 startX = info.x;
70877164 startY = info.y;
70887165
7089
- hitSomething = 0;
7166
+ hitSomething = -1;
70907167 cVector origin = new cVector();
70917168 //LA.xformPos(origin, toParent, origin);
70927169 Rectangle spot = new Rectangle();
....@@ -7119,7 +7196,7 @@
71197196 }
71207197
71217198 //System.out.println("info.modifiers = " + info.modifiers);
7122
- modified = (info.modifiers & CameraPane.META) != 0;
7199
+ modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
71237200 //System.out.println("modified = " + modified);
71247201 //new Exception().printStackTrace();
71257202 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7147,7 +7224,7 @@
71477224 return true;
71487225 }
71497226
7150
- void doEditDrag0(ClickInfo info)
7227
+ void doEditDrag0(ClickInfo info, boolean opposite)
71517228 {
71527229 if (hitSomething == 0)
71537230 {
....@@ -7162,6 +7239,7 @@
71627239 //System.out.println("hitSomething = " + hitSomething);
71637240
71647241 double scale = 0.005f * info.camera.Distance();
7242
+
71657243 cVector xlate = new cVector();
71667244 //cVector xlate2 = new cVector();
71677245 switch (hitSomething)
....@@ -7172,9 +7250,9 @@
71727250
71737251 case hitCenter: // Translate
71747252
7175
- scale *= 0.05f * info.pane.theRenderer.renderCamera.Distance();
7253
+ scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
71767254
7177
- if (modified)
7255
+ if (modified || opposite)
71787256 {
71797257 //assert(false);
71807258 /*
....@@ -7220,10 +7298,10 @@
72207298 }
72217299 LA.xformDir(up, ClickInfo.matbuffer, up);
72227300 // if (!CameraPane.LOCALTRANSFORM)
7223
- LA.xformDir(up, info.pane.theRenderer.renderCamera.toScreen, up);
7301
+ LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
72247302 LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
72257303 // if (!CameraPane.LOCALTRANSFORM)
7226
- LA.xformDir(away, info.pane.theRenderer.renderCamera.toScreen, away);
7304
+ LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
72277305 //LA.vecCross(up, cVector.Z, right2);
72287306
72297307 cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
....@@ -7268,6 +7346,7 @@
72687346
72697347 if (modified)
72707348 {
7349
+ // Rotate 90 degrees
72717350 angle /= (Math.PI / 4);
72727351 angle = Math.floor(angle + 0.5);
72737352 angle *= (Math.PI / 4);
....@@ -7281,7 +7360,7 @@
72817360 }
72827361 /**/
72837362
7284
- switch (info.pane.renderCamera.viewCode)
7363
+ switch (info.pane.RenderCamera().viewCode)
72857364 {
72867365 case 1: // '\001'
72877366 LA.matZRotate(toParent, angle);
....@@ -7309,24 +7388,27 @@
73097388
73107389 case hitScale: // scale
73117390 double hScale = (double) (info.x - centerPt.x) / 32;
7391
+ double sign = 1;
7392
+ if (hScale < 0)
7393
+ {
7394
+ sign = -1;
7395
+ }
7396
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
73127397 if (hScale < 0.01)
73137398 {
7314
- hScale = 0.01;
7399
+ //hScale = 0.01;
73157400 }
7316
- hScale = Math.pow(hScale, scale * 50);
7317
- if (hScale < 0.01)
7318
- {
7319
- hScale = 0.01;
7320
- }
7401
+
73217402 double vScale = (double) (info.y - centerPt.y) / 32;
7322
- if (vScale < 0.01)
7403
+ sign = 1;
7404
+ if (vScale < 0)
73237405 {
7324
- vScale = 0.01;
7406
+ sign = -1;
73257407 }
7326
- vScale = Math.pow(vScale, scale * 50);
7408
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
73277409 if (vScale < 0.01)
73287410 {
7329
- vScale = 0.01;
7411
+ //vScale = 0.01;
73307412 }
73317413 LA.matCopy(startMat, toParent);
73327414 /**/
....@@ -7337,17 +7419,24 @@
73377419 }
73387420 /**/
73397421
7340
- switch (info.pane.renderCamera.viewCode)
7422
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7423
+
7424
+ if (totalScale < 0.01)
7425
+ {
7426
+ totalScale = 0.01;
7427
+ }
7428
+
7429
+ switch (info.pane.RenderCamera().viewCode)
73417430 {
73427431 case 3: // '\001'
73437432 if (modified)
73447433 {
73457434 //LA.matScale(toParent, 1, hScale, vScale);
7346
- LA.matScale(toParent, vScale, 1, 1);
7435
+ LA.matScale(toParent, totalScale, 1, 1);
73477436 } // vScale, 1);
73487437 else
73497438 {
7350
- LA.matScale(toParent, vScale, vScale, vScale);
7439
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
73517440 } // vScale, 1);
73527441 break;
73537442
....@@ -7355,10 +7444,10 @@
73557444 if (modified)
73567445 {
73577446 //LA.matScale(toParent, hScale, 1, vScale);
7358
- LA.matScale(toParent, 1, vScale, 1);
7447
+ LA.matScale(toParent, 1, totalScale, 1);
73597448 } else
73607449 {
7361
- LA.matScale(toParent, vScale, 1, vScale);
7450
+ LA.matScale(toParent, totalScale, 1, totalScale);
73627451 }
73637452 break;
73647453
....@@ -7366,10 +7455,10 @@
73667455 if (modified)
73677456 {
73687457 //LA.matScale(toParent, hScale, vScale, 1);
7369
- LA.matScale(toParent, 1, 1, vScale);
7458
+ LA.matScale(toParent, 1, 1, totalScale);
73707459 } else
73717460 {
7372
- LA.matScale(toParent, vScale, vScale, 1);
7461
+ LA.matScale(toParent, totalScale, totalScale, 1);
73737462 }
73747463 break;
73757464 }
....@@ -7502,14 +7591,22 @@
75027591 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
75037592 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
75047593 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7594
+
7595
+ String objname;
7596
+
75057597 if (false) //parent != null)
75067598 {
7507
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7599
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
75087600 } else
75097601 {
7510
- return GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ") ")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ +System.identityHashCode(this);
7602
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
75117603 } // + super.toString();
75127604 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
7605
+
7606
+ if (!Globals.ADVANCED)
7607
+ return objname;
7608
+
7609
+ return objname + " " + System.identityHashCode(this);
75137610 }
75147611
75157612 public int hashCode()
....@@ -7565,6 +7662,7 @@
75657662 objectUI.closeUI();
75667663 if (editWindow != null)
75677664 {
7665
+ editWindow.ctrlPanel.FlushUI();
75687666 editWindow.refreshContents();
75697667 } // ? new
75707668 objectUI = null;
....@@ -7585,7 +7683,7 @@
75857683 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
75867684
75877685 Object3D /*Composite*/ parent;
7588
- Object3D /*Composite*/ fileparent;
7686
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
75897687
75907688 double[][] toParent; // dynamic matrix
75917689 double[][] fromParent;
....@@ -7700,7 +7798,7 @@
77007798 {
77017799 assert(bRep != null);
77027800 if (!(support instanceof GenericJoint)) // support.bRep != null)
7703
- GrafreeD.Assert(support.bRep == bRep.support);
7801
+ Grafreed.Assert(support.bRep == bRep.support);
77047802 }
77057803 else
77067804 {
....@@ -7749,9 +7847,9 @@
77497847 private static cVector edge2 = new cVector();
77507848 //private static cVector norm = new cVector();
77517849 /*transient private*/ int hitSomething;
7752
- private static final int hitCenter = 1;
7753
- private static final int hitScale = 2;
7754
- private static final int hitRotate = 3;
7850
+ static final int hitCenter = 1;
7851
+ static final int hitScale = 2;
7852
+ static final int hitRotate = 3;
77557853 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
77567854 /*transient*/ private Point centerPt;
77577855 /*transient*/ private int startX;