camera / model matrix errors

Started by
1 comment, last by hooded_paladin 17 years, 10 months ago
I'm just confused about all this... I have these matrix transforms almost right but they're not quite right. The camera has position, "forward," "up," and "right" vectors. So does the object. To render the object I do gl.glLoadMatrixd(cameramatrix,0); gl.glMultMatrixd(object1.getObjectMatrix(),0); and then draw the points. The camera matrix is: -side.x,up.x,-forward.x,0 -side.y,up.y,-forward.y,0 -side.z,up.z,-forward.z,0 position(dot)side,position(dot)up,position(dot)forward,1 The object matrix is: side.x,side.y,side.z,0 up.x,up.y,up.z,0 forward.x,forward.y,forward.z,0 position.x,position.y,position.z,0 I think I have it mostly correct but things are weird... I think pitching up pitches the camera down among other things. Can anyone help me find the errors, or point me to a resource to help me learn about this (I'm having trouble finding information on this specific method of orientations)?
______________________________Pretty guy for a white fly.
Advertisement
Couple quick comments. Although you may be indexing them correctly in the code, you're writing your matrices in row-vector format, and OpenGL uses column vectors. Also, I think the middle translation element of your camera matrix needs to be negated. Can't comment on the rotation direction, since we don't know how exactly you're computing your side, up and forward vectors.
Oh, great, thanks. I think that negation fixed it.

If anyone cares those matrices are turned into an array in this order:
0 1 2 3
4 5 6 7
8 9 10 11
12 13 14 15

and that converts it right.

Thanks jyk!
______________________________Pretty guy for a white fly.

This topic is closed to new replies.

Advertisement