Normand Briere
2019-10-06 ce660a4b6ba367bd162dd2cff26d02c80a34c912
Mocap.java
....@@ -261,6 +261,8 @@
261261
262262 // LA.matConcat(toParent, hip.get(0).toParent, toParent);
263263
264
+ CameraPane.CreateSelectedPoint();
265
+
264266 CameraPane.debugpointG.toParent[3][0] = poship.x;
265267 CameraPane.debugpointG.toParent[3][1] = poship.y;
266268 CameraPane.debugpointG.toParent[3][2] = poship.z;
....@@ -484,6 +486,12 @@
484486 {
485487 Object3D hip = get(0);
486488
489
+ if (toParent == null)
490
+ {
491
+ toParent = LA.newMatrix();
492
+ fromParent = LA.newMatrix();
493
+ }
494
+
487495 LA.matConcat(toParent, hip.get(0).toParent, matrix);
488496
489497 mocaporigin.x = matrix[3][0];
....@@ -495,6 +503,7 @@
495503 centroid.z = matrix[3][2];
496504 // this.getCentroid(centroid, true);
497505
506
+ CameraPane.CreateSelectedPoint();
498507 CameraPane.debugpointG.name = "";
499508 CameraPane.debugpointG.toParent[3][0] = mocaporigin.x;
500509 CameraPane.debugpointG.toParent[3][1] = mocaporigin.y;
....@@ -638,6 +647,24 @@
638647 // transient // aout 2013
639648 Object3D skeleton;
640649
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
+
641668 boolean smoothed;
642669
643670 //boolean touched;
....@@ -664,8 +691,8 @@
664691 double targetdirx;
665692 double targetdirz;
666693
667
- double goalposx = -20;
668
- double goalposz = -10;
694
+ double goalposx = 0; // -20;
695
+ double goalposz = 0; // -10;
669696
670697 boolean followpath;
671698
....@@ -921,7 +948,7 @@
921948 // //GetFileRoot();
922949
923950 // sept 2014: //
924
- GrafreeD.RENDERME = 3; // patch for Merge objects
951
+ Grafreed.RENDERME = 3; // patch for Merge objects
925952 float[] thedata = bvh.animation.getBoneData(0);
926953
927954 os.x = (float) (path.get(i).toParent[3][0]); // - thedata[frame*6]);
....@@ -971,7 +998,7 @@
971998
972999 get(0).link2master = path.size() > 1; // hip orientation
9731000
974
- if (get(0).link2master)
1001
+ if (get(0).Link2Support())
9751002 {
9761003 rotateonce = 2;
9771004 }
....@@ -1400,7 +1427,7 @@
14001427 double w = 0.00015;
14011428
14021429 //if (!sourcenode.link2master) // strong pin on floor
1403
- if (parent.link2master) // strong pin on floor
1430
+ if (parent.Link2Support()) // strong pin on floor
14041431 {
14051432 w = 0.005; // .001;
14061433 }
....@@ -1566,7 +1593,7 @@
15661593
15671594 lastsoundtime = Globals.framecount;
15681595
1569
- GrafreeD.hassound = true;
1596
+ Grafreed.hassound = true;
15701597 }
15711598 // else
15721599 // System.out.println("skipped");
....@@ -1614,7 +1641,7 @@
16141641 // sourcenode.parent.toParent[3][1] = ground - floor.y;
16151642 // sourcenode.parent.toParent[3][2] += groundz - floor.z;
16161643 // sourcenode.parent.toParent[3][1] = K * (ground - floor.y) + (1 - K) * oldposy;
1617
- 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
16181645 {
16191646 v0.x = groundx - floor.x;
16201647 v0.y = 0; // groundx - floor.x;
....@@ -1979,7 +2006,7 @@
19792006 // if (sourcenode.link2master)
19802007 // if (goalx != 0 || goalz != 0)
19812008 // K = 0.02; // .0625;
1982
- if (parent.link2master) // strong pin on floor
2009
+ if (parent.Link2Support()) // strong pin on floor
19832010 {
19842011 K = 0.05; // 0.02;
19852012 }
....@@ -2267,7 +2294,7 @@
22672294 }
22682295
22692296 if (!smoothed)
2270
- for (int i=1; --i>=0;)
2297
+ for (int i=10; --i>=0;)
22712298 SmoothAnimData(); // much reduces shakiness
22722299
22732300 smoothed = true;
....@@ -2396,9 +2423,9 @@
23962423 // SetBreakPoint(get(0).toParent[0], 0);
23972424 // }
23982425
2399
- boolean setrotation = get(0).link2master && !firsttimeafterload && frame > 0;
2426
+ boolean setrotation = get(0).Link2Support() && !firsttimeafterload && frame > 0;
24002427 boolean setposition = sourcenode != null && // sourcenode.parent != null && // july 2014
2401
- sourcenode./*parent.*/link2master && !firsttimeafterload && frame > 0;
2428
+ sourcenode./*parent.*/Link2Support() && !firsttimeafterload && frame > 0;
24022429
24032430 // cVector centroid = new cVector();
24042431 // cVector floor = new cVector();
....@@ -2797,7 +2824,8 @@
27972824 //if (bone._rotationEnabled)
27982825 if (//frame > 0 &&
27992826 !bone.skipmocap &&
2800
- !bone.name.contains("head") // &&
2827
+ !bone.name.contains("head") &&
2828
+ !bone.name.contains("Head") // &&
28012829 // !bone.name.contains("rFoot") &&
28022830 // !bone.name.contains("lFoot") &&
28032831 // !bone.name.contains("Pinky") &&
....@@ -2830,7 +2858,7 @@
28302858
28312859 // set translation
28322860 // (currently only possible for root bone! see mocapdata.com data)
2833
- if (bone._isRoot && link2master) // && !GetFileRoot().link2master)
2861
+ if (bone._isRoot && Link2Support()) // && !GetFileRoot().link2master)
28342862 {
28352863 if (hasTranslation) // && _translationEnabled)
28362864 {
....@@ -3233,8 +3261,8 @@
32333261
32343262 // aout 2013 endframe = 0; // june 2013
32353263
3236
- //ResetZero();
3237
- setPose(frame);
3264
+ ResetZero();
3265
+ //setPose(frame);
32383266 }
32393267
32403268 static int mocapsupport = 0;
....@@ -3252,12 +3280,13 @@
32523280
32533281 int step = 1;
32543282
3283
+ // patch for running hare
32553284 if (speedup) // fev 2014
32563285 step *= 2; // 4;
32573286 if (rewind) // mars 2014
32583287 step *= 4;
32593288
3260
- if (CameraPane.FAST) // && !CameraPane.HOLD)
3289
+ //if (CameraPane.FAST) // && !CameraPane.HOLD)
32613290 step *= CameraPane.STEP;
32623291
32633292 //System.err.println("Step Mocap frame # " + frame);
....@@ -3298,23 +3327,40 @@
32983327 // SetPositionDelta(false, true, false); // ?? false);
32993328 {
33003329 if (support == null)
3301
- 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
+ }
33023340 else
33033341 {
3304
- try
3305
- {
3342
+// try
3343
+// {
33063344 bvh = ((Mocap)support.get(mocapsupport++ % support.Size())).bvh;
33073345
33083346 // SetPositionDelta(false, true, true, true);
33093347 LoadData();
33103348 Rewind();
33113349 Fade();
3312
- }
3313
- catch (Exception e)
3314
- {
3315
- e.printStackTrace();
3316
- ObjEditor.LoadBVHFile(fullname, this, false, beginframe, lastframetest);
3317
- }
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
+// }
33183364 }
33193365 }
33203366
....@@ -3871,17 +3917,24 @@
38713917 // if (firstframe)
38723918 // return;
38733919
3874
- if (!restarted && /*display.restartframe &&*/
3875
- Globals.isLIVE() && live && display.DrawMode() == display.SHADOW) // FUCK
3920
+ if (//!restarted && /*display.restartframe &&*/
3921
+ Globals.isLIVE() && live && (display.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE))
38763922 {
38773923 //display.restartframe = false;
38783924 restarted = true;
3925
+ //System.err.println("restarted = true");
38793926 Step();
3927
+
3928
+ Globals.lighttouched = true;
38803929 }
38813930 else
38823931 {
3883
- if (Globals.isLIVE() && live && display.DrawMode() != display.SHADOW)
3932
+ //System.err.println("restarted");
3933
+ if (Globals.isLIVE() && live && display.DrawMode() != iCameraPane.SHADOW)
3934
+ {
38843935 restarted = false;
3936
+ //System.err.println("restarted = false");
3937
+ }
38853938 }
38863939
38873940 super.drawSelf(display, root, selected, blocked);
....@@ -3941,6 +3994,11 @@
39413994 // GetObject().release(i);
39423995 }
39433996
3997
+ boolean HasBigData()
3998
+ {
3999
+ return skeleton != null;
4000
+ }
4001
+
39444002 public Object3D get(int i)
39454003 {
39464004 if (i != 0)