Blender Coordinate System to OpenGL

Some simple transformations may require when we import a 3d model from a modeling package which uses different coordinate system than the 3D engine we use.   Though both Blender and OpenGL use right handed coordinate system,  Blender is designed to have its z axis point upwards.  So if we import a 3d model which is created in Blender with its height along Z axis, the model seem to aligned with the view direction if we try to draw it in OpenGL with the default model, projection transformations.  We need to apply some rotations, translations as well as some vertex reordering to make the geometry visually appear similar to where we have created it.

I hope Blender has its coordinate system pretty hard coded into this.  And I found this question in a few game development forums asking for a solution.

Coordinate System

Differences in Axis orientations in both Blender and OpenGL.



I find there are two solutions to overcome this.

Method 1

Multiply the transformation matrix of the scenegraph root node with a rotation matrix of -90 degrees around x axis.

Method 2

Alter the transformation matrices in the scene nodes of the scene graph also alter all the mesh vertices and normals.

That is, for every  vertex (x, y, z) in a model created within the Blender modify the coordinate to (x, z, -y)

(x, y,z) => (x, z, -y)

Since all the mesh vertices has been altered, we need to alter the transformation matrices also.

For every transformation matrix in the scene graph,
1. Swap 2nd and 3rd columns
2. Swap 2nd and 3rd rows
3. Negate the 3rd column
4. Negate the 3rd row

Matrix Transform


It works fine for me.  Comments and feedbacks are always welcome.

Comment ( 1 )

  1. / ReplyScippie
    I believe m22 should not be negated (as I believe it is negated twice). If you negate them, your vertices/normals will deform.

Leave a reply

Your email address will not be published.

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>