Normand Briere
2019-06-11 5e6a6f3319f0c4c687fe71952ac9ecc17792b83a
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
....@@ -775,7 +779,7 @@
775779 if (step == 0)
776780 step = 1;
777781 if (maxcount == 0)
778
- maxcount = 2048; // 4;
782
+ maxcount = 128; // 2048; // 4;
779783 // if (acceleration == 0)
780784 // acceleration = 10;
781785 if (delay == 0) // serial
....@@ -5371,6 +5375,43 @@
53715375 }
53725376 }
53735377
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
+
53745415 void SetBumpTexture(String tex)
53755416 {
53765417 if (GetTextures() == null)
....@@ -6950,8 +6991,8 @@
69506991 // {
69516992 // CameraPane.Ymax = spoth;
69526993 // }
6953
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
6954
- 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);
69556996 spot.translate(0, -32);
69566997 info.g.setColor(Color.green);
69576998 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
....@@ -7006,7 +7047,7 @@
70067047 startX = info.x;
70077048 startY = info.y;
70087049
7009
- hitSomething = 0;
7050
+ hitSomething = -1;
70107051 cVector origin = new cVector();
70117052 //LA.xformPos(origin, toParent, origin);
70127053 Rectangle spot = new Rectangle();
....@@ -7082,6 +7123,7 @@
70827123 //System.out.println("hitSomething = " + hitSomething);
70837124
70847125 double scale = 0.005f * info.camera.Distance();
7126
+
70857127 cVector xlate = new cVector();
70867128 //cVector xlate2 = new cVector();
70877129 switch (hitSomething)
....@@ -7230,24 +7272,27 @@
72307272
72317273 case hitScale: // scale
72327274 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);
72337281 if (hScale < 0.01)
72347282 {
7235
- hScale = 0.01;
7283
+ //hScale = 0.01;
72367284 }
7237
- hScale = Math.pow(hScale, scale * 50);
7238
- if (hScale < 0.01)
7239
- {
7240
- hScale = 0.01;
7241
- }
7285
+
72427286 double vScale = (double) (info.y - centerPt.y) / 32;
7243
- if (vScale < 0.01)
7287
+ sign = 1;
7288
+ if (vScale < 0)
72447289 {
7245
- vScale = 0.01;
7290
+ sign = -1;
72467291 }
7247
- vScale = Math.pow(vScale, scale * 50);
7292
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
72487293 if (vScale < 0.01)
72497294 {
7250
- vScale = 0.01;
7295
+ //vScale = 0.01;
72517296 }
72527297 LA.matCopy(startMat, toParent);
72537298 /**/
....@@ -7258,17 +7303,24 @@
72587303 }
72597304 /**/
72607305
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
+
72617313 switch (info.pane.RenderCamera().viewCode)
72627314 {
72637315 case 3: // '\001'
72647316 if (modified)
72657317 {
72667318 //LA.matScale(toParent, 1, hScale, vScale);
7267
- LA.matScale(toParent, vScale, 1, 1);
7319
+ LA.matScale(toParent, totalScale, 1, 1);
72687320 } // vScale, 1);
72697321 else
72707322 {
7271
- LA.matScale(toParent, vScale, vScale, vScale);
7323
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
72727324 } // vScale, 1);
72737325 break;
72747326
....@@ -7276,10 +7328,10 @@
72767328 if (modified)
72777329 {
72787330 //LA.matScale(toParent, hScale, 1, vScale);
7279
- LA.matScale(toParent, 1, vScale, 1);
7331
+ LA.matScale(toParent, 1, totalScale, 1);
72807332 } else
72817333 {
7282
- LA.matScale(toParent, vScale, 1, vScale);
7334
+ LA.matScale(toParent, totalScale, 1, totalScale);
72837335 }
72847336 break;
72857337
....@@ -7287,10 +7339,10 @@
72877339 if (modified)
72887340 {
72897341 //LA.matScale(toParent, hScale, vScale, 1);
7290
- LA.matScale(toParent, 1, 1, vScale);
7342
+ LA.matScale(toParent, 1, 1, totalScale);
72917343 } else
72927344 {
7293
- LA.matScale(toParent, vScale, vScale, 1);
7345
+ LA.matScale(toParent, totalScale, totalScale, 1);
72947346 }
72957347 break;
72967348 }
....@@ -7431,7 +7483,7 @@
74317483 objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
74327484 } else
74337485 {
7434
- 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) ":"") */ "";
74357487 } // + super.toString();
74367488 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
74377489
....@@ -7679,9 +7731,9 @@
76797731 private static cVector edge2 = new cVector();
76807732 //private static cVector norm = new cVector();
76817733 /*transient private*/ int hitSomething;
7682
- private static final int hitCenter = 1;
7683
- private static final int hitScale = 2;
7684
- private static final int hitRotate = 3;
7734
+ static final int hitCenter = 1;
7735
+ static final int hitScale = 2;
7736
+ static final int hitRotate = 3;
76857737 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
76867738 /*transient*/ private Point centerPt;
76877739 /*transient*/ private int startX;