.. | .. |
---|
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 | |
---|
.. | .. |
---|
156 | 160 | blockloop = true; |
---|
157 | 161 | child.RestoreSupports(); |
---|
158 | 162 | blockloop = false; |
---|
| 163 | + } |
---|
| 164 | +} |
---|
| 165 | + |
---|
| 166 | +void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable) |
---|
| 167 | +{ |
---|
| 168 | + if (hashtable.containsKey(GetUUID())) |
---|
| 169 | + { |
---|
| 170 | + Object3D o = hashtable.get(GetUUID()); |
---|
| 171 | + |
---|
| 172 | + assert(this.bRep == o.bRep); |
---|
| 173 | + if (this.bRep != null) |
---|
| 174 | + assert(this.bRep.support == o.transientrep); |
---|
| 175 | + |
---|
| 176 | + return; |
---|
| 177 | + } |
---|
| 178 | + |
---|
| 179 | + Object3D o = new Object3D(); |
---|
| 180 | + o.bRep = this.bRep; |
---|
| 181 | + if (this.bRep != null) |
---|
| 182 | + { |
---|
| 183 | + o.transientrep = this.bRep.support; |
---|
| 184 | + o.bRep.support = null; |
---|
| 185 | + } |
---|
| 186 | + |
---|
| 187 | +// o.support = this.support; |
---|
| 188 | +// o.fileparent = this.fileparent; |
---|
| 189 | +// if (this.bRep != null) |
---|
| 190 | +// o.bRep = this.bRep.support; |
---|
| 191 | + |
---|
| 192 | + hashtable.put(GetUUID(), o); |
---|
| 193 | + |
---|
| 194 | + this.bRep = null; |
---|
| 195 | +// if (this.bRep != null) |
---|
| 196 | +// this.bRep.support = null; |
---|
| 197 | +// this.support = null; |
---|
| 198 | +// this.fileparent = null; |
---|
| 199 | + |
---|
| 200 | + for (int i=0; i<Size(); i++) |
---|
| 201 | + { |
---|
| 202 | + get(i).ExtractBigData(hashtable); |
---|
| 203 | + } |
---|
| 204 | +} |
---|
| 205 | + |
---|
| 206 | +void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable) |
---|
| 207 | +{ |
---|
| 208 | + if (!hashtable.containsKey(GetUUID())) |
---|
| 209 | + return; |
---|
| 210 | + |
---|
| 211 | + Object3D o = hashtable.get(GetUUID()); |
---|
| 212 | + |
---|
| 213 | + this.bRep = o.bRep; |
---|
| 214 | + if (this.bRep != null) |
---|
| 215 | + this.bRep.support = o.transientrep; |
---|
| 216 | +// this.support = o.support; |
---|
| 217 | +// this.fileparent = o.fileparent; |
---|
| 218 | + |
---|
| 219 | + hashtable.remove(GetUUID()); |
---|
| 220 | + |
---|
| 221 | + for (int i=0; i<Size(); i++) |
---|
| 222 | + { |
---|
| 223 | + get(i).RestoreBigData(hashtable); |
---|
159 | 224 | } |
---|
160 | 225 | } |
---|
161 | 226 | |
---|
.. | .. |
---|
300 | 365 | } |
---|
301 | 366 | |
---|
302 | 367 | boolean live = false; |
---|
| 368 | + boolean dontselect = false; |
---|
303 | 369 | boolean hide = false; |
---|
304 | 370 | boolean link2master = false; // performs reset support/master at each frame |
---|
305 | 371 | boolean marked = false; // animation node |
---|
.. | .. |
---|
774 | 840 | if (step == 0) |
---|
775 | 841 | step = 1; |
---|
776 | 842 | if (maxcount == 0) |
---|
777 | | - maxcount = 2048; // 4; |
---|
| 843 | + maxcount = 128; // 2048; // 4; |
---|
778 | 844 | // if (acceleration == 0) |
---|
779 | 845 | // acceleration = 10; |
---|
780 | 846 | if (delay == 0) // serial |
---|
.. | .. |
---|
1834 | 1900 | if (obj.name == null) |
---|
1835 | 1901 | continue; // can't be a null one |
---|
1836 | 1902 | |
---|
| 1903 | + // Try perfect match first. |
---|
1837 | 1904 | if (n.equals(obj.name)) |
---|
1838 | 1905 | { |
---|
1839 | 1906 | theobj = obj; |
---|
1840 | 1907 | count++; |
---|
1841 | 1908 | } |
---|
1842 | 1909 | } |
---|
| 1910 | + |
---|
| 1911 | + // not needed: n = n.split(":")[0]; // Poser generates a count |
---|
1843 | 1912 | |
---|
1844 | 1913 | if (count != 1) |
---|
1845 | 1914 | for (int i=Size(); --i>=0;) |
---|
.. | .. |
---|
3002 | 3071 | v.fromParent = LA.newMatrix(); |
---|
3003 | 3072 | } |
---|
3004 | 3073 | |
---|
3005 | | - LA.matConcat(v.toParent, toParent, v.toParent); |
---|
3006 | | - LA.matConcat(fromParent, v.fromParent, v.fromParent); |
---|
| 3074 | +// LA.matConcat(v.toParent, toParent, v.toParent); |
---|
| 3075 | +// LA.matConcat(fromParent, v.fromParent, v.fromParent); |
---|
| 3076 | + LA.matConcat(toParent, v.toParent, v.toParent); |
---|
| 3077 | + LA.matConcat(v.fromParent, fromParent, v.fromParent); |
---|
3007 | 3078 | } |
---|
3008 | 3079 | |
---|
3009 | 3080 | toParent = null; // LA.matIdentity(toParent); |
---|
.. | .. |
---|
3236 | 3307 | bRep.support = null; |
---|
3237 | 3308 | BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep); |
---|
3238 | 3309 | // bRep.SplitInTwo(onlyone); // thread... |
---|
3239 | | - temprep.SplitInTwo(reduction34, onlyone); |
---|
| 3310 | + |
---|
| 3311 | + while(temprep.SplitInTwo(reduction34, onlyone)); |
---|
| 3312 | + |
---|
3240 | 3313 | bRep = temprep; |
---|
3241 | 3314 | bRep.support = sup; |
---|
3242 | 3315 | Touch(); |
---|
.. | .. |
---|
4711 | 4784 | |
---|
4712 | 4785 | cTreePath SelectLeaf(int indexcount, boolean deselect) |
---|
4713 | 4786 | { |
---|
4714 | | - if (hide) |
---|
| 4787 | + if (hide || dontselect) |
---|
4715 | 4788 | return null; |
---|
4716 | 4789 | |
---|
4717 | 4790 | if (count <= 0) |
---|
.. | .. |
---|
4737 | 4810 | |
---|
4738 | 4811 | cTreePath Select(int indexcount, boolean deselect) |
---|
4739 | 4812 | { |
---|
4740 | | - if (hide) |
---|
| 4813 | + if (hide || dontselect) |
---|
4741 | 4814 | return null; |
---|
4742 | 4815 | |
---|
4743 | 4816 | if (count <= 0) |
---|
.. | .. |
---|
5363 | 5436 | } |
---|
5364 | 5437 | } |
---|
5365 | 5438 | |
---|
| 5439 | + UUID GetUUID() |
---|
| 5440 | + { |
---|
| 5441 | + if (uuid == null) |
---|
| 5442 | + { |
---|
| 5443 | + // Serial |
---|
| 5444 | + uuid = UUID.randomUUID(); |
---|
| 5445 | + } |
---|
| 5446 | + |
---|
| 5447 | + return uuid; |
---|
| 5448 | + } |
---|
| 5449 | + |
---|
| 5450 | + Object3D GetObject(UUID uid) |
---|
| 5451 | + { |
---|
| 5452 | + if (blockloop) |
---|
| 5453 | + return null; |
---|
| 5454 | + |
---|
| 5455 | + if (GetUUID().equals(uid)) |
---|
| 5456 | + return this; |
---|
| 5457 | + |
---|
| 5458 | + int nb = Size(); |
---|
| 5459 | + for (int i = 0; i < nb; i++) |
---|
| 5460 | + { |
---|
| 5461 | + Object3D child = (Object3D) get(i); |
---|
| 5462 | + |
---|
| 5463 | + if (child == null) |
---|
| 5464 | + continue; |
---|
| 5465 | + |
---|
| 5466 | + blockloop = true; |
---|
| 5467 | + Object3D obj = child.GetObject(uid); |
---|
| 5468 | + blockloop = false; |
---|
| 5469 | + if (obj != null) |
---|
| 5470 | + return obj; |
---|
| 5471 | + } |
---|
| 5472 | + |
---|
| 5473 | + return null; |
---|
| 5474 | + } |
---|
| 5475 | + |
---|
5366 | 5476 | void SetBumpTexture(String tex) |
---|
5367 | 5477 | { |
---|
5368 | 5478 | if (GetTextures() == null) |
---|
.. | .. |
---|
5407 | 5517 | boolean NeedSupport() |
---|
5408 | 5518 | { |
---|
5409 | 5519 | return |
---|
5410 | | - CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null |
---|
| 5520 | + CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null |
---|
5411 | 5521 | // PROBLEM with CROWD!! |
---|
5412 | 5522 | && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD); |
---|
5413 | 5523 | } |
---|
.. | .. |
---|
5424 | 5534 | } |
---|
5425 | 5535 | |
---|
5426 | 5536 | if (display.DrawMode() == iCameraPane.SELECTION && |
---|
5427 | | - hide) |
---|
| 5537 | + (hide || dontselect)) |
---|
5428 | 5538 | return; |
---|
5429 | 5539 | |
---|
5430 | 5540 | if (name != null && name.contains("sclera")) |
---|
.. | .. |
---|
5666 | 5776 | tex = GetTextures(); |
---|
5667 | 5777 | } |
---|
5668 | 5778 | |
---|
5669 | | - display.BindTextures(tex, texres); |
---|
| 5779 | + boolean failed = false; |
---|
| 5780 | + |
---|
| 5781 | + try |
---|
| 5782 | + { |
---|
| 5783 | + display.BindTextures(tex, texres); |
---|
| 5784 | + } |
---|
| 5785 | + catch (Exception e) |
---|
| 5786 | + { |
---|
| 5787 | + System.err.println("FAILED: " + this); |
---|
| 5788 | + failed = true; |
---|
| 5789 | + } |
---|
5670 | 5790 | |
---|
5671 | 5791 | if (!compiled) |
---|
5672 | 5792 | { |
---|
.. | .. |
---|
5688 | 5808 | } |
---|
5689 | 5809 | } |
---|
5690 | 5810 | |
---|
5691 | | - display.ReleaseTextures(tex); |
---|
| 5811 | + if (!failed) |
---|
| 5812 | + display.ReleaseTextures(tex); |
---|
5692 | 5813 | |
---|
5693 | 5814 | display.PopMaterial(this, selected); |
---|
5694 | 5815 | } |
---|
.. | .. |
---|
5817 | 5938 | |
---|
5818 | 5939 | void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
5819 | 5940 | { |
---|
| 5941 | + if (display.DrawMode() == iCameraPane.SELECTION && dontselect) |
---|
| 5942 | + return; |
---|
| 5943 | + |
---|
5820 | 5944 | if (hide) |
---|
5821 | 5945 | return; |
---|
5822 | 5946 | // shadow optimisation |
---|
.. | .. |
---|
5941 | 6065 | { |
---|
5942 | 6066 | if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000) |
---|
5943 | 6067 | return; // no shadow for transparent objects |
---|
| 6068 | + |
---|
| 6069 | + if (display.DrawMode() == iCameraPane.SELECTION && dontselect) |
---|
| 6070 | + return; |
---|
5944 | 6071 | |
---|
5945 | 6072 | if (hide) |
---|
5946 | 6073 | return; |
---|
.. | .. |
---|
6925 | 7052 | // { |
---|
6926 | 7053 | // CameraPane.Ymax = spoth; |
---|
6927 | 7054 | // } |
---|
6928 | | - info.g.drawLine(spotw, spoth, spotw, spoth - 15); |
---|
6929 | | - info.g.drawLine(spotw, spoth, spotw - 15, spoth); |
---|
| 7055 | + // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - 15); |
---|
| 7056 | + //info.g.drawLine(spotw, spoth, spotw - 15, spoth); |
---|
6930 | 7057 | spot.translate(0, -32); |
---|
6931 | 7058 | info.g.setColor(Color.green); |
---|
6932 | 7059 | info.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
.. | .. |
---|
6981 | 7108 | startX = info.x; |
---|
6982 | 7109 | startY = info.y; |
---|
6983 | 7110 | |
---|
6984 | | - hitSomething = 0; |
---|
| 7111 | + hitSomething = -1; |
---|
6985 | 7112 | cVector origin = new cVector(); |
---|
6986 | 7113 | //LA.xformPos(origin, toParent, origin); |
---|
6987 | 7114 | Rectangle spot = new Rectangle(); |
---|
.. | .. |
---|
7057 | 7184 | //System.out.println("hitSomething = " + hitSomething); |
---|
7058 | 7185 | |
---|
7059 | 7186 | double scale = 0.005f * info.camera.Distance(); |
---|
| 7187 | + |
---|
7060 | 7188 | cVector xlate = new cVector(); |
---|
7061 | 7189 | //cVector xlate2 = new cVector(); |
---|
7062 | 7190 | switch (hitSomething) |
---|
.. | .. |
---|
7205 | 7333 | |
---|
7206 | 7334 | case hitScale: // scale |
---|
7207 | 7335 | double hScale = (double) (info.x - centerPt.x) / 32; |
---|
| 7336 | + double sign = 1; |
---|
| 7337 | + if (hScale < 0) |
---|
| 7338 | + { |
---|
| 7339 | + sign = -1; |
---|
| 7340 | + } |
---|
| 7341 | + hScale = sign*Math.pow(sign*hScale, scale * 50); |
---|
7208 | 7342 | if (hScale < 0.01) |
---|
7209 | 7343 | { |
---|
7210 | | - hScale = 0.01; |
---|
| 7344 | + //hScale = 0.01; |
---|
7211 | 7345 | } |
---|
7212 | | - hScale = Math.pow(hScale, scale * 50); |
---|
7213 | | - if (hScale < 0.01) |
---|
7214 | | - { |
---|
7215 | | - hScale = 0.01; |
---|
7216 | | - } |
---|
| 7346 | + |
---|
7217 | 7347 | double vScale = (double) (info.y - centerPt.y) / 32; |
---|
7218 | | - if (vScale < 0.01) |
---|
| 7348 | + sign = 1; |
---|
| 7349 | + if (vScale < 0) |
---|
7219 | 7350 | { |
---|
7220 | | - vScale = 0.01; |
---|
| 7351 | + sign = -1; |
---|
7221 | 7352 | } |
---|
7222 | | - vScale = Math.pow(vScale, scale * 50); |
---|
| 7353 | + vScale = sign*Math.pow(sign*vScale, scale * 50); |
---|
7223 | 7354 | if (vScale < 0.01) |
---|
7224 | 7355 | { |
---|
7225 | | - vScale = 0.01; |
---|
| 7356 | + //vScale = 0.01; |
---|
7226 | 7357 | } |
---|
7227 | 7358 | LA.matCopy(startMat, toParent); |
---|
7228 | 7359 | /**/ |
---|
.. | .. |
---|
7233 | 7364 | } |
---|
7234 | 7365 | /**/ |
---|
7235 | 7366 | |
---|
| 7367 | + double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2); |
---|
| 7368 | + |
---|
| 7369 | + if (totalScale < 0.01) |
---|
| 7370 | + { |
---|
| 7371 | + totalScale = 0.01; |
---|
| 7372 | + } |
---|
| 7373 | + |
---|
7236 | 7374 | switch (info.pane.RenderCamera().viewCode) |
---|
7237 | 7375 | { |
---|
7238 | 7376 | case 3: // '\001' |
---|
7239 | 7377 | if (modified) |
---|
7240 | 7378 | { |
---|
7241 | 7379 | //LA.matScale(toParent, 1, hScale, vScale); |
---|
7242 | | - LA.matScale(toParent, vScale, 1, 1); |
---|
| 7380 | + LA.matScale(toParent, totalScale, 1, 1); |
---|
7243 | 7381 | } // vScale, 1); |
---|
7244 | 7382 | else |
---|
7245 | 7383 | { |
---|
7246 | | - LA.matScale(toParent, vScale, vScale, vScale); |
---|
| 7384 | + LA.matScale(toParent, totalScale, totalScale, totalScale); |
---|
7247 | 7385 | } // vScale, 1); |
---|
7248 | 7386 | break; |
---|
7249 | 7387 | |
---|
.. | .. |
---|
7251 | 7389 | if (modified) |
---|
7252 | 7390 | { |
---|
7253 | 7391 | //LA.matScale(toParent, hScale, 1, vScale); |
---|
7254 | | - LA.matScale(toParent, 1, vScale, 1); |
---|
| 7392 | + LA.matScale(toParent, 1, totalScale, 1); |
---|
7255 | 7393 | } else |
---|
7256 | 7394 | { |
---|
7257 | | - LA.matScale(toParent, vScale, 1, vScale); |
---|
| 7395 | + LA.matScale(toParent, totalScale, 1, totalScale); |
---|
7258 | 7396 | } |
---|
7259 | 7397 | break; |
---|
7260 | 7398 | |
---|
.. | .. |
---|
7262 | 7400 | if (modified) |
---|
7263 | 7401 | { |
---|
7264 | 7402 | //LA.matScale(toParent, hScale, vScale, 1); |
---|
7265 | | - LA.matScale(toParent, 1, 1, vScale); |
---|
| 7403 | + LA.matScale(toParent, 1, 1, totalScale); |
---|
7266 | 7404 | } else |
---|
7267 | 7405 | { |
---|
7268 | | - LA.matScale(toParent, vScale, vScale, 1); |
---|
| 7406 | + LA.matScale(toParent, totalScale, totalScale, 1); |
---|
7269 | 7407 | } |
---|
7270 | 7408 | break; |
---|
7271 | 7409 | } |
---|
.. | .. |
---|
7406 | 7544 | objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")"; |
---|
7407 | 7545 | } else |
---|
7408 | 7546 | { |
---|
7409 | | - objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ ""; |
---|
| 7547 | + objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ ""; |
---|
7410 | 7548 | } // + super.toString(); |
---|
7411 | 7549 | //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName(); |
---|
7412 | 7550 | |
---|
.. | .. |
---|
7490 | 7628 | /*transient*/ cVector2[] projectedVertices = new cVector2[0]; |
---|
7491 | 7629 | |
---|
7492 | 7630 | Object3D /*Composite*/ parent; |
---|
7493 | | - Object3D /*Composite*/ fileparent; |
---|
| 7631 | + Object3D /*Composite*/ fileparent; // In the case of FileObject |
---|
7494 | 7632 | |
---|
7495 | 7633 | double[][] toParent; // dynamic matrix |
---|
7496 | 7634 | double[][] fromParent; |
---|
.. | .. |
---|
7654 | 7792 | private static cVector edge2 = new cVector(); |
---|
7655 | 7793 | //private static cVector norm = new cVector(); |
---|
7656 | 7794 | /*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; |
---|
| 7795 | + static final int hitCenter = 1; |
---|
| 7796 | + static final int hitScale = 2; |
---|
| 7797 | + static final int hitRotate = 3; |
---|
7660 | 7798 | /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag |
---|
7661 | 7799 | /*transient*/ private Point centerPt; |
---|
7662 | 7800 | /*transient*/ private int startX; |
---|