.. | .. |
---|
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 | |
---|
.. | .. |
---|
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 | } |
---|
.. | .. |
---|
477 | 477 | } |
---|
478 | 478 | } |
---|
479 | 479 | |
---|
| 480 | + static cVector centroid = new cVector(); |
---|
| 481 | + static cVector mocaporigin = new cVector(); |
---|
| 482 | + |
---|
480 | 483 | void SetHipOrientation() |
---|
481 | 484 | { |
---|
482 | 485 | Object3D hip = get(0); |
---|
483 | 486 | |
---|
484 | 487 | LA.matConcat(toParent, hip.get(0).toParent, matrix); |
---|
485 | 488 | |
---|
486 | | - cVector centroid = new cVector(); |
---|
| 489 | + mocaporigin.x = matrix[3][0]; |
---|
| 490 | + mocaporigin.y = matrix[3][1]; |
---|
| 491 | + mocaporigin.z = matrix[3][2]; |
---|
| 492 | + |
---|
487 | 493 | centroid.x = matrix[3][0]; |
---|
488 | 494 | centroid.y = matrix[3][1]; |
---|
489 | 495 | centroid.z = matrix[3][2]; |
---|
490 | | - this.getCentroid(centroid, true); |
---|
| 496 | +// this.getCentroid(centroid, true); |
---|
| 497 | + |
---|
| 498 | + CameraPane.debugpointG.name = ""; |
---|
| 499 | + CameraPane.debugpointG.toParent[3][0] = mocaporigin.x; |
---|
| 500 | + CameraPane.debugpointG.toParent[3][1] = mocaporigin.y; |
---|
| 501 | + CameraPane.debugpointG.toParent[3][2] = mocaporigin.z; |
---|
| 502 | + |
---|
| 503 | + CameraPane.debugpointP.name = ""; |
---|
| 504 | + CameraPane.debugpointP.toParent[3][0] = centroid.x; |
---|
| 505 | + CameraPane.debugpointP.toParent[3][1] = centroid.y; |
---|
| 506 | + CameraPane.debugpointP.toParent[3][2] = centroid.z; |
---|
491 | 507 | |
---|
492 | 508 | cVector goal = GetGoal(centroid); |
---|
493 | 509 | if (goal != null) |
---|
494 | 510 | { |
---|
495 | | - System.err.println("GOAL change (" + this + "): " + goal + " (was " + goalx + ", " + goalz + ")"); |
---|
| 511 | + System.err.println("GOAL change (" + this + "): " + goal + " (was " + goalposx + ", " + goalposz + ")"); |
---|
496 | 512 | |
---|
497 | | - goalx = goal.x; |
---|
498 | | - goalz = goal.z; |
---|
499 | | - targetx = targetz = 0; |
---|
| 513 | + goalposx = goal.x; |
---|
| 514 | + goalposz = goal.z; |
---|
| 515 | + targetdirx = targetdirz = 0; |
---|
500 | 516 | } |
---|
501 | 517 | |
---|
502 | | - if (goalx == 0 && goalz == 0) |
---|
| 518 | + if (goalposx == 0 && goalposz == 0) |
---|
503 | 519 | { |
---|
504 | 520 | // No target |
---|
505 | 521 | if (ScriptNode.speaker != null) |
---|
.. | .. |
---|
533 | 549 | //sourcenode.parent.TransformToLocal(dst); |
---|
534 | 550 | this.parent.TransformToLocal(dst); |
---|
535 | 551 | |
---|
536 | | - goalx = dst.x; |
---|
537 | | - goalz = dst.z; |
---|
| 552 | + goalposx = dst.x; |
---|
| 553 | + goalposz = dst.z; |
---|
538 | 554 | } |
---|
539 | 555 | else |
---|
540 | 556 | return; |
---|
.. | .. |
---|
550 | 566 | |
---|
551 | 567 | double angleYhip = Math.atan2(-temp.z, temp.x); |
---|
552 | 568 | |
---|
553 | | - double angleYtarget = Math.atan2(goalx - centroid.x, goalz - centroid.z); |
---|
| 569 | + double angleYtarget = Math.atan2(goalposx - centroid.x, goalposz - centroid.z); |
---|
554 | 570 | |
---|
555 | 571 | LA.matIdentity(matrix); |
---|
556 | 572 | LA.matTranslate(matrix, -centroid.x, -centroid.y, -centroid.z); |
---|
557 | | - double angle = CurveAngle(0, angleYtarget - angleYhip, 1); // 0.1f); |
---|
| 573 | + double angle = CurveAngle(0, angleYtarget - angleYhip, 0.1f); |
---|
558 | 574 | LA.matYRotate(matrix, angle); |
---|
559 | 575 | LA.matTranslate(matrix, centroid.x, centroid.y, centroid.z); |
---|
560 | 576 | |
---|
561 | 577 | LA.matConcat(matrix, toParent, toParent); |
---|
562 | 578 | |
---|
563 | 579 | LA.matInvert(toParent, fromParent); |
---|
| 580 | + |
---|
| 581 | + LA.matConcat(toParent, hip.get(0).toParent, matrix); |
---|
| 582 | + |
---|
| 583 | + centroid.x = matrix[3][0]; |
---|
| 584 | + centroid.y = matrix[3][1]; |
---|
| 585 | + centroid.z = matrix[3][2]; |
---|
| 586 | + |
---|
| 587 | + double dist = LA.distance(centroid, mocaporigin); |
---|
564 | 588 | |
---|
565 | 589 | CheckForAction(centroid); |
---|
566 | 590 | } |
---|
.. | .. |
---|
637 | 661 | double pinx; |
---|
638 | 662 | double pinz; |
---|
639 | 663 | |
---|
640 | | - double targetx; |
---|
641 | | - double targetz; |
---|
| 664 | + double targetdirx; |
---|
| 665 | + double targetdirz; |
---|
642 | 666 | |
---|
643 | | - double goalx = -20; |
---|
644 | | - double goalz = -10; |
---|
| 667 | + double goalposx = -20; |
---|
| 668 | + double goalposz = -10; |
---|
645 | 669 | |
---|
646 | 670 | boolean followpath; |
---|
647 | 671 | |
---|
.. | .. |
---|
712 | 736 | scriptactions.clear(); |
---|
713 | 737 | } |
---|
714 | 738 | |
---|
715 | | - static double EPSACTION = 0.1; // 0.075; // 0.1; |
---|
| 739 | + static double EPSACTION = 0.1; // 0.075; // 0.1;Came |
---|
716 | 740 | |
---|
717 | 741 | void AddFromTo(cVector from, cVector to) |
---|
718 | 742 | { |
---|
.. | .. |
---|
1278 | 1302 | |
---|
1279 | 1303 | void SetPosition(Object3D sourcenode, cVector floor, long floorid, cVector centroid) |
---|
1280 | 1304 | { |
---|
| 1305 | + assert(false); |
---|
1281 | 1306 | //assert(CameraPane.drawMode == CameraPane.SHADOW); |
---|
1282 | 1307 | |
---|
1283 | 1308 | Object3D transformnode = new Object3D(); |
---|
.. | .. |
---|
1481 | 1506 | groundid = floorid; |
---|
1482 | 1507 | |
---|
1483 | 1508 | // green |
---|
1484 | | - CameraPane.debugpoint.toParent[3][0] = groundx; |
---|
1485 | | - CameraPane.debugpoint.toParent[3][1] = floor.y; |
---|
1486 | | - CameraPane.debugpoint.toParent[3][2] = groundz; |
---|
| 1509 | + CameraPane.debugpointG.toParent[3][0] = groundx; |
---|
| 1510 | + CameraPane.debugpointG.toParent[3][1] = floor.y; |
---|
| 1511 | + CameraPane.debugpointG.toParent[3][2] = groundz; |
---|
1487 | 1512 | |
---|
1488 | 1513 | if (true) // slow && stepout && onein) |
---|
1489 | 1514 | { |
---|
.. | .. |
---|
1560 | 1585 | |
---|
1561 | 1586 | // System.out.println("Allo " + sourcenode); |
---|
1562 | 1587 | // 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; |
---|
| 1588 | + CameraPane.debugpointP.toParent[3][0] = floor.x;// + posx; |
---|
| 1589 | + CameraPane.debugpointP.toParent[3][1] = ground; // floor.y;// + sourcenode.parent.toParent[3][1]; |
---|
| 1590 | + CameraPane.debugpointP.toParent[3][2] = floor.z;// + posz; |
---|
1566 | 1591 | |
---|
1567 | 1592 | |
---|
1568 | 1593 | if (false) // dist2 > 0.1) |
---|
.. | .. |
---|
1628 | 1653 | this.get(0).TransformToWorld(v0); |
---|
1629 | 1654 | |
---|
1630 | 1655 | // cyan |
---|
1631 | | - CameraPane.debugpoint3.toParent[3][0] = v0.x; |
---|
1632 | | - CameraPane.debugpoint3.toParent[3][1] = ground; |
---|
1633 | | - CameraPane.debugpoint3.toParent[3][2] = v0.z; |
---|
| 1656 | + CameraPane.debugpointC.toParent[3][0] = v0.x; |
---|
| 1657 | + CameraPane.debugpointC.toParent[3][1] = ground; |
---|
| 1658 | + CameraPane.debugpointC.toParent[3][2] = v0.z; |
---|
1634 | 1659 | |
---|
1635 | 1660 | LA.matConcat(sourcenode.toParent, transformnode.toParent, sourcenode.toParent); |
---|
1636 | 1661 | LA.matInvert(sourcenode.toParent, sourcenode.fromParent); |
---|
.. | .. |
---|
1640 | 1665 | this.get(0).TransformToWorld(v0); |
---|
1641 | 1666 | |
---|
1642 | 1667 | // red |
---|
1643 | | - CameraPane.debugpoint4.toParent[3][0] = v0.x; |
---|
1644 | | - CameraPane.debugpoint4.toParent[3][1] = ground; |
---|
1645 | | - CameraPane.debugpoint4.toParent[3][2] = v0.z; |
---|
| 1668 | + CameraPane.debugpointR.toParent[3][0] = v0.x; |
---|
| 1669 | + CameraPane.debugpointR.toParent[3][1] = ground; |
---|
| 1670 | + CameraPane.debugpointR.toParent[3][2] = v0.z; |
---|
1646 | 1671 | } |
---|
1647 | 1672 | } |
---|
1648 | 1673 | |
---|
.. | .. |
---|
1682 | 1707 | |
---|
1683 | 1708 | if (goal != null) |
---|
1684 | 1709 | { |
---|
1685 | | - System.err.println("GOAL change (" + sourcenode + "): " + goal + " (was " + goalx + ", " + goalz + ")"); |
---|
| 1710 | + System.err.println("GOAL change (" + sourcenode + "): " + goal + " (was " + goalposx + ", " + goalposz + ")"); |
---|
1686 | 1711 | //sourcenode.parent.parent.Dump(); |
---|
1687 | | - goalx = goal.x; |
---|
1688 | | - goalz = goal.z; |
---|
1689 | | - targetx = targetz = 0; |
---|
| 1712 | + goalposx = goal.x; |
---|
| 1713 | + goalposz = goal.z; |
---|
| 1714 | + targetdirx = targetdirz = 0; |
---|
1690 | 1715 | |
---|
1691 | 1716 | followpath = true; |
---|
1692 | 1717 | } |
---|
.. | .. |
---|
1737 | 1762 | // } |
---|
1738 | 1763 | if (false) // !uselast) |
---|
1739 | 1764 | { |
---|
1740 | | - CameraPane.debugpoint.toParent[3][0] = dst.x; |
---|
1741 | | - CameraPane.debugpoint.toParent[3][1] = dst.y; |
---|
1742 | | - CameraPane.debugpoint.toParent[3][2] = dst.z; |
---|
| 1765 | + CameraPane.debugpointG.toParent[3][0] = dst.x; |
---|
| 1766 | + CameraPane.debugpointG.toParent[3][1] = dst.y; |
---|
| 1767 | + CameraPane.debugpointG.toParent[3][2] = dst.z; |
---|
1743 | 1768 | } |
---|
1744 | 1769 | } |
---|
1745 | 1770 | |
---|
1746 | | - if (goalx != 0 || goalz != 0) // TODO |
---|
| 1771 | + if (goalposx != 0 || goalposz != 0) // TODO |
---|
1747 | 1772 | { |
---|
1748 | 1773 | // overwrite speaker orientation |
---|
1749 | | - dst.set(goalx,0,goalz); |
---|
| 1774 | + dst.set(goalposx,0,goalposz); |
---|
1750 | 1775 | if (sourcenode.parent != null) // july 2014 |
---|
1751 | 1776 | sourcenode.parent. |
---|
1752 | 1777 | TransformToLocal(dst); |
---|
.. | .. |
---|
1798 | 1823 | // mars 2014 |
---|
1799 | 1824 | if (false) // goalx != 0 || goalz != 0) |
---|
1800 | 1825 | { |
---|
1801 | | - targetx = dst.x - src.x; |
---|
1802 | | - targetz = dst.z - src.z; |
---|
| 1826 | + targetdirx = dst.x - src.x; |
---|
| 1827 | + targetdirz = dst.z - src.z; |
---|
1803 | 1828 | |
---|
1804 | | - if (Math.abs(targetx) > 0.1 || Math.abs(targetz) > 0.1) |
---|
| 1829 | + if (Math.abs(targetdirx) > 0.1 || Math.abs(targetdirz) > 0.1) |
---|
1805 | 1830 | { |
---|
1806 | 1831 | // far enough from goal. keep the goal position. |
---|
1807 | | - targetx = 0; |
---|
1808 | | - targetz = 0; |
---|
| 1832 | + targetdirx = 0; |
---|
| 1833 | + targetdirz = 0; |
---|
1809 | 1834 | } |
---|
1810 | 1835 | else |
---|
1811 | 1836 | { |
---|
1812 | 1837 | // too close to goal. switch to target direction instead. |
---|
1813 | | - goalx = 0; |
---|
1814 | | - goalz = 0; |
---|
| 1838 | + goalposx = 0; |
---|
| 1839 | + goalposz = 0; |
---|
1815 | 1840 | } |
---|
1816 | 1841 | } |
---|
1817 | 1842 | |
---|
1818 | 1843 | //sourcenode.getCentroid(src, true); |
---|
1819 | 1844 | |
---|
1820 | | - if (speakernode == sourcenode && goalx == 0 && goalz == 0) |
---|
| 1845 | + if (speakernode == sourcenode && goalposx == 0 && goalposz == 0) |
---|
1821 | 1846 | { |
---|
1822 | 1847 | if (ScriptNode.lastspeaker != null) |
---|
1823 | 1848 | new Exception().printStackTrace(); |
---|
.. | .. |
---|
1826 | 1851 | |
---|
1827 | 1852 | // LA.xformPos(src, fromParent, src); |
---|
1828 | 1853 | |
---|
1829 | | - if ((ScriptNode.speaker != null && CameraPane.SPEAKERMOCAP || goalx != 0 || goalz != 0) && targetx == 0 && targetz == 0) |
---|
| 1854 | + if ((ScriptNode.speaker != null && CameraPane.SPEAKERMOCAP || goalposx != 0 || goalposz != 0) && targetdirx == 0 && targetdirz == 0) |
---|
1830 | 1855 | dst.sub(src); |
---|
1831 | 1856 | else |
---|
1832 | 1857 | // vector mode |
---|
1833 | 1858 | { |
---|
1834 | | - dst.x = targetx; |
---|
1835 | | - dst.z = targetz; |
---|
| 1859 | + dst.x = targetdirx; |
---|
| 1860 | + dst.z = targetdirz; |
---|
1836 | 1861 | |
---|
1837 | 1862 | // TEST TARGET |
---|
1838 | 1863 | // dst.x = CameraPane.selectedpoint.toParent[3][0]; |
---|
.. | .. |
---|
2280 | 2305 | toVector.x = LA.cos(to); |
---|
2281 | 2306 | toVector.y = LA.sin(to); |
---|
2282 | 2307 | |
---|
| 2308 | + double fromA = Math.atan2(fromVector.y, fromVector.x); |
---|
| 2309 | + double toA = Math.atan2(toVector.y, toVector.x); |
---|
| 2310 | + |
---|
2283 | 2311 | Vector2d currentVector = Slerp(fromVector, toVector, step); |
---|
2284 | 2312 | |
---|
2285 | | - return Math.atan2(currentVector.y, currentVector.x); |
---|
| 2313 | + double angle = Math.atan2(currentVector.y, currentVector.x); |
---|
| 2314 | + |
---|
| 2315 | + double angle2 = (1-step) * fromA + step * toA; |
---|
| 2316 | + |
---|
| 2317 | + return angle; |
---|
2286 | 2318 | } |
---|
2287 | 2319 | |
---|
2288 | 2320 | public static Vector2d Slerp(Vector2d from, Vector2d to, double step) |
---|
.. | .. |
---|
3191 | 3223 | |
---|
3192 | 3224 | // july 2014 |
---|
3193 | 3225 | // goalx = goalz = 0; |
---|
3194 | | - targetx = targetz = 0; |
---|
| 3226 | + targetdirx = targetdirz = 0; |
---|
3195 | 3227 | |
---|
3196 | 3228 | //SetPositionDelta(true, true, true, false); |
---|
3197 | 3229 | // LoadData(); |
---|