Normand Briere
2019-08-23 60cec91731a350fe67e9b5ffe7a00d70e9026314
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 {
....@@ -641,7 +687,7 @@
641687 {
642688 if (maxcount != 1)
643689 {
644
- new Exception().printStackTrace();
690
+ //new Exception().printStackTrace();
645691 }
646692
647693 toParentMarked = LA.newMatrix();
....@@ -2323,11 +2369,6 @@
23232369
23242370 InitOthers();
23252371
2326
- if (this instanceof Camera)
2327
- {
2328
- material.shift = 90;
2329
- }
2330
-
23312372 material.multiply = multiply;
23322373
23332374 if (multiply)
....@@ -3576,15 +3617,47 @@
35763617
35773618 void ClearMaterials()
35783619 {
3620
+ if (blockloop)
3621
+ return;
3622
+
3623
+ blockloop = true;
3624
+
35793625 ClearMaterial();
3580
- for (int i = 0; i < size(); i++)
3626
+ for (int i = 0; i < Size(); i++)
35813627 {
3582
- Object3D child = (Object3D) reserve(i);
3628
+ Object3D child = (Object3D) get(i);
35833629 if (child == null)
35843630 continue;
35853631 child.ClearMaterials();
3586
- release(i);
35873632 }
3633
+
3634
+ blockloop = false;
3635
+ }
3636
+
3637
+ void ClearVersionList()
3638
+ {
3639
+ this.versionlist = null;
3640
+ this.versionindex = -1;
3641
+ this.versiontable = null;
3642
+ }
3643
+
3644
+ void ClearVersions()
3645
+ {
3646
+ if (blockloop)
3647
+ return;
3648
+
3649
+ blockloop = true;
3650
+
3651
+ ClearVersionList();
3652
+ for (int i = 0; i < Size(); i++)
3653
+ {
3654
+ Object3D child = (Object3D) get(i);
3655
+ if (child == null)
3656
+ continue;
3657
+ child.ClearVersions();
3658
+ }
3659
+
3660
+ blockloop = false;
35883661 }
35893662
35903663 void FlipV(boolean flip)
....@@ -5574,6 +5647,11 @@
55745647 if (fullname == null)
55755648 return "";
55765649
5650
+ if (fullname.pigment != null)
5651
+ {
5652
+ return fullname.pigment;
5653
+ }
5654
+
55775655 // System.out.println("Fullname = " + fullname);
55785656
55795657 // Does not work on Windows due to C:
....@@ -5586,7 +5664,7 @@
55865664
55875665 if (split.length == 0)
55885666 {
5589
- return "";
5667
+ return fullname.pigment = "";
55905668 }
55915669
55925670 if (split.length <= 2)
....@@ -5594,22 +5672,27 @@
55945672 if (fullname.name.endsWith(":"))
55955673 {
55965674 // Windows
5597
- return fullname.name.substring(0, fullname.name.length()-1);
5675
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
55985676 }
55995677
5600
- return split[0];
5678
+ return fullname.pigment = split[0];
56015679 }
56025680
56035681 // Windows
56045682 assert(split.length == 4);
56055683
5606
- return split[0] + ":" + split[1];
5684
+ return fullname.pigment = split[0] + ":" + split[1];
56075685 }
56085686
56095687 static String GetBump(cTexture fullname)
56105688 {
56115689 if (fullname == null)
56125690 return "";
5691
+
5692
+ if (fullname.bump != null)
5693
+ {
5694
+ return fullname.bump;
5695
+ }
56135696
56145697 // System.out.println("Fullname = " + fullname);
56155698 // Does not work on Windows due to C:
....@@ -5621,12 +5704,12 @@
56215704
56225705 if (split.length == 0)
56235706 {
5624
- return "";
5707
+ return fullname.bump = "";
56255708 }
56265709
56275710 if (split.length == 1)
56285711 {
5629
- return "";
5712
+ return fullname.bump = "";
56305713 }
56315714
56325715 if (split.length == 2)
....@@ -5634,16 +5717,16 @@
56345717 if (fullname.name.endsWith(":"))
56355718 {
56365719 // Windows
5637
- return "";
5720
+ return fullname.bump = "";
56385721 }
56395722
5640
- return split[1];
5723
+ return fullname.bump = split[1];
56415724 }
56425725
56435726 // Windows
56445727 assert(split.length == 4);
56455728
5646
- return split[2] + ":" + split[3];
5729
+ return fullname.bump = split[2] + ":" + split[3];
56475730 }
56485731
56495732 String GetPigmentTexture()
....@@ -5726,6 +5809,9 @@
57265809 texname = "";
57275810
57285811 GetTextures().name = texname + ":" + GetBump(GetTextures());
5812
+
5813
+ GetTextures().pigment = null;
5814
+
57295815 Touch();
57305816 }
57315817
....@@ -5798,6 +5884,8 @@
57985884 texname = "";
57995885
58005886 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
5887
+
5888
+ GetTextures().bump = null;
58015889
58025890 Touch();
58035891 }
....@@ -7402,7 +7490,7 @@
74027490 boundary.y = spot.y - 30;
74037491 boundary.width = spot.width + 60;
74047492 boundary.height = spot.height + 60;
7405
- clickInfo.g.setColor(Color.red);
7493
+ clickInfo.g.setColor(Color.white);
74067494 int spotw = spot.x + spot.width;
74077495 int spoth = spot.y + spot.height;
74087496 clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
....@@ -7422,7 +7510,29 @@
74227510 // {
74237511 // CameraPane.Ymax = spoth;
74247512 // }
7425
- spot.translate(32, 32);
7513
+// if (CameraPane.Xmin > spot.x)
7514
+// {
7515
+// CameraPane.Xmin = spot.x;
7516
+// }
7517
+// if (CameraPane.Xmax < spotw)
7518
+// {
7519
+// CameraPane.Xmax = spotw;
7520
+// }
7521
+// if (CameraPane.Ymin > spot.y)
7522
+// {
7523
+// CameraPane.Ymin = spot.y;
7524
+// }
7525
+// if (CameraPane.Ymax < spoth)
7526
+// {
7527
+// CameraPane.Ymax = spoth;
7528
+// }
7529
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7530
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
7531
+ spot.translate(32, 0);
7532
+ clickInfo.g.setColor(Color.yellow);
7533
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7534
+
7535
+ spot.translate(32, 64);
74267536 spotw = spot.x + spot.width;
74277537 spoth = spot.y + spot.height;
74287538 clickInfo.g.setColor(Color.cyan);
....@@ -7443,28 +7553,7 @@
74437553 // {
74447554 // CameraPane.Ymax = spoth;
74457555 // }
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);
74517556 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
-// }
74687557 clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
74697558 (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
74707559 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
....@@ -7523,12 +7612,14 @@
75237612 retval = true;
75247613 }
75257614 spot.translate(0, 32);
7615
+ spot.translate(32, 0);
7616
+ spot.translate(0, 32);
75267617 if (spot.contains(clickInfo.x, clickInfo.y))
75277618 {
75287619 hitSomething = hitScale;
75297620
75307621 double scale = 0.005f * clickInfo.camera.Distance();
7531
- double hScale = (double) (clickInfo.x - centerPt.x) / 32;
7622
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
75327623 double sign = 1;
75337624 if (hScale < 0)
75347625 {
....@@ -7540,7 +7631,7 @@
75407631 //hScale = 0.01;
75417632 }
75427633
7543
- double vScale = (double) (clickInfo.y - centerPt.y) / 32;
7634
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
75447635 sign = 1;
75457636 if (vScale < 0)
75467637 {
....@@ -7620,7 +7711,9 @@
76207711
76217712 scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
76227713
7623
- if (modified || opposite)
7714
+ // Modified could snap
7715
+ if (//modified ||
7716
+ opposite)
76247717 {
76257718 //assert(false);
76267719 /*
....@@ -7714,7 +7807,7 @@
77147807
77157808 if (modified)
77167809 {
7717
- // Rotate 90 degrees
7810
+ // Rotate 45 degrees
77187811 angle /= (Math.PI / 4);
77197812 angle = Math.floor(angle + 0.5);
77207813 angle *= (Math.PI / 4);
....@@ -7755,7 +7848,7 @@
77557848 break;
77567849
77577850 case hitScale: // scale
7758
- double hScale = (double) (clickInfo.x - centerPt.x) / 32;
7851
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
77597852 double sign = 1;
77607853 if (hScale < 0)
77617854 {
....@@ -7767,7 +7860,7 @@
77677860 //hScale = 0.01;
77687861 }
77697862
7770
- double vScale = (double) (clickInfo.y - centerPt.y) / 32;
7863
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
77717864 sign = 1;
77727865 if (vScale < 0)
77737866 {
....@@ -7800,21 +7893,27 @@
78007893 case 3: // '\001'
78017894 if (modified || opposite)
78027895 {
7896
+ if (modified) // && opposite)
7897
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7898
+ else
78037899 //LA.matScale(toParent, 1, hScale, vScale);
7804
- LA.matScale(toParent, totalScale, 1, 1);
7900
+ LA.matScale(toParent, totalScale, 1, 1);
78057901 } // vScale, 1);
78067902 else
78077903 {
78087904 // EXCEPTION!
7809
- LA.matScale(toParent, totalScale, totalScale, totalScale);
7905
+ LA.matScale(toParent, 1, totalScale, totalScale);
78107906 } // vScale, 1);
78117907 break;
78127908
78137909 case 2: // '\002'
78147910 if (modified || opposite)
78157911 {
7816
- //LA.matScale(toParent, hScale, 1, vScale);
7817
- LA.matScale(toParent, 1, totalScale, 1);
7912
+ if (modified) // && opposite)
7913
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7914
+ else
7915
+ //LA.matScale(toParent, hScale, 1, vScale);
7916
+ LA.matScale(toParent, 1, totalScale, 1);
78187917 } else
78197918 {
78207919 LA.matScale(toParent, totalScale, 1, totalScale);
....@@ -7824,8 +7923,11 @@
78247923 case 1: // '\003'
78257924 if (modified || opposite)
78267925 {
7827
- //LA.matScale(toParent, hScale, vScale, 1);
7828
- LA.matScale(toParent, 1, 1, totalScale);
7926
+ if (modified) // && opposite)
7927
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7928
+ else
7929
+ //LA.matScale(toParent, hScale, vScale, 1);
7930
+ LA.matScale(toParent, 1, 1, totalScale);
78297931 } else
78307932 {
78317933 LA.matScale(toParent, totalScale, totalScale, 1);