.. | .. |
---|
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 | |
---|
.. | .. |
---|
775 | 832 | if (step == 0) |
---|
776 | 833 | step = 1; |
---|
777 | 834 | if (maxcount == 0) |
---|
778 | | - maxcount = 2048; // 4; |
---|
| 835 | + maxcount = 128; // 2048; // 4; |
---|
779 | 836 | // if (acceleration == 0) |
---|
780 | 837 | // acceleration = 10; |
---|
781 | 838 | if (delay == 0) // serial |
---|
.. | .. |
---|
5371 | 5428 | } |
---|
5372 | 5429 | } |
---|
5373 | 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 | + |
---|
5374 | 5468 | void SetBumpTexture(String tex) |
---|
5375 | 5469 | { |
---|
5376 | 5470 | if (GetTextures() == null) |
---|
.. | .. |
---|
6950 | 7044 | // { |
---|
6951 | 7045 | // CameraPane.Ymax = spoth; |
---|
6952 | 7046 | // } |
---|
6953 | | - info.g.drawLine(spotw, spoth, spotw, spoth - 15); |
---|
6954 | | - 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); |
---|
6955 | 7049 | spot.translate(0, -32); |
---|
6956 | 7050 | info.g.setColor(Color.green); |
---|
6957 | 7051 | info.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
.. | .. |
---|
7006 | 7100 | startX = info.x; |
---|
7007 | 7101 | startY = info.y; |
---|
7008 | 7102 | |
---|
7009 | | - hitSomething = 0; |
---|
| 7103 | + hitSomething = -1; |
---|
7010 | 7104 | cVector origin = new cVector(); |
---|
7011 | 7105 | //LA.xformPos(origin, toParent, origin); |
---|
7012 | 7106 | Rectangle spot = new Rectangle(); |
---|
.. | .. |
---|
7082 | 7176 | //System.out.println("hitSomething = " + hitSomething); |
---|
7083 | 7177 | |
---|
7084 | 7178 | double scale = 0.005f * info.camera.Distance(); |
---|
| 7179 | + |
---|
7085 | 7180 | cVector xlate = new cVector(); |
---|
7086 | 7181 | //cVector xlate2 = new cVector(); |
---|
7087 | 7182 | switch (hitSomething) |
---|
.. | .. |
---|
7230 | 7325 | |
---|
7231 | 7326 | case hitScale: // scale |
---|
7232 | 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); |
---|
7233 | 7334 | if (hScale < 0.01) |
---|
7234 | 7335 | { |
---|
7235 | | - hScale = 0.01; |
---|
| 7336 | + //hScale = 0.01; |
---|
7236 | 7337 | } |
---|
7237 | | - hScale = Math.pow(hScale, scale * 50); |
---|
7238 | | - if (hScale < 0.01) |
---|
7239 | | - { |
---|
7240 | | - hScale = 0.01; |
---|
7241 | | - } |
---|
| 7338 | + |
---|
7242 | 7339 | double vScale = (double) (info.y - centerPt.y) / 32; |
---|
7243 | | - if (vScale < 0.01) |
---|
| 7340 | + sign = 1; |
---|
| 7341 | + if (vScale < 0) |
---|
7244 | 7342 | { |
---|
7245 | | - vScale = 0.01; |
---|
| 7343 | + sign = -1; |
---|
7246 | 7344 | } |
---|
7247 | | - vScale = Math.pow(vScale, scale * 50); |
---|
| 7345 | + vScale = sign*Math.pow(sign*vScale, scale * 50); |
---|
7248 | 7346 | if (vScale < 0.01) |
---|
7249 | 7347 | { |
---|
7250 | | - vScale = 0.01; |
---|
| 7348 | + //vScale = 0.01; |
---|
7251 | 7349 | } |
---|
7252 | 7350 | LA.matCopy(startMat, toParent); |
---|
7253 | 7351 | /**/ |
---|
.. | .. |
---|
7258 | 7356 | } |
---|
7259 | 7357 | /**/ |
---|
7260 | 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 | + |
---|
7261 | 7366 | switch (info.pane.RenderCamera().viewCode) |
---|
7262 | 7367 | { |
---|
7263 | 7368 | case 3: // '\001' |
---|
7264 | 7369 | if (modified) |
---|
7265 | 7370 | { |
---|
7266 | 7371 | //LA.matScale(toParent, 1, hScale, vScale); |
---|
7267 | | - LA.matScale(toParent, vScale, 1, 1); |
---|
| 7372 | + LA.matScale(toParent, totalScale, 1, 1); |
---|
7268 | 7373 | } // vScale, 1); |
---|
7269 | 7374 | else |
---|
7270 | 7375 | { |
---|
7271 | | - LA.matScale(toParent, vScale, vScale, vScale); |
---|
| 7376 | + LA.matScale(toParent, totalScale, totalScale, totalScale); |
---|
7272 | 7377 | } // vScale, 1); |
---|
7273 | 7378 | break; |
---|
7274 | 7379 | |
---|
.. | .. |
---|
7276 | 7381 | if (modified) |
---|
7277 | 7382 | { |
---|
7278 | 7383 | //LA.matScale(toParent, hScale, 1, vScale); |
---|
7279 | | - LA.matScale(toParent, 1, vScale, 1); |
---|
| 7384 | + LA.matScale(toParent, 1, totalScale, 1); |
---|
7280 | 7385 | } else |
---|
7281 | 7386 | { |
---|
7282 | | - LA.matScale(toParent, vScale, 1, vScale); |
---|
| 7387 | + LA.matScale(toParent, totalScale, 1, totalScale); |
---|
7283 | 7388 | } |
---|
7284 | 7389 | break; |
---|
7285 | 7390 | |
---|
.. | .. |
---|
7287 | 7392 | if (modified) |
---|
7288 | 7393 | { |
---|
7289 | 7394 | //LA.matScale(toParent, hScale, vScale, 1); |
---|
7290 | | - LA.matScale(toParent, 1, 1, vScale); |
---|
| 7395 | + LA.matScale(toParent, 1, 1, totalScale); |
---|
7291 | 7396 | } else |
---|
7292 | 7397 | { |
---|
7293 | | - LA.matScale(toParent, vScale, vScale, 1); |
---|
| 7398 | + LA.matScale(toParent, totalScale, totalScale, 1); |
---|
7294 | 7399 | } |
---|
7295 | 7400 | break; |
---|
7296 | 7401 | } |
---|
.. | .. |
---|
7431 | 7536 | objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")"; |
---|
7432 | 7537 | } else |
---|
7433 | 7538 | { |
---|
7434 | | - 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) ":"") */ ""; |
---|
7435 | 7540 | } // + super.toString(); |
---|
7436 | 7541 | //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName(); |
---|
7437 | 7542 | |
---|
.. | .. |
---|
7515 | 7620 | /*transient*/ cVector2[] projectedVertices = new cVector2[0]; |
---|
7516 | 7621 | |
---|
7517 | 7622 | Object3D /*Composite*/ parent; |
---|
7518 | | - Object3D /*Composite*/ fileparent; |
---|
| 7623 | + Object3D /*Composite*/ fileparent; // In the case of FileObject |
---|
7519 | 7624 | |
---|
7520 | 7625 | double[][] toParent; // dynamic matrix |
---|
7521 | 7626 | double[][] fromParent; |
---|
.. | .. |
---|
7679 | 7784 | private static cVector edge2 = new cVector(); |
---|
7680 | 7785 | //private static cVector norm = new cVector(); |
---|
7681 | 7786 | /*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; |
---|
| 7787 | + static final int hitCenter = 1; |
---|
| 7788 | + static final int hitScale = 2; |
---|
| 7789 | + static final int hitRotate = 3; |
---|
7685 | 7790 | /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag |
---|
7686 | 7791 | /*transient*/ private Point centerPt; |
---|
7687 | 7792 | /*transient*/ private int startX; |
---|