• Advertisement
Sign in to follow this  

camera / model matrix errors

This topic is 4337 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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)?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement