.. | .. |
---|
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 | |
---|
.. | .. |
---|
283 | 285 | poship.x = hip.get(0).toParent[3][0]; |
---|
284 | 286 | poship.y = hip.get(0).toParent[3][1]; |
---|
285 | 287 | poship.z = hip.get(0).toParent[3][2]; |
---|
| 288 | + |
---|
| 289 | + temp.x = 1; |
---|
| 290 | + temp.y = 0; |
---|
| 291 | + temp.z = 0; |
---|
| 292 | + |
---|
| 293 | + LA.xformDir(temp, hip.get(0).toParent, temp); |
---|
| 294 | + |
---|
| 295 | + angleYhip = Math.atan2(-temp.z, temp.x); |
---|
286 | 296 | |
---|
287 | | - // AT*AR = A'T*BT*A'R*BR |
---|
288 | | - // |
---|
289 | | - LA.matInvert(hip.get(0).toParent, matrix); |
---|
| 297 | + LA.matIdentity(matrix); |
---|
| 298 | + LA.matYRotate(matrix, angleYhip); |
---|
| 299 | + LA.matTranslate(matrix, poship.x, poship.y, poship.z); |
---|
| 300 | + |
---|
| 301 | + //LA.matInvert(hip.get(0).toParent, matrix); |
---|
| 302 | + LA.matInvert(matrix, matrix); |
---|
290 | 303 | |
---|
291 | 304 | //LA.matIdentity(matrix); |
---|
292 | 305 | //LA.matTranslate(matrix, -poship.x, -poship.y, -poship.z); |
---|
293 | 306 | |
---|
294 | 307 | LA.matConcat(toParent, matrix, toParent); |
---|
295 | 308 | |
---|
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 | | - |
---|
| 309 | + |
---|
308 | 310 | LA.matConcat(toParent, hip.get(0).toParent, matrix); |
---|
309 | 311 | pos.x = hip.get(0).toParent[3][0]; |
---|
310 | 312 | pos.y = hip.get(0).toParent[3][1]; |
---|
.. | .. |
---|
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 | } |
---|
.. | .. |
---|
476 | 478 | currenthip[i] = data[frame3 + i]; |
---|
477 | 479 | } |
---|
478 | 480 | } |
---|
| 481 | + |
---|
| 482 | + static cVector centroid = new cVector(); |
---|
| 483 | + static cVector mocaporigin = new cVector(); |
---|
| 484 | + |
---|
| 485 | + void SetHipOrientation() |
---|
| 486 | + { |
---|
| 487 | + Object3D hip = get(0); |
---|
| 488 | + |
---|
| 489 | + if (toParent == null) |
---|
| 490 | + { |
---|
| 491 | + toParent = LA.newMatrix(); |
---|
| 492 | + fromParent = LA.newMatrix(); |
---|
| 493 | + } |
---|
| 494 | + |
---|
| 495 | + LA.matConcat(toParent, hip.get(0).toParent, matrix); |
---|
| 496 | + |
---|
| 497 | + mocaporigin.x = matrix[3][0]; |
---|
| 498 | + mocaporigin.y = matrix[3][1]; |
---|
| 499 | + mocaporigin.z = matrix[3][2]; |
---|
| 500 | + |
---|
| 501 | + centroid.x = matrix[3][0]; |
---|
| 502 | + centroid.y = matrix[3][1]; |
---|
| 503 | + centroid.z = matrix[3][2]; |
---|
| 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; |
---|
| 516 | + |
---|
| 517 | + cVector goal = GetGoal(centroid); |
---|
| 518 | + if (goal != null) |
---|
| 519 | + { |
---|
| 520 | + System.err.println("GOAL change (" + this + "): " + goal + " (was " + goalposx + ", " + goalposz + ")"); |
---|
| 521 | + |
---|
| 522 | + goalposx = goal.x; |
---|
| 523 | + goalposz = goal.z; |
---|
| 524 | + targetdirx = targetdirz = 0; |
---|
| 525 | + } |
---|
| 526 | + |
---|
| 527 | + if (goalposx == 0 && goalposz == 0) |
---|
| 528 | + { |
---|
| 529 | + // No target |
---|
| 530 | + if (ScriptNode.speaker != null) |
---|
| 531 | + { |
---|
| 532 | + Object3D sourcenode = GetFileRoot(); |
---|
| 533 | + Object3D speakernode = ScriptNode.speaker.GetFileRoot(); |
---|
| 534 | + |
---|
| 535 | + //System.err.println("speaker is " + speakernode + "; last was " + ScriptNode.lastspeaker); |
---|
| 536 | + |
---|
| 537 | + Object3D speaker = ScriptNode.speaker; |
---|
| 538 | + |
---|
| 539 | + if (speakernode == sourcenode) |
---|
| 540 | + { |
---|
| 541 | + if (ScriptNode.lastspeaker != null) |
---|
| 542 | + { |
---|
| 543 | + speakernode = ScriptNode.lastspeaker.GetFileRoot(); |
---|
| 544 | + speaker = ScriptNode.lastspeaker; |
---|
| 545 | + } |
---|
| 546 | + else |
---|
| 547 | + return; |
---|
| 548 | + } |
---|
| 549 | + |
---|
| 550 | + cVector dst = new cVector(); |
---|
| 551 | + |
---|
| 552 | + boolean success = speakernode.getCentroid(dst); // , true); |
---|
| 553 | + |
---|
| 554 | + if (!success) |
---|
| 555 | + new Exception().printStackTrace(); |
---|
| 556 | + |
---|
| 557 | + //speakernode.parent.TransformToWorld(dst); |
---|
| 558 | + //sourcenode.parent.TransformToLocal(dst); |
---|
| 559 | + this.parent.TransformToLocal(dst); |
---|
| 560 | + |
---|
| 561 | + goalposx = dst.x; |
---|
| 562 | + goalposz = dst.z; |
---|
| 563 | + } |
---|
| 564 | + else |
---|
| 565 | + return; |
---|
| 566 | + } |
---|
| 567 | + |
---|
| 568 | + cVector temp = new cVector(); |
---|
| 569 | + |
---|
| 570 | + temp.x = 1; |
---|
| 571 | + temp.y = 0; |
---|
| 572 | + temp.z = 0; |
---|
| 573 | + |
---|
| 574 | + LA.xformDir(temp, matrix, temp); |
---|
| 575 | + |
---|
| 576 | + double angleYhip = Math.atan2(-temp.z, temp.x); |
---|
| 577 | + |
---|
| 578 | + double angleYtarget = Math.atan2(goalposx - centroid.x, goalposz - centroid.z); |
---|
| 579 | + |
---|
| 580 | + LA.matIdentity(matrix); |
---|
| 581 | + LA.matTranslate(matrix, -centroid.x, -centroid.y, -centroid.z); |
---|
| 582 | + double angle = CurveAngle(0, angleYtarget - angleYhip, 0.1f); |
---|
| 583 | + LA.matYRotate(matrix, angle); |
---|
| 584 | + LA.matTranslate(matrix, centroid.x, centroid.y, centroid.z); |
---|
| 585 | + |
---|
| 586 | + LA.matConcat(matrix, toParent, toParent); |
---|
| 587 | + |
---|
| 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); |
---|
| 597 | + |
---|
| 598 | + CheckForAction(centroid); |
---|
| 599 | + } |
---|
479 | 600 | |
---|
480 | 601 | void WriteTo(java.io.Writer writer) throws Exception |
---|
481 | 602 | { |
---|
.. | .. |
---|
526 | 647 | // transient // aout 2013 |
---|
527 | 648 | Object3D skeleton; |
---|
528 | 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 | + |
---|
529 | 668 | boolean smoothed; |
---|
530 | 669 | |
---|
531 | 670 | //boolean touched; |
---|
.. | .. |
---|
549 | 688 | double pinx; |
---|
550 | 689 | double pinz; |
---|
551 | 690 | |
---|
552 | | - double targetx; |
---|
553 | | - double targetz; |
---|
| 691 | + double targetdirx; |
---|
| 692 | + double targetdirz; |
---|
554 | 693 | |
---|
555 | | - double goalx; |
---|
556 | | - double goalz; |
---|
| 694 | + double goalposx = 0; // -20; |
---|
| 695 | + double goalposz = 0; // -10; |
---|
557 | 696 | |
---|
558 | 697 | boolean followpath; |
---|
559 | 698 | |
---|
.. | .. |
---|
624 | 763 | scriptactions.clear(); |
---|
625 | 764 | } |
---|
626 | 765 | |
---|
627 | | - static double EPSACTION = 0.1; // 0.075; // 0.1; |
---|
| 766 | + static double EPSACTION = 0.1; // 0.075; // 0.1;Came |
---|
628 | 767 | |
---|
629 | 768 | void AddFromTo(cVector from, cVector to) |
---|
630 | 769 | { |
---|
.. | .. |
---|
809 | 948 | // //GetFileRoot(); |
---|
810 | 949 | |
---|
811 | 950 | // sept 2014: // |
---|
812 | | - GrafreeD.RENDERME = 3; // patch for Merge objects |
---|
| 951 | + Grafreed.RENDERME = 3; // patch for Merge objects |
---|
813 | 952 | float[] thedata = bvh.animation.getBoneData(0); |
---|
814 | 953 | |
---|
815 | 954 | os.x = (float) (path.get(i).toParent[3][0]); // - thedata[frame*6]); |
---|
.. | .. |
---|
859 | 998 | |
---|
860 | 999 | get(0).link2master = path.size() > 1; // hip orientation |
---|
861 | 1000 | |
---|
862 | | - if (get(0).link2master) |
---|
| 1001 | + if (get(0).Link2Support()) |
---|
863 | 1002 | { |
---|
864 | 1003 | rotateonce = 2; |
---|
865 | 1004 | } |
---|
.. | .. |
---|
910 | 1049 | testvect.set(from); |
---|
911 | 1050 | testvect.sub(fromto.from); |
---|
912 | 1051 | |
---|
| 1052 | + testvect.y = 0; // PATCH |
---|
| 1053 | + |
---|
913 | 1054 | int factor = 1; |
---|
914 | 1055 | |
---|
915 | 1056 | //if (CameraPane.FAST) |
---|
.. | .. |
---|
951 | 1092 | |
---|
952 | 1093 | testvect.set(from); |
---|
953 | 1094 | testvect.sub(fromto.from); |
---|
| 1095 | + |
---|
| 1096 | + testvect.y = 0; // PATCH |
---|
954 | 1097 | |
---|
955 | 1098 | int factor = 1; |
---|
956 | 1099 | |
---|
.. | .. |
---|
1186 | 1329 | |
---|
1187 | 1330 | void SetPosition(Object3D sourcenode, cVector floor, long floorid, cVector centroid) |
---|
1188 | 1331 | { |
---|
| 1332 | + assert(false); |
---|
1189 | 1333 | //assert(CameraPane.drawMode == CameraPane.SHADOW); |
---|
1190 | 1334 | |
---|
1191 | 1335 | Object3D transformnode = new Object3D(); |
---|
.. | .. |
---|
1283 | 1427 | double w = 0.00015; |
---|
1284 | 1428 | |
---|
1285 | 1429 | //if (!sourcenode.link2master) // strong pin on floor |
---|
1286 | | - if (parent.link2master) // strong pin on floor |
---|
| 1430 | + if (parent.Link2Support()) // strong pin on floor |
---|
1287 | 1431 | { |
---|
1288 | 1432 | w = 0.005; // .001; |
---|
1289 | 1433 | } |
---|
.. | .. |
---|
1389 | 1533 | groundid = floorid; |
---|
1390 | 1534 | |
---|
1391 | 1535 | // green |
---|
1392 | | - CameraPane.debugpoint.toParent[3][0] = groundx; |
---|
1393 | | - CameraPane.debugpoint.toParent[3][1] = floor.y; |
---|
1394 | | - 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; |
---|
1395 | 1539 | |
---|
1396 | 1540 | if (true) // slow && stepout && onein) |
---|
1397 | 1541 | { |
---|
.. | .. |
---|
1402 | 1546 | // mywave = currentwave++; |
---|
1403 | 1547 | // } |
---|
1404 | 1548 | // sound |
---|
1405 | | - cVector eye = CameraPane.theRenderer.eyeCamera.location; |
---|
| 1549 | + cVector eye = Globals.theRenderer.EyeCamera().location; |
---|
1406 | 1550 | |
---|
1407 | 1551 | // if (sourcenode.parent.parent != null) |
---|
1408 | 1552 | // sourcenode.parent.parent.TransformToWorld(floor, tmp); |
---|
.. | .. |
---|
1447 | 1591 | //GraphreeD. |
---|
1448 | 1592 | wav.play(volume * usedvolume); //, mywave); |
---|
1449 | 1593 | |
---|
1450 | | - lastsoundtime = CameraPane.framecount; |
---|
| 1594 | + lastsoundtime = Globals.framecount; |
---|
1451 | 1595 | |
---|
1452 | | - GrafreeD.hassound = true; |
---|
| 1596 | + Grafreed.hassound = true; |
---|
1453 | 1597 | } |
---|
1454 | 1598 | // else |
---|
1455 | 1599 | // System.out.println("skipped"); |
---|
.. | .. |
---|
1468 | 1612 | |
---|
1469 | 1613 | // System.out.println("Allo " + sourcenode); |
---|
1470 | 1614 | // 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; |
---|
| 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; |
---|
1474 | 1618 | |
---|
1475 | 1619 | |
---|
1476 | 1620 | if (false) // dist2 > 0.1) |
---|
.. | .. |
---|
1497 | 1641 | // sourcenode.parent.toParent[3][1] = ground - floor.y; |
---|
1498 | 1642 | // sourcenode.parent.toParent[3][2] += groundz - floor.z; |
---|
1499 | 1643 | // sourcenode.parent.toParent[3][1] = K * (ground - floor.y) + (1 - K) * oldposy; |
---|
1500 | | - 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 |
---|
1501 | 1645 | { |
---|
1502 | 1646 | v0.x = groundx - floor.x; |
---|
1503 | 1647 | v0.y = 0; // groundx - floor.x; |
---|
.. | .. |
---|
1536 | 1680 | this.get(0).TransformToWorld(v0); |
---|
1537 | 1681 | |
---|
1538 | 1682 | // cyan |
---|
1539 | | - CameraPane.debugpoint3.toParent[3][0] = v0.x; |
---|
1540 | | - CameraPane.debugpoint3.toParent[3][1] = ground; |
---|
1541 | | - 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; |
---|
1542 | 1686 | |
---|
1543 | 1687 | LA.matConcat(sourcenode.toParent, transformnode.toParent, sourcenode.toParent); |
---|
1544 | 1688 | LA.matInvert(sourcenode.toParent, sourcenode.fromParent); |
---|
.. | .. |
---|
1548 | 1692 | this.get(0).TransformToWorld(v0); |
---|
1549 | 1693 | |
---|
1550 | 1694 | // red |
---|
1551 | | - CameraPane.debugpoint4.toParent[3][0] = v0.x; |
---|
1552 | | - CameraPane.debugpoint4.toParent[3][1] = ground; |
---|
1553 | | - 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; |
---|
1554 | 1698 | } |
---|
1555 | 1699 | } |
---|
1556 | 1700 | |
---|
.. | .. |
---|
1590 | 1734 | |
---|
1591 | 1735 | if (goal != null) |
---|
1592 | 1736 | { |
---|
1593 | | - System.err.println("GOAL change (" + sourcenode + "): " + goal + " (was " + goalx + ", " + goalz + ")"); |
---|
| 1737 | + System.err.println("GOAL change (" + sourcenode + "): " + goal + " (was " + goalposx + ", " + goalposz + ")"); |
---|
1594 | 1738 | //sourcenode.parent.parent.Dump(); |
---|
1595 | | - goalx = goal.x; |
---|
1596 | | - goalz = goal.z; |
---|
1597 | | - targetx = targetz = 0; |
---|
| 1739 | + goalposx = goal.x; |
---|
| 1740 | + goalposz = goal.z; |
---|
| 1741 | + targetdirx = targetdirz = 0; |
---|
1598 | 1742 | |
---|
1599 | 1743 | followpath = true; |
---|
1600 | 1744 | } |
---|
.. | .. |
---|
1645 | 1789 | // } |
---|
1646 | 1790 | if (false) // !uselast) |
---|
1647 | 1791 | { |
---|
1648 | | - CameraPane.debugpoint.toParent[3][0] = dst.x; |
---|
1649 | | - CameraPane.debugpoint.toParent[3][1] = dst.y; |
---|
1650 | | - 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; |
---|
1651 | 1795 | } |
---|
1652 | 1796 | } |
---|
1653 | 1797 | |
---|
1654 | | - if (goalx != 0 || goalz != 0) // TODO |
---|
| 1798 | + if (goalposx != 0 || goalposz != 0) // TODO |
---|
1655 | 1799 | { |
---|
1656 | 1800 | // overwrite speaker orientation |
---|
1657 | | - dst.set(goalx,0,goalz); |
---|
| 1801 | + dst.set(goalposx,0,goalposz); |
---|
1658 | 1802 | if (sourcenode.parent != null) // july 2014 |
---|
1659 | 1803 | sourcenode.parent. |
---|
1660 | 1804 | TransformToLocal(dst); |
---|
.. | .. |
---|
1706 | 1850 | // mars 2014 |
---|
1707 | 1851 | if (false) // goalx != 0 || goalz != 0) |
---|
1708 | 1852 | { |
---|
1709 | | - targetx = dst.x - src.x; |
---|
1710 | | - targetz = dst.z - src.z; |
---|
| 1853 | + targetdirx = dst.x - src.x; |
---|
| 1854 | + targetdirz = dst.z - src.z; |
---|
1711 | 1855 | |
---|
1712 | | - if (Math.abs(targetx) > 0.1 || Math.abs(targetz) > 0.1) |
---|
| 1856 | + if (Math.abs(targetdirx) > 0.1 || Math.abs(targetdirz) > 0.1) |
---|
1713 | 1857 | { |
---|
1714 | 1858 | // far enough from goal. keep the goal position. |
---|
1715 | | - targetx = 0; |
---|
1716 | | - targetz = 0; |
---|
| 1859 | + targetdirx = 0; |
---|
| 1860 | + targetdirz = 0; |
---|
1717 | 1861 | } |
---|
1718 | 1862 | else |
---|
1719 | 1863 | { |
---|
1720 | 1864 | // too close to goal. switch to target direction instead. |
---|
1721 | | - goalx = 0; |
---|
1722 | | - goalz = 0; |
---|
| 1865 | + goalposx = 0; |
---|
| 1866 | + goalposz = 0; |
---|
1723 | 1867 | } |
---|
1724 | 1868 | } |
---|
1725 | 1869 | |
---|
1726 | 1870 | //sourcenode.getCentroid(src, true); |
---|
1727 | 1871 | |
---|
1728 | | - if (speakernode == sourcenode && goalx == 0 && goalz == 0) |
---|
| 1872 | + if (speakernode == sourcenode && goalposx == 0 && goalposz == 0) |
---|
1729 | 1873 | { |
---|
1730 | 1874 | if (ScriptNode.lastspeaker != null) |
---|
1731 | 1875 | new Exception().printStackTrace(); |
---|
.. | .. |
---|
1734 | 1878 | |
---|
1735 | 1879 | // LA.xformPos(src, fromParent, src); |
---|
1736 | 1880 | |
---|
1737 | | - 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) |
---|
1738 | 1882 | dst.sub(src); |
---|
1739 | 1883 | else |
---|
1740 | 1884 | // vector mode |
---|
1741 | 1885 | { |
---|
1742 | | - dst.x = targetx; |
---|
1743 | | - dst.z = targetz; |
---|
| 1886 | + dst.x = targetdirx; |
---|
| 1887 | + dst.z = targetdirz; |
---|
1744 | 1888 | |
---|
1745 | 1889 | // TEST TARGET |
---|
1746 | 1890 | // dst.x = CameraPane.selectedpoint.toParent[3][0]; |
---|
.. | .. |
---|
1862 | 2006 | // if (sourcenode.link2master) |
---|
1863 | 2007 | // if (goalx != 0 || goalz != 0) |
---|
1864 | 2008 | // K = 0.02; // .0625; |
---|
1865 | | - if (parent.link2master) // strong pin on floor |
---|
| 2009 | + if (parent.Link2Support()) // strong pin on floor |
---|
1866 | 2010 | { |
---|
1867 | 2011 | K = 0.05; // 0.02; |
---|
1868 | 2012 | } |
---|
.. | .. |
---|
2150 | 2294 | } |
---|
2151 | 2295 | |
---|
2152 | 2296 | if (!smoothed) |
---|
2153 | | - for (int i=0; --i>=0;) |
---|
| 2297 | + for (int i=10; --i>=0;) |
---|
2154 | 2298 | SmoothAnimData(); // much reduces shakiness |
---|
2155 | 2299 | |
---|
2156 | 2300 | smoothed = true; |
---|
.. | .. |
---|
2188 | 2332 | toVector.x = LA.cos(to); |
---|
2189 | 2333 | toVector.y = LA.sin(to); |
---|
2190 | 2334 | |
---|
| 2335 | + double fromA = Math.atan2(fromVector.y, fromVector.x); |
---|
| 2336 | + double toA = Math.atan2(toVector.y, toVector.x); |
---|
| 2337 | + |
---|
2191 | 2338 | Vector2d currentVector = Slerp(fromVector, toVector, step); |
---|
2192 | 2339 | |
---|
2193 | | - 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; |
---|
2194 | 2345 | } |
---|
2195 | 2346 | |
---|
2196 | 2347 | public static Vector2d Slerp(Vector2d from, Vector2d to, double step) |
---|
.. | .. |
---|
2243 | 2394 | e.printStackTrace(); |
---|
2244 | 2395 | } |
---|
2245 | 2396 | |
---|
| 2397 | + SetHipOrientation(); |
---|
| 2398 | + |
---|
2246 | 2399 | if (true) |
---|
2247 | 2400 | return; |
---|
2248 | 2401 | |
---|
.. | .. |
---|
2270 | 2423 | // SetBreakPoint(get(0).toParent[0], 0); |
---|
2271 | 2424 | // } |
---|
2272 | 2425 | |
---|
2273 | | - boolean setrotation = get(0).link2master && !firsttimeafterload && frame > 0; |
---|
| 2426 | + boolean setrotation = get(0).Link2Support() && !firsttimeafterload && frame > 0; |
---|
2274 | 2427 | boolean setposition = sourcenode != null && // sourcenode.parent != null && // july 2014 |
---|
2275 | | - sourcenode./*parent.*/link2master && !firsttimeafterload && frame > 0; |
---|
| 2428 | + sourcenode./*parent.*/Link2Support() && !firsttimeafterload && frame > 0; |
---|
2276 | 2429 | |
---|
2277 | 2430 | // cVector centroid = new cVector(); |
---|
2278 | 2431 | // cVector floor = new cVector(); |
---|
.. | .. |
---|
2670 | 2823 | // set rotation |
---|
2671 | 2824 | //if (bone._rotationEnabled) |
---|
2672 | 2825 | if (//frame > 0 && |
---|
2673 | | - !bone.skipmocap //&& |
---|
2674 | | - //!bone.name.contains("head") && |
---|
| 2826 | + !bone.skipmocap && |
---|
| 2827 | + !bone.name.contains("head") && |
---|
| 2828 | + !bone.name.contains("Head") // && |
---|
2675 | 2829 | // !bone.name.contains("rFoot") && |
---|
2676 | 2830 | // !bone.name.contains("lFoot") && |
---|
2677 | 2831 | // !bone.name.contains("Pinky") && |
---|
.. | .. |
---|
2704 | 2858 | |
---|
2705 | 2859 | // set translation |
---|
2706 | 2860 | // (currently only possible for root bone! see mocapdata.com data) |
---|
2707 | | - if (bone._isRoot && link2master) // && !GetFileRoot().link2master) |
---|
| 2861 | + if (bone._isRoot && Link2Support()) // && !GetFileRoot().link2master) |
---|
2708 | 2862 | { |
---|
2709 | 2863 | if (hasTranslation) // && _translationEnabled) |
---|
2710 | 2864 | { |
---|
.. | .. |
---|
3096 | 3250 | // LA.matIdentity(rot.fromParent); |
---|
3097 | 3251 | |
---|
3098 | 3252 | // july 2014 |
---|
3099 | | - goalx = goalz = 0; |
---|
3100 | | - targetx = targetz = 0; |
---|
| 3253 | +// goalx = goalz = 0; |
---|
| 3254 | + targetdirx = targetdirz = 0; |
---|
3101 | 3255 | |
---|
3102 | 3256 | //SetPositionDelta(true, true, true, false); |
---|
3103 | 3257 | // LoadData(); |
---|
.. | .. |
---|
3107 | 3261 | |
---|
3108 | 3262 | // aout 2013 endframe = 0; // june 2013 |
---|
3109 | 3263 | |
---|
3110 | | - //ResetZero(); |
---|
3111 | | - setPose(frame); |
---|
| 3264 | + ResetZero(); |
---|
| 3265 | + //setPose(frame); |
---|
3112 | 3266 | } |
---|
3113 | 3267 | |
---|
3114 | 3268 | static int mocapsupport = 0; |
---|
.. | .. |
---|
3126 | 3280 | |
---|
3127 | 3281 | int step = 1; |
---|
3128 | 3282 | |
---|
| 3283 | + // patch for running hare |
---|
3129 | 3284 | if (speedup) // fev 2014 |
---|
3130 | 3285 | step *= 2; // 4; |
---|
3131 | 3286 | if (rewind) // mars 2014 |
---|
3132 | 3287 | step *= 4; |
---|
3133 | 3288 | |
---|
3134 | | - if (CameraPane.FAST) // && !CameraPane.HOLD) |
---|
| 3289 | + //if (CameraPane.FAST) // && !CameraPane.HOLD) |
---|
3135 | 3290 | step *= CameraPane.STEP; |
---|
3136 | 3291 | |
---|
3137 | 3292 | //System.err.println("Step Mocap frame # " + frame); |
---|
.. | .. |
---|
3163 | 3318 | "; fullname = " + fullname); |
---|
3164 | 3319 | |
---|
3165 | 3320 | //int delta = frame - baseframe; |
---|
3166 | | - if (CameraPane.CROWD) |
---|
| 3321 | + if (Globals.CROWD) |
---|
3167 | 3322 | { |
---|
3168 | 3323 | baseframe = GetFirstFrame(); // 0 initial point |
---|
3169 | 3324 | } |
---|
.. | .. |
---|
3172 | 3327 | // SetPositionDelta(false, true, false); // ?? false); |
---|
3173 | 3328 | { |
---|
3174 | 3329 | if (support == null) |
---|
3175 | | - 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 | + } |
---|
3176 | 3340 | else |
---|
3177 | 3341 | { |
---|
3178 | | - try |
---|
3179 | | - { |
---|
| 3342 | +// try |
---|
| 3343 | +// { |
---|
3180 | 3344 | bvh = ((Mocap)support.get(mocapsupport++ % support.Size())).bvh; |
---|
3181 | 3345 | |
---|
3182 | 3346 | // SetPositionDelta(false, true, true, true); |
---|
3183 | 3347 | LoadData(); |
---|
3184 | 3348 | Rewind(); |
---|
3185 | 3349 | Fade(); |
---|
3186 | | - } |
---|
3187 | | - catch (Exception e) |
---|
3188 | | - { |
---|
3189 | | - e.printStackTrace(); |
---|
3190 | | - ObjEditor.LoadBVHFile(fullname, this, false, beginframe, lastframetest); |
---|
3191 | | - } |
---|
| 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 | +// } |
---|
3192 | 3364 | } |
---|
3193 | 3365 | } |
---|
3194 | 3366 | |
---|
.. | .. |
---|
3370 | 3542 | // filters out bad input data |
---|
3371 | 3543 | void FilterAnimData() |
---|
3372 | 3544 | { |
---|
| 3545 | + new Exception().printStackTrace(); |
---|
3373 | 3546 | System.exit(0); |
---|
3374 | 3547 | |
---|
3375 | 3548 | float[] data; // = bvh.animation.getBoneData(0); |
---|
.. | .. |
---|
3727 | 3900 | |
---|
3728 | 3901 | transient boolean restarted; // CROWD issue? |
---|
3729 | 3902 | |
---|
3730 | | - void drawSelf(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
| 3903 | + void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
3731 | 3904 | { |
---|
3732 | 3905 | //System.err.println("drawSelf Mocap frame # " + frame); |
---|
3733 | 3906 | //System.err.println("drawSelf Mocap baseframe # " + baseframe); |
---|
.. | .. |
---|
3744 | 3917 | // if (firstframe) |
---|
3745 | 3918 | // return; |
---|
3746 | 3919 | |
---|
3747 | | - if (!restarted && /*display.restartframe &&*/ |
---|
3748 | | - 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)) |
---|
3749 | 3922 | { |
---|
3750 | 3923 | //display.restartframe = false; |
---|
3751 | 3924 | restarted = true; |
---|
| 3925 | + //System.err.println("restarted = true"); |
---|
3752 | 3926 | Step(); |
---|
| 3927 | + |
---|
| 3928 | + Globals.lighttouched = true; |
---|
3753 | 3929 | } |
---|
3754 | 3930 | else |
---|
3755 | 3931 | { |
---|
3756 | | - if (display.isLIVE() && live && display.drawMode != display.SHADOW) |
---|
| 3932 | + //System.err.println("restarted"); |
---|
| 3933 | + if (Globals.isLIVE() && live && display.DrawMode() != iCameraPane.SHADOW) |
---|
| 3934 | + { |
---|
3757 | 3935 | restarted = false; |
---|
| 3936 | + //System.err.println("restarted = false"); |
---|
| 3937 | + } |
---|
3758 | 3938 | } |
---|
3759 | 3939 | |
---|
3760 | 3940 | super.drawSelf(display, root, selected, blocked); |
---|
.. | .. |
---|
3814 | 3994 | // GetObject().release(i); |
---|
3815 | 3995 | } |
---|
3816 | 3996 | |
---|
| 3997 | + boolean HasBigData() |
---|
| 3998 | + { |
---|
| 3999 | + return skeleton != null; |
---|
| 4000 | + } |
---|
| 4001 | + |
---|
3817 | 4002 | public Object3D get(int i) |
---|
3818 | 4003 | { |
---|
3819 | 4004 | if (i != 0) |
---|