Finding current 3d position?
Hi guys :)
Is there a way to find the current point in 3d space? Without needing to do my rotations and translations with my own matrices?
So I can rotate and translate to a point and find out where I am?
Thanks!
Ok I just found I can do:
glGetDoublev (GL_MODELVIEW_MATRIX, mvmatrix);
and extract the position.
But gluLookAt messes the values up - without the command (so no camera!) they're correct, I put gluLookAt back in and they're off - is there a way to solve this problem please?
glGetDoublev (GL_MODELVIEW_MATRIX, mvmatrix);
and extract the position.
But gluLookAt messes the values up - without the command (so no camera!) they're correct, I put gluLookAt back in and they're off - is there a way to solve this problem please?
Quote:
Is there a way to find the current point in 3d space? Without needing to do my rotations and translations with my own matrices?
short answer, no.
and you should be using your own matrices anyway.
The modelview matrix is the inverse of the camera matrix. So the position will be 'messed up'.
It should be possible via matrix algebra (If memory serves me correctly, gl uses collumn major matrices). Just extract the modelview matrix:
the indices 3, 7, 11 should represent the x, y, z coordinate translations repsectively, from the origin. Its a bit of a hack, but it should work.
Cheers,
- llvllatrix
| 0 1 2 3 || 4 5 6 7 || 8 9 10 11 | | 12 13 14 15 |
the indices 3, 7, 11 should represent the x, y, z coordinate translations repsectively, from the origin. Its a bit of a hack, but it should work.
Cheers,
- llvllatrix
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement