• Advertisement
Sign in to follow this  

Finding current 3d position?

This topic is 4840 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

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!

Share this post


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

Share this post


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

Share this post


Link to post
Share on other sites
It should be possible via matrix algebra (If memory serves me correctly, gl uses collumn major matrices). Just extract the modelview matrix:

| 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

Share this post


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

  • Advertisement