Normand Briere
2019-11-17 cb37a129d1adb403019c96e798e86e2da9667f15
Mocap.java
....@@ -29,7 +29,7 @@
2929
3030 void Fade()
3131 {
32
- if (true) // currentbones == null || CameraPane.fullreset)
32
+ if (currentbones == null || CameraPane.fullreset)
3333 return;
3434
3535 cVector temp = new cVector();
....@@ -107,7 +107,7 @@
107107 //data[f3 + i] += pos[i] - data[frame3 + i];
108108 // data[f3 + i] = k*data[f3+i] + (1-k)*
109109 // 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);
111111 }
112112
113113 // TODO: translation
....@@ -225,7 +225,7 @@
225225 // before resetting the mocap data.
226226 void SetGlobalTransform()
227227 {
228
- SetCurrentBones(frame);
228
+ //SetCurrentBones(frame);
229229
230230 cVector temp = new cVector();
231231 cVector pos = new cVector();
....@@ -235,6 +235,12 @@
235235 double angleYhip = 0;
236236
237237 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
+ }
238244
239245 LA.matConcat(toParent, hip.get(0).toParent, matrix);
240246 poship.x = matrix[3][0];
....@@ -255,9 +261,11 @@
255261
256262 // LA.matConcat(toParent, hip.get(0).toParent, toParent);
257263
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.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;
261269
262270 LA.matInvert(toParent, fromParent);
263271
....@@ -277,28 +285,28 @@
277285 poship.x = hip.get(0).toParent[3][0];
278286 poship.y = hip.get(0).toParent[3][1];
279287 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);
280296
281
- // AT*AR = A'T*BT*A'R*BR
282
- //
283
- 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);
284303
285304 //LA.matIdentity(matrix);
286305 //LA.matTranslate(matrix, -poship.x, -poship.y, -poship.z);
287306
288307 LA.matConcat(toParent, matrix, toParent);
289308
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
-
309
+
302310 LA.matConcat(toParent, hip.get(0).toParent, matrix);
303311 pos.x = hip.get(0).toParent[3][0];
304312 pos.y = hip.get(0).toParent[3][1];
....@@ -318,21 +326,21 @@
318326 // LA.matYRotate(toParent, angleY - angleYhip);
319327 // LA.matTranslate(toParent, pos.x - poship.x, pos.y - poship.y, pos.z - poship.z);
320328
321
- CameraPane.debugpoint2.toParent[3][0] = pos.x;
322
- CameraPane.debugpoint2.toParent[3][1] = pos.y;
323
- 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;
324332
325
- CameraPane.debugpoint3.toParent[3][0] = poship.x;
326
- CameraPane.debugpoint3.toParent[3][1] = poship.y;
327
- 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;
328336
329337 poship.x = toParent[3][0];
330338 poship.y = toParent[3][1];
331339 poship.z = toParent[3][2];
332340
333
- CameraPane.debugpoint4.toParent[3][0] = poship.x;
334
- CameraPane.debugpoint4.toParent[3][1] = poship.y;
335
- 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;
336344
337345 LA.matInvert(toParent, fromParent);
338346 }
....@@ -470,6 +478,125 @@
470478 currenthip[i] = data[frame3 + i];
471479 }
472480 }
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
+ }
473600
474601 void WriteTo(java.io.Writer writer) throws Exception
475602 {
....@@ -520,6 +647,24 @@
520647 // transient // aout 2013
521648 Object3D skeleton;
522649
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
+
523668 boolean smoothed;
524669
525670 //boolean touched;
....@@ -543,11 +688,11 @@
543688 double pinx;
544689 double pinz;
545690
546
- double targetx;
547
- double targetz;
691
+ double targetdirx;
692
+ double targetdirz;
548693
549
- double goalx;
550
- double goalz;
694
+ double goalposx = 0; // -20;
695
+ double goalposz = 0; // -10;
551696
552697 boolean followpath;
553698
....@@ -618,7 +763,7 @@
618763 scriptactions.clear();
619764 }
620765
621
- static double EPSACTION = 0.1; // 0.075; // 0.1;
766
+ static double EPSACTION = 0.1; // 0.075; // 0.1;Came
622767
623768 void AddFromTo(cVector from, cVector to)
624769 {
....@@ -803,7 +948,7 @@
803948 // //GetFileRoot();
804949
805950 // sept 2014: //
806
- GrafreeD.RENDERME = 3; // patch for Merge objects
951
+ Grafreed.RENDERME = 3; // patch for Merge objects
807952 float[] thedata = bvh.animation.getBoneData(0);
808953
809954 os.x = (float) (path.get(i).toParent[3][0]); // - thedata[frame*6]);
....@@ -853,7 +998,7 @@
853998
854999 get(0).link2master = path.size() > 1; // hip orientation
8551000
856
- if (get(0).link2master)
1001
+ if (get(0).Link2Support())
8571002 {
8581003 rotateonce = 2;
8591004 }
....@@ -904,6 +1049,8 @@
9041049 testvect.set(from);
9051050 testvect.sub(fromto.from);
9061051
1052
+ testvect.y = 0; // PATCH
1053
+
9071054 int factor = 1;
9081055
9091056 //if (CameraPane.FAST)
....@@ -945,6 +1092,8 @@
9451092
9461093 testvect.set(from);
9471094 testvect.sub(fromto.from);
1095
+
1096
+ testvect.y = 0; // PATCH
9481097
9491098 int factor = 1;
9501099
....@@ -1180,6 +1329,7 @@
11801329
11811330 void SetPosition(Object3D sourcenode, cVector floor, long floorid, cVector centroid)
11821331 {
1332
+ assert(false);
11831333 //assert(CameraPane.drawMode == CameraPane.SHADOW);
11841334
11851335 Object3D transformnode = new Object3D();
....@@ -1277,7 +1427,7 @@
12771427 double w = 0.00015;
12781428
12791429 //if (!sourcenode.link2master) // strong pin on floor
1280
- if (parent.link2master) // strong pin on floor
1430
+ if (parent.Link2Support()) // strong pin on floor
12811431 {
12821432 w = 0.005; // .001;
12831433 }
....@@ -1383,9 +1533,9 @@
13831533 groundid = floorid;
13841534
13851535 // green
1386
- CameraPane.debugpoint.toParent[3][0] = groundx;
1387
- CameraPane.debugpoint.toParent[3][1] = floor.y;
1388
- 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;
13891539
13901540 if (true) // slow && stepout && onein)
13911541 {
....@@ -1396,7 +1546,7 @@
13961546 // mywave = currentwave++;
13971547 // }
13981548 // sound
1399
- cVector eye = CameraPane.theRenderer.eyeCamera.location;
1549
+ cVector eye = Globals.theRenderer.EyeCamera().location;
14001550
14011551 // if (sourcenode.parent.parent != null)
14021552 // sourcenode.parent.parent.TransformToWorld(floor, tmp);
....@@ -1441,9 +1591,9 @@
14411591 //GraphreeD.
14421592 wav.play(volume * usedvolume); //, mywave);
14431593
1444
- lastsoundtime = CameraPane.framecount;
1594
+ lastsoundtime = Globals.framecount;
14451595
1446
- GrafreeD.hassound = true;
1596
+ Grafreed.hassound = true;
14471597 }
14481598 // else
14491599 // System.out.println("skipped");
....@@ -1462,9 +1612,9 @@
14621612
14631613 // System.out.println("Allo " + sourcenode);
14641614 // 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;
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;
14681618
14691619
14701620 if (false) // dist2 > 0.1)
....@@ -1491,7 +1641,7 @@
14911641 // sourcenode.parent.toParent[3][1] = ground - floor.y;
14921642 // sourcenode.parent.toParent[3][2] += groundz - floor.z;
14931643 // sourcenode.parent.toParent[3][1] = K * (ground - floor.y) + (1 - K) * oldposy;
1494
- 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
14951645 {
14961646 v0.x = groundx - floor.x;
14971647 v0.y = 0; // groundx - floor.x;
....@@ -1530,9 +1680,9 @@
15301680 this.get(0).TransformToWorld(v0);
15311681
15321682 // cyan
1533
- CameraPane.debugpoint3.toParent[3][0] = v0.x;
1534
- CameraPane.debugpoint3.toParent[3][1] = ground;
1535
- 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;
15361686
15371687 LA.matConcat(sourcenode.toParent, transformnode.toParent, sourcenode.toParent);
15381688 LA.matInvert(sourcenode.toParent, sourcenode.fromParent);
....@@ -1542,9 +1692,9 @@
15421692 this.get(0).TransformToWorld(v0);
15431693
15441694 // red
1545
- CameraPane.debugpoint4.toParent[3][0] = v0.x;
1546
- CameraPane.debugpoint4.toParent[3][1] = ground;
1547
- 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;
15481698 }
15491699 }
15501700
....@@ -1584,11 +1734,11 @@
15841734
15851735 if (goal != null)
15861736 {
1587
- System.err.println("GOAL change (" + sourcenode + "): " + goal + " (was " + goalx + ", " + goalz + ")");
1737
+ System.err.println("GOAL change (" + sourcenode + "): " + goal + " (was " + goalposx + ", " + goalposz + ")");
15881738 //sourcenode.parent.parent.Dump();
1589
- goalx = goal.x;
1590
- goalz = goal.z;
1591
- targetx = targetz = 0;
1739
+ goalposx = goal.x;
1740
+ goalposz = goal.z;
1741
+ targetdirx = targetdirz = 0;
15921742
15931743 followpath = true;
15941744 }
....@@ -1639,16 +1789,16 @@
16391789 // }
16401790 if (false) // !uselast)
16411791 {
1642
- CameraPane.debugpoint.toParent[3][0] = dst.x;
1643
- CameraPane.debugpoint.toParent[3][1] = dst.y;
1644
- 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;
16451795 }
16461796 }
16471797
1648
- if (goalx != 0 || goalz != 0) // TODO
1798
+ if (goalposx != 0 || goalposz != 0) // TODO
16491799 {
16501800 // overwrite speaker orientation
1651
- dst.set(goalx,0,goalz);
1801
+ dst.set(goalposx,0,goalposz);
16521802 if (sourcenode.parent != null) // july 2014
16531803 sourcenode.parent.
16541804 TransformToLocal(dst);
....@@ -1700,26 +1850,26 @@
17001850 // mars 2014
17011851 if (false) // goalx != 0 || goalz != 0)
17021852 {
1703
- targetx = dst.x - src.x;
1704
- targetz = dst.z - src.z;
1853
+ targetdirx = dst.x - src.x;
1854
+ targetdirz = dst.z - src.z;
17051855
1706
- if (Math.abs(targetx) > 0.1 || Math.abs(targetz) > 0.1)
1856
+ if (Math.abs(targetdirx) > 0.1 || Math.abs(targetdirz) > 0.1)
17071857 {
17081858 // far enough from goal. keep the goal position.
1709
- targetx = 0;
1710
- targetz = 0;
1859
+ targetdirx = 0;
1860
+ targetdirz = 0;
17111861 }
17121862 else
17131863 {
17141864 // too close to goal. switch to target direction instead.
1715
- goalx = 0;
1716
- goalz = 0;
1865
+ goalposx = 0;
1866
+ goalposz = 0;
17171867 }
17181868 }
17191869
17201870 //sourcenode.getCentroid(src, true);
17211871
1722
- if (speakernode == sourcenode && goalx == 0 && goalz == 0)
1872
+ if (speakernode == sourcenode && goalposx == 0 && goalposz == 0)
17231873 {
17241874 if (ScriptNode.lastspeaker != null)
17251875 new Exception().printStackTrace();
....@@ -1728,13 +1878,13 @@
17281878
17291879 // LA.xformPos(src, fromParent, src);
17301880
1731
- 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)
17321882 dst.sub(src);
17331883 else
17341884 // vector mode
17351885 {
1736
- dst.x = targetx;
1737
- dst.z = targetz;
1886
+ dst.x = targetdirx;
1887
+ dst.z = targetdirz;
17381888
17391889 // TEST TARGET
17401890 // dst.x = CameraPane.selectedpoint.toParent[3][0];
....@@ -1856,7 +2006,7 @@
18562006 // if (sourcenode.link2master)
18572007 // if (goalx != 0 || goalz != 0)
18582008 // K = 0.02; // .0625;
1859
- if (parent.link2master) // strong pin on floor
2009
+ if (parent.Link2Support()) // strong pin on floor
18602010 {
18612011 K = 0.05; // 0.02;
18622012 }
....@@ -2144,7 +2294,7 @@
21442294 }
21452295
21462296 if (!smoothed)
2147
- for (int i=0; --i>=0;)
2297
+ for (int i=10; --i>=0;)
21482298 SmoothAnimData(); // much reduces shakiness
21492299
21502300 smoothed = true;
....@@ -2182,9 +2332,16 @@
21822332 toVector.x = LA.cos(to);
21832333 toVector.y = LA.sin(to);
21842334
2335
+ double fromA = Math.atan2(fromVector.y, fromVector.x);
2336
+ double toA = Math.atan2(toVector.y, toVector.x);
2337
+
21852338 Vector2d currentVector = Slerp(fromVector, toVector, step);
21862339
2187
- 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;
21882345 }
21892346
21902347 public static Vector2d Slerp(Vector2d from, Vector2d to, double step)
....@@ -2237,6 +2394,8 @@
22372394 e.printStackTrace();
22382395 }
22392396
2397
+ SetHipOrientation();
2398
+
22402399 if (true)
22412400 return;
22422401
....@@ -2264,9 +2423,9 @@
22642423 // SetBreakPoint(get(0).toParent[0], 0);
22652424 // }
22662425
2267
- boolean setrotation = get(0).link2master && !firsttimeafterload && frame > 0;
2426
+ boolean setrotation = get(0).Link2Support() && !firsttimeafterload && frame > 0;
22682427 boolean setposition = sourcenode != null && // sourcenode.parent != null && // july 2014
2269
- sourcenode./*parent.*/link2master && !firsttimeafterload && frame > 0;
2428
+ sourcenode./*parent.*/Link2Support() && !firsttimeafterload && frame > 0;
22702429
22712430 // cVector centroid = new cVector();
22722431 // cVector floor = new cVector();
....@@ -2664,8 +2823,9 @@
26642823 // set rotation
26652824 //if (bone._rotationEnabled)
26662825 if (//frame > 0 &&
2667
- !bone.skipmocap //&&
2668
- //!bone.name.contains("head") &&
2826
+ !bone.skipmocap &&
2827
+ !bone.name.contains("head") &&
2828
+ !bone.name.contains("Head") // &&
26692829 // !bone.name.contains("rFoot") &&
26702830 // !bone.name.contains("lFoot") &&
26712831 // !bone.name.contains("Pinky") &&
....@@ -2698,7 +2858,7 @@
26982858
26992859 // set translation
27002860 // (currently only possible for root bone! see mocapdata.com data)
2701
- if (bone._isRoot && link2master) // && !GetFileRoot().link2master)
2861
+ if (bone._isRoot && Link2Support()) // && !GetFileRoot().link2master)
27022862 {
27032863 if (hasTranslation) // && _translationEnabled)
27042864 {
....@@ -3020,7 +3180,8 @@
30203180 }
30213181 }
30223182
3023
- static int offset = 1; // 5; // 10; // 5; // 100; // skip initial "T"
3183
+ // skip initial "T"
3184
+ static int offset = 1; // 5; // 10; // 5; // 100;
30243185
30253186 void ReadBVH()
30263187 {
....@@ -3049,8 +3210,8 @@
30493210
30503211 void Reset()
30513212 {
3052
- if (fullname != null)
3053
- ReadBVH();
3213
+// if (fullname != null)
3214
+// ReadBVH();
30543215
30553216 Object3D hip = get(0);
30563217
....@@ -3089,8 +3250,8 @@
30893250 // LA.matIdentity(rot.fromParent);
30903251
30913252 // july 2014
3092
- goalx = goalz = 0;
3093
- targetx = targetz = 0;
3253
+// goalx = goalz = 0;
3254
+ targetdirx = targetdirz = 0;
30943255
30953256 //SetPositionDelta(true, true, true, false);
30963257 // LoadData();
....@@ -3100,8 +3261,8 @@
31003261
31013262 // aout 2013 endframe = 0; // june 2013
31023263
3103
- //ResetZero();
3104
- setPose(frame);
3264
+ ResetZero();
3265
+ //setPose(frame);
31053266 }
31063267
31073268 static int mocapsupport = 0;
....@@ -3119,12 +3280,13 @@
31193280
31203281 int step = 1;
31213282
3283
+ // patch for running hare
31223284 if (speedup) // fev 2014
31233285 step *= 2; // 4;
31243286 if (rewind) // mars 2014
31253287 step *= 4;
31263288
3127
- if (CameraPane.FAST) // && !CameraPane.HOLD)
3289
+ //if (CameraPane.FAST) // && !CameraPane.HOLD)
31283290 step *= CameraPane.STEP;
31293291
31303292 //System.err.println("Step Mocap frame # " + frame);
....@@ -3132,7 +3294,7 @@
31323294 baseframe += step;
31333295
31343296 //frame = baseframe;
3135
- frame += step;
3297
+ //frame += step;
31363298
31373299 // if (frame != baseframe)
31383300 // {
....@@ -3156,7 +3318,7 @@
31563318 "; fullname = " + fullname);
31573319
31583320 //int delta = frame - baseframe;
3159
- if (CameraPane.CROWD)
3321
+ if (Globals.CROWD)
31603322 {
31613323 baseframe = GetFirstFrame(); // 0 initial point
31623324 }
....@@ -3165,32 +3327,53 @@
31653327 // SetPositionDelta(false, true, false); // ?? false);
31663328 {
31673329 if (support == null)
3168
- 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
+ }
31693340 else
31703341 {
3171
- try
3172
- {
3342
+// try
3343
+// {
31733344 bvh = ((Mocap)support.get(mocapsupport++ % support.Size())).bvh;
31743345
31753346 // SetPositionDelta(false, true, true, true);
31763347 LoadData();
31773348 Rewind();
31783349 Fade();
3179
- }
3180
- catch (Exception e)
3181
- {
3182
- e.printStackTrace();
3183
- ObjEditor.LoadBVHFile(fullname, this, false, beginframe, lastframetest);
3184
- }
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
+// }
31853364 }
31863365 }
3366
+
3367
+ frame = GetFirstFrame();
31873368 }
3369
+ else
3370
+ frame += step;
31883371
31893372 //SetPositionDelta(false);
31903373
3191
- if (frame >= bvh.animation.getNumFrames())
3192
- //baseframe =
3193
- frame = GetFirstFrame(); // 0; // offset; // initial point
3374
+// if (frame >= bvh.animation.getNumFrames())
3375
+// //baseframe =
3376
+// frame = GetFirstFrame(); // 0; // offset; // initial point
31943377
31953378 //System.err.println("frame = " + frame);
31963379 if (lastframe != 0)
....@@ -3359,6 +3542,7 @@
33593542 // filters out bad input data
33603543 void FilterAnimData()
33613544 {
3545
+ new Exception().printStackTrace();
33623546 System.exit(0);
33633547
33643548 float[] data; // = bvh.animation.getBoneData(0);
....@@ -3716,7 +3900,7 @@
37163900
37173901 transient boolean restarted; // CROWD issue?
37183902
3719
- void drawSelf(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
3903
+ void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
37203904 {
37213905 //System.err.println("drawSelf Mocap frame # " + frame);
37223906 //System.err.println("drawSelf Mocap baseframe # " + baseframe);
....@@ -3733,17 +3917,24 @@
37333917 // if (firstframe)
37343918 // return;
37353919
3736
- if (!restarted && /*display.restartframe &&*/
3737
- 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))
37383922 {
37393923 //display.restartframe = false;
37403924 restarted = true;
3925
+ //System.err.println("restarted = true");
37413926 Step();
3927
+
3928
+ Globals.lighttouched = true;
37423929 }
37433930 else
37443931 {
3745
- if (display.isLIVE() && live && display.drawMode != display.SHADOW)
3932
+ //System.err.println("restarted");
3933
+ if (Globals.isLIVE() && live && display.DrawMode() != iCameraPane.SHADOW)
3934
+ {
37463935 restarted = false;
3936
+ //System.err.println("restarted = false");
3937
+ }
37473938 }
37483939
37493940 super.drawSelf(display, root, selected, blocked);
....@@ -3803,6 +3994,11 @@
38033994 // GetObject().release(i);
38043995 }
38053996
3997
+ boolean HasBigData()
3998
+ {
3999
+ return skeleton != null;
4000
+ }
4001
+
38064002 public Object3D get(int i)
38074003 {
38084004 if (i != 0)