Normand Briere
2019-08-22 0c7b833be7d86598a6813cd1c6db0ca9e1b17966
Object3D.java
....@@ -36,6 +36,8 @@
3636 Object3D versionlist[];
3737 int versionindex = -1;
3838
39
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable; // = new java.util.Hashtable<java.util.UUID, Object3D>();
40
+
3941 ScriptNode scriptnode;
4042
4143 void InitOthers()
....@@ -269,6 +271,50 @@
269271 //
270272 // return null;
271273 // }
274
+
275
+ transient boolean tag;
276
+
277
+ void TagObjects(Object3D o, boolean tag)
278
+ {
279
+ if (blockloop)
280
+ return;
281
+
282
+ o.tag = tag;
283
+
284
+ if (o == this)
285
+ return;
286
+
287
+ blockloop = true;
288
+
289
+ for (int i=0; i<Size(); i++)
290
+ {
291
+ get(i).TagObjects(o, tag);
292
+ }
293
+
294
+ blockloop = false;
295
+ }
296
+
297
+ boolean HasTags()
298
+ {
299
+ if (blockloop)
300
+ return false;
301
+
302
+ blockloop = true;
303
+
304
+ boolean hasTags = false;
305
+
306
+ for (int i=0; i<Size(); i++)
307
+ {
308
+ hasTags |= get(i).tag || get(i).HasTags();
309
+
310
+ if (hasTags)
311
+ break;
312
+ }
313
+
314
+ blockloop = false;
315
+
316
+ return hasTags;
317
+ }
272318
273319 void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
274320 {
....@@ -2468,6 +2514,11 @@
24682514 else
24692515 {
24702516 //((ObjEditor)editWindow).SetupUI2(null);
2517
+ if (objectUI != null)
2518
+ ((ObjEditor)objectUI).pinButton.setSelected(pinned);
2519
+ else
2520
+ //new Exception().printStackTrace();
2521
+ System.err.println("objectUI is null");
24712522 }
24722523 }
24732524
....@@ -3571,15 +3622,47 @@
35713622
35723623 void ClearMaterials()
35733624 {
3625
+ if (blockloop)
3626
+ return;
3627
+
3628
+ blockloop = true;
3629
+
35743630 ClearMaterial();
3575
- for (int i = 0; i < size(); i++)
3631
+ for (int i = 0; i < Size(); i++)
35763632 {
3577
- Object3D child = (Object3D) reserve(i);
3633
+ Object3D child = (Object3D) get(i);
35783634 if (child == null)
35793635 continue;
35803636 child.ClearMaterials();
3581
- release(i);
35823637 }
3638
+
3639
+ blockloop = false;
3640
+ }
3641
+
3642
+ void ClearVersionList()
3643
+ {
3644
+ this.versionlist = null;
3645
+ this.versionindex = -1;
3646
+ this.versiontable = null;
3647
+ }
3648
+
3649
+ void ClearVersions()
3650
+ {
3651
+ if (blockloop)
3652
+ return;
3653
+
3654
+ blockloop = true;
3655
+
3656
+ ClearVersionList();
3657
+ for (int i = 0; i < Size(); i++)
3658
+ {
3659
+ Object3D child = (Object3D) get(i);
3660
+ if (child == null)
3661
+ continue;
3662
+ child.ClearVersions();
3663
+ }
3664
+
3665
+ blockloop = false;
35833666 }
35843667
35853668 void FlipV(boolean flip)
....@@ -5569,6 +5652,11 @@
55695652 if (fullname == null)
55705653 return "";
55715654
5655
+ if (fullname.pigment != null)
5656
+ {
5657
+ return fullname.pigment;
5658
+ }
5659
+
55725660 // System.out.println("Fullname = " + fullname);
55735661
55745662 // Does not work on Windows due to C:
....@@ -5581,7 +5669,7 @@
55815669
55825670 if (split.length == 0)
55835671 {
5584
- return "";
5672
+ return fullname.pigment = "";
55855673 }
55865674
55875675 if (split.length <= 2)
....@@ -5589,22 +5677,27 @@
55895677 if (fullname.name.endsWith(":"))
55905678 {
55915679 // Windows
5592
- return fullname.name.substring(0, fullname.name.length()-1);
5680
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
55935681 }
55945682
5595
- return split[0];
5683
+ return fullname.pigment = split[0];
55965684 }
55975685
55985686 // Windows
55995687 assert(split.length == 4);
56005688
5601
- return split[0] + ":" + split[1];
5689
+ return fullname.pigment = split[0] + ":" + split[1];
56025690 }
56035691
56045692 static String GetBump(cTexture fullname)
56055693 {
56065694 if (fullname == null)
56075695 return "";
5696
+
5697
+ if (fullname.bump != null)
5698
+ {
5699
+ return fullname.bump;
5700
+ }
56085701
56095702 // System.out.println("Fullname = " + fullname);
56105703 // Does not work on Windows due to C:
....@@ -5616,12 +5709,12 @@
56165709
56175710 if (split.length == 0)
56185711 {
5619
- return "";
5712
+ return fullname.bump = "";
56205713 }
56215714
56225715 if (split.length == 1)
56235716 {
5624
- return "";
5717
+ return fullname.bump = "";
56255718 }
56265719
56275720 if (split.length == 2)
....@@ -5629,16 +5722,16 @@
56295722 if (fullname.name.endsWith(":"))
56305723 {
56315724 // Windows
5632
- return "";
5725
+ return fullname.bump = "";
56335726 }
56345727
5635
- return split[1];
5728
+ return fullname.bump = split[1];
56365729 }
56375730
56385731 // Windows
56395732 assert(split.length == 4);
56405733
5641
- return split[2] + ":" + split[3];
5734
+ return fullname.bump = split[2] + ":" + split[3];
56425735 }
56435736
56445737 String GetPigmentTexture()
....@@ -5721,6 +5814,9 @@
57215814 texname = "";
57225815
57235816 GetTextures().name = texname + ":" + GetBump(GetTextures());
5817
+
5818
+ GetTextures().pigment = null;
5819
+
57245820 Touch();
57255821 }
57265822
....@@ -5793,6 +5889,8 @@
57935889 texname = "";
57945890
57955891 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
5892
+
5893
+ GetTextures().bump = null;
57965894
57975895 Touch();
57985896 }
....@@ -7397,7 +7495,7 @@
73977495 boundary.y = spot.y - 30;
73987496 boundary.width = spot.width + 60;
73997497 boundary.height = spot.height + 60;
7400
- clickInfo.g.setColor(Color.red);
7498
+ clickInfo.g.setColor(Color.white);
74017499 int spotw = spot.x + spot.width;
74027500 int spoth = spot.y + spot.height;
74037501 clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
....@@ -7417,7 +7515,29 @@
74177515 // {
74187516 // CameraPane.Ymax = spoth;
74197517 // }
7420
- spot.translate(32, 32);
7518
+// if (CameraPane.Xmin > spot.x)
7519
+// {
7520
+// CameraPane.Xmin = spot.x;
7521
+// }
7522
+// if (CameraPane.Xmax < spotw)
7523
+// {
7524
+// CameraPane.Xmax = spotw;
7525
+// }
7526
+// if (CameraPane.Ymin > spot.y)
7527
+// {
7528
+// CameraPane.Ymin = spot.y;
7529
+// }
7530
+// if (CameraPane.Ymax < spoth)
7531
+// {
7532
+// CameraPane.Ymax = spoth;
7533
+// }
7534
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7535
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
7536
+ spot.translate(32, 0);
7537
+ clickInfo.g.setColor(Color.yellow);
7538
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7539
+
7540
+ spot.translate(32, 64);
74217541 spotw = spot.x + spot.width;
74227542 spoth = spot.y + spot.height;
74237543 clickInfo.g.setColor(Color.cyan);
....@@ -7438,28 +7558,7 @@
74387558 // {
74397559 // CameraPane.Ymax = spoth;
74407560 // }
7441
- // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7442
- //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
7443
- spot.translate(0, -32);
7444
- clickInfo.g.setColor(Color.yellow);
7445
- clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
74467561 clickInfo.g.setColor(Color.green);
7447
-// if (CameraPane.Xmin > spot.x)
7448
-// {
7449
-// CameraPane.Xmin = spot.x;
7450
-// }
7451
-// if (CameraPane.Xmax < spotw)
7452
-// {
7453
-// CameraPane.Xmax = spotw;
7454
-// }
7455
-// if (CameraPane.Ymin > spot.y)
7456
-// {
7457
-// CameraPane.Ymin = spot.y;
7458
-// }
7459
-// if (CameraPane.Ymax < spoth)
7460
-// {
7461
-// CameraPane.Ymax = spoth;
7462
-// }
74637562 clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
74647563 (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
74657564 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
....@@ -7518,12 +7617,14 @@
75187617 retval = true;
75197618 }
75207619 spot.translate(0, 32);
7620
+ spot.translate(32, 0);
7621
+ spot.translate(0, 32);
75217622 if (spot.contains(clickInfo.x, clickInfo.y))
75227623 {
75237624 hitSomething = hitScale;
75247625
75257626 double scale = 0.005f * clickInfo.camera.Distance();
7526
- double hScale = (double) (clickInfo.x - centerPt.x) / 32;
7627
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
75277628 double sign = 1;
75287629 if (hScale < 0)
75297630 {
....@@ -7535,7 +7636,7 @@
75357636 //hScale = 0.01;
75367637 }
75377638
7538
- double vScale = (double) (clickInfo.y - centerPt.y) / 32;
7639
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
75397640 sign = 1;
75407641 if (vScale < 0)
75417642 {
....@@ -7750,7 +7851,7 @@
77507851 break;
77517852
77527853 case hitScale: // scale
7753
- double hScale = (double) (clickInfo.x - centerPt.x) / 32;
7854
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
77547855 double sign = 1;
77557856 if (hScale < 0)
77567857 {
....@@ -7762,7 +7863,7 @@
77627863 //hScale = 0.01;
77637864 }
77647865
7765
- double vScale = (double) (clickInfo.y - centerPt.y) / 32;
7866
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
77667867 sign = 1;
77677868 if (vScale < 0)
77687869 {
....@@ -7795,21 +7896,27 @@
77957896 case 3: // '\001'
77967897 if (modified || opposite)
77977898 {
7899
+ if (modified && opposite)
7900
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7901
+ else
77987902 //LA.matScale(toParent, 1, hScale, vScale);
7799
- LA.matScale(toParent, totalScale, 1, 1);
7903
+ LA.matScale(toParent, totalScale, 1, 1);
78007904 } // vScale, 1);
78017905 else
78027906 {
78037907 // EXCEPTION!
7804
- LA.matScale(toParent, totalScale, totalScale, totalScale);
7908
+ LA.matScale(toParent, 1, totalScale, totalScale);
78057909 } // vScale, 1);
78067910 break;
78077911
78087912 case 2: // '\002'
78097913 if (modified || opposite)
78107914 {
7811
- //LA.matScale(toParent, hScale, 1, vScale);
7812
- LA.matScale(toParent, 1, totalScale, 1);
7915
+ if (modified && opposite)
7916
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7917
+ else
7918
+ //LA.matScale(toParent, hScale, 1, vScale);
7919
+ LA.matScale(toParent, 1, totalScale, 1);
78137920 } else
78147921 {
78157922 LA.matScale(toParent, totalScale, 1, totalScale);
....@@ -7819,8 +7926,11 @@
78197926 case 1: // '\003'
78207927 if (modified || opposite)
78217928 {
7822
- //LA.matScale(toParent, hScale, vScale, 1);
7823
- LA.matScale(toParent, 1, 1, totalScale);
7929
+ if (modified && opposite)
7930
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7931
+ else
7932
+ //LA.matScale(toParent, hScale, vScale, 1);
7933
+ LA.matScale(toParent, 1, 1, totalScale);
78247934 } else
78257935 {
78267936 LA.matScale(toParent, totalScale, totalScale, 1);