.. | .. |
---|
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 | |
---|
.. | .. |
---|
300 | 304 | } |
---|
301 | 305 | |
---|
302 | 306 | boolean live = false; |
---|
| 307 | + boolean dontselect = false; |
---|
303 | 308 | boolean hide = false; |
---|
304 | 309 | boolean link2master = false; // performs reset support/master at each frame |
---|
305 | 310 | boolean marked = false; // animation node |
---|
.. | .. |
---|
774 | 779 | if (step == 0) |
---|
775 | 780 | step = 1; |
---|
776 | 781 | if (maxcount == 0) |
---|
777 | | - maxcount = 2048; // 4; |
---|
| 782 | + maxcount = 128; // 2048; // 4; |
---|
778 | 783 | // if (acceleration == 0) |
---|
779 | 784 | // acceleration = 10; |
---|
780 | 785 | if (delay == 0) // serial |
---|
.. | .. |
---|
1834 | 1839 | if (obj.name == null) |
---|
1835 | 1840 | continue; // can't be a null one |
---|
1836 | 1841 | |
---|
| 1842 | + // Try perfect match first. |
---|
1837 | 1843 | if (n.equals(obj.name)) |
---|
1838 | 1844 | { |
---|
1839 | 1845 | theobj = obj; |
---|
1840 | 1846 | count++; |
---|
1841 | 1847 | } |
---|
1842 | 1848 | } |
---|
| 1849 | + |
---|
| 1850 | + // not needed: n = n.split(":")[0]; // Poser generates a count |
---|
1843 | 1851 | |
---|
1844 | 1852 | if (count != 1) |
---|
1845 | 1853 | for (int i=Size(); --i>=0;) |
---|
.. | .. |
---|
3002 | 3010 | v.fromParent = LA.newMatrix(); |
---|
3003 | 3011 | } |
---|
3004 | 3012 | |
---|
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); |
---|
3007 | 3017 | } |
---|
3008 | 3018 | |
---|
3009 | 3019 | toParent = null; // LA.matIdentity(toParent); |
---|
.. | .. |
---|
3236 | 3246 | bRep.support = null; |
---|
3237 | 3247 | BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep); |
---|
3238 | 3248 | // bRep.SplitInTwo(onlyone); // thread... |
---|
3239 | | - temprep.SplitInTwo(reduction34, onlyone); |
---|
| 3249 | + |
---|
| 3250 | + while(temprep.SplitInTwo(reduction34, onlyone)); |
---|
| 3251 | + |
---|
3240 | 3252 | bRep = temprep; |
---|
3241 | 3253 | bRep.support = sup; |
---|
3242 | 3254 | Touch(); |
---|
.. | .. |
---|
4711 | 4723 | |
---|
4712 | 4724 | cTreePath SelectLeaf(int indexcount, boolean deselect) |
---|
4713 | 4725 | { |
---|
4714 | | - if (hide) |
---|
| 4726 | + if (hide || dontselect) |
---|
4715 | 4727 | return null; |
---|
4716 | 4728 | |
---|
4717 | 4729 | if (count <= 0) |
---|
.. | .. |
---|
4737 | 4749 | |
---|
4738 | 4750 | cTreePath Select(int indexcount, boolean deselect) |
---|
4739 | 4751 | { |
---|
4740 | | - if (hide) |
---|
| 4752 | + if (hide || dontselect) |
---|
4741 | 4753 | return null; |
---|
4742 | 4754 | |
---|
4743 | 4755 | if (count <= 0) |
---|
.. | .. |
---|
5363 | 5375 | } |
---|
5364 | 5376 | } |
---|
5365 | 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 | + |
---|
5366 | 5415 | void SetBumpTexture(String tex) |
---|
5367 | 5416 | { |
---|
5368 | 5417 | if (GetTextures() == null) |
---|
.. | .. |
---|
5407 | 5456 | boolean NeedSupport() |
---|
5408 | 5457 | { |
---|
5409 | 5458 | return |
---|
5410 | | - CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null |
---|
| 5459 | + CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null |
---|
5411 | 5460 | // PROBLEM with CROWD!! |
---|
5412 | 5461 | && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD); |
---|
5413 | 5462 | } |
---|
.. | .. |
---|
5424 | 5473 | } |
---|
5425 | 5474 | |
---|
5426 | 5475 | if (display.DrawMode() == iCameraPane.SELECTION && |
---|
5427 | | - hide) |
---|
| 5476 | + (hide || dontselect)) |
---|
5428 | 5477 | return; |
---|
5429 | 5478 | |
---|
5430 | 5479 | if (name != null && name.contains("sclera")) |
---|
.. | .. |
---|
5666 | 5715 | tex = GetTextures(); |
---|
5667 | 5716 | } |
---|
5668 | 5717 | |
---|
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 | + } |
---|
5670 | 5729 | |
---|
5671 | 5730 | if (!compiled) |
---|
5672 | 5731 | { |
---|
.. | .. |
---|
5688 | 5747 | } |
---|
5689 | 5748 | } |
---|
5690 | 5749 | |
---|
5691 | | - display.ReleaseTextures(tex); |
---|
| 5750 | + if (!failed) |
---|
| 5751 | + display.ReleaseTextures(tex); |
---|
5692 | 5752 | |
---|
5693 | 5753 | display.PopMaterial(this, selected); |
---|
5694 | 5754 | } |
---|
.. | .. |
---|
5817 | 5877 | |
---|
5818 | 5878 | void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
5819 | 5879 | { |
---|
| 5880 | + if (display.DrawMode() == iCameraPane.SELECTION && dontselect) |
---|
| 5881 | + return; |
---|
| 5882 | + |
---|
5820 | 5883 | if (hide) |
---|
5821 | 5884 | return; |
---|
5822 | 5885 | // shadow optimisation |
---|
.. | .. |
---|
5941 | 6004 | { |
---|
5942 | 6005 | if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000) |
---|
5943 | 6006 | return; // no shadow for transparent objects |
---|
| 6007 | + |
---|
| 6008 | + if (display.DrawMode() == iCameraPane.SELECTION && dontselect) |
---|
| 6009 | + return; |
---|
5944 | 6010 | |
---|
5945 | 6011 | if (hide) |
---|
5946 | 6012 | return; |
---|
.. | .. |
---|
6925 | 6991 | // { |
---|
6926 | 6992 | // CameraPane.Ymax = spoth; |
---|
6927 | 6993 | // } |
---|
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); |
---|
6930 | 6996 | spot.translate(0, -32); |
---|
6931 | 6997 | info.g.setColor(Color.green); |
---|
6932 | 6998 | info.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
.. | .. |
---|
6981 | 7047 | startX = info.x; |
---|
6982 | 7048 | startY = info.y; |
---|
6983 | 7049 | |
---|
6984 | | - hitSomething = 0; |
---|
| 7050 | + hitSomething = -1; |
---|
6985 | 7051 | cVector origin = new cVector(); |
---|
6986 | 7052 | //LA.xformPos(origin, toParent, origin); |
---|
6987 | 7053 | Rectangle spot = new Rectangle(); |
---|
.. | .. |
---|
7057 | 7123 | //System.out.println("hitSomething = " + hitSomething); |
---|
7058 | 7124 | |
---|
7059 | 7125 | double scale = 0.005f * info.camera.Distance(); |
---|
| 7126 | + |
---|
7060 | 7127 | cVector xlate = new cVector(); |
---|
7061 | 7128 | //cVector xlate2 = new cVector(); |
---|
7062 | 7129 | switch (hitSomething) |
---|
.. | .. |
---|
7205 | 7272 | |
---|
7206 | 7273 | case hitScale: // scale |
---|
7207 | 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); |
---|
7208 | 7281 | if (hScale < 0.01) |
---|
7209 | 7282 | { |
---|
7210 | | - hScale = 0.01; |
---|
| 7283 | + //hScale = 0.01; |
---|
7211 | 7284 | } |
---|
7212 | | - hScale = Math.pow(hScale, scale * 50); |
---|
7213 | | - if (hScale < 0.01) |
---|
7214 | | - { |
---|
7215 | | - hScale = 0.01; |
---|
7216 | | - } |
---|
| 7285 | + |
---|
7217 | 7286 | double vScale = (double) (info.y - centerPt.y) / 32; |
---|
7218 | | - if (vScale < 0.01) |
---|
| 7287 | + sign = 1; |
---|
| 7288 | + if (vScale < 0) |
---|
7219 | 7289 | { |
---|
7220 | | - vScale = 0.01; |
---|
| 7290 | + sign = -1; |
---|
7221 | 7291 | } |
---|
7222 | | - vScale = Math.pow(vScale, scale * 50); |
---|
| 7292 | + vScale = sign*Math.pow(sign*vScale, scale * 50); |
---|
7223 | 7293 | if (vScale < 0.01) |
---|
7224 | 7294 | { |
---|
7225 | | - vScale = 0.01; |
---|
| 7295 | + //vScale = 0.01; |
---|
7226 | 7296 | } |
---|
7227 | 7297 | LA.matCopy(startMat, toParent); |
---|
7228 | 7298 | /**/ |
---|
.. | .. |
---|
7233 | 7303 | } |
---|
7234 | 7304 | /**/ |
---|
7235 | 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 | + |
---|
7236 | 7313 | switch (info.pane.RenderCamera().viewCode) |
---|
7237 | 7314 | { |
---|
7238 | 7315 | case 3: // '\001' |
---|
7239 | 7316 | if (modified) |
---|
7240 | 7317 | { |
---|
7241 | 7318 | //LA.matScale(toParent, 1, hScale, vScale); |
---|
7242 | | - LA.matScale(toParent, vScale, 1, 1); |
---|
| 7319 | + LA.matScale(toParent, totalScale, 1, 1); |
---|
7243 | 7320 | } // vScale, 1); |
---|
7244 | 7321 | else |
---|
7245 | 7322 | { |
---|
7246 | | - LA.matScale(toParent, vScale, vScale, vScale); |
---|
| 7323 | + LA.matScale(toParent, totalScale, totalScale, totalScale); |
---|
7247 | 7324 | } // vScale, 1); |
---|
7248 | 7325 | break; |
---|
7249 | 7326 | |
---|
.. | .. |
---|
7251 | 7328 | if (modified) |
---|
7252 | 7329 | { |
---|
7253 | 7330 | //LA.matScale(toParent, hScale, 1, vScale); |
---|
7254 | | - LA.matScale(toParent, 1, vScale, 1); |
---|
| 7331 | + LA.matScale(toParent, 1, totalScale, 1); |
---|
7255 | 7332 | } else |
---|
7256 | 7333 | { |
---|
7257 | | - LA.matScale(toParent, vScale, 1, vScale); |
---|
| 7334 | + LA.matScale(toParent, totalScale, 1, totalScale); |
---|
7258 | 7335 | } |
---|
7259 | 7336 | break; |
---|
7260 | 7337 | |
---|
.. | .. |
---|
7262 | 7339 | if (modified) |
---|
7263 | 7340 | { |
---|
7264 | 7341 | //LA.matScale(toParent, hScale, vScale, 1); |
---|
7265 | | - LA.matScale(toParent, 1, 1, vScale); |
---|
| 7342 | + LA.matScale(toParent, 1, 1, totalScale); |
---|
7266 | 7343 | } else |
---|
7267 | 7344 | { |
---|
7268 | | - LA.matScale(toParent, vScale, vScale, 1); |
---|
| 7345 | + LA.matScale(toParent, totalScale, totalScale, 1); |
---|
7269 | 7346 | } |
---|
7270 | 7347 | break; |
---|
7271 | 7348 | } |
---|
.. | .. |
---|
7406 | 7483 | objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")"; |
---|
7407 | 7484 | } else |
---|
7408 | 7485 | { |
---|
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) ":"") */ ""; |
---|
7410 | 7487 | } // + super.toString(); |
---|
7411 | 7488 | //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName(); |
---|
7412 | 7489 | |
---|
.. | .. |
---|
7654 | 7731 | private static cVector edge2 = new cVector(); |
---|
7655 | 7732 | //private static cVector norm = new cVector(); |
---|
7656 | 7733 | /*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; |
---|
7660 | 7737 | /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag |
---|
7661 | 7738 | /*transient*/ private Point centerPt; |
---|
7662 | 7739 | /*transient*/ private int startX; |
---|