How do I convert matrices intended for OpenGL to be compatible for DirectX?

Posted by gardian06 on Game Development See other posts from Game Development or by gardian06
Published on 2012-03-30T20:29:31Z Indexed on 2012/03/30 23:43 UTC
Read the original article Hit count: 218

Filed under:
|
|

I have finished working through the book "Game Physics Engine Development 2nd Ed" by Millington, and have got it working, but I want to adapt it to work with DirectX.

I understand that D3D9+ has the option to use either left handed, or right handed convention, but I am unsure about how to return my matrices to be usable by D3D. The source code gives returning OpenGL column major matrices (the transpose of the working transform matrix shown below), but DirectX is row major.

For those unfamiliar for the organization of the matrices used in the book:

[r11 r12 r13 t1]
[r21 r22 r23 t2]
[r31 r32 r33 t3]
[ 0   0   0   1]

r## meaning the value of that element in the rotation matrix, and t# meaning the translation value.

So the question in short is: How do I convert the matrix above to be easily usable by D3D? All of the documentation that I have found simply states that D3D is row major, but not where to put what elements so that it is usable by D3D in terms of rotation, and translation elements.

© Game Development or respective owner

Related posts about physics

Related posts about graphics