Normand Briere
2019-08-14 0c1f740dd6ddd6432dc29266e42ef851e26027bb
Object3D.java
....@@ -22,8 +22,20 @@
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();
2627
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
+
2739 ScriptNode scriptnode;
2840
2941 void InitOthers()
....@@ -104,117 +116,201 @@
104116
105117 // transient boolean reduced; // for morph reduction
106118
107
-transient com.bulletphysics.linearmath.Transform cache; // for fast merge
108
-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
109121
110
-transient Object3D transientsupport; // for cloning
111
-transient boolean transientlink2master;
122
+ transient Object3D transientsupport; // for cloning
123
+ transient boolean transientlink2master;
112124
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)
125
+ void SaveSupports()
125126 {
126
- 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
+ }
127150 }
128
-
129
- for (int i = 0; i < Size(); i++)
151
+
152
+ void RestoreSupports()
130153 {
131
- Object3D child = (Object3D) get(i);
132
- if (child == null)
133
- 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
+
134285 blockloop = true;
135
- child.SaveSupports();
286
+
287
+ //hashtable.remove(GetUUID());
288
+
289
+ for (int i=0; i<Size(); i++)
290
+ {
291
+ get(i).RestoreBigData(hashtable);
292
+ }
293
+
136294 blockloop = false;
137295 }
138
-}
139296
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)
297
+ void RestoreBigData(Object3D o)
151298 {
152
- 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;
153313 }
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
-}
218314
219315 // MOCAP SUPPORT
220316 double tx,ty,tz,rx,ry,rz;
....@@ -357,6 +453,7 @@
357453 }
358454
359455 boolean live = false;
456
+ transient boolean keepdontselect;
360457 boolean dontselect = false;
361458 boolean hide = false;
362459 boolean link2master = false; // performs reset support/master at each frame
....@@ -539,12 +636,14 @@
539636 toParent = LA.newMatrix();
540637 fromParent = LA.newMatrix();
541638 }
639
+
542640 if (toParentMarked == null)
543641 {
544642 if (maxcount != 1)
545643 {
546644 new Exception().printStackTrace();
547645 }
646
+
548647 toParentMarked = LA.newMatrix();
549648 fromParentMarked = LA.newMatrix();
550649 }
....@@ -855,7 +954,7 @@
855954
856955 if (marked && Globals.isLIVE() && live &&
857956 //TEMP21aug2018
858
- (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
957
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
859958 currentframe != Globals.framecount)
860959 {
861960 currentframe = Globals.framecount;
....@@ -867,7 +966,8 @@
867966
868967 boolean changedir = random && Math.random() < 0.01; // && !link2master;
869968
870
- if (transformcount*factor > maxcount || (step == 1 && changedir))
969
+ if (transformcount*factor >= maxcount && (rewind || random) ||
970
+ (step == 1 && changedir))
871971 {
872972 countdown = 1;
873973 delay = speedup?8:1;
....@@ -939,6 +1039,10 @@
9391039 if (material == null || material.multiply)
9401040 return true;
9411041
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.
9421046 return material.opacity > 0.99;
9431047 }
9441048
....@@ -1339,6 +1443,7 @@
13391443 toParent = LA.newMatrix();
13401444 fromParent = LA.newMatrix();
13411445 }
1446
+
13421447 LA.matCopy(other.toParent, toParent);
13431448 LA.matCopy(other.fromParent, fromParent);
13441449
....@@ -2360,6 +2465,15 @@
23602465 }
23612466 */
23622467 }
2468
+ else
2469
+ {
2470
+ //((ObjEditor)editWindow).SetupUI2(null);
2471
+ if (objectUI != null)
2472
+ ((ObjEditor)objectUI).pinButton.setSelected(pinned);
2473
+ else
2474
+ //new Exception().printStackTrace();
2475
+ System.err.println("objectUI is null");
2476
+ }
23632477 }
23642478
23652479 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
....@@ -2401,6 +2515,14 @@
24012515 {
24022516 editWindow.refreshContents();
24032517 }
2518
+ else
2519
+ {
2520
+ if (manipWindow != null)
2521
+ {
2522
+ manipWindow.refreshContents();
2523
+ }
2524
+ }
2525
+
24042526 //if (parent != null)
24052527 //parent.refreshEditWindow();
24062528 }
....@@ -2480,7 +2602,8 @@
24802602 private static final int editSelf = 1;
24812603 private static final int editChild = 2;
24822604
2483
- void drawEditHandles(ClickInfo info, int level)
2605
+ void drawEditHandles(//ClickInfo info,
2606
+ int level)
24842607 {
24852608 if (level == 0)
24862609 {
....@@ -2488,7 +2611,8 @@
24882611 return;
24892612
24902613 Object3D selectee;
2491
- for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(info, level + 1))
2614
+ for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(//info,
2615
+ level + 1))
24922616 {
24932617 selectee = (Object3D) e.nextElement();
24942618 }
....@@ -2496,19 +2620,22 @@
24962620 } else
24972621 {
24982622 //super.
2499
- drawEditHandles0(info, level + 1);
2623
+ drawEditHandles0(//info,
2624
+ level + 1);
25002625 }
25012626 }
25022627
2503
- boolean doEditClick(ClickInfo info, int level)
2628
+ boolean doEditClick(//ClickInfo info,
2629
+ int level)
25042630 {
25052631 doSomething = 0;
25062632 if (level == 0)
25072633 {
2508
- return doParentClick(info);
2634
+ return doParentClick(); //info);
25092635 }
25102636 if (//super.
2511
- doEditClick0(info, level))
2637
+ doEditClick0(//info,
2638
+ level))
25122639 {
25132640 doSomething = 1;
25142641 return true;
....@@ -2518,7 +2645,7 @@
25182645 }
25192646 }
25202647
2521
- boolean doParentClick(ClickInfo info)
2648
+ boolean doParentClick() //ClickInfo info)
25222649 {
25232650 if (selection == null)
25242651 {
....@@ -2531,7 +2658,8 @@
25312658 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
25322659 {
25332660 Object3D selectee = (Object3D) e.nextElement();
2534
- if (selectee.doEditClick(info, 1))
2661
+ if (selectee.doEditClick(//info,
2662
+ 1))
25352663 {
25362664 childToDrag = selectee;
25372665 doSomething = 2;
....@@ -2543,13 +2671,15 @@
25432671 return retval;
25442672 }
25452673
2546
- void doEditDrag(ClickInfo info, boolean opposite)
2674
+ void doEditDrag(//ClickInfo clickInfo,
2675
+ boolean opposite)
25472676 {
25482677 switch (doSomething)
25492678 {
25502679 case 1: // '\001'
25512680 //super.
2552
- doEditDrag0(info, opposite);
2681
+ doEditDrag0(//clickInfo,
2682
+ opposite);
25532683 break;
25542684
25552685 case 2: // '\002'
....@@ -2562,11 +2692,13 @@
25622692 {
25632693 //sel.hitSomething = childToDrag.hitSomething;
25642694 //childToDrag.doEditDrag(info);
2565
- sel.doEditDrag(info, opposite);
2695
+ sel.doEditDrag(//clickInfo,
2696
+ opposite);
25662697 } else
25672698 {
25682699 //super.
2569
- doEditDrag0(info, opposite);
2700
+ doEditDrag0(//clickInfo,
2701
+ opposite);
25702702 }
25712703 }
25722704 break;
....@@ -2584,6 +2716,9 @@
25842716 {
25852717 deselectAll();
25862718 }
2719
+
2720
+ new Exception().printStackTrace();
2721
+
25872722 ClickInfo newInfo = new ClickInfo();
25882723 newInfo.flags = info.flags;
25892724 newInfo.bounds = info.bounds;
....@@ -2676,6 +2811,18 @@
26762811 void GenNormalsS(boolean crease)
26772812 {
26782813 selection.GenNormals(crease);
2814
+// for (int i=0; i<selection.size(); i++)
2815
+// {
2816
+// Object3D selectee = (Object3D) selection.elementAt(i);
2817
+// selectee.GenNormals(crease);
2818
+// }
2819
+
2820
+ //Touch();
2821
+ }
2822
+
2823
+ void GenNormalsMeshS()
2824
+ {
2825
+ selection.GenNormalsMesh();
26792826 // for (int i=0; i<selection.size(); i++)
26802827 // {
26812828 // Object3D selectee = (Object3D) selection.elementAt(i);
....@@ -2816,6 +2963,24 @@
28162963 if (child == null)
28172964 continue;
28182965 child.GenNormals(crease);
2966
+// Children().release(i);
2967
+ }
2968
+ blockloop = false;
2969
+ }
2970
+
2971
+ void GenNormalsMesh()
2972
+ {
2973
+ if (blockloop)
2974
+ return;
2975
+
2976
+ blockloop = true;
2977
+ GenNormalsMesh0();
2978
+ for (int i = 0; i < Children().Size(); i++)
2979
+ {
2980
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2981
+ if (child == null)
2982
+ continue;
2983
+ child.GenNormalsMesh();
28192984 // Children().release(i);
28202985 }
28212986 blockloop = false;
....@@ -2988,11 +3153,20 @@
29883153 }
29893154 }
29903155
3156
+ void GenNormalsMesh0()
3157
+ {
3158
+ if (bRep != null)
3159
+ {
3160
+ bRep.GenerateNormalsMesh();
3161
+ Touch();
3162
+ }
3163
+ }
3164
+
29913165 void GenNormalsMINE0()
29923166 {
29933167 if (bRep != null)
29943168 {
2995
- bRep.GenerateNormalsMINE();
3169
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
29963170 Touch();
29973171 }
29983172 }
....@@ -3438,7 +3612,8 @@
34383612 if (blockloop)
34393613 return;
34403614
3441
- if (marked || (bRep != null && material != null)) // borderline...
3615
+ if (//marked || // does not make sense
3616
+ (bRep != null || material != null)) // borderline...
34423617 live = h;
34433618
34443619 for (int i = 0; i < Size(); i++)
....@@ -3459,7 +3634,8 @@
34593634 return;
34603635
34613636 //if (bRep != null)
3462
- if (marked || (bRep != null && material != null)) // borderline...
3637
+ if (//marked || // does not make sense
3638
+ (bRep != null || material != null)) // borderline...
34633639 link2master = h;
34643640
34653641 for (int i = 0; i < Size(); i++)
....@@ -3479,7 +3655,8 @@
34793655 if (blockloop)
34803656 return;
34813657
3482
- if (marked || (bRep != null && material != null)) // borderline...
3658
+ if (//marked || // does not make sense
3659
+ (bRep != null || material != null)) // borderline...
34833660 hide = h;
34843661
34853662 for (int i = 0; i < Size(); i++)
....@@ -3499,7 +3676,7 @@
34993676 if (blockloop)
35003677 return;
35013678
3502
- if (bRep != null && material != null) // borderline...
3679
+ if (bRep != null || material != null) // borderline...
35033680 marked = h;
35043681
35053682 for (int i = 0; i < Size(); i++)
....@@ -3509,6 +3686,46 @@
35093686 continue;
35103687 blockloop = true;
35113688 child.MarkLeaves(h);
3689
+ blockloop = false;
3690
+ // release(i);
3691
+ }
3692
+ }
3693
+
3694
+ void RewindLeaves(boolean h)
3695
+ {
3696
+ if (blockloop)
3697
+ return;
3698
+
3699
+ if (bRep != null || material != null) // borderline...
3700
+ rewind = h;
3701
+
3702
+ for (int i = 0; i < Size(); i++)
3703
+ {
3704
+ Object3D child = (Object3D) get(i); // reserve(i);
3705
+ if (child == null)
3706
+ continue;
3707
+ blockloop = true;
3708
+ child.RewindLeaves(h);
3709
+ blockloop = false;
3710
+ // release(i);
3711
+ }
3712
+ }
3713
+
3714
+ void RandomLeaves(boolean h)
3715
+ {
3716
+ if (blockloop)
3717
+ return;
3718
+
3719
+ if (bRep != null || material != null) // borderline...
3720
+ random = h;
3721
+
3722
+ for (int i = 0; i < Size(); i++)
3723
+ {
3724
+ Object3D child = (Object3D) get(i); // reserve(i);
3725
+ if (child == null)
3726
+ continue;
3727
+ blockloop = true;
3728
+ child.RandomLeaves(h);
35123729 blockloop = false;
35133730 // release(i);
35143731 }
....@@ -4286,6 +4503,55 @@
42864503 }
42874504 }
42884505
4506
+ void RepairSOV()
4507
+ {
4508
+ if (blockloop)
4509
+ return;
4510
+
4511
+ String texname = this.GetPigmentTexture();
4512
+
4513
+ if (texname.startsWith("sov"))
4514
+ {
4515
+ String[] s = texname.split("/");
4516
+
4517
+ String[] sname = s[1].split("Color.pn");
4518
+
4519
+ texname = sname[0];
4520
+
4521
+ if (sname.length > 1)
4522
+ {
4523
+ texname += "Color.jpg";
4524
+ }
4525
+
4526
+ this.SetPigmentTexture("sov/" + texname);
4527
+ }
4528
+
4529
+ texname = this.GetBumpTexture();
4530
+
4531
+ if (texname.startsWith("sov"))
4532
+ {
4533
+ String[] s = texname.split("/");
4534
+
4535
+ String[] sname = s[1].split("Bump.pn");
4536
+
4537
+ texname = sname[0];
4538
+
4539
+ if (sname.length > 1)
4540
+ {
4541
+ texname += "Bump.jpg";
4542
+ }
4543
+
4544
+ this.SetBumpTexture("sov/" + texname);
4545
+ }
4546
+
4547
+ for (int i=0; i<Size(); i++)
4548
+ {
4549
+ blockloop = true;
4550
+ get(i).RepairSOV();
4551
+ blockloop = false;
4552
+ }
4553
+ }
4554
+
42894555 void RepairTexture()
42904556 {
42914557 if (this instanceof FileObject || blockloop)
....@@ -4800,6 +5066,14 @@
48005066 }
48015067 }
48025068
5069
+ ObjEditor GetWindow()
5070
+ {
5071
+ if (editWindow != null)
5072
+ return editWindow;
5073
+
5074
+ return manipWindow;
5075
+ }
5076
+
48035077 cTreePath Select(int indexcount, boolean deselect)
48045078 {
48055079 if (hide || dontselect)
....@@ -4836,10 +5110,11 @@
48365110 if (leaf != null)
48375111 {
48385112 cTreePath tp = new cTreePath(this, leaf);
4839
- if (editWindow != null)
5113
+ ObjEditor window = GetWindow();
5114
+ if (window != null)
48405115 {
48415116 //System.out.println("editWindow = " + editWindow + " vs " + this);
4842
- editWindow.Select(tp, deselect, true);
5117
+ window.Select(tp, deselect, true);
48435118 }
48445119
48455120 return tp;
....@@ -4856,6 +5131,7 @@
48565131
48575132 if (child == null)
48585133 continue;
5134
+
48595135 if (child.HasTransparency() && child.size() != 0)
48605136 {
48615137 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4865,9 +5141,10 @@
48655141 if (leaf != null)
48665142 {
48675143 cTreePath tp = new cTreePath(this, leaf);
4868
- if (editWindow != null)
5144
+ ObjEditor window = GetWindow();
5145
+ if (window != null)
48695146 {
4870
- editWindow.Select(tp, deselect, true);
5147
+ window.Select(tp, deselect, true);
48715148 }
48725149
48735150 return tp;
....@@ -5192,6 +5469,51 @@
51925469 blockloop = false;
51935470 }
51945471
5472
+ void ResetSelectable()
5473
+ {
5474
+ if (blockloop)
5475
+ return;
5476
+
5477
+ blockloop = true;
5478
+
5479
+ keepdontselect = dontselect;
5480
+ dontselect = true;
5481
+
5482
+ Object3D child;
5483
+ int nb = Size();
5484
+ for (int i = 0; i < nb; i++)
5485
+ {
5486
+ child = (Object3D) get(i);
5487
+ if (child == null)
5488
+ continue;
5489
+ child.ResetSelectable();
5490
+ }
5491
+
5492
+ blockloop = false;
5493
+ }
5494
+
5495
+ void RestoreSelectable()
5496
+ {
5497
+ if (blockloop)
5498
+ return;
5499
+
5500
+ blockloop = true;
5501
+
5502
+ dontselect = keepdontselect;
5503
+
5504
+ Object3D child;
5505
+ int nb = Size();
5506
+ for (int i = 0; i < nb; i++)
5507
+ {
5508
+ child = (Object3D) get(i);
5509
+ if (child == null)
5510
+ continue;
5511
+ child.RestoreSelectable();
5512
+ }
5513
+
5514
+ blockloop = false;
5515
+ }
5516
+
51955517 boolean IsSelected()
51965518 {
51975519 if (parent == null)
....@@ -5252,6 +5574,11 @@
52525574 if (fullname == null)
52535575 return "";
52545576
5577
+ if (fullname.pigment != null)
5578
+ {
5579
+ return fullname.pigment;
5580
+ }
5581
+
52555582 // System.out.println("Fullname = " + fullname);
52565583
52575584 // Does not work on Windows due to C:
....@@ -5264,7 +5591,7 @@
52645591
52655592 if (split.length == 0)
52665593 {
5267
- return "";
5594
+ return fullname.pigment = "";
52685595 }
52695596
52705597 if (split.length <= 2)
....@@ -5272,22 +5599,27 @@
52725599 if (fullname.name.endsWith(":"))
52735600 {
52745601 // Windows
5275
- return fullname.name.substring(0, fullname.name.length()-1);
5602
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
52765603 }
52775604
5278
- return split[0];
5605
+ return fullname.pigment = split[0];
52795606 }
52805607
52815608 // Windows
52825609 assert(split.length == 4);
52835610
5284
- return split[0] + ":" + split[1];
5611
+ return fullname.pigment = split[0] + ":" + split[1];
52855612 }
52865613
52875614 static String GetBump(cTexture fullname)
52885615 {
52895616 if (fullname == null)
52905617 return "";
5618
+
5619
+ if (fullname.bump != null)
5620
+ {
5621
+ return fullname.bump;
5622
+ }
52915623
52925624 // System.out.println("Fullname = " + fullname);
52935625 // Does not work on Windows due to C:
....@@ -5299,12 +5631,12 @@
52995631
53005632 if (split.length == 0)
53015633 {
5302
- return "";
5634
+ return fullname.bump = "";
53035635 }
53045636
53055637 if (split.length == 1)
53065638 {
5307
- return "";
5639
+ return fullname.bump = "";
53085640 }
53095641
53105642 if (split.length == 2)
....@@ -5312,16 +5644,16 @@
53125644 if (fullname.name.endsWith(":"))
53135645 {
53145646 // Windows
5315
- return "";
5647
+ return fullname.bump = "";
53165648 }
53175649
5318
- return split[1];
5650
+ return fullname.bump = split[1];
53195651 }
53205652
53215653 // Windows
53225654 assert(split.length == 4);
53235655
5324
- return split[2] + ":" + split[3];
5656
+ return fullname.bump = split[2] + ":" + split[3];
53255657 }
53265658
53275659 String GetPigmentTexture()
....@@ -5404,6 +5736,9 @@
54045736 texname = "";
54055737
54065738 GetTextures().name = texname + ":" + GetBump(GetTextures());
5739
+
5740
+ GetTextures().pigment = null;
5741
+
54075742 Touch();
54085743 }
54095744
....@@ -5477,6 +5812,8 @@
54775812
54785813 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
54795814
5815
+ GetTextures().bump = null;
5816
+
54805817 Touch();
54815818 }
54825819
....@@ -5501,6 +5838,38 @@
55015838 }
55025839 }
55035840
5841
+ void EmbedTextures(boolean embed)
5842
+ {
5843
+ if (blockloop)
5844
+ return;
5845
+
5846
+ //if (GetTextures() != null)
5847
+ if (embed)
5848
+ CameraPane.EmbedTextures(GetTextures());
5849
+ else
5850
+ {
5851
+ GetTextures().pigmentdata = null;
5852
+ GetTextures().bumpdata = null;
5853
+ GetTextures().pw = 0;
5854
+ GetTextures().ph = 0;
5855
+ GetTextures().bw = 0;
5856
+ GetTextures().bh = 0;
5857
+ }
5858
+
5859
+ int nb = Size();
5860
+ for (int i = 0; i < nb; i++)
5861
+ {
5862
+ Object3D child = (Object3D) get(i);
5863
+
5864
+ if (child == null)
5865
+ continue;
5866
+
5867
+ blockloop = true;
5868
+ child.EmbedTextures(embed);
5869
+ blockloop = false;
5870
+ }
5871
+ }
5872
+
55045873 void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
55055874 {
55065875 Draw(display, root, selected, blocked);
....@@ -5509,12 +5878,23 @@
55095878 boolean NeedSupport()
55105879 {
55115880 return
5512
- CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null
5881
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
55135882 // PROBLEM with CROWD!!
55145883 && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
55155884 }
55165885
55175886 static boolean DEBUG_SELECTION = false;
5887
+
5888
+ boolean IsLive()
5889
+ {
5890
+ if (live)
5891
+ return true;
5892
+
5893
+ if (parent == null)
5894
+ return false;
5895
+
5896
+ return parent.IsLive();
5897
+ }
55185898
55195899 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
55205900 {
....@@ -5576,8 +5956,10 @@
55765956 if (support != null)
55775957 support = support;
55785958
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);
5959
+ boolean usecalllists = !IsLive() && IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5960
+ //boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5961
+
5962
+ //usecalllists &= display.DrawMode() == display.DEFAULT; // Don't compute list in shadow pass.
55815963
55825964 if (!usecalllists && bRep != null && bRep.displaylist > 0)
55835965 {
....@@ -5587,8 +5969,9 @@
55875969 // usecalllists &= !(parent instanceof RandomNode);
55885970 // usecalllists = false;
55895971
5590
- if (GetBRep() != null)
5591
- usecalllists = usecalllists;
5972
+ if (display.DrawMode() == display.SHADOW)
5973
+ //GetBRep() != null)
5974
+ usecalllists = !!usecalllists;
55925975 //System.out.println("draw " + this);
55935976 //new Exception().printStackTrace();
55945977
....@@ -5597,10 +5980,12 @@
55975980 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
55985981
55995982 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5600
- (touched || (bRep != null && bRep.displaylist <= 0)))
5983
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5984
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
56015985 {
56025986 Globals.lighttouched = true;
56035987 } // all panes...
5988
+
56045989 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
56055990 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
56065991 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5608,7 +5993,7 @@
56085993 if (!(this instanceof Composite))
56095994 touched = false;
56105995 //if (displaylist == -1 && usecalllists)
5611
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
5996
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
56125997 {
56135998 bRep.displaylist = display.GenList();
56145999 assert(bRep.displaylist != 0);
....@@ -5619,7 +6004,7 @@
56196004
56206005 //System.out.println("\tnew list " + list);
56216006 //gl.glDrawBuffer(gl.GL_NONE);
5622
- if (usecalllists)
6007
+ if (usecalllists && bRep.displaylist > 0)
56236008 {
56246009 // System.err.println("new list " + bRep.displaylist + " for " + this);
56256010 display.NewList(bRep.displaylist);
....@@ -5628,7 +6013,7 @@
56286013 CallList(display, root, selected, blocked);
56296014
56306015 // compiled = true;
5631
- if (usecalllists)
6016
+ if (usecalllists && bRep.displaylist > 0)
56326017 {
56336018 // System.err.println("end list " + bRep.displaylist + " for " + this);
56346019 display.EndList();
....@@ -5728,6 +6113,7 @@
57286113 if (GetBRep() != null)
57296114 {
57306115 display.NextIndex();
6116
+
57316117 // vertex color conflict : gl.glCallList(list);
57326118 DrawNode(display, root, selected);
57336119 if (this instanceof BezierPatch)
....@@ -5768,16 +6154,27 @@
57686154 tex = GetTextures();
57696155 }
57706156
5771
- boolean failed = false;
6157
+ boolean failedPigment = false;
6158
+ boolean failedBump = false;
57726159
57736160 try
57746161 {
5775
- display.BindTextures(tex, texres);
6162
+ display.BindPigmentTexture(tex, texres);
57766163 }
57776164 catch (Exception e)
57786165 {
57796166 System.err.println("FAILED: " + this);
5780
- failed = true;
6167
+ failedPigment = true;
6168
+ }
6169
+
6170
+ try
6171
+ {
6172
+ display.BindBumpTexture(tex, texres);
6173
+ }
6174
+ catch (Exception e)
6175
+ {
6176
+ //System.err.println("FAILED: " + this);
6177
+ failedBump = true;
57816178 }
57826179
57836180 if (!compiled)
....@@ -5800,8 +6197,11 @@
58006197 }
58016198 }
58026199
5803
- if (!failed)
5804
- display.ReleaseTextures(tex);
6200
+ if (!failedBump)
6201
+ display.ReleaseBumpTexture(tex);
6202
+
6203
+ if (!failedPigment)
6204
+ display.ReleasePigmentTexture(tex);
58056205
58066206 display.PopMaterial(this, selected);
58076207 }
....@@ -6174,6 +6574,11 @@
61746574 // dec 2012
61756575 new Exception().printStackTrace();
61766576 return;
6577
+ }
6578
+
6579
+ if (dontselect)
6580
+ {
6581
+ //bRep.GenerateNormalsMINE();
61776582 }
61786583
61796584 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -6959,20 +7364,23 @@
69597364 }
69607365 }
69617366
6962
- protected void calcHotSpot(cVector in, ClickInfo info, Point outPt, Rectangle outRec)
7367
+ static ClickInfo clickInfo = new ClickInfo();
7368
+
7369
+ protected void calcHotSpot(cVector in, //ClickInfo clickInfo,
7370
+ Point outPt, Rectangle outRec)
69637371 {
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;
7372
+ int hc = clickInfo.bounds.x + clickInfo.bounds.width / 2;
7373
+ int vc = clickInfo.bounds.y + clickInfo.bounds.height / 2;
7374
+ double[][] toscreen = clickInfo.toScreen;
69677375 if (toscreen == null)
69687376 {
6969
- toscreen = new Camera(info.camera.viewCode).toScreen;
7377
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
69707378 }
69717379 cVector vec = in;
69727380 LA.xformPos(in, toscreen, in);
69737381 //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();
7382
+ vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
7383
+ vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
69767384 outPt.x = hc + (int) vec.x;
69777385 outPt.y = vc - (int) vec.y;
69787386 outRec.x = outPt.x - 3;
....@@ -6980,15 +7388,18 @@
69807388 outRec.width = outRec.height = 6;
69817389 }
69827390
6983
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7391
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7392
+ )
69847393 {
69857394 Point pt = new Point(0, 0);
69867395 Rectangle rec = new Rectangle();
6987
- calcHotSpot(in, info, pt, rec);
7396
+ calcHotSpot(in, //clickInfo,
7397
+ pt, rec);
69887398 return rec;
69897399 }
69907400
6991
- void drawEditHandles0(ClickInfo info, int level)
7401
+ void drawEditHandles0(//ClickInfo clickInfo,
7402
+ int level)
69927403 {
69937404 if (level == 0)
69947405 {
....@@ -6997,16 +7408,19 @@
69977408 {
69987409 cVector origin = new cVector();
69997410 //LA.xformPos(origin, toParent, origin);
7000
- Rectangle spot = calcHotSpot(origin, info);
7411
+ if (this.clickInfo == null)
7412
+ this.clickInfo = new ClickInfo();
7413
+
7414
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
70017415 Rectangle boundary = new Rectangle();
70027416 boundary.x = spot.x - 30;
70037417 boundary.y = spot.y - 30;
70047418 boundary.width = spot.width + 60;
70057419 boundary.height = spot.height + 60;
7006
- info.g.setColor(Color.red);
7420
+ clickInfo.g.setColor(Color.red);
70077421 int spotw = spot.x + spot.width;
70087422 int spoth = spot.y + spot.height;
7009
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7423
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
70107424 // if (CameraPane.Xmin > spot.x)
70117425 // {
70127426 // CameraPane.Xmin = spot.x;
....@@ -7023,11 +7437,33 @@
70237437 // {
70247438 // CameraPane.Ymax = spoth;
70257439 // }
7026
- spot.translate(32, 32);
7440
+// if (CameraPane.Xmin > spot.x)
7441
+// {
7442
+// CameraPane.Xmin = spot.x;
7443
+// }
7444
+// if (CameraPane.Xmax < spotw)
7445
+// {
7446
+// CameraPane.Xmax = spotw;
7447
+// }
7448
+// if (CameraPane.Ymin > spot.y)
7449
+// {
7450
+// CameraPane.Ymin = spot.y;
7451
+// }
7452
+// if (CameraPane.Ymax < spoth)
7453
+// {
7454
+// CameraPane.Ymax = spoth;
7455
+// }
7456
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7457
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
7458
+ spot.translate(32, 0);
7459
+ clickInfo.g.setColor(Color.yellow);
7460
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7461
+
7462
+ spot.translate(32, 64);
70277463 spotw = spot.x + spot.width;
70287464 spoth = spot.y + spot.height;
7029
- info.g.setColor(Color.blue);
7030
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7465
+ clickInfo.g.setColor(Color.cyan);
7466
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
70317467 // if (CameraPane.Xmin > spot.x)
70327468 // {
70337469 // CameraPane.Xmin = spot.x;
....@@ -7044,29 +7480,9 @@
70447480 // {
70457481 // CameraPane.Ymax = spoth;
70467482 // }
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);
7483
+ clickInfo.g.setColor(Color.green);
7484
+ clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
7485
+ (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
70707486 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
70717487 // if (CameraPane.Xmin > boundary.x)
70727488 // {
....@@ -7088,7 +7504,8 @@
70887504 }
70897505 }
70907506
7091
- boolean doEditClick0(ClickInfo info, int level)
7507
+ boolean doEditClick0(//ClickInfo clickInfo,
7508
+ int level)
70927509 {
70937510 if (level == 0)
70947511 {
....@@ -7097,8 +7514,8 @@
70977514
70987515 boolean retval = false;
70997516
7100
- startX = info.x;
7101
- startY = info.y;
7517
+ startX = clickInfo.x;
7518
+ startY = clickInfo.y;
71027519
71037520 hitSomething = -1;
71047521 cVector origin = new cVector();
....@@ -7108,22 +7525,53 @@
71087525 {
71097526 centerPt = new Point(0, 0);
71107527 }
7111
- calcHotSpot(origin, info, centerPt, spot);
7112
- if (spot.contains(info.x, info.y))
7528
+ calcHotSpot(origin, //info,
7529
+ centerPt, spot);
7530
+ if (spot.contains(clickInfo.x, clickInfo.y))
71137531 {
71147532 hitSomething = hitCenter;
71157533 retval = true;
71167534 }
71177535 spot.translate(32, 0);
7118
- if (spot.contains(info.x, info.y))
7536
+ if (spot.contains(clickInfo.x, clickInfo.y))
71197537 {
71207538 hitSomething = hitRotate;
71217539 retval = true;
71227540 }
71237541 spot.translate(0, 32);
7124
- if (spot.contains(info.x, info.y))
7542
+ spot.translate(32, 0);
7543
+ spot.translate(0, 32);
7544
+ if (spot.contains(clickInfo.x, clickInfo.y))
71257545 {
71267546 hitSomething = hitScale;
7547
+
7548
+ double scale = 0.005f * clickInfo.camera.Distance();
7549
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
7550
+ double sign = 1;
7551
+ if (hScale < 0)
7552
+ {
7553
+ sign = -1;
7554
+ }
7555
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
7556
+ if (hScale < 0.01)
7557
+ {
7558
+ //hScale = 0.01;
7559
+ }
7560
+
7561
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
7562
+ sign = 1;
7563
+ if (vScale < 0)
7564
+ {
7565
+ sign = -1;
7566
+ }
7567
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
7568
+ if (vScale < 0.01)
7569
+ {
7570
+ //vScale = 0.01;
7571
+ }
7572
+
7573
+ clickInfo.scale = Math.sqrt(hScale*hScale + vScale*vScale);
7574
+
71277575 retval = true;
71287576 }
71297577
....@@ -7133,7 +7581,7 @@
71337581 }
71347582
71357583 //System.out.println("info.modifiers = " + info.modifiers);
7136
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7584
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
71377585 //System.out.println("modified = " + modified);
71387586 //new Exception().printStackTrace();
71397587 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7161,7 +7609,8 @@
71617609 return true;
71627610 }
71637611
7164
- void doEditDrag0(ClickInfo info, boolean opposite)
7612
+ void doEditDrag0(//ClickInfo info,
7613
+ boolean opposite)
71657614 {
71667615 if (hitSomething == 0)
71677616 {
....@@ -7175,7 +7624,7 @@
71757624
71767625 //System.out.println("hitSomething = " + hitSomething);
71777626
7178
- double scale = 0.005f * info.camera.Distance();
7627
+ double scale = 0.005f * clickInfo.camera.Distance();
71797628
71807629 cVector xlate = new cVector();
71817630 //cVector xlate2 = new cVector();
....@@ -7209,8 +7658,8 @@
72097658 toParent[3][i] = xlate.get(i);
72107659 LA.matInvert(toParent, fromParent);
72117660 */
7212
- cVector delta = LA.newVector(0, 0, startY - info.y);
7213
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7661
+ cVector delta = LA.newVector(0, 0, startY - clickInfo.y);
7662
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
72147663
72157664 LA.matCopy(startMat, toParent);
72167665 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7219,7 +7668,7 @@
72197668 } else
72207669 {
72217670 //LA.xformDir(delta, info.camera.fromScreen, delta);
7222
- cVector up = new cVector(info.camera.up);
7671
+ cVector up = new cVector(clickInfo.camera.up);
72237672 cVector away = new cVector();
72247673 //cVector right2 = new cVector();
72257674 //LA.vecCross(up, cVector.Z, right);
....@@ -7236,19 +7685,19 @@
72367685 LA.xformDir(up, ClickInfo.matbuffer, up);
72377686 // if (!CameraPane.LOCALTRANSFORM)
72387687 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7239
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7688
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
72407689 // if (!CameraPane.LOCALTRANSFORM)
72417690 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
72427691 //LA.vecCross(up, cVector.Z, right2);
72437692
7244
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7693
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
72457694
72467695 //System.out.println("DELTA0 = " + delta);
72477696 //System.out.println("AWAY = " + info.camera.away);
72487697 //System.out.println("UP = " + info.camera.up);
72497698 if (away.z > 0)
72507699 {
7251
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7700
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
72527701 {
72537702 delta.x = -delta.x;
72547703 } else
....@@ -7263,7 +7712,7 @@
72637712 //System.out.println("DELTA1 = " + delta);
72647713 LA.xformDir(delta, ClickInfo.matbuffer, delta);
72657714 //System.out.println("DELTA2 = " + delta);
7266
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7715
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
72677716 LA.matCopy(startMat, toParent);
72687717 //System.out.println("DELTA3 = " + delta);
72697718 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7273,8 +7722,8 @@
72737722 break;
72747723
72757724 case hitRotate: // rotate
7276
- int dx = info.x - centerPt.x;
7277
- int dy = -(info.y - centerPt.y);
7725
+ int dx = clickInfo.x - centerPt.x;
7726
+ int dy = -(clickInfo.y - centerPt.y);
72787727 double angle = (double) Math.atan2(dx, dy);
72797728 angle = -(1.570796 - angle);
72807729
....@@ -7297,7 +7746,7 @@
72977746 }
72987747 /**/
72997748
7300
- switch (info.pane.RenderCamera().viewCode)
7749
+ switch (clickInfo.pane.RenderCamera().viewCode)
73017750 {
73027751 case 1: // '\001'
73037752 LA.matZRotate(toParent, angle);
....@@ -7324,7 +7773,7 @@
73247773 break;
73257774
73267775 case hitScale: // scale
7327
- double hScale = (double) (info.x - centerPt.x) / 32;
7776
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
73287777 double sign = 1;
73297778 if (hScale < 0)
73307779 {
....@@ -7336,7 +7785,7 @@
73367785 //hScale = 0.01;
73377786 }
73387787
7339
- double vScale = (double) (info.y - centerPt.y) / 32;
7788
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
73407789 sign = 1;
73417790 if (vScale < 0)
73427791 {
....@@ -7347,6 +7796,7 @@
73477796 {
73487797 //vScale = 0.01;
73497798 }
7799
+
73507800 LA.matCopy(startMat, toParent);
73517801 /**/
73527802 for (int i = 0; i < 3; i++)
....@@ -7356,29 +7806,30 @@
73567806 }
73577807 /**/
73587808
7359
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7809
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
73607810
73617811 if (totalScale < 0.01)
73627812 {
73637813 totalScale = 0.01;
73647814 }
73657815
7366
- switch (info.pane.RenderCamera().viewCode)
7816
+ switch (clickInfo.pane.RenderCamera().viewCode)
73677817 {
73687818 case 3: // '\001'
7369
- if (modified)
7819
+ if (modified || opposite)
73707820 {
73717821 //LA.matScale(toParent, 1, hScale, vScale);
73727822 LA.matScale(toParent, totalScale, 1, 1);
73737823 } // vScale, 1);
73747824 else
73757825 {
7826
+ // EXCEPTION!
73767827 LA.matScale(toParent, totalScale, totalScale, totalScale);
73777828 } // vScale, 1);
73787829 break;
73797830
73807831 case 2: // '\002'
7381
- if (modified)
7832
+ if (modified || opposite)
73827833 {
73837834 //LA.matScale(toParent, hScale, 1, vScale);
73847835 LA.matScale(toParent, 1, totalScale, 1);
....@@ -7389,7 +7840,7 @@
73897840 break;
73907841
73917842 case 1: // '\003'
7392
- if (modified)
7843
+ if (modified || opposite)
73937844 {
73947845 //LA.matScale(toParent, hScale, vScale, 1);
73957846 LA.matScale(toParent, 1, 1, totalScale);
....@@ -7429,7 +7880,7 @@
74297880 } // NEW ...
74307881
74317882
7432
- info.pane.repaint();
7883
+ clickInfo.pane.repaint();
74337884 }
74347885
74357886 boolean overflow = false;
....@@ -7609,6 +8060,10 @@
76098060 editWindow = null;
76108061 } // ?
76118062 }
8063
+ else
8064
+ {
8065
+ //editWindow.closeUI();
8066
+ }
76128067 }
76138068
76148069 boolean root; // patch for edit windows
....@@ -7766,6 +8221,10 @@
77668221 }
77678222
77688223 transient ObjEditor editWindow;
8224
+ transient ObjEditor manipWindow;
8225
+
8226
+ transient boolean pinned;
8227
+
77698228 transient ObjectUI objectUI;
77708229 public static int povDepth = 0;
77718230 private static cVector tbMin = new cVector();