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)
....@@ -2468,6 +2509,11 @@
24682509 else
24692510 {
24702511 //((ObjEditor)editWindow).SetupUI2(null);
2512
+ if (objectUI != null)
2513
+ ((ObjEditor)objectUI).pinButton.setSelected(pinned);
2514
+ else
2515
+ //new Exception().printStackTrace();
2516
+ System.err.println("objectUI is null");
24712517 }
24722518 }
24732519
....@@ -3571,15 +3617,47 @@
35713617
35723618 void ClearMaterials()
35733619 {
3620
+ if (blockloop)
3621
+ return;
3622
+
3623
+ blockloop = true;
3624
+
35743625 ClearMaterial();
3575
- for (int i = 0; i < size(); i++)
3626
+ for (int i = 0; i < Size(); i++)
35763627 {
3577
- Object3D child = (Object3D) reserve(i);
3628
+ Object3D child = (Object3D) get(i);
35783629 if (child == null)
35793630 continue;
35803631 child.ClearMaterials();
3581
- release(i);
35823632 }
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;
35833661 }
35843662
35853663 void FlipV(boolean flip)
....@@ -5569,6 +5647,11 @@
55695647 if (fullname == null)
55705648 return "";
55715649
5650
+ if (fullname.pigment != null)
5651
+ {
5652
+ return fullname.pigment;
5653
+ }
5654
+
55725655 // System.out.println("Fullname = " + fullname);
55735656
55745657 // Does not work on Windows due to C:
....@@ -5581,7 +5664,7 @@
55815664
55825665 if (split.length == 0)
55835666 {
5584
- return "";
5667
+ return fullname.pigment = "";
55855668 }
55865669
55875670 if (split.length <= 2)
....@@ -5589,22 +5672,27 @@
55895672 if (fullname.name.endsWith(":"))
55905673 {
55915674 // Windows
5592
- return fullname.name.substring(0, fullname.name.length()-1);
5675
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
55935676 }
55945677
5595
- return split[0];
5678
+ return fullname.pigment = split[0];
55965679 }
55975680
55985681 // Windows
55995682 assert(split.length == 4);
56005683
5601
- return split[0] + ":" + split[1];
5684
+ return fullname.pigment = split[0] + ":" + split[1];
56025685 }
56035686
56045687 static String GetBump(cTexture fullname)
56055688 {
56065689 if (fullname == null)
56075690 return "";
5691
+
5692
+ if (fullname.bump != null)
5693
+ {
5694
+ return fullname.bump;
5695
+ }
56085696
56095697 // System.out.println("Fullname = " + fullname);
56105698 // Does not work on Windows due to C:
....@@ -5616,12 +5704,12 @@
56165704
56175705 if (split.length == 0)
56185706 {
5619
- return "";
5707
+ return fullname.bump = "";
56205708 }
56215709
56225710 if (split.length == 1)
56235711 {
5624
- return "";
5712
+ return fullname.bump = "";
56255713 }
56265714
56275715 if (split.length == 2)
....@@ -5629,16 +5717,16 @@
56295717 if (fullname.name.endsWith(":"))
56305718 {
56315719 // Windows
5632
- return "";
5720
+ return fullname.bump = "";
56335721 }
56345722
5635
- return split[1];
5723
+ return fullname.bump = split[1];
56365724 }
56375725
56385726 // Windows
56395727 assert(split.length == 4);
56405728
5641
- return split[2] + ":" + split[3];
5729
+ return fullname.bump = split[2] + ":" + split[3];
56425730 }
56435731
56445732 String GetPigmentTexture()
....@@ -5721,6 +5809,9 @@
57215809 texname = "";
57225810
57235811 GetTextures().name = texname + ":" + GetBump(GetTextures());
5812
+
5813
+ GetTextures().pigment = null;
5814
+
57245815 Touch();
57255816 }
57265817
....@@ -5793,6 +5884,8 @@
57935884 texname = "";
57945885
57955886 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
5887
+
5888
+ GetTextures().bump = null;
57965889
57975890 Touch();
57985891 }
....@@ -7397,7 +7490,7 @@
73977490 boundary.y = spot.y - 30;
73987491 boundary.width = spot.width + 60;
73997492 boundary.height = spot.height + 60;
7400
- clickInfo.g.setColor(Color.red);
7493
+ clickInfo.g.setColor(Color.white);
74017494 int spotw = spot.x + spot.width;
74027495 int spoth = spot.y + spot.height;
74037496 clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
....@@ -7417,7 +7510,29 @@
74177510 // {
74187511 // CameraPane.Ymax = spoth;
74197512 // }
7420
- 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);
74217536 spotw = spot.x + spot.width;
74227537 spoth = spot.y + spot.height;
74237538 clickInfo.g.setColor(Color.cyan);
....@@ -7438,28 +7553,7 @@
74387553 // {
74397554 // CameraPane.Ymax = spoth;
74407555 // }
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);
74467556 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
-// }
74637557 clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
74647558 (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
74657559 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
....@@ -7518,12 +7612,14 @@
75187612 retval = true;
75197613 }
75207614 spot.translate(0, 32);
7615
+ spot.translate(32, 0);
7616
+ spot.translate(0, 32);
75217617 if (spot.contains(clickInfo.x, clickInfo.y))
75227618 {
75237619 hitSomething = hitScale;
75247620
75257621 double scale = 0.005f * clickInfo.camera.Distance();
7526
- double hScale = (double) (clickInfo.x - centerPt.x) / 32;
7622
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
75277623 double sign = 1;
75287624 if (hScale < 0)
75297625 {
....@@ -7535,7 +7631,7 @@
75357631 //hScale = 0.01;
75367632 }
75377633
7538
- double vScale = (double) (clickInfo.y - centerPt.y) / 32;
7634
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
75397635 sign = 1;
75407636 if (vScale < 0)
75417637 {
....@@ -7615,7 +7711,9 @@
76157711
76167712 scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
76177713
7618
- if (modified || opposite)
7714
+ // Modified could snap
7715
+ if (//modified ||
7716
+ opposite)
76197717 {
76207718 //assert(false);
76217719 /*
....@@ -7709,7 +7807,7 @@
77097807
77107808 if (modified)
77117809 {
7712
- // Rotate 90 degrees
7810
+ // Rotate 45 degrees
77137811 angle /= (Math.PI / 4);
77147812 angle = Math.floor(angle + 0.5);
77157813 angle *= (Math.PI / 4);
....@@ -7750,7 +7848,7 @@
77507848 break;
77517849
77527850 case hitScale: // scale
7753
- double hScale = (double) (clickInfo.x - centerPt.x) / 32;
7851
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
77547852 double sign = 1;
77557853 if (hScale < 0)
77567854 {
....@@ -7762,7 +7860,7 @@
77627860 //hScale = 0.01;
77637861 }
77647862
7765
- double vScale = (double) (clickInfo.y - centerPt.y) / 32;
7863
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
77667864 sign = 1;
77677865 if (vScale < 0)
77687866 {
....@@ -7795,21 +7893,27 @@
77957893 case 3: // '\001'
77967894 if (modified || opposite)
77977895 {
7896
+ if (modified) // && opposite)
7897
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7898
+ else
77987899 //LA.matScale(toParent, 1, hScale, vScale);
7799
- LA.matScale(toParent, totalScale, 1, 1);
7900
+ LA.matScale(toParent, totalScale, 1, 1);
78007901 } // vScale, 1);
78017902 else
78027903 {
78037904 // EXCEPTION!
7804
- LA.matScale(toParent, totalScale, totalScale, totalScale);
7905
+ LA.matScale(toParent, 1, totalScale, totalScale);
78057906 } // vScale, 1);
78067907 break;
78077908
78087909 case 2: // '\002'
78097910 if (modified || opposite)
78107911 {
7811
- //LA.matScale(toParent, hScale, 1, vScale);
7812
- 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);
78137917 } else
78147918 {
78157919 LA.matScale(toParent, totalScale, 1, totalScale);
....@@ -7819,8 +7923,11 @@
78197923 case 1: // '\003'
78207924 if (modified || opposite)
78217925 {
7822
- //LA.matScale(toParent, hScale, vScale, 1);
7823
- 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);
78247931 } else
78257932 {
78267933 LA.matScale(toParent, totalScale, totalScale, 1);