I’m doing some matrix multiplication and the scaling seems weird.
v[0] = new(-0.5f, +0.5f, -0.5f);
v[1] = new(-0.5f, +0.5f, +0.5f);
v[2] = new(+0.5f, +0.5f, +0.5f);
v[3] = new(+0.5f, +0.5f, -0.5f);
for(int i = 0; i < 4; i++) {
Vector3 n = translation.MultiplyPoint3x4(v[i]);
n += rotation.MultiplyPoint3x4(v[i]);
n += scale.MultiplyPoint3x4(v[i]);
MB.mesh.verts.Write<Vector3>(new(x + n.x, y + n.y, z + n.z));
}
The scaling always seems to triple the value.
Matrix4x4 translation = Matrix4x4.Translate(new(0, 0, 0));
Matrix4x4 rotation = Matrix4x4.Rotate(Quaternion.Euler(0, r, 0));
Matrix4x4 scale = Matrix4x4.Scale(new(-1, -1, -1));
if (MB.transforms.ContainsKey(ID)) {
MB.transforms.TryGetValue(ID, out Dev.Component.Transform tr);
translation = Matrix4x4.Translate(tr.position);
rotation = Matrix4x4.Rotate(Quaternion.Euler(tr.rotation.x, tr.rotation.y, tr.rotation.z));
scale = Matrix4x4.Scale(tr.scale);
}
It only stays the same when I use -1. Is there a specific order we need to do the matrix multiplication in? Or a way to do all 3 at once?