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

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

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628400
• Total Posts
2982450

• 9
• 10
• 9
• 19
• 24