Normand Briere
2019-08-22 0c7b833be7d86598a6813cd1c6db0ca9e1b17966
Object3D.java
....@@ -22,6 +22,7 @@
2222 //static final long serialVersionUID = -607422624994562685L;
2323 static final long serialVersionUID = 5022536242724664900L;
2424
25
+ // Use GetUUID for backward compatibility with null.
2526 private UUID uuid = UUID.randomUUID();
2627
2728 // TEMPORARY for mocap undo. No need to be transient.
....@@ -32,9 +33,11 @@
3233 String skyboxname;
3334 String skyboxext;
3435
35
- byte[] versions[];
36
+ Object3D versionlist[];
3637 int versionindex = -1;
3738
39
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable; // = new java.util.Hashtable<java.util.UUID, Object3D>();
40
+
3841 ScriptNode scriptnode;
3942
4043 void InitOthers()
....@@ -222,7 +225,7 @@
222225 // o.bRep.support = null;
223226 // }
224227 o.selection = this.selection;
225
- o.versions = this.versions;
228
+ o.versionlist = this.versionlist;
226229 o.versionindex = this.versionindex;
227230
228231 if (this.support != null)
....@@ -244,6 +247,73 @@
244247 // this.bRep.support = null;
245248 // this.support = null;
246249 // this.fileparent = null;
250
+ }
251
+
252
+// Object3D GetObject(java.util.UUID uuid)
253
+// {
254
+// if (this.uuid.equals(uuid))
255
+// return this;
256
+//
257
+// if (blockloop)
258
+// return null;
259
+//
260
+// blockloop = true;
261
+//
262
+// for (int i=0; i<Size(); i++)
263
+// {
264
+// Object3D o = get(i).GetObject(uuid);
265
+//
266
+// if (o != null)
267
+// return o;
268
+// }
269
+//
270
+// blockloop = false;
271
+//
272
+// return null;
273
+// }
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;
247317 }
248318
249319 void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
....@@ -280,7 +350,7 @@
280350
281351 this.selection = o.selection;
282352
283
- this.versions = o.versions;
353
+ this.versionlist = o.versionlist;
284354 this.versionindex = o.versionindex;
285355 // July 2019 if (this.bRep != null)
286356 // this.bRep.support = o.transientrep;
....@@ -2444,6 +2514,11 @@
24442514 else
24452515 {
24462516 //((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");
24472522 }
24482523 }
24492524
....@@ -3547,15 +3622,47 @@
35473622
35483623 void ClearMaterials()
35493624 {
3625
+ if (blockloop)
3626
+ return;
3627
+
3628
+ blockloop = true;
3629
+
35503630 ClearMaterial();
3551
- for (int i = 0; i < size(); i++)
3631
+ for (int i = 0; i < Size(); i++)
35523632 {
3553
- Object3D child = (Object3D) reserve(i);
3633
+ Object3D child = (Object3D) get(i);
35543634 if (child == null)
35553635 continue;
35563636 child.ClearMaterials();
3557
- release(i);
35583637 }
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;
35593666 }
35603667
35613668 void FlipV(boolean flip)
....@@ -5545,6 +5652,11 @@
55455652 if (fullname == null)
55465653 return "";
55475654
5655
+ if (fullname.pigment != null)
5656
+ {
5657
+ return fullname.pigment;
5658
+ }
5659
+
55485660 // System.out.println("Fullname = " + fullname);
55495661
55505662 // Does not work on Windows due to C:
....@@ -5557,7 +5669,7 @@
55575669
55585670 if (split.length == 0)
55595671 {
5560
- return "";
5672
+ return fullname.pigment = "";
55615673 }
55625674
55635675 if (split.length <= 2)
....@@ -5565,22 +5677,27 @@
55655677 if (fullname.name.endsWith(":"))
55665678 {
55675679 // Windows
5568
- return fullname.name.substring(0, fullname.name.length()-1);
5680
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
55695681 }
55705682
5571
- return split[0];
5683
+ return fullname.pigment = split[0];
55725684 }
55735685
55745686 // Windows
55755687 assert(split.length == 4);
55765688
5577
- return split[0] + ":" + split[1];
5689
+ return fullname.pigment = split[0] + ":" + split[1];
55785690 }
55795691
55805692 static String GetBump(cTexture fullname)
55815693 {
55825694 if (fullname == null)
55835695 return "";
5696
+
5697
+ if (fullname.bump != null)
5698
+ {
5699
+ return fullname.bump;
5700
+ }
55845701
55855702 // System.out.println("Fullname = " + fullname);
55865703 // Does not work on Windows due to C:
....@@ -5592,12 +5709,12 @@
55925709
55935710 if (split.length == 0)
55945711 {
5595
- return "";
5712
+ return fullname.bump = "";
55965713 }
55975714
55985715 if (split.length == 1)
55995716 {
5600
- return "";
5717
+ return fullname.bump = "";
56015718 }
56025719
56035720 if (split.length == 2)
....@@ -5605,16 +5722,16 @@
56055722 if (fullname.name.endsWith(":"))
56065723 {
56075724 // Windows
5608
- return "";
5725
+ return fullname.bump = "";
56095726 }
56105727
5611
- return split[1];
5728
+ return fullname.bump = split[1];
56125729 }
56135730
56145731 // Windows
56155732 assert(split.length == 4);
56165733
5617
- return split[2] + ":" + split[3];
5734
+ return fullname.bump = split[2] + ":" + split[3];
56185735 }
56195736
56205737 String GetPigmentTexture()
....@@ -5697,6 +5814,9 @@
56975814 texname = "";
56985815
56995816 GetTextures().name = texname + ":" + GetBump(GetTextures());
5817
+
5818
+ GetTextures().pigment = null;
5819
+
57005820 Touch();
57015821 }
57025822
....@@ -5769,6 +5889,8 @@
57695889 texname = "";
57705890
57715891 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
5892
+
5893
+ GetTextures().bump = null;
57725894
57735895 Touch();
57745896 }
....@@ -7373,7 +7495,7 @@
73737495 boundary.y = spot.y - 30;
73747496 boundary.width = spot.width + 60;
73757497 boundary.height = spot.height + 60;
7376
- clickInfo.g.setColor(Color.red);
7498
+ clickInfo.g.setColor(Color.white);
73777499 int spotw = spot.x + spot.width;
73787500 int spoth = spot.y + spot.height;
73797501 clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
....@@ -7393,7 +7515,29 @@
73937515 // {
73947516 // CameraPane.Ymax = spoth;
73957517 // }
7396
- 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);
73977541 spotw = spot.x + spot.width;
73987542 spoth = spot.y + spot.height;
73997543 clickInfo.g.setColor(Color.cyan);
....@@ -7414,28 +7558,7 @@
74147558 // {
74157559 // CameraPane.Ymax = spoth;
74167560 // }
7417
- // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7418
- //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
7419
- spot.translate(0, -32);
7420
- clickInfo.g.setColor(Color.yellow);
7421
- clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
74227561 clickInfo.g.setColor(Color.green);
7423
-// if (CameraPane.Xmin > spot.x)
7424
-// {
7425
-// CameraPane.Xmin = spot.x;
7426
-// }
7427
-// if (CameraPane.Xmax < spotw)
7428
-// {
7429
-// CameraPane.Xmax = spotw;
7430
-// }
7431
-// if (CameraPane.Ymin > spot.y)
7432
-// {
7433
-// CameraPane.Ymin = spot.y;
7434
-// }
7435
-// if (CameraPane.Ymax < spoth)
7436
-// {
7437
-// CameraPane.Ymax = spoth;
7438
-// }
74397562 clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
74407563 (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
74417564 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
....@@ -7494,12 +7617,14 @@
74947617 retval = true;
74957618 }
74967619 spot.translate(0, 32);
7620
+ spot.translate(32, 0);
7621
+ spot.translate(0, 32);
74977622 if (spot.contains(clickInfo.x, clickInfo.y))
74987623 {
74997624 hitSomething = hitScale;
75007625
75017626 double scale = 0.005f * clickInfo.camera.Distance();
7502
- double hScale = (double) (clickInfo.x - centerPt.x) / 32;
7627
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
75037628 double sign = 1;
75047629 if (hScale < 0)
75057630 {
....@@ -7511,7 +7636,7 @@
75117636 //hScale = 0.01;
75127637 }
75137638
7514
- double vScale = (double) (clickInfo.y - centerPt.y) / 32;
7639
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
75157640 sign = 1;
75167641 if (vScale < 0)
75177642 {
....@@ -7726,7 +7851,7 @@
77267851 break;
77277852
77287853 case hitScale: // scale
7729
- double hScale = (double) (clickInfo.x - centerPt.x) / 32;
7854
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
77307855 double sign = 1;
77317856 if (hScale < 0)
77327857 {
....@@ -7738,7 +7863,7 @@
77387863 //hScale = 0.01;
77397864 }
77407865
7741
- double vScale = (double) (clickInfo.y - centerPt.y) / 32;
7866
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
77427867 sign = 1;
77437868 if (vScale < 0)
77447869 {
....@@ -7771,21 +7896,27 @@
77717896 case 3: // '\001'
77727897 if (modified || opposite)
77737898 {
7899
+ if (modified && opposite)
7900
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7901
+ else
77747902 //LA.matScale(toParent, 1, hScale, vScale);
7775
- LA.matScale(toParent, totalScale, 1, 1);
7903
+ LA.matScale(toParent, totalScale, 1, 1);
77767904 } // vScale, 1);
77777905 else
77787906 {
77797907 // EXCEPTION!
7780
- LA.matScale(toParent, totalScale, totalScale, totalScale);
7908
+ LA.matScale(toParent, 1, totalScale, totalScale);
77817909 } // vScale, 1);
77827910 break;
77837911
77847912 case 2: // '\002'
77857913 if (modified || opposite)
77867914 {
7787
- //LA.matScale(toParent, hScale, 1, vScale);
7788
- 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);
77897920 } else
77907921 {
77917922 LA.matScale(toParent, totalScale, 1, totalScale);
....@@ -7795,8 +7926,11 @@
77957926 case 1: // '\003'
77967927 if (modified || opposite)
77977928 {
7798
- //LA.matScale(toParent, hScale, vScale, 1);
7799
- 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);
78007934 } else
78017935 {
78027936 LA.matScale(toParent, totalScale, totalScale, 1);