# Getting Exact Eye Position

## Recommended Posts

I need to get the exact location of the camera in my scene. Normally I would just use a camera class for all translations and rotations but I'm using a tookit called Diverse for a virtual environment and there are some translations made behind the scenes that I don't know about. Is there a way that I can get the world position of the camera? I have been trying to use the unproject function but the values are off by a small amount compared to a test program I have where I know the exact location of the camera. Here's the function that I got from nehe:

CVector3 GetOGLPos()
{
GLint viewport[4];
GLdouble modelview[16];
GLdouble projection[16];
GLdouble posX, posY, posZ;

glGetDoublev( GL_MODELVIEW_MATRIX, modelview );
glGetDoublev( GL_PROJECTION_MATRIX, projection );
glGetIntegerv( GL_VIEWPORT, viewport );

gluUnProject( 512, 384, 0, modelview, projection, viewport, &posX, &posY, &posZ);

return CVector3(posX, posY, posZ);
}


I thought maybe setting the z value to 0 would let me get the middle of the camera but then I realized that the screen is infront of the convergence point, so what I really need to get is the convergence point. I'm thinking the z should be negative but how do I figure out how much? My FOV is 45 degrees and the screen size is 1024x768. Anyone have any ideas how to get the convergence point?

##### Share on other sites
Ha. I should have just fooled around a little bit more. Problem solved. Just set z to a really really high negative value.

## Create an account

Register a new account

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627664
• Total Posts
2978522

• 10
• 10
• 12
• 22
• 13