Normand Briere
2019-08-26 6266c8a4b2485b29a7d5bcb217460d7aad3e1c4a
Object3D.java
....@@ -22,15 +22,37 @@
2222 //static final long serialVersionUID = -607422624994562685L;
2323 static final long serialVersionUID = 5022536242724664900L;
2424
25
+ // Use GetUUID for backward compatibility with null.
2526 private UUID uuid = UUID.randomUUID();
2627
27
- // TEMPORARY for mocap undo
28
- mocap.reader.BVHReader.BVHResult bvh;
29
- Object3D skeleton;
28
+ // TEMPORARY for mocap undo. No need to be transient.
29
+ mocap.reader.BVHReader.BVHResult savebvh;
30
+ Object3D saveskeleton;
3031 //
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>();
3140
3241 ScriptNode scriptnode;
3342
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
+
3456 void InitOthers()
3557 {
3658 if (projectedVertices == null || projectedVertices.length <= 2)
....@@ -170,24 +192,35 @@
170192
171193 void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
172194 {
195
+ Object3D o;
196
+
173197 if (hashtable.containsKey(GetUUID()))
174198 {
175
- Object3D o = hashtable.get(GetUUID());
199
+ o = hashtable.get(GetUUID());
176200
177201 Grafreed.Assert(this.bRep == o.bRep);
178
- if (this.bRep != null)
179
- assert(this.bRep.support == o.transientrep);
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);
180210
181
- return;
211
+ hashtable.put(GetUUID(), o);
182212 }
183213
184
- Object3D o = new Object3D();
185
-
186
- hashtable.put(GetUUID(), o);
187
-
188
- for (int i=0; i<Size(); i++)
214
+ if (!blockloop)
189215 {
190
- get(i).ExtractBigData(hashtable);
216
+ blockloop = true;
217
+
218
+ for (int i=0; i<Size(); i++)
219
+ {
220
+ get(i).ExtractBigData(hashtable);
221
+ }
222
+
223
+ blockloop = false;
191224 }
192225
193226 ExtractBigData(o);
....@@ -195,11 +228,26 @@
195228
196229 void ExtractBigData(Object3D o)
197230 {
231
+ if (o.bRep != null)
232
+ Grafreed.Assert(o.bRep == this.bRep);
233
+
198234 o.bRep = this.bRep;
199
- if (this.bRep != null)
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)
200245 {
201
- o.transientrep = this.bRep.support;
202
- o.bRep.support = null;
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;
203251 }
204252
205253 // o.support = this.support;
....@@ -214,6 +262,73 @@
214262 // this.fileparent = null;
215263 }
216264
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
+
300
+ blockloop = true;
301
+
302
+ for (int i=0; i<Size(); i++)
303
+ {
304
+ get(i).TagObjects(o, tag);
305
+ }
306
+
307
+ blockloop = false;
308
+ }
309
+
310
+ boolean HasTags()
311
+ {
312
+ if (blockloop)
313
+ return false;
314
+
315
+ blockloop = true;
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
+
217332 void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
218333 {
219334 if (!hashtable.containsKey(GetUUID()))
....@@ -223,19 +338,35 @@
223338
224339 RestoreBigData(o);
225340
226
- hashtable.remove(GetUUID());
341
+ if (blockloop)
342
+ return;
343
+
344
+ blockloop = true;
345
+
346
+ //hashtable.remove(GetUUID());
227347
228348 for (int i=0; i<Size(); i++)
229349 {
230350 get(i).RestoreBigData(hashtable);
231351 }
352
+
353
+ blockloop = false;
232354 }
233355
234356 void RestoreBigData(Object3D o)
235357 {
236358 this.bRep = o.bRep;
237
- if (this.bRep != null)
238
- this.bRep.support = o.transientrep;
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;
239370 // this.support = o.support;
240371 // this.fileparent = o.fileparent;
241372 }
....@@ -381,6 +512,7 @@
381512 }
382513
383514 boolean live = false;
515
+ transient boolean keepdontselect;
384516 boolean dontselect = false;
385517 boolean hide = false;
386518 boolean link2master = false; // performs reset support/master at each frame
....@@ -449,11 +581,11 @@
449581 }
450582 }
451583
452
- int memorysize;
584
+ transient int memorysize; // needs to be transient, dunno why
453585
454586 int MemorySize()
455587 {
456
- if (true) // memorysize == 0)
588
+ if (memorysize == 0)
457589 {
458590 try
459591 {
....@@ -568,7 +700,7 @@
568700 {
569701 if (maxcount != 1)
570702 {
571
- new Exception().printStackTrace();
703
+ //new Exception().printStackTrace();
572704 }
573705
574706 toParentMarked = LA.newMatrix();
....@@ -881,7 +1013,7 @@
8811013
8821014 if (marked && Globals.isLIVE() && live &&
8831015 //TEMP21aug2018
884
- (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
1016
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
8851017 currentframe != Globals.framecount)
8861018 {
8871019 currentframe = Globals.framecount;
....@@ -966,6 +1098,10 @@
9661098 if (material == null || material.multiply)
9671099 return true;
9681100
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.
9691105 return material.opacity > 0.99;
9701106 }
9711107
....@@ -1366,6 +1502,7 @@
13661502 toParent = LA.newMatrix();
13671503 fromParent = LA.newMatrix();
13681504 }
1505
+
13691506 LA.matCopy(other.toParent, toParent);
13701507 LA.matCopy(other.fromParent, fromParent);
13711508
....@@ -2245,11 +2382,6 @@
22452382
22462383 InitOthers();
22472384
2248
- if (this instanceof Camera)
2249
- {
2250
- material.shift = 90;
2251
- }
2252
-
22532385 material.multiply = multiply;
22542386
22552387 if (multiply)
....@@ -2390,6 +2522,11 @@
23902522 else
23912523 {
23922524 //((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");
23932530 }
23942531 }
23952532
....@@ -2432,6 +2569,14 @@
24322569 {
24332570 editWindow.refreshContents();
24342571 }
2572
+ else
2573
+ {
2574
+ if (manipWindow != null)
2575
+ {
2576
+ manipWindow.refreshContents();
2577
+ }
2578
+ }
2579
+
24352580 //if (parent != null)
24362581 //parent.refreshEditWindow();
24372582 }
....@@ -2511,7 +2656,8 @@
25112656 private static final int editSelf = 1;
25122657 private static final int editChild = 2;
25132658
2514
- void drawEditHandles(ClickInfo info, int level)
2659
+ void drawEditHandles(//ClickInfo info,
2660
+ int level)
25152661 {
25162662 if (level == 0)
25172663 {
....@@ -2519,7 +2665,8 @@
25192665 return;
25202666
25212667 Object3D selectee;
2522
- 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))
25232670 {
25242671 selectee = (Object3D) e.nextElement();
25252672 }
....@@ -2527,19 +2674,22 @@
25272674 } else
25282675 {
25292676 //super.
2530
- drawEditHandles0(info, level + 1);
2677
+ drawEditHandles0(//info,
2678
+ level + 1);
25312679 }
25322680 }
25332681
2534
- boolean doEditClick(ClickInfo info, int level)
2682
+ boolean doEditClick(//ClickInfo info,
2683
+ int level)
25352684 {
25362685 doSomething = 0;
25372686 if (level == 0)
25382687 {
2539
- return doParentClick(info);
2688
+ return doParentClick(); //info);
25402689 }
25412690 if (//super.
2542
- doEditClick0(info, level))
2691
+ doEditClick0(//info,
2692
+ level))
25432693 {
25442694 doSomething = 1;
25452695 return true;
....@@ -2549,7 +2699,7 @@
25492699 }
25502700 }
25512701
2552
- boolean doParentClick(ClickInfo info)
2702
+ boolean doParentClick() //ClickInfo info)
25532703 {
25542704 if (selection == null)
25552705 {
....@@ -2562,7 +2712,8 @@
25622712 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
25632713 {
25642714 Object3D selectee = (Object3D) e.nextElement();
2565
- if (selectee.doEditClick(info, 1))
2715
+ if (selectee.doEditClick(//info,
2716
+ 1))
25662717 {
25672718 childToDrag = selectee;
25682719 doSomething = 2;
....@@ -2574,13 +2725,15 @@
25742725 return retval;
25752726 }
25762727
2577
- void doEditDrag(ClickInfo info, boolean opposite)
2728
+ void doEditDrag(//ClickInfo clickInfo,
2729
+ boolean opposite)
25782730 {
25792731 switch (doSomething)
25802732 {
25812733 case 1: // '\001'
25822734 //super.
2583
- doEditDrag0(info, opposite);
2735
+ doEditDrag0(//clickInfo,
2736
+ opposite);
25842737 break;
25852738
25862739 case 2: // '\002'
....@@ -2593,11 +2746,13 @@
25932746 {
25942747 //sel.hitSomething = childToDrag.hitSomething;
25952748 //childToDrag.doEditDrag(info);
2596
- sel.doEditDrag(info, opposite);
2749
+ sel.doEditDrag(//clickInfo,
2750
+ opposite);
25972751 } else
25982752 {
25992753 //super.
2600
- doEditDrag0(info, opposite);
2754
+ doEditDrag0(//clickInfo,
2755
+ opposite);
26012756 }
26022757 }
26032758 break;
....@@ -2615,6 +2770,9 @@
26152770 {
26162771 deselectAll();
26172772 }
2773
+
2774
+ new Exception().printStackTrace();
2775
+
26182776 ClickInfo newInfo = new ClickInfo();
26192777 newInfo.flags = info.flags;
26202778 newInfo.bounds = info.bounds;
....@@ -3062,7 +3220,7 @@
30623220 {
30633221 if (bRep != null)
30643222 {
3065
- bRep.GenerateNormalsMINE();
3223
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
30663224 Touch();
30673225 }
30683226 }
....@@ -3119,6 +3277,93 @@
31193277 blockloop = false;
31203278 }
31213279
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
+
31223367 void TransformChildren()
31233368 {
31243369 if (toParent != null)
....@@ -3472,15 +3717,47 @@
34723717
34733718 void ClearMaterials()
34743719 {
3720
+ if (blockloop)
3721
+ return;
3722
+
3723
+ blockloop = true;
3724
+
34753725 ClearMaterial();
3476
- for (int i = 0; i < size(); i++)
3726
+ for (int i = 0; i < Size(); i++)
34773727 {
3478
- Object3D child = (Object3D) reserve(i);
3728
+ Object3D child = (Object3D) get(i);
34793729 if (child == null)
34803730 continue;
34813731 child.ClearMaterials();
3482
- release(i);
34833732 }
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;
34843761 }
34853762
34863763 void FlipV(boolean flip)
....@@ -4962,6 +5239,14 @@
49625239 }
49635240 }
49645241
5242
+ ObjEditor GetWindow()
5243
+ {
5244
+ if (editWindow != null)
5245
+ return editWindow;
5246
+
5247
+ return manipWindow;
5248
+ }
5249
+
49655250 cTreePath Select(int indexcount, boolean deselect)
49665251 {
49675252 if (hide || dontselect)
....@@ -4998,10 +5283,11 @@
49985283 if (leaf != null)
49995284 {
50005285 cTreePath tp = new cTreePath(this, leaf);
5001
- if (editWindow != null)
5286
+ ObjEditor window = GetWindow();
5287
+ if (window != null)
50025288 {
50035289 //System.out.println("editWindow = " + editWindow + " vs " + this);
5004
- editWindow.Select(tp, deselect, true);
5290
+ window.Select(tp, deselect, true);
50055291 }
50065292
50075293 return tp;
....@@ -5018,6 +5304,7 @@
50185304
50195305 if (child == null)
50205306 continue;
5307
+
50215308 if (child.HasTransparency() && child.size() != 0)
50225309 {
50235310 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -5027,9 +5314,10 @@
50275314 if (leaf != null)
50285315 {
50295316 cTreePath tp = new cTreePath(this, leaf);
5030
- if (editWindow != null)
5317
+ ObjEditor window = GetWindow();
5318
+ if (window != null)
50315319 {
5032
- editWindow.Select(tp, deselect, true);
5320
+ window.Select(tp, deselect, true);
50335321 }
50345322
50355323 return tp;
....@@ -5354,6 +5642,51 @@
53545642 blockloop = false;
53555643 }
53565644
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
+
53575690 boolean IsSelected()
53585691 {
53595692 if (parent == null)
....@@ -5414,6 +5747,11 @@
54145747 if (fullname == null)
54155748 return "";
54165749
5750
+ if (fullname.pigment != null)
5751
+ {
5752
+ return fullname.pigment;
5753
+ }
5754
+
54175755 // System.out.println("Fullname = " + fullname);
54185756
54195757 // Does not work on Windows due to C:
....@@ -5426,7 +5764,7 @@
54265764
54275765 if (split.length == 0)
54285766 {
5429
- return "";
5767
+ return fullname.pigment = "";
54305768 }
54315769
54325770 if (split.length <= 2)
....@@ -5434,22 +5772,27 @@
54345772 if (fullname.name.endsWith(":"))
54355773 {
54365774 // Windows
5437
- return fullname.name.substring(0, fullname.name.length()-1);
5775
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
54385776 }
54395777
5440
- return split[0];
5778
+ return fullname.pigment = split[0];
54415779 }
54425780
54435781 // Windows
54445782 assert(split.length == 4);
54455783
5446
- return split[0] + ":" + split[1];
5784
+ return fullname.pigment = split[0] + ":" + split[1];
54475785 }
54485786
54495787 static String GetBump(cTexture fullname)
54505788 {
54515789 if (fullname == null)
54525790 return "";
5791
+
5792
+ if (fullname.bump != null)
5793
+ {
5794
+ return fullname.bump;
5795
+ }
54535796
54545797 // System.out.println("Fullname = " + fullname);
54555798 // Does not work on Windows due to C:
....@@ -5461,12 +5804,12 @@
54615804
54625805 if (split.length == 0)
54635806 {
5464
- return "";
5807
+ return fullname.bump = "";
54655808 }
54665809
54675810 if (split.length == 1)
54685811 {
5469
- return "";
5812
+ return fullname.bump = "";
54705813 }
54715814
54725815 if (split.length == 2)
....@@ -5474,16 +5817,16 @@
54745817 if (fullname.name.endsWith(":"))
54755818 {
54765819 // Windows
5477
- return "";
5820
+ return fullname.bump = "";
54785821 }
54795822
5480
- return split[1];
5823
+ return fullname.bump = split[1];
54815824 }
54825825
54835826 // Windows
54845827 assert(split.length == 4);
54855828
5486
- return split[2] + ":" + split[3];
5829
+ return fullname.bump = split[2] + ":" + split[3];
54875830 }
54885831
54895832 String GetPigmentTexture()
....@@ -5566,6 +5909,9 @@
55665909 texname = "";
55675910
55685911 GetTextures().name = texname + ":" + GetBump(GetTextures());
5912
+
5913
+ GetTextures().pigment = null;
5914
+
55695915 Touch();
55705916 }
55715917
....@@ -5639,6 +5985,8 @@
56395985
56405986 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
56415987
5988
+ GetTextures().bump = null;
5989
+
56425990 Touch();
56435991 }
56445992
....@@ -5659,6 +6007,38 @@
56596007
56606008 blockloop = true;
56616009 child.ResetBumpTexture();
6010
+ blockloop = false;
6011
+ }
6012
+ }
6013
+
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);
56626042 blockloop = false;
56636043 }
56646044 }
....@@ -5687,6 +6067,11 @@
56876067 return false;
56886068
56896069 return parent.IsLive();
6070
+ }
6071
+
6072
+ boolean IsDynamic()
6073
+ {
6074
+ return live && bRep != null;
56906075 }
56916076
56926077 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
....@@ -5749,8 +6134,11 @@
57496134 if (support != null)
57506135 support = support;
57516136
5752
- //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5753
- boolean usecalllists = IsLive(); // 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.
57546142
57556143 if (!usecalllists && bRep != null && bRep.displaylist > 0)
57566144 {
....@@ -5760,8 +6148,9 @@
57606148 // usecalllists &= !(parent instanceof RandomNode);
57616149 // usecalllists = false;
57626150
5763
- if (GetBRep() != null)
5764
- usecalllists = usecalllists;
6151
+ if (display.DrawMode() == display.SHADOW)
6152
+ //GetBRep() != null)
6153
+ usecalllists = !!usecalllists;
57656154 //System.out.println("draw " + this);
57666155 //new Exception().printStackTrace();
57676156
....@@ -5771,7 +6160,7 @@
57716160
57726161 if (!selectmode && //display.DrawMode() != display.SELECTION &&
57736162 //(touched || (bRep != null && bRep.displaylist <= 0)))
5774
- (Globals.isLIVE() || touched && (bRep != null && bRep.displaylist <= 0)))
6163
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
57756164 {
57766165 Globals.lighttouched = true;
57776166 } // all panes...
....@@ -5783,7 +6172,7 @@
57836172 if (!(this instanceof Composite))
57846173 touched = false;
57856174 //if (displaylist == -1 && usecalllists)
5786
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
6175
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
57876176 {
57886177 bRep.displaylist = display.GenList();
57896178 assert(bRep.displaylist != 0);
....@@ -5794,7 +6183,7 @@
57946183
57956184 //System.out.println("\tnew list " + list);
57966185 //gl.glDrawBuffer(gl.GL_NONE);
5797
- if (usecalllists)
6186
+ if (usecalllists && bRep.displaylist > 0)
57986187 {
57996188 // System.err.println("new list " + bRep.displaylist + " for " + this);
58006189 display.NewList(bRep.displaylist);
....@@ -5803,7 +6192,7 @@
58036192 CallList(display, root, selected, blocked);
58046193
58056194 // compiled = true;
5806
- if (usecalllists)
6195
+ if (usecalllists && bRep.displaylist > 0)
58076196 {
58086197 // System.err.println("end list " + bRep.displaylist + " for " + this);
58096198 display.EndList();
....@@ -5903,6 +6292,7 @@
59036292 if (GetBRep() != null)
59046293 {
59056294 display.NextIndex();
6295
+
59066296 // vertex color conflict : gl.glCallList(list);
59076297 DrawNode(display, root, selected);
59086298 if (this instanceof BezierPatch)
....@@ -7153,20 +7543,23 @@
71537543 }
71547544 }
71557545
7156
- 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)
71577550 {
7158
- int hc = info.bounds.x + info.bounds.width / 2;
7159
- int vc = info.bounds.y + info.bounds.height / 2;
7160
- 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;
71617554 if (toscreen == null)
71627555 {
7163
- toscreen = new Camera(info.camera.viewCode).toScreen;
7556
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
71647557 }
71657558 cVector vec = in;
71667559 LA.xformPos(in, toscreen, in);
71677560 //System.out.println("Distance = " + info.camera.Distance());
7168
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
7169
- 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();
71707563 outPt.x = hc + (int) vec.x;
71717564 outPt.y = vc - (int) vec.y;
71727565 outRec.x = outPt.x - 3;
....@@ -7174,15 +7567,18 @@
71747567 outRec.width = outRec.height = 6;
71757568 }
71767569
7177
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7570
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7571
+ )
71787572 {
71797573 Point pt = new Point(0, 0);
71807574 Rectangle rec = new Rectangle();
7181
- calcHotSpot(in, info, pt, rec);
7575
+ calcHotSpot(in, //clickInfo,
7576
+ pt, rec);
71827577 return rec;
71837578 }
71847579
7185
- void drawEditHandles0(ClickInfo info, int level)
7580
+ void drawEditHandles0(//ClickInfo clickInfo,
7581
+ int level)
71867582 {
71877583 if (level == 0)
71887584 {
....@@ -7191,16 +7587,19 @@
71917587 {
71927588 cVector origin = new cVector();
71937589 //LA.xformPos(origin, toParent, origin);
7194
- Rectangle spot = calcHotSpot(origin, info);
7590
+ if (this.clickInfo == null)
7591
+ this.clickInfo = new ClickInfo();
7592
+
7593
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
71957594 Rectangle boundary = new Rectangle();
71967595 boundary.x = spot.x - 30;
71977596 boundary.y = spot.y - 30;
71987597 boundary.width = spot.width + 60;
71997598 boundary.height = spot.height + 60;
7200
- info.g.setColor(Color.red);
7599
+ clickInfo.g.setColor(Color.white);
72017600 int spotw = spot.x + spot.width;
72027601 int spoth = spot.y + spot.height;
7203
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7602
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
72047603 // if (CameraPane.Xmin > spot.x)
72057604 // {
72067605 // CameraPane.Xmin = spot.x;
....@@ -7217,11 +7616,6 @@
72177616 // {
72187617 // CameraPane.Ymax = spoth;
72197618 // }
7220
- spot.translate(32, 32);
7221
- spotw = spot.x + spot.width;
7222
- spoth = spot.y + spot.height;
7223
- info.g.setColor(Color.cyan);
7224
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
72257619 // if (CameraPane.Xmin > spot.x)
72267620 // {
72277621 // CameraPane.Xmin = spot.x;
....@@ -7240,10 +7634,15 @@
72407634 // }
72417635 // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
72427636 //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
7243
- spot.translate(0, -32);
7244
- info.g.setColor(Color.yellow);
7245
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7246
- info.g.setColor(Color.green);
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);
7642
+ spotw = spot.x + spot.width;
7643
+ spoth = spot.y + spot.height;
7644
+ clickInfo.g.setColor(Color.cyan);
7645
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
72477646 // if (CameraPane.Xmin > spot.x)
72487647 // {
72497648 // CameraPane.Xmin = spot.x;
....@@ -7260,8 +7659,9 @@
72607659 // {
72617660 // CameraPane.Ymax = spoth;
72627661 // }
7263
- info.g.drawArc(boundary.x, boundary.y,
7264
- 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);
72657665 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
72667666 // if (CameraPane.Xmin > boundary.x)
72677667 // {
....@@ -7283,7 +7683,8 @@
72837683 }
72847684 }
72857685
7286
- boolean doEditClick0(ClickInfo info, int level)
7686
+ boolean doEditClick0(//ClickInfo clickInfo,
7687
+ int level)
72877688 {
72887689 if (level == 0)
72897690 {
....@@ -7292,8 +7693,8 @@
72927693
72937694 boolean retval = false;
72947695
7295
- startX = info.x;
7296
- startY = info.y;
7696
+ startX = clickInfo.x;
7697
+ startY = clickInfo.y;
72977698
72987699 hitSomething = -1;
72997700 cVector origin = new cVector();
....@@ -7303,22 +7704,53 @@
73037704 {
73047705 centerPt = new Point(0, 0);
73057706 }
7306
- calcHotSpot(origin, info, centerPt, spot);
7307
- if (spot.contains(info.x, info.y))
7707
+ calcHotSpot(origin, //info,
7708
+ centerPt, spot);
7709
+ if (spot.contains(clickInfo.x, clickInfo.y))
73087710 {
73097711 hitSomething = hitCenter;
73107712 retval = true;
73117713 }
73127714 spot.translate(32, 0);
7313
- if (spot.contains(info.x, info.y))
7715
+ if (spot.contains(clickInfo.x, clickInfo.y))
73147716 {
73157717 hitSomething = hitRotate;
73167718 retval = true;
73177719 }
73187720 spot.translate(0, 32);
7319
- 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))
73207724 {
73217725 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
+
73227754 retval = true;
73237755 }
73247756
....@@ -7328,7 +7760,7 @@
73287760 }
73297761
73307762 //System.out.println("info.modifiers = " + info.modifiers);
7331
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7763
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
73327764 //System.out.println("modified = " + modified);
73337765 //new Exception().printStackTrace();
73347766 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7356,7 +7788,8 @@
73567788 return true;
73577789 }
73587790
7359
- void doEditDrag0(ClickInfo info, boolean opposite)
7791
+ void doEditDrag0(//ClickInfo info,
7792
+ boolean opposite)
73607793 {
73617794 if (hitSomething == 0)
73627795 {
....@@ -7370,7 +7803,7 @@
73707803
73717804 //System.out.println("hitSomething = " + hitSomething);
73727805
7373
- double scale = 0.005f * info.camera.Distance();
7806
+ double scale = 0.005f * clickInfo.camera.Distance();
73747807
73757808 cVector xlate = new cVector();
73767809 //cVector xlate2 = new cVector();
....@@ -7384,7 +7817,9 @@
73847817
73857818 scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
73867819
7387
- if (modified || opposite)
7820
+ // Modified could snap
7821
+ if (//modified ||
7822
+ opposite)
73887823 {
73897824 //assert(false);
73907825 /*
....@@ -7404,8 +7839,8 @@
74047839 toParent[3][i] = xlate.get(i);
74057840 LA.matInvert(toParent, fromParent);
74067841 */
7407
- cVector delta = LA.newVector(0, 0, startY - info.y);
7408
- 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);
74097844
74107845 LA.matCopy(startMat, toParent);
74117846 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7414,7 +7849,7 @@
74147849 } else
74157850 {
74167851 //LA.xformDir(delta, info.camera.fromScreen, delta);
7417
- cVector up = new cVector(info.camera.up);
7852
+ cVector up = new cVector(clickInfo.camera.up);
74187853 cVector away = new cVector();
74197854 //cVector right2 = new cVector();
74207855 //LA.vecCross(up, cVector.Z, right);
....@@ -7431,19 +7866,19 @@
74317866 LA.xformDir(up, ClickInfo.matbuffer, up);
74327867 // if (!CameraPane.LOCALTRANSFORM)
74337868 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7434
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7869
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
74357870 // if (!CameraPane.LOCALTRANSFORM)
74367871 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
74377872 //LA.vecCross(up, cVector.Z, right2);
74387873
7439
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7874
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
74407875
74417876 //System.out.println("DELTA0 = " + delta);
74427877 //System.out.println("AWAY = " + info.camera.away);
74437878 //System.out.println("UP = " + info.camera.up);
74447879 if (away.z > 0)
74457880 {
7446
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7881
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
74477882 {
74487883 delta.x = -delta.x;
74497884 } else
....@@ -7458,7 +7893,7 @@
74587893 //System.out.println("DELTA1 = " + delta);
74597894 LA.xformDir(delta, ClickInfo.matbuffer, delta);
74607895 //System.out.println("DELTA2 = " + delta);
7461
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7896
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
74627897 LA.matCopy(startMat, toParent);
74637898 //System.out.println("DELTA3 = " + delta);
74647899 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7468,8 +7903,8 @@
74687903 break;
74697904
74707905 case hitRotate: // rotate
7471
- int dx = info.x - centerPt.x;
7472
- int dy = -(info.y - centerPt.y);
7906
+ int dx = clickInfo.x - centerPt.x;
7907
+ int dy = -(clickInfo.y - centerPt.y);
74737908 double angle = (double) Math.atan2(dx, dy);
74747909 angle = -(1.570796 - angle);
74757910
....@@ -7478,7 +7913,7 @@
74787913
74797914 if (modified)
74807915 {
7481
- // Rotate 90 degrees
7916
+ // Rotate 45 degrees
74827917 angle /= (Math.PI / 4);
74837918 angle = Math.floor(angle + 0.5);
74847919 angle *= (Math.PI / 4);
....@@ -7492,7 +7927,7 @@
74927927 }
74937928 /**/
74947929
7495
- switch (info.pane.RenderCamera().viewCode)
7930
+ switch (clickInfo.pane.RenderCamera().viewCode)
74967931 {
74977932 case 1: // '\001'
74987933 LA.matZRotate(toParent, angle);
....@@ -7519,7 +7954,7 @@
75197954 break;
75207955
75217956 case hitScale: // scale
7522
- double hScale = (double) (info.x - centerPt.x) / 32;
7957
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
75237958 double sign = 1;
75247959 if (hScale < 0)
75257960 {
....@@ -7531,7 +7966,7 @@
75317966 //hScale = 0.01;
75327967 }
75337968
7534
- double vScale = (double) (info.y - centerPt.y) / 32;
7969
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
75357970 sign = 1;
75367971 if (vScale < 0)
75377972 {
....@@ -7542,6 +7977,7 @@
75427977 {
75437978 //vScale = 0.01;
75447979 }
7980
+
75457981 LA.matCopy(startMat, toParent);
75467982 /**/
75477983 for (int i = 0; i < 3; i++)
....@@ -7551,33 +7987,39 @@
75517987 }
75527988 /**/
75537989
7554
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7990
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
75557991
75567992 if (totalScale < 0.01)
75577993 {
75587994 totalScale = 0.01;
75597995 }
75607996
7561
- switch (info.pane.RenderCamera().viewCode)
7997
+ switch (clickInfo.pane.RenderCamera().viewCode)
75627998 {
75637999 case 3: // '\001'
75648000 if (modified || opposite)
75658001 {
8002
+ if (modified) // && opposite)
8003
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
8004
+ else
75668005 //LA.matScale(toParent, 1, hScale, vScale);
7567
- LA.matScale(toParent, totalScale, 1, 1);
8006
+ LA.matScale(toParent, totalScale, 1, 1);
75688007 } // vScale, 1);
75698008 else
75708009 {
75718010 // EXCEPTION!
7572
- LA.matScale(toParent, totalScale, totalScale, totalScale);
8011
+ LA.matScale(toParent, 1, totalScale, totalScale);
75738012 } // vScale, 1);
75748013 break;
75758014
75768015 case 2: // '\002'
75778016 if (modified || opposite)
75788017 {
7579
- //LA.matScale(toParent, hScale, 1, vScale);
7580
- LA.matScale(toParent, 1, totalScale, 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);
75818023 } else
75828024 {
75838025 LA.matScale(toParent, totalScale, 1, totalScale);
....@@ -7587,8 +8029,11 @@
75878029 case 1: // '\003'
75888030 if (modified || opposite)
75898031 {
7590
- //LA.matScale(toParent, hScale, vScale, 1);
7591
- LA.matScale(toParent, 1, 1, totalScale);
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);
75928037 } else
75938038 {
75948039 LA.matScale(toParent, totalScale, totalScale, 1);
....@@ -7625,7 +8070,7 @@
76258070 } // NEW ...
76268071
76278072
7628
- info.pane.repaint();
8073
+ clickInfo.pane.repaint();
76298074 }
76308075
76318076 boolean overflow = false;
....@@ -7736,10 +8181,10 @@
77368181 } // + super.toString();
77378182 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
77388183
7739
- if (!Globals.ADVANCED)
7740
- return objname;
8184
+// if (!Globals.ADVANCED)
8185
+// return objname;
77418186
7742
- return objname + " " + System.identityHashCode(this);
8187
+ return objname + " " + System.identityHashCode(this); // + GetUUID()
77438188 }
77448189
77458190 public int hashCode()
....@@ -7966,6 +8411,10 @@
79668411 }
79678412
79688413 transient ObjEditor editWindow;
8414
+ transient ObjEditor manipWindow;
8415
+
8416
+ transient boolean pinned;
8417
+
79698418 transient ObjectUI objectUI;
79708419 public static int povDepth = 0;
79718420 private static cVector tbMin = new cVector();