.. | .. |
---|
26 | 26 | public class Mocap extends Object3D |
---|
27 | 27 | { |
---|
28 | 28 | static final long serialVersionUID = 7437391692559853707L; |
---|
| 29 | + |
---|
| 30 | + void Fade() |
---|
| 31 | + { |
---|
| 32 | + if (currentbones == null || CameraPane.fullreset) |
---|
| 33 | + return; |
---|
| 34 | + |
---|
| 35 | + cVector temp = new cVector(); |
---|
| 36 | + |
---|
| 37 | + int numframes = bvh.animation.getNumFrames(); |
---|
| 38 | + |
---|
| 39 | + int b; |
---|
| 40 | + float[] data; |
---|
| 41 | + Quat4d quatstart = new Quat4d(); |
---|
| 42 | + Quat4d quatend = new Quat4d(); |
---|
| 43 | + Quat4d quat = new Quat4d(); |
---|
| 44 | + Matrix4d mat4d = new Matrix4d(); |
---|
| 45 | + double[][] rot = new double[4][4]; |
---|
| 46 | + for (b=numbones; --b>=0;) // HIP ROTATION: 0;) |
---|
| 47 | + { |
---|
| 48 | + // int hipindex = get(0)._index; |
---|
| 49 | + |
---|
| 50 | +// assert(get(0).get(0)._isHip); |
---|
| 51 | + |
---|
| 52 | + // if (b == hipindex) |
---|
| 53 | + // continue; |
---|
| 54 | + |
---|
| 55 | + data = bvh.animation.getBoneData(b); |
---|
| 56 | + |
---|
| 57 | + int dof = 3; // data.length/numframes; |
---|
| 58 | + |
---|
| 59 | + if (b == 0) |
---|
| 60 | + { |
---|
| 61 | + dof = 6; |
---|
| 62 | + } |
---|
| 63 | + // assert(dof == 3); |
---|
| 64 | + |
---|
| 65 | + int boneframe3 = (b-1)*3; // dof; |
---|
| 66 | + |
---|
| 67 | + // System.err.println("Bone #" + b + ": dof = " + dof); |
---|
| 68 | + int fadein = 45; // 120; |
---|
| 69 | + |
---|
| 70 | + // if (b == hipindex) |
---|
| 71 | + // fadein *= 5; |
---|
| 72 | + |
---|
| 73 | + if (fadein > numframes) |
---|
| 74 | + fadein = 0; // numframes; |
---|
| 75 | + |
---|
| 76 | + for (int fi=fadein; --fi>=0;) |
---|
| 77 | + //for (int f=numframes; --f>=0;) |
---|
| 78 | + { |
---|
| 79 | + int f = fi + GetFirstFrame(); |
---|
| 80 | + |
---|
| 81 | + int f3 = f*dof; |
---|
| 82 | + |
---|
| 83 | + float k = fi; |
---|
| 84 | + |
---|
| 85 | + k /= fadein - 1; |
---|
| 86 | + |
---|
| 87 | + if (Float.isNaN(k)) |
---|
| 88 | + k = 1; // 0/0 |
---|
| 89 | + |
---|
| 90 | + k = (float) (-Math.cos(k*Math.PI)); |
---|
| 91 | + k += 1; |
---|
| 92 | + k /= 2; |
---|
| 93 | + |
---|
| 94 | + int start = 3; |
---|
| 95 | + int end = 0; |
---|
| 96 | + |
---|
| 97 | + if (dof == 6) |
---|
| 98 | + { |
---|
| 99 | + start = 6; |
---|
| 100 | + end = 3; |
---|
| 101 | + } |
---|
| 102 | + |
---|
| 103 | + if (b == 0) |
---|
| 104 | + { |
---|
| 105 | + for (int i=start; --i>=end;) |
---|
| 106 | + { |
---|
| 107 | + //data[f3 + i] += pos[i] - data[frame3 + i]; |
---|
| 108 | +// data[f3 + i] = k*data[f3+i] + (1-k)* |
---|
| 109 | +// currentbones[boneframe3 + i-end]; |
---|
| 110 | +// data[f3 + i] = (float)CurveAngle(data[f3+i], currenthip[i], 1-k); |
---|
| 111 | + } |
---|
| 112 | + |
---|
| 113 | + // TODO: translation |
---|
| 114 | + |
---|
| 115 | +// _t1.setIdentity(); |
---|
| 116 | +// _t2.setIdentity(); |
---|
| 117 | +// _t2.rotZ(currentbones[boneframe3 + start-1-end]); |
---|
| 118 | +// _t1.mul(_t2); |
---|
| 119 | +// _t2.setIdentity(); |
---|
| 120 | +// if (b == 0) |
---|
| 121 | +// { |
---|
| 122 | +// _t2.rotY(currentbones[boneframe3 + start-2-end]); |
---|
| 123 | +// _t1.mul(_t2); |
---|
| 124 | +// _t2.setIdentity(); |
---|
| 125 | +// _t2.rotX(currentbones[boneframe3 + start-3-end]); |
---|
| 126 | +// } |
---|
| 127 | +// else |
---|
| 128 | +// { |
---|
| 129 | +// _t2.rotX(currentbones[boneframe3 + start-2-end]); |
---|
| 130 | +// _t1.mul(_t2); |
---|
| 131 | +// _t2.setIdentity(); |
---|
| 132 | +// _t2.rotY(currentbones[boneframe3 + start-3-end]); |
---|
| 133 | +// } |
---|
| 134 | +// _t1.mul(_t2); |
---|
| 135 | +// _t2.setIdentity(); |
---|
| 136 | +// |
---|
| 137 | +// _t1.get(mat4d); |
---|
| 138 | +// |
---|
| 139 | +// mat4d.get(quatstart); |
---|
| 140 | +// |
---|
| 141 | +// _t1.setIdentity(); |
---|
| 142 | +// _t2.setIdentity(); |
---|
| 143 | +// _t2.rotZ(data[f3 + start-1]); |
---|
| 144 | +// _t1.mul(_t2); |
---|
| 145 | +// _t2.setIdentity(); |
---|
| 146 | +// if (b == 0) |
---|
| 147 | +// { |
---|
| 148 | +// _t2.rotY(data[f3 + start-2]); |
---|
| 149 | +// _t1.mul(_t2); |
---|
| 150 | +// _t2.setIdentity(); |
---|
| 151 | +// _t2.rotX(data[f3 + start-3]); |
---|
| 152 | +// } |
---|
| 153 | +// else |
---|
| 154 | +// { |
---|
| 155 | +// _t2.rotX(data[f3 + start-2]); |
---|
| 156 | +// _t1.mul(_t2); |
---|
| 157 | +// _t2.setIdentity(); |
---|
| 158 | +// _t2.rotY(data[f3 + start-3]); |
---|
| 159 | +// } |
---|
| 160 | +// |
---|
| 161 | +// _t1.mul(_t2); |
---|
| 162 | +// _t2.setIdentity(); |
---|
| 163 | +// |
---|
| 164 | +// _t1.get(mat4d); |
---|
| 165 | +// |
---|
| 166 | +// mat4d.get(quatend); |
---|
| 167 | +// |
---|
| 168 | +// double dot = quatstart.x*quatend.x + |
---|
| 169 | +// quatstart.y*quatend.y + |
---|
| 170 | +// quatstart.z*quatend.z + |
---|
| 171 | +// quatstart.w*quatend.w |
---|
| 172 | +// ; |
---|
| 173 | +// |
---|
| 174 | +// if (dot < 0) |
---|
| 175 | +// { |
---|
| 176 | +// quatend.x *= -1; |
---|
| 177 | +// quatend.y *= -1; |
---|
| 178 | +// quatend.z *= -1; |
---|
| 179 | +// quatend.w *= -1; |
---|
| 180 | +// } |
---|
| 181 | +// |
---|
| 182 | +// // k = 1-k; |
---|
| 183 | +// |
---|
| 184 | +// quat.x = (1-k)*quatstart.x + k*quatend.x; |
---|
| 185 | +// quat.y = (1-k)*quatstart.y + k*quatend.y; |
---|
| 186 | +// quat.z = (1-k)*quatstart.z + k*quatend.z; |
---|
| 187 | +// quat.w = (1-k)*quatstart.w + k*quatend.w; |
---|
| 188 | +// |
---|
| 189 | +// quat.normalize(); |
---|
| 190 | +// |
---|
| 191 | +// mat4d.set(quat); |
---|
| 192 | +// |
---|
| 193 | +// cJ3D.SetTransform(rot, mat4d); |
---|
| 194 | +// |
---|
| 195 | +// matrixToEulerXYZ(rot, temp); |
---|
| 196 | +// |
---|
| 197 | +// data[f3 + start-1] = -(float)temp.z; |
---|
| 198 | +// |
---|
| 199 | +// if (b == 0) |
---|
| 200 | +// { |
---|
| 201 | +// data[f3 + start-2] = -(float)temp.y; |
---|
| 202 | +// data[f3 + start-3] = -(float)temp.x; |
---|
| 203 | +// } |
---|
| 204 | +// else |
---|
| 205 | +// { |
---|
| 206 | +// data[f3 + start-2] = -(float)temp.x; |
---|
| 207 | +// data[f3 + start-3] = -(float)temp.y; |
---|
| 208 | +// } |
---|
| 209 | + } |
---|
| 210 | + else |
---|
| 211 | + { |
---|
| 212 | + for (int i=start; --i>=end;) |
---|
| 213 | + { |
---|
| 214 | + //data[f3 + i] += pos[i] - data[frame3 + i]; |
---|
| 215 | +// data[f3 + i] = k*data[f3+i] + (1-k)* |
---|
| 216 | +// currentbones[boneframe3 + i-end]; |
---|
| 217 | + data[f3 + i] = (float)CurveAngle(data[f3+i], currentbones[boneframe3 + i/*-end*/], 1-k); |
---|
| 218 | + } |
---|
| 219 | + } |
---|
| 220 | + } |
---|
| 221 | + } |
---|
| 222 | + } |
---|
| 223 | + |
---|
| 224 | + // Updates the toParent matrix to keep the same position and orientation |
---|
| 225 | + // before resetting the mocap data. |
---|
| 226 | + void SetGlobalTransform() |
---|
| 227 | + { |
---|
| 228 | + //SetCurrentBones(frame); |
---|
| 229 | + |
---|
| 230 | + cVector temp = new cVector(); |
---|
| 231 | + cVector pos = new cVector(); |
---|
| 232 | + cVector poship = new cVector(); |
---|
| 233 | + |
---|
| 234 | + double angleY = 0; |
---|
| 235 | + double angleYhip = 0; |
---|
| 236 | + |
---|
| 237 | + Object3D hip = get(0); |
---|
| 238 | + |
---|
| 239 | + if (hip.get(0).toParent == null) |
---|
| 240 | + { |
---|
| 241 | + hip.get(0).toParent = LA.newMatrix(); |
---|
| 242 | + hip.get(0).fromParent = LA.newMatrix(); |
---|
| 243 | + } |
---|
| 244 | + |
---|
| 245 | + LA.matConcat(toParent, hip.get(0).toParent, matrix); |
---|
| 246 | + poship.x = matrix[3][0]; |
---|
| 247 | + poship.y = matrix[3][1]; |
---|
| 248 | + poship.z = matrix[3][2]; |
---|
| 249 | + |
---|
| 250 | + temp.x = 1; |
---|
| 251 | + temp.y = 0; |
---|
| 252 | + temp.z = 0; |
---|
| 253 | + |
---|
| 254 | + LA.xformDir(temp, matrix, temp); |
---|
| 255 | + |
---|
| 256 | + angleYhip = Math.atan2(-temp.z, temp.x); |
---|
| 257 | + |
---|
| 258 | + LA.matIdentity(toParent); |
---|
| 259 | + LA.matYRotate(toParent, angleYhip); |
---|
| 260 | + LA.matTranslate(toParent, poship.x, poship.y, poship.z); |
---|
| 261 | + |
---|
| 262 | +// LA.matConcat(toParent, hip.get(0).toParent, toParent); |
---|
| 263 | + |
---|
| 264 | + CameraPane.CreateSelectedPoint(); |
---|
| 265 | + |
---|
| 266 | + CameraPane.debugpointG.toParent[3][0] = poship.x; |
---|
| 267 | + CameraPane.debugpointG.toParent[3][1] = poship.y; |
---|
| 268 | + CameraPane.debugpointG.toParent[3][2] = poship.z; |
---|
| 269 | + |
---|
| 270 | + LA.matInvert(toParent, fromParent); |
---|
| 271 | + |
---|
| 272 | + LA.matIdentity(hip.get(0).toParent); |
---|
| 273 | + LA.matIdentity(hip.get(0).fromParent); |
---|
| 274 | + |
---|
| 275 | +// if (true) |
---|
| 276 | +// return; |
---|
| 277 | + |
---|
| 278 | + // Updates hip.get(0).toParent |
---|
| 279 | + setPose(hip, GetFirstFrame(), bvh.animation.getBoneData(hip._index)); |
---|
| 280 | + |
---|
| 281 | + // A = toParent; B = hip.get(0).toParent |
---|
| 282 | + // A'*B = A |
---|
| 283 | + // A' = A * B-1 |
---|
| 284 | + |
---|
| 285 | + poship.x = hip.get(0).toParent[3][0]; |
---|
| 286 | + poship.y = hip.get(0).toParent[3][1]; |
---|
| 287 | + poship.z = hip.get(0).toParent[3][2]; |
---|
| 288 | + |
---|
| 289 | + temp.x = 1; |
---|
| 290 | + temp.y = 0; |
---|
| 291 | + temp.z = 0; |
---|
| 292 | + |
---|
| 293 | + LA.xformDir(temp, hip.get(0).toParent, temp); |
---|
| 294 | + |
---|
| 295 | + angleYhip = Math.atan2(-temp.z, temp.x); |
---|
| 296 | + |
---|
| 297 | + LA.matIdentity(matrix); |
---|
| 298 | + LA.matYRotate(matrix, angleYhip); |
---|
| 299 | + LA.matTranslate(matrix, poship.x, poship.y, poship.z); |
---|
| 300 | + |
---|
| 301 | + //LA.matInvert(hip.get(0).toParent, matrix); |
---|
| 302 | + LA.matInvert(matrix, matrix); |
---|
| 303 | + |
---|
| 304 | + //LA.matIdentity(matrix); |
---|
| 305 | + //LA.matTranslate(matrix, -poship.x, -poship.y, -poship.z); |
---|
| 306 | + |
---|
| 307 | + LA.matConcat(toParent, matrix, toParent); |
---|
| 308 | + |
---|
| 309 | + |
---|
| 310 | + LA.matConcat(toParent, hip.get(0).toParent, matrix); |
---|
| 311 | + pos.x = hip.get(0).toParent[3][0]; |
---|
| 312 | + pos.y = hip.get(0).toParent[3][1]; |
---|
| 313 | + pos.z = hip.get(0).toParent[3][2]; |
---|
| 314 | + LA.xformPos(new cVector(), hip.get(0).toParent, pos); |
---|
| 315 | + LA.xformPos(pos, toParent, pos); |
---|
| 316 | + |
---|
| 317 | +// temp.x = 1; |
---|
| 318 | +// temp.y = 0; |
---|
| 319 | +// temp.z = 0; |
---|
| 320 | +// |
---|
| 321 | +// LA.xformDir(temp, toParent, temp); |
---|
| 322 | +// |
---|
| 323 | +// angleY = Math.atan2(-temp.z, temp.x); |
---|
| 324 | +// |
---|
| 325 | +// LA.matIdentity(toParent); |
---|
| 326 | +// LA.matYRotate(toParent, angleY - angleYhip); |
---|
| 327 | +// LA.matTranslate(toParent, pos.x - poship.x, pos.y - poship.y, pos.z - poship.z); |
---|
| 328 | + |
---|
| 329 | + CameraPane.debugpointP.toParent[3][0] = pos.x; |
---|
| 330 | + CameraPane.debugpointP.toParent[3][1] = pos.y; |
---|
| 331 | + CameraPane.debugpointP.toParent[3][2] = pos.z; |
---|
| 332 | + |
---|
| 333 | + CameraPane.debugpointC.toParent[3][0] = poship.x; |
---|
| 334 | + CameraPane.debugpointC.toParent[3][1] = poship.y; |
---|
| 335 | + CameraPane.debugpointC.toParent[3][2] = poship.z; |
---|
| 336 | + |
---|
| 337 | + poship.x = toParent[3][0]; |
---|
| 338 | + poship.y = toParent[3][1]; |
---|
| 339 | + poship.z = toParent[3][2]; |
---|
| 340 | + |
---|
| 341 | + CameraPane.debugpointR.toParent[3][0] = poship.x; |
---|
| 342 | + CameraPane.debugpointR.toParent[3][1] = poship.y; |
---|
| 343 | + CameraPane.debugpointR.toParent[3][2] = poship.z; |
---|
| 344 | + |
---|
| 345 | + LA.matInvert(toParent, fromParent); |
---|
| 346 | + } |
---|
| 347 | + |
---|
| 348 | + void LoadData() |
---|
| 349 | + { |
---|
| 350 | + float[] thedata = bvh.animation.getBoneData(0); |
---|
| 351 | + |
---|
| 352 | +// thedata[0] = 0; |
---|
| 353 | +// thedata[1] = 0; |
---|
| 354 | +// thedata[2] = 0; |
---|
| 355 | +// thedata[3] = 0; |
---|
| 356 | +// thedata[4] = 0; |
---|
| 357 | +// thedata[5] = 0; |
---|
| 358 | + |
---|
| 359 | + if (true) |
---|
| 360 | + return; |
---|
| 361 | + |
---|
| 362 | + for (int b=numbones; --b>=0;) |
---|
| 363 | + //int b = 0; |
---|
| 364 | + { |
---|
| 365 | + thedata = bvh.animation.getBoneData(b); |
---|
| 366 | + |
---|
| 367 | + int numframes = bvh.animation.getNumFrames(); |
---|
| 368 | + |
---|
| 369 | + int dof = 6; // thedata.length/numframes; |
---|
| 370 | + |
---|
| 371 | + if (b > 0) |
---|
| 372 | + dof = 3; |
---|
| 373 | + |
---|
| 374 | + if (dof != thedata.length/numframes) |
---|
| 375 | + { |
---|
| 376 | + System.err.println("Bone #" + b + ": dof = " + dof + " ---> " + (thedata.length/numframes)); |
---|
| 377 | + dof = thedata.length/numframes; |
---|
| 378 | + } |
---|
| 379 | + |
---|
| 380 | + //for (int f=numframes; --f>=offset;) |
---|
| 381 | + int firstframe = GetFirstFrame(); |
---|
| 382 | + for (int f=0; f<numframes-firstframe; f++) |
---|
| 383 | + { |
---|
| 384 | + int f3 = f*dof; |
---|
| 385 | + |
---|
| 386 | + //for (int i=3/*dof*/; --i>=0;) |
---|
| 387 | + for (int i=dof; --i>=0;) |
---|
| 388 | + { |
---|
| 389 | + //thedata[f3 + i] += thedata[i] - thedata[offset*dof + i]; |
---|
| 390 | + thedata[f3 + i] = thedata[f3 + firstframe*dof + i]; |
---|
| 391 | + } |
---|
| 392 | + } |
---|
| 393 | + } |
---|
| 394 | + } |
---|
| 395 | + |
---|
| 396 | + void ResetZero() |
---|
| 397 | + { |
---|
| 398 | + for (int b=numbones; --b>=0;) |
---|
| 399 | + { |
---|
| 400 | + float[] thedata = bvh.animation.getBoneData(b); |
---|
| 401 | + |
---|
| 402 | + int numframes = bvh.animation.getNumFrames(); |
---|
| 403 | + |
---|
| 404 | + int dof = 6; |
---|
| 405 | + |
---|
| 406 | + if (b > 0) |
---|
| 407 | + dof = 3; |
---|
| 408 | + |
---|
| 409 | + for (int i=dof; --i>=0;) |
---|
| 410 | + { |
---|
| 411 | + thedata[i] = 0; |
---|
| 412 | + } |
---|
| 413 | + } |
---|
| 414 | + } |
---|
| 415 | + |
---|
| 416 | + void SetCurrentBones(int frame) |
---|
| 417 | + { |
---|
| 418 | + if (frame == 0) |
---|
| 419 | + { |
---|
| 420 | + //frame = 1; |
---|
| 421 | + } |
---|
| 422 | + |
---|
| 423 | + if (currentbones == null) |
---|
| 424 | + { |
---|
| 425 | + currentbones = new double[(numbones-1)*3]; |
---|
| 426 | + currenthip = new double[6]; |
---|
| 427 | + } |
---|
| 428 | + |
---|
| 429 | + for (int b=numbones; --b>=1;) // HIP ROTATION: 0;) |
---|
| 430 | + //int b = 0; |
---|
| 431 | + { |
---|
| 432 | + float[] data = bvh.animation.getBoneData(b); |
---|
| 433 | + |
---|
| 434 | + // int numframes = bvh.animation.getNumFrames(); |
---|
| 435 | + |
---|
| 436 | + int dof = 6; // data.length/numframes; |
---|
| 437 | + |
---|
| 438 | + if (b > 0) |
---|
| 439 | + dof = 3; |
---|
| 440 | + |
---|
| 441 | + //assert(dof == 3); |
---|
| 442 | + |
---|
| 443 | + // System.err.println("Bone #" + b + ": dof = " + dof); |
---|
| 444 | + int theframe = // 1; // baseframe; |
---|
| 445 | + frame; |
---|
| 446 | + |
---|
| 447 | + int frame3 = theframe*dof; |
---|
| 448 | + int bone3 = (b-1)*dof; |
---|
| 449 | + |
---|
| 450 | + int start = 3; |
---|
| 451 | + int end = 0; |
---|
| 452 | + |
---|
| 453 | + if (dof == 6) |
---|
| 454 | + { |
---|
| 455 | + start = 6; |
---|
| 456 | + //end = 3; |
---|
| 457 | + } |
---|
| 458 | + |
---|
| 459 | + for (int i=start; --i>=end;) |
---|
| 460 | + { |
---|
| 461 | + currentbones[bone3 + i/*-end*/] = data[frame3 + i]; |
---|
| 462 | + } |
---|
| 463 | + } |
---|
| 464 | + |
---|
| 465 | + float[] data = bvh.animation.getBoneData(0); |
---|
| 466 | + |
---|
| 467 | + int dof = 6; |
---|
| 468 | + |
---|
| 469 | + int theframe = frame; |
---|
| 470 | + |
---|
| 471 | + int frame3 = theframe*dof; |
---|
| 472 | + |
---|
| 473 | + int start = 6; |
---|
| 474 | + int end = 0; |
---|
| 475 | + |
---|
| 476 | + for (int i=start; --i>=end;) |
---|
| 477 | + { |
---|
| 478 | + currenthip[i] = data[frame3 + i]; |
---|
| 479 | + } |
---|
| 480 | + } |
---|
| 481 | + |
---|
| 482 | + static cVector centroid = new cVector(); |
---|
| 483 | + static cVector mocaporigin = new cVector(); |
---|
| 484 | + |
---|
| 485 | + void SetHipOrientation() |
---|
| 486 | + { |
---|
| 487 | + Object3D hip = get(0); |
---|
| 488 | + |
---|
| 489 | + if (toParent == null) |
---|
| 490 | + { |
---|
| 491 | + toParent = LA.newMatrix(); |
---|
| 492 | + fromParent = LA.newMatrix(); |
---|
| 493 | + } |
---|
| 494 | + |
---|
| 495 | + LA.matConcat(toParent, hip.get(0).toParent, matrix); |
---|
| 496 | + |
---|
| 497 | + mocaporigin.x = matrix[3][0]; |
---|
| 498 | + mocaporigin.y = matrix[3][1]; |
---|
| 499 | + mocaporigin.z = matrix[3][2]; |
---|
| 500 | + |
---|
| 501 | + centroid.x = matrix[3][0]; |
---|
| 502 | + centroid.y = matrix[3][1]; |
---|
| 503 | + centroid.z = matrix[3][2]; |
---|
| 504 | +// this.getCentroid(centroid, true); |
---|
| 505 | + |
---|
| 506 | + CameraPane.CreateSelectedPoint(); |
---|
| 507 | + CameraPane.debugpointG.name = ""; |
---|
| 508 | + CameraPane.debugpointG.toParent[3][0] = mocaporigin.x; |
---|
| 509 | + CameraPane.debugpointG.toParent[3][1] = mocaporigin.y; |
---|
| 510 | + CameraPane.debugpointG.toParent[3][2] = mocaporigin.z; |
---|
| 511 | + |
---|
| 512 | + CameraPane.debugpointP.name = ""; |
---|
| 513 | + CameraPane.debugpointP.toParent[3][0] = centroid.x; |
---|
| 514 | + CameraPane.debugpointP.toParent[3][1] = centroid.y; |
---|
| 515 | + CameraPane.debugpointP.toParent[3][2] = centroid.z; |
---|
| 516 | + |
---|
| 517 | + cVector goal = GetGoal(centroid); |
---|
| 518 | + if (goal != null) |
---|
| 519 | + { |
---|
| 520 | + System.err.println("GOAL change (" + this + "): " + goal + " (was " + goalposx + ", " + goalposz + ")"); |
---|
| 521 | + |
---|
| 522 | + goalposx = goal.x; |
---|
| 523 | + goalposz = goal.z; |
---|
| 524 | + targetdirx = targetdirz = 0; |
---|
| 525 | + } |
---|
| 526 | + |
---|
| 527 | + if (goalposx == 0 && goalposz == 0) |
---|
| 528 | + { |
---|
| 529 | + // No target |
---|
| 530 | + if (ScriptNode.speaker != null) |
---|
| 531 | + { |
---|
| 532 | + Object3D sourcenode = GetFileRoot(); |
---|
| 533 | + Object3D speakernode = ScriptNode.speaker.GetFileRoot(); |
---|
| 534 | + |
---|
| 535 | + //System.err.println("speaker is " + speakernode + "; last was " + ScriptNode.lastspeaker); |
---|
| 536 | + |
---|
| 537 | + Object3D speaker = ScriptNode.speaker; |
---|
| 538 | + |
---|
| 539 | + if (speakernode == sourcenode) |
---|
| 540 | + { |
---|
| 541 | + if (ScriptNode.lastspeaker != null) |
---|
| 542 | + { |
---|
| 543 | + speakernode = ScriptNode.lastspeaker.GetFileRoot(); |
---|
| 544 | + speaker = ScriptNode.lastspeaker; |
---|
| 545 | + } |
---|
| 546 | + else |
---|
| 547 | + return; |
---|
| 548 | + } |
---|
| 549 | + |
---|
| 550 | + cVector dst = new cVector(); |
---|
| 551 | + |
---|
| 552 | + boolean success = speakernode.getCentroid(dst); // , true); |
---|
| 553 | + |
---|
| 554 | + if (!success) |
---|
| 555 | + new Exception().printStackTrace(); |
---|
| 556 | + |
---|
| 557 | + //speakernode.parent.TransformToWorld(dst); |
---|
| 558 | + //sourcenode.parent.TransformToLocal(dst); |
---|
| 559 | + this.parent.TransformToLocal(dst); |
---|
| 560 | + |
---|
| 561 | + goalposx = dst.x; |
---|
| 562 | + goalposz = dst.z; |
---|
| 563 | + } |
---|
| 564 | + else |
---|
| 565 | + return; |
---|
| 566 | + } |
---|
| 567 | + |
---|
| 568 | + cVector temp = new cVector(); |
---|
| 569 | + |
---|
| 570 | + temp.x = 1; |
---|
| 571 | + temp.y = 0; |
---|
| 572 | + temp.z = 0; |
---|
| 573 | + |
---|
| 574 | + LA.xformDir(temp, matrix, temp); |
---|
| 575 | + |
---|
| 576 | + double angleYhip = Math.atan2(-temp.z, temp.x); |
---|
| 577 | + |
---|
| 578 | + double angleYtarget = Math.atan2(goalposx - centroid.x, goalposz - centroid.z); |
---|
| 579 | + |
---|
| 580 | + LA.matIdentity(matrix); |
---|
| 581 | + LA.matTranslate(matrix, -centroid.x, -centroid.y, -centroid.z); |
---|
| 582 | + double angle = CurveAngle(0, angleYtarget - angleYhip, 0.1f); |
---|
| 583 | + LA.matYRotate(matrix, angle); |
---|
| 584 | + LA.matTranslate(matrix, centroid.x, centroid.y, centroid.z); |
---|
| 585 | + |
---|
| 586 | + LA.matConcat(matrix, toParent, toParent); |
---|
| 587 | + |
---|
| 588 | + LA.matInvert(toParent, fromParent); |
---|
| 589 | + |
---|
| 590 | + LA.matConcat(toParent, hip.get(0).toParent, matrix); |
---|
| 591 | + |
---|
| 592 | + centroid.x = matrix[3][0]; |
---|
| 593 | + centroid.y = matrix[3][1]; |
---|
| 594 | + centroid.z = matrix[3][2]; |
---|
| 595 | + |
---|
| 596 | + double dist = LA.distance(centroid, mocaporigin); |
---|
| 597 | + |
---|
| 598 | + CheckForAction(centroid); |
---|
| 599 | + } |
---|
29 | 600 | |
---|
30 | 601 | void WriteTo(java.io.Writer writer) throws Exception |
---|
31 | 602 | { |
---|
.. | .. |
---|
76 | 647 | // transient // aout 2013 |
---|
77 | 648 | Object3D skeleton; |
---|
78 | 649 | |
---|
| 650 | + void ExtractBigData(Object3D o) |
---|
| 651 | + { |
---|
| 652 | + super.ExtractBigData(o); |
---|
| 653 | + |
---|
| 654 | + o.savebvh = this.bvh; |
---|
| 655 | + o.saveskeleton = this.skeleton; |
---|
| 656 | + this.bvh = null; |
---|
| 657 | + this.skeleton = null; |
---|
| 658 | + } |
---|
| 659 | + |
---|
| 660 | + void RestoreBigData(Object3D o) |
---|
| 661 | + { |
---|
| 662 | + super.RestoreBigData(o); |
---|
| 663 | + |
---|
| 664 | + this.bvh = o.savebvh; |
---|
| 665 | + this.skeleton = o.saveskeleton; |
---|
| 666 | + } |
---|
| 667 | + |
---|
79 | 668 | boolean smoothed; |
---|
80 | 669 | |
---|
81 | 670 | //boolean touched; |
---|
.. | .. |
---|
99 | 688 | double pinx; |
---|
100 | 689 | double pinz; |
---|
101 | 690 | |
---|
102 | | - double targetx; |
---|
103 | | - double targetz; |
---|
| 691 | + double targetdirx; |
---|
| 692 | + double targetdirz; |
---|
104 | 693 | |
---|
105 | | - double goalx; |
---|
106 | | - double goalz; |
---|
| 694 | + double goalposx = 0; // -20; |
---|
| 695 | + double goalposz = 0; // -10; |
---|
107 | 696 | |
---|
108 | 697 | boolean followpath; |
---|
109 | 698 | |
---|
.. | .. |
---|
174 | 763 | scriptactions.clear(); |
---|
175 | 764 | } |
---|
176 | 765 | |
---|
177 | | - static double EPSACTION = 0.1; // 0.075; // 0.1; |
---|
| 766 | + static double EPSACTION = 0.1; // 0.075; // 0.1;Came |
---|
178 | 767 | |
---|
179 | 768 | void AddFromTo(cVector from, cVector to) |
---|
180 | 769 | { |
---|
.. | .. |
---|
359 | 948 | // //GetFileRoot(); |
---|
360 | 949 | |
---|
361 | 950 | // sept 2014: // |
---|
362 | | - GrafreeD.RENDERME = 3; // patch for Merge objects |
---|
| 951 | + Grafreed.RENDERME = 3; // patch for Merge objects |
---|
363 | 952 | float[] thedata = bvh.animation.getBoneData(0); |
---|
364 | 953 | |
---|
365 | 954 | os.x = (float) (path.get(i).toParent[3][0]); // - thedata[frame*6]); |
---|
.. | .. |
---|
409 | 998 | |
---|
410 | 999 | get(0).link2master = path.size() > 1; // hip orientation |
---|
411 | 1000 | |
---|
412 | | - if (get(0).link2master) |
---|
| 1001 | + if (get(0).Link2Support()) |
---|
413 | 1002 | { |
---|
414 | 1003 | rotateonce = 2; |
---|
415 | 1004 | } |
---|
.. | .. |
---|
460 | 1049 | testvect.set(from); |
---|
461 | 1050 | testvect.sub(fromto.from); |
---|
462 | 1051 | |
---|
| 1052 | + testvect.y = 0; // PATCH |
---|
| 1053 | + |
---|
463 | 1054 | int factor = 1; |
---|
464 | 1055 | |
---|
465 | 1056 | //if (CameraPane.FAST) |
---|
.. | .. |
---|
501 | 1092 | |
---|
502 | 1093 | testvect.set(from); |
---|
503 | 1094 | testvect.sub(fromto.from); |
---|
| 1095 | + |
---|
| 1096 | + testvect.y = 0; // PATCH |
---|
504 | 1097 | |
---|
505 | 1098 | int factor = 1; |
---|
506 | 1099 | |
---|
.. | .. |
---|
705 | 1298 | // skip first node: translation |
---|
706 | 1299 | // Object3D b = input.get(0); |
---|
707 | 1300 | |
---|
708 | | - setPose(input, f, data.getBoneData(input._index), false); //, null); |
---|
| 1301 | + setPose(input, f, data.getBoneData(input._index)); //, false); //, null); |
---|
709 | 1302 | } |
---|
710 | 1303 | |
---|
711 | 1304 | //mocap.figure.Bone[] children = b.getChildren(); |
---|
.. | .. |
---|
736 | 1329 | |
---|
737 | 1330 | void SetPosition(Object3D sourcenode, cVector floor, long floorid, cVector centroid) |
---|
738 | 1331 | { |
---|
| 1332 | + assert(false); |
---|
739 | 1333 | //assert(CameraPane.drawMode == CameraPane.SHADOW); |
---|
740 | 1334 | |
---|
741 | 1335 | Object3D transformnode = new Object3D(); |
---|
.. | .. |
---|
833 | 1427 | double w = 0.00015; |
---|
834 | 1428 | |
---|
835 | 1429 | //if (!sourcenode.link2master) // strong pin on floor |
---|
836 | | - if (parent.link2master) // strong pin on floor |
---|
| 1430 | + if (parent.Link2Support()) // strong pin on floor |
---|
837 | 1431 | { |
---|
838 | 1432 | w = 0.005; // .001; |
---|
839 | 1433 | } |
---|
.. | .. |
---|
921 | 1515 | //groundz += sourcenode.parent.toParent[3][2] - posz; |
---|
922 | 1516 | } |
---|
923 | 1517 | |
---|
924 | | - boolean footcontact = CameraPane.FOOTCONTACT; // false; |
---|
| 1518 | + boolean footcontact = false; // CameraPane.FOOTCONTACT; // false; |
---|
925 | 1519 | |
---|
926 | 1520 | if (footcontact && ground != -123456) |
---|
927 | 1521 | { |
---|
.. | .. |
---|
939 | 1533 | groundid = floorid; |
---|
940 | 1534 | |
---|
941 | 1535 | // green |
---|
942 | | - CameraPane.debugpoint.toParent[3][0] = groundx; |
---|
943 | | - CameraPane.debugpoint.toParent[3][1] = floor.y; |
---|
944 | | - CameraPane.debugpoint.toParent[3][2] = groundz; |
---|
| 1536 | + CameraPane.debugpointG.toParent[3][0] = groundx; |
---|
| 1537 | + CameraPane.debugpointG.toParent[3][1] = floor.y; |
---|
| 1538 | + CameraPane.debugpointG.toParent[3][2] = groundz; |
---|
945 | 1539 | |
---|
946 | 1540 | if (true) // slow && stepout && onein) |
---|
947 | 1541 | { |
---|
.. | .. |
---|
952 | 1546 | // mywave = currentwave++; |
---|
953 | 1547 | // } |
---|
954 | 1548 | // sound |
---|
955 | | - cVector eye = CameraPane.theRenderer.eyeCamera.location; |
---|
| 1549 | + cVector eye = Globals.theRenderer.EyeCamera().location; |
---|
956 | 1550 | |
---|
957 | 1551 | // if (sourcenode.parent.parent != null) |
---|
958 | 1552 | // sourcenode.parent.parent.TransformToWorld(floor, tmp); |
---|
.. | .. |
---|
997 | 1591 | //GraphreeD. |
---|
998 | 1592 | wav.play(volume * usedvolume); //, mywave); |
---|
999 | 1593 | |
---|
1000 | | - lastsoundtime = CameraPane.framecount; |
---|
| 1594 | + lastsoundtime = Globals.framecount; |
---|
1001 | 1595 | |
---|
1002 | | - GrafreeD.hassound = true; |
---|
| 1596 | + Grafreed.hassound = true; |
---|
1003 | 1597 | } |
---|
1004 | 1598 | // else |
---|
1005 | 1599 | // System.out.println("skipped"); |
---|
.. | .. |
---|
1018 | 1612 | |
---|
1019 | 1613 | // System.out.println("Allo " + sourcenode); |
---|
1020 | 1614 | // purple |
---|
1021 | | - CameraPane.debugpoint2.toParent[3][0] = floor.x;// + posx; |
---|
1022 | | - CameraPane.debugpoint2.toParent[3][1] = ground; // floor.y;// + sourcenode.parent.toParent[3][1]; |
---|
1023 | | - CameraPane.debugpoint2.toParent[3][2] = floor.z;// + posz; |
---|
| 1615 | + CameraPane.debugpointP.toParent[3][0] = floor.x;// + posx; |
---|
| 1616 | + CameraPane.debugpointP.toParent[3][1] = ground; // floor.y;// + sourcenode.parent.toParent[3][1]; |
---|
| 1617 | + CameraPane.debugpointP.toParent[3][2] = floor.z;// + posz; |
---|
1024 | 1618 | |
---|
1025 | 1619 | |
---|
1026 | 1620 | if (false) // dist2 > 0.1) |
---|
.. | .. |
---|
1047 | 1641 | // sourcenode.parent.toParent[3][1] = ground - floor.y; |
---|
1048 | 1642 | // sourcenode.parent.toParent[3][2] += groundz - floor.z; |
---|
1049 | 1643 | // sourcenode.parent.toParent[3][1] = K * (ground - floor.y) + (1 - K) * oldposy; |
---|
1050 | | - if (footcontact && (sourcenode.parent != null && !sourcenode.parent.link2master)) // strong pin on floor |
---|
| 1644 | + if (footcontact && (sourcenode.parent != null && !sourcenode.parent.Link2Support())) // strong pin on floor |
---|
1051 | 1645 | { |
---|
1052 | 1646 | v0.x = groundx - floor.x; |
---|
1053 | 1647 | v0.y = 0; // groundx - floor.x; |
---|
.. | .. |
---|
1086 | 1680 | this.get(0).TransformToWorld(v0); |
---|
1087 | 1681 | |
---|
1088 | 1682 | // cyan |
---|
1089 | | - CameraPane.debugpoint3.toParent[3][0] = v0.x; |
---|
1090 | | - CameraPane.debugpoint3.toParent[3][1] = ground; |
---|
1091 | | - CameraPane.debugpoint3.toParent[3][2] = v0.z; |
---|
| 1683 | + CameraPane.debugpointC.toParent[3][0] = v0.x; |
---|
| 1684 | + CameraPane.debugpointC.toParent[3][1] = ground; |
---|
| 1685 | + CameraPane.debugpointC.toParent[3][2] = v0.z; |
---|
1092 | 1686 | |
---|
1093 | 1687 | LA.matConcat(sourcenode.toParent, transformnode.toParent, sourcenode.toParent); |
---|
1094 | 1688 | LA.matInvert(sourcenode.toParent, sourcenode.fromParent); |
---|
.. | .. |
---|
1098 | 1692 | this.get(0).TransformToWorld(v0); |
---|
1099 | 1693 | |
---|
1100 | 1694 | // red |
---|
1101 | | - CameraPane.debugpoint4.toParent[3][0] = v0.x; |
---|
1102 | | - CameraPane.debugpoint4.toParent[3][1] = ground; |
---|
1103 | | - CameraPane.debugpoint4.toParent[3][2] = v0.z; |
---|
| 1695 | + CameraPane.debugpointR.toParent[3][0] = v0.x; |
---|
| 1696 | + CameraPane.debugpointR.toParent[3][1] = ground; |
---|
| 1697 | + CameraPane.debugpointR.toParent[3][2] = v0.z; |
---|
1104 | 1698 | } |
---|
1105 | 1699 | } |
---|
1106 | 1700 | |
---|
.. | .. |
---|
1140 | 1734 | |
---|
1141 | 1735 | if (goal != null) |
---|
1142 | 1736 | { |
---|
1143 | | - System.err.println("GOAL change (" + sourcenode + "): " + goal + " (was " + goalx + ", " + goalz + ")"); |
---|
| 1737 | + System.err.println("GOAL change (" + sourcenode + "): " + goal + " (was " + goalposx + ", " + goalposz + ")"); |
---|
1144 | 1738 | //sourcenode.parent.parent.Dump(); |
---|
1145 | | - goalx = goal.x; |
---|
1146 | | - goalz = goal.z; |
---|
1147 | | - targetx = targetz = 0; |
---|
| 1739 | + goalposx = goal.x; |
---|
| 1740 | + goalposz = goal.z; |
---|
| 1741 | + targetdirx = targetdirz = 0; |
---|
1148 | 1742 | |
---|
1149 | 1743 | followpath = true; |
---|
1150 | 1744 | } |
---|
.. | .. |
---|
1195 | 1789 | // } |
---|
1196 | 1790 | if (false) // !uselast) |
---|
1197 | 1791 | { |
---|
1198 | | - CameraPane.debugpoint.toParent[3][0] = dst.x; |
---|
1199 | | - CameraPane.debugpoint.toParent[3][1] = dst.y; |
---|
1200 | | - CameraPane.debugpoint.toParent[3][2] = dst.z; |
---|
| 1792 | + CameraPane.debugpointG.toParent[3][0] = dst.x; |
---|
| 1793 | + CameraPane.debugpointG.toParent[3][1] = dst.y; |
---|
| 1794 | + CameraPane.debugpointG.toParent[3][2] = dst.z; |
---|
1201 | 1795 | } |
---|
1202 | 1796 | } |
---|
1203 | 1797 | |
---|
1204 | | - if (goalx != 0 || goalz != 0) // TODO |
---|
| 1798 | + if (goalposx != 0 || goalposz != 0) // TODO |
---|
1205 | 1799 | { |
---|
1206 | 1800 | // overwrite speaker orientation |
---|
1207 | | - dst.set(goalx,0,goalz); |
---|
| 1801 | + dst.set(goalposx,0,goalposz); |
---|
1208 | 1802 | if (sourcenode.parent != null) // july 2014 |
---|
1209 | 1803 | sourcenode.parent. |
---|
1210 | 1804 | TransformToLocal(dst); |
---|
.. | .. |
---|
1220 | 1814 | src.x = 0; |
---|
1221 | 1815 | src.y = 0; |
---|
1222 | 1816 | src.z = 0; |
---|
| 1817 | + LA.xformPos(src, get(0).get(0).toParent, src); |
---|
1223 | 1818 | LA.xformPos(src, get(0).toParent, src); |
---|
1224 | 1819 | LA.xformPos(src, toParent, src); |
---|
1225 | 1820 | // LA.xformPos(src, rotsourcenode.toParent, src); |
---|
.. | .. |
---|
1255 | 1850 | // mars 2014 |
---|
1256 | 1851 | if (false) // goalx != 0 || goalz != 0) |
---|
1257 | 1852 | { |
---|
1258 | | - targetx = dst.x - src.x; |
---|
1259 | | - targetz = dst.z - src.z; |
---|
| 1853 | + targetdirx = dst.x - src.x; |
---|
| 1854 | + targetdirz = dst.z - src.z; |
---|
1260 | 1855 | |
---|
1261 | | - if (Math.abs(targetx) > 0.1 || Math.abs(targetz) > 0.1) |
---|
| 1856 | + if (Math.abs(targetdirx) > 0.1 || Math.abs(targetdirz) > 0.1) |
---|
1262 | 1857 | { |
---|
1263 | 1858 | // far enough from goal. keep the goal position. |
---|
1264 | | - targetx = 0; |
---|
1265 | | - targetz = 0; |
---|
| 1859 | + targetdirx = 0; |
---|
| 1860 | + targetdirz = 0; |
---|
1266 | 1861 | } |
---|
1267 | 1862 | else |
---|
1268 | 1863 | { |
---|
1269 | 1864 | // too close to goal. switch to target direction instead. |
---|
1270 | | - goalx = 0; |
---|
1271 | | - goalz = 0; |
---|
| 1865 | + goalposx = 0; |
---|
| 1866 | + goalposz = 0; |
---|
1272 | 1867 | } |
---|
1273 | 1868 | } |
---|
1274 | 1869 | |
---|
1275 | 1870 | //sourcenode.getCentroid(src, true); |
---|
1276 | 1871 | |
---|
1277 | | - if (speakernode == sourcenode && goalx == 0 && goalz == 0) |
---|
| 1872 | + if (speakernode == sourcenode && goalposx == 0 && goalposz == 0) |
---|
1278 | 1873 | { |
---|
1279 | 1874 | if (ScriptNode.lastspeaker != null) |
---|
1280 | 1875 | new Exception().printStackTrace(); |
---|
.. | .. |
---|
1283 | 1878 | |
---|
1284 | 1879 | // LA.xformPos(src, fromParent, src); |
---|
1285 | 1880 | |
---|
1286 | | - if ((ScriptNode.speaker != null && CameraPane.SPEAKERMOCAP || goalx != 0 || goalz != 0) && targetx == 0 && targetz == 0) |
---|
| 1881 | + if ((ScriptNode.speaker != null && CameraPane.SPEAKERMOCAP || goalposx != 0 || goalposz != 0) && targetdirx == 0 && targetdirz == 0) |
---|
1287 | 1882 | dst.sub(src); |
---|
1288 | 1883 | else |
---|
1289 | 1884 | // vector mode |
---|
1290 | 1885 | { |
---|
1291 | | - dst.x = targetx; |
---|
1292 | | - dst.z = targetz; |
---|
| 1886 | + dst.x = targetdirx; |
---|
| 1887 | + dst.z = targetdirz; |
---|
1293 | 1888 | |
---|
1294 | 1889 | // TEST TARGET |
---|
1295 | 1890 | // dst.x = CameraPane.selectedpoint.toParent[3][0]; |
---|
.. | .. |
---|
1411 | 2006 | // if (sourcenode.link2master) |
---|
1412 | 2007 | // if (goalx != 0 || goalz != 0) |
---|
1413 | 2008 | // K = 0.02; // .0625; |
---|
1414 | | - if (parent.link2master) // strong pin on floor |
---|
| 2009 | + if (parent.Link2Support()) // strong pin on floor |
---|
1415 | 2010 | { |
---|
1416 | 2011 | K = 0.05; // 0.02; |
---|
1417 | 2012 | } |
---|
.. | .. |
---|
1563 | 2158 | toParent = LA.newMatrix(); |
---|
1564 | 2159 | fromParent = LA.newMatrix(); |
---|
1565 | 2160 | } |
---|
| 2161 | + |
---|
1566 | 2162 | LA.matConcat(toParent, rotsourcenode.toParent, toParent); |
---|
1567 | 2163 | LA.matInvert(toParent, fromParent); |
---|
1568 | 2164 | |
---|
.. | .. |
---|
1698 | 2294 | } |
---|
1699 | 2295 | |
---|
1700 | 2296 | if (!smoothed) |
---|
1701 | | - for (int i=4; --i>=0;) |
---|
| 2297 | + for (int i=10; --i>=0;) |
---|
1702 | 2298 | SmoothAnimData(); // much reduces shakiness |
---|
1703 | 2299 | |
---|
1704 | 2300 | smoothed = true; |
---|
.. | .. |
---|
1736 | 2332 | toVector.x = LA.cos(to); |
---|
1737 | 2333 | toVector.y = LA.sin(to); |
---|
1738 | 2334 | |
---|
| 2335 | + double fromA = Math.atan2(fromVector.y, fromVector.x); |
---|
| 2336 | + double toA = Math.atan2(toVector.y, toVector.x); |
---|
| 2337 | + |
---|
1739 | 2338 | Vector2d currentVector = Slerp(fromVector, toVector, step); |
---|
1740 | 2339 | |
---|
1741 | | - return Math.atan2(currentVector.y, currentVector.x); |
---|
| 2340 | + double angle = Math.atan2(currentVector.y, currentVector.x); |
---|
| 2341 | + |
---|
| 2342 | + double angle2 = (1-step) * fromA + step * toA; |
---|
| 2343 | + |
---|
| 2344 | + return angle; |
---|
1742 | 2345 | } |
---|
1743 | 2346 | |
---|
1744 | 2347 | public static Vector2d Slerp(Vector2d from, Vector2d to, double step) |
---|
.. | .. |
---|
1780 | 2383 | if (!live) // aout 2013 |
---|
1781 | 2384 | return; |
---|
1782 | 2385 | |
---|
1783 | | - cVector centroid = new cVector(); |
---|
1784 | | - cVector floor = new cVector(); |
---|
1785 | | - |
---|
1786 | | - Object3D sourcenode = GetFileRoot(); |
---|
| 2386 | + //bvh.skeleton.setPose(f, bvh.animation.getBoneData(bvh.skeleton.getIndex()), null); |
---|
| 2387 | + try |
---|
| 2388 | + { |
---|
| 2389 | + SetPose(GetSkeleton(), bvh.animation, f); |
---|
| 2390 | + SetCurrentBones(frame); |
---|
| 2391 | + } |
---|
| 2392 | + catch (Exception e) |
---|
| 2393 | + { |
---|
| 2394 | + e.printStackTrace(); |
---|
| 2395 | + } |
---|
1787 | 2396 | |
---|
1788 | | - boolean success; // = sourcenode.getCentroid(centroid); |
---|
| 2397 | + SetHipOrientation(); |
---|
| 2398 | + |
---|
| 2399 | + if (true) |
---|
| 2400 | + return; |
---|
| 2401 | + |
---|
| 2402 | + cVector centroid = new cVector(); |
---|
| 2403 | + cVector floor = new cVector(); |
---|
| 2404 | + |
---|
| 2405 | + Object3D sourcenode = GetFileRoot(); |
---|
| 2406 | + |
---|
| 2407 | + boolean success; // = sourcenode.getCentroid(centroid); |
---|
1789 | 2408 | // if (!success) |
---|
1790 | 2409 | // { |
---|
1791 | 2410 | // //assert(success); |
---|
.. | .. |
---|
1793 | 2412 | // System.out.println("No centroid for " + sourcenode); |
---|
1794 | 2413 | // } |
---|
1795 | 2414 | |
---|
1796 | | - //bvh.skeleton.setPose(f, bvh.animation.getBoneData(bvh.skeleton.getIndex()), null); |
---|
1797 | | - try |
---|
1798 | | - { |
---|
1799 | | - SetPose(GetSkeleton(), bvh.animation, f); |
---|
1800 | | - } |
---|
1801 | | - catch (Exception e) |
---|
1802 | | - { |
---|
1803 | | - e.printStackTrace(); |
---|
1804 | | - } |
---|
1805 | | - |
---|
1806 | 2415 | if (sourcenode.parent == null && sourcenode.fileparent == null) |
---|
1807 | 2416 | { |
---|
1808 | 2417 | // No GFD |
---|
.. | .. |
---|
1814 | 2423 | // SetBreakPoint(get(0).toParent[0], 0); |
---|
1815 | 2424 | // } |
---|
1816 | 2425 | |
---|
1817 | | - boolean setrotation = get(0).link2master && !firsttimeafterload && frame > 0; |
---|
| 2426 | + boolean setrotation = get(0).Link2Support() && !firsttimeafterload && frame > 0; |
---|
1818 | 2427 | boolean setposition = sourcenode != null && // sourcenode.parent != null && // july 2014 |
---|
1819 | | - sourcenode./*parent.*/link2master && !firsttimeafterload && frame > 0; |
---|
| 2428 | + sourcenode./*parent.*/Link2Support() && !firsttimeafterload && frame > 0; |
---|
1820 | 2429 | |
---|
1821 | 2430 | // cVector centroid = new cVector(); |
---|
1822 | 2431 | // cVector floor = new cVector(); |
---|
.. | .. |
---|
2050 | 2659 | * @param frame |
---|
2051 | 2660 | * Frame number |
---|
2052 | 2661 | */ |
---|
2053 | | - public void setPose(Object3D bone, int frame, float[] data, boolean fade) //, Point3d offsetTrans) |
---|
| 2662 | + public void setPose(Object3D bone, int frame, float[] data) //, boolean fade) //, Point3d offsetTrans) |
---|
2054 | 2663 | { |
---|
2055 | 2664 | if (!live) // aout 2013 |
---|
2056 | 2665 | return; |
---|
.. | .. |
---|
2058 | 2667 | cVector temp = new cVector(); |
---|
2059 | 2668 | cVector temp0 = new cVector(); |
---|
2060 | 2669 | double pos[] = new double[3]; |
---|
| 2670 | + double angleY = 0; |
---|
| 2671 | + double sinY = 0; |
---|
| 2672 | + double cosY = 0; |
---|
| 2673 | + |
---|
| 2674 | + if (false) // bone._isRoot && firsttimeafterload && frame > 0) |
---|
| 2675 | + { |
---|
| 2676 | + bone.get(0).GlobalTransformInv(); |
---|
| 2677 | + |
---|
| 2678 | + temp.x = bone.get(0).globalTransform[3][0]; |
---|
| 2679 | + temp.y = bone.get(0).globalTransform[3][1]; |
---|
| 2680 | + temp.z = bone.get(0).globalTransform[3][2]; |
---|
| 2681 | + |
---|
| 2682 | + pos[0] = temp.x; |
---|
| 2683 | + pos[1] = temp.y; |
---|
| 2684 | + pos[2] = temp.z; |
---|
| 2685 | + |
---|
| 2686 | + temp.x = 1; |
---|
| 2687 | + temp.y = 0; |
---|
| 2688 | + temp.z = 0; |
---|
| 2689 | + |
---|
| 2690 | + LA.xformDir(temp, bone.get(0).globalTransform, temp); |
---|
| 2691 | + |
---|
| 2692 | + sinY = temp.z; |
---|
| 2693 | + cosY = temp.x; |
---|
| 2694 | + |
---|
| 2695 | + angleY = Math.atan2(-sinY, cosY); |
---|
| 2696 | + } |
---|
2061 | 2697 | |
---|
2062 | 2698 | // Object3D obj = get(0); |
---|
2063 | 2699 | // Object3D gp = this.parent; |
---|
.. | .. |
---|
2189 | 2825 | if (//frame > 0 && |
---|
2190 | 2826 | !bone.skipmocap && |
---|
2191 | 2827 | !bone.name.contains("head") && |
---|
| 2828 | + !bone.name.contains("Head") // && |
---|
2192 | 2829 | // !bone.name.contains("rFoot") && |
---|
2193 | 2830 | // !bone.name.contains("lFoot") && |
---|
2194 | | - !bone.name.contains("Pinky") && |
---|
2195 | | - !bone.name.contains("Ring") && |
---|
2196 | | - !bone.name.contains("Mid") && |
---|
2197 | | - !bone.name.contains("Index") && |
---|
2198 | | - !bone.name.contains("Thumb") |
---|
| 2831 | +// !bone.name.contains("Pinky") && |
---|
| 2832 | +// !bone.name.contains("Ring") && |
---|
| 2833 | +// !bone.name.contains("Mid") && |
---|
| 2834 | +// !bone.name.contains("Index") && |
---|
| 2835 | +// !bone.name.contains("Thumb") |
---|
2199 | 2836 | ) |
---|
2200 | 2837 | { |
---|
2201 | 2838 | //_rotTG.setTransform(_t1); |
---|
.. | .. |
---|
2221 | 2858 | |
---|
2222 | 2859 | // set translation |
---|
2223 | 2860 | // (currently only possible for root bone! see mocapdata.com data) |
---|
2224 | | - if (bone._isRoot && link2master) // && !GetFileRoot().link2master) |
---|
| 2861 | + if (bone._isRoot && Link2Support()) // && !GetFileRoot().link2master) |
---|
2225 | 2862 | { |
---|
2226 | 2863 | if (hasTranslation) // && _translationEnabled) |
---|
2227 | 2864 | { |
---|
2228 | 2865 | // CROWD |
---|
2229 | 2866 | //cJ3D.GetTranslation(bone, _trans0); |
---|
2230 | 2867 | //_trans.add(_trans0); |
---|
2231 | | - _transTF.setIdentity(); |
---|
| 2868 | + //_transTF.setIdentity(); |
---|
| 2869 | + _transTF.set(_t1); |
---|
2232 | 2870 | _transTF.setTranslation(_trans); |
---|
2233 | 2871 | // System.err.println("Translate: " + _transTF); |
---|
2234 | 2872 | //_transTG.setTransform(_transTF); |
---|
2235 | | - cJ3D.ResetTransform(bone, _transTF, true); // translation node |
---|
| 2873 | + cJ3D.ResetTransform(bone.get(0), _transTF, true); // translation node |
---|
| 2874 | + //cJ3D.ResetTransform(bone, _transTF, true); // translation node |
---|
2236 | 2875 | } |
---|
2237 | 2876 | } |
---|
2238 | 2877 | |
---|
2239 | | - if (bone._isRoot && firsttimeafterload && frame > 0) |
---|
| 2878 | + if (false) // bone._isRoot && firsttimeafterload && frame > 0) |
---|
2240 | 2879 | { |
---|
2241 | 2880 | assert(bone == get(0)); |
---|
2242 | 2881 | |
---|
.. | .. |
---|
2252 | 2891 | // LA.matConcat(originmatrixinv, tempmatrixinv, fromParent); // ABC * (B'*C')^-1 |
---|
2253 | 2892 | // |
---|
2254 | 2893 | |
---|
2255 | | - Invariants(); |
---|
2256 | | - bone.Invariants(); |
---|
2257 | | - bone.get(0).Invariants(); |
---|
2258 | | - // if (origin == null) |
---|
2259 | | - // origin = null; |
---|
2260 | | - origin.Invariants(); |
---|
2261 | | - origin0.Invariants(); |
---|
| 2894 | + Invariants(); |
---|
| 2895 | + bone.Invariants(); |
---|
| 2896 | + bone.get(0).Invariants(); |
---|
| 2897 | + // if (origin == null) |
---|
| 2898 | + // origin = null; |
---|
| 2899 | + origin.Invariants(); |
---|
| 2900 | + origin0.Invariants(); |
---|
2262 | 2901 | |
---|
2263 | | - |
---|
2264 | | - LA.matConcat(bone.get(0).fromParent, bone.fromParent, tempmatrix); // B' * C' |
---|
2265 | | - LA.matConcat(origin.toParent, tempmatrix, toParent); |
---|
| 2902 | + |
---|
| 2903 | +//?? LA.matConcat(bone.get(0).fromParent, bone.fromParent, tempmatrix); // B' * C' |
---|
| 2904 | +//?? LA.matConcat(origin.toParent, tempmatrix, toParent); |
---|
2266 | 2905 | |
---|
2267 | 2906 | // matrixToEulerXYZ(toParent, temp); |
---|
2268 | 2907 | // matrixToEulerXYZ(bone.get(0).toParent, temp); |
---|
.. | .. |
---|
2296 | 2935 | // |
---|
2297 | 2936 | // mat4d.get(quat); |
---|
2298 | 2937 | |
---|
2299 | | - if (true) // hip correction |
---|
| 2938 | + if (false) // hip correction |
---|
2300 | 2939 | { |
---|
2301 | 2940 | _t2.setIdentity(); |
---|
2302 | 2941 | |
---|
.. | .. |
---|
2337 | 2976 | //????? LA.matConcat(bone.get(0).toParent, bone.toParent, tempmatrix); // B' * C' |
---|
2338 | 2977 | // LA.matConcat(origin.fromParent, tempmatrix, fromParent); |
---|
2339 | 2978 | |
---|
2340 | | - LA.matInvert(toParent, fromParent); |
---|
| 2979 | +//?? LA.matInvert(toParent, fromParent); |
---|
2341 | 2980 | |
---|
2342 | | - Invariants(); |
---|
2343 | | - bone.Invariants(); |
---|
2344 | | - bone.get(0).Invariants(); |
---|
2345 | | - origin.Invariants(); |
---|
2346 | | - origin0.Invariants(); |
---|
| 2981 | + Invariants(); |
---|
| 2982 | + bone.Invariants(); |
---|
| 2983 | + bone.get(0).Invariants(); |
---|
| 2984 | + origin.Invariants(); |
---|
| 2985 | + origin0.Invariants(); |
---|
2347 | 2986 | |
---|
2348 | 2987 | // LA.matInvert(fromParent, tempmatrix); |
---|
2349 | 2988 | // |
---|
.. | .. |
---|
2364 | 3003 | // temp.x = data[0]; |
---|
2365 | 3004 | // temp.y = data[1]; |
---|
2366 | 3005 | // temp.z = data[2]; |
---|
2367 | | - LA.xformPos(temp, origin0.toParent, temp0); |
---|
| 3006 | + LA.xformPos(temp, origin0.toParent, temp0); // NU |
---|
2368 | 3007 | |
---|
2369 | | -// bone.GlobalTransformInv(); |
---|
2370 | | - |
---|
2371 | | - temp0.x = bone.globalTransform[3][0]; |
---|
2372 | | - temp0.y = bone.globalTransform[3][1]; |
---|
2373 | | - temp0.z = bone.globalTransform[3][2]; |
---|
2374 | | - |
---|
| 3008 | +// bone.get(0).GlobalTransformInv(); |
---|
| 3009 | +// |
---|
| 3010 | +// temp0.x = bone.get(0).globalTransform[3][0]; |
---|
| 3011 | +// temp0.y = bone.get(0).globalTransform[3][1]; |
---|
| 3012 | +// temp0.z = bone.get(0).globalTransform[3][2]; |
---|
| 3013 | +// |
---|
2375 | 3014 | // MEGA TEST // june 2014: necessary for precision? otherwise comment works |
---|
2376 | | -fromParent[3][0] = 0; |
---|
2377 | | -fromParent[3][1] = 0; |
---|
2378 | | -fromParent[3][2] = 0; |
---|
2379 | | -LA.matInvert(fromParent, toParent); |
---|
| 3015 | +//fromParent[3][0] = 0; |
---|
| 3016 | +//fromParent[3][1] = 0; |
---|
| 3017 | +//fromParent[3][2] = 0; |
---|
| 3018 | +//LA.matInvert(fromParent, toParent); |
---|
2380 | 3019 | |
---|
2381 | | - LA.xformPos(temp0, fromParent, temp); |
---|
| 3020 | + LA.xformPos(temp0, fromParent, temp); // NU |
---|
2382 | 3021 | //LA.xformPos(temp, bone.fromParent, temp); |
---|
2383 | 3022 | // float[] data; |
---|
2384 | 3023 | |
---|
2385 | | - pos[0] = temp.x; |
---|
2386 | | - pos[1] = temp.y; |
---|
2387 | | - pos[2] = temp.z; |
---|
| 3024 | +// pos[0] = temp.x; |
---|
| 3025 | +// pos[1] = temp.y; |
---|
| 3026 | +// pos[2] = temp.z; |
---|
| 3027 | +// |
---|
| 3028 | +// temp.x = 1; |
---|
| 3029 | +// temp.y = 0; |
---|
| 3030 | +// temp.z = 0; |
---|
| 3031 | +// |
---|
| 3032 | +// LA.xformDir(temp, bone.get(0).globalTransform, temp); |
---|
2388 | 3033 | |
---|
2389 | 3034 | // CameraPane.selectedpoint.toParent[3][0] = temp0.x; |
---|
2390 | 3035 | // CameraPane.selectedpoint.toParent[3][1] = temp0.y; |
---|
2391 | 3036 | // CameraPane.selectedpoint.toParent[3][2] = temp0.z; |
---|
2392 | 3037 | |
---|
2393 | | - int numframes = bvh.animation.getNumFrames(); |
---|
| 3038 | + int numframes = bvh.animation.getNumFrames(); |
---|
2394 | 3039 | |
---|
2395 | 3040 | int b = 0; |
---|
2396 | 3041 | { |
---|
.. | .. |
---|
2398 | 3043 | |
---|
2399 | 3044 | int dof = 6; /// data.length/numframes; |
---|
2400 | 3045 | |
---|
2401 | | - // july 2014 |
---|
2402 | | - if (dof != data.length/numframes) |
---|
2403 | | - { |
---|
2404 | | - System.err.println("Bone #" + b + ": dof = " + dof + " ---> " + (data.length/numframes)); |
---|
2405 | | - dof = data.length/numframes; |
---|
2406 | | - } |
---|
| 3046 | + // july 2014 |
---|
| 3047 | + if (dof != data.length/numframes) |
---|
| 3048 | + { |
---|
| 3049 | + System.err.println("Bone #" + b + ": dof = " + dof + " ---> " + (data.length/numframes)); |
---|
| 3050 | + dof = data.length/numframes; |
---|
| 3051 | + } |
---|
2407 | 3052 | |
---|
2408 | 3053 | |
---|
2409 | 3054 | int theframe = 0; // baseframe; |
---|
.. | .. |
---|
2455 | 3100 | // } |
---|
2456 | 3101 | // } |
---|
2457 | 3102 | |
---|
2458 | | - data[f3 + i] += pos[i] - data[frame3 + i]; |
---|
| 3103 | + data[f3 + i] += /*pos[i]*/ - data[frame3 + i]; |
---|
2459 | 3104 | |
---|
2460 | 3105 | // if (f < 3) |
---|
2461 | 3106 | // { |
---|
2462 | 3107 | // System.out.print(data[f3 + i] + " "); |
---|
2463 | 3108 | // } |
---|
2464 | 3109 | } |
---|
2465 | | -// if (f < 3) |
---|
2466 | | -// { |
---|
2467 | | -// System.out.println(); |
---|
2468 | | -// } |
---|
| 3110 | + |
---|
| 3111 | + double t1 = data[f3 + 0]; |
---|
| 3112 | + double t2 = data[f3 + 2]; |
---|
| 3113 | + |
---|
| 3114 | + data[f3 + 0] = (float)(cosY*t1 - sinY*t2); |
---|
| 3115 | + data[f3 + 2] = (float)(sinY*t1 + cosY*t2); |
---|
| 3116 | + |
---|
| 3117 | + for (int i=3/*dof*/; --i>=0;) |
---|
| 3118 | + { |
---|
| 3119 | + data[f3 + i] += pos[i]; |
---|
| 3120 | + } |
---|
| 3121 | + |
---|
| 3122 | + data[f3 + 4] += angleY - data[frame3 + 4]; |
---|
2469 | 3123 | } |
---|
2470 | 3124 | } |
---|
2471 | 3125 | |
---|
.. | .. |
---|
2479 | 3133 | // temp.y = data[1]; |
---|
2480 | 3134 | // temp.z = data[2]; |
---|
2481 | 3135 | |
---|
2482 | | - if (fade && currentbones != null && !CameraPane.fullreset) |
---|
2483 | | - { |
---|
2484 | | - Quat4d quatstart = new Quat4d(); |
---|
2485 | | - Quat4d quatend = new Quat4d(); |
---|
2486 | | - Quat4d quat = new Quat4d(); |
---|
2487 | | - Matrix4d mat4d = new Matrix4d(); |
---|
2488 | | - double[][] rot = new double[4][4]; |
---|
2489 | | - |
---|
2490 | | - for (b=numbones; --b>=1;) // HIP ROTATION: 0;) |
---|
2491 | | - { |
---|
2492 | | - int hipindex = get(0)._index; |
---|
2493 | | - |
---|
2494 | | -// assert(get(0).get(0)._isHip); |
---|
2495 | | - |
---|
2496 | | - // if (b == hipindex) |
---|
2497 | | - // continue; |
---|
2498 | | - |
---|
2499 | | - data = bvh.animation.getBoneData(b); |
---|
2500 | | - |
---|
2501 | | - int dof = 3; // data.length/numframes; |
---|
2502 | | - |
---|
2503 | | - // assert(dof == 3); |
---|
2504 | | - |
---|
2505 | | - int boneframe3 = b*3; // dof; |
---|
2506 | | - |
---|
2507 | | - // System.err.println("Bone #" + b + ": dof = " + dof); |
---|
2508 | | - int fadein = 45; // 120; |
---|
2509 | | - |
---|
2510 | | - // if (b == hipindex) |
---|
2511 | | - // fadein *= 5; |
---|
2512 | | - |
---|
2513 | | - if (fadein > numframes) |
---|
2514 | | - fadein = 0; // numframes; |
---|
2515 | | - |
---|
2516 | | - for (int fi=fadein; --fi>=0;) |
---|
2517 | | - //for (int f=numframes; --f>=0;) |
---|
2518 | | - { |
---|
2519 | | - int f = fi + GetFirstFrame(); |
---|
2520 | | - |
---|
2521 | | - int f3 = f*dof; |
---|
2522 | | - |
---|
2523 | | - float k = fi; |
---|
2524 | | - |
---|
2525 | | - k /= fadein - 1; |
---|
2526 | | - |
---|
2527 | | - if (Float.isNaN(k)) |
---|
2528 | | - k = 1; // 0/0 |
---|
2529 | | - |
---|
2530 | | - k = (float) (-Math.cos(k*Math.PI)); |
---|
2531 | | - k += 1; |
---|
2532 | | - k /= 2; |
---|
2533 | | - |
---|
2534 | | - int start = 3; |
---|
2535 | | - int end = 0; |
---|
2536 | | - |
---|
2537 | | - if (dof == 6) |
---|
2538 | | - { |
---|
2539 | | - start = 6; |
---|
2540 | | - end = 3; |
---|
2541 | | - } |
---|
2542 | | - |
---|
2543 | | - if (b == 0) |
---|
2544 | | - { |
---|
2545 | | - _t1.setIdentity(); |
---|
2546 | | - _t2.setIdentity(); |
---|
2547 | | - _t2.rotZ(currentbones[boneframe3 + start-1-end]); |
---|
2548 | | - _t1.mul(_t2); |
---|
2549 | | - _t2.setIdentity(); |
---|
2550 | | - if (b == 0) |
---|
2551 | | - { |
---|
2552 | | - _t2.rotY(currentbones[boneframe3 + start-2-end]); |
---|
2553 | | - _t1.mul(_t2); |
---|
2554 | | - _t2.setIdentity(); |
---|
2555 | | - _t2.rotX(currentbones[boneframe3 + start-3-end]); |
---|
2556 | | - } |
---|
2557 | | - else |
---|
2558 | | - { |
---|
2559 | | - _t2.rotX(currentbones[boneframe3 + start-2-end]); |
---|
2560 | | - _t1.mul(_t2); |
---|
2561 | | - _t2.setIdentity(); |
---|
2562 | | - _t2.rotY(currentbones[boneframe3 + start-3-end]); |
---|
2563 | | - } |
---|
2564 | | - _t1.mul(_t2); |
---|
2565 | | - _t2.setIdentity(); |
---|
2566 | | - |
---|
2567 | | - _t1.get(mat4d); |
---|
2568 | | - |
---|
2569 | | - mat4d.get(quatstart); |
---|
2570 | | - |
---|
2571 | | - _t1.setIdentity(); |
---|
2572 | | - _t2.setIdentity(); |
---|
2573 | | - _t2.rotZ(data[f3 + start-1]); |
---|
2574 | | - _t1.mul(_t2); |
---|
2575 | | - _t2.setIdentity(); |
---|
2576 | | - if (b == 0) |
---|
2577 | | - { |
---|
2578 | | - _t2.rotY(data[f3 + start-2]); |
---|
2579 | | - _t1.mul(_t2); |
---|
2580 | | - _t2.setIdentity(); |
---|
2581 | | - _t2.rotX(data[f3 + start-3]); |
---|
2582 | | - } |
---|
2583 | | - else |
---|
2584 | | - { |
---|
2585 | | - _t2.rotX(data[f3 + start-2]); |
---|
2586 | | - _t1.mul(_t2); |
---|
2587 | | - _t2.setIdentity(); |
---|
2588 | | - _t2.rotY(data[f3 + start-3]); |
---|
2589 | | - } |
---|
2590 | | - |
---|
2591 | | - _t1.mul(_t2); |
---|
2592 | | - _t2.setIdentity(); |
---|
2593 | | - |
---|
2594 | | - _t1.get(mat4d); |
---|
2595 | | - |
---|
2596 | | - mat4d.get(quatend); |
---|
2597 | | - |
---|
2598 | | - double dot = quatstart.x*quatend.x + |
---|
2599 | | - quatstart.y*quatend.y + |
---|
2600 | | - quatstart.z*quatend.z + |
---|
2601 | | - quatstart.w*quatend.w |
---|
2602 | | - ; |
---|
2603 | | - |
---|
2604 | | - if (dot < 0) |
---|
2605 | | - { |
---|
2606 | | - quatend.x *= -1; |
---|
2607 | | - quatend.y *= -1; |
---|
2608 | | - quatend.z *= -1; |
---|
2609 | | - quatend.w *= -1; |
---|
2610 | | - } |
---|
2611 | | - |
---|
2612 | | - // k = 1-k; |
---|
2613 | | - |
---|
2614 | | - quat.x = (1-k)*quatstart.x + k*quatend.x; |
---|
2615 | | - quat.y = (1-k)*quatstart.y + k*quatend.y; |
---|
2616 | | - quat.z = (1-k)*quatstart.z + k*quatend.z; |
---|
2617 | | - quat.w = (1-k)*quatstart.w + k*quatend.w; |
---|
2618 | | - |
---|
2619 | | - quat.normalize(); |
---|
2620 | | - |
---|
2621 | | - mat4d.set(quat); |
---|
2622 | | - |
---|
2623 | | - cJ3D.SetTransform(rot, mat4d); |
---|
2624 | | - |
---|
2625 | | - matrixToEulerXYZ(rot, temp); |
---|
2626 | | - |
---|
2627 | | - data[f3 + start-1] = -(float)temp.z; |
---|
2628 | | - |
---|
2629 | | - if (b == 0) |
---|
2630 | | - { |
---|
2631 | | - data[f3 + start-2] = -(float)temp.y; |
---|
2632 | | - data[f3 + start-3] = -(float)temp.x; |
---|
2633 | | - } |
---|
2634 | | - else |
---|
2635 | | - { |
---|
2636 | | - data[f3 + start-2] = -(float)temp.x; |
---|
2637 | | - data[f3 + start-3] = -(float)temp.y; |
---|
2638 | | - } |
---|
2639 | | - } |
---|
2640 | | - else |
---|
2641 | | - { |
---|
2642 | | - for (int i=start; --i>=end;) |
---|
2643 | | - { |
---|
2644 | | - //data[f3 + i] += pos[i] - data[frame3 + i]; |
---|
2645 | | - // data[f3 + i] = k*data[f3+i] + (1-k)* |
---|
2646 | | - // currentbones[boneframe3 + i-end]; |
---|
2647 | | - data[f3 + i] = (float)CurveAngle(data[f3+i], currentbones[boneframe3 + i-end], 1-k); |
---|
2648 | | - } |
---|
2649 | | - } |
---|
2650 | | - |
---|
2651 | | - } |
---|
2652 | | - } |
---|
2653 | | - |
---|
2654 | | - } |
---|
| 3136 | +// if (fade && currentbones != null && !CameraPane.fullreset) |
---|
| 3137 | +// { |
---|
| 3138 | +// Fade(); |
---|
| 3139 | +// } |
---|
2655 | 3140 | } |
---|
2656 | | - |
---|
| 3141 | + |
---|
2657 | 3142 | if (false) // doesn't change anything bone._isRoot) |
---|
2658 | 3143 | { |
---|
2659 | 3144 | // Reset orientation |
---|
2660 | 3145 | _t2.setIdentity(); |
---|
2661 | | - |
---|
| 3146 | + |
---|
2662 | 3147 | double tx = bone.toParent[3][0]; |
---|
2663 | 3148 | double ty = bone.toParent[3][1]; |
---|
2664 | 3149 | double tz = bone.toParent[3][2]; |
---|
.. | .. |
---|
2667 | 3152 | temp.y = 0; |
---|
2668 | 3153 | temp.z = 0; |
---|
2669 | 3154 | LA.xformDir(temp, bone.toParent, temp); |
---|
2670 | | - |
---|
| 3155 | + |
---|
2671 | 3156 | double angle = Math.atan2(-temp.z, temp.x); |
---|
2672 | | - |
---|
| 3157 | + |
---|
2673 | 3158 | _t2.rotY(angle); |
---|
2674 | 3159 | // _t1.setIdentity(); |
---|
2675 | 3160 | // _t1.rotX(temp.x); |
---|
.. | .. |
---|
2682 | 3167 | // _t1.setIdentity(); |
---|
2683 | 3168 | // _t1.rotZ(temp.z); |
---|
2684 | 3169 | // _t2.mul(_t1); |
---|
2685 | | - |
---|
| 3170 | + |
---|
2686 | 3171 | cJ3D.ResetTransform(bone, _t2, false); |
---|
2687 | | - |
---|
| 3172 | + |
---|
2688 | 3173 | bone.toParent[3][0] = tx; |
---|
2689 | 3174 | bone.toParent[3][1] = ty; |
---|
2690 | 3175 | bone.toParent[3][2] = tz; |
---|
2691 | 3176 | } |
---|
2692 | 3177 | } |
---|
2693 | 3178 | |
---|
2694 | | - if (currentbones == null) |
---|
2695 | | - currentbones = new double[numbones*3]; |
---|
2696 | | - |
---|
2697 | | - for (int b=numbones; --b>=1;) // 0;) |
---|
2698 | | - //int b = 0; |
---|
2699 | | - { |
---|
2700 | | - data = bvh.animation.getBoneData(b); |
---|
2701 | | - |
---|
2702 | | - int numframes = bvh.animation.getNumFrames(); |
---|
2703 | | - |
---|
2704 | | - int dof = 6; // data.length/numframes; |
---|
2705 | | - |
---|
2706 | | - if (b > 0) |
---|
2707 | | - dof = 3; |
---|
2708 | | - |
---|
2709 | | - //assert(dof == 3); |
---|
2710 | | - |
---|
2711 | | - // System.err.println("Bone #" + b + ": dof = " + dof); |
---|
2712 | | - int theframe = // 1; // baseframe; |
---|
2713 | | - frame; |
---|
2714 | | - |
---|
2715 | | - int frame3 = theframe*dof; |
---|
2716 | | - int bone3 = b*3; // dof; |
---|
2717 | | - |
---|
2718 | | - int start = 3; |
---|
2719 | | - int end = 0; |
---|
2720 | | - |
---|
2721 | | - if (dof == 6) |
---|
2722 | | - { |
---|
2723 | | - start = 6; |
---|
2724 | | - end = 3; |
---|
2725 | | - } |
---|
2726 | | - for (int i=start; --i>=end;) |
---|
2727 | | - { |
---|
2728 | | - currentbones[bone3 + i-end] = data[frame3 + i]; |
---|
2729 | | - } |
---|
2730 | | - } |
---|
| 3179 | + // SetCurrentBones(frame); |
---|
2731 | 3180 | } |
---|
2732 | 3181 | } |
---|
2733 | 3182 | |
---|
2734 | | - static int offset = 1; // 5; // 10; // 5; // 100; // skip initial "T" |
---|
| 3183 | + // skip initial "T" |
---|
| 3184 | + static int offset = 1; // 5; // 10; // 5; // 100; |
---|
2735 | 3185 | |
---|
2736 | 3186 | void ReadBVH() |
---|
2737 | 3187 | { |
---|
.. | .. |
---|
2760 | 3210 | |
---|
2761 | 3211 | void Reset() |
---|
2762 | 3212 | { |
---|
2763 | | - if (fullname != null) |
---|
2764 | | - ReadBVH(); |
---|
| 3213 | +// if (fullname != null) |
---|
| 3214 | +// ReadBVH(); |
---|
2765 | 3215 | |
---|
2766 | 3216 | Object3D hip = get(0); |
---|
2767 | 3217 | |
---|
2768 | 3218 | // assert(obj.name.equals("hip")); |
---|
2769 | 3219 | |
---|
2770 | | - Object3D rot = hip.get(0); |
---|
| 3220 | + //Object3D rot = hip.get(0); |
---|
2771 | 3221 | |
---|
2772 | 3222 | // assert(obj.name == null); // .equals("hip#")); |
---|
2773 | 3223 | |
---|
.. | .. |
---|
2777 | 3227 | hip.fromParent = LA.newMatrix(); |
---|
2778 | 3228 | } |
---|
2779 | 3229 | |
---|
2780 | | - hip.toParent[3][0] = hip.toParent[3][1] = hip.toParent[3][2] = 0; |
---|
2781 | | - hip.fromParent[3][0] = hip.fromParent[3][1] = hip.fromParent[3][2] = 0; |
---|
| 3230 | + //hip.toParent[3][0] = hip.toParent[3][1] = hip.toParent[3][2] = 0; |
---|
| 3231 | + //hip.fromParent[3][0] = hip.fromParent[3][1] = hip.fromParent[3][2] = 0; |
---|
2782 | 3232 | |
---|
2783 | 3233 | if (toParent == null) |
---|
2784 | 3234 | { |
---|
.. | .. |
---|
2790 | 3240 | LA.matIdentity(fromParent); |
---|
2791 | 3241 | // LA.matIdentity(hip.toParent); |
---|
2792 | 3242 | // LA.matIdentity(hip.fromParent); |
---|
2793 | | - if (rot.toParent == null) |
---|
2794 | | - { |
---|
2795 | | - // june 2014 |
---|
2796 | | - rot.toParent = LA.newMatrix(); |
---|
2797 | | - rot.fromParent = LA.newMatrix(); |
---|
2798 | | - } |
---|
2799 | | - LA.matIdentity(rot.toParent); |
---|
2800 | | - LA.matIdentity(rot.fromParent); |
---|
| 3243 | +// if (rot.toParent == null) |
---|
| 3244 | +// { |
---|
| 3245 | +// // june 2014 |
---|
| 3246 | +// rot.toParent = LA.newMatrix(); |
---|
| 3247 | +// rot.fromParent = LA.newMatrix(); |
---|
| 3248 | +// } |
---|
| 3249 | +// LA.matIdentity(rot.toParent); |
---|
| 3250 | +// LA.matIdentity(rot.fromParent); |
---|
2801 | 3251 | |
---|
2802 | 3252 | // july 2014 |
---|
2803 | | - goalx = goalz = 0; |
---|
2804 | | - targetx = targetz = 0; |
---|
| 3253 | +// goalx = goalz = 0; |
---|
| 3254 | + targetdirx = targetdirz = 0; |
---|
2805 | 3255 | |
---|
2806 | | - SetPositionDelta(true, true, true, false); |
---|
| 3256 | + //SetPositionDelta(true, true, true, false); |
---|
| 3257 | +// LoadData(); |
---|
| 3258 | +// Rewind(); |
---|
2807 | 3259 | |
---|
2808 | 3260 | baseframe = frame = 0; // T pose. No offset. |
---|
2809 | 3261 | |
---|
2810 | 3262 | // aout 2013 endframe = 0; // june 2013 |
---|
2811 | 3263 | |
---|
2812 | | - setPose(frame); |
---|
| 3264 | + ResetZero(); |
---|
| 3265 | + //setPose(frame); |
---|
2813 | 3266 | } |
---|
2814 | 3267 | |
---|
2815 | 3268 | static int mocapsupport = 0; |
---|
.. | .. |
---|
2827 | 3280 | |
---|
2828 | 3281 | int step = 1; |
---|
2829 | 3282 | |
---|
| 3283 | + // patch for running hare |
---|
2830 | 3284 | if (speedup) // fev 2014 |
---|
2831 | 3285 | step *= 2; // 4; |
---|
2832 | 3286 | if (rewind) // mars 2014 |
---|
2833 | 3287 | step *= 4; |
---|
2834 | 3288 | |
---|
2835 | | - if (CameraPane.FAST) // && !CameraPane.HOLD) |
---|
| 3289 | + //if (CameraPane.FAST) // && !CameraPane.HOLD) |
---|
2836 | 3290 | step *= CameraPane.STEP; |
---|
2837 | 3291 | |
---|
2838 | 3292 | //System.err.println("Step Mocap frame # " + frame); |
---|
.. | .. |
---|
2840 | 3294 | baseframe += step; |
---|
2841 | 3295 | |
---|
2842 | 3296 | //frame = baseframe; |
---|
2843 | | - frame += step; |
---|
| 3297 | + //frame += step; |
---|
2844 | 3298 | |
---|
2845 | 3299 | // if (frame != baseframe) |
---|
2846 | 3300 | // { |
---|
.. | .. |
---|
2854 | 3308 | if (lastframetest == 0) |
---|
2855 | 3309 | lastframetest = bvh.animation.getNumFrames(); |
---|
2856 | 3310 | |
---|
| 3311 | + // WARNING: RESET DESTROYS EVERYTHING |
---|
2857 | 3312 | if (baseframe >= lastframetest) // july 2013 // - GetFirstFrame()) |
---|
2858 | 3313 | { |
---|
2859 | 3314 | System.out.println("MOCAP reset: " + this.GetFileRoot() + |
---|
.. | .. |
---|
2863 | 3318 | "; fullname = " + fullname); |
---|
2864 | 3319 | |
---|
2865 | 3320 | //int delta = frame - baseframe; |
---|
2866 | | - if (CameraPane.CROWD) |
---|
| 3321 | + if (Globals.CROWD) |
---|
2867 | 3322 | { |
---|
2868 | 3323 | baseframe = GetFirstFrame(); // 0 initial point |
---|
2869 | 3324 | } |
---|
.. | .. |
---|
2872 | 3327 | // SetPositionDelta(false, true, false); // ?? false); |
---|
2873 | 3328 | { |
---|
2874 | 3329 | if (support == null) |
---|
2875 | | - ObjEditor.LoadBVHFile(fullname, this, false, beginframe, lastframetest); |
---|
2876 | | - else |
---|
2877 | 3330 | { |
---|
2878 | | - try |
---|
| 3331 | + if (bvh == null && new File(fullname).exists()) |
---|
| 3332 | + ObjEditor.LoadBVHFile(fullname, this, false, beginframe, lastframetest); |
---|
| 3333 | + else |
---|
2879 | 3334 | { |
---|
2880 | | - bvh = ((Mocap)support.get(mocapsupport++ % support.Size())).bvh; |
---|
2881 | | - |
---|
2882 | | - SetPositionDelta(false, true, true, true); |
---|
2883 | | - } |
---|
2884 | | - catch (Exception e) |
---|
2885 | | - { |
---|
2886 | | - e.printStackTrace(); |
---|
2887 | | - ObjEditor.LoadBVHFile(fullname, this, false, beginframe, lastframetest); |
---|
| 3335 | + SetGlobalTransform(); |
---|
| 3336 | + Rewind(); |
---|
| 3337 | + Fade(); |
---|
2888 | 3338 | } |
---|
2889 | 3339 | } |
---|
| 3340 | + else |
---|
| 3341 | + { |
---|
| 3342 | +// try |
---|
| 3343 | +// { |
---|
| 3344 | + bvh = ((Mocap)support.get(mocapsupport++ % support.Size())).bvh; |
---|
| 3345 | + |
---|
| 3346 | + // SetPositionDelta(false, true, true, true); |
---|
| 3347 | + LoadData(); |
---|
| 3348 | + Rewind(); |
---|
| 3349 | + Fade(); |
---|
| 3350 | +// } |
---|
| 3351 | +// catch (Exception e) |
---|
| 3352 | +// { |
---|
| 3353 | +// System.err.println("An error occured while loading data. Use fallback by loading the file."); |
---|
| 3354 | +// //e.printStackTrace(); |
---|
| 3355 | +// try |
---|
| 3356 | +// { |
---|
| 3357 | +// ObjEditor.LoadBVHFile(fullname, this, false, beginframe, lastframetest); |
---|
| 3358 | +// } |
---|
| 3359 | +// catch (Exception e2) |
---|
| 3360 | +// { |
---|
| 3361 | +// System.err.println("Motion file not found: " + fullname); |
---|
| 3362 | +// } |
---|
| 3363 | +// } |
---|
| 3364 | + } |
---|
2890 | 3365 | } |
---|
| 3366 | + |
---|
| 3367 | + frame = GetFirstFrame(); |
---|
2891 | 3368 | } |
---|
| 3369 | + else |
---|
| 3370 | + frame += step; |
---|
2892 | 3371 | |
---|
2893 | 3372 | //SetPositionDelta(false); |
---|
2894 | 3373 | |
---|
2895 | | - if (frame >= bvh.animation.getNumFrames()) |
---|
2896 | | - //baseframe = |
---|
2897 | | - frame = GetFirstFrame(); // 0; // offset; // initial point |
---|
| 3374 | +// if (frame >= bvh.animation.getNumFrames()) |
---|
| 3375 | +// //baseframe = |
---|
| 3376 | +// frame = GetFirstFrame(); // 0; // offset; // initial point |
---|
2898 | 3377 | |
---|
2899 | 3378 | //System.err.println("frame = " + frame); |
---|
2900 | 3379 | if (lastframe != 0) |
---|
.. | .. |
---|
3063 | 3542 | // filters out bad input data |
---|
3064 | 3543 | void FilterAnimData() |
---|
3065 | 3544 | { |
---|
| 3545 | + new Exception().printStackTrace(); |
---|
3066 | 3546 | System.exit(0); |
---|
3067 | 3547 | |
---|
3068 | 3548 | float[] data; // = bvh.animation.getBoneData(0); |
---|
.. | .. |
---|
3192 | 3672 | //static |
---|
3193 | 3673 | transient |
---|
3194 | 3674 | double[] currentbones; |
---|
| 3675 | + double[] currenthip; |
---|
| 3676 | + |
---|
3195 | 3677 | transient boolean inbetween; |
---|
3196 | 3678 | |
---|
3197 | 3679 | void SetPositionDelta(boolean reset, boolean rewind, boolean load, boolean fade) |
---|
.. | .. |
---|
3202 | 3684 | //assert(dim == numframes*6); |
---|
3203 | 3685 | |
---|
3204 | 3686 | if (load) |
---|
3205 | | - for (int b=numbones; --b>=0;) |
---|
3206 | | - //int b = 0; |
---|
3207 | | - { |
---|
3208 | | - float[] thedata = bvh.animation.getBoneData(b); |
---|
3209 | | - |
---|
3210 | | - int numframes = bvh.animation.getNumFrames(); |
---|
3211 | | - |
---|
3212 | | - int dof = 6; // thedata.length/numframes; |
---|
3213 | | - |
---|
3214 | | - if (b > 0) |
---|
3215 | | - dof = 3; |
---|
3216 | | - |
---|
3217 | | - if (dof != thedata.length/numframes) |
---|
3218 | | - { |
---|
3219 | | - System.err.println("Bone #" + b + ": dof = " + dof + " ---> " + (thedata.length/numframes)); |
---|
3220 | | - dof = thedata.length/numframes; |
---|
3221 | | - } |
---|
3222 | | - |
---|
3223 | | - //for (int f=numframes; --f>=offset;) |
---|
3224 | | - int firstframe = GetFirstFrame(); |
---|
3225 | | - for (int f=0; f<numframes-firstframe; f++) |
---|
3226 | | - { |
---|
3227 | | - int f3 = f*dof; |
---|
3228 | | - |
---|
3229 | | - //for (int i=3/*dof*/; --i>=0;) |
---|
3230 | | - for (int i=dof; --i>=0;) |
---|
3231 | | - { |
---|
3232 | | - //thedata[f3 + i] += thedata[i] - thedata[offset*dof + i]; |
---|
3233 | | - thedata[f3 + i] = thedata[f3 + firstframe*dof + i]; |
---|
3234 | | - } |
---|
3235 | | - } |
---|
3236 | | - } |
---|
| 3687 | + { |
---|
| 3688 | + LoadData(); |
---|
| 3689 | + } |
---|
3237 | 3690 | |
---|
3238 | 3691 | // assert(thedata[0] == 0); |
---|
3239 | 3692 | // assert(thedata[1] == 0); |
---|
.. | .. |
---|
3243 | 3696 | // assert(thedata[7] == 0); |
---|
3244 | 3697 | // assert(thedata[8] == 0); |
---|
3245 | 3698 | |
---|
3246 | | - Object3D obj = get(0); |
---|
| 3699 | + Object3D hip = get(0); |
---|
3247 | 3700 | |
---|
3248 | 3701 | // assert(obj.name.equals("hip")); |
---|
3249 | 3702 | |
---|
3250 | | - Object3D rot = obj.get(0); |
---|
| 3703 | + Object3D rot = hip.get(0); |
---|
3251 | 3704 | |
---|
3252 | 3705 | // if (toParent == null) |
---|
3253 | 3706 | // { |
---|
.. | .. |
---|
3259 | 3712 | // // assert(obj.name == null); // .equals("hip#")); |
---|
3260 | 3713 | |
---|
3261 | 3714 | Invariants(); |
---|
3262 | | - obj.Invariants(); |
---|
| 3715 | + hip.Invariants(); |
---|
3263 | 3716 | rot.Invariants(); |
---|
3264 | 3717 | |
---|
3265 | 3718 | if (origin == null) |
---|
.. | .. |
---|
3280 | 3733 | fromParent = LA.newMatrix(); |
---|
3281 | 3734 | } |
---|
3282 | 3735 | |
---|
3283 | | - if (obj.toParent == null) // june 2014 |
---|
| 3736 | + if (hip.toParent == null) // june 2014 |
---|
3284 | 3737 | { |
---|
3285 | | - obj.toParent = LA.newMatrix(); |
---|
3286 | | - obj.fromParent = LA.newMatrix(); |
---|
| 3738 | + hip.toParent = LA.newMatrix(); |
---|
| 3739 | + hip.fromParent = LA.newMatrix(); |
---|
3287 | 3740 | } |
---|
3288 | 3741 | |
---|
3289 | | - LA.matConcat(toParent, obj.toParent, origin0.toParent); // AB |
---|
| 3742 | + LA.matConcat(toParent, hip.toParent, origin0.toParent); // AB |
---|
3290 | 3743 | Object3D gp = this.parent; |
---|
3291 | 3744 | this.parent = null; |
---|
3292 | | - obj.GlobalTransformInv(); |
---|
| 3745 | + hip.GlobalTransformInv(); |
---|
3293 | 3746 | this.parent = gp; |
---|
3294 | 3747 | |
---|
3295 | 3748 | if (rot.toParent == null) |
---|
.. | .. |
---|
3312 | 3765 | LA.matInvert(origin.toParent, origin.fromParent); |
---|
3313 | 3766 | |
---|
3314 | 3767 | Invariants(); |
---|
3315 | | - obj.Invariants(); |
---|
| 3768 | + hip.Invariants(); |
---|
3316 | 3769 | rot.Invariants(); |
---|
3317 | 3770 | origin.Invariants(); |
---|
3318 | 3771 | origin0.Invariants(); |
---|
3319 | 3772 | |
---|
3320 | | - firsttimeafterload = true; |
---|
| 3773 | + firsttimeafterload = false; // true; |
---|
3321 | 3774 | |
---|
3322 | 3775 | if (rewind) |
---|
3323 | 3776 | Rewind(); |
---|
3324 | 3777 | |
---|
3325 | | - setPose(obj, frame, bvh.animation.getBoneData(obj._index), fade); |
---|
| 3778 | + setPose(hip, frame, bvh.animation.getBoneData(hip._index)); //, fade); |
---|
3326 | 3779 | |
---|
3327 | | - if (true) |
---|
3328 | | - return; |
---|
| 3780 | + if (true) |
---|
| 3781 | + return; |
---|
3329 | 3782 | |
---|
3330 | 3783 | double pos[] = new double[6]; |
---|
3331 | 3784 | |
---|
3332 | 3785 | if (!reset) |
---|
3333 | 3786 | { |
---|
3334 | | - assert(obj.tx == obj.toParent[3][0]); |
---|
3335 | | - assert(obj.ty == obj.toParent[3][1]); |
---|
3336 | | - assert(obj.tz == obj.toParent[3][2]); |
---|
| 3787 | + assert(hip.tx == hip.toParent[3][0]); |
---|
| 3788 | + assert(hip.ty == hip.toParent[3][1]); |
---|
| 3789 | + assert(hip.tz == hip.toParent[3][2]); |
---|
3337 | 3790 | |
---|
3338 | | - pos[0] = obj.tx; // obj.toParent[3][0]; |
---|
3339 | | - pos[1] = obj.ty; // obj.toParent[3][1]; |
---|
3340 | | - pos[2] = obj.tz; // obj.toParent[3][2]; |
---|
3341 | | - pos[3] = obj.rz; |
---|
3342 | | - pos[4] = obj.ry; |
---|
3343 | | - pos[5] = obj.rx; |
---|
| 3791 | + pos[0] = hip.tx; // obj.toParent[3][0]; |
---|
| 3792 | + pos[1] = hip.ty; // obj.toParent[3][1]; |
---|
| 3793 | + pos[2] = hip.tz; // obj.toParent[3][2]; |
---|
| 3794 | + pos[3] = hip.rz; |
---|
| 3795 | + pos[4] = hip.ry; |
---|
| 3796 | + pos[5] = hip.rx; |
---|
3344 | 3797 | } |
---|
3345 | 3798 | |
---|
3346 | 3799 | cVector temp = new cVector(); |
---|
3347 | | - temp.x = obj.globalTransform[3][0]; |
---|
3348 | | - temp.y = obj.globalTransform[3][1]; |
---|
3349 | | - temp.z = obj.globalTransform[3][2]; |
---|
| 3800 | + temp.x = hip.globalTransform[3][0]; |
---|
| 3801 | + temp.y = hip.globalTransform[3][1]; |
---|
| 3802 | + temp.z = hip.globalTransform[3][2]; |
---|
3350 | 3803 | // LA.xformPos(temp, origin0.toParent, temp); |
---|
3351 | 3804 | // System.err.println("POS0 = " + temp.x + ", " + temp.y + ", " + temp.z + ";"); |
---|
3352 | 3805 | |
---|
.. | .. |
---|
3430 | 3883 | } |
---|
3431 | 3884 | |
---|
3432 | 3885 | // Rewind(); |
---|
3433 | | - setPose(obj, frame, bvh.animation.getBoneData(obj._index), true); |
---|
| 3886 | + setPose(hip, frame, bvh.animation.getBoneData(hip._index)); // , true); |
---|
3434 | 3887 | } |
---|
3435 | 3888 | |
---|
3436 | 3889 | void Rewind() |
---|
.. | .. |
---|
3447 | 3900 | |
---|
3448 | 3901 | transient boolean restarted; // CROWD issue? |
---|
3449 | 3902 | |
---|
3450 | | - void drawSelf(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
| 3903 | + void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
3451 | 3904 | { |
---|
3452 | 3905 | //System.err.println("drawSelf Mocap frame # " + frame); |
---|
3453 | 3906 | //System.err.println("drawSelf Mocap baseframe # " + baseframe); |
---|
.. | .. |
---|
3464 | 3917 | // if (firstframe) |
---|
3465 | 3918 | // return; |
---|
3466 | 3919 | |
---|
3467 | | - if (!restarted && /*display.restartframe &&*/ |
---|
3468 | | - display.isLIVE() && live && display.drawMode == display.SHADOW) // FUCK |
---|
| 3920 | + if (//!restarted && /*display.restartframe &&*/ |
---|
| 3921 | + Globals.isLIVE() && live && (display.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE)) |
---|
3469 | 3922 | { |
---|
3470 | 3923 | //display.restartframe = false; |
---|
3471 | 3924 | restarted = true; |
---|
| 3925 | + //System.err.println("restarted = true"); |
---|
3472 | 3926 | Step(); |
---|
| 3927 | + |
---|
| 3928 | + Globals.lighttouched = true; |
---|
3473 | 3929 | } |
---|
3474 | 3930 | else |
---|
3475 | 3931 | { |
---|
3476 | | - if (display.isLIVE() && live && display.drawMode != display.SHADOW) |
---|
| 3932 | + //System.err.println("restarted"); |
---|
| 3933 | + if (Globals.isLIVE() && live && display.DrawMode() != iCameraPane.SHADOW) |
---|
| 3934 | + { |
---|
3477 | 3935 | restarted = false; |
---|
| 3936 | + //System.err.println("restarted = false"); |
---|
| 3937 | + } |
---|
3478 | 3938 | } |
---|
3479 | 3939 | |
---|
3480 | 3940 | super.drawSelf(display, root, selected, blocked); |
---|
.. | .. |
---|
3534 | 3994 | // GetObject().release(i); |
---|
3535 | 3995 | } |
---|
3536 | 3996 | |
---|
| 3997 | + boolean HasBigData() |
---|
| 3998 | + { |
---|
| 3999 | + return skeleton != null; |
---|
| 4000 | + } |
---|
| 4001 | + |
---|
3537 | 4002 | public Object3D get(int i) |
---|
3538 | 4003 | { |
---|
3539 | 4004 | if (i != 0) |
---|