| .. | .. |
|---|
| 283 | 283 | poship.x = hip.get(0).toParent[3][0]; |
|---|
| 284 | 284 | poship.y = hip.get(0).toParent[3][1]; |
|---|
| 285 | 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); |
|---|
| 286 | 294 | |
|---|
| 287 | | - // AT*AR = A'T*BT*A'R*BR |
|---|
| 288 | | - // |
|---|
| 289 | | - 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); |
|---|
| 290 | 301 | |
|---|
| 291 | 302 | //LA.matIdentity(matrix); |
|---|
| 292 | 303 | //LA.matTranslate(matrix, -poship.x, -poship.y, -poship.z); |
|---|
| 293 | 304 | |
|---|
| 294 | 305 | LA.matConcat(toParent, matrix, toParent); |
|---|
| 295 | 306 | |
|---|
| 296 | | -// poship.x = hip.get(0).toParent[3][0]; |
|---|
| 297 | | -// poship.y = hip.get(0).toParent[3][1]; |
|---|
| 298 | | -// poship.z = hip.get(0).toParent[3][2]; |
|---|
| 299 | | -// |
|---|
| 300 | | -// temp.x = 1; |
|---|
| 301 | | -// temp.y = 0; |
|---|
| 302 | | -// temp.z = 0; |
|---|
| 303 | | -// |
|---|
| 304 | | -// LA.xformDir(temp, hip.get(0).toParent, temp); |
|---|
| 305 | | -// |
|---|
| 306 | | -// angleYhip = Math.atan2(-temp.z, temp.x); |
|---|
| 307 | | - |
|---|
| 307 | + |
|---|
| 308 | 308 | LA.matConcat(toParent, hip.get(0).toParent, matrix); |
|---|
| 309 | 309 | pos.x = hip.get(0).toParent[3][0]; |
|---|
| 310 | 310 | pos.y = hip.get(0).toParent[3][1]; |
|---|
| .. | .. |
|---|
| 476 | 476 | currenthip[i] = data[frame3 + i]; |
|---|
| 477 | 477 | } |
|---|
| 478 | 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 | + } |
|---|
| 479 | 567 | |
|---|
| 480 | 568 | void WriteTo(java.io.Writer writer) throws Exception |
|---|
| 481 | 569 | { |
|---|
| .. | .. |
|---|
| 552 | 640 | double targetx; |
|---|
| 553 | 641 | double targetz; |
|---|
| 554 | 642 | |
|---|
| 555 | | - double goalx; |
|---|
| 556 | | - double goalz; |
|---|
| 643 | + double goalx = -20; |
|---|
| 644 | + double goalz = -10; |
|---|
| 557 | 645 | |
|---|
| 558 | 646 | boolean followpath; |
|---|
| 559 | 647 | |
|---|
| .. | .. |
|---|
| 910 | 998 | testvect.set(from); |
|---|
| 911 | 999 | testvect.sub(fromto.from); |
|---|
| 912 | 1000 | |
|---|
| 1001 | + testvect.y = 0; // PATCH |
|---|
| 1002 | + |
|---|
| 913 | 1003 | int factor = 1; |
|---|
| 914 | 1004 | |
|---|
| 915 | 1005 | //if (CameraPane.FAST) |
|---|
| .. | .. |
|---|
| 951 | 1041 | |
|---|
| 952 | 1042 | testvect.set(from); |
|---|
| 953 | 1043 | testvect.sub(fromto.from); |
|---|
| 1044 | + |
|---|
| 1045 | + testvect.y = 0; // PATCH |
|---|
| 954 | 1046 | |
|---|
| 955 | 1047 | int factor = 1; |
|---|
| 956 | 1048 | |
|---|
| .. | .. |
|---|
| 2243 | 2335 | e.printStackTrace(); |
|---|
| 2244 | 2336 | } |
|---|
| 2245 | 2337 | |
|---|
| 2338 | + SetHipOrientation(); |
|---|
| 2339 | + |
|---|
| 2246 | 2340 | if (true) |
|---|
| 2247 | 2341 | return; |
|---|
| 2248 | 2342 | |
|---|
| .. | .. |
|---|
| 2670 | 2764 | // set rotation |
|---|
| 2671 | 2765 | //if (bone._rotationEnabled) |
|---|
| 2672 | 2766 | if (//frame > 0 && |
|---|
| 2673 | | - !bone.skipmocap //&& |
|---|
| 2674 | | - //!bone.name.contains("head") && |
|---|
| 2767 | + !bone.skipmocap && |
|---|
| 2768 | + !bone.name.contains("head") // && |
|---|
| 2675 | 2769 | // !bone.name.contains("rFoot") && |
|---|
| 2676 | 2770 | // !bone.name.contains("lFoot") && |
|---|
| 2677 | 2771 | // !bone.name.contains("Pinky") && |
|---|
| .. | .. |
|---|
| 3096 | 3190 | // LA.matIdentity(rot.fromParent); |
|---|
| 3097 | 3191 | |
|---|
| 3098 | 3192 | // july 2014 |
|---|
| 3099 | | - goalx = goalz = 0; |
|---|
| 3193 | +// goalx = goalz = 0; |
|---|
| 3100 | 3194 | targetx = targetz = 0; |
|---|
| 3101 | 3195 | |
|---|
| 3102 | 3196 | //SetPositionDelta(true, true, true, false); |
|---|