Sign in to follow this  
jeffason

Convert rotations from right hand to left hand?

Recommended Posts

Hi,

I had the same problem with a Maya exporter -> DirectX (Maya = right handed, DirectX = left handed.

For the rotation, I found the following : If you have your rotations around each axis, and applied in the order : X, Y then Z, in a right handed system, then in a left handed system, it will be : X, -Y, -Z.

I did found that in a totally empiric way, but I've been using my exporter since half a year now, and I've never had any problem.


Share this post


Link to post
Share on other sites
Yeh thats what we're doing. Using Maya for our level editor in a DirectX based game. I tried what you said and it doesn't seem to work, can you show me exactly how you grabbed the rotation values from maya? Also, how were you constructing your projection/view matrices in DX? RH or LH?

Share this post


Link to post
Share on other sites
Can you just use a right hand coordinate system instead (rather than converting everything)? We had the same Maya problem, and switching our game to the LH system was pretty painless; 2 steps really (if I remember correctly):

1) Switch the D3DX functions that end in RH to LH
2) Switch the renderstate for culling to the reverse of what you have

I think that's pretty much all I did and never had a problem afterwards. The only downside is that mesh viewer uses a LH system, so it lessens it's value as a tool slightly.

NOTE: This assumes you use the D3DX functions for creating your transform matricies.

Matt Hughson

Share this post


Link to post
Share on other sites
Ok, here's the function which extract a transformation matrix from a dagPath, and convert it to left handed :


MFnTransform transform(dagPath);
float mat[4][4];
MEulerRotation eulerRotation;
double scale[3];
MVector translation;

// extract the transformations from the transform
transform.getRotation(eulerRotation);
transform.getScale(scale);
translation = transform.translation(MSpace::kWorld);

// convert it to left handed
translation.x = -translation.x;
eulerRotation.y = -eulerRotation.y;
eulerRotation.z = -eulerRotation.z;

// rebuild a transformtion matrix from the modified transformations
MTransformationMatrix transformationMatrix;
transformationMatrix = transformationMatrix.identity;
transformationMatrix.rotateBy(eulerRotation, MSpace::kWorld);
transformationMatrix.setScale(scale, MSpace::kObject);
transformationMatrix.setTranslation(translation, MSpace::kWorld);

// extract the new matrix
MMatrix mayaMatrix = transformationMatrix.asMatrix();
mayaMatrix.get(mat);

// store it
matrix._11 = mat[0][0]; matrix._12 = mat[0][1]; matrix._13 = mat[0][2]; matrix._14 = mat[0][3];
matrix._21 = mat[1][0]; matrix._22 = mat[1][1]; matrix._23 = mat[1][2]; matrix._24 = mat[1][3];
matrix._31 = mat[2][0]; matrix._32 = mat[2][1]; matrix._33 = mat[2][2]; matrix._34 = mat[2][3];
matrix._41 = mat[3][0]; matrix._42 = mat[3][1]; matrix._43 = mat[3][2]; matrix._44 = mat[3][3];


Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this