Normand Briere
2019-06-21 15123b19e7bc8da2869429b07f0fbaa0598e945e
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;
....@@ -808,7 +893,8 @@
808893
809894 boolean changedir = random && Math.random() < 0.01; // && !link2master;
810895
811
- if (transformcount*factor > maxcount || (step == 1 && changedir))
896
+ if (transformcount*factor >= maxcount && (rewind || random) ||
897
+ (step == 1 && changedir))
812898 {
813899 countdown = 1;
814900 delay = speedup?8:1;
....@@ -911,6 +997,11 @@
911997 fromParent = null; // LA.newMatrix();
912998 bRep = null; // new BoundaryRep();
913999
1000
+ if (oname != null && oname.equals("LeftHand"))
1001
+ {
1002
+ name = oname;
1003
+ }
1004
+
9141005 /*
9151006 float hue = (float)Math.random();
9161007 Color col;
....@@ -953,7 +1044,7 @@
9531044
9541045 public Object clone()
9551046 {
956
- return GrafreeD.clone(this);
1047
+ return Grafreed.clone(this);
9571048 }
9581049
9591050 Object3D copyExpand()
....@@ -1469,7 +1560,7 @@
14691560 BoundaryRep.SEUIL = other.material.cameralight;
14701561
14711562 // Set default to 0.1
1472
- BoundaryRep.SEUIL /= 2;
1563
+ BoundaryRep.SEUIL /= 4; // 2;
14731564 System.out.println("SEUIL = " + BoundaryRep.SEUIL);
14741565 }
14751566
....@@ -1728,7 +1819,7 @@
17281819 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17291820 o.bRep = transientrep;
17301821 if (clone)
1731
- o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
1822
+ o.bRep = (BoundaryRep) Grafreed.clone(transientrep);
17321823 o.CreateMaterial();
17331824 o.SetAttributes(this, -1);
17341825 //parent
....@@ -1741,7 +1832,7 @@
17411832 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17421833 o.bRep = bRep;
17431834 if (clone)
1744
- o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
1835
+ o.bRep = (BoundaryRep) Grafreed.clone(bRep);
17451836 o.CreateMaterial();
17461837 //o.overwriteThis(this, -1);
17471838 o.SetAttributes(this, -1);
....@@ -1828,12 +1919,15 @@
18281919 if (obj.name == null)
18291920 continue; // can't be a null one
18301921
1922
+ // Try perfect match first.
18311923 if (n.equals(obj.name))
18321924 {
18331925 theobj = obj;
18341926 count++;
18351927 }
18361928 }
1929
+
1930
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18371931
18381932 if (count != 1)
18391933 for (int i=Size(); --i>=0;)
....@@ -2299,6 +2393,7 @@
22992393 {
23002394 if (newWindow)
23012395 {
2396
+ new Exception().printStackTrace();
23022397 System.exit(0);
23032398 if (parent != null)
23042399 {
....@@ -2475,13 +2570,13 @@
24752570 return retval;
24762571 }
24772572
2478
- void doEditDrag(ClickInfo info)
2573
+ void doEditDrag(ClickInfo info, boolean opposite)
24792574 {
24802575 switch (doSomething)
24812576 {
24822577 case 1: // '\001'
24832578 //super.
2484
- doEditDrag0(info);
2579
+ doEditDrag0(info, opposite);
24852580 break;
24862581
24872582 case 2: // '\002'
....@@ -2494,11 +2589,11 @@
24942589 {
24952590 //sel.hitSomething = childToDrag.hitSomething;
24962591 //childToDrag.doEditDrag(info);
2497
- sel.doEditDrag(info);
2592
+ sel.doEditDrag(info, opposite);
24982593 } else
24992594 {
25002595 //super.
2501
- doEditDrag0(info);
2596
+ doEditDrag0(info, opposite);
25022597 }
25032598 }
25042599 break;
....@@ -2608,6 +2703,18 @@
26082703 void GenNormalsS(boolean crease)
26092704 {
26102705 selection.GenNormals(crease);
2706
+// for (int i=0; i<selection.size(); i++)
2707
+// {
2708
+// Object3D selectee = (Object3D) selection.elementAt(i);
2709
+// selectee.GenNormals(crease);
2710
+// }
2711
+
2712
+ //Touch();
2713
+ }
2714
+
2715
+ void GenNormalsMeshS()
2716
+ {
2717
+ selection.GenNormalsMesh();
26112718 // for (int i=0; i<selection.size(); i++)
26122719 // {
26132720 // Object3D selectee = (Object3D) selection.elementAt(i);
....@@ -2748,6 +2855,24 @@
27482855 if (child == null)
27492856 continue;
27502857 child.GenNormals(crease);
2858
+// Children().release(i);
2859
+ }
2860
+ blockloop = false;
2861
+ }
2862
+
2863
+ void GenNormalsMesh()
2864
+ {
2865
+ if (blockloop)
2866
+ return;
2867
+
2868
+ blockloop = true;
2869
+ GenNormalsMesh0();
2870
+ for (int i = 0; i < Children().Size(); i++)
2871
+ {
2872
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2873
+ if (child == null)
2874
+ continue;
2875
+ child.GenNormalsMesh();
27512876 // Children().release(i);
27522877 }
27532878 blockloop = false;
....@@ -2905,7 +3030,8 @@
29053030 {
29063031 if (bRep != null)
29073032 {
2908
- bRep.GenUV();
3033
+ bRep.GenUV(); //1);
3034
+ //bRep.UnfoldUV();
29093035 Touch();
29103036 }
29113037 }
....@@ -2915,6 +3041,15 @@
29153041 if (bRep != null)
29163042 {
29173043 bRep.GenerateNormals(crease);
3044
+ Touch();
3045
+ }
3046
+ }
3047
+
3048
+ void GenNormalsMesh0()
3049
+ {
3050
+ if (bRep != null)
3051
+ {
3052
+ bRep.GenerateNormalsMesh();
29183053 Touch();
29193054 }
29203055 }
....@@ -2980,6 +3115,33 @@
29803115 blockloop = false;
29813116 }
29823117
3118
+ void TransformChildren()
3119
+ {
3120
+ if (toParent != null)
3121
+ {
3122
+ for (int i=Size(); --i>=0;)
3123
+ {
3124
+ Object3D v = get(i);
3125
+
3126
+ if (v.toParent == null)
3127
+ {
3128
+ v.toParent = LA.newMatrix();
3129
+ v.fromParent = LA.newMatrix();
3130
+ }
3131
+
3132
+// LA.matConcat(v.toParent, toParent, v.toParent);
3133
+// LA.matConcat(fromParent, v.fromParent, v.fromParent);
3134
+ LA.matConcat(toParent, v.toParent, v.toParent);
3135
+ LA.matConcat(v.fromParent, fromParent, v.fromParent);
3136
+ }
3137
+
3138
+ toParent = null; // LA.matIdentity(toParent);
3139
+ fromParent = null; // LA.matIdentity(fromParent);
3140
+
3141
+ Touch();
3142
+ }
3143
+ }
3144
+
29833145 void TransformGeometry()
29843146 {
29853147 Object3D obj = this;
....@@ -3201,9 +3363,11 @@
32013363
32023364 BoundaryRep sup = bRep.support;
32033365 bRep.support = null;
3204
- BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
3366
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
32053367 // bRep.SplitInTwo(onlyone); // thread...
3206
- temprep.SplitInTwo(reduction34, onlyone);
3368
+
3369
+ while(temprep.SplitInTwo(reduction34, onlyone));
3370
+
32073371 bRep = temprep;
32083372 bRep.support = sup;
32093373 Touch();
....@@ -3340,7 +3504,8 @@
33403504 if (blockloop)
33413505 return;
33423506
3343
- if (marked || (bRep != null && material != null)) // borderline...
3507
+ if (//marked || // does not make sense
3508
+ (bRep != null || material != null)) // borderline...
33443509 live = h;
33453510
33463511 for (int i = 0; i < Size(); i++)
....@@ -3361,7 +3526,8 @@
33613526 return;
33623527
33633528 //if (bRep != null)
3364
- if (marked || (bRep != null && material != null)) // borderline...
3529
+ if (//marked || // does not make sense
3530
+ (bRep != null || material != null)) // borderline...
33653531 link2master = h;
33663532
33673533 for (int i = 0; i < Size(); i++)
....@@ -3381,7 +3547,8 @@
33813547 if (blockloop)
33823548 return;
33833549
3384
- if (marked || (bRep != null && material != null)) // borderline...
3550
+ if (//marked || // does not make sense
3551
+ (bRep != null || material != null)) // borderline...
33853552 hide = h;
33863553
33873554 for (int i = 0; i < Size(); i++)
....@@ -3401,7 +3568,7 @@
34013568 if (blockloop)
34023569 return;
34033570
3404
- if (bRep != null && material != null) // borderline...
3571
+ if (bRep != null || material != null) // borderline...
34053572 marked = h;
34063573
34073574 for (int i = 0; i < Size(); i++)
....@@ -3411,6 +3578,46 @@
34113578 continue;
34123579 blockloop = true;
34133580 child.MarkLeaves(h);
3581
+ blockloop = false;
3582
+ // release(i);
3583
+ }
3584
+ }
3585
+
3586
+ void RewindLeaves(boolean h)
3587
+ {
3588
+ if (blockloop)
3589
+ return;
3590
+
3591
+ if (bRep != null || material != null) // borderline...
3592
+ rewind = h;
3593
+
3594
+ for (int i = 0; i < Size(); i++)
3595
+ {
3596
+ Object3D child = (Object3D) get(i); // reserve(i);
3597
+ if (child == null)
3598
+ continue;
3599
+ blockloop = true;
3600
+ child.RewindLeaves(h);
3601
+ blockloop = false;
3602
+ // release(i);
3603
+ }
3604
+ }
3605
+
3606
+ void RandomLeaves(boolean h)
3607
+ {
3608
+ if (blockloop)
3609
+ return;
3610
+
3611
+ if (bRep != null || material != null) // borderline...
3612
+ random = h;
3613
+
3614
+ for (int i = 0; i < Size(); i++)
3615
+ {
3616
+ Object3D child = (Object3D) get(i); // reserve(i);
3617
+ if (child == null)
3618
+ continue;
3619
+ blockloop = true;
3620
+ child.RandomLeaves(h);
34143621 blockloop = false;
34153622 // release(i);
34163623 }
....@@ -3725,7 +3932,7 @@
37253932 if (child == null)
37263933 continue;
37273934
3728
- if (GrafreeD.RENDERME > 0)
3935
+ if (Grafreed.RENDERME > 0)
37293936 {
37303937 if (child instanceof Merge)
37313938 ((Merge)child).renderme();
....@@ -3876,7 +4083,7 @@
38764083 if (child == null)
38774084 continue;
38784085
3879
- if (GrafreeD.RENDERME > 0)
4086
+ if (Grafreed.RENDERME > 0)
38804087 {
38814088 if (child instanceof Merge)
38824089 ((Merge)child).renderme();
....@@ -4071,7 +4278,7 @@
40714278 if (child == null)
40724279 continue;
40734280
4074
- if (GrafreeD.RENDERME > 0)
4281
+ if (Grafreed.RENDERME > 0)
40754282 {
40764283 if (child instanceof Merge)
40774284 ((Merge)child).renderme();
....@@ -4184,6 +4391,55 @@
41844391 {
41854392 blockloop = true;
41864393 get(i).RepairShadow();
4394
+ blockloop = false;
4395
+ }
4396
+ }
4397
+
4398
+ void RepairSOV()
4399
+ {
4400
+ if (blockloop)
4401
+ return;
4402
+
4403
+ String texname = this.GetPigmentTexture();
4404
+
4405
+ if (texname.startsWith("sov"))
4406
+ {
4407
+ String[] s = texname.split("/");
4408
+
4409
+ String[] sname = s[1].split("Color.pn");
4410
+
4411
+ texname = sname[0];
4412
+
4413
+ if (sname.length > 1)
4414
+ {
4415
+ texname += "Color.jpg";
4416
+ }
4417
+
4418
+ this.SetPigmentTexture("sov/" + texname);
4419
+ }
4420
+
4421
+ texname = this.GetBumpTexture();
4422
+
4423
+ if (texname.startsWith("sov"))
4424
+ {
4425
+ String[] s = texname.split("/");
4426
+
4427
+ String[] sname = s[1].split("Bump.pn");
4428
+
4429
+ texname = sname[0];
4430
+
4431
+ if (sname.length > 1)
4432
+ {
4433
+ texname += "Bump.jpg";
4434
+ }
4435
+
4436
+ this.SetBumpTexture("sov/" + texname);
4437
+ }
4438
+
4439
+ for (int i=0; i<Size(); i++)
4440
+ {
4441
+ blockloop = true;
4442
+ get(i).RepairSOV();
41874443 blockloop = false;
41884444 }
41894445 }
....@@ -4678,7 +4934,7 @@
46784934
46794935 cTreePath SelectLeaf(int indexcount, boolean deselect)
46804936 {
4681
- if (hide)
4937
+ if (hide || dontselect)
46824938 return null;
46834939
46844940 if (count <= 0)
....@@ -4704,7 +4960,7 @@
47044960
47054961 cTreePath Select(int indexcount, boolean deselect)
47064962 {
4707
- if (hide)
4963
+ if (hide || dontselect)
47084964 return null;
47094965
47104966 if (count <= 0)
....@@ -4854,7 +5110,7 @@
48545110 return globalTransform;
48555111 }
48565112
4857
- void PreprocessOcclusion(CameraPane cp)
5113
+ void PreprocessOcclusion(iCameraPane cp)
48585114 {
48595115 /*
48605116 if (AOdone)
....@@ -5156,10 +5412,34 @@
51565412
51575413 // System.out.println("Fullname = " + fullname);
51585414
5159
- if (fullname.name.indexOf(":") == -1)
5160
- return fullname.name;
5415
+ // Does not work on Windows due to C:
5416
+// if (fullname.name.indexOf(":") == -1)
5417
+// return fullname.name;
5418
+//
5419
+// return fullname.name.substring(0,fullname.name.indexOf(":"));
51615420
5162
- return fullname.name.substring(0,fullname.name.indexOf(":"));
5421
+ String[] split = fullname.name.split(":");
5422
+
5423
+ if (split.length == 0)
5424
+ {
5425
+ return "";
5426
+ }
5427
+
5428
+ if (split.length <= 2)
5429
+ {
5430
+ if (fullname.name.endsWith(":"))
5431
+ {
5432
+ // Windows
5433
+ return fullname.name.substring(0, fullname.name.length()-1);
5434
+ }
5435
+
5436
+ return split[0];
5437
+ }
5438
+
5439
+ // Windows
5440
+ assert(split.length == 4);
5441
+
5442
+ return split[0] + ":" + split[1];
51635443 }
51645444
51655445 static String GetBump(cTexture fullname)
....@@ -5168,10 +5448,38 @@
51685448 return "";
51695449
51705450 // 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());
5451
+ // Does not work on Windows due to C:
5452
+// if (fullname.name.indexOf(":") == -1)
5453
+// return "";
5454
+//
5455
+// return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5456
+ String[] split = fullname.name.split(":");
5457
+
5458
+ if (split.length == 0)
5459
+ {
5460
+ return "";
5461
+ }
5462
+
5463
+ if (split.length == 1)
5464
+ {
5465
+ return "";
5466
+ }
5467
+
5468
+ if (split.length == 2)
5469
+ {
5470
+ if (fullname.name.endsWith(":"))
5471
+ {
5472
+ // Windows
5473
+ return "";
5474
+ }
5475
+
5476
+ return split[1];
5477
+ }
5478
+
5479
+ // Windows
5480
+ assert(split.length == 4);
5481
+
5482
+ return split[2] + ":" + split[3];
51755483 }
51765484
51775485 String GetPigmentTexture()
....@@ -5245,7 +5553,7 @@
52455553 System.out.print("; textures = " + textures);
52465554 System.out.println("; usedtextures = " + usedtextures);
52475555
5248
- if (GetTextures() == null)
5556
+ if (GetTextures() == null) // What is that??
52495557 GetTextures().name = ":";
52505558
52515559 String texname = tex;
....@@ -5276,6 +5584,43 @@
52765584 child.ResetPigmentTexture();
52775585 blockloop = false;
52785586 }
5587
+ }
5588
+
5589
+ UUID GetUUID()
5590
+ {
5591
+ if (uuid == null)
5592
+ {
5593
+ // Serial
5594
+ uuid = UUID.randomUUID();
5595
+ }
5596
+
5597
+ return uuid;
5598
+ }
5599
+
5600
+ Object3D GetObject(UUID uid)
5601
+ {
5602
+ if (blockloop)
5603
+ return null;
5604
+
5605
+ if (GetUUID().equals(uid))
5606
+ return this;
5607
+
5608
+ int nb = Size();
5609
+ for (int i = 0; i < nb; i++)
5610
+ {
5611
+ Object3D child = (Object3D) get(i);
5612
+
5613
+ if (child == null)
5614
+ continue;
5615
+
5616
+ blockloop = true;
5617
+ Object3D obj = child.GetObject(uid);
5618
+ blockloop = false;
5619
+ if (obj != null)
5620
+ return obj;
5621
+ }
5622
+
5623
+ return null;
52795624 }
52805625
52815626 void SetBumpTexture(String tex)
....@@ -5322,11 +5667,23 @@
53225667 boolean NeedSupport()
53235668 {
53245669 return
5325
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5670
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
53265671 // PROBLEM with CROWD!!
5327
- && (Globals.DrawMode() == iCameraPane.SHADOW || Globals.CROWD);
5672
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
53285673 }
53295674
5675
+ static boolean DEBUG_SELECTION = false;
5676
+
5677
+ boolean IsLive()
5678
+ {
5679
+ if (live)
5680
+ return true;
5681
+
5682
+ if (parent == null)
5683
+ return false;
5684
+
5685
+ return parent.IsLive();
5686
+ }
53305687
53315688 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
53325689 {
....@@ -5338,7 +5695,7 @@
53385695 }
53395696
53405697 if (display.DrawMode() == iCameraPane.SELECTION &&
5341
- hide)
5698
+ (hide || dontselect))
53425699 return;
53435700
53445701 if (name != null && name.contains("sclera"))
....@@ -5365,12 +5722,12 @@
53655722 }
53665723
53675724 if ((//display.DrawMode() == CameraPane.SHADOW ||
5368
- display.DrawMode() == CameraPane.SELECTION || CameraPane.DEBUG_SELECTION) && HasTransparency())
5725
+ display.DrawMode() == iCameraPane.SELECTION || display.IsDebugSelection()) && HasTransparency())
53695726 {
53705727 return;
53715728 }
53725729
5373
- javax.media.opengl.GL gl = display.GetGL();
5730
+ //javax.media.opengl.GL gl = display.GetGL();
53745731
53755732 /*
53765733 if (touched)
....@@ -5389,7 +5746,7 @@
53895746 support = support;
53905747
53915748 //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);
5749
+ boolean usecalllists = IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
53935750
53945751 if (!usecalllists && bRep != null && bRep.displaylist > 0)
53955752 {
....@@ -5406,13 +5763,15 @@
54065763
54075764 boolean compiled = false;
54085765
5409
- boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION;
5766
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
54105767
54115768 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5412
- (touched || (bRep != null && bRep.displaylist <= 0)))
5769
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5770
+ (Globals.isLIVE() || touched && (bRep != null && bRep.displaylist <= 0)))
54135771 {
54145772 Globals.lighttouched = true;
54155773 } // all panes...
5774
+
54165775 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
54175776 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
54185777 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5422,7 +5781,7 @@
54225781 //if (displaylist == -1 && usecalllists)
54235782 if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
54245783 {
5425
- bRep.displaylist = gl.glGenLists(1);
5784
+ bRep.displaylist = display.GenList();
54265785 assert(bRep.displaylist != 0);
54275786 // System.err.println("glGenLists: " + bRep.displaylist + " for " + this);
54285787 //System.out.println("\tgen list " + list);
....@@ -5434,14 +5793,16 @@
54345793 if (usecalllists)
54355794 {
54365795 // System.err.println("new list " + bRep.displaylist + " for " + this);
5437
- gl.glNewList(bRep.displaylist, gl.GL_COMPILE); //_AND_EXECUTE);
5796
+ display.NewList(bRep.displaylist);
54385797 }
5798
+
54395799 CallList(display, root, selected, blocked);
5800
+
54405801 // compiled = true;
54415802 if (usecalllists)
54425803 {
54435804 // System.err.println("end list " + bRep.displaylist + " for " + this);
5444
- gl.glEndList();
5805
+ display.EndList();
54455806 }
54465807 //gl.glDrawBuffer(gl.GL_BACK);
54475808 // XXX touched = false;
....@@ -5484,12 +5845,12 @@
54845845
54855846 // frustum culling
54865847 if (CameraPane.FRUSTUM && !blocked && !IsInfinite() && GetBRep() != null // && GetBRep().VertexCount() != 1260 // default grid
5487
- && display.DrawMode() != CameraPane.SELECTION)
5848
+ && display.DrawMode() != iCameraPane.SELECTION)
54885849 {
5489
- if (display.DrawMode() == CameraPane.SHADOW)
5850
+ if (display.DrawMode() == iCameraPane.SHADOW)
54905851 {
54915852 if (!link2master // tricky to cull in shadow mode.
5492
- && GetBRep().FrustumCull(this, gl, display.LightCamera(), true))
5853
+ && GetBRep().FrustumCull(this, null, display.LightCamera(), true))
54935854 {
54945855 //System.out.print("CULLED");
54955856 culled = true;
....@@ -5497,7 +5858,7 @@
54975858 }
54985859 else
54995860 //GetBRep().getBounds(v0, v1, this);
5500
- if (GetBRep().FrustumCull(this, gl, display.RenderCamera(), false))
5861
+ if (GetBRep().FrustumCull(this, null, display.RenderCamera(), false))
55015862 culled = true;
55025863
55035864 // LA.xformPos(v0, display.renderCamera.toScreen, v0);
....@@ -5533,11 +5894,11 @@
55335894
55345895
55355896 if (!culled)
5536
- if (display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION)
5897
+ if (display.DrawMode() == display.SELECTION || display.IsDebugSelection())
55375898 {
55385899 if (GetBRep() != null)
55395900 {
5540
- CameraPane.NextIndex(this, gl);
5901
+ display.NextIndex();
55415902 // vertex color conflict : gl.glCallList(list);
55425903 DrawNode(display, root, selected);
55435904 if (this instanceof BezierPatch)
....@@ -5578,7 +5939,28 @@
55785939 tex = GetTextures();
55795940 }
55805941
5581
- display.BindTextures(tex, texres);
5942
+ boolean failedPigment = false;
5943
+ boolean failedBump = false;
5944
+
5945
+ try
5946
+ {
5947
+ display.BindPigmentTexture(tex, texres);
5948
+ }
5949
+ catch (Exception e)
5950
+ {
5951
+ System.err.println("FAILED: " + this);
5952
+ failedPigment = true;
5953
+ }
5954
+
5955
+ try
5956
+ {
5957
+ display.BindBumpTexture(tex, texres);
5958
+ }
5959
+ catch (Exception e)
5960
+ {
5961
+ //System.err.println("FAILED: " + this);
5962
+ failedBump = true;
5963
+ }
55825964
55835965 if (!compiled)
55845966 {
....@@ -5594,13 +5976,17 @@
55945976
55955977 // System.err.println("glCallList: " + bRep.displaylist + " for " + this);
55965978 assert(bRep.displaylist != 0);
5597
- gl.glCallList(bRep.displaylist);
5979
+ display.CallList(bRep.displaylist);
55985980 // june 2013 drawSelf(display, root, selected);
55995981 }
56005982 }
56015983 }
56025984
5603
- display.ReleaseTextures(tex);
5985
+ if (!failedBump)
5986
+ display.ReleaseBumpTexture(tex);
5987
+
5988
+ if (!failedPigment)
5989
+ display.ReleasePigmentTexture(tex);
56045990
56055991 display.PopMaterial(this, selected);
56065992 }
....@@ -5729,6 +6115,9 @@
57296115
57306116 void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57316117 {
6118
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6119
+ return;
6120
+
57326121 if (hide)
57336122 return;
57346123 // shadow optimisation
....@@ -5854,6 +6243,9 @@
58546243 if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
58556244 return; // no shadow for transparent objects
58566245
6246
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6247
+ return;
6248
+
58576249 if (hide)
58586250 return;
58596251
....@@ -5894,9 +6286,10 @@
58946286 return;
58956287 }
58966288
6289
+ //bRep.GenUV(1/material.diffuseness);
58976290 // bRep.lock = true;
58986291
5899
- javax.media.opengl.GL gl = display.GetGL();
6292
+ //javax.media.opengl.GL gl = display.GetGL();
59006293
59016294 if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera)
59026295 {
....@@ -5913,23 +6306,7 @@
59136306
59146307 bRep.getMinMax(min, max, 100);
59156308
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();
6309
+ display.DrawBox(min, max);
59336310
59346311 return;
59356312 }
....@@ -5973,7 +6350,7 @@
59736350 {
59746351 //throw new Error();
59756352
5976
- boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION;
6353
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
59776354
59786355 int[] strips = bRep.getRawIndices();
59796356
....@@ -5983,178 +6360,14 @@
59836360 new Exception().printStackTrace();
59846361 return;
59856362 }
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
- }
6363
+
6364
+ display.DrawGeometry(bRep, flipV, selectmode);
61526365 } else // catch (Error e)
61536366 {
61546367 // TRIANGLE ARRAY
61556368 if (IsOpaque()) // Static())
61566369 {
6157
- gl.glBegin(gl.GL_TRIANGLES);
6370
+ display.StartTriangles();
61586371 int facecount = bRep.FaceCount();
61596372 for (int i = 0; i < facecount; i++)
61606373 {
....@@ -6219,7 +6432,7 @@
62196432
62206433 display.DrawFace(this, p, q, r, face);
62216434 }
6222
- gl.glEnd();
6435
+ display.EndTriangles();
62236436 }
62246437 else
62256438 {
....@@ -6248,8 +6461,8 @@
62486461 //System.out.println("SORT");
62496462
62506463 java.util.Arrays.sort(facescompare);
6251
-
6252
- gl.glBegin(gl.GL_TRIANGLES);
6464
+
6465
+ display.StartTriangles();
62536466 for (int i = 0; i < facecount; i++)
62546467 {
62556468 Face face = bRep.GetFace(facescompare[i].index);
....@@ -6263,11 +6476,12 @@
62636476
62646477 display.DrawFace(this, p, q, r, face);
62656478 }
6266
- gl.glEnd();
6479
+ display.EndTriangles();
62676480 }
62686481
62696482 if (false) // live && support != null && support.bRep != null) // debug weights
62706483 {
6484
+ /*
62716485 gl.glDisable(gl.GL_LIGHTING);
62726486 float[] colorV = new float[3];
62736487
....@@ -6346,6 +6560,7 @@
63466560 // gl.glEnd();
63476561 }
63486562 }
6563
+ */
63496564 }
63506565 }
63516566
....@@ -6390,7 +6605,7 @@
63906605 center.add(r);
63916606 center.mul(1.0/3);
63926607
6393
- center.sub(CameraPane.theRenderer.eyeCamera.location);
6608
+ center.sub(Globals.theRenderer.EyeCamera().location);
63946609
63956610 distance = center.dot(center);
63966611 }
....@@ -6404,22 +6619,6 @@
64046619 void Print(Vertex v)
64056620 {
64066621 //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);
64236622 }
64246623
64256624 void drawSelf(ClickInfo info, int level, boolean select)
....@@ -6993,83 +7192,84 @@
69937192 int spotw = spot.x + spot.width;
69947193 int spoth = spot.y + spot.height;
69957194 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
- }
7195
+// if (CameraPane.Xmin > spot.x)
7196
+// {
7197
+// CameraPane.Xmin = spot.x;
7198
+// }
7199
+// if (CameraPane.Xmax < spotw)
7200
+// {
7201
+// CameraPane.Xmax = spotw;
7202
+// }
7203
+// if (CameraPane.Ymin > spot.y)
7204
+// {
7205
+// CameraPane.Ymin = spot.y;
7206
+// }
7207
+// if (CameraPane.Ymax < spoth)
7208
+// {
7209
+// CameraPane.Ymax = spoth;
7210
+// }
70127211 spot.translate(32, 32);
70137212 spotw = spot.x + spot.width;
70147213 spoth = spot.y + spot.height;
7015
- info.g.setColor(Color.blue);
7214
+ info.g.setColor(Color.cyan);
70167215 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);
7216
+// if (CameraPane.Xmin > spot.x)
7217
+// {
7218
+// CameraPane.Xmin = spot.x;
7219
+// }
7220
+// if (CameraPane.Xmax < spotw)
7221
+// {
7222
+// CameraPane.Xmax = spotw;
7223
+// }
7224
+// if (CameraPane.Ymin > spot.y)
7225
+// {
7226
+// CameraPane.Ymin = spot.y;
7227
+// }
7228
+// if (CameraPane.Ymax < spoth)
7229
+// {
7230
+// CameraPane.Ymax = spoth;
7231
+// }
7232
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7233
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
70357234 spot.translate(0, -32);
7036
- info.g.setColor(Color.green);
7235
+ info.g.setColor(Color.yellow);
70377236 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
- }
7237
+ info.g.setColor(Color.green);
7238
+// if (CameraPane.Xmin > spot.x)
7239
+// {
7240
+// CameraPane.Xmin = spot.x;
7241
+// }
7242
+// if (CameraPane.Xmax < spotw)
7243
+// {
7244
+// CameraPane.Xmax = spotw;
7245
+// }
7246
+// if (CameraPane.Ymin > spot.y)
7247
+// {
7248
+// CameraPane.Ymin = spot.y;
7249
+// }
7250
+// if (CameraPane.Ymax < spoth)
7251
+// {
7252
+// CameraPane.Ymax = spoth;
7253
+// }
70547254 info.g.drawArc(boundary.x, boundary.y,
70557255 boundary.width, boundary.height, 0, 360);
70567256 //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
- }
7257
+// if (CameraPane.Xmin > boundary.x)
7258
+// {
7259
+// CameraPane.Xmin = boundary.x;
7260
+// }
7261
+// if (CameraPane.Xmax < boundary.x + boundary.width)
7262
+// {
7263
+// CameraPane.Xmax = boundary.x + boundary.width;
7264
+// }
7265
+// if (CameraPane.Ymin > boundary.y)
7266
+// {
7267
+// CameraPane.Ymin = boundary.y;
7268
+// }
7269
+// if (CameraPane.Ymax < boundary.y + boundary.height)
7270
+// {
7271
+// CameraPane.Ymax = boundary.y + boundary.height;
7272
+// }
70737273 return;
70747274 }
70757275 }
....@@ -7086,7 +7286,7 @@
70867286 startX = info.x;
70877287 startY = info.y;
70887288
7089
- hitSomething = 0;
7289
+ hitSomething = -1;
70907290 cVector origin = new cVector();
70917291 //LA.xformPos(origin, toParent, origin);
70927292 Rectangle spot = new Rectangle();
....@@ -7119,7 +7319,7 @@
71197319 }
71207320
71217321 //System.out.println("info.modifiers = " + info.modifiers);
7122
- modified = (info.modifiers & CameraPane.META) != 0;
7322
+ modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
71237323 //System.out.println("modified = " + modified);
71247324 //new Exception().printStackTrace();
71257325 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7147,7 +7347,7 @@
71477347 return true;
71487348 }
71497349
7150
- void doEditDrag0(ClickInfo info)
7350
+ void doEditDrag0(ClickInfo info, boolean opposite)
71517351 {
71527352 if (hitSomething == 0)
71537353 {
....@@ -7162,6 +7362,7 @@
71627362 //System.out.println("hitSomething = " + hitSomething);
71637363
71647364 double scale = 0.005f * info.camera.Distance();
7365
+
71657366 cVector xlate = new cVector();
71667367 //cVector xlate2 = new cVector();
71677368 switch (hitSomething)
....@@ -7172,9 +7373,9 @@
71727373
71737374 case hitCenter: // Translate
71747375
7175
- scale *= 0.05f * info.pane.theRenderer.renderCamera.Distance();
7376
+ scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
71767377
7177
- if (modified)
7378
+ if (modified || opposite)
71787379 {
71797380 //assert(false);
71807381 /*
....@@ -7220,10 +7421,10 @@
72207421 }
72217422 LA.xformDir(up, ClickInfo.matbuffer, up);
72227423 // if (!CameraPane.LOCALTRANSFORM)
7223
- LA.xformDir(up, info.pane.theRenderer.renderCamera.toScreen, up);
7424
+ LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
72247425 LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
72257426 // if (!CameraPane.LOCALTRANSFORM)
7226
- LA.xformDir(away, info.pane.theRenderer.renderCamera.toScreen, away);
7427
+ LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
72277428 //LA.vecCross(up, cVector.Z, right2);
72287429
72297430 cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
....@@ -7268,6 +7469,7 @@
72687469
72697470 if (modified)
72707471 {
7472
+ // Rotate 90 degrees
72717473 angle /= (Math.PI / 4);
72727474 angle = Math.floor(angle + 0.5);
72737475 angle *= (Math.PI / 4);
....@@ -7281,7 +7483,7 @@
72817483 }
72827484 /**/
72837485
7284
- switch (info.pane.renderCamera.viewCode)
7486
+ switch (info.pane.RenderCamera().viewCode)
72857487 {
72867488 case 1: // '\001'
72877489 LA.matZRotate(toParent, angle);
....@@ -7309,24 +7511,27 @@
73097511
73107512 case hitScale: // scale
73117513 double hScale = (double) (info.x - centerPt.x) / 32;
7514
+ double sign = 1;
7515
+ if (hScale < 0)
7516
+ {
7517
+ sign = -1;
7518
+ }
7519
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
73127520 if (hScale < 0.01)
73137521 {
7314
- hScale = 0.01;
7522
+ //hScale = 0.01;
73157523 }
7316
- hScale = Math.pow(hScale, scale * 50);
7317
- if (hScale < 0.01)
7318
- {
7319
- hScale = 0.01;
7320
- }
7524
+
73217525 double vScale = (double) (info.y - centerPt.y) / 32;
7322
- if (vScale < 0.01)
7526
+ sign = 1;
7527
+ if (vScale < 0)
73237528 {
7324
- vScale = 0.01;
7529
+ sign = -1;
73257530 }
7326
- vScale = Math.pow(vScale, scale * 50);
7531
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
73277532 if (vScale < 0.01)
73287533 {
7329
- vScale = 0.01;
7534
+ //vScale = 0.01;
73307535 }
73317536 LA.matCopy(startMat, toParent);
73327537 /**/
....@@ -7337,39 +7542,47 @@
73377542 }
73387543 /**/
73397544
7340
- switch (info.pane.renderCamera.viewCode)
7545
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7546
+
7547
+ if (totalScale < 0.01)
7548
+ {
7549
+ totalScale = 0.01;
7550
+ }
7551
+
7552
+ switch (info.pane.RenderCamera().viewCode)
73417553 {
73427554 case 3: // '\001'
7343
- if (modified)
7555
+ if (modified || opposite)
73447556 {
73457557 //LA.matScale(toParent, 1, hScale, vScale);
7346
- LA.matScale(toParent, vScale, 1, 1);
7558
+ LA.matScale(toParent, totalScale, 1, 1);
73477559 } // vScale, 1);
73487560 else
73497561 {
7350
- LA.matScale(toParent, vScale, vScale, vScale);
7562
+ // EXCEPTION!
7563
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
73517564 } // vScale, 1);
73527565 break;
73537566
73547567 case 2: // '\002'
7355
- if (modified)
7568
+ if (modified || opposite)
73567569 {
73577570 //LA.matScale(toParent, hScale, 1, vScale);
7358
- LA.matScale(toParent, 1, vScale, 1);
7571
+ LA.matScale(toParent, 1, totalScale, 1);
73597572 } else
73607573 {
7361
- LA.matScale(toParent, vScale, 1, vScale);
7574
+ LA.matScale(toParent, totalScale, 1, totalScale);
73627575 }
73637576 break;
73647577
73657578 case 1: // '\003'
7366
- if (modified)
7579
+ if (modified || opposite)
73677580 {
73687581 //LA.matScale(toParent, hScale, vScale, 1);
7369
- LA.matScale(toParent, 1, 1, vScale);
7582
+ LA.matScale(toParent, 1, 1, totalScale);
73707583 } else
73717584 {
7372
- LA.matScale(toParent, vScale, vScale, 1);
7585
+ LA.matScale(toParent, totalScale, totalScale, 1);
73737586 }
73747587 break;
73757588 }
....@@ -7502,14 +7715,22 @@
75027715 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
75037716 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
75047717 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7718
+
7719
+ String objname;
7720
+
75057721 if (false) //parent != null)
75067722 {
7507
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7723
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
75087724 } else
75097725 {
7510
- return GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ") ")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ +System.identityHashCode(this);
7726
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
75117727 } // + super.toString();
75127728 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
7729
+
7730
+ if (!Globals.ADVANCED)
7731
+ return objname;
7732
+
7733
+ return objname + " " + System.identityHashCode(this);
75137734 }
75147735
75157736 public int hashCode()
....@@ -7565,6 +7786,7 @@
75657786 objectUI.closeUI();
75667787 if (editWindow != null)
75677788 {
7789
+ editWindow.ctrlPanel.FlushUI();
75687790 editWindow.refreshContents();
75697791 } // ? new
75707792 objectUI = null;
....@@ -7585,7 +7807,7 @@
75857807 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
75867808
75877809 Object3D /*Composite*/ parent;
7588
- Object3D /*Composite*/ fileparent;
7810
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
75897811
75907812 double[][] toParent; // dynamic matrix
75917813 double[][] fromParent;
....@@ -7700,7 +7922,7 @@
77007922 {
77017923 assert(bRep != null);
77027924 if (!(support instanceof GenericJoint)) // support.bRep != null)
7703
- GrafreeD.Assert(support.bRep == bRep.support);
7925
+ Grafreed.Assert(support.bRep == bRep.support);
77047926 }
77057927 else
77067928 {
....@@ -7749,9 +7971,9 @@
77497971 private static cVector edge2 = new cVector();
77507972 //private static cVector norm = new cVector();
77517973 /*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;
7974
+ static final int hitCenter = 1;
7975
+ static final int hitScale = 2;
7976
+ static final int hitRotate = 3;
77557977 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
77567978 /*transient*/ private Point centerPt;
77577979 /*transient*/ private int startX;