Rotation matrix

I was wondering if anyone could shed some light on my problem. I’m importing data from an old game. I have all the geometry import code done and I’m now on the actual object definition file. This is basically a list which references meshes and give their positions on the object, and links them all in a hierarchy.

I’ve successfully implemented these in my 3D Studio Max import plugin. It imports all the meshes, their translation matrix and then applies it. However I’m having a lot less luck in OpenGL.

A few examples:

[ 1.0 ][ 0.0 ][ 0.0 ]
[ 0.0 ][ 1.0 ][ 0.0 ]
[ 0.0 ][ 0.0 ][ 1.0 ]
[ 5.0 ][ 0.2 ][ 0.0 ]

I can handle these fine as theyre simple translations, 5 across, 0.2 up. I’ve just been using glTranslatef to move objects around.

The problem I’m having is that sometimes I’ll get a translation matrix like this:

[ 0.6 ][-0.01][-0.79]
[ 0.09][ 0.9 ][ 0.01]
[ 0.79][ 0.0 ][ 0.6 ]
[ 0.0 ][ 5.0 ][ 0.0 ]

where the object is obviously not aligned to the initial axis, and I’m not sure exactly what to do with it. I’ve looked at simply multiplying it into the modelview matrix like I did with the 3Dsmax plugin but OGL translations matrices seem to be 4x4, and when I try to convert mine over to 4x4, it just messes up. I’ve also tried just settings the modelview matrix to the translation matrix as best I can but obviously the camera translations are erased when I do this.

Anyone got any suggestions to how I can go about this?

You can probably just add another column onto each matrix containing 0,0,0,1.

[ 0.6 ][-0.01][-0.79]
[ 0.09][ 0.9 ][ 0.01]
[ 0.79][ 0.0 ][ 0.6 ]
[ 0.0 ][ 5.0 ][ 0.0 ]

would become

[ 0.6 ][-0.01][-0.79][ 0.0 ]
[ 0.09][ 0.9 ][ 0.01][ 0.0 ]
[ 0.79][ 0.0 ][ 0.6 ][ 0.0 ]
[ 0.0 ][ 5.0 ][ 0.0 ][ 1.0 ]