.. | .. |
---|
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.CreateSelectedPoint(); |
---|
| 265 | + |
---|
| 266 | + CameraPane.debugpointG.toParent[3][0] = poship.x; |
---|
| 267 | + CameraPane.debugpointG.toParent[3][1] = poship.y; |
---|
| 268 | + CameraPane.debugpointG.toParent[3][2] = poship.z; |
---|
267 | 269 | |
---|
268 | 270 | LA.matInvert(toParent, fromParent); |
---|
269 | 271 | |
---|
.. | .. |
---|
324 | 326 | // LA.matYRotate(toParent, angleY - angleYhip); |
---|
325 | 327 | // LA.matTranslate(toParent, pos.x - poship.x, pos.y - poship.y, pos.z - poship.z); |
---|
326 | 328 | |
---|
327 | | - CameraPane.debugpoint2.toParent[3][0] = pos.x; |
---|
328 | | - CameraPane.debugpoint2.toParent[3][1] = pos.y; |
---|
329 | | - CameraPane.debugpoint2.toParent[3][2] = pos.z; |
---|
| 329 | + CameraPane.debugpointP.toParent[3][0] = pos.x; |
---|
| 330 | + CameraPane.debugpointP.toParent[3][1] = pos.y; |
---|
| 331 | + CameraPane.debugpointP.toParent[3][2] = pos.z; |
---|
330 | 332 | |
---|
331 | | - CameraPane.debugpoint3.toParent[3][0] = poship.x; |
---|
332 | | - CameraPane.debugpoint3.toParent[3][1] = poship.y; |
---|
333 | | - CameraPane.debugpoint3.toParent[3][2] = poship.z; |
---|
| 333 | + CameraPane.debugpointC.toParent[3][0] = poship.x; |
---|
| 334 | + CameraPane.debugpointC.toParent[3][1] = poship.y; |
---|
| 335 | + CameraPane.debugpointC.toParent[3][2] = poship.z; |
---|
334 | 336 | |
---|
335 | 337 | poship.x = toParent[3][0]; |
---|
336 | 338 | poship.y = toParent[3][1]; |
---|
337 | 339 | poship.z = toParent[3][2]; |
---|
338 | 340 | |
---|
339 | | - CameraPane.debugpoint4.toParent[3][0] = poship.x; |
---|
340 | | - CameraPane.debugpoint4.toParent[3][1] = poship.y; |
---|
341 | | - CameraPane.debugpoint4.toParent[3][2] = poship.z; |
---|
| 341 | + CameraPane.debugpointR.toParent[3][0] = poship.x; |
---|
| 342 | + CameraPane.debugpointR.toParent[3][1] = poship.y; |
---|
| 343 | + CameraPane.debugpointR.toParent[3][2] = poship.z; |
---|
342 | 344 | |
---|
343 | 345 | LA.matInvert(toParent, fromParent); |
---|
344 | 346 | } |
---|
.. | .. |
---|
477 | 479 | } |
---|
478 | 480 | } |
---|
479 | 481 | |
---|
| 482 | + static cVector centroid = new cVector(); |
---|
| 483 | + static cVector mocaporigin = new cVector(); |
---|
| 484 | + |
---|
480 | 485 | void SetHipOrientation() |
---|
481 | 486 | { |
---|
482 | 487 | Object3D hip = get(0); |
---|
483 | 488 | |
---|
| 489 | + if (toParent == null) |
---|
| 490 | + { |
---|
| 491 | + toParent = LA.newMatrix(); |
---|
| 492 | + fromParent = LA.newMatrix(); |
---|
| 493 | + } |
---|
| 494 | + |
---|
484 | 495 | LA.matConcat(toParent, hip.get(0).toParent, matrix); |
---|
485 | 496 | |
---|
486 | | - cVector centroid = new cVector(); |
---|
| 497 | + mocaporigin.x = matrix[3][0]; |
---|
| 498 | + mocaporigin.y = matrix[3][1]; |
---|
| 499 | + mocaporigin.z = matrix[3][2]; |
---|
| 500 | + |
---|
487 | 501 | centroid.x = matrix[3][0]; |
---|
488 | 502 | centroid.y = matrix[3][1]; |
---|
489 | 503 | centroid.z = matrix[3][2]; |
---|
490 | | - this.getCentroid(centroid, true); |
---|
| 504 | +// this.getCentroid(centroid, true); |
---|
| 505 | + |
---|
| 506 | + CameraPane.CreateSelectedPoint(); |
---|
| 507 | + CameraPane.debugpointG.name = ""; |
---|
| 508 | + CameraPane.debugpointG.toParent[3][0] = mocaporigin.x; |
---|
| 509 | + CameraPane.debugpointG.toParent[3][1] = mocaporigin.y; |
---|
| 510 | + CameraPane.debugpointG.toParent[3][2] = mocaporigin.z; |
---|
| 511 | + |
---|
| 512 | + CameraPane.debugpointP.name = ""; |
---|
| 513 | + CameraPane.debugpointP.toParent[3][0] = centroid.x; |
---|
| 514 | + CameraPane.debugpointP.toParent[3][1] = centroid.y; |
---|
| 515 | + CameraPane.debugpointP.toParent[3][2] = centroid.z; |
---|
491 | 516 | |
---|
492 | 517 | cVector goal = GetGoal(centroid); |
---|
493 | 518 | if (goal != null) |
---|
494 | 519 | { |
---|
495 | | - System.err.println("GOAL change (" + this + "): " + goal + " (was " + goalx + ", " + goalz + ")"); |
---|
| 520 | + System.err.println("GOAL change (" + this + "): " + goal + " (was " + goalposx + ", " + goalposz + ")"); |
---|
496 | 521 | |
---|
497 | | - goalx = goal.x; |
---|
498 | | - goalz = goal.z; |
---|
499 | | - targetx = targetz = 0; |
---|
| 522 | + goalposx = goal.x; |
---|
| 523 | + goalposz = goal.z; |
---|
| 524 | + targetdirx = targetdirz = 0; |
---|
500 | 525 | } |
---|
501 | 526 | |
---|
502 | | - if (goalx == 0 && goalz == 0) |
---|
| 527 | + if (goalposx == 0 && goalposz == 0) |
---|
503 | 528 | { |
---|
504 | 529 | // No target |
---|
505 | 530 | if (ScriptNode.speaker != null) |
---|
.. | .. |
---|
533 | 558 | //sourcenode.parent.TransformToLocal(dst); |
---|
534 | 559 | this.parent.TransformToLocal(dst); |
---|
535 | 560 | |
---|
536 | | - goalx = dst.x; |
---|
537 | | - goalz = dst.z; |
---|
| 561 | + goalposx = dst.x; |
---|
| 562 | + goalposz = dst.z; |
---|
538 | 563 | } |
---|
539 | 564 | else |
---|
540 | 565 | return; |
---|
.. | .. |
---|
550 | 575 | |
---|
551 | 576 | double angleYhip = Math.atan2(-temp.z, temp.x); |
---|
552 | 577 | |
---|
553 | | - double angleYtarget = Math.atan2(goalx - centroid.x, goalz - centroid.z); |
---|
| 578 | + double angleYtarget = Math.atan2(goalposx - centroid.x, goalposz - centroid.z); |
---|
554 | 579 | |
---|
555 | 580 | LA.matIdentity(matrix); |
---|
556 | 581 | LA.matTranslate(matrix, -centroid.x, -centroid.y, -centroid.z); |
---|
557 | | - double angle = CurveAngle(0, angleYtarget - angleYhip, 1); // 0.1f); |
---|
| 582 | + double angle = CurveAngle(0, angleYtarget - angleYhip, 0.1f); |
---|
558 | 583 | LA.matYRotate(matrix, angle); |
---|
559 | 584 | LA.matTranslate(matrix, centroid.x, centroid.y, centroid.z); |
---|
560 | 585 | |
---|
561 | 586 | LA.matConcat(matrix, toParent, toParent); |
---|
562 | 587 | |
---|
563 | 588 | LA.matInvert(toParent, fromParent); |
---|
| 589 | + |
---|
| 590 | + LA.matConcat(toParent, hip.get(0).toParent, matrix); |
---|
| 591 | + |
---|
| 592 | + centroid.x = matrix[3][0]; |
---|
| 593 | + centroid.y = matrix[3][1]; |
---|
| 594 | + centroid.z = matrix[3][2]; |
---|
| 595 | + |
---|
| 596 | + double dist = LA.distance(centroid, mocaporigin); |
---|
564 | 597 | |
---|
565 | 598 | CheckForAction(centroid); |
---|
566 | 599 | } |
---|
.. | .. |
---|
614 | 647 | // transient // aout 2013 |
---|
615 | 648 | Object3D skeleton; |
---|
616 | 649 | |
---|
| 650 | + void ExtractBigData(Object3D o) |
---|
| 651 | + { |
---|
| 652 | + super.ExtractBigData(o); |
---|
| 653 | + |
---|
| 654 | + o.savebvh = this.bvh; |
---|
| 655 | + o.saveskeleton = this.skeleton; |
---|
| 656 | + this.bvh = null; |
---|
| 657 | + this.skeleton = null; |
---|
| 658 | + } |
---|
| 659 | + |
---|
| 660 | + void RestoreBigData(Object3D o) |
---|
| 661 | + { |
---|
| 662 | + super.RestoreBigData(o); |
---|
| 663 | + |
---|
| 664 | + this.bvh = o.savebvh; |
---|
| 665 | + this.skeleton = o.saveskeleton; |
---|
| 666 | + } |
---|
| 667 | + |
---|
617 | 668 | boolean smoothed; |
---|
618 | 669 | |
---|
619 | 670 | //boolean touched; |
---|
.. | .. |
---|
637 | 688 | double pinx; |
---|
638 | 689 | double pinz; |
---|
639 | 690 | |
---|
640 | | - double targetx; |
---|
641 | | - double targetz; |
---|
| 691 | + double targetdirx; |
---|
| 692 | + double targetdirz; |
---|
642 | 693 | |
---|
643 | | - double goalx = -20; |
---|
644 | | - double goalz = -10; |
---|
| 694 | + double goalposx = 0; // -20; |
---|
| 695 | + double goalposz = 0; // -10; |
---|
645 | 696 | |
---|
646 | 697 | boolean followpath; |
---|
647 | 698 | |
---|
.. | .. |
---|
712 | 763 | scriptactions.clear(); |
---|
713 | 764 | } |
---|
714 | 765 | |
---|
715 | | - static double EPSACTION = 0.1; // 0.075; // 0.1; |
---|
| 766 | + static double EPSACTION = 0.1; // 0.075; // 0.1;Came |
---|
716 | 767 | |
---|
717 | 768 | void AddFromTo(cVector from, cVector to) |
---|
718 | 769 | { |
---|
.. | .. |
---|
897 | 948 | // //GetFileRoot(); |
---|
898 | 949 | |
---|
899 | 950 | // sept 2014: // |
---|
900 | | - GrafreeD.RENDERME = 3; // patch for Merge objects |
---|
| 951 | + Grafreed.RENDERME = 3; // patch for Merge objects |
---|
901 | 952 | float[] thedata = bvh.animation.getBoneData(0); |
---|
902 | 953 | |
---|
903 | 954 | os.x = (float) (path.get(i).toParent[3][0]); // - thedata[frame*6]); |
---|
.. | .. |
---|
947 | 998 | |
---|
948 | 999 | get(0).link2master = path.size() > 1; // hip orientation |
---|
949 | 1000 | |
---|
950 | | - if (get(0).link2master) |
---|
| 1001 | + if (get(0).Link2Support()) |
---|
951 | 1002 | { |
---|
952 | 1003 | rotateonce = 2; |
---|
953 | 1004 | } |
---|
.. | .. |
---|
1278 | 1329 | |
---|
1279 | 1330 | void SetPosition(Object3D sourcenode, cVector floor, long floorid, cVector centroid) |
---|
1280 | 1331 | { |
---|
| 1332 | + assert(false); |
---|
1281 | 1333 | //assert(CameraPane.drawMode == CameraPane.SHADOW); |
---|
1282 | 1334 | |
---|
1283 | 1335 | Object3D transformnode = new Object3D(); |
---|
.. | .. |
---|
1375 | 1427 | double w = 0.00015; |
---|
1376 | 1428 | |
---|
1377 | 1429 | //if (!sourcenode.link2master) // strong pin on floor |
---|
1378 | | - if (parent.link2master) // strong pin on floor |
---|
| 1430 | + if (parent.Link2Support()) // strong pin on floor |
---|
1379 | 1431 | { |
---|
1380 | 1432 | w = 0.005; // .001; |
---|
1381 | 1433 | } |
---|
.. | .. |
---|
1481 | 1533 | groundid = floorid; |
---|
1482 | 1534 | |
---|
1483 | 1535 | // green |
---|
1484 | | - CameraPane.debugpoint.toParent[3][0] = groundx; |
---|
1485 | | - CameraPane.debugpoint.toParent[3][1] = floor.y; |
---|
1486 | | - CameraPane.debugpoint.toParent[3][2] = groundz; |
---|
| 1536 | + CameraPane.debugpointG.toParent[3][0] = groundx; |
---|
| 1537 | + CameraPane.debugpointG.toParent[3][1] = floor.y; |
---|
| 1538 | + CameraPane.debugpointG.toParent[3][2] = groundz; |
---|
1487 | 1539 | |
---|
1488 | 1540 | if (true) // slow && stepout && onein) |
---|
1489 | 1541 | { |
---|
.. | .. |
---|
1494 | 1546 | // mywave = currentwave++; |
---|
1495 | 1547 | // } |
---|
1496 | 1548 | // sound |
---|
1497 | | - cVector eye = CameraPane.theRenderer.eyeCamera.location; |
---|
| 1549 | + cVector eye = Globals.theRenderer.EyeCamera().location; |
---|
1498 | 1550 | |
---|
1499 | 1551 | // if (sourcenode.parent.parent != null) |
---|
1500 | 1552 | // sourcenode.parent.parent.TransformToWorld(floor, tmp); |
---|
.. | .. |
---|
1539 | 1591 | //GraphreeD. |
---|
1540 | 1592 | wav.play(volume * usedvolume); //, mywave); |
---|
1541 | 1593 | |
---|
1542 | | - lastsoundtime = CameraPane.framecount; |
---|
| 1594 | + lastsoundtime = Globals.framecount; |
---|
1543 | 1595 | |
---|
1544 | | - GrafreeD.hassound = true; |
---|
| 1596 | + Grafreed.hassound = true; |
---|
1545 | 1597 | } |
---|
1546 | 1598 | // else |
---|
1547 | 1599 | // System.out.println("skipped"); |
---|
.. | .. |
---|
1560 | 1612 | |
---|
1561 | 1613 | // System.out.println("Allo " + sourcenode); |
---|
1562 | 1614 | // purple |
---|
1563 | | - CameraPane.debugpoint2.toParent[3][0] = floor.x;// + posx; |
---|
1564 | | - CameraPane.debugpoint2.toParent[3][1] = ground; // floor.y;// + sourcenode.parent.toParent[3][1]; |
---|
1565 | | - CameraPane.debugpoint2.toParent[3][2] = floor.z;// + posz; |
---|
| 1615 | + CameraPane.debugpointP.toParent[3][0] = floor.x;// + posx; |
---|
| 1616 | + CameraPane.debugpointP.toParent[3][1] = ground; // floor.y;// + sourcenode.parent.toParent[3][1]; |
---|
| 1617 | + CameraPane.debugpointP.toParent[3][2] = floor.z;// + posz; |
---|
1566 | 1618 | |
---|
1567 | 1619 | |
---|
1568 | 1620 | if (false) // dist2 > 0.1) |
---|
.. | .. |
---|
1589 | 1641 | // sourcenode.parent.toParent[3][1] = ground - floor.y; |
---|
1590 | 1642 | // sourcenode.parent.toParent[3][2] += groundz - floor.z; |
---|
1591 | 1643 | // sourcenode.parent.toParent[3][1] = K * (ground - floor.y) + (1 - K) * oldposy; |
---|
1592 | | - if (footcontact && (sourcenode.parent != null && !sourcenode.parent.link2master)) // strong pin on floor |
---|
| 1644 | + if (footcontact && (sourcenode.parent != null && !sourcenode.parent.Link2Support())) // strong pin on floor |
---|
1593 | 1645 | { |
---|
1594 | 1646 | v0.x = groundx - floor.x; |
---|
1595 | 1647 | v0.y = 0; // groundx - floor.x; |
---|
.. | .. |
---|
1628 | 1680 | this.get(0).TransformToWorld(v0); |
---|
1629 | 1681 | |
---|
1630 | 1682 | // cyan |
---|
1631 | | - CameraPane.debugpoint3.toParent[3][0] = v0.x; |
---|
1632 | | - CameraPane.debugpoint3.toParent[3][1] = ground; |
---|
1633 | | - CameraPane.debugpoint3.toParent[3][2] = v0.z; |
---|
| 1683 | + CameraPane.debugpointC.toParent[3][0] = v0.x; |
---|
| 1684 | + CameraPane.debugpointC.toParent[3][1] = ground; |
---|
| 1685 | + CameraPane.debugpointC.toParent[3][2] = v0.z; |
---|
1634 | 1686 | |
---|
1635 | 1687 | LA.matConcat(sourcenode.toParent, transformnode.toParent, sourcenode.toParent); |
---|
1636 | 1688 | LA.matInvert(sourcenode.toParent, sourcenode.fromParent); |
---|
.. | .. |
---|
1640 | 1692 | this.get(0).TransformToWorld(v0); |
---|
1641 | 1693 | |
---|
1642 | 1694 | // red |
---|
1643 | | - CameraPane.debugpoint4.toParent[3][0] = v0.x; |
---|
1644 | | - CameraPane.debugpoint4.toParent[3][1] = ground; |
---|
1645 | | - CameraPane.debugpoint4.toParent[3][2] = v0.z; |
---|
| 1695 | + CameraPane.debugpointR.toParent[3][0] = v0.x; |
---|
| 1696 | + CameraPane.debugpointR.toParent[3][1] = ground; |
---|
| 1697 | + CameraPane.debugpointR.toParent[3][2] = v0.z; |
---|
1646 | 1698 | } |
---|
1647 | 1699 | } |
---|
1648 | 1700 | |
---|
.. | .. |
---|
1682 | 1734 | |
---|
1683 | 1735 | if (goal != null) |
---|
1684 | 1736 | { |
---|
1685 | | - System.err.println("GOAL change (" + sourcenode + "): " + goal + " (was " + goalx + ", " + goalz + ")"); |
---|
| 1737 | + System.err.println("GOAL change (" + sourcenode + "): " + goal + " (was " + goalposx + ", " + goalposz + ")"); |
---|
1686 | 1738 | //sourcenode.parent.parent.Dump(); |
---|
1687 | | - goalx = goal.x; |
---|
1688 | | - goalz = goal.z; |
---|
1689 | | - targetx = targetz = 0; |
---|
| 1739 | + goalposx = goal.x; |
---|
| 1740 | + goalposz = goal.z; |
---|
| 1741 | + targetdirx = targetdirz = 0; |
---|
1690 | 1742 | |
---|
1691 | 1743 | followpath = true; |
---|
1692 | 1744 | } |
---|
.. | .. |
---|
1737 | 1789 | // } |
---|
1738 | 1790 | if (false) // !uselast) |
---|
1739 | 1791 | { |
---|
1740 | | - CameraPane.debugpoint.toParent[3][0] = dst.x; |
---|
1741 | | - CameraPane.debugpoint.toParent[3][1] = dst.y; |
---|
1742 | | - CameraPane.debugpoint.toParent[3][2] = dst.z; |
---|
| 1792 | + CameraPane.debugpointG.toParent[3][0] = dst.x; |
---|
| 1793 | + CameraPane.debugpointG.toParent[3][1] = dst.y; |
---|
| 1794 | + CameraPane.debugpointG.toParent[3][2] = dst.z; |
---|
1743 | 1795 | } |
---|
1744 | 1796 | } |
---|
1745 | 1797 | |
---|
1746 | | - if (goalx != 0 || goalz != 0) // TODO |
---|
| 1798 | + if (goalposx != 0 || goalposz != 0) // TODO |
---|
1747 | 1799 | { |
---|
1748 | 1800 | // overwrite speaker orientation |
---|
1749 | | - dst.set(goalx,0,goalz); |
---|
| 1801 | + dst.set(goalposx,0,goalposz); |
---|
1750 | 1802 | if (sourcenode.parent != null) // july 2014 |
---|
1751 | 1803 | sourcenode.parent. |
---|
1752 | 1804 | TransformToLocal(dst); |
---|
.. | .. |
---|
1798 | 1850 | // mars 2014 |
---|
1799 | 1851 | if (false) // goalx != 0 || goalz != 0) |
---|
1800 | 1852 | { |
---|
1801 | | - targetx = dst.x - src.x; |
---|
1802 | | - targetz = dst.z - src.z; |
---|
| 1853 | + targetdirx = dst.x - src.x; |
---|
| 1854 | + targetdirz = dst.z - src.z; |
---|
1803 | 1855 | |
---|
1804 | | - if (Math.abs(targetx) > 0.1 || Math.abs(targetz) > 0.1) |
---|
| 1856 | + if (Math.abs(targetdirx) > 0.1 || Math.abs(targetdirz) > 0.1) |
---|
1805 | 1857 | { |
---|
1806 | 1858 | // far enough from goal. keep the goal position. |
---|
1807 | | - targetx = 0; |
---|
1808 | | - targetz = 0; |
---|
| 1859 | + targetdirx = 0; |
---|
| 1860 | + targetdirz = 0; |
---|
1809 | 1861 | } |
---|
1810 | 1862 | else |
---|
1811 | 1863 | { |
---|
1812 | 1864 | // too close to goal. switch to target direction instead. |
---|
1813 | | - goalx = 0; |
---|
1814 | | - goalz = 0; |
---|
| 1865 | + goalposx = 0; |
---|
| 1866 | + goalposz = 0; |
---|
1815 | 1867 | } |
---|
1816 | 1868 | } |
---|
1817 | 1869 | |
---|
1818 | 1870 | //sourcenode.getCentroid(src, true); |
---|
1819 | 1871 | |
---|
1820 | | - if (speakernode == sourcenode && goalx == 0 && goalz == 0) |
---|
| 1872 | + if (speakernode == sourcenode && goalposx == 0 && goalposz == 0) |
---|
1821 | 1873 | { |
---|
1822 | 1874 | if (ScriptNode.lastspeaker != null) |
---|
1823 | 1875 | new Exception().printStackTrace(); |
---|
.. | .. |
---|
1826 | 1878 | |
---|
1827 | 1879 | // LA.xformPos(src, fromParent, src); |
---|
1828 | 1880 | |
---|
1829 | | - if ((ScriptNode.speaker != null && CameraPane.SPEAKERMOCAP || goalx != 0 || goalz != 0) && targetx == 0 && targetz == 0) |
---|
| 1881 | + if ((ScriptNode.speaker != null && CameraPane.SPEAKERMOCAP || goalposx != 0 || goalposz != 0) && targetdirx == 0 && targetdirz == 0) |
---|
1830 | 1882 | dst.sub(src); |
---|
1831 | 1883 | else |
---|
1832 | 1884 | // vector mode |
---|
1833 | 1885 | { |
---|
1834 | | - dst.x = targetx; |
---|
1835 | | - dst.z = targetz; |
---|
| 1886 | + dst.x = targetdirx; |
---|
| 1887 | + dst.z = targetdirz; |
---|
1836 | 1888 | |
---|
1837 | 1889 | // TEST TARGET |
---|
1838 | 1890 | // dst.x = CameraPane.selectedpoint.toParent[3][0]; |
---|
.. | .. |
---|
1954 | 2006 | // if (sourcenode.link2master) |
---|
1955 | 2007 | // if (goalx != 0 || goalz != 0) |
---|
1956 | 2008 | // K = 0.02; // .0625; |
---|
1957 | | - if (parent.link2master) // strong pin on floor |
---|
| 2009 | + if (parent.Link2Support()) // strong pin on floor |
---|
1958 | 2010 | { |
---|
1959 | 2011 | K = 0.05; // 0.02; |
---|
1960 | 2012 | } |
---|
.. | .. |
---|
2242 | 2294 | } |
---|
2243 | 2295 | |
---|
2244 | 2296 | if (!smoothed) |
---|
2245 | | - for (int i=0; --i>=0;) |
---|
| 2297 | + for (int i=10; --i>=0;) |
---|
2246 | 2298 | SmoothAnimData(); // much reduces shakiness |
---|
2247 | 2299 | |
---|
2248 | 2300 | smoothed = true; |
---|
.. | .. |
---|
2280 | 2332 | toVector.x = LA.cos(to); |
---|
2281 | 2333 | toVector.y = LA.sin(to); |
---|
2282 | 2334 | |
---|
| 2335 | + double fromA = Math.atan2(fromVector.y, fromVector.x); |
---|
| 2336 | + double toA = Math.atan2(toVector.y, toVector.x); |
---|
| 2337 | + |
---|
2283 | 2338 | Vector2d currentVector = Slerp(fromVector, toVector, step); |
---|
2284 | 2339 | |
---|
2285 | | - return Math.atan2(currentVector.y, currentVector.x); |
---|
| 2340 | + double angle = Math.atan2(currentVector.y, currentVector.x); |
---|
| 2341 | + |
---|
| 2342 | + double angle2 = (1-step) * fromA + step * toA; |
---|
| 2343 | + |
---|
| 2344 | + return angle; |
---|
2286 | 2345 | } |
---|
2287 | 2346 | |
---|
2288 | 2347 | public static Vector2d Slerp(Vector2d from, Vector2d to, double step) |
---|
.. | .. |
---|
2364 | 2423 | // SetBreakPoint(get(0).toParent[0], 0); |
---|
2365 | 2424 | // } |
---|
2366 | 2425 | |
---|
2367 | | - boolean setrotation = get(0).link2master && !firsttimeafterload && frame > 0; |
---|
| 2426 | + boolean setrotation = get(0).Link2Support() && !firsttimeafterload && frame > 0; |
---|
2368 | 2427 | boolean setposition = sourcenode != null && // sourcenode.parent != null && // july 2014 |
---|
2369 | | - sourcenode./*parent.*/link2master && !firsttimeafterload && frame > 0; |
---|
| 2428 | + sourcenode./*parent.*/Link2Support() && !firsttimeafterload && frame > 0; |
---|
2370 | 2429 | |
---|
2371 | 2430 | // cVector centroid = new cVector(); |
---|
2372 | 2431 | // cVector floor = new cVector(); |
---|
.. | .. |
---|
2765 | 2824 | //if (bone._rotationEnabled) |
---|
2766 | 2825 | if (//frame > 0 && |
---|
2767 | 2826 | !bone.skipmocap && |
---|
2768 | | - !bone.name.contains("head") // && |
---|
| 2827 | + !bone.name.contains("head") && |
---|
| 2828 | + !bone.name.contains("Head") // && |
---|
2769 | 2829 | // !bone.name.contains("rFoot") && |
---|
2770 | 2830 | // !bone.name.contains("lFoot") && |
---|
2771 | 2831 | // !bone.name.contains("Pinky") && |
---|
.. | .. |
---|
2798 | 2858 | |
---|
2799 | 2859 | // set translation |
---|
2800 | 2860 | // (currently only possible for root bone! see mocapdata.com data) |
---|
2801 | | - if (bone._isRoot && link2master) // && !GetFileRoot().link2master) |
---|
| 2861 | + if (bone._isRoot && Link2Support()) // && !GetFileRoot().link2master) |
---|
2802 | 2862 | { |
---|
2803 | 2863 | if (hasTranslation) // && _translationEnabled) |
---|
2804 | 2864 | { |
---|
.. | .. |
---|
3191 | 3251 | |
---|
3192 | 3252 | // july 2014 |
---|
3193 | 3253 | // goalx = goalz = 0; |
---|
3194 | | - targetx = targetz = 0; |
---|
| 3254 | + targetdirx = targetdirz = 0; |
---|
3195 | 3255 | |
---|
3196 | 3256 | //SetPositionDelta(true, true, true, false); |
---|
3197 | 3257 | // LoadData(); |
---|
.. | .. |
---|
3201 | 3261 | |
---|
3202 | 3262 | // aout 2013 endframe = 0; // june 2013 |
---|
3203 | 3263 | |
---|
3204 | | - //ResetZero(); |
---|
3205 | | - setPose(frame); |
---|
| 3264 | + ResetZero(); |
---|
| 3265 | + //setPose(frame); |
---|
3206 | 3266 | } |
---|
3207 | 3267 | |
---|
3208 | 3268 | static int mocapsupport = 0; |
---|
.. | .. |
---|
3220 | 3280 | |
---|
3221 | 3281 | int step = 1; |
---|
3222 | 3282 | |
---|
| 3283 | + // patch for running hare |
---|
3223 | 3284 | if (speedup) // fev 2014 |
---|
3224 | 3285 | step *= 2; // 4; |
---|
3225 | 3286 | if (rewind) // mars 2014 |
---|
3226 | 3287 | step *= 4; |
---|
3227 | 3288 | |
---|
3228 | | - if (CameraPane.FAST) // && !CameraPane.HOLD) |
---|
| 3289 | + //if (CameraPane.FAST) // && !CameraPane.HOLD) |
---|
3229 | 3290 | step *= CameraPane.STEP; |
---|
3230 | 3291 | |
---|
3231 | 3292 | //System.err.println("Step Mocap frame # " + frame); |
---|
.. | .. |
---|
3257 | 3318 | "; fullname = " + fullname); |
---|
3258 | 3319 | |
---|
3259 | 3320 | //int delta = frame - baseframe; |
---|
3260 | | - if (CameraPane.CROWD) |
---|
| 3321 | + if (Globals.CROWD) |
---|
3261 | 3322 | { |
---|
3262 | 3323 | baseframe = GetFirstFrame(); // 0 initial point |
---|
3263 | 3324 | } |
---|
.. | .. |
---|
3266 | 3327 | // SetPositionDelta(false, true, false); // ?? false); |
---|
3267 | 3328 | { |
---|
3268 | 3329 | if (support == null) |
---|
3269 | | - ObjEditor.LoadBVHFile(fullname, this, false, beginframe, lastframetest); |
---|
| 3330 | + { |
---|
| 3331 | + if (bvh == null && new File(fullname).exists()) |
---|
| 3332 | + ObjEditor.LoadBVHFile(fullname, this, false, beginframe, lastframetest); |
---|
| 3333 | + else |
---|
| 3334 | + { |
---|
| 3335 | + SetGlobalTransform(); |
---|
| 3336 | + Rewind(); |
---|
| 3337 | + Fade(); |
---|
| 3338 | + } |
---|
| 3339 | + } |
---|
3270 | 3340 | else |
---|
3271 | 3341 | { |
---|
3272 | | - try |
---|
3273 | | - { |
---|
| 3342 | +// try |
---|
| 3343 | +// { |
---|
3274 | 3344 | bvh = ((Mocap)support.get(mocapsupport++ % support.Size())).bvh; |
---|
3275 | 3345 | |
---|
3276 | 3346 | // SetPositionDelta(false, true, true, true); |
---|
3277 | 3347 | LoadData(); |
---|
3278 | 3348 | Rewind(); |
---|
3279 | 3349 | Fade(); |
---|
3280 | | - } |
---|
3281 | | - catch (Exception e) |
---|
3282 | | - { |
---|
3283 | | - e.printStackTrace(); |
---|
3284 | | - ObjEditor.LoadBVHFile(fullname, this, false, beginframe, lastframetest); |
---|
3285 | | - } |
---|
| 3350 | +// } |
---|
| 3351 | +// catch (Exception e) |
---|
| 3352 | +// { |
---|
| 3353 | +// System.err.println("An error occured while loading data. Use fallback by loading the file."); |
---|
| 3354 | +// //e.printStackTrace(); |
---|
| 3355 | +// try |
---|
| 3356 | +// { |
---|
| 3357 | +// ObjEditor.LoadBVHFile(fullname, this, false, beginframe, lastframetest); |
---|
| 3358 | +// } |
---|
| 3359 | +// catch (Exception e2) |
---|
| 3360 | +// { |
---|
| 3361 | +// System.err.println("Motion file not found: " + fullname); |
---|
| 3362 | +// } |
---|
| 3363 | +// } |
---|
3286 | 3364 | } |
---|
3287 | 3365 | } |
---|
3288 | 3366 | |
---|
.. | .. |
---|
3464 | 3542 | // filters out bad input data |
---|
3465 | 3543 | void FilterAnimData() |
---|
3466 | 3544 | { |
---|
| 3545 | + new Exception().printStackTrace(); |
---|
3467 | 3546 | System.exit(0); |
---|
3468 | 3547 | |
---|
3469 | 3548 | float[] data; // = bvh.animation.getBoneData(0); |
---|
.. | .. |
---|
3821 | 3900 | |
---|
3822 | 3901 | transient boolean restarted; // CROWD issue? |
---|
3823 | 3902 | |
---|
3824 | | - void drawSelf(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
| 3903 | + void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
3825 | 3904 | { |
---|
3826 | 3905 | //System.err.println("drawSelf Mocap frame # " + frame); |
---|
3827 | 3906 | //System.err.println("drawSelf Mocap baseframe # " + baseframe); |
---|
.. | .. |
---|
3838 | 3917 | // if (firstframe) |
---|
3839 | 3918 | // return; |
---|
3840 | 3919 | |
---|
3841 | | - if (!restarted && /*display.restartframe &&*/ |
---|
3842 | | - display.isLIVE() && live && display.drawMode == display.SHADOW) // FUCK |
---|
| 3920 | + if (//!restarted && /*display.restartframe &&*/ |
---|
| 3921 | + Globals.isLIVE() && live && (display.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE)) |
---|
3843 | 3922 | { |
---|
3844 | 3923 | //display.restartframe = false; |
---|
3845 | 3924 | restarted = true; |
---|
| 3925 | + //System.err.println("restarted = true"); |
---|
3846 | 3926 | Step(); |
---|
| 3927 | + |
---|
| 3928 | + Globals.lighttouched = true; |
---|
3847 | 3929 | } |
---|
3848 | 3930 | else |
---|
3849 | 3931 | { |
---|
3850 | | - if (display.isLIVE() && live && display.drawMode != display.SHADOW) |
---|
| 3932 | + //System.err.println("restarted"); |
---|
| 3933 | + if (Globals.isLIVE() && live && display.DrawMode() != iCameraPane.SHADOW) |
---|
| 3934 | + { |
---|
3851 | 3935 | restarted = false; |
---|
| 3936 | + //System.err.println("restarted = false"); |
---|
| 3937 | + } |
---|
3852 | 3938 | } |
---|
3853 | 3939 | |
---|
3854 | 3940 | super.drawSelf(display, root, selected, blocked); |
---|
.. | .. |
---|
3908 | 3994 | // GetObject().release(i); |
---|
3909 | 3995 | } |
---|
3910 | 3996 | |
---|
| 3997 | + boolean HasBigData() |
---|
| 3998 | + { |
---|
| 3999 | + return skeleton != null; |
---|
| 4000 | + } |
---|
| 4001 | + |
---|
3911 | 4002 | public Object3D get(int i) |
---|
3912 | 4003 | { |
---|
3913 | 4004 | if (i != 0) |
---|