Normand Briere
2019-08-17 ecc1309a04b527c62ffe97e814daf050dbd025cd
Object3D.java
....@@ -14,11 +14,29 @@
1414 import //weka.core.
1515 matrix.Matrix;
1616
17
+import java.util.UUID;
18
+
1719 //import net.sourceforge.sizeof.SizeOf;
1820 public class Object3D extends Vector<Object3D> implements java.io.Serializable, iSendInfo //, aurelienribon.tweenengine.TweenAccessor<Object3D>
1921 {
2022 //static final long serialVersionUID = -607422624994562685L;
2123 static final long serialVersionUID = 5022536242724664900L;
24
+
25
+ // Use GetUUID for backward compatibility with null.
26
+ private UUID uuid = UUID.randomUUID();
27
+
28
+ // TEMPORARY for mocap undo. No need to be transient.
29
+ mocap.reader.BVHReader.BVHResult savebvh;
30
+ Object3D saveskeleton;
31
+ //
32
+
33
+ String skyboxname;
34
+ String skyboxext;
35
+
36
+ Object3D versionlist[];
37
+ int versionindex = -1;
38
+
39
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable; // = new java.util.Hashtable<java.util.UUID, Object3D>();
2240
2341 ScriptNode scriptnode;
2442
....@@ -100,64 +118,201 @@
100118
101119 // transient boolean reduced; // for morph reduction
102120
103
-transient com.bulletphysics.linearmath.Transform cache; // for fast merge
104
-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
105123
106
-transient Object3D transientsupport; // for cloning
107
-transient boolean transientlink2master;
124
+ transient Object3D transientsupport; // for cloning
125
+ transient boolean transientlink2master;
108126
109
-void SaveSupports()
110
-{
111
- if (blockloop)
112
- return;
113
-
114
- transientsupport = support;
115
- transientlink2master = link2master;
116
-
117
- support = null;
118
- link2master = false;
119
-
120
- if (bRep != null)
127
+ void SaveSupports()
121128 {
122
- 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
+ }
123152 }
124
-
125
- for (int i = 0; i < Size(); i++)
153
+
154
+ void RestoreSupports()
126155 {
127
- Object3D child = (Object3D) get(i);
128
- if (child == null)
129
- 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
+
130287 blockloop = true;
131
- child.SaveSupports();
288
+
289
+ //hashtable.remove(GetUUID());
290
+
291
+ for (int i=0; i<Size(); i++)
292
+ {
293
+ get(i).RestoreBigData(hashtable);
294
+ }
295
+
132296 blockloop = false;
133297 }
134
-}
135298
136
-void RestoreSupports()
137
-{
138
- if (blockloop)
139
- return;
140
-
141
- support = transientsupport;
142
- link2master = transientlink2master;
143
- transientsupport = null;
144
- transientlink2master = false;
145
-
146
- if (bRep != null)
299
+ void RestoreBigData(Object3D o)
147300 {
148
- 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;
149315 }
150
-
151
- for (int i = 0; i < Size(); i++)
152
- {
153
- Object3D child = (Object3D) get(i);
154
- if (child == null)
155
- continue;
156
- blockloop = true;
157
- child.RestoreSupports();
158
- blockloop = false;
159
- }
160
-}
161316
162317 // MOCAP SUPPORT
163318 double tx,ty,tz,rx,ry,rz;
....@@ -300,6 +455,7 @@
300455 }
301456
302457 boolean live = false;
458
+ transient boolean keepdontselect;
303459 boolean dontselect = false;
304460 boolean hide = false;
305461 boolean link2master = false; // performs reset support/master at each frame
....@@ -482,12 +638,14 @@
482638 toParent = LA.newMatrix();
483639 fromParent = LA.newMatrix();
484640 }
641
+
485642 if (toParentMarked == null)
486643 {
487644 if (maxcount != 1)
488645 {
489646 new Exception().printStackTrace();
490647 }
648
+
491649 toParentMarked = LA.newMatrix();
492650 fromParentMarked = LA.newMatrix();
493651 }
....@@ -775,7 +933,7 @@
775933 if (step == 0)
776934 step = 1;
777935 if (maxcount == 0)
778
- maxcount = 2048; // 4;
936
+ maxcount = 128; // 2048; // 4;
779937 // if (acceleration == 0)
780938 // acceleration = 10;
781939 if (delay == 0) // serial
....@@ -798,7 +956,7 @@
798956
799957 if (marked && Globals.isLIVE() && live &&
800958 //TEMP21aug2018
801
- (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
959
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
802960 currentframe != Globals.framecount)
803961 {
804962 currentframe = Globals.framecount;
....@@ -810,7 +968,8 @@
810968
811969 boolean changedir = random && Math.random() < 0.01; // && !link2master;
812970
813
- if (transformcount*factor > maxcount || (step == 1 && changedir))
971
+ if (transformcount*factor >= maxcount && (rewind || random) ||
972
+ (step == 1 && changedir))
814973 {
815974 countdown = 1;
816975 delay = speedup?8:1;
....@@ -882,6 +1041,10 @@
8821041 if (material == null || material.multiply)
8831042 return true;
8841043
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.
8851048 return material.opacity > 0.99;
8861049 }
8871050
....@@ -1282,6 +1445,7 @@
12821445 toParent = LA.newMatrix();
12831446 fromParent = LA.newMatrix();
12841447 }
1448
+
12851449 LA.matCopy(other.toParent, toParent);
12861450 LA.matCopy(other.fromParent, fromParent);
12871451
....@@ -2303,6 +2467,15 @@
23032467 }
23042468 */
23052469 }
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
+ }
23062479 }
23072480
23082481 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
....@@ -2344,6 +2517,14 @@
23442517 {
23452518 editWindow.refreshContents();
23462519 }
2520
+ else
2521
+ {
2522
+ if (manipWindow != null)
2523
+ {
2524
+ manipWindow.refreshContents();
2525
+ }
2526
+ }
2527
+
23472528 //if (parent != null)
23482529 //parent.refreshEditWindow();
23492530 }
....@@ -2423,7 +2604,8 @@
24232604 private static final int editSelf = 1;
24242605 private static final int editChild = 2;
24252606
2426
- void drawEditHandles(ClickInfo info, int level)
2607
+ void drawEditHandles(//ClickInfo info,
2608
+ int level)
24272609 {
24282610 if (level == 0)
24292611 {
....@@ -2431,7 +2613,8 @@
24312613 return;
24322614
24332615 Object3D selectee;
2434
- 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))
24352618 {
24362619 selectee = (Object3D) e.nextElement();
24372620 }
....@@ -2439,19 +2622,22 @@
24392622 } else
24402623 {
24412624 //super.
2442
- drawEditHandles0(info, level + 1);
2625
+ drawEditHandles0(//info,
2626
+ level + 1);
24432627 }
24442628 }
24452629
2446
- boolean doEditClick(ClickInfo info, int level)
2630
+ boolean doEditClick(//ClickInfo info,
2631
+ int level)
24472632 {
24482633 doSomething = 0;
24492634 if (level == 0)
24502635 {
2451
- return doParentClick(info);
2636
+ return doParentClick(); //info);
24522637 }
24532638 if (//super.
2454
- doEditClick0(info, level))
2639
+ doEditClick0(//info,
2640
+ level))
24552641 {
24562642 doSomething = 1;
24572643 return true;
....@@ -2461,7 +2647,7 @@
24612647 }
24622648 }
24632649
2464
- boolean doParentClick(ClickInfo info)
2650
+ boolean doParentClick() //ClickInfo info)
24652651 {
24662652 if (selection == null)
24672653 {
....@@ -2474,7 +2660,8 @@
24742660 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
24752661 {
24762662 Object3D selectee = (Object3D) e.nextElement();
2477
- if (selectee.doEditClick(info, 1))
2663
+ if (selectee.doEditClick(//info,
2664
+ 1))
24782665 {
24792666 childToDrag = selectee;
24802667 doSomething = 2;
....@@ -2486,13 +2673,15 @@
24862673 return retval;
24872674 }
24882675
2489
- void doEditDrag(ClickInfo info, boolean opposite)
2676
+ void doEditDrag(//ClickInfo clickInfo,
2677
+ boolean opposite)
24902678 {
24912679 switch (doSomething)
24922680 {
24932681 case 1: // '\001'
24942682 //super.
2495
- doEditDrag0(info, opposite);
2683
+ doEditDrag0(//clickInfo,
2684
+ opposite);
24962685 break;
24972686
24982687 case 2: // '\002'
....@@ -2505,11 +2694,13 @@
25052694 {
25062695 //sel.hitSomething = childToDrag.hitSomething;
25072696 //childToDrag.doEditDrag(info);
2508
- sel.doEditDrag(info, opposite);
2697
+ sel.doEditDrag(//clickInfo,
2698
+ opposite);
25092699 } else
25102700 {
25112701 //super.
2512
- doEditDrag0(info, opposite);
2702
+ doEditDrag0(//clickInfo,
2703
+ opposite);
25132704 }
25142705 }
25152706 break;
....@@ -2527,6 +2718,9 @@
25272718 {
25282719 deselectAll();
25292720 }
2721
+
2722
+ new Exception().printStackTrace();
2723
+
25302724 ClickInfo newInfo = new ClickInfo();
25312725 newInfo.flags = info.flags;
25322726 newInfo.bounds = info.bounds;
....@@ -2619,6 +2813,18 @@
26192813 void GenNormalsS(boolean crease)
26202814 {
26212815 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();
26222828 // for (int i=0; i<selection.size(); i++)
26232829 // {
26242830 // Object3D selectee = (Object3D) selection.elementAt(i);
....@@ -2759,6 +2965,24 @@
27592965 if (child == null)
27602966 continue;
27612967 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();
27622986 // Children().release(i);
27632987 }
27642988 blockloop = false;
....@@ -2931,11 +3155,20 @@
29313155 }
29323156 }
29333157
3158
+ void GenNormalsMesh0()
3159
+ {
3160
+ if (bRep != null)
3161
+ {
3162
+ bRep.GenerateNormalsMesh();
3163
+ Touch();
3164
+ }
3165
+ }
3166
+
29343167 void GenNormalsMINE0()
29353168 {
29363169 if (bRep != null)
29373170 {
2938
- bRep.GenerateNormalsMINE();
3171
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
29393172 Touch();
29403173 }
29413174 }
....@@ -3381,7 +3614,8 @@
33813614 if (blockloop)
33823615 return;
33833616
3384
- if (marked || (bRep != null && material != null)) // borderline...
3617
+ if (//marked || // does not make sense
3618
+ (bRep != null || material != null)) // borderline...
33853619 live = h;
33863620
33873621 for (int i = 0; i < Size(); i++)
....@@ -3402,7 +3636,8 @@
34023636 return;
34033637
34043638 //if (bRep != null)
3405
- if (marked || (bRep != null && material != null)) // borderline...
3639
+ if (//marked || // does not make sense
3640
+ (bRep != null || material != null)) // borderline...
34063641 link2master = h;
34073642
34083643 for (int i = 0; i < Size(); i++)
....@@ -3422,7 +3657,8 @@
34223657 if (blockloop)
34233658 return;
34243659
3425
- if (marked || (bRep != null && material != null)) // borderline...
3660
+ if (//marked || // does not make sense
3661
+ (bRep != null || material != null)) // borderline...
34263662 hide = h;
34273663
34283664 for (int i = 0; i < Size(); i++)
....@@ -3442,7 +3678,7 @@
34423678 if (blockloop)
34433679 return;
34443680
3445
- if (bRep != null && material != null) // borderline...
3681
+ if (bRep != null || material != null) // borderline...
34463682 marked = h;
34473683
34483684 for (int i = 0; i < Size(); i++)
....@@ -3452,6 +3688,46 @@
34523688 continue;
34533689 blockloop = true;
34543690 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);
34553731 blockloop = false;
34563732 // release(i);
34573733 }
....@@ -4229,6 +4505,55 @@
42294505 }
42304506 }
42314507
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
+
42324557 void RepairTexture()
42334558 {
42344559 if (this instanceof FileObject || blockloop)
....@@ -4743,6 +5068,14 @@
47435068 }
47445069 }
47455070
5071
+ ObjEditor GetWindow()
5072
+ {
5073
+ if (editWindow != null)
5074
+ return editWindow;
5075
+
5076
+ return manipWindow;
5077
+ }
5078
+
47465079 cTreePath Select(int indexcount, boolean deselect)
47475080 {
47485081 if (hide || dontselect)
....@@ -4779,10 +5112,11 @@
47795112 if (leaf != null)
47805113 {
47815114 cTreePath tp = new cTreePath(this, leaf);
4782
- if (editWindow != null)
5115
+ ObjEditor window = GetWindow();
5116
+ if (window != null)
47835117 {
47845118 //System.out.println("editWindow = " + editWindow + " vs " + this);
4785
- editWindow.Select(tp, deselect, true);
5119
+ window.Select(tp, deselect, true);
47865120 }
47875121
47885122 return tp;
....@@ -4799,6 +5133,7 @@
47995133
48005134 if (child == null)
48015135 continue;
5136
+
48025137 if (child.HasTransparency() && child.size() != 0)
48035138 {
48045139 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4808,9 +5143,10 @@
48085143 if (leaf != null)
48095144 {
48105145 cTreePath tp = new cTreePath(this, leaf);
4811
- if (editWindow != null)
5146
+ ObjEditor window = GetWindow();
5147
+ if (window != null)
48125148 {
4813
- editWindow.Select(tp, deselect, true);
5149
+ window.Select(tp, deselect, true);
48145150 }
48155151
48165152 return tp;
....@@ -5135,6 +5471,51 @@
51355471 blockloop = false;
51365472 }
51375473
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
+
51385519 boolean IsSelected()
51395520 {
51405521 if (parent == null)
....@@ -5195,6 +5576,11 @@
51955576 if (fullname == null)
51965577 return "";
51975578
5579
+ if (fullname.pigment != null)
5580
+ {
5581
+ return fullname.pigment;
5582
+ }
5583
+
51985584 // System.out.println("Fullname = " + fullname);
51995585
52005586 // Does not work on Windows due to C:
....@@ -5207,7 +5593,7 @@
52075593
52085594 if (split.length == 0)
52095595 {
5210
- return "";
5596
+ return fullname.pigment = "";
52115597 }
52125598
52135599 if (split.length <= 2)
....@@ -5215,22 +5601,27 @@
52155601 if (fullname.name.endsWith(":"))
52165602 {
52175603 // Windows
5218
- return fullname.name.substring(0, fullname.name.length()-1);
5604
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
52195605 }
52205606
5221
- return split[0];
5607
+ return fullname.pigment = split[0];
52225608 }
52235609
52245610 // Windows
52255611 assert(split.length == 4);
52265612
5227
- return split[0] + ":" + split[1];
5613
+ return fullname.pigment = split[0] + ":" + split[1];
52285614 }
52295615
52305616 static String GetBump(cTexture fullname)
52315617 {
52325618 if (fullname == null)
52335619 return "";
5620
+
5621
+ if (fullname.bump != null)
5622
+ {
5623
+ return fullname.bump;
5624
+ }
52345625
52355626 // System.out.println("Fullname = " + fullname);
52365627 // Does not work on Windows due to C:
....@@ -5242,12 +5633,12 @@
52425633
52435634 if (split.length == 0)
52445635 {
5245
- return "";
5636
+ return fullname.bump = "";
52465637 }
52475638
52485639 if (split.length == 1)
52495640 {
5250
- return "";
5641
+ return fullname.bump = "";
52515642 }
52525643
52535644 if (split.length == 2)
....@@ -5255,16 +5646,16 @@
52555646 if (fullname.name.endsWith(":"))
52565647 {
52575648 // Windows
5258
- return "";
5649
+ return fullname.bump = "";
52595650 }
52605651
5261
- return split[1];
5652
+ return fullname.bump = split[1];
52625653 }
52635654
52645655 // Windows
52655656 assert(split.length == 4);
52665657
5267
- return split[2] + ":" + split[3];
5658
+ return fullname.bump = split[2] + ":" + split[3];
52685659 }
52695660
52705661 String GetPigmentTexture()
....@@ -5347,6 +5738,9 @@
53475738 texname = "";
53485739
53495740 GetTextures().name = texname + ":" + GetBump(GetTextures());
5741
+
5742
+ GetTextures().pigment = null;
5743
+
53505744 Touch();
53515745 }
53525746
....@@ -5371,6 +5765,43 @@
53715765 }
53725766 }
53735767
5768
+ UUID GetUUID()
5769
+ {
5770
+ if (uuid == null)
5771
+ {
5772
+ // Serial
5773
+ uuid = UUID.randomUUID();
5774
+ }
5775
+
5776
+ return uuid;
5777
+ }
5778
+
5779
+ Object3D GetObject(UUID uid)
5780
+ {
5781
+ if (blockloop)
5782
+ return null;
5783
+
5784
+ if (GetUUID().equals(uid))
5785
+ return this;
5786
+
5787
+ int nb = Size();
5788
+ for (int i = 0; i < nb; i++)
5789
+ {
5790
+ Object3D child = (Object3D) get(i);
5791
+
5792
+ if (child == null)
5793
+ continue;
5794
+
5795
+ blockloop = true;
5796
+ Object3D obj = child.GetObject(uid);
5797
+ blockloop = false;
5798
+ if (obj != null)
5799
+ return obj;
5800
+ }
5801
+
5802
+ return null;
5803
+ }
5804
+
53745805 void SetBumpTexture(String tex)
53755806 {
53765807 if (GetTextures() == null)
....@@ -5382,6 +5813,8 @@
53825813 texname = "";
53835814
53845815 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
5816
+
5817
+ GetTextures().bump = null;
53855818
53865819 Touch();
53875820 }
....@@ -5407,6 +5840,38 @@
54075840 }
54085841 }
54095842
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
+
54105875 void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
54115876 {
54125877 Draw(display, root, selected, blocked);
....@@ -5415,12 +5880,23 @@
54155880 boolean NeedSupport()
54165881 {
54175882 return
5418
- CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null
5883
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
54195884 // PROBLEM with CROWD!!
54205885 && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
54215886 }
54225887
54235888 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
+ }
54245900
54255901 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
54265902 {
....@@ -5482,8 +5958,10 @@
54825958 if (support != null)
54835959 support = support;
54845960
5485
- //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5486
- 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.
54875965
54885966 if (!usecalllists && bRep != null && bRep.displaylist > 0)
54895967 {
....@@ -5493,8 +5971,9 @@
54935971 // usecalllists &= !(parent instanceof RandomNode);
54945972 // usecalllists = false;
54955973
5496
- if (GetBRep() != null)
5497
- usecalllists = usecalllists;
5974
+ if (display.DrawMode() == display.SHADOW)
5975
+ //GetBRep() != null)
5976
+ usecalllists = !!usecalllists;
54985977 //System.out.println("draw " + this);
54995978 //new Exception().printStackTrace();
55005979
....@@ -5503,10 +5982,12 @@
55035982 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
55045983
55055984 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5506
- (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)))
55075987 {
55085988 Globals.lighttouched = true;
55095989 } // all panes...
5990
+
55105991 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
55115992 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
55125993 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5514,7 +5995,7 @@
55145995 if (!(this instanceof Composite))
55155996 touched = false;
55165997 //if (displaylist == -1 && usecalllists)
5517
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
5998
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
55185999 {
55196000 bRep.displaylist = display.GenList();
55206001 assert(bRep.displaylist != 0);
....@@ -5525,7 +6006,7 @@
55256006
55266007 //System.out.println("\tnew list " + list);
55276008 //gl.glDrawBuffer(gl.GL_NONE);
5528
- if (usecalllists)
6009
+ if (usecalllists && bRep.displaylist > 0)
55296010 {
55306011 // System.err.println("new list " + bRep.displaylist + " for " + this);
55316012 display.NewList(bRep.displaylist);
....@@ -5534,7 +6015,7 @@
55346015 CallList(display, root, selected, blocked);
55356016
55366017 // compiled = true;
5537
- if (usecalllists)
6018
+ if (usecalllists && bRep.displaylist > 0)
55386019 {
55396020 // System.err.println("end list " + bRep.displaylist + " for " + this);
55406021 display.EndList();
....@@ -5634,6 +6115,7 @@
56346115 if (GetBRep() != null)
56356116 {
56366117 display.NextIndex();
6118
+
56376119 // vertex color conflict : gl.glCallList(list);
56386120 DrawNode(display, root, selected);
56396121 if (this instanceof BezierPatch)
....@@ -5674,16 +6156,27 @@
56746156 tex = GetTextures();
56756157 }
56766158
5677
- boolean failed = false;
6159
+ boolean failedPigment = false;
6160
+ boolean failedBump = false;
56786161
56796162 try
56806163 {
5681
- display.BindTextures(tex, texres);
6164
+ display.BindPigmentTexture(tex, texres);
56826165 }
56836166 catch (Exception e)
56846167 {
56856168 System.err.println("FAILED: " + this);
5686
- 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;
56876180 }
56886181
56896182 if (!compiled)
....@@ -5706,8 +6199,11 @@
57066199 }
57076200 }
57086201
5709
- if (!failed)
5710
- display.ReleaseTextures(tex);
6202
+ if (!failedBump)
6203
+ display.ReleaseBumpTexture(tex);
6204
+
6205
+ if (!failedPigment)
6206
+ display.ReleasePigmentTexture(tex);
57116207
57126208 display.PopMaterial(this, selected);
57136209 }
....@@ -6080,6 +6576,11 @@
60806576 // dec 2012
60816577 new Exception().printStackTrace();
60826578 return;
6579
+ }
6580
+
6581
+ if (dontselect)
6582
+ {
6583
+ //bRep.GenerateNormalsMINE();
60836584 }
60846585
60856586 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -6865,20 +7366,23 @@
68657366 }
68667367 }
68677368
6868
- 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)
68697373 {
6870
- int hc = info.bounds.x + info.bounds.width / 2;
6871
- int vc = info.bounds.y + info.bounds.height / 2;
6872
- 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;
68737377 if (toscreen == null)
68747378 {
6875
- toscreen = new Camera(info.camera.viewCode).toScreen;
7379
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
68767380 }
68777381 cVector vec = in;
68787382 LA.xformPos(in, toscreen, in);
68797383 //System.out.println("Distance = " + info.camera.Distance());
6880
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
6881
- 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();
68827386 outPt.x = hc + (int) vec.x;
68837387 outPt.y = vc - (int) vec.y;
68847388 outRec.x = outPt.x - 3;
....@@ -6886,15 +7390,18 @@
68867390 outRec.width = outRec.height = 6;
68877391 }
68887392
6889
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7393
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7394
+ )
68907395 {
68917396 Point pt = new Point(0, 0);
68927397 Rectangle rec = new Rectangle();
6893
- calcHotSpot(in, info, pt, rec);
7398
+ calcHotSpot(in, //clickInfo,
7399
+ pt, rec);
68947400 return rec;
68957401 }
68967402
6897
- void drawEditHandles0(ClickInfo info, int level)
7403
+ void drawEditHandles0(//ClickInfo clickInfo,
7404
+ int level)
68987405 {
68997406 if (level == 0)
69007407 {
....@@ -6903,16 +7410,19 @@
69037410 {
69047411 cVector origin = new cVector();
69057412 //LA.xformPos(origin, toParent, origin);
6906
- Rectangle spot = calcHotSpot(origin, info);
7413
+ if (this.clickInfo == null)
7414
+ this.clickInfo = new ClickInfo();
7415
+
7416
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
69077417 Rectangle boundary = new Rectangle();
69087418 boundary.x = spot.x - 30;
69097419 boundary.y = spot.y - 30;
69107420 boundary.width = spot.width + 60;
69117421 boundary.height = spot.height + 60;
6912
- info.g.setColor(Color.red);
7422
+ clickInfo.g.setColor(Color.white);
69137423 int spotw = spot.x + spot.width;
69147424 int spoth = spot.y + spot.height;
6915
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7425
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
69167426 // if (CameraPane.Xmin > spot.x)
69177427 // {
69187428 // CameraPane.Xmin = spot.x;
....@@ -6929,11 +7439,33 @@
69297439 // {
69307440 // CameraPane.Ymax = spoth;
69317441 // }
6932
- 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);
69337465 spotw = spot.x + spot.width;
69347466 spoth = spot.y + spot.height;
6935
- info.g.setColor(Color.blue);
6936
- 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);
69377469 // if (CameraPane.Xmin > spot.x)
69387470 // {
69397471 // CameraPane.Xmin = spot.x;
....@@ -6950,29 +7482,9 @@
69507482 // {
69517483 // CameraPane.Ymax = spoth;
69527484 // }
6953
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
6954
- info.g.drawLine(spotw, spoth, spotw - 15, spoth);
6955
- spot.translate(0, -32);
6956
- info.g.setColor(Color.green);
6957
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
6958
-// if (CameraPane.Xmin > spot.x)
6959
-// {
6960
-// CameraPane.Xmin = spot.x;
6961
-// }
6962
-// if (CameraPane.Xmax < spotw)
6963
-// {
6964
-// CameraPane.Xmax = spotw;
6965
-// }
6966
-// if (CameraPane.Ymin > spot.y)
6967
-// {
6968
-// CameraPane.Ymin = spot.y;
6969
-// }
6970
-// if (CameraPane.Ymax < spoth)
6971
-// {
6972
-// CameraPane.Ymax = spoth;
6973
-// }
6974
- info.g.drawArc(boundary.x, boundary.y,
6975
- 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);
69767488 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
69777489 // if (CameraPane.Xmin > boundary.x)
69787490 // {
....@@ -6994,7 +7506,8 @@
69947506 }
69957507 }
69967508
6997
- boolean doEditClick0(ClickInfo info, int level)
7509
+ boolean doEditClick0(//ClickInfo clickInfo,
7510
+ int level)
69987511 {
69997512 if (level == 0)
70007513 {
....@@ -7003,10 +7516,10 @@
70037516
70047517 boolean retval = false;
70057518
7006
- startX = info.x;
7007
- startY = info.y;
7519
+ startX = clickInfo.x;
7520
+ startY = clickInfo.y;
70087521
7009
- hitSomething = 0;
7522
+ hitSomething = -1;
70107523 cVector origin = new cVector();
70117524 //LA.xformPos(origin, toParent, origin);
70127525 Rectangle spot = new Rectangle();
....@@ -7014,22 +7527,53 @@
70147527 {
70157528 centerPt = new Point(0, 0);
70167529 }
7017
- calcHotSpot(origin, info, centerPt, spot);
7018
- if (spot.contains(info.x, info.y))
7530
+ calcHotSpot(origin, //info,
7531
+ centerPt, spot);
7532
+ if (spot.contains(clickInfo.x, clickInfo.y))
70197533 {
70207534 hitSomething = hitCenter;
70217535 retval = true;
70227536 }
70237537 spot.translate(32, 0);
7024
- if (spot.contains(info.x, info.y))
7538
+ if (spot.contains(clickInfo.x, clickInfo.y))
70257539 {
70267540 hitSomething = hitRotate;
70277541 retval = true;
70287542 }
70297543 spot.translate(0, 32);
7030
- 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))
70317547 {
70327548 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
+
70337577 retval = true;
70347578 }
70357579
....@@ -7039,7 +7583,7 @@
70397583 }
70407584
70417585 //System.out.println("info.modifiers = " + info.modifiers);
7042
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7586
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
70437587 //System.out.println("modified = " + modified);
70447588 //new Exception().printStackTrace();
70457589 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7067,7 +7611,8 @@
70677611 return true;
70687612 }
70697613
7070
- void doEditDrag0(ClickInfo info, boolean opposite)
7614
+ void doEditDrag0(//ClickInfo info,
7615
+ boolean opposite)
70717616 {
70727617 if (hitSomething == 0)
70737618 {
....@@ -7081,7 +7626,8 @@
70817626
70827627 //System.out.println("hitSomething = " + hitSomething);
70837628
7084
- double scale = 0.005f * info.camera.Distance();
7629
+ double scale = 0.005f * clickInfo.camera.Distance();
7630
+
70857631 cVector xlate = new cVector();
70867632 //cVector xlate2 = new cVector();
70877633 switch (hitSomething)
....@@ -7114,8 +7660,8 @@
71147660 toParent[3][i] = xlate.get(i);
71157661 LA.matInvert(toParent, fromParent);
71167662 */
7117
- cVector delta = LA.newVector(0, 0, startY - info.y);
7118
- 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);
71197665
71207666 LA.matCopy(startMat, toParent);
71217667 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7124,7 +7670,7 @@
71247670 } else
71257671 {
71267672 //LA.xformDir(delta, info.camera.fromScreen, delta);
7127
- cVector up = new cVector(info.camera.up);
7673
+ cVector up = new cVector(clickInfo.camera.up);
71287674 cVector away = new cVector();
71297675 //cVector right2 = new cVector();
71307676 //LA.vecCross(up, cVector.Z, right);
....@@ -7141,19 +7687,19 @@
71417687 LA.xformDir(up, ClickInfo.matbuffer, up);
71427688 // if (!CameraPane.LOCALTRANSFORM)
71437689 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7144
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7690
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
71457691 // if (!CameraPane.LOCALTRANSFORM)
71467692 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
71477693 //LA.vecCross(up, cVector.Z, right2);
71487694
7149
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7695
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
71507696
71517697 //System.out.println("DELTA0 = " + delta);
71527698 //System.out.println("AWAY = " + info.camera.away);
71537699 //System.out.println("UP = " + info.camera.up);
71547700 if (away.z > 0)
71557701 {
7156
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7702
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
71577703 {
71587704 delta.x = -delta.x;
71597705 } else
....@@ -7168,7 +7714,7 @@
71687714 //System.out.println("DELTA1 = " + delta);
71697715 LA.xformDir(delta, ClickInfo.matbuffer, delta);
71707716 //System.out.println("DELTA2 = " + delta);
7171
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7717
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
71727718 LA.matCopy(startMat, toParent);
71737719 //System.out.println("DELTA3 = " + delta);
71747720 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7178,8 +7724,8 @@
71787724 break;
71797725
71807726 case hitRotate: // rotate
7181
- int dx = info.x - centerPt.x;
7182
- int dy = -(info.y - centerPt.y);
7727
+ int dx = clickInfo.x - centerPt.x;
7728
+ int dy = -(clickInfo.y - centerPt.y);
71837729 double angle = (double) Math.atan2(dx, dy);
71847730 angle = -(1.570796 - angle);
71857731
....@@ -7202,7 +7748,7 @@
72027748 }
72037749 /**/
72047750
7205
- switch (info.pane.RenderCamera().viewCode)
7751
+ switch (clickInfo.pane.RenderCamera().viewCode)
72067752 {
72077753 case 1: // '\001'
72087754 LA.matZRotate(toParent, angle);
....@@ -7229,26 +7775,30 @@
72297775 break;
72307776
72317777 case hitScale: // scale
7232
- double hScale = (double) (info.x - centerPt.x) / 32;
7778
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
7779
+ double sign = 1;
7780
+ if (hScale < 0)
7781
+ {
7782
+ sign = -1;
7783
+ }
7784
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
72337785 if (hScale < 0.01)
72347786 {
7235
- hScale = 0.01;
7787
+ //hScale = 0.01;
72367788 }
7237
- hScale = Math.pow(hScale, scale * 50);
7238
- if (hScale < 0.01)
7789
+
7790
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
7791
+ sign = 1;
7792
+ if (vScale < 0)
72397793 {
7240
- hScale = 0.01;
7794
+ sign = -1;
72417795 }
7242
- double vScale = (double) (info.y - centerPt.y) / 32;
7796
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
72437797 if (vScale < 0.01)
72447798 {
7245
- vScale = 0.01;
7799
+ //vScale = 0.01;
72467800 }
7247
- vScale = Math.pow(vScale, scale * 50);
7248
- if (vScale < 0.01)
7249
- {
7250
- vScale = 0.01;
7251
- }
7801
+
72527802 LA.matCopy(startMat, toParent);
72537803 /**/
72547804 for (int i = 0; i < 3; i++)
....@@ -7258,39 +7808,56 @@
72587808 }
72597809 /**/
72607810
7261
- switch (info.pane.RenderCamera().viewCode)
7811
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
7812
+
7813
+ if (totalScale < 0.01)
7814
+ {
7815
+ totalScale = 0.01;
7816
+ }
7817
+
7818
+ switch (clickInfo.pane.RenderCamera().viewCode)
72627819 {
72637820 case 3: // '\001'
7264
- if (modified)
7821
+ if (modified || opposite)
72657822 {
7823
+ if (modified && opposite)
7824
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7825
+ else
72667826 //LA.matScale(toParent, 1, hScale, vScale);
7267
- LA.matScale(toParent, vScale, 1, 1);
7827
+ LA.matScale(toParent, totalScale, 1, 1);
72687828 } // vScale, 1);
72697829 else
72707830 {
7271
- LA.matScale(toParent, vScale, vScale, vScale);
7831
+ // EXCEPTION!
7832
+ LA.matScale(toParent, 1, totalScale, totalScale);
72727833 } // vScale, 1);
72737834 break;
72747835
72757836 case 2: // '\002'
7276
- if (modified)
7837
+ if (modified || opposite)
72777838 {
7278
- //LA.matScale(toParent, hScale, 1, vScale);
7279
- LA.matScale(toParent, 1, vScale, 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);
72807844 } else
72817845 {
7282
- LA.matScale(toParent, vScale, 1, vScale);
7846
+ LA.matScale(toParent, totalScale, 1, totalScale);
72837847 }
72847848 break;
72857849
72867850 case 1: // '\003'
7287
- if (modified)
7851
+ if (modified || opposite)
72887852 {
7289
- //LA.matScale(toParent, hScale, vScale, 1);
7290
- LA.matScale(toParent, 1, 1, vScale);
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);
72917858 } else
72927859 {
7293
- LA.matScale(toParent, vScale, vScale, 1);
7860
+ LA.matScale(toParent, totalScale, totalScale, 1);
72947861 }
72957862 break;
72967863 }
....@@ -7324,7 +7891,7 @@
73247891 } // NEW ...
73257892
73267893
7327
- info.pane.repaint();
7894
+ clickInfo.pane.repaint();
73287895 }
73297896
73307897 boolean overflow = false;
....@@ -7431,7 +7998,7 @@
74317998 objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
74327999 } else
74338000 {
7434
- objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
8001
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
74358002 } // + super.toString();
74368003 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
74378004
....@@ -7504,6 +8071,10 @@
75048071 editWindow = null;
75058072 } // ?
75068073 }
8074
+ else
8075
+ {
8076
+ //editWindow.closeUI();
8077
+ }
75078078 }
75088079
75098080 boolean root; // patch for edit windows
....@@ -7515,7 +8086,7 @@
75158086 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
75168087
75178088 Object3D /*Composite*/ parent;
7518
- Object3D /*Composite*/ fileparent;
8089
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
75198090
75208091 double[][] toParent; // dynamic matrix
75218092 double[][] fromParent;
....@@ -7661,6 +8232,10 @@
76618232 }
76628233
76638234 transient ObjEditor editWindow;
8235
+ transient ObjEditor manipWindow;
8236
+
8237
+ transient boolean pinned;
8238
+
76648239 transient ObjectUI objectUI;
76658240 public static int povDepth = 0;
76668241 private static cVector tbMin = new cVector();
....@@ -7679,9 +8254,9 @@
76798254 private static cVector edge2 = new cVector();
76808255 //private static cVector norm = new cVector();
76818256 /*transient private*/ int hitSomething;
7682
- private static final int hitCenter = 1;
7683
- private static final int hitScale = 2;
7684
- private static final int hitRotate = 3;
8257
+ static final int hitCenter = 1;
8258
+ static final int hitScale = 2;
8259
+ static final int hitRotate = 3;
76858260 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
76868261 /*transient*/ private Point centerPt;
76878262 /*transient*/ private int startX;