Normand Briere
2019-08-23 60cec91731a350fe67e9b5ffe7a00d70e9026314
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
- Object3D 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;
....@@ -617,7 +687,7 @@
617687 {
618688 if (maxcount != 1)
619689 {
620
- new Exception().printStackTrace();
690
+ //new Exception().printStackTrace();
621691 }
622692
623693 toParentMarked = LA.newMatrix();
....@@ -2299,11 +2369,6 @@
22992369
23002370 InitOthers();
23012371
2302
- if (this instanceof Camera)
2303
- {
2304
- material.shift = 90;
2305
- }
2306
-
23072372 material.multiply = multiply;
23082373
23092374 if (multiply)
....@@ -2444,6 +2509,11 @@
24442509 else
24452510 {
24462511 //((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");
24472517 }
24482518 }
24492519
....@@ -3547,15 +3617,47 @@
35473617
35483618 void ClearMaterials()
35493619 {
3620
+ if (blockloop)
3621
+ return;
3622
+
3623
+ blockloop = true;
3624
+
35503625 ClearMaterial();
3551
- for (int i = 0; i < size(); i++)
3626
+ for (int i = 0; i < Size(); i++)
35523627 {
3553
- Object3D child = (Object3D) reserve(i);
3628
+ Object3D child = (Object3D) get(i);
35543629 if (child == null)
35553630 continue;
35563631 child.ClearMaterials();
3557
- release(i);
35583632 }
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;
35593661 }
35603662
35613663 void FlipV(boolean flip)
....@@ -5545,6 +5647,11 @@
55455647 if (fullname == null)
55465648 return "";
55475649
5650
+ if (fullname.pigment != null)
5651
+ {
5652
+ return fullname.pigment;
5653
+ }
5654
+
55485655 // System.out.println("Fullname = " + fullname);
55495656
55505657 // Does not work on Windows due to C:
....@@ -5557,7 +5664,7 @@
55575664
55585665 if (split.length == 0)
55595666 {
5560
- return "";
5667
+ return fullname.pigment = "";
55615668 }
55625669
55635670 if (split.length <= 2)
....@@ -5565,22 +5672,27 @@
55655672 if (fullname.name.endsWith(":"))
55665673 {
55675674 // Windows
5568
- return fullname.name.substring(0, fullname.name.length()-1);
5675
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
55695676 }
55705677
5571
- return split[0];
5678
+ return fullname.pigment = split[0];
55725679 }
55735680
55745681 // Windows
55755682 assert(split.length == 4);
55765683
5577
- return split[0] + ":" + split[1];
5684
+ return fullname.pigment = split[0] + ":" + split[1];
55785685 }
55795686
55805687 static String GetBump(cTexture fullname)
55815688 {
55825689 if (fullname == null)
55835690 return "";
5691
+
5692
+ if (fullname.bump != null)
5693
+ {
5694
+ return fullname.bump;
5695
+ }
55845696
55855697 // System.out.println("Fullname = " + fullname);
55865698 // Does not work on Windows due to C:
....@@ -5592,12 +5704,12 @@
55925704
55935705 if (split.length == 0)
55945706 {
5595
- return "";
5707
+ return fullname.bump = "";
55965708 }
55975709
55985710 if (split.length == 1)
55995711 {
5600
- return "";
5712
+ return fullname.bump = "";
56015713 }
56025714
56035715 if (split.length == 2)
....@@ -5605,16 +5717,16 @@
56055717 if (fullname.name.endsWith(":"))
56065718 {
56075719 // Windows
5608
- return "";
5720
+ return fullname.bump = "";
56095721 }
56105722
5611
- return split[1];
5723
+ return fullname.bump = split[1];
56125724 }
56135725
56145726 // Windows
56155727 assert(split.length == 4);
56165728
5617
- return split[2] + ":" + split[3];
5729
+ return fullname.bump = split[2] + ":" + split[3];
56185730 }
56195731
56205732 String GetPigmentTexture()
....@@ -5697,6 +5809,9 @@
56975809 texname = "";
56985810
56995811 GetTextures().name = texname + ":" + GetBump(GetTextures());
5812
+
5813
+ GetTextures().pigment = null;
5814
+
57005815 Touch();
57015816 }
57025817
....@@ -5769,6 +5884,8 @@
57695884 texname = "";
57705885
57715886 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
5887
+
5888
+ GetTextures().bump = null;
57725889
57735890 Touch();
57745891 }
....@@ -7373,7 +7490,7 @@
73737490 boundary.y = spot.y - 30;
73747491 boundary.width = spot.width + 60;
73757492 boundary.height = spot.height + 60;
7376
- clickInfo.g.setColor(Color.red);
7493
+ clickInfo.g.setColor(Color.white);
73777494 int spotw = spot.x + spot.width;
73787495 int spoth = spot.y + spot.height;
73797496 clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
....@@ -7393,7 +7510,29 @@
73937510 // {
73947511 // CameraPane.Ymax = spoth;
73957512 // }
7396
- 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);
73977536 spotw = spot.x + spot.width;
73987537 spoth = spot.y + spot.height;
73997538 clickInfo.g.setColor(Color.cyan);
....@@ -7414,28 +7553,7 @@
74147553 // {
74157554 // CameraPane.Ymax = spoth;
74167555 // }
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);
74227556 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
-// }
74397557 clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
74407558 (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
74417559 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
....@@ -7494,12 +7612,14 @@
74947612 retval = true;
74957613 }
74967614 spot.translate(0, 32);
7615
+ spot.translate(32, 0);
7616
+ spot.translate(0, 32);
74977617 if (spot.contains(clickInfo.x, clickInfo.y))
74987618 {
74997619 hitSomething = hitScale;
75007620
75017621 double scale = 0.005f * clickInfo.camera.Distance();
7502
- double hScale = (double) (clickInfo.x - centerPt.x) / 32;
7622
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
75037623 double sign = 1;
75047624 if (hScale < 0)
75057625 {
....@@ -7511,7 +7631,7 @@
75117631 //hScale = 0.01;
75127632 }
75137633
7514
- double vScale = (double) (clickInfo.y - centerPt.y) / 32;
7634
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
75157635 sign = 1;
75167636 if (vScale < 0)
75177637 {
....@@ -7591,7 +7711,9 @@
75917711
75927712 scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
75937713
7594
- if (modified || opposite)
7714
+ // Modified could snap
7715
+ if (//modified ||
7716
+ opposite)
75957717 {
75967718 //assert(false);
75977719 /*
....@@ -7685,7 +7807,7 @@
76857807
76867808 if (modified)
76877809 {
7688
- // Rotate 90 degrees
7810
+ // Rotate 45 degrees
76897811 angle /= (Math.PI / 4);
76907812 angle = Math.floor(angle + 0.5);
76917813 angle *= (Math.PI / 4);
....@@ -7726,7 +7848,7 @@
77267848 break;
77277849
77287850 case hitScale: // scale
7729
- double hScale = (double) (clickInfo.x - centerPt.x) / 32;
7851
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
77307852 double sign = 1;
77317853 if (hScale < 0)
77327854 {
....@@ -7738,7 +7860,7 @@
77387860 //hScale = 0.01;
77397861 }
77407862
7741
- double vScale = (double) (clickInfo.y - centerPt.y) / 32;
7863
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
77427864 sign = 1;
77437865 if (vScale < 0)
77447866 {
....@@ -7771,21 +7893,27 @@
77717893 case 3: // '\001'
77727894 if (modified || opposite)
77737895 {
7896
+ if (modified) // && opposite)
7897
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7898
+ else
77747899 //LA.matScale(toParent, 1, hScale, vScale);
7775
- LA.matScale(toParent, totalScale, 1, 1);
7900
+ LA.matScale(toParent, totalScale, 1, 1);
77767901 } // vScale, 1);
77777902 else
77787903 {
77797904 // EXCEPTION!
7780
- LA.matScale(toParent, totalScale, totalScale, totalScale);
7905
+ LA.matScale(toParent, 1, totalScale, totalScale);
77817906 } // vScale, 1);
77827907 break;
77837908
77847909 case 2: // '\002'
77857910 if (modified || opposite)
77867911 {
7787
- //LA.matScale(toParent, hScale, 1, vScale);
7788
- 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);
77897917 } else
77907918 {
77917919 LA.matScale(toParent, totalScale, 1, totalScale);
....@@ -7795,8 +7923,11 @@
77957923 case 1: // '\003'
77967924 if (modified || opposite)
77977925 {
7798
- //LA.matScale(toParent, hScale, vScale, 1);
7799
- 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);
78007931 } else
78017932 {
78027933 LA.matScale(toParent, totalScale, totalScale, 1);