.. | .. |
---|
261 | 261 | |
---|
262 | 262 | // LA.matConcat(toParent, hip.get(0).toParent, toParent); |
---|
263 | 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; |
---|
| 264 | + CameraPane.debugpointG.toParent[3][0] = poship.x; |
---|
| 265 | + CameraPane.debugpointG.toParent[3][1] = poship.y; |
---|
| 266 | + CameraPane.debugpointG.toParent[3][2] = poship.z; |
---|
267 | 267 | |
---|
268 | 268 | LA.matInvert(toParent, fromParent); |
---|
269 | 269 | |
---|
.. | .. |
---|
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]; |
---|
.. | .. |
---|
324 | 324 | // LA.matYRotate(toParent, angleY - angleYhip); |
---|
325 | 325 | // LA.matTranslate(toParent, pos.x - poship.x, pos.y - poship.y, pos.z - poship.z); |
---|
326 | 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; |
---|
| 327 | + CameraPane.debugpointP.toParent[3][0] = pos.x; |
---|
| 328 | + CameraPane.debugpointP.toParent[3][1] = pos.y; |
---|
| 329 | + CameraPane.debugpointP.toParent[3][2] = pos.z; |
---|
330 | 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; |
---|
| 331 | + CameraPane.debugpointC.toParent[3][0] = poship.x; |
---|
| 332 | + CameraPane.debugpointC.toParent[3][1] = poship.y; |
---|
| 333 | + CameraPane.debugpointC.toParent[3][2] = poship.z; |
---|
334 | 334 | |
---|
335 | 335 | poship.x = toParent[3][0]; |
---|
336 | 336 | poship.y = toParent[3][1]; |
---|
337 | 337 | poship.z = toParent[3][2]; |
---|
338 | 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; |
---|
| 339 | + CameraPane.debugpointR.toParent[3][0] = poship.x; |
---|
| 340 | + CameraPane.debugpointR.toParent[3][1] = poship.y; |
---|
| 341 | + CameraPane.debugpointR.toParent[3][2] = poship.z; |
---|
342 | 342 | |
---|
343 | 343 | LA.matInvert(toParent, fromParent); |
---|
344 | 344 | } |
---|
.. | .. |
---|
476 | 476 | currenthip[i] = data[frame3 + i]; |
---|
477 | 477 | } |
---|
478 | 478 | } |
---|
| 479 | + |
---|
| 480 | + static cVector centroid = new cVector(); |
---|
| 481 | + static cVector mocaporigin = new cVector(); |
---|
| 482 | + |
---|
| 483 | + void SetHipOrientation() |
---|
| 484 | + { |
---|
| 485 | + Object3D hip = get(0); |
---|
| 486 | + |
---|
| 487 | + if (toParent == null) |
---|
| 488 | + { |
---|
| 489 | + toParent = LA.newMatrix(); |
---|
| 490 | + fromParent = LA.newMatrix(); |
---|
| 491 | + } |
---|
| 492 | + |
---|
| 493 | + LA.matConcat(toParent, hip.get(0).toParent, matrix); |
---|
| 494 | + |
---|
| 495 | + mocaporigin.x = matrix[3][0]; |
---|
| 496 | + mocaporigin.y = matrix[3][1]; |
---|
| 497 | + mocaporigin.z = matrix[3][2]; |
---|
| 498 | + |
---|
| 499 | + centroid.x = matrix[3][0]; |
---|
| 500 | + centroid.y = matrix[3][1]; |
---|
| 501 | + centroid.z = matrix[3][2]; |
---|
| 502 | +// this.getCentroid(centroid, true); |
---|
| 503 | + |
---|
| 504 | + CameraPane.debugpointG.name = ""; |
---|
| 505 | + CameraPane.debugpointG.toParent[3][0] = mocaporigin.x; |
---|
| 506 | + CameraPane.debugpointG.toParent[3][1] = mocaporigin.y; |
---|
| 507 | + CameraPane.debugpointG.toParent[3][2] = mocaporigin.z; |
---|
| 508 | + |
---|
| 509 | + CameraPane.debugpointP.name = ""; |
---|
| 510 | + CameraPane.debugpointP.toParent[3][0] = centroid.x; |
---|
| 511 | + CameraPane.debugpointP.toParent[3][1] = centroid.y; |
---|
| 512 | + CameraPane.debugpointP.toParent[3][2] = centroid.z; |
---|
| 513 | + |
---|
| 514 | + cVector goal = GetGoal(centroid); |
---|
| 515 | + if (goal != null) |
---|
| 516 | + { |
---|
| 517 | + System.err.println("GOAL change (" + this + "): " + goal + " (was " + goalposx + ", " + goalposz + ")"); |
---|
| 518 | + |
---|
| 519 | + goalposx = goal.x; |
---|
| 520 | + goalposz = goal.z; |
---|
| 521 | + targetdirx = targetdirz = 0; |
---|
| 522 | + } |
---|
| 523 | + |
---|
| 524 | + if (goalposx == 0 && goalposz == 0) |
---|
| 525 | + { |
---|
| 526 | + // No target |
---|
| 527 | + if (ScriptNode.speaker != null) |
---|
| 528 | + { |
---|
| 529 | + Object3D sourcenode = GetFileRoot(); |
---|
| 530 | + Object3D speakernode = ScriptNode.speaker.GetFileRoot(); |
---|
| 531 | + |
---|
| 532 | + //System.err.println("speaker is " + speakernode + "; last was " + ScriptNode.lastspeaker); |
---|
| 533 | + |
---|
| 534 | + Object3D speaker = ScriptNode.speaker; |
---|
| 535 | + |
---|
| 536 | + if (speakernode == sourcenode) |
---|
| 537 | + { |
---|
| 538 | + if (ScriptNode.lastspeaker != null) |
---|
| 539 | + { |
---|
| 540 | + speakernode = ScriptNode.lastspeaker.GetFileRoot(); |
---|
| 541 | + speaker = ScriptNode.lastspeaker; |
---|
| 542 | + } |
---|
| 543 | + else |
---|
| 544 | + return; |
---|
| 545 | + } |
---|
| 546 | + |
---|
| 547 | + cVector dst = new cVector(); |
---|
| 548 | + |
---|
| 549 | + boolean success = speakernode.getCentroid(dst); // , true); |
---|
| 550 | + |
---|
| 551 | + if (!success) |
---|
| 552 | + new Exception().printStackTrace(); |
---|
| 553 | + |
---|
| 554 | + //speakernode.parent.TransformToWorld(dst); |
---|
| 555 | + //sourcenode.parent.TransformToLocal(dst); |
---|
| 556 | + this.parent.TransformToLocal(dst); |
---|
| 557 | + |
---|
| 558 | + goalposx = dst.x; |
---|
| 559 | + goalposz = dst.z; |
---|
| 560 | + } |
---|
| 561 | + else |
---|
| 562 | + return; |
---|
| 563 | + } |
---|
| 564 | + |
---|
| 565 | + cVector temp = new cVector(); |
---|
| 566 | + |
---|
| 567 | + temp.x = 1; |
---|
| 568 | + temp.y = 0; |
---|
| 569 | + temp.z = 0; |
---|
| 570 | + |
---|
| 571 | + LA.xformDir(temp, matrix, temp); |
---|
| 572 | + |
---|
| 573 | + double angleYhip = Math.atan2(-temp.z, temp.x); |
---|
| 574 | + |
---|
| 575 | + double angleYtarget = Math.atan2(goalposx - centroid.x, goalposz - centroid.z); |
---|
| 576 | + |
---|
| 577 | + LA.matIdentity(matrix); |
---|
| 578 | + LA.matTranslate(matrix, -centroid.x, -centroid.y, -centroid.z); |
---|
| 579 | + double angle = CurveAngle(0, angleYtarget - angleYhip, 0.1f); |
---|
| 580 | + LA.matYRotate(matrix, angle); |
---|
| 581 | + LA.matTranslate(matrix, centroid.x, centroid.y, centroid.z); |
---|
| 582 | + |
---|
| 583 | + LA.matConcat(matrix, toParent, toParent); |
---|
| 584 | + |
---|
| 585 | + LA.matInvert(toParent, fromParent); |
---|
| 586 | + |
---|
| 587 | + LA.matConcat(toParent, hip.get(0).toParent, matrix); |
---|
| 588 | + |
---|
| 589 | + centroid.x = matrix[3][0]; |
---|
| 590 | + centroid.y = matrix[3][1]; |
---|
| 591 | + centroid.z = matrix[3][2]; |
---|
| 592 | + |
---|
| 593 | + double dist = LA.distance(centroid, mocaporigin); |
---|
| 594 | + |
---|
| 595 | + CheckForAction(centroid); |
---|
| 596 | + } |
---|
479 | 597 | |
---|
480 | 598 | void WriteTo(java.io.Writer writer) throws Exception |
---|
481 | 599 | { |
---|
.. | .. |
---|
526 | 644 | // transient // aout 2013 |
---|
527 | 645 | Object3D skeleton; |
---|
528 | 646 | |
---|
| 647 | + void ExtractBigData(Object3D o) |
---|
| 648 | + { |
---|
| 649 | + super.ExtractBigData(o); |
---|
| 650 | + |
---|
| 651 | + o.bvh = this.bvh; |
---|
| 652 | + o.skeleton = this.skeleton; |
---|
| 653 | + this.bvh = null; |
---|
| 654 | + this.skeleton = null; |
---|
| 655 | + } |
---|
| 656 | + |
---|
| 657 | + void RestoreBigData(Object3D o) |
---|
| 658 | + { |
---|
| 659 | + super.RestoreBigData(o); |
---|
| 660 | + |
---|
| 661 | + this.bvh = o.bvh; |
---|
| 662 | + this.skeleton = o.skeleton; |
---|
| 663 | + } |
---|
| 664 | + |
---|
529 | 665 | boolean smoothed; |
---|
530 | 666 | |
---|
531 | 667 | //boolean touched; |
---|
.. | .. |
---|
549 | 685 | double pinx; |
---|
550 | 686 | double pinz; |
---|
551 | 687 | |
---|
552 | | - double targetx; |
---|
553 | | - double targetz; |
---|
| 688 | + double targetdirx; |
---|
| 689 | + double targetdirz; |
---|
554 | 690 | |
---|
555 | | - double goalx; |
---|
556 | | - double goalz; |
---|
| 691 | + double goalposx = 0; // -20; |
---|
| 692 | + double goalposz = 0; // -10; |
---|
557 | 693 | |
---|
558 | 694 | boolean followpath; |
---|
559 | 695 | |
---|
.. | .. |
---|
624 | 760 | scriptactions.clear(); |
---|
625 | 761 | } |
---|
626 | 762 | |
---|
627 | | - static double EPSACTION = 0.1; // 0.075; // 0.1; |
---|
| 763 | + static double EPSACTION = 0.1; // 0.075; // 0.1;Came |
---|
628 | 764 | |
---|
629 | 765 | void AddFromTo(cVector from, cVector to) |
---|
630 | 766 | { |
---|
.. | .. |
---|
809 | 945 | // //GetFileRoot(); |
---|
810 | 946 | |
---|
811 | 947 | // sept 2014: // |
---|
812 | | - GrafreeD.RENDERME = 3; // patch for Merge objects |
---|
| 948 | + Grafreed.RENDERME = 3; // patch for Merge objects |
---|
813 | 949 | float[] thedata = bvh.animation.getBoneData(0); |
---|
814 | 950 | |
---|
815 | 951 | os.x = (float) (path.get(i).toParent[3][0]); // - thedata[frame*6]); |
---|
.. | .. |
---|
910 | 1046 | testvect.set(from); |
---|
911 | 1047 | testvect.sub(fromto.from); |
---|
912 | 1048 | |
---|
| 1049 | + testvect.y = 0; // PATCH |
---|
| 1050 | + |
---|
913 | 1051 | int factor = 1; |
---|
914 | 1052 | |
---|
915 | 1053 | //if (CameraPane.FAST) |
---|
.. | .. |
---|
951 | 1089 | |
---|
952 | 1090 | testvect.set(from); |
---|
953 | 1091 | testvect.sub(fromto.from); |
---|
| 1092 | + |
---|
| 1093 | + testvect.y = 0; // PATCH |
---|
954 | 1094 | |
---|
955 | 1095 | int factor = 1; |
---|
956 | 1096 | |
---|
.. | .. |
---|
1186 | 1326 | |
---|
1187 | 1327 | void SetPosition(Object3D sourcenode, cVector floor, long floorid, cVector centroid) |
---|
1188 | 1328 | { |
---|
| 1329 | + assert(false); |
---|
1189 | 1330 | //assert(CameraPane.drawMode == CameraPane.SHADOW); |
---|
1190 | 1331 | |
---|
1191 | 1332 | Object3D transformnode = new Object3D(); |
---|
.. | .. |
---|
1389 | 1530 | groundid = floorid; |
---|
1390 | 1531 | |
---|
1391 | 1532 | // green |
---|
1392 | | - CameraPane.debugpoint.toParent[3][0] = groundx; |
---|
1393 | | - CameraPane.debugpoint.toParent[3][1] = floor.y; |
---|
1394 | | - CameraPane.debugpoint.toParent[3][2] = groundz; |
---|
| 1533 | + CameraPane.debugpointG.toParent[3][0] = groundx; |
---|
| 1534 | + CameraPane.debugpointG.toParent[3][1] = floor.y; |
---|
| 1535 | + CameraPane.debugpointG.toParent[3][2] = groundz; |
---|
1395 | 1536 | |
---|
1396 | 1537 | if (true) // slow && stepout && onein) |
---|
1397 | 1538 | { |
---|
.. | .. |
---|
1402 | 1543 | // mywave = currentwave++; |
---|
1403 | 1544 | // } |
---|
1404 | 1545 | // sound |
---|
1405 | | - cVector eye = CameraPane.theRenderer.eyeCamera.location; |
---|
| 1546 | + cVector eye = Globals.theRenderer.EyeCamera().location; |
---|
1406 | 1547 | |
---|
1407 | 1548 | // if (sourcenode.parent.parent != null) |
---|
1408 | 1549 | // sourcenode.parent.parent.TransformToWorld(floor, tmp); |
---|
.. | .. |
---|
1447 | 1588 | //GraphreeD. |
---|
1448 | 1589 | wav.play(volume * usedvolume); //, mywave); |
---|
1449 | 1590 | |
---|
1450 | | - lastsoundtime = CameraPane.framecount; |
---|
| 1591 | + lastsoundtime = Globals.framecount; |
---|
1451 | 1592 | |
---|
1452 | | - GrafreeD.hassound = true; |
---|
| 1593 | + Grafreed.hassound = true; |
---|
1453 | 1594 | } |
---|
1454 | 1595 | // else |
---|
1455 | 1596 | // System.out.println("skipped"); |
---|
.. | .. |
---|
1468 | 1609 | |
---|
1469 | 1610 | // System.out.println("Allo " + sourcenode); |
---|
1470 | 1611 | // purple |
---|
1471 | | - CameraPane.debugpoint2.toParent[3][0] = floor.x;// + posx; |
---|
1472 | | - CameraPane.debugpoint2.toParent[3][1] = ground; // floor.y;// + sourcenode.parent.toParent[3][1]; |
---|
1473 | | - CameraPane.debugpoint2.toParent[3][2] = floor.z;// + posz; |
---|
| 1612 | + CameraPane.debugpointP.toParent[3][0] = floor.x;// + posx; |
---|
| 1613 | + CameraPane.debugpointP.toParent[3][1] = ground; // floor.y;// + sourcenode.parent.toParent[3][1]; |
---|
| 1614 | + CameraPane.debugpointP.toParent[3][2] = floor.z;// + posz; |
---|
1474 | 1615 | |
---|
1475 | 1616 | |
---|
1476 | 1617 | if (false) // dist2 > 0.1) |
---|
.. | .. |
---|
1536 | 1677 | this.get(0).TransformToWorld(v0); |
---|
1537 | 1678 | |
---|
1538 | 1679 | // cyan |
---|
1539 | | - CameraPane.debugpoint3.toParent[3][0] = v0.x; |
---|
1540 | | - CameraPane.debugpoint3.toParent[3][1] = ground; |
---|
1541 | | - CameraPane.debugpoint3.toParent[3][2] = v0.z; |
---|
| 1680 | + CameraPane.debugpointC.toParent[3][0] = v0.x; |
---|
| 1681 | + CameraPane.debugpointC.toParent[3][1] = ground; |
---|
| 1682 | + CameraPane.debugpointC.toParent[3][2] = v0.z; |
---|
1542 | 1683 | |
---|
1543 | 1684 | LA.matConcat(sourcenode.toParent, transformnode.toParent, sourcenode.toParent); |
---|
1544 | 1685 | LA.matInvert(sourcenode.toParent, sourcenode.fromParent); |
---|
.. | .. |
---|
1548 | 1689 | this.get(0).TransformToWorld(v0); |
---|
1549 | 1690 | |
---|
1550 | 1691 | // red |
---|
1551 | | - CameraPane.debugpoint4.toParent[3][0] = v0.x; |
---|
1552 | | - CameraPane.debugpoint4.toParent[3][1] = ground; |
---|
1553 | | - CameraPane.debugpoint4.toParent[3][2] = v0.z; |
---|
| 1692 | + CameraPane.debugpointR.toParent[3][0] = v0.x; |
---|
| 1693 | + CameraPane.debugpointR.toParent[3][1] = ground; |
---|
| 1694 | + CameraPane.debugpointR.toParent[3][2] = v0.z; |
---|
1554 | 1695 | } |
---|
1555 | 1696 | } |
---|
1556 | 1697 | |
---|
.. | .. |
---|
1590 | 1731 | |
---|
1591 | 1732 | if (goal != null) |
---|
1592 | 1733 | { |
---|
1593 | | - System.err.println("GOAL change (" + sourcenode + "): " + goal + " (was " + goalx + ", " + goalz + ")"); |
---|
| 1734 | + System.err.println("GOAL change (" + sourcenode + "): " + goal + " (was " + goalposx + ", " + goalposz + ")"); |
---|
1594 | 1735 | //sourcenode.parent.parent.Dump(); |
---|
1595 | | - goalx = goal.x; |
---|
1596 | | - goalz = goal.z; |
---|
1597 | | - targetx = targetz = 0; |
---|
| 1736 | + goalposx = goal.x; |
---|
| 1737 | + goalposz = goal.z; |
---|
| 1738 | + targetdirx = targetdirz = 0; |
---|
1598 | 1739 | |
---|
1599 | 1740 | followpath = true; |
---|
1600 | 1741 | } |
---|
.. | .. |
---|
1645 | 1786 | // } |
---|
1646 | 1787 | if (false) // !uselast) |
---|
1647 | 1788 | { |
---|
1648 | | - CameraPane.debugpoint.toParent[3][0] = dst.x; |
---|
1649 | | - CameraPane.debugpoint.toParent[3][1] = dst.y; |
---|
1650 | | - CameraPane.debugpoint.toParent[3][2] = dst.z; |
---|
| 1789 | + CameraPane.debugpointG.toParent[3][0] = dst.x; |
---|
| 1790 | + CameraPane.debugpointG.toParent[3][1] = dst.y; |
---|
| 1791 | + CameraPane.debugpointG.toParent[3][2] = dst.z; |
---|
1651 | 1792 | } |
---|
1652 | 1793 | } |
---|
1653 | 1794 | |
---|
1654 | | - if (goalx != 0 || goalz != 0) // TODO |
---|
| 1795 | + if (goalposx != 0 || goalposz != 0) // TODO |
---|
1655 | 1796 | { |
---|
1656 | 1797 | // overwrite speaker orientation |
---|
1657 | | - dst.set(goalx,0,goalz); |
---|
| 1798 | + dst.set(goalposx,0,goalposz); |
---|
1658 | 1799 | if (sourcenode.parent != null) // july 2014 |
---|
1659 | 1800 | sourcenode.parent. |
---|
1660 | 1801 | TransformToLocal(dst); |
---|
.. | .. |
---|
1706 | 1847 | // mars 2014 |
---|
1707 | 1848 | if (false) // goalx != 0 || goalz != 0) |
---|
1708 | 1849 | { |
---|
1709 | | - targetx = dst.x - src.x; |
---|
1710 | | - targetz = dst.z - src.z; |
---|
| 1850 | + targetdirx = dst.x - src.x; |
---|
| 1851 | + targetdirz = dst.z - src.z; |
---|
1711 | 1852 | |
---|
1712 | | - if (Math.abs(targetx) > 0.1 || Math.abs(targetz) > 0.1) |
---|
| 1853 | + if (Math.abs(targetdirx) > 0.1 || Math.abs(targetdirz) > 0.1) |
---|
1713 | 1854 | { |
---|
1714 | 1855 | // far enough from goal. keep the goal position. |
---|
1715 | | - targetx = 0; |
---|
1716 | | - targetz = 0; |
---|
| 1856 | + targetdirx = 0; |
---|
| 1857 | + targetdirz = 0; |
---|
1717 | 1858 | } |
---|
1718 | 1859 | else |
---|
1719 | 1860 | { |
---|
1720 | 1861 | // too close to goal. switch to target direction instead. |
---|
1721 | | - goalx = 0; |
---|
1722 | | - goalz = 0; |
---|
| 1862 | + goalposx = 0; |
---|
| 1863 | + goalposz = 0; |
---|
1723 | 1864 | } |
---|
1724 | 1865 | } |
---|
1725 | 1866 | |
---|
1726 | 1867 | //sourcenode.getCentroid(src, true); |
---|
1727 | 1868 | |
---|
1728 | | - if (speakernode == sourcenode && goalx == 0 && goalz == 0) |
---|
| 1869 | + if (speakernode == sourcenode && goalposx == 0 && goalposz == 0) |
---|
1729 | 1870 | { |
---|
1730 | 1871 | if (ScriptNode.lastspeaker != null) |
---|
1731 | 1872 | new Exception().printStackTrace(); |
---|
.. | .. |
---|
1734 | 1875 | |
---|
1735 | 1876 | // LA.xformPos(src, fromParent, src); |
---|
1736 | 1877 | |
---|
1737 | | - if ((ScriptNode.speaker != null && CameraPane.SPEAKERMOCAP || goalx != 0 || goalz != 0) && targetx == 0 && targetz == 0) |
---|
| 1878 | + if ((ScriptNode.speaker != null && CameraPane.SPEAKERMOCAP || goalposx != 0 || goalposz != 0) && targetdirx == 0 && targetdirz == 0) |
---|
1738 | 1879 | dst.sub(src); |
---|
1739 | 1880 | else |
---|
1740 | 1881 | // vector mode |
---|
1741 | 1882 | { |
---|
1742 | | - dst.x = targetx; |
---|
1743 | | - dst.z = targetz; |
---|
| 1883 | + dst.x = targetdirx; |
---|
| 1884 | + dst.z = targetdirz; |
---|
1744 | 1885 | |
---|
1745 | 1886 | // TEST TARGET |
---|
1746 | 1887 | // dst.x = CameraPane.selectedpoint.toParent[3][0]; |
---|
.. | .. |
---|
2150 | 2291 | } |
---|
2151 | 2292 | |
---|
2152 | 2293 | if (!smoothed) |
---|
2153 | | - for (int i=0; --i>=0;) |
---|
| 2294 | + for (int i=10; --i>=0;) |
---|
2154 | 2295 | SmoothAnimData(); // much reduces shakiness |
---|
2155 | 2296 | |
---|
2156 | 2297 | smoothed = true; |
---|
.. | .. |
---|
2188 | 2329 | toVector.x = LA.cos(to); |
---|
2189 | 2330 | toVector.y = LA.sin(to); |
---|
2190 | 2331 | |
---|
| 2332 | + double fromA = Math.atan2(fromVector.y, fromVector.x); |
---|
| 2333 | + double toA = Math.atan2(toVector.y, toVector.x); |
---|
| 2334 | + |
---|
2191 | 2335 | Vector2d currentVector = Slerp(fromVector, toVector, step); |
---|
2192 | 2336 | |
---|
2193 | | - return Math.atan2(currentVector.y, currentVector.x); |
---|
| 2337 | + double angle = Math.atan2(currentVector.y, currentVector.x); |
---|
| 2338 | + |
---|
| 2339 | + double angle2 = (1-step) * fromA + step * toA; |
---|
| 2340 | + |
---|
| 2341 | + return angle; |
---|
2194 | 2342 | } |
---|
2195 | 2343 | |
---|
2196 | 2344 | public static Vector2d Slerp(Vector2d from, Vector2d to, double step) |
---|
.. | .. |
---|
2242 | 2390 | { |
---|
2243 | 2391 | e.printStackTrace(); |
---|
2244 | 2392 | } |
---|
| 2393 | + |
---|
| 2394 | + SetHipOrientation(); |
---|
2245 | 2395 | |
---|
2246 | 2396 | if (true) |
---|
2247 | 2397 | return; |
---|
.. | .. |
---|
2670 | 2820 | // set rotation |
---|
2671 | 2821 | //if (bone._rotationEnabled) |
---|
2672 | 2822 | if (//frame > 0 && |
---|
2673 | | - !bone.skipmocap //&& |
---|
2674 | | - //!bone.name.contains("head") && |
---|
| 2823 | + !bone.skipmocap && |
---|
| 2824 | + !bone.name.contains("head") && |
---|
| 2825 | + !bone.name.contains("Head") // && |
---|
2675 | 2826 | // !bone.name.contains("rFoot") && |
---|
2676 | 2827 | // !bone.name.contains("lFoot") && |
---|
2677 | 2828 | // !bone.name.contains("Pinky") && |
---|
.. | .. |
---|
3056 | 3207 | |
---|
3057 | 3208 | void Reset() |
---|
3058 | 3209 | { |
---|
3059 | | - if (fullname != null) |
---|
3060 | | - ReadBVH(); |
---|
| 3210 | +// if (fullname != null) |
---|
| 3211 | +// ReadBVH(); |
---|
3061 | 3212 | |
---|
3062 | 3213 | Object3D hip = get(0); |
---|
3063 | 3214 | |
---|
.. | .. |
---|
3096 | 3247 | // LA.matIdentity(rot.fromParent); |
---|
3097 | 3248 | |
---|
3098 | 3249 | // july 2014 |
---|
3099 | | - goalx = goalz = 0; |
---|
3100 | | - targetx = targetz = 0; |
---|
| 3250 | +// goalx = goalz = 0; |
---|
| 3251 | + targetdirx = targetdirz = 0; |
---|
3101 | 3252 | |
---|
3102 | 3253 | //SetPositionDelta(true, true, true, false); |
---|
3103 | 3254 | // LoadData(); |
---|
.. | .. |
---|
3107 | 3258 | |
---|
3108 | 3259 | // aout 2013 endframe = 0; // june 2013 |
---|
3109 | 3260 | |
---|
3110 | | - //ResetZero(); |
---|
3111 | | - setPose(frame); |
---|
| 3261 | + ResetZero(); |
---|
| 3262 | + //setPose(frame); |
---|
3112 | 3263 | } |
---|
3113 | 3264 | |
---|
3114 | 3265 | static int mocapsupport = 0; |
---|
.. | .. |
---|
3126 | 3277 | |
---|
3127 | 3278 | int step = 1; |
---|
3128 | 3279 | |
---|
| 3280 | + // patch for running hare |
---|
3129 | 3281 | if (speedup) // fev 2014 |
---|
3130 | 3282 | step *= 2; // 4; |
---|
3131 | 3283 | if (rewind) // mars 2014 |
---|
3132 | 3284 | step *= 4; |
---|
3133 | 3285 | |
---|
3134 | | - if (CameraPane.FAST) // && !CameraPane.HOLD) |
---|
| 3286 | + //if (CameraPane.FAST) // && !CameraPane.HOLD) |
---|
3135 | 3287 | step *= CameraPane.STEP; |
---|
3136 | 3288 | |
---|
3137 | 3289 | //System.err.println("Step Mocap frame # " + frame); |
---|
.. | .. |
---|
3163 | 3315 | "; fullname = " + fullname); |
---|
3164 | 3316 | |
---|
3165 | 3317 | //int delta = frame - baseframe; |
---|
3166 | | - if (CameraPane.CROWD) |
---|
| 3318 | + if (Globals.CROWD) |
---|
3167 | 3319 | { |
---|
3168 | 3320 | baseframe = GetFirstFrame(); // 0 initial point |
---|
3169 | 3321 | } |
---|
.. | .. |
---|
3172 | 3324 | // SetPositionDelta(false, true, false); // ?? false); |
---|
3173 | 3325 | { |
---|
3174 | 3326 | if (support == null) |
---|
3175 | | - ObjEditor.LoadBVHFile(fullname, this, false, beginframe, lastframetest); |
---|
| 3327 | + { |
---|
| 3328 | + if (bvh == null && new File(fullname).exists()) |
---|
| 3329 | + ObjEditor.LoadBVHFile(fullname, this, false, beginframe, lastframetest); |
---|
| 3330 | + else |
---|
| 3331 | + { |
---|
| 3332 | + SetGlobalTransform(); |
---|
| 3333 | + Rewind(); |
---|
| 3334 | + Fade(); |
---|
| 3335 | + } |
---|
| 3336 | + } |
---|
3176 | 3337 | else |
---|
3177 | 3338 | { |
---|
3178 | | - try |
---|
3179 | | - { |
---|
| 3339 | +// try |
---|
| 3340 | +// { |
---|
3180 | 3341 | bvh = ((Mocap)support.get(mocapsupport++ % support.Size())).bvh; |
---|
3181 | 3342 | |
---|
3182 | 3343 | // SetPositionDelta(false, true, true, true); |
---|
3183 | 3344 | LoadData(); |
---|
3184 | 3345 | Rewind(); |
---|
3185 | 3346 | Fade(); |
---|
3186 | | - } |
---|
3187 | | - catch (Exception e) |
---|
3188 | | - { |
---|
3189 | | - e.printStackTrace(); |
---|
3190 | | - ObjEditor.LoadBVHFile(fullname, this, false, beginframe, lastframetest); |
---|
3191 | | - } |
---|
| 3347 | +// } |
---|
| 3348 | +// catch (Exception e) |
---|
| 3349 | +// { |
---|
| 3350 | +// System.err.println("An error occured while loading data. Use fallback by loading the file."); |
---|
| 3351 | +// //e.printStackTrace(); |
---|
| 3352 | +// try |
---|
| 3353 | +// { |
---|
| 3354 | +// ObjEditor.LoadBVHFile(fullname, this, false, beginframe, lastframetest); |
---|
| 3355 | +// } |
---|
| 3356 | +// catch (Exception e2) |
---|
| 3357 | +// { |
---|
| 3358 | +// System.err.println("Motion file not found: " + fullname); |
---|
| 3359 | +// } |
---|
| 3360 | +// } |
---|
3192 | 3361 | } |
---|
3193 | 3362 | } |
---|
3194 | 3363 | |
---|
.. | .. |
---|
3370 | 3539 | // filters out bad input data |
---|
3371 | 3540 | void FilterAnimData() |
---|
3372 | 3541 | { |
---|
| 3542 | + new Exception().printStackTrace(); |
---|
3373 | 3543 | System.exit(0); |
---|
3374 | 3544 | |
---|
3375 | 3545 | float[] data; // = bvh.animation.getBoneData(0); |
---|
.. | .. |
---|
3727 | 3897 | |
---|
3728 | 3898 | transient boolean restarted; // CROWD issue? |
---|
3729 | 3899 | |
---|
3730 | | - void drawSelf(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
| 3900 | + void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
3731 | 3901 | { |
---|
3732 | 3902 | //System.err.println("drawSelf Mocap frame # " + frame); |
---|
3733 | 3903 | //System.err.println("drawSelf Mocap baseframe # " + baseframe); |
---|
.. | .. |
---|
3744 | 3914 | // if (firstframe) |
---|
3745 | 3915 | // return; |
---|
3746 | 3916 | |
---|
3747 | | - if (!restarted && /*display.restartframe &&*/ |
---|
3748 | | - display.isLIVE() && live && display.drawMode == display.SHADOW) // FUCK |
---|
| 3917 | + if (//!restarted && /*display.restartframe &&*/ |
---|
| 3918 | + Globals.isLIVE() && live && (display.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW)) |
---|
3749 | 3919 | { |
---|
3750 | 3920 | //display.restartframe = false; |
---|
3751 | 3921 | restarted = true; |
---|
| 3922 | + //System.err.println("restarted = true"); |
---|
3752 | 3923 | Step(); |
---|
3753 | 3924 | } |
---|
3754 | 3925 | else |
---|
3755 | 3926 | { |
---|
3756 | | - if (display.isLIVE() && live && display.drawMode != display.SHADOW) |
---|
| 3927 | + //System.err.println("restarted"); |
---|
| 3928 | + if (Globals.isLIVE() && live && display.DrawMode() != iCameraPane.SHADOW) |
---|
| 3929 | + { |
---|
3757 | 3930 | restarted = false; |
---|
| 3931 | + //System.err.println("restarted = false"); |
---|
| 3932 | + } |
---|
3758 | 3933 | } |
---|
3759 | 3934 | |
---|
3760 | 3935 | super.drawSelf(display, root, selected, blocked); |
---|