GL_MODELVIEW_MATRIX

Started by
2 comments, last by ProfEich 20 years ago
Hi! I''m completly controling a camera with a matrix. Well - Now I have an array with 16 entries and I don''t know how I can get the position of the camera and the current rotation. Could someone help me? thanks :D glLoadIdentity(); glMultMatrixf(cam->Matrix); cam->Position.x = ? cam->Position.y = ? cam->Position.z = ? cam->Rotation.x = ? cam->Rotation.y = ? cam->Rotation.z = ?
Advertisement
if you look far down the first page of this post, you should find a very indepth explaination of how a matrix works.



| - My project website - | - email me - |
well, in your example you just use this for getting the position:

Vector3 getPosition()
{
return Vector3(m[12],m[13],m[14]);
}

I tried this before, too, in my camera.cpp. But if I rotate the camera the position get wired.
no. not quite. I said for a matrix''s position you get element 12,13 and 14. But the modelview is the inverse of the matrix represnting the position of the camera... so these values will not be the position of the camera at all. You will need to invert the matrix to get the position.

This topic is closed to new replies.

Advertisement