Normand Briere
2019-08-16 83d0c2fa0bd2e96448f776144e1a89cdb1bb6998
Object3D.java
....@@ -22,7 +22,21 @@
2222 //static final long serialVersionUID = -607422624994562685L;
2323 static final long serialVersionUID = 5022536242724664900L;
2424
25
+ // Use GetUUID for backward compatibility with null.
2526 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
+
39
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable; // = new java.util.Hashtable<java.util.UUID, Object3D>();
2640
2741 ScriptNode scriptnode;
2842
....@@ -104,125 +118,201 @@
104118
105119 // transient boolean reduced; // for morph reduction
106120
107
-transient com.bulletphysics.linearmath.Transform cache; // for fast merge
108
-transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
121
+ transient com.bulletphysics.linearmath.Transform cache; // for fast merge
122
+ transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
109123
110
-transient Object3D transientsupport; // for cloning
111
-transient boolean transientlink2master;
124
+ transient Object3D transientsupport; // for cloning
125
+ transient boolean transientlink2master;
112126
113
-void SaveSupports()
114
-{
115
- if (blockloop)
116
- return;
117
-
118
- transientsupport = support;
119
- transientlink2master = link2master;
120
-
121
- support = null;
122
- link2master = false;
123
-
124
- if (bRep != null)
127
+ void SaveSupports()
125128 {
126
- bRep.SaveSupports();
129
+ if (blockloop)
130
+ return;
131
+
132
+ transientsupport = support;
133
+ transientlink2master = link2master;
134
+
135
+ support = null;
136
+ link2master = false;
137
+
138
+ if (bRep != null)
139
+ {
140
+ bRep.SaveSupports();
141
+ }
142
+
143
+ for (int i = 0; i < Size(); i++)
144
+ {
145
+ Object3D child = (Object3D) get(i);
146
+ if (child == null)
147
+ continue;
148
+ blockloop = true;
149
+ child.SaveSupports();
150
+ blockloop = false;
151
+ }
127152 }
128
-
129
- for (int i = 0; i < Size(); i++)
130
- {
131
- Object3D child = (Object3D) get(i);
132
- if (child == null)
133
- continue;
134
- blockloop = true;
135
- child.SaveSupports();
136
- blockloop = false;
137
- }
138
-}
139153
140
-void RestoreSupports()
141
-{
142
- if (blockloop)
143
- return;
154
+ void RestoreSupports()
155
+ {
156
+ if (blockloop)
157
+ return;
144158
145
- support = transientsupport;
146
- link2master = transientlink2master;
147
- transientsupport = null;
148
- transientlink2master = false;
149
-
150
- if (bRep != null)
151
- {
152
- bRep.RestoreSupports();
153
- }
154
-
155
- for (int i = 0; i < Size(); i++)
156
- {
157
- Object3D child = (Object3D) get(i);
158
- if (child == null)
159
- continue;
160
- blockloop = true;
161
- child.RestoreSupports();
162
- blockloop = false;
163
- }
164
-}
159
+ support = transientsupport;
160
+ link2master = transientlink2master;
161
+ transientsupport = null;
162
+ transientlink2master = false;
165163
166
-void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
167
-{
168
- if (hashtable.containsKey(GetUUID()))
164
+ if (bRep != null)
165
+ {
166
+ bRep.RestoreSupports();
167
+ }
168
+
169
+ for (int i = 0; i < Size(); i++)
170
+ {
171
+ Object3D child = (Object3D) get(i);
172
+ if (child == null)
173
+ continue;
174
+ blockloop = true;
175
+ child.RestoreSupports();
176
+ blockloop = false;
177
+ }
178
+ }
179
+
180
+ void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
169181 {
182
+ Object3D o;
183
+
184
+ if (hashtable.containsKey(GetUUID()))
185
+ {
186
+ o = hashtable.get(GetUUID());
187
+
188
+ Grafreed.Assert(this.bRep == o.bRep);
189
+ //if (this.bRep != null)
190
+ // assert(this.bRep.support == o.transientrep);
191
+ if (this.support != null)
192
+ assert(this.support.bRep == o.transientrep);
193
+ }
194
+ else
195
+ {
196
+ o = new Object3D("copy of " + this.name);
197
+
198
+ hashtable.put(GetUUID(), o);
199
+ }
200
+
201
+ if (!blockloop)
202
+ {
203
+ blockloop = true;
204
+
205
+ for (int i=0; i<Size(); i++)
206
+ {
207
+ get(i).ExtractBigData(hashtable);
208
+ }
209
+
210
+ blockloop = false;
211
+ }
212
+
213
+ ExtractBigData(o);
214
+ }
215
+
216
+ void ExtractBigData(Object3D o)
217
+ {
218
+ if (o.bRep != null)
219
+ Grafreed.Assert(o.bRep == this.bRep);
220
+
221
+ o.bRep = this.bRep;
222
+// July 2019 if (this.bRep != null)
223
+// {
224
+// o.transientrep = this.bRep.support;
225
+// o.bRep.support = null;
226
+// }
227
+ o.selection = this.selection;
228
+ o.versionlist = this.versionlist;
229
+ o.versionindex = this.versionindex;
230
+
231
+ if (this.support != null)
232
+ {
233
+ if (o.transientrep != null)
234
+ Grafreed.Assert(o.transientrep == this.support.bRep);
235
+
236
+ o.transientrep = this.support.bRep;
237
+ this.support.bRep = null;
238
+ }
239
+
240
+ // o.support = this.support;
241
+ // o.fileparent = this.fileparent;
242
+ // if (this.bRep != null)
243
+ // o.bRep = this.bRep.support;
244
+
245
+ this.bRep = null;
246
+ // if (this.bRep != null)
247
+ // this.bRep.support = null;
248
+ // this.support = null;
249
+ // this.fileparent = null;
250
+ }
251
+
252
+// Object3D GetObject(java.util.UUID uuid)
253
+// {
254
+// if (this.uuid.equals(uuid))
255
+// return this;
256
+//
257
+// if (blockloop)
258
+// return null;
259
+//
260
+// blockloop = true;
261
+//
262
+// for (int i=0; i<Size(); i++)
263
+// {
264
+// Object3D o = get(i).GetObject(uuid);
265
+//
266
+// if (o != null)
267
+// return o;
268
+// }
269
+//
270
+// blockloop = false;
271
+//
272
+// return null;
273
+// }
274
+
275
+ void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
276
+ {
277
+ if (!hashtable.containsKey(GetUUID()))
278
+ return;
279
+
170280 Object3D o = hashtable.get(GetUUID());
171281
172
- assert(this.bRep == o.bRep);
173
- if (this.bRep != null)
174
- assert(this.bRep.support == o.transientrep);
175
-
176
- return;
177
- }
178
-
179
- Object3D o = new Object3D();
180
- o.bRep = this.bRep;
181
- if (this.bRep != null)
182
- {
183
- o.transientrep = this.bRep.support;
184
- o.bRep.support = null;
185
- }
186
-
187
-// o.support = this.support;
188
-// o.fileparent = this.fileparent;
189
-// if (this.bRep != null)
190
-// o.bRep = this.bRep.support;
191
-
192
- hashtable.put(GetUUID(), o);
193
-
194
- this.bRep = null;
195
-// if (this.bRep != null)
196
-// this.bRep.support = null;
197
-// this.support = null;
198
-// this.fileparent = null;
199
-
200
- for (int i=0; i<Size(); i++)
201
- {
202
- get(i).ExtractBigData(hashtable);
203
- }
204
-}
282
+ RestoreBigData(o);
205283
206
-void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
207
-{
208
- if (!hashtable.containsKey(GetUUID()))
209
- return;
210
-
211
- Object3D o = hashtable.get(GetUUID());
212
-
213
- this.bRep = o.bRep;
214
- if (this.bRep != null)
215
- this.bRep.support = o.transientrep;
216
-// this.support = o.support;
217
-// this.fileparent = o.fileparent;
218
-
219
- hashtable.remove(GetUUID());
220
-
221
- for (int i=0; i<Size(); i++)
222
- {
223
- get(i).RestoreBigData(hashtable);
284
+ if (blockloop)
285
+ return;
286
+
287
+ blockloop = true;
288
+
289
+ //hashtable.remove(GetUUID());
290
+
291
+ for (int i=0; i<Size(); i++)
292
+ {
293
+ get(i).RestoreBigData(hashtable);
294
+ }
295
+
296
+ blockloop = false;
224297 }
225
-}
298
+
299
+ void RestoreBigData(Object3D o)
300
+ {
301
+ this.bRep = o.bRep;
302
+ if (this.support != null && o.transientrep != null)
303
+ {
304
+ this.support.bRep = o.transientrep;
305
+ }
306
+
307
+ this.selection = o.selection;
308
+
309
+ this.versionlist = o.versionlist;
310
+ this.versionindex = o.versionindex;
311
+// July 2019 if (this.bRep != null)
312
+// this.bRep.support = o.transientrep;
313
+ // this.support = o.support;
314
+ // this.fileparent = o.fileparent;
315
+ }
226316
227317 // MOCAP SUPPORT
228318 double tx,ty,tz,rx,ry,rz;
....@@ -365,6 +455,7 @@
365455 }
366456
367457 boolean live = false;
458
+ transient boolean keepdontselect;
368459 boolean dontselect = false;
369460 boolean hide = false;
370461 boolean link2master = false; // performs reset support/master at each frame
....@@ -547,12 +638,14 @@
547638 toParent = LA.newMatrix();
548639 fromParent = LA.newMatrix();
549640 }
641
+
550642 if (toParentMarked == null)
551643 {
552644 if (maxcount != 1)
553645 {
554646 new Exception().printStackTrace();
555647 }
648
+
556649 toParentMarked = LA.newMatrix();
557650 fromParentMarked = LA.newMatrix();
558651 }
....@@ -863,7 +956,7 @@
863956
864957 if (marked && Globals.isLIVE() && live &&
865958 //TEMP21aug2018
866
- (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
959
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
867960 currentframe != Globals.framecount)
868961 {
869962 currentframe = Globals.framecount;
....@@ -875,7 +968,8 @@
875968
876969 boolean changedir = random && Math.random() < 0.01; // && !link2master;
877970
878
- if (transformcount*factor > maxcount || (step == 1 && changedir))
971
+ if (transformcount*factor >= maxcount && (rewind || random) ||
972
+ (step == 1 && changedir))
879973 {
880974 countdown = 1;
881975 delay = speedup?8:1;
....@@ -947,6 +1041,10 @@
9471041 if (material == null || material.multiply)
9481042 return true;
9491043
1044
+ if (projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
1045
+ return false;
1046
+
1047
+ // Transparent objects are dynamic because we have to sort the triangles.
9501048 return material.opacity > 0.99;
9511049 }
9521050
....@@ -1347,6 +1445,7 @@
13471445 toParent = LA.newMatrix();
13481446 fromParent = LA.newMatrix();
13491447 }
1448
+
13501449 LA.matCopy(other.toParent, toParent);
13511450 LA.matCopy(other.fromParent, fromParent);
13521451
....@@ -2368,6 +2467,15 @@
23682467 }
23692468 */
23702469 }
2470
+ else
2471
+ {
2472
+ //((ObjEditor)editWindow).SetupUI2(null);
2473
+ if (objectUI != null)
2474
+ ((ObjEditor)objectUI).pinButton.setSelected(pinned);
2475
+ else
2476
+ //new Exception().printStackTrace();
2477
+ System.err.println("objectUI is null");
2478
+ }
23712479 }
23722480
23732481 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
....@@ -2409,6 +2517,14 @@
24092517 {
24102518 editWindow.refreshContents();
24112519 }
2520
+ else
2521
+ {
2522
+ if (manipWindow != null)
2523
+ {
2524
+ manipWindow.refreshContents();
2525
+ }
2526
+ }
2527
+
24122528 //if (parent != null)
24132529 //parent.refreshEditWindow();
24142530 }
....@@ -2488,7 +2604,8 @@
24882604 private static final int editSelf = 1;
24892605 private static final int editChild = 2;
24902606
2491
- void drawEditHandles(ClickInfo info, int level)
2607
+ void drawEditHandles(//ClickInfo info,
2608
+ int level)
24922609 {
24932610 if (level == 0)
24942611 {
....@@ -2496,7 +2613,8 @@
24962613 return;
24972614
24982615 Object3D selectee;
2499
- for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(info, level + 1))
2616
+ for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(//info,
2617
+ level + 1))
25002618 {
25012619 selectee = (Object3D) e.nextElement();
25022620 }
....@@ -2504,19 +2622,22 @@
25042622 } else
25052623 {
25062624 //super.
2507
- drawEditHandles0(info, level + 1);
2625
+ drawEditHandles0(//info,
2626
+ level + 1);
25082627 }
25092628 }
25102629
2511
- boolean doEditClick(ClickInfo info, int level)
2630
+ boolean doEditClick(//ClickInfo info,
2631
+ int level)
25122632 {
25132633 doSomething = 0;
25142634 if (level == 0)
25152635 {
2516
- return doParentClick(info);
2636
+ return doParentClick(); //info);
25172637 }
25182638 if (//super.
2519
- doEditClick0(info, level))
2639
+ doEditClick0(//info,
2640
+ level))
25202641 {
25212642 doSomething = 1;
25222643 return true;
....@@ -2526,7 +2647,7 @@
25262647 }
25272648 }
25282649
2529
- boolean doParentClick(ClickInfo info)
2650
+ boolean doParentClick() //ClickInfo info)
25302651 {
25312652 if (selection == null)
25322653 {
....@@ -2539,7 +2660,8 @@
25392660 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
25402661 {
25412662 Object3D selectee = (Object3D) e.nextElement();
2542
- if (selectee.doEditClick(info, 1))
2663
+ if (selectee.doEditClick(//info,
2664
+ 1))
25432665 {
25442666 childToDrag = selectee;
25452667 doSomething = 2;
....@@ -2551,13 +2673,15 @@
25512673 return retval;
25522674 }
25532675
2554
- void doEditDrag(ClickInfo info, boolean opposite)
2676
+ void doEditDrag(//ClickInfo clickInfo,
2677
+ boolean opposite)
25552678 {
25562679 switch (doSomething)
25572680 {
25582681 case 1: // '\001'
25592682 //super.
2560
- doEditDrag0(info, opposite);
2683
+ doEditDrag0(//clickInfo,
2684
+ opposite);
25612685 break;
25622686
25632687 case 2: // '\002'
....@@ -2570,11 +2694,13 @@
25702694 {
25712695 //sel.hitSomething = childToDrag.hitSomething;
25722696 //childToDrag.doEditDrag(info);
2573
- sel.doEditDrag(info, opposite);
2697
+ sel.doEditDrag(//clickInfo,
2698
+ opposite);
25742699 } else
25752700 {
25762701 //super.
2577
- doEditDrag0(info, opposite);
2702
+ doEditDrag0(//clickInfo,
2703
+ opposite);
25782704 }
25792705 }
25802706 break;
....@@ -2592,6 +2718,9 @@
25922718 {
25932719 deselectAll();
25942720 }
2721
+
2722
+ new Exception().printStackTrace();
2723
+
25952724 ClickInfo newInfo = new ClickInfo();
25962725 newInfo.flags = info.flags;
25972726 newInfo.bounds = info.bounds;
....@@ -2684,6 +2813,18 @@
26842813 void GenNormalsS(boolean crease)
26852814 {
26862815 selection.GenNormals(crease);
2816
+// for (int i=0; i<selection.size(); i++)
2817
+// {
2818
+// Object3D selectee = (Object3D) selection.elementAt(i);
2819
+// selectee.GenNormals(crease);
2820
+// }
2821
+
2822
+ //Touch();
2823
+ }
2824
+
2825
+ void GenNormalsMeshS()
2826
+ {
2827
+ selection.GenNormalsMesh();
26872828 // for (int i=0; i<selection.size(); i++)
26882829 // {
26892830 // Object3D selectee = (Object3D) selection.elementAt(i);
....@@ -2824,6 +2965,24 @@
28242965 if (child == null)
28252966 continue;
28262967 child.GenNormals(crease);
2968
+// Children().release(i);
2969
+ }
2970
+ blockloop = false;
2971
+ }
2972
+
2973
+ void GenNormalsMesh()
2974
+ {
2975
+ if (blockloop)
2976
+ return;
2977
+
2978
+ blockloop = true;
2979
+ GenNormalsMesh0();
2980
+ for (int i = 0; i < Children().Size(); i++)
2981
+ {
2982
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2983
+ if (child == null)
2984
+ continue;
2985
+ child.GenNormalsMesh();
28272986 // Children().release(i);
28282987 }
28292988 blockloop = false;
....@@ -2996,11 +3155,20 @@
29963155 }
29973156 }
29983157
3158
+ void GenNormalsMesh0()
3159
+ {
3160
+ if (bRep != null)
3161
+ {
3162
+ bRep.GenerateNormalsMesh();
3163
+ Touch();
3164
+ }
3165
+ }
3166
+
29993167 void GenNormalsMINE0()
30003168 {
30013169 if (bRep != null)
30023170 {
3003
- bRep.GenerateNormalsMINE();
3171
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
30043172 Touch();
30053173 }
30063174 }
....@@ -3446,7 +3614,8 @@
34463614 if (blockloop)
34473615 return;
34483616
3449
- if (marked || (bRep != null && material != null)) // borderline...
3617
+ if (//marked || // does not make sense
3618
+ (bRep != null || material != null)) // borderline...
34503619 live = h;
34513620
34523621 for (int i = 0; i < Size(); i++)
....@@ -3467,7 +3636,8 @@
34673636 return;
34683637
34693638 //if (bRep != null)
3470
- if (marked || (bRep != null && material != null)) // borderline...
3639
+ if (//marked || // does not make sense
3640
+ (bRep != null || material != null)) // borderline...
34713641 link2master = h;
34723642
34733643 for (int i = 0; i < Size(); i++)
....@@ -3487,7 +3657,8 @@
34873657 if (blockloop)
34883658 return;
34893659
3490
- if (marked || (bRep != null && material != null)) // borderline...
3660
+ if (//marked || // does not make sense
3661
+ (bRep != null || material != null)) // borderline...
34913662 hide = h;
34923663
34933664 for (int i = 0; i < Size(); i++)
....@@ -3507,7 +3678,7 @@
35073678 if (blockloop)
35083679 return;
35093680
3510
- if (bRep != null && material != null) // borderline...
3681
+ if (bRep != null || material != null) // borderline...
35113682 marked = h;
35123683
35133684 for (int i = 0; i < Size(); i++)
....@@ -3517,6 +3688,46 @@
35173688 continue;
35183689 blockloop = true;
35193690 child.MarkLeaves(h);
3691
+ blockloop = false;
3692
+ // release(i);
3693
+ }
3694
+ }
3695
+
3696
+ void RewindLeaves(boolean h)
3697
+ {
3698
+ if (blockloop)
3699
+ return;
3700
+
3701
+ if (bRep != null || material != null) // borderline...
3702
+ rewind = h;
3703
+
3704
+ for (int i = 0; i < Size(); i++)
3705
+ {
3706
+ Object3D child = (Object3D) get(i); // reserve(i);
3707
+ if (child == null)
3708
+ continue;
3709
+ blockloop = true;
3710
+ child.RewindLeaves(h);
3711
+ blockloop = false;
3712
+ // release(i);
3713
+ }
3714
+ }
3715
+
3716
+ void RandomLeaves(boolean h)
3717
+ {
3718
+ if (blockloop)
3719
+ return;
3720
+
3721
+ if (bRep != null || material != null) // borderline...
3722
+ random = h;
3723
+
3724
+ for (int i = 0; i < Size(); i++)
3725
+ {
3726
+ Object3D child = (Object3D) get(i); // reserve(i);
3727
+ if (child == null)
3728
+ continue;
3729
+ blockloop = true;
3730
+ child.RandomLeaves(h);
35203731 blockloop = false;
35213732 // release(i);
35223733 }
....@@ -4294,6 +4505,55 @@
42944505 }
42954506 }
42964507
4508
+ void RepairSOV()
4509
+ {
4510
+ if (blockloop)
4511
+ return;
4512
+
4513
+ String texname = this.GetPigmentTexture();
4514
+
4515
+ if (texname.startsWith("sov"))
4516
+ {
4517
+ String[] s = texname.split("/");
4518
+
4519
+ String[] sname = s[1].split("Color.pn");
4520
+
4521
+ texname = sname[0];
4522
+
4523
+ if (sname.length > 1)
4524
+ {
4525
+ texname += "Color.jpg";
4526
+ }
4527
+
4528
+ this.SetPigmentTexture("sov/" + texname);
4529
+ }
4530
+
4531
+ texname = this.GetBumpTexture();
4532
+
4533
+ if (texname.startsWith("sov"))
4534
+ {
4535
+ String[] s = texname.split("/");
4536
+
4537
+ String[] sname = s[1].split("Bump.pn");
4538
+
4539
+ texname = sname[0];
4540
+
4541
+ if (sname.length > 1)
4542
+ {
4543
+ texname += "Bump.jpg";
4544
+ }
4545
+
4546
+ this.SetBumpTexture("sov/" + texname);
4547
+ }
4548
+
4549
+ for (int i=0; i<Size(); i++)
4550
+ {
4551
+ blockloop = true;
4552
+ get(i).RepairSOV();
4553
+ blockloop = false;
4554
+ }
4555
+ }
4556
+
42974557 void RepairTexture()
42984558 {
42994559 if (this instanceof FileObject || blockloop)
....@@ -4808,6 +5068,14 @@
48085068 }
48095069 }
48105070
5071
+ ObjEditor GetWindow()
5072
+ {
5073
+ if (editWindow != null)
5074
+ return editWindow;
5075
+
5076
+ return manipWindow;
5077
+ }
5078
+
48115079 cTreePath Select(int indexcount, boolean deselect)
48125080 {
48135081 if (hide || dontselect)
....@@ -4844,10 +5112,11 @@
48445112 if (leaf != null)
48455113 {
48465114 cTreePath tp = new cTreePath(this, leaf);
4847
- if (editWindow != null)
5115
+ ObjEditor window = GetWindow();
5116
+ if (window != null)
48485117 {
48495118 //System.out.println("editWindow = " + editWindow + " vs " + this);
4850
- editWindow.Select(tp, deselect, true);
5119
+ window.Select(tp, deselect, true);
48515120 }
48525121
48535122 return tp;
....@@ -4864,6 +5133,7 @@
48645133
48655134 if (child == null)
48665135 continue;
5136
+
48675137 if (child.HasTransparency() && child.size() != 0)
48685138 {
48695139 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4873,9 +5143,10 @@
48735143 if (leaf != null)
48745144 {
48755145 cTreePath tp = new cTreePath(this, leaf);
4876
- if (editWindow != null)
5146
+ ObjEditor window = GetWindow();
5147
+ if (window != null)
48775148 {
4878
- editWindow.Select(tp, deselect, true);
5149
+ window.Select(tp, deselect, true);
48795150 }
48805151
48815152 return tp;
....@@ -5200,6 +5471,51 @@
52005471 blockloop = false;
52015472 }
52025473
5474
+ void ResetSelectable()
5475
+ {
5476
+ if (blockloop)
5477
+ return;
5478
+
5479
+ blockloop = true;
5480
+
5481
+ keepdontselect = dontselect;
5482
+ dontselect = true;
5483
+
5484
+ Object3D child;
5485
+ int nb = Size();
5486
+ for (int i = 0; i < nb; i++)
5487
+ {
5488
+ child = (Object3D) get(i);
5489
+ if (child == null)
5490
+ continue;
5491
+ child.ResetSelectable();
5492
+ }
5493
+
5494
+ blockloop = false;
5495
+ }
5496
+
5497
+ void RestoreSelectable()
5498
+ {
5499
+ if (blockloop)
5500
+ return;
5501
+
5502
+ blockloop = true;
5503
+
5504
+ dontselect = keepdontselect;
5505
+
5506
+ Object3D child;
5507
+ int nb = Size();
5508
+ for (int i = 0; i < nb; i++)
5509
+ {
5510
+ child = (Object3D) get(i);
5511
+ if (child == null)
5512
+ continue;
5513
+ child.RestoreSelectable();
5514
+ }
5515
+
5516
+ blockloop = false;
5517
+ }
5518
+
52035519 boolean IsSelected()
52045520 {
52055521 if (parent == null)
....@@ -5260,6 +5576,11 @@
52605576 if (fullname == null)
52615577 return "";
52625578
5579
+ if (fullname.pigment != null)
5580
+ {
5581
+ return fullname.pigment;
5582
+ }
5583
+
52635584 // System.out.println("Fullname = " + fullname);
52645585
52655586 // Does not work on Windows due to C:
....@@ -5272,7 +5593,7 @@
52725593
52735594 if (split.length == 0)
52745595 {
5275
- return "";
5596
+ return fullname.pigment = "";
52765597 }
52775598
52785599 if (split.length <= 2)
....@@ -5280,22 +5601,27 @@
52805601 if (fullname.name.endsWith(":"))
52815602 {
52825603 // Windows
5283
- return fullname.name.substring(0, fullname.name.length()-1);
5604
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
52845605 }
52855606
5286
- return split[0];
5607
+ return fullname.pigment = split[0];
52875608 }
52885609
52895610 // Windows
52905611 assert(split.length == 4);
52915612
5292
- return split[0] + ":" + split[1];
5613
+ return fullname.pigment = split[0] + ":" + split[1];
52935614 }
52945615
52955616 static String GetBump(cTexture fullname)
52965617 {
52975618 if (fullname == null)
52985619 return "";
5620
+
5621
+ if (fullname.bump != null)
5622
+ {
5623
+ return fullname.bump;
5624
+ }
52995625
53005626 // System.out.println("Fullname = " + fullname);
53015627 // Does not work on Windows due to C:
....@@ -5307,12 +5633,12 @@
53075633
53085634 if (split.length == 0)
53095635 {
5310
- return "";
5636
+ return fullname.bump = "";
53115637 }
53125638
53135639 if (split.length == 1)
53145640 {
5315
- return "";
5641
+ return fullname.bump = "";
53165642 }
53175643
53185644 if (split.length == 2)
....@@ -5320,16 +5646,16 @@
53205646 if (fullname.name.endsWith(":"))
53215647 {
53225648 // Windows
5323
- return "";
5649
+ return fullname.bump = "";
53245650 }
53255651
5326
- return split[1];
5652
+ return fullname.bump = split[1];
53275653 }
53285654
53295655 // Windows
53305656 assert(split.length == 4);
53315657
5332
- return split[2] + ":" + split[3];
5658
+ return fullname.bump = split[2] + ":" + split[3];
53335659 }
53345660
53355661 String GetPigmentTexture()
....@@ -5412,6 +5738,9 @@
54125738 texname = "";
54135739
54145740 GetTextures().name = texname + ":" + GetBump(GetTextures());
5741
+
5742
+ GetTextures().pigment = null;
5743
+
54155744 Touch();
54165745 }
54175746
....@@ -5485,6 +5814,8 @@
54855814
54865815 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
54875816
5817
+ GetTextures().bump = null;
5818
+
54885819 Touch();
54895820 }
54905821
....@@ -5509,6 +5840,38 @@
55095840 }
55105841 }
55115842
5843
+ void EmbedTextures(boolean embed)
5844
+ {
5845
+ if (blockloop)
5846
+ return;
5847
+
5848
+ //if (GetTextures() != null)
5849
+ if (embed)
5850
+ CameraPane.EmbedTextures(GetTextures());
5851
+ else
5852
+ {
5853
+ GetTextures().pigmentdata = null;
5854
+ GetTextures().bumpdata = null;
5855
+ GetTextures().pw = 0;
5856
+ GetTextures().ph = 0;
5857
+ GetTextures().bw = 0;
5858
+ GetTextures().bh = 0;
5859
+ }
5860
+
5861
+ int nb = Size();
5862
+ for (int i = 0; i < nb; i++)
5863
+ {
5864
+ Object3D child = (Object3D) get(i);
5865
+
5866
+ if (child == null)
5867
+ continue;
5868
+
5869
+ blockloop = true;
5870
+ child.EmbedTextures(embed);
5871
+ blockloop = false;
5872
+ }
5873
+ }
5874
+
55125875 void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
55135876 {
55145877 Draw(display, root, selected, blocked);
....@@ -5517,12 +5880,23 @@
55175880 boolean NeedSupport()
55185881 {
55195882 return
5520
- CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null
5883
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
55215884 // PROBLEM with CROWD!!
55225885 && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
55235886 }
55245887
55255888 static boolean DEBUG_SELECTION = false;
5889
+
5890
+ boolean IsLive()
5891
+ {
5892
+ if (live)
5893
+ return true;
5894
+
5895
+ if (parent == null)
5896
+ return false;
5897
+
5898
+ return parent.IsLive();
5899
+ }
55265900
55275901 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
55285902 {
....@@ -5584,8 +5958,10 @@
55845958 if (support != null)
55855959 support = support;
55865960
5587
- //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5588
- boolean usecalllists = false; // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5961
+ boolean usecalllists = !IsLive() && IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5962
+ //boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5963
+
5964
+ //usecalllists &= display.DrawMode() == display.DEFAULT; // Don't compute list in shadow pass.
55895965
55905966 if (!usecalllists && bRep != null && bRep.displaylist > 0)
55915967 {
....@@ -5595,8 +5971,9 @@
55955971 // usecalllists &= !(parent instanceof RandomNode);
55965972 // usecalllists = false;
55975973
5598
- if (GetBRep() != null)
5599
- usecalllists = usecalllists;
5974
+ if (display.DrawMode() == display.SHADOW)
5975
+ //GetBRep() != null)
5976
+ usecalllists = !!usecalllists;
56005977 //System.out.println("draw " + this);
56015978 //new Exception().printStackTrace();
56025979
....@@ -5605,10 +5982,12 @@
56055982 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
56065983
56075984 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5608
- (touched || (bRep != null && bRep.displaylist <= 0)))
5985
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5986
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
56095987 {
56105988 Globals.lighttouched = true;
56115989 } // all panes...
5990
+
56125991 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
56135992 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
56145993 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5616,7 +5995,7 @@
56165995 if (!(this instanceof Composite))
56175996 touched = false;
56185997 //if (displaylist == -1 && usecalllists)
5619
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
5998
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
56205999 {
56216000 bRep.displaylist = display.GenList();
56226001 assert(bRep.displaylist != 0);
....@@ -5627,7 +6006,7 @@
56276006
56286007 //System.out.println("\tnew list " + list);
56296008 //gl.glDrawBuffer(gl.GL_NONE);
5630
- if (usecalllists)
6009
+ if (usecalllists && bRep.displaylist > 0)
56316010 {
56326011 // System.err.println("new list " + bRep.displaylist + " for " + this);
56336012 display.NewList(bRep.displaylist);
....@@ -5636,7 +6015,7 @@
56366015 CallList(display, root, selected, blocked);
56376016
56386017 // compiled = true;
5639
- if (usecalllists)
6018
+ if (usecalllists && bRep.displaylist > 0)
56406019 {
56416020 // System.err.println("end list " + bRep.displaylist + " for " + this);
56426021 display.EndList();
....@@ -5736,6 +6115,7 @@
57366115 if (GetBRep() != null)
57376116 {
57386117 display.NextIndex();
6118
+
57396119 // vertex color conflict : gl.glCallList(list);
57406120 DrawNode(display, root, selected);
57416121 if (this instanceof BezierPatch)
....@@ -5776,16 +6156,27 @@
57766156 tex = GetTextures();
57776157 }
57786158
5779
- boolean failed = false;
6159
+ boolean failedPigment = false;
6160
+ boolean failedBump = false;
57806161
57816162 try
57826163 {
5783
- display.BindTextures(tex, texres);
6164
+ display.BindPigmentTexture(tex, texres);
57846165 }
57856166 catch (Exception e)
57866167 {
57876168 System.err.println("FAILED: " + this);
5788
- failed = true;
6169
+ failedPigment = true;
6170
+ }
6171
+
6172
+ try
6173
+ {
6174
+ display.BindBumpTexture(tex, texres);
6175
+ }
6176
+ catch (Exception e)
6177
+ {
6178
+ //System.err.println("FAILED: " + this);
6179
+ failedBump = true;
57896180 }
57906181
57916182 if (!compiled)
....@@ -5808,8 +6199,11 @@
58086199 }
58096200 }
58106201
5811
- if (!failed)
5812
- display.ReleaseTextures(tex);
6202
+ if (!failedBump)
6203
+ display.ReleaseBumpTexture(tex);
6204
+
6205
+ if (!failedPigment)
6206
+ display.ReleasePigmentTexture(tex);
58136207
58146208 display.PopMaterial(this, selected);
58156209 }
....@@ -6182,6 +6576,11 @@
61826576 // dec 2012
61836577 new Exception().printStackTrace();
61846578 return;
6579
+ }
6580
+
6581
+ if (dontselect)
6582
+ {
6583
+ //bRep.GenerateNormalsMINE();
61856584 }
61866585
61876586 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -6967,20 +7366,23 @@
69677366 }
69687367 }
69697368
6970
- protected void calcHotSpot(cVector in, ClickInfo info, Point outPt, Rectangle outRec)
7369
+ static ClickInfo clickInfo = new ClickInfo();
7370
+
7371
+ protected void calcHotSpot(cVector in, //ClickInfo clickInfo,
7372
+ Point outPt, Rectangle outRec)
69717373 {
6972
- int hc = info.bounds.x + info.bounds.width / 2;
6973
- int vc = info.bounds.y + info.bounds.height / 2;
6974
- double[][] toscreen = info.toScreen;
7374
+ int hc = clickInfo.bounds.x + clickInfo.bounds.width / 2;
7375
+ int vc = clickInfo.bounds.y + clickInfo.bounds.height / 2;
7376
+ double[][] toscreen = clickInfo.toScreen;
69757377 if (toscreen == null)
69767378 {
6977
- toscreen = new Camera(info.camera.viewCode).toScreen;
7379
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
69787380 }
69797381 cVector vec = in;
69807382 LA.xformPos(in, toscreen, in);
69817383 //System.out.println("Distance = " + info.camera.Distance());
6982
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
6983
- vec.y *= 100 * info.camera.SCALE / info.camera.Distance();
7384
+ vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
7385
+ vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
69847386 outPt.x = hc + (int) vec.x;
69857387 outPt.y = vc - (int) vec.y;
69867388 outRec.x = outPt.x - 3;
....@@ -6988,15 +7390,18 @@
69887390 outRec.width = outRec.height = 6;
69897391 }
69907392
6991
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7393
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7394
+ )
69927395 {
69937396 Point pt = new Point(0, 0);
69947397 Rectangle rec = new Rectangle();
6995
- calcHotSpot(in, info, pt, rec);
7398
+ calcHotSpot(in, //clickInfo,
7399
+ pt, rec);
69967400 return rec;
69977401 }
69987402
6999
- void drawEditHandles0(ClickInfo info, int level)
7403
+ void drawEditHandles0(//ClickInfo clickInfo,
7404
+ int level)
70007405 {
70017406 if (level == 0)
70027407 {
....@@ -7005,16 +7410,19 @@
70057410 {
70067411 cVector origin = new cVector();
70077412 //LA.xformPos(origin, toParent, origin);
7008
- Rectangle spot = calcHotSpot(origin, info);
7413
+ if (this.clickInfo == null)
7414
+ this.clickInfo = new ClickInfo();
7415
+
7416
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
70097417 Rectangle boundary = new Rectangle();
70107418 boundary.x = spot.x - 30;
70117419 boundary.y = spot.y - 30;
70127420 boundary.width = spot.width + 60;
70137421 boundary.height = spot.height + 60;
7014
- info.g.setColor(Color.red);
7422
+ clickInfo.g.setColor(Color.white);
70157423 int spotw = spot.x + spot.width;
70167424 int spoth = spot.y + spot.height;
7017
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7425
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
70187426 // if (CameraPane.Xmin > spot.x)
70197427 // {
70207428 // CameraPane.Xmin = spot.x;
....@@ -7031,11 +7439,33 @@
70317439 // {
70327440 // CameraPane.Ymax = spoth;
70337441 // }
7034
- spot.translate(32, 32);
7442
+// if (CameraPane.Xmin > spot.x)
7443
+// {
7444
+// CameraPane.Xmin = spot.x;
7445
+// }
7446
+// if (CameraPane.Xmax < spotw)
7447
+// {
7448
+// CameraPane.Xmax = spotw;
7449
+// }
7450
+// if (CameraPane.Ymin > spot.y)
7451
+// {
7452
+// CameraPane.Ymin = spot.y;
7453
+// }
7454
+// if (CameraPane.Ymax < spoth)
7455
+// {
7456
+// CameraPane.Ymax = spoth;
7457
+// }
7458
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7459
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
7460
+ spot.translate(32, 0);
7461
+ clickInfo.g.setColor(Color.yellow);
7462
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7463
+
7464
+ spot.translate(32, 64);
70357465 spotw = spot.x + spot.width;
70367466 spoth = spot.y + spot.height;
7037
- info.g.setColor(Color.blue);
7038
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7467
+ clickInfo.g.setColor(Color.cyan);
7468
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
70397469 // if (CameraPane.Xmin > spot.x)
70407470 // {
70417471 // CameraPane.Xmin = spot.x;
....@@ -7052,29 +7482,9 @@
70527482 // {
70537483 // CameraPane.Ymax = spoth;
70547484 // }
7055
- // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7056
- //info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7057
- spot.translate(0, -32);
7058
- info.g.setColor(Color.green);
7059
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7060
-// if (CameraPane.Xmin > spot.x)
7061
-// {
7062
-// CameraPane.Xmin = spot.x;
7063
-// }
7064
-// if (CameraPane.Xmax < spotw)
7065
-// {
7066
-// CameraPane.Xmax = spotw;
7067
-// }
7068
-// if (CameraPane.Ymin > spot.y)
7069
-// {
7070
-// CameraPane.Ymin = spot.y;
7071
-// }
7072
-// if (CameraPane.Ymax < spoth)
7073
-// {
7074
-// CameraPane.Ymax = spoth;
7075
-// }
7076
- info.g.drawArc(boundary.x, boundary.y,
7077
- boundary.width, boundary.height, 0, 360);
7485
+ clickInfo.g.setColor(Color.green);
7486
+ clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
7487
+ (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
70787488 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
70797489 // if (CameraPane.Xmin > boundary.x)
70807490 // {
....@@ -7096,7 +7506,8 @@
70967506 }
70977507 }
70987508
7099
- boolean doEditClick0(ClickInfo info, int level)
7509
+ boolean doEditClick0(//ClickInfo clickInfo,
7510
+ int level)
71007511 {
71017512 if (level == 0)
71027513 {
....@@ -7105,8 +7516,8 @@
71057516
71067517 boolean retval = false;
71077518
7108
- startX = info.x;
7109
- startY = info.y;
7519
+ startX = clickInfo.x;
7520
+ startY = clickInfo.y;
71107521
71117522 hitSomething = -1;
71127523 cVector origin = new cVector();
....@@ -7116,22 +7527,53 @@
71167527 {
71177528 centerPt = new Point(0, 0);
71187529 }
7119
- calcHotSpot(origin, info, centerPt, spot);
7120
- if (spot.contains(info.x, info.y))
7530
+ calcHotSpot(origin, //info,
7531
+ centerPt, spot);
7532
+ if (spot.contains(clickInfo.x, clickInfo.y))
71217533 {
71227534 hitSomething = hitCenter;
71237535 retval = true;
71247536 }
71257537 spot.translate(32, 0);
7126
- if (spot.contains(info.x, info.y))
7538
+ if (spot.contains(clickInfo.x, clickInfo.y))
71277539 {
71287540 hitSomething = hitRotate;
71297541 retval = true;
71307542 }
71317543 spot.translate(0, 32);
7132
- if (spot.contains(info.x, info.y))
7544
+ spot.translate(32, 0);
7545
+ spot.translate(0, 32);
7546
+ if (spot.contains(clickInfo.x, clickInfo.y))
71337547 {
71347548 hitSomething = hitScale;
7549
+
7550
+ double scale = 0.005f * clickInfo.camera.Distance();
7551
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
7552
+ double sign = 1;
7553
+ if (hScale < 0)
7554
+ {
7555
+ sign = -1;
7556
+ }
7557
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
7558
+ if (hScale < 0.01)
7559
+ {
7560
+ //hScale = 0.01;
7561
+ }
7562
+
7563
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
7564
+ sign = 1;
7565
+ if (vScale < 0)
7566
+ {
7567
+ sign = -1;
7568
+ }
7569
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
7570
+ if (vScale < 0.01)
7571
+ {
7572
+ //vScale = 0.01;
7573
+ }
7574
+
7575
+ clickInfo.scale = Math.sqrt(hScale*hScale + vScale*vScale);
7576
+
71357577 retval = true;
71367578 }
71377579
....@@ -7141,7 +7583,7 @@
71417583 }
71427584
71437585 //System.out.println("info.modifiers = " + info.modifiers);
7144
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7586
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
71457587 //System.out.println("modified = " + modified);
71467588 //new Exception().printStackTrace();
71477589 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7169,7 +7611,8 @@
71697611 return true;
71707612 }
71717613
7172
- void doEditDrag0(ClickInfo info, boolean opposite)
7614
+ void doEditDrag0(//ClickInfo info,
7615
+ boolean opposite)
71737616 {
71747617 if (hitSomething == 0)
71757618 {
....@@ -7183,7 +7626,7 @@
71837626
71847627 //System.out.println("hitSomething = " + hitSomething);
71857628
7186
- double scale = 0.005f * info.camera.Distance();
7629
+ double scale = 0.005f * clickInfo.camera.Distance();
71877630
71887631 cVector xlate = new cVector();
71897632 //cVector xlate2 = new cVector();
....@@ -7217,8 +7660,8 @@
72177660 toParent[3][i] = xlate.get(i);
72187661 LA.matInvert(toParent, fromParent);
72197662 */
7220
- cVector delta = LA.newVector(0, 0, startY - info.y);
7221
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7663
+ cVector delta = LA.newVector(0, 0, startY - clickInfo.y);
7664
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
72227665
72237666 LA.matCopy(startMat, toParent);
72247667 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7227,7 +7670,7 @@
72277670 } else
72287671 {
72297672 //LA.xformDir(delta, info.camera.fromScreen, delta);
7230
- cVector up = new cVector(info.camera.up);
7673
+ cVector up = new cVector(clickInfo.camera.up);
72317674 cVector away = new cVector();
72327675 //cVector right2 = new cVector();
72337676 //LA.vecCross(up, cVector.Z, right);
....@@ -7244,19 +7687,19 @@
72447687 LA.xformDir(up, ClickInfo.matbuffer, up);
72457688 // if (!CameraPane.LOCALTRANSFORM)
72467689 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7247
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7690
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
72487691 // if (!CameraPane.LOCALTRANSFORM)
72497692 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
72507693 //LA.vecCross(up, cVector.Z, right2);
72517694
7252
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7695
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
72537696
72547697 //System.out.println("DELTA0 = " + delta);
72557698 //System.out.println("AWAY = " + info.camera.away);
72567699 //System.out.println("UP = " + info.camera.up);
72577700 if (away.z > 0)
72587701 {
7259
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7702
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
72607703 {
72617704 delta.x = -delta.x;
72627705 } else
....@@ -7271,7 +7714,7 @@
72717714 //System.out.println("DELTA1 = " + delta);
72727715 LA.xformDir(delta, ClickInfo.matbuffer, delta);
72737716 //System.out.println("DELTA2 = " + delta);
7274
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7717
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
72757718 LA.matCopy(startMat, toParent);
72767719 //System.out.println("DELTA3 = " + delta);
72777720 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7281,8 +7724,8 @@
72817724 break;
72827725
72837726 case hitRotate: // rotate
7284
- int dx = info.x - centerPt.x;
7285
- int dy = -(info.y - centerPt.y);
7727
+ int dx = clickInfo.x - centerPt.x;
7728
+ int dy = -(clickInfo.y - centerPt.y);
72867729 double angle = (double) Math.atan2(dx, dy);
72877730 angle = -(1.570796 - angle);
72887731
....@@ -7305,7 +7748,7 @@
73057748 }
73067749 /**/
73077750
7308
- switch (info.pane.RenderCamera().viewCode)
7751
+ switch (clickInfo.pane.RenderCamera().viewCode)
73097752 {
73107753 case 1: // '\001'
73117754 LA.matZRotate(toParent, angle);
....@@ -7332,7 +7775,7 @@
73327775 break;
73337776
73347777 case hitScale: // scale
7335
- double hScale = (double) (info.x - centerPt.x) / 32;
7778
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
73367779 double sign = 1;
73377780 if (hScale < 0)
73387781 {
....@@ -7344,7 +7787,7 @@
73447787 //hScale = 0.01;
73457788 }
73467789
7347
- double vScale = (double) (info.y - centerPt.y) / 32;
7790
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
73487791 sign = 1;
73497792 if (vScale < 0)
73507793 {
....@@ -7355,6 +7798,7 @@
73557798 {
73567799 //vScale = 0.01;
73577800 }
7801
+
73587802 LA.matCopy(startMat, toParent);
73597803 /**/
73607804 for (int i = 0; i < 3; i++)
....@@ -7364,32 +7808,39 @@
73647808 }
73657809 /**/
73667810
7367
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7811
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
73687812
73697813 if (totalScale < 0.01)
73707814 {
73717815 totalScale = 0.01;
73727816 }
73737817
7374
- switch (info.pane.RenderCamera().viewCode)
7818
+ switch (clickInfo.pane.RenderCamera().viewCode)
73757819 {
73767820 case 3: // '\001'
7377
- if (modified)
7821
+ if (modified || opposite)
73787822 {
7823
+ if (modified && opposite)
7824
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7825
+ else
73797826 //LA.matScale(toParent, 1, hScale, vScale);
7380
- LA.matScale(toParent, totalScale, 1, 1);
7827
+ LA.matScale(toParent, totalScale, 1, 1);
73817828 } // vScale, 1);
73827829 else
73837830 {
7384
- LA.matScale(toParent, totalScale, totalScale, totalScale);
7831
+ // EXCEPTION!
7832
+ LA.matScale(toParent, 1, totalScale, totalScale);
73857833 } // vScale, 1);
73867834 break;
73877835
73887836 case 2: // '\002'
7389
- if (modified)
7837
+ if (modified || opposite)
73907838 {
7391
- //LA.matScale(toParent, hScale, 1, vScale);
7392
- LA.matScale(toParent, 1, totalScale, 1);
7839
+ if (modified && opposite)
7840
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7841
+ else
7842
+ //LA.matScale(toParent, hScale, 1, vScale);
7843
+ LA.matScale(toParent, 1, totalScale, 1);
73937844 } else
73947845 {
73957846 LA.matScale(toParent, totalScale, 1, totalScale);
....@@ -7397,10 +7848,13 @@
73977848 break;
73987849
73997850 case 1: // '\003'
7400
- if (modified)
7851
+ if (modified || opposite)
74017852 {
7402
- //LA.matScale(toParent, hScale, vScale, 1);
7403
- LA.matScale(toParent, 1, 1, totalScale);
7853
+ if (modified && opposite)
7854
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7855
+ else
7856
+ //LA.matScale(toParent, hScale, vScale, 1);
7857
+ LA.matScale(toParent, 1, 1, totalScale);
74047858 } else
74057859 {
74067860 LA.matScale(toParent, totalScale, totalScale, 1);
....@@ -7437,7 +7891,7 @@
74377891 } // NEW ...
74387892
74397893
7440
- info.pane.repaint();
7894
+ clickInfo.pane.repaint();
74417895 }
74427896
74437897 boolean overflow = false;
....@@ -7617,6 +8071,10 @@
76178071 editWindow = null;
76188072 } // ?
76198073 }
8074
+ else
8075
+ {
8076
+ //editWindow.closeUI();
8077
+ }
76208078 }
76218079
76228080 boolean root; // patch for edit windows
....@@ -7774,6 +8232,10 @@
77748232 }
77758233
77768234 transient ObjEditor editWindow;
8235
+ transient ObjEditor manipWindow;
8236
+
8237
+ transient boolean pinned;
8238
+
77778239 transient ObjectUI objectUI;
77788240 public static int povDepth = 0;
77798241 private static cVector tbMin = new cVector();