Normand Briere
2019-07-14 bc829f47837b5a001f911542140b0b8e63c2bb0c
Object3D.java
....@@ -5,6 +5,7 @@
55 import java.util.Vector;
66
77 import javax.media.j3d.Transform3D;
8
+import javax.media.opengl.GL;
89 import javax.vecmath.Vector3d;
910
1011 import javax.imageio.ImageIO;
....@@ -13,11 +14,20 @@
1314 import //weka.core.
1415 matrix.Matrix;
1516
17
+import java.util.UUID;
18
+
1619 //import net.sourceforge.sizeof.SizeOf;
1720 public class Object3D extends Vector<Object3D> implements java.io.Serializable, iSendInfo //, aurelienribon.tweenengine.TweenAccessor<Object3D>
1821 {
1922 //static final long serialVersionUID = -607422624994562685L;
2023 static final long serialVersionUID = 5022536242724664900L;
24
+
25
+ private UUID uuid = UUID.randomUUID();
26
+
27
+ // TEMPORARY for mocap undo. No need to be transient.
28
+ mocap.reader.BVHReader.BVHResult savebvh;
29
+ Object3D saveskeleton;
30
+ //
2131
2232 ScriptNode scriptnode;
2333
....@@ -99,64 +109,170 @@
99109
100110 // transient boolean reduced; // for morph reduction
101111
102
-transient com.bulletphysics.linearmath.Transform cache; // for fast merge
103
-transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
112
+ transient com.bulletphysics.linearmath.Transform cache; // for fast merge
113
+ transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
104114
105
-transient Object3D transientsupport; // for cloning
106
-transient boolean transientlink2master;
115
+ transient Object3D transientsupport; // for cloning
116
+ transient boolean transientlink2master;
107117
108
-void SaveSupports()
109
-{
110
- if (blockloop)
111
- return;
112
-
113
- transientsupport = support;
114
- transientlink2master = link2master;
115
-
116
- support = null;
117
- link2master = false;
118
-
119
- if (bRep != null)
118
+ void SaveSupports()
120119 {
121
- bRep.SaveSupports();
120
+ if (blockloop)
121
+ return;
122
+
123
+ transientsupport = support;
124
+ transientlink2master = link2master;
125
+
126
+ support = null;
127
+ link2master = false;
128
+
129
+ if (bRep != null)
130
+ {
131
+ bRep.SaveSupports();
132
+ }
133
+
134
+ for (int i = 0; i < Size(); i++)
135
+ {
136
+ Object3D child = (Object3D) get(i);
137
+ if (child == null)
138
+ continue;
139
+ blockloop = true;
140
+ child.SaveSupports();
141
+ blockloop = false;
142
+ }
122143 }
123
-
124
- for (int i = 0; i < Size(); i++)
144
+
145
+ void RestoreSupports()
125146 {
126
- Object3D child = (Object3D) get(i);
127
- if (child == null)
128
- continue;
147
+ if (blockloop)
148
+ return;
149
+
150
+ support = transientsupport;
151
+ link2master = transientlink2master;
152
+ transientsupport = null;
153
+ transientlink2master = false;
154
+
155
+ if (bRep != null)
156
+ {
157
+ bRep.RestoreSupports();
158
+ }
159
+
160
+ for (int i = 0; i < Size(); i++)
161
+ {
162
+ Object3D child = (Object3D) get(i);
163
+ if (child == null)
164
+ continue;
165
+ blockloop = true;
166
+ child.RestoreSupports();
167
+ blockloop = false;
168
+ }
169
+ }
170
+
171
+ void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
172
+ {
173
+ Object3D o;
174
+
175
+ if (hashtable.containsKey(GetUUID()))
176
+ {
177
+ o = hashtable.get(GetUUID());
178
+
179
+ Grafreed.Assert(this.bRep == o.bRep);
180
+ //if (this.bRep != null)
181
+ // assert(this.bRep.support == o.transientrep);
182
+ if (this.support != null)
183
+ assert(this.support.bRep == o.transientrep);
184
+ }
185
+ else
186
+ {
187
+ o = new Object3D("copy of " + this.name);
188
+
189
+ hashtable.put(GetUUID(), o);
190
+ }
191
+
192
+ if (!blockloop)
193
+ {
194
+ blockloop = true;
195
+
196
+ for (int i=0; i<Size(); i++)
197
+ {
198
+ get(i).ExtractBigData(hashtable);
199
+ }
200
+
201
+ blockloop = false;
202
+ }
203
+
204
+ ExtractBigData(o);
205
+ }
206
+
207
+ void ExtractBigData(Object3D o)
208
+ {
209
+ if (o.bRep != null)
210
+ Grafreed.Assert(o.bRep == this.bRep);
211
+
212
+ o.bRep = this.bRep;
213
+// July 2019 if (this.bRep != null)
214
+// {
215
+// o.transientrep = this.bRep.support;
216
+// o.bRep.support = null;
217
+// }
218
+
219
+ if (this.support != null)
220
+ {
221
+ if (o.transientrep != null)
222
+ Grafreed.Assert(o.transientrep == this.support.bRep);
223
+
224
+ o.transientrep = this.support.bRep;
225
+ this.support.bRep = null;
226
+ }
227
+
228
+ // o.support = this.support;
229
+ // o.fileparent = this.fileparent;
230
+ // if (this.bRep != null)
231
+ // o.bRep = this.bRep.support;
232
+
233
+ this.bRep = null;
234
+ // if (this.bRep != null)
235
+ // this.bRep.support = null;
236
+ // this.support = null;
237
+ // this.fileparent = null;
238
+ }
239
+
240
+ void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
241
+ {
242
+ if (!hashtable.containsKey(GetUUID()))
243
+ return;
244
+
245
+ Object3D o = hashtable.get(GetUUID());
246
+
247
+ RestoreBigData(o);
248
+
249
+ if (blockloop)
250
+ return;
251
+
129252 blockloop = true;
130
- child.SaveSupports();
253
+
254
+ //hashtable.remove(GetUUID());
255
+
256
+ for (int i=0; i<Size(); i++)
257
+ {
258
+ get(i).RestoreBigData(hashtable);
259
+ }
260
+
131261 blockloop = false;
132262 }
133
-}
134263
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)
264
+ void RestoreBigData(Object3D o)
146265 {
147
- bRep.RestoreSupports();
266
+ this.bRep = o.bRep;
267
+ if (this.support != null && o.transientrep != null)
268
+ {
269
+ this.support.bRep = o.transientrep;
270
+ }
271
+// July 2019 if (this.bRep != null)
272
+// this.bRep.support = o.transientrep;
273
+ // this.support = o.support;
274
+ // this.fileparent = o.fileparent;
148275 }
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
-}
160276
161277 // MOCAP SUPPORT
162278 double tx,ty,tz,rx,ry,rz;
....@@ -299,6 +415,7 @@
299415 }
300416
301417 boolean live = false;
418
+ boolean dontselect = false;
302419 boolean hide = false;
303420 boolean link2master = false; // performs reset support/master at each frame
304421 boolean marked = false; // animation node
....@@ -480,12 +597,14 @@
480597 toParent = LA.newMatrix();
481598 fromParent = LA.newMatrix();
482599 }
600
+
483601 if (toParentMarked == null)
484602 {
485603 if (maxcount != 1)
486604 {
487605 new Exception().printStackTrace();
488606 }
607
+
489608 toParentMarked = LA.newMatrix();
490609 fromParentMarked = LA.newMatrix();
491610 }
....@@ -773,7 +892,7 @@
773892 if (step == 0)
774893 step = 1;
775894 if (maxcount == 0)
776
- maxcount = 2048; // 4;
895
+ maxcount = 128; // 2048; // 4;
777896 // if (acceleration == 0)
778897 // acceleration = 10;
779898 if (delay == 0) // serial
....@@ -796,7 +915,7 @@
796915
797916 if (marked && Globals.isLIVE() && live &&
798917 //TEMP21aug2018
799
- Globals.DrawMode() == iCameraPane.SHADOW &&
918
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
800919 currentframe != Globals.framecount)
801920 {
802921 currentframe = Globals.framecount;
....@@ -808,7 +927,8 @@
808927
809928 boolean changedir = random && Math.random() < 0.01; // && !link2master;
810929
811
- if (transformcount*factor > maxcount || (step == 1 && changedir))
930
+ if (transformcount*factor >= maxcount && (rewind || random) ||
931
+ (step == 1 && changedir))
812932 {
813933 countdown = 1;
814934 delay = speedup?8:1;
....@@ -880,6 +1000,7 @@
8801000 if (material == null || material.multiply)
8811001 return true;
8821002
1003
+ // Transparent objects are dynamic because we have to sort the triangles.
8831004 return material.opacity > 0.99;
8841005 }
8851006
....@@ -911,6 +1032,11 @@
9111032 fromParent = null; // LA.newMatrix();
9121033 bRep = null; // new BoundaryRep();
9131034
1035
+ if (oname != null && oname.equals("LeftHand"))
1036
+ {
1037
+ name = oname;
1038
+ }
1039
+
9141040 /*
9151041 float hue = (float)Math.random();
9161042 Color col;
....@@ -953,7 +1079,7 @@
9531079
9541080 public Object clone()
9551081 {
956
- return GrafreeD.clone(this);
1082
+ return Grafreed.clone(this);
9571083 }
9581084
9591085 Object3D copyExpand()
....@@ -1275,6 +1401,7 @@
12751401 toParent = LA.newMatrix();
12761402 fromParent = LA.newMatrix();
12771403 }
1404
+
12781405 LA.matCopy(other.toParent, toParent);
12791406 LA.matCopy(other.fromParent, fromParent);
12801407
....@@ -1469,7 +1596,7 @@
14691596 BoundaryRep.SEUIL = other.material.cameralight;
14701597
14711598 // Set default to 0.1
1472
- BoundaryRep.SEUIL /= 2;
1599
+ BoundaryRep.SEUIL /= 4; // 2;
14731600 System.out.println("SEUIL = " + BoundaryRep.SEUIL);
14741601 }
14751602
....@@ -1728,7 +1855,7 @@
17281855 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17291856 o.bRep = transientrep;
17301857 if (clone)
1731
- o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
1858
+ o.bRep = (BoundaryRep) Grafreed.clone(transientrep);
17321859 o.CreateMaterial();
17331860 o.SetAttributes(this, -1);
17341861 //parent
....@@ -1741,7 +1868,7 @@
17411868 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17421869 o.bRep = bRep;
17431870 if (clone)
1744
- o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
1871
+ o.bRep = (BoundaryRep) Grafreed.clone(bRep);
17451872 o.CreateMaterial();
17461873 //o.overwriteThis(this, -1);
17471874 o.SetAttributes(this, -1);
....@@ -1828,12 +1955,15 @@
18281955 if (obj.name == null)
18291956 continue; // can't be a null one
18301957
1958
+ // Try perfect match first.
18311959 if (n.equals(obj.name))
18321960 {
18331961 theobj = obj;
18341962 count++;
18351963 }
18361964 }
1965
+
1966
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18371967
18381968 if (count != 1)
18391969 for (int i=Size(); --i>=0;)
....@@ -2293,12 +2423,17 @@
22932423 }
22942424 */
22952425 }
2426
+ else
2427
+ {
2428
+ //((ObjEditor)editWindow).SetupUI2(null);
2429
+ }
22962430 }
22972431
22982432 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
22992433 {
23002434 if (newWindow)
23012435 {
2436
+ new Exception().printStackTrace();
23022437 System.exit(0);
23032438 if (parent != null)
23042439 {
....@@ -2333,6 +2468,14 @@
23332468 {
23342469 editWindow.refreshContents();
23352470 }
2471
+ else
2472
+ {
2473
+ if (manipWindow != null)
2474
+ {
2475
+ manipWindow.refreshContents();
2476
+ }
2477
+ }
2478
+
23362479 //if (parent != null)
23372480 //parent.refreshEditWindow();
23382481 }
....@@ -2475,13 +2618,13 @@
24752618 return retval;
24762619 }
24772620
2478
- void doEditDrag(ClickInfo info)
2621
+ void doEditDrag(ClickInfo info, boolean opposite)
24792622 {
24802623 switch (doSomething)
24812624 {
24822625 case 1: // '\001'
24832626 //super.
2484
- doEditDrag0(info);
2627
+ doEditDrag0(info, opposite);
24852628 break;
24862629
24872630 case 2: // '\002'
....@@ -2494,11 +2637,11 @@
24942637 {
24952638 //sel.hitSomething = childToDrag.hitSomething;
24962639 //childToDrag.doEditDrag(info);
2497
- sel.doEditDrag(info);
2640
+ sel.doEditDrag(info, opposite);
24982641 } else
24992642 {
25002643 //super.
2501
- doEditDrag0(info);
2644
+ doEditDrag0(info, opposite);
25022645 }
25032646 }
25042647 break;
....@@ -2608,6 +2751,18 @@
26082751 void GenNormalsS(boolean crease)
26092752 {
26102753 selection.GenNormals(crease);
2754
+// for (int i=0; i<selection.size(); i++)
2755
+// {
2756
+// Object3D selectee = (Object3D) selection.elementAt(i);
2757
+// selectee.GenNormals(crease);
2758
+// }
2759
+
2760
+ //Touch();
2761
+ }
2762
+
2763
+ void GenNormalsMeshS()
2764
+ {
2765
+ selection.GenNormalsMesh();
26112766 // for (int i=0; i<selection.size(); i++)
26122767 // {
26132768 // Object3D selectee = (Object3D) selection.elementAt(i);
....@@ -2748,6 +2903,24 @@
27482903 if (child == null)
27492904 continue;
27502905 child.GenNormals(crease);
2906
+// Children().release(i);
2907
+ }
2908
+ blockloop = false;
2909
+ }
2910
+
2911
+ void GenNormalsMesh()
2912
+ {
2913
+ if (blockloop)
2914
+ return;
2915
+
2916
+ blockloop = true;
2917
+ GenNormalsMesh0();
2918
+ for (int i = 0; i < Children().Size(); i++)
2919
+ {
2920
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2921
+ if (child == null)
2922
+ continue;
2923
+ child.GenNormalsMesh();
27512924 // Children().release(i);
27522925 }
27532926 blockloop = false;
....@@ -2905,7 +3078,8 @@
29053078 {
29063079 if (bRep != null)
29073080 {
2908
- bRep.GenUV();
3081
+ bRep.GenUV(); //1);
3082
+ //bRep.UnfoldUV();
29093083 Touch();
29103084 }
29113085 }
....@@ -2915,6 +3089,15 @@
29153089 if (bRep != null)
29163090 {
29173091 bRep.GenerateNormals(crease);
3092
+ Touch();
3093
+ }
3094
+ }
3095
+
3096
+ void GenNormalsMesh0()
3097
+ {
3098
+ if (bRep != null)
3099
+ {
3100
+ bRep.GenerateNormalsMesh();
29183101 Touch();
29193102 }
29203103 }
....@@ -2980,6 +3163,33 @@
29803163 blockloop = false;
29813164 }
29823165
3166
+ void TransformChildren()
3167
+ {
3168
+ if (toParent != null)
3169
+ {
3170
+ for (int i=Size(); --i>=0;)
3171
+ {
3172
+ Object3D v = get(i);
3173
+
3174
+ if (v.toParent == null)
3175
+ {
3176
+ v.toParent = LA.newMatrix();
3177
+ v.fromParent = LA.newMatrix();
3178
+ }
3179
+
3180
+// LA.matConcat(v.toParent, toParent, v.toParent);
3181
+// LA.matConcat(fromParent, v.fromParent, v.fromParent);
3182
+ LA.matConcat(toParent, v.toParent, v.toParent);
3183
+ LA.matConcat(v.fromParent, fromParent, v.fromParent);
3184
+ }
3185
+
3186
+ toParent = null; // LA.matIdentity(toParent);
3187
+ fromParent = null; // LA.matIdentity(fromParent);
3188
+
3189
+ Touch();
3190
+ }
3191
+ }
3192
+
29833193 void TransformGeometry()
29843194 {
29853195 Object3D obj = this;
....@@ -3201,9 +3411,11 @@
32013411
32023412 BoundaryRep sup = bRep.support;
32033413 bRep.support = null;
3204
- BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
3414
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
32053415 // bRep.SplitInTwo(onlyone); // thread...
3206
- temprep.SplitInTwo(reduction34, onlyone);
3416
+
3417
+ while(temprep.SplitInTwo(reduction34, onlyone));
3418
+
32073419 bRep = temprep;
32083420 bRep.support = sup;
32093421 Touch();
....@@ -3340,7 +3552,8 @@
33403552 if (blockloop)
33413553 return;
33423554
3343
- if (marked || (bRep != null && material != null)) // borderline...
3555
+ if (//marked || // does not make sense
3556
+ (bRep != null || material != null)) // borderline...
33443557 live = h;
33453558
33463559 for (int i = 0; i < Size(); i++)
....@@ -3361,7 +3574,8 @@
33613574 return;
33623575
33633576 //if (bRep != null)
3364
- if (marked || (bRep != null && material != null)) // borderline...
3577
+ if (//marked || // does not make sense
3578
+ (bRep != null || material != null)) // borderline...
33653579 link2master = h;
33663580
33673581 for (int i = 0; i < Size(); i++)
....@@ -3381,7 +3595,8 @@
33813595 if (blockloop)
33823596 return;
33833597
3384
- if (marked || (bRep != null && material != null)) // borderline...
3598
+ if (//marked || // does not make sense
3599
+ (bRep != null || material != null)) // borderline...
33853600 hide = h;
33863601
33873602 for (int i = 0; i < Size(); i++)
....@@ -3401,7 +3616,7 @@
34013616 if (blockloop)
34023617 return;
34033618
3404
- if (bRep != null && material != null) // borderline...
3619
+ if (bRep != null || material != null) // borderline...
34053620 marked = h;
34063621
34073622 for (int i = 0; i < Size(); i++)
....@@ -3411,6 +3626,46 @@
34113626 continue;
34123627 blockloop = true;
34133628 child.MarkLeaves(h);
3629
+ blockloop = false;
3630
+ // release(i);
3631
+ }
3632
+ }
3633
+
3634
+ void RewindLeaves(boolean h)
3635
+ {
3636
+ if (blockloop)
3637
+ return;
3638
+
3639
+ if (bRep != null || material != null) // borderline...
3640
+ rewind = h;
3641
+
3642
+ for (int i = 0; i < Size(); i++)
3643
+ {
3644
+ Object3D child = (Object3D) get(i); // reserve(i);
3645
+ if (child == null)
3646
+ continue;
3647
+ blockloop = true;
3648
+ child.RewindLeaves(h);
3649
+ blockloop = false;
3650
+ // release(i);
3651
+ }
3652
+ }
3653
+
3654
+ void RandomLeaves(boolean h)
3655
+ {
3656
+ if (blockloop)
3657
+ return;
3658
+
3659
+ if (bRep != null || material != null) // borderline...
3660
+ random = h;
3661
+
3662
+ for (int i = 0; i < Size(); i++)
3663
+ {
3664
+ Object3D child = (Object3D) get(i); // reserve(i);
3665
+ if (child == null)
3666
+ continue;
3667
+ blockloop = true;
3668
+ child.RandomLeaves(h);
34143669 blockloop = false;
34153670 // release(i);
34163671 }
....@@ -3725,7 +3980,7 @@
37253980 if (child == null)
37263981 continue;
37273982
3728
- if (GrafreeD.RENDERME > 0)
3983
+ if (Grafreed.RENDERME > 0)
37293984 {
37303985 if (child instanceof Merge)
37313986 ((Merge)child).renderme();
....@@ -3876,7 +4131,7 @@
38764131 if (child == null)
38774132 continue;
38784133
3879
- if (GrafreeD.RENDERME > 0)
4134
+ if (Grafreed.RENDERME > 0)
38804135 {
38814136 if (child instanceof Merge)
38824137 ((Merge)child).renderme();
....@@ -4071,7 +4326,7 @@
40714326 if (child == null)
40724327 continue;
40734328
4074
- if (GrafreeD.RENDERME > 0)
4329
+ if (Grafreed.RENDERME > 0)
40754330 {
40764331 if (child instanceof Merge)
40774332 ((Merge)child).renderme();
....@@ -4184,6 +4439,55 @@
41844439 {
41854440 blockloop = true;
41864441 get(i).RepairShadow();
4442
+ blockloop = false;
4443
+ }
4444
+ }
4445
+
4446
+ void RepairSOV()
4447
+ {
4448
+ if (blockloop)
4449
+ return;
4450
+
4451
+ String texname = this.GetPigmentTexture();
4452
+
4453
+ if (texname.startsWith("sov"))
4454
+ {
4455
+ String[] s = texname.split("/");
4456
+
4457
+ String[] sname = s[1].split("Color.pn");
4458
+
4459
+ texname = sname[0];
4460
+
4461
+ if (sname.length > 1)
4462
+ {
4463
+ texname += "Color.jpg";
4464
+ }
4465
+
4466
+ this.SetPigmentTexture("sov/" + texname);
4467
+ }
4468
+
4469
+ texname = this.GetBumpTexture();
4470
+
4471
+ if (texname.startsWith("sov"))
4472
+ {
4473
+ String[] s = texname.split("/");
4474
+
4475
+ String[] sname = s[1].split("Bump.pn");
4476
+
4477
+ texname = sname[0];
4478
+
4479
+ if (sname.length > 1)
4480
+ {
4481
+ texname += "Bump.jpg";
4482
+ }
4483
+
4484
+ this.SetBumpTexture("sov/" + texname);
4485
+ }
4486
+
4487
+ for (int i=0; i<Size(); i++)
4488
+ {
4489
+ blockloop = true;
4490
+ get(i).RepairSOV();
41874491 blockloop = false;
41884492 }
41894493 }
....@@ -4678,7 +4982,7 @@
46784982
46794983 cTreePath SelectLeaf(int indexcount, boolean deselect)
46804984 {
4681
- if (hide)
4985
+ if (hide || dontselect)
46824986 return null;
46834987
46844988 if (count <= 0)
....@@ -4702,9 +5006,17 @@
47025006 }
47035007 }
47045008
5009
+ ObjEditor GetWindow()
5010
+ {
5011
+ if (editWindow != null)
5012
+ return editWindow;
5013
+
5014
+ return manipWindow;
5015
+ }
5016
+
47055017 cTreePath Select(int indexcount, boolean deselect)
47065018 {
4707
- if (hide)
5019
+ if (hide || dontselect)
47085020 return null;
47095021
47105022 if (count <= 0)
....@@ -4738,10 +5050,11 @@
47385050 if (leaf != null)
47395051 {
47405052 cTreePath tp = new cTreePath(this, leaf);
4741
- if (editWindow != null)
5053
+ ObjEditor window = GetWindow();
5054
+ if (window != null)
47425055 {
47435056 //System.out.println("editWindow = " + editWindow + " vs " + this);
4744
- editWindow.Select(tp, deselect, true);
5057
+ window.Select(tp, deselect, true);
47455058 }
47465059
47475060 return tp;
....@@ -4758,6 +5071,7 @@
47585071
47595072 if (child == null)
47605073 continue;
5074
+
47615075 if (child.HasTransparency() && child.size() != 0)
47625076 {
47635077 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4767,9 +5081,10 @@
47675081 if (leaf != null)
47685082 {
47695083 cTreePath tp = new cTreePath(this, leaf);
4770
- if (editWindow != null)
5084
+ ObjEditor window = GetWindow();
5085
+ if (window != null)
47715086 {
4772
- editWindow.Select(tp, deselect, true);
5087
+ window.Select(tp, deselect, true);
47735088 }
47745089
47755090 return tp;
....@@ -5156,10 +5471,34 @@
51565471
51575472 // System.out.println("Fullname = " + fullname);
51585473
5159
- if (fullname.name.indexOf(":") == -1)
5160
- return fullname.name;
5474
+ // Does not work on Windows due to C:
5475
+// if (fullname.name.indexOf(":") == -1)
5476
+// return fullname.name;
5477
+//
5478
+// return fullname.name.substring(0,fullname.name.indexOf(":"));
51615479
5162
- return fullname.name.substring(0,fullname.name.indexOf(":"));
5480
+ String[] split = fullname.name.split(":");
5481
+
5482
+ if (split.length == 0)
5483
+ {
5484
+ return "";
5485
+ }
5486
+
5487
+ if (split.length <= 2)
5488
+ {
5489
+ if (fullname.name.endsWith(":"))
5490
+ {
5491
+ // Windows
5492
+ return fullname.name.substring(0, fullname.name.length()-1);
5493
+ }
5494
+
5495
+ return split[0];
5496
+ }
5497
+
5498
+ // Windows
5499
+ assert(split.length == 4);
5500
+
5501
+ return split[0] + ":" + split[1];
51635502 }
51645503
51655504 static String GetBump(cTexture fullname)
....@@ -5168,10 +5507,38 @@
51685507 return "";
51695508
51705509 // 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());
5510
+ // Does not work on Windows due to C:
5511
+// if (fullname.name.indexOf(":") == -1)
5512
+// return "";
5513
+//
5514
+// return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5515
+ String[] split = fullname.name.split(":");
5516
+
5517
+ if (split.length == 0)
5518
+ {
5519
+ return "";
5520
+ }
5521
+
5522
+ if (split.length == 1)
5523
+ {
5524
+ return "";
5525
+ }
5526
+
5527
+ if (split.length == 2)
5528
+ {
5529
+ if (fullname.name.endsWith(":"))
5530
+ {
5531
+ // Windows
5532
+ return "";
5533
+ }
5534
+
5535
+ return split[1];
5536
+ }
5537
+
5538
+ // Windows
5539
+ assert(split.length == 4);
5540
+
5541
+ return split[2] + ":" + split[3];
51755542 }
51765543
51775544 String GetPigmentTexture()
....@@ -5245,7 +5612,7 @@
52455612 System.out.print("; textures = " + textures);
52465613 System.out.println("; usedtextures = " + usedtextures);
52475614
5248
- if (GetTextures() == null)
5615
+ if (GetTextures() == null) // What is that??
52495616 GetTextures().name = ":";
52505617
52515618 String texname = tex;
....@@ -5276,6 +5643,43 @@
52765643 child.ResetPigmentTexture();
52775644 blockloop = false;
52785645 }
5646
+ }
5647
+
5648
+ UUID GetUUID()
5649
+ {
5650
+ if (uuid == null)
5651
+ {
5652
+ // Serial
5653
+ uuid = UUID.randomUUID();
5654
+ }
5655
+
5656
+ return uuid;
5657
+ }
5658
+
5659
+ Object3D GetObject(UUID uid)
5660
+ {
5661
+ if (blockloop)
5662
+ return null;
5663
+
5664
+ if (GetUUID().equals(uid))
5665
+ return this;
5666
+
5667
+ int nb = Size();
5668
+ for (int i = 0; i < nb; i++)
5669
+ {
5670
+ Object3D child = (Object3D) get(i);
5671
+
5672
+ if (child == null)
5673
+ continue;
5674
+
5675
+ blockloop = true;
5676
+ Object3D obj = child.GetObject(uid);
5677
+ blockloop = false;
5678
+ if (obj != null)
5679
+ return obj;
5680
+ }
5681
+
5682
+ return null;
52795683 }
52805684
52815685 void SetBumpTexture(String tex)
....@@ -5322,12 +5726,23 @@
53225726 boolean NeedSupport()
53235727 {
53245728 return
5325
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5729
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
53265730 // PROBLEM with CROWD!!
5327
- && (Globals.DrawMode() == iCameraPane.SHADOW || Globals.CROWD);
5731
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
53285732 }
53295733
53305734 static boolean DEBUG_SELECTION = false;
5735
+
5736
+ boolean IsLive()
5737
+ {
5738
+ if (live)
5739
+ return true;
5740
+
5741
+ if (parent == null)
5742
+ return false;
5743
+
5744
+ return parent.IsLive();
5745
+ }
53315746
53325747 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
53335748 {
....@@ -5339,7 +5754,7 @@
53395754 }
53405755
53415756 if (display.DrawMode() == iCameraPane.SELECTION &&
5342
- hide)
5757
+ (hide || dontselect))
53435758 return;
53445759
53455760 if (name != null && name.contains("sclera"))
....@@ -5371,7 +5786,7 @@
53715786 return;
53725787 }
53735788
5374
- javax.media.opengl.GL gl = display.GetGL();
5789
+ //javax.media.opengl.GL gl = display.GetGL();
53755790
53765791 /*
53775792 if (touched)
....@@ -5390,7 +5805,7 @@
53905805 support = support;
53915806
53925807 //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);
5808
+ boolean usecalllists = !IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
53945809
53955810 if (!usecalllists && bRep != null && bRep.displaylist > 0)
53965811 {
....@@ -5410,10 +5825,12 @@
54105825 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
54115826
54125827 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5413
- (touched || (bRep != null && bRep.displaylist <= 0)))
5828
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5829
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
54145830 {
54155831 Globals.lighttouched = true;
54165832 } // all panes...
5833
+
54175834 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
54185835 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
54195836 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5423,7 +5840,7 @@
54235840 //if (displaylist == -1 && usecalllists)
54245841 if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
54255842 {
5426
- bRep.displaylist = gl.glGenLists(1);
5843
+ bRep.displaylist = display.GenList();
54275844 assert(bRep.displaylist != 0);
54285845 // System.err.println("glGenLists: " + bRep.displaylist + " for " + this);
54295846 //System.out.println("\tgen list " + list);
....@@ -5435,14 +5852,16 @@
54355852 if (usecalllists)
54365853 {
54375854 // System.err.println("new list " + bRep.displaylist + " for " + this);
5438
- gl.glNewList(bRep.displaylist, gl.GL_COMPILE); //_AND_EXECUTE);
5855
+ display.NewList(bRep.displaylist);
54395856 }
5857
+
54405858 CallList(display, root, selected, blocked);
5859
+
54415860 // compiled = true;
54425861 if (usecalllists)
54435862 {
54445863 // System.err.println("end list " + bRep.displaylist + " for " + this);
5445
- gl.glEndList();
5864
+ display.EndList();
54465865 }
54475866 //gl.glDrawBuffer(gl.GL_BACK);
54485867 // XXX touched = false;
....@@ -5490,7 +5909,7 @@
54905909 if (display.DrawMode() == iCameraPane.SHADOW)
54915910 {
54925911 if (!link2master // tricky to cull in shadow mode.
5493
- && GetBRep().FrustumCull(this, gl, display.LightCamera(), true))
5912
+ && GetBRep().FrustumCull(this, null, display.LightCamera(), true))
54945913 {
54955914 //System.out.print("CULLED");
54965915 culled = true;
....@@ -5498,7 +5917,7 @@
54985917 }
54995918 else
55005919 //GetBRep().getBounds(v0, v1, this);
5501
- if (GetBRep().FrustumCull(this, gl, display.RenderCamera(), false))
5920
+ if (GetBRep().FrustumCull(this, null, display.RenderCamera(), false))
55025921 culled = true;
55035922
55045923 // LA.xformPos(v0, display.renderCamera.toScreen, v0);
....@@ -5538,7 +5957,8 @@
55385957 {
55395958 if (GetBRep() != null)
55405959 {
5541
- CameraPane.NextIndex(this, gl);
5960
+ display.NextIndex();
5961
+
55425962 // vertex color conflict : gl.glCallList(list);
55435963 DrawNode(display, root, selected);
55445964 if (this instanceof BezierPatch)
....@@ -5579,7 +5999,28 @@
55795999 tex = GetTextures();
55806000 }
55816001
5582
- display.BindTextures(tex, texres);
6002
+ boolean failedPigment = false;
6003
+ boolean failedBump = false;
6004
+
6005
+ try
6006
+ {
6007
+ display.BindPigmentTexture(tex, texres);
6008
+ }
6009
+ catch (Exception e)
6010
+ {
6011
+ System.err.println("FAILED: " + this);
6012
+ failedPigment = true;
6013
+ }
6014
+
6015
+ try
6016
+ {
6017
+ display.BindBumpTexture(tex, texres);
6018
+ }
6019
+ catch (Exception e)
6020
+ {
6021
+ //System.err.println("FAILED: " + this);
6022
+ failedBump = true;
6023
+ }
55836024
55846025 if (!compiled)
55856026 {
....@@ -5595,13 +6036,17 @@
55956036
55966037 // System.err.println("glCallList: " + bRep.displaylist + " for " + this);
55976038 assert(bRep.displaylist != 0);
5598
- gl.glCallList(bRep.displaylist);
6039
+ display.CallList(bRep.displaylist);
55996040 // june 2013 drawSelf(display, root, selected);
56006041 }
56016042 }
56026043 }
56036044
5604
- display.ReleaseTextures(tex);
6045
+ if (!failedBump)
6046
+ display.ReleaseBumpTexture(tex);
6047
+
6048
+ if (!failedPigment)
6049
+ display.ReleasePigmentTexture(tex);
56056050
56066051 display.PopMaterial(this, selected);
56076052 }
....@@ -5730,6 +6175,9 @@
57306175
57316176 void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57326177 {
6178
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6179
+ return;
6180
+
57336181 if (hide)
57346182 return;
57356183 // shadow optimisation
....@@ -5855,6 +6303,9 @@
58556303 if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
58566304 return; // no shadow for transparent objects
58576305
6306
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6307
+ return;
6308
+
58586309 if (hide)
58596310 return;
58606311
....@@ -5895,9 +6346,10 @@
58956346 return;
58966347 }
58976348
6349
+ //bRep.GenUV(1/material.diffuseness);
58986350 // bRep.lock = true;
58996351
5900
- javax.media.opengl.GL gl = display.GetGL();
6352
+ //javax.media.opengl.GL gl = display.GetGL();
59016353
59026354 if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera)
59036355 {
....@@ -5914,23 +6366,7 @@
59146366
59156367 bRep.getMinMax(min, max, 100);
59166368
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();
6369
+ display.DrawBox(min, max);
59346370
59356371 return;
59366372 }
....@@ -5984,178 +6420,19 @@
59846420 new Exception().printStackTrace();
59856421 return;
59866422 }
5987
-
5988
- // TRIANGLE STRIP ARRAY
5989
- if (bRep.trimmed)
6423
+
6424
+ if (dontselect)
59906425 {
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;
6426
+ //bRep.GenerateNormalsMINE();
61226427 }
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
- }
6428
+
6429
+ display.DrawGeometry(bRep, flipV, selectmode);
61536430 } else // catch (Error e)
61546431 {
61556432 // TRIANGLE ARRAY
61566433 if (IsOpaque()) // Static())
61576434 {
6158
- gl.glBegin(gl.GL_TRIANGLES);
6435
+ display.StartTriangles();
61596436 int facecount = bRep.FaceCount();
61606437 for (int i = 0; i < facecount; i++)
61616438 {
....@@ -6220,7 +6497,7 @@
62206497
62216498 display.DrawFace(this, p, q, r, face);
62226499 }
6223
- gl.glEnd();
6500
+ display.EndTriangles();
62246501 }
62256502 else
62266503 {
....@@ -6249,8 +6526,8 @@
62496526 //System.out.println("SORT");
62506527
62516528 java.util.Arrays.sort(facescompare);
6252
-
6253
- gl.glBegin(gl.GL_TRIANGLES);
6529
+
6530
+ display.StartTriangles();
62546531 for (int i = 0; i < facecount; i++)
62556532 {
62566533 Face face = bRep.GetFace(facescompare[i].index);
....@@ -6264,11 +6541,12 @@
62646541
62656542 display.DrawFace(this, p, q, r, face);
62666543 }
6267
- gl.glEnd();
6544
+ display.EndTriangles();
62686545 }
62696546
62706547 if (false) // live && support != null && support.bRep != null) // debug weights
62716548 {
6549
+ /*
62726550 gl.glDisable(gl.GL_LIGHTING);
62736551 float[] colorV = new float[3];
62746552
....@@ -6347,6 +6625,7 @@
63476625 // gl.glEnd();
63486626 }
63496627 }
6628
+ */
63506629 }
63516630 }
63526631
....@@ -6405,22 +6684,6 @@
64056684 void Print(Vertex v)
64066685 {
64076686 //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);
64246687 }
64256688
64266689 void drawSelf(ClickInfo info, int level, boolean select)
....@@ -7013,7 +7276,7 @@
70137276 spot.translate(32, 32);
70147277 spotw = spot.x + spot.width;
70157278 spoth = spot.y + spot.height;
7016
- info.g.setColor(Color.blue);
7279
+ info.g.setColor(Color.cyan);
70177280 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
70187281 // if (CameraPane.Xmin > spot.x)
70197282 // {
....@@ -7031,11 +7294,12 @@
70317294 // {
70327295 // CameraPane.Ymax = spoth;
70337296 // }
7034
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7035
- info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7297
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7298
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
70367299 spot.translate(0, -32);
7037
- info.g.setColor(Color.green);
7300
+ info.g.setColor(Color.yellow);
70387301 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7302
+ info.g.setColor(Color.green);
70397303 // if (CameraPane.Xmin > spot.x)
70407304 // {
70417305 // CameraPane.Xmin = spot.x;
....@@ -7052,8 +7316,8 @@
70527316 // {
70537317 // CameraPane.Ymax = spoth;
70547318 // }
7055
- info.g.drawArc(boundary.x, boundary.y,
7056
- boundary.width, boundary.height, 0, 360);
7319
+ info.g.drawArc(boundary.x + info.DX, boundary.y + info.DY,
7320
+ (int)(boundary.width * info.W), (int)(boundary.height * info.W), 0, 360);
70577321 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
70587322 // if (CameraPane.Xmin > boundary.x)
70597323 // {
....@@ -7087,7 +7351,7 @@
70877351 startX = info.x;
70887352 startY = info.y;
70897353
7090
- hitSomething = 0;
7354
+ hitSomething = -1;
70917355 cVector origin = new cVector();
70927356 //LA.xformPos(origin, toParent, origin);
70937357 Rectangle spot = new Rectangle();
....@@ -7120,7 +7384,7 @@
71207384 }
71217385
71227386 //System.out.println("info.modifiers = " + info.modifiers);
7123
- modified = (info.modifiers & CameraPane.META) != 0;
7387
+ modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
71247388 //System.out.println("modified = " + modified);
71257389 //new Exception().printStackTrace();
71267390 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7148,7 +7412,7 @@
71487412 return true;
71497413 }
71507414
7151
- void doEditDrag0(ClickInfo info)
7415
+ void doEditDrag0(ClickInfo info, boolean opposite)
71527416 {
71537417 if (hitSomething == 0)
71547418 {
....@@ -7163,6 +7427,7 @@
71637427 //System.out.println("hitSomething = " + hitSomething);
71647428
71657429 double scale = 0.005f * info.camera.Distance();
7430
+
71667431 cVector xlate = new cVector();
71677432 //cVector xlate2 = new cVector();
71687433 switch (hitSomething)
....@@ -7175,7 +7440,7 @@
71757440
71767441 scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
71777442
7178
- if (modified)
7443
+ if (modified || opposite)
71797444 {
71807445 //assert(false);
71817446 /*
....@@ -7269,6 +7534,7 @@
72697534
72707535 if (modified)
72717536 {
7537
+ // Rotate 90 degrees
72727538 angle /= (Math.PI / 4);
72737539 angle = Math.floor(angle + 0.5);
72747540 angle *= (Math.PI / 4);
....@@ -7310,24 +7576,27 @@
73107576
73117577 case hitScale: // scale
73127578 double hScale = (double) (info.x - centerPt.x) / 32;
7579
+ double sign = 1;
7580
+ if (hScale < 0)
7581
+ {
7582
+ sign = -1;
7583
+ }
7584
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
73137585 if (hScale < 0.01)
73147586 {
7315
- hScale = 0.01;
7587
+ //hScale = 0.01;
73167588 }
7317
- hScale = Math.pow(hScale, scale * 50);
7318
- if (hScale < 0.01)
7319
- {
7320
- hScale = 0.01;
7321
- }
7589
+
73227590 double vScale = (double) (info.y - centerPt.y) / 32;
7323
- if (vScale < 0.01)
7591
+ sign = 1;
7592
+ if (vScale < 0)
73247593 {
7325
- vScale = 0.01;
7594
+ sign = -1;
73267595 }
7327
- vScale = Math.pow(vScale, scale * 50);
7596
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
73287597 if (vScale < 0.01)
73297598 {
7330
- vScale = 0.01;
7599
+ //vScale = 0.01;
73317600 }
73327601 LA.matCopy(startMat, toParent);
73337602 /**/
....@@ -7338,39 +7607,47 @@
73387607 }
73397608 /**/
73407609
7610
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7611
+
7612
+ if (totalScale < 0.01)
7613
+ {
7614
+ totalScale = 0.01;
7615
+ }
7616
+
73417617 switch (info.pane.RenderCamera().viewCode)
73427618 {
73437619 case 3: // '\001'
7344
- if (modified)
7620
+ if (modified || opposite)
73457621 {
73467622 //LA.matScale(toParent, 1, hScale, vScale);
7347
- LA.matScale(toParent, vScale, 1, 1);
7623
+ LA.matScale(toParent, totalScale, 1, 1);
73487624 } // vScale, 1);
73497625 else
73507626 {
7351
- LA.matScale(toParent, vScale, vScale, vScale);
7627
+ // EXCEPTION!
7628
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
73527629 } // vScale, 1);
73537630 break;
73547631
73557632 case 2: // '\002'
7356
- if (modified)
7633
+ if (modified || opposite)
73577634 {
73587635 //LA.matScale(toParent, hScale, 1, vScale);
7359
- LA.matScale(toParent, 1, vScale, 1);
7636
+ LA.matScale(toParent, 1, totalScale, 1);
73607637 } else
73617638 {
7362
- LA.matScale(toParent, vScale, 1, vScale);
7639
+ LA.matScale(toParent, totalScale, 1, totalScale);
73637640 }
73647641 break;
73657642
73667643 case 1: // '\003'
7367
- if (modified)
7644
+ if (modified || opposite)
73687645 {
73697646 //LA.matScale(toParent, hScale, vScale, 1);
7370
- LA.matScale(toParent, 1, 1, vScale);
7647
+ LA.matScale(toParent, 1, 1, totalScale);
73717648 } else
73727649 {
7373
- LA.matScale(toParent, vScale, vScale, 1);
7650
+ LA.matScale(toParent, totalScale, totalScale, 1);
73747651 }
73757652 break;
73767653 }
....@@ -7503,14 +7780,22 @@
75037780 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
75047781 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
75057782 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7783
+
7784
+ String objname;
7785
+
75067786 if (false) //parent != null)
75077787 {
7508
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7788
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
75097789 } else
75107790 {
7511
- return GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ") ")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ +System.identityHashCode(this);
7791
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
75127792 } // + super.toString();
75137793 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
7794
+
7795
+ if (!Globals.ADVANCED)
7796
+ return objname;
7797
+
7798
+ return objname + " " + System.identityHashCode(this);
75147799 }
75157800
75167801 public int hashCode()
....@@ -7566,6 +7851,7 @@
75667851 objectUI.closeUI();
75677852 if (editWindow != null)
75687853 {
7854
+ editWindow.ctrlPanel.FlushUI();
75697855 editWindow.refreshContents();
75707856 } // ? new
75717857 objectUI = null;
....@@ -7574,6 +7860,10 @@
75747860 {
75757861 editWindow = null;
75767862 } // ?
7863
+ }
7864
+ else
7865
+ {
7866
+ //editWindow.closeUI();
75777867 }
75787868 }
75797869
....@@ -7586,7 +7876,7 @@
75867876 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
75877877
75887878 Object3D /*Composite*/ parent;
7589
- Object3D /*Composite*/ fileparent;
7879
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
75907880
75917881 double[][] toParent; // dynamic matrix
75927882 double[][] fromParent;
....@@ -7701,7 +7991,7 @@
77017991 {
77027992 assert(bRep != null);
77037993 if (!(support instanceof GenericJoint)) // support.bRep != null)
7704
- GrafreeD.Assert(support.bRep == bRep.support);
7994
+ Grafreed.Assert(support.bRep == bRep.support);
77057995 }
77067996 else
77077997 {
....@@ -7732,6 +8022,10 @@
77328022 }
77338023
77348024 transient ObjEditor editWindow;
8025
+ transient ObjEditor manipWindow;
8026
+
8027
+ transient boolean pinned;
8028
+
77358029 transient ObjectUI objectUI;
77368030 public static int povDepth = 0;
77378031 private static cVector tbMin = new cVector();
....@@ -7750,9 +8044,9 @@
77508044 private static cVector edge2 = new cVector();
77518045 //private static cVector norm = new cVector();
77528046 /*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;
8047
+ static final int hitCenter = 1;
8048
+ static final int hitScale = 2;
8049
+ static final int hitRotate = 3;
77568050 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
77578051 /*transient*/ private Point centerPt;
77588052 /*transient*/ private int startX;