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,7 +2509,11 @@
24682509 else
24692510 {
24702511 //((ObjEditor)editWindow).SetupUI2(null);
2471
- ((ObjEditor)objectUI).pinButton.setSelected(pinned);
2512
+ if (objectUI != null)
2513
+ ((ObjEditor)objectUI).pinButton.setSelected(pinned);
2514
+ else
2515
+ //new Exception().printStackTrace();
2516
+ System.err.println("objectUI is null");
24722517 }
24732518 }
24742519
....@@ -3572,15 +3617,47 @@
35723617
35733618 void ClearMaterials()
35743619 {
3620
+ if (blockloop)
3621
+ return;
3622
+
3623
+ blockloop = true;
3624
+
35753625 ClearMaterial();
3576
- for (int i = 0; i < size(); i++)
3626
+ for (int i = 0; i < Size(); i++)
35773627 {
3578
- Object3D child = (Object3D) reserve(i);
3628
+ Object3D child = (Object3D) get(i);
35793629 if (child == null)
35803630 continue;
35813631 child.ClearMaterials();
3582
- release(i);
35833632 }
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;
35843661 }
35853662
35863663 void FlipV(boolean flip)
....@@ -5570,6 +5647,11 @@
55705647 if (fullname == null)
55715648 return "";
55725649
5650
+ if (fullname.pigment != null)
5651
+ {
5652
+ return fullname.pigment;
5653
+ }
5654
+
55735655 // System.out.println("Fullname = " + fullname);
55745656
55755657 // Does not work on Windows due to C:
....@@ -5582,7 +5664,7 @@
55825664
55835665 if (split.length == 0)
55845666 {
5585
- return "";
5667
+ return fullname.pigment = "";
55865668 }
55875669
55885670 if (split.length <= 2)
....@@ -5590,22 +5672,27 @@
55905672 if (fullname.name.endsWith(":"))
55915673 {
55925674 // Windows
5593
- return fullname.name.substring(0, fullname.name.length()-1);
5675
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
55945676 }
55955677
5596
- return split[0];
5678
+ return fullname.pigment = split[0];
55975679 }
55985680
55995681 // Windows
56005682 assert(split.length == 4);
56015683
5602
- return split[0] + ":" + split[1];
5684
+ return fullname.pigment = split[0] + ":" + split[1];
56035685 }
56045686
56055687 static String GetBump(cTexture fullname)
56065688 {
56075689 if (fullname == null)
56085690 return "";
5691
+
5692
+ if (fullname.bump != null)
5693
+ {
5694
+ return fullname.bump;
5695
+ }
56095696
56105697 // System.out.println("Fullname = " + fullname);
56115698 // Does not work on Windows due to C:
....@@ -5617,12 +5704,12 @@
56175704
56185705 if (split.length == 0)
56195706 {
5620
- return "";
5707
+ return fullname.bump = "";
56215708 }
56225709
56235710 if (split.length == 1)
56245711 {
5625
- return "";
5712
+ return fullname.bump = "";
56265713 }
56275714
56285715 if (split.length == 2)
....@@ -5630,16 +5717,16 @@
56305717 if (fullname.name.endsWith(":"))
56315718 {
56325719 // Windows
5633
- return "";
5720
+ return fullname.bump = "";
56345721 }
56355722
5636
- return split[1];
5723
+ return fullname.bump = split[1];
56375724 }
56385725
56395726 // Windows
56405727 assert(split.length == 4);
56415728
5642
- return split[2] + ":" + split[3];
5729
+ return fullname.bump = split[2] + ":" + split[3];
56435730 }
56445731
56455732 String GetPigmentTexture()
....@@ -5722,6 +5809,9 @@
57225809 texname = "";
57235810
57245811 GetTextures().name = texname + ":" + GetBump(GetTextures());
5812
+
5813
+ GetTextures().pigment = null;
5814
+
57255815 Touch();
57265816 }
57275817
....@@ -5794,6 +5884,8 @@
57945884 texname = "";
57955885
57965886 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
5887
+
5888
+ GetTextures().bump = null;
57975889
57985890 Touch();
57995891 }
....@@ -7398,7 +7490,7 @@
73987490 boundary.y = spot.y - 30;
73997491 boundary.width = spot.width + 60;
74007492 boundary.height = spot.height + 60;
7401
- clickInfo.g.setColor(Color.red);
7493
+ clickInfo.g.setColor(Color.white);
74027494 int spotw = spot.x + spot.width;
74037495 int spoth = spot.y + spot.height;
74047496 clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
....@@ -7418,7 +7510,29 @@
74187510 // {
74197511 // CameraPane.Ymax = spoth;
74207512 // }
7421
- 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);
74227536 spotw = spot.x + spot.width;
74237537 spoth = spot.y + spot.height;
74247538 clickInfo.g.setColor(Color.cyan);
....@@ -7439,28 +7553,7 @@
74397553 // {
74407554 // CameraPane.Ymax = spoth;
74417555 // }
7442
- // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7443
- //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
7444
- spot.translate(0, -32);
7445
- clickInfo.g.setColor(Color.yellow);
7446
- clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
74477556 clickInfo.g.setColor(Color.green);
7448
-// if (CameraPane.Xmin > spot.x)
7449
-// {
7450
-// CameraPane.Xmin = spot.x;
7451
-// }
7452
-// if (CameraPane.Xmax < spotw)
7453
-// {
7454
-// CameraPane.Xmax = spotw;
7455
-// }
7456
-// if (CameraPane.Ymin > spot.y)
7457
-// {
7458
-// CameraPane.Ymin = spot.y;
7459
-// }
7460
-// if (CameraPane.Ymax < spoth)
7461
-// {
7462
-// CameraPane.Ymax = spoth;
7463
-// }
74647557 clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
74657558 (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
74667559 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
....@@ -7519,12 +7612,14 @@
75197612 retval = true;
75207613 }
75217614 spot.translate(0, 32);
7615
+ spot.translate(32, 0);
7616
+ spot.translate(0, 32);
75227617 if (spot.contains(clickInfo.x, clickInfo.y))
75237618 {
75247619 hitSomething = hitScale;
75257620
75267621 double scale = 0.005f * clickInfo.camera.Distance();
7527
- double hScale = (double) (clickInfo.x - centerPt.x) / 32;
7622
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
75287623 double sign = 1;
75297624 if (hScale < 0)
75307625 {
....@@ -7536,7 +7631,7 @@
75367631 //hScale = 0.01;
75377632 }
75387633
7539
- double vScale = (double) (clickInfo.y - centerPt.y) / 32;
7634
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
75407635 sign = 1;
75417636 if (vScale < 0)
75427637 {
....@@ -7616,7 +7711,9 @@
76167711
76177712 scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
76187713
7619
- if (modified || opposite)
7714
+ // Modified could snap
7715
+ if (//modified ||
7716
+ opposite)
76207717 {
76217718 //assert(false);
76227719 /*
....@@ -7710,7 +7807,7 @@
77107807
77117808 if (modified)
77127809 {
7713
- // Rotate 90 degrees
7810
+ // Rotate 45 degrees
77147811 angle /= (Math.PI / 4);
77157812 angle = Math.floor(angle + 0.5);
77167813 angle *= (Math.PI / 4);
....@@ -7751,7 +7848,7 @@
77517848 break;
77527849
77537850 case hitScale: // scale
7754
- double hScale = (double) (clickInfo.x - centerPt.x) / 32;
7851
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
77557852 double sign = 1;
77567853 if (hScale < 0)
77577854 {
....@@ -7763,7 +7860,7 @@
77637860 //hScale = 0.01;
77647861 }
77657862
7766
- double vScale = (double) (clickInfo.y - centerPt.y) / 32;
7863
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
77677864 sign = 1;
77687865 if (vScale < 0)
77697866 {
....@@ -7796,21 +7893,27 @@
77967893 case 3: // '\001'
77977894 if (modified || opposite)
77987895 {
7896
+ if (modified) // && opposite)
7897
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7898
+ else
77997899 //LA.matScale(toParent, 1, hScale, vScale);
7800
- LA.matScale(toParent, totalScale, 1, 1);
7900
+ LA.matScale(toParent, totalScale, 1, 1);
78017901 } // vScale, 1);
78027902 else
78037903 {
78047904 // EXCEPTION!
7805
- LA.matScale(toParent, totalScale, totalScale, totalScale);
7905
+ LA.matScale(toParent, 1, totalScale, totalScale);
78067906 } // vScale, 1);
78077907 break;
78087908
78097909 case 2: // '\002'
78107910 if (modified || opposite)
78117911 {
7812
- //LA.matScale(toParent, hScale, 1, vScale);
7813
- 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);
78147917 } else
78157918 {
78167919 LA.matScale(toParent, totalScale, 1, totalScale);
....@@ -7820,8 +7923,11 @@
78207923 case 1: // '\003'
78217924 if (modified || opposite)
78227925 {
7823
- //LA.matScale(toParent, hScale, vScale, 1);
7824
- 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);
78257931 } else
78267932 {
78277933 LA.matScale(toParent, totalScale, totalScale, 1);