.. | .. |
---|
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(); |
---|
| 26 | + |
---|
| 27 | + // TEMPORARY for mocap undo |
---|
| 28 | + mocap.reader.BVHReader.BVHResult bvh; |
---|
| 29 | + Object3D skeleton; |
---|
| 30 | + // |
---|
22 | 31 | |
---|
23 | 32 | ScriptNode scriptnode; |
---|
24 | 33 | |
---|
.. | .. |
---|
100 | 109 | |
---|
101 | 110 | // transient boolean reduced; // for morph reduction |
---|
102 | 111 | |
---|
103 | | -transient com.bulletphysics.linearmath.Transform cache; // for fast merge |
---|
104 | | -transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge |
---|
| 112 | + transient com.bulletphysics.linearmath.Transform cache; // for fast merge |
---|
| 113 | + transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge |
---|
105 | 114 | |
---|
106 | | -transient Object3D transientsupport; // for cloning |
---|
107 | | -transient boolean transientlink2master; |
---|
| 115 | + transient Object3D transientsupport; // for cloning |
---|
| 116 | + transient boolean transientlink2master; |
---|
108 | 117 | |
---|
109 | | -void SaveSupports() |
---|
110 | | -{ |
---|
111 | | - if (blockloop) |
---|
112 | | - return; |
---|
113 | | - |
---|
114 | | - transientsupport = support; |
---|
115 | | - transientlink2master = link2master; |
---|
116 | | - |
---|
117 | | - support = null; |
---|
118 | | - link2master = false; |
---|
119 | | - |
---|
120 | | - if (bRep != null) |
---|
| 118 | + void SaveSupports() |
---|
121 | 119 | { |
---|
122 | | - bRep.SaveSupports(); |
---|
123 | | - } |
---|
124 | | - |
---|
125 | | - for (int i = 0; i < Size(); i++) |
---|
126 | | - { |
---|
127 | | - Object3D child = (Object3D) get(i); |
---|
128 | | - if (child == null) |
---|
129 | | - continue; |
---|
130 | | - blockloop = true; |
---|
131 | | - child.SaveSupports(); |
---|
132 | | - blockloop = false; |
---|
133 | | - } |
---|
134 | | -} |
---|
| 120 | + if (blockloop) |
---|
| 121 | + return; |
---|
135 | 122 | |
---|
136 | | -void RestoreSupports() |
---|
137 | | -{ |
---|
138 | | - if (blockloop) |
---|
139 | | - return; |
---|
| 123 | + transientsupport = support; |
---|
| 124 | + transientlink2master = link2master; |
---|
140 | 125 | |
---|
141 | | - support = transientsupport; |
---|
142 | | - link2master = transientlink2master; |
---|
143 | | - transientsupport = null; |
---|
144 | | - transientlink2master = false; |
---|
145 | | - |
---|
146 | | - if (bRep != null) |
---|
147 | | - { |
---|
148 | | - bRep.RestoreSupports(); |
---|
| 126 | + support = null; |
---|
| 127 | + link2master = false; |
---|
| 128 | + |
---|
| 129 | + if (bRep != null) |
---|
| 130 | + { |
---|
| 131 | + bRep.SaveSupports(); |
---|
| 132 | + } |
---|
| 133 | + |
---|
| 134 | + for (int i = 0; i < Size(); i++) |
---|
| 135 | + { |
---|
| 136 | + Object3D child = (Object3D) get(i); |
---|
| 137 | + if (child == null) |
---|
| 138 | + continue; |
---|
| 139 | + blockloop = true; |
---|
| 140 | + child.SaveSupports(); |
---|
| 141 | + blockloop = false; |
---|
| 142 | + } |
---|
149 | 143 | } |
---|
150 | | - |
---|
151 | | - for (int i = 0; i < Size(); i++) |
---|
| 144 | + |
---|
| 145 | + void RestoreSupports() |
---|
152 | 146 | { |
---|
153 | | - Object3D child = (Object3D) get(i); |
---|
154 | | - if (child == null) |
---|
155 | | - continue; |
---|
156 | | - blockloop = true; |
---|
157 | | - child.RestoreSupports(); |
---|
158 | | - blockloop = false; |
---|
| 147 | + if (blockloop) |
---|
| 148 | + return; |
---|
| 149 | + |
---|
| 150 | + support = transientsupport; |
---|
| 151 | + link2master = transientlink2master; |
---|
| 152 | + transientsupport = null; |
---|
| 153 | + transientlink2master = false; |
---|
| 154 | + |
---|
| 155 | + if (bRep != null) |
---|
| 156 | + { |
---|
| 157 | + bRep.RestoreSupports(); |
---|
| 158 | + } |
---|
| 159 | + |
---|
| 160 | + for (int i = 0; i < Size(); i++) |
---|
| 161 | + { |
---|
| 162 | + Object3D child = (Object3D) get(i); |
---|
| 163 | + if (child == null) |
---|
| 164 | + continue; |
---|
| 165 | + blockloop = true; |
---|
| 166 | + child.RestoreSupports(); |
---|
| 167 | + blockloop = false; |
---|
| 168 | + } |
---|
159 | 169 | } |
---|
160 | | -} |
---|
| 170 | + |
---|
| 171 | + void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable) |
---|
| 172 | + { |
---|
| 173 | + if (hashtable.containsKey(GetUUID())) |
---|
| 174 | + { |
---|
| 175 | + Object3D o = hashtable.get(GetUUID()); |
---|
| 176 | + |
---|
| 177 | + assert(this.bRep == o.bRep); |
---|
| 178 | + if (this.bRep != null) |
---|
| 179 | + assert(this.bRep.support == o.transientrep); |
---|
| 180 | + |
---|
| 181 | + return; |
---|
| 182 | + } |
---|
| 183 | + |
---|
| 184 | + Object3D o = new Object3D(); |
---|
| 185 | + |
---|
| 186 | + hashtable.put(GetUUID(), o); |
---|
| 187 | + |
---|
| 188 | + for (int i=0; i<Size(); i++) |
---|
| 189 | + { |
---|
| 190 | + get(i).ExtractBigData(hashtable); |
---|
| 191 | + } |
---|
| 192 | + |
---|
| 193 | + ExtractBigData(o); |
---|
| 194 | + } |
---|
| 195 | + |
---|
| 196 | + void ExtractBigData(Object3D o) |
---|
| 197 | + { |
---|
| 198 | + o.bRep = this.bRep; |
---|
| 199 | + if (this.bRep != null) |
---|
| 200 | + { |
---|
| 201 | + o.transientrep = this.bRep.support; |
---|
| 202 | + o.bRep.support = null; |
---|
| 203 | + } |
---|
| 204 | + |
---|
| 205 | + // o.support = this.support; |
---|
| 206 | + // o.fileparent = this.fileparent; |
---|
| 207 | + // if (this.bRep != null) |
---|
| 208 | + // o.bRep = this.bRep.support; |
---|
| 209 | + |
---|
| 210 | + this.bRep = null; |
---|
| 211 | + // if (this.bRep != null) |
---|
| 212 | + // this.bRep.support = null; |
---|
| 213 | + // this.support = null; |
---|
| 214 | + // this.fileparent = null; |
---|
| 215 | + } |
---|
| 216 | + |
---|
| 217 | + void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable) |
---|
| 218 | + { |
---|
| 219 | + if (!hashtable.containsKey(GetUUID())) |
---|
| 220 | + return; |
---|
| 221 | + |
---|
| 222 | + Object3D o = hashtable.get(GetUUID()); |
---|
| 223 | + |
---|
| 224 | + RestoreBigData(o); |
---|
| 225 | + |
---|
| 226 | + hashtable.remove(GetUUID()); |
---|
| 227 | + |
---|
| 228 | + for (int i=0; i<Size(); i++) |
---|
| 229 | + { |
---|
| 230 | + get(i).RestoreBigData(hashtable); |
---|
| 231 | + } |
---|
| 232 | + } |
---|
| 233 | + |
---|
| 234 | + void RestoreBigData(Object3D o) |
---|
| 235 | + { |
---|
| 236 | + this.bRep = o.bRep; |
---|
| 237 | + if (this.bRep != null) |
---|
| 238 | + this.bRep.support = o.transientrep; |
---|
| 239 | + // this.support = o.support; |
---|
| 240 | + // this.fileparent = o.fileparent; |
---|
| 241 | + } |
---|
161 | 242 | |
---|
162 | 243 | // MOCAP SUPPORT |
---|
163 | 244 | double tx,ty,tz,rx,ry,rz; |
---|
.. | .. |
---|
775 | 856 | if (step == 0) |
---|
776 | 857 | step = 1; |
---|
777 | 858 | if (maxcount == 0) |
---|
778 | | - maxcount = 2048; // 4; |
---|
| 859 | + maxcount = 128; // 2048; // 4; |
---|
779 | 860 | // if (acceleration == 0) |
---|
780 | 861 | // acceleration = 10; |
---|
781 | 862 | if (delay == 0) // serial |
---|
.. | .. |
---|
2628 | 2709 | //Touch(); |
---|
2629 | 2710 | } |
---|
2630 | 2711 | |
---|
| 2712 | + void GenNormalsMeshS() |
---|
| 2713 | + { |
---|
| 2714 | + selection.GenNormalsMesh(); |
---|
| 2715 | +// for (int i=0; i<selection.size(); i++) |
---|
| 2716 | +// { |
---|
| 2717 | +// Object3D selectee = (Object3D) selection.elementAt(i); |
---|
| 2718 | +// selectee.GenNormals(crease); |
---|
| 2719 | +// } |
---|
| 2720 | + |
---|
| 2721 | + //Touch(); |
---|
| 2722 | + } |
---|
| 2723 | + |
---|
2631 | 2724 | void ClearColorsS() |
---|
2632 | 2725 | { |
---|
2633 | 2726 | selection.ClearColors(); |
---|
.. | .. |
---|
2759 | 2852 | if (child == null) |
---|
2760 | 2853 | continue; |
---|
2761 | 2854 | child.GenNormals(crease); |
---|
| 2855 | +// Children().release(i); |
---|
| 2856 | + } |
---|
| 2857 | + blockloop = false; |
---|
| 2858 | + } |
---|
| 2859 | + |
---|
| 2860 | + void GenNormalsMesh() |
---|
| 2861 | + { |
---|
| 2862 | + if (blockloop) |
---|
| 2863 | + return; |
---|
| 2864 | + |
---|
| 2865 | + blockloop = true; |
---|
| 2866 | + GenNormalsMesh0(); |
---|
| 2867 | + for (int i = 0; i < Children().Size(); i++) |
---|
| 2868 | + { |
---|
| 2869 | + Object3D child = (Object3D) Children().get(i); // reserve(i); |
---|
| 2870 | + if (child == null) |
---|
| 2871 | + continue; |
---|
| 2872 | + child.GenNormalsMesh(); |
---|
2762 | 2873 | // Children().release(i); |
---|
2763 | 2874 | } |
---|
2764 | 2875 | blockloop = false; |
---|
.. | .. |
---|
2927 | 3038 | if (bRep != null) |
---|
2928 | 3039 | { |
---|
2929 | 3040 | bRep.GenerateNormals(crease); |
---|
| 3041 | + Touch(); |
---|
| 3042 | + } |
---|
| 3043 | + } |
---|
| 3044 | + |
---|
| 3045 | + void GenNormalsMesh0() |
---|
| 3046 | + { |
---|
| 3047 | + if (bRep != null) |
---|
| 3048 | + { |
---|
| 3049 | + bRep.GenerateNormalsMesh(); |
---|
2930 | 3050 | Touch(); |
---|
2931 | 3051 | } |
---|
2932 | 3052 | } |
---|
.. | .. |
---|
5371 | 5491 | } |
---|
5372 | 5492 | } |
---|
5373 | 5493 | |
---|
| 5494 | + UUID GetUUID() |
---|
| 5495 | + { |
---|
| 5496 | + if (uuid == null) |
---|
| 5497 | + { |
---|
| 5498 | + // Serial |
---|
| 5499 | + uuid = UUID.randomUUID(); |
---|
| 5500 | + } |
---|
| 5501 | + |
---|
| 5502 | + return uuid; |
---|
| 5503 | + } |
---|
| 5504 | + |
---|
| 5505 | + Object3D GetObject(UUID uid) |
---|
| 5506 | + { |
---|
| 5507 | + if (blockloop) |
---|
| 5508 | + return null; |
---|
| 5509 | + |
---|
| 5510 | + if (GetUUID().equals(uid)) |
---|
| 5511 | + return this; |
---|
| 5512 | + |
---|
| 5513 | + int nb = Size(); |
---|
| 5514 | + for (int i = 0; i < nb; i++) |
---|
| 5515 | + { |
---|
| 5516 | + Object3D child = (Object3D) get(i); |
---|
| 5517 | + |
---|
| 5518 | + if (child == null) |
---|
| 5519 | + continue; |
---|
| 5520 | + |
---|
| 5521 | + blockloop = true; |
---|
| 5522 | + Object3D obj = child.GetObject(uid); |
---|
| 5523 | + blockloop = false; |
---|
| 5524 | + if (obj != null) |
---|
| 5525 | + return obj; |
---|
| 5526 | + } |
---|
| 5527 | + |
---|
| 5528 | + return null; |
---|
| 5529 | + } |
---|
| 5530 | + |
---|
5374 | 5531 | void SetBumpTexture(String tex) |
---|
5375 | 5532 | { |
---|
5376 | 5533 | if (GetTextures() == null) |
---|
.. | .. |
---|
6950 | 7107 | // { |
---|
6951 | 7108 | // CameraPane.Ymax = spoth; |
---|
6952 | 7109 | // } |
---|
6953 | | - info.g.drawLine(spotw, spoth, spotw, spoth - 15); |
---|
6954 | | - info.g.drawLine(spotw, spoth, spotw - 15, spoth); |
---|
| 7110 | + // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - 15); |
---|
| 7111 | + //info.g.drawLine(spotw, spoth, spotw - 15, spoth); |
---|
6955 | 7112 | spot.translate(0, -32); |
---|
6956 | 7113 | info.g.setColor(Color.green); |
---|
6957 | 7114 | info.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
.. | .. |
---|
7006 | 7163 | startX = info.x; |
---|
7007 | 7164 | startY = info.y; |
---|
7008 | 7165 | |
---|
7009 | | - hitSomething = 0; |
---|
| 7166 | + hitSomething = -1; |
---|
7010 | 7167 | cVector origin = new cVector(); |
---|
7011 | 7168 | //LA.xformPos(origin, toParent, origin); |
---|
7012 | 7169 | Rectangle spot = new Rectangle(); |
---|
.. | .. |
---|
7082 | 7239 | //System.out.println("hitSomething = " + hitSomething); |
---|
7083 | 7240 | |
---|
7084 | 7241 | double scale = 0.005f * info.camera.Distance(); |
---|
| 7242 | + |
---|
7085 | 7243 | cVector xlate = new cVector(); |
---|
7086 | 7244 | //cVector xlate2 = new cVector(); |
---|
7087 | 7245 | switch (hitSomething) |
---|
.. | .. |
---|
7230 | 7388 | |
---|
7231 | 7389 | case hitScale: // scale |
---|
7232 | 7390 | double hScale = (double) (info.x - centerPt.x) / 32; |
---|
| 7391 | + double sign = 1; |
---|
| 7392 | + if (hScale < 0) |
---|
| 7393 | + { |
---|
| 7394 | + sign = -1; |
---|
| 7395 | + } |
---|
| 7396 | + hScale = sign*Math.pow(sign*hScale, scale * 50); |
---|
7233 | 7397 | if (hScale < 0.01) |
---|
7234 | 7398 | { |
---|
7235 | | - hScale = 0.01; |
---|
| 7399 | + //hScale = 0.01; |
---|
7236 | 7400 | } |
---|
7237 | | - hScale = Math.pow(hScale, scale * 50); |
---|
7238 | | - if (hScale < 0.01) |
---|
7239 | | - { |
---|
7240 | | - hScale = 0.01; |
---|
7241 | | - } |
---|
| 7401 | + |
---|
7242 | 7402 | double vScale = (double) (info.y - centerPt.y) / 32; |
---|
7243 | | - if (vScale < 0.01) |
---|
| 7403 | + sign = 1; |
---|
| 7404 | + if (vScale < 0) |
---|
7244 | 7405 | { |
---|
7245 | | - vScale = 0.01; |
---|
| 7406 | + sign = -1; |
---|
7246 | 7407 | } |
---|
7247 | | - vScale = Math.pow(vScale, scale * 50); |
---|
| 7408 | + vScale = sign*Math.pow(sign*vScale, scale * 50); |
---|
7248 | 7409 | if (vScale < 0.01) |
---|
7249 | 7410 | { |
---|
7250 | | - vScale = 0.01; |
---|
| 7411 | + //vScale = 0.01; |
---|
7251 | 7412 | } |
---|
7252 | 7413 | LA.matCopy(startMat, toParent); |
---|
7253 | 7414 | /**/ |
---|
.. | .. |
---|
7258 | 7419 | } |
---|
7259 | 7420 | /**/ |
---|
7260 | 7421 | |
---|
| 7422 | + double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2); |
---|
| 7423 | + |
---|
| 7424 | + if (totalScale < 0.01) |
---|
| 7425 | + { |
---|
| 7426 | + totalScale = 0.01; |
---|
| 7427 | + } |
---|
| 7428 | + |
---|
7261 | 7429 | switch (info.pane.RenderCamera().viewCode) |
---|
7262 | 7430 | { |
---|
7263 | 7431 | case 3: // '\001' |
---|
7264 | 7432 | if (modified) |
---|
7265 | 7433 | { |
---|
7266 | 7434 | //LA.matScale(toParent, 1, hScale, vScale); |
---|
7267 | | - LA.matScale(toParent, vScale, 1, 1); |
---|
| 7435 | + LA.matScale(toParent, totalScale, 1, 1); |
---|
7268 | 7436 | } // vScale, 1); |
---|
7269 | 7437 | else |
---|
7270 | 7438 | { |
---|
7271 | | - LA.matScale(toParent, vScale, vScale, vScale); |
---|
| 7439 | + LA.matScale(toParent, totalScale, totalScale, totalScale); |
---|
7272 | 7440 | } // vScale, 1); |
---|
7273 | 7441 | break; |
---|
7274 | 7442 | |
---|
.. | .. |
---|
7276 | 7444 | if (modified) |
---|
7277 | 7445 | { |
---|
7278 | 7446 | //LA.matScale(toParent, hScale, 1, vScale); |
---|
7279 | | - LA.matScale(toParent, 1, vScale, 1); |
---|
| 7447 | + LA.matScale(toParent, 1, totalScale, 1); |
---|
7280 | 7448 | } else |
---|
7281 | 7449 | { |
---|
7282 | | - LA.matScale(toParent, vScale, 1, vScale); |
---|
| 7450 | + LA.matScale(toParent, totalScale, 1, totalScale); |
---|
7283 | 7451 | } |
---|
7284 | 7452 | break; |
---|
7285 | 7453 | |
---|
.. | .. |
---|
7287 | 7455 | if (modified) |
---|
7288 | 7456 | { |
---|
7289 | 7457 | //LA.matScale(toParent, hScale, vScale, 1); |
---|
7290 | | - LA.matScale(toParent, 1, 1, vScale); |
---|
| 7458 | + LA.matScale(toParent, 1, 1, totalScale); |
---|
7291 | 7459 | } else |
---|
7292 | 7460 | { |
---|
7293 | | - LA.matScale(toParent, vScale, vScale, 1); |
---|
| 7461 | + LA.matScale(toParent, totalScale, totalScale, 1); |
---|
7294 | 7462 | } |
---|
7295 | 7463 | break; |
---|
7296 | 7464 | } |
---|
.. | .. |
---|
7431 | 7599 | objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")"; |
---|
7432 | 7600 | } else |
---|
7433 | 7601 | { |
---|
7434 | | - objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ ""; |
---|
| 7602 | + objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ ""; |
---|
7435 | 7603 | } // + super.toString(); |
---|
7436 | 7604 | //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName(); |
---|
7437 | 7605 | |
---|
.. | .. |
---|
7515 | 7683 | /*transient*/ cVector2[] projectedVertices = new cVector2[0]; |
---|
7516 | 7684 | |
---|
7517 | 7685 | Object3D /*Composite*/ parent; |
---|
7518 | | - Object3D /*Composite*/ fileparent; |
---|
| 7686 | + Object3D /*Composite*/ fileparent; // In the case of FileObject |
---|
7519 | 7687 | |
---|
7520 | 7688 | double[][] toParent; // dynamic matrix |
---|
7521 | 7689 | double[][] fromParent; |
---|
.. | .. |
---|
7679 | 7847 | private static cVector edge2 = new cVector(); |
---|
7680 | 7848 | //private static cVector norm = new cVector(); |
---|
7681 | 7849 | /*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; |
---|
| 7850 | + static final int hitCenter = 1; |
---|
| 7851 | + static final int hitScale = 2; |
---|
| 7852 | + static final int hitRotate = 3; |
---|
7685 | 7853 | /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag |
---|
7686 | 7854 | /*transient*/ private Point centerPt; |
---|
7687 | 7855 | /*transient*/ private int startX; |
---|