Normand Briere
2019-07-25 f2b6a33fdf84a06b958f9cb9d667a2eff3063d8b
Object3D.java
....@@ -14,12 +14,24 @@
1414 import //weka.core.
1515 matrix.Matrix;
1616
17
+import java.util.UUID;
18
+
1719 //import net.sourceforge.sizeof.SizeOf;
1820 public class Object3D extends Vector<Object3D> implements java.io.Serializable, iSendInfo //, aurelienribon.tweenengine.TweenAccessor<Object3D>
1921 {
2022 //static final long serialVersionUID = -607422624994562685L;
2123 static final long serialVersionUID = 5022536242724664900L;
2224
25
+ private UUID uuid = UUID.randomUUID();
26
+
27
+ // TEMPORARY for mocap undo. No need to be transient.
28
+ mocap.reader.BVHReader.BVHResult savebvh;
29
+ Object3D saveskeleton;
30
+ //
31
+
32
+ byte[] versions[];
33
+ int versionindex = -1;
34
+
2335 ScriptNode scriptnode;
2436
2537 void InitOthers()
....@@ -100,64 +112,178 @@
100112
101113 // transient boolean reduced; // for morph reduction
102114
103
-transient com.bulletphysics.linearmath.Transform cache; // for fast merge
104
-transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
115
+ transient com.bulletphysics.linearmath.Transform cache; // for fast merge
116
+ transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
105117
106
-transient Object3D transientsupport; // for cloning
107
-transient boolean transientlink2master;
118
+ transient Object3D transientsupport; // for cloning
119
+ transient boolean transientlink2master;
108120
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)
121
+ void SaveSupports()
121122 {
122
- bRep.SaveSupports();
123
+ if (blockloop)
124
+ return;
125
+
126
+ transientsupport = support;
127
+ transientlink2master = link2master;
128
+
129
+ support = null;
130
+ link2master = false;
131
+
132
+ if (bRep != null)
133
+ {
134
+ bRep.SaveSupports();
135
+ }
136
+
137
+ for (int i = 0; i < Size(); i++)
138
+ {
139
+ Object3D child = (Object3D) get(i);
140
+ if (child == null)
141
+ continue;
142
+ blockloop = true;
143
+ child.SaveSupports();
144
+ blockloop = false;
145
+ }
123146 }
124
-
125
- for (int i = 0; i < Size(); i++)
147
+
148
+ void RestoreSupports()
126149 {
127
- Object3D child = (Object3D) get(i);
128
- if (child == null)
129
- continue;
150
+ if (blockloop)
151
+ return;
152
+
153
+ support = transientsupport;
154
+ link2master = transientlink2master;
155
+ transientsupport = null;
156
+ transientlink2master = false;
157
+
158
+ if (bRep != null)
159
+ {
160
+ bRep.RestoreSupports();
161
+ }
162
+
163
+ for (int i = 0; i < Size(); i++)
164
+ {
165
+ Object3D child = (Object3D) get(i);
166
+ if (child == null)
167
+ continue;
168
+ blockloop = true;
169
+ child.RestoreSupports();
170
+ blockloop = false;
171
+ }
172
+ }
173
+
174
+ void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
175
+ {
176
+ Object3D o;
177
+
178
+ if (hashtable.containsKey(GetUUID()))
179
+ {
180
+ o = hashtable.get(GetUUID());
181
+
182
+ Grafreed.Assert(this.bRep == o.bRep);
183
+ //if (this.bRep != null)
184
+ // assert(this.bRep.support == o.transientrep);
185
+ if (this.support != null)
186
+ assert(this.support.bRep == o.transientrep);
187
+ }
188
+ else
189
+ {
190
+ o = new Object3D("copy of " + this.name);
191
+
192
+ hashtable.put(GetUUID(), o);
193
+ }
194
+
195
+ if (!blockloop)
196
+ {
197
+ blockloop = true;
198
+
199
+ for (int i=0; i<Size(); i++)
200
+ {
201
+ get(i).ExtractBigData(hashtable);
202
+ }
203
+
204
+ blockloop = false;
205
+ }
206
+
207
+ ExtractBigData(o);
208
+ }
209
+
210
+ void ExtractBigData(Object3D o)
211
+ {
212
+ if (o.bRep != null)
213
+ Grafreed.Assert(o.bRep == this.bRep);
214
+
215
+ o.bRep = this.bRep;
216
+// July 2019 if (this.bRep != null)
217
+// {
218
+// o.transientrep = this.bRep.support;
219
+// o.bRep.support = null;
220
+// }
221
+ o.selection = this.selection;
222
+ o.versions = this.versions;
223
+ o.versionindex = this.versionindex;
224
+
225
+ if (this.support != null)
226
+ {
227
+ if (o.transientrep != null)
228
+ Grafreed.Assert(o.transientrep == this.support.bRep);
229
+
230
+ o.transientrep = this.support.bRep;
231
+ this.support.bRep = null;
232
+ }
233
+
234
+ // o.support = this.support;
235
+ // o.fileparent = this.fileparent;
236
+ // if (this.bRep != null)
237
+ // o.bRep = this.bRep.support;
238
+
239
+ this.bRep = null;
240
+ // if (this.bRep != null)
241
+ // this.bRep.support = null;
242
+ // this.support = null;
243
+ // this.fileparent = null;
244
+ }
245
+
246
+ void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
247
+ {
248
+ if (!hashtable.containsKey(GetUUID()))
249
+ return;
250
+
251
+ Object3D o = hashtable.get(GetUUID());
252
+
253
+ RestoreBigData(o);
254
+
255
+ if (blockloop)
256
+ return;
257
+
130258 blockloop = true;
131
- child.SaveSupports();
259
+
260
+ //hashtable.remove(GetUUID());
261
+
262
+ for (int i=0; i<Size(); i++)
263
+ {
264
+ get(i).RestoreBigData(hashtable);
265
+ }
266
+
132267 blockloop = false;
133268 }
134
-}
135269
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)
270
+ void RestoreBigData(Object3D o)
147271 {
148
- bRep.RestoreSupports();
272
+ this.bRep = o.bRep;
273
+ if (this.support != null && o.transientrep != null)
274
+ {
275
+ this.support.bRep = o.transientrep;
276
+ }
277
+
278
+ this.selection = o.selection;
279
+
280
+ this.versions = o.versions;
281
+ this.versionindex = o.versionindex;
282
+// July 2019 if (this.bRep != null)
283
+// this.bRep.support = o.transientrep;
284
+ // this.support = o.support;
285
+ // this.fileparent = o.fileparent;
149286 }
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
-}
161287
162288 // MOCAP SUPPORT
163289 double tx,ty,tz,rx,ry,rz;
....@@ -300,6 +426,8 @@
300426 }
301427
302428 boolean live = false;
429
+ transient boolean keepdontselect;
430
+ boolean dontselect = false;
303431 boolean hide = false;
304432 boolean link2master = false; // performs reset support/master at each frame
305433 boolean marked = false; // animation node
....@@ -481,12 +609,14 @@
481609 toParent = LA.newMatrix();
482610 fromParent = LA.newMatrix();
483611 }
612
+
484613 if (toParentMarked == null)
485614 {
486615 if (maxcount != 1)
487616 {
488617 new Exception().printStackTrace();
489618 }
619
+
490620 toParentMarked = LA.newMatrix();
491621 fromParentMarked = LA.newMatrix();
492622 }
....@@ -774,7 +904,7 @@
774904 if (step == 0)
775905 step = 1;
776906 if (maxcount == 0)
777
- maxcount = 2048; // 4;
907
+ maxcount = 128; // 2048; // 4;
778908 // if (acceleration == 0)
779909 // acceleration = 10;
780910 if (delay == 0) // serial
....@@ -797,7 +927,7 @@
797927
798928 if (marked && Globals.isLIVE() && live &&
799929 //TEMP21aug2018
800
- Globals.DrawMode() == iCameraPane.SHADOW &&
930
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
801931 currentframe != Globals.framecount)
802932 {
803933 currentframe = Globals.framecount;
....@@ -809,7 +939,8 @@
809939
810940 boolean changedir = random && Math.random() < 0.01; // && !link2master;
811941
812
- if (transformcount*factor > maxcount || (step == 1 && changedir))
942
+ if (transformcount*factor >= maxcount && (rewind || random) ||
943
+ (step == 1 && changedir))
813944 {
814945 countdown = 1;
815946 delay = speedup?8:1;
....@@ -881,6 +1012,7 @@
8811012 if (material == null || material.multiply)
8821013 return true;
8831014
1015
+ // Transparent objects are dynamic because we have to sort the triangles.
8841016 return material.opacity > 0.99;
8851017 }
8861018
....@@ -912,6 +1044,11 @@
9121044 fromParent = null; // LA.newMatrix();
9131045 bRep = null; // new BoundaryRep();
9141046
1047
+ if (oname != null && oname.equals("LeftHand"))
1048
+ {
1049
+ name = oname;
1050
+ }
1051
+
9151052 /*
9161053 float hue = (float)Math.random();
9171054 Color col;
....@@ -954,7 +1091,7 @@
9541091
9551092 public Object clone()
9561093 {
957
- return GrafreeD.clone(this);
1094
+ return Grafreed.clone(this);
9581095 }
9591096
9601097 Object3D copyExpand()
....@@ -1276,6 +1413,7 @@
12761413 toParent = LA.newMatrix();
12771414 fromParent = LA.newMatrix();
12781415 }
1416
+
12791417 LA.matCopy(other.toParent, toParent);
12801418 LA.matCopy(other.fromParent, fromParent);
12811419
....@@ -1470,7 +1608,7 @@
14701608 BoundaryRep.SEUIL = other.material.cameralight;
14711609
14721610 // Set default to 0.1
1473
- BoundaryRep.SEUIL /= 2;
1611
+ BoundaryRep.SEUIL /= 4; // 2;
14741612 System.out.println("SEUIL = " + BoundaryRep.SEUIL);
14751613 }
14761614
....@@ -1729,7 +1867,7 @@
17291867 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17301868 o.bRep = transientrep;
17311869 if (clone)
1732
- o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
1870
+ o.bRep = (BoundaryRep) Grafreed.clone(transientrep);
17331871 o.CreateMaterial();
17341872 o.SetAttributes(this, -1);
17351873 //parent
....@@ -1742,7 +1880,7 @@
17421880 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17431881 o.bRep = bRep;
17441882 if (clone)
1745
- o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
1883
+ o.bRep = (BoundaryRep) Grafreed.clone(bRep);
17461884 o.CreateMaterial();
17471885 //o.overwriteThis(this, -1);
17481886 o.SetAttributes(this, -1);
....@@ -1829,12 +1967,15 @@
18291967 if (obj.name == null)
18301968 continue; // can't be a null one
18311969
1970
+ // Try perfect match first.
18321971 if (n.equals(obj.name))
18331972 {
18341973 theobj = obj;
18351974 count++;
18361975 }
18371976 }
1977
+
1978
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18381979
18391980 if (count != 1)
18401981 for (int i=Size(); --i>=0;)
....@@ -2294,6 +2435,10 @@
22942435 }
22952436 */
22962437 }
2438
+ else
2439
+ {
2440
+ //((ObjEditor)editWindow).SetupUI2(null);
2441
+ }
22972442 }
22982443
22992444 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
....@@ -2335,6 +2480,14 @@
23352480 {
23362481 editWindow.refreshContents();
23372482 }
2483
+ else
2484
+ {
2485
+ if (manipWindow != null)
2486
+ {
2487
+ manipWindow.refreshContents();
2488
+ }
2489
+ }
2490
+
23382491 //if (parent != null)
23392492 //parent.refreshEditWindow();
23402493 }
....@@ -2414,7 +2567,8 @@
24142567 private static final int editSelf = 1;
24152568 private static final int editChild = 2;
24162569
2417
- void drawEditHandles(ClickInfo info, int level)
2570
+ void drawEditHandles(//ClickInfo info,
2571
+ int level)
24182572 {
24192573 if (level == 0)
24202574 {
....@@ -2422,7 +2576,8 @@
24222576 return;
24232577
24242578 Object3D selectee;
2425
- for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(info, level + 1))
2579
+ for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(//info,
2580
+ level + 1))
24262581 {
24272582 selectee = (Object3D) e.nextElement();
24282583 }
....@@ -2430,19 +2585,22 @@
24302585 } else
24312586 {
24322587 //super.
2433
- drawEditHandles0(info, level + 1);
2588
+ drawEditHandles0(//info,
2589
+ level + 1);
24342590 }
24352591 }
24362592
2437
- boolean doEditClick(ClickInfo info, int level)
2593
+ boolean doEditClick(//ClickInfo info,
2594
+ int level)
24382595 {
24392596 doSomething = 0;
24402597 if (level == 0)
24412598 {
2442
- return doParentClick(info);
2599
+ return doParentClick(); //info);
24432600 }
24442601 if (//super.
2445
- doEditClick0(info, level))
2602
+ doEditClick0(//info,
2603
+ level))
24462604 {
24472605 doSomething = 1;
24482606 return true;
....@@ -2452,7 +2610,7 @@
24522610 }
24532611 }
24542612
2455
- boolean doParentClick(ClickInfo info)
2613
+ boolean doParentClick() //ClickInfo info)
24562614 {
24572615 if (selection == null)
24582616 {
....@@ -2465,7 +2623,8 @@
24652623 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
24662624 {
24672625 Object3D selectee = (Object3D) e.nextElement();
2468
- if (selectee.doEditClick(info, 1))
2626
+ if (selectee.doEditClick(//info,
2627
+ 1))
24692628 {
24702629 childToDrag = selectee;
24712630 doSomething = 2;
....@@ -2477,13 +2636,15 @@
24772636 return retval;
24782637 }
24792638
2480
- void doEditDrag(ClickInfo info)
2639
+ void doEditDrag(//ClickInfo clickInfo,
2640
+ boolean opposite)
24812641 {
24822642 switch (doSomething)
24832643 {
24842644 case 1: // '\001'
24852645 //super.
2486
- doEditDrag0(info);
2646
+ doEditDrag0(//clickInfo,
2647
+ opposite);
24872648 break;
24882649
24892650 case 2: // '\002'
....@@ -2496,11 +2657,13 @@
24962657 {
24972658 //sel.hitSomething = childToDrag.hitSomething;
24982659 //childToDrag.doEditDrag(info);
2499
- sel.doEditDrag(info);
2660
+ sel.doEditDrag(//clickInfo,
2661
+ opposite);
25002662 } else
25012663 {
25022664 //super.
2503
- doEditDrag0(info);
2665
+ doEditDrag0(//clickInfo,
2666
+ opposite);
25042667 }
25052668 }
25062669 break;
....@@ -2518,6 +2681,9 @@
25182681 {
25192682 deselectAll();
25202683 }
2684
+
2685
+ new Exception().printStackTrace();
2686
+
25212687 ClickInfo newInfo = new ClickInfo();
25222688 newInfo.flags = info.flags;
25232689 newInfo.bounds = info.bounds;
....@@ -2610,6 +2776,18 @@
26102776 void GenNormalsS(boolean crease)
26112777 {
26122778 selection.GenNormals(crease);
2779
+// for (int i=0; i<selection.size(); i++)
2780
+// {
2781
+// Object3D selectee = (Object3D) selection.elementAt(i);
2782
+// selectee.GenNormals(crease);
2783
+// }
2784
+
2785
+ //Touch();
2786
+ }
2787
+
2788
+ void GenNormalsMeshS()
2789
+ {
2790
+ selection.GenNormalsMesh();
26132791 // for (int i=0; i<selection.size(); i++)
26142792 // {
26152793 // Object3D selectee = (Object3D) selection.elementAt(i);
....@@ -2750,6 +2928,24 @@
27502928 if (child == null)
27512929 continue;
27522930 child.GenNormals(crease);
2931
+// Children().release(i);
2932
+ }
2933
+ blockloop = false;
2934
+ }
2935
+
2936
+ void GenNormalsMesh()
2937
+ {
2938
+ if (blockloop)
2939
+ return;
2940
+
2941
+ blockloop = true;
2942
+ GenNormalsMesh0();
2943
+ for (int i = 0; i < Children().Size(); i++)
2944
+ {
2945
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2946
+ if (child == null)
2947
+ continue;
2948
+ child.GenNormalsMesh();
27532949 // Children().release(i);
27542950 }
27552951 blockloop = false;
....@@ -2922,11 +3118,20 @@
29223118 }
29233119 }
29243120
3121
+ void GenNormalsMesh0()
3122
+ {
3123
+ if (bRep != null)
3124
+ {
3125
+ bRep.GenerateNormalsMesh();
3126
+ Touch();
3127
+ }
3128
+ }
3129
+
29253130 void GenNormalsMINE0()
29263131 {
29273132 if (bRep != null)
29283133 {
2929
- bRep.GenerateNormalsMINE();
3134
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
29303135 Touch();
29313136 }
29323137 }
....@@ -2983,6 +3188,33 @@
29833188 blockloop = false;
29843189 }
29853190
3191
+ void TransformChildren()
3192
+ {
3193
+ if (toParent != null)
3194
+ {
3195
+ for (int i=Size(); --i>=0;)
3196
+ {
3197
+ Object3D v = get(i);
3198
+
3199
+ if (v.toParent == null)
3200
+ {
3201
+ v.toParent = LA.newMatrix();
3202
+ v.fromParent = LA.newMatrix();
3203
+ }
3204
+
3205
+// LA.matConcat(v.toParent, toParent, v.toParent);
3206
+// LA.matConcat(fromParent, v.fromParent, v.fromParent);
3207
+ LA.matConcat(toParent, v.toParent, v.toParent);
3208
+ LA.matConcat(v.fromParent, fromParent, v.fromParent);
3209
+ }
3210
+
3211
+ toParent = null; // LA.matIdentity(toParent);
3212
+ fromParent = null; // LA.matIdentity(fromParent);
3213
+
3214
+ Touch();
3215
+ }
3216
+ }
3217
+
29863218 void TransformGeometry()
29873219 {
29883220 Object3D obj = this;
....@@ -3204,9 +3436,11 @@
32043436
32053437 BoundaryRep sup = bRep.support;
32063438 bRep.support = null;
3207
- BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
3439
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
32083440 // bRep.SplitInTwo(onlyone); // thread...
3209
- temprep.SplitInTwo(reduction34, onlyone);
3441
+
3442
+ while(temprep.SplitInTwo(reduction34, onlyone));
3443
+
32103444 bRep = temprep;
32113445 bRep.support = sup;
32123446 Touch();
....@@ -3343,7 +3577,8 @@
33433577 if (blockloop)
33443578 return;
33453579
3346
- if (marked || (bRep != null && material != null)) // borderline...
3580
+ if (//marked || // does not make sense
3581
+ (bRep != null || material != null)) // borderline...
33473582 live = h;
33483583
33493584 for (int i = 0; i < Size(); i++)
....@@ -3364,7 +3599,8 @@
33643599 return;
33653600
33663601 //if (bRep != null)
3367
- if (marked || (bRep != null && material != null)) // borderline...
3602
+ if (//marked || // does not make sense
3603
+ (bRep != null || material != null)) // borderline...
33683604 link2master = h;
33693605
33703606 for (int i = 0; i < Size(); i++)
....@@ -3384,7 +3620,8 @@
33843620 if (blockloop)
33853621 return;
33863622
3387
- if (marked || (bRep != null && material != null)) // borderline...
3623
+ if (//marked || // does not make sense
3624
+ (bRep != null || material != null)) // borderline...
33883625 hide = h;
33893626
33903627 for (int i = 0; i < Size(); i++)
....@@ -3404,7 +3641,7 @@
34043641 if (blockloop)
34053642 return;
34063643
3407
- if (bRep != null && material != null) // borderline...
3644
+ if (bRep != null || material != null) // borderline...
34083645 marked = h;
34093646
34103647 for (int i = 0; i < Size(); i++)
....@@ -3414,6 +3651,46 @@
34143651 continue;
34153652 blockloop = true;
34163653 child.MarkLeaves(h);
3654
+ blockloop = false;
3655
+ // release(i);
3656
+ }
3657
+ }
3658
+
3659
+ void RewindLeaves(boolean h)
3660
+ {
3661
+ if (blockloop)
3662
+ return;
3663
+
3664
+ if (bRep != null || material != null) // borderline...
3665
+ rewind = h;
3666
+
3667
+ for (int i = 0; i < Size(); i++)
3668
+ {
3669
+ Object3D child = (Object3D) get(i); // reserve(i);
3670
+ if (child == null)
3671
+ continue;
3672
+ blockloop = true;
3673
+ child.RewindLeaves(h);
3674
+ blockloop = false;
3675
+ // release(i);
3676
+ }
3677
+ }
3678
+
3679
+ void RandomLeaves(boolean h)
3680
+ {
3681
+ if (blockloop)
3682
+ return;
3683
+
3684
+ if (bRep != null || material != null) // borderline...
3685
+ random = h;
3686
+
3687
+ for (int i = 0; i < Size(); i++)
3688
+ {
3689
+ Object3D child = (Object3D) get(i); // reserve(i);
3690
+ if (child == null)
3691
+ continue;
3692
+ blockloop = true;
3693
+ child.RandomLeaves(h);
34173694 blockloop = false;
34183695 // release(i);
34193696 }
....@@ -3728,7 +4005,7 @@
37284005 if (child == null)
37294006 continue;
37304007
3731
- if (GrafreeD.RENDERME > 0)
4008
+ if (Grafreed.RENDERME > 0)
37324009 {
37334010 if (child instanceof Merge)
37344011 ((Merge)child).renderme();
....@@ -3879,7 +4156,7 @@
38794156 if (child == null)
38804157 continue;
38814158
3882
- if (GrafreeD.RENDERME > 0)
4159
+ if (Grafreed.RENDERME > 0)
38834160 {
38844161 if (child instanceof Merge)
38854162 ((Merge)child).renderme();
....@@ -4074,7 +4351,7 @@
40744351 if (child == null)
40754352 continue;
40764353
4077
- if (GrafreeD.RENDERME > 0)
4354
+ if (Grafreed.RENDERME > 0)
40784355 {
40794356 if (child instanceof Merge)
40804357 ((Merge)child).renderme();
....@@ -4187,6 +4464,55 @@
41874464 {
41884465 blockloop = true;
41894466 get(i).RepairShadow();
4467
+ blockloop = false;
4468
+ }
4469
+ }
4470
+
4471
+ void RepairSOV()
4472
+ {
4473
+ if (blockloop)
4474
+ return;
4475
+
4476
+ String texname = this.GetPigmentTexture();
4477
+
4478
+ if (texname.startsWith("sov"))
4479
+ {
4480
+ String[] s = texname.split("/");
4481
+
4482
+ String[] sname = s[1].split("Color.pn");
4483
+
4484
+ texname = sname[0];
4485
+
4486
+ if (sname.length > 1)
4487
+ {
4488
+ texname += "Color.jpg";
4489
+ }
4490
+
4491
+ this.SetPigmentTexture("sov/" + texname);
4492
+ }
4493
+
4494
+ texname = this.GetBumpTexture();
4495
+
4496
+ if (texname.startsWith("sov"))
4497
+ {
4498
+ String[] s = texname.split("/");
4499
+
4500
+ String[] sname = s[1].split("Bump.pn");
4501
+
4502
+ texname = sname[0];
4503
+
4504
+ if (sname.length > 1)
4505
+ {
4506
+ texname += "Bump.jpg";
4507
+ }
4508
+
4509
+ this.SetBumpTexture("sov/" + texname);
4510
+ }
4511
+
4512
+ for (int i=0; i<Size(); i++)
4513
+ {
4514
+ blockloop = true;
4515
+ get(i).RepairSOV();
41904516 blockloop = false;
41914517 }
41924518 }
....@@ -4681,7 +5007,7 @@
46815007
46825008 cTreePath SelectLeaf(int indexcount, boolean deselect)
46835009 {
4684
- if (hide)
5010
+ if (hide || dontselect)
46855011 return null;
46865012
46875013 if (count <= 0)
....@@ -4705,9 +5031,17 @@
47055031 }
47065032 }
47075033
5034
+ ObjEditor GetWindow()
5035
+ {
5036
+ if (editWindow != null)
5037
+ return editWindow;
5038
+
5039
+ return manipWindow;
5040
+ }
5041
+
47085042 cTreePath Select(int indexcount, boolean deselect)
47095043 {
4710
- if (hide)
5044
+ if (hide || dontselect)
47115045 return null;
47125046
47135047 if (count <= 0)
....@@ -4741,10 +5075,11 @@
47415075 if (leaf != null)
47425076 {
47435077 cTreePath tp = new cTreePath(this, leaf);
4744
- if (editWindow != null)
5078
+ ObjEditor window = GetWindow();
5079
+ if (window != null)
47455080 {
47465081 //System.out.println("editWindow = " + editWindow + " vs " + this);
4747
- editWindow.Select(tp, deselect, true);
5082
+ window.Select(tp, deselect, true);
47485083 }
47495084
47505085 return tp;
....@@ -4761,6 +5096,7 @@
47615096
47625097 if (child == null)
47635098 continue;
5099
+
47645100 if (child.HasTransparency() && child.size() != 0)
47655101 {
47665102 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4770,9 +5106,10 @@
47705106 if (leaf != null)
47715107 {
47725108 cTreePath tp = new cTreePath(this, leaf);
4773
- if (editWindow != null)
5109
+ ObjEditor window = GetWindow();
5110
+ if (window != null)
47745111 {
4775
- editWindow.Select(tp, deselect, true);
5112
+ window.Select(tp, deselect, true);
47765113 }
47775114
47785115 return tp;
....@@ -5097,6 +5434,51 @@
50975434 blockloop = false;
50985435 }
50995436
5437
+ void ResetSelectable()
5438
+ {
5439
+ if (blockloop)
5440
+ return;
5441
+
5442
+ blockloop = true;
5443
+
5444
+ keepdontselect = dontselect;
5445
+ dontselect = true;
5446
+
5447
+ Object3D child;
5448
+ int nb = Size();
5449
+ for (int i = 0; i < nb; i++)
5450
+ {
5451
+ child = (Object3D) get(i);
5452
+ if (child == null)
5453
+ continue;
5454
+ child.ResetSelectable();
5455
+ }
5456
+
5457
+ blockloop = false;
5458
+ }
5459
+
5460
+ void RestoreSelectable()
5461
+ {
5462
+ if (blockloop)
5463
+ return;
5464
+
5465
+ blockloop = true;
5466
+
5467
+ dontselect = keepdontselect;
5468
+
5469
+ Object3D child;
5470
+ int nb = Size();
5471
+ for (int i = 0; i < nb; i++)
5472
+ {
5473
+ child = (Object3D) get(i);
5474
+ if (child == null)
5475
+ continue;
5476
+ child.RestoreSelectable();
5477
+ }
5478
+
5479
+ blockloop = false;
5480
+ }
5481
+
51005482 boolean IsSelected()
51015483 {
51025484 if (parent == null)
....@@ -5159,10 +5541,34 @@
51595541
51605542 // System.out.println("Fullname = " + fullname);
51615543
5162
- if (fullname.name.indexOf(":") == -1)
5163
- return fullname.name;
5544
+ // Does not work on Windows due to C:
5545
+// if (fullname.name.indexOf(":") == -1)
5546
+// return fullname.name;
5547
+//
5548
+// return fullname.name.substring(0,fullname.name.indexOf(":"));
51645549
5165
- return fullname.name.substring(0,fullname.name.indexOf(":"));
5550
+ String[] split = fullname.name.split(":");
5551
+
5552
+ if (split.length == 0)
5553
+ {
5554
+ return "";
5555
+ }
5556
+
5557
+ if (split.length <= 2)
5558
+ {
5559
+ if (fullname.name.endsWith(":"))
5560
+ {
5561
+ // Windows
5562
+ return fullname.name.substring(0, fullname.name.length()-1);
5563
+ }
5564
+
5565
+ return split[0];
5566
+ }
5567
+
5568
+ // Windows
5569
+ assert(split.length == 4);
5570
+
5571
+ return split[0] + ":" + split[1];
51665572 }
51675573
51685574 static String GetBump(cTexture fullname)
....@@ -5171,10 +5577,38 @@
51715577 return "";
51725578
51735579 // System.out.println("Fullname = " + fullname);
5174
- if (fullname.name.indexOf(":") == -1)
5175
- return "";
5176
-
5177
- return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5580
+ // Does not work on Windows due to C:
5581
+// if (fullname.name.indexOf(":") == -1)
5582
+// return "";
5583
+//
5584
+// return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5585
+ String[] split = fullname.name.split(":");
5586
+
5587
+ if (split.length == 0)
5588
+ {
5589
+ return "";
5590
+ }
5591
+
5592
+ if (split.length == 1)
5593
+ {
5594
+ return "";
5595
+ }
5596
+
5597
+ if (split.length == 2)
5598
+ {
5599
+ if (fullname.name.endsWith(":"))
5600
+ {
5601
+ // Windows
5602
+ return "";
5603
+ }
5604
+
5605
+ return split[1];
5606
+ }
5607
+
5608
+ // Windows
5609
+ assert(split.length == 4);
5610
+
5611
+ return split[2] + ":" + split[3];
51785612 }
51795613
51805614 String GetPigmentTexture()
....@@ -5248,7 +5682,7 @@
52485682 System.out.print("; textures = " + textures);
52495683 System.out.println("; usedtextures = " + usedtextures);
52505684
5251
- if (GetTextures() == null)
5685
+ if (GetTextures() == null) // What is that??
52525686 GetTextures().name = ":";
52535687
52545688 String texname = tex;
....@@ -5279,6 +5713,43 @@
52795713 child.ResetPigmentTexture();
52805714 blockloop = false;
52815715 }
5716
+ }
5717
+
5718
+ UUID GetUUID()
5719
+ {
5720
+ if (uuid == null)
5721
+ {
5722
+ // Serial
5723
+ uuid = UUID.randomUUID();
5724
+ }
5725
+
5726
+ return uuid;
5727
+ }
5728
+
5729
+ Object3D GetObject(UUID uid)
5730
+ {
5731
+ if (blockloop)
5732
+ return null;
5733
+
5734
+ if (GetUUID().equals(uid))
5735
+ return this;
5736
+
5737
+ int nb = Size();
5738
+ for (int i = 0; i < nb; i++)
5739
+ {
5740
+ Object3D child = (Object3D) get(i);
5741
+
5742
+ if (child == null)
5743
+ continue;
5744
+
5745
+ blockloop = true;
5746
+ Object3D obj = child.GetObject(uid);
5747
+ blockloop = false;
5748
+ if (obj != null)
5749
+ return obj;
5750
+ }
5751
+
5752
+ return null;
52825753 }
52835754
52845755 void SetBumpTexture(String tex)
....@@ -5317,6 +5788,38 @@
53175788 }
53185789 }
53195790
5791
+ void EmbedTextures(boolean embed)
5792
+ {
5793
+ if (blockloop)
5794
+ return;
5795
+
5796
+ //if (GetTextures() != null)
5797
+ if (embed)
5798
+ CameraPane.EmbedTextures(GetTextures());
5799
+ else
5800
+ {
5801
+ GetTextures().pigmentdata = null;
5802
+ GetTextures().bumpdata = null;
5803
+ GetTextures().pw = 0;
5804
+ GetTextures().ph = 0;
5805
+ GetTextures().bw = 0;
5806
+ GetTextures().bh = 0;
5807
+ }
5808
+
5809
+ int nb = Size();
5810
+ for (int i = 0; i < nb; i++)
5811
+ {
5812
+ Object3D child = (Object3D) get(i);
5813
+
5814
+ if (child == null)
5815
+ continue;
5816
+
5817
+ blockloop = true;
5818
+ child.EmbedTextures(embed);
5819
+ blockloop = false;
5820
+ }
5821
+ }
5822
+
53205823 void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
53215824 {
53225825 Draw(display, root, selected, blocked);
....@@ -5325,12 +5828,23 @@
53255828 boolean NeedSupport()
53265829 {
53275830 return
5328
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5831
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
53295832 // PROBLEM with CROWD!!
5330
- && (Globals.DrawMode() == iCameraPane.SHADOW || Globals.CROWD);
5833
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
53315834 }
53325835
53335836 static boolean DEBUG_SELECTION = false;
5837
+
5838
+ boolean IsLive()
5839
+ {
5840
+ if (live)
5841
+ return true;
5842
+
5843
+ if (parent == null)
5844
+ return false;
5845
+
5846
+ return parent.IsLive();
5847
+ }
53345848
53355849 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
53365850 {
....@@ -5342,7 +5856,7 @@
53425856 }
53435857
53445858 if (display.DrawMode() == iCameraPane.SELECTION &&
5345
- hide)
5859
+ (hide || dontselect))
53465860 return;
53475861
53485862 if (name != null && name.contains("sclera"))
....@@ -5393,7 +5907,7 @@
53935907 support = support;
53945908
53955909 //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5396
- boolean usecalllists = false; // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5910
+ boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
53975911
53985912 if (!usecalllists && bRep != null && bRep.displaylist > 0)
53995913 {
....@@ -5413,10 +5927,12 @@
54135927 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
54145928
54155929 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5416
- (touched || (bRep != null && bRep.displaylist <= 0)))
5930
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5931
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
54175932 {
54185933 Globals.lighttouched = true;
54195934 } // all panes...
5935
+
54205936 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
54215937 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
54225938 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5544,6 +6060,7 @@
55446060 if (GetBRep() != null)
55456061 {
55466062 display.NextIndex();
6063
+
55476064 // vertex color conflict : gl.glCallList(list);
55486065 DrawNode(display, root, selected);
55496066 if (this instanceof BezierPatch)
....@@ -5584,7 +6101,28 @@
55846101 tex = GetTextures();
55856102 }
55866103
5587
- display.BindTextures(tex, texres);
6104
+ boolean failedPigment = false;
6105
+ boolean failedBump = false;
6106
+
6107
+ try
6108
+ {
6109
+ display.BindPigmentTexture(tex, texres);
6110
+ }
6111
+ catch (Exception e)
6112
+ {
6113
+ System.err.println("FAILED: " + this);
6114
+ failedPigment = true;
6115
+ }
6116
+
6117
+ try
6118
+ {
6119
+ display.BindBumpTexture(tex, texres);
6120
+ }
6121
+ catch (Exception e)
6122
+ {
6123
+ //System.err.println("FAILED: " + this);
6124
+ failedBump = true;
6125
+ }
55886126
55896127 if (!compiled)
55906128 {
....@@ -5606,7 +6144,11 @@
56066144 }
56076145 }
56086146
5609
- display.ReleaseTextures(tex);
6147
+ if (!failedBump)
6148
+ display.ReleaseBumpTexture(tex);
6149
+
6150
+ if (!failedPigment)
6151
+ display.ReleasePigmentTexture(tex);
56106152
56116153 display.PopMaterial(this, selected);
56126154 }
....@@ -5735,6 +6277,9 @@
57356277
57366278 void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57376279 {
6280
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6281
+ return;
6282
+
57386283 if (hide)
57396284 return;
57406285 // shadow optimisation
....@@ -5860,6 +6405,9 @@
58606405 if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
58616406 return; // no shadow for transparent objects
58626407
6408
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6409
+ return;
6410
+
58636411 if (hide)
58646412 return;
58656413
....@@ -5973,6 +6521,11 @@
59736521 // dec 2012
59746522 new Exception().printStackTrace();
59756523 return;
6524
+ }
6525
+
6526
+ if (dontselect)
6527
+ {
6528
+ //bRep.GenerateNormalsMINE();
59766529 }
59776530
59786531 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -6758,20 +7311,23 @@
67587311 }
67597312 }
67607313
6761
- protected void calcHotSpot(cVector in, ClickInfo info, Point outPt, Rectangle outRec)
7314
+ static ClickInfo clickInfo = new ClickInfo();
7315
+
7316
+ protected void calcHotSpot(cVector in, //ClickInfo clickInfo,
7317
+ Point outPt, Rectangle outRec)
67627318 {
6763
- int hc = info.bounds.x + info.bounds.width / 2;
6764
- int vc = info.bounds.y + info.bounds.height / 2;
6765
- double[][] toscreen = info.toScreen;
7319
+ int hc = clickInfo.bounds.x + clickInfo.bounds.width / 2;
7320
+ int vc = clickInfo.bounds.y + clickInfo.bounds.height / 2;
7321
+ double[][] toscreen = clickInfo.toScreen;
67667322 if (toscreen == null)
67677323 {
6768
- toscreen = new Camera(info.camera.viewCode).toScreen;
7324
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
67697325 }
67707326 cVector vec = in;
67717327 LA.xformPos(in, toscreen, in);
67727328 //System.out.println("Distance = " + info.camera.Distance());
6773
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
6774
- vec.y *= 100 * info.camera.SCALE / info.camera.Distance();
7329
+ vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
7330
+ vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
67757331 outPt.x = hc + (int) vec.x;
67767332 outPt.y = vc - (int) vec.y;
67777333 outRec.x = outPt.x - 3;
....@@ -6779,15 +7335,18 @@
67797335 outRec.width = outRec.height = 6;
67807336 }
67817337
6782
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7338
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7339
+ )
67837340 {
67847341 Point pt = new Point(0, 0);
67857342 Rectangle rec = new Rectangle();
6786
- calcHotSpot(in, info, pt, rec);
7343
+ calcHotSpot(in, //clickInfo,
7344
+ pt, rec);
67877345 return rec;
67887346 }
67897347
6790
- void drawEditHandles0(ClickInfo info, int level)
7348
+ void drawEditHandles0(//ClickInfo clickInfo,
7349
+ int level)
67917350 {
67927351 if (level == 0)
67937352 {
....@@ -6796,16 +7355,19 @@
67967355 {
67977356 cVector origin = new cVector();
67987357 //LA.xformPos(origin, toParent, origin);
6799
- Rectangle spot = calcHotSpot(origin, info);
7358
+ if (this.clickInfo == null)
7359
+ this.clickInfo = new ClickInfo();
7360
+
7361
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
68007362 Rectangle boundary = new Rectangle();
68017363 boundary.x = spot.x - 30;
68027364 boundary.y = spot.y - 30;
68037365 boundary.width = spot.width + 60;
68047366 boundary.height = spot.height + 60;
6805
- info.g.setColor(Color.red);
7367
+ clickInfo.g.setColor(Color.red);
68067368 int spotw = spot.x + spot.width;
68077369 int spoth = spot.y + spot.height;
6808
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7370
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
68097371 // if (CameraPane.Xmin > spot.x)
68107372 // {
68117373 // CameraPane.Xmin = spot.x;
....@@ -6825,8 +7387,8 @@
68257387 spot.translate(32, 32);
68267388 spotw = spot.x + spot.width;
68277389 spoth = spot.y + spot.height;
6828
- info.g.setColor(Color.blue);
6829
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7390
+ clickInfo.g.setColor(Color.cyan);
7391
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
68307392 // if (CameraPane.Xmin > spot.x)
68317393 // {
68327394 // CameraPane.Xmin = spot.x;
....@@ -6843,11 +7405,12 @@
68437405 // {
68447406 // CameraPane.Ymax = spoth;
68457407 // }
6846
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
6847
- info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7408
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7409
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
68487410 spot.translate(0, -32);
6849
- info.g.setColor(Color.green);
6850
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7411
+ clickInfo.g.setColor(Color.yellow);
7412
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7413
+ clickInfo.g.setColor(Color.green);
68517414 // if (CameraPane.Xmin > spot.x)
68527415 // {
68537416 // CameraPane.Xmin = spot.x;
....@@ -6864,8 +7427,8 @@
68647427 // {
68657428 // CameraPane.Ymax = spoth;
68667429 // }
6867
- info.g.drawArc(boundary.x, boundary.y,
6868
- boundary.width, boundary.height, 0, 360);
7430
+ clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
7431
+ (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
68697432 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
68707433 // if (CameraPane.Xmin > boundary.x)
68717434 // {
....@@ -6887,7 +7450,8 @@
68877450 }
68887451 }
68897452
6890
- boolean doEditClick0(ClickInfo info, int level)
7453
+ boolean doEditClick0(//ClickInfo clickInfo,
7454
+ int level)
68917455 {
68927456 if (level == 0)
68937457 {
....@@ -6896,10 +7460,10 @@
68967460
68977461 boolean retval = false;
68987462
6899
- startX = info.x;
6900
- startY = info.y;
7463
+ startX = clickInfo.x;
7464
+ startY = clickInfo.y;
69017465
6902
- hitSomething = 0;
7466
+ hitSomething = -1;
69037467 cVector origin = new cVector();
69047468 //LA.xformPos(origin, toParent, origin);
69057469 Rectangle spot = new Rectangle();
....@@ -6907,22 +7471,51 @@
69077471 {
69087472 centerPt = new Point(0, 0);
69097473 }
6910
- calcHotSpot(origin, info, centerPt, spot);
6911
- if (spot.contains(info.x, info.y))
7474
+ calcHotSpot(origin, //info,
7475
+ centerPt, spot);
7476
+ if (spot.contains(clickInfo.x, clickInfo.y))
69127477 {
69137478 hitSomething = hitCenter;
69147479 retval = true;
69157480 }
69167481 spot.translate(32, 0);
6917
- if (spot.contains(info.x, info.y))
7482
+ if (spot.contains(clickInfo.x, clickInfo.y))
69187483 {
69197484 hitSomething = hitRotate;
69207485 retval = true;
69217486 }
69227487 spot.translate(0, 32);
6923
- if (spot.contains(info.x, info.y))
7488
+ if (spot.contains(clickInfo.x, clickInfo.y))
69247489 {
69257490 hitSomething = hitScale;
7491
+
7492
+ double scale = 0.005f * clickInfo.camera.Distance();
7493
+ double hScale = (double) (clickInfo.x /*- centerPt.x*/) / 32;
7494
+ double sign = 1;
7495
+ if (hScale < 0)
7496
+ {
7497
+ sign = -1;
7498
+ }
7499
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
7500
+ if (hScale < 0.01)
7501
+ {
7502
+ //hScale = 0.01;
7503
+ }
7504
+
7505
+ double vScale = (double) (clickInfo.y /*- centerPt.y*/) / 32;
7506
+ sign = 1;
7507
+ if (vScale < 0)
7508
+ {
7509
+ sign = -1;
7510
+ }
7511
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
7512
+ if (vScale < 0.01)
7513
+ {
7514
+ //vScale = 0.01;
7515
+ }
7516
+
7517
+ clickInfo.scale = Math.sqrt(hScale*hScale + vScale*vScale);
7518
+
69267519 retval = true;
69277520 }
69287521
....@@ -6932,7 +7525,7 @@
69327525 }
69337526
69347527 //System.out.println("info.modifiers = " + info.modifiers);
6935
- modified = (info.modifiers & CameraPane.META) != 0;
7528
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
69367529 //System.out.println("modified = " + modified);
69377530 //new Exception().printStackTrace();
69387531 //viewCode = info.pane.renderCamera.viewCode;
....@@ -6960,7 +7553,8 @@
69607553 return true;
69617554 }
69627555
6963
- void doEditDrag0(ClickInfo info)
7556
+ void doEditDrag0(//ClickInfo info,
7557
+ boolean opposite)
69647558 {
69657559 if (hitSomething == 0)
69667560 {
....@@ -6974,7 +7568,8 @@
69747568
69757569 //System.out.println("hitSomething = " + hitSomething);
69767570
6977
- double scale = 0.005f * info.camera.Distance();
7571
+ double scale = 0.005f * clickInfo.camera.Distance();
7572
+
69787573 cVector xlate = new cVector();
69797574 //cVector xlate2 = new cVector();
69807575 switch (hitSomething)
....@@ -6987,7 +7582,7 @@
69877582
69887583 scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
69897584
6990
- if (modified)
7585
+ if (modified || opposite)
69917586 {
69927587 //assert(false);
69937588 /*
....@@ -7007,8 +7602,8 @@
70077602 toParent[3][i] = xlate.get(i);
70087603 LA.matInvert(toParent, fromParent);
70097604 */
7010
- cVector delta = LA.newVector(0, 0, startY - info.y);
7011
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7605
+ cVector delta = LA.newVector(0, 0, startY - clickInfo.y);
7606
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
70127607
70137608 LA.matCopy(startMat, toParent);
70147609 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7017,7 +7612,7 @@
70177612 } else
70187613 {
70197614 //LA.xformDir(delta, info.camera.fromScreen, delta);
7020
- cVector up = new cVector(info.camera.up);
7615
+ cVector up = new cVector(clickInfo.camera.up);
70217616 cVector away = new cVector();
70227617 //cVector right2 = new cVector();
70237618 //LA.vecCross(up, cVector.Z, right);
....@@ -7034,19 +7629,19 @@
70347629 LA.xformDir(up, ClickInfo.matbuffer, up);
70357630 // if (!CameraPane.LOCALTRANSFORM)
70367631 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7037
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7632
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
70387633 // if (!CameraPane.LOCALTRANSFORM)
70397634 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
70407635 //LA.vecCross(up, cVector.Z, right2);
70417636
7042
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7637
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
70437638
70447639 //System.out.println("DELTA0 = " + delta);
70457640 //System.out.println("AWAY = " + info.camera.away);
70467641 //System.out.println("UP = " + info.camera.up);
70477642 if (away.z > 0)
70487643 {
7049
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7644
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
70507645 {
70517646 delta.x = -delta.x;
70527647 } else
....@@ -7061,7 +7656,7 @@
70617656 //System.out.println("DELTA1 = " + delta);
70627657 LA.xformDir(delta, ClickInfo.matbuffer, delta);
70637658 //System.out.println("DELTA2 = " + delta);
7064
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7659
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
70657660 LA.matCopy(startMat, toParent);
70667661 //System.out.println("DELTA3 = " + delta);
70677662 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7071,8 +7666,8 @@
70717666 break;
70727667
70737668 case hitRotate: // rotate
7074
- int dx = info.x - centerPt.x;
7075
- int dy = -(info.y - centerPt.y);
7669
+ int dx = clickInfo.x - centerPt.x;
7670
+ int dy = -(clickInfo.y - centerPt.y);
70767671 double angle = (double) Math.atan2(dx, dy);
70777672 angle = -(1.570796 - angle);
70787673
....@@ -7081,6 +7676,7 @@
70817676
70827677 if (modified)
70837678 {
7679
+ // Rotate 90 degrees
70847680 angle /= (Math.PI / 4);
70857681 angle = Math.floor(angle + 0.5);
70867682 angle *= (Math.PI / 4);
....@@ -7094,7 +7690,7 @@
70947690 }
70957691 /**/
70967692
7097
- switch (info.pane.RenderCamera().viewCode)
7693
+ switch (clickInfo.pane.RenderCamera().viewCode)
70987694 {
70997695 case 1: // '\001'
71007696 LA.matZRotate(toParent, angle);
....@@ -7121,26 +7717,30 @@
71217717 break;
71227718
71237719 case hitScale: // scale
7124
- double hScale = (double) (info.x - centerPt.x) / 32;
7720
+ double hScale = (double) (clickInfo.x /*- centerPt.x*/) / 32;
7721
+ double sign = 1;
7722
+ if (hScale < 0)
7723
+ {
7724
+ sign = -1;
7725
+ }
7726
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
71257727 if (hScale < 0.01)
71267728 {
7127
- hScale = 0.01;
7729
+ //hScale = 0.01;
71287730 }
7129
- hScale = Math.pow(hScale, scale * 50);
7130
- if (hScale < 0.01)
7731
+
7732
+ double vScale = (double) (clickInfo.y /*- centerPt.y*/) / 32;
7733
+ sign = 1;
7734
+ if (vScale < 0)
71317735 {
7132
- hScale = 0.01;
7736
+ sign = -1;
71337737 }
7134
- double vScale = (double) (info.y - centerPt.y) / 32;
7738
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
71357739 if (vScale < 0.01)
71367740 {
7137
- vScale = 0.01;
7741
+ //vScale = 0.01;
71387742 }
7139
- vScale = Math.pow(vScale, scale * 50);
7140
- if (vScale < 0.01)
7141
- {
7142
- vScale = 0.01;
7143
- }
7743
+
71447744 LA.matCopy(startMat, toParent);
71457745 /**/
71467746 for (int i = 0; i < 3; i++)
....@@ -7150,39 +7750,47 @@
71507750 }
71517751 /**/
71527752
7153
- switch (info.pane.RenderCamera().viewCode)
7753
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
7754
+
7755
+ if (totalScale < 0.01)
7756
+ {
7757
+ totalScale = 0.01;
7758
+ }
7759
+
7760
+ switch (clickInfo.pane.RenderCamera().viewCode)
71547761 {
71557762 case 3: // '\001'
7156
- if (modified)
7763
+ if (modified || opposite)
71577764 {
71587765 //LA.matScale(toParent, 1, hScale, vScale);
7159
- LA.matScale(toParent, vScale, 1, 1);
7766
+ LA.matScale(toParent, totalScale, 1, 1);
71607767 } // vScale, 1);
71617768 else
71627769 {
7163
- LA.matScale(toParent, vScale, vScale, vScale);
7770
+ // EXCEPTION!
7771
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
71647772 } // vScale, 1);
71657773 break;
71667774
71677775 case 2: // '\002'
7168
- if (modified)
7776
+ if (modified || opposite)
71697777 {
71707778 //LA.matScale(toParent, hScale, 1, vScale);
7171
- LA.matScale(toParent, 1, vScale, 1);
7779
+ LA.matScale(toParent, 1, totalScale, 1);
71727780 } else
71737781 {
7174
- LA.matScale(toParent, vScale, 1, vScale);
7782
+ LA.matScale(toParent, totalScale, 1, totalScale);
71757783 }
71767784 break;
71777785
71787786 case 1: // '\003'
7179
- if (modified)
7787
+ if (modified || opposite)
71807788 {
71817789 //LA.matScale(toParent, hScale, vScale, 1);
7182
- LA.matScale(toParent, 1, 1, vScale);
7790
+ LA.matScale(toParent, 1, 1, totalScale);
71837791 } else
71847792 {
7185
- LA.matScale(toParent, vScale, vScale, 1);
7793
+ LA.matScale(toParent, totalScale, totalScale, 1);
71867794 }
71877795 break;
71887796 }
....@@ -7216,7 +7824,7 @@
72167824 } // NEW ...
72177825
72187826
7219
- info.pane.repaint();
7827
+ clickInfo.pane.repaint();
72207828 }
72217829
72227830 boolean overflow = false;
....@@ -7315,14 +7923,22 @@
73157923 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
73167924 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
73177925 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7926
+
7927
+ String objname;
7928
+
73187929 if (false) //parent != null)
73197930 {
7320
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7931
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
73217932 } else
73227933 {
7323
- return GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ") ")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ +System.identityHashCode(this);
7934
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
73247935 } // + super.toString();
73257936 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
7937
+
7938
+ if (!Globals.ADVANCED)
7939
+ return objname;
7940
+
7941
+ return objname + " " + System.identityHashCode(this);
73267942 }
73277943
73287944 public int hashCode()
....@@ -7378,6 +7994,7 @@
73787994 objectUI.closeUI();
73797995 if (editWindow != null)
73807996 {
7997
+ editWindow.ctrlPanel.FlushUI();
73817998 editWindow.refreshContents();
73827999 } // ? new
73838000 objectUI = null;
....@@ -7386,6 +8003,10 @@
73868003 {
73878004 editWindow = null;
73888005 } // ?
8006
+ }
8007
+ else
8008
+ {
8009
+ //editWindow.closeUI();
73898010 }
73908011 }
73918012
....@@ -7398,7 +8019,7 @@
73988019 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
73998020
74008021 Object3D /*Composite*/ parent;
7401
- Object3D /*Composite*/ fileparent;
8022
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
74028023
74038024 double[][] toParent; // dynamic matrix
74048025 double[][] fromParent;
....@@ -7513,7 +8134,7 @@
75138134 {
75148135 assert(bRep != null);
75158136 if (!(support instanceof GenericJoint)) // support.bRep != null)
7516
- GrafreeD.Assert(support.bRep == bRep.support);
8137
+ Grafreed.Assert(support.bRep == bRep.support);
75178138 }
75188139 else
75198140 {
....@@ -7544,6 +8165,10 @@
75448165 }
75458166
75468167 transient ObjEditor editWindow;
8168
+ transient ObjEditor manipWindow;
8169
+
8170
+ transient boolean pinned;
8171
+
75478172 transient ObjectUI objectUI;
75488173 public static int povDepth = 0;
75498174 private static cVector tbMin = new cVector();
....@@ -7562,9 +8187,9 @@
75628187 private static cVector edge2 = new cVector();
75638188 //private static cVector norm = new cVector();
75648189 /*transient private*/ int hitSomething;
7565
- private static final int hitCenter = 1;
7566
- private static final int hitScale = 2;
7567
- private static final int hitRotate = 3;
8190
+ static final int hitCenter = 1;
8191
+ static final int hitScale = 2;
8192
+ static final int hitRotate = 3;
75688193 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
75698194 /*transient*/ private Point centerPt;
75708195 /*transient*/ private int startX;