Normand Briere
2019-06-11 1d909ffa0c2beb51d453b53b845c4f3a749ca5f0
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,11 +14,15 @@
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;
24
+
25
+ private UUID uuid = UUID.randomUUID();
2126
2227 ScriptNode scriptnode;
2328
....@@ -299,6 +304,7 @@
299304 }
300305
301306 boolean live = false;
307
+ boolean dontselect = false;
302308 boolean hide = false;
303309 boolean link2master = false; // performs reset support/master at each frame
304310 boolean marked = false; // animation node
....@@ -773,7 +779,7 @@
773779 if (step == 0)
774780 step = 1;
775781 if (maxcount == 0)
776
- maxcount = 2048; // 4;
782
+ maxcount = 128; // 2048; // 4;
777783 // if (acceleration == 0)
778784 // acceleration = 10;
779785 if (delay == 0) // serial
....@@ -796,7 +802,7 @@
796802
797803 if (marked && Globals.isLIVE() && live &&
798804 //TEMP21aug2018
799
- Globals.DrawMode() == iCameraPane.SHADOW &&
805
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
800806 currentframe != Globals.framecount)
801807 {
802808 currentframe = Globals.framecount;
....@@ -911,6 +917,11 @@
911917 fromParent = null; // LA.newMatrix();
912918 bRep = null; // new BoundaryRep();
913919
920
+ if (oname != null && oname.equals("LeftHand"))
921
+ {
922
+ name = oname;
923
+ }
924
+
914925 /*
915926 float hue = (float)Math.random();
916927 Color col;
....@@ -953,7 +964,7 @@
953964
954965 public Object clone()
955966 {
956
- return GrafreeD.clone(this);
967
+ return Grafreed.clone(this);
957968 }
958969
959970 Object3D copyExpand()
....@@ -1469,7 +1480,7 @@
14691480 BoundaryRep.SEUIL = other.material.cameralight;
14701481
14711482 // Set default to 0.1
1472
- BoundaryRep.SEUIL /= 2;
1483
+ BoundaryRep.SEUIL /= 4; // 2;
14731484 System.out.println("SEUIL = " + BoundaryRep.SEUIL);
14741485 }
14751486
....@@ -1728,7 +1739,7 @@
17281739 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17291740 o.bRep = transientrep;
17301741 if (clone)
1731
- o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
1742
+ o.bRep = (BoundaryRep) Grafreed.clone(transientrep);
17321743 o.CreateMaterial();
17331744 o.SetAttributes(this, -1);
17341745 //parent
....@@ -1741,7 +1752,7 @@
17411752 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17421753 o.bRep = bRep;
17431754 if (clone)
1744
- o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
1755
+ o.bRep = (BoundaryRep) Grafreed.clone(bRep);
17451756 o.CreateMaterial();
17461757 //o.overwriteThis(this, -1);
17471758 o.SetAttributes(this, -1);
....@@ -1828,12 +1839,15 @@
18281839 if (obj.name == null)
18291840 continue; // can't be a null one
18301841
1842
+ // Try perfect match first.
18311843 if (n.equals(obj.name))
18321844 {
18331845 theobj = obj;
18341846 count++;
18351847 }
18361848 }
1849
+
1850
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18371851
18381852 if (count != 1)
18391853 for (int i=Size(); --i>=0;)
....@@ -2299,6 +2313,7 @@
22992313 {
23002314 if (newWindow)
23012315 {
2316
+ new Exception().printStackTrace();
23022317 System.exit(0);
23032318 if (parent != null)
23042319 {
....@@ -2475,13 +2490,13 @@
24752490 return retval;
24762491 }
24772492
2478
- void doEditDrag(ClickInfo info)
2493
+ void doEditDrag(ClickInfo info, boolean opposite)
24792494 {
24802495 switch (doSomething)
24812496 {
24822497 case 1: // '\001'
24832498 //super.
2484
- doEditDrag0(info);
2499
+ doEditDrag0(info, opposite);
24852500 break;
24862501
24872502 case 2: // '\002'
....@@ -2494,11 +2509,11 @@
24942509 {
24952510 //sel.hitSomething = childToDrag.hitSomething;
24962511 //childToDrag.doEditDrag(info);
2497
- sel.doEditDrag(info);
2512
+ sel.doEditDrag(info, opposite);
24982513 } else
24992514 {
25002515 //super.
2501
- doEditDrag0(info);
2516
+ doEditDrag0(info, opposite);
25022517 }
25032518 }
25042519 break;
....@@ -2905,7 +2920,8 @@
29052920 {
29062921 if (bRep != null)
29072922 {
2908
- bRep.GenUV();
2923
+ bRep.GenUV(); //1);
2924
+ //bRep.UnfoldUV();
29092925 Touch();
29102926 }
29112927 }
....@@ -2980,6 +2996,33 @@
29802996 blockloop = false;
29812997 }
29822998
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
+
29833026 void TransformGeometry()
29843027 {
29853028 Object3D obj = this;
....@@ -3201,9 +3244,11 @@
32013244
32023245 BoundaryRep sup = bRep.support;
32033246 bRep.support = null;
3204
- BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
3247
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
32053248 // bRep.SplitInTwo(onlyone); // thread...
3206
- temprep.SplitInTwo(reduction34, onlyone);
3249
+
3250
+ while(temprep.SplitInTwo(reduction34, onlyone));
3251
+
32073252 bRep = temprep;
32083253 bRep.support = sup;
32093254 Touch();
....@@ -3725,7 +3770,7 @@
37253770 if (child == null)
37263771 continue;
37273772
3728
- if (GrafreeD.RENDERME > 0)
3773
+ if (Grafreed.RENDERME > 0)
37293774 {
37303775 if (child instanceof Merge)
37313776 ((Merge)child).renderme();
....@@ -3876,7 +3921,7 @@
38763921 if (child == null)
38773922 continue;
38783923
3879
- if (GrafreeD.RENDERME > 0)
3924
+ if (Grafreed.RENDERME > 0)
38803925 {
38813926 if (child instanceof Merge)
38823927 ((Merge)child).renderme();
....@@ -4071,7 +4116,7 @@
40714116 if (child == null)
40724117 continue;
40734118
4074
- if (GrafreeD.RENDERME > 0)
4119
+ if (Grafreed.RENDERME > 0)
40754120 {
40764121 if (child instanceof Merge)
40774122 ((Merge)child).renderme();
....@@ -4678,7 +4723,7 @@
46784723
46794724 cTreePath SelectLeaf(int indexcount, boolean deselect)
46804725 {
4681
- if (hide)
4726
+ if (hide || dontselect)
46824727 return null;
46834728
46844729 if (count <= 0)
....@@ -4704,7 +4749,7 @@
47044749
47054750 cTreePath Select(int indexcount, boolean deselect)
47064751 {
4707
- if (hide)
4752
+ if (hide || dontselect)
47084753 return null;
47094754
47104755 if (count <= 0)
....@@ -5156,10 +5201,34 @@
51565201
51575202 // System.out.println("Fullname = " + fullname);
51585203
5159
- if (fullname.name.indexOf(":") == -1)
5160
- 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(":"));
51615209
5162
- 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];
51635232 }
51645233
51655234 static String GetBump(cTexture fullname)
....@@ -5168,10 +5237,38 @@
51685237 return "";
51695238
51705239 // 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());
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];
51755272 }
51765273
51775274 String GetPigmentTexture()
....@@ -5245,7 +5342,7 @@
52455342 System.out.print("; textures = " + textures);
52465343 System.out.println("; usedtextures = " + usedtextures);
52475344
5248
- if (GetTextures() == null)
5345
+ if (GetTextures() == null) // What is that??
52495346 GetTextures().name = ":";
52505347
52515348 String texname = tex;
....@@ -5276,6 +5373,43 @@
52765373 child.ResetPigmentTexture();
52775374 blockloop = false;
52785375 }
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;
52795413 }
52805414
52815415 void SetBumpTexture(String tex)
....@@ -5322,9 +5456,9 @@
53225456 boolean NeedSupport()
53235457 {
53245458 return
5325
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5459
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null
53265460 // PROBLEM with CROWD!!
5327
- && (Globals.DrawMode() == iCameraPane.SHADOW || Globals.CROWD);
5461
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
53285462 }
53295463
53305464 static boolean DEBUG_SELECTION = false;
....@@ -5339,7 +5473,7 @@
53395473 }
53405474
53415475 if (display.DrawMode() == iCameraPane.SELECTION &&
5342
- hide)
5476
+ (hide || dontselect))
53435477 return;
53445478
53455479 if (name != null && name.contains("sclera"))
....@@ -5371,7 +5505,7 @@
53715505 return;
53725506 }
53735507
5374
- javax.media.opengl.GL gl = display.GetGL();
5508
+ //javax.media.opengl.GL gl = display.GetGL();
53755509
53765510 /*
53775511 if (touched)
....@@ -5423,7 +5557,7 @@
54235557 //if (displaylist == -1 && usecalllists)
54245558 if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
54255559 {
5426
- bRep.displaylist = gl.glGenLists(1);
5560
+ bRep.displaylist = display.GenList();
54275561 assert(bRep.displaylist != 0);
54285562 // System.err.println("glGenLists: " + bRep.displaylist + " for " + this);
54295563 //System.out.println("\tgen list " + list);
....@@ -5435,14 +5569,16 @@
54355569 if (usecalllists)
54365570 {
54375571 // System.err.println("new list " + bRep.displaylist + " for " + this);
5438
- gl.glNewList(bRep.displaylist, gl.GL_COMPILE); //_AND_EXECUTE);
5572
+ display.NewList(bRep.displaylist);
54395573 }
5574
+
54405575 CallList(display, root, selected, blocked);
5576
+
54415577 // compiled = true;
54425578 if (usecalllists)
54435579 {
54445580 // System.err.println("end list " + bRep.displaylist + " for " + this);
5445
- gl.glEndList();
5581
+ display.EndList();
54465582 }
54475583 //gl.glDrawBuffer(gl.GL_BACK);
54485584 // XXX touched = false;
....@@ -5490,7 +5626,7 @@
54905626 if (display.DrawMode() == iCameraPane.SHADOW)
54915627 {
54925628 if (!link2master // tricky to cull in shadow mode.
5493
- && GetBRep().FrustumCull(this, gl, display.LightCamera(), true))
5629
+ && GetBRep().FrustumCull(this, null, display.LightCamera(), true))
54945630 {
54955631 //System.out.print("CULLED");
54965632 culled = true;
....@@ -5498,7 +5634,7 @@
54985634 }
54995635 else
55005636 //GetBRep().getBounds(v0, v1, this);
5501
- if (GetBRep().FrustumCull(this, gl, display.RenderCamera(), false))
5637
+ if (GetBRep().FrustumCull(this, null, display.RenderCamera(), false))
55025638 culled = true;
55035639
55045640 // LA.xformPos(v0, display.renderCamera.toScreen, v0);
....@@ -5538,7 +5674,7 @@
55385674 {
55395675 if (GetBRep() != null)
55405676 {
5541
- CameraPane.NextIndex(this, gl);
5677
+ display.NextIndex();
55425678 // vertex color conflict : gl.glCallList(list);
55435679 DrawNode(display, root, selected);
55445680 if (this instanceof BezierPatch)
....@@ -5579,7 +5715,17 @@
55795715 tex = GetTextures();
55805716 }
55815717
5582
- 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
+ }
55835729
55845730 if (!compiled)
55855731 {
....@@ -5595,13 +5741,14 @@
55955741
55965742 // System.err.println("glCallList: " + bRep.displaylist + " for " + this);
55975743 assert(bRep.displaylist != 0);
5598
- gl.glCallList(bRep.displaylist);
5744
+ display.CallList(bRep.displaylist);
55995745 // june 2013 drawSelf(display, root, selected);
56005746 }
56015747 }
56025748 }
56035749
5604
- display.ReleaseTextures(tex);
5750
+ if (!failed)
5751
+ display.ReleaseTextures(tex);
56055752
56065753 display.PopMaterial(this, selected);
56075754 }
....@@ -5730,6 +5877,9 @@
57305877
57315878 void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57325879 {
5880
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
5881
+ return;
5882
+
57335883 if (hide)
57345884 return;
57355885 // shadow optimisation
....@@ -5855,6 +6005,9 @@
58556005 if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
58566006 return; // no shadow for transparent objects
58576007
6008
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6009
+ return;
6010
+
58586011 if (hide)
58596012 return;
58606013
....@@ -5895,9 +6048,10 @@
58956048 return;
58966049 }
58976050
6051
+ //bRep.GenUV(1/material.diffuseness);
58986052 // bRep.lock = true;
58996053
5900
- javax.media.opengl.GL gl = display.GetGL();
6054
+ //javax.media.opengl.GL gl = display.GetGL();
59016055
59026056 if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera)
59036057 {
....@@ -5914,23 +6068,7 @@
59146068
59156069 bRep.getMinMax(min, max, 100);
59166070
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();
6071
+ display.DrawBox(min, max);
59346072
59356073 return;
59366074 }
....@@ -5984,178 +6122,14 @@
59846122 new Exception().printStackTrace();
59856123 return;
59866124 }
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
- }
6125
+
6126
+ display.DrawGeometry(bRep, flipV, selectmode);
61536127 } else // catch (Error e)
61546128 {
61556129 // TRIANGLE ARRAY
61566130 if (IsOpaque()) // Static())
61576131 {
6158
- gl.glBegin(gl.GL_TRIANGLES);
6132
+ display.StartTriangles();
61596133 int facecount = bRep.FaceCount();
61606134 for (int i = 0; i < facecount; i++)
61616135 {
....@@ -6220,7 +6194,7 @@
62206194
62216195 display.DrawFace(this, p, q, r, face);
62226196 }
6223
- gl.glEnd();
6197
+ display.EndTriangles();
62246198 }
62256199 else
62266200 {
....@@ -6249,8 +6223,8 @@
62496223 //System.out.println("SORT");
62506224
62516225 java.util.Arrays.sort(facescompare);
6252
-
6253
- gl.glBegin(gl.GL_TRIANGLES);
6226
+
6227
+ display.StartTriangles();
62546228 for (int i = 0; i < facecount; i++)
62556229 {
62566230 Face face = bRep.GetFace(facescompare[i].index);
....@@ -6264,11 +6238,12 @@
62646238
62656239 display.DrawFace(this, p, q, r, face);
62666240 }
6267
- gl.glEnd();
6241
+ display.EndTriangles();
62686242 }
62696243
62706244 if (false) // live && support != null && support.bRep != null) // debug weights
62716245 {
6246
+ /*
62726247 gl.glDisable(gl.GL_LIGHTING);
62736248 float[] colorV = new float[3];
62746249
....@@ -6347,6 +6322,7 @@
63476322 // gl.glEnd();
63486323 }
63496324 }
6325
+ */
63506326 }
63516327 }
63526328
....@@ -6405,22 +6381,6 @@
64056381 void Print(Vertex v)
64066382 {
64076383 //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);
64246384 }
64256385
64266386 void drawSelf(ClickInfo info, int level, boolean select)
....@@ -7031,8 +6991,8 @@
70316991 // {
70326992 // CameraPane.Ymax = spoth;
70336993 // }
7034
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7035
- info.g.drawLine(spotw, spoth, spotw - 15, spoth);
6994
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - 15);
6995
+ //info.g.drawLine(spotw, spoth, spotw - 15, spoth);
70366996 spot.translate(0, -32);
70376997 info.g.setColor(Color.green);
70386998 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
....@@ -7087,7 +7047,7 @@
70877047 startX = info.x;
70887048 startY = info.y;
70897049
7090
- hitSomething = 0;
7050
+ hitSomething = -1;
70917051 cVector origin = new cVector();
70927052 //LA.xformPos(origin, toParent, origin);
70937053 Rectangle spot = new Rectangle();
....@@ -7120,7 +7080,7 @@
71207080 }
71217081
71227082 //System.out.println("info.modifiers = " + info.modifiers);
7123
- modified = (info.modifiers & CameraPane.META) != 0;
7083
+ modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
71247084 //System.out.println("modified = " + modified);
71257085 //new Exception().printStackTrace();
71267086 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7148,7 +7108,7 @@
71487108 return true;
71497109 }
71507110
7151
- void doEditDrag0(ClickInfo info)
7111
+ void doEditDrag0(ClickInfo info, boolean opposite)
71527112 {
71537113 if (hitSomething == 0)
71547114 {
....@@ -7163,6 +7123,7 @@
71637123 //System.out.println("hitSomething = " + hitSomething);
71647124
71657125 double scale = 0.005f * info.camera.Distance();
7126
+
71667127 cVector xlate = new cVector();
71677128 //cVector xlate2 = new cVector();
71687129 switch (hitSomething)
....@@ -7175,7 +7136,7 @@
71757136
71767137 scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
71777138
7178
- if (modified)
7139
+ if (modified || opposite)
71797140 {
71807141 //assert(false);
71817142 /*
....@@ -7269,6 +7230,7 @@
72697230
72707231 if (modified)
72717232 {
7233
+ // Rotate 90 degrees
72727234 angle /= (Math.PI / 4);
72737235 angle = Math.floor(angle + 0.5);
72747236 angle *= (Math.PI / 4);
....@@ -7310,24 +7272,27 @@
73107272
73117273 case hitScale: // scale
73127274 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);
73137281 if (hScale < 0.01)
73147282 {
7315
- hScale = 0.01;
7283
+ //hScale = 0.01;
73167284 }
7317
- hScale = Math.pow(hScale, scale * 50);
7318
- if (hScale < 0.01)
7319
- {
7320
- hScale = 0.01;
7321
- }
7285
+
73227286 double vScale = (double) (info.y - centerPt.y) / 32;
7323
- if (vScale < 0.01)
7287
+ sign = 1;
7288
+ if (vScale < 0)
73247289 {
7325
- vScale = 0.01;
7290
+ sign = -1;
73267291 }
7327
- vScale = Math.pow(vScale, scale * 50);
7292
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
73287293 if (vScale < 0.01)
73297294 {
7330
- vScale = 0.01;
7295
+ //vScale = 0.01;
73317296 }
73327297 LA.matCopy(startMat, toParent);
73337298 /**/
....@@ -7338,17 +7303,24 @@
73387303 }
73397304 /**/
73407305
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
+
73417313 switch (info.pane.RenderCamera().viewCode)
73427314 {
73437315 case 3: // '\001'
73447316 if (modified)
73457317 {
73467318 //LA.matScale(toParent, 1, hScale, vScale);
7347
- LA.matScale(toParent, vScale, 1, 1);
7319
+ LA.matScale(toParent, totalScale, 1, 1);
73487320 } // vScale, 1);
73497321 else
73507322 {
7351
- LA.matScale(toParent, vScale, vScale, vScale);
7323
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
73527324 } // vScale, 1);
73537325 break;
73547326
....@@ -7356,10 +7328,10 @@
73567328 if (modified)
73577329 {
73587330 //LA.matScale(toParent, hScale, 1, vScale);
7359
- LA.matScale(toParent, 1, vScale, 1);
7331
+ LA.matScale(toParent, 1, totalScale, 1);
73607332 } else
73617333 {
7362
- LA.matScale(toParent, vScale, 1, vScale);
7334
+ LA.matScale(toParent, totalScale, 1, totalScale);
73637335 }
73647336 break;
73657337
....@@ -7367,10 +7339,10 @@
73677339 if (modified)
73687340 {
73697341 //LA.matScale(toParent, hScale, vScale, 1);
7370
- LA.matScale(toParent, 1, 1, vScale);
7342
+ LA.matScale(toParent, 1, 1, totalScale);
73717343 } else
73727344 {
7373
- LA.matScale(toParent, vScale, vScale, 1);
7345
+ LA.matScale(toParent, totalScale, totalScale, 1);
73747346 }
73757347 break;
73767348 }
....@@ -7503,14 +7475,22 @@
75037475 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
75047476 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
75057477 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7478
+
7479
+ String objname;
7480
+
75067481 if (false) //parent != null)
75077482 {
7508
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7483
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
75097484 } else
75107485 {
7511
- 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) ":"") */ "";
75127487 } // + super.toString();
75137488 //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);
75147494 }
75157495
75167496 public int hashCode()
....@@ -7566,6 +7546,7 @@
75667546 objectUI.closeUI();
75677547 if (editWindow != null)
75687548 {
7549
+ editWindow.ctrlPanel.FlushUI();
75697550 editWindow.refreshContents();
75707551 } // ? new
75717552 objectUI = null;
....@@ -7701,7 +7682,7 @@
77017682 {
77027683 assert(bRep != null);
77037684 if (!(support instanceof GenericJoint)) // support.bRep != null)
7704
- GrafreeD.Assert(support.bRep == bRep.support);
7685
+ Grafreed.Assert(support.bRep == bRep.support);
77057686 }
77067687 else
77077688 {
....@@ -7750,9 +7731,9 @@
77507731 private static cVector edge2 = new cVector();
77517732 //private static cVector norm = new cVector();
77527733 /*transient private*/ int hitSomething;
7753
- private static final int hitCenter = 1;
7754
- private static final int hitScale = 2;
7755
- private static final int hitRotate = 3;
7734
+ static final int hitCenter = 1;
7735
+ static final int hitScale = 2;
7736
+ static final int hitRotate = 3;
77567737 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
77577738 /*transient*/ private Point centerPt;
77587739 /*transient*/ private int startX;