.. | .. |
---|
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 | + return; |
---|
| 170 | + |
---|
| 171 | + Object3D o = new Object3D(); |
---|
| 172 | + o.bRep = this.bRep; |
---|
| 173 | + if (this.bRep != null) |
---|
| 174 | + { |
---|
| 175 | + o.transientrep = this.bRep.support; |
---|
| 176 | + o.bRep.support = null; |
---|
| 177 | + } |
---|
| 178 | + |
---|
| 179 | +// o.support = this.support; |
---|
| 180 | +// o.fileparent = this.fileparent; |
---|
| 181 | +// if (this.bRep != null) |
---|
| 182 | +// o.bRep = this.bRep.support; |
---|
| 183 | + |
---|
| 184 | + hashtable.put(GetUUID(), o); |
---|
| 185 | + |
---|
| 186 | + this.bRep = null; |
---|
| 187 | +// if (this.bRep != null) |
---|
| 188 | +// this.bRep.support = null; |
---|
| 189 | +// this.support = null; |
---|
| 190 | +// this.fileparent = null; |
---|
| 191 | + |
---|
| 192 | + for (int i=0; i<Size(); i++) |
---|
| 193 | + { |
---|
| 194 | + get(i).ExtractBigData(hashtable); |
---|
| 195 | + } |
---|
| 196 | +} |
---|
| 197 | + |
---|
| 198 | +void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable) |
---|
| 199 | +{ |
---|
| 200 | + if (!hashtable.containsKey(GetUUID())) |
---|
| 201 | + return; |
---|
| 202 | + |
---|
| 203 | + Object3D o = hashtable.get(GetUUID()); |
---|
| 204 | + |
---|
| 205 | + this.bRep = o.bRep; |
---|
| 206 | + if (this.bRep != null) |
---|
| 207 | + this.bRep.support = o.transientrep; |
---|
| 208 | +// this.support = o.support; |
---|
| 209 | +// this.fileparent = o.fileparent; |
---|
| 210 | + |
---|
| 211 | + hashtable.remove(GetUUID()); |
---|
| 212 | + |
---|
| 213 | + for (int i=0; i<Size(); i++) |
---|
| 214 | + { |
---|
| 215 | + get(i).RestoreBigData(hashtable); |
---|
159 | 216 | } |
---|
160 | 217 | } |
---|
161 | 218 | |
---|
.. | .. |
---|
300 | 357 | } |
---|
301 | 358 | |
---|
302 | 359 | boolean live = false; |
---|
| 360 | + boolean dontselect = false; |
---|
303 | 361 | boolean hide = false; |
---|
304 | 362 | boolean link2master = false; // performs reset support/master at each frame |
---|
305 | 363 | boolean marked = false; // animation node |
---|
.. | .. |
---|
774 | 832 | if (step == 0) |
---|
775 | 833 | step = 1; |
---|
776 | 834 | if (maxcount == 0) |
---|
777 | | - maxcount = 2048; // 4; |
---|
| 835 | + maxcount = 128; // 2048; // 4; |
---|
778 | 836 | // if (acceleration == 0) |
---|
779 | 837 | // acceleration = 10; |
---|
780 | 838 | if (delay == 0) // serial |
---|
.. | .. |
---|
1834 | 1892 | if (obj.name == null) |
---|
1835 | 1893 | continue; // can't be a null one |
---|
1836 | 1894 | |
---|
| 1895 | + // Try perfect match first. |
---|
1837 | 1896 | if (n.equals(obj.name)) |
---|
1838 | 1897 | { |
---|
1839 | 1898 | theobj = obj; |
---|
1840 | 1899 | count++; |
---|
1841 | 1900 | } |
---|
1842 | 1901 | } |
---|
| 1902 | + |
---|
| 1903 | + // not needed: n = n.split(":")[0]; // Poser generates a count |
---|
1843 | 1904 | |
---|
1844 | 1905 | if (count != 1) |
---|
1845 | 1906 | for (int i=Size(); --i>=0;) |
---|
.. | .. |
---|
3002 | 3063 | v.fromParent = LA.newMatrix(); |
---|
3003 | 3064 | } |
---|
3004 | 3065 | |
---|
3005 | | - LA.matConcat(v.toParent, toParent, v.toParent); |
---|
3006 | | - LA.matConcat(fromParent, v.fromParent, v.fromParent); |
---|
| 3066 | +// LA.matConcat(v.toParent, toParent, v.toParent); |
---|
| 3067 | +// LA.matConcat(fromParent, v.fromParent, v.fromParent); |
---|
| 3068 | + LA.matConcat(toParent, v.toParent, v.toParent); |
---|
| 3069 | + LA.matConcat(v.fromParent, fromParent, v.fromParent); |
---|
3007 | 3070 | } |
---|
3008 | 3071 | |
---|
3009 | 3072 | toParent = null; // LA.matIdentity(toParent); |
---|
.. | .. |
---|
3236 | 3299 | bRep.support = null; |
---|
3237 | 3300 | BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep); |
---|
3238 | 3301 | // bRep.SplitInTwo(onlyone); // thread... |
---|
3239 | | - temprep.SplitInTwo(reduction34, onlyone); |
---|
| 3302 | + |
---|
| 3303 | + while(temprep.SplitInTwo(reduction34, onlyone)); |
---|
| 3304 | + |
---|
3240 | 3305 | bRep = temprep; |
---|
3241 | 3306 | bRep.support = sup; |
---|
3242 | 3307 | Touch(); |
---|
.. | .. |
---|
4711 | 4776 | |
---|
4712 | 4777 | cTreePath SelectLeaf(int indexcount, boolean deselect) |
---|
4713 | 4778 | { |
---|
4714 | | - if (hide) |
---|
| 4779 | + if (hide || dontselect) |
---|
4715 | 4780 | return null; |
---|
4716 | 4781 | |
---|
4717 | 4782 | if (count <= 0) |
---|
.. | .. |
---|
4737 | 4802 | |
---|
4738 | 4803 | cTreePath Select(int indexcount, boolean deselect) |
---|
4739 | 4804 | { |
---|
4740 | | - if (hide) |
---|
| 4805 | + if (hide || dontselect) |
---|
4741 | 4806 | return null; |
---|
4742 | 4807 | |
---|
4743 | 4808 | if (count <= 0) |
---|
.. | .. |
---|
5363 | 5428 | } |
---|
5364 | 5429 | } |
---|
5365 | 5430 | |
---|
| 5431 | + UUID GetUUID() |
---|
| 5432 | + { |
---|
| 5433 | + if (uuid == null) |
---|
| 5434 | + { |
---|
| 5435 | + // Serial |
---|
| 5436 | + uuid = UUID.randomUUID(); |
---|
| 5437 | + } |
---|
| 5438 | + |
---|
| 5439 | + return uuid; |
---|
| 5440 | + } |
---|
| 5441 | + |
---|
| 5442 | + Object3D GetObject(UUID uid) |
---|
| 5443 | + { |
---|
| 5444 | + if (blockloop) |
---|
| 5445 | + return null; |
---|
| 5446 | + |
---|
| 5447 | + if (GetUUID().equals(uid)) |
---|
| 5448 | + return this; |
---|
| 5449 | + |
---|
| 5450 | + int nb = Size(); |
---|
| 5451 | + for (int i = 0; i < nb; i++) |
---|
| 5452 | + { |
---|
| 5453 | + Object3D child = (Object3D) get(i); |
---|
| 5454 | + |
---|
| 5455 | + if (child == null) |
---|
| 5456 | + continue; |
---|
| 5457 | + |
---|
| 5458 | + blockloop = true; |
---|
| 5459 | + Object3D obj = child.GetObject(uid); |
---|
| 5460 | + blockloop = false; |
---|
| 5461 | + if (obj != null) |
---|
| 5462 | + return obj; |
---|
| 5463 | + } |
---|
| 5464 | + |
---|
| 5465 | + return null; |
---|
| 5466 | + } |
---|
| 5467 | + |
---|
5366 | 5468 | void SetBumpTexture(String tex) |
---|
5367 | 5469 | { |
---|
5368 | 5470 | if (GetTextures() == null) |
---|
.. | .. |
---|
5407 | 5509 | boolean NeedSupport() |
---|
5408 | 5510 | { |
---|
5409 | 5511 | return |
---|
5410 | | - CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null |
---|
| 5512 | + CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null |
---|
5411 | 5513 | // PROBLEM with CROWD!! |
---|
5412 | 5514 | && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD); |
---|
5413 | 5515 | } |
---|
.. | .. |
---|
5424 | 5526 | } |
---|
5425 | 5527 | |
---|
5426 | 5528 | if (display.DrawMode() == iCameraPane.SELECTION && |
---|
5427 | | - hide) |
---|
| 5529 | + (hide || dontselect)) |
---|
5428 | 5530 | return; |
---|
5429 | 5531 | |
---|
5430 | 5532 | if (name != null && name.contains("sclera")) |
---|
.. | .. |
---|
5666 | 5768 | tex = GetTextures(); |
---|
5667 | 5769 | } |
---|
5668 | 5770 | |
---|
5669 | | - display.BindTextures(tex, texres); |
---|
| 5771 | + boolean failed = false; |
---|
| 5772 | + |
---|
| 5773 | + try |
---|
| 5774 | + { |
---|
| 5775 | + display.BindTextures(tex, texres); |
---|
| 5776 | + } |
---|
| 5777 | + catch (Exception e) |
---|
| 5778 | + { |
---|
| 5779 | + System.err.println("FAILED: " + this); |
---|
| 5780 | + failed = true; |
---|
| 5781 | + } |
---|
5670 | 5782 | |
---|
5671 | 5783 | if (!compiled) |
---|
5672 | 5784 | { |
---|
.. | .. |
---|
5688 | 5800 | } |
---|
5689 | 5801 | } |
---|
5690 | 5802 | |
---|
5691 | | - display.ReleaseTextures(tex); |
---|
| 5803 | + if (!failed) |
---|
| 5804 | + display.ReleaseTextures(tex); |
---|
5692 | 5805 | |
---|
5693 | 5806 | display.PopMaterial(this, selected); |
---|
5694 | 5807 | } |
---|
.. | .. |
---|
5817 | 5930 | |
---|
5818 | 5931 | void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
5819 | 5932 | { |
---|
| 5933 | + if (display.DrawMode() == iCameraPane.SELECTION && dontselect) |
---|
| 5934 | + return; |
---|
| 5935 | + |
---|
5820 | 5936 | if (hide) |
---|
5821 | 5937 | return; |
---|
5822 | 5938 | // shadow optimisation |
---|
.. | .. |
---|
5941 | 6057 | { |
---|
5942 | 6058 | if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000) |
---|
5943 | 6059 | return; // no shadow for transparent objects |
---|
| 6060 | + |
---|
| 6061 | + if (display.DrawMode() == iCameraPane.SELECTION && dontselect) |
---|
| 6062 | + return; |
---|
5944 | 6063 | |
---|
5945 | 6064 | if (hide) |
---|
5946 | 6065 | return; |
---|
.. | .. |
---|
6925 | 7044 | // { |
---|
6926 | 7045 | // CameraPane.Ymax = spoth; |
---|
6927 | 7046 | // } |
---|
6928 | | - info.g.drawLine(spotw, spoth, spotw, spoth - 15); |
---|
6929 | | - info.g.drawLine(spotw, spoth, spotw - 15, spoth); |
---|
| 7047 | + // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - 15); |
---|
| 7048 | + //info.g.drawLine(spotw, spoth, spotw - 15, spoth); |
---|
6930 | 7049 | spot.translate(0, -32); |
---|
6931 | 7050 | info.g.setColor(Color.green); |
---|
6932 | 7051 | info.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
.. | .. |
---|
6981 | 7100 | startX = info.x; |
---|
6982 | 7101 | startY = info.y; |
---|
6983 | 7102 | |
---|
6984 | | - hitSomething = 0; |
---|
| 7103 | + hitSomething = -1; |
---|
6985 | 7104 | cVector origin = new cVector(); |
---|
6986 | 7105 | //LA.xformPos(origin, toParent, origin); |
---|
6987 | 7106 | Rectangle spot = new Rectangle(); |
---|
.. | .. |
---|
7057 | 7176 | //System.out.println("hitSomething = " + hitSomething); |
---|
7058 | 7177 | |
---|
7059 | 7178 | double scale = 0.005f * info.camera.Distance(); |
---|
| 7179 | + |
---|
7060 | 7180 | cVector xlate = new cVector(); |
---|
7061 | 7181 | //cVector xlate2 = new cVector(); |
---|
7062 | 7182 | switch (hitSomething) |
---|
.. | .. |
---|
7205 | 7325 | |
---|
7206 | 7326 | case hitScale: // scale |
---|
7207 | 7327 | double hScale = (double) (info.x - centerPt.x) / 32; |
---|
| 7328 | + double sign = 1; |
---|
| 7329 | + if (hScale < 0) |
---|
| 7330 | + { |
---|
| 7331 | + sign = -1; |
---|
| 7332 | + } |
---|
| 7333 | + hScale = sign*Math.pow(sign*hScale, scale * 50); |
---|
7208 | 7334 | if (hScale < 0.01) |
---|
7209 | 7335 | { |
---|
7210 | | - hScale = 0.01; |
---|
| 7336 | + //hScale = 0.01; |
---|
7211 | 7337 | } |
---|
7212 | | - hScale = Math.pow(hScale, scale * 50); |
---|
7213 | | - if (hScale < 0.01) |
---|
7214 | | - { |
---|
7215 | | - hScale = 0.01; |
---|
7216 | | - } |
---|
| 7338 | + |
---|
7217 | 7339 | double vScale = (double) (info.y - centerPt.y) / 32; |
---|
7218 | | - if (vScale < 0.01) |
---|
| 7340 | + sign = 1; |
---|
| 7341 | + if (vScale < 0) |
---|
7219 | 7342 | { |
---|
7220 | | - vScale = 0.01; |
---|
| 7343 | + sign = -1; |
---|
7221 | 7344 | } |
---|
7222 | | - vScale = Math.pow(vScale, scale * 50); |
---|
| 7345 | + vScale = sign*Math.pow(sign*vScale, scale * 50); |
---|
7223 | 7346 | if (vScale < 0.01) |
---|
7224 | 7347 | { |
---|
7225 | | - vScale = 0.01; |
---|
| 7348 | + //vScale = 0.01; |
---|
7226 | 7349 | } |
---|
7227 | 7350 | LA.matCopy(startMat, toParent); |
---|
7228 | 7351 | /**/ |
---|
.. | .. |
---|
7233 | 7356 | } |
---|
7234 | 7357 | /**/ |
---|
7235 | 7358 | |
---|
| 7359 | + double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2); |
---|
| 7360 | + |
---|
| 7361 | + if (totalScale < 0.01) |
---|
| 7362 | + { |
---|
| 7363 | + totalScale = 0.01; |
---|
| 7364 | + } |
---|
| 7365 | + |
---|
7236 | 7366 | switch (info.pane.RenderCamera().viewCode) |
---|
7237 | 7367 | { |
---|
7238 | 7368 | case 3: // '\001' |
---|
7239 | 7369 | if (modified) |
---|
7240 | 7370 | { |
---|
7241 | 7371 | //LA.matScale(toParent, 1, hScale, vScale); |
---|
7242 | | - LA.matScale(toParent, vScale, 1, 1); |
---|
| 7372 | + LA.matScale(toParent, totalScale, 1, 1); |
---|
7243 | 7373 | } // vScale, 1); |
---|
7244 | 7374 | else |
---|
7245 | 7375 | { |
---|
7246 | | - LA.matScale(toParent, vScale, vScale, vScale); |
---|
| 7376 | + LA.matScale(toParent, totalScale, totalScale, totalScale); |
---|
7247 | 7377 | } // vScale, 1); |
---|
7248 | 7378 | break; |
---|
7249 | 7379 | |
---|
.. | .. |
---|
7251 | 7381 | if (modified) |
---|
7252 | 7382 | { |
---|
7253 | 7383 | //LA.matScale(toParent, hScale, 1, vScale); |
---|
7254 | | - LA.matScale(toParent, 1, vScale, 1); |
---|
| 7384 | + LA.matScale(toParent, 1, totalScale, 1); |
---|
7255 | 7385 | } else |
---|
7256 | 7386 | { |
---|
7257 | | - LA.matScale(toParent, vScale, 1, vScale); |
---|
| 7387 | + LA.matScale(toParent, totalScale, 1, totalScale); |
---|
7258 | 7388 | } |
---|
7259 | 7389 | break; |
---|
7260 | 7390 | |
---|
.. | .. |
---|
7262 | 7392 | if (modified) |
---|
7263 | 7393 | { |
---|
7264 | 7394 | //LA.matScale(toParent, hScale, vScale, 1); |
---|
7265 | | - LA.matScale(toParent, 1, 1, vScale); |
---|
| 7395 | + LA.matScale(toParent, 1, 1, totalScale); |
---|
7266 | 7396 | } else |
---|
7267 | 7397 | { |
---|
7268 | | - LA.matScale(toParent, vScale, vScale, 1); |
---|
| 7398 | + LA.matScale(toParent, totalScale, totalScale, 1); |
---|
7269 | 7399 | } |
---|
7270 | 7400 | break; |
---|
7271 | 7401 | } |
---|
.. | .. |
---|
7406 | 7536 | objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")"; |
---|
7407 | 7537 | } else |
---|
7408 | 7538 | { |
---|
7409 | | - objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ ""; |
---|
| 7539 | + objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ ""; |
---|
7410 | 7540 | } // + super.toString(); |
---|
7411 | 7541 | //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName(); |
---|
7412 | 7542 | |
---|
.. | .. |
---|
7490 | 7620 | /*transient*/ cVector2[] projectedVertices = new cVector2[0]; |
---|
7491 | 7621 | |
---|
7492 | 7622 | Object3D /*Composite*/ parent; |
---|
7493 | | - Object3D /*Composite*/ fileparent; |
---|
| 7623 | + Object3D /*Composite*/ fileparent; // In the case of FileObject |
---|
7494 | 7624 | |
---|
7495 | 7625 | double[][] toParent; // dynamic matrix |
---|
7496 | 7626 | double[][] fromParent; |
---|
.. | .. |
---|
7654 | 7784 | private static cVector edge2 = new cVector(); |
---|
7655 | 7785 | //private static cVector norm = new cVector(); |
---|
7656 | 7786 | /*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; |
---|
| 7787 | + static final int hitCenter = 1; |
---|
| 7788 | + static final int hitScale = 2; |
---|
| 7789 | + static final int hitRotate = 3; |
---|
7660 | 7790 | /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag |
---|
7661 | 7791 | /*transient*/ private Point centerPt; |
---|
7662 | 7792 | /*transient*/ private int startX; |
---|