Normand Briere
2018-12-15 6ed65dcb597fb2153cef75bf1845978f1115658c
Mocap.java
....@@ -261,9 +261,9 @@
261261
262262 // LA.matConcat(toParent, hip.get(0).toParent, toParent);
263263
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;
267267
268268 LA.matInvert(toParent, fromParent);
269269
....@@ -324,21 +324,21 @@
324324 // LA.matYRotate(toParent, angleY - angleYhip);
325325 // LA.matTranslate(toParent, pos.x - poship.x, pos.y - poship.y, pos.z - poship.z);
326326
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;
330330
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;
334334
335335 poship.x = toParent[3][0];
336336 poship.y = toParent[3][1];
337337 poship.z = toParent[3][2];
338338
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;
342342
343343 LA.matInvert(toParent, fromParent);
344344 }
....@@ -477,29 +477,45 @@
477477 }
478478 }
479479
480
+ static cVector centroid = new cVector();
481
+ static cVector mocaporigin = new cVector();
482
+
480483 void SetHipOrientation()
481484 {
482485 Object3D hip = get(0);
483486
484487 LA.matConcat(toParent, hip.get(0).toParent, matrix);
485488
486
- cVector centroid = new cVector();
489
+ mocaporigin.x = matrix[3][0];
490
+ mocaporigin.y = matrix[3][1];
491
+ mocaporigin.z = matrix[3][2];
492
+
487493 centroid.x = matrix[3][0];
488494 centroid.y = matrix[3][1];
489495 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;
491507
492508 cVector goal = GetGoal(centroid);
493509 if (goal != null)
494510 {
495
- System.err.println("GOAL change (" + this + "): " + goal + " (was " + goalx + ", " + goalz + ")");
511
+ System.err.println("GOAL change (" + this + "): " + goal + " (was " + goalposx + ", " + goalposz + ")");
496512
497
- goalx = goal.x;
498
- goalz = goal.z;
499
- targetx = targetz = 0;
513
+ goalposx = goal.x;
514
+ goalposz = goal.z;
515
+ targetdirx = targetdirz = 0;
500516 }
501517
502
- if (goalx == 0 && goalz == 0)
518
+ if (goalposx == 0 && goalposz == 0)
503519 {
504520 // No target
505521 if (ScriptNode.speaker != null)
....@@ -533,8 +549,8 @@
533549 //sourcenode.parent.TransformToLocal(dst);
534550 this.parent.TransformToLocal(dst);
535551
536
- goalx = dst.x;
537
- goalz = dst.z;
552
+ goalposx = dst.x;
553
+ goalposz = dst.z;
538554 }
539555 else
540556 return;
....@@ -550,17 +566,25 @@
550566
551567 double angleYhip = Math.atan2(-temp.z, temp.x);
552568
553
- double angleYtarget = Math.atan2(goalx - centroid.x, goalz - centroid.z);
569
+ double angleYtarget = Math.atan2(goalposx - centroid.x, goalposz - centroid.z);
554570
555571 LA.matIdentity(matrix);
556572 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);
558574 LA.matYRotate(matrix, angle);
559575 LA.matTranslate(matrix, centroid.x, centroid.y, centroid.z);
560576
561577 LA.matConcat(matrix, toParent, toParent);
562578
563579 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);
564588
565589 CheckForAction(centroid);
566590 }
....@@ -637,11 +661,11 @@
637661 double pinx;
638662 double pinz;
639663
640
- double targetx;
641
- double targetz;
664
+ double targetdirx;
665
+ double targetdirz;
642666
643
- double goalx = -20;
644
- double goalz = -10;
667
+ double goalposx = -20;
668
+ double goalposz = -10;
645669
646670 boolean followpath;
647671
....@@ -712,7 +736,7 @@
712736 scriptactions.clear();
713737 }
714738
715
- static double EPSACTION = 0.1; // 0.075; // 0.1;
739
+ static double EPSACTION = 0.1; // 0.075; // 0.1;Came
716740
717741 void AddFromTo(cVector from, cVector to)
718742 {
....@@ -1278,6 +1302,7 @@
12781302
12791303 void SetPosition(Object3D sourcenode, cVector floor, long floorid, cVector centroid)
12801304 {
1305
+ assert(false);
12811306 //assert(CameraPane.drawMode == CameraPane.SHADOW);
12821307
12831308 Object3D transformnode = new Object3D();
....@@ -1481,9 +1506,9 @@
14811506 groundid = floorid;
14821507
14831508 // 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;
14871512
14881513 if (true) // slow && stepout && onein)
14891514 {
....@@ -1560,9 +1585,9 @@
15601585
15611586 // System.out.println("Allo " + sourcenode);
15621587 // 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;
15661591
15671592
15681593 if (false) // dist2 > 0.1)
....@@ -1628,9 +1653,9 @@
16281653 this.get(0).TransformToWorld(v0);
16291654
16301655 // 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;
16341659
16351660 LA.matConcat(sourcenode.toParent, transformnode.toParent, sourcenode.toParent);
16361661 LA.matInvert(sourcenode.toParent, sourcenode.fromParent);
....@@ -1640,9 +1665,9 @@
16401665 this.get(0).TransformToWorld(v0);
16411666
16421667 // 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;
16461671 }
16471672 }
16481673
....@@ -1682,11 +1707,11 @@
16821707
16831708 if (goal != null)
16841709 {
1685
- System.err.println("GOAL change (" + sourcenode + "): " + goal + " (was " + goalx + ", " + goalz + ")");
1710
+ System.err.println("GOAL change (" + sourcenode + "): " + goal + " (was " + goalposx + ", " + goalposz + ")");
16861711 //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;
16901715
16911716 followpath = true;
16921717 }
....@@ -1737,16 +1762,16 @@
17371762 // }
17381763 if (false) // !uselast)
17391764 {
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;
17431768 }
17441769 }
17451770
1746
- if (goalx != 0 || goalz != 0) // TODO
1771
+ if (goalposx != 0 || goalposz != 0) // TODO
17471772 {
17481773 // overwrite speaker orientation
1749
- dst.set(goalx,0,goalz);
1774
+ dst.set(goalposx,0,goalposz);
17501775 if (sourcenode.parent != null) // july 2014
17511776 sourcenode.parent.
17521777 TransformToLocal(dst);
....@@ -1798,26 +1823,26 @@
17981823 // mars 2014
17991824 if (false) // goalx != 0 || goalz != 0)
18001825 {
1801
- targetx = dst.x - src.x;
1802
- targetz = dst.z - src.z;
1826
+ targetdirx = dst.x - src.x;
1827
+ targetdirz = dst.z - src.z;
18031828
1804
- if (Math.abs(targetx) > 0.1 || Math.abs(targetz) > 0.1)
1829
+ if (Math.abs(targetdirx) > 0.1 || Math.abs(targetdirz) > 0.1)
18051830 {
18061831 // far enough from goal. keep the goal position.
1807
- targetx = 0;
1808
- targetz = 0;
1832
+ targetdirx = 0;
1833
+ targetdirz = 0;
18091834 }
18101835 else
18111836 {
18121837 // too close to goal. switch to target direction instead.
1813
- goalx = 0;
1814
- goalz = 0;
1838
+ goalposx = 0;
1839
+ goalposz = 0;
18151840 }
18161841 }
18171842
18181843 //sourcenode.getCentroid(src, true);
18191844
1820
- if (speakernode == sourcenode && goalx == 0 && goalz == 0)
1845
+ if (speakernode == sourcenode && goalposx == 0 && goalposz == 0)
18211846 {
18221847 if (ScriptNode.lastspeaker != null)
18231848 new Exception().printStackTrace();
....@@ -1826,13 +1851,13 @@
18261851
18271852 // LA.xformPos(src, fromParent, src);
18281853
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)
18301855 dst.sub(src);
18311856 else
18321857 // vector mode
18331858 {
1834
- dst.x = targetx;
1835
- dst.z = targetz;
1859
+ dst.x = targetdirx;
1860
+ dst.z = targetdirz;
18361861
18371862 // TEST TARGET
18381863 // dst.x = CameraPane.selectedpoint.toParent[3][0];
....@@ -2280,9 +2305,16 @@
22802305 toVector.x = LA.cos(to);
22812306 toVector.y = LA.sin(to);
22822307
2308
+ double fromA = Math.atan2(fromVector.y, fromVector.x);
2309
+ double toA = Math.atan2(toVector.y, toVector.x);
2310
+
22832311 Vector2d currentVector = Slerp(fromVector, toVector, step);
22842312
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;
22862318 }
22872319
22882320 public static Vector2d Slerp(Vector2d from, Vector2d to, double step)
....@@ -3191,7 +3223,7 @@
31913223
31923224 // july 2014
31933225 // goalx = goalz = 0;
3194
- targetx = targetz = 0;
3226
+ targetdirx = targetdirz = 0;
31953227
31963228 //SetPositionDelta(true, true, true, false);
31973229 // LoadData();