Sign in to follow this  

Getting Exact Eye Position

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

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


Link to post
Share on other sites

This topic is 3781 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.

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