Normand Briere
2019-06-29 a69bb4474a3264a9a7a7f8b8d8154ea771f167c8
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,52 @@
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
487
+ if (toParent == null)
488
+ {
489
+ toParent = LA.newMatrix();
490
+ fromParent = LA.newMatrix();
491
+ }
492
+
484493 LA.matConcat(toParent, hip.get(0).toParent, matrix);
485494
486
- cVector centroid = new cVector();
495
+ mocaporigin.x = matrix[3][0];
496
+ mocaporigin.y = matrix[3][1];
497
+ mocaporigin.z = matrix[3][2];
498
+
487499 centroid.x = matrix[3][0];
488500 centroid.y = matrix[3][1];
489501 centroid.z = matrix[3][2];
490
- this.getCentroid(centroid, true);
502
+// this.getCentroid(centroid, true);
503
+
504
+ CameraPane.CreateSelectedPoint();
505
+ CameraPane.debugpointG.name = "";
506
+ CameraPane.debugpointG.toParent[3][0] = mocaporigin.x;
507
+ CameraPane.debugpointG.toParent[3][1] = mocaporigin.y;
508
+ CameraPane.debugpointG.toParent[3][2] = mocaporigin.z;
509
+
510
+ CameraPane.debugpointP.name = "";
511
+ CameraPane.debugpointP.toParent[3][0] = centroid.x;
512
+ CameraPane.debugpointP.toParent[3][1] = centroid.y;
513
+ CameraPane.debugpointP.toParent[3][2] = centroid.z;
491514
492515 cVector goal = GetGoal(centroid);
493516 if (goal != null)
494517 {
495
- System.err.println("GOAL change (" + this + "): " + goal + " (was " + goalx + ", " + goalz + ")");
518
+ System.err.println("GOAL change (" + this + "): " + goal + " (was " + goalposx + ", " + goalposz + ")");
496519
497
- goalx = goal.x;
498
- goalz = goal.z;
499
- targetx = targetz = 0;
520
+ goalposx = goal.x;
521
+ goalposz = goal.z;
522
+ targetdirx = targetdirz = 0;
500523 }
501524
502
- if (goalx == 0 && goalz == 0)
525
+ if (goalposx == 0 && goalposz == 0)
503526 {
504527 // No target
505528 if (ScriptNode.speaker != null)
....@@ -533,8 +556,8 @@
533556 //sourcenode.parent.TransformToLocal(dst);
534557 this.parent.TransformToLocal(dst);
535558
536
- goalx = dst.x;
537
- goalz = dst.z;
559
+ goalposx = dst.x;
560
+ goalposz = dst.z;
538561 }
539562 else
540563 return;
....@@ -550,17 +573,25 @@
550573
551574 double angleYhip = Math.atan2(-temp.z, temp.x);
552575
553
- double angleYtarget = Math.atan2(goalx - centroid.x, goalz - centroid.z);
576
+ double angleYtarget = Math.atan2(goalposx - centroid.x, goalposz - centroid.z);
554577
555578 LA.matIdentity(matrix);
556579 LA.matTranslate(matrix, -centroid.x, -centroid.y, -centroid.z);
557
- double angle = CurveAngle(0, angleYtarget - angleYhip, 1); // 0.1f);
580
+ double angle = CurveAngle(0, angleYtarget - angleYhip, 0.1f);
558581 LA.matYRotate(matrix, angle);
559582 LA.matTranslate(matrix, centroid.x, centroid.y, centroid.z);
560583
561584 LA.matConcat(matrix, toParent, toParent);
562585
563586 LA.matInvert(toParent, fromParent);
587
+
588
+ LA.matConcat(toParent, hip.get(0).toParent, matrix);
589
+
590
+ centroid.x = matrix[3][0];
591
+ centroid.y = matrix[3][1];
592
+ centroid.z = matrix[3][2];
593
+
594
+ double dist = LA.distance(centroid, mocaporigin);
564595
565596 CheckForAction(centroid);
566597 }
....@@ -614,6 +645,24 @@
614645 // transient // aout 2013
615646 Object3D skeleton;
616647
648
+ void ExtractBigData(Object3D o)
649
+ {
650
+ super.ExtractBigData(o);
651
+
652
+ o.bvh = this.bvh;
653
+ o.skeleton = this.skeleton;
654
+ this.bvh = null;
655
+ this.skeleton = null;
656
+ }
657
+
658
+ void RestoreBigData(Object3D o)
659
+ {
660
+ super.RestoreBigData(o);
661
+
662
+ this.bvh = o.bvh;
663
+ this.skeleton = o.skeleton;
664
+ }
665
+
617666 boolean smoothed;
618667
619668 //boolean touched;
....@@ -637,11 +686,11 @@
637686 double pinx;
638687 double pinz;
639688
640
- double targetx;
641
- double targetz;
689
+ double targetdirx;
690
+ double targetdirz;
642691
643
- double goalx = -20;
644
- double goalz = -10;
692
+ double goalposx = 0; // -20;
693
+ double goalposz = 0; // -10;
645694
646695 boolean followpath;
647696
....@@ -712,7 +761,7 @@
712761 scriptactions.clear();
713762 }
714763
715
- static double EPSACTION = 0.1; // 0.075; // 0.1;
764
+ static double EPSACTION = 0.1; // 0.075; // 0.1;Came
716765
717766 void AddFromTo(cVector from, cVector to)
718767 {
....@@ -897,7 +946,7 @@
897946 // //GetFileRoot();
898947
899948 // sept 2014: //
900
- GrafreeD.RENDERME = 3; // patch for Merge objects
949
+ Grafreed.RENDERME = 3; // patch for Merge objects
901950 float[] thedata = bvh.animation.getBoneData(0);
902951
903952 os.x = (float) (path.get(i).toParent[3][0]); // - thedata[frame*6]);
....@@ -1278,6 +1327,7 @@
12781327
12791328 void SetPosition(Object3D sourcenode, cVector floor, long floorid, cVector centroid)
12801329 {
1330
+ assert(false);
12811331 //assert(CameraPane.drawMode == CameraPane.SHADOW);
12821332
12831333 Object3D transformnode = new Object3D();
....@@ -1481,9 +1531,9 @@
14811531 groundid = floorid;
14821532
14831533 // green
1484
- CameraPane.debugpoint.toParent[3][0] = groundx;
1485
- CameraPane.debugpoint.toParent[3][1] = floor.y;
1486
- CameraPane.debugpoint.toParent[3][2] = groundz;
1534
+ CameraPane.debugpointG.toParent[3][0] = groundx;
1535
+ CameraPane.debugpointG.toParent[3][1] = floor.y;
1536
+ CameraPane.debugpointG.toParent[3][2] = groundz;
14871537
14881538 if (true) // slow && stepout && onein)
14891539 {
....@@ -1494,7 +1544,7 @@
14941544 // mywave = currentwave++;
14951545 // }
14961546 // sound
1497
- cVector eye = CameraPane.theRenderer.eyeCamera.location;
1547
+ cVector eye = Globals.theRenderer.EyeCamera().location;
14981548
14991549 // if (sourcenode.parent.parent != null)
15001550 // sourcenode.parent.parent.TransformToWorld(floor, tmp);
....@@ -1539,9 +1589,9 @@
15391589 //GraphreeD.
15401590 wav.play(volume * usedvolume); //, mywave);
15411591
1542
- lastsoundtime = CameraPane.framecount;
1592
+ lastsoundtime = Globals.framecount;
15431593
1544
- GrafreeD.hassound = true;
1594
+ Grafreed.hassound = true;
15451595 }
15461596 // else
15471597 // System.out.println("skipped");
....@@ -1560,9 +1610,9 @@
15601610
15611611 // System.out.println("Allo " + sourcenode);
15621612 // 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;
1613
+ CameraPane.debugpointP.toParent[3][0] = floor.x;// + posx;
1614
+ CameraPane.debugpointP.toParent[3][1] = ground; // floor.y;// + sourcenode.parent.toParent[3][1];
1615
+ CameraPane.debugpointP.toParent[3][2] = floor.z;// + posz;
15661616
15671617
15681618 if (false) // dist2 > 0.1)
....@@ -1628,9 +1678,9 @@
16281678 this.get(0).TransformToWorld(v0);
16291679
16301680 // cyan
1631
- CameraPane.debugpoint3.toParent[3][0] = v0.x;
1632
- CameraPane.debugpoint3.toParent[3][1] = ground;
1633
- CameraPane.debugpoint3.toParent[3][2] = v0.z;
1681
+ CameraPane.debugpointC.toParent[3][0] = v0.x;
1682
+ CameraPane.debugpointC.toParent[3][1] = ground;
1683
+ CameraPane.debugpointC.toParent[3][2] = v0.z;
16341684
16351685 LA.matConcat(sourcenode.toParent, transformnode.toParent, sourcenode.toParent);
16361686 LA.matInvert(sourcenode.toParent, sourcenode.fromParent);
....@@ -1640,9 +1690,9 @@
16401690 this.get(0).TransformToWorld(v0);
16411691
16421692 // red
1643
- CameraPane.debugpoint4.toParent[3][0] = v0.x;
1644
- CameraPane.debugpoint4.toParent[3][1] = ground;
1645
- CameraPane.debugpoint4.toParent[3][2] = v0.z;
1693
+ CameraPane.debugpointR.toParent[3][0] = v0.x;
1694
+ CameraPane.debugpointR.toParent[3][1] = ground;
1695
+ CameraPane.debugpointR.toParent[3][2] = v0.z;
16461696 }
16471697 }
16481698
....@@ -1682,11 +1732,11 @@
16821732
16831733 if (goal != null)
16841734 {
1685
- System.err.println("GOAL change (" + sourcenode + "): " + goal + " (was " + goalx + ", " + goalz + ")");
1735
+ System.err.println("GOAL change (" + sourcenode + "): " + goal + " (was " + goalposx + ", " + goalposz + ")");
16861736 //sourcenode.parent.parent.Dump();
1687
- goalx = goal.x;
1688
- goalz = goal.z;
1689
- targetx = targetz = 0;
1737
+ goalposx = goal.x;
1738
+ goalposz = goal.z;
1739
+ targetdirx = targetdirz = 0;
16901740
16911741 followpath = true;
16921742 }
....@@ -1737,16 +1787,16 @@
17371787 // }
17381788 if (false) // !uselast)
17391789 {
1740
- CameraPane.debugpoint.toParent[3][0] = dst.x;
1741
- CameraPane.debugpoint.toParent[3][1] = dst.y;
1742
- CameraPane.debugpoint.toParent[3][2] = dst.z;
1790
+ CameraPane.debugpointG.toParent[3][0] = dst.x;
1791
+ CameraPane.debugpointG.toParent[3][1] = dst.y;
1792
+ CameraPane.debugpointG.toParent[3][2] = dst.z;
17431793 }
17441794 }
17451795
1746
- if (goalx != 0 || goalz != 0) // TODO
1796
+ if (goalposx != 0 || goalposz != 0) // TODO
17471797 {
17481798 // overwrite speaker orientation
1749
- dst.set(goalx,0,goalz);
1799
+ dst.set(goalposx,0,goalposz);
17501800 if (sourcenode.parent != null) // july 2014
17511801 sourcenode.parent.
17521802 TransformToLocal(dst);
....@@ -1798,26 +1848,26 @@
17981848 // mars 2014
17991849 if (false) // goalx != 0 || goalz != 0)
18001850 {
1801
- targetx = dst.x - src.x;
1802
- targetz = dst.z - src.z;
1851
+ targetdirx = dst.x - src.x;
1852
+ targetdirz = dst.z - src.z;
18031853
1804
- if (Math.abs(targetx) > 0.1 || Math.abs(targetz) > 0.1)
1854
+ if (Math.abs(targetdirx) > 0.1 || Math.abs(targetdirz) > 0.1)
18051855 {
18061856 // far enough from goal. keep the goal position.
1807
- targetx = 0;
1808
- targetz = 0;
1857
+ targetdirx = 0;
1858
+ targetdirz = 0;
18091859 }
18101860 else
18111861 {
18121862 // too close to goal. switch to target direction instead.
1813
- goalx = 0;
1814
- goalz = 0;
1863
+ goalposx = 0;
1864
+ goalposz = 0;
18151865 }
18161866 }
18171867
18181868 //sourcenode.getCentroid(src, true);
18191869
1820
- if (speakernode == sourcenode && goalx == 0 && goalz == 0)
1870
+ if (speakernode == sourcenode && goalposx == 0 && goalposz == 0)
18211871 {
18221872 if (ScriptNode.lastspeaker != null)
18231873 new Exception().printStackTrace();
....@@ -1826,13 +1876,13 @@
18261876
18271877 // LA.xformPos(src, fromParent, src);
18281878
1829
- if ((ScriptNode.speaker != null && CameraPane.SPEAKERMOCAP || goalx != 0 || goalz != 0) && targetx == 0 && targetz == 0)
1879
+ if ((ScriptNode.speaker != null && CameraPane.SPEAKERMOCAP || goalposx != 0 || goalposz != 0) && targetdirx == 0 && targetdirz == 0)
18301880 dst.sub(src);
18311881 else
18321882 // vector mode
18331883 {
1834
- dst.x = targetx;
1835
- dst.z = targetz;
1884
+ dst.x = targetdirx;
1885
+ dst.z = targetdirz;
18361886
18371887 // TEST TARGET
18381888 // dst.x = CameraPane.selectedpoint.toParent[3][0];
....@@ -2242,7 +2292,7 @@
22422292 }
22432293
22442294 if (!smoothed)
2245
- for (int i=0; --i>=0;)
2295
+ for (int i=10; --i>=0;)
22462296 SmoothAnimData(); // much reduces shakiness
22472297
22482298 smoothed = true;
....@@ -2280,9 +2330,16 @@
22802330 toVector.x = LA.cos(to);
22812331 toVector.y = LA.sin(to);
22822332
2333
+ double fromA = Math.atan2(fromVector.y, fromVector.x);
2334
+ double toA = Math.atan2(toVector.y, toVector.x);
2335
+
22832336 Vector2d currentVector = Slerp(fromVector, toVector, step);
22842337
2285
- return Math.atan2(currentVector.y, currentVector.x);
2338
+ double angle = Math.atan2(currentVector.y, currentVector.x);
2339
+
2340
+ double angle2 = (1-step) * fromA + step * toA;
2341
+
2342
+ return angle;
22862343 }
22872344
22882345 public static Vector2d Slerp(Vector2d from, Vector2d to, double step)
....@@ -2765,7 +2822,8 @@
27652822 //if (bone._rotationEnabled)
27662823 if (//frame > 0 &&
27672824 !bone.skipmocap &&
2768
- !bone.name.contains("head") // &&
2825
+ !bone.name.contains("head") &&
2826
+ !bone.name.contains("Head") // &&
27692827 // !bone.name.contains("rFoot") &&
27702828 // !bone.name.contains("lFoot") &&
27712829 // !bone.name.contains("Pinky") &&
....@@ -3191,7 +3249,7 @@
31913249
31923250 // july 2014
31933251 // goalx = goalz = 0;
3194
- targetx = targetz = 0;
3252
+ targetdirx = targetdirz = 0;
31953253
31963254 //SetPositionDelta(true, true, true, false);
31973255 // LoadData();
....@@ -3201,8 +3259,8 @@
32013259
32023260 // aout 2013 endframe = 0; // june 2013
32033261
3204
- //ResetZero();
3205
- setPose(frame);
3262
+ ResetZero();
3263
+ //setPose(frame);
32063264 }
32073265
32083266 static int mocapsupport = 0;
....@@ -3220,12 +3278,13 @@
32203278
32213279 int step = 1;
32223280
3281
+ // patch for running hare
32233282 if (speedup) // fev 2014
32243283 step *= 2; // 4;
32253284 if (rewind) // mars 2014
32263285 step *= 4;
32273286
3228
- if (CameraPane.FAST) // && !CameraPane.HOLD)
3287
+ //if (CameraPane.FAST) // && !CameraPane.HOLD)
32293288 step *= CameraPane.STEP;
32303289
32313290 //System.err.println("Step Mocap frame # " + frame);
....@@ -3257,7 +3316,7 @@
32573316 "; fullname = " + fullname);
32583317
32593318 //int delta = frame - baseframe;
3260
- if (CameraPane.CROWD)
3319
+ if (Globals.CROWD)
32613320 {
32623321 baseframe = GetFirstFrame(); // 0 initial point
32633322 }
....@@ -3266,23 +3325,40 @@
32663325 // SetPositionDelta(false, true, false); // ?? false);
32673326 {
32683327 if (support == null)
3269
- ObjEditor.LoadBVHFile(fullname, this, false, beginframe, lastframetest);
3328
+ {
3329
+ if (bvh == null && new File(fullname).exists())
3330
+ ObjEditor.LoadBVHFile(fullname, this, false, beginframe, lastframetest);
3331
+ else
3332
+ {
3333
+ SetGlobalTransform();
3334
+ Rewind();
3335
+ Fade();
3336
+ }
3337
+ }
32703338 else
32713339 {
3272
- try
3273
- {
3340
+// try
3341
+// {
32743342 bvh = ((Mocap)support.get(mocapsupport++ % support.Size())).bvh;
32753343
32763344 // SetPositionDelta(false, true, true, true);
32773345 LoadData();
32783346 Rewind();
32793347 Fade();
3280
- }
3281
- catch (Exception e)
3282
- {
3283
- e.printStackTrace();
3284
- ObjEditor.LoadBVHFile(fullname, this, false, beginframe, lastframetest);
3285
- }
3348
+// }
3349
+// catch (Exception e)
3350
+// {
3351
+// System.err.println("An error occured while loading data. Use fallback by loading the file.");
3352
+// //e.printStackTrace();
3353
+// try
3354
+// {
3355
+// ObjEditor.LoadBVHFile(fullname, this, false, beginframe, lastframetest);
3356
+// }
3357
+// catch (Exception e2)
3358
+// {
3359
+// System.err.println("Motion file not found: " + fullname);
3360
+// }
3361
+// }
32863362 }
32873363 }
32883364
....@@ -3464,6 +3540,7 @@
34643540 // filters out bad input data
34653541 void FilterAnimData()
34663542 {
3543
+ new Exception().printStackTrace();
34673544 System.exit(0);
34683545
34693546 float[] data; // = bvh.animation.getBoneData(0);
....@@ -3821,7 +3898,7 @@
38213898
38223899 transient boolean restarted; // CROWD issue?
38233900
3824
- void drawSelf(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
3901
+ void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
38253902 {
38263903 //System.err.println("drawSelf Mocap frame # " + frame);
38273904 //System.err.println("drawSelf Mocap baseframe # " + baseframe);
....@@ -3838,17 +3915,22 @@
38383915 // if (firstframe)
38393916 // return;
38403917
3841
- if (!restarted && /*display.restartframe &&*/
3842
- display.isLIVE() && live && display.drawMode == display.SHADOW) // FUCK
3918
+ if (//!restarted && /*display.restartframe &&*/
3919
+ Globals.isLIVE() && live && (display.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE))
38433920 {
38443921 //display.restartframe = false;
38453922 restarted = true;
3923
+ //System.err.println("restarted = true");
38463924 Step();
38473925 }
38483926 else
38493927 {
3850
- if (display.isLIVE() && live && display.drawMode != display.SHADOW)
3928
+ //System.err.println("restarted");
3929
+ if (Globals.isLIVE() && live && display.DrawMode() != iCameraPane.SHADOW)
3930
+ {
38513931 restarted = false;
3932
+ //System.err.println("restarted = false");
3933
+ }
38523934 }
38533935
38543936 super.drawSelf(display, root, selected, blocked);