Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Transforming a 4x4 matrix from one base to another

  1. Sep 1, 2008 #1
    I'm writing an exporter for 3d studio max and i want to export skeletal animation. 3D studio max uses a coordinate system that has the X axis going from left to right, the Z Axis going from bottom to top and the Y axis going from front to back. Opengl uses a left handed coordinate system, whilst 3d max uses a right handed coordinate system. OpenGL's X axis goes from left to right, Y goes from bottom to top and Z goes from back to front.

    I want to convert a 3d studio max matrix to use it with OpenGL. Matrices hold transformation information. How can i accomplish this?
     
  2. jcsd
  3. Sep 1, 2008 #2

    HallsofIvy

    User Avatar
    Staff Emeritus
    Science Advisor

    Sounds to me like (x, y, z) in 3D studio max goes to (-x, z, y) in OpenGL. The matrix
    [tex]\left[\begin{array}{ccc}-1 & 0 & 0 \\ 0 & 0 & 1\\ 0 & 1 & 0\end{array}\right][/tex]
    will do that.

    That matrix happens to have the nice property that it is its own inverse (because the inverse of changing x to -x is changing x to -x and the inverse of swapping y and z is to swap y and z) so you can also use it to change coord systems the other way.
     
  4. Sep 1, 2008 #3
    I think i don't know where -X is coming from. In the phase where i load the static model i convert every 3d studio max point from (x,y,z) to (x,z,-y) and it works fine. 3D studio max uses 4x4 matrices that contain on the last row a translation component. I tried converting a 3d studio max matrix into an opengl in quite a few ways but i had no luck :confused:. So your matrix indeed converts a point from (x,yz) to (-x,z,y), which is not what i'm doing. What i'm interested though is how to convert a 4x4 row major 3ds matrix into a 4x4 column major ogl matrix.
     
  5. Sep 2, 2008 #4

    HallsofIvy

    User Avatar
    Staff Emeritus
    Science Advisor

    My fault. I misread and thought OpenGL's x-axis went from right to left! The correct matrix is
    [tex]\left[\begin{array}{ccc}1 & 0 & 0 \\ 0 & 0 & 1\\ 0 & 1 & 0\end{array}\right][/tex]
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: Transforming a 4x4 matrix from one base to another
  1. 4x4 Matrix (Replies: 3)

Loading...