Normand Briere
2019-08-17 d5d6485126da83b06645e90e3e4ce66659a56009
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
....@@ -5545,6 +5620,11 @@
55455620 if (fullname == null)
55465621 return "";
55475622
5623
+ if (fullname.pigment != null)
5624
+ {
5625
+ return fullname.pigment;
5626
+ }
5627
+
55485628 // System.out.println("Fullname = " + fullname);
55495629
55505630 // Does not work on Windows due to C:
....@@ -5557,7 +5637,7 @@
55575637
55585638 if (split.length == 0)
55595639 {
5560
- return "";
5640
+ return fullname.pigment = "";
55615641 }
55625642
55635643 if (split.length <= 2)
....@@ -5565,22 +5645,27 @@
55655645 if (fullname.name.endsWith(":"))
55665646 {
55675647 // Windows
5568
- return fullname.name.substring(0, fullname.name.length()-1);
5648
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
55695649 }
55705650
5571
- return split[0];
5651
+ return fullname.pigment = split[0];
55725652 }
55735653
55745654 // Windows
55755655 assert(split.length == 4);
55765656
5577
- return split[0] + ":" + split[1];
5657
+ return fullname.pigment = split[0] + ":" + split[1];
55785658 }
55795659
55805660 static String GetBump(cTexture fullname)
55815661 {
55825662 if (fullname == null)
55835663 return "";
5664
+
5665
+ if (fullname.bump != null)
5666
+ {
5667
+ return fullname.bump;
5668
+ }
55845669
55855670 // System.out.println("Fullname = " + fullname);
55865671 // Does not work on Windows due to C:
....@@ -5592,12 +5677,12 @@
55925677
55935678 if (split.length == 0)
55945679 {
5595
- return "";
5680
+ return fullname.bump = "";
55965681 }
55975682
55985683 if (split.length == 1)
55995684 {
5600
- return "";
5685
+ return fullname.bump = "";
56015686 }
56025687
56035688 if (split.length == 2)
....@@ -5605,16 +5690,16 @@
56055690 if (fullname.name.endsWith(":"))
56065691 {
56075692 // Windows
5608
- return "";
5693
+ return fullname.bump = "";
56095694 }
56105695
5611
- return split[1];
5696
+ return fullname.bump = split[1];
56125697 }
56135698
56145699 // Windows
56155700 assert(split.length == 4);
56165701
5617
- return split[2] + ":" + split[3];
5702
+ return fullname.bump = split[2] + ":" + split[3];
56185703 }
56195704
56205705 String GetPigmentTexture()
....@@ -5697,6 +5782,9 @@
56975782 texname = "";
56985783
56995784 GetTextures().name = texname + ":" + GetBump(GetTextures());
5785
+
5786
+ GetTextures().pigment = null;
5787
+
57005788 Touch();
57015789 }
57025790
....@@ -5769,6 +5857,8 @@
57695857 texname = "";
57705858
57715859 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
5860
+
5861
+ GetTextures().bump = null;
57725862
57735863 Touch();
57745864 }
....@@ -7373,7 +7463,7 @@
73737463 boundary.y = spot.y - 30;
73747464 boundary.width = spot.width + 60;
73757465 boundary.height = spot.height + 60;
7376
- clickInfo.g.setColor(Color.red);
7466
+ clickInfo.g.setColor(Color.white);
73777467 int spotw = spot.x + spot.width;
73787468 int spoth = spot.y + spot.height;
73797469 clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
....@@ -7393,7 +7483,29 @@
73937483 // {
73947484 // CameraPane.Ymax = spoth;
73957485 // }
7396
- spot.translate(32, 32);
7486
+// if (CameraPane.Xmin > spot.x)
7487
+// {
7488
+// CameraPane.Xmin = spot.x;
7489
+// }
7490
+// if (CameraPane.Xmax < spotw)
7491
+// {
7492
+// CameraPane.Xmax = spotw;
7493
+// }
7494
+// if (CameraPane.Ymin > spot.y)
7495
+// {
7496
+// CameraPane.Ymin = spot.y;
7497
+// }
7498
+// if (CameraPane.Ymax < spoth)
7499
+// {
7500
+// CameraPane.Ymax = spoth;
7501
+// }
7502
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7503
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
7504
+ spot.translate(32, 0);
7505
+ clickInfo.g.setColor(Color.yellow);
7506
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7507
+
7508
+ spot.translate(32, 64);
73977509 spotw = spot.x + spot.width;
73987510 spoth = spot.y + spot.height;
73997511 clickInfo.g.setColor(Color.cyan);
....@@ -7414,28 +7526,7 @@
74147526 // {
74157527 // CameraPane.Ymax = spoth;
74167528 // }
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);
74227529 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
-// }
74397530 clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
74407531 (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
74417532 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
....@@ -7494,12 +7585,14 @@
74947585 retval = true;
74957586 }
74967587 spot.translate(0, 32);
7588
+ spot.translate(32, 0);
7589
+ spot.translate(0, 32);
74977590 if (spot.contains(clickInfo.x, clickInfo.y))
74987591 {
74997592 hitSomething = hitScale;
75007593
75017594 double scale = 0.005f * clickInfo.camera.Distance();
7502
- double hScale = (double) (clickInfo.x - centerPt.x) / 32;
7595
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
75037596 double sign = 1;
75047597 if (hScale < 0)
75057598 {
....@@ -7511,7 +7604,7 @@
75117604 //hScale = 0.01;
75127605 }
75137606
7514
- double vScale = (double) (clickInfo.y - centerPt.y) / 32;
7607
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
75157608 sign = 1;
75167609 if (vScale < 0)
75177610 {
....@@ -7726,7 +7819,7 @@
77267819 break;
77277820
77287821 case hitScale: // scale
7729
- double hScale = (double) (clickInfo.x - centerPt.x) / 32;
7822
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
77307823 double sign = 1;
77317824 if (hScale < 0)
77327825 {
....@@ -7738,7 +7831,7 @@
77387831 //hScale = 0.01;
77397832 }
77407833
7741
- double vScale = (double) (clickInfo.y - centerPt.y) / 32;
7834
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
77427835 sign = 1;
77437836 if (vScale < 0)
77447837 {
....@@ -7771,21 +7864,27 @@
77717864 case 3: // '\001'
77727865 if (modified || opposite)
77737866 {
7867
+ if (modified && opposite)
7868
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7869
+ else
77747870 //LA.matScale(toParent, 1, hScale, vScale);
7775
- LA.matScale(toParent, totalScale, 1, 1);
7871
+ LA.matScale(toParent, totalScale, 1, 1);
77767872 } // vScale, 1);
77777873 else
77787874 {
77797875 // EXCEPTION!
7780
- LA.matScale(toParent, totalScale, totalScale, totalScale);
7876
+ LA.matScale(toParent, 1, totalScale, totalScale);
77817877 } // vScale, 1);
77827878 break;
77837879
77847880 case 2: // '\002'
77857881 if (modified || opposite)
77867882 {
7787
- //LA.matScale(toParent, hScale, 1, vScale);
7788
- LA.matScale(toParent, 1, totalScale, 1);
7883
+ if (modified && opposite)
7884
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7885
+ else
7886
+ //LA.matScale(toParent, hScale, 1, vScale);
7887
+ LA.matScale(toParent, 1, totalScale, 1);
77897888 } else
77907889 {
77917890 LA.matScale(toParent, totalScale, 1, totalScale);
....@@ -7795,8 +7894,11 @@
77957894 case 1: // '\003'
77967895 if (modified || opposite)
77977896 {
7798
- //LA.matScale(toParent, hScale, vScale, 1);
7799
- LA.matScale(toParent, 1, 1, totalScale);
7897
+ if (modified && opposite)
7898
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7899
+ else
7900
+ //LA.matScale(toParent, hScale, vScale, 1);
7901
+ LA.matScale(toParent, 1, 1, totalScale);
78007902 } else
78017903 {
78027904 LA.matScale(toParent, totalScale, totalScale, 1);