Jump to content
  • Advertisement
Sign in to follow this  
xerodsm

Getting Exact Eye Position

This topic is 3996 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
Advertisement
Ha. I should have just fooled around a little bit more. Problem solved. Just set z to a really really high negative value.

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!