Normand Briere
2019-08-05 de0d8d87447fea5faea469ccf8072a7aead35b6d
Object3D.java
....@@ -14,12 +14,28 @@
1414 import //weka.core.
1515 matrix.Matrix;
1616
17
+import java.util.UUID;
18
+
1719 //import net.sourceforge.sizeof.SizeOf;
1820 public class Object3D extends Vector<Object3D> implements java.io.Serializable, iSendInfo //, aurelienribon.tweenengine.TweenAccessor<Object3D>
1921 {
2022 //static final long serialVersionUID = -607422624994562685L;
2123 static final long serialVersionUID = 5022536242724664900L;
2224
25
+ // Use GetUUID for backward compatibility with null.
26
+ private UUID uuid = UUID.randomUUID();
27
+
28
+ // TEMPORARY for mocap undo. No need to be transient.
29
+ mocap.reader.BVHReader.BVHResult savebvh;
30
+ Object3D saveskeleton;
31
+ //
32
+
33
+ String skyboxname;
34
+ String skyboxext;
35
+
36
+ Object3D versionlist[];
37
+ int versionindex = -1;
38
+
2339 ScriptNode scriptnode;
2440
2541 void InitOthers()
....@@ -100,64 +116,201 @@
100116
101117 // transient boolean reduced; // for morph reduction
102118
103
-transient com.bulletphysics.linearmath.Transform cache; // for fast merge
104
-transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
119
+ transient com.bulletphysics.linearmath.Transform cache; // for fast merge
120
+ transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
105121
106
-transient Object3D transientsupport; // for cloning
107
-transient boolean transientlink2master;
122
+ transient Object3D transientsupport; // for cloning
123
+ transient boolean transientlink2master;
108124
109
-void SaveSupports()
110
-{
111
- if (blockloop)
112
- return;
113
-
114
- transientsupport = support;
115
- transientlink2master = link2master;
116
-
117
- support = null;
118
- link2master = false;
119
-
120
- if (bRep != null)
125
+ void SaveSupports()
121126 {
122
- bRep.SaveSupports();
127
+ if (blockloop)
128
+ return;
129
+
130
+ transientsupport = support;
131
+ transientlink2master = link2master;
132
+
133
+ support = null;
134
+ link2master = false;
135
+
136
+ if (bRep != null)
137
+ {
138
+ bRep.SaveSupports();
139
+ }
140
+
141
+ for (int i = 0; i < Size(); i++)
142
+ {
143
+ Object3D child = (Object3D) get(i);
144
+ if (child == null)
145
+ continue;
146
+ blockloop = true;
147
+ child.SaveSupports();
148
+ blockloop = false;
149
+ }
123150 }
124
-
125
- for (int i = 0; i < Size(); i++)
151
+
152
+ void RestoreSupports()
126153 {
127
- Object3D child = (Object3D) get(i);
128
- if (child == null)
129
- continue;
154
+ if (blockloop)
155
+ return;
156
+
157
+ support = transientsupport;
158
+ link2master = transientlink2master;
159
+ transientsupport = null;
160
+ transientlink2master = false;
161
+
162
+ if (bRep != null)
163
+ {
164
+ bRep.RestoreSupports();
165
+ }
166
+
167
+ for (int i = 0; i < Size(); i++)
168
+ {
169
+ Object3D child = (Object3D) get(i);
170
+ if (child == null)
171
+ continue;
172
+ blockloop = true;
173
+ child.RestoreSupports();
174
+ blockloop = false;
175
+ }
176
+ }
177
+
178
+ void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
179
+ {
180
+ Object3D o;
181
+
182
+ if (hashtable.containsKey(GetUUID()))
183
+ {
184
+ o = hashtable.get(GetUUID());
185
+
186
+ Grafreed.Assert(this.bRep == o.bRep);
187
+ //if (this.bRep != null)
188
+ // assert(this.bRep.support == o.transientrep);
189
+ if (this.support != null)
190
+ assert(this.support.bRep == o.transientrep);
191
+ }
192
+ else
193
+ {
194
+ o = new Object3D("copy of " + this.name);
195
+
196
+ hashtable.put(GetUUID(), o);
197
+ }
198
+
199
+ if (!blockloop)
200
+ {
201
+ blockloop = true;
202
+
203
+ for (int i=0; i<Size(); i++)
204
+ {
205
+ get(i).ExtractBigData(hashtable);
206
+ }
207
+
208
+ blockloop = false;
209
+ }
210
+
211
+ ExtractBigData(o);
212
+ }
213
+
214
+ void ExtractBigData(Object3D o)
215
+ {
216
+ if (o.bRep != null)
217
+ Grafreed.Assert(o.bRep == this.bRep);
218
+
219
+ o.bRep = this.bRep;
220
+// July 2019 if (this.bRep != null)
221
+// {
222
+// o.transientrep = this.bRep.support;
223
+// o.bRep.support = null;
224
+// }
225
+ o.selection = this.selection;
226
+ o.versionlist = this.versionlist;
227
+ o.versionindex = this.versionindex;
228
+
229
+ if (this.support != null)
230
+ {
231
+ if (o.transientrep != null)
232
+ Grafreed.Assert(o.transientrep == this.support.bRep);
233
+
234
+ o.transientrep = this.support.bRep;
235
+ this.support.bRep = null;
236
+ }
237
+
238
+ // o.support = this.support;
239
+ // o.fileparent = this.fileparent;
240
+ // if (this.bRep != null)
241
+ // o.bRep = this.bRep.support;
242
+
243
+ this.bRep = null;
244
+ // if (this.bRep != null)
245
+ // this.bRep.support = null;
246
+ // this.support = null;
247
+ // this.fileparent = null;
248
+ }
249
+
250
+// Object3D GetObject(java.util.UUID uuid)
251
+// {
252
+// if (this.uuid.equals(uuid))
253
+// return this;
254
+//
255
+// if (blockloop)
256
+// return null;
257
+//
258
+// blockloop = true;
259
+//
260
+// for (int i=0; i<Size(); i++)
261
+// {
262
+// Object3D o = get(i).GetObject(uuid);
263
+//
264
+// if (o != null)
265
+// return o;
266
+// }
267
+//
268
+// blockloop = false;
269
+//
270
+// return null;
271
+// }
272
+
273
+ void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
274
+ {
275
+ if (!hashtable.containsKey(GetUUID()))
276
+ return;
277
+
278
+ Object3D o = hashtable.get(GetUUID());
279
+
280
+ RestoreBigData(o);
281
+
282
+ if (blockloop)
283
+ return;
284
+
130285 blockloop = true;
131
- child.SaveSupports();
286
+
287
+ //hashtable.remove(GetUUID());
288
+
289
+ for (int i=0; i<Size(); i++)
290
+ {
291
+ get(i).RestoreBigData(hashtable);
292
+ }
293
+
132294 blockloop = false;
133295 }
134
-}
135296
136
-void RestoreSupports()
137
-{
138
- if (blockloop)
139
- return;
140
-
141
- support = transientsupport;
142
- link2master = transientlink2master;
143
- transientsupport = null;
144
- transientlink2master = false;
145
-
146
- if (bRep != null)
297
+ void RestoreBigData(Object3D o)
147298 {
148
- bRep.RestoreSupports();
299
+ this.bRep = o.bRep;
300
+ if (this.support != null && o.transientrep != null)
301
+ {
302
+ this.support.bRep = o.transientrep;
303
+ }
304
+
305
+ this.selection = o.selection;
306
+
307
+ this.versionlist = o.versionlist;
308
+ this.versionindex = o.versionindex;
309
+// July 2019 if (this.bRep != null)
310
+// this.bRep.support = o.transientrep;
311
+ // this.support = o.support;
312
+ // this.fileparent = o.fileparent;
149313 }
150
-
151
- for (int i = 0; i < Size(); i++)
152
- {
153
- Object3D child = (Object3D) get(i);
154
- if (child == null)
155
- continue;
156
- blockloop = true;
157
- child.RestoreSupports();
158
- blockloop = false;
159
- }
160
-}
161314
162315 // MOCAP SUPPORT
163316 double tx,ty,tz,rx,ry,rz;
....@@ -300,6 +453,8 @@
300453 }
301454
302455 boolean live = false;
456
+ transient boolean keepdontselect;
457
+ boolean dontselect = false;
303458 boolean hide = false;
304459 boolean link2master = false; // performs reset support/master at each frame
305460 boolean marked = false; // animation node
....@@ -481,12 +636,14 @@
481636 toParent = LA.newMatrix();
482637 fromParent = LA.newMatrix();
483638 }
639
+
484640 if (toParentMarked == null)
485641 {
486642 if (maxcount != 1)
487643 {
488644 new Exception().printStackTrace();
489645 }
646
+
490647 toParentMarked = LA.newMatrix();
491648 fromParentMarked = LA.newMatrix();
492649 }
....@@ -774,7 +931,7 @@
774931 if (step == 0)
775932 step = 1;
776933 if (maxcount == 0)
777
- maxcount = 2048; // 4;
934
+ maxcount = 128; // 2048; // 4;
778935 // if (acceleration == 0)
779936 // acceleration = 10;
780937 if (delay == 0) // serial
....@@ -797,7 +954,7 @@
797954
798955 if (marked && Globals.isLIVE() && live &&
799956 //TEMP21aug2018
800
- (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
957
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
801958 currentframe != Globals.framecount)
802959 {
803960 currentframe = Globals.framecount;
....@@ -809,7 +966,8 @@
809966
810967 boolean changedir = random && Math.random() < 0.01; // && !link2master;
811968
812
- if (transformcount*factor > maxcount || (step == 1 && changedir))
969
+ if (transformcount*factor >= maxcount && (rewind || random) ||
970
+ (step == 1 && changedir))
813971 {
814972 countdown = 1;
815973 delay = speedup?8:1;
....@@ -881,6 +1039,10 @@
8811039 if (material == null || material.multiply)
8821040 return true;
8831041
1042
+ if (projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
1043
+ return false;
1044
+
1045
+ // Transparent objects are dynamic because we have to sort the triangles.
8841046 return material.opacity > 0.99;
8851047 }
8861048
....@@ -1281,6 +1443,7 @@
12811443 toParent = LA.newMatrix();
12821444 fromParent = LA.newMatrix();
12831445 }
1446
+
12841447 LA.matCopy(other.toParent, toParent);
12851448 LA.matCopy(other.fromParent, fromParent);
12861449
....@@ -1834,12 +1997,15 @@
18341997 if (obj.name == null)
18351998 continue; // can't be a null one
18361999
2000
+ // Try perfect match first.
18372001 if (n.equals(obj.name))
18382002 {
18392003 theobj = obj;
18402004 count++;
18412005 }
18422006 }
2007
+
2008
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18432009
18442010 if (count != 1)
18452011 for (int i=Size(); --i>=0;)
....@@ -2299,6 +2465,10 @@
22992465 }
23002466 */
23012467 }
2468
+ else
2469
+ {
2470
+ //((ObjEditor)editWindow).SetupUI2(null);
2471
+ }
23022472 }
23032473
23042474 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
....@@ -2340,6 +2510,14 @@
23402510 {
23412511 editWindow.refreshContents();
23422512 }
2513
+ else
2514
+ {
2515
+ if (manipWindow != null)
2516
+ {
2517
+ manipWindow.refreshContents();
2518
+ }
2519
+ }
2520
+
23432521 //if (parent != null)
23442522 //parent.refreshEditWindow();
23452523 }
....@@ -2419,7 +2597,8 @@
24192597 private static final int editSelf = 1;
24202598 private static final int editChild = 2;
24212599
2422
- void drawEditHandles(ClickInfo info, int level)
2600
+ void drawEditHandles(//ClickInfo info,
2601
+ int level)
24232602 {
24242603 if (level == 0)
24252604 {
....@@ -2427,7 +2606,8 @@
24272606 return;
24282607
24292608 Object3D selectee;
2430
- for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(info, level + 1))
2609
+ for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(//info,
2610
+ level + 1))
24312611 {
24322612 selectee = (Object3D) e.nextElement();
24332613 }
....@@ -2435,19 +2615,22 @@
24352615 } else
24362616 {
24372617 //super.
2438
- drawEditHandles0(info, level + 1);
2618
+ drawEditHandles0(//info,
2619
+ level + 1);
24392620 }
24402621 }
24412622
2442
- boolean doEditClick(ClickInfo info, int level)
2623
+ boolean doEditClick(//ClickInfo info,
2624
+ int level)
24432625 {
24442626 doSomething = 0;
24452627 if (level == 0)
24462628 {
2447
- return doParentClick(info);
2629
+ return doParentClick(); //info);
24482630 }
24492631 if (//super.
2450
- doEditClick0(info, level))
2632
+ doEditClick0(//info,
2633
+ level))
24512634 {
24522635 doSomething = 1;
24532636 return true;
....@@ -2457,7 +2640,7 @@
24572640 }
24582641 }
24592642
2460
- boolean doParentClick(ClickInfo info)
2643
+ boolean doParentClick() //ClickInfo info)
24612644 {
24622645 if (selection == null)
24632646 {
....@@ -2470,7 +2653,8 @@
24702653 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
24712654 {
24722655 Object3D selectee = (Object3D) e.nextElement();
2473
- if (selectee.doEditClick(info, 1))
2656
+ if (selectee.doEditClick(//info,
2657
+ 1))
24742658 {
24752659 childToDrag = selectee;
24762660 doSomething = 2;
....@@ -2482,13 +2666,15 @@
24822666 return retval;
24832667 }
24842668
2485
- void doEditDrag(ClickInfo info, boolean opposite)
2669
+ void doEditDrag(//ClickInfo clickInfo,
2670
+ boolean opposite)
24862671 {
24872672 switch (doSomething)
24882673 {
24892674 case 1: // '\001'
24902675 //super.
2491
- doEditDrag0(info, opposite);
2676
+ doEditDrag0(//clickInfo,
2677
+ opposite);
24922678 break;
24932679
24942680 case 2: // '\002'
....@@ -2501,11 +2687,13 @@
25012687 {
25022688 //sel.hitSomething = childToDrag.hitSomething;
25032689 //childToDrag.doEditDrag(info);
2504
- sel.doEditDrag(info, opposite);
2690
+ sel.doEditDrag(//clickInfo,
2691
+ opposite);
25052692 } else
25062693 {
25072694 //super.
2508
- doEditDrag0(info, opposite);
2695
+ doEditDrag0(//clickInfo,
2696
+ opposite);
25092697 }
25102698 }
25112699 break;
....@@ -2523,6 +2711,9 @@
25232711 {
25242712 deselectAll();
25252713 }
2714
+
2715
+ new Exception().printStackTrace();
2716
+
25262717 ClickInfo newInfo = new ClickInfo();
25272718 newInfo.flags = info.flags;
25282719 newInfo.bounds = info.bounds;
....@@ -2615,6 +2806,18 @@
26152806 void GenNormalsS(boolean crease)
26162807 {
26172808 selection.GenNormals(crease);
2809
+// for (int i=0; i<selection.size(); i++)
2810
+// {
2811
+// Object3D selectee = (Object3D) selection.elementAt(i);
2812
+// selectee.GenNormals(crease);
2813
+// }
2814
+
2815
+ //Touch();
2816
+ }
2817
+
2818
+ void GenNormalsMeshS()
2819
+ {
2820
+ selection.GenNormalsMesh();
26182821 // for (int i=0; i<selection.size(); i++)
26192822 // {
26202823 // Object3D selectee = (Object3D) selection.elementAt(i);
....@@ -2755,6 +2958,24 @@
27552958 if (child == null)
27562959 continue;
27572960 child.GenNormals(crease);
2961
+// Children().release(i);
2962
+ }
2963
+ blockloop = false;
2964
+ }
2965
+
2966
+ void GenNormalsMesh()
2967
+ {
2968
+ if (blockloop)
2969
+ return;
2970
+
2971
+ blockloop = true;
2972
+ GenNormalsMesh0();
2973
+ for (int i = 0; i < Children().Size(); i++)
2974
+ {
2975
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2976
+ if (child == null)
2977
+ continue;
2978
+ child.GenNormalsMesh();
27582979 // Children().release(i);
27592980 }
27602981 blockloop = false;
....@@ -2927,11 +3148,20 @@
29273148 }
29283149 }
29293150
3151
+ void GenNormalsMesh0()
3152
+ {
3153
+ if (bRep != null)
3154
+ {
3155
+ bRep.GenerateNormalsMesh();
3156
+ Touch();
3157
+ }
3158
+ }
3159
+
29303160 void GenNormalsMINE0()
29313161 {
29323162 if (bRep != null)
29333163 {
2934
- bRep.GenerateNormalsMINE();
3164
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
29353165 Touch();
29363166 }
29373167 }
....@@ -3002,8 +3232,10 @@
30023232 v.fromParent = LA.newMatrix();
30033233 }
30043234
3005
- LA.matConcat(v.toParent, toParent, v.toParent);
3006
- LA.matConcat(fromParent, v.fromParent, v.fromParent);
3235
+// LA.matConcat(v.toParent, toParent, v.toParent);
3236
+// LA.matConcat(fromParent, v.fromParent, v.fromParent);
3237
+ LA.matConcat(toParent, v.toParent, v.toParent);
3238
+ LA.matConcat(v.fromParent, fromParent, v.fromParent);
30073239 }
30083240
30093241 toParent = null; // LA.matIdentity(toParent);
....@@ -3236,7 +3468,9 @@
32363468 bRep.support = null;
32373469 BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
32383470 // bRep.SplitInTwo(onlyone); // thread...
3239
- temprep.SplitInTwo(reduction34, onlyone);
3471
+
3472
+ while(temprep.SplitInTwo(reduction34, onlyone));
3473
+
32403474 bRep = temprep;
32413475 bRep.support = sup;
32423476 Touch();
....@@ -3373,7 +3607,8 @@
33733607 if (blockloop)
33743608 return;
33753609
3376
- if (marked || (bRep != null && material != null)) // borderline...
3610
+ if (//marked || // does not make sense
3611
+ (bRep != null || material != null)) // borderline...
33773612 live = h;
33783613
33793614 for (int i = 0; i < Size(); i++)
....@@ -3394,7 +3629,8 @@
33943629 return;
33953630
33963631 //if (bRep != null)
3397
- if (marked || (bRep != null && material != null)) // borderline...
3632
+ if (//marked || // does not make sense
3633
+ (bRep != null || material != null)) // borderline...
33983634 link2master = h;
33993635
34003636 for (int i = 0; i < Size(); i++)
....@@ -3414,7 +3650,8 @@
34143650 if (blockloop)
34153651 return;
34163652
3417
- if (marked || (bRep != null && material != null)) // borderline...
3653
+ if (//marked || // does not make sense
3654
+ (bRep != null || material != null)) // borderline...
34183655 hide = h;
34193656
34203657 for (int i = 0; i < Size(); i++)
....@@ -3434,7 +3671,7 @@
34343671 if (blockloop)
34353672 return;
34363673
3437
- if (bRep != null && material != null) // borderline...
3674
+ if (bRep != null || material != null) // borderline...
34383675 marked = h;
34393676
34403677 for (int i = 0; i < Size(); i++)
....@@ -3444,6 +3681,46 @@
34443681 continue;
34453682 blockloop = true;
34463683 child.MarkLeaves(h);
3684
+ blockloop = false;
3685
+ // release(i);
3686
+ }
3687
+ }
3688
+
3689
+ void RewindLeaves(boolean h)
3690
+ {
3691
+ if (blockloop)
3692
+ return;
3693
+
3694
+ if (bRep != null || material != null) // borderline...
3695
+ rewind = h;
3696
+
3697
+ for (int i = 0; i < Size(); i++)
3698
+ {
3699
+ Object3D child = (Object3D) get(i); // reserve(i);
3700
+ if (child == null)
3701
+ continue;
3702
+ blockloop = true;
3703
+ child.RewindLeaves(h);
3704
+ blockloop = false;
3705
+ // release(i);
3706
+ }
3707
+ }
3708
+
3709
+ void RandomLeaves(boolean h)
3710
+ {
3711
+ if (blockloop)
3712
+ return;
3713
+
3714
+ if (bRep != null || material != null) // borderline...
3715
+ random = h;
3716
+
3717
+ for (int i = 0; i < Size(); i++)
3718
+ {
3719
+ Object3D child = (Object3D) get(i); // reserve(i);
3720
+ if (child == null)
3721
+ continue;
3722
+ blockloop = true;
3723
+ child.RandomLeaves(h);
34473724 blockloop = false;
34483725 // release(i);
34493726 }
....@@ -4221,6 +4498,55 @@
42214498 }
42224499 }
42234500
4501
+ void RepairSOV()
4502
+ {
4503
+ if (blockloop)
4504
+ return;
4505
+
4506
+ String texname = this.GetPigmentTexture();
4507
+
4508
+ if (texname.startsWith("sov"))
4509
+ {
4510
+ String[] s = texname.split("/");
4511
+
4512
+ String[] sname = s[1].split("Color.pn");
4513
+
4514
+ texname = sname[0];
4515
+
4516
+ if (sname.length > 1)
4517
+ {
4518
+ texname += "Color.jpg";
4519
+ }
4520
+
4521
+ this.SetPigmentTexture("sov/" + texname);
4522
+ }
4523
+
4524
+ texname = this.GetBumpTexture();
4525
+
4526
+ if (texname.startsWith("sov"))
4527
+ {
4528
+ String[] s = texname.split("/");
4529
+
4530
+ String[] sname = s[1].split("Bump.pn");
4531
+
4532
+ texname = sname[0];
4533
+
4534
+ if (sname.length > 1)
4535
+ {
4536
+ texname += "Bump.jpg";
4537
+ }
4538
+
4539
+ this.SetBumpTexture("sov/" + texname);
4540
+ }
4541
+
4542
+ for (int i=0; i<Size(); i++)
4543
+ {
4544
+ blockloop = true;
4545
+ get(i).RepairSOV();
4546
+ blockloop = false;
4547
+ }
4548
+ }
4549
+
42244550 void RepairTexture()
42254551 {
42264552 if (this instanceof FileObject || blockloop)
....@@ -4711,7 +5037,7 @@
47115037
47125038 cTreePath SelectLeaf(int indexcount, boolean deselect)
47135039 {
4714
- if (hide)
5040
+ if (hide || dontselect)
47155041 return null;
47165042
47175043 if (count <= 0)
....@@ -4735,9 +5061,17 @@
47355061 }
47365062 }
47375063
5064
+ ObjEditor GetWindow()
5065
+ {
5066
+ if (editWindow != null)
5067
+ return editWindow;
5068
+
5069
+ return manipWindow;
5070
+ }
5071
+
47385072 cTreePath Select(int indexcount, boolean deselect)
47395073 {
4740
- if (hide)
5074
+ if (hide || dontselect)
47415075 return null;
47425076
47435077 if (count <= 0)
....@@ -4771,10 +5105,11 @@
47715105 if (leaf != null)
47725106 {
47735107 cTreePath tp = new cTreePath(this, leaf);
4774
- if (editWindow != null)
5108
+ ObjEditor window = GetWindow();
5109
+ if (window != null)
47755110 {
47765111 //System.out.println("editWindow = " + editWindow + " vs " + this);
4777
- editWindow.Select(tp, deselect, true);
5112
+ window.Select(tp, deselect, true);
47785113 }
47795114
47805115 return tp;
....@@ -4791,6 +5126,7 @@
47915126
47925127 if (child == null)
47935128 continue;
5129
+
47945130 if (child.HasTransparency() && child.size() != 0)
47955131 {
47965132 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4800,9 +5136,10 @@
48005136 if (leaf != null)
48015137 {
48025138 cTreePath tp = new cTreePath(this, leaf);
4803
- if (editWindow != null)
5139
+ ObjEditor window = GetWindow();
5140
+ if (window != null)
48045141 {
4805
- editWindow.Select(tp, deselect, true);
5142
+ window.Select(tp, deselect, true);
48065143 }
48075144
48085145 return tp;
....@@ -5127,6 +5464,51 @@
51275464 blockloop = false;
51285465 }
51295466
5467
+ void ResetSelectable()
5468
+ {
5469
+ if (blockloop)
5470
+ return;
5471
+
5472
+ blockloop = true;
5473
+
5474
+ keepdontselect = dontselect;
5475
+ dontselect = true;
5476
+
5477
+ Object3D child;
5478
+ int nb = Size();
5479
+ for (int i = 0; i < nb; i++)
5480
+ {
5481
+ child = (Object3D) get(i);
5482
+ if (child == null)
5483
+ continue;
5484
+ child.ResetSelectable();
5485
+ }
5486
+
5487
+ blockloop = false;
5488
+ }
5489
+
5490
+ void RestoreSelectable()
5491
+ {
5492
+ if (blockloop)
5493
+ return;
5494
+
5495
+ blockloop = true;
5496
+
5497
+ dontselect = keepdontselect;
5498
+
5499
+ Object3D child;
5500
+ int nb = Size();
5501
+ for (int i = 0; i < nb; i++)
5502
+ {
5503
+ child = (Object3D) get(i);
5504
+ if (child == null)
5505
+ continue;
5506
+ child.RestoreSelectable();
5507
+ }
5508
+
5509
+ blockloop = false;
5510
+ }
5511
+
51305512 boolean IsSelected()
51315513 {
51325514 if (parent == null)
....@@ -5363,6 +5745,43 @@
53635745 }
53645746 }
53655747
5748
+ UUID GetUUID()
5749
+ {
5750
+ if (uuid == null)
5751
+ {
5752
+ // Serial
5753
+ uuid = UUID.randomUUID();
5754
+ }
5755
+
5756
+ return uuid;
5757
+ }
5758
+
5759
+ Object3D GetObject(UUID uid)
5760
+ {
5761
+ if (blockloop)
5762
+ return null;
5763
+
5764
+ if (GetUUID().equals(uid))
5765
+ return this;
5766
+
5767
+ int nb = Size();
5768
+ for (int i = 0; i < nb; i++)
5769
+ {
5770
+ Object3D child = (Object3D) get(i);
5771
+
5772
+ if (child == null)
5773
+ continue;
5774
+
5775
+ blockloop = true;
5776
+ Object3D obj = child.GetObject(uid);
5777
+ blockloop = false;
5778
+ if (obj != null)
5779
+ return obj;
5780
+ }
5781
+
5782
+ return null;
5783
+ }
5784
+
53665785 void SetBumpTexture(String tex)
53675786 {
53685787 if (GetTextures() == null)
....@@ -5399,6 +5818,38 @@
53995818 }
54005819 }
54015820
5821
+ void EmbedTextures(boolean embed)
5822
+ {
5823
+ if (blockloop)
5824
+ return;
5825
+
5826
+ //if (GetTextures() != null)
5827
+ if (embed)
5828
+ CameraPane.EmbedTextures(GetTextures());
5829
+ else
5830
+ {
5831
+ GetTextures().pigmentdata = null;
5832
+ GetTextures().bumpdata = null;
5833
+ GetTextures().pw = 0;
5834
+ GetTextures().ph = 0;
5835
+ GetTextures().bw = 0;
5836
+ GetTextures().bh = 0;
5837
+ }
5838
+
5839
+ int nb = Size();
5840
+ for (int i = 0; i < nb; i++)
5841
+ {
5842
+ Object3D child = (Object3D) get(i);
5843
+
5844
+ if (child == null)
5845
+ continue;
5846
+
5847
+ blockloop = true;
5848
+ child.EmbedTextures(embed);
5849
+ blockloop = false;
5850
+ }
5851
+ }
5852
+
54025853 void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
54035854 {
54045855 Draw(display, root, selected, blocked);
....@@ -5407,12 +5858,23 @@
54075858 boolean NeedSupport()
54085859 {
54095860 return
5410
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5861
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
54115862 // PROBLEM with CROWD!!
54125863 && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
54135864 }
54145865
54155866 static boolean DEBUG_SELECTION = false;
5867
+
5868
+ boolean IsLive()
5869
+ {
5870
+ if (live)
5871
+ return true;
5872
+
5873
+ if (parent == null)
5874
+ return false;
5875
+
5876
+ return parent.IsLive();
5877
+ }
54165878
54175879 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
54185880 {
....@@ -5424,7 +5886,7 @@
54245886 }
54255887
54265888 if (display.DrawMode() == iCameraPane.SELECTION &&
5427
- hide)
5889
+ (hide || dontselect))
54285890 return;
54295891
54305892 if (name != null && name.contains("sclera"))
....@@ -5474,8 +5936,10 @@
54745936 if (support != null)
54755937 support = support;
54765938
5477
- //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5478
- boolean usecalllists = false; // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5939
+ boolean usecalllists = !IsLive() && IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5940
+ //boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5941
+
5942
+ //usecalllists &= display.DrawMode() == display.DEFAULT; // Don't compute list in shadow pass.
54795943
54805944 if (!usecalllists && bRep != null && bRep.displaylist > 0)
54815945 {
....@@ -5485,8 +5949,9 @@
54855949 // usecalllists &= !(parent instanceof RandomNode);
54865950 // usecalllists = false;
54875951
5488
- if (GetBRep() != null)
5489
- usecalllists = usecalllists;
5952
+ if (display.DrawMode() == display.SHADOW)
5953
+ //GetBRep() != null)
5954
+ usecalllists = !!usecalllists;
54905955 //System.out.println("draw " + this);
54915956 //new Exception().printStackTrace();
54925957
....@@ -5495,10 +5960,12 @@
54955960 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
54965961
54975962 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5498
- (touched || (bRep != null && bRep.displaylist <= 0)))
5963
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5964
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
54995965 {
55005966 Globals.lighttouched = true;
55015967 } // all panes...
5968
+
55025969 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
55035970 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
55045971 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5506,7 +5973,7 @@
55065973 if (!(this instanceof Composite))
55075974 touched = false;
55085975 //if (displaylist == -1 && usecalllists)
5509
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
5976
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
55105977 {
55115978 bRep.displaylist = display.GenList();
55125979 assert(bRep.displaylist != 0);
....@@ -5517,7 +5984,7 @@
55175984
55185985 //System.out.println("\tnew list " + list);
55195986 //gl.glDrawBuffer(gl.GL_NONE);
5520
- if (usecalllists)
5987
+ if (usecalllists && bRep.displaylist > 0)
55215988 {
55225989 // System.err.println("new list " + bRep.displaylist + " for " + this);
55235990 display.NewList(bRep.displaylist);
....@@ -5526,7 +5993,7 @@
55265993 CallList(display, root, selected, blocked);
55275994
55285995 // compiled = true;
5529
- if (usecalllists)
5996
+ if (usecalllists && bRep.displaylist > 0)
55305997 {
55315998 // System.err.println("end list " + bRep.displaylist + " for " + this);
55325999 display.EndList();
....@@ -5626,6 +6093,7 @@
56266093 if (GetBRep() != null)
56276094 {
56286095 display.NextIndex();
6096
+
56296097 // vertex color conflict : gl.glCallList(list);
56306098 DrawNode(display, root, selected);
56316099 if (this instanceof BezierPatch)
....@@ -5666,7 +6134,28 @@
56666134 tex = GetTextures();
56676135 }
56686136
5669
- display.BindTextures(tex, texres);
6137
+ boolean failedPigment = false;
6138
+ boolean failedBump = false;
6139
+
6140
+ try
6141
+ {
6142
+ display.BindPigmentTexture(tex, texres);
6143
+ }
6144
+ catch (Exception e)
6145
+ {
6146
+ System.err.println("FAILED: " + this);
6147
+ failedPigment = true;
6148
+ }
6149
+
6150
+ try
6151
+ {
6152
+ display.BindBumpTexture(tex, texres);
6153
+ }
6154
+ catch (Exception e)
6155
+ {
6156
+ //System.err.println("FAILED: " + this);
6157
+ failedBump = true;
6158
+ }
56706159
56716160 if (!compiled)
56726161 {
....@@ -5688,7 +6177,11 @@
56886177 }
56896178 }
56906179
5691
- display.ReleaseTextures(tex);
6180
+ if (!failedBump)
6181
+ display.ReleaseBumpTexture(tex);
6182
+
6183
+ if (!failedPigment)
6184
+ display.ReleasePigmentTexture(tex);
56926185
56936186 display.PopMaterial(this, selected);
56946187 }
....@@ -5817,6 +6310,9 @@
58176310
58186311 void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
58196312 {
6313
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6314
+ return;
6315
+
58206316 if (hide)
58216317 return;
58226318 // shadow optimisation
....@@ -5942,6 +6438,9 @@
59426438 if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
59436439 return; // no shadow for transparent objects
59446440
6441
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6442
+ return;
6443
+
59456444 if (hide)
59466445 return;
59476446
....@@ -6055,6 +6554,11 @@
60556554 // dec 2012
60566555 new Exception().printStackTrace();
60576556 return;
6557
+ }
6558
+
6559
+ if (dontselect)
6560
+ {
6561
+ //bRep.GenerateNormalsMINE();
60586562 }
60596563
60606564 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -6840,20 +7344,23 @@
68407344 }
68417345 }
68427346
6843
- protected void calcHotSpot(cVector in, ClickInfo info, Point outPt, Rectangle outRec)
7347
+ static ClickInfo clickInfo = new ClickInfo();
7348
+
7349
+ protected void calcHotSpot(cVector in, //ClickInfo clickInfo,
7350
+ Point outPt, Rectangle outRec)
68447351 {
6845
- int hc = info.bounds.x + info.bounds.width / 2;
6846
- int vc = info.bounds.y + info.bounds.height / 2;
6847
- double[][] toscreen = info.toScreen;
7352
+ int hc = clickInfo.bounds.x + clickInfo.bounds.width / 2;
7353
+ int vc = clickInfo.bounds.y + clickInfo.bounds.height / 2;
7354
+ double[][] toscreen = clickInfo.toScreen;
68487355 if (toscreen == null)
68497356 {
6850
- toscreen = new Camera(info.camera.viewCode).toScreen;
7357
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
68517358 }
68527359 cVector vec = in;
68537360 LA.xformPos(in, toscreen, in);
68547361 //System.out.println("Distance = " + info.camera.Distance());
6855
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
6856
- vec.y *= 100 * info.camera.SCALE / info.camera.Distance();
7362
+ vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
7363
+ vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
68577364 outPt.x = hc + (int) vec.x;
68587365 outPt.y = vc - (int) vec.y;
68597366 outRec.x = outPt.x - 3;
....@@ -6861,15 +7368,18 @@
68617368 outRec.width = outRec.height = 6;
68627369 }
68637370
6864
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7371
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7372
+ )
68657373 {
68667374 Point pt = new Point(0, 0);
68677375 Rectangle rec = new Rectangle();
6868
- calcHotSpot(in, info, pt, rec);
7376
+ calcHotSpot(in, //clickInfo,
7377
+ pt, rec);
68697378 return rec;
68707379 }
68717380
6872
- void drawEditHandles0(ClickInfo info, int level)
7381
+ void drawEditHandles0(//ClickInfo clickInfo,
7382
+ int level)
68737383 {
68747384 if (level == 0)
68757385 {
....@@ -6878,16 +7388,19 @@
68787388 {
68797389 cVector origin = new cVector();
68807390 //LA.xformPos(origin, toParent, origin);
6881
- Rectangle spot = calcHotSpot(origin, info);
7391
+ if (this.clickInfo == null)
7392
+ this.clickInfo = new ClickInfo();
7393
+
7394
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
68827395 Rectangle boundary = new Rectangle();
68837396 boundary.x = spot.x - 30;
68847397 boundary.y = spot.y - 30;
68857398 boundary.width = spot.width + 60;
68867399 boundary.height = spot.height + 60;
6887
- info.g.setColor(Color.red);
7400
+ clickInfo.g.setColor(Color.red);
68887401 int spotw = spot.x + spot.width;
68897402 int spoth = spot.y + spot.height;
6890
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7403
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
68917404 // if (CameraPane.Xmin > spot.x)
68927405 // {
68937406 // CameraPane.Xmin = spot.x;
....@@ -6907,8 +7420,8 @@
69077420 spot.translate(32, 32);
69087421 spotw = spot.x + spot.width;
69097422 spoth = spot.y + spot.height;
6910
- info.g.setColor(Color.blue);
6911
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7423
+ clickInfo.g.setColor(Color.cyan);
7424
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
69127425 // if (CameraPane.Xmin > spot.x)
69137426 // {
69147427 // CameraPane.Xmin = spot.x;
....@@ -6925,11 +7438,12 @@
69257438 // {
69267439 // CameraPane.Ymax = spoth;
69277440 // }
6928
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
6929
- info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7441
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7442
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
69307443 spot.translate(0, -32);
6931
- info.g.setColor(Color.green);
6932
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7444
+ clickInfo.g.setColor(Color.yellow);
7445
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7446
+ clickInfo.g.setColor(Color.green);
69337447 // if (CameraPane.Xmin > spot.x)
69347448 // {
69357449 // CameraPane.Xmin = spot.x;
....@@ -6946,8 +7460,8 @@
69467460 // {
69477461 // CameraPane.Ymax = spoth;
69487462 // }
6949
- info.g.drawArc(boundary.x, boundary.y,
6950
- boundary.width, boundary.height, 0, 360);
7463
+ clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
7464
+ (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
69517465 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
69527466 // if (CameraPane.Xmin > boundary.x)
69537467 // {
....@@ -6969,7 +7483,8 @@
69697483 }
69707484 }
69717485
6972
- boolean doEditClick0(ClickInfo info, int level)
7486
+ boolean doEditClick0(//ClickInfo clickInfo,
7487
+ int level)
69737488 {
69747489 if (level == 0)
69757490 {
....@@ -6978,10 +7493,10 @@
69787493
69797494 boolean retval = false;
69807495
6981
- startX = info.x;
6982
- startY = info.y;
7496
+ startX = clickInfo.x;
7497
+ startY = clickInfo.y;
69837498
6984
- hitSomething = 0;
7499
+ hitSomething = -1;
69857500 cVector origin = new cVector();
69867501 //LA.xformPos(origin, toParent, origin);
69877502 Rectangle spot = new Rectangle();
....@@ -6989,22 +7504,51 @@
69897504 {
69907505 centerPt = new Point(0, 0);
69917506 }
6992
- calcHotSpot(origin, info, centerPt, spot);
6993
- if (spot.contains(info.x, info.y))
7507
+ calcHotSpot(origin, //info,
7508
+ centerPt, spot);
7509
+ if (spot.contains(clickInfo.x, clickInfo.y))
69947510 {
69957511 hitSomething = hitCenter;
69967512 retval = true;
69977513 }
69987514 spot.translate(32, 0);
6999
- if (spot.contains(info.x, info.y))
7515
+ if (spot.contains(clickInfo.x, clickInfo.y))
70007516 {
70017517 hitSomething = hitRotate;
70027518 retval = true;
70037519 }
70047520 spot.translate(0, 32);
7005
- if (spot.contains(info.x, info.y))
7521
+ if (spot.contains(clickInfo.x, clickInfo.y))
70067522 {
70077523 hitSomething = hitScale;
7524
+
7525
+ double scale = 0.005f * clickInfo.camera.Distance();
7526
+ double hScale = (double) (clickInfo.x - centerPt.x) / 32;
7527
+ double sign = 1;
7528
+ if (hScale < 0)
7529
+ {
7530
+ sign = -1;
7531
+ }
7532
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
7533
+ if (hScale < 0.01)
7534
+ {
7535
+ //hScale = 0.01;
7536
+ }
7537
+
7538
+ double vScale = (double) (clickInfo.y - centerPt.y) / 32;
7539
+ sign = 1;
7540
+ if (vScale < 0)
7541
+ {
7542
+ sign = -1;
7543
+ }
7544
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
7545
+ if (vScale < 0.01)
7546
+ {
7547
+ //vScale = 0.01;
7548
+ }
7549
+
7550
+ clickInfo.scale = Math.sqrt(hScale*hScale + vScale*vScale);
7551
+
70087552 retval = true;
70097553 }
70107554
....@@ -7014,7 +7558,7 @@
70147558 }
70157559
70167560 //System.out.println("info.modifiers = " + info.modifiers);
7017
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7561
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
70187562 //System.out.println("modified = " + modified);
70197563 //new Exception().printStackTrace();
70207564 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7042,7 +7586,8 @@
70427586 return true;
70437587 }
70447588
7045
- void doEditDrag0(ClickInfo info, boolean opposite)
7589
+ void doEditDrag0(//ClickInfo info,
7590
+ boolean opposite)
70467591 {
70477592 if (hitSomething == 0)
70487593 {
....@@ -7056,7 +7601,8 @@
70567601
70577602 //System.out.println("hitSomething = " + hitSomething);
70587603
7059
- double scale = 0.005f * info.camera.Distance();
7604
+ double scale = 0.005f * clickInfo.camera.Distance();
7605
+
70607606 cVector xlate = new cVector();
70617607 //cVector xlate2 = new cVector();
70627608 switch (hitSomething)
....@@ -7089,8 +7635,8 @@
70897635 toParent[3][i] = xlate.get(i);
70907636 LA.matInvert(toParent, fromParent);
70917637 */
7092
- cVector delta = LA.newVector(0, 0, startY - info.y);
7093
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7638
+ cVector delta = LA.newVector(0, 0, startY - clickInfo.y);
7639
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
70947640
70957641 LA.matCopy(startMat, toParent);
70967642 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7099,7 +7645,7 @@
70997645 } else
71007646 {
71017647 //LA.xformDir(delta, info.camera.fromScreen, delta);
7102
- cVector up = new cVector(info.camera.up);
7648
+ cVector up = new cVector(clickInfo.camera.up);
71037649 cVector away = new cVector();
71047650 //cVector right2 = new cVector();
71057651 //LA.vecCross(up, cVector.Z, right);
....@@ -7116,19 +7662,19 @@
71167662 LA.xformDir(up, ClickInfo.matbuffer, up);
71177663 // if (!CameraPane.LOCALTRANSFORM)
71187664 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7119
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7665
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
71207666 // if (!CameraPane.LOCALTRANSFORM)
71217667 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
71227668 //LA.vecCross(up, cVector.Z, right2);
71237669
7124
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7670
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
71257671
71267672 //System.out.println("DELTA0 = " + delta);
71277673 //System.out.println("AWAY = " + info.camera.away);
71287674 //System.out.println("UP = " + info.camera.up);
71297675 if (away.z > 0)
71307676 {
7131
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7677
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
71327678 {
71337679 delta.x = -delta.x;
71347680 } else
....@@ -7143,7 +7689,7 @@
71437689 //System.out.println("DELTA1 = " + delta);
71447690 LA.xformDir(delta, ClickInfo.matbuffer, delta);
71457691 //System.out.println("DELTA2 = " + delta);
7146
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7692
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
71477693 LA.matCopy(startMat, toParent);
71487694 //System.out.println("DELTA3 = " + delta);
71497695 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7153,8 +7699,8 @@
71537699 break;
71547700
71557701 case hitRotate: // rotate
7156
- int dx = info.x - centerPt.x;
7157
- int dy = -(info.y - centerPt.y);
7702
+ int dx = clickInfo.x - centerPt.x;
7703
+ int dy = -(clickInfo.y - centerPt.y);
71587704 double angle = (double) Math.atan2(dx, dy);
71597705 angle = -(1.570796 - angle);
71607706
....@@ -7177,7 +7723,7 @@
71777723 }
71787724 /**/
71797725
7180
- switch (info.pane.RenderCamera().viewCode)
7726
+ switch (clickInfo.pane.RenderCamera().viewCode)
71817727 {
71827728 case 1: // '\001'
71837729 LA.matZRotate(toParent, angle);
....@@ -7204,26 +7750,30 @@
72047750 break;
72057751
72067752 case hitScale: // scale
7207
- double hScale = (double) (info.x - centerPt.x) / 32;
7753
+ double hScale = (double) (clickInfo.x - centerPt.x) / 32;
7754
+ double sign = 1;
7755
+ if (hScale < 0)
7756
+ {
7757
+ sign = -1;
7758
+ }
7759
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
72087760 if (hScale < 0.01)
72097761 {
7210
- hScale = 0.01;
7762
+ //hScale = 0.01;
72117763 }
7212
- hScale = Math.pow(hScale, scale * 50);
7213
- if (hScale < 0.01)
7764
+
7765
+ double vScale = (double) (clickInfo.y - centerPt.y) / 32;
7766
+ sign = 1;
7767
+ if (vScale < 0)
72147768 {
7215
- hScale = 0.01;
7769
+ sign = -1;
72167770 }
7217
- double vScale = (double) (info.y - centerPt.y) / 32;
7771
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
72187772 if (vScale < 0.01)
72197773 {
7220
- vScale = 0.01;
7774
+ //vScale = 0.01;
72217775 }
7222
- vScale = Math.pow(vScale, scale * 50);
7223
- if (vScale < 0.01)
7224
- {
7225
- vScale = 0.01;
7226
- }
7776
+
72277777 LA.matCopy(startMat, toParent);
72287778 /**/
72297779 for (int i = 0; i < 3; i++)
....@@ -7233,39 +7783,47 @@
72337783 }
72347784 /**/
72357785
7236
- switch (info.pane.RenderCamera().viewCode)
7786
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
7787
+
7788
+ if (totalScale < 0.01)
7789
+ {
7790
+ totalScale = 0.01;
7791
+ }
7792
+
7793
+ switch (clickInfo.pane.RenderCamera().viewCode)
72377794 {
72387795 case 3: // '\001'
7239
- if (modified)
7796
+ if (modified || opposite)
72407797 {
72417798 //LA.matScale(toParent, 1, hScale, vScale);
7242
- LA.matScale(toParent, vScale, 1, 1);
7799
+ LA.matScale(toParent, totalScale, 1, 1);
72437800 } // vScale, 1);
72447801 else
72457802 {
7246
- LA.matScale(toParent, vScale, vScale, vScale);
7803
+ // EXCEPTION!
7804
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
72477805 } // vScale, 1);
72487806 break;
72497807
72507808 case 2: // '\002'
7251
- if (modified)
7809
+ if (modified || opposite)
72527810 {
72537811 //LA.matScale(toParent, hScale, 1, vScale);
7254
- LA.matScale(toParent, 1, vScale, 1);
7812
+ LA.matScale(toParent, 1, totalScale, 1);
72557813 } else
72567814 {
7257
- LA.matScale(toParent, vScale, 1, vScale);
7815
+ LA.matScale(toParent, totalScale, 1, totalScale);
72587816 }
72597817 break;
72607818
72617819 case 1: // '\003'
7262
- if (modified)
7820
+ if (modified || opposite)
72637821 {
72647822 //LA.matScale(toParent, hScale, vScale, 1);
7265
- LA.matScale(toParent, 1, 1, vScale);
7823
+ LA.matScale(toParent, 1, 1, totalScale);
72667824 } else
72677825 {
7268
- LA.matScale(toParent, vScale, vScale, 1);
7826
+ LA.matScale(toParent, totalScale, totalScale, 1);
72697827 }
72707828 break;
72717829 }
....@@ -7299,7 +7857,7 @@
72997857 } // NEW ...
73007858
73017859
7302
- info.pane.repaint();
7860
+ clickInfo.pane.repaint();
73037861 }
73047862
73057863 boolean overflow = false;
....@@ -7406,7 +7964,7 @@
74067964 objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
74077965 } else
74087966 {
7409
- objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
7967
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
74107968 } // + super.toString();
74117969 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
74127970
....@@ -7479,6 +8037,10 @@
74798037 editWindow = null;
74808038 } // ?
74818039 }
8040
+ else
8041
+ {
8042
+ //editWindow.closeUI();
8043
+ }
74828044 }
74838045
74848046 boolean root; // patch for edit windows
....@@ -7490,7 +8052,7 @@
74908052 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
74918053
74928054 Object3D /*Composite*/ parent;
7493
- Object3D /*Composite*/ fileparent;
8055
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
74948056
74958057 double[][] toParent; // dynamic matrix
74968058 double[][] fromParent;
....@@ -7636,6 +8198,10 @@
76368198 }
76378199
76388200 transient ObjEditor editWindow;
8201
+ transient ObjEditor manipWindow;
8202
+
8203
+ transient boolean pinned;
8204
+
76398205 transient ObjectUI objectUI;
76408206 public static int povDepth = 0;
76418207 private static cVector tbMin = new cVector();
....@@ -7654,9 +8220,9 @@
76548220 private static cVector edge2 = new cVector();
76558221 //private static cVector norm = new cVector();
76568222 /*transient private*/ int hitSomething;
7657
- private static final int hitCenter = 1;
7658
- private static final int hitScale = 2;
7659
- private static final int hitRotate = 3;
8223
+ static final int hitCenter = 1;
8224
+ static final int hitScale = 2;
8225
+ static final int hitRotate = 3;
76608226 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
76618227 /*transient*/ private Point centerPt;
76628228 /*transient*/ private int startX;