.. | .. |
---|
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 | { |
---|
.. | .. |
---|
549 | 667 | double pinx; |
---|
550 | 668 | double pinz; |
---|
551 | 669 | |
---|
552 | | - double targetx; |
---|
553 | | - double targetz; |
---|
| 670 | + double targetdirx; |
---|
| 671 | + double targetdirz; |
---|
554 | 672 | |
---|
555 | | - double goalx; |
---|
556 | | - double goalz; |
---|
| 673 | + double goalposx = 0; // -20; |
---|
| 674 | + double goalposz = 0; // -10; |
---|
557 | 675 | |
---|
558 | 676 | boolean followpath; |
---|
559 | 677 | |
---|
.. | .. |
---|
624 | 742 | scriptactions.clear(); |
---|
625 | 743 | } |
---|
626 | 744 | |
---|
627 | | - static double EPSACTION = 0.1; // 0.075; // 0.1; |
---|
| 745 | + static double EPSACTION = 0.1; // 0.075; // 0.1;Came |
---|
628 | 746 | |
---|
629 | 747 | void AddFromTo(cVector from, cVector to) |
---|
630 | 748 | { |
---|
.. | .. |
---|
809 | 927 | // //GetFileRoot(); |
---|
810 | 928 | |
---|
811 | 929 | // sept 2014: // |
---|
812 | | - GrafreeD.RENDERME = 3; // patch for Merge objects |
---|
| 930 | + Grafreed.RENDERME = 3; // patch for Merge objects |
---|
813 | 931 | float[] thedata = bvh.animation.getBoneData(0); |
---|
814 | 932 | |
---|
815 | 933 | os.x = (float) (path.get(i).toParent[3][0]); // - thedata[frame*6]); |
---|
.. | .. |
---|
910 | 1028 | testvect.set(from); |
---|
911 | 1029 | testvect.sub(fromto.from); |
---|
912 | 1030 | |
---|
| 1031 | + testvect.y = 0; // PATCH |
---|
| 1032 | + |
---|
913 | 1033 | int factor = 1; |
---|
914 | 1034 | |
---|
915 | 1035 | //if (CameraPane.FAST) |
---|
.. | .. |
---|
951 | 1071 | |
---|
952 | 1072 | testvect.set(from); |
---|
953 | 1073 | testvect.sub(fromto.from); |
---|
| 1074 | + |
---|
| 1075 | + testvect.y = 0; // PATCH |
---|
954 | 1076 | |
---|
955 | 1077 | int factor = 1; |
---|
956 | 1078 | |
---|
.. | .. |
---|
1186 | 1308 | |
---|
1187 | 1309 | void SetPosition(Object3D sourcenode, cVector floor, long floorid, cVector centroid) |
---|
1188 | 1310 | { |
---|
| 1311 | + assert(false); |
---|
1189 | 1312 | //assert(CameraPane.drawMode == CameraPane.SHADOW); |
---|
1190 | 1313 | |
---|
1191 | 1314 | Object3D transformnode = new Object3D(); |
---|
.. | .. |
---|
1389 | 1512 | groundid = floorid; |
---|
1390 | 1513 | |
---|
1391 | 1514 | // green |
---|
1392 | | - CameraPane.debugpoint.toParent[3][0] = groundx; |
---|
1393 | | - CameraPane.debugpoint.toParent[3][1] = floor.y; |
---|
1394 | | - CameraPane.debugpoint.toParent[3][2] = groundz; |
---|
| 1515 | + CameraPane.debugpointG.toParent[3][0] = groundx; |
---|
| 1516 | + CameraPane.debugpointG.toParent[3][1] = floor.y; |
---|
| 1517 | + CameraPane.debugpointG.toParent[3][2] = groundz; |
---|
1395 | 1518 | |
---|
1396 | 1519 | if (true) // slow && stepout && onein) |
---|
1397 | 1520 | { |
---|
.. | .. |
---|
1402 | 1525 | // mywave = currentwave++; |
---|
1403 | 1526 | // } |
---|
1404 | 1527 | // sound |
---|
1405 | | - cVector eye = CameraPane.theRenderer.eyeCamera.location; |
---|
| 1528 | + cVector eye = Globals.theRenderer.EyeCamera().location; |
---|
1406 | 1529 | |
---|
1407 | 1530 | // if (sourcenode.parent.parent != null) |
---|
1408 | 1531 | // sourcenode.parent.parent.TransformToWorld(floor, tmp); |
---|
.. | .. |
---|
1447 | 1570 | //GraphreeD. |
---|
1448 | 1571 | wav.play(volume * usedvolume); //, mywave); |
---|
1449 | 1572 | |
---|
1450 | | - lastsoundtime = CameraPane.framecount; |
---|
| 1573 | + lastsoundtime = Globals.framecount; |
---|
1451 | 1574 | |
---|
1452 | | - GrafreeD.hassound = true; |
---|
| 1575 | + Grafreed.hassound = true; |
---|
1453 | 1576 | } |
---|
1454 | 1577 | // else |
---|
1455 | 1578 | // System.out.println("skipped"); |
---|
.. | .. |
---|
1468 | 1591 | |
---|
1469 | 1592 | // System.out.println("Allo " + sourcenode); |
---|
1470 | 1593 | // 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; |
---|
| 1594 | + CameraPane.debugpointP.toParent[3][0] = floor.x;// + posx; |
---|
| 1595 | + CameraPane.debugpointP.toParent[3][1] = ground; // floor.y;// + sourcenode.parent.toParent[3][1]; |
---|
| 1596 | + CameraPane.debugpointP.toParent[3][2] = floor.z;// + posz; |
---|
1474 | 1597 | |
---|
1475 | 1598 | |
---|
1476 | 1599 | if (false) // dist2 > 0.1) |
---|
.. | .. |
---|
1536 | 1659 | this.get(0).TransformToWorld(v0); |
---|
1537 | 1660 | |
---|
1538 | 1661 | // cyan |
---|
1539 | | - CameraPane.debugpoint3.toParent[3][0] = v0.x; |
---|
1540 | | - CameraPane.debugpoint3.toParent[3][1] = ground; |
---|
1541 | | - CameraPane.debugpoint3.toParent[3][2] = v0.z; |
---|
| 1662 | + CameraPane.debugpointC.toParent[3][0] = v0.x; |
---|
| 1663 | + CameraPane.debugpointC.toParent[3][1] = ground; |
---|
| 1664 | + CameraPane.debugpointC.toParent[3][2] = v0.z; |
---|
1542 | 1665 | |
---|
1543 | 1666 | LA.matConcat(sourcenode.toParent, transformnode.toParent, sourcenode.toParent); |
---|
1544 | 1667 | LA.matInvert(sourcenode.toParent, sourcenode.fromParent); |
---|
.. | .. |
---|
1548 | 1671 | this.get(0).TransformToWorld(v0); |
---|
1549 | 1672 | |
---|
1550 | 1673 | // red |
---|
1551 | | - CameraPane.debugpoint4.toParent[3][0] = v0.x; |
---|
1552 | | - CameraPane.debugpoint4.toParent[3][1] = ground; |
---|
1553 | | - CameraPane.debugpoint4.toParent[3][2] = v0.z; |
---|
| 1674 | + CameraPane.debugpointR.toParent[3][0] = v0.x; |
---|
| 1675 | + CameraPane.debugpointR.toParent[3][1] = ground; |
---|
| 1676 | + CameraPane.debugpointR.toParent[3][2] = v0.z; |
---|
1554 | 1677 | } |
---|
1555 | 1678 | } |
---|
1556 | 1679 | |
---|
.. | .. |
---|
1590 | 1713 | |
---|
1591 | 1714 | if (goal != null) |
---|
1592 | 1715 | { |
---|
1593 | | - System.err.println("GOAL change (" + sourcenode + "): " + goal + " (was " + goalx + ", " + goalz + ")"); |
---|
| 1716 | + System.err.println("GOAL change (" + sourcenode + "): " + goal + " (was " + goalposx + ", " + goalposz + ")"); |
---|
1594 | 1717 | //sourcenode.parent.parent.Dump(); |
---|
1595 | | - goalx = goal.x; |
---|
1596 | | - goalz = goal.z; |
---|
1597 | | - targetx = targetz = 0; |
---|
| 1718 | + goalposx = goal.x; |
---|
| 1719 | + goalposz = goal.z; |
---|
| 1720 | + targetdirx = targetdirz = 0; |
---|
1598 | 1721 | |
---|
1599 | 1722 | followpath = true; |
---|
1600 | 1723 | } |
---|
.. | .. |
---|
1645 | 1768 | // } |
---|
1646 | 1769 | if (false) // !uselast) |
---|
1647 | 1770 | { |
---|
1648 | | - CameraPane.debugpoint.toParent[3][0] = dst.x; |
---|
1649 | | - CameraPane.debugpoint.toParent[3][1] = dst.y; |
---|
1650 | | - CameraPane.debugpoint.toParent[3][2] = dst.z; |
---|
| 1771 | + CameraPane.debugpointG.toParent[3][0] = dst.x; |
---|
| 1772 | + CameraPane.debugpointG.toParent[3][1] = dst.y; |
---|
| 1773 | + CameraPane.debugpointG.toParent[3][2] = dst.z; |
---|
1651 | 1774 | } |
---|
1652 | 1775 | } |
---|
1653 | 1776 | |
---|
1654 | | - if (goalx != 0 || goalz != 0) // TODO |
---|
| 1777 | + if (goalposx != 0 || goalposz != 0) // TODO |
---|
1655 | 1778 | { |
---|
1656 | 1779 | // overwrite speaker orientation |
---|
1657 | | - dst.set(goalx,0,goalz); |
---|
| 1780 | + dst.set(goalposx,0,goalposz); |
---|
1658 | 1781 | if (sourcenode.parent != null) // july 2014 |
---|
1659 | 1782 | sourcenode.parent. |
---|
1660 | 1783 | TransformToLocal(dst); |
---|
.. | .. |
---|
1706 | 1829 | // mars 2014 |
---|
1707 | 1830 | if (false) // goalx != 0 || goalz != 0) |
---|
1708 | 1831 | { |
---|
1709 | | - targetx = dst.x - src.x; |
---|
1710 | | - targetz = dst.z - src.z; |
---|
| 1832 | + targetdirx = dst.x - src.x; |
---|
| 1833 | + targetdirz = dst.z - src.z; |
---|
1711 | 1834 | |
---|
1712 | | - if (Math.abs(targetx) > 0.1 || Math.abs(targetz) > 0.1) |
---|
| 1835 | + if (Math.abs(targetdirx) > 0.1 || Math.abs(targetdirz) > 0.1) |
---|
1713 | 1836 | { |
---|
1714 | 1837 | // far enough from goal. keep the goal position. |
---|
1715 | | - targetx = 0; |
---|
1716 | | - targetz = 0; |
---|
| 1838 | + targetdirx = 0; |
---|
| 1839 | + targetdirz = 0; |
---|
1717 | 1840 | } |
---|
1718 | 1841 | else |
---|
1719 | 1842 | { |
---|
1720 | 1843 | // too close to goal. switch to target direction instead. |
---|
1721 | | - goalx = 0; |
---|
1722 | | - goalz = 0; |
---|
| 1844 | + goalposx = 0; |
---|
| 1845 | + goalposz = 0; |
---|
1723 | 1846 | } |
---|
1724 | 1847 | } |
---|
1725 | 1848 | |
---|
1726 | 1849 | //sourcenode.getCentroid(src, true); |
---|
1727 | 1850 | |
---|
1728 | | - if (speakernode == sourcenode && goalx == 0 && goalz == 0) |
---|
| 1851 | + if (speakernode == sourcenode && goalposx == 0 && goalposz == 0) |
---|
1729 | 1852 | { |
---|
1730 | 1853 | if (ScriptNode.lastspeaker != null) |
---|
1731 | 1854 | new Exception().printStackTrace(); |
---|
.. | .. |
---|
1734 | 1857 | |
---|
1735 | 1858 | // LA.xformPos(src, fromParent, src); |
---|
1736 | 1859 | |
---|
1737 | | - if ((ScriptNode.speaker != null && CameraPane.SPEAKERMOCAP || goalx != 0 || goalz != 0) && targetx == 0 && targetz == 0) |
---|
| 1860 | + if ((ScriptNode.speaker != null && CameraPane.SPEAKERMOCAP || goalposx != 0 || goalposz != 0) && targetdirx == 0 && targetdirz == 0) |
---|
1738 | 1861 | dst.sub(src); |
---|
1739 | 1862 | else |
---|
1740 | 1863 | // vector mode |
---|
1741 | 1864 | { |
---|
1742 | | - dst.x = targetx; |
---|
1743 | | - dst.z = targetz; |
---|
| 1865 | + dst.x = targetdirx; |
---|
| 1866 | + dst.z = targetdirz; |
---|
1744 | 1867 | |
---|
1745 | 1868 | // TEST TARGET |
---|
1746 | 1869 | // dst.x = CameraPane.selectedpoint.toParent[3][0]; |
---|
.. | .. |
---|
2150 | 2273 | } |
---|
2151 | 2274 | |
---|
2152 | 2275 | if (!smoothed) |
---|
2153 | | - for (int i=0; --i>=0;) |
---|
| 2276 | + for (int i=10; --i>=0;) |
---|
2154 | 2277 | SmoothAnimData(); // much reduces shakiness |
---|
2155 | 2278 | |
---|
2156 | 2279 | smoothed = true; |
---|
.. | .. |
---|
2188 | 2311 | toVector.x = LA.cos(to); |
---|
2189 | 2312 | toVector.y = LA.sin(to); |
---|
2190 | 2313 | |
---|
| 2314 | + double fromA = Math.atan2(fromVector.y, fromVector.x); |
---|
| 2315 | + double toA = Math.atan2(toVector.y, toVector.x); |
---|
| 2316 | + |
---|
2191 | 2317 | Vector2d currentVector = Slerp(fromVector, toVector, step); |
---|
2192 | 2318 | |
---|
2193 | | - return Math.atan2(currentVector.y, currentVector.x); |
---|
| 2319 | + double angle = Math.atan2(currentVector.y, currentVector.x); |
---|
| 2320 | + |
---|
| 2321 | + double angle2 = (1-step) * fromA + step * toA; |
---|
| 2322 | + |
---|
| 2323 | + return angle; |
---|
2194 | 2324 | } |
---|
2195 | 2325 | |
---|
2196 | 2326 | public static Vector2d Slerp(Vector2d from, Vector2d to, double step) |
---|
.. | .. |
---|
2242 | 2372 | { |
---|
2243 | 2373 | e.printStackTrace(); |
---|
2244 | 2374 | } |
---|
| 2375 | + |
---|
| 2376 | + SetHipOrientation(); |
---|
2245 | 2377 | |
---|
2246 | 2378 | if (true) |
---|
2247 | 2379 | return; |
---|
.. | .. |
---|
2670 | 2802 | // set rotation |
---|
2671 | 2803 | //if (bone._rotationEnabled) |
---|
2672 | 2804 | if (//frame > 0 && |
---|
2673 | | - !bone.skipmocap //&& |
---|
2674 | | - //!bone.name.contains("head") && |
---|
| 2805 | + !bone.skipmocap && |
---|
| 2806 | + !bone.name.contains("head") && |
---|
| 2807 | + !bone.name.contains("Head") // && |
---|
2675 | 2808 | // !bone.name.contains("rFoot") && |
---|
2676 | 2809 | // !bone.name.contains("lFoot") && |
---|
2677 | 2810 | // !bone.name.contains("Pinky") && |
---|
.. | .. |
---|
3096 | 3229 | // LA.matIdentity(rot.fromParent); |
---|
3097 | 3230 | |
---|
3098 | 3231 | // july 2014 |
---|
3099 | | - goalx = goalz = 0; |
---|
3100 | | - targetx = targetz = 0; |
---|
| 3232 | +// goalx = goalz = 0; |
---|
| 3233 | + targetdirx = targetdirz = 0; |
---|
3101 | 3234 | |
---|
3102 | 3235 | //SetPositionDelta(true, true, true, false); |
---|
3103 | 3236 | // LoadData(); |
---|
.. | .. |
---|
3107 | 3240 | |
---|
3108 | 3241 | // aout 2013 endframe = 0; // june 2013 |
---|
3109 | 3242 | |
---|
3110 | | - //ResetZero(); |
---|
3111 | | - setPose(frame); |
---|
| 3243 | + ResetZero(); |
---|
| 3244 | + //setPose(frame); |
---|
3112 | 3245 | } |
---|
3113 | 3246 | |
---|
3114 | 3247 | static int mocapsupport = 0; |
---|
.. | .. |
---|
3126 | 3259 | |
---|
3127 | 3260 | int step = 1; |
---|
3128 | 3261 | |
---|
| 3262 | + // patch for running hare |
---|
3129 | 3263 | if (speedup) // fev 2014 |
---|
3130 | 3264 | step *= 2; // 4; |
---|
3131 | 3265 | if (rewind) // mars 2014 |
---|
3132 | 3266 | step *= 4; |
---|
3133 | 3267 | |
---|
3134 | | - if (CameraPane.FAST) // && !CameraPane.HOLD) |
---|
| 3268 | + //if (CameraPane.FAST) // && !CameraPane.HOLD) |
---|
3135 | 3269 | step *= CameraPane.STEP; |
---|
3136 | 3270 | |
---|
3137 | 3271 | //System.err.println("Step Mocap frame # " + frame); |
---|
.. | .. |
---|
3163 | 3297 | "; fullname = " + fullname); |
---|
3164 | 3298 | |
---|
3165 | 3299 | //int delta = frame - baseframe; |
---|
3166 | | - if (CameraPane.CROWD) |
---|
| 3300 | + if (Globals.CROWD) |
---|
3167 | 3301 | { |
---|
3168 | 3302 | baseframe = GetFirstFrame(); // 0 initial point |
---|
3169 | 3303 | } |
---|
.. | .. |
---|
3172 | 3306 | // SetPositionDelta(false, true, false); // ?? false); |
---|
3173 | 3307 | { |
---|
3174 | 3308 | if (support == null) |
---|
3175 | | - ObjEditor.LoadBVHFile(fullname, this, false, beginframe, lastframetest); |
---|
| 3309 | + { |
---|
| 3310 | + if (bvh == null && new File(fullname).exists()) |
---|
| 3311 | + ObjEditor.LoadBVHFile(fullname, this, false, beginframe, lastframetest); |
---|
| 3312 | + else |
---|
| 3313 | + { |
---|
| 3314 | + SetGlobalTransform(); |
---|
| 3315 | + Rewind(); |
---|
| 3316 | + Fade(); |
---|
| 3317 | + } |
---|
| 3318 | + } |
---|
3176 | 3319 | else |
---|
3177 | 3320 | { |
---|
3178 | | - try |
---|
3179 | | - { |
---|
| 3321 | +// try |
---|
| 3322 | +// { |
---|
3180 | 3323 | bvh = ((Mocap)support.get(mocapsupport++ % support.Size())).bvh; |
---|
3181 | 3324 | |
---|
3182 | 3325 | // SetPositionDelta(false, true, true, true); |
---|
3183 | 3326 | LoadData(); |
---|
3184 | 3327 | Rewind(); |
---|
3185 | 3328 | Fade(); |
---|
3186 | | - } |
---|
3187 | | - catch (Exception e) |
---|
3188 | | - { |
---|
3189 | | - e.printStackTrace(); |
---|
3190 | | - ObjEditor.LoadBVHFile(fullname, this, false, beginframe, lastframetest); |
---|
3191 | | - } |
---|
| 3329 | +// } |
---|
| 3330 | +// catch (Exception e) |
---|
| 3331 | +// { |
---|
| 3332 | +// System.err.println("An error occured while loading data. Use fallback by loading the file."); |
---|
| 3333 | +// //e.printStackTrace(); |
---|
| 3334 | +// try |
---|
| 3335 | +// { |
---|
| 3336 | +// ObjEditor.LoadBVHFile(fullname, this, false, beginframe, lastframetest); |
---|
| 3337 | +// } |
---|
| 3338 | +// catch (Exception e2) |
---|
| 3339 | +// { |
---|
| 3340 | +// System.err.println("Motion file not found: " + fullname); |
---|
| 3341 | +// } |
---|
| 3342 | +// } |
---|
3192 | 3343 | } |
---|
3193 | 3344 | } |
---|
3194 | 3345 | |
---|
.. | .. |
---|
3370 | 3521 | // filters out bad input data |
---|
3371 | 3522 | void FilterAnimData() |
---|
3372 | 3523 | { |
---|
| 3524 | + new Exception().printStackTrace(); |
---|
3373 | 3525 | System.exit(0); |
---|
3374 | 3526 | |
---|
3375 | 3527 | float[] data; // = bvh.animation.getBoneData(0); |
---|
.. | .. |
---|
3727 | 3879 | |
---|
3728 | 3880 | transient boolean restarted; // CROWD issue? |
---|
3729 | 3881 | |
---|
3730 | | - void drawSelf(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
| 3882 | + void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
3731 | 3883 | { |
---|
3732 | 3884 | //System.err.println("drawSelf Mocap frame # " + frame); |
---|
3733 | 3885 | //System.err.println("drawSelf Mocap baseframe # " + baseframe); |
---|
.. | .. |
---|
3744 | 3896 | // if (firstframe) |
---|
3745 | 3897 | // return; |
---|
3746 | 3898 | |
---|
3747 | | - if (!restarted && /*display.restartframe &&*/ |
---|
3748 | | - display.isLIVE() && live && display.drawMode == display.SHADOW) // FUCK |
---|
| 3899 | + if (//!restarted && /*display.restartframe &&*/ |
---|
| 3900 | + Globals.isLIVE() && live && (display.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW)) |
---|
3749 | 3901 | { |
---|
3750 | 3902 | //display.restartframe = false; |
---|
3751 | 3903 | restarted = true; |
---|
| 3904 | + //System.err.println("restarted = true"); |
---|
3752 | 3905 | Step(); |
---|
3753 | 3906 | } |
---|
3754 | 3907 | else |
---|
3755 | 3908 | { |
---|
3756 | | - if (display.isLIVE() && live && display.drawMode != display.SHADOW) |
---|
| 3909 | + //System.err.println("restarted"); |
---|
| 3910 | + if (Globals.isLIVE() && live && display.DrawMode() != iCameraPane.SHADOW) |
---|
| 3911 | + { |
---|
3757 | 3912 | restarted = false; |
---|
| 3913 | + //System.err.println("restarted = false"); |
---|
| 3914 | + } |
---|
3758 | 3915 | } |
---|
3759 | 3916 | |
---|
3760 | 3917 | super.drawSelf(display, root, selected, blocked); |
---|