# Changing up vector used by OpenGL

For the life of me I can’t find anywhere in the man pages for OpenGL how to setup OpenGL to use the Z-axis as the up vector instead of the Y-axis. Does anybody know how to do this?

Thanks,

LoCo3D

Just use glRotate(…) to get things the way you want them.

Nate

Or use gluLookAt() to set up your camera to be looking from the x or y axis with z up.

– Zeno

I guess I should explain why I need to do this. I wrote a 3DStudioMAX importer over the weekend, but in 3DStudioMAX, Z is the up vector…So, all the vertex positions and face mappings I have are incorrect if used in a system where Y is up.

Would it just be easier if I converted the vertices myself and leave OpenGL as it is?

Thanks for the ideas,

LoCo3D

My 3dsmax loader applies the transform at load time. The transform is one of:

out.z = in.x; out.y = in.z; out.z = -in.y;

out.z = in.x; out.y = -in.z; out.z = in.y;

These amount to a 90 degree rotate around the x axis, up or down. Try one, if things come out upside down, use the other (It depends on how you modeled in Max – there’s also the “do I see the front or the back” issue when loading models).

Zeno:

I thought about your way at first, but that wouldn’t change the face mappings in my index…would still have inconsistencies between the CCW and CW faces due to incorrect up vector.

jwatte:

I kinda figured I would be better off doing it this way.

Thanks fellas.

I think it should look something like this.

``````| 1  0  0  0 |
``````

I = | 0 0 1* 0 |
| 0 1* 0 0 |
| 0 0 0 1 |

*) I think one of them is suppose to be negative. Just try and see what happens.

This “identity matrix” will map 3DSMAX’s Z-axis to OpenGL’s Y-axis, and the other way around aswell.