Normand Briere
2019-08-17 07c0c67b88160b51e61c5c1d2b9b602daafa44a9
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,117 +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++)
153
+
154
+ void RestoreSupports()
130155 {
131
- Object3D child = (Object3D) get(i);
132
- if (child == null)
133
- continue;
156
+ if (blockloop)
157
+ return;
158
+
159
+ support = transientsupport;
160
+ link2master = transientlink2master;
161
+ transientsupport = null;
162
+ transientlink2master = false;
163
+
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)
181
+ {
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
+
280
+ Object3D o = hashtable.get(GetUUID());
281
+
282
+ RestoreBigData(o);
283
+
284
+ if (blockloop)
285
+ return;
286
+
134287 blockloop = true;
135
- child.SaveSupports();
288
+
289
+ //hashtable.remove(GetUUID());
290
+
291
+ for (int i=0; i<Size(); i++)
292
+ {
293
+ get(i).RestoreBigData(hashtable);
294
+ }
295
+
136296 blockloop = false;
137297 }
138
-}
139298
140
-void RestoreSupports()
141
-{
142
- if (blockloop)
143
- return;
144
-
145
- support = transientsupport;
146
- link2master = transientlink2master;
147
- transientsupport = null;
148
- transientlink2master = false;
149
-
150
- if (bRep != null)
299
+ void RestoreBigData(Object3D o)
151300 {
152
- bRep.RestoreSupports();
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;
153315 }
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
-}
165
-
166
-void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
167
-{
168
- if (hashtable.containsKey(GetUUID()))
169
- return;
170
-
171
- Object3D o = new Object3D();
172
- o.bRep = this.bRep;
173
- if (this.bRep != null)
174
- {
175
- o.transientrep = this.bRep.support;
176
- o.bRep.support = null;
177
- }
178
-
179
-// o.support = this.support;
180
-// o.fileparent = this.fileparent;
181
-// if (this.bRep != null)
182
-// o.bRep = this.bRep.support;
183
-
184
- hashtable.put(GetUUID(), o);
185
-
186
- this.bRep = null;
187
-// if (this.bRep != null)
188
-// this.bRep.support = null;
189
-// this.support = null;
190
-// this.fileparent = null;
191
-
192
- for (int i=0; i<Size(); i++)
193
- {
194
- get(i).ExtractBigData(hashtable);
195
- }
196
-}
197
-
198
-void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
199
-{
200
- if (!hashtable.containsKey(GetUUID()))
201
- return;
202
-
203
- Object3D o = hashtable.get(GetUUID());
204
-
205
- this.bRep = o.bRep;
206
- if (this.bRep != null)
207
- this.bRep.support = o.transientrep;
208
-// this.support = o.support;
209
-// this.fileparent = o.fileparent;
210
-
211
- hashtable.remove(GetUUID());
212
-
213
- for (int i=0; i<Size(); i++)
214
- {
215
- get(i).RestoreBigData(hashtable);
216
- }
217
-}
218316
219317 // MOCAP SUPPORT
220318 double tx,ty,tz,rx,ry,rz;
....@@ -357,6 +455,7 @@
357455 }
358456
359457 boolean live = false;
458
+ transient boolean keepdontselect;
360459 boolean dontselect = false;
361460 boolean hide = false;
362461 boolean link2master = false; // performs reset support/master at each frame
....@@ -539,12 +638,14 @@
539638 toParent = LA.newMatrix();
540639 fromParent = LA.newMatrix();
541640 }
641
+
542642 if (toParentMarked == null)
543643 {
544644 if (maxcount != 1)
545645 {
546646 new Exception().printStackTrace();
547647 }
648
+
548649 toParentMarked = LA.newMatrix();
549650 fromParentMarked = LA.newMatrix();
550651 }
....@@ -855,7 +956,7 @@
855956
856957 if (marked && Globals.isLIVE() && live &&
857958 //TEMP21aug2018
858
- (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
959
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
859960 currentframe != Globals.framecount)
860961 {
861962 currentframe = Globals.framecount;
....@@ -867,7 +968,8 @@
867968
868969 boolean changedir = random && Math.random() < 0.01; // && !link2master;
869970
870
- if (transformcount*factor > maxcount || (step == 1 && changedir))
971
+ if (transformcount*factor >= maxcount && (rewind || random) ||
972
+ (step == 1 && changedir))
871973 {
872974 countdown = 1;
873975 delay = speedup?8:1;
....@@ -939,6 +1041,10 @@
9391041 if (material == null || material.multiply)
9401042 return true;
9411043
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.
9421048 return material.opacity > 0.99;
9431049 }
9441050
....@@ -1339,6 +1445,7 @@
13391445 toParent = LA.newMatrix();
13401446 fromParent = LA.newMatrix();
13411447 }
1448
+
13421449 LA.matCopy(other.toParent, toParent);
13431450 LA.matCopy(other.fromParent, fromParent);
13441451
....@@ -2360,6 +2467,15 @@
23602467 }
23612468 */
23622469 }
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
+ }
23632479 }
23642480
23652481 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
....@@ -2401,6 +2517,14 @@
24012517 {
24022518 editWindow.refreshContents();
24032519 }
2520
+ else
2521
+ {
2522
+ if (manipWindow != null)
2523
+ {
2524
+ manipWindow.refreshContents();
2525
+ }
2526
+ }
2527
+
24042528 //if (parent != null)
24052529 //parent.refreshEditWindow();
24062530 }
....@@ -2480,7 +2604,8 @@
24802604 private static final int editSelf = 1;
24812605 private static final int editChild = 2;
24822606
2483
- void drawEditHandles(ClickInfo info, int level)
2607
+ void drawEditHandles(//ClickInfo info,
2608
+ int level)
24842609 {
24852610 if (level == 0)
24862611 {
....@@ -2488,7 +2613,8 @@
24882613 return;
24892614
24902615 Object3D selectee;
2491
- 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))
24922618 {
24932619 selectee = (Object3D) e.nextElement();
24942620 }
....@@ -2496,19 +2622,22 @@
24962622 } else
24972623 {
24982624 //super.
2499
- drawEditHandles0(info, level + 1);
2625
+ drawEditHandles0(//info,
2626
+ level + 1);
25002627 }
25012628 }
25022629
2503
- boolean doEditClick(ClickInfo info, int level)
2630
+ boolean doEditClick(//ClickInfo info,
2631
+ int level)
25042632 {
25052633 doSomething = 0;
25062634 if (level == 0)
25072635 {
2508
- return doParentClick(info);
2636
+ return doParentClick(); //info);
25092637 }
25102638 if (//super.
2511
- doEditClick0(info, level))
2639
+ doEditClick0(//info,
2640
+ level))
25122641 {
25132642 doSomething = 1;
25142643 return true;
....@@ -2518,7 +2647,7 @@
25182647 }
25192648 }
25202649
2521
- boolean doParentClick(ClickInfo info)
2650
+ boolean doParentClick() //ClickInfo info)
25222651 {
25232652 if (selection == null)
25242653 {
....@@ -2531,7 +2660,8 @@
25312660 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
25322661 {
25332662 Object3D selectee = (Object3D) e.nextElement();
2534
- if (selectee.doEditClick(info, 1))
2663
+ if (selectee.doEditClick(//info,
2664
+ 1))
25352665 {
25362666 childToDrag = selectee;
25372667 doSomething = 2;
....@@ -2543,13 +2673,15 @@
25432673 return retval;
25442674 }
25452675
2546
- void doEditDrag(ClickInfo info, boolean opposite)
2676
+ void doEditDrag(//ClickInfo clickInfo,
2677
+ boolean opposite)
25472678 {
25482679 switch (doSomething)
25492680 {
25502681 case 1: // '\001'
25512682 //super.
2552
- doEditDrag0(info, opposite);
2683
+ doEditDrag0(//clickInfo,
2684
+ opposite);
25532685 break;
25542686
25552687 case 2: // '\002'
....@@ -2562,11 +2694,13 @@
25622694 {
25632695 //sel.hitSomething = childToDrag.hitSomething;
25642696 //childToDrag.doEditDrag(info);
2565
- sel.doEditDrag(info, opposite);
2697
+ sel.doEditDrag(//clickInfo,
2698
+ opposite);
25662699 } else
25672700 {
25682701 //super.
2569
- doEditDrag0(info, opposite);
2702
+ doEditDrag0(//clickInfo,
2703
+ opposite);
25702704 }
25712705 }
25722706 break;
....@@ -2584,6 +2718,9 @@
25842718 {
25852719 deselectAll();
25862720 }
2721
+
2722
+ new Exception().printStackTrace();
2723
+
25872724 ClickInfo newInfo = new ClickInfo();
25882725 newInfo.flags = info.flags;
25892726 newInfo.bounds = info.bounds;
....@@ -2676,6 +2813,18 @@
26762813 void GenNormalsS(boolean crease)
26772814 {
26782815 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();
26792828 // for (int i=0; i<selection.size(); i++)
26802829 // {
26812830 // Object3D selectee = (Object3D) selection.elementAt(i);
....@@ -2816,6 +2965,24 @@
28162965 if (child == null)
28172966 continue;
28182967 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();
28192986 // Children().release(i);
28202987 }
28212988 blockloop = false;
....@@ -2988,11 +3155,20 @@
29883155 }
29893156 }
29903157
3158
+ void GenNormalsMesh0()
3159
+ {
3160
+ if (bRep != null)
3161
+ {
3162
+ bRep.GenerateNormalsMesh();
3163
+ Touch();
3164
+ }
3165
+ }
3166
+
29913167 void GenNormalsMINE0()
29923168 {
29933169 if (bRep != null)
29943170 {
2995
- bRep.GenerateNormalsMINE();
3171
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
29963172 Touch();
29973173 }
29983174 }
....@@ -3438,7 +3614,8 @@
34383614 if (blockloop)
34393615 return;
34403616
3441
- if (marked || (bRep != null && material != null)) // borderline...
3617
+ if (//marked || // does not make sense
3618
+ (bRep != null || material != null)) // borderline...
34423619 live = h;
34433620
34443621 for (int i = 0; i < Size(); i++)
....@@ -3459,7 +3636,8 @@
34593636 return;
34603637
34613638 //if (bRep != null)
3462
- if (marked || (bRep != null && material != null)) // borderline...
3639
+ if (//marked || // does not make sense
3640
+ (bRep != null || material != null)) // borderline...
34633641 link2master = h;
34643642
34653643 for (int i = 0; i < Size(); i++)
....@@ -3479,7 +3657,8 @@
34793657 if (blockloop)
34803658 return;
34813659
3482
- if (marked || (bRep != null && material != null)) // borderline...
3660
+ if (//marked || // does not make sense
3661
+ (bRep != null || material != null)) // borderline...
34833662 hide = h;
34843663
34853664 for (int i = 0; i < Size(); i++)
....@@ -3499,7 +3678,7 @@
34993678 if (blockloop)
35003679 return;
35013680
3502
- if (bRep != null && material != null) // borderline...
3681
+ if (bRep != null || material != null) // borderline...
35033682 marked = h;
35043683
35053684 for (int i = 0; i < Size(); i++)
....@@ -3509,6 +3688,46 @@
35093688 continue;
35103689 blockloop = true;
35113690 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);
35123731 blockloop = false;
35133732 // release(i);
35143733 }
....@@ -4286,6 +4505,55 @@
42864505 }
42874506 }
42884507
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
+
42894557 void RepairTexture()
42904558 {
42914559 if (this instanceof FileObject || blockloop)
....@@ -4800,6 +5068,14 @@
48005068 }
48015069 }
48025070
5071
+ ObjEditor GetWindow()
5072
+ {
5073
+ if (editWindow != null)
5074
+ return editWindow;
5075
+
5076
+ return manipWindow;
5077
+ }
5078
+
48035079 cTreePath Select(int indexcount, boolean deselect)
48045080 {
48055081 if (hide || dontselect)
....@@ -4836,10 +5112,11 @@
48365112 if (leaf != null)
48375113 {
48385114 cTreePath tp = new cTreePath(this, leaf);
4839
- if (editWindow != null)
5115
+ ObjEditor window = GetWindow();
5116
+ if (window != null)
48405117 {
48415118 //System.out.println("editWindow = " + editWindow + " vs " + this);
4842
- editWindow.Select(tp, deselect, true);
5119
+ window.Select(tp, deselect, true);
48435120 }
48445121
48455122 return tp;
....@@ -4856,6 +5133,7 @@
48565133
48575134 if (child == null)
48585135 continue;
5136
+
48595137 if (child.HasTransparency() && child.size() != 0)
48605138 {
48615139 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4865,9 +5143,10 @@
48655143 if (leaf != null)
48665144 {
48675145 cTreePath tp = new cTreePath(this, leaf);
4868
- if (editWindow != null)
5146
+ ObjEditor window = GetWindow();
5147
+ if (window != null)
48695148 {
4870
- editWindow.Select(tp, deselect, true);
5149
+ window.Select(tp, deselect, true);
48715150 }
48725151
48735152 return tp;
....@@ -5192,6 +5471,51 @@
51925471 blockloop = false;
51935472 }
51945473
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
+
51955519 boolean IsSelected()
51965520 {
51975521 if (parent == null)
....@@ -5252,6 +5576,11 @@
52525576 if (fullname == null)
52535577 return "";
52545578
5579
+ if (fullname.pigment != null)
5580
+ {
5581
+ return fullname.pigment;
5582
+ }
5583
+
52555584 // System.out.println("Fullname = " + fullname);
52565585
52575586 // Does not work on Windows due to C:
....@@ -5264,7 +5593,7 @@
52645593
52655594 if (split.length == 0)
52665595 {
5267
- return "";
5596
+ return fullname.pigment = "";
52685597 }
52695598
52705599 if (split.length <= 2)
....@@ -5272,22 +5601,27 @@
52725601 if (fullname.name.endsWith(":"))
52735602 {
52745603 // Windows
5275
- return fullname.name.substring(0, fullname.name.length()-1);
5604
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
52765605 }
52775606
5278
- return split[0];
5607
+ return fullname.pigment = split[0];
52795608 }
52805609
52815610 // Windows
52825611 assert(split.length == 4);
52835612
5284
- return split[0] + ":" + split[1];
5613
+ return fullname.pigment = split[0] + ":" + split[1];
52855614 }
52865615
52875616 static String GetBump(cTexture fullname)
52885617 {
52895618 if (fullname == null)
52905619 return "";
5620
+
5621
+ if (fullname.bump != null)
5622
+ {
5623
+ return fullname.bump;
5624
+ }
52915625
52925626 // System.out.println("Fullname = " + fullname);
52935627 // Does not work on Windows due to C:
....@@ -5299,12 +5633,12 @@
52995633
53005634 if (split.length == 0)
53015635 {
5302
- return "";
5636
+ return fullname.bump = "";
53035637 }
53045638
53055639 if (split.length == 1)
53065640 {
5307
- return "";
5641
+ return fullname.bump = "";
53085642 }
53095643
53105644 if (split.length == 2)
....@@ -5312,16 +5646,16 @@
53125646 if (fullname.name.endsWith(":"))
53135647 {
53145648 // Windows
5315
- return "";
5649
+ return fullname.bump = "";
53165650 }
53175651
5318
- return split[1];
5652
+ return fullname.bump = split[1];
53195653 }
53205654
53215655 // Windows
53225656 assert(split.length == 4);
53235657
5324
- return split[2] + ":" + split[3];
5658
+ return fullname.bump = split[2] + ":" + split[3];
53255659 }
53265660
53275661 String GetPigmentTexture()
....@@ -5404,6 +5738,9 @@
54045738 texname = "";
54055739
54065740 GetTextures().name = texname + ":" + GetBump(GetTextures());
5741
+
5742
+ GetTextures().pigment = null;
5743
+
54075744 Touch();
54085745 }
54095746
....@@ -5477,6 +5814,8 @@
54775814
54785815 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
54795816
5817
+ GetTextures().bump = null;
5818
+
54805819 Touch();
54815820 }
54825821
....@@ -5501,6 +5840,38 @@
55015840 }
55025841 }
55035842
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
+
55045875 void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
55055876 {
55065877 Draw(display, root, selected, blocked);
....@@ -5509,12 +5880,23 @@
55095880 boolean NeedSupport()
55105881 {
55115882 return
5512
- CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null
5883
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
55135884 // PROBLEM with CROWD!!
55145885 && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
55155886 }
55165887
55175888 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
+ }
55185900
55195901 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
55205902 {
....@@ -5576,8 +5958,10 @@
55765958 if (support != null)
55775959 support = support;
55785960
5579
- //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5580
- 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.
55815965
55825966 if (!usecalllists && bRep != null && bRep.displaylist > 0)
55835967 {
....@@ -5587,8 +5971,9 @@
55875971 // usecalllists &= !(parent instanceof RandomNode);
55885972 // usecalllists = false;
55895973
5590
- if (GetBRep() != null)
5591
- usecalllists = usecalllists;
5974
+ if (display.DrawMode() == display.SHADOW)
5975
+ //GetBRep() != null)
5976
+ usecalllists = !!usecalllists;
55925977 //System.out.println("draw " + this);
55935978 //new Exception().printStackTrace();
55945979
....@@ -5597,10 +5982,12 @@
55975982 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
55985983
55995984 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5600
- (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)))
56015987 {
56025988 Globals.lighttouched = true;
56035989 } // all panes...
5990
+
56045991 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
56055992 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
56065993 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5608,7 +5995,7 @@
56085995 if (!(this instanceof Composite))
56095996 touched = false;
56105997 //if (displaylist == -1 && usecalllists)
5611
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
5998
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
56125999 {
56136000 bRep.displaylist = display.GenList();
56146001 assert(bRep.displaylist != 0);
....@@ -5619,7 +6006,7 @@
56196006
56206007 //System.out.println("\tnew list " + list);
56216008 //gl.glDrawBuffer(gl.GL_NONE);
5622
- if (usecalllists)
6009
+ if (usecalllists && bRep.displaylist > 0)
56236010 {
56246011 // System.err.println("new list " + bRep.displaylist + " for " + this);
56256012 display.NewList(bRep.displaylist);
....@@ -5628,7 +6015,7 @@
56286015 CallList(display, root, selected, blocked);
56296016
56306017 // compiled = true;
5631
- if (usecalllists)
6018
+ if (usecalllists && bRep.displaylist > 0)
56326019 {
56336020 // System.err.println("end list " + bRep.displaylist + " for " + this);
56346021 display.EndList();
....@@ -5728,6 +6115,7 @@
57286115 if (GetBRep() != null)
57296116 {
57306117 display.NextIndex();
6118
+
57316119 // vertex color conflict : gl.glCallList(list);
57326120 DrawNode(display, root, selected);
57336121 if (this instanceof BezierPatch)
....@@ -5768,16 +6156,27 @@
57686156 tex = GetTextures();
57696157 }
57706158
5771
- boolean failed = false;
6159
+ boolean failedPigment = false;
6160
+ boolean failedBump = false;
57726161
57736162 try
57746163 {
5775
- display.BindTextures(tex, texres);
6164
+ display.BindPigmentTexture(tex, texres);
57766165 }
57776166 catch (Exception e)
57786167 {
57796168 System.err.println("FAILED: " + this);
5780
- 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;
57816180 }
57826181
57836182 if (!compiled)
....@@ -5800,8 +6199,11 @@
58006199 }
58016200 }
58026201
5803
- if (!failed)
5804
- display.ReleaseTextures(tex);
6202
+ if (!failedBump)
6203
+ display.ReleaseBumpTexture(tex);
6204
+
6205
+ if (!failedPigment)
6206
+ display.ReleasePigmentTexture(tex);
58056207
58066208 display.PopMaterial(this, selected);
58076209 }
....@@ -6174,6 +6576,11 @@
61746576 // dec 2012
61756577 new Exception().printStackTrace();
61766578 return;
6579
+ }
6580
+
6581
+ if (dontselect)
6582
+ {
6583
+ //bRep.GenerateNormalsMINE();
61776584 }
61786585
61796586 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -6959,20 +7366,23 @@
69597366 }
69607367 }
69617368
6962
- 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)
69637373 {
6964
- int hc = info.bounds.x + info.bounds.width / 2;
6965
- int vc = info.bounds.y + info.bounds.height / 2;
6966
- 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;
69677377 if (toscreen == null)
69687378 {
6969
- toscreen = new Camera(info.camera.viewCode).toScreen;
7379
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
69707380 }
69717381 cVector vec = in;
69727382 LA.xformPos(in, toscreen, in);
69737383 //System.out.println("Distance = " + info.camera.Distance());
6974
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
6975
- 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();
69767386 outPt.x = hc + (int) vec.x;
69777387 outPt.y = vc - (int) vec.y;
69787388 outRec.x = outPt.x - 3;
....@@ -6980,15 +7390,18 @@
69807390 outRec.width = outRec.height = 6;
69817391 }
69827392
6983
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7393
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7394
+ )
69847395 {
69857396 Point pt = new Point(0, 0);
69867397 Rectangle rec = new Rectangle();
6987
- calcHotSpot(in, info, pt, rec);
7398
+ calcHotSpot(in, //clickInfo,
7399
+ pt, rec);
69887400 return rec;
69897401 }
69907402
6991
- void drawEditHandles0(ClickInfo info, int level)
7403
+ void drawEditHandles0(//ClickInfo clickInfo,
7404
+ int level)
69927405 {
69937406 if (level == 0)
69947407 {
....@@ -6997,16 +7410,19 @@
69977410 {
69987411 cVector origin = new cVector();
69997412 //LA.xformPos(origin, toParent, origin);
7000
- Rectangle spot = calcHotSpot(origin, info);
7413
+ if (this.clickInfo == null)
7414
+ this.clickInfo = new ClickInfo();
7415
+
7416
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
70017417 Rectangle boundary = new Rectangle();
70027418 boundary.x = spot.x - 30;
70037419 boundary.y = spot.y - 30;
70047420 boundary.width = spot.width + 60;
70057421 boundary.height = spot.height + 60;
7006
- info.g.setColor(Color.red);
7422
+ clickInfo.g.setColor(Color.white);
70077423 int spotw = spot.x + spot.width;
70087424 int spoth = spot.y + spot.height;
7009
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7425
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
70107426 // if (CameraPane.Xmin > spot.x)
70117427 // {
70127428 // CameraPane.Xmin = spot.x;
....@@ -7023,11 +7439,33 @@
70237439 // {
70247440 // CameraPane.Ymax = spoth;
70257441 // }
7026
- 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);
70277465 spotw = spot.x + spot.width;
70287466 spoth = spot.y + spot.height;
7029
- info.g.setColor(Color.blue);
7030
- 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);
70317469 // if (CameraPane.Xmin > spot.x)
70327470 // {
70337471 // CameraPane.Xmin = spot.x;
....@@ -7044,29 +7482,9 @@
70447482 // {
70457483 // CameraPane.Ymax = spoth;
70467484 // }
7047
- // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7048
- //info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7049
- spot.translate(0, -32);
7050
- info.g.setColor(Color.green);
7051
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7052
-// if (CameraPane.Xmin > spot.x)
7053
-// {
7054
-// CameraPane.Xmin = spot.x;
7055
-// }
7056
-// if (CameraPane.Xmax < spotw)
7057
-// {
7058
-// CameraPane.Xmax = spotw;
7059
-// }
7060
-// if (CameraPane.Ymin > spot.y)
7061
-// {
7062
-// CameraPane.Ymin = spot.y;
7063
-// }
7064
-// if (CameraPane.Ymax < spoth)
7065
-// {
7066
-// CameraPane.Ymax = spoth;
7067
-// }
7068
- info.g.drawArc(boundary.x, boundary.y,
7069
- 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);
70707488 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
70717489 // if (CameraPane.Xmin > boundary.x)
70727490 // {
....@@ -7088,7 +7506,8 @@
70887506 }
70897507 }
70907508
7091
- boolean doEditClick0(ClickInfo info, int level)
7509
+ boolean doEditClick0(//ClickInfo clickInfo,
7510
+ int level)
70927511 {
70937512 if (level == 0)
70947513 {
....@@ -7097,8 +7516,8 @@
70977516
70987517 boolean retval = false;
70997518
7100
- startX = info.x;
7101
- startY = info.y;
7519
+ startX = clickInfo.x;
7520
+ startY = clickInfo.y;
71027521
71037522 hitSomething = -1;
71047523 cVector origin = new cVector();
....@@ -7108,22 +7527,53 @@
71087527 {
71097528 centerPt = new Point(0, 0);
71107529 }
7111
- calcHotSpot(origin, info, centerPt, spot);
7112
- if (spot.contains(info.x, info.y))
7530
+ calcHotSpot(origin, //info,
7531
+ centerPt, spot);
7532
+ if (spot.contains(clickInfo.x, clickInfo.y))
71137533 {
71147534 hitSomething = hitCenter;
71157535 retval = true;
71167536 }
71177537 spot.translate(32, 0);
7118
- if (spot.contains(info.x, info.y))
7538
+ if (spot.contains(clickInfo.x, clickInfo.y))
71197539 {
71207540 hitSomething = hitRotate;
71217541 retval = true;
71227542 }
71237543 spot.translate(0, 32);
7124
- 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))
71257547 {
71267548 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
+
71277577 retval = true;
71287578 }
71297579
....@@ -7133,7 +7583,7 @@
71337583 }
71347584
71357585 //System.out.println("info.modifiers = " + info.modifiers);
7136
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7586
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
71377587 //System.out.println("modified = " + modified);
71387588 //new Exception().printStackTrace();
71397589 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7161,7 +7611,8 @@
71617611 return true;
71627612 }
71637613
7164
- void doEditDrag0(ClickInfo info, boolean opposite)
7614
+ void doEditDrag0(//ClickInfo info,
7615
+ boolean opposite)
71657616 {
71667617 if (hitSomething == 0)
71677618 {
....@@ -7175,7 +7626,7 @@
71757626
71767627 //System.out.println("hitSomething = " + hitSomething);
71777628
7178
- double scale = 0.005f * info.camera.Distance();
7629
+ double scale = 0.005f * clickInfo.camera.Distance();
71797630
71807631 cVector xlate = new cVector();
71817632 //cVector xlate2 = new cVector();
....@@ -7209,8 +7660,8 @@
72097660 toParent[3][i] = xlate.get(i);
72107661 LA.matInvert(toParent, fromParent);
72117662 */
7212
- cVector delta = LA.newVector(0, 0, startY - info.y);
7213
- 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);
72147665
72157666 LA.matCopy(startMat, toParent);
72167667 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7219,7 +7670,7 @@
72197670 } else
72207671 {
72217672 //LA.xformDir(delta, info.camera.fromScreen, delta);
7222
- cVector up = new cVector(info.camera.up);
7673
+ cVector up = new cVector(clickInfo.camera.up);
72237674 cVector away = new cVector();
72247675 //cVector right2 = new cVector();
72257676 //LA.vecCross(up, cVector.Z, right);
....@@ -7236,19 +7687,19 @@
72367687 LA.xformDir(up, ClickInfo.matbuffer, up);
72377688 // if (!CameraPane.LOCALTRANSFORM)
72387689 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7239
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7690
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
72407691 // if (!CameraPane.LOCALTRANSFORM)
72417692 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
72427693 //LA.vecCross(up, cVector.Z, right2);
72437694
7244
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7695
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
72457696
72467697 //System.out.println("DELTA0 = " + delta);
72477698 //System.out.println("AWAY = " + info.camera.away);
72487699 //System.out.println("UP = " + info.camera.up);
72497700 if (away.z > 0)
72507701 {
7251
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7702
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
72527703 {
72537704 delta.x = -delta.x;
72547705 } else
....@@ -7263,7 +7714,7 @@
72637714 //System.out.println("DELTA1 = " + delta);
72647715 LA.xformDir(delta, ClickInfo.matbuffer, delta);
72657716 //System.out.println("DELTA2 = " + delta);
7266
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7717
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
72677718 LA.matCopy(startMat, toParent);
72687719 //System.out.println("DELTA3 = " + delta);
72697720 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7273,8 +7724,8 @@
72737724 break;
72747725
72757726 case hitRotate: // rotate
7276
- int dx = info.x - centerPt.x;
7277
- int dy = -(info.y - centerPt.y);
7727
+ int dx = clickInfo.x - centerPt.x;
7728
+ int dy = -(clickInfo.y - centerPt.y);
72787729 double angle = (double) Math.atan2(dx, dy);
72797730 angle = -(1.570796 - angle);
72807731
....@@ -7297,7 +7748,7 @@
72977748 }
72987749 /**/
72997750
7300
- switch (info.pane.RenderCamera().viewCode)
7751
+ switch (clickInfo.pane.RenderCamera().viewCode)
73017752 {
73027753 case 1: // '\001'
73037754 LA.matZRotate(toParent, angle);
....@@ -7324,7 +7775,7 @@
73247775 break;
73257776
73267777 case hitScale: // scale
7327
- double hScale = (double) (info.x - centerPt.x) / 32;
7778
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
73287779 double sign = 1;
73297780 if (hScale < 0)
73307781 {
....@@ -7336,7 +7787,7 @@
73367787 //hScale = 0.01;
73377788 }
73387789
7339
- double vScale = (double) (info.y - centerPt.y) / 32;
7790
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
73407791 sign = 1;
73417792 if (vScale < 0)
73427793 {
....@@ -7347,6 +7798,7 @@
73477798 {
73487799 //vScale = 0.01;
73497800 }
7801
+
73507802 LA.matCopy(startMat, toParent);
73517803 /**/
73527804 for (int i = 0; i < 3; i++)
....@@ -7356,32 +7808,39 @@
73567808 }
73577809 /**/
73587810
7359
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7811
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
73607812
73617813 if (totalScale < 0.01)
73627814 {
73637815 totalScale = 0.01;
73647816 }
73657817
7366
- switch (info.pane.RenderCamera().viewCode)
7818
+ switch (clickInfo.pane.RenderCamera().viewCode)
73677819 {
73687820 case 3: // '\001'
7369
- if (modified)
7821
+ if (modified || opposite)
73707822 {
7823
+ if (modified && opposite)
7824
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7825
+ else
73717826 //LA.matScale(toParent, 1, hScale, vScale);
7372
- LA.matScale(toParent, totalScale, 1, 1);
7827
+ LA.matScale(toParent, totalScale, 1, 1);
73737828 } // vScale, 1);
73747829 else
73757830 {
7376
- LA.matScale(toParent, totalScale, totalScale, totalScale);
7831
+ // EXCEPTION!
7832
+ LA.matScale(toParent, 1, totalScale, totalScale);
73777833 } // vScale, 1);
73787834 break;
73797835
73807836 case 2: // '\002'
7381
- if (modified)
7837
+ if (modified || opposite)
73827838 {
7383
- //LA.matScale(toParent, hScale, 1, vScale);
7384
- 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);
73857844 } else
73867845 {
73877846 LA.matScale(toParent, totalScale, 1, totalScale);
....@@ -7389,10 +7848,13 @@
73897848 break;
73907849
73917850 case 1: // '\003'
7392
- if (modified)
7851
+ if (modified || opposite)
73937852 {
7394
- //LA.matScale(toParent, hScale, vScale, 1);
7395
- 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);
73967858 } else
73977859 {
73987860 LA.matScale(toParent, totalScale, totalScale, 1);
....@@ -7429,7 +7891,7 @@
74297891 } // NEW ...
74307892
74317893
7432
- info.pane.repaint();
7894
+ clickInfo.pane.repaint();
74337895 }
74347896
74357897 boolean overflow = false;
....@@ -7609,6 +8071,10 @@
76098071 editWindow = null;
76108072 } // ?
76118073 }
8074
+ else
8075
+ {
8076
+ //editWindow.closeUI();
8077
+ }
76128078 }
76138079
76148080 boolean root; // patch for edit windows
....@@ -7766,6 +8232,10 @@
77668232 }
77678233
77688234 transient ObjEditor editWindow;
8235
+ transient ObjEditor manipWindow;
8236
+
8237
+ transient boolean pinned;
8238
+
77698239 transient ObjectUI objectUI;
77708240 public static int povDepth = 0;
77718241 private static cVector tbMin = new cVector();