Normand Briere
2019-08-17 5892f05411c3d4dce2d8a59e0966dc2e1843a971
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,8 @@
300455 }
301456
302457 boolean live = false;
458
+ transient boolean keepdontselect;
459
+ boolean dontselect = false;
303460 boolean hide = false;
304461 boolean link2master = false; // performs reset support/master at each frame
305462 boolean marked = false; // animation node
....@@ -481,12 +638,14 @@
481638 toParent = LA.newMatrix();
482639 fromParent = LA.newMatrix();
483640 }
641
+
484642 if (toParentMarked == null)
485643 {
486644 if (maxcount != 1)
487645 {
488646 new Exception().printStackTrace();
489647 }
648
+
490649 toParentMarked = LA.newMatrix();
491650 fromParentMarked = LA.newMatrix();
492651 }
....@@ -774,7 +933,7 @@
774933 if (step == 0)
775934 step = 1;
776935 if (maxcount == 0)
777
- maxcount = 2048; // 4;
936
+ maxcount = 128; // 2048; // 4;
778937 // if (acceleration == 0)
779938 // acceleration = 10;
780939 if (delay == 0) // serial
....@@ -797,7 +956,7 @@
797956
798957 if (marked && Globals.isLIVE() && live &&
799958 //TEMP21aug2018
800
- Globals.DrawMode() == iCameraPane.SHADOW &&
959
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
801960 currentframe != Globals.framecount)
802961 {
803962 currentframe = Globals.framecount;
....@@ -809,7 +968,8 @@
809968
810969 boolean changedir = random && Math.random() < 0.01; // && !link2master;
811970
812
- if (transformcount*factor > maxcount || (step == 1 && changedir))
971
+ if (transformcount*factor >= maxcount && (rewind || random) ||
972
+ (step == 1 && changedir))
813973 {
814974 countdown = 1;
815975 delay = speedup?8:1;
....@@ -881,6 +1041,10 @@
8811041 if (material == null || material.multiply)
8821042 return true;
8831043
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.
8841048 return material.opacity > 0.99;
8851049 }
8861050
....@@ -912,6 +1076,11 @@
9121076 fromParent = null; // LA.newMatrix();
9131077 bRep = null; // new BoundaryRep();
9141078
1079
+ if (oname != null && oname.equals("LeftHand"))
1080
+ {
1081
+ name = oname;
1082
+ }
1083
+
9151084 /*
9161085 float hue = (float)Math.random();
9171086 Color col;
....@@ -954,7 +1123,7 @@
9541123
9551124 public Object clone()
9561125 {
957
- return GrafreeD.clone(this);
1126
+ return Grafreed.clone(this);
9581127 }
9591128
9601129 Object3D copyExpand()
....@@ -1276,6 +1445,7 @@
12761445 toParent = LA.newMatrix();
12771446 fromParent = LA.newMatrix();
12781447 }
1448
+
12791449 LA.matCopy(other.toParent, toParent);
12801450 LA.matCopy(other.fromParent, fromParent);
12811451
....@@ -1470,7 +1640,7 @@
14701640 BoundaryRep.SEUIL = other.material.cameralight;
14711641
14721642 // Set default to 0.1
1473
- BoundaryRep.SEUIL /= 2;
1643
+ BoundaryRep.SEUIL /= 4; // 2;
14741644 System.out.println("SEUIL = " + BoundaryRep.SEUIL);
14751645 }
14761646
....@@ -1729,7 +1899,7 @@
17291899 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17301900 o.bRep = transientrep;
17311901 if (clone)
1732
- o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
1902
+ o.bRep = (BoundaryRep) Grafreed.clone(transientrep);
17331903 o.CreateMaterial();
17341904 o.SetAttributes(this, -1);
17351905 //parent
....@@ -1742,7 +1912,7 @@
17421912 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17431913 o.bRep = bRep;
17441914 if (clone)
1745
- o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
1915
+ o.bRep = (BoundaryRep) Grafreed.clone(bRep);
17461916 o.CreateMaterial();
17471917 //o.overwriteThis(this, -1);
17481918 o.SetAttributes(this, -1);
....@@ -1829,12 +1999,15 @@
18291999 if (obj.name == null)
18302000 continue; // can't be a null one
18312001
2002
+ // Try perfect match first.
18322003 if (n.equals(obj.name))
18332004 {
18342005 theobj = obj;
18352006 count++;
18362007 }
18372008 }
2009
+
2010
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18382011
18392012 if (count != 1)
18402013 for (int i=Size(); --i>=0;)
....@@ -2294,12 +2467,22 @@
22942467 }
22952468 */
22962469 }
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
+ }
22972479 }
22982480
22992481 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
23002482 {
23012483 if (newWindow)
23022484 {
2485
+ new Exception().printStackTrace();
23032486 System.exit(0);
23042487 if (parent != null)
23052488 {
....@@ -2334,6 +2517,14 @@
23342517 {
23352518 editWindow.refreshContents();
23362519 }
2520
+ else
2521
+ {
2522
+ if (manipWindow != null)
2523
+ {
2524
+ manipWindow.refreshContents();
2525
+ }
2526
+ }
2527
+
23372528 //if (parent != null)
23382529 //parent.refreshEditWindow();
23392530 }
....@@ -2413,7 +2604,8 @@
24132604 private static final int editSelf = 1;
24142605 private static final int editChild = 2;
24152606
2416
- void drawEditHandles(ClickInfo info, int level)
2607
+ void drawEditHandles(//ClickInfo info,
2608
+ int level)
24172609 {
24182610 if (level == 0)
24192611 {
....@@ -2421,7 +2613,8 @@
24212613 return;
24222614
24232615 Object3D selectee;
2424
- 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))
24252618 {
24262619 selectee = (Object3D) e.nextElement();
24272620 }
....@@ -2429,19 +2622,22 @@
24292622 } else
24302623 {
24312624 //super.
2432
- drawEditHandles0(info, level + 1);
2625
+ drawEditHandles0(//info,
2626
+ level + 1);
24332627 }
24342628 }
24352629
2436
- boolean doEditClick(ClickInfo info, int level)
2630
+ boolean doEditClick(//ClickInfo info,
2631
+ int level)
24372632 {
24382633 doSomething = 0;
24392634 if (level == 0)
24402635 {
2441
- return doParentClick(info);
2636
+ return doParentClick(); //info);
24422637 }
24432638 if (//super.
2444
- doEditClick0(info, level))
2639
+ doEditClick0(//info,
2640
+ level))
24452641 {
24462642 doSomething = 1;
24472643 return true;
....@@ -2451,7 +2647,7 @@
24512647 }
24522648 }
24532649
2454
- boolean doParentClick(ClickInfo info)
2650
+ boolean doParentClick() //ClickInfo info)
24552651 {
24562652 if (selection == null)
24572653 {
....@@ -2464,7 +2660,8 @@
24642660 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
24652661 {
24662662 Object3D selectee = (Object3D) e.nextElement();
2467
- if (selectee.doEditClick(info, 1))
2663
+ if (selectee.doEditClick(//info,
2664
+ 1))
24682665 {
24692666 childToDrag = selectee;
24702667 doSomething = 2;
....@@ -2476,13 +2673,15 @@
24762673 return retval;
24772674 }
24782675
2479
- void doEditDrag(ClickInfo info)
2676
+ void doEditDrag(//ClickInfo clickInfo,
2677
+ boolean opposite)
24802678 {
24812679 switch (doSomething)
24822680 {
24832681 case 1: // '\001'
24842682 //super.
2485
- doEditDrag0(info);
2683
+ doEditDrag0(//clickInfo,
2684
+ opposite);
24862685 break;
24872686
24882687 case 2: // '\002'
....@@ -2495,11 +2694,13 @@
24952694 {
24962695 //sel.hitSomething = childToDrag.hitSomething;
24972696 //childToDrag.doEditDrag(info);
2498
- sel.doEditDrag(info);
2697
+ sel.doEditDrag(//clickInfo,
2698
+ opposite);
24992699 } else
25002700 {
25012701 //super.
2502
- doEditDrag0(info);
2702
+ doEditDrag0(//clickInfo,
2703
+ opposite);
25032704 }
25042705 }
25052706 break;
....@@ -2517,6 +2718,9 @@
25172718 {
25182719 deselectAll();
25192720 }
2721
+
2722
+ new Exception().printStackTrace();
2723
+
25202724 ClickInfo newInfo = new ClickInfo();
25212725 newInfo.flags = info.flags;
25222726 newInfo.bounds = info.bounds;
....@@ -2609,6 +2813,18 @@
26092813 void GenNormalsS(boolean crease)
26102814 {
26112815 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();
26122828 // for (int i=0; i<selection.size(); i++)
26132829 // {
26142830 // Object3D selectee = (Object3D) selection.elementAt(i);
....@@ -2749,6 +2965,24 @@
27492965 if (child == null)
27502966 continue;
27512967 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();
27522986 // Children().release(i);
27532987 }
27542988 blockloop = false;
....@@ -2906,7 +3140,8 @@
29063140 {
29073141 if (bRep != null)
29083142 {
2909
- bRep.GenUV();
3143
+ bRep.GenUV(); //1);
3144
+ //bRep.UnfoldUV();
29103145 Touch();
29113146 }
29123147 }
....@@ -2920,11 +3155,20 @@
29203155 }
29213156 }
29223157
3158
+ void GenNormalsMesh0()
3159
+ {
3160
+ if (bRep != null)
3161
+ {
3162
+ bRep.GenerateNormalsMesh();
3163
+ Touch();
3164
+ }
3165
+ }
3166
+
29233167 void GenNormalsMINE0()
29243168 {
29253169 if (bRep != null)
29263170 {
2927
- bRep.GenerateNormalsMINE();
3171
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
29283172 Touch();
29293173 }
29303174 }
....@@ -2981,6 +3225,33 @@
29813225 blockloop = false;
29823226 }
29833227
3228
+ void TransformChildren()
3229
+ {
3230
+ if (toParent != null)
3231
+ {
3232
+ for (int i=Size(); --i>=0;)
3233
+ {
3234
+ Object3D v = get(i);
3235
+
3236
+ if (v.toParent == null)
3237
+ {
3238
+ v.toParent = LA.newMatrix();
3239
+ v.fromParent = LA.newMatrix();
3240
+ }
3241
+
3242
+// LA.matConcat(v.toParent, toParent, v.toParent);
3243
+// LA.matConcat(fromParent, v.fromParent, v.fromParent);
3244
+ LA.matConcat(toParent, v.toParent, v.toParent);
3245
+ LA.matConcat(v.fromParent, fromParent, v.fromParent);
3246
+ }
3247
+
3248
+ toParent = null; // LA.matIdentity(toParent);
3249
+ fromParent = null; // LA.matIdentity(fromParent);
3250
+
3251
+ Touch();
3252
+ }
3253
+ }
3254
+
29843255 void TransformGeometry()
29853256 {
29863257 Object3D obj = this;
....@@ -3202,9 +3473,11 @@
32023473
32033474 BoundaryRep sup = bRep.support;
32043475 bRep.support = null;
3205
- BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
3476
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
32063477 // bRep.SplitInTwo(onlyone); // thread...
3207
- temprep.SplitInTwo(reduction34, onlyone);
3478
+
3479
+ while(temprep.SplitInTwo(reduction34, onlyone));
3480
+
32083481 bRep = temprep;
32093482 bRep.support = sup;
32103483 Touch();
....@@ -3341,7 +3614,8 @@
33413614 if (blockloop)
33423615 return;
33433616
3344
- if (marked || (bRep != null && material != null)) // borderline...
3617
+ if (//marked || // does not make sense
3618
+ (bRep != null || material != null)) // borderline...
33453619 live = h;
33463620
33473621 for (int i = 0; i < Size(); i++)
....@@ -3362,7 +3636,8 @@
33623636 return;
33633637
33643638 //if (bRep != null)
3365
- if (marked || (bRep != null && material != null)) // borderline...
3639
+ if (//marked || // does not make sense
3640
+ (bRep != null || material != null)) // borderline...
33663641 link2master = h;
33673642
33683643 for (int i = 0; i < Size(); i++)
....@@ -3382,7 +3657,8 @@
33823657 if (blockloop)
33833658 return;
33843659
3385
- if (marked || (bRep != null && material != null)) // borderline...
3660
+ if (//marked || // does not make sense
3661
+ (bRep != null || material != null)) // borderline...
33863662 hide = h;
33873663
33883664 for (int i = 0; i < Size(); i++)
....@@ -3402,7 +3678,7 @@
34023678 if (blockloop)
34033679 return;
34043680
3405
- if (bRep != null && material != null) // borderline...
3681
+ if (bRep != null || material != null) // borderline...
34063682 marked = h;
34073683
34083684 for (int i = 0; i < Size(); i++)
....@@ -3412,6 +3688,46 @@
34123688 continue;
34133689 blockloop = true;
34143690 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);
34153731 blockloop = false;
34163732 // release(i);
34173733 }
....@@ -3726,7 +4042,7 @@
37264042 if (child == null)
37274043 continue;
37284044
3729
- if (GrafreeD.RENDERME > 0)
4045
+ if (Grafreed.RENDERME > 0)
37304046 {
37314047 if (child instanceof Merge)
37324048 ((Merge)child).renderme();
....@@ -3877,7 +4193,7 @@
38774193 if (child == null)
38784194 continue;
38794195
3880
- if (GrafreeD.RENDERME > 0)
4196
+ if (Grafreed.RENDERME > 0)
38814197 {
38824198 if (child instanceof Merge)
38834199 ((Merge)child).renderme();
....@@ -4072,7 +4388,7 @@
40724388 if (child == null)
40734389 continue;
40744390
4075
- if (GrafreeD.RENDERME > 0)
4391
+ if (Grafreed.RENDERME > 0)
40764392 {
40774393 if (child instanceof Merge)
40784394 ((Merge)child).renderme();
....@@ -4185,6 +4501,55 @@
41854501 {
41864502 blockloop = true;
41874503 get(i).RepairShadow();
4504
+ blockloop = false;
4505
+ }
4506
+ }
4507
+
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();
41884553 blockloop = false;
41894554 }
41904555 }
....@@ -4679,7 +5044,7 @@
46795044
46805045 cTreePath SelectLeaf(int indexcount, boolean deselect)
46815046 {
4682
- if (hide)
5047
+ if (hide || dontselect)
46835048 return null;
46845049
46855050 if (count <= 0)
....@@ -4703,9 +5068,17 @@
47035068 }
47045069 }
47055070
5071
+ ObjEditor GetWindow()
5072
+ {
5073
+ if (editWindow != null)
5074
+ return editWindow;
5075
+
5076
+ return manipWindow;
5077
+ }
5078
+
47065079 cTreePath Select(int indexcount, boolean deselect)
47075080 {
4708
- if (hide)
5081
+ if (hide || dontselect)
47095082 return null;
47105083
47115084 if (count <= 0)
....@@ -4739,10 +5112,11 @@
47395112 if (leaf != null)
47405113 {
47415114 cTreePath tp = new cTreePath(this, leaf);
4742
- if (editWindow != null)
5115
+ ObjEditor window = GetWindow();
5116
+ if (window != null)
47435117 {
47445118 //System.out.println("editWindow = " + editWindow + " vs " + this);
4745
- editWindow.Select(tp, deselect, true);
5119
+ window.Select(tp, deselect, true);
47465120 }
47475121
47485122 return tp;
....@@ -4759,6 +5133,7 @@
47595133
47605134 if (child == null)
47615135 continue;
5136
+
47625137 if (child.HasTransparency() && child.size() != 0)
47635138 {
47645139 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4768,9 +5143,10 @@
47685143 if (leaf != null)
47695144 {
47705145 cTreePath tp = new cTreePath(this, leaf);
4771
- if (editWindow != null)
5146
+ ObjEditor window = GetWindow();
5147
+ if (window != null)
47725148 {
4773
- editWindow.Select(tp, deselect, true);
5149
+ window.Select(tp, deselect, true);
47745150 }
47755151
47765152 return tp;
....@@ -5095,6 +5471,51 @@
50955471 blockloop = false;
50965472 }
50975473
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
+
50985519 boolean IsSelected()
50995520 {
51005521 if (parent == null)
....@@ -5155,12 +5576,41 @@
51555576 if (fullname == null)
51565577 return "";
51575578
5579
+ if (fullname.pigment != null)
5580
+ {
5581
+ return fullname.pigment;
5582
+ }
5583
+
51585584 // System.out.println("Fullname = " + fullname);
51595585
5160
- if (fullname.name.indexOf(":") == -1)
5161
- return fullname.name;
5586
+ // Does not work on Windows due to C:
5587
+// if (fullname.name.indexOf(":") == -1)
5588
+// return fullname.name;
5589
+//
5590
+// return fullname.name.substring(0,fullname.name.indexOf(":"));
51625591
5163
- return fullname.name.substring(0,fullname.name.indexOf(":"));
5592
+ String[] split = fullname.name.split(":");
5593
+
5594
+ if (split.length == 0)
5595
+ {
5596
+ return fullname.pigment = "";
5597
+ }
5598
+
5599
+ if (split.length <= 2)
5600
+ {
5601
+ if (fullname.name.endsWith(":"))
5602
+ {
5603
+ // Windows
5604
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
5605
+ }
5606
+
5607
+ return fullname.pigment = split[0];
5608
+ }
5609
+
5610
+ // Windows
5611
+ assert(split.length == 4);
5612
+
5613
+ return fullname.pigment = split[0] + ":" + split[1];
51645614 }
51655615
51665616 static String GetBump(cTexture fullname)
....@@ -5168,11 +5618,44 @@
51685618 if (fullname == null)
51695619 return "";
51705620
5621
+ if (fullname.bump != null)
5622
+ {
5623
+ return fullname.bump;
5624
+ }
5625
+
51715626 // System.out.println("Fullname = " + fullname);
5172
- if (fullname.name.indexOf(":") == -1)
5173
- return "";
5174
-
5175
- return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5627
+ // Does not work on Windows due to C:
5628
+// if (fullname.name.indexOf(":") == -1)
5629
+// return "";
5630
+//
5631
+// return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5632
+ String[] split = fullname.name.split(":");
5633
+
5634
+ if (split.length == 0)
5635
+ {
5636
+ return fullname.bump = "";
5637
+ }
5638
+
5639
+ if (split.length == 1)
5640
+ {
5641
+ return fullname.bump = "";
5642
+ }
5643
+
5644
+ if (split.length == 2)
5645
+ {
5646
+ if (fullname.name.endsWith(":"))
5647
+ {
5648
+ // Windows
5649
+ return fullname.bump = "";
5650
+ }
5651
+
5652
+ return fullname.bump = split[1];
5653
+ }
5654
+
5655
+ // Windows
5656
+ assert(split.length == 4);
5657
+
5658
+ return fullname.bump = split[2] + ":" + split[3];
51765659 }
51775660
51785661 String GetPigmentTexture()
....@@ -5246,7 +5729,7 @@
52465729 System.out.print("; textures = " + textures);
52475730 System.out.println("; usedtextures = " + usedtextures);
52485731
5249
- if (GetTextures() == null)
5732
+ if (GetTextures() == null) // What is that??
52505733 GetTextures().name = ":";
52515734
52525735 String texname = tex;
....@@ -5255,6 +5738,9 @@
52555738 texname = "";
52565739
52575740 GetTextures().name = texname + ":" + GetBump(GetTextures());
5741
+
5742
+ GetTextures().pigment = null;
5743
+
52585744 Touch();
52595745 }
52605746
....@@ -5279,6 +5765,43 @@
52795765 }
52805766 }
52815767
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
+
52825805 void SetBumpTexture(String tex)
52835806 {
52845807 if (GetTextures() == null)
....@@ -5290,6 +5813,8 @@
52905813 texname = "";
52915814
52925815 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
5816
+
5817
+ GetTextures().bump = null;
52935818
52945819 Touch();
52955820 }
....@@ -5315,6 +5840,38 @@
53155840 }
53165841 }
53175842
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
+
53185875 void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
53195876 {
53205877 Draw(display, root, selected, blocked);
....@@ -5323,12 +5880,23 @@
53235880 boolean NeedSupport()
53245881 {
53255882 return
5326
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5883
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
53275884 // PROBLEM with CROWD!!
5328
- && (Globals.DrawMode() == iCameraPane.SHADOW || Globals.CROWD);
5885
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
53295886 }
53305887
53315888 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
+ }
53325900
53335901 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
53345902 {
....@@ -5340,7 +5908,7 @@
53405908 }
53415909
53425910 if (display.DrawMode() == iCameraPane.SELECTION &&
5343
- hide)
5911
+ (hide || dontselect))
53445912 return;
53455913
53465914 if (name != null && name.contains("sclera"))
....@@ -5390,8 +5958,10 @@
53905958 if (support != null)
53915959 support = support;
53925960
5393
- //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5394
- 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.
53955965
53965966 if (!usecalllists && bRep != null && bRep.displaylist > 0)
53975967 {
....@@ -5401,8 +5971,9 @@
54015971 // usecalllists &= !(parent instanceof RandomNode);
54025972 // usecalllists = false;
54035973
5404
- if (GetBRep() != null)
5405
- usecalllists = usecalllists;
5974
+ if (display.DrawMode() == display.SHADOW)
5975
+ //GetBRep() != null)
5976
+ usecalllists = !!usecalllists;
54065977 //System.out.println("draw " + this);
54075978 //new Exception().printStackTrace();
54085979
....@@ -5411,10 +5982,12 @@
54115982 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
54125983
54135984 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5414
- (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)))
54155987 {
54165988 Globals.lighttouched = true;
54175989 } // all panes...
5990
+
54185991 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
54195992 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
54205993 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5422,7 +5995,7 @@
54225995 if (!(this instanceof Composite))
54235996 touched = false;
54245997 //if (displaylist == -1 && usecalllists)
5425
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
5998
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
54265999 {
54276000 bRep.displaylist = display.GenList();
54286001 assert(bRep.displaylist != 0);
....@@ -5433,7 +6006,7 @@
54336006
54346007 //System.out.println("\tnew list " + list);
54356008 //gl.glDrawBuffer(gl.GL_NONE);
5436
- if (usecalllists)
6009
+ if (usecalllists && bRep.displaylist > 0)
54376010 {
54386011 // System.err.println("new list " + bRep.displaylist + " for " + this);
54396012 display.NewList(bRep.displaylist);
....@@ -5442,7 +6015,7 @@
54426015 CallList(display, root, selected, blocked);
54436016
54446017 // compiled = true;
5445
- if (usecalllists)
6018
+ if (usecalllists && bRep.displaylist > 0)
54466019 {
54476020 // System.err.println("end list " + bRep.displaylist + " for " + this);
54486021 display.EndList();
....@@ -5542,6 +6115,7 @@
55426115 if (GetBRep() != null)
55436116 {
55446117 display.NextIndex();
6118
+
55456119 // vertex color conflict : gl.glCallList(list);
55466120 DrawNode(display, root, selected);
55476121 if (this instanceof BezierPatch)
....@@ -5582,7 +6156,28 @@
55826156 tex = GetTextures();
55836157 }
55846158
5585
- display.BindTextures(tex, texres);
6159
+ boolean failedPigment = false;
6160
+ boolean failedBump = false;
6161
+
6162
+ try
6163
+ {
6164
+ display.BindPigmentTexture(tex, texres);
6165
+ }
6166
+ catch (Exception e)
6167
+ {
6168
+ System.err.println("FAILED: " + this);
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;
6180
+ }
55866181
55876182 if (!compiled)
55886183 {
....@@ -5604,7 +6199,11 @@
56046199 }
56056200 }
56066201
5607
- display.ReleaseTextures(tex);
6202
+ if (!failedBump)
6203
+ display.ReleaseBumpTexture(tex);
6204
+
6205
+ if (!failedPigment)
6206
+ display.ReleasePigmentTexture(tex);
56086207
56096208 display.PopMaterial(this, selected);
56106209 }
....@@ -5733,6 +6332,9 @@
57336332
57346333 void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57356334 {
6335
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6336
+ return;
6337
+
57366338 if (hide)
57376339 return;
57386340 // shadow optimisation
....@@ -5858,6 +6460,9 @@
58586460 if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
58596461 return; // no shadow for transparent objects
58606462
6463
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6464
+ return;
6465
+
58616466 if (hide)
58626467 return;
58636468
....@@ -5898,6 +6503,7 @@
58986503 return;
58996504 }
59006505
6506
+ //bRep.GenUV(1/material.diffuseness);
59016507 // bRep.lock = true;
59026508
59036509 //javax.media.opengl.GL gl = display.GetGL();
....@@ -5970,6 +6576,11 @@
59706576 // dec 2012
59716577 new Exception().printStackTrace();
59726578 return;
6579
+ }
6580
+
6581
+ if (dontselect)
6582
+ {
6583
+ //bRep.GenerateNormalsMINE();
59736584 }
59746585
59756586 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -6755,20 +7366,23 @@
67557366 }
67567367 }
67577368
6758
- 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)
67597373 {
6760
- int hc = info.bounds.x + info.bounds.width / 2;
6761
- int vc = info.bounds.y + info.bounds.height / 2;
6762
- 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;
67637377 if (toscreen == null)
67647378 {
6765
- toscreen = new Camera(info.camera.viewCode).toScreen;
7379
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
67667380 }
67677381 cVector vec = in;
67687382 LA.xformPos(in, toscreen, in);
67697383 //System.out.println("Distance = " + info.camera.Distance());
6770
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
6771
- 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();
67727386 outPt.x = hc + (int) vec.x;
67737387 outPt.y = vc - (int) vec.y;
67747388 outRec.x = outPt.x - 3;
....@@ -6776,15 +7390,18 @@
67767390 outRec.width = outRec.height = 6;
67777391 }
67787392
6779
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7393
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7394
+ )
67807395 {
67817396 Point pt = new Point(0, 0);
67827397 Rectangle rec = new Rectangle();
6783
- calcHotSpot(in, info, pt, rec);
7398
+ calcHotSpot(in, //clickInfo,
7399
+ pt, rec);
67847400 return rec;
67857401 }
67867402
6787
- void drawEditHandles0(ClickInfo info, int level)
7403
+ void drawEditHandles0(//ClickInfo clickInfo,
7404
+ int level)
67887405 {
67897406 if (level == 0)
67907407 {
....@@ -6793,16 +7410,19 @@
67937410 {
67947411 cVector origin = new cVector();
67957412 //LA.xformPos(origin, toParent, origin);
6796
- Rectangle spot = calcHotSpot(origin, info);
7413
+ if (this.clickInfo == null)
7414
+ this.clickInfo = new ClickInfo();
7415
+
7416
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
67977417 Rectangle boundary = new Rectangle();
67987418 boundary.x = spot.x - 30;
67997419 boundary.y = spot.y - 30;
68007420 boundary.width = spot.width + 60;
68017421 boundary.height = spot.height + 60;
6802
- info.g.setColor(Color.red);
7422
+ clickInfo.g.setColor(Color.white);
68037423 int spotw = spot.x + spot.width;
68047424 int spoth = spot.y + spot.height;
6805
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7425
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
68067426 // if (CameraPane.Xmin > spot.x)
68077427 // {
68087428 // CameraPane.Xmin = spot.x;
....@@ -6819,11 +7439,33 @@
68197439 // {
68207440 // CameraPane.Ymax = spoth;
68217441 // }
6822
- 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);
68237465 spotw = spot.x + spot.width;
68247466 spoth = spot.y + spot.height;
6825
- info.g.setColor(Color.blue);
6826
- 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);
68277469 // if (CameraPane.Xmin > spot.x)
68287470 // {
68297471 // CameraPane.Xmin = spot.x;
....@@ -6840,29 +7482,9 @@
68407482 // {
68417483 // CameraPane.Ymax = spoth;
68427484 // }
6843
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
6844
- info.g.drawLine(spotw, spoth, spotw - 15, spoth);
6845
- spot.translate(0, -32);
6846
- info.g.setColor(Color.green);
6847
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
6848
-// if (CameraPane.Xmin > spot.x)
6849
-// {
6850
-// CameraPane.Xmin = spot.x;
6851
-// }
6852
-// if (CameraPane.Xmax < spotw)
6853
-// {
6854
-// CameraPane.Xmax = spotw;
6855
-// }
6856
-// if (CameraPane.Ymin > spot.y)
6857
-// {
6858
-// CameraPane.Ymin = spot.y;
6859
-// }
6860
-// if (CameraPane.Ymax < spoth)
6861
-// {
6862
-// CameraPane.Ymax = spoth;
6863
-// }
6864
- info.g.drawArc(boundary.x, boundary.y,
6865
- 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);
68667488 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
68677489 // if (CameraPane.Xmin > boundary.x)
68687490 // {
....@@ -6884,7 +7506,8 @@
68847506 }
68857507 }
68867508
6887
- boolean doEditClick0(ClickInfo info, int level)
7509
+ boolean doEditClick0(//ClickInfo clickInfo,
7510
+ int level)
68887511 {
68897512 if (level == 0)
68907513 {
....@@ -6893,10 +7516,10 @@
68937516
68947517 boolean retval = false;
68957518
6896
- startX = info.x;
6897
- startY = info.y;
7519
+ startX = clickInfo.x;
7520
+ startY = clickInfo.y;
68987521
6899
- hitSomething = 0;
7522
+ hitSomething = -1;
69007523 cVector origin = new cVector();
69017524 //LA.xformPos(origin, toParent, origin);
69027525 Rectangle spot = new Rectangle();
....@@ -6904,22 +7527,53 @@
69047527 {
69057528 centerPt = new Point(0, 0);
69067529 }
6907
- calcHotSpot(origin, info, centerPt, spot);
6908
- if (spot.contains(info.x, info.y))
7530
+ calcHotSpot(origin, //info,
7531
+ centerPt, spot);
7532
+ if (spot.contains(clickInfo.x, clickInfo.y))
69097533 {
69107534 hitSomething = hitCenter;
69117535 retval = true;
69127536 }
69137537 spot.translate(32, 0);
6914
- if (spot.contains(info.x, info.y))
7538
+ if (spot.contains(clickInfo.x, clickInfo.y))
69157539 {
69167540 hitSomething = hitRotate;
69177541 retval = true;
69187542 }
69197543 spot.translate(0, 32);
6920
- 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))
69217547 {
69227548 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
+
69237577 retval = true;
69247578 }
69257579
....@@ -6929,7 +7583,7 @@
69297583 }
69307584
69317585 //System.out.println("info.modifiers = " + info.modifiers);
6932
- modified = (info.modifiers & CameraPane.META) != 0;
7586
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
69337587 //System.out.println("modified = " + modified);
69347588 //new Exception().printStackTrace();
69357589 //viewCode = info.pane.renderCamera.viewCode;
....@@ -6957,7 +7611,8 @@
69577611 return true;
69587612 }
69597613
6960
- void doEditDrag0(ClickInfo info)
7614
+ void doEditDrag0(//ClickInfo info,
7615
+ boolean opposite)
69617616 {
69627617 if (hitSomething == 0)
69637618 {
....@@ -6971,7 +7626,8 @@
69717626
69727627 //System.out.println("hitSomething = " + hitSomething);
69737628
6974
- double scale = 0.005f * info.camera.Distance();
7629
+ double scale = 0.005f * clickInfo.camera.Distance();
7630
+
69757631 cVector xlate = new cVector();
69767632 //cVector xlate2 = new cVector();
69777633 switch (hitSomething)
....@@ -6984,7 +7640,7 @@
69847640
69857641 scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
69867642
6987
- if (modified)
7643
+ if (modified || opposite)
69887644 {
69897645 //assert(false);
69907646 /*
....@@ -7004,8 +7660,8 @@
70047660 toParent[3][i] = xlate.get(i);
70057661 LA.matInvert(toParent, fromParent);
70067662 */
7007
- cVector delta = LA.newVector(0, 0, startY - info.y);
7008
- 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);
70097665
70107666 LA.matCopy(startMat, toParent);
70117667 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7014,7 +7670,7 @@
70147670 } else
70157671 {
70167672 //LA.xformDir(delta, info.camera.fromScreen, delta);
7017
- cVector up = new cVector(info.camera.up);
7673
+ cVector up = new cVector(clickInfo.camera.up);
70187674 cVector away = new cVector();
70197675 //cVector right2 = new cVector();
70207676 //LA.vecCross(up, cVector.Z, right);
....@@ -7031,19 +7687,19 @@
70317687 LA.xformDir(up, ClickInfo.matbuffer, up);
70327688 // if (!CameraPane.LOCALTRANSFORM)
70337689 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7034
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7690
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
70357691 // if (!CameraPane.LOCALTRANSFORM)
70367692 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
70377693 //LA.vecCross(up, cVector.Z, right2);
70387694
7039
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7695
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
70407696
70417697 //System.out.println("DELTA0 = " + delta);
70427698 //System.out.println("AWAY = " + info.camera.away);
70437699 //System.out.println("UP = " + info.camera.up);
70447700 if (away.z > 0)
70457701 {
7046
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7702
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
70477703 {
70487704 delta.x = -delta.x;
70497705 } else
....@@ -7058,7 +7714,7 @@
70587714 //System.out.println("DELTA1 = " + delta);
70597715 LA.xformDir(delta, ClickInfo.matbuffer, delta);
70607716 //System.out.println("DELTA2 = " + delta);
7061
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7717
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
70627718 LA.matCopy(startMat, toParent);
70637719 //System.out.println("DELTA3 = " + delta);
70647720 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7068,8 +7724,8 @@
70687724 break;
70697725
70707726 case hitRotate: // rotate
7071
- int dx = info.x - centerPt.x;
7072
- int dy = -(info.y - centerPt.y);
7727
+ int dx = clickInfo.x - centerPt.x;
7728
+ int dy = -(clickInfo.y - centerPt.y);
70737729 double angle = (double) Math.atan2(dx, dy);
70747730 angle = -(1.570796 - angle);
70757731
....@@ -7078,6 +7734,7 @@
70787734
70797735 if (modified)
70807736 {
7737
+ // Rotate 90 degrees
70817738 angle /= (Math.PI / 4);
70827739 angle = Math.floor(angle + 0.5);
70837740 angle *= (Math.PI / 4);
....@@ -7091,7 +7748,7 @@
70917748 }
70927749 /**/
70937750
7094
- switch (info.pane.RenderCamera().viewCode)
7751
+ switch (clickInfo.pane.RenderCamera().viewCode)
70957752 {
70967753 case 1: // '\001'
70977754 LA.matZRotate(toParent, angle);
....@@ -7118,26 +7775,30 @@
71187775 break;
71197776
71207777 case hitScale: // scale
7121
- 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);
71227785 if (hScale < 0.01)
71237786 {
7124
- hScale = 0.01;
7787
+ //hScale = 0.01;
71257788 }
7126
- hScale = Math.pow(hScale, scale * 50);
7127
- if (hScale < 0.01)
7789
+
7790
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
7791
+ sign = 1;
7792
+ if (vScale < 0)
71287793 {
7129
- hScale = 0.01;
7794
+ sign = -1;
71307795 }
7131
- double vScale = (double) (info.y - centerPt.y) / 32;
7796
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
71327797 if (vScale < 0.01)
71337798 {
7134
- vScale = 0.01;
7799
+ //vScale = 0.01;
71357800 }
7136
- vScale = Math.pow(vScale, scale * 50);
7137
- if (vScale < 0.01)
7138
- {
7139
- vScale = 0.01;
7140
- }
7801
+
71417802 LA.matCopy(startMat, toParent);
71427803 /**/
71437804 for (int i = 0; i < 3; i++)
....@@ -7147,39 +7808,56 @@
71477808 }
71487809 /**/
71497810
7150
- 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)
71517819 {
71527820 case 3: // '\001'
7153
- if (modified)
7821
+ if (modified || opposite)
71547822 {
7823
+ if (modified && opposite)
7824
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7825
+ else
71557826 //LA.matScale(toParent, 1, hScale, vScale);
7156
- LA.matScale(toParent, vScale, 1, 1);
7827
+ LA.matScale(toParent, totalScale, 1, 1);
71577828 } // vScale, 1);
71587829 else
71597830 {
7160
- LA.matScale(toParent, vScale, vScale, vScale);
7831
+ // EXCEPTION!
7832
+ LA.matScale(toParent, 1, totalScale, totalScale);
71617833 } // vScale, 1);
71627834 break;
71637835
71647836 case 2: // '\002'
7165
- if (modified)
7837
+ if (modified || opposite)
71667838 {
7167
- //LA.matScale(toParent, hScale, 1, vScale);
7168
- 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);
71697844 } else
71707845 {
7171
- LA.matScale(toParent, vScale, 1, vScale);
7846
+ LA.matScale(toParent, totalScale, 1, totalScale);
71727847 }
71737848 break;
71747849
71757850 case 1: // '\003'
7176
- if (modified)
7851
+ if (modified || opposite)
71777852 {
7178
- //LA.matScale(toParent, hScale, vScale, 1);
7179
- 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);
71807858 } else
71817859 {
7182
- LA.matScale(toParent, vScale, vScale, 1);
7860
+ LA.matScale(toParent, totalScale, totalScale, 1);
71837861 }
71847862 break;
71857863 }
....@@ -7213,7 +7891,7 @@
72137891 } // NEW ...
72147892
72157893
7216
- info.pane.repaint();
7894
+ clickInfo.pane.repaint();
72177895 }
72187896
72197897 boolean overflow = false;
....@@ -7312,14 +7990,22 @@
73127990 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
73137991 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
73147992 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7993
+
7994
+ String objname;
7995
+
73157996 if (false) //parent != null)
73167997 {
7317
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7998
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
73187999 } else
73198000 {
7320
- return GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ") ")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ +System.identityHashCode(this);
8001
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
73218002 } // + super.toString();
73228003 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
8004
+
8005
+ if (!Globals.ADVANCED)
8006
+ return objname;
8007
+
8008
+ return objname + " " + System.identityHashCode(this);
73238009 }
73248010
73258011 public int hashCode()
....@@ -7375,6 +8061,7 @@
73758061 objectUI.closeUI();
73768062 if (editWindow != null)
73778063 {
8064
+ editWindow.ctrlPanel.FlushUI();
73788065 editWindow.refreshContents();
73798066 } // ? new
73808067 objectUI = null;
....@@ -7383,6 +8070,10 @@
73838070 {
73848071 editWindow = null;
73858072 } // ?
8073
+ }
8074
+ else
8075
+ {
8076
+ //editWindow.closeUI();
73868077 }
73878078 }
73888079
....@@ -7395,7 +8086,7 @@
73958086 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
73968087
73978088 Object3D /*Composite*/ parent;
7398
- Object3D /*Composite*/ fileparent;
8089
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
73998090
74008091 double[][] toParent; // dynamic matrix
74018092 double[][] fromParent;
....@@ -7510,7 +8201,7 @@
75108201 {
75118202 assert(bRep != null);
75128203 if (!(support instanceof GenericJoint)) // support.bRep != null)
7513
- GrafreeD.Assert(support.bRep == bRep.support);
8204
+ Grafreed.Assert(support.bRep == bRep.support);
75148205 }
75158206 else
75168207 {
....@@ -7541,6 +8232,10 @@
75418232 }
75428233
75438234 transient ObjEditor editWindow;
8235
+ transient ObjEditor manipWindow;
8236
+
8237
+ transient boolean pinned;
8238
+
75448239 transient ObjectUI objectUI;
75458240 public static int povDepth = 0;
75468241 private static cVector tbMin = new cVector();
....@@ -7559,9 +8254,9 @@
75598254 private static cVector edge2 = new cVector();
75608255 //private static cVector norm = new cVector();
75618256 /*transient private*/ int hitSomething;
7562
- private static final int hitCenter = 1;
7563
- private static final int hitScale = 2;
7564
- private static final int hitRotate = 3;
8257
+ static final int hitCenter = 1;
8258
+ static final int hitScale = 2;
8259
+ static final int hitRotate = 3;
75658260 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
75668261 /*transient*/ private Point centerPt;
75678262 /*transient*/ private int startX;