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 {
....@@ -3576,15 +3622,47 @@
35763622
35773623 void ClearMaterials()
35783624 {
3625
+ if (blockloop)
3626
+ return;
3627
+
3628
+ blockloop = true;
3629
+
35793630 ClearMaterial();
3580
- for (int i = 0; i < size(); i++)
3631
+ for (int i = 0; i < Size(); i++)
35813632 {
3582
- Object3D child = (Object3D) reserve(i);
3633
+ Object3D child = (Object3D) get(i);
35833634 if (child == null)
35843635 continue;
35853636 child.ClearMaterials();
3586
- release(i);
35873637 }
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;
35883666 }
35893667
35903668 void FlipV(boolean flip)
....@@ -5574,6 +5652,11 @@
55745652 if (fullname == null)
55755653 return "";
55765654
5655
+ if (fullname.pigment != null)
5656
+ {
5657
+ return fullname.pigment;
5658
+ }
5659
+
55775660 // System.out.println("Fullname = " + fullname);
55785661
55795662 // Does not work on Windows due to C:
....@@ -5586,7 +5669,7 @@
55865669
55875670 if (split.length == 0)
55885671 {
5589
- return "";
5672
+ return fullname.pigment = "";
55905673 }
55915674
55925675 if (split.length <= 2)
....@@ -5594,22 +5677,27 @@
55945677 if (fullname.name.endsWith(":"))
55955678 {
55965679 // Windows
5597
- return fullname.name.substring(0, fullname.name.length()-1);
5680
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
55985681 }
55995682
5600
- return split[0];
5683
+ return fullname.pigment = split[0];
56015684 }
56025685
56035686 // Windows
56045687 assert(split.length == 4);
56055688
5606
- return split[0] + ":" + split[1];
5689
+ return fullname.pigment = split[0] + ":" + split[1];
56075690 }
56085691
56095692 static String GetBump(cTexture fullname)
56105693 {
56115694 if (fullname == null)
56125695 return "";
5696
+
5697
+ if (fullname.bump != null)
5698
+ {
5699
+ return fullname.bump;
5700
+ }
56135701
56145702 // System.out.println("Fullname = " + fullname);
56155703 // Does not work on Windows due to C:
....@@ -5621,12 +5709,12 @@
56215709
56225710 if (split.length == 0)
56235711 {
5624
- return "";
5712
+ return fullname.bump = "";
56255713 }
56265714
56275715 if (split.length == 1)
56285716 {
5629
- return "";
5717
+ return fullname.bump = "";
56305718 }
56315719
56325720 if (split.length == 2)
....@@ -5634,16 +5722,16 @@
56345722 if (fullname.name.endsWith(":"))
56355723 {
56365724 // Windows
5637
- return "";
5725
+ return fullname.bump = "";
56385726 }
56395727
5640
- return split[1];
5728
+ return fullname.bump = split[1];
56415729 }
56425730
56435731 // Windows
56445732 assert(split.length == 4);
56455733
5646
- return split[2] + ":" + split[3];
5734
+ return fullname.bump = split[2] + ":" + split[3];
56475735 }
56485736
56495737 String GetPigmentTexture()
....@@ -5726,6 +5814,9 @@
57265814 texname = "";
57275815
57285816 GetTextures().name = texname + ":" + GetBump(GetTextures());
5817
+
5818
+ GetTextures().pigment = null;
5819
+
57295820 Touch();
57305821 }
57315822
....@@ -5798,6 +5889,8 @@
57985889 texname = "";
57995890
58005891 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
5892
+
5893
+ GetTextures().bump = null;
58015894
58025895 Touch();
58035896 }
....@@ -7402,7 +7495,7 @@
74027495 boundary.y = spot.y - 30;
74037496 boundary.width = spot.width + 60;
74047497 boundary.height = spot.height + 60;
7405
- clickInfo.g.setColor(Color.red);
7498
+ clickInfo.g.setColor(Color.white);
74067499 int spotw = spot.x + spot.width;
74077500 int spoth = spot.y + spot.height;
74087501 clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
....@@ -7422,7 +7515,29 @@
74227515 // {
74237516 // CameraPane.Ymax = spoth;
74247517 // }
7425
- 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);
74267541 spotw = spot.x + spot.width;
74277542 spoth = spot.y + spot.height;
74287543 clickInfo.g.setColor(Color.cyan);
....@@ -7443,28 +7558,7 @@
74437558 // {
74447559 // CameraPane.Ymax = spoth;
74457560 // }
7446
- // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7447
- //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
7448
- spot.translate(0, -32);
7449
- clickInfo.g.setColor(Color.yellow);
7450
- clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
74517561 clickInfo.g.setColor(Color.green);
7452
-// if (CameraPane.Xmin > spot.x)
7453
-// {
7454
-// CameraPane.Xmin = spot.x;
7455
-// }
7456
-// if (CameraPane.Xmax < spotw)
7457
-// {
7458
-// CameraPane.Xmax = spotw;
7459
-// }
7460
-// if (CameraPane.Ymin > spot.y)
7461
-// {
7462
-// CameraPane.Ymin = spot.y;
7463
-// }
7464
-// if (CameraPane.Ymax < spoth)
7465
-// {
7466
-// CameraPane.Ymax = spoth;
7467
-// }
74687562 clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
74697563 (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
74707564 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
....@@ -7523,12 +7617,14 @@
75237617 retval = true;
75247618 }
75257619 spot.translate(0, 32);
7620
+ spot.translate(32, 0);
7621
+ spot.translate(0, 32);
75267622 if (spot.contains(clickInfo.x, clickInfo.y))
75277623 {
75287624 hitSomething = hitScale;
75297625
75307626 double scale = 0.005f * clickInfo.camera.Distance();
7531
- double hScale = (double) (clickInfo.x - centerPt.x) / 32;
7627
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
75327628 double sign = 1;
75337629 if (hScale < 0)
75347630 {
....@@ -7540,7 +7636,7 @@
75407636 //hScale = 0.01;
75417637 }
75427638
7543
- double vScale = (double) (clickInfo.y - centerPt.y) / 32;
7639
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
75447640 sign = 1;
75457641 if (vScale < 0)
75467642 {
....@@ -7755,7 +7851,7 @@
77557851 break;
77567852
77577853 case hitScale: // scale
7758
- double hScale = (double) (clickInfo.x - centerPt.x) / 32;
7854
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
77597855 double sign = 1;
77607856 if (hScale < 0)
77617857 {
....@@ -7767,7 +7863,7 @@
77677863 //hScale = 0.01;
77687864 }
77697865
7770
- double vScale = (double) (clickInfo.y - centerPt.y) / 32;
7866
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
77717867 sign = 1;
77727868 if (vScale < 0)
77737869 {
....@@ -7800,21 +7896,27 @@
78007896 case 3: // '\001'
78017897 if (modified || opposite)
78027898 {
7899
+ if (modified && opposite)
7900
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7901
+ else
78037902 //LA.matScale(toParent, 1, hScale, vScale);
7804
- LA.matScale(toParent, totalScale, 1, 1);
7903
+ LA.matScale(toParent, totalScale, 1, 1);
78057904 } // vScale, 1);
78067905 else
78077906 {
78087907 // EXCEPTION!
7809
- LA.matScale(toParent, totalScale, totalScale, totalScale);
7908
+ LA.matScale(toParent, 1, totalScale, totalScale);
78107909 } // vScale, 1);
78117910 break;
78127911
78137912 case 2: // '\002'
78147913 if (modified || opposite)
78157914 {
7816
- //LA.matScale(toParent, hScale, 1, vScale);
7817
- 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);
78187920 } else
78197921 {
78207922 LA.matScale(toParent, totalScale, 1, totalScale);
....@@ -7824,8 +7926,11 @@
78247926 case 1: // '\003'
78257927 if (modified || opposite)
78267928 {
7827
- //LA.matScale(toParent, hScale, vScale, 1);
7828
- 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);
78297934 } else
78307935 {
78317936 LA.matScale(toParent, totalScale, totalScale, 1);