Normand Briere
2019-06-11 5e6a6f3319f0c4c687fe71952ac9ecc17792b83a
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 {
....@@ -286,6 +304,7 @@
286304 }
287305
288306 boolean live = false;
307
+ boolean dontselect = false;
289308 boolean hide = false;
290309 boolean link2master = false; // performs reset support/master at each frame
291310 boolean marked = false; // animation node
....@@ -295,6 +314,8 @@
295314 boolean random = false;
296315 boolean speedup = false;
297316 boolean rewind = false;
317
+
318
+ float NORMALPUSH = 0;
298319
299320 Object3D support;
300321
....@@ -355,7 +376,7 @@
355376
356377 int MemorySize()
357378 {
358
- if (memorysize == 0)
379
+ if (true) // memorysize == 0)
359380 {
360381 try
361382 {
....@@ -415,16 +436,16 @@
415436 {
416437 Object3D copy = this;
417438
418
- Camera parentcam = CameraPane.theRenderer.manipCamera;
439
+ Camera parentcam = Globals.theRenderer.ManipCamera();
419440
420
- if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[0])
441
+ if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[0])
421442 {
422
- parentcam = CameraPane.theRenderer.cameras[1];
443
+ parentcam = Globals.theRenderer.Cameras()[1];
423444 }
424445
425
- if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[1])
446
+ if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[1])
426447 {
427
- parentcam = CameraPane.theRenderer.cameras[0];
448
+ parentcam = Globals.theRenderer.Cameras()[0];
428449 }
429450
430451 if (this == parentcam)
....@@ -432,7 +453,7 @@
432453 //assert(this instanceof Camera);
433454
434455 for (int count = parentcam.GetTransformCount(); --count>=0;)
435
- LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.toParent, CameraPane.theRenderer.targetLookAt);
456
+ LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.toParent, Globals.theRenderer.TargetLookAt());
436457 }
437458
438459 copy.marked ^= true;
....@@ -452,7 +473,7 @@
452473 //assert(this instanceof Camera);
453474
454475 for (int count = parentcam.GetTransformCount(); --count>=0;)
455
- LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.fromParent, CameraPane.theRenderer.targetLookAt);
476
+ LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.fromParent, Globals.theRenderer.TargetLookAt());
456477 }
457478
458479 copy.Touch(); // display list issue
....@@ -587,7 +608,7 @@
587608 return;
588609 }
589610
590
- if (CameraPane.fromscript)
611
+ if (Globals.fromscript)
591612 {
592613 transformcount = 0;
593614 return;
....@@ -745,7 +766,7 @@
745766
746767 int GetTransformCount()
747768 {
748
- // marde pour serialization de Texture
769
+ // patch pour serialization de Texture
749770 resetmaxcount();
750771 resettransformcount();
751772 resetstep();
....@@ -758,7 +779,7 @@
758779 if (step == 0)
759780 step = 1;
760781 if (maxcount == 0)
761
- maxcount = 2048; // 4;
782
+ maxcount = 128; // 2048; // 4;
762783 // if (acceleration == 0)
763784 // acceleration = 10;
764785 if (delay == 0) // serial
....@@ -779,9 +800,12 @@
779800 // factor = CameraPane.STEP;
780801 // }
781802
782
- if (marked && CameraPane.isLIVE() && live && CameraPane.drawMode == CameraPane.SHADOW && currentframe != CameraPane.framecount)
803
+ if (marked && Globals.isLIVE() && live &&
804
+ //TEMP21aug2018
805
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
806
+ currentframe != Globals.framecount)
783807 {
784
- currentframe = CameraPane.framecount;
808
+ currentframe = Globals.framecount;
785809
786810 // System.err.println("transformcount = " + transformcount);
787811 // System.err.println("factor = " + factor);
....@@ -893,6 +917,11 @@
893917 fromParent = null; // LA.newMatrix();
894918 bRep = null; // new BoundaryRep();
895919
920
+ if (oname != null && oname.equals("LeftHand"))
921
+ {
922
+ name = oname;
923
+ }
924
+
896925 /*
897926 float hue = (float)Math.random();
898927 Color col;
....@@ -935,7 +964,7 @@
935964
936965 public Object clone()
937966 {
938
- return GraphreeD.clone(this);
967
+ return Grafreed.clone(this);
939968 }
940969
941970 Object3D copyExpand()
....@@ -1446,7 +1475,16 @@
14461475 // if (other == null)
14471476 // return;
14481477
1449
- System.out.println("Link support this = " + this + "; other = " + other);
1478
+ if (other != null)
1479
+ {
1480
+ BoundaryRep.SEUIL = other.material.cameralight;
1481
+
1482
+ // Set default to 0.1
1483
+ BoundaryRep.SEUIL /= 4; // 2;
1484
+ System.out.println("SEUIL = " + BoundaryRep.SEUIL);
1485
+ }
1486
+
1487
+ System.out.println("Link this = " + this + "; support = " + other);
14501488
14511489 //if (bRep != null)
14521490 // bRep.linkVerticesThis(other.bRep);
....@@ -1701,7 +1739,7 @@
17011739 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17021740 o.bRep = transientrep;
17031741 if (clone)
1704
- o.bRep = (BoundaryRep) GraphreeD.clone(transientrep);
1742
+ o.bRep = (BoundaryRep) Grafreed.clone(transientrep);
17051743 o.CreateMaterial();
17061744 o.SetAttributes(this, -1);
17071745 //parent
....@@ -1714,7 +1752,7 @@
17141752 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17151753 o.bRep = bRep;
17161754 if (clone)
1717
- o.bRep = (BoundaryRep) GraphreeD.clone(bRep);
1755
+ o.bRep = (BoundaryRep) Grafreed.clone(bRep);
17181756 o.CreateMaterial();
17191757 //o.overwriteThis(this, -1);
17201758 o.SetAttributes(this, -1);
....@@ -1756,7 +1794,7 @@
17561794 // {
17571795 // assert(bRep == null);
17581796 // Object3D o = new Object3D("Geometry:" + this.name);
1759
-// o.bRep = (BoundaryRep) GraphreeD.clone(transientrep);
1797
+// o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
17601798 // o.CreateMaterial();
17611799 // parent.addChild(o);
17621800 // }
....@@ -1765,7 +1803,7 @@
17651803 // {
17661804 // assert(transientrep == null);
17671805 // Object3D o = new Object3D("Geometry:" + this.name);
1768
-// o.bRep = (BoundaryRep) GraphreeD.clone(bRep);
1806
+// o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
17691807 // o.CreateMaterial();
17701808 // parent.addChild(o);
17711809 // }
....@@ -1801,12 +1839,15 @@
18011839 if (obj.name == null)
18021840 continue; // can't be a null one
18031841
1842
+ // Try perfect match first.
18041843 if (n.equals(obj.name))
18051844 {
18061845 theobj = obj;
18071846 count++;
18081847 }
18091848 }
1849
+
1850
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18101851
18111852 if (count != 1)
18121853 for (int i=Size(); --i>=0;)
....@@ -1816,8 +1857,9 @@
18161857 if (obj.name == null)
18171858 continue; // can't be a null one
18181859
1819
- //if (n.contains(obj.name)) // dec 2013 name.split(":")[0])) // Poser generates a count
1820
- if (n.startsWith(obj.name))
1860
+ String name = obj.name.split(":")[0]; // Poser generates a count
1861
+ //if (n.startsWith(obj.name))
1862
+ if (n.contains(name))
18211863 {
18221864 theobj = obj;
18231865 count++;
....@@ -2120,15 +2162,8 @@
21202162 if (/*parent != null &&*/ material == null)
21212163 {
21222164 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
2165
+
2166
+ InitOthers();
21322167
21332168 if (this instanceof Camera)
21342169 {
....@@ -2278,6 +2313,7 @@
22782313 {
22792314 if (newWindow)
22802315 {
2316
+ new Exception().printStackTrace();
22812317 System.exit(0);
22822318 if (parent != null)
22832319 {
....@@ -2454,13 +2490,13 @@
24542490 return retval;
24552491 }
24562492
2457
- void doEditDrag(ClickInfo info)
2493
+ void doEditDrag(ClickInfo info, boolean opposite)
24582494 {
24592495 switch (doSomething)
24602496 {
24612497 case 1: // '\001'
24622498 //super.
2463
- doEditDrag0(info);
2499
+ doEditDrag0(info, opposite);
24642500 break;
24652501
24662502 case 2: // '\002'
....@@ -2473,11 +2509,11 @@
24732509 {
24742510 //sel.hitSomething = childToDrag.hitSomething;
24752511 //childToDrag.doEditDrag(info);
2476
- sel.doEditDrag(info);
2512
+ sel.doEditDrag(info, opposite);
24772513 } else
24782514 {
24792515 //super.
2480
- doEditDrag0(info);
2516
+ doEditDrag0(info, opposite);
24812517 }
24822518 }
24832519 break;
....@@ -2732,6 +2768,24 @@
27322768 blockloop = false;
27332769 }
27342770
2771
+ void GenNormalsMINE()
2772
+ {
2773
+ if (blockloop)
2774
+ return;
2775
+
2776
+ blockloop = true;
2777
+ GenNormalsMINE0();
2778
+ for (int i = 0; i < Children().Size(); i++)
2779
+ {
2780
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2781
+ if (child == null)
2782
+ continue;
2783
+ child.GenNormalsMINE();
2784
+// Children().release(i);
2785
+ }
2786
+ blockloop = false;
2787
+ }
2788
+
27352789 void ClearColors()
27362790 {
27372791 if (blockloop)
....@@ -2866,7 +2920,8 @@
28662920 {
28672921 if (bRep != null)
28682922 {
2869
- bRep.GenUV();
2923
+ bRep.GenUV(); //1);
2924
+ //bRep.UnfoldUV();
28702925 Touch();
28712926 }
28722927 }
....@@ -2876,6 +2931,15 @@
28762931 if (bRep != null)
28772932 {
28782933 bRep.GenerateNormals(crease);
2934
+ Touch();
2935
+ }
2936
+ }
2937
+
2938
+ void GenNormalsMINE0()
2939
+ {
2940
+ if (bRep != null)
2941
+ {
2942
+ bRep.GenerateNormalsMINE();
28792943 Touch();
28802944 }
28812945 }
....@@ -2932,6 +2996,33 @@
29322996 blockloop = false;
29332997 }
29342998
2999
+ void TransformChildren()
3000
+ {
3001
+ if (toParent != null)
3002
+ {
3003
+ for (int i=Size(); --i>=0;)
3004
+ {
3005
+ Object3D v = get(i);
3006
+
3007
+ if (v.toParent == null)
3008
+ {
3009
+ v.toParent = LA.newMatrix();
3010
+ v.fromParent = LA.newMatrix();
3011
+ }
3012
+
3013
+// LA.matConcat(v.toParent, toParent, v.toParent);
3014
+// LA.matConcat(fromParent, v.fromParent, v.fromParent);
3015
+ LA.matConcat(toParent, v.toParent, v.toParent);
3016
+ LA.matConcat(v.fromParent, fromParent, v.fromParent);
3017
+ }
3018
+
3019
+ toParent = null; // LA.matIdentity(toParent);
3020
+ fromParent = null; // LA.matIdentity(fromParent);
3021
+
3022
+ Touch();
3023
+ }
3024
+ }
3025
+
29353026 void TransformGeometry()
29363027 {
29373028 Object3D obj = this;
....@@ -3153,9 +3244,11 @@
31533244
31543245 BoundaryRep sup = bRep.support;
31553246 bRep.support = null;
3156
- BoundaryRep temprep = (BoundaryRep) GraphreeD.clone(bRep);
3247
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
31573248 // bRep.SplitInTwo(onlyone); // thread...
3158
- temprep.SplitInTwo(reduction34, onlyone);
3249
+
3250
+ while(temprep.SplitInTwo(reduction34, onlyone));
3251
+
31593252 bRep = temprep;
31603253 bRep.support = sup;
31613254 Touch();
....@@ -3677,7 +3770,7 @@
36773770 if (child == null)
36783771 continue;
36793772
3680
- if (GraphreeD.RENDERME > 0)
3773
+ if (Grafreed.RENDERME > 0)
36813774 {
36823775 if (child instanceof Merge)
36833776 ((Merge)child).renderme();
....@@ -3717,7 +3810,7 @@
37173810
37183811 boolean getCentroid(cVector centroid, boolean xform)
37193812 {
3720
- assert(false);
3813
+// for speaker assert(false);
37213814 if (blockloop)
37223815 return false;
37233816
....@@ -3828,7 +3921,7 @@
38283921 if (child == null)
38293922 continue;
38303923
3831
- if (GraphreeD.RENDERME > 0)
3924
+ if (Grafreed.RENDERME > 0)
38323925 {
38333926 if (child instanceof Merge)
38343927 ((Merge)child).renderme();
....@@ -4023,7 +4116,7 @@
40234116 if (child == null)
40244117 continue;
40254118
4026
- if (GraphreeD.RENDERME > 0)
4119
+ if (Grafreed.RENDERME > 0)
40274120 {
40284121 if (child instanceof Merge)
40294122 ((Merge)child).renderme();
....@@ -4111,7 +4204,7 @@
41114204 if (blockloop)
41124205 return;
41134206
4114
- for (int i=0; i<size(); i++)
4207
+ for (int i=0; i<Size(); i++)
41154208 {
41164209 if (get(i).parent != this)
41174210 {
....@@ -4120,6 +4213,22 @@
41204213 }
41214214 blockloop = true;
41224215 get(i).RepairParent();
4216
+ blockloop = false;
4217
+ }
4218
+ }
4219
+
4220
+ void RepairShadow()
4221
+ {
4222
+ if (blockloop)
4223
+ return;
4224
+
4225
+ if (this.material != null)
4226
+ this.InitOthers();
4227
+
4228
+ for (int i=0; i<Size(); i++)
4229
+ {
4230
+ blockloop = true;
4231
+ get(i).RepairShadow();
41234232 blockloop = false;
41244233 }
41254234 }
....@@ -4515,16 +4624,28 @@
45154624
45164625 Object3D GetFileRoot()
45174626 {
4627
+ if (overflow)
4628
+ return null;
4629
+
4630
+ overflow = true;
4631
+
4632
+ Object3D pfr = null;
4633
+
45184634 if (parent == null && fileparent == null)
4519
- return this;
4635
+ pfr = this;
45204636
45214637 if (parent == null && fileparent != null) // V4.gfd???
4522
- return fileparent;
4638
+ pfr = fileparent;
45234639
4524
- if (parent == null)
4525
- return this;
4640
+ if (pfr == null && parent == null)
4641
+ pfr = this;
45264642
4527
- return parent.GetFileRoot();
4643
+ if (pfr == null)
4644
+ pfr = parent.GetFileRoot();
4645
+
4646
+ overflow = false;
4647
+
4648
+ return pfr;
45284649 }
45294650
45304651 cTreePath GetPath()
....@@ -4602,7 +4723,7 @@
46024723
46034724 cTreePath SelectLeaf(int indexcount, boolean deselect)
46044725 {
4605
- if (hide)
4726
+ if (hide || dontselect)
46064727 return null;
46074728
46084729 if (count <= 0)
....@@ -4628,7 +4749,7 @@
46284749
46294750 cTreePath Select(int indexcount, boolean deselect)
46304751 {
4631
- if (hide)
4752
+ if (hide || dontselect)
46324753 return null;
46334754
46344755 if (count <= 0)
....@@ -4778,7 +4899,7 @@
47784899 return globalTransform;
47794900 }
47804901
4781
- void PreprocessOcclusion(CameraPane cp)
4902
+ void PreprocessOcclusion(iCameraPane cp)
47824903 {
47834904 /*
47844905 if (AOdone)
....@@ -4925,7 +5046,8 @@
49255046 } else //
49265047 if (editWindow != null)
49275048 {
4928
- editWindow.cameraView.lighttouched = true;
5049
+ //editWindow.cameraView.lighttouched = true;
5050
+ Globals.lighttouched = true;
49295051 }
49305052 }
49315053
....@@ -5079,10 +5201,34 @@
50795201
50805202 // System.out.println("Fullname = " + fullname);
50815203
5082
- if (fullname.name.indexOf(":") == -1)
5083
- return fullname.name;
5204
+ // Does not work on Windows due to C:
5205
+// if (fullname.name.indexOf(":") == -1)
5206
+// return fullname.name;
5207
+//
5208
+// return fullname.name.substring(0,fullname.name.indexOf(":"));
50845209
5085
- return fullname.name.substring(0,fullname.name.indexOf(":"));
5210
+ String[] split = fullname.name.split(":");
5211
+
5212
+ if (split.length == 0)
5213
+ {
5214
+ return "";
5215
+ }
5216
+
5217
+ if (split.length <= 2)
5218
+ {
5219
+ if (fullname.name.endsWith(":"))
5220
+ {
5221
+ // Windows
5222
+ return fullname.name.substring(0, fullname.name.length()-1);
5223
+ }
5224
+
5225
+ return split[0];
5226
+ }
5227
+
5228
+ // Windows
5229
+ assert(split.length == 4);
5230
+
5231
+ return split[0] + ":" + split[1];
50865232 }
50875233
50885234 static String GetBump(cTexture fullname)
....@@ -5091,10 +5237,38 @@
50915237 return "";
50925238
50935239 // 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());
5240
+ // Does not work on Windows due to C:
5241
+// if (fullname.name.indexOf(":") == -1)
5242
+// return "";
5243
+//
5244
+// return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5245
+ String[] split = fullname.name.split(":");
5246
+
5247
+ if (split.length == 0)
5248
+ {
5249
+ return "";
5250
+ }
5251
+
5252
+ if (split.length == 1)
5253
+ {
5254
+ return "";
5255
+ }
5256
+
5257
+ if (split.length == 2)
5258
+ {
5259
+ if (fullname.name.endsWith(":"))
5260
+ {
5261
+ // Windows
5262
+ return "";
5263
+ }
5264
+
5265
+ return split[1];
5266
+ }
5267
+
5268
+ // Windows
5269
+ assert(split.length == 4);
5270
+
5271
+ return split[2] + ":" + split[3];
50985272 }
50995273
51005274 String GetPigmentTexture()
....@@ -5168,7 +5342,7 @@
51685342 System.out.print("; textures = " + textures);
51695343 System.out.println("; usedtextures = " + usedtextures);
51705344
5171
- if (GetTextures() == null)
5345
+ if (GetTextures() == null) // What is that??
51725346 GetTextures().name = ":";
51735347
51745348 String texname = tex;
....@@ -5199,6 +5373,43 @@
51995373 child.ResetPigmentTexture();
52005374 blockloop = false;
52015375 }
5376
+ }
5377
+
5378
+ UUID GetUUID()
5379
+ {
5380
+ if (uuid == null)
5381
+ {
5382
+ // Serial
5383
+ uuid = UUID.randomUUID();
5384
+ }
5385
+
5386
+ return uuid;
5387
+ }
5388
+
5389
+ Object3D GetObject(UUID uid)
5390
+ {
5391
+ if (blockloop)
5392
+ return null;
5393
+
5394
+ if (GetUUID().equals(uid))
5395
+ return this;
5396
+
5397
+ int nb = Size();
5398
+ for (int i = 0; i < nb; i++)
5399
+ {
5400
+ Object3D child = (Object3D) get(i);
5401
+
5402
+ if (child == null)
5403
+ continue;
5404
+
5405
+ blockloop = true;
5406
+ Object3D obj = child.GetObject(uid);
5407
+ blockloop = false;
5408
+ if (obj != null)
5409
+ return obj;
5410
+ }
5411
+
5412
+ return null;
52025413 }
52035414
52045415 void SetBumpTexture(String tex)
....@@ -5237,25 +5448,22 @@
52375448 }
52385449 }
52395450
5240
- void draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5451
+ void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
52415452 {
52425453 Draw(display, root, selected, blocked);
52435454 }
52445455
5245
- static cMaterial[] materialstack = new cMaterial[65536];
5246
- static boolean[] selectedstack = new boolean[65536];
5247
- static int materialdepth = 0;
5248
-
52495456 boolean NeedSupport()
52505457 {
52515458 return
5252
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5459
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null
52535460 // PROBLEM with CROWD!!
5254
- && (CameraPane.drawMode == CameraPane.SHADOW || CameraPane.CROWD);
5461
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
52555462 }
52565463
5464
+ static boolean DEBUG_SELECTION = false;
52575465
5258
- void Draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5466
+ void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
52595467 {
52605468 Invariants(); // june 2013
52615469
....@@ -5264,8 +5472,8 @@
52645472 // System.err.println("Draw " + this + " Frame # " + ((Mocap)((Merge)support).object).frame);
52655473 }
52665474
5267
- if (display.drawMode == CameraPane.SELECTION &&
5268
- hide)
5475
+ if (display.DrawMode() == iCameraPane.SELECTION &&
5476
+ (hide || dontselect))
52695477 return;
52705478
52715479 if (name != null && name.contains("sclera"))
....@@ -5280,10 +5488,10 @@
52805488 if (name != null && name.contains("sclera"))
52815489 name = name;
52825490
5283
- if (this instanceof CheckerIG)
5491
+ if (this instanceof Checker)
52845492 return;
52855493
5286
- if (display.drawMode == display.SHADOW && PASSTEST)
5494
+ if (display.DrawMode() == display.SHADOW && PASSTEST)
52875495 return;
52885496
52895497 if (count <= 0)
....@@ -5291,13 +5499,13 @@
52915499 return;
52925500 }
52935501
5294
- if ((//display.drawMode == CameraPane.SHADOW ||
5295
- display.drawMode == CameraPane.SELECTION || CameraPane.DEBUG_SELECTION) && HasTransparency())
5502
+ if ((//display.DrawMode() == CameraPane.SHADOW ||
5503
+ display.DrawMode() == iCameraPane.SELECTION || display.IsDebugSelection()) && HasTransparency())
52965504 {
52975505 return;
52985506 }
52995507
5300
- javax.media.opengl.GL gl = display.GetGL();
5508
+ //javax.media.opengl.GL gl = display.GetGL();
53015509
53025510 /*
53035511 if (touched)
....@@ -5333,15 +5541,15 @@
53335541
53345542 boolean compiled = false;
53355543
5336
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
5544
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
53375545
5338
- if (!selectmode && //display.drawMode != display.SELECTION &&
5546
+ if (!selectmode && //display.DrawMode() != display.SELECTION &&
53395547 (touched || (bRep != null && bRep.displaylist <= 0)))
53405548 {
5341
- display.lighttouched = true;
5549
+ Globals.lighttouched = true;
53425550 } // 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 &&
5551
+ //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
5552
+ if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
53455553 (touched || (bRep != null && bRep.displaylist <= 0)))
53465554 {
53475555 if (!(this instanceof Composite))
....@@ -5349,7 +5557,7 @@
53495557 //if (displaylist == -1 && usecalllists)
53505558 if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
53515559 {
5352
- bRep.displaylist = gl.glGenLists(1);
5560
+ bRep.displaylist = display.GenList();
53535561 assert(bRep.displaylist != 0);
53545562 // System.err.println("glGenLists: " + bRep.displaylist + " for " + this);
53555563 //System.out.println("\tgen list " + list);
....@@ -5361,18 +5569,20 @@
53615569 if (usecalllists)
53625570 {
53635571 // System.err.println("new list " + bRep.displaylist + " for " + this);
5364
- gl.glNewList(bRep.displaylist, gl.GL_COMPILE); //_AND_EXECUTE);
5572
+ display.NewList(bRep.displaylist);
53655573 }
5574
+
53665575 CallList(display, root, selected, blocked);
5576
+
53675577 // compiled = true;
53685578 if (usecalllists)
53695579 {
53705580 // System.err.println("end list " + bRep.displaylist + " for " + this);
5371
- gl.glEndList();
5581
+ display.EndList();
53725582 }
53735583 //gl.glDrawBuffer(gl.GL_BACK);
53745584 // XXX touched = false;
5375
- display.lighttouched = true; // all panes...
5585
+ Globals.lighttouched = true; // all panes...
53765586 }
53775587
53785588 touched = GetBRep() == null; // this instanceof Composite || this instanceof FileObject; // false;
....@@ -5411,12 +5621,12 @@
54115621
54125622 // frustum culling
54135623 if (CameraPane.FRUSTUM && !blocked && !IsInfinite() && GetBRep() != null // && GetBRep().VertexCount() != 1260 // default grid
5414
- && display.drawMode != CameraPane.SELECTION)
5624
+ && display.DrawMode() != iCameraPane.SELECTION)
54155625 {
5416
- if (display.drawMode == CameraPane.SHADOW)
5626
+ if (display.DrawMode() == iCameraPane.SHADOW)
54175627 {
54185628 if (!link2master // tricky to cull in shadow mode.
5419
- && GetBRep().FrustumCull(this, gl, display.lightCamera, true))
5629
+ && GetBRep().FrustumCull(this, null, display.LightCamera(), true))
54205630 {
54215631 //System.out.print("CULLED");
54225632 culled = true;
....@@ -5424,7 +5634,7 @@
54245634 }
54255635 else
54265636 //GetBRep().getBounds(v0, v1, this);
5427
- if (GetBRep().FrustumCull(this, gl, display.renderCamera, false))
5637
+ if (GetBRep().FrustumCull(this, null, display.RenderCamera(), false))
54285638 culled = true;
54295639
54305640 // LA.xformPos(v0, display.renderCamera.toScreen, v0);
....@@ -5460,11 +5670,11 @@
54605670
54615671
54625672 if (!culled)
5463
- if (display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION)
5673
+ if (display.DrawMode() == display.SELECTION || display.IsDebugSelection())
54645674 {
54655675 if (GetBRep() != null)
54665676 {
5467
- CameraPane.NextIndex(this, gl);
5677
+ display.NextIndex();
54685678 // vertex color conflict : gl.glCallList(list);
54695679 DrawNode(display, root, selected);
54705680 if (this instanceof BezierPatch)
....@@ -5486,53 +5696,7 @@
54865696 color[2] /= 2;
54875697 gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT_AND_DIFFUSE, color, 0);
54885698 */
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
- }
5699
+ display.PushMaterial(this, selected);
55365700
55375701 //System.out.println("call list " + list);
55385702 //System.out.println();
....@@ -5551,7 +5715,17 @@
55515715 tex = GetTextures();
55525716 }
55535717
5554
- display.BindTextures(tex, texres);
5718
+ boolean failed = false;
5719
+
5720
+ try
5721
+ {
5722
+ display.BindTextures(tex, texres);
5723
+ }
5724
+ catch (Exception e)
5725
+ {
5726
+ System.err.println("FAILED: " + this);
5727
+ failed = true;
5728
+ }
55555729
55565730 if (!compiled)
55575731 {
....@@ -5567,30 +5741,16 @@
55675741
55685742 // System.err.println("glCallList: " + bRep.displaylist + " for " + this);
55695743 assert(bRep.displaylist != 0);
5570
- gl.glCallList(bRep.displaylist);
5744
+ display.CallList(bRep.displaylist);
55715745 // june 2013 drawSelf(display, root, selected);
55725746 }
55735747 }
55745748 }
55755749
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
- }
5750
+ if (!failed)
5751
+ display.ReleaseTextures(tex);
5752
+
5753
+ display.PopMaterial(this, selected);
55945754 }
55955755
55965756 if (this instanceof Texture || this instanceof TextureNode)
....@@ -5632,7 +5792,7 @@
56325792 // resetMasterNode();
56335793 }
56345794
5635
- void CallList(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5795
+ void CallList(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
56365796 {
56375797 if (GetBRep() == null)
56385798 {
....@@ -5715,8 +5875,11 @@
57155875 boolean flipV = false; // true;
57165876 int texres = 0; // 0 = low, 1 = normal, 2 = high res texture
57175877
5718
- void drawSelf(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5878
+ void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57195879 {
5880
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
5881
+ return;
5882
+
57205883 if (hide)
57215884 return;
57225885 // shadow optimisation
....@@ -5774,16 +5937,7 @@
57745937 // // ??????????????????????????? Touch();
57755938 // }
57765939
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
- }
5940
+display.PushMaterial2(this, selected);
57875941
57885942 Object3D child;
57895943 boolean sel;
....@@ -5807,12 +5961,12 @@
58075961 if (!child.HasTransparency())
58085962 {
58095963 sel = root != null && root.selection != null && root.selection.indexOf(child) != -1;
5810
- // GraphreeD.tracein("draw ", child);
5964
+ // GrafreeD.tracein("draw ", child);
58115965 boolean wasblocked = blockdraw;
58125966 blockdraw = true;
58135967 child.draw(display, root, selected || sel, wasblocked || blocked); // || child.IsSelected());
58145968 blockdraw = false;
5815
- // GraphreeD.traceout("draw ", child);
5969
+ // GrafreeD.traceout("draw ", child);
58165970 }
58175971
58185972 release(i);
....@@ -5835,19 +5989,7 @@
58355989 */
58365990 //depth += 1;
58375991
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
-
5992
+display.PopMaterial2(this);
58515993 /*
58525994 display.ReleaseTextures(tex);
58535995 */
....@@ -5858,10 +6000,13 @@
58586000
58596001 //static cVector min,max;
58606002
5861
- void DrawNode(CameraPane display, Object3D /*Composite*/ root, boolean selected)
6003
+ void DrawNode(iCameraPane display, Object3D /*Composite*/ root, boolean selected)
58626004 {
5863
- if (display.drawMode == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
6005
+ if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
58646006 return; // no shadow for transparent objects
6007
+
6008
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6009
+ return;
58656010
58666011 if (hide)
58676012 return;
....@@ -5903,11 +6048,12 @@
59036048 return;
59046049 }
59056050
6051
+ //bRep.GenUV(1/material.diffuseness);
59066052 // bRep.lock = true;
59076053
5908
- javax.media.opengl.GL gl = display.GetGL();
6054
+ //javax.media.opengl.GL gl = display.GetGL();
59096055
5910
- if (CameraPane.BOXMODE) // || CameraPane.movingcamera)
6056
+ if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera)
59116057 {
59126058 int fc = bRep.FaceCount();
59136059 int vc = bRep.VertexCount();
....@@ -5922,23 +6068,7 @@
59226068
59236069 bRep.getMinMax(min, max, 100);
59246070
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();
6071
+ display.DrawBox(min, max);
59426072
59436073 return;
59446074 }
....@@ -5982,7 +6112,7 @@
59826112 {
59836113 //throw new Error();
59846114
5985
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
6115
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
59866116
59876117 int[] strips = bRep.getRawIndices();
59886118
....@@ -5992,178 +6122,14 @@
59926122 new Exception().printStackTrace();
59936123 return;
59946124 }
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
- }
6125
+
6126
+ display.DrawGeometry(bRep, flipV, selectmode);
61616127 } else // catch (Error e)
61626128 {
61636129 // TRIANGLE ARRAY
61646130 if (IsOpaque()) // Static())
61656131 {
6166
- gl.glBegin(gl.GL_TRIANGLES);
6132
+ display.StartTriangles();
61676133 int facecount = bRep.FaceCount();
61686134 for (int i = 0; i < facecount; i++)
61696135 {
....@@ -6226,9 +6192,9 @@
62266192 // // r.norm.dot(v3) > -0.5)
62276193 // // continue;
62286194
6229
- drawFace(p, q, r, display, face);
6195
+ display.DrawFace(this, p, q, r, face);
62306196 }
6231
- gl.glEnd();
6197
+ display.EndTriangles();
62326198 }
62336199 else
62346200 {
....@@ -6257,8 +6223,8 @@
62576223 //System.out.println("SORT");
62586224
62596225 java.util.Arrays.sort(facescompare);
6260
-
6261
- gl.glBegin(gl.GL_TRIANGLES);
6226
+
6227
+ display.StartTriangles();
62626228 for (int i = 0; i < facecount; i++)
62636229 {
62646230 Face face = bRep.GetFace(facescompare[i].index);
....@@ -6270,13 +6236,14 @@
62706236 Vertex q = bRep.GetVertex(face.q);
62716237 Vertex r = bRep.GetVertex(face.r);
62726238
6273
- drawFace(p, q, r, display, face);
6239
+ display.DrawFace(this, p, q, r, face);
62746240 }
6275
- gl.glEnd();
6241
+ display.EndTriangles();
62766242 }
62776243
62786244 if (false) // live && support != null && support.bRep != null) // debug weights
62796245 {
6246
+ /*
62806247 gl.glDisable(gl.GL_LIGHTING);
62816248 float[] colorV = new float[3];
62826249
....@@ -6355,6 +6322,7 @@
63556322 // gl.glEnd();
63566323 }
63576324 }
6325
+ */
63586326 }
63596327 }
63606328
....@@ -6399,7 +6367,7 @@
63996367 center.add(r);
64006368 center.mul(1.0/3);
64016369
6402
- center.sub(CameraPane.theRenderer.eyeCamera.location);
6370
+ center.sub(Globals.theRenderer.EyeCamera().location);
64036371
64046372 distance = center.dot(center);
64056373 }
....@@ -6410,347 +6378,11 @@
64106378
64116379 transient FaceCompare[] facescompare = null;
64126380
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
-
65876381 void Print(Vertex v)
65886382 {
65896383 //System.err.println("(" + v.x + ", " + v.y + ", " + v.z + ")");
65906384 }
65916385
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
-
67546386 void drawSelf(ClickInfo info, int level, boolean select)
67556387 {
67566388 if (bRep == null)
....@@ -7322,83 +6954,83 @@
73226954 int spotw = spot.x + spot.width;
73236955 int spoth = spot.y + spot.height;
73246956 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
- }
6957
+// if (CameraPane.Xmin > spot.x)
6958
+// {
6959
+// CameraPane.Xmin = spot.x;
6960
+// }
6961
+// if (CameraPane.Xmax < spotw)
6962
+// {
6963
+// CameraPane.Xmax = spotw;
6964
+// }
6965
+// if (CameraPane.Ymin > spot.y)
6966
+// {
6967
+// CameraPane.Ymin = spot.y;
6968
+// }
6969
+// if (CameraPane.Ymax < spoth)
6970
+// {
6971
+// CameraPane.Ymax = spoth;
6972
+// }
73416973 spot.translate(32, 32);
73426974 spotw = spot.x + spot.width;
73436975 spoth = spot.y + spot.height;
73446976 info.g.setColor(Color.blue);
73456977 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);
6978
+// if (CameraPane.Xmin > spot.x)
6979
+// {
6980
+// CameraPane.Xmin = spot.x;
6981
+// }
6982
+// if (CameraPane.Xmax < spotw)
6983
+// {
6984
+// CameraPane.Xmax = spotw;
6985
+// }
6986
+// if (CameraPane.Ymin > spot.y)
6987
+// {
6988
+// CameraPane.Ymin = spot.y;
6989
+// }
6990
+// if (CameraPane.Ymax < spoth)
6991
+// {
6992
+// CameraPane.Ymax = spoth;
6993
+// }
6994
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - 15);
6995
+ //info.g.drawLine(spotw, spoth, spotw - 15, spoth);
73646996 spot.translate(0, -32);
73656997 info.g.setColor(Color.green);
73666998 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
- }
6999
+// if (CameraPane.Xmin > spot.x)
7000
+// {
7001
+// CameraPane.Xmin = spot.x;
7002
+// }
7003
+// if (CameraPane.Xmax < spotw)
7004
+// {
7005
+// CameraPane.Xmax = spotw;
7006
+// }
7007
+// if (CameraPane.Ymin > spot.y)
7008
+// {
7009
+// CameraPane.Ymin = spot.y;
7010
+// }
7011
+// if (CameraPane.Ymax < spoth)
7012
+// {
7013
+// CameraPane.Ymax = spoth;
7014
+// }
73837015 info.g.drawArc(boundary.x, boundary.y,
73847016 boundary.width, boundary.height, 0, 360);
73857017 //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
- }
7018
+// if (CameraPane.Xmin > boundary.x)
7019
+// {
7020
+// CameraPane.Xmin = boundary.x;
7021
+// }
7022
+// if (CameraPane.Xmax < boundary.x + boundary.width)
7023
+// {
7024
+// CameraPane.Xmax = boundary.x + boundary.width;
7025
+// }
7026
+// if (CameraPane.Ymin > boundary.y)
7027
+// {
7028
+// CameraPane.Ymin = boundary.y;
7029
+// }
7030
+// if (CameraPane.Ymax < boundary.y + boundary.height)
7031
+// {
7032
+// CameraPane.Ymax = boundary.y + boundary.height;
7033
+// }
74027034 return;
74037035 }
74047036 }
....@@ -7415,7 +7047,7 @@
74157047 startX = info.x;
74167048 startY = info.y;
74177049
7418
- hitSomething = 0;
7050
+ hitSomething = -1;
74197051 cVector origin = new cVector();
74207052 //LA.xformPos(origin, toParent, origin);
74217053 Rectangle spot = new Rectangle();
....@@ -7448,7 +7080,7 @@
74487080 }
74497081
74507082 //System.out.println("info.modifiers = " + info.modifiers);
7451
- modified = (info.modifiers & CameraPane.META) != 0;
7083
+ modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
74527084 //System.out.println("modified = " + modified);
74537085 //new Exception().printStackTrace();
74547086 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7476,7 +7108,7 @@
74767108 return true;
74777109 }
74787110
7479
- void doEditDrag0(ClickInfo info)
7111
+ void doEditDrag0(ClickInfo info, boolean opposite)
74807112 {
74817113 if (hitSomething == 0)
74827114 {
....@@ -7491,6 +7123,7 @@
74917123 //System.out.println("hitSomething = " + hitSomething);
74927124
74937125 double scale = 0.005f * info.camera.Distance();
7126
+
74947127 cVector xlate = new cVector();
74957128 //cVector xlate2 = new cVector();
74967129 switch (hitSomething)
....@@ -7501,9 +7134,9 @@
75017134
75027135 case hitCenter: // Translate
75037136
7504
- scale *= 0.05f * info.pane.theRenderer.renderCamera.Distance();
7137
+ scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
75057138
7506
- if (modified)
7139
+ if (modified || opposite)
75077140 {
75087141 //assert(false);
75097142 /*
....@@ -7549,10 +7182,10 @@
75497182 }
75507183 LA.xformDir(up, ClickInfo.matbuffer, up);
75517184 // if (!CameraPane.LOCALTRANSFORM)
7552
- LA.xformDir(up, info.pane.theRenderer.renderCamera.toScreen, up);
7185
+ LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
75537186 LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
75547187 // if (!CameraPane.LOCALTRANSFORM)
7555
- LA.xformDir(away, info.pane.theRenderer.renderCamera.toScreen, away);
7188
+ LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
75567189 //LA.vecCross(up, cVector.Z, right2);
75577190
75587191 cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
....@@ -7597,6 +7230,7 @@
75977230
75987231 if (modified)
75997232 {
7233
+ // Rotate 90 degrees
76007234 angle /= (Math.PI / 4);
76017235 angle = Math.floor(angle + 0.5);
76027236 angle *= (Math.PI / 4);
....@@ -7610,7 +7244,7 @@
76107244 }
76117245 /**/
76127246
7613
- switch (info.pane.renderCamera.viewCode)
7247
+ switch (info.pane.RenderCamera().viewCode)
76147248 {
76157249 case 1: // '\001'
76167250 LA.matZRotate(toParent, angle);
....@@ -7638,24 +7272,27 @@
76387272
76397273 case hitScale: // scale
76407274 double hScale = (double) (info.x - centerPt.x) / 32;
7275
+ double sign = 1;
7276
+ if (hScale < 0)
7277
+ {
7278
+ sign = -1;
7279
+ }
7280
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
76417281 if (hScale < 0.01)
76427282 {
7643
- hScale = 0.01;
7283
+ //hScale = 0.01;
76447284 }
7645
- hScale = Math.pow(hScale, scale * 50);
7646
- if (hScale < 0.01)
7647
- {
7648
- hScale = 0.01;
7649
- }
7285
+
76507286 double vScale = (double) (info.y - centerPt.y) / 32;
7651
- if (vScale < 0.01)
7287
+ sign = 1;
7288
+ if (vScale < 0)
76527289 {
7653
- vScale = 0.01;
7290
+ sign = -1;
76547291 }
7655
- vScale = Math.pow(vScale, scale * 50);
7292
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
76567293 if (vScale < 0.01)
76577294 {
7658
- vScale = 0.01;
7295
+ //vScale = 0.01;
76597296 }
76607297 LA.matCopy(startMat, toParent);
76617298 /**/
....@@ -7666,17 +7303,24 @@
76667303 }
76677304 /**/
76687305
7669
- switch (info.pane.renderCamera.viewCode)
7306
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7307
+
7308
+ if (totalScale < 0.01)
7309
+ {
7310
+ totalScale = 0.01;
7311
+ }
7312
+
7313
+ switch (info.pane.RenderCamera().viewCode)
76707314 {
76717315 case 3: // '\001'
76727316 if (modified)
76737317 {
76747318 //LA.matScale(toParent, 1, hScale, vScale);
7675
- LA.matScale(toParent, vScale, 1, 1);
7319
+ LA.matScale(toParent, totalScale, 1, 1);
76767320 } // vScale, 1);
76777321 else
76787322 {
7679
- LA.matScale(toParent, vScale, vScale, vScale);
7323
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
76807324 } // vScale, 1);
76817325 break;
76827326
....@@ -7684,10 +7328,10 @@
76847328 if (modified)
76857329 {
76867330 //LA.matScale(toParent, hScale, 1, vScale);
7687
- LA.matScale(toParent, 1, vScale, 1);
7331
+ LA.matScale(toParent, 1, totalScale, 1);
76887332 } else
76897333 {
7690
- LA.matScale(toParent, vScale, 1, vScale);
7334
+ LA.matScale(toParent, totalScale, 1, totalScale);
76917335 }
76927336 break;
76937337
....@@ -7695,10 +7339,10 @@
76957339 if (modified)
76967340 {
76977341 //LA.matScale(toParent, hScale, vScale, 1);
7698
- LA.matScale(toParent, 1, 1, vScale);
7342
+ LA.matScale(toParent, 1, 1, totalScale);
76997343 } else
77007344 {
7701
- LA.matScale(toParent, vScale, vScale, 1);
7345
+ LA.matScale(toParent, totalScale, totalScale, 1);
77027346 }
77037347 break;
77047348 }
....@@ -7719,7 +7363,7 @@
77197363 if (parent == null)
77207364 {
77217365 System.out.println("NULL PARENT");
7722
- new Exception().printStackTrace();
7366
+ //new Exception().printStackTrace();
77237367 } else
77247368 {
77257369 if (parent instanceof BezierPatch)
....@@ -7735,8 +7379,15 @@
77357379 info.pane.repaint();
77367380 }
77377381
7382
+ boolean overflow = false;
7383
+
77387384 void TransformToWorld(cVector out) // , cVector out)
77397385 {
7386
+ if (overflow)
7387
+ return;
7388
+
7389
+ overflow = true;
7390
+
77407391 // june 2013 ??? assert (in == out);
77417392 cVector in = out;
77427393 if (toParent != null && !(this instanceof Texture || this instanceof TextureNode))
....@@ -7753,6 +7404,8 @@
77537404 {
77547405 (parent!=null?parent:fileparent).TransformToWorld(out); //, out);
77557406 }
7407
+
7408
+ overflow = false;
77567409 }
77577410
77587411 void TransformToLocal(cVector out) //, cVector out)
....@@ -7822,14 +7475,22 @@
78227475 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
78237476 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
78247477 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7478
+
7479
+ String objname;
7480
+
78257481 if (false) //parent != null)
78267482 {
7827
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7483
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
78287484 } else
78297485 {
7830
- return GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ") ")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ +System.identityHashCode(this);
7486
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
78317487 } // + super.toString();
78327488 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
7489
+
7490
+ if (!Globals.ADVANCED)
7491
+ return objname;
7492
+
7493
+ return objname + " " + System.identityHashCode(this);
78337494 }
78347495
78357496 public int hashCode()
....@@ -7885,6 +7546,7 @@
78857546 objectUI.closeUI();
78867547 if (editWindow != null)
78877548 {
7549
+ editWindow.ctrlPanel.FlushUI();
78887550 editWindow.refreshContents();
78897551 } // ? new
78907552 objectUI = null;
....@@ -7995,19 +7657,22 @@
79957657 max = new cVector();
79967658 }
79977659
7998
- Object3D sourcenode = GetFileRoot();
7999
-
8000
- if (!sourcenode.name.contains("rclab"))
7660
+ if (false) // Can crawl!!
80017661 {
8002
- getBounds(min, max, true);
7662
+ Object3D sourcenode = GetFileRoot();
80037663
8004
- if (min.y != Double.POSITIVE_INFINITY && min.y > 2)
7664
+ if (sourcenode != null && !sourcenode.name.contains("rclab"))
80057665 {
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();
7666
+ getBounds(min, max, true);
7667
+
7668
+ if (min.y != Double.POSITIVE_INFINITY && min.y > 2)
7669
+ {
7670
+ // sourcenode.getBounds(min, max, true);
7671
+ sourcenode.getBounds(v0, v1, true);
7672
+ // sourcenode.toParent = sourcenode.toParent;
7673
+ // get(0).toParent = get(0).toParent;
7674
+ // sourcenode.GlobalTransform();
7675
+ }
80117676 }
80127677 }
80137678
....@@ -8016,7 +7681,8 @@
80167681 if (support != null)
80177682 {
80187683 assert(bRep != null);
8019
- GraphreeD.Assert(support.bRep == bRep.support);
7684
+ if (!(support instanceof GenericJoint)) // support.bRep != null)
7685
+ Grafreed.Assert(support.bRep == bRep.support);
80207686 }
80217687 else
80227688 {
....@@ -8065,9 +7731,9 @@
80657731 private static cVector edge2 = new cVector();
80667732 //private static cVector norm = new cVector();
80677733 /*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;
7734
+ static final int hitCenter = 1;
7735
+ static final int hitScale = 2;
7736
+ static final int hitRotate = 3;
80717737 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
80727738 /*transient*/ private Point centerPt;
80737739 /*transient*/ private int startX;
....@@ -8099,6 +7765,8 @@
80997765 {
81007766 Object3D targ = this;
81017767
7768
+ targ.NORMALPUSH = obj.NORMALPUSH;
7769
+
81027770 if (obj.material != null)
81037771 {
81047772 if ((mask&MATERIAL)!=0) // ==(COLOR|MATERIAL))