Normand Briere
2018-07-01 89c1ad67bc65d24ceadfa9e95f8c5515283f1e97
Reverse matrix order.
4 files modified
72 ■■■■■ changed files
Camera.java 8 ●●●●● patch | view | raw | blame | history
LA.java 33 ●●●●● patch | view | raw | blame | history
Mocap.java 27 ●●●● patch | view | raw | blame | history
ObjEditor.java 4 ●●●● patch | view | raw | blame | history
Camera.java
....@@ -392,13 +392,15 @@
392392 if (CameraPane.ROTATECAMERA)
393393 {
394394 double[][] rotate = { { 0,1,0,0 }, { -1,0,0,0}, { 0,0,1,0}, { 0,0,0,1 } };
395
- double[][] rotate_1 = { { 0,-1,0,0 }, { 1,0,0,0}, { 0,0,1,0}, { 0,0,0,1 } };
395
+ //double[][] rotate_1 = { { 0,-1,0,0 }, { 1,0,0,0}, { 0,0,1,0}, { 0,0,0,1 } };
396396
397
- LA.matConcat(rotate, fromScreen, fromScreen);
398
- LA.matConcat(toScreen, rotate_1, toScreen);
397
+ LA.matConcat(fromScreen, rotate, fromScreen);
398
+ //LA.matConcat(toScreen, rotate_1, toScreen);
399399 }
400400 //if (this == CameraPane.lightCamera)
401401 //CameraPane.lighttouched = true;
402
+
403
+ LA.matInvert(fromScreen, toScreen);
402404 }
403405
404406 // void Draw(CameraPane display, Object3D /*Composite*/ root, boolean selected)
LA.java
....@@ -306,6 +306,14 @@
306306
307307 }
308308
309
+ GrafreeD.Assert(Math.abs(src[0][3]) <= 1E-15);
310
+ GrafreeD.Assert(Math.abs(src[1][3]) <= 1E-15);
311
+ GrafreeD.Assert(Math.abs(src[2][3]) <= 1E-15);
312
+ GrafreeD.Assert(Math.abs(src[3][3] - 1) <= 1E-15);
313
+ GrafreeD.Assert(Math.abs(dst[0][3]) <= 1E-15);
314
+ GrafreeD.Assert(Math.abs(dst[1][3]) <= 1E-15);
315
+ GrafreeD.Assert(Math.abs(dst[2][3]) <= 1E-15);
316
+ GrafreeD.Assert(Math.abs(dst[3][3] - 1) <= 1E-15);
309317 }
310318
311319 static double toRadians(double degrees)
....@@ -321,14 +329,14 @@
321329
322330 for (int j = 0; j < 4; j++)
323331 {
324
- double[] leftj = left[j];
332
+ double[] rightj = right[j];
325333 double[] concat = concatTemp[j];
326334 for (int i = 0; i < 4; i++)
327335 {
328336 concat[i] = 0;
329337 for (int k = 0; k < 4; k++)
330338 {
331
- concat[i] += leftj[k] * right[k][i];
339
+ concat[i] += left[k][i] * rightj[k];
332340 }
333341 }
334342 }
....@@ -345,7 +353,7 @@
345353 //xlateTemp[0][3] = dx;
346354 //xlateTemp[1][3] = dy;
347355 //xlateTemp[2][3] = dz;
348
- matConcat(mat, xlateTemp, mat);
356
+ matConcat(xlateTemp, mat, mat);
349357 }
350358
351359 static void matHomogene(double mat[][], double dx, double dy, double dz)
....@@ -357,7 +365,7 @@
357365 //xlateTemp[0][3] = dx;
358366 //xlateTemp[1][3] = dy;
359367 //xlateTemp[2][3] = dz;
360
- matConcat(mat, xlateTemp, mat);
368
+ matConcat(xlateTemp, mat, mat);
361369 }
362370
363371 static void matTranslateInv(double mat[][], double dx, double dy, double dz)
....@@ -369,7 +377,7 @@
369377 //xlateTemp[0][3] = dx;
370378 //xlateTemp[1][3] = dy;
371379 //xlateTemp[2][3] = dz;
372
- matConcat(xlateTemp, mat, mat);
380
+ matConcat(mat, xlateTemp, mat);
373381 }
374382
375383 static void matScale(double mat[][], double sx, double sy, double sz)
....@@ -378,7 +386,8 @@
378386 xlateTemp[0][0] = sx;
379387 xlateTemp[1][1] = sy;
380388 xlateTemp[2][2] = sz;
381
- matConcat(mat, xlateTemp, mat);
389
+ matConcat(xlateTemp, mat, mat);
390
+ //matConcat(mat, xlateTemp, mat);
382391 }
383392
384393 static void matXRotate(double mat[][], double radians)
....@@ -387,9 +396,9 @@
387396 rotTemp[1][1] = rotTemp[2][2] = (double) Math.cos(radians);
388397 rotTemp[2][1] = -(rotTemp[1][2] = (double) Math.sin(radians));
389398 // if (CameraPane.LOCALTRANSFORM)
390
- // matConcat(rotTemp, mat, mat);
399
+ matConcat(rotTemp, mat, mat);
391400 // else
392
- matConcat(mat, rotTemp, mat);
401
+ // matConcat(mat, rotTemp, mat);
393402 }
394403
395404 static void matYRotate(double mat[][], double radians)
....@@ -398,9 +407,9 @@
398407 rotTemp[0][0] = rotTemp[2][2] = (double) Math.cos(-radians);
399408 rotTemp[2][0] = -(rotTemp[0][2] = (double) Math.sin(-radians));
400409 // if (CameraPane.LOCALTRANSFORM)
401
- // matConcat(rotTemp, mat, mat);
410
+ matConcat(rotTemp, mat, mat);
402411 // else
403
- matConcat(mat, rotTemp, mat);
412
+ // matConcat(mat, rotTemp, mat);
404413 }
405414
406415 static void matZRotate(double mat[][], double radians)
....@@ -409,9 +418,9 @@
409418 rotTemp[0][0] = rotTemp[1][1] = (double) Math.cos(radians);
410419 rotTemp[1][0] = -(rotTemp[0][1] = (double) Math.sin(radians));
411420 // if (CameraPane.LOCALTRANSFORM)
412
- // matConcat(rotTemp, mat, mat);
421
+ matConcat(rotTemp, mat, mat);
413422 // else
414
- matConcat(mat, rotTemp, mat);
423
+ // matConcat(mat, rotTemp, mat);
415424 }
416425
417426 // Project A onto B
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];
....@@ -3020,7 +3026,8 @@
30203026 }
30213027 }
30223028
3023
- static int offset = 1; // 5; // 10; // 5; // 100; // skip initial "T"
3029
+ // skip initial "T"
3030
+ static int offset = 1; // 5; // 10; // 5; // 100;
30243031
30253032 void ReadBVH()
30263033 {
....@@ -3132,7 +3139,7 @@
31323139 baseframe += step;
31333140
31343141 //frame = baseframe;
3135
- frame += step;
3142
+ //frame += step;
31363143
31373144 // if (frame != baseframe)
31383145 // {
....@@ -3184,13 +3191,17 @@
31843191 }
31853192 }
31863193 }
3194
+
3195
+ frame = GetFirstFrame();
31873196 }
3197
+ else
3198
+ frame += step;
31883199
31893200 //SetPositionDelta(false);
31903201
3191
- if (frame >= bvh.animation.getNumFrames())
3192
- //baseframe =
3193
- frame = GetFirstFrame(); // 0; // offset; // initial point
3202
+// if (frame >= bvh.animation.getNumFrames())
3203
+// //baseframe =
3204
+// frame = GetFirstFrame(); // 0; // offset; // initial point
31943205
31953206 //System.err.println("frame = " + frame);
31963207 if (lastframe != 0)
ObjEditor.java
....@@ -2194,6 +2194,8 @@
21942194 {
21952195 Mocap sel = (Mocap) copy.selection.get(0);
21962196
2197
+ sel.SetCurrentBones(sel.frame);
2198
+
21972199 sel.fullname = fullname;
21982200
21992201 if (changename)
....@@ -2245,6 +2247,8 @@
22452247 {
22462248 Mocap sel = (Mocap) select;
22472249
2250
+ sel.SetCurrentBones(sel.frame);
2251
+
22482252 File file = new File(fullname);
22492253
22502254 // Mocap mocap = new Mocap("Mocap" + file.getName());