Normand Briere
2019-06-13 4629090fafbef256abd0686a85ee12042d658868
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,20 @@
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();
26
+
27
+ // TEMPORARY for mocap undo
28
+ mocap.reader.BVHReader.BVHResult bvh;
29
+ Object3D skeleton;
30
+ //
2131
2232 ScriptNode scriptnode;
2333
....@@ -99,64 +109,136 @@
99109
100110 // transient boolean reduced; // for morph reduction
101111
102
-transient com.bulletphysics.linearmath.Transform cache; // for fast merge
103
-transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
112
+ transient com.bulletphysics.linearmath.Transform cache; // for fast merge
113
+ transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
104114
105
-transient Object3D transientsupport; // for cloning
106
-transient boolean transientlink2master;
115
+ transient Object3D transientsupport; // for cloning
116
+ transient boolean transientlink2master;
107117
108
-void SaveSupports()
109
-{
110
- if (blockloop)
111
- return;
112
-
113
- transientsupport = support;
114
- transientlink2master = link2master;
115
-
116
- support = null;
117
- link2master = false;
118
-
119
- if (bRep != null)
118
+ void SaveSupports()
120119 {
121
- bRep.SaveSupports();
122
- }
123
-
124
- for (int i = 0; i < Size(); i++)
125
- {
126
- Object3D child = (Object3D) get(i);
127
- if (child == null)
128
- continue;
129
- blockloop = true;
130
- child.SaveSupports();
131
- blockloop = false;
132
- }
133
-}
120
+ if (blockloop)
121
+ return;
134122
135
-void RestoreSupports()
136
-{
137
- if (blockloop)
138
- return;
123
+ transientsupport = support;
124
+ transientlink2master = link2master;
139125
140
- support = transientsupport;
141
- link2master = transientlink2master;
142
- transientsupport = null;
143
- transientlink2master = false;
144
-
145
- if (bRep != null)
146
- {
147
- bRep.RestoreSupports();
126
+ support = null;
127
+ link2master = false;
128
+
129
+ if (bRep != null)
130
+ {
131
+ bRep.SaveSupports();
132
+ }
133
+
134
+ for (int i = 0; i < Size(); i++)
135
+ {
136
+ Object3D child = (Object3D) get(i);
137
+ if (child == null)
138
+ continue;
139
+ blockloop = true;
140
+ child.SaveSupports();
141
+ blockloop = false;
142
+ }
148143 }
149
-
150
- for (int i = 0; i < Size(); i++)
144
+
145
+ void RestoreSupports()
151146 {
152
- Object3D child = (Object3D) get(i);
153
- if (child == null)
154
- continue;
155
- blockloop = true;
156
- child.RestoreSupports();
157
- blockloop = false;
147
+ if (blockloop)
148
+ return;
149
+
150
+ support = transientsupport;
151
+ link2master = transientlink2master;
152
+ transientsupport = null;
153
+ transientlink2master = false;
154
+
155
+ if (bRep != null)
156
+ {
157
+ bRep.RestoreSupports();
158
+ }
159
+
160
+ for (int i = 0; i < Size(); i++)
161
+ {
162
+ Object3D child = (Object3D) get(i);
163
+ if (child == null)
164
+ continue;
165
+ blockloop = true;
166
+ child.RestoreSupports();
167
+ blockloop = false;
168
+ }
158169 }
159
-}
170
+
171
+ void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
172
+ {
173
+ if (hashtable.containsKey(GetUUID()))
174
+ {
175
+ Object3D o = hashtable.get(GetUUID());
176
+
177
+ assert(this.bRep == o.bRep);
178
+ if (this.bRep != null)
179
+ assert(this.bRep.support == o.transientrep);
180
+
181
+ return;
182
+ }
183
+
184
+ Object3D o = new Object3D();
185
+
186
+ hashtable.put(GetUUID(), o);
187
+
188
+ for (int i=0; i<Size(); i++)
189
+ {
190
+ get(i).ExtractBigData(hashtable);
191
+ }
192
+
193
+ ExtractBigData(o);
194
+ }
195
+
196
+ void ExtractBigData(Object3D o)
197
+ {
198
+ o.bRep = this.bRep;
199
+ if (this.bRep != null)
200
+ {
201
+ o.transientrep = this.bRep.support;
202
+ o.bRep.support = null;
203
+ }
204
+
205
+ // o.support = this.support;
206
+ // o.fileparent = this.fileparent;
207
+ // if (this.bRep != null)
208
+ // o.bRep = this.bRep.support;
209
+
210
+ this.bRep = null;
211
+ // if (this.bRep != null)
212
+ // this.bRep.support = null;
213
+ // this.support = null;
214
+ // this.fileparent = null;
215
+ }
216
+
217
+ void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
218
+ {
219
+ if (!hashtable.containsKey(GetUUID()))
220
+ return;
221
+
222
+ Object3D o = hashtable.get(GetUUID());
223
+
224
+ RestoreBigData(o);
225
+
226
+ hashtable.remove(GetUUID());
227
+
228
+ for (int i=0; i<Size(); i++)
229
+ {
230
+ get(i).RestoreBigData(hashtable);
231
+ }
232
+ }
233
+
234
+ void RestoreBigData(Object3D o)
235
+ {
236
+ this.bRep = o.bRep;
237
+ if (this.bRep != null)
238
+ this.bRep.support = o.transientrep;
239
+ // this.support = o.support;
240
+ // this.fileparent = o.fileparent;
241
+ }
160242
161243 // MOCAP SUPPORT
162244 double tx,ty,tz,rx,ry,rz;
....@@ -299,6 +381,7 @@
299381 }
300382
301383 boolean live = false;
384
+ boolean dontselect = false;
302385 boolean hide = false;
303386 boolean link2master = false; // performs reset support/master at each frame
304387 boolean marked = false; // animation node
....@@ -773,7 +856,7 @@
773856 if (step == 0)
774857 step = 1;
775858 if (maxcount == 0)
776
- maxcount = 2048; // 4;
859
+ maxcount = 128; // 2048; // 4;
777860 // if (acceleration == 0)
778861 // acceleration = 10;
779862 if (delay == 0) // serial
....@@ -796,7 +879,7 @@
796879
797880 if (marked && Globals.isLIVE() && live &&
798881 //TEMP21aug2018
799
- Globals.DrawMode() == iCameraPane.SHADOW &&
882
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
800883 currentframe != Globals.framecount)
801884 {
802885 currentframe = Globals.framecount;
....@@ -911,6 +994,11 @@
911994 fromParent = null; // LA.newMatrix();
912995 bRep = null; // new BoundaryRep();
913996
997
+ if (oname != null && oname.equals("LeftHand"))
998
+ {
999
+ name = oname;
1000
+ }
1001
+
9141002 /*
9151003 float hue = (float)Math.random();
9161004 Color col;
....@@ -953,7 +1041,7 @@
9531041
9541042 public Object clone()
9551043 {
956
- return GrafreeD.clone(this);
1044
+ return Grafreed.clone(this);
9571045 }
9581046
9591047 Object3D copyExpand()
....@@ -1469,7 +1557,7 @@
14691557 BoundaryRep.SEUIL = other.material.cameralight;
14701558
14711559 // Set default to 0.1
1472
- BoundaryRep.SEUIL /= 2;
1560
+ BoundaryRep.SEUIL /= 4; // 2;
14731561 System.out.println("SEUIL = " + BoundaryRep.SEUIL);
14741562 }
14751563
....@@ -1728,7 +1816,7 @@
17281816 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17291817 o.bRep = transientrep;
17301818 if (clone)
1731
- o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
1819
+ o.bRep = (BoundaryRep) Grafreed.clone(transientrep);
17321820 o.CreateMaterial();
17331821 o.SetAttributes(this, -1);
17341822 //parent
....@@ -1741,7 +1829,7 @@
17411829 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17421830 o.bRep = bRep;
17431831 if (clone)
1744
- o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
1832
+ o.bRep = (BoundaryRep) Grafreed.clone(bRep);
17451833 o.CreateMaterial();
17461834 //o.overwriteThis(this, -1);
17471835 o.SetAttributes(this, -1);
....@@ -1828,12 +1916,15 @@
18281916 if (obj.name == null)
18291917 continue; // can't be a null one
18301918
1919
+ // Try perfect match first.
18311920 if (n.equals(obj.name))
18321921 {
18331922 theobj = obj;
18341923 count++;
18351924 }
18361925 }
1926
+
1927
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18371928
18381929 if (count != 1)
18391930 for (int i=Size(); --i>=0;)
....@@ -2299,6 +2390,7 @@
22992390 {
23002391 if (newWindow)
23012392 {
2393
+ new Exception().printStackTrace();
23022394 System.exit(0);
23032395 if (parent != null)
23042396 {
....@@ -2475,13 +2567,13 @@
24752567 return retval;
24762568 }
24772569
2478
- void doEditDrag(ClickInfo info)
2570
+ void doEditDrag(ClickInfo info, boolean opposite)
24792571 {
24802572 switch (doSomething)
24812573 {
24822574 case 1: // '\001'
24832575 //super.
2484
- doEditDrag0(info);
2576
+ doEditDrag0(info, opposite);
24852577 break;
24862578
24872579 case 2: // '\002'
....@@ -2494,11 +2586,11 @@
24942586 {
24952587 //sel.hitSomething = childToDrag.hitSomething;
24962588 //childToDrag.doEditDrag(info);
2497
- sel.doEditDrag(info);
2589
+ sel.doEditDrag(info, opposite);
24982590 } else
24992591 {
25002592 //super.
2501
- doEditDrag0(info);
2593
+ doEditDrag0(info, opposite);
25022594 }
25032595 }
25042596 break;
....@@ -2608,6 +2700,18 @@
26082700 void GenNormalsS(boolean crease)
26092701 {
26102702 selection.GenNormals(crease);
2703
+// for (int i=0; i<selection.size(); i++)
2704
+// {
2705
+// Object3D selectee = (Object3D) selection.elementAt(i);
2706
+// selectee.GenNormals(crease);
2707
+// }
2708
+
2709
+ //Touch();
2710
+ }
2711
+
2712
+ void GenNormalsMeshS()
2713
+ {
2714
+ selection.GenNormalsMesh();
26112715 // for (int i=0; i<selection.size(); i++)
26122716 // {
26132717 // Object3D selectee = (Object3D) selection.elementAt(i);
....@@ -2748,6 +2852,24 @@
27482852 if (child == null)
27492853 continue;
27502854 child.GenNormals(crease);
2855
+// Children().release(i);
2856
+ }
2857
+ blockloop = false;
2858
+ }
2859
+
2860
+ void GenNormalsMesh()
2861
+ {
2862
+ if (blockloop)
2863
+ return;
2864
+
2865
+ blockloop = true;
2866
+ GenNormalsMesh0();
2867
+ for (int i = 0; i < Children().Size(); i++)
2868
+ {
2869
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2870
+ if (child == null)
2871
+ continue;
2872
+ child.GenNormalsMesh();
27512873 // Children().release(i);
27522874 }
27532875 blockloop = false;
....@@ -2905,7 +3027,8 @@
29053027 {
29063028 if (bRep != null)
29073029 {
2908
- bRep.GenUV();
3030
+ bRep.GenUV(); //1);
3031
+ //bRep.UnfoldUV();
29093032 Touch();
29103033 }
29113034 }
....@@ -2915,6 +3038,15 @@
29153038 if (bRep != null)
29163039 {
29173040 bRep.GenerateNormals(crease);
3041
+ Touch();
3042
+ }
3043
+ }
3044
+
3045
+ void GenNormalsMesh0()
3046
+ {
3047
+ if (bRep != null)
3048
+ {
3049
+ bRep.GenerateNormalsMesh();
29183050 Touch();
29193051 }
29203052 }
....@@ -2980,6 +3112,33 @@
29803112 blockloop = false;
29813113 }
29823114
3115
+ void TransformChildren()
3116
+ {
3117
+ if (toParent != null)
3118
+ {
3119
+ for (int i=Size(); --i>=0;)
3120
+ {
3121
+ Object3D v = get(i);
3122
+
3123
+ if (v.toParent == null)
3124
+ {
3125
+ v.toParent = LA.newMatrix();
3126
+ v.fromParent = LA.newMatrix();
3127
+ }
3128
+
3129
+// LA.matConcat(v.toParent, toParent, v.toParent);
3130
+// LA.matConcat(fromParent, v.fromParent, v.fromParent);
3131
+ LA.matConcat(toParent, v.toParent, v.toParent);
3132
+ LA.matConcat(v.fromParent, fromParent, v.fromParent);
3133
+ }
3134
+
3135
+ toParent = null; // LA.matIdentity(toParent);
3136
+ fromParent = null; // LA.matIdentity(fromParent);
3137
+
3138
+ Touch();
3139
+ }
3140
+ }
3141
+
29833142 void TransformGeometry()
29843143 {
29853144 Object3D obj = this;
....@@ -3201,9 +3360,11 @@
32013360
32023361 BoundaryRep sup = bRep.support;
32033362 bRep.support = null;
3204
- BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
3363
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
32053364 // bRep.SplitInTwo(onlyone); // thread...
3206
- temprep.SplitInTwo(reduction34, onlyone);
3365
+
3366
+ while(temprep.SplitInTwo(reduction34, onlyone));
3367
+
32073368 bRep = temprep;
32083369 bRep.support = sup;
32093370 Touch();
....@@ -3725,7 +3886,7 @@
37253886 if (child == null)
37263887 continue;
37273888
3728
- if (GrafreeD.RENDERME > 0)
3889
+ if (Grafreed.RENDERME > 0)
37293890 {
37303891 if (child instanceof Merge)
37313892 ((Merge)child).renderme();
....@@ -3876,7 +4037,7 @@
38764037 if (child == null)
38774038 continue;
38784039
3879
- if (GrafreeD.RENDERME > 0)
4040
+ if (Grafreed.RENDERME > 0)
38804041 {
38814042 if (child instanceof Merge)
38824043 ((Merge)child).renderme();
....@@ -4071,7 +4232,7 @@
40714232 if (child == null)
40724233 continue;
40734234
4074
- if (GrafreeD.RENDERME > 0)
4235
+ if (Grafreed.RENDERME > 0)
40754236 {
40764237 if (child instanceof Merge)
40774238 ((Merge)child).renderme();
....@@ -4678,7 +4839,7 @@
46784839
46794840 cTreePath SelectLeaf(int indexcount, boolean deselect)
46804841 {
4681
- if (hide)
4842
+ if (hide || dontselect)
46824843 return null;
46834844
46844845 if (count <= 0)
....@@ -4704,7 +4865,7 @@
47044865
47054866 cTreePath Select(int indexcount, boolean deselect)
47064867 {
4707
- if (hide)
4868
+ if (hide || dontselect)
47084869 return null;
47094870
47104871 if (count <= 0)
....@@ -5156,10 +5317,34 @@
51565317
51575318 // System.out.println("Fullname = " + fullname);
51585319
5159
- if (fullname.name.indexOf(":") == -1)
5160
- return fullname.name;
5320
+ // Does not work on Windows due to C:
5321
+// if (fullname.name.indexOf(":") == -1)
5322
+// return fullname.name;
5323
+//
5324
+// return fullname.name.substring(0,fullname.name.indexOf(":"));
51615325
5162
- return fullname.name.substring(0,fullname.name.indexOf(":"));
5326
+ String[] split = fullname.name.split(":");
5327
+
5328
+ if (split.length == 0)
5329
+ {
5330
+ return "";
5331
+ }
5332
+
5333
+ if (split.length <= 2)
5334
+ {
5335
+ if (fullname.name.endsWith(":"))
5336
+ {
5337
+ // Windows
5338
+ return fullname.name.substring(0, fullname.name.length()-1);
5339
+ }
5340
+
5341
+ return split[0];
5342
+ }
5343
+
5344
+ // Windows
5345
+ assert(split.length == 4);
5346
+
5347
+ return split[0] + ":" + split[1];
51635348 }
51645349
51655350 static String GetBump(cTexture fullname)
....@@ -5168,10 +5353,38 @@
51685353 return "";
51695354
51705355 // 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());
5356
+ // Does not work on Windows due to C:
5357
+// if (fullname.name.indexOf(":") == -1)
5358
+// return "";
5359
+//
5360
+// return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5361
+ String[] split = fullname.name.split(":");
5362
+
5363
+ if (split.length == 0)
5364
+ {
5365
+ return "";
5366
+ }
5367
+
5368
+ if (split.length == 1)
5369
+ {
5370
+ return "";
5371
+ }
5372
+
5373
+ if (split.length == 2)
5374
+ {
5375
+ if (fullname.name.endsWith(":"))
5376
+ {
5377
+ // Windows
5378
+ return "";
5379
+ }
5380
+
5381
+ return split[1];
5382
+ }
5383
+
5384
+ // Windows
5385
+ assert(split.length == 4);
5386
+
5387
+ return split[2] + ":" + split[3];
51755388 }
51765389
51775390 String GetPigmentTexture()
....@@ -5245,7 +5458,7 @@
52455458 System.out.print("; textures = " + textures);
52465459 System.out.println("; usedtextures = " + usedtextures);
52475460
5248
- if (GetTextures() == null)
5461
+ if (GetTextures() == null) // What is that??
52495462 GetTextures().name = ":";
52505463
52515464 String texname = tex;
....@@ -5276,6 +5489,43 @@
52765489 child.ResetPigmentTexture();
52775490 blockloop = false;
52785491 }
5492
+ }
5493
+
5494
+ UUID GetUUID()
5495
+ {
5496
+ if (uuid == null)
5497
+ {
5498
+ // Serial
5499
+ uuid = UUID.randomUUID();
5500
+ }
5501
+
5502
+ return uuid;
5503
+ }
5504
+
5505
+ Object3D GetObject(UUID uid)
5506
+ {
5507
+ if (blockloop)
5508
+ return null;
5509
+
5510
+ if (GetUUID().equals(uid))
5511
+ return this;
5512
+
5513
+ int nb = Size();
5514
+ for (int i = 0; i < nb; i++)
5515
+ {
5516
+ Object3D child = (Object3D) get(i);
5517
+
5518
+ if (child == null)
5519
+ continue;
5520
+
5521
+ blockloop = true;
5522
+ Object3D obj = child.GetObject(uid);
5523
+ blockloop = false;
5524
+ if (obj != null)
5525
+ return obj;
5526
+ }
5527
+
5528
+ return null;
52795529 }
52805530
52815531 void SetBumpTexture(String tex)
....@@ -5322,9 +5572,9 @@
53225572 boolean NeedSupport()
53235573 {
53245574 return
5325
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5575
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null
53265576 // PROBLEM with CROWD!!
5327
- && (Globals.DrawMode() == iCameraPane.SHADOW || Globals.CROWD);
5577
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
53285578 }
53295579
53305580 static boolean DEBUG_SELECTION = false;
....@@ -5339,7 +5589,7 @@
53395589 }
53405590
53415591 if (display.DrawMode() == iCameraPane.SELECTION &&
5342
- hide)
5592
+ (hide || dontselect))
53435593 return;
53445594
53455595 if (name != null && name.contains("sclera"))
....@@ -5371,7 +5621,7 @@
53715621 return;
53725622 }
53735623
5374
- javax.media.opengl.GL gl = display.GetGL();
5624
+ //javax.media.opengl.GL gl = display.GetGL();
53755625
53765626 /*
53775627 if (touched)
....@@ -5423,7 +5673,7 @@
54235673 //if (displaylist == -1 && usecalllists)
54245674 if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
54255675 {
5426
- bRep.displaylist = gl.glGenLists(1);
5676
+ bRep.displaylist = display.GenList();
54275677 assert(bRep.displaylist != 0);
54285678 // System.err.println("glGenLists: " + bRep.displaylist + " for " + this);
54295679 //System.out.println("\tgen list " + list);
....@@ -5435,14 +5685,16 @@
54355685 if (usecalllists)
54365686 {
54375687 // System.err.println("new list " + bRep.displaylist + " for " + this);
5438
- gl.glNewList(bRep.displaylist, gl.GL_COMPILE); //_AND_EXECUTE);
5688
+ display.NewList(bRep.displaylist);
54395689 }
5690
+
54405691 CallList(display, root, selected, blocked);
5692
+
54415693 // compiled = true;
54425694 if (usecalllists)
54435695 {
54445696 // System.err.println("end list " + bRep.displaylist + " for " + this);
5445
- gl.glEndList();
5697
+ display.EndList();
54465698 }
54475699 //gl.glDrawBuffer(gl.GL_BACK);
54485700 // XXX touched = false;
....@@ -5490,7 +5742,7 @@
54905742 if (display.DrawMode() == iCameraPane.SHADOW)
54915743 {
54925744 if (!link2master // tricky to cull in shadow mode.
5493
- && GetBRep().FrustumCull(this, gl, display.LightCamera(), true))
5745
+ && GetBRep().FrustumCull(this, null, display.LightCamera(), true))
54945746 {
54955747 //System.out.print("CULLED");
54965748 culled = true;
....@@ -5498,7 +5750,7 @@
54985750 }
54995751 else
55005752 //GetBRep().getBounds(v0, v1, this);
5501
- if (GetBRep().FrustumCull(this, gl, display.RenderCamera(), false))
5753
+ if (GetBRep().FrustumCull(this, null, display.RenderCamera(), false))
55025754 culled = true;
55035755
55045756 // LA.xformPos(v0, display.renderCamera.toScreen, v0);
....@@ -5538,7 +5790,7 @@
55385790 {
55395791 if (GetBRep() != null)
55405792 {
5541
- CameraPane.NextIndex(this, gl);
5793
+ display.NextIndex();
55425794 // vertex color conflict : gl.glCallList(list);
55435795 DrawNode(display, root, selected);
55445796 if (this instanceof BezierPatch)
....@@ -5579,7 +5831,17 @@
55795831 tex = GetTextures();
55805832 }
55815833
5582
- display.BindTextures(tex, texres);
5834
+ boolean failed = false;
5835
+
5836
+ try
5837
+ {
5838
+ display.BindTextures(tex, texres);
5839
+ }
5840
+ catch (Exception e)
5841
+ {
5842
+ System.err.println("FAILED: " + this);
5843
+ failed = true;
5844
+ }
55835845
55845846 if (!compiled)
55855847 {
....@@ -5595,13 +5857,14 @@
55955857
55965858 // System.err.println("glCallList: " + bRep.displaylist + " for " + this);
55975859 assert(bRep.displaylist != 0);
5598
- gl.glCallList(bRep.displaylist);
5860
+ display.CallList(bRep.displaylist);
55995861 // june 2013 drawSelf(display, root, selected);
56005862 }
56015863 }
56025864 }
56035865
5604
- display.ReleaseTextures(tex);
5866
+ if (!failed)
5867
+ display.ReleaseTextures(tex);
56055868
56065869 display.PopMaterial(this, selected);
56075870 }
....@@ -5730,6 +5993,9 @@
57305993
57315994 void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57325995 {
5996
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
5997
+ return;
5998
+
57335999 if (hide)
57346000 return;
57356001 // shadow optimisation
....@@ -5855,6 +6121,9 @@
58556121 if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
58566122 return; // no shadow for transparent objects
58576123
6124
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6125
+ return;
6126
+
58586127 if (hide)
58596128 return;
58606129
....@@ -5895,9 +6164,10 @@
58956164 return;
58966165 }
58976166
6167
+ //bRep.GenUV(1/material.diffuseness);
58986168 // bRep.lock = true;
58996169
5900
- javax.media.opengl.GL gl = display.GetGL();
6170
+ //javax.media.opengl.GL gl = display.GetGL();
59016171
59026172 if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera)
59036173 {
....@@ -5914,23 +6184,7 @@
59146184
59156185 bRep.getMinMax(min, max, 100);
59166186
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();
6187
+ display.DrawBox(min, max);
59346188
59356189 return;
59366190 }
....@@ -5984,178 +6238,14 @@
59846238 new Exception().printStackTrace();
59856239 return;
59866240 }
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
- }
6241
+
6242
+ display.DrawGeometry(bRep, flipV, selectmode);
61536243 } else // catch (Error e)
61546244 {
61556245 // TRIANGLE ARRAY
61566246 if (IsOpaque()) // Static())
61576247 {
6158
- gl.glBegin(gl.GL_TRIANGLES);
6248
+ display.StartTriangles();
61596249 int facecount = bRep.FaceCount();
61606250 for (int i = 0; i < facecount; i++)
61616251 {
....@@ -6220,7 +6310,7 @@
62206310
62216311 display.DrawFace(this, p, q, r, face);
62226312 }
6223
- gl.glEnd();
6313
+ display.EndTriangles();
62246314 }
62256315 else
62266316 {
....@@ -6249,8 +6339,8 @@
62496339 //System.out.println("SORT");
62506340
62516341 java.util.Arrays.sort(facescompare);
6252
-
6253
- gl.glBegin(gl.GL_TRIANGLES);
6342
+
6343
+ display.StartTriangles();
62546344 for (int i = 0; i < facecount; i++)
62556345 {
62566346 Face face = bRep.GetFace(facescompare[i].index);
....@@ -6264,11 +6354,12 @@
62646354
62656355 display.DrawFace(this, p, q, r, face);
62666356 }
6267
- gl.glEnd();
6357
+ display.EndTriangles();
62686358 }
62696359
62706360 if (false) // live && support != null && support.bRep != null) // debug weights
62716361 {
6362
+ /*
62726363 gl.glDisable(gl.GL_LIGHTING);
62736364 float[] colorV = new float[3];
62746365
....@@ -6347,6 +6438,7 @@
63476438 // gl.glEnd();
63486439 }
63496440 }
6441
+ */
63506442 }
63516443 }
63526444
....@@ -6405,22 +6497,6 @@
64056497 void Print(Vertex v)
64066498 {
64076499 //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);
64246500 }
64256501
64266502 void drawSelf(ClickInfo info, int level, boolean select)
....@@ -7031,8 +7107,8 @@
70317107 // {
70327108 // CameraPane.Ymax = spoth;
70337109 // }
7034
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7035
- info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7110
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7111
+ //info.g.drawLine(spotw, spoth, spotw - 15, spoth);
70367112 spot.translate(0, -32);
70377113 info.g.setColor(Color.green);
70387114 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
....@@ -7087,7 +7163,7 @@
70877163 startX = info.x;
70887164 startY = info.y;
70897165
7090
- hitSomething = 0;
7166
+ hitSomething = -1;
70917167 cVector origin = new cVector();
70927168 //LA.xformPos(origin, toParent, origin);
70937169 Rectangle spot = new Rectangle();
....@@ -7120,7 +7196,7 @@
71207196 }
71217197
71227198 //System.out.println("info.modifiers = " + info.modifiers);
7123
- modified = (info.modifiers & CameraPane.META) != 0;
7199
+ modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
71247200 //System.out.println("modified = " + modified);
71257201 //new Exception().printStackTrace();
71267202 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7148,7 +7224,7 @@
71487224 return true;
71497225 }
71507226
7151
- void doEditDrag0(ClickInfo info)
7227
+ void doEditDrag0(ClickInfo info, boolean opposite)
71527228 {
71537229 if (hitSomething == 0)
71547230 {
....@@ -7163,6 +7239,7 @@
71637239 //System.out.println("hitSomething = " + hitSomething);
71647240
71657241 double scale = 0.005f * info.camera.Distance();
7242
+
71667243 cVector xlate = new cVector();
71677244 //cVector xlate2 = new cVector();
71687245 switch (hitSomething)
....@@ -7175,7 +7252,7 @@
71757252
71767253 scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
71777254
7178
- if (modified)
7255
+ if (modified || opposite)
71797256 {
71807257 //assert(false);
71817258 /*
....@@ -7269,6 +7346,7 @@
72697346
72707347 if (modified)
72717348 {
7349
+ // Rotate 90 degrees
72727350 angle /= (Math.PI / 4);
72737351 angle = Math.floor(angle + 0.5);
72747352 angle *= (Math.PI / 4);
....@@ -7310,24 +7388,27 @@
73107388
73117389 case hitScale: // scale
73127390 double hScale = (double) (info.x - centerPt.x) / 32;
7391
+ double sign = 1;
7392
+ if (hScale < 0)
7393
+ {
7394
+ sign = -1;
7395
+ }
7396
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
73137397 if (hScale < 0.01)
73147398 {
7315
- hScale = 0.01;
7399
+ //hScale = 0.01;
73167400 }
7317
- hScale = Math.pow(hScale, scale * 50);
7318
- if (hScale < 0.01)
7319
- {
7320
- hScale = 0.01;
7321
- }
7401
+
73227402 double vScale = (double) (info.y - centerPt.y) / 32;
7323
- if (vScale < 0.01)
7403
+ sign = 1;
7404
+ if (vScale < 0)
73247405 {
7325
- vScale = 0.01;
7406
+ sign = -1;
73267407 }
7327
- vScale = Math.pow(vScale, scale * 50);
7408
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
73287409 if (vScale < 0.01)
73297410 {
7330
- vScale = 0.01;
7411
+ //vScale = 0.01;
73317412 }
73327413 LA.matCopy(startMat, toParent);
73337414 /**/
....@@ -7338,17 +7419,24 @@
73387419 }
73397420 /**/
73407421
7422
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7423
+
7424
+ if (totalScale < 0.01)
7425
+ {
7426
+ totalScale = 0.01;
7427
+ }
7428
+
73417429 switch (info.pane.RenderCamera().viewCode)
73427430 {
73437431 case 3: // '\001'
73447432 if (modified)
73457433 {
73467434 //LA.matScale(toParent, 1, hScale, vScale);
7347
- LA.matScale(toParent, vScale, 1, 1);
7435
+ LA.matScale(toParent, totalScale, 1, 1);
73487436 } // vScale, 1);
73497437 else
73507438 {
7351
- LA.matScale(toParent, vScale, vScale, vScale);
7439
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
73527440 } // vScale, 1);
73537441 break;
73547442
....@@ -7356,10 +7444,10 @@
73567444 if (modified)
73577445 {
73587446 //LA.matScale(toParent, hScale, 1, vScale);
7359
- LA.matScale(toParent, 1, vScale, 1);
7447
+ LA.matScale(toParent, 1, totalScale, 1);
73607448 } else
73617449 {
7362
- LA.matScale(toParent, vScale, 1, vScale);
7450
+ LA.matScale(toParent, totalScale, 1, totalScale);
73637451 }
73647452 break;
73657453
....@@ -7367,10 +7455,10 @@
73677455 if (modified)
73687456 {
73697457 //LA.matScale(toParent, hScale, vScale, 1);
7370
- LA.matScale(toParent, 1, 1, vScale);
7458
+ LA.matScale(toParent, 1, 1, totalScale);
73717459 } else
73727460 {
7373
- LA.matScale(toParent, vScale, vScale, 1);
7461
+ LA.matScale(toParent, totalScale, totalScale, 1);
73747462 }
73757463 break;
73767464 }
....@@ -7503,14 +7591,22 @@
75037591 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
75047592 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
75057593 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7594
+
7595
+ String objname;
7596
+
75067597 if (false) //parent != null)
75077598 {
7508
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7599
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
75097600 } else
75107601 {
7511
- return GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ") ")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ +System.identityHashCode(this);
7602
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
75127603 } // + super.toString();
75137604 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
7605
+
7606
+ if (!Globals.ADVANCED)
7607
+ return objname;
7608
+
7609
+ return objname + " " + System.identityHashCode(this);
75147610 }
75157611
75167612 public int hashCode()
....@@ -7566,6 +7662,7 @@
75667662 objectUI.closeUI();
75677663 if (editWindow != null)
75687664 {
7665
+ editWindow.ctrlPanel.FlushUI();
75697666 editWindow.refreshContents();
75707667 } // ? new
75717668 objectUI = null;
....@@ -7586,7 +7683,7 @@
75867683 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
75877684
75887685 Object3D /*Composite*/ parent;
7589
- Object3D /*Composite*/ fileparent;
7686
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
75907687
75917688 double[][] toParent; // dynamic matrix
75927689 double[][] fromParent;
....@@ -7701,7 +7798,7 @@
77017798 {
77027799 assert(bRep != null);
77037800 if (!(support instanceof GenericJoint)) // support.bRep != null)
7704
- GrafreeD.Assert(support.bRep == bRep.support);
7801
+ Grafreed.Assert(support.bRep == bRep.support);
77057802 }
77067803 else
77077804 {
....@@ -7750,9 +7847,9 @@
77507847 private static cVector edge2 = new cVector();
77517848 //private static cVector norm = new cVector();
77527849 /*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;
7850
+ static final int hitCenter = 1;
7851
+ static final int hitScale = 2;
7852
+ static final int hitRotate = 3;
77567853 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
77577854 /*transient*/ private Point centerPt;
77587855 /*transient*/ private int startX;