.. | .. |
---|
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.debugpoint.toParent[3][0] = poship.x; |
---|
| 265 | + CameraPane.debugpoint.toParent[3][1] = poship.y; |
---|
| 266 | + CameraPane.debugpoint.toParent[3][2] = poship.z; |
---|
| 267 | + |
---|
| 268 | + LA.matInvert(toParent, fromParent); |
---|
| 269 | + |
---|
| 270 | + LA.matIdentity(hip.get(0).toParent); |
---|
| 271 | + LA.matIdentity(hip.get(0).fromParent); |
---|
| 272 | + |
---|
| 273 | +// if (true) |
---|
| 274 | +// return; |
---|
| 275 | + |
---|
| 276 | + // Updates hip.get(0).toParent |
---|
| 277 | + setPose(hip, GetFirstFrame(), bvh.animation.getBoneData(hip._index)); |
---|
| 278 | + |
---|
| 279 | + // A = toParent; B = hip.get(0).toParent |
---|
| 280 | + // A'*B = A |
---|
| 281 | + // A' = A * B-1 |
---|
| 282 | + |
---|
| 283 | + poship.x = hip.get(0).toParent[3][0]; |
---|
| 284 | + poship.y = hip.get(0).toParent[3][1]; |
---|
| 285 | + poship.z = hip.get(0).toParent[3][2]; |
---|
| 286 | + |
---|
| 287 | + temp.x = 1; |
---|
| 288 | + temp.y = 0; |
---|
| 289 | + temp.z = 0; |
---|
| 290 | + |
---|
| 291 | + LA.xformDir(temp, hip.get(0).toParent, temp); |
---|
| 292 | + |
---|
| 293 | + angleYhip = Math.atan2(-temp.z, temp.x); |
---|
| 294 | + |
---|
| 295 | + LA.matIdentity(matrix); |
---|
| 296 | + LA.matYRotate(matrix, angleYhip); |
---|
| 297 | + LA.matTranslate(matrix, poship.x, poship.y, poship.z); |
---|
| 298 | + |
---|
| 299 | + //LA.matInvert(hip.get(0).toParent, matrix); |
---|
| 300 | + LA.matInvert(matrix, matrix); |
---|
| 301 | + |
---|
| 302 | + //LA.matIdentity(matrix); |
---|
| 303 | + //LA.matTranslate(matrix, -poship.x, -poship.y, -poship.z); |
---|
| 304 | + |
---|
| 305 | + LA.matConcat(toParent, matrix, toParent); |
---|
| 306 | + |
---|
| 307 | + |
---|
| 308 | + LA.matConcat(toParent, hip.get(0).toParent, matrix); |
---|
| 309 | + pos.x = hip.get(0).toParent[3][0]; |
---|
| 310 | + pos.y = hip.get(0).toParent[3][1]; |
---|
| 311 | + pos.z = hip.get(0).toParent[3][2]; |
---|
| 312 | + LA.xformPos(new cVector(), hip.get(0).toParent, pos); |
---|
| 313 | + LA.xformPos(pos, toParent, pos); |
---|
| 314 | + |
---|
| 315 | +// temp.x = 1; |
---|
| 316 | +// temp.y = 0; |
---|
| 317 | +// temp.z = 0; |
---|
| 318 | +// |
---|
| 319 | +// LA.xformDir(temp, toParent, temp); |
---|
| 320 | +// |
---|
| 321 | +// angleY = Math.atan2(-temp.z, temp.x); |
---|
| 322 | +// |
---|
| 323 | +// LA.matIdentity(toParent); |
---|
| 324 | +// LA.matYRotate(toParent, angleY - angleYhip); |
---|
| 325 | +// LA.matTranslate(toParent, pos.x - poship.x, pos.y - poship.y, pos.z - poship.z); |
---|
| 326 | + |
---|
| 327 | + CameraPane.debugpoint2.toParent[3][0] = pos.x; |
---|
| 328 | + CameraPane.debugpoint2.toParent[3][1] = pos.y; |
---|
| 329 | + CameraPane.debugpoint2.toParent[3][2] = pos.z; |
---|
| 330 | + |
---|
| 331 | + CameraPane.debugpoint3.toParent[3][0] = poship.x; |
---|
| 332 | + CameraPane.debugpoint3.toParent[3][1] = poship.y; |
---|
| 333 | + CameraPane.debugpoint3.toParent[3][2] = poship.z; |
---|
| 334 | + |
---|
| 335 | + poship.x = toParent[3][0]; |
---|
| 336 | + poship.y = toParent[3][1]; |
---|
| 337 | + poship.z = toParent[3][2]; |
---|
| 338 | + |
---|
| 339 | + CameraPane.debugpoint4.toParent[3][0] = poship.x; |
---|
| 340 | + CameraPane.debugpoint4.toParent[3][1] = poship.y; |
---|
| 341 | + CameraPane.debugpoint4.toParent[3][2] = poship.z; |
---|
| 342 | + |
---|
| 343 | + LA.matInvert(toParent, fromParent); |
---|
| 344 | + } |
---|
| 345 | + |
---|
| 346 | + void LoadData() |
---|
| 347 | + { |
---|
| 348 | + float[] thedata = bvh.animation.getBoneData(0); |
---|
| 349 | + |
---|
| 350 | +// thedata[0] = 0; |
---|
| 351 | +// thedata[1] = 0; |
---|
| 352 | +// thedata[2] = 0; |
---|
| 353 | +// thedata[3] = 0; |
---|
| 354 | +// thedata[4] = 0; |
---|
| 355 | +// thedata[5] = 0; |
---|
| 356 | + |
---|
| 357 | + if (true) |
---|
| 358 | + return; |
---|
| 359 | + |
---|
| 360 | + for (int b=numbones; --b>=0;) |
---|
| 361 | + //int b = 0; |
---|
| 362 | + { |
---|
| 363 | + thedata = bvh.animation.getBoneData(b); |
---|
| 364 | + |
---|
| 365 | + int numframes = bvh.animation.getNumFrames(); |
---|
| 366 | + |
---|
| 367 | + int dof = 6; // thedata.length/numframes; |
---|
| 368 | + |
---|
| 369 | + if (b > 0) |
---|
| 370 | + dof = 3; |
---|
| 371 | + |
---|
| 372 | + if (dof != thedata.length/numframes) |
---|
| 373 | + { |
---|
| 374 | + System.err.println("Bone #" + b + ": dof = " + dof + " ---> " + (thedata.length/numframes)); |
---|
| 375 | + dof = thedata.length/numframes; |
---|
| 376 | + } |
---|
| 377 | + |
---|
| 378 | + //for (int f=numframes; --f>=offset;) |
---|
| 379 | + int firstframe = GetFirstFrame(); |
---|
| 380 | + for (int f=0; f<numframes-firstframe; f++) |
---|
| 381 | + { |
---|
| 382 | + int f3 = f*dof; |
---|
| 383 | + |
---|
| 384 | + //for (int i=3/*dof*/; --i>=0;) |
---|
| 385 | + for (int i=dof; --i>=0;) |
---|
| 386 | + { |
---|
| 387 | + //thedata[f3 + i] += thedata[i] - thedata[offset*dof + i]; |
---|
| 388 | + thedata[f3 + i] = thedata[f3 + firstframe*dof + i]; |
---|
| 389 | + } |
---|
| 390 | + } |
---|
| 391 | + } |
---|
| 392 | + } |
---|
| 393 | + |
---|
| 394 | + void ResetZero() |
---|
| 395 | + { |
---|
| 396 | + for (int b=numbones; --b>=0;) |
---|
| 397 | + { |
---|
| 398 | + float[] thedata = bvh.animation.getBoneData(b); |
---|
| 399 | + |
---|
| 400 | + int numframes = bvh.animation.getNumFrames(); |
---|
| 401 | + |
---|
| 402 | + int dof = 6; |
---|
| 403 | + |
---|
| 404 | + if (b > 0) |
---|
| 405 | + dof = 3; |
---|
| 406 | + |
---|
| 407 | + for (int i=dof; --i>=0;) |
---|
| 408 | + { |
---|
| 409 | + thedata[i] = 0; |
---|
| 410 | + } |
---|
| 411 | + } |
---|
| 412 | + } |
---|
| 413 | + |
---|
| 414 | + void SetCurrentBones(int frame) |
---|
| 415 | + { |
---|
| 416 | + if (frame == 0) |
---|
| 417 | + { |
---|
| 418 | + //frame = 1; |
---|
| 419 | + } |
---|
| 420 | + |
---|
| 421 | + if (currentbones == null) |
---|
| 422 | + { |
---|
| 423 | + currentbones = new double[(numbones-1)*3]; |
---|
| 424 | + currenthip = new double[6]; |
---|
| 425 | + } |
---|
| 426 | + |
---|
| 427 | + for (int b=numbones; --b>=1;) // HIP ROTATION: 0;) |
---|
| 428 | + //int b = 0; |
---|
| 429 | + { |
---|
| 430 | + float[] data = bvh.animation.getBoneData(b); |
---|
| 431 | + |
---|
| 432 | + // int numframes = bvh.animation.getNumFrames(); |
---|
| 433 | + |
---|
| 434 | + int dof = 6; // data.length/numframes; |
---|
| 435 | + |
---|
| 436 | + if (b > 0) |
---|
| 437 | + dof = 3; |
---|
| 438 | + |
---|
| 439 | + //assert(dof == 3); |
---|
| 440 | + |
---|
| 441 | + // System.err.println("Bone #" + b + ": dof = " + dof); |
---|
| 442 | + int theframe = // 1; // baseframe; |
---|
| 443 | + frame; |
---|
| 444 | + |
---|
| 445 | + int frame3 = theframe*dof; |
---|
| 446 | + int bone3 = (b-1)*dof; |
---|
| 447 | + |
---|
| 448 | + int start = 3; |
---|
| 449 | + int end = 0; |
---|
| 450 | + |
---|
| 451 | + if (dof == 6) |
---|
| 452 | + { |
---|
| 453 | + start = 6; |
---|
| 454 | + //end = 3; |
---|
| 455 | + } |
---|
| 456 | + |
---|
| 457 | + for (int i=start; --i>=end;) |
---|
| 458 | + { |
---|
| 459 | + currentbones[bone3 + i/*-end*/] = data[frame3 + i]; |
---|
| 460 | + } |
---|
| 461 | + } |
---|
| 462 | + |
---|
| 463 | + float[] data = bvh.animation.getBoneData(0); |
---|
| 464 | + |
---|
| 465 | + int dof = 6; |
---|
| 466 | + |
---|
| 467 | + int theframe = frame; |
---|
| 468 | + |
---|
| 469 | + int frame3 = theframe*dof; |
---|
| 470 | + |
---|
| 471 | + int start = 6; |
---|
| 472 | + int end = 0; |
---|
| 473 | + |
---|
| 474 | + for (int i=start; --i>=end;) |
---|
| 475 | + { |
---|
| 476 | + currenthip[i] = data[frame3 + i]; |
---|
| 477 | + } |
---|
| 478 | + } |
---|
| 479 | + |
---|
| 480 | + void SetHipOrientation() |
---|
| 481 | + { |
---|
| 482 | + Object3D hip = get(0); |
---|
| 483 | + |
---|
| 484 | + LA.matConcat(toParent, hip.get(0).toParent, matrix); |
---|
| 485 | + |
---|
| 486 | + cVector centroid = new cVector(); |
---|
| 487 | + centroid.x = matrix[3][0]; |
---|
| 488 | + centroid.y = matrix[3][1]; |
---|
| 489 | + centroid.z = matrix[3][2]; |
---|
| 490 | + this.getCentroid(centroid, true); |
---|
| 491 | + |
---|
| 492 | + cVector goal = GetGoal(centroid); |
---|
| 493 | + if (goal != null) |
---|
| 494 | + { |
---|
| 495 | + System.err.println("GOAL change (" + this + "): " + goal + " (was " + goalx + ", " + goalz + ")"); |
---|
| 496 | + |
---|
| 497 | + goalx = goal.x; |
---|
| 498 | + goalz = goal.z; |
---|
| 499 | + targetx = targetz = 0; |
---|
| 500 | + } |
---|
| 501 | + |
---|
| 502 | + if (goalx == 0 && goalz == 0) |
---|
| 503 | + { |
---|
| 504 | + // No target |
---|
| 505 | + if (ScriptNode.speaker != null) |
---|
| 506 | + { |
---|
| 507 | + Object3D sourcenode = GetFileRoot(); |
---|
| 508 | + Object3D speakernode = ScriptNode.speaker.GetFileRoot(); |
---|
| 509 | + |
---|
| 510 | + //System.err.println("speaker is " + speakernode + "; last was " + ScriptNode.lastspeaker); |
---|
| 511 | + |
---|
| 512 | + Object3D speaker = ScriptNode.speaker; |
---|
| 513 | + |
---|
| 514 | + if (speakernode == sourcenode) |
---|
| 515 | + { |
---|
| 516 | + if (ScriptNode.lastspeaker != null) |
---|
| 517 | + { |
---|
| 518 | + speakernode = ScriptNode.lastspeaker.GetFileRoot(); |
---|
| 519 | + speaker = ScriptNode.lastspeaker; |
---|
| 520 | + } |
---|
| 521 | + else |
---|
| 522 | + return; |
---|
| 523 | + } |
---|
| 524 | + |
---|
| 525 | + cVector dst = new cVector(); |
---|
| 526 | + |
---|
| 527 | + boolean success = speakernode.getCentroid(dst); // , true); |
---|
| 528 | + |
---|
| 529 | + if (!success) |
---|
| 530 | + new Exception().printStackTrace(); |
---|
| 531 | + |
---|
| 532 | + //speakernode.parent.TransformToWorld(dst); |
---|
| 533 | + //sourcenode.parent.TransformToLocal(dst); |
---|
| 534 | + this.parent.TransformToLocal(dst); |
---|
| 535 | + |
---|
| 536 | + goalx = dst.x; |
---|
| 537 | + goalz = dst.z; |
---|
| 538 | + } |
---|
| 539 | + else |
---|
| 540 | + return; |
---|
| 541 | + } |
---|
| 542 | + |
---|
| 543 | + cVector temp = new cVector(); |
---|
| 544 | + |
---|
| 545 | + temp.x = 1; |
---|
| 546 | + temp.y = 0; |
---|
| 547 | + temp.z = 0; |
---|
| 548 | + |
---|
| 549 | + LA.xformDir(temp, matrix, temp); |
---|
| 550 | + |
---|
| 551 | + double angleYhip = Math.atan2(-temp.z, temp.x); |
---|
| 552 | + |
---|
| 553 | + double angleYtarget = Math.atan2(goalx - centroid.x, goalz - centroid.z); |
---|
| 554 | + |
---|
| 555 | + LA.matIdentity(matrix); |
---|
| 556 | + LA.matTranslate(matrix, -centroid.x, -centroid.y, -centroid.z); |
---|
| 557 | + double angle = CurveAngle(0, angleYtarget - angleYhip, 1); // 0.1f); |
---|
| 558 | + LA.matYRotate(matrix, angle); |
---|
| 559 | + LA.matTranslate(matrix, centroid.x, centroid.y, centroid.z); |
---|
| 560 | + |
---|
| 561 | + LA.matConcat(matrix, toParent, toParent); |
---|
| 562 | + |
---|
| 563 | + LA.matInvert(toParent, fromParent); |
---|
| 564 | + |
---|
| 565 | + CheckForAction(centroid); |
---|
| 566 | + } |
---|
29 | 567 | |
---|
30 | 568 | void WriteTo(java.io.Writer writer) throws Exception |
---|
31 | 569 | { |
---|
.. | .. |
---|
102 | 640 | double targetx; |
---|
103 | 641 | double targetz; |
---|
104 | 642 | |
---|
105 | | - double goalx; |
---|
106 | | - double goalz; |
---|
| 643 | + double goalx = -20; |
---|
| 644 | + double goalz = -10; |
---|
107 | 645 | |
---|
108 | 646 | boolean followpath; |
---|
109 | 647 | |
---|
.. | .. |
---|
460 | 998 | testvect.set(from); |
---|
461 | 999 | testvect.sub(fromto.from); |
---|
462 | 1000 | |
---|
| 1001 | + testvect.y = 0; // PATCH |
---|
| 1002 | + |
---|
463 | 1003 | int factor = 1; |
---|
464 | 1004 | |
---|
465 | 1005 | //if (CameraPane.FAST) |
---|
.. | .. |
---|
501 | 1041 | |
---|
502 | 1042 | testvect.set(from); |
---|
503 | 1043 | testvect.sub(fromto.from); |
---|
| 1044 | + |
---|
| 1045 | + testvect.y = 0; // PATCH |
---|
504 | 1046 | |
---|
505 | 1047 | int factor = 1; |
---|
506 | 1048 | |
---|
.. | .. |
---|
705 | 1247 | // skip first node: translation |
---|
706 | 1248 | // Object3D b = input.get(0); |
---|
707 | 1249 | |
---|
708 | | - setPose(input, f, data.getBoneData(input._index), false); //, null); |
---|
| 1250 | + setPose(input, f, data.getBoneData(input._index)); //, false); //, null); |
---|
709 | 1251 | } |
---|
710 | 1252 | |
---|
711 | 1253 | //mocap.figure.Bone[] children = b.getChildren(); |
---|
.. | .. |
---|
921 | 1463 | //groundz += sourcenode.parent.toParent[3][2] - posz; |
---|
922 | 1464 | } |
---|
923 | 1465 | |
---|
924 | | - boolean footcontact = CameraPane.FOOTCONTACT; // false; |
---|
| 1466 | + boolean footcontact = false; // CameraPane.FOOTCONTACT; // false; |
---|
925 | 1467 | |
---|
926 | 1468 | if (footcontact && ground != -123456) |
---|
927 | 1469 | { |
---|
.. | .. |
---|
1220 | 1762 | src.x = 0; |
---|
1221 | 1763 | src.y = 0; |
---|
1222 | 1764 | src.z = 0; |
---|
| 1765 | + LA.xformPos(src, get(0).get(0).toParent, src); |
---|
1223 | 1766 | LA.xformPos(src, get(0).toParent, src); |
---|
1224 | 1767 | LA.xformPos(src, toParent, src); |
---|
1225 | 1768 | // LA.xformPos(src, rotsourcenode.toParent, src); |
---|
.. | .. |
---|
1563 | 2106 | toParent = LA.newMatrix(); |
---|
1564 | 2107 | fromParent = LA.newMatrix(); |
---|
1565 | 2108 | } |
---|
| 2109 | + |
---|
1566 | 2110 | LA.matConcat(toParent, rotsourcenode.toParent, toParent); |
---|
1567 | 2111 | LA.matInvert(toParent, fromParent); |
---|
1568 | 2112 | |
---|
.. | .. |
---|
1698 | 2242 | } |
---|
1699 | 2243 | |
---|
1700 | 2244 | if (!smoothed) |
---|
1701 | | - for (int i=4; --i>=0;) |
---|
| 2245 | + for (int i=0; --i>=0;) |
---|
1702 | 2246 | SmoothAnimData(); // much reduces shakiness |
---|
1703 | 2247 | |
---|
1704 | 2248 | smoothed = true; |
---|
.. | .. |
---|
1780 | 2324 | if (!live) // aout 2013 |
---|
1781 | 2325 | return; |
---|
1782 | 2326 | |
---|
1783 | | - cVector centroid = new cVector(); |
---|
1784 | | - cVector floor = new cVector(); |
---|
1785 | | - |
---|
1786 | | - Object3D sourcenode = GetFileRoot(); |
---|
| 2327 | + //bvh.skeleton.setPose(f, bvh.animation.getBoneData(bvh.skeleton.getIndex()), null); |
---|
| 2328 | + try |
---|
| 2329 | + { |
---|
| 2330 | + SetPose(GetSkeleton(), bvh.animation, f); |
---|
| 2331 | + SetCurrentBones(frame); |
---|
| 2332 | + } |
---|
| 2333 | + catch (Exception e) |
---|
| 2334 | + { |
---|
| 2335 | + e.printStackTrace(); |
---|
| 2336 | + } |
---|
1787 | 2337 | |
---|
1788 | | - boolean success; // = sourcenode.getCentroid(centroid); |
---|
| 2338 | + SetHipOrientation(); |
---|
| 2339 | + |
---|
| 2340 | + if (true) |
---|
| 2341 | + return; |
---|
| 2342 | + |
---|
| 2343 | + cVector centroid = new cVector(); |
---|
| 2344 | + cVector floor = new cVector(); |
---|
| 2345 | + |
---|
| 2346 | + Object3D sourcenode = GetFileRoot(); |
---|
| 2347 | + |
---|
| 2348 | + boolean success; // = sourcenode.getCentroid(centroid); |
---|
1789 | 2349 | // if (!success) |
---|
1790 | 2350 | // { |
---|
1791 | 2351 | // //assert(success); |
---|
.. | .. |
---|
1793 | 2353 | // System.out.println("No centroid for " + sourcenode); |
---|
1794 | 2354 | // } |
---|
1795 | 2355 | |
---|
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 | 2356 | if (sourcenode.parent == null && sourcenode.fileparent == null) |
---|
1807 | 2357 | { |
---|
1808 | 2358 | // No GFD |
---|
.. | .. |
---|
2050 | 2600 | * @param frame |
---|
2051 | 2601 | * Frame number |
---|
2052 | 2602 | */ |
---|
2053 | | - public void setPose(Object3D bone, int frame, float[] data, boolean fade) //, Point3d offsetTrans) |
---|
| 2603 | + public void setPose(Object3D bone, int frame, float[] data) //, boolean fade) //, Point3d offsetTrans) |
---|
2054 | 2604 | { |
---|
2055 | 2605 | if (!live) // aout 2013 |
---|
2056 | 2606 | return; |
---|
.. | .. |
---|
2058 | 2608 | cVector temp = new cVector(); |
---|
2059 | 2609 | cVector temp0 = new cVector(); |
---|
2060 | 2610 | double pos[] = new double[3]; |
---|
| 2611 | + double angleY = 0; |
---|
| 2612 | + double sinY = 0; |
---|
| 2613 | + double cosY = 0; |
---|
| 2614 | + |
---|
| 2615 | + if (false) // bone._isRoot && firsttimeafterload && frame > 0) |
---|
| 2616 | + { |
---|
| 2617 | + bone.get(0).GlobalTransformInv(); |
---|
| 2618 | + |
---|
| 2619 | + temp.x = bone.get(0).globalTransform[3][0]; |
---|
| 2620 | + temp.y = bone.get(0).globalTransform[3][1]; |
---|
| 2621 | + temp.z = bone.get(0).globalTransform[3][2]; |
---|
| 2622 | + |
---|
| 2623 | + pos[0] = temp.x; |
---|
| 2624 | + pos[1] = temp.y; |
---|
| 2625 | + pos[2] = temp.z; |
---|
| 2626 | + |
---|
| 2627 | + temp.x = 1; |
---|
| 2628 | + temp.y = 0; |
---|
| 2629 | + temp.z = 0; |
---|
| 2630 | + |
---|
| 2631 | + LA.xformDir(temp, bone.get(0).globalTransform, temp); |
---|
| 2632 | + |
---|
| 2633 | + sinY = temp.z; |
---|
| 2634 | + cosY = temp.x; |
---|
| 2635 | + |
---|
| 2636 | + angleY = Math.atan2(-sinY, cosY); |
---|
| 2637 | + } |
---|
2061 | 2638 | |
---|
2062 | 2639 | // Object3D obj = get(0); |
---|
2063 | 2640 | // Object3D gp = this.parent; |
---|
.. | .. |
---|
2188 | 2765 | //if (bone._rotationEnabled) |
---|
2189 | 2766 | if (//frame > 0 && |
---|
2190 | 2767 | !bone.skipmocap && |
---|
2191 | | - !bone.name.contains("head") && |
---|
| 2768 | + !bone.name.contains("head") // && |
---|
2192 | 2769 | // !bone.name.contains("rFoot") && |
---|
2193 | 2770 | // !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") |
---|
| 2771 | +// !bone.name.contains("Pinky") && |
---|
| 2772 | +// !bone.name.contains("Ring") && |
---|
| 2773 | +// !bone.name.contains("Mid") && |
---|
| 2774 | +// !bone.name.contains("Index") && |
---|
| 2775 | +// !bone.name.contains("Thumb") |
---|
2199 | 2776 | ) |
---|
2200 | 2777 | { |
---|
2201 | 2778 | //_rotTG.setTransform(_t1); |
---|
.. | .. |
---|
2228 | 2805 | // CROWD |
---|
2229 | 2806 | //cJ3D.GetTranslation(bone, _trans0); |
---|
2230 | 2807 | //_trans.add(_trans0); |
---|
2231 | | - _transTF.setIdentity(); |
---|
| 2808 | + //_transTF.setIdentity(); |
---|
| 2809 | + _transTF.set(_t1); |
---|
2232 | 2810 | _transTF.setTranslation(_trans); |
---|
2233 | 2811 | // System.err.println("Translate: " + _transTF); |
---|
2234 | 2812 | //_transTG.setTransform(_transTF); |
---|
2235 | | - cJ3D.ResetTransform(bone, _transTF, true); // translation node |
---|
| 2813 | + cJ3D.ResetTransform(bone.get(0), _transTF, true); // translation node |
---|
| 2814 | + //cJ3D.ResetTransform(bone, _transTF, true); // translation node |
---|
2236 | 2815 | } |
---|
2237 | 2816 | } |
---|
2238 | 2817 | |
---|
2239 | | - if (bone._isRoot && firsttimeafterload && frame > 0) |
---|
| 2818 | + if (false) // bone._isRoot && firsttimeafterload && frame > 0) |
---|
2240 | 2819 | { |
---|
2241 | 2820 | assert(bone == get(0)); |
---|
2242 | 2821 | |
---|
.. | .. |
---|
2252 | 2831 | // LA.matConcat(originmatrixinv, tempmatrixinv, fromParent); // ABC * (B'*C')^-1 |
---|
2253 | 2832 | // |
---|
2254 | 2833 | |
---|
2255 | | - Invariants(); |
---|
2256 | | - bone.Invariants(); |
---|
2257 | | - bone.get(0).Invariants(); |
---|
2258 | | - // if (origin == null) |
---|
2259 | | - // origin = null; |
---|
2260 | | - origin.Invariants(); |
---|
2261 | | - origin0.Invariants(); |
---|
| 2834 | + Invariants(); |
---|
| 2835 | + bone.Invariants(); |
---|
| 2836 | + bone.get(0).Invariants(); |
---|
| 2837 | + // if (origin == null) |
---|
| 2838 | + // origin = null; |
---|
| 2839 | + origin.Invariants(); |
---|
| 2840 | + origin0.Invariants(); |
---|
2262 | 2841 | |
---|
2263 | | - |
---|
2264 | | - LA.matConcat(bone.get(0).fromParent, bone.fromParent, tempmatrix); // B' * C' |
---|
2265 | | - LA.matConcat(origin.toParent, tempmatrix, toParent); |
---|
| 2842 | + |
---|
| 2843 | +//?? LA.matConcat(bone.get(0).fromParent, bone.fromParent, tempmatrix); // B' * C' |
---|
| 2844 | +//?? LA.matConcat(origin.toParent, tempmatrix, toParent); |
---|
2266 | 2845 | |
---|
2267 | 2846 | // matrixToEulerXYZ(toParent, temp); |
---|
2268 | 2847 | // matrixToEulerXYZ(bone.get(0).toParent, temp); |
---|
.. | .. |
---|
2296 | 2875 | // |
---|
2297 | 2876 | // mat4d.get(quat); |
---|
2298 | 2877 | |
---|
2299 | | - if (true) // hip correction |
---|
| 2878 | + if (false) // hip correction |
---|
2300 | 2879 | { |
---|
2301 | 2880 | _t2.setIdentity(); |
---|
2302 | 2881 | |
---|
.. | .. |
---|
2337 | 2916 | //????? LA.matConcat(bone.get(0).toParent, bone.toParent, tempmatrix); // B' * C' |
---|
2338 | 2917 | // LA.matConcat(origin.fromParent, tempmatrix, fromParent); |
---|
2339 | 2918 | |
---|
2340 | | - LA.matInvert(toParent, fromParent); |
---|
| 2919 | +//?? LA.matInvert(toParent, fromParent); |
---|
2341 | 2920 | |
---|
2342 | | - Invariants(); |
---|
2343 | | - bone.Invariants(); |
---|
2344 | | - bone.get(0).Invariants(); |
---|
2345 | | - origin.Invariants(); |
---|
2346 | | - origin0.Invariants(); |
---|
| 2921 | + Invariants(); |
---|
| 2922 | + bone.Invariants(); |
---|
| 2923 | + bone.get(0).Invariants(); |
---|
| 2924 | + origin.Invariants(); |
---|
| 2925 | + origin0.Invariants(); |
---|
2347 | 2926 | |
---|
2348 | 2927 | // LA.matInvert(fromParent, tempmatrix); |
---|
2349 | 2928 | // |
---|
.. | .. |
---|
2364 | 2943 | // temp.x = data[0]; |
---|
2365 | 2944 | // temp.y = data[1]; |
---|
2366 | 2945 | // temp.z = data[2]; |
---|
2367 | | - LA.xformPos(temp, origin0.toParent, temp0); |
---|
| 2946 | + LA.xformPos(temp, origin0.toParent, temp0); // NU |
---|
2368 | 2947 | |
---|
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 | | - |
---|
| 2948 | +// bone.get(0).GlobalTransformInv(); |
---|
| 2949 | +// |
---|
| 2950 | +// temp0.x = bone.get(0).globalTransform[3][0]; |
---|
| 2951 | +// temp0.y = bone.get(0).globalTransform[3][1]; |
---|
| 2952 | +// temp0.z = bone.get(0).globalTransform[3][2]; |
---|
| 2953 | +// |
---|
2375 | 2954 | // 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); |
---|
| 2955 | +//fromParent[3][0] = 0; |
---|
| 2956 | +//fromParent[3][1] = 0; |
---|
| 2957 | +//fromParent[3][2] = 0; |
---|
| 2958 | +//LA.matInvert(fromParent, toParent); |
---|
2380 | 2959 | |
---|
2381 | | - LA.xformPos(temp0, fromParent, temp); |
---|
| 2960 | + LA.xformPos(temp0, fromParent, temp); // NU |
---|
2382 | 2961 | //LA.xformPos(temp, bone.fromParent, temp); |
---|
2383 | 2962 | // float[] data; |
---|
2384 | 2963 | |
---|
2385 | | - pos[0] = temp.x; |
---|
2386 | | - pos[1] = temp.y; |
---|
2387 | | - pos[2] = temp.z; |
---|
| 2964 | +// pos[0] = temp.x; |
---|
| 2965 | +// pos[1] = temp.y; |
---|
| 2966 | +// pos[2] = temp.z; |
---|
| 2967 | +// |
---|
| 2968 | +// temp.x = 1; |
---|
| 2969 | +// temp.y = 0; |
---|
| 2970 | +// temp.z = 0; |
---|
| 2971 | +// |
---|
| 2972 | +// LA.xformDir(temp, bone.get(0).globalTransform, temp); |
---|
2388 | 2973 | |
---|
2389 | 2974 | // CameraPane.selectedpoint.toParent[3][0] = temp0.x; |
---|
2390 | 2975 | // CameraPane.selectedpoint.toParent[3][1] = temp0.y; |
---|
2391 | 2976 | // CameraPane.selectedpoint.toParent[3][2] = temp0.z; |
---|
2392 | 2977 | |
---|
2393 | | - int numframes = bvh.animation.getNumFrames(); |
---|
| 2978 | + int numframes = bvh.animation.getNumFrames(); |
---|
2394 | 2979 | |
---|
2395 | 2980 | int b = 0; |
---|
2396 | 2981 | { |
---|
.. | .. |
---|
2398 | 2983 | |
---|
2399 | 2984 | int dof = 6; /// data.length/numframes; |
---|
2400 | 2985 | |
---|
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 | | - } |
---|
| 2986 | + // july 2014 |
---|
| 2987 | + if (dof != data.length/numframes) |
---|
| 2988 | + { |
---|
| 2989 | + System.err.println("Bone #" + b + ": dof = " + dof + " ---> " + (data.length/numframes)); |
---|
| 2990 | + dof = data.length/numframes; |
---|
| 2991 | + } |
---|
2407 | 2992 | |
---|
2408 | 2993 | |
---|
2409 | 2994 | int theframe = 0; // baseframe; |
---|
.. | .. |
---|
2455 | 3040 | // } |
---|
2456 | 3041 | // } |
---|
2457 | 3042 | |
---|
2458 | | - data[f3 + i] += pos[i] - data[frame3 + i]; |
---|
| 3043 | + data[f3 + i] += /*pos[i]*/ - data[frame3 + i]; |
---|
2459 | 3044 | |
---|
2460 | 3045 | // if (f < 3) |
---|
2461 | 3046 | // { |
---|
2462 | 3047 | // System.out.print(data[f3 + i] + " "); |
---|
2463 | 3048 | // } |
---|
2464 | 3049 | } |
---|
2465 | | -// if (f < 3) |
---|
2466 | | -// { |
---|
2467 | | -// System.out.println(); |
---|
2468 | | -// } |
---|
| 3050 | + |
---|
| 3051 | + double t1 = data[f3 + 0]; |
---|
| 3052 | + double t2 = data[f3 + 2]; |
---|
| 3053 | + |
---|
| 3054 | + data[f3 + 0] = (float)(cosY*t1 - sinY*t2); |
---|
| 3055 | + data[f3 + 2] = (float)(sinY*t1 + cosY*t2); |
---|
| 3056 | + |
---|
| 3057 | + for (int i=3/*dof*/; --i>=0;) |
---|
| 3058 | + { |
---|
| 3059 | + data[f3 + i] += pos[i]; |
---|
| 3060 | + } |
---|
| 3061 | + |
---|
| 3062 | + data[f3 + 4] += angleY - data[frame3 + 4]; |
---|
2469 | 3063 | } |
---|
2470 | 3064 | } |
---|
2471 | 3065 | |
---|
.. | .. |
---|
2479 | 3073 | // temp.y = data[1]; |
---|
2480 | 3074 | // temp.z = data[2]; |
---|
2481 | 3075 | |
---|
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 | | - } |
---|
| 3076 | +// if (fade && currentbones != null && !CameraPane.fullreset) |
---|
| 3077 | +// { |
---|
| 3078 | +// Fade(); |
---|
| 3079 | +// } |
---|
2655 | 3080 | } |
---|
2656 | | - |
---|
| 3081 | + |
---|
2657 | 3082 | if (false) // doesn't change anything bone._isRoot) |
---|
2658 | 3083 | { |
---|
2659 | 3084 | // Reset orientation |
---|
2660 | 3085 | _t2.setIdentity(); |
---|
2661 | | - |
---|
| 3086 | + |
---|
2662 | 3087 | double tx = bone.toParent[3][0]; |
---|
2663 | 3088 | double ty = bone.toParent[3][1]; |
---|
2664 | 3089 | double tz = bone.toParent[3][2]; |
---|
.. | .. |
---|
2667 | 3092 | temp.y = 0; |
---|
2668 | 3093 | temp.z = 0; |
---|
2669 | 3094 | LA.xformDir(temp, bone.toParent, temp); |
---|
2670 | | - |
---|
| 3095 | + |
---|
2671 | 3096 | double angle = Math.atan2(-temp.z, temp.x); |
---|
2672 | | - |
---|
| 3097 | + |
---|
2673 | 3098 | _t2.rotY(angle); |
---|
2674 | 3099 | // _t1.setIdentity(); |
---|
2675 | 3100 | // _t1.rotX(temp.x); |
---|
.. | .. |
---|
2682 | 3107 | // _t1.setIdentity(); |
---|
2683 | 3108 | // _t1.rotZ(temp.z); |
---|
2684 | 3109 | // _t2.mul(_t1); |
---|
2685 | | - |
---|
| 3110 | + |
---|
2686 | 3111 | cJ3D.ResetTransform(bone, _t2, false); |
---|
2687 | | - |
---|
| 3112 | + |
---|
2688 | 3113 | bone.toParent[3][0] = tx; |
---|
2689 | 3114 | bone.toParent[3][1] = ty; |
---|
2690 | 3115 | bone.toParent[3][2] = tz; |
---|
2691 | 3116 | } |
---|
2692 | 3117 | } |
---|
2693 | 3118 | |
---|
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 | | - } |
---|
| 3119 | + // SetCurrentBones(frame); |
---|
2731 | 3120 | } |
---|
2732 | 3121 | } |
---|
2733 | 3122 | |
---|
2734 | | - static int offset = 1; // 5; // 10; // 5; // 100; // skip initial "T" |
---|
| 3123 | + // skip initial "T" |
---|
| 3124 | + static int offset = 1; // 5; // 10; // 5; // 100; |
---|
2735 | 3125 | |
---|
2736 | 3126 | void ReadBVH() |
---|
2737 | 3127 | { |
---|
.. | .. |
---|
2760 | 3150 | |
---|
2761 | 3151 | void Reset() |
---|
2762 | 3152 | { |
---|
2763 | | - if (fullname != null) |
---|
2764 | | - ReadBVH(); |
---|
| 3153 | +// if (fullname != null) |
---|
| 3154 | +// ReadBVH(); |
---|
2765 | 3155 | |
---|
2766 | 3156 | Object3D hip = get(0); |
---|
2767 | 3157 | |
---|
2768 | 3158 | // assert(obj.name.equals("hip")); |
---|
2769 | 3159 | |
---|
2770 | | - Object3D rot = hip.get(0); |
---|
| 3160 | + //Object3D rot = hip.get(0); |
---|
2771 | 3161 | |
---|
2772 | 3162 | // assert(obj.name == null); // .equals("hip#")); |
---|
2773 | 3163 | |
---|
.. | .. |
---|
2777 | 3167 | hip.fromParent = LA.newMatrix(); |
---|
2778 | 3168 | } |
---|
2779 | 3169 | |
---|
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; |
---|
| 3170 | + //hip.toParent[3][0] = hip.toParent[3][1] = hip.toParent[3][2] = 0; |
---|
| 3171 | + //hip.fromParent[3][0] = hip.fromParent[3][1] = hip.fromParent[3][2] = 0; |
---|
2782 | 3172 | |
---|
2783 | 3173 | if (toParent == null) |
---|
2784 | 3174 | { |
---|
.. | .. |
---|
2790 | 3180 | LA.matIdentity(fromParent); |
---|
2791 | 3181 | // LA.matIdentity(hip.toParent); |
---|
2792 | 3182 | // 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); |
---|
| 3183 | +// if (rot.toParent == null) |
---|
| 3184 | +// { |
---|
| 3185 | +// // june 2014 |
---|
| 3186 | +// rot.toParent = LA.newMatrix(); |
---|
| 3187 | +// rot.fromParent = LA.newMatrix(); |
---|
| 3188 | +// } |
---|
| 3189 | +// LA.matIdentity(rot.toParent); |
---|
| 3190 | +// LA.matIdentity(rot.fromParent); |
---|
2801 | 3191 | |
---|
2802 | 3192 | // july 2014 |
---|
2803 | | - goalx = goalz = 0; |
---|
| 3193 | +// goalx = goalz = 0; |
---|
2804 | 3194 | targetx = targetz = 0; |
---|
2805 | 3195 | |
---|
2806 | | - SetPositionDelta(true, true, true, false); |
---|
| 3196 | + //SetPositionDelta(true, true, true, false); |
---|
| 3197 | +// LoadData(); |
---|
| 3198 | +// Rewind(); |
---|
2807 | 3199 | |
---|
2808 | 3200 | baseframe = frame = 0; // T pose. No offset. |
---|
2809 | 3201 | |
---|
2810 | 3202 | // aout 2013 endframe = 0; // june 2013 |
---|
2811 | 3203 | |
---|
| 3204 | + //ResetZero(); |
---|
2812 | 3205 | setPose(frame); |
---|
2813 | 3206 | } |
---|
2814 | 3207 | |
---|
.. | .. |
---|
2840 | 3233 | baseframe += step; |
---|
2841 | 3234 | |
---|
2842 | 3235 | //frame = baseframe; |
---|
2843 | | - frame += step; |
---|
| 3236 | + //frame += step; |
---|
2844 | 3237 | |
---|
2845 | 3238 | // if (frame != baseframe) |
---|
2846 | 3239 | // { |
---|
.. | .. |
---|
2854 | 3247 | if (lastframetest == 0) |
---|
2855 | 3248 | lastframetest = bvh.animation.getNumFrames(); |
---|
2856 | 3249 | |
---|
| 3250 | + // WARNING: RESET DESTROYS EVERYTHING |
---|
2857 | 3251 | if (baseframe >= lastframetest) // july 2013 // - GetFirstFrame()) |
---|
2858 | 3252 | { |
---|
2859 | 3253 | System.out.println("MOCAP reset: " + this.GetFileRoot() + |
---|
.. | .. |
---|
2879 | 3273 | { |
---|
2880 | 3274 | bvh = ((Mocap)support.get(mocapsupport++ % support.Size())).bvh; |
---|
2881 | 3275 | |
---|
2882 | | - SetPositionDelta(false, true, true, true); |
---|
| 3276 | + // SetPositionDelta(false, true, true, true); |
---|
| 3277 | + LoadData(); |
---|
| 3278 | + Rewind(); |
---|
| 3279 | + Fade(); |
---|
2883 | 3280 | } |
---|
2884 | 3281 | catch (Exception e) |
---|
2885 | 3282 | { |
---|
.. | .. |
---|
2888 | 3285 | } |
---|
2889 | 3286 | } |
---|
2890 | 3287 | } |
---|
| 3288 | + |
---|
| 3289 | + frame = GetFirstFrame(); |
---|
2891 | 3290 | } |
---|
| 3291 | + else |
---|
| 3292 | + frame += step; |
---|
2892 | 3293 | |
---|
2893 | 3294 | //SetPositionDelta(false); |
---|
2894 | 3295 | |
---|
2895 | | - if (frame >= bvh.animation.getNumFrames()) |
---|
2896 | | - //baseframe = |
---|
2897 | | - frame = GetFirstFrame(); // 0; // offset; // initial point |
---|
| 3296 | +// if (frame >= bvh.animation.getNumFrames()) |
---|
| 3297 | +// //baseframe = |
---|
| 3298 | +// frame = GetFirstFrame(); // 0; // offset; // initial point |
---|
2898 | 3299 | |
---|
2899 | 3300 | //System.err.println("frame = " + frame); |
---|
2900 | 3301 | if (lastframe != 0) |
---|
.. | .. |
---|
3192 | 3593 | //static |
---|
3193 | 3594 | transient |
---|
3194 | 3595 | double[] currentbones; |
---|
| 3596 | + double[] currenthip; |
---|
| 3597 | + |
---|
3195 | 3598 | transient boolean inbetween; |
---|
3196 | 3599 | |
---|
3197 | 3600 | void SetPositionDelta(boolean reset, boolean rewind, boolean load, boolean fade) |
---|
.. | .. |
---|
3202 | 3605 | //assert(dim == numframes*6); |
---|
3203 | 3606 | |
---|
3204 | 3607 | 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 | | - } |
---|
| 3608 | + { |
---|
| 3609 | + LoadData(); |
---|
| 3610 | + } |
---|
3237 | 3611 | |
---|
3238 | 3612 | // assert(thedata[0] == 0); |
---|
3239 | 3613 | // assert(thedata[1] == 0); |
---|
.. | .. |
---|
3243 | 3617 | // assert(thedata[7] == 0); |
---|
3244 | 3618 | // assert(thedata[8] == 0); |
---|
3245 | 3619 | |
---|
3246 | | - Object3D obj = get(0); |
---|
| 3620 | + Object3D hip = get(0); |
---|
3247 | 3621 | |
---|
3248 | 3622 | // assert(obj.name.equals("hip")); |
---|
3249 | 3623 | |
---|
3250 | | - Object3D rot = obj.get(0); |
---|
| 3624 | + Object3D rot = hip.get(0); |
---|
3251 | 3625 | |
---|
3252 | 3626 | // if (toParent == null) |
---|
3253 | 3627 | // { |
---|
.. | .. |
---|
3259 | 3633 | // // assert(obj.name == null); // .equals("hip#")); |
---|
3260 | 3634 | |
---|
3261 | 3635 | Invariants(); |
---|
3262 | | - obj.Invariants(); |
---|
| 3636 | + hip.Invariants(); |
---|
3263 | 3637 | rot.Invariants(); |
---|
3264 | 3638 | |
---|
3265 | 3639 | if (origin == null) |
---|
.. | .. |
---|
3280 | 3654 | fromParent = LA.newMatrix(); |
---|
3281 | 3655 | } |
---|
3282 | 3656 | |
---|
3283 | | - if (obj.toParent == null) // june 2014 |
---|
| 3657 | + if (hip.toParent == null) // june 2014 |
---|
3284 | 3658 | { |
---|
3285 | | - obj.toParent = LA.newMatrix(); |
---|
3286 | | - obj.fromParent = LA.newMatrix(); |
---|
| 3659 | + hip.toParent = LA.newMatrix(); |
---|
| 3660 | + hip.fromParent = LA.newMatrix(); |
---|
3287 | 3661 | } |
---|
3288 | 3662 | |
---|
3289 | | - LA.matConcat(toParent, obj.toParent, origin0.toParent); // AB |
---|
| 3663 | + LA.matConcat(toParent, hip.toParent, origin0.toParent); // AB |
---|
3290 | 3664 | Object3D gp = this.parent; |
---|
3291 | 3665 | this.parent = null; |
---|
3292 | | - obj.GlobalTransformInv(); |
---|
| 3666 | + hip.GlobalTransformInv(); |
---|
3293 | 3667 | this.parent = gp; |
---|
3294 | 3668 | |
---|
3295 | 3669 | if (rot.toParent == null) |
---|
.. | .. |
---|
3312 | 3686 | LA.matInvert(origin.toParent, origin.fromParent); |
---|
3313 | 3687 | |
---|
3314 | 3688 | Invariants(); |
---|
3315 | | - obj.Invariants(); |
---|
| 3689 | + hip.Invariants(); |
---|
3316 | 3690 | rot.Invariants(); |
---|
3317 | 3691 | origin.Invariants(); |
---|
3318 | 3692 | origin0.Invariants(); |
---|
3319 | 3693 | |
---|
3320 | | - firsttimeafterload = true; |
---|
| 3694 | + firsttimeafterload = false; // true; |
---|
3321 | 3695 | |
---|
3322 | 3696 | if (rewind) |
---|
3323 | 3697 | Rewind(); |
---|
3324 | 3698 | |
---|
3325 | | - setPose(obj, frame, bvh.animation.getBoneData(obj._index), fade); |
---|
| 3699 | + setPose(hip, frame, bvh.animation.getBoneData(hip._index)); //, fade); |
---|
3326 | 3700 | |
---|
3327 | | - if (true) |
---|
3328 | | - return; |
---|
| 3701 | + if (true) |
---|
| 3702 | + return; |
---|
3329 | 3703 | |
---|
3330 | 3704 | double pos[] = new double[6]; |
---|
3331 | 3705 | |
---|
3332 | 3706 | if (!reset) |
---|
3333 | 3707 | { |
---|
3334 | | - assert(obj.tx == obj.toParent[3][0]); |
---|
3335 | | - assert(obj.ty == obj.toParent[3][1]); |
---|
3336 | | - assert(obj.tz == obj.toParent[3][2]); |
---|
| 3708 | + assert(hip.tx == hip.toParent[3][0]); |
---|
| 3709 | + assert(hip.ty == hip.toParent[3][1]); |
---|
| 3710 | + assert(hip.tz == hip.toParent[3][2]); |
---|
3337 | 3711 | |
---|
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; |
---|
| 3712 | + pos[0] = hip.tx; // obj.toParent[3][0]; |
---|
| 3713 | + pos[1] = hip.ty; // obj.toParent[3][1]; |
---|
| 3714 | + pos[2] = hip.tz; // obj.toParent[3][2]; |
---|
| 3715 | + pos[3] = hip.rz; |
---|
| 3716 | + pos[4] = hip.ry; |
---|
| 3717 | + pos[5] = hip.rx; |
---|
3344 | 3718 | } |
---|
3345 | 3719 | |
---|
3346 | 3720 | 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]; |
---|
| 3721 | + temp.x = hip.globalTransform[3][0]; |
---|
| 3722 | + temp.y = hip.globalTransform[3][1]; |
---|
| 3723 | + temp.z = hip.globalTransform[3][2]; |
---|
3350 | 3724 | // LA.xformPos(temp, origin0.toParent, temp); |
---|
3351 | 3725 | // System.err.println("POS0 = " + temp.x + ", " + temp.y + ", " + temp.z + ";"); |
---|
3352 | 3726 | |
---|
.. | .. |
---|
3430 | 3804 | } |
---|
3431 | 3805 | |
---|
3432 | 3806 | // Rewind(); |
---|
3433 | | - setPose(obj, frame, bvh.animation.getBoneData(obj._index), true); |
---|
| 3807 | + setPose(hip, frame, bvh.animation.getBoneData(hip._index)); // , true); |
---|
3434 | 3808 | } |
---|
3435 | 3809 | |
---|
3436 | 3810 | void Rewind() |
---|