Normand Briere
2019-06-17 13e9febe94aaeebad9c97f6d3e2aa4d73b2495c8
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,13 +14,35 @@
1314 import //weka.core.
1415 matrix.Matrix;
1516
17
+import java.util.UUID;
18
+
1619 //import net.sourceforge.sizeof.SizeOf;
1720 public class Object3D extends Vector<Object3D> implements java.io.Serializable, iSendInfo //, aurelienribon.tweenengine.TweenAccessor<Object3D>
1821 {
1922 //static final long serialVersionUID = -607422624994562685L;
2023 static final long serialVersionUID = 5022536242724664900L;
2124
25
+ private UUID uuid = UUID.randomUUID();
26
+
27
+ // TEMPORARY for mocap undo
28
+ mocap.reader.BVHReader.BVHResult bvh;
29
+ Object3D skeleton;
30
+ //
31
+
2232 ScriptNode scriptnode;
33
+
34
+ void InitOthers()
35
+ {
36
+ if (projectedVertices == null || projectedVertices.length <= 2)
37
+ {
38
+ projectedVertices = new Object3D.cVector2[3];
39
+ }
40
+ for (int i = 0; i < 3; i++)
41
+ {
42
+ projectedVertices[i] = new cVector2(); // Others
43
+ }
44
+ projectedVertices[0].x = 100; // bump
45
+ }
2346
2447 void MinMax(cVector minima, cVector maxima)
2548 {
....@@ -86,64 +109,136 @@
86109
87110 // transient boolean reduced; // for morph reduction
88111
89
-transient com.bulletphysics.linearmath.Transform cache; // for fast merge
90
-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
91114
92
-transient Object3D transientsupport; // for cloning
93
-transient boolean transientlink2master;
115
+ transient Object3D transientsupport; // for cloning
116
+ transient boolean transientlink2master;
94117
95
-void SaveSupports()
96
-{
97
- if (blockloop)
98
- return;
99
-
100
- transientsupport = support;
101
- transientlink2master = link2master;
102
-
103
- support = null;
104
- link2master = false;
105
-
106
- if (bRep != null)
118
+ void SaveSupports()
107119 {
108
- bRep.SaveSupports();
109
- }
110
-
111
- for (int i = 0; i < Size(); i++)
112
- {
113
- Object3D child = (Object3D) get(i);
114
- if (child == null)
115
- continue;
116
- blockloop = true;
117
- child.SaveSupports();
118
- blockloop = false;
119
- }
120
-}
120
+ if (blockloop)
121
+ return;
121122
122
-void RestoreSupports()
123
-{
124
- if (blockloop)
125
- return;
123
+ transientsupport = support;
124
+ transientlink2master = link2master;
126125
127
- support = transientsupport;
128
- link2master = transientlink2master;
129
- transientsupport = null;
130
- transientlink2master = false;
131
-
132
- if (bRep != null)
133
- {
134
- 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
+ }
135143 }
136
-
137
- for (int i = 0; i < Size(); i++)
144
+
145
+ void RestoreSupports()
138146 {
139
- Object3D child = (Object3D) get(i);
140
- if (child == null)
141
- continue;
142
- blockloop = true;
143
- child.RestoreSupports();
144
- 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
+ }
145169 }
146
-}
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
+ }
147242
148243 // MOCAP SUPPORT
149244 double tx,ty,tz,rx,ry,rz;
....@@ -286,6 +381,7 @@
286381 }
287382
288383 boolean live = false;
384
+ boolean dontselect = false;
289385 boolean hide = false;
290386 boolean link2master = false; // performs reset support/master at each frame
291387 boolean marked = false; // animation node
....@@ -295,6 +391,8 @@
295391 boolean random = false;
296392 boolean speedup = false;
297393 boolean rewind = false;
394
+
395
+ float NORMALPUSH = 0;
298396
299397 Object3D support;
300398
....@@ -355,7 +453,7 @@
355453
356454 int MemorySize()
357455 {
358
- if (memorysize == 0)
456
+ if (true) // memorysize == 0)
359457 {
360458 try
361459 {
....@@ -415,16 +513,16 @@
415513 {
416514 Object3D copy = this;
417515
418
- Camera parentcam = CameraPane.theRenderer.manipCamera;
516
+ Camera parentcam = Globals.theRenderer.ManipCamera();
419517
420
- if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[0])
518
+ if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[0])
421519 {
422
- parentcam = CameraPane.theRenderer.cameras[1];
520
+ parentcam = Globals.theRenderer.Cameras()[1];
423521 }
424522
425
- if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[1])
523
+ if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[1])
426524 {
427
- parentcam = CameraPane.theRenderer.cameras[0];
525
+ parentcam = Globals.theRenderer.Cameras()[0];
428526 }
429527
430528 if (this == parentcam)
....@@ -432,7 +530,7 @@
432530 //assert(this instanceof Camera);
433531
434532 for (int count = parentcam.GetTransformCount(); --count>=0;)
435
- LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.toParent, CameraPane.theRenderer.targetLookAt);
533
+ LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.toParent, Globals.theRenderer.TargetLookAt());
436534 }
437535
438536 copy.marked ^= true;
....@@ -452,7 +550,7 @@
452550 //assert(this instanceof Camera);
453551
454552 for (int count = parentcam.GetTransformCount(); --count>=0;)
455
- LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.fromParent, CameraPane.theRenderer.targetLookAt);
553
+ LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.fromParent, Globals.theRenderer.TargetLookAt());
456554 }
457555
458556 copy.Touch(); // display list issue
....@@ -465,12 +563,14 @@
465563 toParent = LA.newMatrix();
466564 fromParent = LA.newMatrix();
467565 }
566
+
468567 if (toParentMarked == null)
469568 {
470569 if (maxcount != 1)
471570 {
472571 new Exception().printStackTrace();
473572 }
573
+
474574 toParentMarked = LA.newMatrix();
475575 fromParentMarked = LA.newMatrix();
476576 }
....@@ -587,7 +687,7 @@
587687 return;
588688 }
589689
590
- if (CameraPane.fromscript)
690
+ if (Globals.fromscript)
591691 {
592692 transformcount = 0;
593693 return;
....@@ -745,7 +845,7 @@
745845
746846 int GetTransformCount()
747847 {
748
- // marde pour serialization de Texture
848
+ // patch pour serialization de Texture
749849 resetmaxcount();
750850 resettransformcount();
751851 resetstep();
....@@ -758,7 +858,7 @@
758858 if (step == 0)
759859 step = 1;
760860 if (maxcount == 0)
761
- maxcount = 2048; // 4;
861
+ maxcount = 128; // 2048; // 4;
762862 // if (acceleration == 0)
763863 // acceleration = 10;
764864 if (delay == 0) // serial
....@@ -779,9 +879,12 @@
779879 // factor = CameraPane.STEP;
780880 // }
781881
782
- if (marked && CameraPane.isLIVE() && live && CameraPane.drawMode == CameraPane.SHADOW && currentframe != CameraPane.framecount)
882
+ if (marked && Globals.isLIVE() && live &&
883
+ //TEMP21aug2018
884
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
885
+ currentframe != Globals.framecount)
783886 {
784
- currentframe = CameraPane.framecount;
887
+ currentframe = Globals.framecount;
785888
786889 // System.err.println("transformcount = " + transformcount);
787890 // System.err.println("factor = " + factor);
....@@ -893,6 +996,11 @@
893996 fromParent = null; // LA.newMatrix();
894997 bRep = null; // new BoundaryRep();
895998
999
+ if (oname != null && oname.equals("LeftHand"))
1000
+ {
1001
+ name = oname;
1002
+ }
1003
+
8961004 /*
8971005 float hue = (float)Math.random();
8981006 Color col;
....@@ -935,7 +1043,7 @@
9351043
9361044 public Object clone()
9371045 {
938
- return GraphreeD.clone(this);
1046
+ return Grafreed.clone(this);
9391047 }
9401048
9411049 Object3D copyExpand()
....@@ -1446,7 +1554,16 @@
14461554 // if (other == null)
14471555 // return;
14481556
1449
- System.out.println("Link support this = " + this + "; other = " + other);
1557
+ if (other != null)
1558
+ {
1559
+ BoundaryRep.SEUIL = other.material.cameralight;
1560
+
1561
+ // Set default to 0.1
1562
+ BoundaryRep.SEUIL /= 4; // 2;
1563
+ System.out.println("SEUIL = " + BoundaryRep.SEUIL);
1564
+ }
1565
+
1566
+ System.out.println("Link this = " + this + "; support = " + other);
14501567
14511568 //if (bRep != null)
14521569 // bRep.linkVerticesThis(other.bRep);
....@@ -1701,7 +1818,7 @@
17011818 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17021819 o.bRep = transientrep;
17031820 if (clone)
1704
- o.bRep = (BoundaryRep) GraphreeD.clone(transientrep);
1821
+ o.bRep = (BoundaryRep) Grafreed.clone(transientrep);
17051822 o.CreateMaterial();
17061823 o.SetAttributes(this, -1);
17071824 //parent
....@@ -1714,7 +1831,7 @@
17141831 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17151832 o.bRep = bRep;
17161833 if (clone)
1717
- o.bRep = (BoundaryRep) GraphreeD.clone(bRep);
1834
+ o.bRep = (BoundaryRep) Grafreed.clone(bRep);
17181835 o.CreateMaterial();
17191836 //o.overwriteThis(this, -1);
17201837 o.SetAttributes(this, -1);
....@@ -1756,7 +1873,7 @@
17561873 // {
17571874 // assert(bRep == null);
17581875 // Object3D o = new Object3D("Geometry:" + this.name);
1759
-// o.bRep = (BoundaryRep) GraphreeD.clone(transientrep);
1876
+// o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
17601877 // o.CreateMaterial();
17611878 // parent.addChild(o);
17621879 // }
....@@ -1765,7 +1882,7 @@
17651882 // {
17661883 // assert(transientrep == null);
17671884 // Object3D o = new Object3D("Geometry:" + this.name);
1768
-// o.bRep = (BoundaryRep) GraphreeD.clone(bRep);
1885
+// o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
17691886 // o.CreateMaterial();
17701887 // parent.addChild(o);
17711888 // }
....@@ -1801,12 +1918,15 @@
18011918 if (obj.name == null)
18021919 continue; // can't be a null one
18031920
1921
+ // Try perfect match first.
18041922 if (n.equals(obj.name))
18051923 {
18061924 theobj = obj;
18071925 count++;
18081926 }
18091927 }
1928
+
1929
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18101930
18111931 if (count != 1)
18121932 for (int i=Size(); --i>=0;)
....@@ -1816,8 +1936,9 @@
18161936 if (obj.name == null)
18171937 continue; // can't be a null one
18181938
1819
- //if (n.contains(obj.name)) // dec 2013 name.split(":")[0])) // Poser generates a count
1820
- if (n.startsWith(obj.name))
1939
+ String name = obj.name.split(":")[0]; // Poser generates a count
1940
+ //if (n.startsWith(obj.name))
1941
+ if (n.contains(name))
18211942 {
18221943 theobj = obj;
18231944 count++;
....@@ -2120,15 +2241,8 @@
21202241 if (/*parent != null &&*/ material == null)
21212242 {
21222243 material = new cMaterial(GetMaterial());
2123
- if (projectedVertices == null || projectedVertices.length <= 2)
2124
- {
2125
- projectedVertices = new Object3D.cVector2[3];
2126
- }
2127
- for (int i = 0; i < 3; i++)
2128
- {
2129
- projectedVertices[i] = new cVector2(); // Others
2130
- }
2131
- projectedVertices[0].x = 100; // bump
2244
+
2245
+ InitOthers();
21322246
21332247 if (this instanceof Camera)
21342248 {
....@@ -2278,6 +2392,7 @@
22782392 {
22792393 if (newWindow)
22802394 {
2395
+ new Exception().printStackTrace();
22812396 System.exit(0);
22822397 if (parent != null)
22832398 {
....@@ -2454,13 +2569,13 @@
24542569 return retval;
24552570 }
24562571
2457
- void doEditDrag(ClickInfo info)
2572
+ void doEditDrag(ClickInfo info, boolean opposite)
24582573 {
24592574 switch (doSomething)
24602575 {
24612576 case 1: // '\001'
24622577 //super.
2463
- doEditDrag0(info);
2578
+ doEditDrag0(info, opposite);
24642579 break;
24652580
24662581 case 2: // '\002'
....@@ -2473,11 +2588,11 @@
24732588 {
24742589 //sel.hitSomething = childToDrag.hitSomething;
24752590 //childToDrag.doEditDrag(info);
2476
- sel.doEditDrag(info);
2591
+ sel.doEditDrag(info, opposite);
24772592 } else
24782593 {
24792594 //super.
2480
- doEditDrag0(info);
2595
+ doEditDrag0(info, opposite);
24812596 }
24822597 }
24832598 break;
....@@ -2587,6 +2702,18 @@
25872702 void GenNormalsS(boolean crease)
25882703 {
25892704 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();
25902717 // for (int i=0; i<selection.size(); i++)
25912718 // {
25922719 // Object3D selectee = (Object3D) selection.elementAt(i);
....@@ -2732,6 +2859,42 @@
27322859 blockloop = false;
27332860 }
27342861
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();
2875
+// Children().release(i);
2876
+ }
2877
+ blockloop = false;
2878
+ }
2879
+
2880
+ void GenNormalsMINE()
2881
+ {
2882
+ if (blockloop)
2883
+ return;
2884
+
2885
+ blockloop = true;
2886
+ GenNormalsMINE0();
2887
+ for (int i = 0; i < Children().Size(); i++)
2888
+ {
2889
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2890
+ if (child == null)
2891
+ continue;
2892
+ child.GenNormalsMINE();
2893
+// Children().release(i);
2894
+ }
2895
+ blockloop = false;
2896
+ }
2897
+
27352898 void ClearColors()
27362899 {
27372900 if (blockloop)
....@@ -2866,7 +3029,8 @@
28663029 {
28673030 if (bRep != null)
28683031 {
2869
- bRep.GenUV();
3032
+ bRep.GenUV(); //1);
3033
+ //bRep.UnfoldUV();
28703034 Touch();
28713035 }
28723036 }
....@@ -2876,6 +3040,24 @@
28763040 if (bRep != null)
28773041 {
28783042 bRep.GenerateNormals(crease);
3043
+ Touch();
3044
+ }
3045
+ }
3046
+
3047
+ void GenNormalsMesh0()
3048
+ {
3049
+ if (bRep != null)
3050
+ {
3051
+ bRep.GenerateNormalsMesh();
3052
+ Touch();
3053
+ }
3054
+ }
3055
+
3056
+ void GenNormalsMINE0()
3057
+ {
3058
+ if (bRep != null)
3059
+ {
3060
+ bRep.GenerateNormalsMINE();
28793061 Touch();
28803062 }
28813063 }
....@@ -2932,6 +3114,33 @@
29323114 blockloop = false;
29333115 }
29343116
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
+
29353144 void TransformGeometry()
29363145 {
29373146 Object3D obj = this;
....@@ -3153,9 +3362,11 @@
31533362
31543363 BoundaryRep sup = bRep.support;
31553364 bRep.support = null;
3156
- BoundaryRep temprep = (BoundaryRep) GraphreeD.clone(bRep);
3365
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
31573366 // bRep.SplitInTwo(onlyone); // thread...
3158
- temprep.SplitInTwo(reduction34, onlyone);
3367
+
3368
+ while(temprep.SplitInTwo(reduction34, onlyone));
3369
+
31593370 bRep = temprep;
31603371 bRep.support = sup;
31613372 Touch();
....@@ -3677,7 +3888,7 @@
36773888 if (child == null)
36783889 continue;
36793890
3680
- if (GraphreeD.RENDERME > 0)
3891
+ if (Grafreed.RENDERME > 0)
36813892 {
36823893 if (child instanceof Merge)
36833894 ((Merge)child).renderme();
....@@ -3717,7 +3928,7 @@
37173928
37183929 boolean getCentroid(cVector centroid, boolean xform)
37193930 {
3720
- assert(false);
3931
+// for speaker assert(false);
37213932 if (blockloop)
37223933 return false;
37233934
....@@ -3828,7 +4039,7 @@
38284039 if (child == null)
38294040 continue;
38304041
3831
- if (GraphreeD.RENDERME > 0)
4042
+ if (Grafreed.RENDERME > 0)
38324043 {
38334044 if (child instanceof Merge)
38344045 ((Merge)child).renderme();
....@@ -4023,7 +4234,7 @@
40234234 if (child == null)
40244235 continue;
40254236
4026
- if (GraphreeD.RENDERME > 0)
4237
+ if (Grafreed.RENDERME > 0)
40274238 {
40284239 if (child instanceof Merge)
40294240 ((Merge)child).renderme();
....@@ -4111,7 +4322,7 @@
41114322 if (blockloop)
41124323 return;
41134324
4114
- for (int i=0; i<size(); i++)
4325
+ for (int i=0; i<Size(); i++)
41154326 {
41164327 if (get(i).parent != this)
41174328 {
....@@ -4120,6 +4331,22 @@
41204331 }
41214332 blockloop = true;
41224333 get(i).RepairParent();
4334
+ blockloop = false;
4335
+ }
4336
+ }
4337
+
4338
+ void RepairShadow()
4339
+ {
4340
+ if (blockloop)
4341
+ return;
4342
+
4343
+ if (this.material != null)
4344
+ this.InitOthers();
4345
+
4346
+ for (int i=0; i<Size(); i++)
4347
+ {
4348
+ blockloop = true;
4349
+ get(i).RepairShadow();
41234350 blockloop = false;
41244351 }
41254352 }
....@@ -4515,16 +4742,28 @@
45154742
45164743 Object3D GetFileRoot()
45174744 {
4745
+ if (overflow)
4746
+ return null;
4747
+
4748
+ overflow = true;
4749
+
4750
+ Object3D pfr = null;
4751
+
45184752 if (parent == null && fileparent == null)
4519
- return this;
4753
+ pfr = this;
45204754
45214755 if (parent == null && fileparent != null) // V4.gfd???
4522
- return fileparent;
4756
+ pfr = fileparent;
45234757
4524
- if (parent == null)
4525
- return this;
4758
+ if (pfr == null && parent == null)
4759
+ pfr = this;
45264760
4527
- return parent.GetFileRoot();
4761
+ if (pfr == null)
4762
+ pfr = parent.GetFileRoot();
4763
+
4764
+ overflow = false;
4765
+
4766
+ return pfr;
45284767 }
45294768
45304769 cTreePath GetPath()
....@@ -4602,7 +4841,7 @@
46024841
46034842 cTreePath SelectLeaf(int indexcount, boolean deselect)
46044843 {
4605
- if (hide)
4844
+ if (hide || dontselect)
46064845 return null;
46074846
46084847 if (count <= 0)
....@@ -4628,7 +4867,7 @@
46284867
46294868 cTreePath Select(int indexcount, boolean deselect)
46304869 {
4631
- if (hide)
4870
+ if (hide || dontselect)
46324871 return null;
46334872
46344873 if (count <= 0)
....@@ -4778,7 +5017,7 @@
47785017 return globalTransform;
47795018 }
47805019
4781
- void PreprocessOcclusion(CameraPane cp)
5020
+ void PreprocessOcclusion(iCameraPane cp)
47825021 {
47835022 /*
47845023 if (AOdone)
....@@ -4925,7 +5164,8 @@
49255164 } else //
49265165 if (editWindow != null)
49275166 {
4928
- editWindow.cameraView.lighttouched = true;
5167
+ //editWindow.cameraView.lighttouched = true;
5168
+ Globals.lighttouched = true;
49295169 }
49305170 }
49315171
....@@ -5079,10 +5319,34 @@
50795319
50805320 // System.out.println("Fullname = " + fullname);
50815321
5082
- if (fullname.name.indexOf(":") == -1)
5083
- return fullname.name;
5322
+ // Does not work on Windows due to C:
5323
+// if (fullname.name.indexOf(":") == -1)
5324
+// return fullname.name;
5325
+//
5326
+// return fullname.name.substring(0,fullname.name.indexOf(":"));
50845327
5085
- return fullname.name.substring(0,fullname.name.indexOf(":"));
5328
+ String[] split = fullname.name.split(":");
5329
+
5330
+ if (split.length == 0)
5331
+ {
5332
+ return "";
5333
+ }
5334
+
5335
+ if (split.length <= 2)
5336
+ {
5337
+ if (fullname.name.endsWith(":"))
5338
+ {
5339
+ // Windows
5340
+ return fullname.name.substring(0, fullname.name.length()-1);
5341
+ }
5342
+
5343
+ return split[0];
5344
+ }
5345
+
5346
+ // Windows
5347
+ assert(split.length == 4);
5348
+
5349
+ return split[0] + ":" + split[1];
50865350 }
50875351
50885352 static String GetBump(cTexture fullname)
....@@ -5091,10 +5355,38 @@
50915355 return "";
50925356
50935357 // System.out.println("Fullname = " + fullname);
5094
- if (fullname.name.indexOf(":") == -1)
5095
- return "";
5096
-
5097
- return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5358
+ // Does not work on Windows due to C:
5359
+// if (fullname.name.indexOf(":") == -1)
5360
+// return "";
5361
+//
5362
+// return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5363
+ String[] split = fullname.name.split(":");
5364
+
5365
+ if (split.length == 0)
5366
+ {
5367
+ return "";
5368
+ }
5369
+
5370
+ if (split.length == 1)
5371
+ {
5372
+ return "";
5373
+ }
5374
+
5375
+ if (split.length == 2)
5376
+ {
5377
+ if (fullname.name.endsWith(":"))
5378
+ {
5379
+ // Windows
5380
+ return "";
5381
+ }
5382
+
5383
+ return split[1];
5384
+ }
5385
+
5386
+ // Windows
5387
+ assert(split.length == 4);
5388
+
5389
+ return split[2] + ":" + split[3];
50985390 }
50995391
51005392 String GetPigmentTexture()
....@@ -5168,7 +5460,7 @@
51685460 System.out.print("; textures = " + textures);
51695461 System.out.println("; usedtextures = " + usedtextures);
51705462
5171
- if (GetTextures() == null)
5463
+ if (GetTextures() == null) // What is that??
51725464 GetTextures().name = ":";
51735465
51745466 String texname = tex;
....@@ -5199,6 +5491,43 @@
51995491 child.ResetPigmentTexture();
52005492 blockloop = false;
52015493 }
5494
+ }
5495
+
5496
+ UUID GetUUID()
5497
+ {
5498
+ if (uuid == null)
5499
+ {
5500
+ // Serial
5501
+ uuid = UUID.randomUUID();
5502
+ }
5503
+
5504
+ return uuid;
5505
+ }
5506
+
5507
+ Object3D GetObject(UUID uid)
5508
+ {
5509
+ if (blockloop)
5510
+ return null;
5511
+
5512
+ if (GetUUID().equals(uid))
5513
+ return this;
5514
+
5515
+ int nb = Size();
5516
+ for (int i = 0; i < nb; i++)
5517
+ {
5518
+ Object3D child = (Object3D) get(i);
5519
+
5520
+ if (child == null)
5521
+ continue;
5522
+
5523
+ blockloop = true;
5524
+ Object3D obj = child.GetObject(uid);
5525
+ blockloop = false;
5526
+ if (obj != null)
5527
+ return obj;
5528
+ }
5529
+
5530
+ return null;
52025531 }
52035532
52045533 void SetBumpTexture(String tex)
....@@ -5237,25 +5566,33 @@
52375566 }
52385567 }
52395568
5240
- void draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5569
+ void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
52415570 {
52425571 Draw(display, root, selected, blocked);
52435572 }
52445573
5245
- static cMaterial[] materialstack = new cMaterial[65536];
5246
- static boolean[] selectedstack = new boolean[65536];
5247
- static int materialdepth = 0;
5248
-
52495574 boolean NeedSupport()
52505575 {
52515576 return
5252
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5577
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
52535578 // PROBLEM with CROWD!!
5254
- && (CameraPane.drawMode == CameraPane.SHADOW || CameraPane.CROWD);
5579
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
52555580 }
52565581
5582
+ static boolean DEBUG_SELECTION = false;
52575583
5258
- void Draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5584
+ boolean IsLive()
5585
+ {
5586
+ if (live)
5587
+ return true;
5588
+
5589
+ if (parent == null)
5590
+ return false;
5591
+
5592
+ return parent.IsLive();
5593
+ }
5594
+
5595
+ void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
52595596 {
52605597 Invariants(); // june 2013
52615598
....@@ -5264,8 +5601,8 @@
52645601 // System.err.println("Draw " + this + " Frame # " + ((Mocap)((Merge)support).object).frame);
52655602 }
52665603
5267
- if (display.drawMode == CameraPane.SELECTION &&
5268
- hide)
5604
+ if (display.DrawMode() == iCameraPane.SELECTION &&
5605
+ (hide || dontselect))
52695606 return;
52705607
52715608 if (name != null && name.contains("sclera"))
....@@ -5280,10 +5617,10 @@
52805617 if (name != null && name.contains("sclera"))
52815618 name = name;
52825619
5283
- if (this instanceof CheckerIG)
5620
+ if (this instanceof Checker)
52845621 return;
52855622
5286
- if (display.drawMode == display.SHADOW && PASSTEST)
5623
+ if (display.DrawMode() == display.SHADOW && PASSTEST)
52875624 return;
52885625
52895626 if (count <= 0)
....@@ -5291,13 +5628,13 @@
52915628 return;
52925629 }
52935630
5294
- if ((//display.drawMode == CameraPane.SHADOW ||
5295
- display.drawMode == CameraPane.SELECTION || CameraPane.DEBUG_SELECTION) && HasTransparency())
5631
+ if ((//display.DrawMode() == CameraPane.SHADOW ||
5632
+ display.DrawMode() == iCameraPane.SELECTION || display.IsDebugSelection()) && HasTransparency())
52965633 {
52975634 return;
52985635 }
52995636
5300
- javax.media.opengl.GL gl = display.GetGL();
5637
+ //javax.media.opengl.GL gl = display.GetGL();
53015638
53025639 /*
53035640 if (touched)
....@@ -5316,7 +5653,7 @@
53165653 support = support;
53175654
53185655 //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5319
- boolean usecalllists = false; // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5656
+ boolean usecalllists = IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
53205657
53215658 if (!usecalllists && bRep != null && bRep.displaylist > 0)
53225659 {
....@@ -5333,15 +5670,17 @@
53335670
53345671 boolean compiled = false;
53355672
5336
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
5673
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
53375674
5338
- if (!selectmode && //display.drawMode != display.SELECTION &&
5339
- (touched || (bRep != null && bRep.displaylist <= 0)))
5675
+ if (!selectmode && //display.DrawMode() != display.SELECTION &&
5676
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5677
+ (Globals.isLIVE() || touched && (bRep != null && bRep.displaylist <= 0)))
53405678 {
5341
- display.lighttouched = true;
5679
+ Globals.lighttouched = true;
53425680 } // all panes...
5343
- //if (usecalllists && display.drawMode != display.SELECTION && display.drawMode != display.SHADOW &&
5344
- if (bRep != null && usecalllists && !selectmode && // june 2013 display.drawMode != display.SHADOW &&
5681
+
5682
+ //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
5683
+ if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
53455684 (touched || (bRep != null && bRep.displaylist <= 0)))
53465685 {
53475686 if (!(this instanceof Composite))
....@@ -5349,7 +5688,7 @@
53495688 //if (displaylist == -1 && usecalllists)
53505689 if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
53515690 {
5352
- bRep.displaylist = gl.glGenLists(1);
5691
+ bRep.displaylist = display.GenList();
53535692 assert(bRep.displaylist != 0);
53545693 // System.err.println("glGenLists: " + bRep.displaylist + " for " + this);
53555694 //System.out.println("\tgen list " + list);
....@@ -5361,18 +5700,20 @@
53615700 if (usecalllists)
53625701 {
53635702 // System.err.println("new list " + bRep.displaylist + " for " + this);
5364
- gl.glNewList(bRep.displaylist, gl.GL_COMPILE); //_AND_EXECUTE);
5703
+ display.NewList(bRep.displaylist);
53655704 }
5705
+
53665706 CallList(display, root, selected, blocked);
5707
+
53675708 // compiled = true;
53685709 if (usecalllists)
53695710 {
53705711 // System.err.println("end list " + bRep.displaylist + " for " + this);
5371
- gl.glEndList();
5712
+ display.EndList();
53725713 }
53735714 //gl.glDrawBuffer(gl.GL_BACK);
53745715 // XXX touched = false;
5375
- display.lighttouched = true; // all panes...
5716
+ Globals.lighttouched = true; // all panes...
53765717 }
53775718
53785719 touched = GetBRep() == null; // this instanceof Composite || this instanceof FileObject; // false;
....@@ -5411,12 +5752,12 @@
54115752
54125753 // frustum culling
54135754 if (CameraPane.FRUSTUM && !blocked && !IsInfinite() && GetBRep() != null // && GetBRep().VertexCount() != 1260 // default grid
5414
- && display.drawMode != CameraPane.SELECTION)
5755
+ && display.DrawMode() != iCameraPane.SELECTION)
54155756 {
5416
- if (display.drawMode == CameraPane.SHADOW)
5757
+ if (display.DrawMode() == iCameraPane.SHADOW)
54175758 {
54185759 if (!link2master // tricky to cull in shadow mode.
5419
- && GetBRep().FrustumCull(this, gl, display.lightCamera, true))
5760
+ && GetBRep().FrustumCull(this, null, display.LightCamera(), true))
54205761 {
54215762 //System.out.print("CULLED");
54225763 culled = true;
....@@ -5424,7 +5765,7 @@
54245765 }
54255766 else
54265767 //GetBRep().getBounds(v0, v1, this);
5427
- if (GetBRep().FrustumCull(this, gl, display.renderCamera, false))
5768
+ if (GetBRep().FrustumCull(this, null, display.RenderCamera(), false))
54285769 culled = true;
54295770
54305771 // LA.xformPos(v0, display.renderCamera.toScreen, v0);
....@@ -5460,11 +5801,11 @@
54605801
54615802
54625803 if (!culled)
5463
- if (display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION)
5804
+ if (display.DrawMode() == display.SELECTION || display.IsDebugSelection())
54645805 {
54655806 if (GetBRep() != null)
54665807 {
5467
- CameraPane.NextIndex(this, gl);
5808
+ display.NextIndex();
54685809 // vertex color conflict : gl.glCallList(list);
54695810 DrawNode(display, root, selected);
54705811 if (this instanceof BezierPatch)
....@@ -5486,53 +5827,7 @@
54865827 color[2] /= 2;
54875828 gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT_AND_DIFFUSE, color, 0);
54885829 */
5489
- if (material != null)
5490
- {
5491
- materialstack[materialdepth] = material;
5492
- selectedstack[materialdepth] = selected;
5493
- cStatic.objectstack[materialdepth++] = this;
5494
- //System.out.println("material " + material);
5495
- //Applet3D.tracein(this, selected);
5496
- display.vector2buffer = projectedVertices;
5497
- if (this instanceof Camera)
5498
- {
5499
- display.options1[0] = material.shift;
5500
- //System.out.println("shift " + material.shift);
5501
- display.options1[1] = material.lightarea;
5502
- display.options1[2] = material.shadowbias;
5503
- display.options1[3] = material.aniso;
5504
- display.options1[4] = material.anisoV;
5505
- display.options2[0] = material.opacity;
5506
- display.options2[1] = material.diffuse;
5507
- display.options2[2] = material.factor;
5508
-
5509
- cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
5510
- display.options3[3] = material.cameralight/0.2f;
5511
-
5512
- // if (display.CURRENTANTIALIAS > 0)
5513
- // display.options3[3] /= 4;
5514
-
5515
- /*
5516
- System.out.println("Focus = " + display.options1[0]);
5517
- System.out.println("Aperture = " + display.options1[1]);
5518
- System.out.println("ShadowBlur = " + display.options1[2]);
5519
- System.out.println("Antialiasing = " + display.options1[3]);
5520
- System.out.println("Fog = " + display.options2[0]);
5521
- System.out.println("Intensity = " + display.options2[1]);
5522
- System.out.println("Elevation = " + display.options2[2]);
5523
- /**/
5524
- } else
5525
- {
5526
- material.Draw(display, selected);
5527
- }
5528
- } else
5529
- {
5530
- if (selected && CameraPane.flash)
5531
- {
5532
- display.modelParams4[1] = 100;
5533
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
5534
- }
5535
- }
5830
+ display.PushMaterial(this, selected);
55365831
55375832 //System.out.println("call list " + list);
55385833 //System.out.println();
....@@ -5551,7 +5846,17 @@
55515846 tex = GetTextures();
55525847 }
55535848
5554
- display.BindTextures(tex, texres);
5849
+ boolean failed = false;
5850
+
5851
+ try
5852
+ {
5853
+ display.BindTextures(tex, texres);
5854
+ }
5855
+ catch (Exception e)
5856
+ {
5857
+ System.err.println("FAILED: " + this);
5858
+ failed = true;
5859
+ }
55555860
55565861 if (!compiled)
55575862 {
....@@ -5567,30 +5872,16 @@
55675872
55685873 // System.err.println("glCallList: " + bRep.displaylist + " for " + this);
55695874 assert(bRep.displaylist != 0);
5570
- gl.glCallList(bRep.displaylist);
5875
+ display.CallList(bRep.displaylist);
55715876 // june 2013 drawSelf(display, root, selected);
55725877 }
55735878 }
55745879 }
55755880
5576
- display.ReleaseTextures(tex);
5577
-
5578
- //if (parent != null && parent.GetMaterial() != null)
5579
- // parent.GetMaterial().Draw(display, parent.IsSelected(this));
5580
- if (material != null)
5581
- {
5582
- materialdepth -= 1;
5583
- if (materialdepth > 0)
5584
- {
5585
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
5586
- materialstack[materialdepth - 1].Draw(display, selectedstack[materialdepth - 1]);
5587
- }
5588
- //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
5589
- } else if (selected && CameraPane.flash && GetMaterial() != null)
5590
- {
5591
- display.modelParams4[1] = GetMaterial().cameralight;
5592
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
5593
- }
5881
+ if (!failed)
5882
+ display.ReleaseTextures(tex);
5883
+
5884
+ display.PopMaterial(this, selected);
55945885 }
55955886
55965887 if (this instanceof Texture || this instanceof TextureNode)
....@@ -5632,7 +5923,7 @@
56325923 // resetMasterNode();
56335924 }
56345925
5635
- void CallList(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5926
+ void CallList(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
56365927 {
56375928 if (GetBRep() == null)
56385929 {
....@@ -5715,8 +6006,11 @@
57156006 boolean flipV = false; // true;
57166007 int texres = 0; // 0 = low, 1 = normal, 2 = high res texture
57176008
5718
- void drawSelf(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
6009
+ void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57196010 {
6011
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6012
+ return;
6013
+
57206014 if (hide)
57216015 return;
57226016 // shadow optimisation
....@@ -5774,16 +6068,7 @@
57746068 // // ??????????????????????????? Touch();
57756069 // }
57766070
5777
- if (material != null)
5778
- {
5779
- materialstack[materialdepth] = material;
5780
- selectedstack[materialdepth] = selected;
5781
- cStatic.objectstack[materialdepth++] = this;
5782
- //System.out.println("material " + material);
5783
- //Applet3D.tracein("selected ", selected);
5784
- display.vector2buffer = projectedVertices;
5785
- material.Draw(display, selected);
5786
- }
6071
+display.PushMaterial2(this, selected);
57876072
57886073 Object3D child;
57896074 boolean sel;
....@@ -5807,12 +6092,12 @@
58076092 if (!child.HasTransparency())
58086093 {
58096094 sel = root != null && root.selection != null && root.selection.indexOf(child) != -1;
5810
- // GraphreeD.tracein("draw ", child);
6095
+ // GrafreeD.tracein("draw ", child);
58116096 boolean wasblocked = blockdraw;
58126097 blockdraw = true;
58136098 child.draw(display, root, selected || sel, wasblocked || blocked); // || child.IsSelected());
58146099 blockdraw = false;
5815
- // GraphreeD.traceout("draw ", child);
6100
+ // GrafreeD.traceout("draw ", child);
58166101 }
58176102
58186103 release(i);
....@@ -5835,19 +6120,7 @@
58356120 */
58366121 //depth += 1;
58376122
5838
- if (material != null)
5839
- {
5840
- materialdepth -= 1;
5841
- if (materialdepth > 0)
5842
- {
5843
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
5844
- materialstack[materialdepth - 1].Draw(display, selectedstack[materialdepth - 1]);
5845
- }
5846
- //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
5847
- //else
5848
- //material.Draw(display, false);
5849
- }
5850
-
6123
+display.PopMaterial2(this);
58516124 /*
58526125 display.ReleaseTextures(tex);
58536126 */
....@@ -5858,10 +6131,13 @@
58586131
58596132 //static cVector min,max;
58606133
5861
- void DrawNode(CameraPane display, Object3D /*Composite*/ root, boolean selected)
6134
+ void DrawNode(iCameraPane display, Object3D /*Composite*/ root, boolean selected)
58626135 {
5863
- if (display.drawMode == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
6136
+ if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
58646137 return; // no shadow for transparent objects
6138
+
6139
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6140
+ return;
58656141
58666142 if (hide)
58676143 return;
....@@ -5903,11 +6179,12 @@
59036179 return;
59046180 }
59056181
6182
+ //bRep.GenUV(1/material.diffuseness);
59066183 // bRep.lock = true;
59076184
5908
- javax.media.opengl.GL gl = display.GetGL();
6185
+ //javax.media.opengl.GL gl = display.GetGL();
59096186
5910
- if (CameraPane.BOXMODE) // || CameraPane.movingcamera)
6187
+ if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera)
59116188 {
59126189 int fc = bRep.FaceCount();
59136190 int vc = bRep.VertexCount();
....@@ -5922,23 +6199,7 @@
59226199
59236200 bRep.getMinMax(min, max, 100);
59246201
5925
- gl.glBegin(gl.GL_LINES);
5926
-
5927
- gl.glVertex3d(min.x, min.y, min.z);
5928
- gl.glVertex3d(min.x, min.y, max.z);
5929
- gl.glVertex3d(min.x, min.y, min.z);
5930
- gl.glVertex3d(min.x, max.y, min.z);
5931
- gl.glVertex3d(min.x, min.y, min.z);
5932
- gl.glVertex3d(max.x, min.y, min.z);
5933
-
5934
- gl.glVertex3d(max.x, max.y, max.z);
5935
- gl.glVertex3d(min.x, max.y, max.z);
5936
- gl.glVertex3d(max.x, max.y, max.z);
5937
- gl.glVertex3d(max.x, min.y, max.z);
5938
- gl.glVertex3d(max.x, max.y, max.z);
5939
- gl.glVertex3d(max.x, max.y, min.z);
5940
-
5941
- gl.glEnd();
6202
+ display.DrawBox(min, max);
59426203
59436204 return;
59446205 }
....@@ -5982,7 +6243,7 @@
59826243 {
59836244 //throw new Error();
59846245
5985
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
6246
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
59866247
59876248 int[] strips = bRep.getRawIndices();
59886249
....@@ -5992,178 +6253,14 @@
59926253 new Exception().printStackTrace();
59936254 return;
59946255 }
5995
-
5996
- // TRIANGLE STRIP ARRAY
5997
- if (bRep.trimmed)
5998
- {
5999
- float[] v = bRep.getRawVertices();
6000
- float[] n = bRep.getRawNormals();
6001
- float[] c = bRep.getRawColors();
6002
- float[] uv = bRep.getRawUVMap();
6003
-
6004
- int count2 = 0;
6005
- int count3 = 0;
6006
-
6007
- if (n.length > 0)
6008
- {
6009
- for (int i = 0; i < strips.length; i++)
6010
- {
6011
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6012
-
6013
- /*
6014
- boolean locked = false;
6015
- float eps = 0.1f;
6016
- boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
6017
-
6018
- int dot = 0;
6019
-
6020
- if ((dot&1) == 0)
6021
- dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
6022
-
6023
- if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
6024
- gl.glTexCoord2f((float) qv.s, (float) qv.t);
6025
- else
6026
- {
6027
- locked = true;
6028
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6029
- }
6030
- //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6031
- gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
6032
- if (hasnorm)
6033
- {
6034
- //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6035
- gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
6036
- }
6037
-
6038
- if ((dot&4) == 0)
6039
- dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
6040
-
6041
- if (wrap || !locked && (dot&8) != 0)
6042
- gl.glTexCoord2f((float) rv.s, (float) rv.t);
6043
- else
6044
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6045
-
6046
- f.dot = dot;
6047
- */
6048
-
6049
- if (!selectmode)
6050
- {
6051
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6052
- {
6053
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6054
- } else
6055
- {
6056
- gl.glNormal3f(0, 0, 1);
6057
- }
6058
-
6059
- if (c != null)
6060
- //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]);
6061
- {
6062
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6063
- }
6064
- }
6065
- if (flipV)
6066
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6067
- else
6068
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6069
- //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6070
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6071
-
6072
- count2 += 2;
6073
- count3 += 3;
6074
- if (!selectmode)
6075
- {
6076
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6077
- {
6078
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6079
- } else
6080
- {
6081
- gl.glNormal3f(0, 0, 1);
6082
- }
6083
- if (c != null)
6084
- {
6085
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6086
- }
6087
- }
6088
- if (flipV)
6089
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6090
- else
6091
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6092
- //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6093
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6094
-
6095
- count2 += 2;
6096
- count3 += 3;
6097
- for (int j = 0; j < strips[i] - 2; j++)
6098
- {
6099
- //gl.glTexCoord2d(...);
6100
- if (!selectmode)
6101
- {
6102
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6103
- {
6104
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6105
- } else
6106
- {
6107
- gl.glNormal3f(0, 0, 1);
6108
- }
6109
- if (c != null)
6110
- {
6111
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6112
- }
6113
- }
6114
-
6115
- if (flipV)
6116
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6117
- else
6118
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6119
- //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
6120
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6121
- count2 += 2;
6122
- count3 += 3;
6123
- }
6124
-
6125
- gl.glEnd();
6126
- }
6127
- }
6128
-
6129
- assert count3 == v.length;
6130
- }
6131
- else // !trimmed
6132
- {
6133
- int count = 0;
6134
- for (int i = 0; i < strips.length; i++)
6135
- {
6136
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6137
-
6138
- Vertex p = bRep.GetVertex(bRep.indices[count++]);
6139
- Vertex q = bRep.GetVertex(bRep.indices[count++]);
6140
-
6141
- drawVertex(gl, p, selectmode);
6142
- drawVertex(gl, q, selectmode);
6143
-
6144
- for (int j = 0; j < strips[i] - 2; j++)
6145
- {
6146
- Vertex r = bRep.GetVertex(bRep.indices[count++]);
6147
-
6148
-// if (j%2 == 0)
6149
-// drawFace(p, q, r, display, null);
6150
-// else
6151
-// drawFace(p, r, q, display, null);
6152
-
6153
-// p = q;
6154
-// q = r;
6155
- drawVertex(gl, r, selectmode);
6156
- }
6157
-
6158
- gl.glEnd();
6159
- }
6160
- }
6256
+
6257
+ display.DrawGeometry(bRep, flipV, selectmode);
61616258 } else // catch (Error e)
61626259 {
61636260 // TRIANGLE ARRAY
61646261 if (IsOpaque()) // Static())
61656262 {
6166
- gl.glBegin(gl.GL_TRIANGLES);
6263
+ display.StartTriangles();
61676264 int facecount = bRep.FaceCount();
61686265 for (int i = 0; i < facecount; i++)
61696266 {
....@@ -6226,9 +6323,9 @@
62266323 // // r.norm.dot(v3) > -0.5)
62276324 // // continue;
62286325
6229
- drawFace(p, q, r, display, face);
6326
+ display.DrawFace(this, p, q, r, face);
62306327 }
6231
- gl.glEnd();
6328
+ display.EndTriangles();
62326329 }
62336330 else
62346331 {
....@@ -6257,8 +6354,8 @@
62576354 //System.out.println("SORT");
62586355
62596356 java.util.Arrays.sort(facescompare);
6260
-
6261
- gl.glBegin(gl.GL_TRIANGLES);
6357
+
6358
+ display.StartTriangles();
62626359 for (int i = 0; i < facecount; i++)
62636360 {
62646361 Face face = bRep.GetFace(facescompare[i].index);
....@@ -6270,13 +6367,14 @@
62706367 Vertex q = bRep.GetVertex(face.q);
62716368 Vertex r = bRep.GetVertex(face.r);
62726369
6273
- drawFace(p, q, r, display, face);
6370
+ display.DrawFace(this, p, q, r, face);
62746371 }
6275
- gl.glEnd();
6372
+ display.EndTriangles();
62766373 }
62776374
62786375 if (false) // live && support != null && support.bRep != null) // debug weights
62796376 {
6377
+ /*
62806378 gl.glDisable(gl.GL_LIGHTING);
62816379 float[] colorV = new float[3];
62826380
....@@ -6355,6 +6453,7 @@
63556453 // gl.glEnd();
63566454 }
63576455 }
6456
+ */
63586457 }
63596458 }
63606459
....@@ -6399,7 +6498,7 @@
63996498 center.add(r);
64006499 center.mul(1.0/3);
64016500
6402
- center.sub(CameraPane.theRenderer.eyeCamera.location);
6501
+ center.sub(Globals.theRenderer.EyeCamera().location);
64036502
64046503 distance = center.dot(center);
64056504 }
....@@ -6410,347 +6509,11 @@
64106509
64116510 transient FaceCompare[] facescompare = null;
64126511
6413
- void SetColor(CameraPane display, Vertex p0)
6414
- {
6415
- if (display.RENDERPROGRAM == 0)
6416
- {
6417
- float r = 0;
6418
- if (bRep != null)
6419
- {
6420
- if (bRep.stripified)
6421
- {
6422
- r = 1;
6423
- }
6424
- }
6425
- float g = 0;
6426
- if (bRep != null)
6427
- {
6428
- if (bRep.trimmed)
6429
- {
6430
- g = 1;
6431
- }
6432
- }
6433
- float b = 0;
6434
- if (support != null && link2master)
6435
- {
6436
- b = 1;
6437
- }
6438
- display.GetGL().glColor3f(r*p0.AO, g*p0.AO, b*p0.AO);
6439
- return;
6440
- }
6441
-
6442
- if (display.drawMode != CameraPane.SHADOW)
6443
- return;
6444
-
6445
- javax.media.opengl.GL gl = display.GetGL();
6446
-// if (true) return;
6447
-// float ao = p.AO;
6448
-//
6449
-// // if (ao == 0 && !bRep.AOdone) // transient problem!
6450
-// // ao = 1;
6451
-//
6452
-// gl.glColor4f(ao, ao, ao, 1);
6453
-
6454
-// CameraPane.selectedpoint.
6455
-// getAverage(cStatic.point1, true);
6456
- if (CameraPane.pointflow == null) // !random) // live)
6457
- {
6458
- return;
6459
- }
6460
-
6461
- cStatic.point1.set(0,0,0);
6462
- LA.xformPos(cStatic.point1, CameraPane.selectedpoint.toParent, cStatic.point1);
6463
-
6464
- cStatic.point1.sub(p0);
6465
-
6466
-
6467
-// if (marked && (p0.vertexlinks == null || support == null || support.bRep == null)) // no position delta?
6468
-// {
6469
-// return;
6470
-// }
6471
-
6472
- //if (true)
6473
- if (cStatic.point1.dot(cStatic.point1) > 0.000001)
6474
- {
6475
- return;
6476
- }
6477
-
6478
- float[] colorV = new float[3];
6479
-
6480
- if (false) // marked)
6481
- {
6482
- // debug rigging weights
6483
- for (int object = 0; object < p0.vertexlinks.length; object++)
6484
- {
6485
- float weight = p0.weights[object] / p0.totalweight;
6486
-
6487
- // if (weight < 0.1)
6488
- // {
6489
- // assert(weight == 0);
6490
- // continue;
6491
- // }
6492
-
6493
- if (p0.vertexlinks[object] == -1)
6494
- continue;
6495
-
6496
- Vertex q = support.bRep.GetVertex(p0.vertexlinks[object]);
6497
-
6498
- int color = //1 << object; //
6499
- //p.vertexlinks.length;
6500
- support.bRep.supports[p0.closestsupport].links[object];
6501
- colorV[2] += (color & 1) * weight;
6502
- colorV[1] += ((color & 2) >> 1) * weight;
6503
- colorV[0] += ((color & 4) >> 2) * weight;
6504
- }
6505
- }
6506
- else
6507
- {
6508
- if (drawingstarted)
6509
- {
6510
- // find next point
6511
- if (bRep.GetVertex(0).faceindices == null)
6512
- {
6513
- bRep.InitFaceIndices();
6514
- }
6515
-
6516
- double ymin = p0.y;
6517
-
6518
- Vertex newp = p0;
6519
-
6520
- for (int fii = 0; fii < p0.faceindices.length; fii++)
6521
- {
6522
- int fi = p0.faceindices[fii];
6523
-
6524
- if (fi == -1)
6525
- break;
6526
-
6527
- Face f = bRep.GetFace(fi);
6528
-
6529
- Vertex p = bRep.GetVertex(f.p);
6530
- Vertex q = bRep.GetVertex(f.q);
6531
- Vertex r = bRep.GetVertex(f.r);
6532
-
6533
- int swap = (int)(Math.random()*3);
6534
-
6535
-// for (int s=swap; --s>=0;)
6536
-// {
6537
-// Vertex t = p;
6538
-// p = q;
6539
-// q = r;
6540
-// r = t;
6541
-// }
6542
- if (ymin > p.y)
6543
- {
6544
- ymin = p.y;
6545
- newp = p;
6546
-// break;
6547
- }
6548
- if (ymin > q.y)
6549
- {
6550
- ymin = q.y;
6551
- newp = q;
6552
-// break;
6553
- }
6554
- if (ymin > r.y)
6555
- {
6556
- ymin = r.y;
6557
- newp = r;
6558
-// break;
6559
- }
6560
- }
6561
-
6562
- CameraPane.selectedpoint.toParent[3][0] = newp.x;
6563
- CameraPane.selectedpoint.toParent[3][1] = newp.y;
6564
- CameraPane.selectedpoint.toParent[3][2] = newp.z;
6565
-
6566
- drawingstarted = false;
6567
-
6568
- // return;
6569
- }
6570
-
6571
- if (false) // CameraPane.DRAW
6572
- {
6573
- p0.AO = colorV[0] = 2;
6574
- colorV[1] = 2;
6575
- colorV[2] = 2;
6576
- }
6577
-
6578
- CameraPane.pointflow.add(p0);
6579
- CameraPane.pointflow.Touch();
6580
- }
6581
-
6582
-// gl.glColor3f(colorV[0], colorV[1], colorV[2]);
6583
-// gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0);
6584
-// gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
6585
- }
6586
-
65876512 void Print(Vertex v)
65886513 {
65896514 //System.err.println("(" + v.x + ", " + v.y + ", " + v.z + ")");
65906515 }
65916516
6592
- void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean selectmode)
6593
- {
6594
- if (!selectmode)
6595
- {
6596
- gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
6597
- gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
6598
-
6599
- if (flipV)
6600
- gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
6601
- else
6602
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6603
- }
6604
-
6605
- gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
6606
- }
6607
-
6608
- void drawFace(Vertex pv, Vertex qv, Vertex rv,
6609
- CameraPane display, Face face)
6610
- {
6611
- if (pv.y == -10000 ||
6612
- qv.y == -10000 ||
6613
- rv.y == -10000)
6614
- return;
6615
-
6616
-// float b = f.nbiterations & 1;
6617
-// float g = (f.nbiterations>>1) & 1;
6618
-// float r = (f.nbiterations>>2) & 1;
6619
-//
6620
-// //if (f.weight == 10000)
6621
-// //{
6622
-// // r = 1; g = b = 0;
6623
-// //}
6624
-// //else
6625
-// //{
6626
-// // assert(f.weight < 10000);
6627
-// r = g = b = (float)bRep.FaceWeight(f)*100;
6628
-// if (r<0)
6629
-// assert(r>=0);
6630
-// //}
6631
-
6632
- javax.media.opengl.GL gl = display.GetGL();
6633
-
6634
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
6635
-
6636
- //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv);
6637
- if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
6638
- {
6639
- //gl.glBegin(gl.GL_TRIANGLES);
6640
- boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
6641
- if (!hasnorm)
6642
- {
6643
- // System.out.println("FUCK!!");
6644
- LA.vecSub(pv/*.pos*/, qv/*.pos*/, v0);
6645
- LA.vecSub(pv/*.pos*/, rv/*.pos*/, v1);
6646
- LA.vecCross(v0, v1, v2);
6647
- LA.vecNormalize(v2);
6648
- gl.glNormal3f((float) v2.x, (float) v2.y, (float) v2.z);
6649
- }
6650
-
6651
- if (hasnorm)
6652
- {
6653
-// if (!pv.norm.normalized())
6654
-// assert(pv.norm.normalized());
6655
-
6656
- //System.out.println("normalp = " + pv.norm.x + ", " + pv.norm.y + ", " + pv.norm.z);
6657
- gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
6658
- }
6659
- gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
6660
- SetColor(display, pv);
6661
- //gl.glColor4f(r, g, b, 1);
6662
- //gl.glColor4f(pv.boundary, pv.boundary, pv.boundary, 1);
6663
- if (flipV)
6664
- gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
6665
- else
6666
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6667
- //System.out.println("vertexp = " + pv.x + ", " + pv.y + ", " + pv.z);
6668
- gl.glVertex3f((float) pv./*pos.*/x, (float) pv./*pos.*/y, (float) pv./*pos.*/z);
6669
-// Print(pv);
6670
- if (hasnorm)
6671
- {
6672
-// assert(qv.norm.normalized());
6673
- //System.out.println("normalq = " + qv.norm.x + ", " + qv.norm.y + ", " + qv.norm.z);
6674
- gl.glNormal3f((float) qv.norm.x, (float) qv.norm.y, (float) qv.norm.z);
6675
- }
6676
- //System.out.println("vertexq = " + qv.s + ", " + qv.t);
6677
- // boolean locked = false;
6678
- // float eps = 0.1f;
6679
- // boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
6680
-
6681
- // int dot = 0; //*/ (int)f.dot;
6682
-
6683
- // if ((dot&1) == 0)
6684
- // dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
6685
-
6686
- // if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
6687
- if (flipV)
6688
- gl.glTexCoord2f((float) qv.s, 1-(float) qv.t);
6689
- else
6690
- gl.glTexCoord2f((float) qv.s, (float) qv.t);
6691
- // else
6692
- // {
6693
- // locked = true;
6694
- // gl.glTexCoord2f((float) pv.s, (float) pv.t);
6695
- // }
6696
- gl.glColor4f(qv.AO, qv.AO, qv.AO, 1);
6697
- SetColor(display, qv);
6698
- //gl.glColor4f(r, g, b, 1);
6699
- //gl.glColor4f(qv.boundary, qv.boundary, qv.boundary, 1);
6700
- //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6701
- gl.glVertex3f((float) qv./*pos.*/x, (float) qv./*pos.*/y, (float) qv./*pos.*/z);
6702
-// Print(qv);
6703
- if (hasnorm)
6704
- {
6705
-// assert(rv.norm.normalized());
6706
- //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6707
- gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
6708
- }
6709
-
6710
- // if ((dot&4) == 0)
6711
- // dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
6712
-
6713
- // if (wrap || !locked && (dot&8) != 0)
6714
- if (flipV)
6715
- gl.glTexCoord2f((float) rv.s, 1-(float) rv.t);
6716
- else
6717
- gl.glTexCoord2f((float) rv.s, (float) rv.t);
6718
- // else
6719
- // gl.glTexCoord2f((float) pv.s, (float) pv.t);
6720
-
6721
- // f.dot = dot;
6722
-
6723
- gl.glColor4f(rv.AO, rv.AO, rv.AO, 1);
6724
- SetColor(display, rv);
6725
- //gl.glColor4f(r, g, b, 1);
6726
- //gl.glColor4f(rv.boundary, rv.boundary, rv.boundary, 1);
6727
- //System.out.println("vertexr = " + rv.x + ", " + rv.y + ", " + rv.z);
6728
- gl.glVertex3f((float) rv./*pos.*/x, (float) rv./*pos.*/y, (float) rv./*pos.*/z);
6729
-// Print(rv);
6730
- //gl.glEnd();
6731
- }
6732
- else
6733
- {
6734
- gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
6735
- gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
6736
- gl.glVertex3f((float) rv.x, (float) rv.y, (float) rv.z);
6737
-
6738
- }
6739
-
6740
- if (false) // (attributes & WIREFRAME) != 0)
6741
- {
6742
- gl.glDisable(gl.GL_LIGHTING);
6743
-
6744
- gl.glBegin(gl.GL_LINE_LOOP);
6745
- gl.glVertex3d(pv./*pos.*/x, pv./*pos.*/y, pv./*pos.*/z);
6746
- gl.glVertex3d(qv./*pos.*/x, qv./*pos.*/y, qv./*pos.*/z);
6747
- gl.glVertex3d(rv./*pos.*/x, rv./*pos.*/y, rv./*pos.*/z);
6748
- gl.glEnd();
6749
-
6750
- gl.glEnable(gl.GL_LIGHTING);
6751
- }
6752
- }
6753
-
67546517 void drawSelf(ClickInfo info, int level, boolean select)
67556518 {
67566519 if (bRep == null)
....@@ -7322,83 +7085,84 @@
73227085 int spotw = spot.x + spot.width;
73237086 int spoth = spot.y + spot.height;
73247087 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7325
- if (CameraPane.Xmin > spot.x)
7326
- {
7327
- CameraPane.Xmin = spot.x;
7328
- }
7329
- if (CameraPane.Xmax < spotw)
7330
- {
7331
- CameraPane.Xmax = spotw;
7332
- }
7333
- if (CameraPane.Ymin > spot.y)
7334
- {
7335
- CameraPane.Ymin = spot.y;
7336
- }
7337
- if (CameraPane.Ymax < spoth)
7338
- {
7339
- CameraPane.Ymax = spoth;
7340
- }
7088
+// if (CameraPane.Xmin > spot.x)
7089
+// {
7090
+// CameraPane.Xmin = spot.x;
7091
+// }
7092
+// if (CameraPane.Xmax < spotw)
7093
+// {
7094
+// CameraPane.Xmax = spotw;
7095
+// }
7096
+// if (CameraPane.Ymin > spot.y)
7097
+// {
7098
+// CameraPane.Ymin = spot.y;
7099
+// }
7100
+// if (CameraPane.Ymax < spoth)
7101
+// {
7102
+// CameraPane.Ymax = spoth;
7103
+// }
73417104 spot.translate(32, 32);
73427105 spotw = spot.x + spot.width;
73437106 spoth = spot.y + spot.height;
7344
- info.g.setColor(Color.blue);
7107
+ info.g.setColor(Color.cyan);
73457108 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7346
- if (CameraPane.Xmin > spot.x)
7347
- {
7348
- CameraPane.Xmin = spot.x;
7349
- }
7350
- if (CameraPane.Xmax < spotw)
7351
- {
7352
- CameraPane.Xmax = spotw;
7353
- }
7354
- if (CameraPane.Ymin > spot.y)
7355
- {
7356
- CameraPane.Ymin = spot.y;
7357
- }
7358
- if (CameraPane.Ymax < spoth)
7359
- {
7360
- CameraPane.Ymax = spoth;
7361
- }
7362
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7363
- info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7109
+// if (CameraPane.Xmin > spot.x)
7110
+// {
7111
+// CameraPane.Xmin = spot.x;
7112
+// }
7113
+// if (CameraPane.Xmax < spotw)
7114
+// {
7115
+// CameraPane.Xmax = spotw;
7116
+// }
7117
+// if (CameraPane.Ymin > spot.y)
7118
+// {
7119
+// CameraPane.Ymin = spot.y;
7120
+// }
7121
+// if (CameraPane.Ymax < spoth)
7122
+// {
7123
+// CameraPane.Ymax = spoth;
7124
+// }
7125
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7126
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
73647127 spot.translate(0, -32);
7365
- info.g.setColor(Color.green);
7128
+ info.g.setColor(Color.yellow);
73667129 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7367
- if (CameraPane.Xmin > spot.x)
7368
- {
7369
- CameraPane.Xmin = spot.x;
7370
- }
7371
- if (CameraPane.Xmax < spotw)
7372
- {
7373
- CameraPane.Xmax = spotw;
7374
- }
7375
- if (CameraPane.Ymin > spot.y)
7376
- {
7377
- CameraPane.Ymin = spot.y;
7378
- }
7379
- if (CameraPane.Ymax < spoth)
7380
- {
7381
- CameraPane.Ymax = spoth;
7382
- }
7130
+ info.g.setColor(Color.green);
7131
+// if (CameraPane.Xmin > spot.x)
7132
+// {
7133
+// CameraPane.Xmin = spot.x;
7134
+// }
7135
+// if (CameraPane.Xmax < spotw)
7136
+// {
7137
+// CameraPane.Xmax = spotw;
7138
+// }
7139
+// if (CameraPane.Ymin > spot.y)
7140
+// {
7141
+// CameraPane.Ymin = spot.y;
7142
+// }
7143
+// if (CameraPane.Ymax < spoth)
7144
+// {
7145
+// CameraPane.Ymax = spoth;
7146
+// }
73837147 info.g.drawArc(boundary.x, boundary.y,
73847148 boundary.width, boundary.height, 0, 360);
73857149 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
7386
- if (CameraPane.Xmin > boundary.x)
7387
- {
7388
- CameraPane.Xmin = boundary.x;
7389
- }
7390
- if (CameraPane.Xmax < boundary.x + boundary.width)
7391
- {
7392
- CameraPane.Xmax = boundary.x + boundary.width;
7393
- }
7394
- if (CameraPane.Ymin > boundary.y)
7395
- {
7396
- CameraPane.Ymin = boundary.y;
7397
- }
7398
- if (CameraPane.Ymax < boundary.y + boundary.height)
7399
- {
7400
- CameraPane.Ymax = boundary.y + boundary.height;
7401
- }
7150
+// if (CameraPane.Xmin > boundary.x)
7151
+// {
7152
+// CameraPane.Xmin = boundary.x;
7153
+// }
7154
+// if (CameraPane.Xmax < boundary.x + boundary.width)
7155
+// {
7156
+// CameraPane.Xmax = boundary.x + boundary.width;
7157
+// }
7158
+// if (CameraPane.Ymin > boundary.y)
7159
+// {
7160
+// CameraPane.Ymin = boundary.y;
7161
+// }
7162
+// if (CameraPane.Ymax < boundary.y + boundary.height)
7163
+// {
7164
+// CameraPane.Ymax = boundary.y + boundary.height;
7165
+// }
74027166 return;
74037167 }
74047168 }
....@@ -7415,7 +7179,7 @@
74157179 startX = info.x;
74167180 startY = info.y;
74177181
7418
- hitSomething = 0;
7182
+ hitSomething = -1;
74197183 cVector origin = new cVector();
74207184 //LA.xformPos(origin, toParent, origin);
74217185 Rectangle spot = new Rectangle();
....@@ -7448,7 +7212,7 @@
74487212 }
74497213
74507214 //System.out.println("info.modifiers = " + info.modifiers);
7451
- modified = (info.modifiers & CameraPane.META) != 0;
7215
+ modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
74527216 //System.out.println("modified = " + modified);
74537217 //new Exception().printStackTrace();
74547218 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7476,7 +7240,7 @@
74767240 return true;
74777241 }
74787242
7479
- void doEditDrag0(ClickInfo info)
7243
+ void doEditDrag0(ClickInfo info, boolean opposite)
74807244 {
74817245 if (hitSomething == 0)
74827246 {
....@@ -7491,6 +7255,7 @@
74917255 //System.out.println("hitSomething = " + hitSomething);
74927256
74937257 double scale = 0.005f * info.camera.Distance();
7258
+
74947259 cVector xlate = new cVector();
74957260 //cVector xlate2 = new cVector();
74967261 switch (hitSomething)
....@@ -7501,9 +7266,9 @@
75017266
75027267 case hitCenter: // Translate
75037268
7504
- scale *= 0.05f * info.pane.theRenderer.renderCamera.Distance();
7269
+ scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
75057270
7506
- if (modified)
7271
+ if (modified || opposite)
75077272 {
75087273 //assert(false);
75097274 /*
....@@ -7549,10 +7314,10 @@
75497314 }
75507315 LA.xformDir(up, ClickInfo.matbuffer, up);
75517316 // if (!CameraPane.LOCALTRANSFORM)
7552
- LA.xformDir(up, info.pane.theRenderer.renderCamera.toScreen, up);
7317
+ LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
75537318 LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
75547319 // if (!CameraPane.LOCALTRANSFORM)
7555
- LA.xformDir(away, info.pane.theRenderer.renderCamera.toScreen, away);
7320
+ LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
75567321 //LA.vecCross(up, cVector.Z, right2);
75577322
75587323 cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
....@@ -7597,6 +7362,7 @@
75977362
75987363 if (modified)
75997364 {
7365
+ // Rotate 90 degrees
76007366 angle /= (Math.PI / 4);
76017367 angle = Math.floor(angle + 0.5);
76027368 angle *= (Math.PI / 4);
....@@ -7610,7 +7376,7 @@
76107376 }
76117377 /**/
76127378
7613
- switch (info.pane.renderCamera.viewCode)
7379
+ switch (info.pane.RenderCamera().viewCode)
76147380 {
76157381 case 1: // '\001'
76167382 LA.matZRotate(toParent, angle);
....@@ -7638,24 +7404,27 @@
76387404
76397405 case hitScale: // scale
76407406 double hScale = (double) (info.x - centerPt.x) / 32;
7407
+ double sign = 1;
7408
+ if (hScale < 0)
7409
+ {
7410
+ sign = -1;
7411
+ }
7412
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
76417413 if (hScale < 0.01)
76427414 {
7643
- hScale = 0.01;
7415
+ //hScale = 0.01;
76447416 }
7645
- hScale = Math.pow(hScale, scale * 50);
7646
- if (hScale < 0.01)
7647
- {
7648
- hScale = 0.01;
7649
- }
7417
+
76507418 double vScale = (double) (info.y - centerPt.y) / 32;
7651
- if (vScale < 0.01)
7419
+ sign = 1;
7420
+ if (vScale < 0)
76527421 {
7653
- vScale = 0.01;
7422
+ sign = -1;
76547423 }
7655
- vScale = Math.pow(vScale, scale * 50);
7424
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
76567425 if (vScale < 0.01)
76577426 {
7658
- vScale = 0.01;
7427
+ //vScale = 0.01;
76597428 }
76607429 LA.matCopy(startMat, toParent);
76617430 /**/
....@@ -7666,39 +7435,46 @@
76667435 }
76677436 /**/
76687437
7669
- switch (info.pane.renderCamera.viewCode)
7438
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7439
+
7440
+ if (totalScale < 0.01)
7441
+ {
7442
+ totalScale = 0.01;
7443
+ }
7444
+
7445
+ switch (info.pane.RenderCamera().viewCode)
76707446 {
76717447 case 3: // '\001'
7672
- if (modified)
7448
+ if (modified || opposite)
76737449 {
76747450 //LA.matScale(toParent, 1, hScale, vScale);
7675
- LA.matScale(toParent, vScale, 1, 1);
7451
+ LA.matScale(toParent, totalScale, 1, 1);
76767452 } // vScale, 1);
76777453 else
76787454 {
7679
- LA.matScale(toParent, vScale, vScale, vScale);
7455
+ LA.matScale(toParent, 1, totalScale, totalScale);
76807456 } // vScale, 1);
76817457 break;
76827458
76837459 case 2: // '\002'
7684
- if (modified)
7460
+ if (modified || opposite)
76857461 {
76867462 //LA.matScale(toParent, hScale, 1, vScale);
7687
- LA.matScale(toParent, 1, vScale, 1);
7463
+ LA.matScale(toParent, 1, totalScale, 1);
76887464 } else
76897465 {
7690
- LA.matScale(toParent, vScale, 1, vScale);
7466
+ LA.matScale(toParent, totalScale, 1, totalScale);
76917467 }
76927468 break;
76937469
76947470 case 1: // '\003'
7695
- if (modified)
7471
+ if (modified || opposite)
76967472 {
76977473 //LA.matScale(toParent, hScale, vScale, 1);
7698
- LA.matScale(toParent, 1, 1, vScale);
7474
+ LA.matScale(toParent, 1, 1, totalScale);
76997475 } else
77007476 {
7701
- LA.matScale(toParent, vScale, vScale, 1);
7477
+ LA.matScale(toParent, totalScale, totalScale, 1);
77027478 }
77037479 break;
77047480 }
....@@ -7719,7 +7495,7 @@
77197495 if (parent == null)
77207496 {
77217497 System.out.println("NULL PARENT");
7722
- new Exception().printStackTrace();
7498
+ //new Exception().printStackTrace();
77237499 } else
77247500 {
77257501 if (parent instanceof BezierPatch)
....@@ -7735,8 +7511,15 @@
77357511 info.pane.repaint();
77367512 }
77377513
7514
+ boolean overflow = false;
7515
+
77387516 void TransformToWorld(cVector out) // , cVector out)
77397517 {
7518
+ if (overflow)
7519
+ return;
7520
+
7521
+ overflow = true;
7522
+
77407523 // june 2013 ??? assert (in == out);
77417524 cVector in = out;
77427525 if (toParent != null && !(this instanceof Texture || this instanceof TextureNode))
....@@ -7753,6 +7536,8 @@
77537536 {
77547537 (parent!=null?parent:fileparent).TransformToWorld(out); //, out);
77557538 }
7539
+
7540
+ overflow = false;
77567541 }
77577542
77587543 void TransformToLocal(cVector out) //, cVector out)
....@@ -7822,14 +7607,22 @@
78227607 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
78237608 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
78247609 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7610
+
7611
+ String objname;
7612
+
78257613 if (false) //parent != null)
78267614 {
7827
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7615
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
78287616 } else
78297617 {
7830
- return GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ") ")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ +System.identityHashCode(this);
7618
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
78317619 } // + super.toString();
78327620 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
7621
+
7622
+ if (!Globals.ADVANCED)
7623
+ return objname;
7624
+
7625
+ return objname + " " + System.identityHashCode(this);
78337626 }
78347627
78357628 public int hashCode()
....@@ -7885,6 +7678,7 @@
78857678 objectUI.closeUI();
78867679 if (editWindow != null)
78877680 {
7681
+ editWindow.ctrlPanel.FlushUI();
78887682 editWindow.refreshContents();
78897683 } // ? new
78907684 objectUI = null;
....@@ -7905,7 +7699,7 @@
79057699 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
79067700
79077701 Object3D /*Composite*/ parent;
7908
- Object3D /*Composite*/ fileparent;
7702
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
79097703
79107704 double[][] toParent; // dynamic matrix
79117705 double[][] fromParent;
....@@ -7995,19 +7789,22 @@
79957789 max = new cVector();
79967790 }
79977791
7998
- Object3D sourcenode = GetFileRoot();
7999
-
8000
- if (!sourcenode.name.contains("rclab"))
7792
+ if (false) // Can crawl!!
80017793 {
8002
- getBounds(min, max, true);
7794
+ Object3D sourcenode = GetFileRoot();
80037795
8004
- if (min.y != Double.POSITIVE_INFINITY && min.y > 2)
7796
+ if (sourcenode != null && !sourcenode.name.contains("rclab"))
80057797 {
8006
-// sourcenode.getBounds(min, max, true);
8007
- sourcenode.getBounds(v0, v1, true);
8008
-// sourcenode.toParent = sourcenode.toParent;
8009
-// get(0).toParent = get(0).toParent;
8010
-// sourcenode.GlobalTransform();
7798
+ getBounds(min, max, true);
7799
+
7800
+ if (min.y != Double.POSITIVE_INFINITY && min.y > 2)
7801
+ {
7802
+ // sourcenode.getBounds(min, max, true);
7803
+ sourcenode.getBounds(v0, v1, true);
7804
+ // sourcenode.toParent = sourcenode.toParent;
7805
+ // get(0).toParent = get(0).toParent;
7806
+ // sourcenode.GlobalTransform();
7807
+ }
80117808 }
80127809 }
80137810
....@@ -8016,7 +7813,8 @@
80167813 if (support != null)
80177814 {
80187815 assert(bRep != null);
8019
- GraphreeD.Assert(support.bRep == bRep.support);
7816
+ if (!(support instanceof GenericJoint)) // support.bRep != null)
7817
+ Grafreed.Assert(support.bRep == bRep.support);
80207818 }
80217819 else
80227820 {
....@@ -8065,9 +7863,9 @@
80657863 private static cVector edge2 = new cVector();
80667864 //private static cVector norm = new cVector();
80677865 /*transient private*/ int hitSomething;
8068
- private static final int hitCenter = 1;
8069
- private static final int hitScale = 2;
8070
- private static final int hitRotate = 3;
7866
+ static final int hitCenter = 1;
7867
+ static final int hitScale = 2;
7868
+ static final int hitRotate = 3;
80717869 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
80727870 /*transient*/ private Point centerPt;
80737871 /*transient*/ private int startX;
....@@ -8099,6 +7897,8 @@
80997897 {
81007898 Object3D targ = this;
81017899
7900
+ targ.NORMALPUSH = obj.NORMALPUSH;
7901
+
81027902 if (obj.material != null)
81037903 {
81047904 if ((mask&MATERIAL)!=0) // ==(COLOR|MATERIAL))