Normand Briere
2019-06-17 e36047725ce3217618d4e5807ac7c8769b9e3598
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
+ Grafreed.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
....@@ -480,12 +563,14 @@
480563 toParent = LA.newMatrix();
481564 fromParent = LA.newMatrix();
482565 }
566
+
483567 if (toParentMarked == null)
484568 {
485569 if (maxcount != 1)
486570 {
487571 new Exception().printStackTrace();
488572 }
573
+
489574 toParentMarked = LA.newMatrix();
490575 fromParentMarked = LA.newMatrix();
491576 }
....@@ -602,7 +687,7 @@
602687 return;
603688 }
604689
605
- if (CameraPane.fromscript)
690
+ if (Globals.fromscript)
606691 {
607692 transformcount = 0;
608693 return;
....@@ -773,7 +858,7 @@
773858 if (step == 0)
774859 step = 1;
775860 if (maxcount == 0)
776
- maxcount = 2048; // 4;
861
+ maxcount = 128; // 2048; // 4;
777862 // if (acceleration == 0)
778863 // acceleration = 10;
779864 if (delay == 0) // serial
....@@ -796,7 +881,7 @@
796881
797882 if (marked && Globals.isLIVE() && live &&
798883 //TEMP21aug2018
799
- Globals.DrawMode() == iCameraPane.SHADOW &&
884
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
800885 currentframe != Globals.framecount)
801886 {
802887 currentframe = Globals.framecount;
....@@ -911,6 +996,11 @@
911996 fromParent = null; // LA.newMatrix();
912997 bRep = null; // new BoundaryRep();
913998
999
+ if (oname != null && oname.equals("LeftHand"))
1000
+ {
1001
+ name = oname;
1002
+ }
1003
+
9141004 /*
9151005 float hue = (float)Math.random();
9161006 Color col;
....@@ -953,7 +1043,7 @@
9531043
9541044 public Object clone()
9551045 {
956
- return GrafreeD.clone(this);
1046
+ return Grafreed.clone(this);
9571047 }
9581048
9591049 Object3D copyExpand()
....@@ -1469,7 +1559,7 @@
14691559 BoundaryRep.SEUIL = other.material.cameralight;
14701560
14711561 // Set default to 0.1
1472
- BoundaryRep.SEUIL /= 2;
1562
+ BoundaryRep.SEUIL /= 4; // 2;
14731563 System.out.println("SEUIL = " + BoundaryRep.SEUIL);
14741564 }
14751565
....@@ -1728,7 +1818,7 @@
17281818 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17291819 o.bRep = transientrep;
17301820 if (clone)
1731
- o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
1821
+ o.bRep = (BoundaryRep) Grafreed.clone(transientrep);
17321822 o.CreateMaterial();
17331823 o.SetAttributes(this, -1);
17341824 //parent
....@@ -1741,7 +1831,7 @@
17411831 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17421832 o.bRep = bRep;
17431833 if (clone)
1744
- o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
1834
+ o.bRep = (BoundaryRep) Grafreed.clone(bRep);
17451835 o.CreateMaterial();
17461836 //o.overwriteThis(this, -1);
17471837 o.SetAttributes(this, -1);
....@@ -1828,12 +1918,15 @@
18281918 if (obj.name == null)
18291919 continue; // can't be a null one
18301920
1921
+ // Try perfect match first.
18311922 if (n.equals(obj.name))
18321923 {
18331924 theobj = obj;
18341925 count++;
18351926 }
18361927 }
1928
+
1929
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18371930
18381931 if (count != 1)
18391932 for (int i=Size(); --i>=0;)
....@@ -2299,6 +2392,7 @@
22992392 {
23002393 if (newWindow)
23012394 {
2395
+ new Exception().printStackTrace();
23022396 System.exit(0);
23032397 if (parent != null)
23042398 {
....@@ -2475,13 +2569,13 @@
24752569 return retval;
24762570 }
24772571
2478
- void doEditDrag(ClickInfo info)
2572
+ void doEditDrag(ClickInfo info, boolean opposite)
24792573 {
24802574 switch (doSomething)
24812575 {
24822576 case 1: // '\001'
24832577 //super.
2484
- doEditDrag0(info);
2578
+ doEditDrag0(info, opposite);
24852579 break;
24862580
24872581 case 2: // '\002'
....@@ -2494,11 +2588,11 @@
24942588 {
24952589 //sel.hitSomething = childToDrag.hitSomething;
24962590 //childToDrag.doEditDrag(info);
2497
- sel.doEditDrag(info);
2591
+ sel.doEditDrag(info, opposite);
24982592 } else
24992593 {
25002594 //super.
2501
- doEditDrag0(info);
2595
+ doEditDrag0(info, opposite);
25022596 }
25032597 }
25042598 break;
....@@ -2608,6 +2702,18 @@
26082702 void GenNormalsS(boolean crease)
26092703 {
26102704 selection.GenNormals(crease);
2705
+// for (int i=0; i<selection.size(); i++)
2706
+// {
2707
+// Object3D selectee = (Object3D) selection.elementAt(i);
2708
+// selectee.GenNormals(crease);
2709
+// }
2710
+
2711
+ //Touch();
2712
+ }
2713
+
2714
+ void GenNormalsMeshS()
2715
+ {
2716
+ selection.GenNormalsMesh();
26112717 // for (int i=0; i<selection.size(); i++)
26122718 // {
26132719 // Object3D selectee = (Object3D) selection.elementAt(i);
....@@ -2748,6 +2854,24 @@
27482854 if (child == null)
27492855 continue;
27502856 child.GenNormals(crease);
2857
+// Children().release(i);
2858
+ }
2859
+ blockloop = false;
2860
+ }
2861
+
2862
+ void GenNormalsMesh()
2863
+ {
2864
+ if (blockloop)
2865
+ return;
2866
+
2867
+ blockloop = true;
2868
+ GenNormalsMesh0();
2869
+ for (int i = 0; i < Children().Size(); i++)
2870
+ {
2871
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2872
+ if (child == null)
2873
+ continue;
2874
+ child.GenNormalsMesh();
27512875 // Children().release(i);
27522876 }
27532877 blockloop = false;
....@@ -2905,7 +3029,8 @@
29053029 {
29063030 if (bRep != null)
29073031 {
2908
- bRep.GenUV();
3032
+ bRep.GenUV(); //1);
3033
+ //bRep.UnfoldUV();
29093034 Touch();
29103035 }
29113036 }
....@@ -2915,6 +3040,15 @@
29153040 if (bRep != null)
29163041 {
29173042 bRep.GenerateNormals(crease);
3043
+ Touch();
3044
+ }
3045
+ }
3046
+
3047
+ void GenNormalsMesh0()
3048
+ {
3049
+ if (bRep != null)
3050
+ {
3051
+ bRep.GenerateNormalsMesh();
29183052 Touch();
29193053 }
29203054 }
....@@ -2980,6 +3114,33 @@
29803114 blockloop = false;
29813115 }
29823116
3117
+ void TransformChildren()
3118
+ {
3119
+ if (toParent != null)
3120
+ {
3121
+ for (int i=Size(); --i>=0;)
3122
+ {
3123
+ Object3D v = get(i);
3124
+
3125
+ if (v.toParent == null)
3126
+ {
3127
+ v.toParent = LA.newMatrix();
3128
+ v.fromParent = LA.newMatrix();
3129
+ }
3130
+
3131
+// LA.matConcat(v.toParent, toParent, v.toParent);
3132
+// LA.matConcat(fromParent, v.fromParent, v.fromParent);
3133
+ LA.matConcat(toParent, v.toParent, v.toParent);
3134
+ LA.matConcat(v.fromParent, fromParent, v.fromParent);
3135
+ }
3136
+
3137
+ toParent = null; // LA.matIdentity(toParent);
3138
+ fromParent = null; // LA.matIdentity(fromParent);
3139
+
3140
+ Touch();
3141
+ }
3142
+ }
3143
+
29833144 void TransformGeometry()
29843145 {
29853146 Object3D obj = this;
....@@ -3201,9 +3362,11 @@
32013362
32023363 BoundaryRep sup = bRep.support;
32033364 bRep.support = null;
3204
- BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
3365
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
32053366 // bRep.SplitInTwo(onlyone); // thread...
3206
- temprep.SplitInTwo(reduction34, onlyone);
3367
+
3368
+ while(temprep.SplitInTwo(reduction34, onlyone));
3369
+
32073370 bRep = temprep;
32083371 bRep.support = sup;
32093372 Touch();
....@@ -3725,7 +3888,7 @@
37253888 if (child == null)
37263889 continue;
37273890
3728
- if (GrafreeD.RENDERME > 0)
3891
+ if (Grafreed.RENDERME > 0)
37293892 {
37303893 if (child instanceof Merge)
37313894 ((Merge)child).renderme();
....@@ -3876,7 +4039,7 @@
38764039 if (child == null)
38774040 continue;
38784041
3879
- if (GrafreeD.RENDERME > 0)
4042
+ if (Grafreed.RENDERME > 0)
38804043 {
38814044 if (child instanceof Merge)
38824045 ((Merge)child).renderme();
....@@ -4071,7 +4234,7 @@
40714234 if (child == null)
40724235 continue;
40734236
4074
- if (GrafreeD.RENDERME > 0)
4237
+ if (Grafreed.RENDERME > 0)
40754238 {
40764239 if (child instanceof Merge)
40774240 ((Merge)child).renderme();
....@@ -4184,6 +4347,55 @@
41844347 {
41854348 blockloop = true;
41864349 get(i).RepairShadow();
4350
+ blockloop = false;
4351
+ }
4352
+ }
4353
+
4354
+ void RepairSOV()
4355
+ {
4356
+ if (blockloop)
4357
+ return;
4358
+
4359
+ String texname = this.GetPigmentTexture();
4360
+
4361
+ if (texname.startsWith("sov"))
4362
+ {
4363
+ String[] s = texname.split("/");
4364
+
4365
+ String[] sname = s[1].split("Color.pn");
4366
+
4367
+ texname = sname[0];
4368
+
4369
+ if (sname.length > 1)
4370
+ {
4371
+ texname += "Color.jpg";
4372
+ }
4373
+
4374
+ this.SetPigmentTexture("sov/" + texname);
4375
+ }
4376
+
4377
+ texname = this.GetBumpTexture();
4378
+
4379
+ if (texname.startsWith("sov"))
4380
+ {
4381
+ String[] s = texname.split("/");
4382
+
4383
+ String[] sname = s[1].split("Bump.pn");
4384
+
4385
+ texname = sname[0];
4386
+
4387
+ if (sname.length > 1)
4388
+ {
4389
+ texname += "Bump.jpg";
4390
+ }
4391
+
4392
+ this.SetBumpTexture("sov/" + texname);
4393
+ }
4394
+
4395
+ for (int i=0; i<Size(); i++)
4396
+ {
4397
+ blockloop = true;
4398
+ get(i).RepairSOV();
41874399 blockloop = false;
41884400 }
41894401 }
....@@ -4678,7 +4890,7 @@
46784890
46794891 cTreePath SelectLeaf(int indexcount, boolean deselect)
46804892 {
4681
- if (hide)
4893
+ if (hide || dontselect)
46824894 return null;
46834895
46844896 if (count <= 0)
....@@ -4704,7 +4916,7 @@
47044916
47054917 cTreePath Select(int indexcount, boolean deselect)
47064918 {
4707
- if (hide)
4919
+ if (hide || dontselect)
47084920 return null;
47094921
47104922 if (count <= 0)
....@@ -4854,7 +5066,7 @@
48545066 return globalTransform;
48555067 }
48565068
4857
- void PreprocessOcclusion(CameraPane cp)
5069
+ void PreprocessOcclusion(iCameraPane cp)
48585070 {
48595071 /*
48605072 if (AOdone)
....@@ -5156,10 +5368,34 @@
51565368
51575369 // System.out.println("Fullname = " + fullname);
51585370
5159
- if (fullname.name.indexOf(":") == -1)
5160
- return fullname.name;
5371
+ // Does not work on Windows due to C:
5372
+// if (fullname.name.indexOf(":") == -1)
5373
+// return fullname.name;
5374
+//
5375
+// return fullname.name.substring(0,fullname.name.indexOf(":"));
51615376
5162
- return fullname.name.substring(0,fullname.name.indexOf(":"));
5377
+ String[] split = fullname.name.split(":");
5378
+
5379
+ if (split.length == 0)
5380
+ {
5381
+ return "";
5382
+ }
5383
+
5384
+ if (split.length <= 2)
5385
+ {
5386
+ if (fullname.name.endsWith(":"))
5387
+ {
5388
+ // Windows
5389
+ return fullname.name.substring(0, fullname.name.length()-1);
5390
+ }
5391
+
5392
+ return split[0];
5393
+ }
5394
+
5395
+ // Windows
5396
+ assert(split.length == 4);
5397
+
5398
+ return split[0] + ":" + split[1];
51635399 }
51645400
51655401 static String GetBump(cTexture fullname)
....@@ -5168,10 +5404,38 @@
51685404 return "";
51695405
51705406 // 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());
5407
+ // Does not work on Windows due to C:
5408
+// if (fullname.name.indexOf(":") == -1)
5409
+// return "";
5410
+//
5411
+// return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5412
+ String[] split = fullname.name.split(":");
5413
+
5414
+ if (split.length == 0)
5415
+ {
5416
+ return "";
5417
+ }
5418
+
5419
+ if (split.length == 1)
5420
+ {
5421
+ return "";
5422
+ }
5423
+
5424
+ if (split.length == 2)
5425
+ {
5426
+ if (fullname.name.endsWith(":"))
5427
+ {
5428
+ // Windows
5429
+ return "";
5430
+ }
5431
+
5432
+ return split[1];
5433
+ }
5434
+
5435
+ // Windows
5436
+ assert(split.length == 4);
5437
+
5438
+ return split[2] + ":" + split[3];
51755439 }
51765440
51775441 String GetPigmentTexture()
....@@ -5245,7 +5509,7 @@
52455509 System.out.print("; textures = " + textures);
52465510 System.out.println("; usedtextures = " + usedtextures);
52475511
5248
- if (GetTextures() == null)
5512
+ if (GetTextures() == null) // What is that??
52495513 GetTextures().name = ":";
52505514
52515515 String texname = tex;
....@@ -5276,6 +5540,43 @@
52765540 child.ResetPigmentTexture();
52775541 blockloop = false;
52785542 }
5543
+ }
5544
+
5545
+ UUID GetUUID()
5546
+ {
5547
+ if (uuid == null)
5548
+ {
5549
+ // Serial
5550
+ uuid = UUID.randomUUID();
5551
+ }
5552
+
5553
+ return uuid;
5554
+ }
5555
+
5556
+ Object3D GetObject(UUID uid)
5557
+ {
5558
+ if (blockloop)
5559
+ return null;
5560
+
5561
+ if (GetUUID().equals(uid))
5562
+ return this;
5563
+
5564
+ int nb = Size();
5565
+ for (int i = 0; i < nb; i++)
5566
+ {
5567
+ Object3D child = (Object3D) get(i);
5568
+
5569
+ if (child == null)
5570
+ continue;
5571
+
5572
+ blockloop = true;
5573
+ Object3D obj = child.GetObject(uid);
5574
+ blockloop = false;
5575
+ if (obj != null)
5576
+ return obj;
5577
+ }
5578
+
5579
+ return null;
52795580 }
52805581
52815582 void SetBumpTexture(String tex)
....@@ -5322,11 +5623,23 @@
53225623 boolean NeedSupport()
53235624 {
53245625 return
5325
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5626
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
53265627 // PROBLEM with CROWD!!
5327
- && (Globals.DrawMode() == iCameraPane.SHADOW || Globals.CROWD);
5628
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
53285629 }
53295630
5631
+ static boolean DEBUG_SELECTION = false;
5632
+
5633
+ boolean IsLive()
5634
+ {
5635
+ if (live)
5636
+ return true;
5637
+
5638
+ if (parent == null)
5639
+ return false;
5640
+
5641
+ return parent.IsLive();
5642
+ }
53305643
53315644 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
53325645 {
....@@ -5338,7 +5651,7 @@
53385651 }
53395652
53405653 if (display.DrawMode() == iCameraPane.SELECTION &&
5341
- hide)
5654
+ (hide || dontselect))
53425655 return;
53435656
53445657 if (name != null && name.contains("sclera"))
....@@ -5365,12 +5678,12 @@
53655678 }
53665679
53675680 if ((//display.DrawMode() == CameraPane.SHADOW ||
5368
- display.DrawMode() == CameraPane.SELECTION || CameraPane.DEBUG_SELECTION) && HasTransparency())
5681
+ display.DrawMode() == iCameraPane.SELECTION || display.IsDebugSelection()) && HasTransparency())
53695682 {
53705683 return;
53715684 }
53725685
5373
- javax.media.opengl.GL gl = display.GetGL();
5686
+ //javax.media.opengl.GL gl = display.GetGL();
53745687
53755688 /*
53765689 if (touched)
....@@ -5389,7 +5702,7 @@
53895702 support = support;
53905703
53915704 //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5392
- boolean usecalllists = false; // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5705
+ boolean usecalllists = IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
53935706
53945707 if (!usecalllists && bRep != null && bRep.displaylist > 0)
53955708 {
....@@ -5406,13 +5719,15 @@
54065719
54075720 boolean compiled = false;
54085721
5409
- boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION;
5722
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
54105723
54115724 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5412
- (touched || (bRep != null && bRep.displaylist <= 0)))
5725
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5726
+ (Globals.isLIVE() || touched && (bRep != null && bRep.displaylist <= 0)))
54135727 {
54145728 Globals.lighttouched = true;
54155729 } // all panes...
5730
+
54165731 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
54175732 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
54185733 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5422,7 +5737,7 @@
54225737 //if (displaylist == -1 && usecalllists)
54235738 if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
54245739 {
5425
- bRep.displaylist = gl.glGenLists(1);
5740
+ bRep.displaylist = display.GenList();
54265741 assert(bRep.displaylist != 0);
54275742 // System.err.println("glGenLists: " + bRep.displaylist + " for " + this);
54285743 //System.out.println("\tgen list " + list);
....@@ -5434,14 +5749,16 @@
54345749 if (usecalllists)
54355750 {
54365751 // System.err.println("new list " + bRep.displaylist + " for " + this);
5437
- gl.glNewList(bRep.displaylist, gl.GL_COMPILE); //_AND_EXECUTE);
5752
+ display.NewList(bRep.displaylist);
54385753 }
5754
+
54395755 CallList(display, root, selected, blocked);
5756
+
54405757 // compiled = true;
54415758 if (usecalllists)
54425759 {
54435760 // System.err.println("end list " + bRep.displaylist + " for " + this);
5444
- gl.glEndList();
5761
+ display.EndList();
54455762 }
54465763 //gl.glDrawBuffer(gl.GL_BACK);
54475764 // XXX touched = false;
....@@ -5484,12 +5801,12 @@
54845801
54855802 // frustum culling
54865803 if (CameraPane.FRUSTUM && !blocked && !IsInfinite() && GetBRep() != null // && GetBRep().VertexCount() != 1260 // default grid
5487
- && display.DrawMode() != CameraPane.SELECTION)
5804
+ && display.DrawMode() != iCameraPane.SELECTION)
54885805 {
5489
- if (display.DrawMode() == CameraPane.SHADOW)
5806
+ if (display.DrawMode() == iCameraPane.SHADOW)
54905807 {
54915808 if (!link2master // tricky to cull in shadow mode.
5492
- && GetBRep().FrustumCull(this, gl, display.LightCamera(), true))
5809
+ && GetBRep().FrustumCull(this, null, display.LightCamera(), true))
54935810 {
54945811 //System.out.print("CULLED");
54955812 culled = true;
....@@ -5497,7 +5814,7 @@
54975814 }
54985815 else
54995816 //GetBRep().getBounds(v0, v1, this);
5500
- if (GetBRep().FrustumCull(this, gl, display.RenderCamera(), false))
5817
+ if (GetBRep().FrustumCull(this, null, display.RenderCamera(), false))
55015818 culled = true;
55025819
55035820 // LA.xformPos(v0, display.renderCamera.toScreen, v0);
....@@ -5533,11 +5850,11 @@
55335850
55345851
55355852 if (!culled)
5536
- if (display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION)
5853
+ if (display.DrawMode() == display.SELECTION || display.IsDebugSelection())
55375854 {
55385855 if (GetBRep() != null)
55395856 {
5540
- CameraPane.NextIndex(this, gl);
5857
+ display.NextIndex();
55415858 // vertex color conflict : gl.glCallList(list);
55425859 DrawNode(display, root, selected);
55435860 if (this instanceof BezierPatch)
....@@ -5578,7 +5895,28 @@
55785895 tex = GetTextures();
55795896 }
55805897
5581
- display.BindTextures(tex, texres);
5898
+ boolean failedPigment = false;
5899
+ boolean failedBump = false;
5900
+
5901
+ try
5902
+ {
5903
+ display.BindPigmentTexture(tex, texres);
5904
+ }
5905
+ catch (Exception e)
5906
+ {
5907
+ System.err.println("FAILED: " + this);
5908
+ failedPigment = true;
5909
+ }
5910
+
5911
+ try
5912
+ {
5913
+ display.BindBumpTexture(tex, texres);
5914
+ }
5915
+ catch (Exception e)
5916
+ {
5917
+ //System.err.println("FAILED: " + this);
5918
+ failedBump = true;
5919
+ }
55825920
55835921 if (!compiled)
55845922 {
....@@ -5594,13 +5932,17 @@
55945932
55955933 // System.err.println("glCallList: " + bRep.displaylist + " for " + this);
55965934 assert(bRep.displaylist != 0);
5597
- gl.glCallList(bRep.displaylist);
5935
+ display.CallList(bRep.displaylist);
55985936 // june 2013 drawSelf(display, root, selected);
55995937 }
56005938 }
56015939 }
56025940
5603
- display.ReleaseTextures(tex);
5941
+ if (!failedBump)
5942
+ display.ReleaseBumpTexture(tex);
5943
+
5944
+ if (!failedPigment)
5945
+ display.ReleasePigmentTexture(tex);
56045946
56055947 display.PopMaterial(this, selected);
56065948 }
....@@ -5729,6 +6071,9 @@
57296071
57306072 void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57316073 {
6074
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6075
+ return;
6076
+
57326077 if (hide)
57336078 return;
57346079 // shadow optimisation
....@@ -5854,6 +6199,9 @@
58546199 if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
58556200 return; // no shadow for transparent objects
58566201
6202
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6203
+ return;
6204
+
58576205 if (hide)
58586206 return;
58596207
....@@ -5894,9 +6242,10 @@
58946242 return;
58956243 }
58966244
6245
+ //bRep.GenUV(1/material.diffuseness);
58976246 // bRep.lock = true;
58986247
5899
- javax.media.opengl.GL gl = display.GetGL();
6248
+ //javax.media.opengl.GL gl = display.GetGL();
59006249
59016250 if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera)
59026251 {
....@@ -5913,23 +6262,7 @@
59136262
59146263 bRep.getMinMax(min, max, 100);
59156264
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();
6265
+ display.DrawBox(min, max);
59336266
59346267 return;
59356268 }
....@@ -5973,7 +6306,7 @@
59736306 {
59746307 //throw new Error();
59756308
5976
- boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION;
6309
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
59776310
59786311 int[] strips = bRep.getRawIndices();
59796312
....@@ -5983,178 +6316,14 @@
59836316 new Exception().printStackTrace();
59846317 return;
59856318 }
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
- }
6319
+
6320
+ display.DrawGeometry(bRep, flipV, selectmode);
61526321 } else // catch (Error e)
61536322 {
61546323 // TRIANGLE ARRAY
61556324 if (IsOpaque()) // Static())
61566325 {
6157
- gl.glBegin(gl.GL_TRIANGLES);
6326
+ display.StartTriangles();
61586327 int facecount = bRep.FaceCount();
61596328 for (int i = 0; i < facecount; i++)
61606329 {
....@@ -6219,7 +6388,7 @@
62196388
62206389 display.DrawFace(this, p, q, r, face);
62216390 }
6222
- gl.glEnd();
6391
+ display.EndTriangles();
62236392 }
62246393 else
62256394 {
....@@ -6248,8 +6417,8 @@
62486417 //System.out.println("SORT");
62496418
62506419 java.util.Arrays.sort(facescompare);
6251
-
6252
- gl.glBegin(gl.GL_TRIANGLES);
6420
+
6421
+ display.StartTriangles();
62536422 for (int i = 0; i < facecount; i++)
62546423 {
62556424 Face face = bRep.GetFace(facescompare[i].index);
....@@ -6263,11 +6432,12 @@
62636432
62646433 display.DrawFace(this, p, q, r, face);
62656434 }
6266
- gl.glEnd();
6435
+ display.EndTriangles();
62676436 }
62686437
62696438 if (false) // live && support != null && support.bRep != null) // debug weights
62706439 {
6440
+ /*
62716441 gl.glDisable(gl.GL_LIGHTING);
62726442 float[] colorV = new float[3];
62736443
....@@ -6346,6 +6516,7 @@
63466516 // gl.glEnd();
63476517 }
63486518 }
6519
+ */
63496520 }
63506521 }
63516522
....@@ -6390,7 +6561,7 @@
63906561 center.add(r);
63916562 center.mul(1.0/3);
63926563
6393
- center.sub(CameraPane.theRenderer.eyeCamera.location);
6564
+ center.sub(Globals.theRenderer.EyeCamera().location);
63946565
63956566 distance = center.dot(center);
63966567 }
....@@ -6404,22 +6575,6 @@
64046575 void Print(Vertex v)
64056576 {
64066577 //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);
64236578 }
64246579
64256580 void drawSelf(ClickInfo info, int level, boolean select)
....@@ -6993,83 +7148,84 @@
69937148 int spotw = spot.x + spot.width;
69947149 int spoth = spot.y + spot.height;
69957150 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
- }
7151
+// if (CameraPane.Xmin > spot.x)
7152
+// {
7153
+// CameraPane.Xmin = spot.x;
7154
+// }
7155
+// if (CameraPane.Xmax < spotw)
7156
+// {
7157
+// CameraPane.Xmax = spotw;
7158
+// }
7159
+// if (CameraPane.Ymin > spot.y)
7160
+// {
7161
+// CameraPane.Ymin = spot.y;
7162
+// }
7163
+// if (CameraPane.Ymax < spoth)
7164
+// {
7165
+// CameraPane.Ymax = spoth;
7166
+// }
70127167 spot.translate(32, 32);
70137168 spotw = spot.x + spot.width;
70147169 spoth = spot.y + spot.height;
7015
- info.g.setColor(Color.blue);
7170
+ info.g.setColor(Color.cyan);
70167171 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);
7172
+// if (CameraPane.Xmin > spot.x)
7173
+// {
7174
+// CameraPane.Xmin = spot.x;
7175
+// }
7176
+// if (CameraPane.Xmax < spotw)
7177
+// {
7178
+// CameraPane.Xmax = spotw;
7179
+// }
7180
+// if (CameraPane.Ymin > spot.y)
7181
+// {
7182
+// CameraPane.Ymin = spot.y;
7183
+// }
7184
+// if (CameraPane.Ymax < spoth)
7185
+// {
7186
+// CameraPane.Ymax = spoth;
7187
+// }
7188
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7189
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
70357190 spot.translate(0, -32);
7036
- info.g.setColor(Color.green);
7191
+ info.g.setColor(Color.yellow);
70377192 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
- }
7193
+ info.g.setColor(Color.green);
7194
+// if (CameraPane.Xmin > spot.x)
7195
+// {
7196
+// CameraPane.Xmin = spot.x;
7197
+// }
7198
+// if (CameraPane.Xmax < spotw)
7199
+// {
7200
+// CameraPane.Xmax = spotw;
7201
+// }
7202
+// if (CameraPane.Ymin > spot.y)
7203
+// {
7204
+// CameraPane.Ymin = spot.y;
7205
+// }
7206
+// if (CameraPane.Ymax < spoth)
7207
+// {
7208
+// CameraPane.Ymax = spoth;
7209
+// }
70547210 info.g.drawArc(boundary.x, boundary.y,
70557211 boundary.width, boundary.height, 0, 360);
70567212 //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
- }
7213
+// if (CameraPane.Xmin > boundary.x)
7214
+// {
7215
+// CameraPane.Xmin = boundary.x;
7216
+// }
7217
+// if (CameraPane.Xmax < boundary.x + boundary.width)
7218
+// {
7219
+// CameraPane.Xmax = boundary.x + boundary.width;
7220
+// }
7221
+// if (CameraPane.Ymin > boundary.y)
7222
+// {
7223
+// CameraPane.Ymin = boundary.y;
7224
+// }
7225
+// if (CameraPane.Ymax < boundary.y + boundary.height)
7226
+// {
7227
+// CameraPane.Ymax = boundary.y + boundary.height;
7228
+// }
70737229 return;
70747230 }
70757231 }
....@@ -7086,7 +7242,7 @@
70867242 startX = info.x;
70877243 startY = info.y;
70887244
7089
- hitSomething = 0;
7245
+ hitSomething = -1;
70907246 cVector origin = new cVector();
70917247 //LA.xformPos(origin, toParent, origin);
70927248 Rectangle spot = new Rectangle();
....@@ -7119,7 +7275,7 @@
71197275 }
71207276
71217277 //System.out.println("info.modifiers = " + info.modifiers);
7122
- modified = (info.modifiers & CameraPane.META) != 0;
7278
+ modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
71237279 //System.out.println("modified = " + modified);
71247280 //new Exception().printStackTrace();
71257281 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7147,7 +7303,7 @@
71477303 return true;
71487304 }
71497305
7150
- void doEditDrag0(ClickInfo info)
7306
+ void doEditDrag0(ClickInfo info, boolean opposite)
71517307 {
71527308 if (hitSomething == 0)
71537309 {
....@@ -7162,6 +7318,7 @@
71627318 //System.out.println("hitSomething = " + hitSomething);
71637319
71647320 double scale = 0.005f * info.camera.Distance();
7321
+
71657322 cVector xlate = new cVector();
71667323 //cVector xlate2 = new cVector();
71677324 switch (hitSomething)
....@@ -7172,9 +7329,9 @@
71727329
71737330 case hitCenter: // Translate
71747331
7175
- scale *= 0.05f * info.pane.theRenderer.renderCamera.Distance();
7332
+ scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
71767333
7177
- if (modified)
7334
+ if (modified || opposite)
71787335 {
71797336 //assert(false);
71807337 /*
....@@ -7220,10 +7377,10 @@
72207377 }
72217378 LA.xformDir(up, ClickInfo.matbuffer, up);
72227379 // if (!CameraPane.LOCALTRANSFORM)
7223
- LA.xformDir(up, info.pane.theRenderer.renderCamera.toScreen, up);
7380
+ LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
72247381 LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
72257382 // if (!CameraPane.LOCALTRANSFORM)
7226
- LA.xformDir(away, info.pane.theRenderer.renderCamera.toScreen, away);
7383
+ LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
72277384 //LA.vecCross(up, cVector.Z, right2);
72287385
72297386 cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
....@@ -7268,6 +7425,7 @@
72687425
72697426 if (modified)
72707427 {
7428
+ // Rotate 90 degrees
72717429 angle /= (Math.PI / 4);
72727430 angle = Math.floor(angle + 0.5);
72737431 angle *= (Math.PI / 4);
....@@ -7281,7 +7439,7 @@
72817439 }
72827440 /**/
72837441
7284
- switch (info.pane.renderCamera.viewCode)
7442
+ switch (info.pane.RenderCamera().viewCode)
72857443 {
72867444 case 1: // '\001'
72877445 LA.matZRotate(toParent, angle);
....@@ -7309,24 +7467,27 @@
73097467
73107468 case hitScale: // scale
73117469 double hScale = (double) (info.x - centerPt.x) / 32;
7470
+ double sign = 1;
7471
+ if (hScale < 0)
7472
+ {
7473
+ sign = -1;
7474
+ }
7475
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
73127476 if (hScale < 0.01)
73137477 {
7314
- hScale = 0.01;
7478
+ //hScale = 0.01;
73157479 }
7316
- hScale = Math.pow(hScale, scale * 50);
7317
- if (hScale < 0.01)
7318
- {
7319
- hScale = 0.01;
7320
- }
7480
+
73217481 double vScale = (double) (info.y - centerPt.y) / 32;
7322
- if (vScale < 0.01)
7482
+ sign = 1;
7483
+ if (vScale < 0)
73237484 {
7324
- vScale = 0.01;
7485
+ sign = -1;
73257486 }
7326
- vScale = Math.pow(vScale, scale * 50);
7487
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
73277488 if (vScale < 0.01)
73287489 {
7329
- vScale = 0.01;
7490
+ //vScale = 0.01;
73307491 }
73317492 LA.matCopy(startMat, toParent);
73327493 /**/
....@@ -7337,39 +7498,47 @@
73377498 }
73387499 /**/
73397500
7340
- switch (info.pane.renderCamera.viewCode)
7501
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7502
+
7503
+ if (totalScale < 0.01)
7504
+ {
7505
+ totalScale = 0.01;
7506
+ }
7507
+
7508
+ switch (info.pane.RenderCamera().viewCode)
73417509 {
73427510 case 3: // '\001'
7343
- if (modified)
7511
+ if (modified || opposite)
73447512 {
73457513 //LA.matScale(toParent, 1, hScale, vScale);
7346
- LA.matScale(toParent, vScale, 1, 1);
7514
+ LA.matScale(toParent, totalScale, 1, 1);
73477515 } // vScale, 1);
73487516 else
73497517 {
7350
- LA.matScale(toParent, vScale, vScale, vScale);
7518
+ // EXCEPTION!
7519
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
73517520 } // vScale, 1);
73527521 break;
73537522
73547523 case 2: // '\002'
7355
- if (modified)
7524
+ if (modified || opposite)
73567525 {
73577526 //LA.matScale(toParent, hScale, 1, vScale);
7358
- LA.matScale(toParent, 1, vScale, 1);
7527
+ LA.matScale(toParent, 1, totalScale, 1);
73597528 } else
73607529 {
7361
- LA.matScale(toParent, vScale, 1, vScale);
7530
+ LA.matScale(toParent, totalScale, 1, totalScale);
73627531 }
73637532 break;
73647533
73657534 case 1: // '\003'
7366
- if (modified)
7535
+ if (modified || opposite)
73677536 {
73687537 //LA.matScale(toParent, hScale, vScale, 1);
7369
- LA.matScale(toParent, 1, 1, vScale);
7538
+ LA.matScale(toParent, 1, 1, totalScale);
73707539 } else
73717540 {
7372
- LA.matScale(toParent, vScale, vScale, 1);
7541
+ LA.matScale(toParent, totalScale, totalScale, 1);
73737542 }
73747543 break;
73757544 }
....@@ -7502,14 +7671,22 @@
75027671 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
75037672 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
75047673 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7674
+
7675
+ String objname;
7676
+
75057677 if (false) //parent != null)
75067678 {
7507
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7679
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
75087680 } else
75097681 {
7510
- return GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ") ")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ +System.identityHashCode(this);
7682
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
75117683 } // + super.toString();
75127684 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
7685
+
7686
+ if (!Globals.ADVANCED)
7687
+ return objname;
7688
+
7689
+ return objname + " " + System.identityHashCode(this);
75137690 }
75147691
75157692 public int hashCode()
....@@ -7565,6 +7742,7 @@
75657742 objectUI.closeUI();
75667743 if (editWindow != null)
75677744 {
7745
+ editWindow.ctrlPanel.FlushUI();
75687746 editWindow.refreshContents();
75697747 } // ? new
75707748 objectUI = null;
....@@ -7585,7 +7763,7 @@
75857763 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
75867764
75877765 Object3D /*Composite*/ parent;
7588
- Object3D /*Composite*/ fileparent;
7766
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
75897767
75907768 double[][] toParent; // dynamic matrix
75917769 double[][] fromParent;
....@@ -7700,7 +7878,7 @@
77007878 {
77017879 assert(bRep != null);
77027880 if (!(support instanceof GenericJoint)) // support.bRep != null)
7703
- GrafreeD.Assert(support.bRep == bRep.support);
7881
+ Grafreed.Assert(support.bRep == bRep.support);
77047882 }
77057883 else
77067884 {
....@@ -7749,9 +7927,9 @@
77497927 private static cVector edge2 = new cVector();
77507928 //private static cVector norm = new cVector();
77517929 /*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;
7930
+ static final int hitCenter = 1;
7931
+ static final int hitScale = 2;
7932
+ static final int hitRotate = 3;
77557933 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
77567934 /*transient*/ private Point centerPt;
77577935 /*transient*/ private int startX;