Converting a transformation matrix from Right-handed to Left-handed coord system

Started by
21 comments, last by gifaraj 18 years ago
Dmytry, thanks for taking the time to setup a test case. The strange thing is, I set up a similar test case and get different results...

#include <buitre/math/math.hpp>#include <iostream>#include <iomanip>using namespace BuitreEngine::Math;void correct(BeMatrix4& matrix){    matrix(2,0) *= -1.0f;    matrix(2,1) *= -1.0f;    matrix(2,3) *= -1.0f;    matrix(0,2) *= -1.0f;    matrix(1,2) *= -1.0f;    matrix(3,2) *= -1.0f;}void correct(BeVector3& v){    v.z() *= 1.0f;}int main(){    BeMatrix4 a = BeMatrix4::ZRot(4.2f) * BeMatrix4::Translation(BeVector3(3, 1, 5));    BeMatrix4 b = BeMatrix4::XRot(2.2f) * BeMatrix4::YRot(1.0f);    BeMatrix4 scale = BeMatrix4::Scale(BeVector3(1,1,-1));    BeVector3 vertex(2.5f, -304.1f, 589.21f);    BeMatrix4 c = a;    BeMatrix4 d = b;    BeVector3 vertex2 = vertex;    correct(c);    correct(d);    correct(vertex2);    std::cout << "vertex: \n" << vertex << std::endl;    std::cout << "vertex * (a * b): \n" << vertex * (a * b) << std::endl;    std::cout << "vertex2 * (c * d): \n" << vertex2 * (c * d) << std::endl;}


Which outputs:

vertex:       2.5    -304.1    589.21vertex * (a * b):   -335.88   -567.46    97.207vertex2 * (c * d):    247.68    385.29   -471.91


operator*(BeVector3 const&, BeMatrix4 const&) just transforms the vector by the matrix.

Any idea?
Advertisement
typo:
v.z() *= 1.0f;
should be
v.z() *= -1.0f;
:-)
doh ;)
thanks.

Well, that seems to be working fine then, but the rendered image says otherwise.. Hmm...

edit:
would that work for bone offset matrices too?

[Edited by - gifaraj on April 4, 2006 1:41:32 PM]

This topic is closed to new replies.

Advertisement