Normand Briere
2019-07-20 0a52bd4800459cd9935f360d7ca9555b6bea2146
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,12 +14,24 @@
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;
2124
25
+ private UUID uuid = UUID.randomUUID();
26
+
27
+ // TEMPORARY for mocap undo. No need to be transient.
28
+ mocap.reader.BVHReader.BVHResult savebvh;
29
+ Object3D saveskeleton;
30
+ //
31
+
32
+ byte[] versions[];
33
+ int versionindex = -1;
34
+
2235 ScriptNode scriptnode;
2336
2437 void InitOthers()
....@@ -99,64 +112,178 @@
99112
100113 // transient boolean reduced; // for morph reduction
101114
102
-transient com.bulletphysics.linearmath.Transform cache; // for fast merge
103
-transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
115
+ transient com.bulletphysics.linearmath.Transform cache; // for fast merge
116
+ transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
104117
105
-transient Object3D transientsupport; // for cloning
106
-transient boolean transientlink2master;
118
+ transient Object3D transientsupport; // for cloning
119
+ transient boolean transientlink2master;
107120
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)
121
+ void SaveSupports()
120122 {
121
- bRep.SaveSupports();
123
+ if (blockloop)
124
+ return;
125
+
126
+ transientsupport = support;
127
+ transientlink2master = link2master;
128
+
129
+ support = null;
130
+ link2master = false;
131
+
132
+ if (bRep != null)
133
+ {
134
+ bRep.SaveSupports();
135
+ }
136
+
137
+ for (int i = 0; i < Size(); i++)
138
+ {
139
+ Object3D child = (Object3D) get(i);
140
+ if (child == null)
141
+ continue;
142
+ blockloop = true;
143
+ child.SaveSupports();
144
+ blockloop = false;
145
+ }
122146 }
123
-
124
- for (int i = 0; i < Size(); i++)
147
+
148
+ void RestoreSupports()
125149 {
126
- Object3D child = (Object3D) get(i);
127
- if (child == null)
128
- continue;
150
+ if (blockloop)
151
+ return;
152
+
153
+ support = transientsupport;
154
+ link2master = transientlink2master;
155
+ transientsupport = null;
156
+ transientlink2master = false;
157
+
158
+ if (bRep != null)
159
+ {
160
+ bRep.RestoreSupports();
161
+ }
162
+
163
+ for (int i = 0; i < Size(); i++)
164
+ {
165
+ Object3D child = (Object3D) get(i);
166
+ if (child == null)
167
+ continue;
168
+ blockloop = true;
169
+ child.RestoreSupports();
170
+ blockloop = false;
171
+ }
172
+ }
173
+
174
+ void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
175
+ {
176
+ Object3D o;
177
+
178
+ if (hashtable.containsKey(GetUUID()))
179
+ {
180
+ o = hashtable.get(GetUUID());
181
+
182
+ Grafreed.Assert(this.bRep == o.bRep);
183
+ //if (this.bRep != null)
184
+ // assert(this.bRep.support == o.transientrep);
185
+ if (this.support != null)
186
+ assert(this.support.bRep == o.transientrep);
187
+ }
188
+ else
189
+ {
190
+ o = new Object3D("copy of " + this.name);
191
+
192
+ hashtable.put(GetUUID(), o);
193
+ }
194
+
195
+ if (!blockloop)
196
+ {
197
+ blockloop = true;
198
+
199
+ for (int i=0; i<Size(); i++)
200
+ {
201
+ get(i).ExtractBigData(hashtable);
202
+ }
203
+
204
+ blockloop = false;
205
+ }
206
+
207
+ ExtractBigData(o);
208
+ }
209
+
210
+ void ExtractBigData(Object3D o)
211
+ {
212
+ if (o.bRep != null)
213
+ Grafreed.Assert(o.bRep == this.bRep);
214
+
215
+ o.bRep = this.bRep;
216
+// July 2019 if (this.bRep != null)
217
+// {
218
+// o.transientrep = this.bRep.support;
219
+// o.bRep.support = null;
220
+// }
221
+ o.selection = this.selection;
222
+ o.versions = this.versions;
223
+ o.versionindex = this.versionindex;
224
+
225
+ if (this.support != null)
226
+ {
227
+ if (o.transientrep != null)
228
+ Grafreed.Assert(o.transientrep == this.support.bRep);
229
+
230
+ o.transientrep = this.support.bRep;
231
+ this.support.bRep = null;
232
+ }
233
+
234
+ // o.support = this.support;
235
+ // o.fileparent = this.fileparent;
236
+ // if (this.bRep != null)
237
+ // o.bRep = this.bRep.support;
238
+
239
+ this.bRep = null;
240
+ // if (this.bRep != null)
241
+ // this.bRep.support = null;
242
+ // this.support = null;
243
+ // this.fileparent = null;
244
+ }
245
+
246
+ void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
247
+ {
248
+ if (!hashtable.containsKey(GetUUID()))
249
+ return;
250
+
251
+ Object3D o = hashtable.get(GetUUID());
252
+
253
+ RestoreBigData(o);
254
+
255
+ if (blockloop)
256
+ return;
257
+
129258 blockloop = true;
130
- child.SaveSupports();
259
+
260
+ //hashtable.remove(GetUUID());
261
+
262
+ for (int i=0; i<Size(); i++)
263
+ {
264
+ get(i).RestoreBigData(hashtable);
265
+ }
266
+
131267 blockloop = false;
132268 }
133
-}
134269
135
-void RestoreSupports()
136
-{
137
- if (blockloop)
138
- return;
139
-
140
- support = transientsupport;
141
- link2master = transientlink2master;
142
- transientsupport = null;
143
- transientlink2master = false;
144
-
145
- if (bRep != null)
270
+ void RestoreBigData(Object3D o)
146271 {
147
- bRep.RestoreSupports();
272
+ this.bRep = o.bRep;
273
+ if (this.support != null && o.transientrep != null)
274
+ {
275
+ this.support.bRep = o.transientrep;
276
+ }
277
+
278
+ this.selection = o.selection;
279
+
280
+ this.versions = o.versions;
281
+ this.versionindex = o.versionindex;
282
+// July 2019 if (this.bRep != null)
283
+// this.bRep.support = o.transientrep;
284
+ // this.support = o.support;
285
+ // this.fileparent = o.fileparent;
148286 }
149
-
150
- for (int i = 0; i < Size(); i++)
151
- {
152
- Object3D child = (Object3D) get(i);
153
- if (child == null)
154
- continue;
155
- blockloop = true;
156
- child.RestoreSupports();
157
- blockloop = false;
158
- }
159
-}
160287
161288 // MOCAP SUPPORT
162289 double tx,ty,tz,rx,ry,rz;
....@@ -299,6 +426,8 @@
299426 }
300427
301428 boolean live = false;
429
+ transient boolean keepdontselect;
430
+ boolean dontselect = false;
302431 boolean hide = false;
303432 boolean link2master = false; // performs reset support/master at each frame
304433 boolean marked = false; // animation node
....@@ -480,12 +609,14 @@
480609 toParent = LA.newMatrix();
481610 fromParent = LA.newMatrix();
482611 }
612
+
483613 if (toParentMarked == null)
484614 {
485615 if (maxcount != 1)
486616 {
487617 new Exception().printStackTrace();
488618 }
619
+
489620 toParentMarked = LA.newMatrix();
490621 fromParentMarked = LA.newMatrix();
491622 }
....@@ -773,7 +904,7 @@
773904 if (step == 0)
774905 step = 1;
775906 if (maxcount == 0)
776
- maxcount = 2048; // 4;
907
+ maxcount = 128; // 2048; // 4;
777908 // if (acceleration == 0)
778909 // acceleration = 10;
779910 if (delay == 0) // serial
....@@ -796,7 +927,7 @@
796927
797928 if (marked && Globals.isLIVE() && live &&
798929 //TEMP21aug2018
799
- Globals.DrawMode() == iCameraPane.SHADOW &&
930
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
800931 currentframe != Globals.framecount)
801932 {
802933 currentframe = Globals.framecount;
....@@ -808,7 +939,8 @@
808939
809940 boolean changedir = random && Math.random() < 0.01; // && !link2master;
810941
811
- if (transformcount*factor > maxcount || (step == 1 && changedir))
942
+ if (transformcount*factor >= maxcount && (rewind || random) ||
943
+ (step == 1 && changedir))
812944 {
813945 countdown = 1;
814946 delay = speedup?8:1;
....@@ -880,6 +1012,7 @@
8801012 if (material == null || material.multiply)
8811013 return true;
8821014
1015
+ // Transparent objects are dynamic because we have to sort the triangles.
8831016 return material.opacity > 0.99;
8841017 }
8851018
....@@ -911,6 +1044,11 @@
9111044 fromParent = null; // LA.newMatrix();
9121045 bRep = null; // new BoundaryRep();
9131046
1047
+ if (oname != null && oname.equals("LeftHand"))
1048
+ {
1049
+ name = oname;
1050
+ }
1051
+
9141052 /*
9151053 float hue = (float)Math.random();
9161054 Color col;
....@@ -953,7 +1091,7 @@
9531091
9541092 public Object clone()
9551093 {
956
- return GrafreeD.clone(this);
1094
+ return Grafreed.clone(this);
9571095 }
9581096
9591097 Object3D copyExpand()
....@@ -1275,6 +1413,7 @@
12751413 toParent = LA.newMatrix();
12761414 fromParent = LA.newMatrix();
12771415 }
1416
+
12781417 LA.matCopy(other.toParent, toParent);
12791418 LA.matCopy(other.fromParent, fromParent);
12801419
....@@ -1469,7 +1608,7 @@
14691608 BoundaryRep.SEUIL = other.material.cameralight;
14701609
14711610 // Set default to 0.1
1472
- BoundaryRep.SEUIL /= 2;
1611
+ BoundaryRep.SEUIL /= 4; // 2;
14731612 System.out.println("SEUIL = " + BoundaryRep.SEUIL);
14741613 }
14751614
....@@ -1728,7 +1867,7 @@
17281867 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17291868 o.bRep = transientrep;
17301869 if (clone)
1731
- o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
1870
+ o.bRep = (BoundaryRep) Grafreed.clone(transientrep);
17321871 o.CreateMaterial();
17331872 o.SetAttributes(this, -1);
17341873 //parent
....@@ -1741,7 +1880,7 @@
17411880 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17421881 o.bRep = bRep;
17431882 if (clone)
1744
- o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
1883
+ o.bRep = (BoundaryRep) Grafreed.clone(bRep);
17451884 o.CreateMaterial();
17461885 //o.overwriteThis(this, -1);
17471886 o.SetAttributes(this, -1);
....@@ -1828,12 +1967,15 @@
18281967 if (obj.name == null)
18291968 continue; // can't be a null one
18301969
1970
+ // Try perfect match first.
18311971 if (n.equals(obj.name))
18321972 {
18331973 theobj = obj;
18341974 count++;
18351975 }
18361976 }
1977
+
1978
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18371979
18381980 if (count != 1)
18391981 for (int i=Size(); --i>=0;)
....@@ -2293,12 +2435,17 @@
22932435 }
22942436 */
22952437 }
2438
+ else
2439
+ {
2440
+ //((ObjEditor)editWindow).SetupUI2(null);
2441
+ }
22962442 }
22972443
22982444 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
22992445 {
23002446 if (newWindow)
23012447 {
2448
+ new Exception().printStackTrace();
23022449 System.exit(0);
23032450 if (parent != null)
23042451 {
....@@ -2333,6 +2480,14 @@
23332480 {
23342481 editWindow.refreshContents();
23352482 }
2483
+ else
2484
+ {
2485
+ if (manipWindow != null)
2486
+ {
2487
+ manipWindow.refreshContents();
2488
+ }
2489
+ }
2490
+
23362491 //if (parent != null)
23372492 //parent.refreshEditWindow();
23382493 }
....@@ -2475,13 +2630,13 @@
24752630 return retval;
24762631 }
24772632
2478
- void doEditDrag(ClickInfo info)
2633
+ void doEditDrag(ClickInfo info, boolean opposite)
24792634 {
24802635 switch (doSomething)
24812636 {
24822637 case 1: // '\001'
24832638 //super.
2484
- doEditDrag0(info);
2639
+ doEditDrag0(info, opposite);
24852640 break;
24862641
24872642 case 2: // '\002'
....@@ -2494,11 +2649,11 @@
24942649 {
24952650 //sel.hitSomething = childToDrag.hitSomething;
24962651 //childToDrag.doEditDrag(info);
2497
- sel.doEditDrag(info);
2652
+ sel.doEditDrag(info, opposite);
24982653 } else
24992654 {
25002655 //super.
2501
- doEditDrag0(info);
2656
+ doEditDrag0(info, opposite);
25022657 }
25032658 }
25042659 break;
....@@ -2608,6 +2763,18 @@
26082763 void GenNormalsS(boolean crease)
26092764 {
26102765 selection.GenNormals(crease);
2766
+// for (int i=0; i<selection.size(); i++)
2767
+// {
2768
+// Object3D selectee = (Object3D) selection.elementAt(i);
2769
+// selectee.GenNormals(crease);
2770
+// }
2771
+
2772
+ //Touch();
2773
+ }
2774
+
2775
+ void GenNormalsMeshS()
2776
+ {
2777
+ selection.GenNormalsMesh();
26112778 // for (int i=0; i<selection.size(); i++)
26122779 // {
26132780 // Object3D selectee = (Object3D) selection.elementAt(i);
....@@ -2748,6 +2915,24 @@
27482915 if (child == null)
27492916 continue;
27502917 child.GenNormals(crease);
2918
+// Children().release(i);
2919
+ }
2920
+ blockloop = false;
2921
+ }
2922
+
2923
+ void GenNormalsMesh()
2924
+ {
2925
+ if (blockloop)
2926
+ return;
2927
+
2928
+ blockloop = true;
2929
+ GenNormalsMesh0();
2930
+ for (int i = 0; i < Children().Size(); i++)
2931
+ {
2932
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2933
+ if (child == null)
2934
+ continue;
2935
+ child.GenNormalsMesh();
27512936 // Children().release(i);
27522937 }
27532938 blockloop = false;
....@@ -2905,7 +3090,8 @@
29053090 {
29063091 if (bRep != null)
29073092 {
2908
- bRep.GenUV();
3093
+ bRep.GenUV(); //1);
3094
+ //bRep.UnfoldUV();
29093095 Touch();
29103096 }
29113097 }
....@@ -2919,11 +3105,20 @@
29193105 }
29203106 }
29213107
3108
+ void GenNormalsMesh0()
3109
+ {
3110
+ if (bRep != null)
3111
+ {
3112
+ bRep.GenerateNormalsMesh();
3113
+ Touch();
3114
+ }
3115
+ }
3116
+
29223117 void GenNormalsMINE0()
29233118 {
29243119 if (bRep != null)
29253120 {
2926
- bRep.GenerateNormalsMINE();
3121
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
29273122 Touch();
29283123 }
29293124 }
....@@ -2980,6 +3175,33 @@
29803175 blockloop = false;
29813176 }
29823177
3178
+ void TransformChildren()
3179
+ {
3180
+ if (toParent != null)
3181
+ {
3182
+ for (int i=Size(); --i>=0;)
3183
+ {
3184
+ Object3D v = get(i);
3185
+
3186
+ if (v.toParent == null)
3187
+ {
3188
+ v.toParent = LA.newMatrix();
3189
+ v.fromParent = LA.newMatrix();
3190
+ }
3191
+
3192
+// LA.matConcat(v.toParent, toParent, v.toParent);
3193
+// LA.matConcat(fromParent, v.fromParent, v.fromParent);
3194
+ LA.matConcat(toParent, v.toParent, v.toParent);
3195
+ LA.matConcat(v.fromParent, fromParent, v.fromParent);
3196
+ }
3197
+
3198
+ toParent = null; // LA.matIdentity(toParent);
3199
+ fromParent = null; // LA.matIdentity(fromParent);
3200
+
3201
+ Touch();
3202
+ }
3203
+ }
3204
+
29833205 void TransformGeometry()
29843206 {
29853207 Object3D obj = this;
....@@ -3201,9 +3423,11 @@
32013423
32023424 BoundaryRep sup = bRep.support;
32033425 bRep.support = null;
3204
- BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
3426
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
32053427 // bRep.SplitInTwo(onlyone); // thread...
3206
- temprep.SplitInTwo(reduction34, onlyone);
3428
+
3429
+ while(temprep.SplitInTwo(reduction34, onlyone));
3430
+
32073431 bRep = temprep;
32083432 bRep.support = sup;
32093433 Touch();
....@@ -3340,7 +3564,8 @@
33403564 if (blockloop)
33413565 return;
33423566
3343
- if (marked || (bRep != null && material != null)) // borderline...
3567
+ if (//marked || // does not make sense
3568
+ (bRep != null || material != null)) // borderline...
33443569 live = h;
33453570
33463571 for (int i = 0; i < Size(); i++)
....@@ -3361,7 +3586,8 @@
33613586 return;
33623587
33633588 //if (bRep != null)
3364
- if (marked || (bRep != null && material != null)) // borderline...
3589
+ if (//marked || // does not make sense
3590
+ (bRep != null || material != null)) // borderline...
33653591 link2master = h;
33663592
33673593 for (int i = 0; i < Size(); i++)
....@@ -3381,7 +3607,8 @@
33813607 if (blockloop)
33823608 return;
33833609
3384
- if (marked || (bRep != null && material != null)) // borderline...
3610
+ if (//marked || // does not make sense
3611
+ (bRep != null || material != null)) // borderline...
33853612 hide = h;
33863613
33873614 for (int i = 0; i < Size(); i++)
....@@ -3401,7 +3628,7 @@
34013628 if (blockloop)
34023629 return;
34033630
3404
- if (bRep != null && material != null) // borderline...
3631
+ if (bRep != null || material != null) // borderline...
34053632 marked = h;
34063633
34073634 for (int i = 0; i < Size(); i++)
....@@ -3411,6 +3638,46 @@
34113638 continue;
34123639 blockloop = true;
34133640 child.MarkLeaves(h);
3641
+ blockloop = false;
3642
+ // release(i);
3643
+ }
3644
+ }
3645
+
3646
+ void RewindLeaves(boolean h)
3647
+ {
3648
+ if (blockloop)
3649
+ return;
3650
+
3651
+ if (bRep != null || material != null) // borderline...
3652
+ rewind = h;
3653
+
3654
+ for (int i = 0; i < Size(); i++)
3655
+ {
3656
+ Object3D child = (Object3D) get(i); // reserve(i);
3657
+ if (child == null)
3658
+ continue;
3659
+ blockloop = true;
3660
+ child.RewindLeaves(h);
3661
+ blockloop = false;
3662
+ // release(i);
3663
+ }
3664
+ }
3665
+
3666
+ void RandomLeaves(boolean h)
3667
+ {
3668
+ if (blockloop)
3669
+ return;
3670
+
3671
+ if (bRep != null || material != null) // borderline...
3672
+ random = h;
3673
+
3674
+ for (int i = 0; i < Size(); i++)
3675
+ {
3676
+ Object3D child = (Object3D) get(i); // reserve(i);
3677
+ if (child == null)
3678
+ continue;
3679
+ blockloop = true;
3680
+ child.RandomLeaves(h);
34143681 blockloop = false;
34153682 // release(i);
34163683 }
....@@ -3725,7 +3992,7 @@
37253992 if (child == null)
37263993 continue;
37273994
3728
- if (GrafreeD.RENDERME > 0)
3995
+ if (Grafreed.RENDERME > 0)
37293996 {
37303997 if (child instanceof Merge)
37313998 ((Merge)child).renderme();
....@@ -3876,7 +4143,7 @@
38764143 if (child == null)
38774144 continue;
38784145
3879
- if (GrafreeD.RENDERME > 0)
4146
+ if (Grafreed.RENDERME > 0)
38804147 {
38814148 if (child instanceof Merge)
38824149 ((Merge)child).renderme();
....@@ -4071,7 +4338,7 @@
40714338 if (child == null)
40724339 continue;
40734340
4074
- if (GrafreeD.RENDERME > 0)
4341
+ if (Grafreed.RENDERME > 0)
40754342 {
40764343 if (child instanceof Merge)
40774344 ((Merge)child).renderme();
....@@ -4184,6 +4451,55 @@
41844451 {
41854452 blockloop = true;
41864453 get(i).RepairShadow();
4454
+ blockloop = false;
4455
+ }
4456
+ }
4457
+
4458
+ void RepairSOV()
4459
+ {
4460
+ if (blockloop)
4461
+ return;
4462
+
4463
+ String texname = this.GetPigmentTexture();
4464
+
4465
+ if (texname.startsWith("sov"))
4466
+ {
4467
+ String[] s = texname.split("/");
4468
+
4469
+ String[] sname = s[1].split("Color.pn");
4470
+
4471
+ texname = sname[0];
4472
+
4473
+ if (sname.length > 1)
4474
+ {
4475
+ texname += "Color.jpg";
4476
+ }
4477
+
4478
+ this.SetPigmentTexture("sov/" + texname);
4479
+ }
4480
+
4481
+ texname = this.GetBumpTexture();
4482
+
4483
+ if (texname.startsWith("sov"))
4484
+ {
4485
+ String[] s = texname.split("/");
4486
+
4487
+ String[] sname = s[1].split("Bump.pn");
4488
+
4489
+ texname = sname[0];
4490
+
4491
+ if (sname.length > 1)
4492
+ {
4493
+ texname += "Bump.jpg";
4494
+ }
4495
+
4496
+ this.SetBumpTexture("sov/" + texname);
4497
+ }
4498
+
4499
+ for (int i=0; i<Size(); i++)
4500
+ {
4501
+ blockloop = true;
4502
+ get(i).RepairSOV();
41874503 blockloop = false;
41884504 }
41894505 }
....@@ -4678,7 +4994,7 @@
46784994
46794995 cTreePath SelectLeaf(int indexcount, boolean deselect)
46804996 {
4681
- if (hide)
4997
+ if (hide || dontselect)
46824998 return null;
46834999
46845000 if (count <= 0)
....@@ -4702,9 +5018,17 @@
47025018 }
47035019 }
47045020
5021
+ ObjEditor GetWindow()
5022
+ {
5023
+ if (editWindow != null)
5024
+ return editWindow;
5025
+
5026
+ return manipWindow;
5027
+ }
5028
+
47055029 cTreePath Select(int indexcount, boolean deselect)
47065030 {
4707
- if (hide)
5031
+ if (hide || dontselect)
47085032 return null;
47095033
47105034 if (count <= 0)
....@@ -4738,10 +5062,11 @@
47385062 if (leaf != null)
47395063 {
47405064 cTreePath tp = new cTreePath(this, leaf);
4741
- if (editWindow != null)
5065
+ ObjEditor window = GetWindow();
5066
+ if (window != null)
47425067 {
47435068 //System.out.println("editWindow = " + editWindow + " vs " + this);
4744
- editWindow.Select(tp, deselect, true);
5069
+ window.Select(tp, deselect, true);
47455070 }
47465071
47475072 return tp;
....@@ -4758,6 +5083,7 @@
47585083
47595084 if (child == null)
47605085 continue;
5086
+
47615087 if (child.HasTransparency() && child.size() != 0)
47625088 {
47635089 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4767,9 +5093,10 @@
47675093 if (leaf != null)
47685094 {
47695095 cTreePath tp = new cTreePath(this, leaf);
4770
- if (editWindow != null)
5096
+ ObjEditor window = GetWindow();
5097
+ if (window != null)
47715098 {
4772
- editWindow.Select(tp, deselect, true);
5099
+ window.Select(tp, deselect, true);
47735100 }
47745101
47755102 return tp;
....@@ -5094,6 +5421,51 @@
50945421 blockloop = false;
50955422 }
50965423
5424
+ void ResetSelectable()
5425
+ {
5426
+ if (blockloop)
5427
+ return;
5428
+
5429
+ blockloop = true;
5430
+
5431
+ keepdontselect = dontselect;
5432
+ dontselect = true;
5433
+
5434
+ Object3D child;
5435
+ int nb = Size();
5436
+ for (int i = 0; i < nb; i++)
5437
+ {
5438
+ child = (Object3D) get(i);
5439
+ if (child == null)
5440
+ continue;
5441
+ child.ResetSelectable();
5442
+ }
5443
+
5444
+ blockloop = false;
5445
+ }
5446
+
5447
+ void RestoreSelectable()
5448
+ {
5449
+ if (blockloop)
5450
+ return;
5451
+
5452
+ blockloop = true;
5453
+
5454
+ dontselect = keepdontselect;
5455
+
5456
+ Object3D child;
5457
+ int nb = Size();
5458
+ for (int i = 0; i < nb; i++)
5459
+ {
5460
+ child = (Object3D) get(i);
5461
+ if (child == null)
5462
+ continue;
5463
+ child.RestoreSelectable();
5464
+ }
5465
+
5466
+ blockloop = false;
5467
+ }
5468
+
50975469 boolean IsSelected()
50985470 {
50995471 if (parent == null)
....@@ -5156,10 +5528,34 @@
51565528
51575529 // System.out.println("Fullname = " + fullname);
51585530
5159
- if (fullname.name.indexOf(":") == -1)
5160
- return fullname.name;
5531
+ // Does not work on Windows due to C:
5532
+// if (fullname.name.indexOf(":") == -1)
5533
+// return fullname.name;
5534
+//
5535
+// return fullname.name.substring(0,fullname.name.indexOf(":"));
51615536
5162
- return fullname.name.substring(0,fullname.name.indexOf(":"));
5537
+ String[] split = fullname.name.split(":");
5538
+
5539
+ if (split.length == 0)
5540
+ {
5541
+ return "";
5542
+ }
5543
+
5544
+ if (split.length <= 2)
5545
+ {
5546
+ if (fullname.name.endsWith(":"))
5547
+ {
5548
+ // Windows
5549
+ return fullname.name.substring(0, fullname.name.length()-1);
5550
+ }
5551
+
5552
+ return split[0];
5553
+ }
5554
+
5555
+ // Windows
5556
+ assert(split.length == 4);
5557
+
5558
+ return split[0] + ":" + split[1];
51635559 }
51645560
51655561 static String GetBump(cTexture fullname)
....@@ -5168,10 +5564,38 @@
51685564 return "";
51695565
51705566 // 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());
5567
+ // Does not work on Windows due to C:
5568
+// if (fullname.name.indexOf(":") == -1)
5569
+// return "";
5570
+//
5571
+// return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5572
+ String[] split = fullname.name.split(":");
5573
+
5574
+ if (split.length == 0)
5575
+ {
5576
+ return "";
5577
+ }
5578
+
5579
+ if (split.length == 1)
5580
+ {
5581
+ return "";
5582
+ }
5583
+
5584
+ if (split.length == 2)
5585
+ {
5586
+ if (fullname.name.endsWith(":"))
5587
+ {
5588
+ // Windows
5589
+ return "";
5590
+ }
5591
+
5592
+ return split[1];
5593
+ }
5594
+
5595
+ // Windows
5596
+ assert(split.length == 4);
5597
+
5598
+ return split[2] + ":" + split[3];
51755599 }
51765600
51775601 String GetPigmentTexture()
....@@ -5245,7 +5669,7 @@
52455669 System.out.print("; textures = " + textures);
52465670 System.out.println("; usedtextures = " + usedtextures);
52475671
5248
- if (GetTextures() == null)
5672
+ if (GetTextures() == null) // What is that??
52495673 GetTextures().name = ":";
52505674
52515675 String texname = tex;
....@@ -5276,6 +5700,43 @@
52765700 child.ResetPigmentTexture();
52775701 blockloop = false;
52785702 }
5703
+ }
5704
+
5705
+ UUID GetUUID()
5706
+ {
5707
+ if (uuid == null)
5708
+ {
5709
+ // Serial
5710
+ uuid = UUID.randomUUID();
5711
+ }
5712
+
5713
+ return uuid;
5714
+ }
5715
+
5716
+ Object3D GetObject(UUID uid)
5717
+ {
5718
+ if (blockloop)
5719
+ return null;
5720
+
5721
+ if (GetUUID().equals(uid))
5722
+ return this;
5723
+
5724
+ int nb = Size();
5725
+ for (int i = 0; i < nb; i++)
5726
+ {
5727
+ Object3D child = (Object3D) get(i);
5728
+
5729
+ if (child == null)
5730
+ continue;
5731
+
5732
+ blockloop = true;
5733
+ Object3D obj = child.GetObject(uid);
5734
+ blockloop = false;
5735
+ if (obj != null)
5736
+ return obj;
5737
+ }
5738
+
5739
+ return null;
52795740 }
52805741
52815742 void SetBumpTexture(String tex)
....@@ -5322,12 +5783,23 @@
53225783 boolean NeedSupport()
53235784 {
53245785 return
5325
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5786
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
53265787 // PROBLEM with CROWD!!
5327
- && (Globals.DrawMode() == iCameraPane.SHADOW || Globals.CROWD);
5788
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
53285789 }
53295790
53305791 static boolean DEBUG_SELECTION = false;
5792
+
5793
+ boolean IsLive()
5794
+ {
5795
+ if (live)
5796
+ return true;
5797
+
5798
+ if (parent == null)
5799
+ return false;
5800
+
5801
+ return parent.IsLive();
5802
+ }
53315803
53325804 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
53335805 {
....@@ -5339,7 +5811,7 @@
53395811 }
53405812
53415813 if (display.DrawMode() == iCameraPane.SELECTION &&
5342
- hide)
5814
+ (hide || dontselect))
53435815 return;
53445816
53455817 if (name != null && name.contains("sclera"))
....@@ -5371,7 +5843,7 @@
53715843 return;
53725844 }
53735845
5374
- javax.media.opengl.GL gl = display.GetGL();
5846
+ //javax.media.opengl.GL gl = display.GetGL();
53755847
53765848 /*
53775849 if (touched)
....@@ -5390,7 +5862,7 @@
53905862 support = support;
53915863
53925864 //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5393
- boolean usecalllists = false; // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5865
+ boolean usecalllists = !IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
53945866
53955867 if (!usecalllists && bRep != null && bRep.displaylist > 0)
53965868 {
....@@ -5410,10 +5882,12 @@
54105882 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
54115883
54125884 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5413
- (touched || (bRep != null && bRep.displaylist <= 0)))
5885
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5886
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
54145887 {
54155888 Globals.lighttouched = true;
54165889 } // all panes...
5890
+
54175891 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
54185892 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
54195893 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5423,7 +5897,7 @@
54235897 //if (displaylist == -1 && usecalllists)
54245898 if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
54255899 {
5426
- bRep.displaylist = gl.glGenLists(1);
5900
+ bRep.displaylist = display.GenList();
54275901 assert(bRep.displaylist != 0);
54285902 // System.err.println("glGenLists: " + bRep.displaylist + " for " + this);
54295903 //System.out.println("\tgen list " + list);
....@@ -5435,14 +5909,16 @@
54355909 if (usecalllists)
54365910 {
54375911 // System.err.println("new list " + bRep.displaylist + " for " + this);
5438
- gl.glNewList(bRep.displaylist, gl.GL_COMPILE); //_AND_EXECUTE);
5912
+ display.NewList(bRep.displaylist);
54395913 }
5914
+
54405915 CallList(display, root, selected, blocked);
5916
+
54415917 // compiled = true;
54425918 if (usecalllists)
54435919 {
54445920 // System.err.println("end list " + bRep.displaylist + " for " + this);
5445
- gl.glEndList();
5921
+ display.EndList();
54465922 }
54475923 //gl.glDrawBuffer(gl.GL_BACK);
54485924 // XXX touched = false;
....@@ -5490,7 +5966,7 @@
54905966 if (display.DrawMode() == iCameraPane.SHADOW)
54915967 {
54925968 if (!link2master // tricky to cull in shadow mode.
5493
- && GetBRep().FrustumCull(this, gl, display.LightCamera(), true))
5969
+ && GetBRep().FrustumCull(this, null, display.LightCamera(), true))
54945970 {
54955971 //System.out.print("CULLED");
54965972 culled = true;
....@@ -5498,7 +5974,7 @@
54985974 }
54995975 else
55005976 //GetBRep().getBounds(v0, v1, this);
5501
- if (GetBRep().FrustumCull(this, gl, display.RenderCamera(), false))
5977
+ if (GetBRep().FrustumCull(this, null, display.RenderCamera(), false))
55025978 culled = true;
55035979
55045980 // LA.xformPos(v0, display.renderCamera.toScreen, v0);
....@@ -5538,7 +6014,8 @@
55386014 {
55396015 if (GetBRep() != null)
55406016 {
5541
- CameraPane.NextIndex(this, gl);
6017
+ display.NextIndex();
6018
+
55426019 // vertex color conflict : gl.glCallList(list);
55436020 DrawNode(display, root, selected);
55446021 if (this instanceof BezierPatch)
....@@ -5579,7 +6056,28 @@
55796056 tex = GetTextures();
55806057 }
55816058
5582
- display.BindTextures(tex, texres);
6059
+ boolean failedPigment = false;
6060
+ boolean failedBump = false;
6061
+
6062
+ try
6063
+ {
6064
+ display.BindPigmentTexture(tex, texres);
6065
+ }
6066
+ catch (Exception e)
6067
+ {
6068
+ System.err.println("FAILED: " + this);
6069
+ failedPigment = true;
6070
+ }
6071
+
6072
+ try
6073
+ {
6074
+ display.BindBumpTexture(tex, texres);
6075
+ }
6076
+ catch (Exception e)
6077
+ {
6078
+ //System.err.println("FAILED: " + this);
6079
+ failedBump = true;
6080
+ }
55836081
55846082 if (!compiled)
55856083 {
....@@ -5595,13 +6093,17 @@
55956093
55966094 // System.err.println("glCallList: " + bRep.displaylist + " for " + this);
55976095 assert(bRep.displaylist != 0);
5598
- gl.glCallList(bRep.displaylist);
6096
+ display.CallList(bRep.displaylist);
55996097 // june 2013 drawSelf(display, root, selected);
56006098 }
56016099 }
56026100 }
56036101
5604
- display.ReleaseTextures(tex);
6102
+ if (!failedBump)
6103
+ display.ReleaseBumpTexture(tex);
6104
+
6105
+ if (!failedPigment)
6106
+ display.ReleasePigmentTexture(tex);
56056107
56066108 display.PopMaterial(this, selected);
56076109 }
....@@ -5730,6 +6232,9 @@
57306232
57316233 void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57326234 {
6235
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6236
+ return;
6237
+
57336238 if (hide)
57346239 return;
57356240 // shadow optimisation
....@@ -5855,6 +6360,9 @@
58556360 if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
58566361 return; // no shadow for transparent objects
58576362
6363
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6364
+ return;
6365
+
58586366 if (hide)
58596367 return;
58606368
....@@ -5895,9 +6403,10 @@
58956403 return;
58966404 }
58976405
6406
+ //bRep.GenUV(1/material.diffuseness);
58986407 // bRep.lock = true;
58996408
5900
- javax.media.opengl.GL gl = display.GetGL();
6409
+ //javax.media.opengl.GL gl = display.GetGL();
59016410
59026411 if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera)
59036412 {
....@@ -5914,23 +6423,7 @@
59146423
59156424 bRep.getMinMax(min, max, 100);
59166425
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();
6426
+ display.DrawBox(min, max);
59346427
59356428 return;
59366429 }
....@@ -5984,178 +6477,19 @@
59846477 new Exception().printStackTrace();
59856478 return;
59866479 }
5987
-
5988
- // TRIANGLE STRIP ARRAY
5989
- if (bRep.trimmed)
6480
+
6481
+ if (dontselect)
59906482 {
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;
6483
+ //bRep.GenerateNormalsMINE();
61226484 }
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
- }
6485
+
6486
+ display.DrawGeometry(bRep, flipV, selectmode);
61536487 } else // catch (Error e)
61546488 {
61556489 // TRIANGLE ARRAY
61566490 if (IsOpaque()) // Static())
61576491 {
6158
- gl.glBegin(gl.GL_TRIANGLES);
6492
+ display.StartTriangles();
61596493 int facecount = bRep.FaceCount();
61606494 for (int i = 0; i < facecount; i++)
61616495 {
....@@ -6220,7 +6554,7 @@
62206554
62216555 display.DrawFace(this, p, q, r, face);
62226556 }
6223
- gl.glEnd();
6557
+ display.EndTriangles();
62246558 }
62256559 else
62266560 {
....@@ -6249,8 +6583,8 @@
62496583 //System.out.println("SORT");
62506584
62516585 java.util.Arrays.sort(facescompare);
6252
-
6253
- gl.glBegin(gl.GL_TRIANGLES);
6586
+
6587
+ display.StartTriangles();
62546588 for (int i = 0; i < facecount; i++)
62556589 {
62566590 Face face = bRep.GetFace(facescompare[i].index);
....@@ -6264,11 +6598,12 @@
62646598
62656599 display.DrawFace(this, p, q, r, face);
62666600 }
6267
- gl.glEnd();
6601
+ display.EndTriangles();
62686602 }
62696603
62706604 if (false) // live && support != null && support.bRep != null) // debug weights
62716605 {
6606
+ /*
62726607 gl.glDisable(gl.GL_LIGHTING);
62736608 float[] colorV = new float[3];
62746609
....@@ -6347,6 +6682,7 @@
63476682 // gl.glEnd();
63486683 }
63496684 }
6685
+ */
63506686 }
63516687 }
63526688
....@@ -6405,22 +6741,6 @@
64056741 void Print(Vertex v)
64066742 {
64076743 //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);
64246744 }
64256745
64266746 void drawSelf(ClickInfo info, int level, boolean select)
....@@ -7013,7 +7333,7 @@
70137333 spot.translate(32, 32);
70147334 spotw = spot.x + spot.width;
70157335 spoth = spot.y + spot.height;
7016
- info.g.setColor(Color.blue);
7336
+ info.g.setColor(Color.cyan);
70177337 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
70187338 // if (CameraPane.Xmin > spot.x)
70197339 // {
....@@ -7031,11 +7351,12 @@
70317351 // {
70327352 // CameraPane.Ymax = spoth;
70337353 // }
7034
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7035
- info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7354
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7355
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
70367356 spot.translate(0, -32);
7037
- info.g.setColor(Color.green);
7357
+ info.g.setColor(Color.yellow);
70387358 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7359
+ info.g.setColor(Color.green);
70397360 // if (CameraPane.Xmin > spot.x)
70407361 // {
70417362 // CameraPane.Xmin = spot.x;
....@@ -7052,8 +7373,8 @@
70527373 // {
70537374 // CameraPane.Ymax = spoth;
70547375 // }
7055
- info.g.drawArc(boundary.x, boundary.y,
7056
- boundary.width, boundary.height, 0, 360);
7376
+ info.g.drawArc(boundary.x + info.DX, boundary.y + info.DY,
7377
+ (int)(boundary.width * info.W), (int)(boundary.height * info.W), 0, 360);
70577378 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
70587379 // if (CameraPane.Xmin > boundary.x)
70597380 // {
....@@ -7087,7 +7408,7 @@
70877408 startX = info.x;
70887409 startY = info.y;
70897410
7090
- hitSomething = 0;
7411
+ hitSomething = -1;
70917412 cVector origin = new cVector();
70927413 //LA.xformPos(origin, toParent, origin);
70937414 Rectangle spot = new Rectangle();
....@@ -7120,7 +7441,7 @@
71207441 }
71217442
71227443 //System.out.println("info.modifiers = " + info.modifiers);
7123
- modified = (info.modifiers & CameraPane.META) != 0;
7444
+ modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
71247445 //System.out.println("modified = " + modified);
71257446 //new Exception().printStackTrace();
71267447 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7148,7 +7469,7 @@
71487469 return true;
71497470 }
71507471
7151
- void doEditDrag0(ClickInfo info)
7472
+ void doEditDrag0(ClickInfo info, boolean opposite)
71527473 {
71537474 if (hitSomething == 0)
71547475 {
....@@ -7163,6 +7484,7 @@
71637484 //System.out.println("hitSomething = " + hitSomething);
71647485
71657486 double scale = 0.005f * info.camera.Distance();
7487
+
71667488 cVector xlate = new cVector();
71677489 //cVector xlate2 = new cVector();
71687490 switch (hitSomething)
....@@ -7175,7 +7497,7 @@
71757497
71767498 scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
71777499
7178
- if (modified)
7500
+ if (modified || opposite)
71797501 {
71807502 //assert(false);
71817503 /*
....@@ -7269,6 +7591,7 @@
72697591
72707592 if (modified)
72717593 {
7594
+ // Rotate 90 degrees
72727595 angle /= (Math.PI / 4);
72737596 angle = Math.floor(angle + 0.5);
72747597 angle *= (Math.PI / 4);
....@@ -7310,24 +7633,27 @@
73107633
73117634 case hitScale: // scale
73127635 double hScale = (double) (info.x - centerPt.x) / 32;
7636
+ double sign = 1;
7637
+ if (hScale < 0)
7638
+ {
7639
+ sign = -1;
7640
+ }
7641
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
73137642 if (hScale < 0.01)
73147643 {
7315
- hScale = 0.01;
7644
+ //hScale = 0.01;
73167645 }
7317
- hScale = Math.pow(hScale, scale * 50);
7318
- if (hScale < 0.01)
7319
- {
7320
- hScale = 0.01;
7321
- }
7646
+
73227647 double vScale = (double) (info.y - centerPt.y) / 32;
7323
- if (vScale < 0.01)
7648
+ sign = 1;
7649
+ if (vScale < 0)
73247650 {
7325
- vScale = 0.01;
7651
+ sign = -1;
73267652 }
7327
- vScale = Math.pow(vScale, scale * 50);
7653
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
73287654 if (vScale < 0.01)
73297655 {
7330
- vScale = 0.01;
7656
+ //vScale = 0.01;
73317657 }
73327658 LA.matCopy(startMat, toParent);
73337659 /**/
....@@ -7338,39 +7664,47 @@
73387664 }
73397665 /**/
73407666
7667
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7668
+
7669
+ if (totalScale < 0.01)
7670
+ {
7671
+ totalScale = 0.01;
7672
+ }
7673
+
73417674 switch (info.pane.RenderCamera().viewCode)
73427675 {
73437676 case 3: // '\001'
7344
- if (modified)
7677
+ if (modified || opposite)
73457678 {
73467679 //LA.matScale(toParent, 1, hScale, vScale);
7347
- LA.matScale(toParent, vScale, 1, 1);
7680
+ LA.matScale(toParent, totalScale, 1, 1);
73487681 } // vScale, 1);
73497682 else
73507683 {
7351
- LA.matScale(toParent, vScale, vScale, vScale);
7684
+ // EXCEPTION!
7685
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
73527686 } // vScale, 1);
73537687 break;
73547688
73557689 case 2: // '\002'
7356
- if (modified)
7690
+ if (modified || opposite)
73577691 {
73587692 //LA.matScale(toParent, hScale, 1, vScale);
7359
- LA.matScale(toParent, 1, vScale, 1);
7693
+ LA.matScale(toParent, 1, totalScale, 1);
73607694 } else
73617695 {
7362
- LA.matScale(toParent, vScale, 1, vScale);
7696
+ LA.matScale(toParent, totalScale, 1, totalScale);
73637697 }
73647698 break;
73657699
73667700 case 1: // '\003'
7367
- if (modified)
7701
+ if (modified || opposite)
73687702 {
73697703 //LA.matScale(toParent, hScale, vScale, 1);
7370
- LA.matScale(toParent, 1, 1, vScale);
7704
+ LA.matScale(toParent, 1, 1, totalScale);
73717705 } else
73727706 {
7373
- LA.matScale(toParent, vScale, vScale, 1);
7707
+ LA.matScale(toParent, totalScale, totalScale, 1);
73747708 }
73757709 break;
73767710 }
....@@ -7503,14 +7837,22 @@
75037837 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
75047838 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
75057839 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7840
+
7841
+ String objname;
7842
+
75067843 if (false) //parent != null)
75077844 {
7508
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7845
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
75097846 } else
75107847 {
7511
- return GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ") ")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ +System.identityHashCode(this);
7848
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
75127849 } // + super.toString();
75137850 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
7851
+
7852
+ if (!Globals.ADVANCED)
7853
+ return objname;
7854
+
7855
+ return objname + " " + System.identityHashCode(this);
75147856 }
75157857
75167858 public int hashCode()
....@@ -7566,6 +7908,7 @@
75667908 objectUI.closeUI();
75677909 if (editWindow != null)
75687910 {
7911
+ editWindow.ctrlPanel.FlushUI();
75697912 editWindow.refreshContents();
75707913 } // ? new
75717914 objectUI = null;
....@@ -7574,6 +7917,10 @@
75747917 {
75757918 editWindow = null;
75767919 } // ?
7920
+ }
7921
+ else
7922
+ {
7923
+ //editWindow.closeUI();
75777924 }
75787925 }
75797926
....@@ -7586,7 +7933,7 @@
75867933 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
75877934
75887935 Object3D /*Composite*/ parent;
7589
- Object3D /*Composite*/ fileparent;
7936
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
75907937
75917938 double[][] toParent; // dynamic matrix
75927939 double[][] fromParent;
....@@ -7701,7 +8048,7 @@
77018048 {
77028049 assert(bRep != null);
77038050 if (!(support instanceof GenericJoint)) // support.bRep != null)
7704
- GrafreeD.Assert(support.bRep == bRep.support);
8051
+ Grafreed.Assert(support.bRep == bRep.support);
77058052 }
77068053 else
77078054 {
....@@ -7732,6 +8079,10 @@
77328079 }
77338080
77348081 transient ObjEditor editWindow;
8082
+ transient ObjEditor manipWindow;
8083
+
8084
+ transient boolean pinned;
8085
+
77358086 transient ObjectUI objectUI;
77368087 public static int povDepth = 0;
77378088 private static cVector tbMin = new cVector();
....@@ -7750,9 +8101,9 @@
77508101 private static cVector edge2 = new cVector();
77518102 //private static cVector norm = new cVector();
77528103 /*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;
8104
+ static final int hitCenter = 1;
8105
+ static final int hitScale = 2;
8106
+ static final int hitRotate = 3;
77568107 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
77578108 /*transient*/ private Point centerPt;
77588109 /*transient*/ private int startX;