Normand Briere
2019-06-11 4113164b3be1e50251ac40d6fd65660f0a6c2e63
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
....@@ -155,6 +160,67 @@
155160 blockloop = true;
156161 child.RestoreSupports();
157162 blockloop = false;
163
+ }
164
+}
165
+
166
+void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
167
+{
168
+ if (hashtable.containsKey(GetUUID()))
169
+ {
170
+ Object3D o = hashtable.get(GetUUID());
171
+
172
+ assert(this.bRep == o.bRep);
173
+ if (this.bRep != null)
174
+ assert(this.bRep.support == o.transientrep);
175
+
176
+ return;
177
+ }
178
+
179
+ Object3D o = new Object3D();
180
+ o.bRep = this.bRep;
181
+ if (this.bRep != null)
182
+ {
183
+ o.transientrep = this.bRep.support;
184
+ o.bRep.support = null;
185
+ }
186
+
187
+// o.support = this.support;
188
+// o.fileparent = this.fileparent;
189
+// if (this.bRep != null)
190
+// o.bRep = this.bRep.support;
191
+
192
+ hashtable.put(GetUUID(), o);
193
+
194
+ this.bRep = null;
195
+// if (this.bRep != null)
196
+// this.bRep.support = null;
197
+// this.support = null;
198
+// this.fileparent = null;
199
+
200
+ for (int i=0; i<Size(); i++)
201
+ {
202
+ get(i).ExtractBigData(hashtable);
203
+ }
204
+}
205
+
206
+void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
207
+{
208
+ if (!hashtable.containsKey(GetUUID()))
209
+ return;
210
+
211
+ Object3D o = hashtable.get(GetUUID());
212
+
213
+ this.bRep = o.bRep;
214
+ if (this.bRep != null)
215
+ this.bRep.support = o.transientrep;
216
+// this.support = o.support;
217
+// this.fileparent = o.fileparent;
218
+
219
+ hashtable.remove(GetUUID());
220
+
221
+ for (int i=0; i<Size(); i++)
222
+ {
223
+ get(i).RestoreBigData(hashtable);
158224 }
159225 }
160226
....@@ -299,6 +365,7 @@
299365 }
300366
301367 boolean live = false;
368
+ boolean dontselect = false;
302369 boolean hide = false;
303370 boolean link2master = false; // performs reset support/master at each frame
304371 boolean marked = false; // animation node
....@@ -773,7 +840,7 @@
773840 if (step == 0)
774841 step = 1;
775842 if (maxcount == 0)
776
- maxcount = 2048; // 4;
843
+ maxcount = 128; // 2048; // 4;
777844 // if (acceleration == 0)
778845 // acceleration = 10;
779846 if (delay == 0) // serial
....@@ -796,7 +863,7 @@
796863
797864 if (marked && Globals.isLIVE() && live &&
798865 //TEMP21aug2018
799
- Globals.DrawMode() == iCameraPane.SHADOW &&
866
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
800867 currentframe != Globals.framecount)
801868 {
802869 currentframe = Globals.framecount;
....@@ -911,6 +978,11 @@
911978 fromParent = null; // LA.newMatrix();
912979 bRep = null; // new BoundaryRep();
913980
981
+ if (oname != null && oname.equals("LeftHand"))
982
+ {
983
+ name = oname;
984
+ }
985
+
914986 /*
915987 float hue = (float)Math.random();
916988 Color col;
....@@ -953,7 +1025,7 @@
9531025
9541026 public Object clone()
9551027 {
956
- return GrafreeD.clone(this);
1028
+ return Grafreed.clone(this);
9571029 }
9581030
9591031 Object3D copyExpand()
....@@ -1469,7 +1541,7 @@
14691541 BoundaryRep.SEUIL = other.material.cameralight;
14701542
14711543 // Set default to 0.1
1472
- BoundaryRep.SEUIL /= 2;
1544
+ BoundaryRep.SEUIL /= 4; // 2;
14731545 System.out.println("SEUIL = " + BoundaryRep.SEUIL);
14741546 }
14751547
....@@ -1728,7 +1800,7 @@
17281800 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17291801 o.bRep = transientrep;
17301802 if (clone)
1731
- o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
1803
+ o.bRep = (BoundaryRep) Grafreed.clone(transientrep);
17321804 o.CreateMaterial();
17331805 o.SetAttributes(this, -1);
17341806 //parent
....@@ -1741,7 +1813,7 @@
17411813 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17421814 o.bRep = bRep;
17431815 if (clone)
1744
- o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
1816
+ o.bRep = (BoundaryRep) Grafreed.clone(bRep);
17451817 o.CreateMaterial();
17461818 //o.overwriteThis(this, -1);
17471819 o.SetAttributes(this, -1);
....@@ -1828,12 +1900,15 @@
18281900 if (obj.name == null)
18291901 continue; // can't be a null one
18301902
1903
+ // Try perfect match first.
18311904 if (n.equals(obj.name))
18321905 {
18331906 theobj = obj;
18341907 count++;
18351908 }
18361909 }
1910
+
1911
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18371912
18381913 if (count != 1)
18391914 for (int i=Size(); --i>=0;)
....@@ -2299,6 +2374,7 @@
22992374 {
23002375 if (newWindow)
23012376 {
2377
+ new Exception().printStackTrace();
23022378 System.exit(0);
23032379 if (parent != null)
23042380 {
....@@ -2475,13 +2551,13 @@
24752551 return retval;
24762552 }
24772553
2478
- void doEditDrag(ClickInfo info)
2554
+ void doEditDrag(ClickInfo info, boolean opposite)
24792555 {
24802556 switch (doSomething)
24812557 {
24822558 case 1: // '\001'
24832559 //super.
2484
- doEditDrag0(info);
2560
+ doEditDrag0(info, opposite);
24852561 break;
24862562
24872563 case 2: // '\002'
....@@ -2494,11 +2570,11 @@
24942570 {
24952571 //sel.hitSomething = childToDrag.hitSomething;
24962572 //childToDrag.doEditDrag(info);
2497
- sel.doEditDrag(info);
2573
+ sel.doEditDrag(info, opposite);
24982574 } else
24992575 {
25002576 //super.
2501
- doEditDrag0(info);
2577
+ doEditDrag0(info, opposite);
25022578 }
25032579 }
25042580 break;
....@@ -2905,7 +2981,8 @@
29052981 {
29062982 if (bRep != null)
29072983 {
2908
- bRep.GenUV();
2984
+ bRep.GenUV(); //1);
2985
+ //bRep.UnfoldUV();
29092986 Touch();
29102987 }
29112988 }
....@@ -2980,6 +3057,33 @@
29803057 blockloop = false;
29813058 }
29823059
3060
+ void TransformChildren()
3061
+ {
3062
+ if (toParent != null)
3063
+ {
3064
+ for (int i=Size(); --i>=0;)
3065
+ {
3066
+ Object3D v = get(i);
3067
+
3068
+ if (v.toParent == null)
3069
+ {
3070
+ v.toParent = LA.newMatrix();
3071
+ v.fromParent = LA.newMatrix();
3072
+ }
3073
+
3074
+// LA.matConcat(v.toParent, toParent, v.toParent);
3075
+// LA.matConcat(fromParent, v.fromParent, v.fromParent);
3076
+ LA.matConcat(toParent, v.toParent, v.toParent);
3077
+ LA.matConcat(v.fromParent, fromParent, v.fromParent);
3078
+ }
3079
+
3080
+ toParent = null; // LA.matIdentity(toParent);
3081
+ fromParent = null; // LA.matIdentity(fromParent);
3082
+
3083
+ Touch();
3084
+ }
3085
+ }
3086
+
29833087 void TransformGeometry()
29843088 {
29853089 Object3D obj = this;
....@@ -3201,9 +3305,11 @@
32013305
32023306 BoundaryRep sup = bRep.support;
32033307 bRep.support = null;
3204
- BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
3308
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
32053309 // bRep.SplitInTwo(onlyone); // thread...
3206
- temprep.SplitInTwo(reduction34, onlyone);
3310
+
3311
+ while(temprep.SplitInTwo(reduction34, onlyone));
3312
+
32073313 bRep = temprep;
32083314 bRep.support = sup;
32093315 Touch();
....@@ -3725,7 +3831,7 @@
37253831 if (child == null)
37263832 continue;
37273833
3728
- if (GrafreeD.RENDERME > 0)
3834
+ if (Grafreed.RENDERME > 0)
37293835 {
37303836 if (child instanceof Merge)
37313837 ((Merge)child).renderme();
....@@ -3876,7 +3982,7 @@
38763982 if (child == null)
38773983 continue;
38783984
3879
- if (GrafreeD.RENDERME > 0)
3985
+ if (Grafreed.RENDERME > 0)
38803986 {
38813987 if (child instanceof Merge)
38823988 ((Merge)child).renderme();
....@@ -4071,7 +4177,7 @@
40714177 if (child == null)
40724178 continue;
40734179
4074
- if (GrafreeD.RENDERME > 0)
4180
+ if (Grafreed.RENDERME > 0)
40754181 {
40764182 if (child instanceof Merge)
40774183 ((Merge)child).renderme();
....@@ -4678,7 +4784,7 @@
46784784
46794785 cTreePath SelectLeaf(int indexcount, boolean deselect)
46804786 {
4681
- if (hide)
4787
+ if (hide || dontselect)
46824788 return null;
46834789
46844790 if (count <= 0)
....@@ -4704,7 +4810,7 @@
47044810
47054811 cTreePath Select(int indexcount, boolean deselect)
47064812 {
4707
- if (hide)
4813
+ if (hide || dontselect)
47084814 return null;
47094815
47104816 if (count <= 0)
....@@ -5156,10 +5262,34 @@
51565262
51575263 // System.out.println("Fullname = " + fullname);
51585264
5159
- if (fullname.name.indexOf(":") == -1)
5160
- return fullname.name;
5265
+ // Does not work on Windows due to C:
5266
+// if (fullname.name.indexOf(":") == -1)
5267
+// return fullname.name;
5268
+//
5269
+// return fullname.name.substring(0,fullname.name.indexOf(":"));
51615270
5162
- return fullname.name.substring(0,fullname.name.indexOf(":"));
5271
+ String[] split = fullname.name.split(":");
5272
+
5273
+ if (split.length == 0)
5274
+ {
5275
+ return "";
5276
+ }
5277
+
5278
+ if (split.length <= 2)
5279
+ {
5280
+ if (fullname.name.endsWith(":"))
5281
+ {
5282
+ // Windows
5283
+ return fullname.name.substring(0, fullname.name.length()-1);
5284
+ }
5285
+
5286
+ return split[0];
5287
+ }
5288
+
5289
+ // Windows
5290
+ assert(split.length == 4);
5291
+
5292
+ return split[0] + ":" + split[1];
51635293 }
51645294
51655295 static String GetBump(cTexture fullname)
....@@ -5168,10 +5298,38 @@
51685298 return "";
51695299
51705300 // 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());
5301
+ // Does not work on Windows due to C:
5302
+// if (fullname.name.indexOf(":") == -1)
5303
+// return "";
5304
+//
5305
+// return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5306
+ String[] split = fullname.name.split(":");
5307
+
5308
+ if (split.length == 0)
5309
+ {
5310
+ return "";
5311
+ }
5312
+
5313
+ if (split.length == 1)
5314
+ {
5315
+ return "";
5316
+ }
5317
+
5318
+ if (split.length == 2)
5319
+ {
5320
+ if (fullname.name.endsWith(":"))
5321
+ {
5322
+ // Windows
5323
+ return "";
5324
+ }
5325
+
5326
+ return split[1];
5327
+ }
5328
+
5329
+ // Windows
5330
+ assert(split.length == 4);
5331
+
5332
+ return split[2] + ":" + split[3];
51755333 }
51765334
51775335 String GetPigmentTexture()
....@@ -5245,7 +5403,7 @@
52455403 System.out.print("; textures = " + textures);
52465404 System.out.println("; usedtextures = " + usedtextures);
52475405
5248
- if (GetTextures() == null)
5406
+ if (GetTextures() == null) // What is that??
52495407 GetTextures().name = ":";
52505408
52515409 String texname = tex;
....@@ -5276,6 +5434,43 @@
52765434 child.ResetPigmentTexture();
52775435 blockloop = false;
52785436 }
5437
+ }
5438
+
5439
+ UUID GetUUID()
5440
+ {
5441
+ if (uuid == null)
5442
+ {
5443
+ // Serial
5444
+ uuid = UUID.randomUUID();
5445
+ }
5446
+
5447
+ return uuid;
5448
+ }
5449
+
5450
+ Object3D GetObject(UUID uid)
5451
+ {
5452
+ if (blockloop)
5453
+ return null;
5454
+
5455
+ if (GetUUID().equals(uid))
5456
+ return this;
5457
+
5458
+ int nb = Size();
5459
+ for (int i = 0; i < nb; i++)
5460
+ {
5461
+ Object3D child = (Object3D) get(i);
5462
+
5463
+ if (child == null)
5464
+ continue;
5465
+
5466
+ blockloop = true;
5467
+ Object3D obj = child.GetObject(uid);
5468
+ blockloop = false;
5469
+ if (obj != null)
5470
+ return obj;
5471
+ }
5472
+
5473
+ return null;
52795474 }
52805475
52815476 void SetBumpTexture(String tex)
....@@ -5322,9 +5517,9 @@
53225517 boolean NeedSupport()
53235518 {
53245519 return
5325
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5520
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null
53265521 // PROBLEM with CROWD!!
5327
- && (Globals.DrawMode() == iCameraPane.SHADOW || Globals.CROWD);
5522
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
53285523 }
53295524
53305525 static boolean DEBUG_SELECTION = false;
....@@ -5339,7 +5534,7 @@
53395534 }
53405535
53415536 if (display.DrawMode() == iCameraPane.SELECTION &&
5342
- hide)
5537
+ (hide || dontselect))
53435538 return;
53445539
53455540 if (name != null && name.contains("sclera"))
....@@ -5371,7 +5566,7 @@
53715566 return;
53725567 }
53735568
5374
- javax.media.opengl.GL gl = display.GetGL();
5569
+ //javax.media.opengl.GL gl = display.GetGL();
53755570
53765571 /*
53775572 if (touched)
....@@ -5423,7 +5618,7 @@
54235618 //if (displaylist == -1 && usecalllists)
54245619 if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
54255620 {
5426
- bRep.displaylist = gl.glGenLists(1);
5621
+ bRep.displaylist = display.GenList();
54275622 assert(bRep.displaylist != 0);
54285623 // System.err.println("glGenLists: " + bRep.displaylist + " for " + this);
54295624 //System.out.println("\tgen list " + list);
....@@ -5435,14 +5630,16 @@
54355630 if (usecalllists)
54365631 {
54375632 // System.err.println("new list " + bRep.displaylist + " for " + this);
5438
- gl.glNewList(bRep.displaylist, gl.GL_COMPILE); //_AND_EXECUTE);
5633
+ display.NewList(bRep.displaylist);
54395634 }
5635
+
54405636 CallList(display, root, selected, blocked);
5637
+
54415638 // compiled = true;
54425639 if (usecalllists)
54435640 {
54445641 // System.err.println("end list " + bRep.displaylist + " for " + this);
5445
- gl.glEndList();
5642
+ display.EndList();
54465643 }
54475644 //gl.glDrawBuffer(gl.GL_BACK);
54485645 // XXX touched = false;
....@@ -5490,7 +5687,7 @@
54905687 if (display.DrawMode() == iCameraPane.SHADOW)
54915688 {
54925689 if (!link2master // tricky to cull in shadow mode.
5493
- && GetBRep().FrustumCull(this, gl, display.LightCamera(), true))
5690
+ && GetBRep().FrustumCull(this, null, display.LightCamera(), true))
54945691 {
54955692 //System.out.print("CULLED");
54965693 culled = true;
....@@ -5498,7 +5695,7 @@
54985695 }
54995696 else
55005697 //GetBRep().getBounds(v0, v1, this);
5501
- if (GetBRep().FrustumCull(this, gl, display.RenderCamera(), false))
5698
+ if (GetBRep().FrustumCull(this, null, display.RenderCamera(), false))
55025699 culled = true;
55035700
55045701 // LA.xformPos(v0, display.renderCamera.toScreen, v0);
....@@ -5538,7 +5735,7 @@
55385735 {
55395736 if (GetBRep() != null)
55405737 {
5541
- CameraPane.NextIndex(this, gl);
5738
+ display.NextIndex();
55425739 // vertex color conflict : gl.glCallList(list);
55435740 DrawNode(display, root, selected);
55445741 if (this instanceof BezierPatch)
....@@ -5579,7 +5776,17 @@
55795776 tex = GetTextures();
55805777 }
55815778
5582
- display.BindTextures(tex, texres);
5779
+ boolean failed = false;
5780
+
5781
+ try
5782
+ {
5783
+ display.BindTextures(tex, texres);
5784
+ }
5785
+ catch (Exception e)
5786
+ {
5787
+ System.err.println("FAILED: " + this);
5788
+ failed = true;
5789
+ }
55835790
55845791 if (!compiled)
55855792 {
....@@ -5595,13 +5802,14 @@
55955802
55965803 // System.err.println("glCallList: " + bRep.displaylist + " for " + this);
55975804 assert(bRep.displaylist != 0);
5598
- gl.glCallList(bRep.displaylist);
5805
+ display.CallList(bRep.displaylist);
55995806 // june 2013 drawSelf(display, root, selected);
56005807 }
56015808 }
56025809 }
56035810
5604
- display.ReleaseTextures(tex);
5811
+ if (!failed)
5812
+ display.ReleaseTextures(tex);
56055813
56065814 display.PopMaterial(this, selected);
56075815 }
....@@ -5730,6 +5938,9 @@
57305938
57315939 void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57325940 {
5941
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
5942
+ return;
5943
+
57335944 if (hide)
57345945 return;
57355946 // shadow optimisation
....@@ -5855,6 +6066,9 @@
58556066 if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
58566067 return; // no shadow for transparent objects
58576068
6069
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6070
+ return;
6071
+
58586072 if (hide)
58596073 return;
58606074
....@@ -5895,9 +6109,10 @@
58956109 return;
58966110 }
58976111
6112
+ //bRep.GenUV(1/material.diffuseness);
58986113 // bRep.lock = true;
58996114
5900
- javax.media.opengl.GL gl = display.GetGL();
6115
+ //javax.media.opengl.GL gl = display.GetGL();
59016116
59026117 if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera)
59036118 {
....@@ -5914,23 +6129,7 @@
59146129
59156130 bRep.getMinMax(min, max, 100);
59166131
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();
6132
+ display.DrawBox(min, max);
59346133
59356134 return;
59366135 }
....@@ -5984,178 +6183,14 @@
59846183 new Exception().printStackTrace();
59856184 return;
59866185 }
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
- }
6186
+
6187
+ display.DrawGeometry(bRep, flipV, selectmode);
61536188 } else // catch (Error e)
61546189 {
61556190 // TRIANGLE ARRAY
61566191 if (IsOpaque()) // Static())
61576192 {
6158
- gl.glBegin(gl.GL_TRIANGLES);
6193
+ display.StartTriangles();
61596194 int facecount = bRep.FaceCount();
61606195 for (int i = 0; i < facecount; i++)
61616196 {
....@@ -6220,7 +6255,7 @@
62206255
62216256 display.DrawFace(this, p, q, r, face);
62226257 }
6223
- gl.glEnd();
6258
+ display.EndTriangles();
62246259 }
62256260 else
62266261 {
....@@ -6249,8 +6284,8 @@
62496284 //System.out.println("SORT");
62506285
62516286 java.util.Arrays.sort(facescompare);
6252
-
6253
- gl.glBegin(gl.GL_TRIANGLES);
6287
+
6288
+ display.StartTriangles();
62546289 for (int i = 0; i < facecount; i++)
62556290 {
62566291 Face face = bRep.GetFace(facescompare[i].index);
....@@ -6264,11 +6299,12 @@
62646299
62656300 display.DrawFace(this, p, q, r, face);
62666301 }
6267
- gl.glEnd();
6302
+ display.EndTriangles();
62686303 }
62696304
62706305 if (false) // live && support != null && support.bRep != null) // debug weights
62716306 {
6307
+ /*
62726308 gl.glDisable(gl.GL_LIGHTING);
62736309 float[] colorV = new float[3];
62746310
....@@ -6347,6 +6383,7 @@
63476383 // gl.glEnd();
63486384 }
63496385 }
6386
+ */
63506387 }
63516388 }
63526389
....@@ -6405,22 +6442,6 @@
64056442 void Print(Vertex v)
64066443 {
64076444 //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);
64246445 }
64256446
64266447 void drawSelf(ClickInfo info, int level, boolean select)
....@@ -7031,8 +7052,8 @@
70317052 // {
70327053 // CameraPane.Ymax = spoth;
70337054 // }
7034
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7035
- info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7055
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7056
+ //info.g.drawLine(spotw, spoth, spotw - 15, spoth);
70367057 spot.translate(0, -32);
70377058 info.g.setColor(Color.green);
70387059 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
....@@ -7087,7 +7108,7 @@
70877108 startX = info.x;
70887109 startY = info.y;
70897110
7090
- hitSomething = 0;
7111
+ hitSomething = -1;
70917112 cVector origin = new cVector();
70927113 //LA.xformPos(origin, toParent, origin);
70937114 Rectangle spot = new Rectangle();
....@@ -7120,7 +7141,7 @@
71207141 }
71217142
71227143 //System.out.println("info.modifiers = " + info.modifiers);
7123
- modified = (info.modifiers & CameraPane.META) != 0;
7144
+ modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
71247145 //System.out.println("modified = " + modified);
71257146 //new Exception().printStackTrace();
71267147 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7148,7 +7169,7 @@
71487169 return true;
71497170 }
71507171
7151
- void doEditDrag0(ClickInfo info)
7172
+ void doEditDrag0(ClickInfo info, boolean opposite)
71527173 {
71537174 if (hitSomething == 0)
71547175 {
....@@ -7163,6 +7184,7 @@
71637184 //System.out.println("hitSomething = " + hitSomething);
71647185
71657186 double scale = 0.005f * info.camera.Distance();
7187
+
71667188 cVector xlate = new cVector();
71677189 //cVector xlate2 = new cVector();
71687190 switch (hitSomething)
....@@ -7175,7 +7197,7 @@
71757197
71767198 scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
71777199
7178
- if (modified)
7200
+ if (modified || opposite)
71797201 {
71807202 //assert(false);
71817203 /*
....@@ -7269,6 +7291,7 @@
72697291
72707292 if (modified)
72717293 {
7294
+ // Rotate 90 degrees
72727295 angle /= (Math.PI / 4);
72737296 angle = Math.floor(angle + 0.5);
72747297 angle *= (Math.PI / 4);
....@@ -7310,24 +7333,27 @@
73107333
73117334 case hitScale: // scale
73127335 double hScale = (double) (info.x - centerPt.x) / 32;
7336
+ double sign = 1;
7337
+ if (hScale < 0)
7338
+ {
7339
+ sign = -1;
7340
+ }
7341
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
73137342 if (hScale < 0.01)
73147343 {
7315
- hScale = 0.01;
7344
+ //hScale = 0.01;
73167345 }
7317
- hScale = Math.pow(hScale, scale * 50);
7318
- if (hScale < 0.01)
7319
- {
7320
- hScale = 0.01;
7321
- }
7346
+
73227347 double vScale = (double) (info.y - centerPt.y) / 32;
7323
- if (vScale < 0.01)
7348
+ sign = 1;
7349
+ if (vScale < 0)
73247350 {
7325
- vScale = 0.01;
7351
+ sign = -1;
73267352 }
7327
- vScale = Math.pow(vScale, scale * 50);
7353
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
73287354 if (vScale < 0.01)
73297355 {
7330
- vScale = 0.01;
7356
+ //vScale = 0.01;
73317357 }
73327358 LA.matCopy(startMat, toParent);
73337359 /**/
....@@ -7338,17 +7364,24 @@
73387364 }
73397365 /**/
73407366
7367
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7368
+
7369
+ if (totalScale < 0.01)
7370
+ {
7371
+ totalScale = 0.01;
7372
+ }
7373
+
73417374 switch (info.pane.RenderCamera().viewCode)
73427375 {
73437376 case 3: // '\001'
73447377 if (modified)
73457378 {
73467379 //LA.matScale(toParent, 1, hScale, vScale);
7347
- LA.matScale(toParent, vScale, 1, 1);
7380
+ LA.matScale(toParent, totalScale, 1, 1);
73487381 } // vScale, 1);
73497382 else
73507383 {
7351
- LA.matScale(toParent, vScale, vScale, vScale);
7384
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
73527385 } // vScale, 1);
73537386 break;
73547387
....@@ -7356,10 +7389,10 @@
73567389 if (modified)
73577390 {
73587391 //LA.matScale(toParent, hScale, 1, vScale);
7359
- LA.matScale(toParent, 1, vScale, 1);
7392
+ LA.matScale(toParent, 1, totalScale, 1);
73607393 } else
73617394 {
7362
- LA.matScale(toParent, vScale, 1, vScale);
7395
+ LA.matScale(toParent, totalScale, 1, totalScale);
73637396 }
73647397 break;
73657398
....@@ -7367,10 +7400,10 @@
73677400 if (modified)
73687401 {
73697402 //LA.matScale(toParent, hScale, vScale, 1);
7370
- LA.matScale(toParent, 1, 1, vScale);
7403
+ LA.matScale(toParent, 1, 1, totalScale);
73717404 } else
73727405 {
7373
- LA.matScale(toParent, vScale, vScale, 1);
7406
+ LA.matScale(toParent, totalScale, totalScale, 1);
73747407 }
73757408 break;
73767409 }
....@@ -7503,14 +7536,22 @@
75037536 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
75047537 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
75057538 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7539
+
7540
+ String objname;
7541
+
75067542 if (false) //parent != null)
75077543 {
7508
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7544
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
75097545 } else
75107546 {
7511
- return GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ") ")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ +System.identityHashCode(this);
7547
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
75127548 } // + super.toString();
75137549 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
7550
+
7551
+ if (!Globals.ADVANCED)
7552
+ return objname;
7553
+
7554
+ return objname + " " + System.identityHashCode(this);
75147555 }
75157556
75167557 public int hashCode()
....@@ -7566,6 +7607,7 @@
75667607 objectUI.closeUI();
75677608 if (editWindow != null)
75687609 {
7610
+ editWindow.ctrlPanel.FlushUI();
75697611 editWindow.refreshContents();
75707612 } // ? new
75717613 objectUI = null;
....@@ -7586,7 +7628,7 @@
75867628 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
75877629
75887630 Object3D /*Composite*/ parent;
7589
- Object3D /*Composite*/ fileparent;
7631
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
75907632
75917633 double[][] toParent; // dynamic matrix
75927634 double[][] fromParent;
....@@ -7701,7 +7743,7 @@
77017743 {
77027744 assert(bRep != null);
77037745 if (!(support instanceof GenericJoint)) // support.bRep != null)
7704
- GrafreeD.Assert(support.bRep == bRep.support);
7746
+ Grafreed.Assert(support.bRep == bRep.support);
77057747 }
77067748 else
77077749 {
....@@ -7750,9 +7792,9 @@
77507792 private static cVector edge2 = new cVector();
77517793 //private static cVector norm = new cVector();
77527794 /*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;
7795
+ static final int hitCenter = 1;
7796
+ static final int hitScale = 2;
7797
+ static final int hitRotate = 3;
77567798 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
77577799 /*transient*/ private Point centerPt;
77587800 /*transient*/ private int startX;