Normand Briere
2019-06-09 8558ae86e65457c512a26339d3660d79eee16ae6
Object3D.java
....@@ -14,11 +14,15 @@
1414 import //weka.core.
1515 matrix.Matrix;
1616
17
+import java.util.UUID;
18
+
1719 //import net.sourceforge.sizeof.SizeOf;
1820 public class Object3D extends Vector<Object3D> implements java.io.Serializable, iSendInfo //, aurelienribon.tweenengine.TweenAccessor<Object3D>
1921 {
2022 //static final long serialVersionUID = -607422624994562685L;
2123 static final long serialVersionUID = 5022536242724664900L;
24
+
25
+ private UUID uuid = UUID.randomUUID();
2226
2327 ScriptNode scriptnode;
2428
....@@ -300,6 +304,7 @@
300304 }
301305
302306 boolean live = false;
307
+ boolean dontselect = false;
303308 boolean hide = false;
304309 boolean link2master = false; // performs reset support/master at each frame
305310 boolean marked = false; // animation node
....@@ -774,7 +779,7 @@
774779 if (step == 0)
775780 step = 1;
776781 if (maxcount == 0)
777
- maxcount = 2048; // 4;
782
+ maxcount = 128; // 2048; // 4;
778783 // if (acceleration == 0)
779784 // acceleration = 10;
780785 if (delay == 0) // serial
....@@ -1834,12 +1839,15 @@
18341839 if (obj.name == null)
18351840 continue; // can't be a null one
18361841
1842
+ // Try perfect match first.
18371843 if (n.equals(obj.name))
18381844 {
18391845 theobj = obj;
18401846 count++;
18411847 }
18421848 }
1849
+
1850
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18431851
18441852 if (count != 1)
18451853 for (int i=Size(); --i>=0;)
....@@ -3002,8 +3010,10 @@
30023010 v.fromParent = LA.newMatrix();
30033011 }
30043012
3005
- LA.matConcat(v.toParent, toParent, v.toParent);
3006
- LA.matConcat(fromParent, v.fromParent, v.fromParent);
3013
+// LA.matConcat(v.toParent, toParent, v.toParent);
3014
+// LA.matConcat(fromParent, v.fromParent, v.fromParent);
3015
+ LA.matConcat(toParent, v.toParent, v.toParent);
3016
+ LA.matConcat(v.fromParent, fromParent, v.fromParent);
30073017 }
30083018
30093019 toParent = null; // LA.matIdentity(toParent);
....@@ -3236,7 +3246,9 @@
32363246 bRep.support = null;
32373247 BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
32383248 // bRep.SplitInTwo(onlyone); // thread...
3239
- temprep.SplitInTwo(reduction34, onlyone);
3249
+
3250
+ while(temprep.SplitInTwo(reduction34, onlyone));
3251
+
32403252 bRep = temprep;
32413253 bRep.support = sup;
32423254 Touch();
....@@ -4711,7 +4723,7 @@
47114723
47124724 cTreePath SelectLeaf(int indexcount, boolean deselect)
47134725 {
4714
- if (hide)
4726
+ if (hide || dontselect)
47154727 return null;
47164728
47174729 if (count <= 0)
....@@ -4737,7 +4749,7 @@
47374749
47384750 cTreePath Select(int indexcount, boolean deselect)
47394751 {
4740
- if (hide)
4752
+ if (hide || dontselect)
47414753 return null;
47424754
47434755 if (count <= 0)
....@@ -5363,6 +5375,43 @@
53635375 }
53645376 }
53655377
5378
+ UUID GetUUID()
5379
+ {
5380
+ if (uuid == null)
5381
+ {
5382
+ // Serial
5383
+ uuid = UUID.randomUUID();
5384
+ }
5385
+
5386
+ return uuid;
5387
+ }
5388
+
5389
+ Object3D GetObject(UUID uid)
5390
+ {
5391
+ if (blockloop)
5392
+ return null;
5393
+
5394
+ if (GetUUID().equals(uid))
5395
+ return this;
5396
+
5397
+ int nb = Size();
5398
+ for (int i = 0; i < nb; i++)
5399
+ {
5400
+ Object3D child = (Object3D) get(i);
5401
+
5402
+ if (child == null)
5403
+ continue;
5404
+
5405
+ blockloop = true;
5406
+ Object3D obj = child.GetObject(uid);
5407
+ blockloop = false;
5408
+ if (obj != null)
5409
+ return obj;
5410
+ }
5411
+
5412
+ return null;
5413
+ }
5414
+
53665415 void SetBumpTexture(String tex)
53675416 {
53685417 if (GetTextures() == null)
....@@ -5407,7 +5456,7 @@
54075456 boolean NeedSupport()
54085457 {
54095458 return
5410
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5459
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null
54115460 // PROBLEM with CROWD!!
54125461 && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
54135462 }
....@@ -5424,7 +5473,7 @@
54245473 }
54255474
54265475 if (display.DrawMode() == iCameraPane.SELECTION &&
5427
- hide)
5476
+ (hide || dontselect))
54285477 return;
54295478
54305479 if (name != null && name.contains("sclera"))
....@@ -5666,7 +5715,17 @@
56665715 tex = GetTextures();
56675716 }
56685717
5669
- display.BindTextures(tex, texres);
5718
+ boolean failed = false;
5719
+
5720
+ try
5721
+ {
5722
+ display.BindTextures(tex, texres);
5723
+ }
5724
+ catch (Exception e)
5725
+ {
5726
+ System.err.println("FAILED: " + this);
5727
+ failed = true;
5728
+ }
56705729
56715730 if (!compiled)
56725731 {
....@@ -5688,7 +5747,8 @@
56885747 }
56895748 }
56905749
5691
- display.ReleaseTextures(tex);
5750
+ if (!failed)
5751
+ display.ReleaseTextures(tex);
56925752
56935753 display.PopMaterial(this, selected);
56945754 }
....@@ -5817,6 +5877,9 @@
58175877
58185878 void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
58195879 {
5880
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
5881
+ return;
5882
+
58205883 if (hide)
58215884 return;
58225885 // shadow optimisation
....@@ -5941,6 +6004,9 @@
59416004 {
59426005 if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
59436006 return; // no shadow for transparent objects
6007
+
6008
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6009
+ return;
59446010
59456011 if (hide)
59466012 return;
....@@ -6925,8 +6991,8 @@
69256991 // {
69266992 // CameraPane.Ymax = spoth;
69276993 // }
6928
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
6929
- info.g.drawLine(spotw, spoth, spotw - 15, spoth);
6994
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - 15);
6995
+ //info.g.drawLine(spotw, spoth, spotw - 15, spoth);
69306996 spot.translate(0, -32);
69316997 info.g.setColor(Color.green);
69326998 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
....@@ -6981,7 +7047,7 @@
69817047 startX = info.x;
69827048 startY = info.y;
69837049
6984
- hitSomething = 0;
7050
+ hitSomething = -1;
69857051 cVector origin = new cVector();
69867052 //LA.xformPos(origin, toParent, origin);
69877053 Rectangle spot = new Rectangle();
....@@ -7057,6 +7123,7 @@
70577123 //System.out.println("hitSomething = " + hitSomething);
70587124
70597125 double scale = 0.005f * info.camera.Distance();
7126
+
70607127 cVector xlate = new cVector();
70617128 //cVector xlate2 = new cVector();
70627129 switch (hitSomething)
....@@ -7205,24 +7272,27 @@
72057272
72067273 case hitScale: // scale
72077274 double hScale = (double) (info.x - centerPt.x) / 32;
7275
+ double sign = 1;
7276
+ if (hScale < 0)
7277
+ {
7278
+ sign = -1;
7279
+ }
7280
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
72087281 if (hScale < 0.01)
72097282 {
7210
- hScale = 0.01;
7283
+ //hScale = 0.01;
72117284 }
7212
- hScale = Math.pow(hScale, scale * 50);
7213
- if (hScale < 0.01)
7214
- {
7215
- hScale = 0.01;
7216
- }
7285
+
72177286 double vScale = (double) (info.y - centerPt.y) / 32;
7218
- if (vScale < 0.01)
7287
+ sign = 1;
7288
+ if (vScale < 0)
72197289 {
7220
- vScale = 0.01;
7290
+ sign = -1;
72217291 }
7222
- vScale = Math.pow(vScale, scale * 50);
7292
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
72237293 if (vScale < 0.01)
72247294 {
7225
- vScale = 0.01;
7295
+ //vScale = 0.01;
72267296 }
72277297 LA.matCopy(startMat, toParent);
72287298 /**/
....@@ -7233,17 +7303,24 @@
72337303 }
72347304 /**/
72357305
7306
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7307
+
7308
+ if (totalScale < 0.01)
7309
+ {
7310
+ totalScale = 0.01;
7311
+ }
7312
+
72367313 switch (info.pane.RenderCamera().viewCode)
72377314 {
72387315 case 3: // '\001'
72397316 if (modified)
72407317 {
72417318 //LA.matScale(toParent, 1, hScale, vScale);
7242
- LA.matScale(toParent, vScale, 1, 1);
7319
+ LA.matScale(toParent, totalScale, 1, 1);
72437320 } // vScale, 1);
72447321 else
72457322 {
7246
- LA.matScale(toParent, vScale, vScale, vScale);
7323
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
72477324 } // vScale, 1);
72487325 break;
72497326
....@@ -7251,10 +7328,10 @@
72517328 if (modified)
72527329 {
72537330 //LA.matScale(toParent, hScale, 1, vScale);
7254
- LA.matScale(toParent, 1, vScale, 1);
7331
+ LA.matScale(toParent, 1, totalScale, 1);
72557332 } else
72567333 {
7257
- LA.matScale(toParent, vScale, 1, vScale);
7334
+ LA.matScale(toParent, totalScale, 1, totalScale);
72587335 }
72597336 break;
72607337
....@@ -7262,10 +7339,10 @@
72627339 if (modified)
72637340 {
72647341 //LA.matScale(toParent, hScale, vScale, 1);
7265
- LA.matScale(toParent, 1, 1, vScale);
7342
+ LA.matScale(toParent, 1, 1, totalScale);
72667343 } else
72677344 {
7268
- LA.matScale(toParent, vScale, vScale, 1);
7345
+ LA.matScale(toParent, totalScale, totalScale, 1);
72697346 }
72707347 break;
72717348 }
....@@ -7406,7 +7483,7 @@
74067483 objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
74077484 } else
74087485 {
7409
- objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
7486
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
74107487 } // + super.toString();
74117488 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
74127489
....@@ -7654,9 +7731,9 @@
76547731 private static cVector edge2 = new cVector();
76557732 //private static cVector norm = new cVector();
76567733 /*transient private*/ int hitSomething;
7657
- private static final int hitCenter = 1;
7658
- private static final int hitScale = 2;
7659
- private static final int hitRotate = 3;
7734
+ static final int hitCenter = 1;
7735
+ static final int hitScale = 2;
7736
+ static final int hitRotate = 3;
76607737 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
76617738 /*transient*/ private Point centerPt;
76627739 /*transient*/ private int startX;