Normand Briere
2019-06-11 d0dc7ff35d71919d503ae35592478b173cf3cfd3
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,30 @@
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
+
2227 ScriptNode scriptnode;
28
+
29
+ void InitOthers()
30
+ {
31
+ if (projectedVertices == null || projectedVertices.length <= 2)
32
+ {
33
+ projectedVertices = new Object3D.cVector2[3];
34
+ }
35
+ for (int i = 0; i < 3; i++)
36
+ {
37
+ projectedVertices[i] = new cVector2(); // Others
38
+ }
39
+ projectedVertices[0].x = 100; // bump
40
+ }
2341
2442 void MinMax(cVector minima, cVector maxima)
2543 {
....@@ -142,6 +160,59 @@
142160 blockloop = true;
143161 child.RestoreSupports();
144162 blockloop = false;
163
+ }
164
+}
165
+
166
+void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
167
+{
168
+ if (hashtable.containsKey(GetUUID()))
169
+ return;
170
+
171
+ Object3D o = new Object3D();
172
+ o.bRep = this.bRep;
173
+ if (this.bRep != null)
174
+ {
175
+ o.transientrep = this.bRep.support;
176
+ o.bRep.support = null;
177
+ }
178
+
179
+// o.support = this.support;
180
+// o.fileparent = this.fileparent;
181
+// if (this.bRep != null)
182
+// o.bRep = this.bRep.support;
183
+
184
+ hashtable.put(GetUUID(), o);
185
+
186
+ this.bRep = null;
187
+// if (this.bRep != null)
188
+// this.bRep.support = null;
189
+// this.support = null;
190
+// this.fileparent = null;
191
+
192
+ for (int i=0; i<Size(); i++)
193
+ {
194
+ get(i).ExtractBigData(hashtable);
195
+ }
196
+}
197
+
198
+void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
199
+{
200
+ if (!hashtable.containsKey(GetUUID()))
201
+ return;
202
+
203
+ Object3D o = hashtable.get(GetUUID());
204
+
205
+ this.bRep = o.bRep;
206
+ if (this.bRep != null)
207
+ this.bRep.support = o.transientrep;
208
+// this.support = o.support;
209
+// this.fileparent = o.fileparent;
210
+
211
+ hashtable.remove(GetUUID());
212
+
213
+ for (int i=0; i<Size(); i++)
214
+ {
215
+ get(i).RestoreBigData(hashtable);
145216 }
146217 }
147218
....@@ -286,6 +357,7 @@
286357 }
287358
288359 boolean live = false;
360
+ boolean dontselect = false;
289361 boolean hide = false;
290362 boolean link2master = false; // performs reset support/master at each frame
291363 boolean marked = false; // animation node
....@@ -295,6 +367,8 @@
295367 boolean random = false;
296368 boolean speedup = false;
297369 boolean rewind = false;
370
+
371
+ float NORMALPUSH = 0;
298372
299373 Object3D support;
300374
....@@ -355,7 +429,7 @@
355429
356430 int MemorySize()
357431 {
358
- if (memorysize == 0)
432
+ if (true) // memorysize == 0)
359433 {
360434 try
361435 {
....@@ -415,16 +489,16 @@
415489 {
416490 Object3D copy = this;
417491
418
- Camera parentcam = CameraPane.theRenderer.manipCamera;
492
+ Camera parentcam = Globals.theRenderer.ManipCamera();
419493
420
- if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[0])
494
+ if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[0])
421495 {
422
- parentcam = CameraPane.theRenderer.cameras[1];
496
+ parentcam = Globals.theRenderer.Cameras()[1];
423497 }
424498
425
- if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[1])
499
+ if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[1])
426500 {
427
- parentcam = CameraPane.theRenderer.cameras[0];
501
+ parentcam = Globals.theRenderer.Cameras()[0];
428502 }
429503
430504 if (this == parentcam)
....@@ -432,7 +506,7 @@
432506 //assert(this instanceof Camera);
433507
434508 for (int count = parentcam.GetTransformCount(); --count>=0;)
435
- LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.toParent, CameraPane.theRenderer.targetLookAt);
509
+ LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.toParent, Globals.theRenderer.TargetLookAt());
436510 }
437511
438512 copy.marked ^= true;
....@@ -452,7 +526,7 @@
452526 //assert(this instanceof Camera);
453527
454528 for (int count = parentcam.GetTransformCount(); --count>=0;)
455
- LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.fromParent, CameraPane.theRenderer.targetLookAt);
529
+ LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.fromParent, Globals.theRenderer.TargetLookAt());
456530 }
457531
458532 copy.Touch(); // display list issue
....@@ -587,7 +661,7 @@
587661 return;
588662 }
589663
590
- if (CameraPane.fromscript)
664
+ if (Globals.fromscript)
591665 {
592666 transformcount = 0;
593667 return;
....@@ -745,7 +819,7 @@
745819
746820 int GetTransformCount()
747821 {
748
- // marde pour serialization de Texture
822
+ // patch pour serialization de Texture
749823 resetmaxcount();
750824 resettransformcount();
751825 resetstep();
....@@ -758,7 +832,7 @@
758832 if (step == 0)
759833 step = 1;
760834 if (maxcount == 0)
761
- maxcount = 2048; // 4;
835
+ maxcount = 128; // 2048; // 4;
762836 // if (acceleration == 0)
763837 // acceleration = 10;
764838 if (delay == 0) // serial
....@@ -779,9 +853,12 @@
779853 // factor = CameraPane.STEP;
780854 // }
781855
782
- if (marked && CameraPane.isLIVE() && live && CameraPane.drawMode == CameraPane.SHADOW && currentframe != CameraPane.framecount)
856
+ if (marked && Globals.isLIVE() && live &&
857
+ //TEMP21aug2018
858
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
859
+ currentframe != Globals.framecount)
783860 {
784
- currentframe = CameraPane.framecount;
861
+ currentframe = Globals.framecount;
785862
786863 // System.err.println("transformcount = " + transformcount);
787864 // System.err.println("factor = " + factor);
....@@ -893,6 +970,11 @@
893970 fromParent = null; // LA.newMatrix();
894971 bRep = null; // new BoundaryRep();
895972
973
+ if (oname != null && oname.equals("LeftHand"))
974
+ {
975
+ name = oname;
976
+ }
977
+
896978 /*
897979 float hue = (float)Math.random();
898980 Color col;
....@@ -935,7 +1017,7 @@
9351017
9361018 public Object clone()
9371019 {
938
- return GraphreeD.clone(this);
1020
+ return Grafreed.clone(this);
9391021 }
9401022
9411023 Object3D copyExpand()
....@@ -1446,7 +1528,16 @@
14461528 // if (other == null)
14471529 // return;
14481530
1449
- System.out.println("Link support this = " + this + "; other = " + other);
1531
+ if (other != null)
1532
+ {
1533
+ BoundaryRep.SEUIL = other.material.cameralight;
1534
+
1535
+ // Set default to 0.1
1536
+ BoundaryRep.SEUIL /= 4; // 2;
1537
+ System.out.println("SEUIL = " + BoundaryRep.SEUIL);
1538
+ }
1539
+
1540
+ System.out.println("Link this = " + this + "; support = " + other);
14501541
14511542 //if (bRep != null)
14521543 // bRep.linkVerticesThis(other.bRep);
....@@ -1701,7 +1792,7 @@
17011792 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17021793 o.bRep = transientrep;
17031794 if (clone)
1704
- o.bRep = (BoundaryRep) GraphreeD.clone(transientrep);
1795
+ o.bRep = (BoundaryRep) Grafreed.clone(transientrep);
17051796 o.CreateMaterial();
17061797 o.SetAttributes(this, -1);
17071798 //parent
....@@ -1714,7 +1805,7 @@
17141805 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17151806 o.bRep = bRep;
17161807 if (clone)
1717
- o.bRep = (BoundaryRep) GraphreeD.clone(bRep);
1808
+ o.bRep = (BoundaryRep) Grafreed.clone(bRep);
17181809 o.CreateMaterial();
17191810 //o.overwriteThis(this, -1);
17201811 o.SetAttributes(this, -1);
....@@ -1756,7 +1847,7 @@
17561847 // {
17571848 // assert(bRep == null);
17581849 // Object3D o = new Object3D("Geometry:" + this.name);
1759
-// o.bRep = (BoundaryRep) GraphreeD.clone(transientrep);
1850
+// o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
17601851 // o.CreateMaterial();
17611852 // parent.addChild(o);
17621853 // }
....@@ -1765,7 +1856,7 @@
17651856 // {
17661857 // assert(transientrep == null);
17671858 // Object3D o = new Object3D("Geometry:" + this.name);
1768
-// o.bRep = (BoundaryRep) GraphreeD.clone(bRep);
1859
+// o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
17691860 // o.CreateMaterial();
17701861 // parent.addChild(o);
17711862 // }
....@@ -1801,12 +1892,15 @@
18011892 if (obj.name == null)
18021893 continue; // can't be a null one
18031894
1895
+ // Try perfect match first.
18041896 if (n.equals(obj.name))
18051897 {
18061898 theobj = obj;
18071899 count++;
18081900 }
18091901 }
1902
+
1903
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18101904
18111905 if (count != 1)
18121906 for (int i=Size(); --i>=0;)
....@@ -1816,8 +1910,9 @@
18161910 if (obj.name == null)
18171911 continue; // can't be a null one
18181912
1819
- //if (n.contains(obj.name)) // dec 2013 name.split(":")[0])) // Poser generates a count
1820
- if (n.startsWith(obj.name))
1913
+ String name = obj.name.split(":")[0]; // Poser generates a count
1914
+ //if (n.startsWith(obj.name))
1915
+ if (n.contains(name))
18211916 {
18221917 theobj = obj;
18231918 count++;
....@@ -2120,15 +2215,8 @@
21202215 if (/*parent != null &&*/ material == null)
21212216 {
21222217 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
2218
+
2219
+ InitOthers();
21322220
21332221 if (this instanceof Camera)
21342222 {
....@@ -2278,6 +2366,7 @@
22782366 {
22792367 if (newWindow)
22802368 {
2369
+ new Exception().printStackTrace();
22812370 System.exit(0);
22822371 if (parent != null)
22832372 {
....@@ -2454,13 +2543,13 @@
24542543 return retval;
24552544 }
24562545
2457
- void doEditDrag(ClickInfo info)
2546
+ void doEditDrag(ClickInfo info, boolean opposite)
24582547 {
24592548 switch (doSomething)
24602549 {
24612550 case 1: // '\001'
24622551 //super.
2463
- doEditDrag0(info);
2552
+ doEditDrag0(info, opposite);
24642553 break;
24652554
24662555 case 2: // '\002'
....@@ -2473,11 +2562,11 @@
24732562 {
24742563 //sel.hitSomething = childToDrag.hitSomething;
24752564 //childToDrag.doEditDrag(info);
2476
- sel.doEditDrag(info);
2565
+ sel.doEditDrag(info, opposite);
24772566 } else
24782567 {
24792568 //super.
2480
- doEditDrag0(info);
2569
+ doEditDrag0(info, opposite);
24812570 }
24822571 }
24832572 break;
....@@ -2732,6 +2821,24 @@
27322821 blockloop = false;
27332822 }
27342823
2824
+ void GenNormalsMINE()
2825
+ {
2826
+ if (blockloop)
2827
+ return;
2828
+
2829
+ blockloop = true;
2830
+ GenNormalsMINE0();
2831
+ for (int i = 0; i < Children().Size(); i++)
2832
+ {
2833
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2834
+ if (child == null)
2835
+ continue;
2836
+ child.GenNormalsMINE();
2837
+// Children().release(i);
2838
+ }
2839
+ blockloop = false;
2840
+ }
2841
+
27352842 void ClearColors()
27362843 {
27372844 if (blockloop)
....@@ -2866,7 +2973,8 @@
28662973 {
28672974 if (bRep != null)
28682975 {
2869
- bRep.GenUV();
2976
+ bRep.GenUV(); //1);
2977
+ //bRep.UnfoldUV();
28702978 Touch();
28712979 }
28722980 }
....@@ -2876,6 +2984,15 @@
28762984 if (bRep != null)
28772985 {
28782986 bRep.GenerateNormals(crease);
2987
+ Touch();
2988
+ }
2989
+ }
2990
+
2991
+ void GenNormalsMINE0()
2992
+ {
2993
+ if (bRep != null)
2994
+ {
2995
+ bRep.GenerateNormalsMINE();
28792996 Touch();
28802997 }
28812998 }
....@@ -2932,6 +3049,33 @@
29323049 blockloop = false;
29333050 }
29343051
3052
+ void TransformChildren()
3053
+ {
3054
+ if (toParent != null)
3055
+ {
3056
+ for (int i=Size(); --i>=0;)
3057
+ {
3058
+ Object3D v = get(i);
3059
+
3060
+ if (v.toParent == null)
3061
+ {
3062
+ v.toParent = LA.newMatrix();
3063
+ v.fromParent = LA.newMatrix();
3064
+ }
3065
+
3066
+// LA.matConcat(v.toParent, toParent, v.toParent);
3067
+// LA.matConcat(fromParent, v.fromParent, v.fromParent);
3068
+ LA.matConcat(toParent, v.toParent, v.toParent);
3069
+ LA.matConcat(v.fromParent, fromParent, v.fromParent);
3070
+ }
3071
+
3072
+ toParent = null; // LA.matIdentity(toParent);
3073
+ fromParent = null; // LA.matIdentity(fromParent);
3074
+
3075
+ Touch();
3076
+ }
3077
+ }
3078
+
29353079 void TransformGeometry()
29363080 {
29373081 Object3D obj = this;
....@@ -3153,9 +3297,11 @@
31533297
31543298 BoundaryRep sup = bRep.support;
31553299 bRep.support = null;
3156
- BoundaryRep temprep = (BoundaryRep) GraphreeD.clone(bRep);
3300
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
31573301 // bRep.SplitInTwo(onlyone); // thread...
3158
- temprep.SplitInTwo(reduction34, onlyone);
3302
+
3303
+ while(temprep.SplitInTwo(reduction34, onlyone));
3304
+
31593305 bRep = temprep;
31603306 bRep.support = sup;
31613307 Touch();
....@@ -3677,7 +3823,7 @@
36773823 if (child == null)
36783824 continue;
36793825
3680
- if (GraphreeD.RENDERME > 0)
3826
+ if (Grafreed.RENDERME > 0)
36813827 {
36823828 if (child instanceof Merge)
36833829 ((Merge)child).renderme();
....@@ -3717,7 +3863,7 @@
37173863
37183864 boolean getCentroid(cVector centroid, boolean xform)
37193865 {
3720
- assert(false);
3866
+// for speaker assert(false);
37213867 if (blockloop)
37223868 return false;
37233869
....@@ -3828,7 +3974,7 @@
38283974 if (child == null)
38293975 continue;
38303976
3831
- if (GraphreeD.RENDERME > 0)
3977
+ if (Grafreed.RENDERME > 0)
38323978 {
38333979 if (child instanceof Merge)
38343980 ((Merge)child).renderme();
....@@ -4023,7 +4169,7 @@
40234169 if (child == null)
40244170 continue;
40254171
4026
- if (GraphreeD.RENDERME > 0)
4172
+ if (Grafreed.RENDERME > 0)
40274173 {
40284174 if (child instanceof Merge)
40294175 ((Merge)child).renderme();
....@@ -4111,7 +4257,7 @@
41114257 if (blockloop)
41124258 return;
41134259
4114
- for (int i=0; i<size(); i++)
4260
+ for (int i=0; i<Size(); i++)
41154261 {
41164262 if (get(i).parent != this)
41174263 {
....@@ -4120,6 +4266,22 @@
41204266 }
41214267 blockloop = true;
41224268 get(i).RepairParent();
4269
+ blockloop = false;
4270
+ }
4271
+ }
4272
+
4273
+ void RepairShadow()
4274
+ {
4275
+ if (blockloop)
4276
+ return;
4277
+
4278
+ if (this.material != null)
4279
+ this.InitOthers();
4280
+
4281
+ for (int i=0; i<Size(); i++)
4282
+ {
4283
+ blockloop = true;
4284
+ get(i).RepairShadow();
41234285 blockloop = false;
41244286 }
41254287 }
....@@ -4515,16 +4677,28 @@
45154677
45164678 Object3D GetFileRoot()
45174679 {
4680
+ if (overflow)
4681
+ return null;
4682
+
4683
+ overflow = true;
4684
+
4685
+ Object3D pfr = null;
4686
+
45184687 if (parent == null && fileparent == null)
4519
- return this;
4688
+ pfr = this;
45204689
45214690 if (parent == null && fileparent != null) // V4.gfd???
4522
- return fileparent;
4691
+ pfr = fileparent;
45234692
4524
- if (parent == null)
4525
- return this;
4693
+ if (pfr == null && parent == null)
4694
+ pfr = this;
45264695
4527
- return parent.GetFileRoot();
4696
+ if (pfr == null)
4697
+ pfr = parent.GetFileRoot();
4698
+
4699
+ overflow = false;
4700
+
4701
+ return pfr;
45284702 }
45294703
45304704 cTreePath GetPath()
....@@ -4602,7 +4776,7 @@
46024776
46034777 cTreePath SelectLeaf(int indexcount, boolean deselect)
46044778 {
4605
- if (hide)
4779
+ if (hide || dontselect)
46064780 return null;
46074781
46084782 if (count <= 0)
....@@ -4628,7 +4802,7 @@
46284802
46294803 cTreePath Select(int indexcount, boolean deselect)
46304804 {
4631
- if (hide)
4805
+ if (hide || dontselect)
46324806 return null;
46334807
46344808 if (count <= 0)
....@@ -4778,7 +4952,7 @@
47784952 return globalTransform;
47794953 }
47804954
4781
- void PreprocessOcclusion(CameraPane cp)
4955
+ void PreprocessOcclusion(iCameraPane cp)
47824956 {
47834957 /*
47844958 if (AOdone)
....@@ -4925,7 +5099,8 @@
49255099 } else //
49265100 if (editWindow != null)
49275101 {
4928
- editWindow.cameraView.lighttouched = true;
5102
+ //editWindow.cameraView.lighttouched = true;
5103
+ Globals.lighttouched = true;
49295104 }
49305105 }
49315106
....@@ -5079,10 +5254,34 @@
50795254
50805255 // System.out.println("Fullname = " + fullname);
50815256
5082
- if (fullname.name.indexOf(":") == -1)
5083
- return fullname.name;
5257
+ // Does not work on Windows due to C:
5258
+// if (fullname.name.indexOf(":") == -1)
5259
+// return fullname.name;
5260
+//
5261
+// return fullname.name.substring(0,fullname.name.indexOf(":"));
50845262
5085
- return fullname.name.substring(0,fullname.name.indexOf(":"));
5263
+ String[] split = fullname.name.split(":");
5264
+
5265
+ if (split.length == 0)
5266
+ {
5267
+ return "";
5268
+ }
5269
+
5270
+ if (split.length <= 2)
5271
+ {
5272
+ if (fullname.name.endsWith(":"))
5273
+ {
5274
+ // Windows
5275
+ return fullname.name.substring(0, fullname.name.length()-1);
5276
+ }
5277
+
5278
+ return split[0];
5279
+ }
5280
+
5281
+ // Windows
5282
+ assert(split.length == 4);
5283
+
5284
+ return split[0] + ":" + split[1];
50865285 }
50875286
50885287 static String GetBump(cTexture fullname)
....@@ -5091,10 +5290,38 @@
50915290 return "";
50925291
50935292 // 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());
5293
+ // Does not work on Windows due to C:
5294
+// if (fullname.name.indexOf(":") == -1)
5295
+// return "";
5296
+//
5297
+// return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5298
+ String[] split = fullname.name.split(":");
5299
+
5300
+ if (split.length == 0)
5301
+ {
5302
+ return "";
5303
+ }
5304
+
5305
+ if (split.length == 1)
5306
+ {
5307
+ return "";
5308
+ }
5309
+
5310
+ if (split.length == 2)
5311
+ {
5312
+ if (fullname.name.endsWith(":"))
5313
+ {
5314
+ // Windows
5315
+ return "";
5316
+ }
5317
+
5318
+ return split[1];
5319
+ }
5320
+
5321
+ // Windows
5322
+ assert(split.length == 4);
5323
+
5324
+ return split[2] + ":" + split[3];
50985325 }
50995326
51005327 String GetPigmentTexture()
....@@ -5168,7 +5395,7 @@
51685395 System.out.print("; textures = " + textures);
51695396 System.out.println("; usedtextures = " + usedtextures);
51705397
5171
- if (GetTextures() == null)
5398
+ if (GetTextures() == null) // What is that??
51725399 GetTextures().name = ":";
51735400
51745401 String texname = tex;
....@@ -5199,6 +5426,43 @@
51995426 child.ResetPigmentTexture();
52005427 blockloop = false;
52015428 }
5429
+ }
5430
+
5431
+ UUID GetUUID()
5432
+ {
5433
+ if (uuid == null)
5434
+ {
5435
+ // Serial
5436
+ uuid = UUID.randomUUID();
5437
+ }
5438
+
5439
+ return uuid;
5440
+ }
5441
+
5442
+ Object3D GetObject(UUID uid)
5443
+ {
5444
+ if (blockloop)
5445
+ return null;
5446
+
5447
+ if (GetUUID().equals(uid))
5448
+ return this;
5449
+
5450
+ int nb = Size();
5451
+ for (int i = 0; i < nb; i++)
5452
+ {
5453
+ Object3D child = (Object3D) get(i);
5454
+
5455
+ if (child == null)
5456
+ continue;
5457
+
5458
+ blockloop = true;
5459
+ Object3D obj = child.GetObject(uid);
5460
+ blockloop = false;
5461
+ if (obj != null)
5462
+ return obj;
5463
+ }
5464
+
5465
+ return null;
52025466 }
52035467
52045468 void SetBumpTexture(String tex)
....@@ -5237,25 +5501,22 @@
52375501 }
52385502 }
52395503
5240
- void draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5504
+ void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
52415505 {
52425506 Draw(display, root, selected, blocked);
52435507 }
52445508
5245
- static cMaterial[] materialstack = new cMaterial[65536];
5246
- static boolean[] selectedstack = new boolean[65536];
5247
- static int materialdepth = 0;
5248
-
52495509 boolean NeedSupport()
52505510 {
52515511 return
5252
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5512
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null
52535513 // PROBLEM with CROWD!!
5254
- && (CameraPane.drawMode == CameraPane.SHADOW || CameraPane.CROWD);
5514
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
52555515 }
52565516
5517
+ static boolean DEBUG_SELECTION = false;
52575518
5258
- void Draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5519
+ void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
52595520 {
52605521 Invariants(); // june 2013
52615522
....@@ -5264,8 +5525,8 @@
52645525 // System.err.println("Draw " + this + " Frame # " + ((Mocap)((Merge)support).object).frame);
52655526 }
52665527
5267
- if (display.drawMode == CameraPane.SELECTION &&
5268
- hide)
5528
+ if (display.DrawMode() == iCameraPane.SELECTION &&
5529
+ (hide || dontselect))
52695530 return;
52705531
52715532 if (name != null && name.contains("sclera"))
....@@ -5280,10 +5541,10 @@
52805541 if (name != null && name.contains("sclera"))
52815542 name = name;
52825543
5283
- if (this instanceof CheckerIG)
5544
+ if (this instanceof Checker)
52845545 return;
52855546
5286
- if (display.drawMode == display.SHADOW && PASSTEST)
5547
+ if (display.DrawMode() == display.SHADOW && PASSTEST)
52875548 return;
52885549
52895550 if (count <= 0)
....@@ -5291,13 +5552,13 @@
52915552 return;
52925553 }
52935554
5294
- if ((//display.drawMode == CameraPane.SHADOW ||
5295
- display.drawMode == CameraPane.SELECTION || CameraPane.DEBUG_SELECTION) && HasTransparency())
5555
+ if ((//display.DrawMode() == CameraPane.SHADOW ||
5556
+ display.DrawMode() == iCameraPane.SELECTION || display.IsDebugSelection()) && HasTransparency())
52965557 {
52975558 return;
52985559 }
52995560
5300
- javax.media.opengl.GL gl = display.GetGL();
5561
+ //javax.media.opengl.GL gl = display.GetGL();
53015562
53025563 /*
53035564 if (touched)
....@@ -5333,15 +5594,15 @@
53335594
53345595 boolean compiled = false;
53355596
5336
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
5597
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
53375598
5338
- if (!selectmode && //display.drawMode != display.SELECTION &&
5599
+ if (!selectmode && //display.DrawMode() != display.SELECTION &&
53395600 (touched || (bRep != null && bRep.displaylist <= 0)))
53405601 {
5341
- display.lighttouched = true;
5602
+ Globals.lighttouched = true;
53425603 } // 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 &&
5604
+ //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
5605
+ if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
53455606 (touched || (bRep != null && bRep.displaylist <= 0)))
53465607 {
53475608 if (!(this instanceof Composite))
....@@ -5349,7 +5610,7 @@
53495610 //if (displaylist == -1 && usecalllists)
53505611 if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
53515612 {
5352
- bRep.displaylist = gl.glGenLists(1);
5613
+ bRep.displaylist = display.GenList();
53535614 assert(bRep.displaylist != 0);
53545615 // System.err.println("glGenLists: " + bRep.displaylist + " for " + this);
53555616 //System.out.println("\tgen list " + list);
....@@ -5361,18 +5622,20 @@
53615622 if (usecalllists)
53625623 {
53635624 // System.err.println("new list " + bRep.displaylist + " for " + this);
5364
- gl.glNewList(bRep.displaylist, gl.GL_COMPILE); //_AND_EXECUTE);
5625
+ display.NewList(bRep.displaylist);
53655626 }
5627
+
53665628 CallList(display, root, selected, blocked);
5629
+
53675630 // compiled = true;
53685631 if (usecalllists)
53695632 {
53705633 // System.err.println("end list " + bRep.displaylist + " for " + this);
5371
- gl.glEndList();
5634
+ display.EndList();
53725635 }
53735636 //gl.glDrawBuffer(gl.GL_BACK);
53745637 // XXX touched = false;
5375
- display.lighttouched = true; // all panes...
5638
+ Globals.lighttouched = true; // all panes...
53765639 }
53775640
53785641 touched = GetBRep() == null; // this instanceof Composite || this instanceof FileObject; // false;
....@@ -5411,12 +5674,12 @@
54115674
54125675 // frustum culling
54135676 if (CameraPane.FRUSTUM && !blocked && !IsInfinite() && GetBRep() != null // && GetBRep().VertexCount() != 1260 // default grid
5414
- && display.drawMode != CameraPane.SELECTION)
5677
+ && display.DrawMode() != iCameraPane.SELECTION)
54155678 {
5416
- if (display.drawMode == CameraPane.SHADOW)
5679
+ if (display.DrawMode() == iCameraPane.SHADOW)
54175680 {
54185681 if (!link2master // tricky to cull in shadow mode.
5419
- && GetBRep().FrustumCull(this, gl, display.lightCamera, true))
5682
+ && GetBRep().FrustumCull(this, null, display.LightCamera(), true))
54205683 {
54215684 //System.out.print("CULLED");
54225685 culled = true;
....@@ -5424,7 +5687,7 @@
54245687 }
54255688 else
54265689 //GetBRep().getBounds(v0, v1, this);
5427
- if (GetBRep().FrustumCull(this, gl, display.renderCamera, false))
5690
+ if (GetBRep().FrustumCull(this, null, display.RenderCamera(), false))
54285691 culled = true;
54295692
54305693 // LA.xformPos(v0, display.renderCamera.toScreen, v0);
....@@ -5460,11 +5723,11 @@
54605723
54615724
54625725 if (!culled)
5463
- if (display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION)
5726
+ if (display.DrawMode() == display.SELECTION || display.IsDebugSelection())
54645727 {
54655728 if (GetBRep() != null)
54665729 {
5467
- CameraPane.NextIndex(this, gl);
5730
+ display.NextIndex();
54685731 // vertex color conflict : gl.glCallList(list);
54695732 DrawNode(display, root, selected);
54705733 if (this instanceof BezierPatch)
....@@ -5486,53 +5749,7 @@
54865749 color[2] /= 2;
54875750 gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT_AND_DIFFUSE, color, 0);
54885751 */
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
- }
5752
+ display.PushMaterial(this, selected);
55365753
55375754 //System.out.println("call list " + list);
55385755 //System.out.println();
....@@ -5551,7 +5768,17 @@
55515768 tex = GetTextures();
55525769 }
55535770
5554
- display.BindTextures(tex, texres);
5771
+ boolean failed = false;
5772
+
5773
+ try
5774
+ {
5775
+ display.BindTextures(tex, texres);
5776
+ }
5777
+ catch (Exception e)
5778
+ {
5779
+ System.err.println("FAILED: " + this);
5780
+ failed = true;
5781
+ }
55555782
55565783 if (!compiled)
55575784 {
....@@ -5567,30 +5794,16 @@
55675794
55685795 // System.err.println("glCallList: " + bRep.displaylist + " for " + this);
55695796 assert(bRep.displaylist != 0);
5570
- gl.glCallList(bRep.displaylist);
5797
+ display.CallList(bRep.displaylist);
55715798 // june 2013 drawSelf(display, root, selected);
55725799 }
55735800 }
55745801 }
55755802
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
- }
5803
+ if (!failed)
5804
+ display.ReleaseTextures(tex);
5805
+
5806
+ display.PopMaterial(this, selected);
55945807 }
55955808
55965809 if (this instanceof Texture || this instanceof TextureNode)
....@@ -5632,7 +5845,7 @@
56325845 // resetMasterNode();
56335846 }
56345847
5635
- void CallList(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5848
+ void CallList(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
56365849 {
56375850 if (GetBRep() == null)
56385851 {
....@@ -5715,8 +5928,11 @@
57155928 boolean flipV = false; // true;
57165929 int texres = 0; // 0 = low, 1 = normal, 2 = high res texture
57175930
5718
- void drawSelf(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5931
+ void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57195932 {
5933
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
5934
+ return;
5935
+
57205936 if (hide)
57215937 return;
57225938 // shadow optimisation
....@@ -5774,16 +5990,7 @@
57745990 // // ??????????????????????????? Touch();
57755991 // }
57765992
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
- }
5993
+display.PushMaterial2(this, selected);
57875994
57885995 Object3D child;
57895996 boolean sel;
....@@ -5807,12 +6014,12 @@
58076014 if (!child.HasTransparency())
58086015 {
58096016 sel = root != null && root.selection != null && root.selection.indexOf(child) != -1;
5810
- // GraphreeD.tracein("draw ", child);
6017
+ // GrafreeD.tracein("draw ", child);
58116018 boolean wasblocked = blockdraw;
58126019 blockdraw = true;
58136020 child.draw(display, root, selected || sel, wasblocked || blocked); // || child.IsSelected());
58146021 blockdraw = false;
5815
- // GraphreeD.traceout("draw ", child);
6022
+ // GrafreeD.traceout("draw ", child);
58166023 }
58176024
58186025 release(i);
....@@ -5835,19 +6042,7 @@
58356042 */
58366043 //depth += 1;
58376044
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
-
6045
+display.PopMaterial2(this);
58516046 /*
58526047 display.ReleaseTextures(tex);
58536048 */
....@@ -5858,10 +6053,13 @@
58586053
58596054 //static cVector min,max;
58606055
5861
- void DrawNode(CameraPane display, Object3D /*Composite*/ root, boolean selected)
6056
+ void DrawNode(iCameraPane display, Object3D /*Composite*/ root, boolean selected)
58626057 {
5863
- if (display.drawMode == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
6058
+ if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
58646059 return; // no shadow for transparent objects
6060
+
6061
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6062
+ return;
58656063
58666064 if (hide)
58676065 return;
....@@ -5903,11 +6101,12 @@
59036101 return;
59046102 }
59056103
6104
+ //bRep.GenUV(1/material.diffuseness);
59066105 // bRep.lock = true;
59076106
5908
- javax.media.opengl.GL gl = display.GetGL();
6107
+ //javax.media.opengl.GL gl = display.GetGL();
59096108
5910
- if (CameraPane.BOXMODE) // || CameraPane.movingcamera)
6109
+ if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera)
59116110 {
59126111 int fc = bRep.FaceCount();
59136112 int vc = bRep.VertexCount();
....@@ -5922,23 +6121,7 @@
59226121
59236122 bRep.getMinMax(min, max, 100);
59246123
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();
6124
+ display.DrawBox(min, max);
59426125
59436126 return;
59446127 }
....@@ -5982,7 +6165,7 @@
59826165 {
59836166 //throw new Error();
59846167
5985
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
6168
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
59866169
59876170 int[] strips = bRep.getRawIndices();
59886171
....@@ -5992,178 +6175,14 @@
59926175 new Exception().printStackTrace();
59936176 return;
59946177 }
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
- }
6178
+
6179
+ display.DrawGeometry(bRep, flipV, selectmode);
61616180 } else // catch (Error e)
61626181 {
61636182 // TRIANGLE ARRAY
61646183 if (IsOpaque()) // Static())
61656184 {
6166
- gl.glBegin(gl.GL_TRIANGLES);
6185
+ display.StartTriangles();
61676186 int facecount = bRep.FaceCount();
61686187 for (int i = 0; i < facecount; i++)
61696188 {
....@@ -6226,9 +6245,9 @@
62266245 // // r.norm.dot(v3) > -0.5)
62276246 // // continue;
62286247
6229
- drawFace(p, q, r, display, face);
6248
+ display.DrawFace(this, p, q, r, face);
62306249 }
6231
- gl.glEnd();
6250
+ display.EndTriangles();
62326251 }
62336252 else
62346253 {
....@@ -6257,8 +6276,8 @@
62576276 //System.out.println("SORT");
62586277
62596278 java.util.Arrays.sort(facescompare);
6260
-
6261
- gl.glBegin(gl.GL_TRIANGLES);
6279
+
6280
+ display.StartTriangles();
62626281 for (int i = 0; i < facecount; i++)
62636282 {
62646283 Face face = bRep.GetFace(facescompare[i].index);
....@@ -6270,13 +6289,14 @@
62706289 Vertex q = bRep.GetVertex(face.q);
62716290 Vertex r = bRep.GetVertex(face.r);
62726291
6273
- drawFace(p, q, r, display, face);
6292
+ display.DrawFace(this, p, q, r, face);
62746293 }
6275
- gl.glEnd();
6294
+ display.EndTriangles();
62766295 }
62776296
62786297 if (false) // live && support != null && support.bRep != null) // debug weights
62796298 {
6299
+ /*
62806300 gl.glDisable(gl.GL_LIGHTING);
62816301 float[] colorV = new float[3];
62826302
....@@ -6355,6 +6375,7 @@
63556375 // gl.glEnd();
63566376 }
63576377 }
6378
+ */
63586379 }
63596380 }
63606381
....@@ -6399,7 +6420,7 @@
63996420 center.add(r);
64006421 center.mul(1.0/3);
64016422
6402
- center.sub(CameraPane.theRenderer.eyeCamera.location);
6423
+ center.sub(Globals.theRenderer.EyeCamera().location);
64036424
64046425 distance = center.dot(center);
64056426 }
....@@ -6410,347 +6431,11 @@
64106431
64116432 transient FaceCompare[] facescompare = null;
64126433
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
-
65876434 void Print(Vertex v)
65886435 {
65896436 //System.err.println("(" + v.x + ", " + v.y + ", " + v.z + ")");
65906437 }
65916438
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
-
67546439 void drawSelf(ClickInfo info, int level, boolean select)
67556440 {
67566441 if (bRep == null)
....@@ -7322,83 +7007,83 @@
73227007 int spotw = spot.x + spot.width;
73237008 int spoth = spot.y + spot.height;
73247009 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
- }
7010
+// if (CameraPane.Xmin > spot.x)
7011
+// {
7012
+// CameraPane.Xmin = spot.x;
7013
+// }
7014
+// if (CameraPane.Xmax < spotw)
7015
+// {
7016
+// CameraPane.Xmax = spotw;
7017
+// }
7018
+// if (CameraPane.Ymin > spot.y)
7019
+// {
7020
+// CameraPane.Ymin = spot.y;
7021
+// }
7022
+// if (CameraPane.Ymax < spoth)
7023
+// {
7024
+// CameraPane.Ymax = spoth;
7025
+// }
73417026 spot.translate(32, 32);
73427027 spotw = spot.x + spot.width;
73437028 spoth = spot.y + spot.height;
73447029 info.g.setColor(Color.blue);
73457030 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);
7031
+// if (CameraPane.Xmin > spot.x)
7032
+// {
7033
+// CameraPane.Xmin = spot.x;
7034
+// }
7035
+// if (CameraPane.Xmax < spotw)
7036
+// {
7037
+// CameraPane.Xmax = spotw;
7038
+// }
7039
+// if (CameraPane.Ymin > spot.y)
7040
+// {
7041
+// CameraPane.Ymin = spot.y;
7042
+// }
7043
+// if (CameraPane.Ymax < spoth)
7044
+// {
7045
+// CameraPane.Ymax = spoth;
7046
+// }
7047
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7048
+ //info.g.drawLine(spotw, spoth, spotw - 15, spoth);
73647049 spot.translate(0, -32);
73657050 info.g.setColor(Color.green);
73667051 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
- }
7052
+// if (CameraPane.Xmin > spot.x)
7053
+// {
7054
+// CameraPane.Xmin = spot.x;
7055
+// }
7056
+// if (CameraPane.Xmax < spotw)
7057
+// {
7058
+// CameraPane.Xmax = spotw;
7059
+// }
7060
+// if (CameraPane.Ymin > spot.y)
7061
+// {
7062
+// CameraPane.Ymin = spot.y;
7063
+// }
7064
+// if (CameraPane.Ymax < spoth)
7065
+// {
7066
+// CameraPane.Ymax = spoth;
7067
+// }
73837068 info.g.drawArc(boundary.x, boundary.y,
73847069 boundary.width, boundary.height, 0, 360);
73857070 //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
- }
7071
+// if (CameraPane.Xmin > boundary.x)
7072
+// {
7073
+// CameraPane.Xmin = boundary.x;
7074
+// }
7075
+// if (CameraPane.Xmax < boundary.x + boundary.width)
7076
+// {
7077
+// CameraPane.Xmax = boundary.x + boundary.width;
7078
+// }
7079
+// if (CameraPane.Ymin > boundary.y)
7080
+// {
7081
+// CameraPane.Ymin = boundary.y;
7082
+// }
7083
+// if (CameraPane.Ymax < boundary.y + boundary.height)
7084
+// {
7085
+// CameraPane.Ymax = boundary.y + boundary.height;
7086
+// }
74027087 return;
74037088 }
74047089 }
....@@ -7415,7 +7100,7 @@
74157100 startX = info.x;
74167101 startY = info.y;
74177102
7418
- hitSomething = 0;
7103
+ hitSomething = -1;
74197104 cVector origin = new cVector();
74207105 //LA.xformPos(origin, toParent, origin);
74217106 Rectangle spot = new Rectangle();
....@@ -7448,7 +7133,7 @@
74487133 }
74497134
74507135 //System.out.println("info.modifiers = " + info.modifiers);
7451
- modified = (info.modifiers & CameraPane.META) != 0;
7136
+ modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
74527137 //System.out.println("modified = " + modified);
74537138 //new Exception().printStackTrace();
74547139 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7476,7 +7161,7 @@
74767161 return true;
74777162 }
74787163
7479
- void doEditDrag0(ClickInfo info)
7164
+ void doEditDrag0(ClickInfo info, boolean opposite)
74807165 {
74817166 if (hitSomething == 0)
74827167 {
....@@ -7491,6 +7176,7 @@
74917176 //System.out.println("hitSomething = " + hitSomething);
74927177
74937178 double scale = 0.005f * info.camera.Distance();
7179
+
74947180 cVector xlate = new cVector();
74957181 //cVector xlate2 = new cVector();
74967182 switch (hitSomething)
....@@ -7501,9 +7187,9 @@
75017187
75027188 case hitCenter: // Translate
75037189
7504
- scale *= 0.05f * info.pane.theRenderer.renderCamera.Distance();
7190
+ scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
75057191
7506
- if (modified)
7192
+ if (modified || opposite)
75077193 {
75087194 //assert(false);
75097195 /*
....@@ -7549,10 +7235,10 @@
75497235 }
75507236 LA.xformDir(up, ClickInfo.matbuffer, up);
75517237 // if (!CameraPane.LOCALTRANSFORM)
7552
- LA.xformDir(up, info.pane.theRenderer.renderCamera.toScreen, up);
7238
+ LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
75537239 LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
75547240 // if (!CameraPane.LOCALTRANSFORM)
7555
- LA.xformDir(away, info.pane.theRenderer.renderCamera.toScreen, away);
7241
+ LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
75567242 //LA.vecCross(up, cVector.Z, right2);
75577243
75587244 cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
....@@ -7597,6 +7283,7 @@
75977283
75987284 if (modified)
75997285 {
7286
+ // Rotate 90 degrees
76007287 angle /= (Math.PI / 4);
76017288 angle = Math.floor(angle + 0.5);
76027289 angle *= (Math.PI / 4);
....@@ -7610,7 +7297,7 @@
76107297 }
76117298 /**/
76127299
7613
- switch (info.pane.renderCamera.viewCode)
7300
+ switch (info.pane.RenderCamera().viewCode)
76147301 {
76157302 case 1: // '\001'
76167303 LA.matZRotate(toParent, angle);
....@@ -7638,24 +7325,27 @@
76387325
76397326 case hitScale: // scale
76407327 double hScale = (double) (info.x - centerPt.x) / 32;
7328
+ double sign = 1;
7329
+ if (hScale < 0)
7330
+ {
7331
+ sign = -1;
7332
+ }
7333
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
76417334 if (hScale < 0.01)
76427335 {
7643
- hScale = 0.01;
7336
+ //hScale = 0.01;
76447337 }
7645
- hScale = Math.pow(hScale, scale * 50);
7646
- if (hScale < 0.01)
7647
- {
7648
- hScale = 0.01;
7649
- }
7338
+
76507339 double vScale = (double) (info.y - centerPt.y) / 32;
7651
- if (vScale < 0.01)
7340
+ sign = 1;
7341
+ if (vScale < 0)
76527342 {
7653
- vScale = 0.01;
7343
+ sign = -1;
76547344 }
7655
- vScale = Math.pow(vScale, scale * 50);
7345
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
76567346 if (vScale < 0.01)
76577347 {
7658
- vScale = 0.01;
7348
+ //vScale = 0.01;
76597349 }
76607350 LA.matCopy(startMat, toParent);
76617351 /**/
....@@ -7666,17 +7356,24 @@
76667356 }
76677357 /**/
76687358
7669
- switch (info.pane.renderCamera.viewCode)
7359
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7360
+
7361
+ if (totalScale < 0.01)
7362
+ {
7363
+ totalScale = 0.01;
7364
+ }
7365
+
7366
+ switch (info.pane.RenderCamera().viewCode)
76707367 {
76717368 case 3: // '\001'
76727369 if (modified)
76737370 {
76747371 //LA.matScale(toParent, 1, hScale, vScale);
7675
- LA.matScale(toParent, vScale, 1, 1);
7372
+ LA.matScale(toParent, totalScale, 1, 1);
76767373 } // vScale, 1);
76777374 else
76787375 {
7679
- LA.matScale(toParent, vScale, vScale, vScale);
7376
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
76807377 } // vScale, 1);
76817378 break;
76827379
....@@ -7684,10 +7381,10 @@
76847381 if (modified)
76857382 {
76867383 //LA.matScale(toParent, hScale, 1, vScale);
7687
- LA.matScale(toParent, 1, vScale, 1);
7384
+ LA.matScale(toParent, 1, totalScale, 1);
76887385 } else
76897386 {
7690
- LA.matScale(toParent, vScale, 1, vScale);
7387
+ LA.matScale(toParent, totalScale, 1, totalScale);
76917388 }
76927389 break;
76937390
....@@ -7695,10 +7392,10 @@
76957392 if (modified)
76967393 {
76977394 //LA.matScale(toParent, hScale, vScale, 1);
7698
- LA.matScale(toParent, 1, 1, vScale);
7395
+ LA.matScale(toParent, 1, 1, totalScale);
76997396 } else
77007397 {
7701
- LA.matScale(toParent, vScale, vScale, 1);
7398
+ LA.matScale(toParent, totalScale, totalScale, 1);
77027399 }
77037400 break;
77047401 }
....@@ -7719,7 +7416,7 @@
77197416 if (parent == null)
77207417 {
77217418 System.out.println("NULL PARENT");
7722
- new Exception().printStackTrace();
7419
+ //new Exception().printStackTrace();
77237420 } else
77247421 {
77257422 if (parent instanceof BezierPatch)
....@@ -7735,8 +7432,15 @@
77357432 info.pane.repaint();
77367433 }
77377434
7435
+ boolean overflow = false;
7436
+
77387437 void TransformToWorld(cVector out) // , cVector out)
77397438 {
7439
+ if (overflow)
7440
+ return;
7441
+
7442
+ overflow = true;
7443
+
77407444 // june 2013 ??? assert (in == out);
77417445 cVector in = out;
77427446 if (toParent != null && !(this instanceof Texture || this instanceof TextureNode))
....@@ -7753,6 +7457,8 @@
77537457 {
77547458 (parent!=null?parent:fileparent).TransformToWorld(out); //, out);
77557459 }
7460
+
7461
+ overflow = false;
77567462 }
77577463
77587464 void TransformToLocal(cVector out) //, cVector out)
....@@ -7822,14 +7528,22 @@
78227528 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
78237529 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
78247530 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7531
+
7532
+ String objname;
7533
+
78257534 if (false) //parent != null)
78267535 {
7827
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7536
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
78287537 } else
78297538 {
7830
- return GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ") ")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ +System.identityHashCode(this);
7539
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
78317540 } // + super.toString();
78327541 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
7542
+
7543
+ if (!Globals.ADVANCED)
7544
+ return objname;
7545
+
7546
+ return objname + " " + System.identityHashCode(this);
78337547 }
78347548
78357549 public int hashCode()
....@@ -7885,6 +7599,7 @@
78857599 objectUI.closeUI();
78867600 if (editWindow != null)
78877601 {
7602
+ editWindow.ctrlPanel.FlushUI();
78887603 editWindow.refreshContents();
78897604 } // ? new
78907605 objectUI = null;
....@@ -7905,7 +7620,7 @@
79057620 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
79067621
79077622 Object3D /*Composite*/ parent;
7908
- Object3D /*Composite*/ fileparent;
7623
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
79097624
79107625 double[][] toParent; // dynamic matrix
79117626 double[][] fromParent;
....@@ -7995,19 +7710,22 @@
79957710 max = new cVector();
79967711 }
79977712
7998
- Object3D sourcenode = GetFileRoot();
7999
-
8000
- if (!sourcenode.name.contains("rclab"))
7713
+ if (false) // Can crawl!!
80017714 {
8002
- getBounds(min, max, true);
7715
+ Object3D sourcenode = GetFileRoot();
80037716
8004
- if (min.y != Double.POSITIVE_INFINITY && min.y > 2)
7717
+ if (sourcenode != null && !sourcenode.name.contains("rclab"))
80057718 {
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();
7719
+ getBounds(min, max, true);
7720
+
7721
+ if (min.y != Double.POSITIVE_INFINITY && min.y > 2)
7722
+ {
7723
+ // sourcenode.getBounds(min, max, true);
7724
+ sourcenode.getBounds(v0, v1, true);
7725
+ // sourcenode.toParent = sourcenode.toParent;
7726
+ // get(0).toParent = get(0).toParent;
7727
+ // sourcenode.GlobalTransform();
7728
+ }
80117729 }
80127730 }
80137731
....@@ -8016,7 +7734,8 @@
80167734 if (support != null)
80177735 {
80187736 assert(bRep != null);
8019
- GraphreeD.Assert(support.bRep == bRep.support);
7737
+ if (!(support instanceof GenericJoint)) // support.bRep != null)
7738
+ Grafreed.Assert(support.bRep == bRep.support);
80207739 }
80217740 else
80227741 {
....@@ -8065,9 +7784,9 @@
80657784 private static cVector edge2 = new cVector();
80667785 //private static cVector norm = new cVector();
80677786 /*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;
7787
+ static final int hitCenter = 1;
7788
+ static final int hitScale = 2;
7789
+ static final int hitRotate = 3;
80717790 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
80727791 /*transient*/ private Point centerPt;
80737792 /*transient*/ private int startX;
....@@ -8099,6 +7818,8 @@
80997818 {
81007819 Object3D targ = this;
81017820
7821
+ targ.NORMALPUSH = obj.NORMALPUSH;
7822
+
81027823 if (obj.material != null)
81037824 {
81047825 if ((mask&MATERIAL)!=0) // ==(COLOR|MATERIAL))