Sign in to follow this  
WoolyUK

Finding current 3d position?

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this