.. | .. |
---|
29 | 29 | |
---|
30 | 30 | void Fade() |
---|
31 | 31 | { |
---|
32 | | - if (true) // currentbones == null || CameraPane.fullreset) |
---|
| 32 | + if (currentbones == null || CameraPane.fullreset) |
---|
33 | 33 | return; |
---|
34 | 34 | |
---|
35 | 35 | cVector temp = new cVector(); |
---|
.. | .. |
---|
107 | 107 | //data[f3 + i] += pos[i] - data[frame3 + i]; |
---|
108 | 108 | // data[f3 + i] = k*data[f3+i] + (1-k)* |
---|
109 | 109 | // currentbones[boneframe3 + i-end]; |
---|
110 | | - data[f3 + i] = (float)CurveAngle(data[f3+i], currenthip[i], 1-k); |
---|
| 110 | +// data[f3 + i] = (float)CurveAngle(data[f3+i], currenthip[i], 1-k); |
---|
111 | 111 | } |
---|
112 | 112 | |
---|
113 | 113 | // TODO: translation |
---|
.. | .. |
---|
225 | 225 | // before resetting the mocap data. |
---|
226 | 226 | void SetGlobalTransform() |
---|
227 | 227 | { |
---|
228 | | - SetCurrentBones(frame); |
---|
| 228 | + //SetCurrentBones(frame); |
---|
229 | 229 | |
---|
230 | 230 | cVector temp = new cVector(); |
---|
231 | 231 | cVector pos = new cVector(); |
---|
.. | .. |
---|
235 | 235 | double angleYhip = 0; |
---|
236 | 236 | |
---|
237 | 237 | Object3D hip = get(0); |
---|
| 238 | + |
---|
| 239 | + if (hip.get(0).toParent == null) |
---|
| 240 | + { |
---|
| 241 | + hip.get(0).toParent = LA.newMatrix(); |
---|
| 242 | + hip.get(0).fromParent = LA.newMatrix(); |
---|
| 243 | + } |
---|
238 | 244 | |
---|
239 | 245 | LA.matConcat(toParent, hip.get(0).toParent, matrix); |
---|
240 | 246 | poship.x = matrix[3][0]; |
---|
.. | .. |
---|
255 | 261 | |
---|
256 | 262 | // LA.matConcat(toParent, hip.get(0).toParent, toParent); |
---|
257 | 263 | |
---|
258 | | - CameraPane.debugpoint.toParent[3][0] = poship.x; |
---|
259 | | - CameraPane.debugpoint.toParent[3][1] = poship.y; |
---|
260 | | - 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; |
---|
261 | 267 | |
---|
262 | 268 | LA.matInvert(toParent, fromParent); |
---|
263 | 269 | |
---|
.. | .. |
---|
277 | 283 | poship.x = hip.get(0).toParent[3][0]; |
---|
278 | 284 | poship.y = hip.get(0).toParent[3][1]; |
---|
279 | 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); |
---|
280 | 294 | |
---|
281 | | - // AT*AR = A'T*BT*A'R*BR |
---|
282 | | - // |
---|
283 | | - 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); |
---|
284 | 301 | |
---|
285 | 302 | //LA.matIdentity(matrix); |
---|
286 | 303 | //LA.matTranslate(matrix, -poship.x, -poship.y, -poship.z); |
---|
287 | 304 | |
---|
288 | 305 | LA.matConcat(toParent, matrix, toParent); |
---|
289 | 306 | |
---|
290 | | -// poship.x = hip.get(0).toParent[3][0]; |
---|
291 | | -// poship.y = hip.get(0).toParent[3][1]; |
---|
292 | | -// poship.z = hip.get(0).toParent[3][2]; |
---|
293 | | -// |
---|
294 | | -// temp.x = 1; |
---|
295 | | -// temp.y = 0; |
---|
296 | | -// temp.z = 0; |
---|
297 | | -// |
---|
298 | | -// LA.xformDir(temp, hip.get(0).toParent, temp); |
---|
299 | | -// |
---|
300 | | -// angleYhip = Math.atan2(-temp.z, temp.x); |
---|
301 | | - |
---|
| 307 | + |
---|
302 | 308 | LA.matConcat(toParent, hip.get(0).toParent, matrix); |
---|
303 | 309 | pos.x = hip.get(0).toParent[3][0]; |
---|
304 | 310 | pos.y = hip.get(0).toParent[3][1]; |
---|
.. | .. |
---|
318 | 324 | // LA.matYRotate(toParent, angleY - angleYhip); |
---|
319 | 325 | // LA.matTranslate(toParent, pos.x - poship.x, pos.y - poship.y, pos.z - poship.z); |
---|
320 | 326 | |
---|
321 | | - CameraPane.debugpoint2.toParent[3][0] = pos.x; |
---|
322 | | - CameraPane.debugpoint2.toParent[3][1] = pos.y; |
---|
323 | | - 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; |
---|
324 | 330 | |
---|
325 | | - CameraPane.debugpoint3.toParent[3][0] = poship.x; |
---|
326 | | - CameraPane.debugpoint3.toParent[3][1] = poship.y; |
---|
327 | | - 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; |
---|
328 | 334 | |
---|
329 | 335 | poship.x = toParent[3][0]; |
---|
330 | 336 | poship.y = toParent[3][1]; |
---|
331 | 337 | poship.z = toParent[3][2]; |
---|
332 | 338 | |
---|
333 | | - CameraPane.debugpoint4.toParent[3][0] = poship.x; |
---|
334 | | - CameraPane.debugpoint4.toParent[3][1] = poship.y; |
---|
335 | | - 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; |
---|
336 | 342 | |
---|
337 | 343 | LA.matInvert(toParent, fromParent); |
---|
338 | 344 | } |
---|
.. | .. |
---|
470 | 476 | currenthip[i] = data[frame3 + i]; |
---|
471 | 477 | } |
---|
472 | 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 | + } |
---|
473 | 597 | |
---|
474 | 598 | void WriteTo(java.io.Writer writer) throws Exception |
---|
475 | 599 | { |
---|
.. | .. |
---|
543 | 667 | double pinx; |
---|
544 | 668 | double pinz; |
---|
545 | 669 | |
---|
546 | | - double targetx; |
---|
547 | | - double targetz; |
---|
| 670 | + double targetdirx; |
---|
| 671 | + double targetdirz; |
---|
548 | 672 | |
---|
549 | | - double goalx; |
---|
550 | | - double goalz; |
---|
| 673 | + double goalposx = 0; // -20; |
---|
| 674 | + double goalposz = 0; // -10; |
---|
551 | 675 | |
---|
552 | 676 | boolean followpath; |
---|
553 | 677 | |
---|
.. | .. |
---|
618 | 742 | scriptactions.clear(); |
---|
619 | 743 | } |
---|
620 | 744 | |
---|
621 | | - static double EPSACTION = 0.1; // 0.075; // 0.1; |
---|
| 745 | + static double EPSACTION = 0.1; // 0.075; // 0.1;Came |
---|
622 | 746 | |
---|
623 | 747 | void AddFromTo(cVector from, cVector to) |
---|
624 | 748 | { |
---|
.. | .. |
---|
803 | 927 | // //GetFileRoot(); |
---|
804 | 928 | |
---|
805 | 929 | // sept 2014: // |
---|
806 | | - GrafreeD.RENDERME = 3; // patch for Merge objects |
---|
| 930 | + Grafreed.RENDERME = 3; // patch for Merge objects |
---|
807 | 931 | float[] thedata = bvh.animation.getBoneData(0); |
---|
808 | 932 | |
---|
809 | 933 | os.x = (float) (path.get(i).toParent[3][0]); // - thedata[frame*6]); |
---|
.. | .. |
---|
904 | 1028 | testvect.set(from); |
---|
905 | 1029 | testvect.sub(fromto.from); |
---|
906 | 1030 | |
---|
| 1031 | + testvect.y = 0; // PATCH |
---|
| 1032 | + |
---|
907 | 1033 | int factor = 1; |
---|
908 | 1034 | |
---|
909 | 1035 | //if (CameraPane.FAST) |
---|
.. | .. |
---|
945 | 1071 | |
---|
946 | 1072 | testvect.set(from); |
---|
947 | 1073 | testvect.sub(fromto.from); |
---|
| 1074 | + |
---|
| 1075 | + testvect.y = 0; // PATCH |
---|
948 | 1076 | |
---|
949 | 1077 | int factor = 1; |
---|
950 | 1078 | |
---|
.. | .. |
---|
1180 | 1308 | |
---|
1181 | 1309 | void SetPosition(Object3D sourcenode, cVector floor, long floorid, cVector centroid) |
---|
1182 | 1310 | { |
---|
| 1311 | + assert(false); |
---|
1183 | 1312 | //assert(CameraPane.drawMode == CameraPane.SHADOW); |
---|
1184 | 1313 | |
---|
1185 | 1314 | Object3D transformnode = new Object3D(); |
---|
.. | .. |
---|
1383 | 1512 | groundid = floorid; |
---|
1384 | 1513 | |
---|
1385 | 1514 | // green |
---|
1386 | | - CameraPane.debugpoint.toParent[3][0] = groundx; |
---|
1387 | | - CameraPane.debugpoint.toParent[3][1] = floor.y; |
---|
1388 | | - 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; |
---|
1389 | 1518 | |
---|
1390 | 1519 | if (true) // slow && stepout && onein) |
---|
1391 | 1520 | { |
---|
.. | .. |
---|
1396 | 1525 | // mywave = currentwave++; |
---|
1397 | 1526 | // } |
---|
1398 | 1527 | // sound |
---|
1399 | | - cVector eye = CameraPane.theRenderer.eyeCamera.location; |
---|
| 1528 | + cVector eye = Globals.theRenderer.EyeCamera().location; |
---|
1400 | 1529 | |
---|
1401 | 1530 | // if (sourcenode.parent.parent != null) |
---|
1402 | 1531 | // sourcenode.parent.parent.TransformToWorld(floor, tmp); |
---|
.. | .. |
---|
1441 | 1570 | //GraphreeD. |
---|
1442 | 1571 | wav.play(volume * usedvolume); //, mywave); |
---|
1443 | 1572 | |
---|
1444 | | - lastsoundtime = CameraPane.framecount; |
---|
| 1573 | + lastsoundtime = Globals.framecount; |
---|
1445 | 1574 | |
---|
1446 | | - GrafreeD.hassound = true; |
---|
| 1575 | + Grafreed.hassound = true; |
---|
1447 | 1576 | } |
---|
1448 | 1577 | // else |
---|
1449 | 1578 | // System.out.println("skipped"); |
---|
.. | .. |
---|
1462 | 1591 | |
---|
1463 | 1592 | // System.out.println("Allo " + sourcenode); |
---|
1464 | 1593 | // purple |
---|
1465 | | - CameraPane.debugpoint2.toParent[3][0] = floor.x;// + posx; |
---|
1466 | | - CameraPane.debugpoint2.toParent[3][1] = ground; // floor.y;// + sourcenode.parent.toParent[3][1]; |
---|
1467 | | - 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; |
---|
1468 | 1597 | |
---|
1469 | 1598 | |
---|
1470 | 1599 | if (false) // dist2 > 0.1) |
---|
.. | .. |
---|
1530 | 1659 | this.get(0).TransformToWorld(v0); |
---|
1531 | 1660 | |
---|
1532 | 1661 | // cyan |
---|
1533 | | - CameraPane.debugpoint3.toParent[3][0] = v0.x; |
---|
1534 | | - CameraPane.debugpoint3.toParent[3][1] = ground; |
---|
1535 | | - 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; |
---|
1536 | 1665 | |
---|
1537 | 1666 | LA.matConcat(sourcenode.toParent, transformnode.toParent, sourcenode.toParent); |
---|
1538 | 1667 | LA.matInvert(sourcenode.toParent, sourcenode.fromParent); |
---|
.. | .. |
---|
1542 | 1671 | this.get(0).TransformToWorld(v0); |
---|
1543 | 1672 | |
---|
1544 | 1673 | // red |
---|
1545 | | - CameraPane.debugpoint4.toParent[3][0] = v0.x; |
---|
1546 | | - CameraPane.debugpoint4.toParent[3][1] = ground; |
---|
1547 | | - 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; |
---|
1548 | 1677 | } |
---|
1549 | 1678 | } |
---|
1550 | 1679 | |
---|
.. | .. |
---|
1584 | 1713 | |
---|
1585 | 1714 | if (goal != null) |
---|
1586 | 1715 | { |
---|
1587 | | - System.err.println("GOAL change (" + sourcenode + "): " + goal + " (was " + goalx + ", " + goalz + ")"); |
---|
| 1716 | + System.err.println("GOAL change (" + sourcenode + "): " + goal + " (was " + goalposx + ", " + goalposz + ")"); |
---|
1588 | 1717 | //sourcenode.parent.parent.Dump(); |
---|
1589 | | - goalx = goal.x; |
---|
1590 | | - goalz = goal.z; |
---|
1591 | | - targetx = targetz = 0; |
---|
| 1718 | + goalposx = goal.x; |
---|
| 1719 | + goalposz = goal.z; |
---|
| 1720 | + targetdirx = targetdirz = 0; |
---|
1592 | 1721 | |
---|
1593 | 1722 | followpath = true; |
---|
1594 | 1723 | } |
---|
.. | .. |
---|
1639 | 1768 | // } |
---|
1640 | 1769 | if (false) // !uselast) |
---|
1641 | 1770 | { |
---|
1642 | | - CameraPane.debugpoint.toParent[3][0] = dst.x; |
---|
1643 | | - CameraPane.debugpoint.toParent[3][1] = dst.y; |
---|
1644 | | - 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; |
---|
1645 | 1774 | } |
---|
1646 | 1775 | } |
---|
1647 | 1776 | |
---|
1648 | | - if (goalx != 0 || goalz != 0) // TODO |
---|
| 1777 | + if (goalposx != 0 || goalposz != 0) // TODO |
---|
1649 | 1778 | { |
---|
1650 | 1779 | // overwrite speaker orientation |
---|
1651 | | - dst.set(goalx,0,goalz); |
---|
| 1780 | + dst.set(goalposx,0,goalposz); |
---|
1652 | 1781 | if (sourcenode.parent != null) // july 2014 |
---|
1653 | 1782 | sourcenode.parent. |
---|
1654 | 1783 | TransformToLocal(dst); |
---|
.. | .. |
---|
1700 | 1829 | // mars 2014 |
---|
1701 | 1830 | if (false) // goalx != 0 || goalz != 0) |
---|
1702 | 1831 | { |
---|
1703 | | - targetx = dst.x - src.x; |
---|
1704 | | - targetz = dst.z - src.z; |
---|
| 1832 | + targetdirx = dst.x - src.x; |
---|
| 1833 | + targetdirz = dst.z - src.z; |
---|
1705 | 1834 | |
---|
1706 | | - if (Math.abs(targetx) > 0.1 || Math.abs(targetz) > 0.1) |
---|
| 1835 | + if (Math.abs(targetdirx) > 0.1 || Math.abs(targetdirz) > 0.1) |
---|
1707 | 1836 | { |
---|
1708 | 1837 | // far enough from goal. keep the goal position. |
---|
1709 | | - targetx = 0; |
---|
1710 | | - targetz = 0; |
---|
| 1838 | + targetdirx = 0; |
---|
| 1839 | + targetdirz = 0; |
---|
1711 | 1840 | } |
---|
1712 | 1841 | else |
---|
1713 | 1842 | { |
---|
1714 | 1843 | // too close to goal. switch to target direction instead. |
---|
1715 | | - goalx = 0; |
---|
1716 | | - goalz = 0; |
---|
| 1844 | + goalposx = 0; |
---|
| 1845 | + goalposz = 0; |
---|
1717 | 1846 | } |
---|
1718 | 1847 | } |
---|
1719 | 1848 | |
---|
1720 | 1849 | //sourcenode.getCentroid(src, true); |
---|
1721 | 1850 | |
---|
1722 | | - if (speakernode == sourcenode && goalx == 0 && goalz == 0) |
---|
| 1851 | + if (speakernode == sourcenode && goalposx == 0 && goalposz == 0) |
---|
1723 | 1852 | { |
---|
1724 | 1853 | if (ScriptNode.lastspeaker != null) |
---|
1725 | 1854 | new Exception().printStackTrace(); |
---|
.. | .. |
---|
1728 | 1857 | |
---|
1729 | 1858 | // LA.xformPos(src, fromParent, src); |
---|
1730 | 1859 | |
---|
1731 | | - 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) |
---|
1732 | 1861 | dst.sub(src); |
---|
1733 | 1862 | else |
---|
1734 | 1863 | // vector mode |
---|
1735 | 1864 | { |
---|
1736 | | - dst.x = targetx; |
---|
1737 | | - dst.z = targetz; |
---|
| 1865 | + dst.x = targetdirx; |
---|
| 1866 | + dst.z = targetdirz; |
---|
1738 | 1867 | |
---|
1739 | 1868 | // TEST TARGET |
---|
1740 | 1869 | // dst.x = CameraPane.selectedpoint.toParent[3][0]; |
---|
.. | .. |
---|
2144 | 2273 | } |
---|
2145 | 2274 | |
---|
2146 | 2275 | if (!smoothed) |
---|
2147 | | - for (int i=0; --i>=0;) |
---|
| 2276 | + for (int i=10; --i>=0;) |
---|
2148 | 2277 | SmoothAnimData(); // much reduces shakiness |
---|
2149 | 2278 | |
---|
2150 | 2279 | smoothed = true; |
---|
.. | .. |
---|
2182 | 2311 | toVector.x = LA.cos(to); |
---|
2183 | 2312 | toVector.y = LA.sin(to); |
---|
2184 | 2313 | |
---|
| 2314 | + double fromA = Math.atan2(fromVector.y, fromVector.x); |
---|
| 2315 | + double toA = Math.atan2(toVector.y, toVector.x); |
---|
| 2316 | + |
---|
2185 | 2317 | Vector2d currentVector = Slerp(fromVector, toVector, step); |
---|
2186 | 2318 | |
---|
2187 | | - 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; |
---|
2188 | 2324 | } |
---|
2189 | 2325 | |
---|
2190 | 2326 | public static Vector2d Slerp(Vector2d from, Vector2d to, double step) |
---|
.. | .. |
---|
2236 | 2372 | { |
---|
2237 | 2373 | e.printStackTrace(); |
---|
2238 | 2374 | } |
---|
| 2375 | + |
---|
| 2376 | + SetHipOrientation(); |
---|
2239 | 2377 | |
---|
2240 | 2378 | if (true) |
---|
2241 | 2379 | return; |
---|
.. | .. |
---|
2664 | 2802 | // set rotation |
---|
2665 | 2803 | //if (bone._rotationEnabled) |
---|
2666 | 2804 | if (//frame > 0 && |
---|
2667 | | - !bone.skipmocap //&& |
---|
2668 | | - //!bone.name.contains("head") && |
---|
| 2805 | + !bone.skipmocap && |
---|
| 2806 | + !bone.name.contains("head") && |
---|
| 2807 | + !bone.name.contains("Head") // && |
---|
2669 | 2808 | // !bone.name.contains("rFoot") && |
---|
2670 | 2809 | // !bone.name.contains("lFoot") && |
---|
2671 | 2810 | // !bone.name.contains("Pinky") && |
---|
.. | .. |
---|
3020 | 3159 | } |
---|
3021 | 3160 | } |
---|
3022 | 3161 | |
---|
3023 | | - static int offset = 1; // 5; // 10; // 5; // 100; // skip initial "T" |
---|
| 3162 | + // skip initial "T" |
---|
| 3163 | + static int offset = 1; // 5; // 10; // 5; // 100; |
---|
3024 | 3164 | |
---|
3025 | 3165 | void ReadBVH() |
---|
3026 | 3166 | { |
---|
.. | .. |
---|
3049 | 3189 | |
---|
3050 | 3190 | void Reset() |
---|
3051 | 3191 | { |
---|
3052 | | - if (fullname != null) |
---|
3053 | | - ReadBVH(); |
---|
| 3192 | +// if (fullname != null) |
---|
| 3193 | +// ReadBVH(); |
---|
3054 | 3194 | |
---|
3055 | 3195 | Object3D hip = get(0); |
---|
3056 | 3196 | |
---|
.. | .. |
---|
3089 | 3229 | // LA.matIdentity(rot.fromParent); |
---|
3090 | 3230 | |
---|
3091 | 3231 | // july 2014 |
---|
3092 | | - goalx = goalz = 0; |
---|
3093 | | - targetx = targetz = 0; |
---|
| 3232 | +// goalx = goalz = 0; |
---|
| 3233 | + targetdirx = targetdirz = 0; |
---|
3094 | 3234 | |
---|
3095 | 3235 | //SetPositionDelta(true, true, true, false); |
---|
3096 | 3236 | // LoadData(); |
---|
.. | .. |
---|
3100 | 3240 | |
---|
3101 | 3241 | // aout 2013 endframe = 0; // june 2013 |
---|
3102 | 3242 | |
---|
3103 | | - //ResetZero(); |
---|
3104 | | - setPose(frame); |
---|
| 3243 | + ResetZero(); |
---|
| 3244 | + //setPose(frame); |
---|
3105 | 3245 | } |
---|
3106 | 3246 | |
---|
3107 | 3247 | static int mocapsupport = 0; |
---|
.. | .. |
---|
3119 | 3259 | |
---|
3120 | 3260 | int step = 1; |
---|
3121 | 3261 | |
---|
| 3262 | + // patch for running hare |
---|
3122 | 3263 | if (speedup) // fev 2014 |
---|
3123 | 3264 | step *= 2; // 4; |
---|
3124 | 3265 | if (rewind) // mars 2014 |
---|
3125 | 3266 | step *= 4; |
---|
3126 | 3267 | |
---|
3127 | | - if (CameraPane.FAST) // && !CameraPane.HOLD) |
---|
| 3268 | + //if (CameraPane.FAST) // && !CameraPane.HOLD) |
---|
3128 | 3269 | step *= CameraPane.STEP; |
---|
3129 | 3270 | |
---|
3130 | 3271 | //System.err.println("Step Mocap frame # " + frame); |
---|
.. | .. |
---|
3132 | 3273 | baseframe += step; |
---|
3133 | 3274 | |
---|
3134 | 3275 | //frame = baseframe; |
---|
3135 | | - frame += step; |
---|
| 3276 | + //frame += step; |
---|
3136 | 3277 | |
---|
3137 | 3278 | // if (frame != baseframe) |
---|
3138 | 3279 | // { |
---|
.. | .. |
---|
3156 | 3297 | "; fullname = " + fullname); |
---|
3157 | 3298 | |
---|
3158 | 3299 | //int delta = frame - baseframe; |
---|
3159 | | - if (CameraPane.CROWD) |
---|
| 3300 | + if (Globals.CROWD) |
---|
3160 | 3301 | { |
---|
3161 | 3302 | baseframe = GetFirstFrame(); // 0 initial point |
---|
3162 | 3303 | } |
---|
.. | .. |
---|
3165 | 3306 | // SetPositionDelta(false, true, false); // ?? false); |
---|
3166 | 3307 | { |
---|
3167 | 3308 | if (support == null) |
---|
3168 | | - 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 | + } |
---|
3169 | 3319 | else |
---|
3170 | 3320 | { |
---|
3171 | | - try |
---|
3172 | | - { |
---|
| 3321 | +// try |
---|
| 3322 | +// { |
---|
3173 | 3323 | bvh = ((Mocap)support.get(mocapsupport++ % support.Size())).bvh; |
---|
3174 | 3324 | |
---|
3175 | 3325 | // SetPositionDelta(false, true, true, true); |
---|
3176 | 3326 | LoadData(); |
---|
3177 | 3327 | Rewind(); |
---|
3178 | 3328 | Fade(); |
---|
3179 | | - } |
---|
3180 | | - catch (Exception e) |
---|
3181 | | - { |
---|
3182 | | - e.printStackTrace(); |
---|
3183 | | - ObjEditor.LoadBVHFile(fullname, this, false, beginframe, lastframetest); |
---|
3184 | | - } |
---|
| 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 | +// } |
---|
3185 | 3343 | } |
---|
3186 | 3344 | } |
---|
| 3345 | + |
---|
| 3346 | + frame = GetFirstFrame(); |
---|
3187 | 3347 | } |
---|
| 3348 | + else |
---|
| 3349 | + frame += step; |
---|
3188 | 3350 | |
---|
3189 | 3351 | //SetPositionDelta(false); |
---|
3190 | 3352 | |
---|
3191 | | - if (frame >= bvh.animation.getNumFrames()) |
---|
3192 | | - //baseframe = |
---|
3193 | | - frame = GetFirstFrame(); // 0; // offset; // initial point |
---|
| 3353 | +// if (frame >= bvh.animation.getNumFrames()) |
---|
| 3354 | +// //baseframe = |
---|
| 3355 | +// frame = GetFirstFrame(); // 0; // offset; // initial point |
---|
3194 | 3356 | |
---|
3195 | 3357 | //System.err.println("frame = " + frame); |
---|
3196 | 3358 | if (lastframe != 0) |
---|
.. | .. |
---|
3359 | 3521 | // filters out bad input data |
---|
3360 | 3522 | void FilterAnimData() |
---|
3361 | 3523 | { |
---|
| 3524 | + new Exception().printStackTrace(); |
---|
3362 | 3525 | System.exit(0); |
---|
3363 | 3526 | |
---|
3364 | 3527 | float[] data; // = bvh.animation.getBoneData(0); |
---|
.. | .. |
---|
3716 | 3879 | |
---|
3717 | 3880 | transient boolean restarted; // CROWD issue? |
---|
3718 | 3881 | |
---|
3719 | | - void drawSelf(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
| 3882 | + void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
3720 | 3883 | { |
---|
3721 | 3884 | //System.err.println("drawSelf Mocap frame # " + frame); |
---|
3722 | 3885 | //System.err.println("drawSelf Mocap baseframe # " + baseframe); |
---|
.. | .. |
---|
3733 | 3896 | // if (firstframe) |
---|
3734 | 3897 | // return; |
---|
3735 | 3898 | |
---|
3736 | | - if (!restarted && /*display.restartframe &&*/ |
---|
3737 | | - display.isLIVE() && live && display.drawMode == display.SHADOW) // FUCK |
---|
| 3899 | + if (//!restarted && /*display.restartframe &&*/ |
---|
| 3900 | + Globals.isLIVE() && live && (display.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW)) |
---|
3738 | 3901 | { |
---|
3739 | 3902 | //display.restartframe = false; |
---|
3740 | 3903 | restarted = true; |
---|
| 3904 | + //System.err.println("restarted = true"); |
---|
3741 | 3905 | Step(); |
---|
3742 | 3906 | } |
---|
3743 | 3907 | else |
---|
3744 | 3908 | { |
---|
3745 | | - if (display.isLIVE() && live && display.drawMode != display.SHADOW) |
---|
| 3909 | + //System.err.println("restarted"); |
---|
| 3910 | + if (Globals.isLIVE() && live && display.DrawMode() != iCameraPane.SHADOW) |
---|
| 3911 | + { |
---|
3746 | 3912 | restarted = false; |
---|
| 3913 | + //System.err.println("restarted = false"); |
---|
| 3914 | + } |
---|
3747 | 3915 | } |
---|
3748 | 3916 | |
---|
3749 | 3917 | super.drawSelf(display, root, selected, blocked); |
---|