.. | .. |
---|
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 | |
---|
.. | .. |
---|
775 | 840 | if (step == 0) |
---|
776 | 841 | step = 1; |
---|
777 | 842 | if (maxcount == 0) |
---|
778 | | - maxcount = 2048; // 4; |
---|
| 843 | + maxcount = 128; // 2048; // 4; |
---|
779 | 844 | // if (acceleration == 0) |
---|
780 | 845 | // acceleration = 10; |
---|
781 | 846 | if (delay == 0) // serial |
---|
.. | .. |
---|
5371 | 5436 | } |
---|
5372 | 5437 | } |
---|
5373 | 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 | + |
---|
5374 | 5476 | void SetBumpTexture(String tex) |
---|
5375 | 5477 | { |
---|
5376 | 5478 | if (GetTextures() == null) |
---|
.. | .. |
---|
6950 | 7052 | // { |
---|
6951 | 7053 | // CameraPane.Ymax = spoth; |
---|
6952 | 7054 | // } |
---|
6953 | | - info.g.drawLine(spotw, spoth, spotw, spoth - 15); |
---|
6954 | | - 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); |
---|
6955 | 7057 | spot.translate(0, -32); |
---|
6956 | 7058 | info.g.setColor(Color.green); |
---|
6957 | 7059 | info.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
.. | .. |
---|
7006 | 7108 | startX = info.x; |
---|
7007 | 7109 | startY = info.y; |
---|
7008 | 7110 | |
---|
7009 | | - hitSomething = 0; |
---|
| 7111 | + hitSomething = -1; |
---|
7010 | 7112 | cVector origin = new cVector(); |
---|
7011 | 7113 | //LA.xformPos(origin, toParent, origin); |
---|
7012 | 7114 | Rectangle spot = new Rectangle(); |
---|
.. | .. |
---|
7082 | 7184 | //System.out.println("hitSomething = " + hitSomething); |
---|
7083 | 7185 | |
---|
7084 | 7186 | double scale = 0.005f * info.camera.Distance(); |
---|
| 7187 | + |
---|
7085 | 7188 | cVector xlate = new cVector(); |
---|
7086 | 7189 | //cVector xlate2 = new cVector(); |
---|
7087 | 7190 | switch (hitSomething) |
---|
.. | .. |
---|
7230 | 7333 | |
---|
7231 | 7334 | case hitScale: // scale |
---|
7232 | 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); |
---|
7233 | 7342 | if (hScale < 0.01) |
---|
7234 | 7343 | { |
---|
7235 | | - hScale = 0.01; |
---|
| 7344 | + //hScale = 0.01; |
---|
7236 | 7345 | } |
---|
7237 | | - hScale = Math.pow(hScale, scale * 50); |
---|
7238 | | - if (hScale < 0.01) |
---|
7239 | | - { |
---|
7240 | | - hScale = 0.01; |
---|
7241 | | - } |
---|
| 7346 | + |
---|
7242 | 7347 | double vScale = (double) (info.y - centerPt.y) / 32; |
---|
7243 | | - if (vScale < 0.01) |
---|
| 7348 | + sign = 1; |
---|
| 7349 | + if (vScale < 0) |
---|
7244 | 7350 | { |
---|
7245 | | - vScale = 0.01; |
---|
| 7351 | + sign = -1; |
---|
7246 | 7352 | } |
---|
7247 | | - vScale = Math.pow(vScale, scale * 50); |
---|
| 7353 | + vScale = sign*Math.pow(sign*vScale, scale * 50); |
---|
7248 | 7354 | if (vScale < 0.01) |
---|
7249 | 7355 | { |
---|
7250 | | - vScale = 0.01; |
---|
| 7356 | + //vScale = 0.01; |
---|
7251 | 7357 | } |
---|
7252 | 7358 | LA.matCopy(startMat, toParent); |
---|
7253 | 7359 | /**/ |
---|
.. | .. |
---|
7258 | 7364 | } |
---|
7259 | 7365 | /**/ |
---|
7260 | 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 | + |
---|
7261 | 7374 | switch (info.pane.RenderCamera().viewCode) |
---|
7262 | 7375 | { |
---|
7263 | 7376 | case 3: // '\001' |
---|
7264 | 7377 | if (modified) |
---|
7265 | 7378 | { |
---|
7266 | 7379 | //LA.matScale(toParent, 1, hScale, vScale); |
---|
7267 | | - LA.matScale(toParent, vScale, 1, 1); |
---|
| 7380 | + LA.matScale(toParent, totalScale, 1, 1); |
---|
7268 | 7381 | } // vScale, 1); |
---|
7269 | 7382 | else |
---|
7270 | 7383 | { |
---|
7271 | | - LA.matScale(toParent, vScale, vScale, vScale); |
---|
| 7384 | + LA.matScale(toParent, totalScale, totalScale, totalScale); |
---|
7272 | 7385 | } // vScale, 1); |
---|
7273 | 7386 | break; |
---|
7274 | 7387 | |
---|
.. | .. |
---|
7276 | 7389 | if (modified) |
---|
7277 | 7390 | { |
---|
7278 | 7391 | //LA.matScale(toParent, hScale, 1, vScale); |
---|
7279 | | - LA.matScale(toParent, 1, vScale, 1); |
---|
| 7392 | + LA.matScale(toParent, 1, totalScale, 1); |
---|
7280 | 7393 | } else |
---|
7281 | 7394 | { |
---|
7282 | | - LA.matScale(toParent, vScale, 1, vScale); |
---|
| 7395 | + LA.matScale(toParent, totalScale, 1, totalScale); |
---|
7283 | 7396 | } |
---|
7284 | 7397 | break; |
---|
7285 | 7398 | |
---|
.. | .. |
---|
7287 | 7400 | if (modified) |
---|
7288 | 7401 | { |
---|
7289 | 7402 | //LA.matScale(toParent, hScale, vScale, 1); |
---|
7290 | | - LA.matScale(toParent, 1, 1, vScale); |
---|
| 7403 | + LA.matScale(toParent, 1, 1, totalScale); |
---|
7291 | 7404 | } else |
---|
7292 | 7405 | { |
---|
7293 | | - LA.matScale(toParent, vScale, vScale, 1); |
---|
| 7406 | + LA.matScale(toParent, totalScale, totalScale, 1); |
---|
7294 | 7407 | } |
---|
7295 | 7408 | break; |
---|
7296 | 7409 | } |
---|
.. | .. |
---|
7431 | 7544 | objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")"; |
---|
7432 | 7545 | } else |
---|
7433 | 7546 | { |
---|
7434 | | - 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) ":"") */ ""; |
---|
7435 | 7548 | } // + super.toString(); |
---|
7436 | 7549 | //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName(); |
---|
7437 | 7550 | |
---|
.. | .. |
---|
7515 | 7628 | /*transient*/ cVector2[] projectedVertices = new cVector2[0]; |
---|
7516 | 7629 | |
---|
7517 | 7630 | Object3D /*Composite*/ parent; |
---|
7518 | | - Object3D /*Composite*/ fileparent; |
---|
| 7631 | + Object3D /*Composite*/ fileparent; // In the case of FileObject |
---|
7519 | 7632 | |
---|
7520 | 7633 | double[][] toParent; // dynamic matrix |
---|
7521 | 7634 | double[][] fromParent; |
---|
.. | .. |
---|
7679 | 7792 | private static cVector edge2 = new cVector(); |
---|
7680 | 7793 | //private static cVector norm = new cVector(); |
---|
7681 | 7794 | /*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; |
---|
| 7795 | + static final int hitCenter = 1; |
---|
| 7796 | + static final int hitScale = 2; |
---|
| 7797 | + static final int hitRotate = 3; |
---|
7685 | 7798 | /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag |
---|
7686 | 7799 | /*transient*/ private Point centerPt; |
---|
7687 | 7800 | /*transient*/ private int startX; |
---|