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
....@@ -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)
....@@ -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,9 +5415,9 @@
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
53305423 static boolean DEBUG_SELECTION = false;
....@@ -5339,7 +5432,7 @@
53395432 }
53405433
53415434 if (display.DrawMode() == iCameraPane.SELECTION &&
5342
- hide)
5435
+ (hide || dontselect))
53435436 return;
53445437
53455438 if (name != null && name.contains("sclera"))
....@@ -5371,7 +5464,7 @@
53715464 return;
53725465 }
53735466
5374
- javax.media.opengl.GL gl = display.GetGL();
5467
+ //javax.media.opengl.GL gl = display.GetGL();
53755468
53765469 /*
53775470 if (touched)
....@@ -5423,7 +5516,7 @@
54235516 //if (displaylist == -1 && usecalllists)
54245517 if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
54255518 {
5426
- bRep.displaylist = gl.glGenLists(1);
5519
+ bRep.displaylist = display.GenList();
54275520 assert(bRep.displaylist != 0);
54285521 // System.err.println("glGenLists: " + bRep.displaylist + " for " + this);
54295522 //System.out.println("\tgen list " + list);
....@@ -5435,14 +5528,16 @@
54355528 if (usecalllists)
54365529 {
54375530 // System.err.println("new list " + bRep.displaylist + " for " + this);
5438
- gl.glNewList(bRep.displaylist, gl.GL_COMPILE); //_AND_EXECUTE);
5531
+ display.NewList(bRep.displaylist);
54395532 }
5533
+
54405534 CallList(display, root, selected, blocked);
5535
+
54415536 // compiled = true;
54425537 if (usecalllists)
54435538 {
54445539 // System.err.println("end list " + bRep.displaylist + " for " + this);
5445
- gl.glEndList();
5540
+ display.EndList();
54465541 }
54475542 //gl.glDrawBuffer(gl.GL_BACK);
54485543 // XXX touched = false;
....@@ -5490,7 +5585,7 @@
54905585 if (display.DrawMode() == iCameraPane.SHADOW)
54915586 {
54925587 if (!link2master // tricky to cull in shadow mode.
5493
- && GetBRep().FrustumCull(this, gl, display.LightCamera(), true))
5588
+ && GetBRep().FrustumCull(this, null, display.LightCamera(), true))
54945589 {
54955590 //System.out.print("CULLED");
54965591 culled = true;
....@@ -5498,7 +5593,7 @@
54985593 }
54995594 else
55005595 //GetBRep().getBounds(v0, v1, this);
5501
- if (GetBRep().FrustumCull(this, gl, display.RenderCamera(), false))
5596
+ if (GetBRep().FrustumCull(this, null, display.RenderCamera(), false))
55025597 culled = true;
55035598
55045599 // LA.xformPos(v0, display.renderCamera.toScreen, v0);
....@@ -5538,7 +5633,7 @@
55385633 {
55395634 if (GetBRep() != null)
55405635 {
5541
- CameraPane.NextIndex(this, gl);
5636
+ display.NextIndex();
55425637 // vertex color conflict : gl.glCallList(list);
55435638 DrawNode(display, root, selected);
55445639 if (this instanceof BezierPatch)
....@@ -5579,7 +5674,17 @@
55795674 tex = GetTextures();
55805675 }
55815676
5582
- 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
+ }
55835688
55845689 if (!compiled)
55855690 {
....@@ -5595,13 +5700,14 @@
55955700
55965701 // System.err.println("glCallList: " + bRep.displaylist + " for " + this);
55975702 assert(bRep.displaylist != 0);
5598
- gl.glCallList(bRep.displaylist);
5703
+ display.CallList(bRep.displaylist);
55995704 // june 2013 drawSelf(display, root, selected);
56005705 }
56015706 }
56025707 }
56035708
5604
- display.ReleaseTextures(tex);
5709
+ if (!failed)
5710
+ display.ReleaseTextures(tex);
56055711
56065712 display.PopMaterial(this, selected);
56075713 }
....@@ -5730,6 +5836,9 @@
57305836
57315837 void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57325838 {
5839
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
5840
+ return;
5841
+
57335842 if (hide)
57345843 return;
57355844 // shadow optimisation
....@@ -5855,6 +5964,9 @@
58555964 if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
58565965 return; // no shadow for transparent objects
58575966
5967
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
5968
+ return;
5969
+
58585970 if (hide)
58595971 return;
58605972
....@@ -5895,9 +6007,10 @@
58956007 return;
58966008 }
58976009
6010
+ //bRep.GenUV(1/material.diffuseness);
58986011 // bRep.lock = true;
58996012
5900
- javax.media.opengl.GL gl = display.GetGL();
6013
+ //javax.media.opengl.GL gl = display.GetGL();
59016014
59026015 if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera)
59036016 {
....@@ -5914,23 +6027,7 @@
59146027
59156028 bRep.getMinMax(min, max, 100);
59166029
5917
- gl.glBegin(gl.GL_LINES);
5918
-
5919
- gl.glVertex3d(min.x, min.y, min.z);
5920
- gl.glVertex3d(min.x, min.y, max.z);
5921
- gl.glVertex3d(min.x, min.y, min.z);
5922
- gl.glVertex3d(min.x, max.y, min.z);
5923
- gl.glVertex3d(min.x, min.y, min.z);
5924
- gl.glVertex3d(max.x, min.y, min.z);
5925
-
5926
- gl.glVertex3d(max.x, max.y, max.z);
5927
- gl.glVertex3d(min.x, max.y, max.z);
5928
- gl.glVertex3d(max.x, max.y, max.z);
5929
- gl.glVertex3d(max.x, min.y, max.z);
5930
- gl.glVertex3d(max.x, max.y, max.z);
5931
- gl.glVertex3d(max.x, max.y, min.z);
5932
-
5933
- gl.glEnd();
6030
+ display.DrawBox(min, max);
59346031
59356032 return;
59366033 }
....@@ -5984,178 +6081,14 @@
59846081 new Exception().printStackTrace();
59856082 return;
59866083 }
5987
-
5988
- // TRIANGLE STRIP ARRAY
5989
- if (bRep.trimmed)
5990
- {
5991
- float[] v = bRep.getRawVertices();
5992
- float[] n = bRep.getRawNormals();
5993
- float[] c = bRep.getRawColors();
5994
- float[] uv = bRep.getRawUVMap();
5995
-
5996
- int count2 = 0;
5997
- int count3 = 0;
5998
-
5999
- if (n.length > 0)
6000
- {
6001
- for (int i = 0; i < strips.length; i++)
6002
- {
6003
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6004
-
6005
- /*
6006
- boolean locked = false;
6007
- float eps = 0.1f;
6008
- boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
6009
-
6010
- int dot = 0;
6011
-
6012
- if ((dot&1) == 0)
6013
- dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
6014
-
6015
- if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
6016
- gl.glTexCoord2f((float) qv.s, (float) qv.t);
6017
- else
6018
- {
6019
- locked = true;
6020
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6021
- }
6022
- //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6023
- gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
6024
- if (hasnorm)
6025
- {
6026
- //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6027
- gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
6028
- }
6029
-
6030
- if ((dot&4) == 0)
6031
- dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
6032
-
6033
- if (wrap || !locked && (dot&8) != 0)
6034
- gl.glTexCoord2f((float) rv.s, (float) rv.t);
6035
- else
6036
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6037
-
6038
- f.dot = dot;
6039
- */
6040
-
6041
- if (!selectmode)
6042
- {
6043
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6044
- {
6045
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6046
- } else
6047
- {
6048
- gl.glNormal3f(0, 0, 1);
6049
- }
6050
-
6051
- if (c != null)
6052
- //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]);
6053
- {
6054
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6055
- }
6056
- }
6057
- if (flipV)
6058
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6059
- else
6060
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6061
- //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6062
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6063
-
6064
- count2 += 2;
6065
- count3 += 3;
6066
- if (!selectmode)
6067
- {
6068
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6069
- {
6070
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6071
- } else
6072
- {
6073
- gl.glNormal3f(0, 0, 1);
6074
- }
6075
- if (c != null)
6076
- {
6077
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6078
- }
6079
- }
6080
- if (flipV)
6081
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6082
- else
6083
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6084
- //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6085
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6086
-
6087
- count2 += 2;
6088
- count3 += 3;
6089
- for (int j = 0; j < strips[i] - 2; j++)
6090
- {
6091
- //gl.glTexCoord2d(...);
6092
- if (!selectmode)
6093
- {
6094
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6095
- {
6096
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6097
- } else
6098
- {
6099
- gl.glNormal3f(0, 0, 1);
6100
- }
6101
- if (c != null)
6102
- {
6103
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6104
- }
6105
- }
6106
-
6107
- if (flipV)
6108
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6109
- else
6110
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6111
- //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
6112
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6113
- count2 += 2;
6114
- count3 += 3;
6115
- }
6116
-
6117
- gl.glEnd();
6118
- }
6119
- }
6120
-
6121
- assert count3 == v.length;
6122
- }
6123
- else // !trimmed
6124
- {
6125
- int count = 0;
6126
- for (int i = 0; i < strips.length; i++)
6127
- {
6128
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6129
-
6130
- Vertex p = bRep.GetVertex(bRep.indices[count++]);
6131
- Vertex q = bRep.GetVertex(bRep.indices[count++]);
6132
-
6133
- drawVertex(gl, p, selectmode);
6134
- drawVertex(gl, q, selectmode);
6135
-
6136
- for (int j = 0; j < strips[i] - 2; j++)
6137
- {
6138
- Vertex r = bRep.GetVertex(bRep.indices[count++]);
6139
-
6140
-// if (j%2 == 0)
6141
-// drawFace(p, q, r, display, null);
6142
-// else
6143
-// drawFace(p, r, q, display, null);
6144
-
6145
-// p = q;
6146
-// q = r;
6147
- drawVertex(gl, r, selectmode);
6148
- }
6149
-
6150
- gl.glEnd();
6151
- }
6152
- }
6084
+
6085
+ display.DrawGeometry(bRep, flipV, selectmode);
61536086 } else // catch (Error e)
61546087 {
61556088 // TRIANGLE ARRAY
61566089 if (IsOpaque()) // Static())
61576090 {
6158
- gl.glBegin(gl.GL_TRIANGLES);
6091
+ display.StartTriangles();
61596092 int facecount = bRep.FaceCount();
61606093 for (int i = 0; i < facecount; i++)
61616094 {
....@@ -6220,7 +6153,7 @@
62206153
62216154 display.DrawFace(this, p, q, r, face);
62226155 }
6223
- gl.glEnd();
6156
+ display.EndTriangles();
62246157 }
62256158 else
62266159 {
....@@ -6249,8 +6182,8 @@
62496182 //System.out.println("SORT");
62506183
62516184 java.util.Arrays.sort(facescompare);
6252
-
6253
- gl.glBegin(gl.GL_TRIANGLES);
6185
+
6186
+ display.StartTriangles();
62546187 for (int i = 0; i < facecount; i++)
62556188 {
62566189 Face face = bRep.GetFace(facescompare[i].index);
....@@ -6264,11 +6197,12 @@
62646197
62656198 display.DrawFace(this, p, q, r, face);
62666199 }
6267
- gl.glEnd();
6200
+ display.EndTriangles();
62686201 }
62696202
62706203 if (false) // live && support != null && support.bRep != null) // debug weights
62716204 {
6205
+ /*
62726206 gl.glDisable(gl.GL_LIGHTING);
62736207 float[] colorV = new float[3];
62746208
....@@ -6347,6 +6281,7 @@
63476281 // gl.glEnd();
63486282 }
63496283 }
6284
+ */
63506285 }
63516286 }
63526287
....@@ -6391,7 +6326,7 @@
63916326 center.add(r);
63926327 center.mul(1.0/3);
63936328
6394
- center.sub(CameraPane.theRenderer.eyeCamera.location);
6329
+ center.sub(Globals.theRenderer.EyeCamera().location);
63956330
63966331 distance = center.dot(center);
63976332 }
....@@ -6405,22 +6340,6 @@
64056340 void Print(Vertex v)
64066341 {
64076342 //System.err.println("(" + v.x + ", " + v.y + ", " + v.z + ")");
6408
- }
6409
-
6410
- void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean selectmode)
6411
- {
6412
- if (!selectmode)
6413
- {
6414
- gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
6415
- gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
6416
-
6417
- if (flipV)
6418
- gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
6419
- else
6420
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6421
- }
6422
-
6423
- gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
64246343 }
64256344
64266345 void drawSelf(ClickInfo info, int level, boolean select)
....@@ -7120,7 +7039,7 @@
71207039 }
71217040
71227041 //System.out.println("info.modifiers = " + info.modifiers);
7123
- modified = (info.modifiers & CameraPane.META) != 0;
7042
+ modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
71247043 //System.out.println("modified = " + modified);
71257044 //new Exception().printStackTrace();
71267045 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7148,7 +7067,7 @@
71487067 return true;
71497068 }
71507069
7151
- void doEditDrag0(ClickInfo info)
7070
+ void doEditDrag0(ClickInfo info, boolean opposite)
71527071 {
71537072 if (hitSomething == 0)
71547073 {
....@@ -7173,9 +7092,9 @@
71737092
71747093 case hitCenter: // Translate
71757094
7176
- scale *= 0.05f * info.pane.theRenderer.renderCamera.Distance();
7095
+ scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
71777096
7178
- if (modified)
7097
+ if (modified || opposite)
71797098 {
71807099 //assert(false);
71817100 /*
....@@ -7221,10 +7140,10 @@
72217140 }
72227141 LA.xformDir(up, ClickInfo.matbuffer, up);
72237142 // if (!CameraPane.LOCALTRANSFORM)
7224
- LA.xformDir(up, info.pane.theRenderer.renderCamera.toScreen, up);
7143
+ LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
72257144 LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
72267145 // if (!CameraPane.LOCALTRANSFORM)
7227
- LA.xformDir(away, info.pane.theRenderer.renderCamera.toScreen, away);
7146
+ LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
72287147 //LA.vecCross(up, cVector.Z, right2);
72297148
72307149 cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
....@@ -7269,6 +7188,7 @@
72697188
72707189 if (modified)
72717190 {
7191
+ // Rotate 90 degrees
72727192 angle /= (Math.PI / 4);
72737193 angle = Math.floor(angle + 0.5);
72747194 angle *= (Math.PI / 4);
....@@ -7282,7 +7202,7 @@
72827202 }
72837203 /**/
72847204
7285
- switch (info.pane.renderCamera.viewCode)
7205
+ switch (info.pane.RenderCamera().viewCode)
72867206 {
72877207 case 1: // '\001'
72887208 LA.matZRotate(toParent, angle);
....@@ -7338,7 +7258,7 @@
73387258 }
73397259 /**/
73407260
7341
- switch (info.pane.renderCamera.viewCode)
7261
+ switch (info.pane.RenderCamera().viewCode)
73427262 {
73437263 case 3: // '\001'
73447264 if (modified)
....@@ -7503,14 +7423,22 @@
75037423 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
75047424 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
75057425 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7426
+
7427
+ String objname;
7428
+
75067429 if (false) //parent != null)
75077430 {
7508
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7431
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
75097432 } else
75107433 {
7511
- 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) ":"") */ "";
75127435 } // + super.toString();
75137436 //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);
75147442 }
75157443
75167444 public int hashCode()
....@@ -7566,6 +7494,7 @@
75667494 objectUI.closeUI();
75677495 if (editWindow != null)
75687496 {
7497
+ editWindow.ctrlPanel.FlushUI();
75697498 editWindow.refreshContents();
75707499 } // ? new
75717500 objectUI = null;
....@@ -7701,7 +7630,7 @@
77017630 {
77027631 assert(bRep != null);
77037632 if (!(support instanceof GenericJoint)) // support.bRep != null)
7704
- GrafreeD.Assert(support.bRep == bRep.support);
7633
+ Grafreed.Assert(support.bRep == bRep.support);
77057634 }
77067635 else
77077636 {