Normand Briere
2019-06-13 4629090fafbef256abd0686a85ee12042d658868
Object3D.java
....@@ -5,6 +5,7 @@
55 import java.util.Vector;
66
77 import javax.media.j3d.Transform3D;
8
+import javax.media.opengl.GL;
89 import javax.vecmath.Vector3d;
910
1011 import javax.imageio.ImageIO;
....@@ -13,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
+ 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
....@@ -587,7 +685,7 @@
587685 return;
588686 }
589687
590
- if (CameraPane.fromscript)
688
+ if (Globals.fromscript)
591689 {
592690 transformcount = 0;
593691 return;
....@@ -745,7 +843,7 @@
745843
746844 int GetTransformCount()
747845 {
748
- // marde pour serialization de Texture
846
+ // patch pour serialization de Texture
749847 resetmaxcount();
750848 resettransformcount();
751849 resetstep();
....@@ -758,7 +856,7 @@
758856 if (step == 0)
759857 step = 1;
760858 if (maxcount == 0)
761
- maxcount = 2048; // 4;
859
+ maxcount = 128; // 2048; // 4;
762860 // if (acceleration == 0)
763861 // acceleration = 10;
764862 if (delay == 0) // serial
....@@ -779,9 +877,12 @@
779877 // factor = CameraPane.STEP;
780878 // }
781879
782
- if (marked && CameraPane.isLIVE() && live && CameraPane.drawMode == CameraPane.SHADOW && currentframe != CameraPane.framecount)
880
+ if (marked && Globals.isLIVE() && live &&
881
+ //TEMP21aug2018
882
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
883
+ currentframe != Globals.framecount)
783884 {
784
- currentframe = CameraPane.framecount;
885
+ currentframe = Globals.framecount;
785886
786887 // System.err.println("transformcount = " + transformcount);
787888 // System.err.println("factor = " + factor);
....@@ -893,6 +994,11 @@
893994 fromParent = null; // LA.newMatrix();
894995 bRep = null; // new BoundaryRep();
895996
997
+ if (oname != null && oname.equals("LeftHand"))
998
+ {
999
+ name = oname;
1000
+ }
1001
+
8961002 /*
8971003 float hue = (float)Math.random();
8981004 Color col;
....@@ -935,7 +1041,7 @@
9351041
9361042 public Object clone()
9371043 {
938
- return GrafreeD.clone(this);
1044
+ return Grafreed.clone(this);
9391045 }
9401046
9411047 Object3D copyExpand()
....@@ -1446,7 +1552,16 @@
14461552 // if (other == null)
14471553 // return;
14481554
1449
- System.out.println("Link support this = " + this + "; other = " + other);
1555
+ if (other != null)
1556
+ {
1557
+ BoundaryRep.SEUIL = other.material.cameralight;
1558
+
1559
+ // Set default to 0.1
1560
+ BoundaryRep.SEUIL /= 4; // 2;
1561
+ System.out.println("SEUIL = " + BoundaryRep.SEUIL);
1562
+ }
1563
+
1564
+ System.out.println("Link this = " + this + "; support = " + other);
14501565
14511566 //if (bRep != null)
14521567 // bRep.linkVerticesThis(other.bRep);
....@@ -1701,7 +1816,7 @@
17011816 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17021817 o.bRep = transientrep;
17031818 if (clone)
1704
- o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
1819
+ o.bRep = (BoundaryRep) Grafreed.clone(transientrep);
17051820 o.CreateMaterial();
17061821 o.SetAttributes(this, -1);
17071822 //parent
....@@ -1714,7 +1829,7 @@
17141829 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17151830 o.bRep = bRep;
17161831 if (clone)
1717
- o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
1832
+ o.bRep = (BoundaryRep) Grafreed.clone(bRep);
17181833 o.CreateMaterial();
17191834 //o.overwriteThis(this, -1);
17201835 o.SetAttributes(this, -1);
....@@ -1801,12 +1916,15 @@
18011916 if (obj.name == null)
18021917 continue; // can't be a null one
18031918
1919
+ // Try perfect match first.
18041920 if (n.equals(obj.name))
18051921 {
18061922 theobj = obj;
18071923 count++;
18081924 }
18091925 }
1926
+
1927
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18101928
18111929 if (count != 1)
18121930 for (int i=Size(); --i>=0;)
....@@ -1816,8 +1934,9 @@
18161934 if (obj.name == null)
18171935 continue; // can't be a null one
18181936
1819
- //if (n.contains(obj.name)) // dec 2013 name.split(":")[0])) // Poser generates a count
1820
- if (n.startsWith(obj.name))
1937
+ String name = obj.name.split(":")[0]; // Poser generates a count
1938
+ //if (n.startsWith(obj.name))
1939
+ if (n.contains(name))
18211940 {
18221941 theobj = obj;
18231942 count++;
....@@ -2120,15 +2239,8 @@
21202239 if (/*parent != null &&*/ material == null)
21212240 {
21222241 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
2242
+
2243
+ InitOthers();
21322244
21332245 if (this instanceof Camera)
21342246 {
....@@ -2278,6 +2390,7 @@
22782390 {
22792391 if (newWindow)
22802392 {
2393
+ new Exception().printStackTrace();
22812394 System.exit(0);
22822395 if (parent != null)
22832396 {
....@@ -2454,13 +2567,13 @@
24542567 return retval;
24552568 }
24562569
2457
- void doEditDrag(ClickInfo info)
2570
+ void doEditDrag(ClickInfo info, boolean opposite)
24582571 {
24592572 switch (doSomething)
24602573 {
24612574 case 1: // '\001'
24622575 //super.
2463
- doEditDrag0(info);
2576
+ doEditDrag0(info, opposite);
24642577 break;
24652578
24662579 case 2: // '\002'
....@@ -2473,11 +2586,11 @@
24732586 {
24742587 //sel.hitSomething = childToDrag.hitSomething;
24752588 //childToDrag.doEditDrag(info);
2476
- sel.doEditDrag(info);
2589
+ sel.doEditDrag(info, opposite);
24772590 } else
24782591 {
24792592 //super.
2480
- doEditDrag0(info);
2593
+ doEditDrag0(info, opposite);
24812594 }
24822595 }
24832596 break;
....@@ -2587,6 +2700,18 @@
25872700 void GenNormalsS(boolean crease)
25882701 {
25892702 selection.GenNormals(crease);
2703
+// for (int i=0; i<selection.size(); i++)
2704
+// {
2705
+// Object3D selectee = (Object3D) selection.elementAt(i);
2706
+// selectee.GenNormals(crease);
2707
+// }
2708
+
2709
+ //Touch();
2710
+ }
2711
+
2712
+ void GenNormalsMeshS()
2713
+ {
2714
+ selection.GenNormalsMesh();
25902715 // for (int i=0; i<selection.size(); i++)
25912716 // {
25922717 // Object3D selectee = (Object3D) selection.elementAt(i);
....@@ -2732,6 +2857,42 @@
27322857 blockloop = false;
27332858 }
27342859
2860
+ void GenNormalsMesh()
2861
+ {
2862
+ if (blockloop)
2863
+ return;
2864
+
2865
+ blockloop = true;
2866
+ GenNormalsMesh0();
2867
+ for (int i = 0; i < Children().Size(); i++)
2868
+ {
2869
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2870
+ if (child == null)
2871
+ continue;
2872
+ child.GenNormalsMesh();
2873
+// Children().release(i);
2874
+ }
2875
+ blockloop = false;
2876
+ }
2877
+
2878
+ void GenNormalsMINE()
2879
+ {
2880
+ if (blockloop)
2881
+ return;
2882
+
2883
+ blockloop = true;
2884
+ GenNormalsMINE0();
2885
+ for (int i = 0; i < Children().Size(); i++)
2886
+ {
2887
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2888
+ if (child == null)
2889
+ continue;
2890
+ child.GenNormalsMINE();
2891
+// Children().release(i);
2892
+ }
2893
+ blockloop = false;
2894
+ }
2895
+
27352896 void ClearColors()
27362897 {
27372898 if (blockloop)
....@@ -2866,7 +3027,8 @@
28663027 {
28673028 if (bRep != null)
28683029 {
2869
- bRep.GenUV();
3030
+ bRep.GenUV(); //1);
3031
+ //bRep.UnfoldUV();
28703032 Touch();
28713033 }
28723034 }
....@@ -2876,6 +3038,24 @@
28763038 if (bRep != null)
28773039 {
28783040 bRep.GenerateNormals(crease);
3041
+ Touch();
3042
+ }
3043
+ }
3044
+
3045
+ void GenNormalsMesh0()
3046
+ {
3047
+ if (bRep != null)
3048
+ {
3049
+ bRep.GenerateNormalsMesh();
3050
+ Touch();
3051
+ }
3052
+ }
3053
+
3054
+ void GenNormalsMINE0()
3055
+ {
3056
+ if (bRep != null)
3057
+ {
3058
+ bRep.GenerateNormalsMINE();
28793059 Touch();
28803060 }
28813061 }
....@@ -2932,6 +3112,33 @@
29323112 blockloop = false;
29333113 }
29343114
3115
+ void TransformChildren()
3116
+ {
3117
+ if (toParent != null)
3118
+ {
3119
+ for (int i=Size(); --i>=0;)
3120
+ {
3121
+ Object3D v = get(i);
3122
+
3123
+ if (v.toParent == null)
3124
+ {
3125
+ v.toParent = LA.newMatrix();
3126
+ v.fromParent = LA.newMatrix();
3127
+ }
3128
+
3129
+// LA.matConcat(v.toParent, toParent, v.toParent);
3130
+// LA.matConcat(fromParent, v.fromParent, v.fromParent);
3131
+ LA.matConcat(toParent, v.toParent, v.toParent);
3132
+ LA.matConcat(v.fromParent, fromParent, v.fromParent);
3133
+ }
3134
+
3135
+ toParent = null; // LA.matIdentity(toParent);
3136
+ fromParent = null; // LA.matIdentity(fromParent);
3137
+
3138
+ Touch();
3139
+ }
3140
+ }
3141
+
29353142 void TransformGeometry()
29363143 {
29373144 Object3D obj = this;
....@@ -3153,9 +3360,11 @@
31533360
31543361 BoundaryRep sup = bRep.support;
31553362 bRep.support = null;
3156
- BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
3363
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
31573364 // bRep.SplitInTwo(onlyone); // thread...
3158
- temprep.SplitInTwo(reduction34, onlyone);
3365
+
3366
+ while(temprep.SplitInTwo(reduction34, onlyone));
3367
+
31593368 bRep = temprep;
31603369 bRep.support = sup;
31613370 Touch();
....@@ -3677,7 +3886,7 @@
36773886 if (child == null)
36783887 continue;
36793888
3680
- if (GrafreeD.RENDERME > 0)
3889
+ if (Grafreed.RENDERME > 0)
36813890 {
36823891 if (child instanceof Merge)
36833892 ((Merge)child).renderme();
....@@ -3828,7 +4037,7 @@
38284037 if (child == null)
38294038 continue;
38304039
3831
- if (GrafreeD.RENDERME > 0)
4040
+ if (Grafreed.RENDERME > 0)
38324041 {
38334042 if (child instanceof Merge)
38344043 ((Merge)child).renderme();
....@@ -4023,7 +4232,7 @@
40234232 if (child == null)
40244233 continue;
40254234
4026
- if (GrafreeD.RENDERME > 0)
4235
+ if (Grafreed.RENDERME > 0)
40274236 {
40284237 if (child instanceof Merge)
40294238 ((Merge)child).renderme();
....@@ -4111,7 +4320,7 @@
41114320 if (blockloop)
41124321 return;
41134322
4114
- for (int i=0; i<size(); i++)
4323
+ for (int i=0; i<Size(); i++)
41154324 {
41164325 if (get(i).parent != this)
41174326 {
....@@ -4120,6 +4329,22 @@
41204329 }
41214330 blockloop = true;
41224331 get(i).RepairParent();
4332
+ blockloop = false;
4333
+ }
4334
+ }
4335
+
4336
+ void RepairShadow()
4337
+ {
4338
+ if (blockloop)
4339
+ return;
4340
+
4341
+ if (this.material != null)
4342
+ this.InitOthers();
4343
+
4344
+ for (int i=0; i<Size(); i++)
4345
+ {
4346
+ blockloop = true;
4347
+ get(i).RepairShadow();
41234348 blockloop = false;
41244349 }
41254350 }
....@@ -4614,7 +4839,7 @@
46144839
46154840 cTreePath SelectLeaf(int indexcount, boolean deselect)
46164841 {
4617
- if (hide)
4842
+ if (hide || dontselect)
46184843 return null;
46194844
46204845 if (count <= 0)
....@@ -4640,7 +4865,7 @@
46404865
46414866 cTreePath Select(int indexcount, boolean deselect)
46424867 {
4643
- if (hide)
4868
+ if (hide || dontselect)
46444869 return null;
46454870
46464871 if (count <= 0)
....@@ -4790,7 +5015,7 @@
47905015 return globalTransform;
47915016 }
47925017
4793
- void PreprocessOcclusion(CameraPane cp)
5018
+ void PreprocessOcclusion(iCameraPane cp)
47945019 {
47955020 /*
47965021 if (AOdone)
....@@ -4937,7 +5162,8 @@
49375162 } else //
49385163 if (editWindow != null)
49395164 {
4940
- editWindow.cameraView.lighttouched = true;
5165
+ //editWindow.cameraView.lighttouched = true;
5166
+ Globals.lighttouched = true;
49415167 }
49425168 }
49435169
....@@ -5091,10 +5317,34 @@
50915317
50925318 // System.out.println("Fullname = " + fullname);
50935319
5094
- if (fullname.name.indexOf(":") == -1)
5095
- return fullname.name;
5320
+ // Does not work on Windows due to C:
5321
+// if (fullname.name.indexOf(":") == -1)
5322
+// return fullname.name;
5323
+//
5324
+// return fullname.name.substring(0,fullname.name.indexOf(":"));
50965325
5097
- return fullname.name.substring(0,fullname.name.indexOf(":"));
5326
+ String[] split = fullname.name.split(":");
5327
+
5328
+ if (split.length == 0)
5329
+ {
5330
+ return "";
5331
+ }
5332
+
5333
+ if (split.length <= 2)
5334
+ {
5335
+ if (fullname.name.endsWith(":"))
5336
+ {
5337
+ // Windows
5338
+ return fullname.name.substring(0, fullname.name.length()-1);
5339
+ }
5340
+
5341
+ return split[0];
5342
+ }
5343
+
5344
+ // Windows
5345
+ assert(split.length == 4);
5346
+
5347
+ return split[0] + ":" + split[1];
50985348 }
50995349
51005350 static String GetBump(cTexture fullname)
....@@ -5103,10 +5353,38 @@
51035353 return "";
51045354
51055355 // System.out.println("Fullname = " + fullname);
5106
- if (fullname.name.indexOf(":") == -1)
5107
- return "";
5108
-
5109
- return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5356
+ // Does not work on Windows due to C:
5357
+// if (fullname.name.indexOf(":") == -1)
5358
+// return "";
5359
+//
5360
+// return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5361
+ String[] split = fullname.name.split(":");
5362
+
5363
+ if (split.length == 0)
5364
+ {
5365
+ return "";
5366
+ }
5367
+
5368
+ if (split.length == 1)
5369
+ {
5370
+ return "";
5371
+ }
5372
+
5373
+ if (split.length == 2)
5374
+ {
5375
+ if (fullname.name.endsWith(":"))
5376
+ {
5377
+ // Windows
5378
+ return "";
5379
+ }
5380
+
5381
+ return split[1];
5382
+ }
5383
+
5384
+ // Windows
5385
+ assert(split.length == 4);
5386
+
5387
+ return split[2] + ":" + split[3];
51105388 }
51115389
51125390 String GetPigmentTexture()
....@@ -5180,7 +5458,7 @@
51805458 System.out.print("; textures = " + textures);
51815459 System.out.println("; usedtextures = " + usedtextures);
51825460
5183
- if (GetTextures() == null)
5461
+ if (GetTextures() == null) // What is that??
51845462 GetTextures().name = ":";
51855463
51865464 String texname = tex;
....@@ -5211,6 +5489,43 @@
52115489 child.ResetPigmentTexture();
52125490 blockloop = false;
52135491 }
5492
+ }
5493
+
5494
+ UUID GetUUID()
5495
+ {
5496
+ if (uuid == null)
5497
+ {
5498
+ // Serial
5499
+ uuid = UUID.randomUUID();
5500
+ }
5501
+
5502
+ return uuid;
5503
+ }
5504
+
5505
+ Object3D GetObject(UUID uid)
5506
+ {
5507
+ if (blockloop)
5508
+ return null;
5509
+
5510
+ if (GetUUID().equals(uid))
5511
+ return this;
5512
+
5513
+ int nb = Size();
5514
+ for (int i = 0; i < nb; i++)
5515
+ {
5516
+ Object3D child = (Object3D) get(i);
5517
+
5518
+ if (child == null)
5519
+ continue;
5520
+
5521
+ blockloop = true;
5522
+ Object3D obj = child.GetObject(uid);
5523
+ blockloop = false;
5524
+ if (obj != null)
5525
+ return obj;
5526
+ }
5527
+
5528
+ return null;
52145529 }
52155530
52165531 void SetBumpTexture(String tex)
....@@ -5249,25 +5564,22 @@
52495564 }
52505565 }
52515566
5252
- void draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5567
+ void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
52535568 {
52545569 Draw(display, root, selected, blocked);
52555570 }
52565571
5257
- static cMaterial[] materialstack = new cMaterial[65536];
5258
- static boolean[] selectedstack = new boolean[65536];
5259
- static int materialdepth = 0;
5260
-
52615572 boolean NeedSupport()
52625573 {
52635574 return
5264
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5575
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null
52655576 // PROBLEM with CROWD!!
5266
- && (CameraPane.drawMode == CameraPane.SHADOW || CameraPane.CROWD);
5577
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
52675578 }
52685579
5580
+ static boolean DEBUG_SELECTION = false;
52695581
5270
- void Draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5582
+ void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
52715583 {
52725584 Invariants(); // june 2013
52735585
....@@ -5276,8 +5588,8 @@
52765588 // System.err.println("Draw " + this + " Frame # " + ((Mocap)((Merge)support).object).frame);
52775589 }
52785590
5279
- if (display.drawMode == CameraPane.SELECTION &&
5280
- hide)
5591
+ if (display.DrawMode() == iCameraPane.SELECTION &&
5592
+ (hide || dontselect))
52815593 return;
52825594
52835595 if (name != null && name.contains("sclera"))
....@@ -5295,7 +5607,7 @@
52955607 if (this instanceof Checker)
52965608 return;
52975609
5298
- if (display.drawMode == display.SHADOW && PASSTEST)
5610
+ if (display.DrawMode() == display.SHADOW && PASSTEST)
52995611 return;
53005612
53015613 if (count <= 0)
....@@ -5303,13 +5615,13 @@
53035615 return;
53045616 }
53055617
5306
- if ((//display.drawMode == CameraPane.SHADOW ||
5307
- display.drawMode == CameraPane.SELECTION || CameraPane.DEBUG_SELECTION) && HasTransparency())
5618
+ if ((//display.DrawMode() == CameraPane.SHADOW ||
5619
+ display.DrawMode() == iCameraPane.SELECTION || display.IsDebugSelection()) && HasTransparency())
53085620 {
53095621 return;
53105622 }
53115623
5312
- javax.media.opengl.GL gl = display.GetGL();
5624
+ //javax.media.opengl.GL gl = display.GetGL();
53135625
53145626 /*
53155627 if (touched)
....@@ -5345,15 +5657,15 @@
53455657
53465658 boolean compiled = false;
53475659
5348
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
5660
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
53495661
5350
- if (!selectmode && //display.drawMode != display.SELECTION &&
5662
+ if (!selectmode && //display.DrawMode() != display.SELECTION &&
53515663 (touched || (bRep != null && bRep.displaylist <= 0)))
53525664 {
5353
- display.lighttouched = true;
5665
+ Globals.lighttouched = true;
53545666 } // all panes...
5355
- //if (usecalllists && display.drawMode != display.SELECTION && display.drawMode != display.SHADOW &&
5356
- if (bRep != null && usecalllists && !selectmode && // june 2013 display.drawMode != display.SHADOW &&
5667
+ //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
5668
+ if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
53575669 (touched || (bRep != null && bRep.displaylist <= 0)))
53585670 {
53595671 if (!(this instanceof Composite))
....@@ -5361,7 +5673,7 @@
53615673 //if (displaylist == -1 && usecalllists)
53625674 if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
53635675 {
5364
- bRep.displaylist = gl.glGenLists(1);
5676
+ bRep.displaylist = display.GenList();
53655677 assert(bRep.displaylist != 0);
53665678 // System.err.println("glGenLists: " + bRep.displaylist + " for " + this);
53675679 //System.out.println("\tgen list " + list);
....@@ -5373,18 +5685,20 @@
53735685 if (usecalllists)
53745686 {
53755687 // System.err.println("new list " + bRep.displaylist + " for " + this);
5376
- gl.glNewList(bRep.displaylist, gl.GL_COMPILE); //_AND_EXECUTE);
5688
+ display.NewList(bRep.displaylist);
53775689 }
5690
+
53785691 CallList(display, root, selected, blocked);
5692
+
53795693 // compiled = true;
53805694 if (usecalllists)
53815695 {
53825696 // System.err.println("end list " + bRep.displaylist + " for " + this);
5383
- gl.glEndList();
5697
+ display.EndList();
53845698 }
53855699 //gl.glDrawBuffer(gl.GL_BACK);
53865700 // XXX touched = false;
5387
- display.lighttouched = true; // all panes...
5701
+ Globals.lighttouched = true; // all panes...
53885702 }
53895703
53905704 touched = GetBRep() == null; // this instanceof Composite || this instanceof FileObject; // false;
....@@ -5423,12 +5737,12 @@
54235737
54245738 // frustum culling
54255739 if (CameraPane.FRUSTUM && !blocked && !IsInfinite() && GetBRep() != null // && GetBRep().VertexCount() != 1260 // default grid
5426
- && display.drawMode != CameraPane.SELECTION)
5740
+ && display.DrawMode() != iCameraPane.SELECTION)
54275741 {
5428
- if (display.drawMode == CameraPane.SHADOW)
5742
+ if (display.DrawMode() == iCameraPane.SHADOW)
54295743 {
54305744 if (!link2master // tricky to cull in shadow mode.
5431
- && GetBRep().FrustumCull(this, gl, display.lightCamera, true))
5745
+ && GetBRep().FrustumCull(this, null, display.LightCamera(), true))
54325746 {
54335747 //System.out.print("CULLED");
54345748 culled = true;
....@@ -5436,7 +5750,7 @@
54365750 }
54375751 else
54385752 //GetBRep().getBounds(v0, v1, this);
5439
- if (GetBRep().FrustumCull(this, gl, display.renderCamera, false))
5753
+ if (GetBRep().FrustumCull(this, null, display.RenderCamera(), false))
54405754 culled = true;
54415755
54425756 // LA.xformPos(v0, display.renderCamera.toScreen, v0);
....@@ -5472,11 +5786,11 @@
54725786
54735787
54745788 if (!culled)
5475
- if (display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION)
5789
+ if (display.DrawMode() == display.SELECTION || display.IsDebugSelection())
54765790 {
54775791 if (GetBRep() != null)
54785792 {
5479
- CameraPane.NextIndex(this, gl);
5793
+ display.NextIndex();
54805794 // vertex color conflict : gl.glCallList(list);
54815795 DrawNode(display, root, selected);
54825796 if (this instanceof BezierPatch)
....@@ -5498,55 +5812,7 @@
54985812 color[2] /= 2;
54995813 gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT_AND_DIFFUSE, color, 0);
55005814 */
5501
- if (material != null)
5502
- {
5503
- materialstack[materialdepth] = material;
5504
- selectedstack[materialdepth] = selected;
5505
- cStatic.objectstack[materialdepth++] = this;
5506
- //System.out.println("material " + material);
5507
- //Applet3D.tracein(this, selected);
5508
- display.vector2buffer = projectedVertices;
5509
- if (this instanceof Camera)
5510
- {
5511
- display.options1[0] = material.shift;
5512
- //System.out.println("shift " + material.shift);
5513
- display.options1[1] = material.lightarea;
5514
- display.options1[2] = material.shadowbias;
5515
- display.options1[3] = material.aniso;
5516
- display.options1[4] = material.anisoV;
5517
- display.options2[0] = material.opacity;
5518
- display.options2[1] = material.diffuse;
5519
- display.options2[2] = material.factor;
5520
-
5521
- cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
5522
- display.options4[0] = material.cameralight/0.2f;
5523
- display.options4[1] = material.subsurface;
5524
- display.options4[2] = material.sheen;
5525
-
5526
- // if (display.CURRENTANTIALIAS > 0)
5527
- // display.options3[3] /= 4;
5528
-
5529
- /*
5530
- System.out.println("Focus = " + display.options1[0]);
5531
- System.out.println("Aperture = " + display.options1[1]);
5532
- System.out.println("ShadowBlur = " + display.options1[2]);
5533
- System.out.println("Antialiasing = " + display.options1[3]);
5534
- System.out.println("Fog = " + display.options2[0]);
5535
- System.out.println("Intensity = " + display.options2[1]);
5536
- System.out.println("Elevation = " + display.options2[2]);
5537
- /**/
5538
- } else
5539
- {
5540
- material.Draw(display, selected);
5541
- }
5542
- } else
5543
- {
5544
- if (selected && CameraPane.flash)
5545
- {
5546
- display.modelParams4[1] = 100;
5547
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
5548
- }
5549
- }
5815
+ display.PushMaterial(this, selected);
55505816
55515817 //System.out.println("call list " + list);
55525818 //System.out.println();
....@@ -5565,7 +5831,17 @@
55655831 tex = GetTextures();
55665832 }
55675833
5568
- display.BindTextures(tex, texres);
5834
+ boolean failed = false;
5835
+
5836
+ try
5837
+ {
5838
+ display.BindTextures(tex, texres);
5839
+ }
5840
+ catch (Exception e)
5841
+ {
5842
+ System.err.println("FAILED: " + this);
5843
+ failed = true;
5844
+ }
55695845
55705846 if (!compiled)
55715847 {
....@@ -5581,30 +5857,16 @@
55815857
55825858 // System.err.println("glCallList: " + bRep.displaylist + " for " + this);
55835859 assert(bRep.displaylist != 0);
5584
- gl.glCallList(bRep.displaylist);
5860
+ display.CallList(bRep.displaylist);
55855861 // june 2013 drawSelf(display, root, selected);
55865862 }
55875863 }
55885864 }
55895865
5590
- display.ReleaseTextures(tex);
5591
-
5592
- //if (parent != null && parent.GetMaterial() != null)
5593
- // parent.GetMaterial().Draw(display, parent.IsSelected(this));
5594
- if (material != null)
5595
- {
5596
- materialdepth -= 1;
5597
- if (materialdepth > 0)
5598
- {
5599
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
5600
- materialstack[materialdepth - 1].Draw(display, selectedstack[materialdepth - 1]);
5601
- }
5602
- //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
5603
- } else if (selected && CameraPane.flash && GetMaterial() != null)
5604
- {
5605
- display.modelParams4[1] = GetMaterial().cameralight;
5606
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
5607
- }
5866
+ if (!failed)
5867
+ display.ReleaseTextures(tex);
5868
+
5869
+ display.PopMaterial(this, selected);
56085870 }
56095871
56105872 if (this instanceof Texture || this instanceof TextureNode)
....@@ -5646,7 +5908,7 @@
56465908 // resetMasterNode();
56475909 }
56485910
5649
- void CallList(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5911
+ void CallList(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
56505912 {
56515913 if (GetBRep() == null)
56525914 {
....@@ -5729,8 +5991,11 @@
57295991 boolean flipV = false; // true;
57305992 int texres = 0; // 0 = low, 1 = normal, 2 = high res texture
57315993
5732
- void drawSelf(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5994
+ void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57335995 {
5996
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
5997
+ return;
5998
+
57345999 if (hide)
57356000 return;
57366001 // shadow optimisation
....@@ -5788,16 +6053,7 @@
57886053 // // ??????????????????????????? Touch();
57896054 // }
57906055
5791
- if (material != null)
5792
- {
5793
- materialstack[materialdepth] = material;
5794
- selectedstack[materialdepth] = selected;
5795
- cStatic.objectstack[materialdepth++] = this;
5796
- //System.out.println("material " + material);
5797
- //Applet3D.tracein("selected ", selected);
5798
- display.vector2buffer = projectedVertices;
5799
- material.Draw(display, selected);
5800
- }
6056
+display.PushMaterial2(this, selected);
58016057
58026058 Object3D child;
58036059 boolean sel;
....@@ -5849,19 +6105,7 @@
58496105 */
58506106 //depth += 1;
58516107
5852
- if (material != null)
5853
- {
5854
- materialdepth -= 1;
5855
- if (materialdepth > 0)
5856
- {
5857
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
5858
- materialstack[materialdepth - 1].Draw(display, selectedstack[materialdepth - 1]);
5859
- }
5860
- //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
5861
- //else
5862
- //material.Draw(display, false);
5863
- }
5864
-
6108
+display.PopMaterial2(this);
58656109 /*
58666110 display.ReleaseTextures(tex);
58676111 */
....@@ -5872,10 +6116,13 @@
58726116
58736117 //static cVector min,max;
58746118
5875
- void DrawNode(CameraPane display, Object3D /*Composite*/ root, boolean selected)
6119
+ void DrawNode(iCameraPane display, Object3D /*Composite*/ root, boolean selected)
58766120 {
5877
- if (display.drawMode == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
6121
+ if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
58786122 return; // no shadow for transparent objects
6123
+
6124
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6125
+ return;
58796126
58806127 if (hide)
58816128 return;
....@@ -5917,11 +6164,12 @@
59176164 return;
59186165 }
59196166
6167
+ //bRep.GenUV(1/material.diffuseness);
59206168 // bRep.lock = true;
59216169
5922
- javax.media.opengl.GL gl = display.GetGL();
6170
+ //javax.media.opengl.GL gl = display.GetGL();
59236171
5924
- if (CameraPane.BOXMODE) // || CameraPane.movingcamera)
6172
+ if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera)
59256173 {
59266174 int fc = bRep.FaceCount();
59276175 int vc = bRep.VertexCount();
....@@ -5936,23 +6184,7 @@
59366184
59376185 bRep.getMinMax(min, max, 100);
59386186
5939
- gl.glBegin(gl.GL_LINES);
5940
-
5941
- gl.glVertex3d(min.x, min.y, min.z);
5942
- gl.glVertex3d(min.x, min.y, max.z);
5943
- gl.glVertex3d(min.x, min.y, min.z);
5944
- gl.glVertex3d(min.x, max.y, min.z);
5945
- gl.glVertex3d(min.x, min.y, min.z);
5946
- gl.glVertex3d(max.x, min.y, min.z);
5947
-
5948
- gl.glVertex3d(max.x, max.y, max.z);
5949
- gl.glVertex3d(min.x, max.y, max.z);
5950
- gl.glVertex3d(max.x, max.y, max.z);
5951
- gl.glVertex3d(max.x, min.y, max.z);
5952
- gl.glVertex3d(max.x, max.y, max.z);
5953
- gl.glVertex3d(max.x, max.y, min.z);
5954
-
5955
- gl.glEnd();
6187
+ display.DrawBox(min, max);
59566188
59576189 return;
59586190 }
....@@ -5996,7 +6228,7 @@
59966228 {
59976229 //throw new Error();
59986230
5999
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
6231
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
60006232
60016233 int[] strips = bRep.getRawIndices();
60026234
....@@ -6006,178 +6238,14 @@
60066238 new Exception().printStackTrace();
60076239 return;
60086240 }
6009
-
6010
- // TRIANGLE STRIP ARRAY
6011
- if (bRep.trimmed)
6012
- {
6013
- float[] v = bRep.getRawVertices();
6014
- float[] n = bRep.getRawNormals();
6015
- float[] c = bRep.getRawColors();
6016
- float[] uv = bRep.getRawUVMap();
6017
-
6018
- int count2 = 0;
6019
- int count3 = 0;
6020
-
6021
- if (n.length > 0)
6022
- {
6023
- for (int i = 0; i < strips.length; i++)
6024
- {
6025
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6026
-
6027
- /*
6028
- boolean locked = false;
6029
- float eps = 0.1f;
6030
- boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
6031
-
6032
- int dot = 0;
6033
-
6034
- if ((dot&1) == 0)
6035
- dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
6036
-
6037
- if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
6038
- gl.glTexCoord2f((float) qv.s, (float) qv.t);
6039
- else
6040
- {
6041
- locked = true;
6042
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6043
- }
6044
- //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6045
- gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
6046
- if (hasnorm)
6047
- {
6048
- //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6049
- gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
6050
- }
6051
-
6052
- if ((dot&4) == 0)
6053
- dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
6054
-
6055
- if (wrap || !locked && (dot&8) != 0)
6056
- gl.glTexCoord2f((float) rv.s, (float) rv.t);
6057
- else
6058
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6059
-
6060
- f.dot = dot;
6061
- */
6062
-
6063
- if (!selectmode)
6064
- {
6065
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6066
- {
6067
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6068
- } else
6069
- {
6070
- gl.glNormal3f(0, 0, 1);
6071
- }
6072
-
6073
- if (c != null)
6074
- //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]);
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("vertex1 = " + 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
- if (!selectmode)
6089
- {
6090
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6091
- {
6092
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6093
- } else
6094
- {
6095
- gl.glNormal3f(0, 0, 1);
6096
- }
6097
- if (c != null)
6098
- {
6099
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6100
- }
6101
- }
6102
- if (flipV)
6103
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6104
- else
6105
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6106
- //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6107
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6108
-
6109
- count2 += 2;
6110
- count3 += 3;
6111
- for (int j = 0; j < strips[i] - 2; j++)
6112
- {
6113
- //gl.glTexCoord2d(...);
6114
- if (!selectmode)
6115
- {
6116
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6117
- {
6118
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6119
- } else
6120
- {
6121
- gl.glNormal3f(0, 0, 1);
6122
- }
6123
- if (c != null)
6124
- {
6125
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6126
- }
6127
- }
6128
-
6129
- if (flipV)
6130
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6131
- else
6132
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6133
- //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
6134
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6135
- count2 += 2;
6136
- count3 += 3;
6137
- }
6138
-
6139
- gl.glEnd();
6140
- }
6141
- }
6142
-
6143
- assert count3 == v.length;
6144
- }
6145
- else // !trimmed
6146
- {
6147
- int count = 0;
6148
- for (int i = 0; i < strips.length; i++)
6149
- {
6150
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6151
-
6152
- Vertex p = bRep.GetVertex(bRep.indices[count++]);
6153
- Vertex q = bRep.GetVertex(bRep.indices[count++]);
6154
-
6155
- drawVertex(gl, p, selectmode);
6156
- drawVertex(gl, q, selectmode);
6157
-
6158
- for (int j = 0; j < strips[i] - 2; j++)
6159
- {
6160
- Vertex r = bRep.GetVertex(bRep.indices[count++]);
6161
-
6162
-// if (j%2 == 0)
6163
-// drawFace(p, q, r, display, null);
6164
-// else
6165
-// drawFace(p, r, q, display, null);
6166
-
6167
-// p = q;
6168
-// q = r;
6169
- drawVertex(gl, r, selectmode);
6170
- }
6171
-
6172
- gl.glEnd();
6173
- }
6174
- }
6241
+
6242
+ display.DrawGeometry(bRep, flipV, selectmode);
61756243 } else // catch (Error e)
61766244 {
61776245 // TRIANGLE ARRAY
61786246 if (IsOpaque()) // Static())
61796247 {
6180
- gl.glBegin(gl.GL_TRIANGLES);
6248
+ display.StartTriangles();
61816249 int facecount = bRep.FaceCount();
61826250 for (int i = 0; i < facecount; i++)
61836251 {
....@@ -6240,9 +6308,9 @@
62406308 // // r.norm.dot(v3) > -0.5)
62416309 // // continue;
62426310
6243
- drawFace(p, q, r, display, face);
6311
+ display.DrawFace(this, p, q, r, face);
62446312 }
6245
- gl.glEnd();
6313
+ display.EndTriangles();
62466314 }
62476315 else
62486316 {
....@@ -6271,8 +6339,8 @@
62716339 //System.out.println("SORT");
62726340
62736341 java.util.Arrays.sort(facescompare);
6274
-
6275
- gl.glBegin(gl.GL_TRIANGLES);
6342
+
6343
+ display.StartTriangles();
62766344 for (int i = 0; i < facecount; i++)
62776345 {
62786346 Face face = bRep.GetFace(facescompare[i].index);
....@@ -6284,13 +6352,14 @@
62846352 Vertex q = bRep.GetVertex(face.q);
62856353 Vertex r = bRep.GetVertex(face.r);
62866354
6287
- drawFace(p, q, r, display, face);
6355
+ display.DrawFace(this, p, q, r, face);
62886356 }
6289
- gl.glEnd();
6357
+ display.EndTriangles();
62906358 }
62916359
62926360 if (false) // live && support != null && support.bRep != null) // debug weights
62936361 {
6362
+ /*
62946363 gl.glDisable(gl.GL_LIGHTING);
62956364 float[] colorV = new float[3];
62966365
....@@ -6369,6 +6438,7 @@
63696438 // gl.glEnd();
63706439 }
63716440 }
6441
+ */
63726442 }
63736443 }
63746444
....@@ -6413,7 +6483,7 @@
64136483 center.add(r);
64146484 center.mul(1.0/3);
64156485
6416
- center.sub(CameraPane.theRenderer.eyeCamera.location);
6486
+ center.sub(Globals.theRenderer.EyeCamera().location);
64176487
64186488 distance = center.dot(center);
64196489 }
....@@ -6424,347 +6494,11 @@
64246494
64256495 transient FaceCompare[] facescompare = null;
64266496
6427
- void SetColor(CameraPane display, Vertex p0)
6428
- {
6429
- if (display.RENDERPROGRAM == 0)
6430
- {
6431
- float r = 0;
6432
- if (bRep != null)
6433
- {
6434
- if (bRep.stripified)
6435
- {
6436
- r = 1;
6437
- }
6438
- }
6439
- float g = 0;
6440
- if (bRep != null)
6441
- {
6442
- if (bRep.trimmed)
6443
- {
6444
- g = 1;
6445
- }
6446
- }
6447
- float b = 0;
6448
- if (support != null && link2master)
6449
- {
6450
- b = 1;
6451
- }
6452
- display.GetGL().glColor3f(r*p0.AO, g*p0.AO, b*p0.AO);
6453
- return;
6454
- }
6455
-
6456
- if (display.drawMode != CameraPane.SHADOW)
6457
- return;
6458
-
6459
- javax.media.opengl.GL gl = display.GetGL();
6460
-// if (true) return;
6461
-// float ao = p.AO;
6462
-//
6463
-// // if (ao == 0 && !bRep.AOdone) // transient problem!
6464
-// // ao = 1;
6465
-//
6466
-// gl.glColor4f(ao, ao, ao, 1);
6467
-
6468
-// CameraPane.selectedpoint.
6469
-// getAverage(cStatic.point1, true);
6470
- if (CameraPane.pointflow == null) // !random) // live)
6471
- {
6472
- return;
6473
- }
6474
-
6475
- cStatic.point1.set(0,0,0);
6476
- LA.xformPos(cStatic.point1, CameraPane.selectedpoint.toParent, cStatic.point1);
6477
-
6478
- cStatic.point1.sub(p0);
6479
-
6480
-
6481
-// if (marked && (p0.vertexlinks == null || support == null || support.bRep == null)) // no position delta?
6482
-// {
6483
-// return;
6484
-// }
6485
-
6486
- //if (true)
6487
- if (cStatic.point1.dot(cStatic.point1) > 0.000001)
6488
- {
6489
- return;
6490
- }
6491
-
6492
- float[] colorV = new float[3];
6493
-
6494
- if (false) // marked)
6495
- {
6496
- // debug rigging weights
6497
- for (int object = 0; object < p0.vertexlinks.length; object++)
6498
- {
6499
- float weight = p0.weights[object] / p0.totalweight;
6500
-
6501
- // if (weight < 0.1)
6502
- // {
6503
- // assert(weight == 0);
6504
- // continue;
6505
- // }
6506
-
6507
- if (p0.vertexlinks[object] == -1)
6508
- continue;
6509
-
6510
- Vertex q = support.bRep.GetVertex(p0.vertexlinks[object]);
6511
-
6512
- int color = //1 << object; //
6513
- //p.vertexlinks.length;
6514
- support.bRep.supports[p0.closestsupport].links[object];
6515
- colorV[2] += (color & 1) * weight;
6516
- colorV[1] += ((color & 2) >> 1) * weight;
6517
- colorV[0] += ((color & 4) >> 2) * weight;
6518
- }
6519
- }
6520
- else
6521
- {
6522
- if (drawingstarted)
6523
- {
6524
- // find next point
6525
- if (bRep.GetVertex(0).faceindices == null)
6526
- {
6527
- bRep.InitFaceIndices();
6528
- }
6529
-
6530
- double ymin = p0.y;
6531
-
6532
- Vertex newp = p0;
6533
-
6534
- for (int fii = 0; fii < p0.faceindices.length; fii++)
6535
- {
6536
- int fi = p0.faceindices[fii];
6537
-
6538
- if (fi == -1)
6539
- break;
6540
-
6541
- Face f = bRep.GetFace(fi);
6542
-
6543
- Vertex p = bRep.GetVertex(f.p);
6544
- Vertex q = bRep.GetVertex(f.q);
6545
- Vertex r = bRep.GetVertex(f.r);
6546
-
6547
- int swap = (int)(Math.random()*3);
6548
-
6549
-// for (int s=swap; --s>=0;)
6550
-// {
6551
-// Vertex t = p;
6552
-// p = q;
6553
-// q = r;
6554
-// r = t;
6555
-// }
6556
- if (ymin > p.y)
6557
- {
6558
- ymin = p.y;
6559
- newp = p;
6560
-// break;
6561
- }
6562
- if (ymin > q.y)
6563
- {
6564
- ymin = q.y;
6565
- newp = q;
6566
-// break;
6567
- }
6568
- if (ymin > r.y)
6569
- {
6570
- ymin = r.y;
6571
- newp = r;
6572
-// break;
6573
- }
6574
- }
6575
-
6576
- CameraPane.selectedpoint.toParent[3][0] = newp.x;
6577
- CameraPane.selectedpoint.toParent[3][1] = newp.y;
6578
- CameraPane.selectedpoint.toParent[3][2] = newp.z;
6579
-
6580
- drawingstarted = false;
6581
-
6582
- // return;
6583
- }
6584
-
6585
- if (false) // CameraPane.DRAW
6586
- {
6587
- p0.AO = colorV[0] = 2;
6588
- colorV[1] = 2;
6589
- colorV[2] = 2;
6590
- }
6591
-
6592
- CameraPane.pointflow.add(p0);
6593
- CameraPane.pointflow.Touch();
6594
- }
6595
-
6596
-// gl.glColor3f(colorV[0], colorV[1], colorV[2]);
6597
-// gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0);
6598
-// gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
6599
- }
6600
-
66016497 void Print(Vertex v)
66026498 {
66036499 //System.err.println("(" + v.x + ", " + v.y + ", " + v.z + ")");
66046500 }
66056501
6606
- void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean selectmode)
6607
- {
6608
- if (!selectmode)
6609
- {
6610
- gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
6611
- gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
6612
-
6613
- if (flipV)
6614
- gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
6615
- else
6616
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6617
- }
6618
-
6619
- gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
6620
- }
6621
-
6622
- void drawFace(Vertex pv, Vertex qv, Vertex rv,
6623
- CameraPane display, Face face)
6624
- {
6625
- if (pv.y == -10000 ||
6626
- qv.y == -10000 ||
6627
- rv.y == -10000)
6628
- return;
6629
-
6630
-// float b = f.nbiterations & 1;
6631
-// float g = (f.nbiterations>>1) & 1;
6632
-// float r = (f.nbiterations>>2) & 1;
6633
-//
6634
-// //if (f.weight == 10000)
6635
-// //{
6636
-// // r = 1; g = b = 0;
6637
-// //}
6638
-// //else
6639
-// //{
6640
-// // assert(f.weight < 10000);
6641
-// r = g = b = (float)bRep.FaceWeight(f)*100;
6642
-// if (r<0)
6643
-// assert(r>=0);
6644
-// //}
6645
-
6646
- javax.media.opengl.GL gl = display.GetGL();
6647
-
6648
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
6649
-
6650
- //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv);
6651
- if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
6652
- {
6653
- //gl.glBegin(gl.GL_TRIANGLES);
6654
- boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
6655
- if (!hasnorm)
6656
- {
6657
- // System.out.println("FUCK!!");
6658
- LA.vecSub(pv/*.pos*/, qv/*.pos*/, v0);
6659
- LA.vecSub(pv/*.pos*/, rv/*.pos*/, v1);
6660
- LA.vecCross(v0, v1, v2);
6661
- LA.vecNormalize(v2);
6662
- gl.glNormal3f((float) v2.x, (float) v2.y, (float) v2.z);
6663
- }
6664
-
6665
- if (hasnorm)
6666
- {
6667
-// if (!pv.norm.normalized())
6668
-// assert(pv.norm.normalized());
6669
-
6670
- //System.out.println("normalp = " + pv.norm.x + ", " + pv.norm.y + ", " + pv.norm.z);
6671
- gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
6672
- }
6673
- gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
6674
- SetColor(display, pv);
6675
- //gl.glColor4f(r, g, b, 1);
6676
- //gl.glColor4f(pv.boundary, pv.boundary, pv.boundary, 1);
6677
- if (flipV)
6678
- gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
6679
- else
6680
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6681
- //System.out.println("vertexp = " + pv.x + ", " + pv.y + ", " + pv.z);
6682
- gl.glVertex3f((float) pv./*pos.*/x, (float) pv./*pos.*/y, (float) pv./*pos.*/z);
6683
-// Print(pv);
6684
- if (hasnorm)
6685
- {
6686
-// assert(qv.norm.normalized());
6687
- //System.out.println("normalq = " + qv.norm.x + ", " + qv.norm.y + ", " + qv.norm.z);
6688
- gl.glNormal3f((float) qv.norm.x, (float) qv.norm.y, (float) qv.norm.z);
6689
- }
6690
- //System.out.println("vertexq = " + qv.s + ", " + qv.t);
6691
- // boolean locked = false;
6692
- // float eps = 0.1f;
6693
- // boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
6694
-
6695
- // int dot = 0; //*/ (int)f.dot;
6696
-
6697
- // if ((dot&1) == 0)
6698
- // dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
6699
-
6700
- // if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
6701
- if (flipV)
6702
- gl.glTexCoord2f((float) qv.s, 1-(float) qv.t);
6703
- else
6704
- gl.glTexCoord2f((float) qv.s, (float) qv.t);
6705
- // else
6706
- // {
6707
- // locked = true;
6708
- // gl.glTexCoord2f((float) pv.s, (float) pv.t);
6709
- // }
6710
- gl.glColor4f(qv.AO, qv.AO, qv.AO, 1);
6711
- SetColor(display, qv);
6712
- //gl.glColor4f(r, g, b, 1);
6713
- //gl.glColor4f(qv.boundary, qv.boundary, qv.boundary, 1);
6714
- //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6715
- gl.glVertex3f((float) qv./*pos.*/x, (float) qv./*pos.*/y, (float) qv./*pos.*/z);
6716
-// Print(qv);
6717
- if (hasnorm)
6718
- {
6719
-// assert(rv.norm.normalized());
6720
- //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6721
- gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
6722
- }
6723
-
6724
- // if ((dot&4) == 0)
6725
- // dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
6726
-
6727
- // if (wrap || !locked && (dot&8) != 0)
6728
- if (flipV)
6729
- gl.glTexCoord2f((float) rv.s, 1-(float) rv.t);
6730
- else
6731
- gl.glTexCoord2f((float) rv.s, (float) rv.t);
6732
- // else
6733
- // gl.glTexCoord2f((float) pv.s, (float) pv.t);
6734
-
6735
- // f.dot = dot;
6736
-
6737
- gl.glColor4f(rv.AO, rv.AO, rv.AO, 1);
6738
- SetColor(display, rv);
6739
- //gl.glColor4f(r, g, b, 1);
6740
- //gl.glColor4f(rv.boundary, rv.boundary, rv.boundary, 1);
6741
- //System.out.println("vertexr = " + rv.x + ", " + rv.y + ", " + rv.z);
6742
- gl.glVertex3f((float) rv./*pos.*/x, (float) rv./*pos.*/y, (float) rv./*pos.*/z);
6743
-// Print(rv);
6744
- //gl.glEnd();
6745
- }
6746
- else
6747
- {
6748
- gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
6749
- gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
6750
- gl.glVertex3f((float) rv.x, (float) rv.y, (float) rv.z);
6751
-
6752
- }
6753
-
6754
- if (false) // (attributes & WIREFRAME) != 0)
6755
- {
6756
- gl.glDisable(gl.GL_LIGHTING);
6757
-
6758
- gl.glBegin(gl.GL_LINE_LOOP);
6759
- gl.glVertex3d(pv./*pos.*/x, pv./*pos.*/y, pv./*pos.*/z);
6760
- gl.glVertex3d(qv./*pos.*/x, qv./*pos.*/y, qv./*pos.*/z);
6761
- gl.glVertex3d(rv./*pos.*/x, rv./*pos.*/y, rv./*pos.*/z);
6762
- gl.glEnd();
6763
-
6764
- gl.glEnable(gl.GL_LIGHTING);
6765
- }
6766
- }
6767
-
67686502 void drawSelf(ClickInfo info, int level, boolean select)
67696503 {
67706504 if (bRep == null)
....@@ -7336,83 +7070,83 @@
73367070 int spotw = spot.x + spot.width;
73377071 int spoth = spot.y + spot.height;
73387072 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7339
- if (CameraPane.Xmin > spot.x)
7340
- {
7341
- CameraPane.Xmin = spot.x;
7342
- }
7343
- if (CameraPane.Xmax < spotw)
7344
- {
7345
- CameraPane.Xmax = spotw;
7346
- }
7347
- if (CameraPane.Ymin > spot.y)
7348
- {
7349
- CameraPane.Ymin = spot.y;
7350
- }
7351
- if (CameraPane.Ymax < spoth)
7352
- {
7353
- CameraPane.Ymax = spoth;
7354
- }
7073
+// if (CameraPane.Xmin > spot.x)
7074
+// {
7075
+// CameraPane.Xmin = spot.x;
7076
+// }
7077
+// if (CameraPane.Xmax < spotw)
7078
+// {
7079
+// CameraPane.Xmax = spotw;
7080
+// }
7081
+// if (CameraPane.Ymin > spot.y)
7082
+// {
7083
+// CameraPane.Ymin = spot.y;
7084
+// }
7085
+// if (CameraPane.Ymax < spoth)
7086
+// {
7087
+// CameraPane.Ymax = spoth;
7088
+// }
73557089 spot.translate(32, 32);
73567090 spotw = spot.x + spot.width;
73577091 spoth = spot.y + spot.height;
73587092 info.g.setColor(Color.blue);
73597093 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7360
- if (CameraPane.Xmin > spot.x)
7361
- {
7362
- CameraPane.Xmin = spot.x;
7363
- }
7364
- if (CameraPane.Xmax < spotw)
7365
- {
7366
- CameraPane.Xmax = spotw;
7367
- }
7368
- if (CameraPane.Ymin > spot.y)
7369
- {
7370
- CameraPane.Ymin = spot.y;
7371
- }
7372
- if (CameraPane.Ymax < spoth)
7373
- {
7374
- CameraPane.Ymax = spoth;
7375
- }
7376
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7377
- info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7094
+// if (CameraPane.Xmin > spot.x)
7095
+// {
7096
+// CameraPane.Xmin = spot.x;
7097
+// }
7098
+// if (CameraPane.Xmax < spotw)
7099
+// {
7100
+// CameraPane.Xmax = spotw;
7101
+// }
7102
+// if (CameraPane.Ymin > spot.y)
7103
+// {
7104
+// CameraPane.Ymin = spot.y;
7105
+// }
7106
+// if (CameraPane.Ymax < spoth)
7107
+// {
7108
+// CameraPane.Ymax = spoth;
7109
+// }
7110
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7111
+ //info.g.drawLine(spotw, spoth, spotw - 15, spoth);
73787112 spot.translate(0, -32);
73797113 info.g.setColor(Color.green);
73807114 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7381
- if (CameraPane.Xmin > spot.x)
7382
- {
7383
- CameraPane.Xmin = spot.x;
7384
- }
7385
- if (CameraPane.Xmax < spotw)
7386
- {
7387
- CameraPane.Xmax = spotw;
7388
- }
7389
- if (CameraPane.Ymin > spot.y)
7390
- {
7391
- CameraPane.Ymin = spot.y;
7392
- }
7393
- if (CameraPane.Ymax < spoth)
7394
- {
7395
- CameraPane.Ymax = spoth;
7396
- }
7115
+// if (CameraPane.Xmin > spot.x)
7116
+// {
7117
+// CameraPane.Xmin = spot.x;
7118
+// }
7119
+// if (CameraPane.Xmax < spotw)
7120
+// {
7121
+// CameraPane.Xmax = spotw;
7122
+// }
7123
+// if (CameraPane.Ymin > spot.y)
7124
+// {
7125
+// CameraPane.Ymin = spot.y;
7126
+// }
7127
+// if (CameraPane.Ymax < spoth)
7128
+// {
7129
+// CameraPane.Ymax = spoth;
7130
+// }
73977131 info.g.drawArc(boundary.x, boundary.y,
73987132 boundary.width, boundary.height, 0, 360);
73997133 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
7400
- if (CameraPane.Xmin > boundary.x)
7401
- {
7402
- CameraPane.Xmin = boundary.x;
7403
- }
7404
- if (CameraPane.Xmax < boundary.x + boundary.width)
7405
- {
7406
- CameraPane.Xmax = boundary.x + boundary.width;
7407
- }
7408
- if (CameraPane.Ymin > boundary.y)
7409
- {
7410
- CameraPane.Ymin = boundary.y;
7411
- }
7412
- if (CameraPane.Ymax < boundary.y + boundary.height)
7413
- {
7414
- CameraPane.Ymax = boundary.y + boundary.height;
7415
- }
7134
+// if (CameraPane.Xmin > boundary.x)
7135
+// {
7136
+// CameraPane.Xmin = boundary.x;
7137
+// }
7138
+// if (CameraPane.Xmax < boundary.x + boundary.width)
7139
+// {
7140
+// CameraPane.Xmax = boundary.x + boundary.width;
7141
+// }
7142
+// if (CameraPane.Ymin > boundary.y)
7143
+// {
7144
+// CameraPane.Ymin = boundary.y;
7145
+// }
7146
+// if (CameraPane.Ymax < boundary.y + boundary.height)
7147
+// {
7148
+// CameraPane.Ymax = boundary.y + boundary.height;
7149
+// }
74167150 return;
74177151 }
74187152 }
....@@ -7429,7 +7163,7 @@
74297163 startX = info.x;
74307164 startY = info.y;
74317165
7432
- hitSomething = 0;
7166
+ hitSomething = -1;
74337167 cVector origin = new cVector();
74347168 //LA.xformPos(origin, toParent, origin);
74357169 Rectangle spot = new Rectangle();
....@@ -7462,7 +7196,7 @@
74627196 }
74637197
74647198 //System.out.println("info.modifiers = " + info.modifiers);
7465
- modified = (info.modifiers & CameraPane.META) != 0;
7199
+ modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
74667200 //System.out.println("modified = " + modified);
74677201 //new Exception().printStackTrace();
74687202 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7490,7 +7224,7 @@
74907224 return true;
74917225 }
74927226
7493
- void doEditDrag0(ClickInfo info)
7227
+ void doEditDrag0(ClickInfo info, boolean opposite)
74947228 {
74957229 if (hitSomething == 0)
74967230 {
....@@ -7505,6 +7239,7 @@
75057239 //System.out.println("hitSomething = " + hitSomething);
75067240
75077241 double scale = 0.005f * info.camera.Distance();
7242
+
75087243 cVector xlate = new cVector();
75097244 //cVector xlate2 = new cVector();
75107245 switch (hitSomething)
....@@ -7515,9 +7250,9 @@
75157250
75167251 case hitCenter: // Translate
75177252
7518
- scale *= 0.05f * info.pane.theRenderer.renderCamera.Distance();
7253
+ scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
75197254
7520
- if (modified)
7255
+ if (modified || opposite)
75217256 {
75227257 //assert(false);
75237258 /*
....@@ -7563,10 +7298,10 @@
75637298 }
75647299 LA.xformDir(up, ClickInfo.matbuffer, up);
75657300 // if (!CameraPane.LOCALTRANSFORM)
7566
- LA.xformDir(up, info.pane.theRenderer.renderCamera.toScreen, up);
7301
+ LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
75677302 LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
75687303 // if (!CameraPane.LOCALTRANSFORM)
7569
- LA.xformDir(away, info.pane.theRenderer.renderCamera.toScreen, away);
7304
+ LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
75707305 //LA.vecCross(up, cVector.Z, right2);
75717306
75727307 cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
....@@ -7611,6 +7346,7 @@
76117346
76127347 if (modified)
76137348 {
7349
+ // Rotate 90 degrees
76147350 angle /= (Math.PI / 4);
76157351 angle = Math.floor(angle + 0.5);
76167352 angle *= (Math.PI / 4);
....@@ -7624,7 +7360,7 @@
76247360 }
76257361 /**/
76267362
7627
- switch (info.pane.renderCamera.viewCode)
7363
+ switch (info.pane.RenderCamera().viewCode)
76287364 {
76297365 case 1: // '\001'
76307366 LA.matZRotate(toParent, angle);
....@@ -7652,24 +7388,27 @@
76527388
76537389 case hitScale: // scale
76547390 double hScale = (double) (info.x - centerPt.x) / 32;
7391
+ double sign = 1;
7392
+ if (hScale < 0)
7393
+ {
7394
+ sign = -1;
7395
+ }
7396
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
76557397 if (hScale < 0.01)
76567398 {
7657
- hScale = 0.01;
7399
+ //hScale = 0.01;
76587400 }
7659
- hScale = Math.pow(hScale, scale * 50);
7660
- if (hScale < 0.01)
7661
- {
7662
- hScale = 0.01;
7663
- }
7401
+
76647402 double vScale = (double) (info.y - centerPt.y) / 32;
7665
- if (vScale < 0.01)
7403
+ sign = 1;
7404
+ if (vScale < 0)
76667405 {
7667
- vScale = 0.01;
7406
+ sign = -1;
76687407 }
7669
- vScale = Math.pow(vScale, scale * 50);
7408
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
76707409 if (vScale < 0.01)
76717410 {
7672
- vScale = 0.01;
7411
+ //vScale = 0.01;
76737412 }
76747413 LA.matCopy(startMat, toParent);
76757414 /**/
....@@ -7680,17 +7419,24 @@
76807419 }
76817420 /**/
76827421
7683
- switch (info.pane.renderCamera.viewCode)
7422
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7423
+
7424
+ if (totalScale < 0.01)
7425
+ {
7426
+ totalScale = 0.01;
7427
+ }
7428
+
7429
+ switch (info.pane.RenderCamera().viewCode)
76847430 {
76857431 case 3: // '\001'
76867432 if (modified)
76877433 {
76887434 //LA.matScale(toParent, 1, hScale, vScale);
7689
- LA.matScale(toParent, vScale, 1, 1);
7435
+ LA.matScale(toParent, totalScale, 1, 1);
76907436 } // vScale, 1);
76917437 else
76927438 {
7693
- LA.matScale(toParent, vScale, vScale, vScale);
7439
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
76947440 } // vScale, 1);
76957441 break;
76967442
....@@ -7698,10 +7444,10 @@
76987444 if (modified)
76997445 {
77007446 //LA.matScale(toParent, hScale, 1, vScale);
7701
- LA.matScale(toParent, 1, vScale, 1);
7447
+ LA.matScale(toParent, 1, totalScale, 1);
77027448 } else
77037449 {
7704
- LA.matScale(toParent, vScale, 1, vScale);
7450
+ LA.matScale(toParent, totalScale, 1, totalScale);
77057451 }
77067452 break;
77077453
....@@ -7709,10 +7455,10 @@
77097455 if (modified)
77107456 {
77117457 //LA.matScale(toParent, hScale, vScale, 1);
7712
- LA.matScale(toParent, 1, 1, vScale);
7458
+ LA.matScale(toParent, 1, 1, totalScale);
77137459 } else
77147460 {
7715
- LA.matScale(toParent, vScale, vScale, 1);
7461
+ LA.matScale(toParent, totalScale, totalScale, 1);
77167462 }
77177463 break;
77187464 }
....@@ -7733,7 +7479,7 @@
77337479 if (parent == null)
77347480 {
77357481 System.out.println("NULL PARENT");
7736
- new Exception().printStackTrace();
7482
+ //new Exception().printStackTrace();
77377483 } else
77387484 {
77397485 if (parent instanceof BezierPatch)
....@@ -7845,14 +7591,22 @@
78457591 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
78467592 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
78477593 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7594
+
7595
+ String objname;
7596
+
78487597 if (false) //parent != null)
78497598 {
7850
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7599
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
78517600 } else
78527601 {
7853
- return GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ") ")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ +System.identityHashCode(this);
7602
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
78547603 } // + super.toString();
78557604 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
7605
+
7606
+ if (!Globals.ADVANCED)
7607
+ return objname;
7608
+
7609
+ return objname + " " + System.identityHashCode(this);
78567610 }
78577611
78587612 public int hashCode()
....@@ -7908,6 +7662,7 @@
79087662 objectUI.closeUI();
79097663 if (editWindow != null)
79107664 {
7665
+ editWindow.ctrlPanel.FlushUI();
79117666 editWindow.refreshContents();
79127667 } // ? new
79137668 objectUI = null;
....@@ -7928,7 +7683,7 @@
79287683 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
79297684
79307685 Object3D /*Composite*/ parent;
7931
- Object3D /*Composite*/ fileparent;
7686
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
79327687
79337688 double[][] toParent; // dynamic matrix
79347689 double[][] fromParent;
....@@ -8043,7 +7798,7 @@
80437798 {
80447799 assert(bRep != null);
80457800 if (!(support instanceof GenericJoint)) // support.bRep != null)
8046
- GrafreeD.Assert(support.bRep == bRep.support);
7801
+ Grafreed.Assert(support.bRep == bRep.support);
80477802 }
80487803 else
80497804 {
....@@ -8092,9 +7847,9 @@
80927847 private static cVector edge2 = new cVector();
80937848 //private static cVector norm = new cVector();
80947849 /*transient private*/ int hitSomething;
8095
- private static final int hitCenter = 1;
8096
- private static final int hitScale = 2;
8097
- private static final int hitRotate = 3;
7850
+ static final int hitCenter = 1;
7851
+ static final int hitScale = 2;
7852
+ static final int hitRotate = 3;
80987853 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
80997854 /*transient*/ private Point centerPt;
81007855 /*transient*/ private int startX;
....@@ -8126,6 +7881,8 @@
81267881 {
81277882 Object3D targ = this;
81287883
7884
+ targ.NORMALPUSH = obj.NORMALPUSH;
7885
+
81297886 if (obj.material != null)
81307887 {
81317888 if ((mask&MATERIAL)!=0) // ==(COLOR|MATERIAL))