.. | .. |
---|
14 | 14 | import //weka.core. |
---|
15 | 15 | matrix.Matrix; |
---|
16 | 16 | |
---|
| 17 | +import java.util.UUID; |
---|
| 18 | + |
---|
17 | 19 | //import net.sourceforge.sizeof.SizeOf; |
---|
18 | 20 | public class Object3D extends Vector<Object3D> implements java.io.Serializable, iSendInfo //, aurelienribon.tweenengine.TweenAccessor<Object3D> |
---|
19 | 21 | { |
---|
20 | 22 | //static final long serialVersionUID = -607422624994562685L; |
---|
21 | 23 | static final long serialVersionUID = 5022536242724664900L; |
---|
| 24 | + |
---|
| 25 | + private UUID uuid = UUID.randomUUID(); |
---|
22 | 26 | |
---|
23 | 27 | ScriptNode scriptnode; |
---|
24 | 28 | |
---|
.. | .. |
---|
775 | 779 | if (step == 0) |
---|
776 | 780 | step = 1; |
---|
777 | 781 | if (maxcount == 0) |
---|
778 | | - maxcount = 2048; // 4; |
---|
| 782 | + maxcount = 128; // 2048; // 4; |
---|
779 | 783 | // if (acceleration == 0) |
---|
780 | 784 | // acceleration = 10; |
---|
781 | 785 | if (delay == 0) // serial |
---|
.. | .. |
---|
5371 | 5375 | } |
---|
5372 | 5376 | } |
---|
5373 | 5377 | |
---|
| 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 | + |
---|
5374 | 5415 | void SetBumpTexture(String tex) |
---|
5375 | 5416 | { |
---|
5376 | 5417 | if (GetTextures() == null) |
---|
.. | .. |
---|
6950 | 6991 | // { |
---|
6951 | 6992 | // CameraPane.Ymax = spoth; |
---|
6952 | 6993 | // } |
---|
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); |
---|
6955 | 6996 | spot.translate(0, -32); |
---|
6956 | 6997 | info.g.setColor(Color.green); |
---|
6957 | 6998 | info.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
.. | .. |
---|
7006 | 7047 | startX = info.x; |
---|
7007 | 7048 | startY = info.y; |
---|
7008 | 7049 | |
---|
7009 | | - hitSomething = 0; |
---|
| 7050 | + hitSomething = -1; |
---|
7010 | 7051 | cVector origin = new cVector(); |
---|
7011 | 7052 | //LA.xformPos(origin, toParent, origin); |
---|
7012 | 7053 | Rectangle spot = new Rectangle(); |
---|
.. | .. |
---|
7082 | 7123 | //System.out.println("hitSomething = " + hitSomething); |
---|
7083 | 7124 | |
---|
7084 | 7125 | double scale = 0.005f * info.camera.Distance(); |
---|
| 7126 | + |
---|
7085 | 7127 | cVector xlate = new cVector(); |
---|
7086 | 7128 | //cVector xlate2 = new cVector(); |
---|
7087 | 7129 | switch (hitSomething) |
---|
.. | .. |
---|
7230 | 7272 | |
---|
7231 | 7273 | case hitScale: // scale |
---|
7232 | 7274 | 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); |
---|
7233 | 7281 | if (hScale < 0.01) |
---|
7234 | 7282 | { |
---|
7235 | | - hScale = 0.01; |
---|
| 7283 | + //hScale = 0.01; |
---|
7236 | 7284 | } |
---|
7237 | | - hScale = Math.pow(hScale, scale * 50); |
---|
7238 | | - if (hScale < 0.01) |
---|
7239 | | - { |
---|
7240 | | - hScale = 0.01; |
---|
7241 | | - } |
---|
| 7285 | + |
---|
7242 | 7286 | double vScale = (double) (info.y - centerPt.y) / 32; |
---|
7243 | | - if (vScale < 0.01) |
---|
| 7287 | + sign = 1; |
---|
| 7288 | + if (vScale < 0) |
---|
7244 | 7289 | { |
---|
7245 | | - vScale = 0.01; |
---|
| 7290 | + sign = -1; |
---|
7246 | 7291 | } |
---|
7247 | | - vScale = Math.pow(vScale, scale * 50); |
---|
| 7292 | + vScale = sign*Math.pow(sign*vScale, scale * 50); |
---|
7248 | 7293 | if (vScale < 0.01) |
---|
7249 | 7294 | { |
---|
7250 | | - vScale = 0.01; |
---|
| 7295 | + //vScale = 0.01; |
---|
7251 | 7296 | } |
---|
7252 | 7297 | LA.matCopy(startMat, toParent); |
---|
7253 | 7298 | /**/ |
---|
.. | .. |
---|
7258 | 7303 | } |
---|
7259 | 7304 | /**/ |
---|
7260 | 7305 | |
---|
| 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 | + |
---|
7261 | 7313 | switch (info.pane.RenderCamera().viewCode) |
---|
7262 | 7314 | { |
---|
7263 | 7315 | case 3: // '\001' |
---|
7264 | 7316 | if (modified) |
---|
7265 | 7317 | { |
---|
7266 | 7318 | //LA.matScale(toParent, 1, hScale, vScale); |
---|
7267 | | - LA.matScale(toParent, vScale, 1, 1); |
---|
| 7319 | + LA.matScale(toParent, totalScale, 1, 1); |
---|
7268 | 7320 | } // vScale, 1); |
---|
7269 | 7321 | else |
---|
7270 | 7322 | { |
---|
7271 | | - LA.matScale(toParent, vScale, vScale, vScale); |
---|
| 7323 | + LA.matScale(toParent, totalScale, totalScale, totalScale); |
---|
7272 | 7324 | } // vScale, 1); |
---|
7273 | 7325 | break; |
---|
7274 | 7326 | |
---|
.. | .. |
---|
7276 | 7328 | if (modified) |
---|
7277 | 7329 | { |
---|
7278 | 7330 | //LA.matScale(toParent, hScale, 1, vScale); |
---|
7279 | | - LA.matScale(toParent, 1, vScale, 1); |
---|
| 7331 | + LA.matScale(toParent, 1, totalScale, 1); |
---|
7280 | 7332 | } else |
---|
7281 | 7333 | { |
---|
7282 | | - LA.matScale(toParent, vScale, 1, vScale); |
---|
| 7334 | + LA.matScale(toParent, totalScale, 1, totalScale); |
---|
7283 | 7335 | } |
---|
7284 | 7336 | break; |
---|
7285 | 7337 | |
---|
.. | .. |
---|
7287 | 7339 | if (modified) |
---|
7288 | 7340 | { |
---|
7289 | 7341 | //LA.matScale(toParent, hScale, vScale, 1); |
---|
7290 | | - LA.matScale(toParent, 1, 1, vScale); |
---|
| 7342 | + LA.matScale(toParent, 1, 1, totalScale); |
---|
7291 | 7343 | } else |
---|
7292 | 7344 | { |
---|
7293 | | - LA.matScale(toParent, vScale, vScale, 1); |
---|
| 7345 | + LA.matScale(toParent, totalScale, totalScale, 1); |
---|
7294 | 7346 | } |
---|
7295 | 7347 | break; |
---|
7296 | 7348 | } |
---|
.. | .. |
---|
7431 | 7483 | objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")"; |
---|
7432 | 7484 | } else |
---|
7433 | 7485 | { |
---|
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) ":"") */ ""; |
---|
7435 | 7487 | } // + super.toString(); |
---|
7436 | 7488 | //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName(); |
---|
7437 | 7489 | |
---|
.. | .. |
---|
7679 | 7731 | private static cVector edge2 = new cVector(); |
---|
7680 | 7732 | //private static cVector norm = new cVector(); |
---|
7681 | 7733 | /*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; |
---|
7685 | 7737 | /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag |
---|
7686 | 7738 | /*transient*/ private Point centerPt; |
---|
7687 | 7739 | /*transient*/ private int startX; |
---|