Normand Briere
2019-07-17 a5580a47d246c1272b10adba68070f6e13da5e41
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[] = new byte[100][];
33
+ int versionindex = -1;
34
+
2235 ScriptNode scriptnode;
2336
2437 void InitOthers()
....@@ -99,64 +112,173 @@
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
+
223
+ if (this.support != null)
224
+ {
225
+ if (o.transientrep != null)
226
+ Grafreed.Assert(o.transientrep == this.support.bRep);
227
+
228
+ o.transientrep = this.support.bRep;
229
+ this.support.bRep = null;
230
+ }
231
+
232
+ // o.support = this.support;
233
+ // o.fileparent = this.fileparent;
234
+ // if (this.bRep != null)
235
+ // o.bRep = this.bRep.support;
236
+
237
+ this.bRep = null;
238
+ // if (this.bRep != null)
239
+ // this.bRep.support = null;
240
+ // this.support = null;
241
+ // this.fileparent = null;
242
+ }
243
+
244
+ void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
245
+ {
246
+ if (!hashtable.containsKey(GetUUID()))
247
+ return;
248
+
249
+ Object3D o = hashtable.get(GetUUID());
250
+
251
+ RestoreBigData(o);
252
+
253
+ if (blockloop)
254
+ return;
255
+
129256 blockloop = true;
130
- child.SaveSupports();
257
+
258
+ //hashtable.remove(GetUUID());
259
+
260
+ for (int i=0; i<Size(); i++)
261
+ {
262
+ get(i).RestoreBigData(hashtable);
263
+ }
264
+
131265 blockloop = false;
132266 }
133
-}
134267
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)
268
+ void RestoreBigData(Object3D o)
146269 {
147
- bRep.RestoreSupports();
270
+ this.bRep = o.bRep;
271
+ if (this.support != null && o.transientrep != null)
272
+ {
273
+ this.support.bRep = o.transientrep;
274
+ }
275
+
276
+ this.selection = o.selection;
277
+// July 2019 if (this.bRep != null)
278
+// this.bRep.support = o.transientrep;
279
+ // this.support = o.support;
280
+ // this.fileparent = o.fileparent;
148281 }
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
-}
160282
161283 // MOCAP SUPPORT
162284 double tx,ty,tz,rx,ry,rz;
....@@ -299,6 +421,7 @@
299421 }
300422
301423 boolean live = false;
424
+ boolean dontselect = false;
302425 boolean hide = false;
303426 boolean link2master = false; // performs reset support/master at each frame
304427 boolean marked = false; // animation node
....@@ -480,12 +603,14 @@
480603 toParent = LA.newMatrix();
481604 fromParent = LA.newMatrix();
482605 }
606
+
483607 if (toParentMarked == null)
484608 {
485609 if (maxcount != 1)
486610 {
487611 new Exception().printStackTrace();
488612 }
613
+
489614 toParentMarked = LA.newMatrix();
490615 fromParentMarked = LA.newMatrix();
491616 }
....@@ -773,7 +898,7 @@
773898 if (step == 0)
774899 step = 1;
775900 if (maxcount == 0)
776
- maxcount = 2048; // 4;
901
+ maxcount = 128; // 2048; // 4;
777902 // if (acceleration == 0)
778903 // acceleration = 10;
779904 if (delay == 0) // serial
....@@ -796,7 +921,7 @@
796921
797922 if (marked && Globals.isLIVE() && live &&
798923 //TEMP21aug2018
799
- Globals.DrawMode() == iCameraPane.SHADOW &&
924
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
800925 currentframe != Globals.framecount)
801926 {
802927 currentframe = Globals.framecount;
....@@ -808,7 +933,8 @@
808933
809934 boolean changedir = random && Math.random() < 0.01; // && !link2master;
810935
811
- if (transformcount*factor > maxcount || (step == 1 && changedir))
936
+ if (transformcount*factor >= maxcount && (rewind || random) ||
937
+ (step == 1 && changedir))
812938 {
813939 countdown = 1;
814940 delay = speedup?8:1;
....@@ -880,6 +1006,7 @@
8801006 if (material == null || material.multiply)
8811007 return true;
8821008
1009
+ // Transparent objects are dynamic because we have to sort the triangles.
8831010 return material.opacity > 0.99;
8841011 }
8851012
....@@ -911,6 +1038,11 @@
9111038 fromParent = null; // LA.newMatrix();
9121039 bRep = null; // new BoundaryRep();
9131040
1041
+ if (oname != null && oname.equals("LeftHand"))
1042
+ {
1043
+ name = oname;
1044
+ }
1045
+
9141046 /*
9151047 float hue = (float)Math.random();
9161048 Color col;
....@@ -953,7 +1085,7 @@
9531085
9541086 public Object clone()
9551087 {
956
- return GrafreeD.clone(this);
1088
+ return Grafreed.clone(this);
9571089 }
9581090
9591091 Object3D copyExpand()
....@@ -1275,6 +1407,7 @@
12751407 toParent = LA.newMatrix();
12761408 fromParent = LA.newMatrix();
12771409 }
1410
+
12781411 LA.matCopy(other.toParent, toParent);
12791412 LA.matCopy(other.fromParent, fromParent);
12801413
....@@ -1469,7 +1602,7 @@
14691602 BoundaryRep.SEUIL = other.material.cameralight;
14701603
14711604 // Set default to 0.1
1472
- BoundaryRep.SEUIL /= 2;
1605
+ BoundaryRep.SEUIL /= 4; // 2;
14731606 System.out.println("SEUIL = " + BoundaryRep.SEUIL);
14741607 }
14751608
....@@ -1728,7 +1861,7 @@
17281861 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17291862 o.bRep = transientrep;
17301863 if (clone)
1731
- o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
1864
+ o.bRep = (BoundaryRep) Grafreed.clone(transientrep);
17321865 o.CreateMaterial();
17331866 o.SetAttributes(this, -1);
17341867 //parent
....@@ -1741,7 +1874,7 @@
17411874 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17421875 o.bRep = bRep;
17431876 if (clone)
1744
- o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
1877
+ o.bRep = (BoundaryRep) Grafreed.clone(bRep);
17451878 o.CreateMaterial();
17461879 //o.overwriteThis(this, -1);
17471880 o.SetAttributes(this, -1);
....@@ -1828,12 +1961,15 @@
18281961 if (obj.name == null)
18291962 continue; // can't be a null one
18301963
1964
+ // Try perfect match first.
18311965 if (n.equals(obj.name))
18321966 {
18331967 theobj = obj;
18341968 count++;
18351969 }
18361970 }
1971
+
1972
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18371973
18381974 if (count != 1)
18391975 for (int i=Size(); --i>=0;)
....@@ -2293,12 +2429,17 @@
22932429 }
22942430 */
22952431 }
2432
+ else
2433
+ {
2434
+ //((ObjEditor)editWindow).SetupUI2(null);
2435
+ }
22962436 }
22972437
22982438 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
22992439 {
23002440 if (newWindow)
23012441 {
2442
+ new Exception().printStackTrace();
23022443 System.exit(0);
23032444 if (parent != null)
23042445 {
....@@ -2333,6 +2474,14 @@
23332474 {
23342475 editWindow.refreshContents();
23352476 }
2477
+ else
2478
+ {
2479
+ if (manipWindow != null)
2480
+ {
2481
+ manipWindow.refreshContents();
2482
+ }
2483
+ }
2484
+
23362485 //if (parent != null)
23372486 //parent.refreshEditWindow();
23382487 }
....@@ -2475,13 +2624,13 @@
24752624 return retval;
24762625 }
24772626
2478
- void doEditDrag(ClickInfo info)
2627
+ void doEditDrag(ClickInfo info, boolean opposite)
24792628 {
24802629 switch (doSomething)
24812630 {
24822631 case 1: // '\001'
24832632 //super.
2484
- doEditDrag0(info);
2633
+ doEditDrag0(info, opposite);
24852634 break;
24862635
24872636 case 2: // '\002'
....@@ -2494,11 +2643,11 @@
24942643 {
24952644 //sel.hitSomething = childToDrag.hitSomething;
24962645 //childToDrag.doEditDrag(info);
2497
- sel.doEditDrag(info);
2646
+ sel.doEditDrag(info, opposite);
24982647 } else
24992648 {
25002649 //super.
2501
- doEditDrag0(info);
2650
+ doEditDrag0(info, opposite);
25022651 }
25032652 }
25042653 break;
....@@ -2608,6 +2757,18 @@
26082757 void GenNormalsS(boolean crease)
26092758 {
26102759 selection.GenNormals(crease);
2760
+// for (int i=0; i<selection.size(); i++)
2761
+// {
2762
+// Object3D selectee = (Object3D) selection.elementAt(i);
2763
+// selectee.GenNormals(crease);
2764
+// }
2765
+
2766
+ //Touch();
2767
+ }
2768
+
2769
+ void GenNormalsMeshS()
2770
+ {
2771
+ selection.GenNormalsMesh();
26112772 // for (int i=0; i<selection.size(); i++)
26122773 // {
26132774 // Object3D selectee = (Object3D) selection.elementAt(i);
....@@ -2748,6 +2909,24 @@
27482909 if (child == null)
27492910 continue;
27502911 child.GenNormals(crease);
2912
+// Children().release(i);
2913
+ }
2914
+ blockloop = false;
2915
+ }
2916
+
2917
+ void GenNormalsMesh()
2918
+ {
2919
+ if (blockloop)
2920
+ return;
2921
+
2922
+ blockloop = true;
2923
+ GenNormalsMesh0();
2924
+ for (int i = 0; i < Children().Size(); i++)
2925
+ {
2926
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2927
+ if (child == null)
2928
+ continue;
2929
+ child.GenNormalsMesh();
27512930 // Children().release(i);
27522931 }
27532932 blockloop = false;
....@@ -2905,7 +3084,8 @@
29053084 {
29063085 if (bRep != null)
29073086 {
2908
- bRep.GenUV();
3087
+ bRep.GenUV(); //1);
3088
+ //bRep.UnfoldUV();
29093089 Touch();
29103090 }
29113091 }
....@@ -2915,6 +3095,15 @@
29153095 if (bRep != null)
29163096 {
29173097 bRep.GenerateNormals(crease);
3098
+ Touch();
3099
+ }
3100
+ }
3101
+
3102
+ void GenNormalsMesh0()
3103
+ {
3104
+ if (bRep != null)
3105
+ {
3106
+ bRep.GenerateNormalsMesh();
29183107 Touch();
29193108 }
29203109 }
....@@ -2980,6 +3169,33 @@
29803169 blockloop = false;
29813170 }
29823171
3172
+ void TransformChildren()
3173
+ {
3174
+ if (toParent != null)
3175
+ {
3176
+ for (int i=Size(); --i>=0;)
3177
+ {
3178
+ Object3D v = get(i);
3179
+
3180
+ if (v.toParent == null)
3181
+ {
3182
+ v.toParent = LA.newMatrix();
3183
+ v.fromParent = LA.newMatrix();
3184
+ }
3185
+
3186
+// LA.matConcat(v.toParent, toParent, v.toParent);
3187
+// LA.matConcat(fromParent, v.fromParent, v.fromParent);
3188
+ LA.matConcat(toParent, v.toParent, v.toParent);
3189
+ LA.matConcat(v.fromParent, fromParent, v.fromParent);
3190
+ }
3191
+
3192
+ toParent = null; // LA.matIdentity(toParent);
3193
+ fromParent = null; // LA.matIdentity(fromParent);
3194
+
3195
+ Touch();
3196
+ }
3197
+ }
3198
+
29833199 void TransformGeometry()
29843200 {
29853201 Object3D obj = this;
....@@ -3201,9 +3417,11 @@
32013417
32023418 BoundaryRep sup = bRep.support;
32033419 bRep.support = null;
3204
- BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
3420
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
32053421 // bRep.SplitInTwo(onlyone); // thread...
3206
- temprep.SplitInTwo(reduction34, onlyone);
3422
+
3423
+ while(temprep.SplitInTwo(reduction34, onlyone));
3424
+
32073425 bRep = temprep;
32083426 bRep.support = sup;
32093427 Touch();
....@@ -3340,7 +3558,8 @@
33403558 if (blockloop)
33413559 return;
33423560
3343
- if (marked || (bRep != null && material != null)) // borderline...
3561
+ if (//marked || // does not make sense
3562
+ (bRep != null || material != null)) // borderline...
33443563 live = h;
33453564
33463565 for (int i = 0; i < Size(); i++)
....@@ -3361,7 +3580,8 @@
33613580 return;
33623581
33633582 //if (bRep != null)
3364
- if (marked || (bRep != null && material != null)) // borderline...
3583
+ if (//marked || // does not make sense
3584
+ (bRep != null || material != null)) // borderline...
33653585 link2master = h;
33663586
33673587 for (int i = 0; i < Size(); i++)
....@@ -3381,7 +3601,8 @@
33813601 if (blockloop)
33823602 return;
33833603
3384
- if (marked || (bRep != null && material != null)) // borderline...
3604
+ if (//marked || // does not make sense
3605
+ (bRep != null || material != null)) // borderline...
33853606 hide = h;
33863607
33873608 for (int i = 0; i < Size(); i++)
....@@ -3401,7 +3622,7 @@
34013622 if (blockloop)
34023623 return;
34033624
3404
- if (bRep != null && material != null) // borderline...
3625
+ if (bRep != null || material != null) // borderline...
34053626 marked = h;
34063627
34073628 for (int i = 0; i < Size(); i++)
....@@ -3411,6 +3632,46 @@
34113632 continue;
34123633 blockloop = true;
34133634 child.MarkLeaves(h);
3635
+ blockloop = false;
3636
+ // release(i);
3637
+ }
3638
+ }
3639
+
3640
+ void RewindLeaves(boolean h)
3641
+ {
3642
+ if (blockloop)
3643
+ return;
3644
+
3645
+ if (bRep != null || material != null) // borderline...
3646
+ rewind = h;
3647
+
3648
+ for (int i = 0; i < Size(); i++)
3649
+ {
3650
+ Object3D child = (Object3D) get(i); // reserve(i);
3651
+ if (child == null)
3652
+ continue;
3653
+ blockloop = true;
3654
+ child.RewindLeaves(h);
3655
+ blockloop = false;
3656
+ // release(i);
3657
+ }
3658
+ }
3659
+
3660
+ void RandomLeaves(boolean h)
3661
+ {
3662
+ if (blockloop)
3663
+ return;
3664
+
3665
+ if (bRep != null || material != null) // borderline...
3666
+ random = h;
3667
+
3668
+ for (int i = 0; i < Size(); i++)
3669
+ {
3670
+ Object3D child = (Object3D) get(i); // reserve(i);
3671
+ if (child == null)
3672
+ continue;
3673
+ blockloop = true;
3674
+ child.RandomLeaves(h);
34143675 blockloop = false;
34153676 // release(i);
34163677 }
....@@ -3725,7 +3986,7 @@
37253986 if (child == null)
37263987 continue;
37273988
3728
- if (GrafreeD.RENDERME > 0)
3989
+ if (Grafreed.RENDERME > 0)
37293990 {
37303991 if (child instanceof Merge)
37313992 ((Merge)child).renderme();
....@@ -3876,7 +4137,7 @@
38764137 if (child == null)
38774138 continue;
38784139
3879
- if (GrafreeD.RENDERME > 0)
4140
+ if (Grafreed.RENDERME > 0)
38804141 {
38814142 if (child instanceof Merge)
38824143 ((Merge)child).renderme();
....@@ -4071,7 +4332,7 @@
40714332 if (child == null)
40724333 continue;
40734334
4074
- if (GrafreeD.RENDERME > 0)
4335
+ if (Grafreed.RENDERME > 0)
40754336 {
40764337 if (child instanceof Merge)
40774338 ((Merge)child).renderme();
....@@ -4184,6 +4445,55 @@
41844445 {
41854446 blockloop = true;
41864447 get(i).RepairShadow();
4448
+ blockloop = false;
4449
+ }
4450
+ }
4451
+
4452
+ void RepairSOV()
4453
+ {
4454
+ if (blockloop)
4455
+ return;
4456
+
4457
+ String texname = this.GetPigmentTexture();
4458
+
4459
+ if (texname.startsWith("sov"))
4460
+ {
4461
+ String[] s = texname.split("/");
4462
+
4463
+ String[] sname = s[1].split("Color.pn");
4464
+
4465
+ texname = sname[0];
4466
+
4467
+ if (sname.length > 1)
4468
+ {
4469
+ texname += "Color.jpg";
4470
+ }
4471
+
4472
+ this.SetPigmentTexture("sov/" + texname);
4473
+ }
4474
+
4475
+ texname = this.GetBumpTexture();
4476
+
4477
+ if (texname.startsWith("sov"))
4478
+ {
4479
+ String[] s = texname.split("/");
4480
+
4481
+ String[] sname = s[1].split("Bump.pn");
4482
+
4483
+ texname = sname[0];
4484
+
4485
+ if (sname.length > 1)
4486
+ {
4487
+ texname += "Bump.jpg";
4488
+ }
4489
+
4490
+ this.SetBumpTexture("sov/" + texname);
4491
+ }
4492
+
4493
+ for (int i=0; i<Size(); i++)
4494
+ {
4495
+ blockloop = true;
4496
+ get(i).RepairSOV();
41874497 blockloop = false;
41884498 }
41894499 }
....@@ -4678,7 +4988,7 @@
46784988
46794989 cTreePath SelectLeaf(int indexcount, boolean deselect)
46804990 {
4681
- if (hide)
4991
+ if (hide || dontselect)
46824992 return null;
46834993
46844994 if (count <= 0)
....@@ -4702,9 +5012,17 @@
47025012 }
47035013 }
47045014
5015
+ ObjEditor GetWindow()
5016
+ {
5017
+ if (editWindow != null)
5018
+ return editWindow;
5019
+
5020
+ return manipWindow;
5021
+ }
5022
+
47055023 cTreePath Select(int indexcount, boolean deselect)
47065024 {
4707
- if (hide)
5025
+ if (hide || dontselect)
47085026 return null;
47095027
47105028 if (count <= 0)
....@@ -4738,10 +5056,11 @@
47385056 if (leaf != null)
47395057 {
47405058 cTreePath tp = new cTreePath(this, leaf);
4741
- if (editWindow != null)
5059
+ ObjEditor window = GetWindow();
5060
+ if (window != null)
47425061 {
47435062 //System.out.println("editWindow = " + editWindow + " vs " + this);
4744
- editWindow.Select(tp, deselect, true);
5063
+ window.Select(tp, deselect, true);
47455064 }
47465065
47475066 return tp;
....@@ -4758,6 +5077,7 @@
47585077
47595078 if (child == null)
47605079 continue;
5080
+
47615081 if (child.HasTransparency() && child.size() != 0)
47625082 {
47635083 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4767,9 +5087,10 @@
47675087 if (leaf != null)
47685088 {
47695089 cTreePath tp = new cTreePath(this, leaf);
4770
- if (editWindow != null)
5090
+ ObjEditor window = GetWindow();
5091
+ if (window != null)
47715092 {
4772
- editWindow.Select(tp, deselect, true);
5093
+ window.Select(tp, deselect, true);
47735094 }
47745095
47755096 return tp;
....@@ -5156,10 +5477,34 @@
51565477
51575478 // System.out.println("Fullname = " + fullname);
51585479
5159
- if (fullname.name.indexOf(":") == -1)
5160
- return fullname.name;
5480
+ // Does not work on Windows due to C:
5481
+// if (fullname.name.indexOf(":") == -1)
5482
+// return fullname.name;
5483
+//
5484
+// return fullname.name.substring(0,fullname.name.indexOf(":"));
51615485
5162
- return fullname.name.substring(0,fullname.name.indexOf(":"));
5486
+ String[] split = fullname.name.split(":");
5487
+
5488
+ if (split.length == 0)
5489
+ {
5490
+ return "";
5491
+ }
5492
+
5493
+ if (split.length <= 2)
5494
+ {
5495
+ if (fullname.name.endsWith(":"))
5496
+ {
5497
+ // Windows
5498
+ return fullname.name.substring(0, fullname.name.length()-1);
5499
+ }
5500
+
5501
+ return split[0];
5502
+ }
5503
+
5504
+ // Windows
5505
+ assert(split.length == 4);
5506
+
5507
+ return split[0] + ":" + split[1];
51635508 }
51645509
51655510 static String GetBump(cTexture fullname)
....@@ -5168,10 +5513,38 @@
51685513 return "";
51695514
51705515 // 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());
5516
+ // Does not work on Windows due to C:
5517
+// if (fullname.name.indexOf(":") == -1)
5518
+// return "";
5519
+//
5520
+// return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5521
+ String[] split = fullname.name.split(":");
5522
+
5523
+ if (split.length == 0)
5524
+ {
5525
+ return "";
5526
+ }
5527
+
5528
+ if (split.length == 1)
5529
+ {
5530
+ return "";
5531
+ }
5532
+
5533
+ if (split.length == 2)
5534
+ {
5535
+ if (fullname.name.endsWith(":"))
5536
+ {
5537
+ // Windows
5538
+ return "";
5539
+ }
5540
+
5541
+ return split[1];
5542
+ }
5543
+
5544
+ // Windows
5545
+ assert(split.length == 4);
5546
+
5547
+ return split[2] + ":" + split[3];
51755548 }
51765549
51775550 String GetPigmentTexture()
....@@ -5245,7 +5618,7 @@
52455618 System.out.print("; textures = " + textures);
52465619 System.out.println("; usedtextures = " + usedtextures);
52475620
5248
- if (GetTextures() == null)
5621
+ if (GetTextures() == null) // What is that??
52495622 GetTextures().name = ":";
52505623
52515624 String texname = tex;
....@@ -5276,6 +5649,43 @@
52765649 child.ResetPigmentTexture();
52775650 blockloop = false;
52785651 }
5652
+ }
5653
+
5654
+ UUID GetUUID()
5655
+ {
5656
+ if (uuid == null)
5657
+ {
5658
+ // Serial
5659
+ uuid = UUID.randomUUID();
5660
+ }
5661
+
5662
+ return uuid;
5663
+ }
5664
+
5665
+ Object3D GetObject(UUID uid)
5666
+ {
5667
+ if (blockloop)
5668
+ return null;
5669
+
5670
+ if (GetUUID().equals(uid))
5671
+ return this;
5672
+
5673
+ int nb = Size();
5674
+ for (int i = 0; i < nb; i++)
5675
+ {
5676
+ Object3D child = (Object3D) get(i);
5677
+
5678
+ if (child == null)
5679
+ continue;
5680
+
5681
+ blockloop = true;
5682
+ Object3D obj = child.GetObject(uid);
5683
+ blockloop = false;
5684
+ if (obj != null)
5685
+ return obj;
5686
+ }
5687
+
5688
+ return null;
52795689 }
52805690
52815691 void SetBumpTexture(String tex)
....@@ -5322,12 +5732,23 @@
53225732 boolean NeedSupport()
53235733 {
53245734 return
5325
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5735
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
53265736 // PROBLEM with CROWD!!
5327
- && (Globals.DrawMode() == iCameraPane.SHADOW || Globals.CROWD);
5737
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
53285738 }
53295739
53305740 static boolean DEBUG_SELECTION = false;
5741
+
5742
+ boolean IsLive()
5743
+ {
5744
+ if (live)
5745
+ return true;
5746
+
5747
+ if (parent == null)
5748
+ return false;
5749
+
5750
+ return parent.IsLive();
5751
+ }
53315752
53325753 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
53335754 {
....@@ -5339,7 +5760,7 @@
53395760 }
53405761
53415762 if (display.DrawMode() == iCameraPane.SELECTION &&
5342
- hide)
5763
+ (hide || dontselect))
53435764 return;
53445765
53455766 if (name != null && name.contains("sclera"))
....@@ -5371,7 +5792,7 @@
53715792 return;
53725793 }
53735794
5374
- javax.media.opengl.GL gl = display.GetGL();
5795
+ //javax.media.opengl.GL gl = display.GetGL();
53755796
53765797 /*
53775798 if (touched)
....@@ -5390,7 +5811,7 @@
53905811 support = support;
53915812
53925813 //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);
5814
+ boolean usecalllists = !IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
53945815
53955816 if (!usecalllists && bRep != null && bRep.displaylist > 0)
53965817 {
....@@ -5410,10 +5831,12 @@
54105831 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
54115832
54125833 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5413
- (touched || (bRep != null && bRep.displaylist <= 0)))
5834
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5835
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
54145836 {
54155837 Globals.lighttouched = true;
54165838 } // all panes...
5839
+
54175840 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
54185841 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
54195842 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5423,7 +5846,7 @@
54235846 //if (displaylist == -1 && usecalllists)
54245847 if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
54255848 {
5426
- bRep.displaylist = gl.glGenLists(1);
5849
+ bRep.displaylist = display.GenList();
54275850 assert(bRep.displaylist != 0);
54285851 // System.err.println("glGenLists: " + bRep.displaylist + " for " + this);
54295852 //System.out.println("\tgen list " + list);
....@@ -5435,14 +5858,16 @@
54355858 if (usecalllists)
54365859 {
54375860 // System.err.println("new list " + bRep.displaylist + " for " + this);
5438
- gl.glNewList(bRep.displaylist, gl.GL_COMPILE); //_AND_EXECUTE);
5861
+ display.NewList(bRep.displaylist);
54395862 }
5863
+
54405864 CallList(display, root, selected, blocked);
5865
+
54415866 // compiled = true;
54425867 if (usecalllists)
54435868 {
54445869 // System.err.println("end list " + bRep.displaylist + " for " + this);
5445
- gl.glEndList();
5870
+ display.EndList();
54465871 }
54475872 //gl.glDrawBuffer(gl.GL_BACK);
54485873 // XXX touched = false;
....@@ -5490,7 +5915,7 @@
54905915 if (display.DrawMode() == iCameraPane.SHADOW)
54915916 {
54925917 if (!link2master // tricky to cull in shadow mode.
5493
- && GetBRep().FrustumCull(this, gl, display.LightCamera(), true))
5918
+ && GetBRep().FrustumCull(this, null, display.LightCamera(), true))
54945919 {
54955920 //System.out.print("CULLED");
54965921 culled = true;
....@@ -5498,7 +5923,7 @@
54985923 }
54995924 else
55005925 //GetBRep().getBounds(v0, v1, this);
5501
- if (GetBRep().FrustumCull(this, gl, display.RenderCamera(), false))
5926
+ if (GetBRep().FrustumCull(this, null, display.RenderCamera(), false))
55025927 culled = true;
55035928
55045929 // LA.xformPos(v0, display.renderCamera.toScreen, v0);
....@@ -5538,7 +5963,8 @@
55385963 {
55395964 if (GetBRep() != null)
55405965 {
5541
- CameraPane.NextIndex(this, gl);
5966
+ display.NextIndex();
5967
+
55425968 // vertex color conflict : gl.glCallList(list);
55435969 DrawNode(display, root, selected);
55445970 if (this instanceof BezierPatch)
....@@ -5579,7 +6005,28 @@
55796005 tex = GetTextures();
55806006 }
55816007
5582
- display.BindTextures(tex, texres);
6008
+ boolean failedPigment = false;
6009
+ boolean failedBump = false;
6010
+
6011
+ try
6012
+ {
6013
+ display.BindPigmentTexture(tex, texres);
6014
+ }
6015
+ catch (Exception e)
6016
+ {
6017
+ System.err.println("FAILED: " + this);
6018
+ failedPigment = true;
6019
+ }
6020
+
6021
+ try
6022
+ {
6023
+ display.BindBumpTexture(tex, texres);
6024
+ }
6025
+ catch (Exception e)
6026
+ {
6027
+ //System.err.println("FAILED: " + this);
6028
+ failedBump = true;
6029
+ }
55836030
55846031 if (!compiled)
55856032 {
....@@ -5595,13 +6042,17 @@
55956042
55966043 // System.err.println("glCallList: " + bRep.displaylist + " for " + this);
55976044 assert(bRep.displaylist != 0);
5598
- gl.glCallList(bRep.displaylist);
6045
+ display.CallList(bRep.displaylist);
55996046 // june 2013 drawSelf(display, root, selected);
56006047 }
56016048 }
56026049 }
56036050
5604
- display.ReleaseTextures(tex);
6051
+ if (!failedBump)
6052
+ display.ReleaseBumpTexture(tex);
6053
+
6054
+ if (!failedPigment)
6055
+ display.ReleasePigmentTexture(tex);
56056056
56066057 display.PopMaterial(this, selected);
56076058 }
....@@ -5730,6 +6181,9 @@
57306181
57316182 void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57326183 {
6184
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6185
+ return;
6186
+
57336187 if (hide)
57346188 return;
57356189 // shadow optimisation
....@@ -5855,6 +6309,9 @@
58556309 if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
58566310 return; // no shadow for transparent objects
58576311
6312
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6313
+ return;
6314
+
58586315 if (hide)
58596316 return;
58606317
....@@ -5895,9 +6352,10 @@
58956352 return;
58966353 }
58976354
6355
+ //bRep.GenUV(1/material.diffuseness);
58986356 // bRep.lock = true;
58996357
5900
- javax.media.opengl.GL gl = display.GetGL();
6358
+ //javax.media.opengl.GL gl = display.GetGL();
59016359
59026360 if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera)
59036361 {
....@@ -5914,23 +6372,7 @@
59146372
59156373 bRep.getMinMax(min, max, 100);
59166374
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();
6375
+ display.DrawBox(min, max);
59346376
59356377 return;
59366378 }
....@@ -5984,178 +6426,19 @@
59846426 new Exception().printStackTrace();
59856427 return;
59866428 }
5987
-
5988
- // TRIANGLE STRIP ARRAY
5989
- if (bRep.trimmed)
6429
+
6430
+ if (dontselect)
59906431 {
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;
6432
+ //bRep.GenerateNormalsMINE();
61226433 }
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
- }
6434
+
6435
+ display.DrawGeometry(bRep, flipV, selectmode);
61536436 } else // catch (Error e)
61546437 {
61556438 // TRIANGLE ARRAY
61566439 if (IsOpaque()) // Static())
61576440 {
6158
- gl.glBegin(gl.GL_TRIANGLES);
6441
+ display.StartTriangles();
61596442 int facecount = bRep.FaceCount();
61606443 for (int i = 0; i < facecount; i++)
61616444 {
....@@ -6220,7 +6503,7 @@
62206503
62216504 display.DrawFace(this, p, q, r, face);
62226505 }
6223
- gl.glEnd();
6506
+ display.EndTriangles();
62246507 }
62256508 else
62266509 {
....@@ -6249,8 +6532,8 @@
62496532 //System.out.println("SORT");
62506533
62516534 java.util.Arrays.sort(facescompare);
6252
-
6253
- gl.glBegin(gl.GL_TRIANGLES);
6535
+
6536
+ display.StartTriangles();
62546537 for (int i = 0; i < facecount; i++)
62556538 {
62566539 Face face = bRep.GetFace(facescompare[i].index);
....@@ -6264,11 +6547,12 @@
62646547
62656548 display.DrawFace(this, p, q, r, face);
62666549 }
6267
- gl.glEnd();
6550
+ display.EndTriangles();
62686551 }
62696552
62706553 if (false) // live && support != null && support.bRep != null) // debug weights
62716554 {
6555
+ /*
62726556 gl.glDisable(gl.GL_LIGHTING);
62736557 float[] colorV = new float[3];
62746558
....@@ -6347,6 +6631,7 @@
63476631 // gl.glEnd();
63486632 }
63496633 }
6634
+ */
63506635 }
63516636 }
63526637
....@@ -6405,22 +6690,6 @@
64056690 void Print(Vertex v)
64066691 {
64076692 //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);
64246693 }
64256694
64266695 void drawSelf(ClickInfo info, int level, boolean select)
....@@ -7013,7 +7282,7 @@
70137282 spot.translate(32, 32);
70147283 spotw = spot.x + spot.width;
70157284 spoth = spot.y + spot.height;
7016
- info.g.setColor(Color.blue);
7285
+ info.g.setColor(Color.cyan);
70177286 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
70187287 // if (CameraPane.Xmin > spot.x)
70197288 // {
....@@ -7031,11 +7300,12 @@
70317300 // {
70327301 // CameraPane.Ymax = spoth;
70337302 // }
7034
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7035
- info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7303
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7304
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
70367305 spot.translate(0, -32);
7037
- info.g.setColor(Color.green);
7306
+ info.g.setColor(Color.yellow);
70387307 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7308
+ info.g.setColor(Color.green);
70397309 // if (CameraPane.Xmin > spot.x)
70407310 // {
70417311 // CameraPane.Xmin = spot.x;
....@@ -7052,8 +7322,8 @@
70527322 // {
70537323 // CameraPane.Ymax = spoth;
70547324 // }
7055
- info.g.drawArc(boundary.x, boundary.y,
7056
- boundary.width, boundary.height, 0, 360);
7325
+ info.g.drawArc(boundary.x + info.DX, boundary.y + info.DY,
7326
+ (int)(boundary.width * info.W), (int)(boundary.height * info.W), 0, 360);
70577327 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
70587328 // if (CameraPane.Xmin > boundary.x)
70597329 // {
....@@ -7087,7 +7357,7 @@
70877357 startX = info.x;
70887358 startY = info.y;
70897359
7090
- hitSomething = 0;
7360
+ hitSomething = -1;
70917361 cVector origin = new cVector();
70927362 //LA.xformPos(origin, toParent, origin);
70937363 Rectangle spot = new Rectangle();
....@@ -7120,7 +7390,7 @@
71207390 }
71217391
71227392 //System.out.println("info.modifiers = " + info.modifiers);
7123
- modified = (info.modifiers & CameraPane.META) != 0;
7393
+ modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
71247394 //System.out.println("modified = " + modified);
71257395 //new Exception().printStackTrace();
71267396 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7148,7 +7418,7 @@
71487418 return true;
71497419 }
71507420
7151
- void doEditDrag0(ClickInfo info)
7421
+ void doEditDrag0(ClickInfo info, boolean opposite)
71527422 {
71537423 if (hitSomething == 0)
71547424 {
....@@ -7163,6 +7433,7 @@
71637433 //System.out.println("hitSomething = " + hitSomething);
71647434
71657435 double scale = 0.005f * info.camera.Distance();
7436
+
71667437 cVector xlate = new cVector();
71677438 //cVector xlate2 = new cVector();
71687439 switch (hitSomething)
....@@ -7175,7 +7446,7 @@
71757446
71767447 scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
71777448
7178
- if (modified)
7449
+ if (modified || opposite)
71797450 {
71807451 //assert(false);
71817452 /*
....@@ -7269,6 +7540,7 @@
72697540
72707541 if (modified)
72717542 {
7543
+ // Rotate 90 degrees
72727544 angle /= (Math.PI / 4);
72737545 angle = Math.floor(angle + 0.5);
72747546 angle *= (Math.PI / 4);
....@@ -7310,24 +7582,27 @@
73107582
73117583 case hitScale: // scale
73127584 double hScale = (double) (info.x - centerPt.x) / 32;
7585
+ double sign = 1;
7586
+ if (hScale < 0)
7587
+ {
7588
+ sign = -1;
7589
+ }
7590
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
73137591 if (hScale < 0.01)
73147592 {
7315
- hScale = 0.01;
7593
+ //hScale = 0.01;
73167594 }
7317
- hScale = Math.pow(hScale, scale * 50);
7318
- if (hScale < 0.01)
7319
- {
7320
- hScale = 0.01;
7321
- }
7595
+
73227596 double vScale = (double) (info.y - centerPt.y) / 32;
7323
- if (vScale < 0.01)
7597
+ sign = 1;
7598
+ if (vScale < 0)
73247599 {
7325
- vScale = 0.01;
7600
+ sign = -1;
73267601 }
7327
- vScale = Math.pow(vScale, scale * 50);
7602
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
73287603 if (vScale < 0.01)
73297604 {
7330
- vScale = 0.01;
7605
+ //vScale = 0.01;
73317606 }
73327607 LA.matCopy(startMat, toParent);
73337608 /**/
....@@ -7338,39 +7613,47 @@
73387613 }
73397614 /**/
73407615
7616
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7617
+
7618
+ if (totalScale < 0.01)
7619
+ {
7620
+ totalScale = 0.01;
7621
+ }
7622
+
73417623 switch (info.pane.RenderCamera().viewCode)
73427624 {
73437625 case 3: // '\001'
7344
- if (modified)
7626
+ if (modified || opposite)
73457627 {
73467628 //LA.matScale(toParent, 1, hScale, vScale);
7347
- LA.matScale(toParent, vScale, 1, 1);
7629
+ LA.matScale(toParent, totalScale, 1, 1);
73487630 } // vScale, 1);
73497631 else
73507632 {
7351
- LA.matScale(toParent, vScale, vScale, vScale);
7633
+ // EXCEPTION!
7634
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
73527635 } // vScale, 1);
73537636 break;
73547637
73557638 case 2: // '\002'
7356
- if (modified)
7639
+ if (modified || opposite)
73577640 {
73587641 //LA.matScale(toParent, hScale, 1, vScale);
7359
- LA.matScale(toParent, 1, vScale, 1);
7642
+ LA.matScale(toParent, 1, totalScale, 1);
73607643 } else
73617644 {
7362
- LA.matScale(toParent, vScale, 1, vScale);
7645
+ LA.matScale(toParent, totalScale, 1, totalScale);
73637646 }
73647647 break;
73657648
73667649 case 1: // '\003'
7367
- if (modified)
7650
+ if (modified || opposite)
73687651 {
73697652 //LA.matScale(toParent, hScale, vScale, 1);
7370
- LA.matScale(toParent, 1, 1, vScale);
7653
+ LA.matScale(toParent, 1, 1, totalScale);
73717654 } else
73727655 {
7373
- LA.matScale(toParent, vScale, vScale, 1);
7656
+ LA.matScale(toParent, totalScale, totalScale, 1);
73747657 }
73757658 break;
73767659 }
....@@ -7503,14 +7786,22 @@
75037786 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
75047787 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
75057788 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7789
+
7790
+ String objname;
7791
+
75067792 if (false) //parent != null)
75077793 {
7508
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7794
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
75097795 } else
75107796 {
7511
- return GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ") ")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ +System.identityHashCode(this);
7797
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
75127798 } // + super.toString();
75137799 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
7800
+
7801
+ if (!Globals.ADVANCED)
7802
+ return objname;
7803
+
7804
+ return objname + " " + System.identityHashCode(this);
75147805 }
75157806
75167807 public int hashCode()
....@@ -7566,6 +7857,7 @@
75667857 objectUI.closeUI();
75677858 if (editWindow != null)
75687859 {
7860
+ editWindow.ctrlPanel.FlushUI();
75697861 editWindow.refreshContents();
75707862 } // ? new
75717863 objectUI = null;
....@@ -7574,6 +7866,10 @@
75747866 {
75757867 editWindow = null;
75767868 } // ?
7869
+ }
7870
+ else
7871
+ {
7872
+ //editWindow.closeUI();
75777873 }
75787874 }
75797875
....@@ -7586,7 +7882,7 @@
75867882 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
75877883
75887884 Object3D /*Composite*/ parent;
7589
- Object3D /*Composite*/ fileparent;
7885
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
75907886
75917887 double[][] toParent; // dynamic matrix
75927888 double[][] fromParent;
....@@ -7701,7 +7997,7 @@
77017997 {
77027998 assert(bRep != null);
77037999 if (!(support instanceof GenericJoint)) // support.bRep != null)
7704
- GrafreeD.Assert(support.bRep == bRep.support);
8000
+ Grafreed.Assert(support.bRep == bRep.support);
77058001 }
77068002 else
77078003 {
....@@ -7732,6 +8028,10 @@
77328028 }
77338029
77348030 transient ObjEditor editWindow;
8031
+ transient ObjEditor manipWindow;
8032
+
8033
+ transient boolean pinned;
8034
+
77358035 transient ObjectUI objectUI;
77368036 public static int povDepth = 0;
77378037 private static cVector tbMin = new cVector();
....@@ -7750,9 +8050,9 @@
77508050 private static cVector edge2 = new cVector();
77518051 //private static cVector norm = new cVector();
77528052 /*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;
8053
+ static final int hitCenter = 1;
8054
+ static final int hitScale = 2;
8055
+ static final int hitRotate = 3;
77568056 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
77578057 /*transient*/ private Point centerPt;
77588058 /*transient*/ private int startX;