From 89c1ad67bc65d24ceadfa9e95f8c5515283f1e97 Mon Sep 17 00:00:00 2001
From: Normand Briere <nbriere@noware.ca>
Date: Sun, 01 Jul 2018 15:45:28 -0400
Subject: [PATCH] Reverse matrix order.
---
ObjEditor.java | 4 ++
Camera.java | 8 ++-
LA.java | 33 ++++++++++------
Mocap.java | 27 +++++++++----
4 files changed, 49 insertions(+), 23 deletions(-)
diff --git a/Camera.java b/Camera.java
index 82f2189..8454950 100644
--- a/Camera.java
+++ b/Camera.java
@@ -392,13 +392,15 @@
if (CameraPane.ROTATECAMERA)
{
double[][] rotate = { { 0,1,0,0 }, { -1,0,0,0}, { 0,0,1,0}, { 0,0,0,1 } };
- double[][] rotate_1 = { { 0,-1,0,0 }, { 1,0,0,0}, { 0,0,1,0}, { 0,0,0,1 } };
+ //double[][] rotate_1 = { { 0,-1,0,0 }, { 1,0,0,0}, { 0,0,1,0}, { 0,0,0,1 } };
- LA.matConcat(rotate, fromScreen, fromScreen);
- LA.matConcat(toScreen, rotate_1, toScreen);
+ LA.matConcat(fromScreen, rotate, fromScreen);
+ //LA.matConcat(toScreen, rotate_1, toScreen);
}
//if (this == CameraPane.lightCamera)
//CameraPane.lighttouched = true;
+
+ LA.matInvert(fromScreen, toScreen);
}
// void Draw(CameraPane display, Object3D /*Composite*/ root, boolean selected)
diff --git a/LA.java b/LA.java
index 3669362..20a9211 100644
--- a/LA.java
+++ b/LA.java
@@ -306,6 +306,14 @@
}
+ GrafreeD.Assert(Math.abs(src[0][3]) <= 1E-15);
+ GrafreeD.Assert(Math.abs(src[1][3]) <= 1E-15);
+ GrafreeD.Assert(Math.abs(src[2][3]) <= 1E-15);
+ GrafreeD.Assert(Math.abs(src[3][3] - 1) <= 1E-15);
+ GrafreeD.Assert(Math.abs(dst[0][3]) <= 1E-15);
+ GrafreeD.Assert(Math.abs(dst[1][3]) <= 1E-15);
+ GrafreeD.Assert(Math.abs(dst[2][3]) <= 1E-15);
+ GrafreeD.Assert(Math.abs(dst[3][3] - 1) <= 1E-15);
}
static double toRadians(double degrees)
@@ -321,14 +329,14 @@
for (int j = 0; j < 4; j++)
{
- double[] leftj = left[j];
+ double[] rightj = right[j];
double[] concat = concatTemp[j];
for (int i = 0; i < 4; i++)
{
concat[i] = 0;
for (int k = 0; k < 4; k++)
{
- concat[i] += leftj[k] * right[k][i];
+ concat[i] += left[k][i] * rightj[k];
}
}
}
@@ -345,7 +353,7 @@
//xlateTemp[0][3] = dx;
//xlateTemp[1][3] = dy;
//xlateTemp[2][3] = dz;
- matConcat(mat, xlateTemp, mat);
+ matConcat(xlateTemp, mat, mat);
}
static void matHomogene(double mat[][], double dx, double dy, double dz)
@@ -357,7 +365,7 @@
//xlateTemp[0][3] = dx;
//xlateTemp[1][3] = dy;
//xlateTemp[2][3] = dz;
- matConcat(mat, xlateTemp, mat);
+ matConcat(xlateTemp, mat, mat);
}
static void matTranslateInv(double mat[][], double dx, double dy, double dz)
@@ -369,7 +377,7 @@
//xlateTemp[0][3] = dx;
//xlateTemp[1][3] = dy;
//xlateTemp[2][3] = dz;
- matConcat(xlateTemp, mat, mat);
+ matConcat(mat, xlateTemp, mat);
}
static void matScale(double mat[][], double sx, double sy, double sz)
@@ -378,7 +386,8 @@
xlateTemp[0][0] = sx;
xlateTemp[1][1] = sy;
xlateTemp[2][2] = sz;
- matConcat(mat, xlateTemp, mat);
+ matConcat(xlateTemp, mat, mat);
+ //matConcat(mat, xlateTemp, mat);
}
static void matXRotate(double mat[][], double radians)
@@ -387,9 +396,9 @@
rotTemp[1][1] = rotTemp[2][2] = (double) Math.cos(radians);
rotTemp[2][1] = -(rotTemp[1][2] = (double) Math.sin(radians));
// if (CameraPane.LOCALTRANSFORM)
- // matConcat(rotTemp, mat, mat);
+ matConcat(rotTemp, mat, mat);
// else
- matConcat(mat, rotTemp, mat);
+ // matConcat(mat, rotTemp, mat);
}
static void matYRotate(double mat[][], double radians)
@@ -398,9 +407,9 @@
rotTemp[0][0] = rotTemp[2][2] = (double) Math.cos(-radians);
rotTemp[2][0] = -(rotTemp[0][2] = (double) Math.sin(-radians));
// if (CameraPane.LOCALTRANSFORM)
- // matConcat(rotTemp, mat, mat);
+ matConcat(rotTemp, mat, mat);
// else
- matConcat(mat, rotTemp, mat);
+ // matConcat(mat, rotTemp, mat);
}
static void matZRotate(double mat[][], double radians)
@@ -409,9 +418,9 @@
rotTemp[0][0] = rotTemp[1][1] = (double) Math.cos(radians);
rotTemp[1][0] = -(rotTemp[0][1] = (double) Math.sin(radians));
// if (CameraPane.LOCALTRANSFORM)
- // matConcat(rotTemp, mat, mat);
+ matConcat(rotTemp, mat, mat);
// else
- matConcat(mat, rotTemp, mat);
+ // matConcat(mat, rotTemp, mat);
}
// Project A onto B
diff --git a/Mocap.java b/Mocap.java
index fc96f41..93dd7ac 100644
--- a/Mocap.java
+++ b/Mocap.java
@@ -29,7 +29,7 @@
void Fade()
{
- if (true) // currentbones == null || CameraPane.fullreset)
+ if (currentbones == null || CameraPane.fullreset)
return;
cVector temp = new cVector();
@@ -107,7 +107,7 @@
//data[f3 + i] += pos[i] - data[frame3 + i];
// data[f3 + i] = k*data[f3+i] + (1-k)*
// currentbones[boneframe3 + i-end];
- data[f3 + i] = (float)CurveAngle(data[f3+i], currenthip[i], 1-k);
+// data[f3 + i] = (float)CurveAngle(data[f3+i], currenthip[i], 1-k);
}
// TODO: translation
@@ -225,7 +225,7 @@
// before resetting the mocap data.
void SetGlobalTransform()
{
- SetCurrentBones(frame);
+ //SetCurrentBones(frame);
cVector temp = new cVector();
cVector pos = new cVector();
@@ -235,6 +235,12 @@
double angleYhip = 0;
Object3D hip = get(0);
+
+ if (hip.get(0).toParent == null)
+ {
+ hip.get(0).toParent = LA.newMatrix();
+ hip.get(0).fromParent = LA.newMatrix();
+ }
LA.matConcat(toParent, hip.get(0).toParent, matrix);
poship.x = matrix[3][0];
@@ -3020,7 +3026,8 @@
}
}
- static int offset = 1; // 5; // 10; // 5; // 100; // skip initial "T"
+ // skip initial "T"
+ static int offset = 1; // 5; // 10; // 5; // 100;
void ReadBVH()
{
@@ -3132,7 +3139,7 @@
baseframe += step;
//frame = baseframe;
- frame += step;
+ //frame += step;
// if (frame != baseframe)
// {
@@ -3184,13 +3191,17 @@
}
}
}
+
+ frame = GetFirstFrame();
}
+ else
+ frame += step;
//SetPositionDelta(false);
- if (frame >= bvh.animation.getNumFrames())
- //baseframe =
- frame = GetFirstFrame(); // 0; // offset; // initial point
+// if (frame >= bvh.animation.getNumFrames())
+// //baseframe =
+// frame = GetFirstFrame(); // 0; // offset; // initial point
//System.err.println("frame = " + frame);
if (lastframe != 0)
diff --git a/ObjEditor.java b/ObjEditor.java
index 74fe7f1..c4118f0 100644
--- a/ObjEditor.java
+++ b/ObjEditor.java
@@ -2194,6 +2194,8 @@
{
Mocap sel = (Mocap) copy.selection.get(0);
+ sel.SetCurrentBones(sel.frame);
+
sel.fullname = fullname;
if (changename)
@@ -2245,6 +2247,8 @@
{
Mocap sel = (Mocap) select;
+ sel.SetCurrentBones(sel.frame);
+
File file = new File(fullname);
// Mocap mocap = new Mocap("Mocap" + file.getName());
--
Gitblit v1.6.2