Normand Briere
2019-08-26 6266c8a4b2485b29a7d5bcb217460d7aad3e1c4a
Object3D.java
....@@ -14,14 +14,45 @@
1414 import //weka.core.
1515 matrix.Matrix;
1616
17
+import java.util.UUID;
18
+
1719 //import net.sourceforge.sizeof.SizeOf;
1820 public class Object3D extends Vector<Object3D> implements java.io.Serializable, iSendInfo //, aurelienribon.tweenengine.TweenAccessor<Object3D>
1921 {
2022 //static final long serialVersionUID = -607422624994562685L;
2123 static final long serialVersionUID = 5022536242724664900L;
2224
25
+ // 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>();
40
+
2341 ScriptNode scriptnode;
2442
43
+ int VersionCount()
44
+ {
45
+ int count = 0;
46
+
47
+ for (int i = versionlist.length; --i >= 0;)
48
+ {
49
+ if (versionlist[i] != null)
50
+ count++;
51
+ }
52
+
53
+ return count;
54
+ }
55
+
2556 void InitOthers()
2657 {
2758 if (projectedVertices == null || projectedVertices.length <= 2)
....@@ -100,64 +131,245 @@
100131
101132 // transient boolean reduced; // for morph reduction
102133
103
-transient com.bulletphysics.linearmath.Transform cache; // for fast merge
104
-transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
134
+ transient com.bulletphysics.linearmath.Transform cache; // for fast merge
135
+ transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
105136
106
-transient Object3D transientsupport; // for cloning
107
-transient boolean transientlink2master;
137
+ transient Object3D transientsupport; // for cloning
138
+ transient boolean transientlink2master;
108139
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)
140
+ void SaveSupports()
121141 {
122
- bRep.SaveSupports();
142
+ if (blockloop)
143
+ return;
144
+
145
+ transientsupport = support;
146
+ transientlink2master = link2master;
147
+
148
+ support = null;
149
+ link2master = false;
150
+
151
+ if (bRep != null)
152
+ {
153
+ bRep.SaveSupports();
154
+ }
155
+
156
+ for (int i = 0; i < Size(); i++)
157
+ {
158
+ Object3D child = (Object3D) get(i);
159
+ if (child == null)
160
+ continue;
161
+ blockloop = true;
162
+ child.SaveSupports();
163
+ blockloop = false;
164
+ }
123165 }
124
-
125
- for (int i = 0; i < Size(); i++)
166
+
167
+ void RestoreSupports()
126168 {
127
- Object3D child = (Object3D) get(i);
128
- if (child == null)
129
- continue;
169
+ if (blockloop)
170
+ return;
171
+
172
+ support = transientsupport;
173
+ link2master = transientlink2master;
174
+ transientsupport = null;
175
+ transientlink2master = false;
176
+
177
+ if (bRep != null)
178
+ {
179
+ bRep.RestoreSupports();
180
+ }
181
+
182
+ for (int i = 0; i < Size(); i++)
183
+ {
184
+ Object3D child = (Object3D) get(i);
185
+ if (child == null)
186
+ continue;
187
+ blockloop = true;
188
+ child.RestoreSupports();
189
+ blockloop = false;
190
+ }
191
+ }
192
+
193
+ void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
194
+ {
195
+ Object3D o;
196
+
197
+ if (hashtable.containsKey(GetUUID()))
198
+ {
199
+ o = hashtable.get(GetUUID());
200
+
201
+ Grafreed.Assert(this.bRep == o.bRep);
202
+ //if (this.bRep != null)
203
+ // assert(this.bRep.support == o.transientrep);
204
+ if (this.support != null)
205
+ assert(this.support.bRep == o.transientrep);
206
+ }
207
+ else
208
+ {
209
+ o = new Object3D("copy of " + this.name);
210
+
211
+ hashtable.put(GetUUID(), o);
212
+ }
213
+
214
+ if (!blockloop)
215
+ {
216
+ blockloop = true;
217
+
218
+ for (int i=0; i<Size(); i++)
219
+ {
220
+ get(i).ExtractBigData(hashtable);
221
+ }
222
+
223
+ blockloop = false;
224
+ }
225
+
226
+ ExtractBigData(o);
227
+ }
228
+
229
+ void ExtractBigData(Object3D o)
230
+ {
231
+ if (o.bRep != null)
232
+ Grafreed.Assert(o.bRep == this.bRep);
233
+
234
+ o.bRep = this.bRep;
235
+// July 2019 if (this.bRep != null)
236
+// {
237
+// o.transientrep = this.bRep.support;
238
+// o.bRep.support = null;
239
+// }
240
+ o.selection = this.selection;
241
+ o.versionlist = this.versionlist;
242
+ o.versionindex = this.versionindex;
243
+
244
+ if (this.support != null)
245
+ {
246
+ if (o.transientrep != null)
247
+ Grafreed.Assert(o.transientrep == this.support.bRep);
248
+
249
+ o.transientrep = this.support.bRep;
250
+ this.support.bRep = null;
251
+ }
252
+
253
+ // o.support = this.support;
254
+ // o.fileparent = this.fileparent;
255
+ // if (this.bRep != null)
256
+ // o.bRep = this.bRep.support;
257
+
258
+ this.bRep = null;
259
+ // if (this.bRep != null)
260
+ // this.bRep.support = null;
261
+ // this.support = null;
262
+ // this.fileparent = null;
263
+ }
264
+
265
+// Object3D GetObject(java.util.UUID uuid)
266
+// {
267
+// if (this.uuid.equals(uuid))
268
+// return this;
269
+//
270
+// if (blockloop)
271
+// return null;
272
+//
273
+// blockloop = true;
274
+//
275
+// for (int i=0; i<Size(); i++)
276
+// {
277
+// Object3D o = get(i).GetObject(uuid);
278
+//
279
+// if (o != null)
280
+// return o;
281
+// }
282
+//
283
+// blockloop = false;
284
+//
285
+// return null;
286
+// }
287
+
288
+ transient boolean tag;
289
+
290
+ void TagObjects(Object3D o, boolean tag)
291
+ {
292
+ if (blockloop)
293
+ return;
294
+
295
+ o.tag = tag;
296
+
297
+ if (o == this)
298
+ return;
299
+
130300 blockloop = true;
131
- child.SaveSupports();
301
+
302
+ for (int i=0; i<Size(); i++)
303
+ {
304
+ get(i).TagObjects(o, tag);
305
+ }
306
+
132307 blockloop = false;
133308 }
134
-}
135309
136
-void RestoreSupports()
137
-{
138
- if (blockloop)
139
- return;
310
+ boolean HasTags()
311
+ {
312
+ if (blockloop)
313
+ return false;
140314
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;
156315 blockloop = true;
157
- child.RestoreSupports();
316
+
317
+ boolean hasTags = false;
318
+
319
+ for (int i=0; i<Size(); i++)
320
+ {
321
+ hasTags |= get(i).tag || get(i).HasTags();
322
+
323
+ if (hasTags)
324
+ break;
325
+ }
326
+
327
+ blockloop = false;
328
+
329
+ return hasTags;
330
+ }
331
+
332
+ void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
333
+ {
334
+ if (!hashtable.containsKey(GetUUID()))
335
+ return;
336
+
337
+ Object3D o = hashtable.get(GetUUID());
338
+
339
+ RestoreBigData(o);
340
+
341
+ if (blockloop)
342
+ return;
343
+
344
+ blockloop = true;
345
+
346
+ //hashtable.remove(GetUUID());
347
+
348
+ for (int i=0; i<Size(); i++)
349
+ {
350
+ get(i).RestoreBigData(hashtable);
351
+ }
352
+
158353 blockloop = false;
159354 }
160
-}
355
+
356
+ void RestoreBigData(Object3D o)
357
+ {
358
+ this.bRep = o.bRep;
359
+ if (this.support != null && o.transientrep != null)
360
+ {
361
+ this.support.bRep = o.transientrep;
362
+ }
363
+
364
+ this.selection = o.selection;
365
+
366
+ this.versionlist = o.versionlist;
367
+ this.versionindex = o.versionindex;
368
+// July 2019 if (this.bRep != null)
369
+// this.bRep.support = o.transientrep;
370
+ // this.support = o.support;
371
+ // this.fileparent = o.fileparent;
372
+ }
161373
162374 // MOCAP SUPPORT
163375 double tx,ty,tz,rx,ry,rz;
....@@ -300,6 +512,8 @@
300512 }
301513
302514 boolean live = false;
515
+ transient boolean keepdontselect;
516
+ boolean dontselect = false;
303517 boolean hide = false;
304518 boolean link2master = false; // performs reset support/master at each frame
305519 boolean marked = false; // animation node
....@@ -367,11 +581,11 @@
367581 }
368582 }
369583
370
- int memorysize;
584
+ transient int memorysize; // needs to be transient, dunno why
371585
372586 int MemorySize()
373587 {
374
- if (true) // memorysize == 0)
588
+ if (memorysize == 0)
375589 {
376590 try
377591 {
....@@ -481,12 +695,14 @@
481695 toParent = LA.newMatrix();
482696 fromParent = LA.newMatrix();
483697 }
698
+
484699 if (toParentMarked == null)
485700 {
486701 if (maxcount != 1)
487702 {
488
- new Exception().printStackTrace();
703
+ //new Exception().printStackTrace();
489704 }
705
+
490706 toParentMarked = LA.newMatrix();
491707 fromParentMarked = LA.newMatrix();
492708 }
....@@ -774,7 +990,7 @@
774990 if (step == 0)
775991 step = 1;
776992 if (maxcount == 0)
777
- maxcount = 2048; // 4;
993
+ maxcount = 128; // 2048; // 4;
778994 // if (acceleration == 0)
779995 // acceleration = 10;
780996 if (delay == 0) // serial
....@@ -797,7 +1013,7 @@
7971013
7981014 if (marked && Globals.isLIVE() && live &&
7991015 //TEMP21aug2018
800
- Globals.DrawMode() == iCameraPane.SHADOW &&
1016
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
8011017 currentframe != Globals.framecount)
8021018 {
8031019 currentframe = Globals.framecount;
....@@ -809,7 +1025,8 @@
8091025
8101026 boolean changedir = random && Math.random() < 0.01; // && !link2master;
8111027
812
- if (transformcount*factor > maxcount || (step == 1 && changedir))
1028
+ if (transformcount*factor >= maxcount && (rewind || random) ||
1029
+ (step == 1 && changedir))
8131030 {
8141031 countdown = 1;
8151032 delay = speedup?8:1;
....@@ -881,6 +1098,10 @@
8811098 if (material == null || material.multiply)
8821099 return true;
8831100
1101
+ if (projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
1102
+ return false;
1103
+
1104
+ // Transparent objects are dynamic because we have to sort the triangles.
8841105 return material.opacity > 0.99;
8851106 }
8861107
....@@ -912,6 +1133,11 @@
9121133 fromParent = null; // LA.newMatrix();
9131134 bRep = null; // new BoundaryRep();
9141135
1136
+ if (oname != null && oname.equals("LeftHand"))
1137
+ {
1138
+ name = oname;
1139
+ }
1140
+
9151141 /*
9161142 float hue = (float)Math.random();
9171143 Color col;
....@@ -954,7 +1180,7 @@
9541180
9551181 public Object clone()
9561182 {
957
- return GrafreeD.clone(this);
1183
+ return Grafreed.clone(this);
9581184 }
9591185
9601186 Object3D copyExpand()
....@@ -1276,6 +1502,7 @@
12761502 toParent = LA.newMatrix();
12771503 fromParent = LA.newMatrix();
12781504 }
1505
+
12791506 LA.matCopy(other.toParent, toParent);
12801507 LA.matCopy(other.fromParent, fromParent);
12811508
....@@ -1470,7 +1697,7 @@
14701697 BoundaryRep.SEUIL = other.material.cameralight;
14711698
14721699 // Set default to 0.1
1473
- BoundaryRep.SEUIL /= 2;
1700
+ BoundaryRep.SEUIL /= 4; // 2;
14741701 System.out.println("SEUIL = " + BoundaryRep.SEUIL);
14751702 }
14761703
....@@ -1729,7 +1956,7 @@
17291956 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17301957 o.bRep = transientrep;
17311958 if (clone)
1732
- o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
1959
+ o.bRep = (BoundaryRep) Grafreed.clone(transientrep);
17331960 o.CreateMaterial();
17341961 o.SetAttributes(this, -1);
17351962 //parent
....@@ -1742,7 +1969,7 @@
17421969 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17431970 o.bRep = bRep;
17441971 if (clone)
1745
- o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
1972
+ o.bRep = (BoundaryRep) Grafreed.clone(bRep);
17461973 o.CreateMaterial();
17471974 //o.overwriteThis(this, -1);
17481975 o.SetAttributes(this, -1);
....@@ -1829,12 +2056,15 @@
18292056 if (obj.name == null)
18302057 continue; // can't be a null one
18312058
2059
+ // Try perfect match first.
18322060 if (n.equals(obj.name))
18332061 {
18342062 theobj = obj;
18352063 count++;
18362064 }
18372065 }
2066
+
2067
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18382068
18392069 if (count != 1)
18402070 for (int i=Size(); --i>=0;)
....@@ -2152,11 +2382,6 @@
21522382
21532383 InitOthers();
21542384
2155
- if (this instanceof Camera)
2156
- {
2157
- material.shift = 90;
2158
- }
2159
-
21602385 material.multiply = multiply;
21612386
21622387 if (multiply)
....@@ -2294,6 +2519,15 @@
22942519 }
22952520 */
22962521 }
2522
+ else
2523
+ {
2524
+ //((ObjEditor)editWindow).SetupUI2(null);
2525
+ if (objectUI != null)
2526
+ ((ObjEditor)objectUI).pinButton.setSelected(pinned);
2527
+ else
2528
+ //new Exception().printStackTrace();
2529
+ System.err.println("objectUI is null");
2530
+ }
22972531 }
22982532
22992533 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
....@@ -2335,6 +2569,14 @@
23352569 {
23362570 editWindow.refreshContents();
23372571 }
2572
+ else
2573
+ {
2574
+ if (manipWindow != null)
2575
+ {
2576
+ manipWindow.refreshContents();
2577
+ }
2578
+ }
2579
+
23382580 //if (parent != null)
23392581 //parent.refreshEditWindow();
23402582 }
....@@ -2414,7 +2656,8 @@
24142656 private static final int editSelf = 1;
24152657 private static final int editChild = 2;
24162658
2417
- void drawEditHandles(ClickInfo info, int level)
2659
+ void drawEditHandles(//ClickInfo info,
2660
+ int level)
24182661 {
24192662 if (level == 0)
24202663 {
....@@ -2422,7 +2665,8 @@
24222665 return;
24232666
24242667 Object3D selectee;
2425
- for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(info, level + 1))
2668
+ for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(//info,
2669
+ level + 1))
24262670 {
24272671 selectee = (Object3D) e.nextElement();
24282672 }
....@@ -2430,19 +2674,22 @@
24302674 } else
24312675 {
24322676 //super.
2433
- drawEditHandles0(info, level + 1);
2677
+ drawEditHandles0(//info,
2678
+ level + 1);
24342679 }
24352680 }
24362681
2437
- boolean doEditClick(ClickInfo info, int level)
2682
+ boolean doEditClick(//ClickInfo info,
2683
+ int level)
24382684 {
24392685 doSomething = 0;
24402686 if (level == 0)
24412687 {
2442
- return doParentClick(info);
2688
+ return doParentClick(); //info);
24432689 }
24442690 if (//super.
2445
- doEditClick0(info, level))
2691
+ doEditClick0(//info,
2692
+ level))
24462693 {
24472694 doSomething = 1;
24482695 return true;
....@@ -2452,7 +2699,7 @@
24522699 }
24532700 }
24542701
2455
- boolean doParentClick(ClickInfo info)
2702
+ boolean doParentClick() //ClickInfo info)
24562703 {
24572704 if (selection == null)
24582705 {
....@@ -2465,7 +2712,8 @@
24652712 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
24662713 {
24672714 Object3D selectee = (Object3D) e.nextElement();
2468
- if (selectee.doEditClick(info, 1))
2715
+ if (selectee.doEditClick(//info,
2716
+ 1))
24692717 {
24702718 childToDrag = selectee;
24712719 doSomething = 2;
....@@ -2477,13 +2725,15 @@
24772725 return retval;
24782726 }
24792727
2480
- void doEditDrag(ClickInfo info, boolean opposite)
2728
+ void doEditDrag(//ClickInfo clickInfo,
2729
+ boolean opposite)
24812730 {
24822731 switch (doSomething)
24832732 {
24842733 case 1: // '\001'
24852734 //super.
2486
- doEditDrag0(info, opposite);
2735
+ doEditDrag0(//clickInfo,
2736
+ opposite);
24872737 break;
24882738
24892739 case 2: // '\002'
....@@ -2496,11 +2746,13 @@
24962746 {
24972747 //sel.hitSomething = childToDrag.hitSomething;
24982748 //childToDrag.doEditDrag(info);
2499
- sel.doEditDrag(info, opposite);
2749
+ sel.doEditDrag(//clickInfo,
2750
+ opposite);
25002751 } else
25012752 {
25022753 //super.
2503
- doEditDrag0(info, opposite);
2754
+ doEditDrag0(//clickInfo,
2755
+ opposite);
25042756 }
25052757 }
25062758 break;
....@@ -2518,6 +2770,9 @@
25182770 {
25192771 deselectAll();
25202772 }
2773
+
2774
+ new Exception().printStackTrace();
2775
+
25212776 ClickInfo newInfo = new ClickInfo();
25222777 newInfo.flags = info.flags;
25232778 newInfo.bounds = info.bounds;
....@@ -2610,6 +2865,18 @@
26102865 void GenNormalsS(boolean crease)
26112866 {
26122867 selection.GenNormals(crease);
2868
+// for (int i=0; i<selection.size(); i++)
2869
+// {
2870
+// Object3D selectee = (Object3D) selection.elementAt(i);
2871
+// selectee.GenNormals(crease);
2872
+// }
2873
+
2874
+ //Touch();
2875
+ }
2876
+
2877
+ void GenNormalsMeshS()
2878
+ {
2879
+ selection.GenNormalsMesh();
26132880 // for (int i=0; i<selection.size(); i++)
26142881 // {
26152882 // Object3D selectee = (Object3D) selection.elementAt(i);
....@@ -2750,6 +3017,24 @@
27503017 if (child == null)
27513018 continue;
27523019 child.GenNormals(crease);
3020
+// Children().release(i);
3021
+ }
3022
+ blockloop = false;
3023
+ }
3024
+
3025
+ void GenNormalsMesh()
3026
+ {
3027
+ if (blockloop)
3028
+ return;
3029
+
3030
+ blockloop = true;
3031
+ GenNormalsMesh0();
3032
+ for (int i = 0; i < Children().Size(); i++)
3033
+ {
3034
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
3035
+ if (child == null)
3036
+ continue;
3037
+ child.GenNormalsMesh();
27533038 // Children().release(i);
27543039 }
27553040 blockloop = false;
....@@ -2922,11 +3207,20 @@
29223207 }
29233208 }
29243209
3210
+ void GenNormalsMesh0()
3211
+ {
3212
+ if (bRep != null)
3213
+ {
3214
+ bRep.GenerateNormalsMesh();
3215
+ Touch();
3216
+ }
3217
+ }
3218
+
29253219 void GenNormalsMINE0()
29263220 {
29273221 if (bRep != null)
29283222 {
2929
- bRep.GenerateNormalsMINE();
3223
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
29303224 Touch();
29313225 }
29323226 }
....@@ -2983,6 +3277,120 @@
29833277 blockloop = false;
29843278 }
29853279
3280
+ public void ResetTransform(int mask)
3281
+ {
3282
+ Object3D obj = this;
3283
+
3284
+ if (mask == -1)
3285
+ {
3286
+ if (obj instanceof Camera) // jan 2014
3287
+ {
3288
+ LA.matIdentity(obj.toParent);
3289
+ LA.matIdentity(obj.fromParent);
3290
+ }
3291
+ else
3292
+ {
3293
+ obj.toParent = null; // jan 2014 LA.matIdentity(obj.toParent);
3294
+ obj.fromParent = null; // LA.matIdentity(obj.fromParent);
3295
+ }
3296
+ return;
3297
+ }
3298
+
3299
+ if ((mask&2) != 0) // Scale/rotation
3300
+ {
3301
+ obj.toParent[0][0] = obj.toParent[1][1] = obj.toParent[2][2] = 1;
3302
+ obj.toParent[0][1] = obj.toParent[1][0] = obj.toParent[2][0] = 0;
3303
+ obj.toParent[0][2] = obj.toParent[1][2] = obj.toParent[2][1] = 0;
3304
+ obj.fromParent[0][0] = obj.fromParent[1][1] = obj.fromParent[2][2] = 1;
3305
+ obj.fromParent[0][1] = obj.fromParent[1][0] = obj.fromParent[2][0] = 0;
3306
+ obj.fromParent[0][2] = obj.fromParent[1][2] = obj.fromParent[2][1] = 0;
3307
+ }
3308
+ if ((mask&1) != 0) // Translation
3309
+ {
3310
+ if (obj.toParent != null)
3311
+ {
3312
+ obj.toParent[3][0] = obj.toParent[3][1] = obj.toParent[3][2] = 0;
3313
+ obj.fromParent[3][0] = obj.fromParent[3][1] = obj.fromParent[3][2] = 0;
3314
+ }
3315
+ }
3316
+ }
3317
+
3318
+ public void TextureRatioTransform(int axis)
3319
+ {
3320
+ cTexture tex = GetTextures();
3321
+
3322
+ com.sun.opengl.util.texture.TextureData texturedata = null;
3323
+
3324
+ try
3325
+ {
3326
+ texturedata = Globals.theRenderer.GetTextureData(tex, false, texres);
3327
+ }
3328
+ catch (Exception e)
3329
+ {
3330
+ System.err.println("FAIL TextureRatio: " + this);
3331
+ }
3332
+
3333
+ LA.matIdentity(Object3D.mat);
3334
+ Object3D.mat[axis][axis] = (double)texturedata.getWidth() / texturedata.getHeight();
3335
+
3336
+ if (toParent == null)
3337
+ {
3338
+ toParent = LA.newMatrix();
3339
+ fromParent = LA.newMatrix();
3340
+ }
3341
+
3342
+ ResetTransform(2);
3343
+
3344
+ LA.matConcat(Object3D.mat, fromParent, fromParent);
3345
+ LA.matInvert(fromParent, toParent);
3346
+ }
3347
+
3348
+ void TextureRatio(int axis)
3349
+ {
3350
+ if (blockloop)
3351
+ return;
3352
+
3353
+ blockloop = true;
3354
+
3355
+ TextureRatioTransform(axis);
3356
+
3357
+ for (int i=Size(); --i>=0;)
3358
+ {
3359
+ Object3D v = get(i);
3360
+
3361
+ v.TextureRatio(axis);
3362
+ }
3363
+
3364
+ blockloop = false;
3365
+ }
3366
+
3367
+ void TransformChildren()
3368
+ {
3369
+ if (toParent != null)
3370
+ {
3371
+ for (int i=Size(); --i>=0;)
3372
+ {
3373
+ Object3D v = get(i);
3374
+
3375
+ if (v.toParent == null)
3376
+ {
3377
+ v.toParent = LA.newMatrix();
3378
+ v.fromParent = LA.newMatrix();
3379
+ }
3380
+
3381
+// LA.matConcat(v.toParent, toParent, v.toParent);
3382
+// LA.matConcat(fromParent, v.fromParent, v.fromParent);
3383
+ LA.matConcat(toParent, v.toParent, v.toParent);
3384
+ LA.matConcat(v.fromParent, fromParent, v.fromParent);
3385
+ }
3386
+
3387
+ toParent = null; // LA.matIdentity(toParent);
3388
+ fromParent = null; // LA.matIdentity(fromParent);
3389
+
3390
+ Touch();
3391
+ }
3392
+ }
3393
+
29863394 void TransformGeometry()
29873395 {
29883396 Object3D obj = this;
....@@ -3204,9 +3612,11 @@
32043612
32053613 BoundaryRep sup = bRep.support;
32063614 bRep.support = null;
3207
- BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
3615
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
32083616 // bRep.SplitInTwo(onlyone); // thread...
3209
- temprep.SplitInTwo(reduction34, onlyone);
3617
+
3618
+ while(temprep.SplitInTwo(reduction34, onlyone));
3619
+
32103620 bRep = temprep;
32113621 bRep.support = sup;
32123622 Touch();
....@@ -3307,15 +3717,47 @@
33073717
33083718 void ClearMaterials()
33093719 {
3720
+ if (blockloop)
3721
+ return;
3722
+
3723
+ blockloop = true;
3724
+
33103725 ClearMaterial();
3311
- for (int i = 0; i < size(); i++)
3726
+ for (int i = 0; i < Size(); i++)
33123727 {
3313
- Object3D child = (Object3D) reserve(i);
3728
+ Object3D child = (Object3D) get(i);
33143729 if (child == null)
33153730 continue;
33163731 child.ClearMaterials();
3317
- release(i);
33183732 }
3733
+
3734
+ blockloop = false;
3735
+ }
3736
+
3737
+ void ClearVersionList()
3738
+ {
3739
+ this.versionlist = null;
3740
+ this.versionindex = -1;
3741
+ this.versiontable = null;
3742
+ }
3743
+
3744
+ void ClearVersions()
3745
+ {
3746
+ if (blockloop)
3747
+ return;
3748
+
3749
+ blockloop = true;
3750
+
3751
+ ClearVersionList();
3752
+ for (int i = 0; i < Size(); i++)
3753
+ {
3754
+ Object3D child = (Object3D) get(i);
3755
+ if (child == null)
3756
+ continue;
3757
+ child.ClearVersions();
3758
+ }
3759
+
3760
+ blockloop = false;
33193761 }
33203762
33213763 void FlipV(boolean flip)
....@@ -3343,7 +3785,8 @@
33433785 if (blockloop)
33443786 return;
33453787
3346
- if (marked || (bRep != null && material != null)) // borderline...
3788
+ if (//marked || // does not make sense
3789
+ (bRep != null || material != null)) // borderline...
33473790 live = h;
33483791
33493792 for (int i = 0; i < Size(); i++)
....@@ -3364,7 +3807,8 @@
33643807 return;
33653808
33663809 //if (bRep != null)
3367
- if (marked || (bRep != null && material != null)) // borderline...
3810
+ if (//marked || // does not make sense
3811
+ (bRep != null || material != null)) // borderline...
33683812 link2master = h;
33693813
33703814 for (int i = 0; i < Size(); i++)
....@@ -3384,7 +3828,8 @@
33843828 if (blockloop)
33853829 return;
33863830
3387
- if (marked || (bRep != null && material != null)) // borderline...
3831
+ if (//marked || // does not make sense
3832
+ (bRep != null || material != null)) // borderline...
33883833 hide = h;
33893834
33903835 for (int i = 0; i < Size(); i++)
....@@ -3404,7 +3849,7 @@
34043849 if (blockloop)
34053850 return;
34063851
3407
- if (bRep != null && material != null) // borderline...
3852
+ if (bRep != null || material != null) // borderline...
34083853 marked = h;
34093854
34103855 for (int i = 0; i < Size(); i++)
....@@ -3414,6 +3859,46 @@
34143859 continue;
34153860 blockloop = true;
34163861 child.MarkLeaves(h);
3862
+ blockloop = false;
3863
+ // release(i);
3864
+ }
3865
+ }
3866
+
3867
+ void RewindLeaves(boolean h)
3868
+ {
3869
+ if (blockloop)
3870
+ return;
3871
+
3872
+ if (bRep != null || material != null) // borderline...
3873
+ rewind = h;
3874
+
3875
+ for (int i = 0; i < Size(); i++)
3876
+ {
3877
+ Object3D child = (Object3D) get(i); // reserve(i);
3878
+ if (child == null)
3879
+ continue;
3880
+ blockloop = true;
3881
+ child.RewindLeaves(h);
3882
+ blockloop = false;
3883
+ // release(i);
3884
+ }
3885
+ }
3886
+
3887
+ void RandomLeaves(boolean h)
3888
+ {
3889
+ if (blockloop)
3890
+ return;
3891
+
3892
+ if (bRep != null || material != null) // borderline...
3893
+ random = h;
3894
+
3895
+ for (int i = 0; i < Size(); i++)
3896
+ {
3897
+ Object3D child = (Object3D) get(i); // reserve(i);
3898
+ if (child == null)
3899
+ continue;
3900
+ blockloop = true;
3901
+ child.RandomLeaves(h);
34173902 blockloop = false;
34183903 // release(i);
34193904 }
....@@ -3728,7 +4213,7 @@
37284213 if (child == null)
37294214 continue;
37304215
3731
- if (GrafreeD.RENDERME > 0)
4216
+ if (Grafreed.RENDERME > 0)
37324217 {
37334218 if (child instanceof Merge)
37344219 ((Merge)child).renderme();
....@@ -3879,7 +4364,7 @@
38794364 if (child == null)
38804365 continue;
38814366
3882
- if (GrafreeD.RENDERME > 0)
4367
+ if (Grafreed.RENDERME > 0)
38834368 {
38844369 if (child instanceof Merge)
38854370 ((Merge)child).renderme();
....@@ -4074,7 +4559,7 @@
40744559 if (child == null)
40754560 continue;
40764561
4077
- if (GrafreeD.RENDERME > 0)
4562
+ if (Grafreed.RENDERME > 0)
40784563 {
40794564 if (child instanceof Merge)
40804565 ((Merge)child).renderme();
....@@ -4187,6 +4672,55 @@
41874672 {
41884673 blockloop = true;
41894674 get(i).RepairShadow();
4675
+ blockloop = false;
4676
+ }
4677
+ }
4678
+
4679
+ void RepairSOV()
4680
+ {
4681
+ if (blockloop)
4682
+ return;
4683
+
4684
+ String texname = this.GetPigmentTexture();
4685
+
4686
+ if (texname.startsWith("sov"))
4687
+ {
4688
+ String[] s = texname.split("/");
4689
+
4690
+ String[] sname = s[1].split("Color.pn");
4691
+
4692
+ texname = sname[0];
4693
+
4694
+ if (sname.length > 1)
4695
+ {
4696
+ texname += "Color.jpg";
4697
+ }
4698
+
4699
+ this.SetPigmentTexture("sov/" + texname);
4700
+ }
4701
+
4702
+ texname = this.GetBumpTexture();
4703
+
4704
+ if (texname.startsWith("sov"))
4705
+ {
4706
+ String[] s = texname.split("/");
4707
+
4708
+ String[] sname = s[1].split("Bump.pn");
4709
+
4710
+ texname = sname[0];
4711
+
4712
+ if (sname.length > 1)
4713
+ {
4714
+ texname += "Bump.jpg";
4715
+ }
4716
+
4717
+ this.SetBumpTexture("sov/" + texname);
4718
+ }
4719
+
4720
+ for (int i=0; i<Size(); i++)
4721
+ {
4722
+ blockloop = true;
4723
+ get(i).RepairSOV();
41904724 blockloop = false;
41914725 }
41924726 }
....@@ -4681,7 +5215,7 @@
46815215
46825216 cTreePath SelectLeaf(int indexcount, boolean deselect)
46835217 {
4684
- if (hide)
5218
+ if (hide || dontselect)
46855219 return null;
46865220
46875221 if (count <= 0)
....@@ -4705,9 +5239,17 @@
47055239 }
47065240 }
47075241
5242
+ ObjEditor GetWindow()
5243
+ {
5244
+ if (editWindow != null)
5245
+ return editWindow;
5246
+
5247
+ return manipWindow;
5248
+ }
5249
+
47085250 cTreePath Select(int indexcount, boolean deselect)
47095251 {
4710
- if (hide)
5252
+ if (hide || dontselect)
47115253 return null;
47125254
47135255 if (count <= 0)
....@@ -4741,10 +5283,11 @@
47415283 if (leaf != null)
47425284 {
47435285 cTreePath tp = new cTreePath(this, leaf);
4744
- if (editWindow != null)
5286
+ ObjEditor window = GetWindow();
5287
+ if (window != null)
47455288 {
47465289 //System.out.println("editWindow = " + editWindow + " vs " + this);
4747
- editWindow.Select(tp, deselect, true);
5290
+ window.Select(tp, deselect, true);
47485291 }
47495292
47505293 return tp;
....@@ -4761,6 +5304,7 @@
47615304
47625305 if (child == null)
47635306 continue;
5307
+
47645308 if (child.HasTransparency() && child.size() != 0)
47655309 {
47665310 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4770,9 +5314,10 @@
47705314 if (leaf != null)
47715315 {
47725316 cTreePath tp = new cTreePath(this, leaf);
4773
- if (editWindow != null)
5317
+ ObjEditor window = GetWindow();
5318
+ if (window != null)
47745319 {
4775
- editWindow.Select(tp, deselect, true);
5320
+ window.Select(tp, deselect, true);
47765321 }
47775322
47785323 return tp;
....@@ -5097,6 +5642,51 @@
50975642 blockloop = false;
50985643 }
50995644
5645
+ void ResetSelectable()
5646
+ {
5647
+ if (blockloop)
5648
+ return;
5649
+
5650
+ blockloop = true;
5651
+
5652
+ keepdontselect = dontselect;
5653
+ dontselect = true;
5654
+
5655
+ Object3D child;
5656
+ int nb = Size();
5657
+ for (int i = 0; i < nb; i++)
5658
+ {
5659
+ child = (Object3D) get(i);
5660
+ if (child == null)
5661
+ continue;
5662
+ child.ResetSelectable();
5663
+ }
5664
+
5665
+ blockloop = false;
5666
+ }
5667
+
5668
+ void RestoreSelectable()
5669
+ {
5670
+ if (blockloop)
5671
+ return;
5672
+
5673
+ blockloop = true;
5674
+
5675
+ dontselect = keepdontselect;
5676
+
5677
+ Object3D child;
5678
+ int nb = Size();
5679
+ for (int i = 0; i < nb; i++)
5680
+ {
5681
+ child = (Object3D) get(i);
5682
+ if (child == null)
5683
+ continue;
5684
+ child.RestoreSelectable();
5685
+ }
5686
+
5687
+ blockloop = false;
5688
+ }
5689
+
51005690 boolean IsSelected()
51015691 {
51025692 if (parent == null)
....@@ -5157,6 +5747,11 @@
51575747 if (fullname == null)
51585748 return "";
51595749
5750
+ if (fullname.pigment != null)
5751
+ {
5752
+ return fullname.pigment;
5753
+ }
5754
+
51605755 // System.out.println("Fullname = " + fullname);
51615756
51625757 // Does not work on Windows due to C:
....@@ -5169,7 +5764,7 @@
51695764
51705765 if (split.length == 0)
51715766 {
5172
- return "";
5767
+ return fullname.pigment = "";
51735768 }
51745769
51755770 if (split.length <= 2)
....@@ -5177,22 +5772,27 @@
51775772 if (fullname.name.endsWith(":"))
51785773 {
51795774 // Windows
5180
- return fullname.name.substring(0, fullname.name.length()-1);
5775
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
51815776 }
51825777
5183
- return split[0];
5778
+ return fullname.pigment = split[0];
51845779 }
51855780
51865781 // Windows
51875782 assert(split.length == 4);
51885783
5189
- return split[0] + ":" + split[1];
5784
+ return fullname.pigment = split[0] + ":" + split[1];
51905785 }
51915786
51925787 static String GetBump(cTexture fullname)
51935788 {
51945789 if (fullname == null)
51955790 return "";
5791
+
5792
+ if (fullname.bump != null)
5793
+ {
5794
+ return fullname.bump;
5795
+ }
51965796
51975797 // System.out.println("Fullname = " + fullname);
51985798 // Does not work on Windows due to C:
....@@ -5204,12 +5804,12 @@
52045804
52055805 if (split.length == 0)
52065806 {
5207
- return "";
5807
+ return fullname.bump = "";
52085808 }
52095809
52105810 if (split.length == 1)
52115811 {
5212
- return "";
5812
+ return fullname.bump = "";
52135813 }
52145814
52155815 if (split.length == 2)
....@@ -5217,16 +5817,16 @@
52175817 if (fullname.name.endsWith(":"))
52185818 {
52195819 // Windows
5220
- return "";
5820
+ return fullname.bump = "";
52215821 }
52225822
5223
- return split[1];
5823
+ return fullname.bump = split[1];
52245824 }
52255825
52265826 // Windows
52275827 assert(split.length == 4);
52285828
5229
- return split[2] + ":" + split[3];
5829
+ return fullname.bump = split[2] + ":" + split[3];
52305830 }
52315831
52325832 String GetPigmentTexture()
....@@ -5309,6 +5909,9 @@
53095909 texname = "";
53105910
53115911 GetTextures().name = texname + ":" + GetBump(GetTextures());
5912
+
5913
+ GetTextures().pigment = null;
5914
+
53125915 Touch();
53135916 }
53145917
....@@ -5333,6 +5936,43 @@
53335936 }
53345937 }
53355938
5939
+ UUID GetUUID()
5940
+ {
5941
+ if (uuid == null)
5942
+ {
5943
+ // Serial
5944
+ uuid = UUID.randomUUID();
5945
+ }
5946
+
5947
+ return uuid;
5948
+ }
5949
+
5950
+ Object3D GetObject(UUID uid)
5951
+ {
5952
+ if (blockloop)
5953
+ return null;
5954
+
5955
+ if (GetUUID().equals(uid))
5956
+ return this;
5957
+
5958
+ int nb = Size();
5959
+ for (int i = 0; i < nb; i++)
5960
+ {
5961
+ Object3D child = (Object3D) get(i);
5962
+
5963
+ if (child == null)
5964
+ continue;
5965
+
5966
+ blockloop = true;
5967
+ Object3D obj = child.GetObject(uid);
5968
+ blockloop = false;
5969
+ if (obj != null)
5970
+ return obj;
5971
+ }
5972
+
5973
+ return null;
5974
+ }
5975
+
53365976 void SetBumpTexture(String tex)
53375977 {
53385978 if (GetTextures() == null)
....@@ -5344,6 +5984,8 @@
53445984 texname = "";
53455985
53465986 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
5987
+
5988
+ GetTextures().bump = null;
53475989
53485990 Touch();
53495991 }
....@@ -5369,6 +6011,38 @@
53696011 }
53706012 }
53716013
6014
+ void EmbedTextures(boolean embed)
6015
+ {
6016
+ if (blockloop)
6017
+ return;
6018
+
6019
+ //if (GetTextures() != null)
6020
+ if (embed)
6021
+ CameraPane.EmbedTextures(GetTextures());
6022
+ else
6023
+ {
6024
+ GetTextures().pigmentdata = null;
6025
+ GetTextures().bumpdata = null;
6026
+ GetTextures().pw = 0;
6027
+ GetTextures().ph = 0;
6028
+ GetTextures().bw = 0;
6029
+ GetTextures().bh = 0;
6030
+ }
6031
+
6032
+ int nb = Size();
6033
+ for (int i = 0; i < nb; i++)
6034
+ {
6035
+ Object3D child = (Object3D) get(i);
6036
+
6037
+ if (child == null)
6038
+ continue;
6039
+
6040
+ blockloop = true;
6041
+ child.EmbedTextures(embed);
6042
+ blockloop = false;
6043
+ }
6044
+ }
6045
+
53726046 void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
53736047 {
53746048 Draw(display, root, selected, blocked);
....@@ -5377,12 +6051,28 @@
53776051 boolean NeedSupport()
53786052 {
53796053 return
5380
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
6054
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
53816055 // PROBLEM with CROWD!!
5382
- && (Globals.DrawMode() == iCameraPane.SHADOW || Globals.CROWD);
6056
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
53836057 }
53846058
53856059 static boolean DEBUG_SELECTION = false;
6060
+
6061
+ boolean IsLive()
6062
+ {
6063
+ if (live)
6064
+ return true;
6065
+
6066
+ if (parent == null)
6067
+ return false;
6068
+
6069
+ return parent.IsLive();
6070
+ }
6071
+
6072
+ boolean IsDynamic()
6073
+ {
6074
+ return live && bRep != null;
6075
+ }
53866076
53876077 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
53886078 {
....@@ -5394,7 +6084,7 @@
53946084 }
53956085
53966086 if (display.DrawMode() == iCameraPane.SELECTION &&
5397
- hide)
6087
+ (hide || dontselect))
53986088 return;
53996089
54006090 if (name != null && name.contains("sclera"))
....@@ -5444,8 +6134,11 @@
54446134 if (support != null)
54456135 support = support;
54466136
5447
- //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5448
- boolean usecalllists = false; // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
6137
+ boolean usecalllists = !IsDynamic() &&
6138
+ IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
6139
+ //boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
6140
+
6141
+ //usecalllists &= display.DrawMode() == display.DEFAULT; // Don't compute list in shadow pass.
54496142
54506143 if (!usecalllists && bRep != null && bRep.displaylist > 0)
54516144 {
....@@ -5455,8 +6148,9 @@
54556148 // usecalllists &= !(parent instanceof RandomNode);
54566149 // usecalllists = false;
54576150
5458
- if (GetBRep() != null)
5459
- usecalllists = usecalllists;
6151
+ if (display.DrawMode() == display.SHADOW)
6152
+ //GetBRep() != null)
6153
+ usecalllists = !!usecalllists;
54606154 //System.out.println("draw " + this);
54616155 //new Exception().printStackTrace();
54626156
....@@ -5465,10 +6159,12 @@
54656159 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
54666160
54676161 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5468
- (touched || (bRep != null && bRep.displaylist <= 0)))
6162
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
6163
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
54696164 {
54706165 Globals.lighttouched = true;
54716166 } // all panes...
6167
+
54726168 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
54736169 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
54746170 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5476,7 +6172,7 @@
54766172 if (!(this instanceof Composite))
54776173 touched = false;
54786174 //if (displaylist == -1 && usecalllists)
5479
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
6175
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
54806176 {
54816177 bRep.displaylist = display.GenList();
54826178 assert(bRep.displaylist != 0);
....@@ -5487,7 +6183,7 @@
54876183
54886184 //System.out.println("\tnew list " + list);
54896185 //gl.glDrawBuffer(gl.GL_NONE);
5490
- if (usecalllists)
6186
+ if (usecalllists && bRep.displaylist > 0)
54916187 {
54926188 // System.err.println("new list " + bRep.displaylist + " for " + this);
54936189 display.NewList(bRep.displaylist);
....@@ -5496,7 +6192,7 @@
54966192 CallList(display, root, selected, blocked);
54976193
54986194 // compiled = true;
5499
- if (usecalllists)
6195
+ if (usecalllists && bRep.displaylist > 0)
55006196 {
55016197 // System.err.println("end list " + bRep.displaylist + " for " + this);
55026198 display.EndList();
....@@ -5596,6 +6292,7 @@
55966292 if (GetBRep() != null)
55976293 {
55986294 display.NextIndex();
6295
+
55996296 // vertex color conflict : gl.glCallList(list);
56006297 DrawNode(display, root, selected);
56016298 if (this instanceof BezierPatch)
....@@ -5636,7 +6333,28 @@
56366333 tex = GetTextures();
56376334 }
56386335
5639
- display.BindTextures(tex, texres);
6336
+ boolean failedPigment = false;
6337
+ boolean failedBump = false;
6338
+
6339
+ try
6340
+ {
6341
+ display.BindPigmentTexture(tex, texres);
6342
+ }
6343
+ catch (Exception e)
6344
+ {
6345
+ System.err.println("FAILED: " + this);
6346
+ failedPigment = true;
6347
+ }
6348
+
6349
+ try
6350
+ {
6351
+ display.BindBumpTexture(tex, texres);
6352
+ }
6353
+ catch (Exception e)
6354
+ {
6355
+ //System.err.println("FAILED: " + this);
6356
+ failedBump = true;
6357
+ }
56406358
56416359 if (!compiled)
56426360 {
....@@ -5658,7 +6376,11 @@
56586376 }
56596377 }
56606378
5661
- display.ReleaseTextures(tex);
6379
+ if (!failedBump)
6380
+ display.ReleaseBumpTexture(tex);
6381
+
6382
+ if (!failedPigment)
6383
+ display.ReleasePigmentTexture(tex);
56626384
56636385 display.PopMaterial(this, selected);
56646386 }
....@@ -5787,6 +6509,9 @@
57876509
57886510 void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57896511 {
6512
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6513
+ return;
6514
+
57906515 if (hide)
57916516 return;
57926517 // shadow optimisation
....@@ -5912,6 +6637,9 @@
59126637 if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
59136638 return; // no shadow for transparent objects
59146639
6640
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6641
+ return;
6642
+
59156643 if (hide)
59166644 return;
59176645
....@@ -6025,6 +6753,11 @@
60256753 // dec 2012
60266754 new Exception().printStackTrace();
60276755 return;
6756
+ }
6757
+
6758
+ if (dontselect)
6759
+ {
6760
+ //bRep.GenerateNormalsMINE();
60286761 }
60296762
60306763 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -6810,20 +7543,23 @@
68107543 }
68117544 }
68127545
6813
- protected void calcHotSpot(cVector in, ClickInfo info, Point outPt, Rectangle outRec)
7546
+ static ClickInfo clickInfo = new ClickInfo();
7547
+
7548
+ protected void calcHotSpot(cVector in, //ClickInfo clickInfo,
7549
+ Point outPt, Rectangle outRec)
68147550 {
6815
- int hc = info.bounds.x + info.bounds.width / 2;
6816
- int vc = info.bounds.y + info.bounds.height / 2;
6817
- double[][] toscreen = info.toScreen;
7551
+ int hc = clickInfo.bounds.x + clickInfo.bounds.width / 2;
7552
+ int vc = clickInfo.bounds.y + clickInfo.bounds.height / 2;
7553
+ double[][] toscreen = clickInfo.toScreen;
68187554 if (toscreen == null)
68197555 {
6820
- toscreen = new Camera(info.camera.viewCode).toScreen;
7556
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
68217557 }
68227558 cVector vec = in;
68237559 LA.xformPos(in, toscreen, in);
68247560 //System.out.println("Distance = " + info.camera.Distance());
6825
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
6826
- vec.y *= 100 * info.camera.SCALE / info.camera.Distance();
7561
+ vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
7562
+ vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
68277563 outPt.x = hc + (int) vec.x;
68287564 outPt.y = vc - (int) vec.y;
68297565 outRec.x = outPt.x - 3;
....@@ -6831,15 +7567,18 @@
68317567 outRec.width = outRec.height = 6;
68327568 }
68337569
6834
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7570
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7571
+ )
68357572 {
68367573 Point pt = new Point(0, 0);
68377574 Rectangle rec = new Rectangle();
6838
- calcHotSpot(in, info, pt, rec);
7575
+ calcHotSpot(in, //clickInfo,
7576
+ pt, rec);
68397577 return rec;
68407578 }
68417579
6842
- void drawEditHandles0(ClickInfo info, int level)
7580
+ void drawEditHandles0(//ClickInfo clickInfo,
7581
+ int level)
68437582 {
68447583 if (level == 0)
68457584 {
....@@ -6848,16 +7587,19 @@
68487587 {
68497588 cVector origin = new cVector();
68507589 //LA.xformPos(origin, toParent, origin);
6851
- Rectangle spot = calcHotSpot(origin, info);
7590
+ if (this.clickInfo == null)
7591
+ this.clickInfo = new ClickInfo();
7592
+
7593
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
68527594 Rectangle boundary = new Rectangle();
68537595 boundary.x = spot.x - 30;
68547596 boundary.y = spot.y - 30;
68557597 boundary.width = spot.width + 60;
68567598 boundary.height = spot.height + 60;
6857
- info.g.setColor(Color.red);
7599
+ clickInfo.g.setColor(Color.white);
68587600 int spotw = spot.x + spot.width;
68597601 int spoth = spot.y + spot.height;
6860
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7602
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
68617603 // if (CameraPane.Xmin > spot.x)
68627604 // {
68637605 // CameraPane.Xmin = spot.x;
....@@ -6874,11 +7616,33 @@
68747616 // {
68757617 // CameraPane.Ymax = spoth;
68767618 // }
6877
- spot.translate(32, 32);
7619
+// if (CameraPane.Xmin > spot.x)
7620
+// {
7621
+// CameraPane.Xmin = spot.x;
7622
+// }
7623
+// if (CameraPane.Xmax < spotw)
7624
+// {
7625
+// CameraPane.Xmax = spotw;
7626
+// }
7627
+// if (CameraPane.Ymin > spot.y)
7628
+// {
7629
+// CameraPane.Ymin = spot.y;
7630
+// }
7631
+// if (CameraPane.Ymax < spoth)
7632
+// {
7633
+// CameraPane.Ymax = spoth;
7634
+// }
7635
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7636
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
7637
+ spot.translate(32, 0);
7638
+ clickInfo.g.setColor(Color.yellow);
7639
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7640
+
7641
+ spot.translate(32, 64);
68787642 spotw = spot.x + spot.width;
68797643 spoth = spot.y + spot.height;
6880
- info.g.setColor(Color.blue);
6881
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7644
+ clickInfo.g.setColor(Color.cyan);
7645
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
68827646 // if (CameraPane.Xmin > spot.x)
68837647 // {
68847648 // CameraPane.Xmin = spot.x;
....@@ -6895,29 +7659,9 @@
68957659 // {
68967660 // CameraPane.Ymax = spoth;
68977661 // }
6898
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
6899
- info.g.drawLine(spotw, spoth, spotw - 15, spoth);
6900
- spot.translate(0, -32);
6901
- info.g.setColor(Color.green);
6902
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
6903
-// if (CameraPane.Xmin > spot.x)
6904
-// {
6905
-// CameraPane.Xmin = spot.x;
6906
-// }
6907
-// if (CameraPane.Xmax < spotw)
6908
-// {
6909
-// CameraPane.Xmax = spotw;
6910
-// }
6911
-// if (CameraPane.Ymin > spot.y)
6912
-// {
6913
-// CameraPane.Ymin = spot.y;
6914
-// }
6915
-// if (CameraPane.Ymax < spoth)
6916
-// {
6917
-// CameraPane.Ymax = spoth;
6918
-// }
6919
- info.g.drawArc(boundary.x, boundary.y,
6920
- boundary.width, boundary.height, 0, 360);
7662
+ clickInfo.g.setColor(Color.green);
7663
+ clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
7664
+ (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
69217665 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
69227666 // if (CameraPane.Xmin > boundary.x)
69237667 // {
....@@ -6939,7 +7683,8 @@
69397683 }
69407684 }
69417685
6942
- boolean doEditClick0(ClickInfo info, int level)
7686
+ boolean doEditClick0(//ClickInfo clickInfo,
7687
+ int level)
69437688 {
69447689 if (level == 0)
69457690 {
....@@ -6948,10 +7693,10 @@
69487693
69497694 boolean retval = false;
69507695
6951
- startX = info.x;
6952
- startY = info.y;
7696
+ startX = clickInfo.x;
7697
+ startY = clickInfo.y;
69537698
6954
- hitSomething = 0;
7699
+ hitSomething = -1;
69557700 cVector origin = new cVector();
69567701 //LA.xformPos(origin, toParent, origin);
69577702 Rectangle spot = new Rectangle();
....@@ -6959,22 +7704,53 @@
69597704 {
69607705 centerPt = new Point(0, 0);
69617706 }
6962
- calcHotSpot(origin, info, centerPt, spot);
6963
- if (spot.contains(info.x, info.y))
7707
+ calcHotSpot(origin, //info,
7708
+ centerPt, spot);
7709
+ if (spot.contains(clickInfo.x, clickInfo.y))
69647710 {
69657711 hitSomething = hitCenter;
69667712 retval = true;
69677713 }
69687714 spot.translate(32, 0);
6969
- if (spot.contains(info.x, info.y))
7715
+ if (spot.contains(clickInfo.x, clickInfo.y))
69707716 {
69717717 hitSomething = hitRotate;
69727718 retval = true;
69737719 }
69747720 spot.translate(0, 32);
6975
- if (spot.contains(info.x, info.y))
7721
+ spot.translate(32, 0);
7722
+ spot.translate(0, 32);
7723
+ if (spot.contains(clickInfo.x, clickInfo.y))
69767724 {
69777725 hitSomething = hitScale;
7726
+
7727
+ double scale = 0.005f * clickInfo.camera.Distance();
7728
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
7729
+ double sign = 1;
7730
+ if (hScale < 0)
7731
+ {
7732
+ sign = -1;
7733
+ }
7734
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
7735
+ if (hScale < 0.01)
7736
+ {
7737
+ //hScale = 0.01;
7738
+ }
7739
+
7740
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
7741
+ sign = 1;
7742
+ if (vScale < 0)
7743
+ {
7744
+ sign = -1;
7745
+ }
7746
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
7747
+ if (vScale < 0.01)
7748
+ {
7749
+ //vScale = 0.01;
7750
+ }
7751
+
7752
+ clickInfo.scale = Math.sqrt(hScale*hScale + vScale*vScale);
7753
+
69787754 retval = true;
69797755 }
69807756
....@@ -6984,7 +7760,7 @@
69847760 }
69857761
69867762 //System.out.println("info.modifiers = " + info.modifiers);
6987
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7763
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
69887764 //System.out.println("modified = " + modified);
69897765 //new Exception().printStackTrace();
69907766 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7012,7 +7788,8 @@
70127788 return true;
70137789 }
70147790
7015
- void doEditDrag0(ClickInfo info, boolean opposite)
7791
+ void doEditDrag0(//ClickInfo info,
7792
+ boolean opposite)
70167793 {
70177794 if (hitSomething == 0)
70187795 {
....@@ -7026,7 +7803,8 @@
70267803
70277804 //System.out.println("hitSomething = " + hitSomething);
70287805
7029
- double scale = 0.005f * info.camera.Distance();
7806
+ double scale = 0.005f * clickInfo.camera.Distance();
7807
+
70307808 cVector xlate = new cVector();
70317809 //cVector xlate2 = new cVector();
70327810 switch (hitSomething)
....@@ -7039,7 +7817,9 @@
70397817
70407818 scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
70417819
7042
- if (modified || opposite)
7820
+ // Modified could snap
7821
+ if (//modified ||
7822
+ opposite)
70437823 {
70447824 //assert(false);
70457825 /*
....@@ -7059,8 +7839,8 @@
70597839 toParent[3][i] = xlate.get(i);
70607840 LA.matInvert(toParent, fromParent);
70617841 */
7062
- cVector delta = LA.newVector(0, 0, startY - info.y);
7063
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7842
+ cVector delta = LA.newVector(0, 0, startY - clickInfo.y);
7843
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
70647844
70657845 LA.matCopy(startMat, toParent);
70667846 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7069,7 +7849,7 @@
70697849 } else
70707850 {
70717851 //LA.xformDir(delta, info.camera.fromScreen, delta);
7072
- cVector up = new cVector(info.camera.up);
7852
+ cVector up = new cVector(clickInfo.camera.up);
70737853 cVector away = new cVector();
70747854 //cVector right2 = new cVector();
70757855 //LA.vecCross(up, cVector.Z, right);
....@@ -7086,19 +7866,19 @@
70867866 LA.xformDir(up, ClickInfo.matbuffer, up);
70877867 // if (!CameraPane.LOCALTRANSFORM)
70887868 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7089
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7869
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
70907870 // if (!CameraPane.LOCALTRANSFORM)
70917871 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
70927872 //LA.vecCross(up, cVector.Z, right2);
70937873
7094
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7874
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
70957875
70967876 //System.out.println("DELTA0 = " + delta);
70977877 //System.out.println("AWAY = " + info.camera.away);
70987878 //System.out.println("UP = " + info.camera.up);
70997879 if (away.z > 0)
71007880 {
7101
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7881
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
71027882 {
71037883 delta.x = -delta.x;
71047884 } else
....@@ -7113,7 +7893,7 @@
71137893 //System.out.println("DELTA1 = " + delta);
71147894 LA.xformDir(delta, ClickInfo.matbuffer, delta);
71157895 //System.out.println("DELTA2 = " + delta);
7116
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7896
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
71177897 LA.matCopy(startMat, toParent);
71187898 //System.out.println("DELTA3 = " + delta);
71197899 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7123,8 +7903,8 @@
71237903 break;
71247904
71257905 case hitRotate: // rotate
7126
- int dx = info.x - centerPt.x;
7127
- int dy = -(info.y - centerPt.y);
7906
+ int dx = clickInfo.x - centerPt.x;
7907
+ int dy = -(clickInfo.y - centerPt.y);
71287908 double angle = (double) Math.atan2(dx, dy);
71297909 angle = -(1.570796 - angle);
71307910
....@@ -7133,7 +7913,7 @@
71337913
71347914 if (modified)
71357915 {
7136
- // Rotate 90 degrees
7916
+ // Rotate 45 degrees
71377917 angle /= (Math.PI / 4);
71387918 angle = Math.floor(angle + 0.5);
71397919 angle *= (Math.PI / 4);
....@@ -7147,7 +7927,7 @@
71477927 }
71487928 /**/
71497929
7150
- switch (info.pane.RenderCamera().viewCode)
7930
+ switch (clickInfo.pane.RenderCamera().viewCode)
71517931 {
71527932 case 1: // '\001'
71537933 LA.matZRotate(toParent, angle);
....@@ -7174,26 +7954,30 @@
71747954 break;
71757955
71767956 case hitScale: // scale
7177
- double hScale = (double) (info.x - centerPt.x) / 32;
7957
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
7958
+ double sign = 1;
7959
+ if (hScale < 0)
7960
+ {
7961
+ sign = -1;
7962
+ }
7963
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
71787964 if (hScale < 0.01)
71797965 {
7180
- hScale = 0.01;
7966
+ //hScale = 0.01;
71817967 }
7182
- hScale = Math.pow(hScale, scale * 50);
7183
- if (hScale < 0.01)
7968
+
7969
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
7970
+ sign = 1;
7971
+ if (vScale < 0)
71847972 {
7185
- hScale = 0.01;
7973
+ sign = -1;
71867974 }
7187
- double vScale = (double) (info.y - centerPt.y) / 32;
7975
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
71887976 if (vScale < 0.01)
71897977 {
7190
- vScale = 0.01;
7978
+ //vScale = 0.01;
71917979 }
7192
- vScale = Math.pow(vScale, scale * 50);
7193
- if (vScale < 0.01)
7194
- {
7195
- vScale = 0.01;
7196
- }
7980
+
71977981 LA.matCopy(startMat, toParent);
71987982 /**/
71997983 for (int i = 0; i < 3; i++)
....@@ -7203,39 +7987,56 @@
72037987 }
72047988 /**/
72057989
7206
- switch (info.pane.RenderCamera().viewCode)
7990
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
7991
+
7992
+ if (totalScale < 0.01)
7993
+ {
7994
+ totalScale = 0.01;
7995
+ }
7996
+
7997
+ switch (clickInfo.pane.RenderCamera().viewCode)
72077998 {
72087999 case 3: // '\001'
7209
- if (modified)
8000
+ if (modified || opposite)
72108001 {
8002
+ if (modified) // && opposite)
8003
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
8004
+ else
72118005 //LA.matScale(toParent, 1, hScale, vScale);
7212
- LA.matScale(toParent, vScale, 1, 1);
8006
+ LA.matScale(toParent, totalScale, 1, 1);
72138007 } // vScale, 1);
72148008 else
72158009 {
7216
- LA.matScale(toParent, vScale, vScale, vScale);
8010
+ // EXCEPTION!
8011
+ LA.matScale(toParent, 1, totalScale, totalScale);
72178012 } // vScale, 1);
72188013 break;
72198014
72208015 case 2: // '\002'
7221
- if (modified)
8016
+ if (modified || opposite)
72228017 {
7223
- //LA.matScale(toParent, hScale, 1, vScale);
7224
- LA.matScale(toParent, 1, vScale, 1);
8018
+ if (modified) // && opposite)
8019
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
8020
+ else
8021
+ //LA.matScale(toParent, hScale, 1, vScale);
8022
+ LA.matScale(toParent, 1, totalScale, 1);
72258023 } else
72268024 {
7227
- LA.matScale(toParent, vScale, 1, vScale);
8025
+ LA.matScale(toParent, totalScale, 1, totalScale);
72288026 }
72298027 break;
72308028
72318029 case 1: // '\003'
7232
- if (modified)
8030
+ if (modified || opposite)
72338031 {
7234
- //LA.matScale(toParent, hScale, vScale, 1);
7235
- LA.matScale(toParent, 1, 1, vScale);
8032
+ if (modified) // && opposite)
8033
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
8034
+ else
8035
+ //LA.matScale(toParent, hScale, vScale, 1);
8036
+ LA.matScale(toParent, 1, 1, totalScale);
72368037 } else
72378038 {
7238
- LA.matScale(toParent, vScale, vScale, 1);
8039
+ LA.matScale(toParent, totalScale, totalScale, 1);
72398040 }
72408041 break;
72418042 }
....@@ -7269,7 +8070,7 @@
72698070 } // NEW ...
72708071
72718072
7272
- info.pane.repaint();
8073
+ clickInfo.pane.repaint();
72738074 }
72748075
72758076 boolean overflow = false;
....@@ -7368,14 +8169,22 @@
73688169 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
73698170 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
73708171 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
8172
+
8173
+ String objname;
8174
+
73718175 if (false) //parent != null)
73728176 {
7373
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
8177
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
73748178 } else
73758179 {
7376
- return GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ") ")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ +System.identityHashCode(this);
8180
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
73778181 } // + super.toString();
73788182 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
8183
+
8184
+// if (!Globals.ADVANCED)
8185
+// return objname;
8186
+
8187
+ return objname + " " + System.identityHashCode(this); // + GetUUID()
73798188 }
73808189
73818190 public int hashCode()
....@@ -7441,6 +8250,10 @@
74418250 editWindow = null;
74428251 } // ?
74438252 }
8253
+ else
8254
+ {
8255
+ //editWindow.closeUI();
8256
+ }
74448257 }
74458258
74468259 boolean root; // patch for edit windows
....@@ -7452,7 +8265,7 @@
74528265 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
74538266
74548267 Object3D /*Composite*/ parent;
7455
- Object3D /*Composite*/ fileparent;
8268
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
74568269
74578270 double[][] toParent; // dynamic matrix
74588271 double[][] fromParent;
....@@ -7567,7 +8380,7 @@
75678380 {
75688381 assert(bRep != null);
75698382 if (!(support instanceof GenericJoint)) // support.bRep != null)
7570
- GrafreeD.Assert(support.bRep == bRep.support);
8383
+ Grafreed.Assert(support.bRep == bRep.support);
75718384 }
75728385 else
75738386 {
....@@ -7598,6 +8411,10 @@
75988411 }
75998412
76008413 transient ObjEditor editWindow;
8414
+ transient ObjEditor manipWindow;
8415
+
8416
+ transient boolean pinned;
8417
+
76018418 transient ObjectUI objectUI;
76028419 public static int povDepth = 0;
76038420 private static cVector tbMin = new cVector();
....@@ -7616,9 +8433,9 @@
76168433 private static cVector edge2 = new cVector();
76178434 //private static cVector norm = new cVector();
76188435 /*transient private*/ int hitSomething;
7619
- private static final int hitCenter = 1;
7620
- private static final int hitScale = 2;
7621
- private static final int hitRotate = 3;
8436
+ static final int hitCenter = 1;
8437
+ static final int hitScale = 2;
8438
+ static final int hitRotate = 3;
76228439 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
76238440 /*transient*/ private Point centerPt;
76248441 /*transient*/ private int startX;