Normand Briere
2019-08-22 0c7b833be7d86598a6813cd1c6db0ca9e1b17966
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,245 @@
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
+ transient boolean tag;
276
+
277
+ void TagObjects(Object3D o, boolean tag)
278
+ {
279
+ if (blockloop)
280
+ return;
281
+
282
+ o.tag = tag;
283
+
284
+ if (o == this)
285
+ return;
286
+
130287 blockloop = true;
131
- child.SaveSupports();
288
+
289
+ for (int i=0; i<Size(); i++)
290
+ {
291
+ get(i).TagObjects(o, tag);
292
+ }
293
+
132294 blockloop = false;
133295 }
134
-}
135296
136
-void RestoreSupports()
137
-{
138
- if (blockloop)
139
- return;
297
+ boolean HasTags()
298
+ {
299
+ if (blockloop)
300
+ return false;
140301
141
- support = transientsupport;
142
- link2master = transientlink2master;
143
- transientsupport = null;
144
- transientlink2master = false;
145
-
146
- if (bRep != null)
147
- {
148
- bRep.RestoreSupports();
149
- }
150
-
151
- for (int i = 0; i < Size(); i++)
152
- {
153
- Object3D child = (Object3D) get(i);
154
- if (child == null)
155
- continue;
156302 blockloop = true;
157
- child.RestoreSupports();
303
+
304
+ boolean hasTags = false;
305
+
306
+ for (int i=0; i<Size(); i++)
307
+ {
308
+ hasTags |= get(i).tag || get(i).HasTags();
309
+
310
+ if (hasTags)
311
+ break;
312
+ }
313
+
314
+ blockloop = false;
315
+
316
+ return hasTags;
317
+ }
318
+
319
+ void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
320
+ {
321
+ if (!hashtable.containsKey(GetUUID()))
322
+ return;
323
+
324
+ Object3D o = hashtable.get(GetUUID());
325
+
326
+ RestoreBigData(o);
327
+
328
+ if (blockloop)
329
+ return;
330
+
331
+ blockloop = true;
332
+
333
+ //hashtable.remove(GetUUID());
334
+
335
+ for (int i=0; i<Size(); i++)
336
+ {
337
+ get(i).RestoreBigData(hashtable);
338
+ }
339
+
158340 blockloop = false;
159341 }
160
-}
342
+
343
+ void RestoreBigData(Object3D o)
344
+ {
345
+ this.bRep = o.bRep;
346
+ if (this.support != null && o.transientrep != null)
347
+ {
348
+ this.support.bRep = o.transientrep;
349
+ }
350
+
351
+ this.selection = o.selection;
352
+
353
+ this.versionlist = o.versionlist;
354
+ this.versionindex = o.versionindex;
355
+// July 2019 if (this.bRep != null)
356
+// this.bRep.support = o.transientrep;
357
+ // this.support = o.support;
358
+ // this.fileparent = o.fileparent;
359
+ }
161360
162361 // MOCAP SUPPORT
163362 double tx,ty,tz,rx,ry,rz;
....@@ -300,6 +499,8 @@
300499 }
301500
302501 boolean live = false;
502
+ transient boolean keepdontselect;
503
+ boolean dontselect = false;
303504 boolean hide = false;
304505 boolean link2master = false; // performs reset support/master at each frame
305506 boolean marked = false; // animation node
....@@ -481,12 +682,14 @@
481682 toParent = LA.newMatrix();
482683 fromParent = LA.newMatrix();
483684 }
685
+
484686 if (toParentMarked == null)
485687 {
486688 if (maxcount != 1)
487689 {
488690 new Exception().printStackTrace();
489691 }
692
+
490693 toParentMarked = LA.newMatrix();
491694 fromParentMarked = LA.newMatrix();
492695 }
....@@ -774,7 +977,7 @@
774977 if (step == 0)
775978 step = 1;
776979 if (maxcount == 0)
777
- maxcount = 2048; // 4;
980
+ maxcount = 128; // 2048; // 4;
778981 // if (acceleration == 0)
779982 // acceleration = 10;
780983 if (delay == 0) // serial
....@@ -797,7 +1000,7 @@
7971000
7981001 if (marked && Globals.isLIVE() && live &&
7991002 //TEMP21aug2018
800
- Globals.DrawMode() == iCameraPane.SHADOW &&
1003
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
8011004 currentframe != Globals.framecount)
8021005 {
8031006 currentframe = Globals.framecount;
....@@ -809,7 +1012,8 @@
8091012
8101013 boolean changedir = random && Math.random() < 0.01; // && !link2master;
8111014
812
- if (transformcount*factor > maxcount || (step == 1 && changedir))
1015
+ if (transformcount*factor >= maxcount && (rewind || random) ||
1016
+ (step == 1 && changedir))
8131017 {
8141018 countdown = 1;
8151019 delay = speedup?8:1;
....@@ -881,6 +1085,10 @@
8811085 if (material == null || material.multiply)
8821086 return true;
8831087
1088
+ if (projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
1089
+ return false;
1090
+
1091
+ // Transparent objects are dynamic because we have to sort the triangles.
8841092 return material.opacity > 0.99;
8851093 }
8861094
....@@ -912,6 +1120,11 @@
9121120 fromParent = null; // LA.newMatrix();
9131121 bRep = null; // new BoundaryRep();
9141122
1123
+ if (oname != null && oname.equals("LeftHand"))
1124
+ {
1125
+ name = oname;
1126
+ }
1127
+
9151128 /*
9161129 float hue = (float)Math.random();
9171130 Color col;
....@@ -954,7 +1167,7 @@
9541167
9551168 public Object clone()
9561169 {
957
- return GrafreeD.clone(this);
1170
+ return Grafreed.clone(this);
9581171 }
9591172
9601173 Object3D copyExpand()
....@@ -1276,6 +1489,7 @@
12761489 toParent = LA.newMatrix();
12771490 fromParent = LA.newMatrix();
12781491 }
1492
+
12791493 LA.matCopy(other.toParent, toParent);
12801494 LA.matCopy(other.fromParent, fromParent);
12811495
....@@ -1470,7 +1684,7 @@
14701684 BoundaryRep.SEUIL = other.material.cameralight;
14711685
14721686 // Set default to 0.1
1473
- BoundaryRep.SEUIL /= 2;
1687
+ BoundaryRep.SEUIL /= 4; // 2;
14741688 System.out.println("SEUIL = " + BoundaryRep.SEUIL);
14751689 }
14761690
....@@ -1729,7 +1943,7 @@
17291943 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17301944 o.bRep = transientrep;
17311945 if (clone)
1732
- o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
1946
+ o.bRep = (BoundaryRep) Grafreed.clone(transientrep);
17331947 o.CreateMaterial();
17341948 o.SetAttributes(this, -1);
17351949 //parent
....@@ -1742,7 +1956,7 @@
17421956 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17431957 o.bRep = bRep;
17441958 if (clone)
1745
- o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
1959
+ o.bRep = (BoundaryRep) Grafreed.clone(bRep);
17461960 o.CreateMaterial();
17471961 //o.overwriteThis(this, -1);
17481962 o.SetAttributes(this, -1);
....@@ -1829,12 +2043,15 @@
18292043 if (obj.name == null)
18302044 continue; // can't be a null one
18312045
2046
+ // Try perfect match first.
18322047 if (n.equals(obj.name))
18332048 {
18342049 theobj = obj;
18352050 count++;
18362051 }
18372052 }
2053
+
2054
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18382055
18392056 if (count != 1)
18402057 for (int i=Size(); --i>=0;)
....@@ -2294,12 +2511,22 @@
22942511 }
22952512 */
22962513 }
2514
+ else
2515
+ {
2516
+ //((ObjEditor)editWindow).SetupUI2(null);
2517
+ if (objectUI != null)
2518
+ ((ObjEditor)objectUI).pinButton.setSelected(pinned);
2519
+ else
2520
+ //new Exception().printStackTrace();
2521
+ System.err.println("objectUI is null");
2522
+ }
22972523 }
22982524
22992525 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
23002526 {
23012527 if (newWindow)
23022528 {
2529
+ new Exception().printStackTrace();
23032530 System.exit(0);
23042531 if (parent != null)
23052532 {
....@@ -2334,6 +2561,14 @@
23342561 {
23352562 editWindow.refreshContents();
23362563 }
2564
+ else
2565
+ {
2566
+ if (manipWindow != null)
2567
+ {
2568
+ manipWindow.refreshContents();
2569
+ }
2570
+ }
2571
+
23372572 //if (parent != null)
23382573 //parent.refreshEditWindow();
23392574 }
....@@ -2413,7 +2648,8 @@
24132648 private static final int editSelf = 1;
24142649 private static final int editChild = 2;
24152650
2416
- void drawEditHandles(ClickInfo info, int level)
2651
+ void drawEditHandles(//ClickInfo info,
2652
+ int level)
24172653 {
24182654 if (level == 0)
24192655 {
....@@ -2421,7 +2657,8 @@
24212657 return;
24222658
24232659 Object3D selectee;
2424
- for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(info, level + 1))
2660
+ for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(//info,
2661
+ level + 1))
24252662 {
24262663 selectee = (Object3D) e.nextElement();
24272664 }
....@@ -2429,19 +2666,22 @@
24292666 } else
24302667 {
24312668 //super.
2432
- drawEditHandles0(info, level + 1);
2669
+ drawEditHandles0(//info,
2670
+ level + 1);
24332671 }
24342672 }
24352673
2436
- boolean doEditClick(ClickInfo info, int level)
2674
+ boolean doEditClick(//ClickInfo info,
2675
+ int level)
24372676 {
24382677 doSomething = 0;
24392678 if (level == 0)
24402679 {
2441
- return doParentClick(info);
2680
+ return doParentClick(); //info);
24422681 }
24432682 if (//super.
2444
- doEditClick0(info, level))
2683
+ doEditClick0(//info,
2684
+ level))
24452685 {
24462686 doSomething = 1;
24472687 return true;
....@@ -2451,7 +2691,7 @@
24512691 }
24522692 }
24532693
2454
- boolean doParentClick(ClickInfo info)
2694
+ boolean doParentClick() //ClickInfo info)
24552695 {
24562696 if (selection == null)
24572697 {
....@@ -2464,7 +2704,8 @@
24642704 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
24652705 {
24662706 Object3D selectee = (Object3D) e.nextElement();
2467
- if (selectee.doEditClick(info, 1))
2707
+ if (selectee.doEditClick(//info,
2708
+ 1))
24682709 {
24692710 childToDrag = selectee;
24702711 doSomething = 2;
....@@ -2476,13 +2717,15 @@
24762717 return retval;
24772718 }
24782719
2479
- void doEditDrag(ClickInfo info)
2720
+ void doEditDrag(//ClickInfo clickInfo,
2721
+ boolean opposite)
24802722 {
24812723 switch (doSomething)
24822724 {
24832725 case 1: // '\001'
24842726 //super.
2485
- doEditDrag0(info);
2727
+ doEditDrag0(//clickInfo,
2728
+ opposite);
24862729 break;
24872730
24882731 case 2: // '\002'
....@@ -2495,11 +2738,13 @@
24952738 {
24962739 //sel.hitSomething = childToDrag.hitSomething;
24972740 //childToDrag.doEditDrag(info);
2498
- sel.doEditDrag(info);
2741
+ sel.doEditDrag(//clickInfo,
2742
+ opposite);
24992743 } else
25002744 {
25012745 //super.
2502
- doEditDrag0(info);
2746
+ doEditDrag0(//clickInfo,
2747
+ opposite);
25032748 }
25042749 }
25052750 break;
....@@ -2517,6 +2762,9 @@
25172762 {
25182763 deselectAll();
25192764 }
2765
+
2766
+ new Exception().printStackTrace();
2767
+
25202768 ClickInfo newInfo = new ClickInfo();
25212769 newInfo.flags = info.flags;
25222770 newInfo.bounds = info.bounds;
....@@ -2609,6 +2857,18 @@
26092857 void GenNormalsS(boolean crease)
26102858 {
26112859 selection.GenNormals(crease);
2860
+// for (int i=0; i<selection.size(); i++)
2861
+// {
2862
+// Object3D selectee = (Object3D) selection.elementAt(i);
2863
+// selectee.GenNormals(crease);
2864
+// }
2865
+
2866
+ //Touch();
2867
+ }
2868
+
2869
+ void GenNormalsMeshS()
2870
+ {
2871
+ selection.GenNormalsMesh();
26122872 // for (int i=0; i<selection.size(); i++)
26132873 // {
26142874 // Object3D selectee = (Object3D) selection.elementAt(i);
....@@ -2749,6 +3009,24 @@
27493009 if (child == null)
27503010 continue;
27513011 child.GenNormals(crease);
3012
+// Children().release(i);
3013
+ }
3014
+ blockloop = false;
3015
+ }
3016
+
3017
+ void GenNormalsMesh()
3018
+ {
3019
+ if (blockloop)
3020
+ return;
3021
+
3022
+ blockloop = true;
3023
+ GenNormalsMesh0();
3024
+ for (int i = 0; i < Children().Size(); i++)
3025
+ {
3026
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
3027
+ if (child == null)
3028
+ continue;
3029
+ child.GenNormalsMesh();
27523030 // Children().release(i);
27533031 }
27543032 blockloop = false;
....@@ -2906,7 +3184,8 @@
29063184 {
29073185 if (bRep != null)
29083186 {
2909
- bRep.GenUV();
3187
+ bRep.GenUV(); //1);
3188
+ //bRep.UnfoldUV();
29103189 Touch();
29113190 }
29123191 }
....@@ -2920,11 +3199,20 @@
29203199 }
29213200 }
29223201
3202
+ void GenNormalsMesh0()
3203
+ {
3204
+ if (bRep != null)
3205
+ {
3206
+ bRep.GenerateNormalsMesh();
3207
+ Touch();
3208
+ }
3209
+ }
3210
+
29233211 void GenNormalsMINE0()
29243212 {
29253213 if (bRep != null)
29263214 {
2927
- bRep.GenerateNormalsMINE();
3215
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
29283216 Touch();
29293217 }
29303218 }
....@@ -2981,6 +3269,33 @@
29813269 blockloop = false;
29823270 }
29833271
3272
+ void TransformChildren()
3273
+ {
3274
+ if (toParent != null)
3275
+ {
3276
+ for (int i=Size(); --i>=0;)
3277
+ {
3278
+ Object3D v = get(i);
3279
+
3280
+ if (v.toParent == null)
3281
+ {
3282
+ v.toParent = LA.newMatrix();
3283
+ v.fromParent = LA.newMatrix();
3284
+ }
3285
+
3286
+// LA.matConcat(v.toParent, toParent, v.toParent);
3287
+// LA.matConcat(fromParent, v.fromParent, v.fromParent);
3288
+ LA.matConcat(toParent, v.toParent, v.toParent);
3289
+ LA.matConcat(v.fromParent, fromParent, v.fromParent);
3290
+ }
3291
+
3292
+ toParent = null; // LA.matIdentity(toParent);
3293
+ fromParent = null; // LA.matIdentity(fromParent);
3294
+
3295
+ Touch();
3296
+ }
3297
+ }
3298
+
29843299 void TransformGeometry()
29853300 {
29863301 Object3D obj = this;
....@@ -3202,9 +3517,11 @@
32023517
32033518 BoundaryRep sup = bRep.support;
32043519 bRep.support = null;
3205
- BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
3520
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
32063521 // bRep.SplitInTwo(onlyone); // thread...
3207
- temprep.SplitInTwo(reduction34, onlyone);
3522
+
3523
+ while(temprep.SplitInTwo(reduction34, onlyone));
3524
+
32083525 bRep = temprep;
32093526 bRep.support = sup;
32103527 Touch();
....@@ -3305,15 +3622,47 @@
33053622
33063623 void ClearMaterials()
33073624 {
3625
+ if (blockloop)
3626
+ return;
3627
+
3628
+ blockloop = true;
3629
+
33083630 ClearMaterial();
3309
- for (int i = 0; i < size(); i++)
3631
+ for (int i = 0; i < Size(); i++)
33103632 {
3311
- Object3D child = (Object3D) reserve(i);
3633
+ Object3D child = (Object3D) get(i);
33123634 if (child == null)
33133635 continue;
33143636 child.ClearMaterials();
3315
- release(i);
33163637 }
3638
+
3639
+ blockloop = false;
3640
+ }
3641
+
3642
+ void ClearVersionList()
3643
+ {
3644
+ this.versionlist = null;
3645
+ this.versionindex = -1;
3646
+ this.versiontable = null;
3647
+ }
3648
+
3649
+ void ClearVersions()
3650
+ {
3651
+ if (blockloop)
3652
+ return;
3653
+
3654
+ blockloop = true;
3655
+
3656
+ ClearVersionList();
3657
+ for (int i = 0; i < Size(); i++)
3658
+ {
3659
+ Object3D child = (Object3D) get(i);
3660
+ if (child == null)
3661
+ continue;
3662
+ child.ClearVersions();
3663
+ }
3664
+
3665
+ blockloop = false;
33173666 }
33183667
33193668 void FlipV(boolean flip)
....@@ -3341,7 +3690,8 @@
33413690 if (blockloop)
33423691 return;
33433692
3344
- if (marked || (bRep != null && material != null)) // borderline...
3693
+ if (//marked || // does not make sense
3694
+ (bRep != null || material != null)) // borderline...
33453695 live = h;
33463696
33473697 for (int i = 0; i < Size(); i++)
....@@ -3362,7 +3712,8 @@
33623712 return;
33633713
33643714 //if (bRep != null)
3365
- if (marked || (bRep != null && material != null)) // borderline...
3715
+ if (//marked || // does not make sense
3716
+ (bRep != null || material != null)) // borderline...
33663717 link2master = h;
33673718
33683719 for (int i = 0; i < Size(); i++)
....@@ -3382,7 +3733,8 @@
33823733 if (blockloop)
33833734 return;
33843735
3385
- if (marked || (bRep != null && material != null)) // borderline...
3736
+ if (//marked || // does not make sense
3737
+ (bRep != null || material != null)) // borderline...
33863738 hide = h;
33873739
33883740 for (int i = 0; i < Size(); i++)
....@@ -3402,7 +3754,7 @@
34023754 if (blockloop)
34033755 return;
34043756
3405
- if (bRep != null && material != null) // borderline...
3757
+ if (bRep != null || material != null) // borderline...
34063758 marked = h;
34073759
34083760 for (int i = 0; i < Size(); i++)
....@@ -3412,6 +3764,46 @@
34123764 continue;
34133765 blockloop = true;
34143766 child.MarkLeaves(h);
3767
+ blockloop = false;
3768
+ // release(i);
3769
+ }
3770
+ }
3771
+
3772
+ void RewindLeaves(boolean h)
3773
+ {
3774
+ if (blockloop)
3775
+ return;
3776
+
3777
+ if (bRep != null || material != null) // borderline...
3778
+ rewind = h;
3779
+
3780
+ for (int i = 0; i < Size(); i++)
3781
+ {
3782
+ Object3D child = (Object3D) get(i); // reserve(i);
3783
+ if (child == null)
3784
+ continue;
3785
+ blockloop = true;
3786
+ child.RewindLeaves(h);
3787
+ blockloop = false;
3788
+ // release(i);
3789
+ }
3790
+ }
3791
+
3792
+ void RandomLeaves(boolean h)
3793
+ {
3794
+ if (blockloop)
3795
+ return;
3796
+
3797
+ if (bRep != null || material != null) // borderline...
3798
+ random = h;
3799
+
3800
+ for (int i = 0; i < Size(); i++)
3801
+ {
3802
+ Object3D child = (Object3D) get(i); // reserve(i);
3803
+ if (child == null)
3804
+ continue;
3805
+ blockloop = true;
3806
+ child.RandomLeaves(h);
34153807 blockloop = false;
34163808 // release(i);
34173809 }
....@@ -3726,7 +4118,7 @@
37264118 if (child == null)
37274119 continue;
37284120
3729
- if (GrafreeD.RENDERME > 0)
4121
+ if (Grafreed.RENDERME > 0)
37304122 {
37314123 if (child instanceof Merge)
37324124 ((Merge)child).renderme();
....@@ -3877,7 +4269,7 @@
38774269 if (child == null)
38784270 continue;
38794271
3880
- if (GrafreeD.RENDERME > 0)
4272
+ if (Grafreed.RENDERME > 0)
38814273 {
38824274 if (child instanceof Merge)
38834275 ((Merge)child).renderme();
....@@ -4072,7 +4464,7 @@
40724464 if (child == null)
40734465 continue;
40744466
4075
- if (GrafreeD.RENDERME > 0)
4467
+ if (Grafreed.RENDERME > 0)
40764468 {
40774469 if (child instanceof Merge)
40784470 ((Merge)child).renderme();
....@@ -4185,6 +4577,55 @@
41854577 {
41864578 blockloop = true;
41874579 get(i).RepairShadow();
4580
+ blockloop = false;
4581
+ }
4582
+ }
4583
+
4584
+ void RepairSOV()
4585
+ {
4586
+ if (blockloop)
4587
+ return;
4588
+
4589
+ String texname = this.GetPigmentTexture();
4590
+
4591
+ if (texname.startsWith("sov"))
4592
+ {
4593
+ String[] s = texname.split("/");
4594
+
4595
+ String[] sname = s[1].split("Color.pn");
4596
+
4597
+ texname = sname[0];
4598
+
4599
+ if (sname.length > 1)
4600
+ {
4601
+ texname += "Color.jpg";
4602
+ }
4603
+
4604
+ this.SetPigmentTexture("sov/" + texname);
4605
+ }
4606
+
4607
+ texname = this.GetBumpTexture();
4608
+
4609
+ if (texname.startsWith("sov"))
4610
+ {
4611
+ String[] s = texname.split("/");
4612
+
4613
+ String[] sname = s[1].split("Bump.pn");
4614
+
4615
+ texname = sname[0];
4616
+
4617
+ if (sname.length > 1)
4618
+ {
4619
+ texname += "Bump.jpg";
4620
+ }
4621
+
4622
+ this.SetBumpTexture("sov/" + texname);
4623
+ }
4624
+
4625
+ for (int i=0; i<Size(); i++)
4626
+ {
4627
+ blockloop = true;
4628
+ get(i).RepairSOV();
41884629 blockloop = false;
41894630 }
41904631 }
....@@ -4679,7 +5120,7 @@
46795120
46805121 cTreePath SelectLeaf(int indexcount, boolean deselect)
46815122 {
4682
- if (hide)
5123
+ if (hide || dontselect)
46835124 return null;
46845125
46855126 if (count <= 0)
....@@ -4703,9 +5144,17 @@
47035144 }
47045145 }
47055146
5147
+ ObjEditor GetWindow()
5148
+ {
5149
+ if (editWindow != null)
5150
+ return editWindow;
5151
+
5152
+ return manipWindow;
5153
+ }
5154
+
47065155 cTreePath Select(int indexcount, boolean deselect)
47075156 {
4708
- if (hide)
5157
+ if (hide || dontselect)
47095158 return null;
47105159
47115160 if (count <= 0)
....@@ -4739,10 +5188,11 @@
47395188 if (leaf != null)
47405189 {
47415190 cTreePath tp = new cTreePath(this, leaf);
4742
- if (editWindow != null)
5191
+ ObjEditor window = GetWindow();
5192
+ if (window != null)
47435193 {
47445194 //System.out.println("editWindow = " + editWindow + " vs " + this);
4745
- editWindow.Select(tp, deselect, true);
5195
+ window.Select(tp, deselect, true);
47465196 }
47475197
47485198 return tp;
....@@ -4759,6 +5209,7 @@
47595209
47605210 if (child == null)
47615211 continue;
5212
+
47625213 if (child.HasTransparency() && child.size() != 0)
47635214 {
47645215 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4768,9 +5219,10 @@
47685219 if (leaf != null)
47695220 {
47705221 cTreePath tp = new cTreePath(this, leaf);
4771
- if (editWindow != null)
5222
+ ObjEditor window = GetWindow();
5223
+ if (window != null)
47725224 {
4773
- editWindow.Select(tp, deselect, true);
5225
+ window.Select(tp, deselect, true);
47745226 }
47755227
47765228 return tp;
....@@ -5095,6 +5547,51 @@
50955547 blockloop = false;
50965548 }
50975549
5550
+ void ResetSelectable()
5551
+ {
5552
+ if (blockloop)
5553
+ return;
5554
+
5555
+ blockloop = true;
5556
+
5557
+ keepdontselect = dontselect;
5558
+ dontselect = true;
5559
+
5560
+ Object3D child;
5561
+ int nb = Size();
5562
+ for (int i = 0; i < nb; i++)
5563
+ {
5564
+ child = (Object3D) get(i);
5565
+ if (child == null)
5566
+ continue;
5567
+ child.ResetSelectable();
5568
+ }
5569
+
5570
+ blockloop = false;
5571
+ }
5572
+
5573
+ void RestoreSelectable()
5574
+ {
5575
+ if (blockloop)
5576
+ return;
5577
+
5578
+ blockloop = true;
5579
+
5580
+ dontselect = keepdontselect;
5581
+
5582
+ Object3D child;
5583
+ int nb = Size();
5584
+ for (int i = 0; i < nb; i++)
5585
+ {
5586
+ child = (Object3D) get(i);
5587
+ if (child == null)
5588
+ continue;
5589
+ child.RestoreSelectable();
5590
+ }
5591
+
5592
+ blockloop = false;
5593
+ }
5594
+
50985595 boolean IsSelected()
50995596 {
51005597 if (parent == null)
....@@ -5155,12 +5652,41 @@
51555652 if (fullname == null)
51565653 return "";
51575654
5655
+ if (fullname.pigment != null)
5656
+ {
5657
+ return fullname.pigment;
5658
+ }
5659
+
51585660 // System.out.println("Fullname = " + fullname);
51595661
5160
- if (fullname.name.indexOf(":") == -1)
5161
- return fullname.name;
5662
+ // Does not work on Windows due to C:
5663
+// if (fullname.name.indexOf(":") == -1)
5664
+// return fullname.name;
5665
+//
5666
+// return fullname.name.substring(0,fullname.name.indexOf(":"));
51625667
5163
- return fullname.name.substring(0,fullname.name.indexOf(":"));
5668
+ String[] split = fullname.name.split(":");
5669
+
5670
+ if (split.length == 0)
5671
+ {
5672
+ return fullname.pigment = "";
5673
+ }
5674
+
5675
+ if (split.length <= 2)
5676
+ {
5677
+ if (fullname.name.endsWith(":"))
5678
+ {
5679
+ // Windows
5680
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
5681
+ }
5682
+
5683
+ return fullname.pigment = split[0];
5684
+ }
5685
+
5686
+ // Windows
5687
+ assert(split.length == 4);
5688
+
5689
+ return fullname.pigment = split[0] + ":" + split[1];
51645690 }
51655691
51665692 static String GetBump(cTexture fullname)
....@@ -5168,11 +5694,44 @@
51685694 if (fullname == null)
51695695 return "";
51705696
5697
+ if (fullname.bump != null)
5698
+ {
5699
+ return fullname.bump;
5700
+ }
5701
+
51715702 // 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());
5703
+ // Does not work on Windows due to C:
5704
+// if (fullname.name.indexOf(":") == -1)
5705
+// return "";
5706
+//
5707
+// return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5708
+ String[] split = fullname.name.split(":");
5709
+
5710
+ if (split.length == 0)
5711
+ {
5712
+ return fullname.bump = "";
5713
+ }
5714
+
5715
+ if (split.length == 1)
5716
+ {
5717
+ return fullname.bump = "";
5718
+ }
5719
+
5720
+ if (split.length == 2)
5721
+ {
5722
+ if (fullname.name.endsWith(":"))
5723
+ {
5724
+ // Windows
5725
+ return fullname.bump = "";
5726
+ }
5727
+
5728
+ return fullname.bump = split[1];
5729
+ }
5730
+
5731
+ // Windows
5732
+ assert(split.length == 4);
5733
+
5734
+ return fullname.bump = split[2] + ":" + split[3];
51765735 }
51775736
51785737 String GetPigmentTexture()
....@@ -5246,7 +5805,7 @@
52465805 System.out.print("; textures = " + textures);
52475806 System.out.println("; usedtextures = " + usedtextures);
52485807
5249
- if (GetTextures() == null)
5808
+ if (GetTextures() == null) // What is that??
52505809 GetTextures().name = ":";
52515810
52525811 String texname = tex;
....@@ -5255,6 +5814,9 @@
52555814 texname = "";
52565815
52575816 GetTextures().name = texname + ":" + GetBump(GetTextures());
5817
+
5818
+ GetTextures().pigment = null;
5819
+
52585820 Touch();
52595821 }
52605822
....@@ -5279,6 +5841,43 @@
52795841 }
52805842 }
52815843
5844
+ UUID GetUUID()
5845
+ {
5846
+ if (uuid == null)
5847
+ {
5848
+ // Serial
5849
+ uuid = UUID.randomUUID();
5850
+ }
5851
+
5852
+ return uuid;
5853
+ }
5854
+
5855
+ Object3D GetObject(UUID uid)
5856
+ {
5857
+ if (blockloop)
5858
+ return null;
5859
+
5860
+ if (GetUUID().equals(uid))
5861
+ return this;
5862
+
5863
+ int nb = Size();
5864
+ for (int i = 0; i < nb; i++)
5865
+ {
5866
+ Object3D child = (Object3D) get(i);
5867
+
5868
+ if (child == null)
5869
+ continue;
5870
+
5871
+ blockloop = true;
5872
+ Object3D obj = child.GetObject(uid);
5873
+ blockloop = false;
5874
+ if (obj != null)
5875
+ return obj;
5876
+ }
5877
+
5878
+ return null;
5879
+ }
5880
+
52825881 void SetBumpTexture(String tex)
52835882 {
52845883 if (GetTextures() == null)
....@@ -5290,6 +5889,8 @@
52905889 texname = "";
52915890
52925891 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
5892
+
5893
+ GetTextures().bump = null;
52935894
52945895 Touch();
52955896 }
....@@ -5315,6 +5916,38 @@
53155916 }
53165917 }
53175918
5919
+ void EmbedTextures(boolean embed)
5920
+ {
5921
+ if (blockloop)
5922
+ return;
5923
+
5924
+ //if (GetTextures() != null)
5925
+ if (embed)
5926
+ CameraPane.EmbedTextures(GetTextures());
5927
+ else
5928
+ {
5929
+ GetTextures().pigmentdata = null;
5930
+ GetTextures().bumpdata = null;
5931
+ GetTextures().pw = 0;
5932
+ GetTextures().ph = 0;
5933
+ GetTextures().bw = 0;
5934
+ GetTextures().bh = 0;
5935
+ }
5936
+
5937
+ int nb = Size();
5938
+ for (int i = 0; i < nb; i++)
5939
+ {
5940
+ Object3D child = (Object3D) get(i);
5941
+
5942
+ if (child == null)
5943
+ continue;
5944
+
5945
+ blockloop = true;
5946
+ child.EmbedTextures(embed);
5947
+ blockloop = false;
5948
+ }
5949
+ }
5950
+
53185951 void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
53195952 {
53205953 Draw(display, root, selected, blocked);
....@@ -5323,12 +5956,23 @@
53235956 boolean NeedSupport()
53245957 {
53255958 return
5326
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5959
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
53275960 // PROBLEM with CROWD!!
5328
- && (Globals.DrawMode() == iCameraPane.SHADOW || Globals.CROWD);
5961
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
53295962 }
53305963
53315964 static boolean DEBUG_SELECTION = false;
5965
+
5966
+ boolean IsLive()
5967
+ {
5968
+ if (live)
5969
+ return true;
5970
+
5971
+ if (parent == null)
5972
+ return false;
5973
+
5974
+ return parent.IsLive();
5975
+ }
53325976
53335977 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
53345978 {
....@@ -5340,7 +5984,7 @@
53405984 }
53415985
53425986 if (display.DrawMode() == iCameraPane.SELECTION &&
5343
- hide)
5987
+ (hide || dontselect))
53445988 return;
53455989
53465990 if (name != null && name.contains("sclera"))
....@@ -5390,8 +6034,10 @@
53906034 if (support != null)
53916035 support = support;
53926036
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);
6037
+ boolean usecalllists = !IsLive() && IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
6038
+ //boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
6039
+
6040
+ //usecalllists &= display.DrawMode() == display.DEFAULT; // Don't compute list in shadow pass.
53956041
53966042 if (!usecalllists && bRep != null && bRep.displaylist > 0)
53976043 {
....@@ -5401,8 +6047,9 @@
54016047 // usecalllists &= !(parent instanceof RandomNode);
54026048 // usecalllists = false;
54036049
5404
- if (GetBRep() != null)
5405
- usecalllists = usecalllists;
6050
+ if (display.DrawMode() == display.SHADOW)
6051
+ //GetBRep() != null)
6052
+ usecalllists = !!usecalllists;
54066053 //System.out.println("draw " + this);
54076054 //new Exception().printStackTrace();
54086055
....@@ -5411,10 +6058,12 @@
54116058 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
54126059
54136060 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5414
- (touched || (bRep != null && bRep.displaylist <= 0)))
6061
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
6062
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
54156063 {
54166064 Globals.lighttouched = true;
54176065 } // all panes...
6066
+
54186067 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
54196068 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
54206069 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5422,7 +6071,7 @@
54226071 if (!(this instanceof Composite))
54236072 touched = false;
54246073 //if (displaylist == -1 && usecalllists)
5425
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
6074
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
54266075 {
54276076 bRep.displaylist = display.GenList();
54286077 assert(bRep.displaylist != 0);
....@@ -5433,7 +6082,7 @@
54336082
54346083 //System.out.println("\tnew list " + list);
54356084 //gl.glDrawBuffer(gl.GL_NONE);
5436
- if (usecalllists)
6085
+ if (usecalllists && bRep.displaylist > 0)
54376086 {
54386087 // System.err.println("new list " + bRep.displaylist + " for " + this);
54396088 display.NewList(bRep.displaylist);
....@@ -5442,7 +6091,7 @@
54426091 CallList(display, root, selected, blocked);
54436092
54446093 // compiled = true;
5445
- if (usecalllists)
6094
+ if (usecalllists && bRep.displaylist > 0)
54466095 {
54476096 // System.err.println("end list " + bRep.displaylist + " for " + this);
54486097 display.EndList();
....@@ -5542,6 +6191,7 @@
55426191 if (GetBRep() != null)
55436192 {
55446193 display.NextIndex();
6194
+
55456195 // vertex color conflict : gl.glCallList(list);
55466196 DrawNode(display, root, selected);
55476197 if (this instanceof BezierPatch)
....@@ -5582,7 +6232,28 @@
55826232 tex = GetTextures();
55836233 }
55846234
5585
- display.BindTextures(tex, texres);
6235
+ boolean failedPigment = false;
6236
+ boolean failedBump = false;
6237
+
6238
+ try
6239
+ {
6240
+ display.BindPigmentTexture(tex, texres);
6241
+ }
6242
+ catch (Exception e)
6243
+ {
6244
+ System.err.println("FAILED: " + this);
6245
+ failedPigment = true;
6246
+ }
6247
+
6248
+ try
6249
+ {
6250
+ display.BindBumpTexture(tex, texres);
6251
+ }
6252
+ catch (Exception e)
6253
+ {
6254
+ //System.err.println("FAILED: " + this);
6255
+ failedBump = true;
6256
+ }
55866257
55876258 if (!compiled)
55886259 {
....@@ -5604,7 +6275,11 @@
56046275 }
56056276 }
56066277
5607
- display.ReleaseTextures(tex);
6278
+ if (!failedBump)
6279
+ display.ReleaseBumpTexture(tex);
6280
+
6281
+ if (!failedPigment)
6282
+ display.ReleasePigmentTexture(tex);
56086283
56096284 display.PopMaterial(this, selected);
56106285 }
....@@ -5733,6 +6408,9 @@
57336408
57346409 void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57356410 {
6411
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6412
+ return;
6413
+
57366414 if (hide)
57376415 return;
57386416 // shadow optimisation
....@@ -5858,6 +6536,9 @@
58586536 if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
58596537 return; // no shadow for transparent objects
58606538
6539
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6540
+ return;
6541
+
58616542 if (hide)
58626543 return;
58636544
....@@ -5898,6 +6579,7 @@
58986579 return;
58996580 }
59006581
6582
+ //bRep.GenUV(1/material.diffuseness);
59016583 // bRep.lock = true;
59026584
59036585 //javax.media.opengl.GL gl = display.GetGL();
....@@ -5970,6 +6652,11 @@
59706652 // dec 2012
59716653 new Exception().printStackTrace();
59726654 return;
6655
+ }
6656
+
6657
+ if (dontselect)
6658
+ {
6659
+ //bRep.GenerateNormalsMINE();
59736660 }
59746661
59756662 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -6755,20 +7442,23 @@
67557442 }
67567443 }
67577444
6758
- protected void calcHotSpot(cVector in, ClickInfo info, Point outPt, Rectangle outRec)
7445
+ static ClickInfo clickInfo = new ClickInfo();
7446
+
7447
+ protected void calcHotSpot(cVector in, //ClickInfo clickInfo,
7448
+ Point outPt, Rectangle outRec)
67597449 {
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;
7450
+ int hc = clickInfo.bounds.x + clickInfo.bounds.width / 2;
7451
+ int vc = clickInfo.bounds.y + clickInfo.bounds.height / 2;
7452
+ double[][] toscreen = clickInfo.toScreen;
67637453 if (toscreen == null)
67647454 {
6765
- toscreen = new Camera(info.camera.viewCode).toScreen;
7455
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
67667456 }
67677457 cVector vec = in;
67687458 LA.xformPos(in, toscreen, in);
67697459 //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();
7460
+ vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
7461
+ vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
67727462 outPt.x = hc + (int) vec.x;
67737463 outPt.y = vc - (int) vec.y;
67747464 outRec.x = outPt.x - 3;
....@@ -6776,15 +7466,18 @@
67767466 outRec.width = outRec.height = 6;
67777467 }
67787468
6779
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7469
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7470
+ )
67807471 {
67817472 Point pt = new Point(0, 0);
67827473 Rectangle rec = new Rectangle();
6783
- calcHotSpot(in, info, pt, rec);
7474
+ calcHotSpot(in, //clickInfo,
7475
+ pt, rec);
67847476 return rec;
67857477 }
67867478
6787
- void drawEditHandles0(ClickInfo info, int level)
7479
+ void drawEditHandles0(//ClickInfo clickInfo,
7480
+ int level)
67887481 {
67897482 if (level == 0)
67907483 {
....@@ -6793,16 +7486,19 @@
67937486 {
67947487 cVector origin = new cVector();
67957488 //LA.xformPos(origin, toParent, origin);
6796
- Rectangle spot = calcHotSpot(origin, info);
7489
+ if (this.clickInfo == null)
7490
+ this.clickInfo = new ClickInfo();
7491
+
7492
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
67977493 Rectangle boundary = new Rectangle();
67987494 boundary.x = spot.x - 30;
67997495 boundary.y = spot.y - 30;
68007496 boundary.width = spot.width + 60;
68017497 boundary.height = spot.height + 60;
6802
- info.g.setColor(Color.red);
7498
+ clickInfo.g.setColor(Color.white);
68037499 int spotw = spot.x + spot.width;
68047500 int spoth = spot.y + spot.height;
6805
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7501
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
68067502 // if (CameraPane.Xmin > spot.x)
68077503 // {
68087504 // CameraPane.Xmin = spot.x;
....@@ -6819,11 +7515,33 @@
68197515 // {
68207516 // CameraPane.Ymax = spoth;
68217517 // }
6822
- spot.translate(32, 32);
7518
+// if (CameraPane.Xmin > spot.x)
7519
+// {
7520
+// CameraPane.Xmin = spot.x;
7521
+// }
7522
+// if (CameraPane.Xmax < spotw)
7523
+// {
7524
+// CameraPane.Xmax = spotw;
7525
+// }
7526
+// if (CameraPane.Ymin > spot.y)
7527
+// {
7528
+// CameraPane.Ymin = spot.y;
7529
+// }
7530
+// if (CameraPane.Ymax < spoth)
7531
+// {
7532
+// CameraPane.Ymax = spoth;
7533
+// }
7534
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7535
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
7536
+ spot.translate(32, 0);
7537
+ clickInfo.g.setColor(Color.yellow);
7538
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7539
+
7540
+ spot.translate(32, 64);
68237541 spotw = spot.x + spot.width;
68247542 spoth = spot.y + spot.height;
6825
- info.g.setColor(Color.blue);
6826
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7543
+ clickInfo.g.setColor(Color.cyan);
7544
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
68277545 // if (CameraPane.Xmin > spot.x)
68287546 // {
68297547 // CameraPane.Xmin = spot.x;
....@@ -6840,29 +7558,9 @@
68407558 // {
68417559 // CameraPane.Ymax = spoth;
68427560 // }
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);
7561
+ clickInfo.g.setColor(Color.green);
7562
+ clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
7563
+ (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
68667564 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
68677565 // if (CameraPane.Xmin > boundary.x)
68687566 // {
....@@ -6884,7 +7582,8 @@
68847582 }
68857583 }
68867584
6887
- boolean doEditClick0(ClickInfo info, int level)
7585
+ boolean doEditClick0(//ClickInfo clickInfo,
7586
+ int level)
68887587 {
68897588 if (level == 0)
68907589 {
....@@ -6893,10 +7592,10 @@
68937592
68947593 boolean retval = false;
68957594
6896
- startX = info.x;
6897
- startY = info.y;
7595
+ startX = clickInfo.x;
7596
+ startY = clickInfo.y;
68987597
6899
- hitSomething = 0;
7598
+ hitSomething = -1;
69007599 cVector origin = new cVector();
69017600 //LA.xformPos(origin, toParent, origin);
69027601 Rectangle spot = new Rectangle();
....@@ -6904,22 +7603,53 @@
69047603 {
69057604 centerPt = new Point(0, 0);
69067605 }
6907
- calcHotSpot(origin, info, centerPt, spot);
6908
- if (spot.contains(info.x, info.y))
7606
+ calcHotSpot(origin, //info,
7607
+ centerPt, spot);
7608
+ if (spot.contains(clickInfo.x, clickInfo.y))
69097609 {
69107610 hitSomething = hitCenter;
69117611 retval = true;
69127612 }
69137613 spot.translate(32, 0);
6914
- if (spot.contains(info.x, info.y))
7614
+ if (spot.contains(clickInfo.x, clickInfo.y))
69157615 {
69167616 hitSomething = hitRotate;
69177617 retval = true;
69187618 }
69197619 spot.translate(0, 32);
6920
- if (spot.contains(info.x, info.y))
7620
+ spot.translate(32, 0);
7621
+ spot.translate(0, 32);
7622
+ if (spot.contains(clickInfo.x, clickInfo.y))
69217623 {
69227624 hitSomething = hitScale;
7625
+
7626
+ double scale = 0.005f * clickInfo.camera.Distance();
7627
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
7628
+ double sign = 1;
7629
+ if (hScale < 0)
7630
+ {
7631
+ sign = -1;
7632
+ }
7633
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
7634
+ if (hScale < 0.01)
7635
+ {
7636
+ //hScale = 0.01;
7637
+ }
7638
+
7639
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
7640
+ sign = 1;
7641
+ if (vScale < 0)
7642
+ {
7643
+ sign = -1;
7644
+ }
7645
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
7646
+ if (vScale < 0.01)
7647
+ {
7648
+ //vScale = 0.01;
7649
+ }
7650
+
7651
+ clickInfo.scale = Math.sqrt(hScale*hScale + vScale*vScale);
7652
+
69237653 retval = true;
69247654 }
69257655
....@@ -6929,7 +7659,7 @@
69297659 }
69307660
69317661 //System.out.println("info.modifiers = " + info.modifiers);
6932
- modified = (info.modifiers & CameraPane.META) != 0;
7662
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
69337663 //System.out.println("modified = " + modified);
69347664 //new Exception().printStackTrace();
69357665 //viewCode = info.pane.renderCamera.viewCode;
....@@ -6957,7 +7687,8 @@
69577687 return true;
69587688 }
69597689
6960
- void doEditDrag0(ClickInfo info)
7690
+ void doEditDrag0(//ClickInfo info,
7691
+ boolean opposite)
69617692 {
69627693 if (hitSomething == 0)
69637694 {
....@@ -6971,7 +7702,8 @@
69717702
69727703 //System.out.println("hitSomething = " + hitSomething);
69737704
6974
- double scale = 0.005f * info.camera.Distance();
7705
+ double scale = 0.005f * clickInfo.camera.Distance();
7706
+
69757707 cVector xlate = new cVector();
69767708 //cVector xlate2 = new cVector();
69777709 switch (hitSomething)
....@@ -6984,7 +7716,7 @@
69847716
69857717 scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
69867718
6987
- if (modified)
7719
+ if (modified || opposite)
69887720 {
69897721 //assert(false);
69907722 /*
....@@ -7004,8 +7736,8 @@
70047736 toParent[3][i] = xlate.get(i);
70057737 LA.matInvert(toParent, fromParent);
70067738 */
7007
- cVector delta = LA.newVector(0, 0, startY - info.y);
7008
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7739
+ cVector delta = LA.newVector(0, 0, startY - clickInfo.y);
7740
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
70097741
70107742 LA.matCopy(startMat, toParent);
70117743 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7014,7 +7746,7 @@
70147746 } else
70157747 {
70167748 //LA.xformDir(delta, info.camera.fromScreen, delta);
7017
- cVector up = new cVector(info.camera.up);
7749
+ cVector up = new cVector(clickInfo.camera.up);
70187750 cVector away = new cVector();
70197751 //cVector right2 = new cVector();
70207752 //LA.vecCross(up, cVector.Z, right);
....@@ -7031,19 +7763,19 @@
70317763 LA.xformDir(up, ClickInfo.matbuffer, up);
70327764 // if (!CameraPane.LOCALTRANSFORM)
70337765 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7034
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7766
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
70357767 // if (!CameraPane.LOCALTRANSFORM)
70367768 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
70377769 //LA.vecCross(up, cVector.Z, right2);
70387770
7039
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7771
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
70407772
70417773 //System.out.println("DELTA0 = " + delta);
70427774 //System.out.println("AWAY = " + info.camera.away);
70437775 //System.out.println("UP = " + info.camera.up);
70447776 if (away.z > 0)
70457777 {
7046
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7778
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
70477779 {
70487780 delta.x = -delta.x;
70497781 } else
....@@ -7058,7 +7790,7 @@
70587790 //System.out.println("DELTA1 = " + delta);
70597791 LA.xformDir(delta, ClickInfo.matbuffer, delta);
70607792 //System.out.println("DELTA2 = " + delta);
7061
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7793
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
70627794 LA.matCopy(startMat, toParent);
70637795 //System.out.println("DELTA3 = " + delta);
70647796 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7068,8 +7800,8 @@
70687800 break;
70697801
70707802 case hitRotate: // rotate
7071
- int dx = info.x - centerPt.x;
7072
- int dy = -(info.y - centerPt.y);
7803
+ int dx = clickInfo.x - centerPt.x;
7804
+ int dy = -(clickInfo.y - centerPt.y);
70737805 double angle = (double) Math.atan2(dx, dy);
70747806 angle = -(1.570796 - angle);
70757807
....@@ -7078,6 +7810,7 @@
70787810
70797811 if (modified)
70807812 {
7813
+ // Rotate 90 degrees
70817814 angle /= (Math.PI / 4);
70827815 angle = Math.floor(angle + 0.5);
70837816 angle *= (Math.PI / 4);
....@@ -7091,7 +7824,7 @@
70917824 }
70927825 /**/
70937826
7094
- switch (info.pane.RenderCamera().viewCode)
7827
+ switch (clickInfo.pane.RenderCamera().viewCode)
70957828 {
70967829 case 1: // '\001'
70977830 LA.matZRotate(toParent, angle);
....@@ -7118,26 +7851,30 @@
71187851 break;
71197852
71207853 case hitScale: // scale
7121
- double hScale = (double) (info.x - centerPt.x) / 32;
7854
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
7855
+ double sign = 1;
7856
+ if (hScale < 0)
7857
+ {
7858
+ sign = -1;
7859
+ }
7860
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
71227861 if (hScale < 0.01)
71237862 {
7124
- hScale = 0.01;
7863
+ //hScale = 0.01;
71257864 }
7126
- hScale = Math.pow(hScale, scale * 50);
7127
- if (hScale < 0.01)
7865
+
7866
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
7867
+ sign = 1;
7868
+ if (vScale < 0)
71287869 {
7129
- hScale = 0.01;
7870
+ sign = -1;
71307871 }
7131
- double vScale = (double) (info.y - centerPt.y) / 32;
7872
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
71327873 if (vScale < 0.01)
71337874 {
7134
- vScale = 0.01;
7875
+ //vScale = 0.01;
71357876 }
7136
- vScale = Math.pow(vScale, scale * 50);
7137
- if (vScale < 0.01)
7138
- {
7139
- vScale = 0.01;
7140
- }
7877
+
71417878 LA.matCopy(startMat, toParent);
71427879 /**/
71437880 for (int i = 0; i < 3; i++)
....@@ -7147,39 +7884,56 @@
71477884 }
71487885 /**/
71497886
7150
- switch (info.pane.RenderCamera().viewCode)
7887
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
7888
+
7889
+ if (totalScale < 0.01)
7890
+ {
7891
+ totalScale = 0.01;
7892
+ }
7893
+
7894
+ switch (clickInfo.pane.RenderCamera().viewCode)
71517895 {
71527896 case 3: // '\001'
7153
- if (modified)
7897
+ if (modified || opposite)
71547898 {
7899
+ if (modified && opposite)
7900
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7901
+ else
71557902 //LA.matScale(toParent, 1, hScale, vScale);
7156
- LA.matScale(toParent, vScale, 1, 1);
7903
+ LA.matScale(toParent, totalScale, 1, 1);
71577904 } // vScale, 1);
71587905 else
71597906 {
7160
- LA.matScale(toParent, vScale, vScale, vScale);
7907
+ // EXCEPTION!
7908
+ LA.matScale(toParent, 1, totalScale, totalScale);
71617909 } // vScale, 1);
71627910 break;
71637911
71647912 case 2: // '\002'
7165
- if (modified)
7913
+ if (modified || opposite)
71667914 {
7167
- //LA.matScale(toParent, hScale, 1, vScale);
7168
- LA.matScale(toParent, 1, vScale, 1);
7915
+ if (modified && opposite)
7916
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7917
+ else
7918
+ //LA.matScale(toParent, hScale, 1, vScale);
7919
+ LA.matScale(toParent, 1, totalScale, 1);
71697920 } else
71707921 {
7171
- LA.matScale(toParent, vScale, 1, vScale);
7922
+ LA.matScale(toParent, totalScale, 1, totalScale);
71727923 }
71737924 break;
71747925
71757926 case 1: // '\003'
7176
- if (modified)
7927
+ if (modified || opposite)
71777928 {
7178
- //LA.matScale(toParent, hScale, vScale, 1);
7179
- LA.matScale(toParent, 1, 1, vScale);
7929
+ if (modified && opposite)
7930
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7931
+ else
7932
+ //LA.matScale(toParent, hScale, vScale, 1);
7933
+ LA.matScale(toParent, 1, 1, totalScale);
71807934 } else
71817935 {
7182
- LA.matScale(toParent, vScale, vScale, 1);
7936
+ LA.matScale(toParent, totalScale, totalScale, 1);
71837937 }
71847938 break;
71857939 }
....@@ -7213,7 +7967,7 @@
72137967 } // NEW ...
72147968
72157969
7216
- info.pane.repaint();
7970
+ clickInfo.pane.repaint();
72177971 }
72187972
72197973 boolean overflow = false;
....@@ -7312,14 +8066,22 @@
73128066 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
73138067 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
73148068 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
8069
+
8070
+ String objname;
8071
+
73158072 if (false) //parent != null)
73168073 {
7317
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
8074
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
73188075 } else
73198076 {
7320
- return GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ") ")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ +System.identityHashCode(this);
8077
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
73218078 } // + super.toString();
73228079 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
8080
+
8081
+ if (!Globals.ADVANCED)
8082
+ return objname;
8083
+
8084
+ return objname + " " + System.identityHashCode(this);
73238085 }
73248086
73258087 public int hashCode()
....@@ -7375,6 +8137,7 @@
73758137 objectUI.closeUI();
73768138 if (editWindow != null)
73778139 {
8140
+ editWindow.ctrlPanel.FlushUI();
73788141 editWindow.refreshContents();
73798142 } // ? new
73808143 objectUI = null;
....@@ -7383,6 +8146,10 @@
73838146 {
73848147 editWindow = null;
73858148 } // ?
8149
+ }
8150
+ else
8151
+ {
8152
+ //editWindow.closeUI();
73868153 }
73878154 }
73888155
....@@ -7395,7 +8162,7 @@
73958162 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
73968163
73978164 Object3D /*Composite*/ parent;
7398
- Object3D /*Composite*/ fileparent;
8165
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
73998166
74008167 double[][] toParent; // dynamic matrix
74018168 double[][] fromParent;
....@@ -7510,7 +8277,7 @@
75108277 {
75118278 assert(bRep != null);
75128279 if (!(support instanceof GenericJoint)) // support.bRep != null)
7513
- GrafreeD.Assert(support.bRep == bRep.support);
8280
+ Grafreed.Assert(support.bRep == bRep.support);
75148281 }
75158282 else
75168283 {
....@@ -7541,6 +8308,10 @@
75418308 }
75428309
75438310 transient ObjEditor editWindow;
8311
+ transient ObjEditor manipWindow;
8312
+
8313
+ transient boolean pinned;
8314
+
75448315 transient ObjectUI objectUI;
75458316 public static int povDepth = 0;
75468317 private static cVector tbMin = new cVector();
....@@ -7559,9 +8330,9 @@
75598330 private static cVector edge2 = new cVector();
75608331 //private static cVector norm = new cVector();
75618332 /*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;
8333
+ static final int hitCenter = 1;
8334
+ static final int hitScale = 2;
8335
+ static final int hitRotate = 3;
75658336 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
75668337 /*transient*/ private Point centerPt;
75678338 /*transient*/ private int startX;