So I can understand things better, I’m trying to get away from calling the gl transformation functions (glTranslatef / glRotatef etc.) instead I’m creating my own matrices and using glMultMatrixf().
The matrix I’ve created for x/y/z rotation seems to work flawlessly, but my translation matrix appears to collapse all the vertices of my meshes into a single axis.
Am I off base in thinking that passing a matrix:
{ 1.0f,0.0f,0.0f,x
0.0f,1.0f,0.0f,y,
0.0f,0.0f,1.0f,z,
0.0f,0.0f,0.0f,1.0f };
to glMultMatrixf is the same as doing glTranslatef(x,y,z)? (I’m column major. Just to make sure I wasn’t all backwards I transposed the above matrix and it still didn’t work. Just seemed to flatten everything to a different axis.)
Am I missing a normalize step somewhere? When IS it a good idea to normalize your matrices.
Thanks ahead of time for dropping some knowledge on me folks!
These are my rotation Matrices:
XAxis
{ 1.0f, 0.0f, 0.0f, 0.0f,
0.0f, (float) Math.cos(x), (float) -Math.sin(x), 0.0f,
0.0f, (float) Math.sin(x), (float) Math.cos(x), 0.0f,
0.0f, 0.0f, 0.0f, 1.0f };
YAxis
{ (float) Math.cos(y),0.0f,(float) Math.sin(y),0.0f,
0.0f,1.0f,0.0f,0.0f,
(float) -Math.sin(y),0.0f,(float) Math.cos(y),0.0f,
0.0f,0.0f,0.0f,1.0f };
ZAxis
{ (float) Math.cos(z),(float) -Math.sin(z),0,0,
(float) Math.sin(z),(float) Math.cos(z),0,0,
0.0f,0.0f,1.0f,0.0f,
0.0f,0.0f,0.0f,1.0f };
That looks transposed to me. The element order should be:
But you’ve got x in element 3, it should be element 12 (same for y and z).
===Edit ===
sorry just noticed you already said you transposed it. But x should definitely be in element 12, just to confirm it for you. I don’t think you’d have to do anything extra to the matrix to get it to work.