Normand Briere
2019-06-09 cd87df088b1850ba0c90beb6c866c443e4eaf3b9
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;
....@@ -299,6 +300,7 @@
299300 }
300301
301302 boolean live = false;
303
+ boolean dontselect = false;
302304 boolean hide = false;
303305 boolean link2master = false; // performs reset support/master at each frame
304306 boolean marked = false; // animation node
....@@ -430,16 +432,16 @@
430432 {
431433 Object3D copy = this;
432434
433
- Camera parentcam = CameraPane.theRenderer.manipCamera;
435
+ Camera parentcam = Globals.theRenderer.ManipCamera();
434436
435
- if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[0])
437
+ if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[0])
436438 {
437
- parentcam = CameraPane.theRenderer.cameras[1];
439
+ parentcam = Globals.theRenderer.Cameras()[1];
438440 }
439441
440
- if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[1])
442
+ if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[1])
441443 {
442
- parentcam = CameraPane.theRenderer.cameras[0];
444
+ parentcam = Globals.theRenderer.Cameras()[0];
443445 }
444446
445447 if (this == parentcam)
....@@ -447,7 +449,7 @@
447449 //assert(this instanceof Camera);
448450
449451 for (int count = parentcam.GetTransformCount(); --count>=0;)
450
- LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.toParent, CameraPane.theRenderer.targetLookAt);
452
+ LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.toParent, Globals.theRenderer.TargetLookAt());
451453 }
452454
453455 copy.marked ^= true;
....@@ -467,7 +469,7 @@
467469 //assert(this instanceof Camera);
468470
469471 for (int count = parentcam.GetTransformCount(); --count>=0;)
470
- LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.fromParent, CameraPane.theRenderer.targetLookAt);
472
+ LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.fromParent, Globals.theRenderer.TargetLookAt());
471473 }
472474
473475 copy.Touch(); // display list issue
....@@ -602,7 +604,7 @@
602604 return;
603605 }
604606
605
- if (CameraPane.fromscript)
607
+ if (Globals.fromscript)
606608 {
607609 transformcount = 0;
608610 return;
....@@ -796,7 +798,7 @@
796798
797799 if (marked && Globals.isLIVE() && live &&
798800 //TEMP21aug2018
799
- Globals.DrawMode() == iCameraPane.SHADOW &&
801
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
800802 currentframe != Globals.framecount)
801803 {
802804 currentframe = Globals.framecount;
....@@ -911,6 +913,11 @@
911913 fromParent = null; // LA.newMatrix();
912914 bRep = null; // new BoundaryRep();
913915
916
+ if (oname != null && oname.equals("LeftHand"))
917
+ {
918
+ name = oname;
919
+ }
920
+
914921 /*
915922 float hue = (float)Math.random();
916923 Color col;
....@@ -953,7 +960,7 @@
953960
954961 public Object clone()
955962 {
956
- return GrafreeD.clone(this);
963
+ return Grafreed.clone(this);
957964 }
958965
959966 Object3D copyExpand()
....@@ -1469,7 +1476,7 @@
14691476 BoundaryRep.SEUIL = other.material.cameralight;
14701477
14711478 // Set default to 0.1
1472
- BoundaryRep.SEUIL /= 2;
1479
+ BoundaryRep.SEUIL /= 4; // 2;
14731480 System.out.println("SEUIL = " + BoundaryRep.SEUIL);
14741481 }
14751482
....@@ -1728,7 +1735,7 @@
17281735 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17291736 o.bRep = transientrep;
17301737 if (clone)
1731
- o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
1738
+ o.bRep = (BoundaryRep) Grafreed.clone(transientrep);
17321739 o.CreateMaterial();
17331740 o.SetAttributes(this, -1);
17341741 //parent
....@@ -1741,7 +1748,7 @@
17411748 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17421749 o.bRep = bRep;
17431750 if (clone)
1744
- o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
1751
+ o.bRep = (BoundaryRep) Grafreed.clone(bRep);
17451752 o.CreateMaterial();
17461753 //o.overwriteThis(this, -1);
17471754 o.SetAttributes(this, -1);
....@@ -1828,12 +1835,15 @@
18281835 if (obj.name == null)
18291836 continue; // can't be a null one
18301837
1838
+ // Try perfect match first.
18311839 if (n.equals(obj.name))
18321840 {
18331841 theobj = obj;
18341842 count++;
18351843 }
18361844 }
1845
+
1846
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18371847
18381848 if (count != 1)
18391849 for (int i=Size(); --i>=0;)
....@@ -2299,6 +2309,7 @@
22992309 {
23002310 if (newWindow)
23012311 {
2312
+ new Exception().printStackTrace();
23022313 System.exit(0);
23032314 if (parent != null)
23042315 {
....@@ -2475,13 +2486,13 @@
24752486 return retval;
24762487 }
24772488
2478
- void doEditDrag(ClickInfo info)
2489
+ void doEditDrag(ClickInfo info, boolean opposite)
24792490 {
24802491 switch (doSomething)
24812492 {
24822493 case 1: // '\001'
24832494 //super.
2484
- doEditDrag0(info);
2495
+ doEditDrag0(info, opposite);
24852496 break;
24862497
24872498 case 2: // '\002'
....@@ -2494,11 +2505,11 @@
24942505 {
24952506 //sel.hitSomething = childToDrag.hitSomething;
24962507 //childToDrag.doEditDrag(info);
2497
- sel.doEditDrag(info);
2508
+ sel.doEditDrag(info, opposite);
24982509 } else
24992510 {
25002511 //super.
2501
- doEditDrag0(info);
2512
+ doEditDrag0(info, opposite);
25022513 }
25032514 }
25042515 break;
....@@ -2905,7 +2916,8 @@
29052916 {
29062917 if (bRep != null)
29072918 {
2908
- bRep.GenUV();
2919
+ bRep.GenUV(); //1);
2920
+ //bRep.UnfoldUV();
29092921 Touch();
29102922 }
29112923 }
....@@ -2980,6 +2992,33 @@
29802992 blockloop = false;
29812993 }
29822994
2995
+ void TransformChildren()
2996
+ {
2997
+ if (toParent != null)
2998
+ {
2999
+ for (int i=Size(); --i>=0;)
3000
+ {
3001
+ Object3D v = get(i);
3002
+
3003
+ if (v.toParent == null)
3004
+ {
3005
+ v.toParent = LA.newMatrix();
3006
+ v.fromParent = LA.newMatrix();
3007
+ }
3008
+
3009
+// LA.matConcat(v.toParent, toParent, v.toParent);
3010
+// LA.matConcat(fromParent, v.fromParent, v.fromParent);
3011
+ LA.matConcat(toParent, v.toParent, v.toParent);
3012
+ LA.matConcat(v.fromParent, fromParent, v.fromParent);
3013
+ }
3014
+
3015
+ toParent = null; // LA.matIdentity(toParent);
3016
+ fromParent = null; // LA.matIdentity(fromParent);
3017
+
3018
+ Touch();
3019
+ }
3020
+ }
3021
+
29833022 void TransformGeometry()
29843023 {
29853024 Object3D obj = this;
....@@ -3201,9 +3240,11 @@
32013240
32023241 BoundaryRep sup = bRep.support;
32033242 bRep.support = null;
3204
- BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
3243
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
32053244 // bRep.SplitInTwo(onlyone); // thread...
3206
- temprep.SplitInTwo(reduction34, onlyone);
3245
+
3246
+ while(temprep.SplitInTwo(reduction34, onlyone));
3247
+
32073248 bRep = temprep;
32083249 bRep.support = sup;
32093250 Touch();
....@@ -3725,7 +3766,7 @@
37253766 if (child == null)
37263767 continue;
37273768
3728
- if (GrafreeD.RENDERME > 0)
3769
+ if (Grafreed.RENDERME > 0)
37293770 {
37303771 if (child instanceof Merge)
37313772 ((Merge)child).renderme();
....@@ -3876,7 +3917,7 @@
38763917 if (child == null)
38773918 continue;
38783919
3879
- if (GrafreeD.RENDERME > 0)
3920
+ if (Grafreed.RENDERME > 0)
38803921 {
38813922 if (child instanceof Merge)
38823923 ((Merge)child).renderme();
....@@ -4071,7 +4112,7 @@
40714112 if (child == null)
40724113 continue;
40734114
4074
- if (GrafreeD.RENDERME > 0)
4115
+ if (Grafreed.RENDERME > 0)
40754116 {
40764117 if (child instanceof Merge)
40774118 ((Merge)child).renderme();
....@@ -4678,7 +4719,7 @@
46784719
46794720 cTreePath SelectLeaf(int indexcount, boolean deselect)
46804721 {
4681
- if (hide)
4722
+ if (hide || dontselect)
46824723 return null;
46834724
46844725 if (count <= 0)
....@@ -4704,7 +4745,7 @@
47044745
47054746 cTreePath Select(int indexcount, boolean deselect)
47064747 {
4707
- if (hide)
4748
+ if (hide || dontselect)
47084749 return null;
47094750
47104751 if (count <= 0)
....@@ -4854,7 +4895,7 @@
48544895 return globalTransform;
48554896 }
48564897
4857
- void PreprocessOcclusion(CameraPane cp)
4898
+ void PreprocessOcclusion(iCameraPane cp)
48584899 {
48594900 /*
48604901 if (AOdone)
....@@ -5156,10 +5197,34 @@
51565197
51575198 // System.out.println("Fullname = " + fullname);
51585199
5159
- if (fullname.name.indexOf(":") == -1)
5160
- return fullname.name;
5200
+ // Does not work on Windows due to C:
5201
+// if (fullname.name.indexOf(":") == -1)
5202
+// return fullname.name;
5203
+//
5204
+// return fullname.name.substring(0,fullname.name.indexOf(":"));
51615205
5162
- return fullname.name.substring(0,fullname.name.indexOf(":"));
5206
+ String[] split = fullname.name.split(":");
5207
+
5208
+ if (split.length == 0)
5209
+ {
5210
+ return "";
5211
+ }
5212
+
5213
+ if (split.length <= 2)
5214
+ {
5215
+ if (fullname.name.endsWith(":"))
5216
+ {
5217
+ // Windows
5218
+ return fullname.name.substring(0, fullname.name.length()-1);
5219
+ }
5220
+
5221
+ return split[0];
5222
+ }
5223
+
5224
+ // Windows
5225
+ assert(split.length == 4);
5226
+
5227
+ return split[0] + ":" + split[1];
51635228 }
51645229
51655230 static String GetBump(cTexture fullname)
....@@ -5168,10 +5233,38 @@
51685233 return "";
51695234
51705235 // System.out.println("Fullname = " + fullname);
5171
- if (fullname.name.indexOf(":") == -1)
5172
- return "";
5173
-
5174
- return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5236
+ // Does not work on Windows due to C:
5237
+// if (fullname.name.indexOf(":") == -1)
5238
+// return "";
5239
+//
5240
+// return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5241
+ String[] split = fullname.name.split(":");
5242
+
5243
+ if (split.length == 0)
5244
+ {
5245
+ return "";
5246
+ }
5247
+
5248
+ if (split.length == 1)
5249
+ {
5250
+ return "";
5251
+ }
5252
+
5253
+ if (split.length == 2)
5254
+ {
5255
+ if (fullname.name.endsWith(":"))
5256
+ {
5257
+ // Windows
5258
+ return "";
5259
+ }
5260
+
5261
+ return split[1];
5262
+ }
5263
+
5264
+ // Windows
5265
+ assert(split.length == 4);
5266
+
5267
+ return split[2] + ":" + split[3];
51755268 }
51765269
51775270 String GetPigmentTexture()
....@@ -5245,7 +5338,7 @@
52455338 System.out.print("; textures = " + textures);
52465339 System.out.println("; usedtextures = " + usedtextures);
52475340
5248
- if (GetTextures() == null)
5341
+ if (GetTextures() == null) // What is that??
52495342 GetTextures().name = ":";
52505343
52515344 String texname = tex;
....@@ -5322,11 +5415,12 @@
53225415 boolean NeedSupport()
53235416 {
53245417 return
5325
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5418
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null
53265419 // PROBLEM with CROWD!!
5327
- && (Globals.DrawMode() == iCameraPane.SHADOW || Globals.CROWD);
5420
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
53285421 }
53295422
5423
+ static boolean DEBUG_SELECTION = false;
53305424
53315425 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
53325426 {
....@@ -5338,7 +5432,7 @@
53385432 }
53395433
53405434 if (display.DrawMode() == iCameraPane.SELECTION &&
5341
- hide)
5435
+ (hide || dontselect))
53425436 return;
53435437
53445438 if (name != null && name.contains("sclera"))
....@@ -5365,12 +5459,12 @@
53655459 }
53665460
53675461 if ((//display.DrawMode() == CameraPane.SHADOW ||
5368
- display.DrawMode() == CameraPane.SELECTION || CameraPane.DEBUG_SELECTION) && HasTransparency())
5462
+ display.DrawMode() == iCameraPane.SELECTION || display.IsDebugSelection()) && HasTransparency())
53695463 {
53705464 return;
53715465 }
53725466
5373
- javax.media.opengl.GL gl = display.GetGL();
5467
+ //javax.media.opengl.GL gl = display.GetGL();
53745468
53755469 /*
53765470 if (touched)
....@@ -5406,7 +5500,7 @@
54065500
54075501 boolean compiled = false;
54085502
5409
- boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION;
5503
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
54105504
54115505 if (!selectmode && //display.DrawMode() != display.SELECTION &&
54125506 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5422,7 +5516,7 @@
54225516 //if (displaylist == -1 && usecalllists)
54235517 if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
54245518 {
5425
- bRep.displaylist = gl.glGenLists(1);
5519
+ bRep.displaylist = display.GenList();
54265520 assert(bRep.displaylist != 0);
54275521 // System.err.println("glGenLists: " + bRep.displaylist + " for " + this);
54285522 //System.out.println("\tgen list " + list);
....@@ -5434,14 +5528,16 @@
54345528 if (usecalllists)
54355529 {
54365530 // System.err.println("new list " + bRep.displaylist + " for " + this);
5437
- gl.glNewList(bRep.displaylist, gl.GL_COMPILE); //_AND_EXECUTE);
5531
+ display.NewList(bRep.displaylist);
54385532 }
5533
+
54395534 CallList(display, root, selected, blocked);
5535
+
54405536 // compiled = true;
54415537 if (usecalllists)
54425538 {
54435539 // System.err.println("end list " + bRep.displaylist + " for " + this);
5444
- gl.glEndList();
5540
+ display.EndList();
54455541 }
54465542 //gl.glDrawBuffer(gl.GL_BACK);
54475543 // XXX touched = false;
....@@ -5484,12 +5580,12 @@
54845580
54855581 // frustum culling
54865582 if (CameraPane.FRUSTUM && !blocked && !IsInfinite() && GetBRep() != null // && GetBRep().VertexCount() != 1260 // default grid
5487
- && display.DrawMode() != CameraPane.SELECTION)
5583
+ && display.DrawMode() != iCameraPane.SELECTION)
54885584 {
5489
- if (display.DrawMode() == CameraPane.SHADOW)
5585
+ if (display.DrawMode() == iCameraPane.SHADOW)
54905586 {
54915587 if (!link2master // tricky to cull in shadow mode.
5492
- && GetBRep().FrustumCull(this, gl, display.LightCamera(), true))
5588
+ && GetBRep().FrustumCull(this, null, display.LightCamera(), true))
54935589 {
54945590 //System.out.print("CULLED");
54955591 culled = true;
....@@ -5497,7 +5593,7 @@
54975593 }
54985594 else
54995595 //GetBRep().getBounds(v0, v1, this);
5500
- if (GetBRep().FrustumCull(this, gl, display.RenderCamera(), false))
5596
+ if (GetBRep().FrustumCull(this, null, display.RenderCamera(), false))
55015597 culled = true;
55025598
55035599 // LA.xformPos(v0, display.renderCamera.toScreen, v0);
....@@ -5533,11 +5629,11 @@
55335629
55345630
55355631 if (!culled)
5536
- if (display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION)
5632
+ if (display.DrawMode() == display.SELECTION || display.IsDebugSelection())
55375633 {
55385634 if (GetBRep() != null)
55395635 {
5540
- CameraPane.NextIndex(this, gl);
5636
+ display.NextIndex();
55415637 // vertex color conflict : gl.glCallList(list);
55425638 DrawNode(display, root, selected);
55435639 if (this instanceof BezierPatch)
....@@ -5578,7 +5674,17 @@
55785674 tex = GetTextures();
55795675 }
55805676
5581
- display.BindTextures(tex, texres);
5677
+ boolean failed = false;
5678
+
5679
+ try
5680
+ {
5681
+ display.BindTextures(tex, texres);
5682
+ }
5683
+ catch (Exception e)
5684
+ {
5685
+ System.err.println("FAILED: " + this);
5686
+ failed = true;
5687
+ }
55825688
55835689 if (!compiled)
55845690 {
....@@ -5594,13 +5700,14 @@
55945700
55955701 // System.err.println("glCallList: " + bRep.displaylist + " for " + this);
55965702 assert(bRep.displaylist != 0);
5597
- gl.glCallList(bRep.displaylist);
5703
+ display.CallList(bRep.displaylist);
55985704 // june 2013 drawSelf(display, root, selected);
55995705 }
56005706 }
56015707 }
56025708
5603
- display.ReleaseTextures(tex);
5709
+ if (!failed)
5710
+ display.ReleaseTextures(tex);
56045711
56055712 display.PopMaterial(this, selected);
56065713 }
....@@ -5729,6 +5836,9 @@
57295836
57305837 void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57315838 {
5839
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
5840
+ return;
5841
+
57325842 if (hide)
57335843 return;
57345844 // shadow optimisation
....@@ -5854,6 +5964,9 @@
58545964 if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
58555965 return; // no shadow for transparent objects
58565966
5967
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
5968
+ return;
5969
+
58575970 if (hide)
58585971 return;
58595972
....@@ -5894,9 +6007,10 @@
58946007 return;
58956008 }
58966009
6010
+ //bRep.GenUV(1/material.diffuseness);
58976011 // bRep.lock = true;
58986012
5899
- javax.media.opengl.GL gl = display.GetGL();
6013
+ //javax.media.opengl.GL gl = display.GetGL();
59006014
59016015 if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera)
59026016 {
....@@ -5913,23 +6027,7 @@
59136027
59146028 bRep.getMinMax(min, max, 100);
59156029
5916
- gl.glBegin(gl.GL_LINES);
5917
-
5918
- gl.glVertex3d(min.x, min.y, min.z);
5919
- gl.glVertex3d(min.x, min.y, max.z);
5920
- gl.glVertex3d(min.x, min.y, min.z);
5921
- gl.glVertex3d(min.x, max.y, min.z);
5922
- gl.glVertex3d(min.x, min.y, min.z);
5923
- gl.glVertex3d(max.x, min.y, min.z);
5924
-
5925
- gl.glVertex3d(max.x, max.y, max.z);
5926
- gl.glVertex3d(min.x, max.y, max.z);
5927
- gl.glVertex3d(max.x, max.y, max.z);
5928
- gl.glVertex3d(max.x, min.y, max.z);
5929
- gl.glVertex3d(max.x, max.y, max.z);
5930
- gl.glVertex3d(max.x, max.y, min.z);
5931
-
5932
- gl.glEnd();
6030
+ display.DrawBox(min, max);
59336031
59346032 return;
59356033 }
....@@ -5973,7 +6071,7 @@
59736071 {
59746072 //throw new Error();
59756073
5976
- boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION;
6074
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
59776075
59786076 int[] strips = bRep.getRawIndices();
59796077
....@@ -5983,178 +6081,14 @@
59836081 new Exception().printStackTrace();
59846082 return;
59856083 }
5986
-
5987
- // TRIANGLE STRIP ARRAY
5988
- if (bRep.trimmed)
5989
- {
5990
- float[] v = bRep.getRawVertices();
5991
- float[] n = bRep.getRawNormals();
5992
- float[] c = bRep.getRawColors();
5993
- float[] uv = bRep.getRawUVMap();
5994
-
5995
- int count2 = 0;
5996
- int count3 = 0;
5997
-
5998
- if (n.length > 0)
5999
- {
6000
- for (int i = 0; i < strips.length; i++)
6001
- {
6002
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6003
-
6004
- /*
6005
- boolean locked = false;
6006
- float eps = 0.1f;
6007
- boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
6008
-
6009
- int dot = 0;
6010
-
6011
- if ((dot&1) == 0)
6012
- dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
6013
-
6014
- if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
6015
- gl.glTexCoord2f((float) qv.s, (float) qv.t);
6016
- else
6017
- {
6018
- locked = true;
6019
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6020
- }
6021
- //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6022
- gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
6023
- if (hasnorm)
6024
- {
6025
- //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6026
- gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
6027
- }
6028
-
6029
- if ((dot&4) == 0)
6030
- dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
6031
-
6032
- if (wrap || !locked && (dot&8) != 0)
6033
- gl.glTexCoord2f((float) rv.s, (float) rv.t);
6034
- else
6035
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6036
-
6037
- f.dot = dot;
6038
- */
6039
-
6040
- if (!selectmode)
6041
- {
6042
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6043
- {
6044
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6045
- } else
6046
- {
6047
- gl.glNormal3f(0, 0, 1);
6048
- }
6049
-
6050
- if (c != null)
6051
- //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]);
6052
- {
6053
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6054
- }
6055
- }
6056
- if (flipV)
6057
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6058
- else
6059
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6060
- //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6061
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6062
-
6063
- count2 += 2;
6064
- count3 += 3;
6065
- if (!selectmode)
6066
- {
6067
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6068
- {
6069
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6070
- } else
6071
- {
6072
- gl.glNormal3f(0, 0, 1);
6073
- }
6074
- if (c != null)
6075
- {
6076
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6077
- }
6078
- }
6079
- if (flipV)
6080
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6081
- else
6082
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6083
- //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6084
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6085
-
6086
- count2 += 2;
6087
- count3 += 3;
6088
- for (int j = 0; j < strips[i] - 2; j++)
6089
- {
6090
- //gl.glTexCoord2d(...);
6091
- if (!selectmode)
6092
- {
6093
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6094
- {
6095
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6096
- } else
6097
- {
6098
- gl.glNormal3f(0, 0, 1);
6099
- }
6100
- if (c != null)
6101
- {
6102
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6103
- }
6104
- }
6105
-
6106
- if (flipV)
6107
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6108
- else
6109
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6110
- //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
6111
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6112
- count2 += 2;
6113
- count3 += 3;
6114
- }
6115
-
6116
- gl.glEnd();
6117
- }
6118
- }
6119
-
6120
- assert count3 == v.length;
6121
- }
6122
- else // !trimmed
6123
- {
6124
- int count = 0;
6125
- for (int i = 0; i < strips.length; i++)
6126
- {
6127
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6128
-
6129
- Vertex p = bRep.GetVertex(bRep.indices[count++]);
6130
- Vertex q = bRep.GetVertex(bRep.indices[count++]);
6131
-
6132
- drawVertex(gl, p, selectmode);
6133
- drawVertex(gl, q, selectmode);
6134
-
6135
- for (int j = 0; j < strips[i] - 2; j++)
6136
- {
6137
- Vertex r = bRep.GetVertex(bRep.indices[count++]);
6138
-
6139
-// if (j%2 == 0)
6140
-// drawFace(p, q, r, display, null);
6141
-// else
6142
-// drawFace(p, r, q, display, null);
6143
-
6144
-// p = q;
6145
-// q = r;
6146
- drawVertex(gl, r, selectmode);
6147
- }
6148
-
6149
- gl.glEnd();
6150
- }
6151
- }
6084
+
6085
+ display.DrawGeometry(bRep, flipV, selectmode);
61526086 } else // catch (Error e)
61536087 {
61546088 // TRIANGLE ARRAY
61556089 if (IsOpaque()) // Static())
61566090 {
6157
- gl.glBegin(gl.GL_TRIANGLES);
6091
+ display.StartTriangles();
61586092 int facecount = bRep.FaceCount();
61596093 for (int i = 0; i < facecount; i++)
61606094 {
....@@ -6219,7 +6153,7 @@
62196153
62206154 display.DrawFace(this, p, q, r, face);
62216155 }
6222
- gl.glEnd();
6156
+ display.EndTriangles();
62236157 }
62246158 else
62256159 {
....@@ -6248,8 +6182,8 @@
62486182 //System.out.println("SORT");
62496183
62506184 java.util.Arrays.sort(facescompare);
6251
-
6252
- gl.glBegin(gl.GL_TRIANGLES);
6185
+
6186
+ display.StartTriangles();
62536187 for (int i = 0; i < facecount; i++)
62546188 {
62556189 Face face = bRep.GetFace(facescompare[i].index);
....@@ -6263,11 +6197,12 @@
62636197
62646198 display.DrawFace(this, p, q, r, face);
62656199 }
6266
- gl.glEnd();
6200
+ display.EndTriangles();
62676201 }
62686202
62696203 if (false) // live && support != null && support.bRep != null) // debug weights
62706204 {
6205
+ /*
62716206 gl.glDisable(gl.GL_LIGHTING);
62726207 float[] colorV = new float[3];
62736208
....@@ -6346,6 +6281,7 @@
63466281 // gl.glEnd();
63476282 }
63486283 }
6284
+ */
63496285 }
63506286 }
63516287
....@@ -6390,7 +6326,7 @@
63906326 center.add(r);
63916327 center.mul(1.0/3);
63926328
6393
- center.sub(CameraPane.theRenderer.eyeCamera.location);
6329
+ center.sub(Globals.theRenderer.EyeCamera().location);
63946330
63956331 distance = center.dot(center);
63966332 }
....@@ -6404,22 +6340,6 @@
64046340 void Print(Vertex v)
64056341 {
64066342 //System.err.println("(" + v.x + ", " + v.y + ", " + v.z + ")");
6407
- }
6408
-
6409
- void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean selectmode)
6410
- {
6411
- if (!selectmode)
6412
- {
6413
- gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
6414
- gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
6415
-
6416
- if (flipV)
6417
- gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
6418
- else
6419
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6420
- }
6421
-
6422
- gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
64236343 }
64246344
64256345 void drawSelf(ClickInfo info, int level, boolean select)
....@@ -6993,83 +6913,83 @@
69936913 int spotw = spot.x + spot.width;
69946914 int spoth = spot.y + spot.height;
69956915 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
6996
- if (CameraPane.Xmin > spot.x)
6997
- {
6998
- CameraPane.Xmin = spot.x;
6999
- }
7000
- if (CameraPane.Xmax < spotw)
7001
- {
7002
- CameraPane.Xmax = spotw;
7003
- }
7004
- if (CameraPane.Ymin > spot.y)
7005
- {
7006
- CameraPane.Ymin = spot.y;
7007
- }
7008
- if (CameraPane.Ymax < spoth)
7009
- {
7010
- CameraPane.Ymax = spoth;
7011
- }
6916
+// if (CameraPane.Xmin > spot.x)
6917
+// {
6918
+// CameraPane.Xmin = spot.x;
6919
+// }
6920
+// if (CameraPane.Xmax < spotw)
6921
+// {
6922
+// CameraPane.Xmax = spotw;
6923
+// }
6924
+// if (CameraPane.Ymin > spot.y)
6925
+// {
6926
+// CameraPane.Ymin = spot.y;
6927
+// }
6928
+// if (CameraPane.Ymax < spoth)
6929
+// {
6930
+// CameraPane.Ymax = spoth;
6931
+// }
70126932 spot.translate(32, 32);
70136933 spotw = spot.x + spot.width;
70146934 spoth = spot.y + spot.height;
70156935 info.g.setColor(Color.blue);
70166936 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7017
- if (CameraPane.Xmin > spot.x)
7018
- {
7019
- CameraPane.Xmin = spot.x;
7020
- }
7021
- if (CameraPane.Xmax < spotw)
7022
- {
7023
- CameraPane.Xmax = spotw;
7024
- }
7025
- if (CameraPane.Ymin > spot.y)
7026
- {
7027
- CameraPane.Ymin = spot.y;
7028
- }
7029
- if (CameraPane.Ymax < spoth)
7030
- {
7031
- CameraPane.Ymax = spoth;
7032
- }
6937
+// if (CameraPane.Xmin > spot.x)
6938
+// {
6939
+// CameraPane.Xmin = spot.x;
6940
+// }
6941
+// if (CameraPane.Xmax < spotw)
6942
+// {
6943
+// CameraPane.Xmax = spotw;
6944
+// }
6945
+// if (CameraPane.Ymin > spot.y)
6946
+// {
6947
+// CameraPane.Ymin = spot.y;
6948
+// }
6949
+// if (CameraPane.Ymax < spoth)
6950
+// {
6951
+// CameraPane.Ymax = spoth;
6952
+// }
70336953 info.g.drawLine(spotw, spoth, spotw, spoth - 15);
70346954 info.g.drawLine(spotw, spoth, spotw - 15, spoth);
70356955 spot.translate(0, -32);
70366956 info.g.setColor(Color.green);
70376957 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7038
- if (CameraPane.Xmin > spot.x)
7039
- {
7040
- CameraPane.Xmin = spot.x;
7041
- }
7042
- if (CameraPane.Xmax < spotw)
7043
- {
7044
- CameraPane.Xmax = spotw;
7045
- }
7046
- if (CameraPane.Ymin > spot.y)
7047
- {
7048
- CameraPane.Ymin = spot.y;
7049
- }
7050
- if (CameraPane.Ymax < spoth)
7051
- {
7052
- CameraPane.Ymax = spoth;
7053
- }
6958
+// if (CameraPane.Xmin > spot.x)
6959
+// {
6960
+// CameraPane.Xmin = spot.x;
6961
+// }
6962
+// if (CameraPane.Xmax < spotw)
6963
+// {
6964
+// CameraPane.Xmax = spotw;
6965
+// }
6966
+// if (CameraPane.Ymin > spot.y)
6967
+// {
6968
+// CameraPane.Ymin = spot.y;
6969
+// }
6970
+// if (CameraPane.Ymax < spoth)
6971
+// {
6972
+// CameraPane.Ymax = spoth;
6973
+// }
70546974 info.g.drawArc(boundary.x, boundary.y,
70556975 boundary.width, boundary.height, 0, 360);
70566976 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
7057
- if (CameraPane.Xmin > boundary.x)
7058
- {
7059
- CameraPane.Xmin = boundary.x;
7060
- }
7061
- if (CameraPane.Xmax < boundary.x + boundary.width)
7062
- {
7063
- CameraPane.Xmax = boundary.x + boundary.width;
7064
- }
7065
- if (CameraPane.Ymin > boundary.y)
7066
- {
7067
- CameraPane.Ymin = boundary.y;
7068
- }
7069
- if (CameraPane.Ymax < boundary.y + boundary.height)
7070
- {
7071
- CameraPane.Ymax = boundary.y + boundary.height;
7072
- }
6977
+// if (CameraPane.Xmin > boundary.x)
6978
+// {
6979
+// CameraPane.Xmin = boundary.x;
6980
+// }
6981
+// if (CameraPane.Xmax < boundary.x + boundary.width)
6982
+// {
6983
+// CameraPane.Xmax = boundary.x + boundary.width;
6984
+// }
6985
+// if (CameraPane.Ymin > boundary.y)
6986
+// {
6987
+// CameraPane.Ymin = boundary.y;
6988
+// }
6989
+// if (CameraPane.Ymax < boundary.y + boundary.height)
6990
+// {
6991
+// CameraPane.Ymax = boundary.y + boundary.height;
6992
+// }
70736993 return;
70746994 }
70756995 }
....@@ -7119,7 +7039,7 @@
71197039 }
71207040
71217041 //System.out.println("info.modifiers = " + info.modifiers);
7122
- modified = (info.modifiers & CameraPane.META) != 0;
7042
+ modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
71237043 //System.out.println("modified = " + modified);
71247044 //new Exception().printStackTrace();
71257045 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7147,7 +7067,7 @@
71477067 return true;
71487068 }
71497069
7150
- void doEditDrag0(ClickInfo info)
7070
+ void doEditDrag0(ClickInfo info, boolean opposite)
71517071 {
71527072 if (hitSomething == 0)
71537073 {
....@@ -7172,9 +7092,9 @@
71727092
71737093 case hitCenter: // Translate
71747094
7175
- scale *= 0.05f * info.pane.theRenderer.renderCamera.Distance();
7095
+ scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
71767096
7177
- if (modified)
7097
+ if (modified || opposite)
71787098 {
71797099 //assert(false);
71807100 /*
....@@ -7220,10 +7140,10 @@
72207140 }
72217141 LA.xformDir(up, ClickInfo.matbuffer, up);
72227142 // if (!CameraPane.LOCALTRANSFORM)
7223
- LA.xformDir(up, info.pane.theRenderer.renderCamera.toScreen, up);
7143
+ LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
72247144 LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
72257145 // if (!CameraPane.LOCALTRANSFORM)
7226
- LA.xformDir(away, info.pane.theRenderer.renderCamera.toScreen, away);
7146
+ LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
72277147 //LA.vecCross(up, cVector.Z, right2);
72287148
72297149 cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
....@@ -7268,6 +7188,7 @@
72687188
72697189 if (modified)
72707190 {
7191
+ // Rotate 90 degrees
72717192 angle /= (Math.PI / 4);
72727193 angle = Math.floor(angle + 0.5);
72737194 angle *= (Math.PI / 4);
....@@ -7281,7 +7202,7 @@
72817202 }
72827203 /**/
72837204
7284
- switch (info.pane.renderCamera.viewCode)
7205
+ switch (info.pane.RenderCamera().viewCode)
72857206 {
72867207 case 1: // '\001'
72877208 LA.matZRotate(toParent, angle);
....@@ -7337,7 +7258,7 @@
73377258 }
73387259 /**/
73397260
7340
- switch (info.pane.renderCamera.viewCode)
7261
+ switch (info.pane.RenderCamera().viewCode)
73417262 {
73427263 case 3: // '\001'
73437264 if (modified)
....@@ -7502,14 +7423,22 @@
75027423 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
75037424 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
75047425 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7426
+
7427
+ String objname;
7428
+
75057429 if (false) //parent != null)
75067430 {
7507
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7431
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
75087432 } else
75097433 {
7510
- return GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ") ")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ +System.identityHashCode(this);
7434
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
75117435 } // + super.toString();
75127436 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
7437
+
7438
+ if (!Globals.ADVANCED)
7439
+ return objname;
7440
+
7441
+ return objname + " " + System.identityHashCode(this);
75137442 }
75147443
75157444 public int hashCode()
....@@ -7565,6 +7494,7 @@
75657494 objectUI.closeUI();
75667495 if (editWindow != null)
75677496 {
7497
+ editWindow.ctrlPanel.FlushUI();
75687498 editWindow.refreshContents();
75697499 } // ? new
75707500 objectUI = null;
....@@ -7700,7 +7630,7 @@
77007630 {
77017631 assert(bRep != null);
77027632 if (!(support instanceof GenericJoint)) // support.bRep != null)
7703
- GrafreeD.Assert(support.bRep == bRep.support);
7633
+ Grafreed.Assert(support.bRep == bRep.support);
77047634 }
77057635 else
77067636 {