Normand Briere
2018-07-03 02e145cb923d601395acc7f15ae9e13f85ef2fbb
Mocap.java
....@@ -26,6 +26,544 @@
2626 public class Mocap extends Object3D
2727 {
2828 static final long serialVersionUID = 7437391692559853707L;
29
+
30
+ void Fade()
31
+ {
32
+ if (currentbones == null || CameraPane.fullreset)
33
+ return;
34
+
35
+ cVector temp = new cVector();
36
+
37
+ int numframes = bvh.animation.getNumFrames();
38
+
39
+ int b;
40
+ float[] data;
41
+ Quat4d quatstart = new Quat4d();
42
+ Quat4d quatend = new Quat4d();
43
+ Quat4d quat = new Quat4d();
44
+ Matrix4d mat4d = new Matrix4d();
45
+ double[][] rot = new double[4][4];
46
+ for (b=numbones; --b>=0;) // HIP ROTATION: 0;)
47
+ {
48
+ // int hipindex = get(0)._index;
49
+
50
+// assert(get(0).get(0)._isHip);
51
+
52
+ // if (b == hipindex)
53
+ // continue;
54
+
55
+ data = bvh.animation.getBoneData(b);
56
+
57
+ int dof = 3; // data.length/numframes;
58
+
59
+ if (b == 0)
60
+ {
61
+ dof = 6;
62
+ }
63
+ // assert(dof == 3);
64
+
65
+ int boneframe3 = (b-1)*3; // dof;
66
+
67
+ // System.err.println("Bone #" + b + ": dof = " + dof);
68
+ int fadein = 45; // 120;
69
+
70
+ // if (b == hipindex)
71
+ // fadein *= 5;
72
+
73
+ if (fadein > numframes)
74
+ fadein = 0; // numframes;
75
+
76
+ for (int fi=fadein; --fi>=0;)
77
+ //for (int f=numframes; --f>=0;)
78
+ {
79
+ int f = fi + GetFirstFrame();
80
+
81
+ int f3 = f*dof;
82
+
83
+ float k = fi;
84
+
85
+ k /= fadein - 1;
86
+
87
+ if (Float.isNaN(k))
88
+ k = 1; // 0/0
89
+
90
+ k = (float) (-Math.cos(k*Math.PI));
91
+ k += 1;
92
+ k /= 2;
93
+
94
+ int start = 3;
95
+ int end = 0;
96
+
97
+ if (dof == 6)
98
+ {
99
+ start = 6;
100
+ end = 3;
101
+ }
102
+
103
+ if (b == 0)
104
+ {
105
+ for (int i=start; --i>=end;)
106
+ {
107
+ //data[f3 + i] += pos[i] - data[frame3 + i];
108
+// data[f3 + i] = k*data[f3+i] + (1-k)*
109
+// currentbones[boneframe3 + i-end];
110
+// data[f3 + i] = (float)CurveAngle(data[f3+i], currenthip[i], 1-k);
111
+ }
112
+
113
+ // TODO: translation
114
+
115
+// _t1.setIdentity();
116
+// _t2.setIdentity();
117
+// _t2.rotZ(currentbones[boneframe3 + start-1-end]);
118
+// _t1.mul(_t2);
119
+// _t2.setIdentity();
120
+// if (b == 0)
121
+// {
122
+// _t2.rotY(currentbones[boneframe3 + start-2-end]);
123
+// _t1.mul(_t2);
124
+// _t2.setIdentity();
125
+// _t2.rotX(currentbones[boneframe3 + start-3-end]);
126
+// }
127
+// else
128
+// {
129
+// _t2.rotX(currentbones[boneframe3 + start-2-end]);
130
+// _t1.mul(_t2);
131
+// _t2.setIdentity();
132
+// _t2.rotY(currentbones[boneframe3 + start-3-end]);
133
+// }
134
+// _t1.mul(_t2);
135
+// _t2.setIdentity();
136
+//
137
+// _t1.get(mat4d);
138
+//
139
+// mat4d.get(quatstart);
140
+//
141
+// _t1.setIdentity();
142
+// _t2.setIdentity();
143
+// _t2.rotZ(data[f3 + start-1]);
144
+// _t1.mul(_t2);
145
+// _t2.setIdentity();
146
+// if (b == 0)
147
+// {
148
+// _t2.rotY(data[f3 + start-2]);
149
+// _t1.mul(_t2);
150
+// _t2.setIdentity();
151
+// _t2.rotX(data[f3 + start-3]);
152
+// }
153
+// else
154
+// {
155
+// _t2.rotX(data[f3 + start-2]);
156
+// _t1.mul(_t2);
157
+// _t2.setIdentity();
158
+// _t2.rotY(data[f3 + start-3]);
159
+// }
160
+//
161
+// _t1.mul(_t2);
162
+// _t2.setIdentity();
163
+//
164
+// _t1.get(mat4d);
165
+//
166
+// mat4d.get(quatend);
167
+//
168
+// double dot = quatstart.x*quatend.x +
169
+// quatstart.y*quatend.y +
170
+// quatstart.z*quatend.z +
171
+// quatstart.w*quatend.w
172
+// ;
173
+//
174
+// if (dot < 0)
175
+// {
176
+// quatend.x *= -1;
177
+// quatend.y *= -1;
178
+// quatend.z *= -1;
179
+// quatend.w *= -1;
180
+// }
181
+//
182
+// // k = 1-k;
183
+//
184
+// quat.x = (1-k)*quatstart.x + k*quatend.x;
185
+// quat.y = (1-k)*quatstart.y + k*quatend.y;
186
+// quat.z = (1-k)*quatstart.z + k*quatend.z;
187
+// quat.w = (1-k)*quatstart.w + k*quatend.w;
188
+//
189
+// quat.normalize();
190
+//
191
+// mat4d.set(quat);
192
+//
193
+// cJ3D.SetTransform(rot, mat4d);
194
+//
195
+// matrixToEulerXYZ(rot, temp);
196
+//
197
+// data[f3 + start-1] = -(float)temp.z;
198
+//
199
+// if (b == 0)
200
+// {
201
+// data[f3 + start-2] = -(float)temp.y;
202
+// data[f3 + start-3] = -(float)temp.x;
203
+// }
204
+// else
205
+// {
206
+// data[f3 + start-2] = -(float)temp.x;
207
+// data[f3 + start-3] = -(float)temp.y;
208
+// }
209
+ }
210
+ else
211
+ {
212
+ for (int i=start; --i>=end;)
213
+ {
214
+ //data[f3 + i] += pos[i] - data[frame3 + i];
215
+// data[f3 + i] = k*data[f3+i] + (1-k)*
216
+// currentbones[boneframe3 + i-end];
217
+ data[f3 + i] = (float)CurveAngle(data[f3+i], currentbones[boneframe3 + i/*-end*/], 1-k);
218
+ }
219
+ }
220
+ }
221
+ }
222
+ }
223
+
224
+ // Updates the toParent matrix to keep the same position and orientation
225
+ // before resetting the mocap data.
226
+ void SetGlobalTransform()
227
+ {
228
+ //SetCurrentBones(frame);
229
+
230
+ cVector temp = new cVector();
231
+ cVector pos = new cVector();
232
+ cVector poship = new cVector();
233
+
234
+ double angleY = 0;
235
+ double angleYhip = 0;
236
+
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
+ }
244
+
245
+ LA.matConcat(toParent, hip.get(0).toParent, matrix);
246
+ poship.x = matrix[3][0];
247
+ poship.y = matrix[3][1];
248
+ poship.z = matrix[3][2];
249
+
250
+ temp.x = 1;
251
+ temp.y = 0;
252
+ temp.z = 0;
253
+
254
+ LA.xformDir(temp, matrix, temp);
255
+
256
+ angleYhip = Math.atan2(-temp.z, temp.x);
257
+
258
+ LA.matIdentity(toParent);
259
+ LA.matYRotate(toParent, angleYhip);
260
+ LA.matTranslate(toParent, poship.x, poship.y, poship.z);
261
+
262
+// LA.matConcat(toParent, hip.get(0).toParent, toParent);
263
+
264
+ CameraPane.debugpoint.toParent[3][0] = poship.x;
265
+ CameraPane.debugpoint.toParent[3][1] = poship.y;
266
+ CameraPane.debugpoint.toParent[3][2] = poship.z;
267
+
268
+ LA.matInvert(toParent, fromParent);
269
+
270
+ LA.matIdentity(hip.get(0).toParent);
271
+ LA.matIdentity(hip.get(0).fromParent);
272
+
273
+// if (true)
274
+// return;
275
+
276
+ // Updates hip.get(0).toParent
277
+ setPose(hip, GetFirstFrame(), bvh.animation.getBoneData(hip._index));
278
+
279
+ // A = toParent; B = hip.get(0).toParent
280
+ // A'*B = A
281
+ // A' = A * B-1
282
+
283
+ poship.x = hip.get(0).toParent[3][0];
284
+ poship.y = hip.get(0).toParent[3][1];
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);
294
+
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);
301
+
302
+ //LA.matIdentity(matrix);
303
+ //LA.matTranslate(matrix, -poship.x, -poship.y, -poship.z);
304
+
305
+ LA.matConcat(toParent, matrix, toParent);
306
+
307
+
308
+ LA.matConcat(toParent, hip.get(0).toParent, matrix);
309
+ pos.x = hip.get(0).toParent[3][0];
310
+ pos.y = hip.get(0).toParent[3][1];
311
+ pos.z = hip.get(0).toParent[3][2];
312
+ LA.xformPos(new cVector(), hip.get(0).toParent, pos);
313
+ LA.xformPos(pos, toParent, pos);
314
+
315
+// temp.x = 1;
316
+// temp.y = 0;
317
+// temp.z = 0;
318
+//
319
+// LA.xformDir(temp, toParent, temp);
320
+//
321
+// angleY = Math.atan2(-temp.z, temp.x);
322
+//
323
+// LA.matIdentity(toParent);
324
+// LA.matYRotate(toParent, angleY - angleYhip);
325
+// LA.matTranslate(toParent, pos.x - poship.x, pos.y - poship.y, pos.z - poship.z);
326
+
327
+ CameraPane.debugpoint2.toParent[3][0] = pos.x;
328
+ CameraPane.debugpoint2.toParent[3][1] = pos.y;
329
+ CameraPane.debugpoint2.toParent[3][2] = pos.z;
330
+
331
+ CameraPane.debugpoint3.toParent[3][0] = poship.x;
332
+ CameraPane.debugpoint3.toParent[3][1] = poship.y;
333
+ CameraPane.debugpoint3.toParent[3][2] = poship.z;
334
+
335
+ poship.x = toParent[3][0];
336
+ poship.y = toParent[3][1];
337
+ poship.z = toParent[3][2];
338
+
339
+ CameraPane.debugpoint4.toParent[3][0] = poship.x;
340
+ CameraPane.debugpoint4.toParent[3][1] = poship.y;
341
+ CameraPane.debugpoint4.toParent[3][2] = poship.z;
342
+
343
+ LA.matInvert(toParent, fromParent);
344
+ }
345
+
346
+ void LoadData()
347
+ {
348
+ float[] thedata = bvh.animation.getBoneData(0);
349
+
350
+// thedata[0] = 0;
351
+// thedata[1] = 0;
352
+// thedata[2] = 0;
353
+// thedata[3] = 0;
354
+// thedata[4] = 0;
355
+// thedata[5] = 0;
356
+
357
+ if (true)
358
+ return;
359
+
360
+ for (int b=numbones; --b>=0;)
361
+ //int b = 0;
362
+ {
363
+ thedata = bvh.animation.getBoneData(b);
364
+
365
+ int numframes = bvh.animation.getNumFrames();
366
+
367
+ int dof = 6; // thedata.length/numframes;
368
+
369
+ if (b > 0)
370
+ dof = 3;
371
+
372
+ if (dof != thedata.length/numframes)
373
+ {
374
+ System.err.println("Bone #" + b + ": dof = " + dof + " ---> " + (thedata.length/numframes));
375
+ dof = thedata.length/numframes;
376
+ }
377
+
378
+ //for (int f=numframes; --f>=offset;)
379
+ int firstframe = GetFirstFrame();
380
+ for (int f=0; f<numframes-firstframe; f++)
381
+ {
382
+ int f3 = f*dof;
383
+
384
+ //for (int i=3/*dof*/; --i>=0;)
385
+ for (int i=dof; --i>=0;)
386
+ {
387
+ //thedata[f3 + i] += thedata[i] - thedata[offset*dof + i];
388
+ thedata[f3 + i] = thedata[f3 + firstframe*dof + i];
389
+ }
390
+ }
391
+ }
392
+ }
393
+
394
+ void ResetZero()
395
+ {
396
+ for (int b=numbones; --b>=0;)
397
+ {
398
+ float[] thedata = bvh.animation.getBoneData(b);
399
+
400
+ int numframes = bvh.animation.getNumFrames();
401
+
402
+ int dof = 6;
403
+
404
+ if (b > 0)
405
+ dof = 3;
406
+
407
+ for (int i=dof; --i>=0;)
408
+ {
409
+ thedata[i] = 0;
410
+ }
411
+ }
412
+ }
413
+
414
+ void SetCurrentBones(int frame)
415
+ {
416
+ if (frame == 0)
417
+ {
418
+ //frame = 1;
419
+ }
420
+
421
+ if (currentbones == null)
422
+ {
423
+ currentbones = new double[(numbones-1)*3];
424
+ currenthip = new double[6];
425
+ }
426
+
427
+ for (int b=numbones; --b>=1;) // HIP ROTATION: 0;)
428
+ //int b = 0;
429
+ {
430
+ float[] data = bvh.animation.getBoneData(b);
431
+
432
+ // int numframes = bvh.animation.getNumFrames();
433
+
434
+ int dof = 6; // data.length/numframes;
435
+
436
+ if (b > 0)
437
+ dof = 3;
438
+
439
+ //assert(dof == 3);
440
+
441
+ // System.err.println("Bone #" + b + ": dof = " + dof);
442
+ int theframe = // 1; // baseframe;
443
+ frame;
444
+
445
+ int frame3 = theframe*dof;
446
+ int bone3 = (b-1)*dof;
447
+
448
+ int start = 3;
449
+ int end = 0;
450
+
451
+ if (dof == 6)
452
+ {
453
+ start = 6;
454
+ //end = 3;
455
+ }
456
+
457
+ for (int i=start; --i>=end;)
458
+ {
459
+ currentbones[bone3 + i/*-end*/] = data[frame3 + i];
460
+ }
461
+ }
462
+
463
+ float[] data = bvh.animation.getBoneData(0);
464
+
465
+ int dof = 6;
466
+
467
+ int theframe = frame;
468
+
469
+ int frame3 = theframe*dof;
470
+
471
+ int start = 6;
472
+ int end = 0;
473
+
474
+ for (int i=start; --i>=end;)
475
+ {
476
+ currenthip[i] = data[frame3 + i];
477
+ }
478
+ }
479
+
480
+ void SetHipOrientation()
481
+ {
482
+ Object3D hip = get(0);
483
+
484
+ LA.matConcat(toParent, hip.get(0).toParent, matrix);
485
+
486
+ cVector centroid = new cVector();
487
+ centroid.x = matrix[3][0];
488
+ centroid.y = matrix[3][1];
489
+ centroid.z = matrix[3][2];
490
+ this.getCentroid(centroid, true);
491
+
492
+ cVector goal = GetGoal(centroid);
493
+ if (goal != null)
494
+ {
495
+ System.err.println("GOAL change (" + this + "): " + goal + " (was " + goalx + ", " + goalz + ")");
496
+
497
+ goalx = goal.x;
498
+ goalz = goal.z;
499
+ targetx = targetz = 0;
500
+ }
501
+
502
+ if (goalx == 0 && goalz == 0)
503
+ {
504
+ // No target
505
+ if (ScriptNode.speaker != null)
506
+ {
507
+ Object3D sourcenode = GetFileRoot();
508
+ Object3D speakernode = ScriptNode.speaker.GetFileRoot();
509
+
510
+ //System.err.println("speaker is " + speakernode + "; last was " + ScriptNode.lastspeaker);
511
+
512
+ Object3D speaker = ScriptNode.speaker;
513
+
514
+ if (speakernode == sourcenode)
515
+ {
516
+ if (ScriptNode.lastspeaker != null)
517
+ {
518
+ speakernode = ScriptNode.lastspeaker.GetFileRoot();
519
+ speaker = ScriptNode.lastspeaker;
520
+ }
521
+ else
522
+ return;
523
+ }
524
+
525
+ cVector dst = new cVector();
526
+
527
+ boolean success = speakernode.getCentroid(dst); // , true);
528
+
529
+ if (!success)
530
+ new Exception().printStackTrace();
531
+
532
+ //speakernode.parent.TransformToWorld(dst);
533
+ //sourcenode.parent.TransformToLocal(dst);
534
+ this.parent.TransformToLocal(dst);
535
+
536
+ goalx = dst.x;
537
+ goalz = dst.z;
538
+ }
539
+ else
540
+ return;
541
+ }
542
+
543
+ cVector temp = new cVector();
544
+
545
+ temp.x = 1;
546
+ temp.y = 0;
547
+ temp.z = 0;
548
+
549
+ LA.xformDir(temp, matrix, temp);
550
+
551
+ double angleYhip = Math.atan2(-temp.z, temp.x);
552
+
553
+ double angleYtarget = Math.atan2(goalx - centroid.x, goalz - centroid.z);
554
+
555
+ LA.matIdentity(matrix);
556
+ LA.matTranslate(matrix, -centroid.x, -centroid.y, -centroid.z);
557
+ double angle = CurveAngle(0, angleYtarget - angleYhip, 1); // 0.1f);
558
+ LA.matYRotate(matrix, angle);
559
+ LA.matTranslate(matrix, centroid.x, centroid.y, centroid.z);
560
+
561
+ LA.matConcat(matrix, toParent, toParent);
562
+
563
+ LA.matInvert(toParent, fromParent);
564
+
565
+ CheckForAction(centroid);
566
+ }
29567
30568 void WriteTo(java.io.Writer writer) throws Exception
31569 {
....@@ -102,8 +640,8 @@
102640 double targetx;
103641 double targetz;
104642
105
- double goalx;
106
- double goalz;
643
+ double goalx = -20;
644
+ double goalz = -10;
107645
108646 boolean followpath;
109647
....@@ -460,6 +998,8 @@
460998 testvect.set(from);
461999 testvect.sub(fromto.from);
4621000
1001
+ testvect.y = 0; // PATCH
1002
+
4631003 int factor = 1;
4641004
4651005 //if (CameraPane.FAST)
....@@ -501,6 +1041,8 @@
5011041
5021042 testvect.set(from);
5031043 testvect.sub(fromto.from);
1044
+
1045
+ testvect.y = 0; // PATCH
5041046
5051047 int factor = 1;
5061048
....@@ -705,7 +1247,7 @@
7051247 // skip first node: translation
7061248 // Object3D b = input.get(0);
7071249
708
- setPose(input, f, data.getBoneData(input._index), false); //, null);
1250
+ setPose(input, f, data.getBoneData(input._index)); //, false); //, null);
7091251 }
7101252
7111253 //mocap.figure.Bone[] children = b.getChildren();
....@@ -921,7 +1463,7 @@
9211463 //groundz += sourcenode.parent.toParent[3][2] - posz;
9221464 }
9231465
924
- boolean footcontact = CameraPane.FOOTCONTACT; // false;
1466
+ boolean footcontact = false; // CameraPane.FOOTCONTACT; // false;
9251467
9261468 if (footcontact && ground != -123456)
9271469 {
....@@ -1220,6 +1762,7 @@
12201762 src.x = 0;
12211763 src.y = 0;
12221764 src.z = 0;
1765
+ LA.xformPos(src, get(0).get(0).toParent, src);
12231766 LA.xformPos(src, get(0).toParent, src);
12241767 LA.xformPos(src, toParent, src);
12251768 // LA.xformPos(src, rotsourcenode.toParent, src);
....@@ -1563,6 +2106,7 @@
15632106 toParent = LA.newMatrix();
15642107 fromParent = LA.newMatrix();
15652108 }
2109
+
15662110 LA.matConcat(toParent, rotsourcenode.toParent, toParent);
15672111 LA.matInvert(toParent, fromParent);
15682112
....@@ -1698,7 +2242,7 @@
16982242 }
16992243
17002244 if (!smoothed)
1701
- for (int i=4; --i>=0;)
2245
+ for (int i=0; --i>=0;)
17022246 SmoothAnimData(); // much reduces shakiness
17032247
17042248 smoothed = true;
....@@ -1780,12 +2324,28 @@
17802324 if (!live) // aout 2013
17812325 return;
17822326
1783
- cVector centroid = new cVector();
1784
- cVector floor = new cVector();
1785
-
1786
- Object3D sourcenode = GetFileRoot();
2327
+ //bvh.skeleton.setPose(f, bvh.animation.getBoneData(bvh.skeleton.getIndex()), null);
2328
+ try
2329
+ {
2330
+ SetPose(GetSkeleton(), bvh.animation, f);
2331
+ SetCurrentBones(frame);
2332
+ }
2333
+ catch (Exception e)
2334
+ {
2335
+ e.printStackTrace();
2336
+ }
17872337
1788
- boolean success; // = sourcenode.getCentroid(centroid);
2338
+ SetHipOrientation();
2339
+
2340
+ if (true)
2341
+ return;
2342
+
2343
+ cVector centroid = new cVector();
2344
+ cVector floor = new cVector();
2345
+
2346
+ Object3D sourcenode = GetFileRoot();
2347
+
2348
+ boolean success; // = sourcenode.getCentroid(centroid);
17892349 // if (!success)
17902350 // {
17912351 // //assert(success);
....@@ -1793,16 +2353,6 @@
17932353 // System.out.println("No centroid for " + sourcenode);
17942354 // }
17952355
1796
- //bvh.skeleton.setPose(f, bvh.animation.getBoneData(bvh.skeleton.getIndex()), null);
1797
- try
1798
- {
1799
- SetPose(GetSkeleton(), bvh.animation, f);
1800
- }
1801
- catch (Exception e)
1802
- {
1803
- e.printStackTrace();
1804
- }
1805
-
18062356 if (sourcenode.parent == null && sourcenode.fileparent == null)
18072357 {
18082358 // No GFD
....@@ -2050,7 +2600,7 @@
20502600 * @param frame
20512601 * Frame number
20522602 */
2053
- public void setPose(Object3D bone, int frame, float[] data, boolean fade) //, Point3d offsetTrans)
2603
+ public void setPose(Object3D bone, int frame, float[] data) //, boolean fade) //, Point3d offsetTrans)
20542604 {
20552605 if (!live) // aout 2013
20562606 return;
....@@ -2058,6 +2608,33 @@
20582608 cVector temp = new cVector();
20592609 cVector temp0 = new cVector();
20602610 double pos[] = new double[3];
2611
+ double angleY = 0;
2612
+ double sinY = 0;
2613
+ double cosY = 0;
2614
+
2615
+ if (false) // bone._isRoot && firsttimeafterload && frame > 0)
2616
+ {
2617
+ bone.get(0).GlobalTransformInv();
2618
+
2619
+ temp.x = bone.get(0).globalTransform[3][0];
2620
+ temp.y = bone.get(0).globalTransform[3][1];
2621
+ temp.z = bone.get(0).globalTransform[3][2];
2622
+
2623
+ pos[0] = temp.x;
2624
+ pos[1] = temp.y;
2625
+ pos[2] = temp.z;
2626
+
2627
+ temp.x = 1;
2628
+ temp.y = 0;
2629
+ temp.z = 0;
2630
+
2631
+ LA.xformDir(temp, bone.get(0).globalTransform, temp);
2632
+
2633
+ sinY = temp.z;
2634
+ cosY = temp.x;
2635
+
2636
+ angleY = Math.atan2(-sinY, cosY);
2637
+ }
20612638
20622639 // Object3D obj = get(0);
20632640 // Object3D gp = this.parent;
....@@ -2188,14 +2765,14 @@
21882765 //if (bone._rotationEnabled)
21892766 if (//frame > 0 &&
21902767 !bone.skipmocap &&
2191
- !bone.name.contains("head") &&
2768
+ !bone.name.contains("head") // &&
21922769 // !bone.name.contains("rFoot") &&
21932770 // !bone.name.contains("lFoot") &&
2194
- !bone.name.contains("Pinky") &&
2195
- !bone.name.contains("Ring") &&
2196
- !bone.name.contains("Mid") &&
2197
- !bone.name.contains("Index") &&
2198
- !bone.name.contains("Thumb")
2771
+// !bone.name.contains("Pinky") &&
2772
+// !bone.name.contains("Ring") &&
2773
+// !bone.name.contains("Mid") &&
2774
+// !bone.name.contains("Index") &&
2775
+// !bone.name.contains("Thumb")
21992776 )
22002777 {
22012778 //_rotTG.setTransform(_t1);
....@@ -2228,15 +2805,17 @@
22282805 // CROWD
22292806 //cJ3D.GetTranslation(bone, _trans0);
22302807 //_trans.add(_trans0);
2231
- _transTF.setIdentity();
2808
+ //_transTF.setIdentity();
2809
+ _transTF.set(_t1);
22322810 _transTF.setTranslation(_trans);
22332811 // System.err.println("Translate: " + _transTF);
22342812 //_transTG.setTransform(_transTF);
2235
- cJ3D.ResetTransform(bone, _transTF, true); // translation node
2813
+ cJ3D.ResetTransform(bone.get(0), _transTF, true); // translation node
2814
+ //cJ3D.ResetTransform(bone, _transTF, true); // translation node
22362815 }
22372816 }
22382817
2239
- if (bone._isRoot && firsttimeafterload && frame > 0)
2818
+ if (false) // bone._isRoot && firsttimeafterload && frame > 0)
22402819 {
22412820 assert(bone == get(0));
22422821
....@@ -2252,17 +2831,17 @@
22522831 // LA.matConcat(originmatrixinv, tempmatrixinv, fromParent); // ABC * (B'*C')^-1
22532832 //
22542833
2255
- Invariants();
2256
- bone.Invariants();
2257
- bone.get(0).Invariants();
2258
- // if (origin == null)
2259
- // origin = null;
2260
- origin.Invariants();
2261
- origin0.Invariants();
2834
+ Invariants();
2835
+ bone.Invariants();
2836
+ bone.get(0).Invariants();
2837
+ // if (origin == null)
2838
+ // origin = null;
2839
+ origin.Invariants();
2840
+ origin0.Invariants();
22622841
2263
-
2264
- LA.matConcat(bone.get(0).fromParent, bone.fromParent, tempmatrix); // B' * C'
2265
- LA.matConcat(origin.toParent, tempmatrix, toParent);
2842
+
2843
+//?? LA.matConcat(bone.get(0).fromParent, bone.fromParent, tempmatrix); // B' * C'
2844
+//?? LA.matConcat(origin.toParent, tempmatrix, toParent);
22662845
22672846 // matrixToEulerXYZ(toParent, temp);
22682847 // matrixToEulerXYZ(bone.get(0).toParent, temp);
....@@ -2296,7 +2875,7 @@
22962875 //
22972876 // mat4d.get(quat);
22982877
2299
- if (true) // hip correction
2878
+ if (false) // hip correction
23002879 {
23012880 _t2.setIdentity();
23022881
....@@ -2337,13 +2916,13 @@
23372916 //????? LA.matConcat(bone.get(0).toParent, bone.toParent, tempmatrix); // B' * C'
23382917 // LA.matConcat(origin.fromParent, tempmatrix, fromParent);
23392918
2340
- LA.matInvert(toParent, fromParent);
2919
+//?? LA.matInvert(toParent, fromParent);
23412920
2342
- Invariants();
2343
- bone.Invariants();
2344
- bone.get(0).Invariants();
2345
- origin.Invariants();
2346
- origin0.Invariants();
2921
+ Invariants();
2922
+ bone.Invariants();
2923
+ bone.get(0).Invariants();
2924
+ origin.Invariants();
2925
+ origin0.Invariants();
23472926
23482927 // LA.matInvert(fromParent, tempmatrix);
23492928 //
....@@ -2364,33 +2943,39 @@
23642943 // temp.x = data[0];
23652944 // temp.y = data[1];
23662945 // temp.z = data[2];
2367
- LA.xformPos(temp, origin0.toParent, temp0);
2946
+ LA.xformPos(temp, origin0.toParent, temp0); // NU
23682947
2369
-// bone.GlobalTransformInv();
2370
-
2371
- temp0.x = bone.globalTransform[3][0];
2372
- temp0.y = bone.globalTransform[3][1];
2373
- temp0.z = bone.globalTransform[3][2];
2374
-
2948
+// bone.get(0).GlobalTransformInv();
2949
+//
2950
+// temp0.x = bone.get(0).globalTransform[3][0];
2951
+// temp0.y = bone.get(0).globalTransform[3][1];
2952
+// temp0.z = bone.get(0).globalTransform[3][2];
2953
+//
23752954 // MEGA TEST // june 2014: necessary for precision? otherwise comment works
2376
-fromParent[3][0] = 0;
2377
-fromParent[3][1] = 0;
2378
-fromParent[3][2] = 0;
2379
-LA.matInvert(fromParent, toParent);
2955
+//fromParent[3][0] = 0;
2956
+//fromParent[3][1] = 0;
2957
+//fromParent[3][2] = 0;
2958
+//LA.matInvert(fromParent, toParent);
23802959
2381
- LA.xformPos(temp0, fromParent, temp);
2960
+ LA.xformPos(temp0, fromParent, temp); // NU
23822961 //LA.xformPos(temp, bone.fromParent, temp);
23832962 // float[] data;
23842963
2385
- pos[0] = temp.x;
2386
- pos[1] = temp.y;
2387
- pos[2] = temp.z;
2964
+// pos[0] = temp.x;
2965
+// pos[1] = temp.y;
2966
+// pos[2] = temp.z;
2967
+//
2968
+// temp.x = 1;
2969
+// temp.y = 0;
2970
+// temp.z = 0;
2971
+//
2972
+// LA.xformDir(temp, bone.get(0).globalTransform, temp);
23882973
23892974 // CameraPane.selectedpoint.toParent[3][0] = temp0.x;
23902975 // CameraPane.selectedpoint.toParent[3][1] = temp0.y;
23912976 // CameraPane.selectedpoint.toParent[3][2] = temp0.z;
23922977
2393
- int numframes = bvh.animation.getNumFrames();
2978
+ int numframes = bvh.animation.getNumFrames();
23942979
23952980 int b = 0;
23962981 {
....@@ -2398,12 +2983,12 @@
23982983
23992984 int dof = 6; /// data.length/numframes;
24002985
2401
- // july 2014
2402
- if (dof != data.length/numframes)
2403
- {
2404
- System.err.println("Bone #" + b + ": dof = " + dof + " ---> " + (data.length/numframes));
2405
- dof = data.length/numframes;
2406
- }
2986
+ // july 2014
2987
+ if (dof != data.length/numframes)
2988
+ {
2989
+ System.err.println("Bone #" + b + ": dof = " + dof + " ---> " + (data.length/numframes));
2990
+ dof = data.length/numframes;
2991
+ }
24072992
24082993
24092994 int theframe = 0; // baseframe;
....@@ -2455,17 +3040,26 @@
24553040 // }
24563041 // }
24573042
2458
- data[f3 + i] += pos[i] - data[frame3 + i];
3043
+ data[f3 + i] += /*pos[i]*/ - data[frame3 + i];
24593044
24603045 // if (f < 3)
24613046 // {
24623047 // System.out.print(data[f3 + i] + " ");
24633048 // }
24643049 }
2465
-// if (f < 3)
2466
-// {
2467
-// System.out.println();
2468
-// }
3050
+
3051
+ double t1 = data[f3 + 0];
3052
+ double t2 = data[f3 + 2];
3053
+
3054
+ data[f3 + 0] = (float)(cosY*t1 - sinY*t2);
3055
+ data[f3 + 2] = (float)(sinY*t1 + cosY*t2);
3056
+
3057
+ for (int i=3/*dof*/; --i>=0;)
3058
+ {
3059
+ data[f3 + i] += pos[i];
3060
+ }
3061
+
3062
+ data[f3 + 4] += angleY - data[frame3 + 4];
24693063 }
24703064 }
24713065
....@@ -2479,186 +3073,17 @@
24793073 // temp.y = data[1];
24803074 // temp.z = data[2];
24813075
2482
- if (fade && currentbones != null && !CameraPane.fullreset)
2483
- {
2484
- Quat4d quatstart = new Quat4d();
2485
- Quat4d quatend = new Quat4d();
2486
- Quat4d quat = new Quat4d();
2487
- Matrix4d mat4d = new Matrix4d();
2488
- double[][] rot = new double[4][4];
2489
-
2490
- for (b=numbones; --b>=1;) // HIP ROTATION: 0;)
2491
- {
2492
- int hipindex = get(0)._index;
2493
-
2494
-// assert(get(0).get(0)._isHip);
2495
-
2496
- // if (b == hipindex)
2497
- // continue;
2498
-
2499
- data = bvh.animation.getBoneData(b);
2500
-
2501
- int dof = 3; // data.length/numframes;
2502
-
2503
- // assert(dof == 3);
2504
-
2505
- int boneframe3 = b*3; // dof;
2506
-
2507
- // System.err.println("Bone #" + b + ": dof = " + dof);
2508
- int fadein = 45; // 120;
2509
-
2510
- // if (b == hipindex)
2511
- // fadein *= 5;
2512
-
2513
- if (fadein > numframes)
2514
- fadein = 0; // numframes;
2515
-
2516
- for (int fi=fadein; --fi>=0;)
2517
- //for (int f=numframes; --f>=0;)
2518
- {
2519
- int f = fi + GetFirstFrame();
2520
-
2521
- int f3 = f*dof;
2522
-
2523
- float k = fi;
2524
-
2525
- k /= fadein - 1;
2526
-
2527
- if (Float.isNaN(k))
2528
- k = 1; // 0/0
2529
-
2530
- k = (float) (-Math.cos(k*Math.PI));
2531
- k += 1;
2532
- k /= 2;
2533
-
2534
- int start = 3;
2535
- int end = 0;
2536
-
2537
- if (dof == 6)
2538
- {
2539
- start = 6;
2540
- end = 3;
2541
- }
2542
-
2543
- if (b == 0)
2544
- {
2545
- _t1.setIdentity();
2546
- _t2.setIdentity();
2547
- _t2.rotZ(currentbones[boneframe3 + start-1-end]);
2548
- _t1.mul(_t2);
2549
- _t2.setIdentity();
2550
- if (b == 0)
2551
- {
2552
- _t2.rotY(currentbones[boneframe3 + start-2-end]);
2553
- _t1.mul(_t2);
2554
- _t2.setIdentity();
2555
- _t2.rotX(currentbones[boneframe3 + start-3-end]);
2556
- }
2557
- else
2558
- {
2559
- _t2.rotX(currentbones[boneframe3 + start-2-end]);
2560
- _t1.mul(_t2);
2561
- _t2.setIdentity();
2562
- _t2.rotY(currentbones[boneframe3 + start-3-end]);
2563
- }
2564
- _t1.mul(_t2);
2565
- _t2.setIdentity();
2566
-
2567
- _t1.get(mat4d);
2568
-
2569
- mat4d.get(quatstart);
2570
-
2571
- _t1.setIdentity();
2572
- _t2.setIdentity();
2573
- _t2.rotZ(data[f3 + start-1]);
2574
- _t1.mul(_t2);
2575
- _t2.setIdentity();
2576
- if (b == 0)
2577
- {
2578
- _t2.rotY(data[f3 + start-2]);
2579
- _t1.mul(_t2);
2580
- _t2.setIdentity();
2581
- _t2.rotX(data[f3 + start-3]);
2582
- }
2583
- else
2584
- {
2585
- _t2.rotX(data[f3 + start-2]);
2586
- _t1.mul(_t2);
2587
- _t2.setIdentity();
2588
- _t2.rotY(data[f3 + start-3]);
2589
- }
2590
-
2591
- _t1.mul(_t2);
2592
- _t2.setIdentity();
2593
-
2594
- _t1.get(mat4d);
2595
-
2596
- mat4d.get(quatend);
2597
-
2598
- double dot = quatstart.x*quatend.x +
2599
- quatstart.y*quatend.y +
2600
- quatstart.z*quatend.z +
2601
- quatstart.w*quatend.w
2602
- ;
2603
-
2604
- if (dot < 0)
2605
- {
2606
- quatend.x *= -1;
2607
- quatend.y *= -1;
2608
- quatend.z *= -1;
2609
- quatend.w *= -1;
2610
- }
2611
-
2612
- // k = 1-k;
2613
-
2614
- quat.x = (1-k)*quatstart.x + k*quatend.x;
2615
- quat.y = (1-k)*quatstart.y + k*quatend.y;
2616
- quat.z = (1-k)*quatstart.z + k*quatend.z;
2617
- quat.w = (1-k)*quatstart.w + k*quatend.w;
2618
-
2619
- quat.normalize();
2620
-
2621
- mat4d.set(quat);
2622
-
2623
- cJ3D.SetTransform(rot, mat4d);
2624
-
2625
- matrixToEulerXYZ(rot, temp);
2626
-
2627
- data[f3 + start-1] = -(float)temp.z;
2628
-
2629
- if (b == 0)
2630
- {
2631
- data[f3 + start-2] = -(float)temp.y;
2632
- data[f3 + start-3] = -(float)temp.x;
2633
- }
2634
- else
2635
- {
2636
- data[f3 + start-2] = -(float)temp.x;
2637
- data[f3 + start-3] = -(float)temp.y;
2638
- }
2639
- }
2640
- else
2641
- {
2642
- for (int i=start; --i>=end;)
2643
- {
2644
- //data[f3 + i] += pos[i] - data[frame3 + i];
2645
- // data[f3 + i] = k*data[f3+i] + (1-k)*
2646
- // currentbones[boneframe3 + i-end];
2647
- data[f3 + i] = (float)CurveAngle(data[f3+i], currentbones[boneframe3 + i-end], 1-k);
2648
- }
2649
- }
2650
-
2651
- }
2652
- }
2653
-
2654
- }
3076
+// if (fade && currentbones != null && !CameraPane.fullreset)
3077
+// {
3078
+// Fade();
3079
+// }
26553080 }
2656
-
3081
+
26573082 if (false) // doesn't change anything bone._isRoot)
26583083 {
26593084 // Reset orientation
26603085 _t2.setIdentity();
2661
-
3086
+
26623087 double tx = bone.toParent[3][0];
26633088 double ty = bone.toParent[3][1];
26643089 double tz = bone.toParent[3][2];
....@@ -2667,9 +3092,9 @@
26673092 temp.y = 0;
26683093 temp.z = 0;
26693094 LA.xformDir(temp, bone.toParent, temp);
2670
-
3095
+
26713096 double angle = Math.atan2(-temp.z, temp.x);
2672
-
3097
+
26733098 _t2.rotY(angle);
26743099 // _t1.setIdentity();
26753100 // _t1.rotX(temp.x);
....@@ -2682,56 +3107,21 @@
26823107 // _t1.setIdentity();
26833108 // _t1.rotZ(temp.z);
26843109 // _t2.mul(_t1);
2685
-
3110
+
26863111 cJ3D.ResetTransform(bone, _t2, false);
2687
-
3112
+
26883113 bone.toParent[3][0] = tx;
26893114 bone.toParent[3][1] = ty;
26903115 bone.toParent[3][2] = tz;
26913116 }
26923117 }
26933118
2694
- if (currentbones == null)
2695
- currentbones = new double[numbones*3];
2696
-
2697
- for (int b=numbones; --b>=1;) // 0;)
2698
- //int b = 0;
2699
- {
2700
- data = bvh.animation.getBoneData(b);
2701
-
2702
- int numframes = bvh.animation.getNumFrames();
2703
-
2704
- int dof = 6; // data.length/numframes;
2705
-
2706
- if (b > 0)
2707
- dof = 3;
2708
-
2709
- //assert(dof == 3);
2710
-
2711
- // System.err.println("Bone #" + b + ": dof = " + dof);
2712
- int theframe = // 1; // baseframe;
2713
- frame;
2714
-
2715
- int frame3 = theframe*dof;
2716
- int bone3 = b*3; // dof;
2717
-
2718
- int start = 3;
2719
- int end = 0;
2720
-
2721
- if (dof == 6)
2722
- {
2723
- start = 6;
2724
- end = 3;
2725
- }
2726
- for (int i=start; --i>=end;)
2727
- {
2728
- currentbones[bone3 + i-end] = data[frame3 + i];
2729
- }
2730
- }
3119
+ // SetCurrentBones(frame);
27313120 }
27323121 }
27333122
2734
- static int offset = 1; // 5; // 10; // 5; // 100; // skip initial "T"
3123
+ // skip initial "T"
3124
+ static int offset = 1; // 5; // 10; // 5; // 100;
27353125
27363126 void ReadBVH()
27373127 {
....@@ -2760,14 +3150,14 @@
27603150
27613151 void Reset()
27623152 {
2763
- if (fullname != null)
2764
- ReadBVH();
3153
+// if (fullname != null)
3154
+// ReadBVH();
27653155
27663156 Object3D hip = get(0);
27673157
27683158 // assert(obj.name.equals("hip"));
27693159
2770
- Object3D rot = hip.get(0);
3160
+ //Object3D rot = hip.get(0);
27713161
27723162 // assert(obj.name == null); // .equals("hip#"));
27733163
....@@ -2777,8 +3167,8 @@
27773167 hip.fromParent = LA.newMatrix();
27783168 }
27793169
2780
- hip.toParent[3][0] = hip.toParent[3][1] = hip.toParent[3][2] = 0;
2781
- hip.fromParent[3][0] = hip.fromParent[3][1] = hip.fromParent[3][2] = 0;
3170
+ //hip.toParent[3][0] = hip.toParent[3][1] = hip.toParent[3][2] = 0;
3171
+ //hip.fromParent[3][0] = hip.fromParent[3][1] = hip.fromParent[3][2] = 0;
27823172
27833173 if (toParent == null)
27843174 {
....@@ -2790,25 +3180,28 @@
27903180 LA.matIdentity(fromParent);
27913181 // LA.matIdentity(hip.toParent);
27923182 // LA.matIdentity(hip.fromParent);
2793
- if (rot.toParent == null)
2794
- {
2795
- // june 2014
2796
- rot.toParent = LA.newMatrix();
2797
- rot.fromParent = LA.newMatrix();
2798
- }
2799
- LA.matIdentity(rot.toParent);
2800
- LA.matIdentity(rot.fromParent);
3183
+// if (rot.toParent == null)
3184
+// {
3185
+// // june 2014
3186
+// rot.toParent = LA.newMatrix();
3187
+// rot.fromParent = LA.newMatrix();
3188
+// }
3189
+// LA.matIdentity(rot.toParent);
3190
+// LA.matIdentity(rot.fromParent);
28013191
28023192 // july 2014
2803
- goalx = goalz = 0;
3193
+// goalx = goalz = 0;
28043194 targetx = targetz = 0;
28053195
2806
- SetPositionDelta(true, true, true, false);
3196
+ //SetPositionDelta(true, true, true, false);
3197
+// LoadData();
3198
+// Rewind();
28073199
28083200 baseframe = frame = 0; // T pose. No offset.
28093201
28103202 // aout 2013 endframe = 0; // june 2013
28113203
3204
+ //ResetZero();
28123205 setPose(frame);
28133206 }
28143207
....@@ -2840,7 +3233,7 @@
28403233 baseframe += step;
28413234
28423235 //frame = baseframe;
2843
- frame += step;
3236
+ //frame += step;
28443237
28453238 // if (frame != baseframe)
28463239 // {
....@@ -2854,6 +3247,7 @@
28543247 if (lastframetest == 0)
28553248 lastframetest = bvh.animation.getNumFrames();
28563249
3250
+ // WARNING: RESET DESTROYS EVERYTHING
28573251 if (baseframe >= lastframetest) // july 2013 // - GetFirstFrame())
28583252 {
28593253 System.out.println("MOCAP reset: " + this.GetFileRoot() +
....@@ -2879,7 +3273,10 @@
28793273 {
28803274 bvh = ((Mocap)support.get(mocapsupport++ % support.Size())).bvh;
28813275
2882
- SetPositionDelta(false, true, true, true);
3276
+ // SetPositionDelta(false, true, true, true);
3277
+ LoadData();
3278
+ Rewind();
3279
+ Fade();
28833280 }
28843281 catch (Exception e)
28853282 {
....@@ -2888,13 +3285,17 @@
28883285 }
28893286 }
28903287 }
3288
+
3289
+ frame = GetFirstFrame();
28913290 }
3291
+ else
3292
+ frame += step;
28923293
28933294 //SetPositionDelta(false);
28943295
2895
- if (frame >= bvh.animation.getNumFrames())
2896
- //baseframe =
2897
- frame = GetFirstFrame(); // 0; // offset; // initial point
3296
+// if (frame >= bvh.animation.getNumFrames())
3297
+// //baseframe =
3298
+// frame = GetFirstFrame(); // 0; // offset; // initial point
28983299
28993300 //System.err.println("frame = " + frame);
29003301 if (lastframe != 0)
....@@ -3192,6 +3593,8 @@
31923593 //static
31933594 transient
31943595 double[] currentbones;
3596
+ double[] currenthip;
3597
+
31953598 transient boolean inbetween;
31963599
31973600 void SetPositionDelta(boolean reset, boolean rewind, boolean load, boolean fade)
....@@ -3202,38 +3605,9 @@
32023605 //assert(dim == numframes*6);
32033606
32043607 if (load)
3205
- for (int b=numbones; --b>=0;)
3206
- //int b = 0;
3207
- {
3208
- float[] thedata = bvh.animation.getBoneData(b);
3209
-
3210
- int numframes = bvh.animation.getNumFrames();
3211
-
3212
- int dof = 6; // thedata.length/numframes;
3213
-
3214
- if (b > 0)
3215
- dof = 3;
3216
-
3217
- if (dof != thedata.length/numframes)
3218
- {
3219
- System.err.println("Bone #" + b + ": dof = " + dof + " ---> " + (thedata.length/numframes));
3220
- dof = thedata.length/numframes;
3221
- }
3222
-
3223
- //for (int f=numframes; --f>=offset;)
3224
- int firstframe = GetFirstFrame();
3225
- for (int f=0; f<numframes-firstframe; f++)
3226
- {
3227
- int f3 = f*dof;
3228
-
3229
- //for (int i=3/*dof*/; --i>=0;)
3230
- for (int i=dof; --i>=0;)
3231
- {
3232
- //thedata[f3 + i] += thedata[i] - thedata[offset*dof + i];
3233
- thedata[f3 + i] = thedata[f3 + firstframe*dof + i];
3234
- }
3235
- }
3236
- }
3608
+ {
3609
+ LoadData();
3610
+ }
32373611
32383612 // assert(thedata[0] == 0);
32393613 // assert(thedata[1] == 0);
....@@ -3243,11 +3617,11 @@
32433617 // assert(thedata[7] == 0);
32443618 // assert(thedata[8] == 0);
32453619
3246
- Object3D obj = get(0);
3620
+ Object3D hip = get(0);
32473621
32483622 // assert(obj.name.equals("hip"));
32493623
3250
- Object3D rot = obj.get(0);
3624
+ Object3D rot = hip.get(0);
32513625
32523626 // if (toParent == null)
32533627 // {
....@@ -3259,7 +3633,7 @@
32593633 // // assert(obj.name == null); // .equals("hip#"));
32603634
32613635 Invariants();
3262
- obj.Invariants();
3636
+ hip.Invariants();
32633637 rot.Invariants();
32643638
32653639 if (origin == null)
....@@ -3280,16 +3654,16 @@
32803654 fromParent = LA.newMatrix();
32813655 }
32823656
3283
- if (obj.toParent == null) // june 2014
3657
+ if (hip.toParent == null) // june 2014
32843658 {
3285
- obj.toParent = LA.newMatrix();
3286
- obj.fromParent = LA.newMatrix();
3659
+ hip.toParent = LA.newMatrix();
3660
+ hip.fromParent = LA.newMatrix();
32873661 }
32883662
3289
- LA.matConcat(toParent, obj.toParent, origin0.toParent); // AB
3663
+ LA.matConcat(toParent, hip.toParent, origin0.toParent); // AB
32903664 Object3D gp = this.parent;
32913665 this.parent = null;
3292
- obj.GlobalTransformInv();
3666
+ hip.GlobalTransformInv();
32933667 this.parent = gp;
32943668
32953669 if (rot.toParent == null)
....@@ -3312,41 +3686,41 @@
33123686 LA.matInvert(origin.toParent, origin.fromParent);
33133687
33143688 Invariants();
3315
- obj.Invariants();
3689
+ hip.Invariants();
33163690 rot.Invariants();
33173691 origin.Invariants();
33183692 origin0.Invariants();
33193693
3320
- firsttimeafterload = true;
3694
+ firsttimeafterload = false; // true;
33213695
33223696 if (rewind)
33233697 Rewind();
33243698
3325
- setPose(obj, frame, bvh.animation.getBoneData(obj._index), fade);
3699
+ setPose(hip, frame, bvh.animation.getBoneData(hip._index)); //, fade);
33263700
3327
- if (true)
3328
- return;
3701
+ if (true)
3702
+ return;
33293703
33303704 double pos[] = new double[6];
33313705
33323706 if (!reset)
33333707 {
3334
- assert(obj.tx == obj.toParent[3][0]);
3335
- assert(obj.ty == obj.toParent[3][1]);
3336
- assert(obj.tz == obj.toParent[3][2]);
3708
+ assert(hip.tx == hip.toParent[3][0]);
3709
+ assert(hip.ty == hip.toParent[3][1]);
3710
+ assert(hip.tz == hip.toParent[3][2]);
33373711
3338
- pos[0] = obj.tx; // obj.toParent[3][0];
3339
- pos[1] = obj.ty; // obj.toParent[3][1];
3340
- pos[2] = obj.tz; // obj.toParent[3][2];
3341
- pos[3] = obj.rz;
3342
- pos[4] = obj.ry;
3343
- pos[5] = obj.rx;
3712
+ pos[0] = hip.tx; // obj.toParent[3][0];
3713
+ pos[1] = hip.ty; // obj.toParent[3][1];
3714
+ pos[2] = hip.tz; // obj.toParent[3][2];
3715
+ pos[3] = hip.rz;
3716
+ pos[4] = hip.ry;
3717
+ pos[5] = hip.rx;
33443718 }
33453719
33463720 cVector temp = new cVector();
3347
- temp.x = obj.globalTransform[3][0];
3348
- temp.y = obj.globalTransform[3][1];
3349
- temp.z = obj.globalTransform[3][2];
3721
+ temp.x = hip.globalTransform[3][0];
3722
+ temp.y = hip.globalTransform[3][1];
3723
+ temp.z = hip.globalTransform[3][2];
33503724 // LA.xformPos(temp, origin0.toParent, temp);
33513725 // System.err.println("POS0 = " + temp.x + ", " + temp.y + ", " + temp.z + ";");
33523726
....@@ -3430,7 +3804,7 @@
34303804 }
34313805
34323806 // Rewind();
3433
- setPose(obj, frame, bvh.animation.getBoneData(obj._index), true);
3807
+ setPose(hip, frame, bvh.animation.getBoneData(hip._index)); // , true);
34343808 }
34353809
34363810 void Rewind()