# Right Hand to Left Hand Conversion

This topic is 4717 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Greetings! I allways thought a right handed matrix like this: R R R 0 (x) 1 0 0 0 R R R 0 (x) 0 0 1 0 R R R 0 (x) 0 1 0 0 X Y Z 0 (x) 0 0 0 1 A x B matrix multiply Would be come a Left handed matrix. But it is not allways the case and I do not know why? The second matrix basicaly does this: X A B X becomes X B A X X A B X becomes X B A X X A B X becomes X B A X X A B X becomes X B A X That isn't allways a solution. What could i implement from the begging since i know the positions (x,y,z) and the rotations (yaw, pitch, roll) that are general in right handed format to make a left handed matrix? I did it like that: D3DXMatrixRotationYawPitchRoll(&matrix, yaw, pitch, roll); matrix._41 = x; matrix._42 = y; matrix._43 = z; and then multiplied it with the upper matrix. Any suggestions how a right handed matrix like that above could get left handed from the begining?

##### Share on other sites
For convet to Left Hand Conversion, try to multiply right hand matrix with
this one:

LT = | -1   0   0   0|     |  0   1   0   0|     |  0   0  -1   0|     |  0   0   0   1|

LT has inverted the X and the Z axis.

##### Share on other sites
Quote:
 For convet to Left Hand Conversion, try to multiply right hand matrix with this one:*source snippet*
I think that's just a 180-degree y-axis rotation. To change handedness you need an odd number of negations (and/or swaps).

##### Share on other sites
Ok Jyk. That's right too.

However, that's for convert OpenGL matrices to DirectX?
DirectX has translation component at fourth row, while OpenGL has it at fourth column.

Also, transformations on DirectX are quite different from Opengl.

With OpenGL:
Tv = M*v' =  Tv = |  x1   y1   z1   tx|*|vx|     |  x2   y2   z2   ty|*|vy|     |  x3   y3   z3   tz|*|vz|     |  0    0    0    1 |*| 1|

With DirectX:
Tv = M*v' =  Tv = |vx  vy  vz  1|  *  |  x1   x2   x3   0 |                         |  y1   y2   y3   0 |                         |  z1   z2   z3   0 |                         |  tx   ty   tz   1 |

Confusing. Isn't it?

When I was dealing with these transformations, I become sick! I'm going to have a headache right now. Changes coordinates system and manages relative positions and orientations gives me a feeling that I am entering to a strange dimension. Have you ever feel the same thing? =)

Really, I haven't been forced to do this before, but possibly in the future.
I suggest you to take a look to the WildMagic Library, or OGRE 3D. These engines had managed this isues very well.

##### Share on other sites
is the ogl matrix just the transpose of the dx matrix?

##### Share on other sites
Are you doing this for real time renderig or for and off line tool like a plug in?

##### Share on other sites
It is acctualy the same isn't it? Basicaly I am writing a Half-Life(2) .smd converter to DirectX. I have a lot of my own model renderers like unreal, ms3d, half-life1 (opengl) but at least unreal works with that upper matrix i have written above.

If you have just one matrix multiply more it does not make a speed difference if it is baken in file or multiplied afterwards.

I was thinking to swap the rotations from the begining like that:
D3DXMatrixRotationYawPitchRoll(&matrix, yaw, pitch, -roll);
matrix._41 = x;
matrix._42 = y;
matrix._43 = -z;

But it does not quite work for a hierarchy. I have to perform some additional checks. I get a lot of help from the JT DirectX Exporter, that is capable of exporting from Milkshape to .X (it has some bugs but for some models it works). Maybe i will find the match.

• 16
• 11
• 9
• 49
• 12
• ### Forum Statistics

• Total Topics
631392
• Total Posts
2999738
×