.. | .. |
---|
29 | 29 | |
---|
30 | 30 | void Fade() |
---|
31 | 31 | { |
---|
32 | | - if (true) // currentbones == null || CameraPane.fullreset) |
---|
| 32 | + if (currentbones == null || CameraPane.fullreset) |
---|
33 | 33 | return; |
---|
34 | 34 | |
---|
35 | 35 | cVector temp = new cVector(); |
---|
.. | .. |
---|
107 | 107 | //data[f3 + i] += pos[i] - data[frame3 + i]; |
---|
108 | 108 | // data[f3 + i] = k*data[f3+i] + (1-k)* |
---|
109 | 109 | // currentbones[boneframe3 + i-end]; |
---|
110 | | - data[f3 + i] = (float)CurveAngle(data[f3+i], currenthip[i], 1-k); |
---|
| 110 | +// data[f3 + i] = (float)CurveAngle(data[f3+i], currenthip[i], 1-k); |
---|
111 | 111 | } |
---|
112 | 112 | |
---|
113 | 113 | // TODO: translation |
---|
.. | .. |
---|
225 | 225 | // before resetting the mocap data. |
---|
226 | 226 | void SetGlobalTransform() |
---|
227 | 227 | { |
---|
228 | | - SetCurrentBones(frame); |
---|
| 228 | + //SetCurrentBones(frame); |
---|
229 | 229 | |
---|
230 | 230 | cVector temp = new cVector(); |
---|
231 | 231 | cVector pos = new cVector(); |
---|
.. | .. |
---|
235 | 235 | double angleYhip = 0; |
---|
236 | 236 | |
---|
237 | 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 | + } |
---|
238 | 244 | |
---|
239 | 245 | LA.matConcat(toParent, hip.get(0).toParent, matrix); |
---|
240 | 246 | poship.x = matrix[3][0]; |
---|
.. | .. |
---|
277 | 283 | poship.x = hip.get(0).toParent[3][0]; |
---|
278 | 284 | poship.y = hip.get(0).toParent[3][1]; |
---|
279 | 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); |
---|
280 | 294 | |
---|
281 | | - // AT*AR = A'T*BT*A'R*BR |
---|
282 | | - // |
---|
283 | | - LA.matInvert(hip.get(0).toParent, matrix); |
---|
| 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); |
---|
284 | 301 | |
---|
285 | 302 | //LA.matIdentity(matrix); |
---|
286 | 303 | //LA.matTranslate(matrix, -poship.x, -poship.y, -poship.z); |
---|
287 | 304 | |
---|
288 | 305 | LA.matConcat(toParent, matrix, toParent); |
---|
289 | 306 | |
---|
290 | | -// poship.x = hip.get(0).toParent[3][0]; |
---|
291 | | -// poship.y = hip.get(0).toParent[3][1]; |
---|
292 | | -// poship.z = hip.get(0).toParent[3][2]; |
---|
293 | | -// |
---|
294 | | -// temp.x = 1; |
---|
295 | | -// temp.y = 0; |
---|
296 | | -// temp.z = 0; |
---|
297 | | -// |
---|
298 | | -// LA.xformDir(temp, hip.get(0).toParent, temp); |
---|
299 | | -// |
---|
300 | | -// angleYhip = Math.atan2(-temp.z, temp.x); |
---|
301 | | - |
---|
| 307 | + |
---|
302 | 308 | LA.matConcat(toParent, hip.get(0).toParent, matrix); |
---|
303 | 309 | pos.x = hip.get(0).toParent[3][0]; |
---|
304 | 310 | pos.y = hip.get(0).toParent[3][1]; |
---|
.. | .. |
---|
470 | 476 | currenthip[i] = data[frame3 + i]; |
---|
471 | 477 | } |
---|
472 | 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 | + } |
---|
473 | 567 | |
---|
474 | 568 | void WriteTo(java.io.Writer writer) throws Exception |
---|
475 | 569 | { |
---|
.. | .. |
---|
546 | 640 | double targetx; |
---|
547 | 641 | double targetz; |
---|
548 | 642 | |
---|
549 | | - double goalx; |
---|
550 | | - double goalz; |
---|
| 643 | + double goalx = -20; |
---|
| 644 | + double goalz = -10; |
---|
551 | 645 | |
---|
552 | 646 | boolean followpath; |
---|
553 | 647 | |
---|
.. | .. |
---|
904 | 998 | testvect.set(from); |
---|
905 | 999 | testvect.sub(fromto.from); |
---|
906 | 1000 | |
---|
| 1001 | + testvect.y = 0; // PATCH |
---|
| 1002 | + |
---|
907 | 1003 | int factor = 1; |
---|
908 | 1004 | |
---|
909 | 1005 | //if (CameraPane.FAST) |
---|
.. | .. |
---|
945 | 1041 | |
---|
946 | 1042 | testvect.set(from); |
---|
947 | 1043 | testvect.sub(fromto.from); |
---|
| 1044 | + |
---|
| 1045 | + testvect.y = 0; // PATCH |
---|
948 | 1046 | |
---|
949 | 1047 | int factor = 1; |
---|
950 | 1048 | |
---|
.. | .. |
---|
2237 | 2335 | e.printStackTrace(); |
---|
2238 | 2336 | } |
---|
2239 | 2337 | |
---|
| 2338 | + SetHipOrientation(); |
---|
| 2339 | + |
---|
2240 | 2340 | if (true) |
---|
2241 | 2341 | return; |
---|
2242 | 2342 | |
---|
.. | .. |
---|
2664 | 2764 | // set rotation |
---|
2665 | 2765 | //if (bone._rotationEnabled) |
---|
2666 | 2766 | if (//frame > 0 && |
---|
2667 | | - !bone.skipmocap //&& |
---|
2668 | | - //!bone.name.contains("head") && |
---|
| 2767 | + !bone.skipmocap && |
---|
| 2768 | + !bone.name.contains("head") // && |
---|
2669 | 2769 | // !bone.name.contains("rFoot") && |
---|
2670 | 2770 | // !bone.name.contains("lFoot") && |
---|
2671 | 2771 | // !bone.name.contains("Pinky") && |
---|
.. | .. |
---|
3020 | 3120 | } |
---|
3021 | 3121 | } |
---|
3022 | 3122 | |
---|
3023 | | - static int offset = 1; // 5; // 10; // 5; // 100; // skip initial "T" |
---|
| 3123 | + // skip initial "T" |
---|
| 3124 | + static int offset = 1; // 5; // 10; // 5; // 100; |
---|
3024 | 3125 | |
---|
3025 | 3126 | void ReadBVH() |
---|
3026 | 3127 | { |
---|
.. | .. |
---|
3049 | 3150 | |
---|
3050 | 3151 | void Reset() |
---|
3051 | 3152 | { |
---|
3052 | | - if (fullname != null) |
---|
3053 | | - ReadBVH(); |
---|
| 3153 | +// if (fullname != null) |
---|
| 3154 | +// ReadBVH(); |
---|
3054 | 3155 | |
---|
3055 | 3156 | Object3D hip = get(0); |
---|
3056 | 3157 | |
---|
.. | .. |
---|
3089 | 3190 | // LA.matIdentity(rot.fromParent); |
---|
3090 | 3191 | |
---|
3091 | 3192 | // july 2014 |
---|
3092 | | - goalx = goalz = 0; |
---|
| 3193 | +// goalx = goalz = 0; |
---|
3093 | 3194 | targetx = targetz = 0; |
---|
3094 | 3195 | |
---|
3095 | 3196 | //SetPositionDelta(true, true, true, false); |
---|
.. | .. |
---|
3132 | 3233 | baseframe += step; |
---|
3133 | 3234 | |
---|
3134 | 3235 | //frame = baseframe; |
---|
3135 | | - frame += step; |
---|
| 3236 | + //frame += step; |
---|
3136 | 3237 | |
---|
3137 | 3238 | // if (frame != baseframe) |
---|
3138 | 3239 | // { |
---|
.. | .. |
---|
3184 | 3285 | } |
---|
3185 | 3286 | } |
---|
3186 | 3287 | } |
---|
| 3288 | + |
---|
| 3289 | + frame = GetFirstFrame(); |
---|
3187 | 3290 | } |
---|
| 3291 | + else |
---|
| 3292 | + frame += step; |
---|
3188 | 3293 | |
---|
3189 | 3294 | //SetPositionDelta(false); |
---|
3190 | 3295 | |
---|
3191 | | - if (frame >= bvh.animation.getNumFrames()) |
---|
3192 | | - //baseframe = |
---|
3193 | | - frame = GetFirstFrame(); // 0; // offset; // initial point |
---|
| 3296 | +// if (frame >= bvh.animation.getNumFrames()) |
---|
| 3297 | +// //baseframe = |
---|
| 3298 | +// frame = GetFirstFrame(); // 0; // offset; // initial point |
---|
3194 | 3299 | |
---|
3195 | 3300 | //System.err.println("frame = " + frame); |
---|
3196 | 3301 | if (lastframe != 0) |
---|