Jump to content
  • Advertisement
Sign in to follow this  
AliG

First Person View

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

Hi, I am using Open Scene Graph to code some basic gaming features. If I have my avatar's head position (X,Y,Z) and orientation (Roll, Pitch, Yaw), is there a series of commands I can use to set up a camera that is the same as my avatar's first person view? I have tried doing it by using viewer.getCamera()->setViewMatrixAsLookAt(eye, center, up) but I am getting a bizarre behavior. I have set up my camera as follows: viewer.getCamera()->setViewMatrixAsLookAt(osg::Vec3(XCoordinate,YCoordinate,ZCoordinate), osg::Vec3(XCoordinate - 10*cos(osg::DegreesToRadians(Pitch))*sin(osg::DegreesToRadians(Yaw)),YCoordinate + 10*cos(osg::DegreesToRadians(Pitch))*cos(osg::DegreesToRadians(Yaw)),ZCoordinate + 10*sin(osg::DegreesToRadians(Pitch))), osg::Vec3(0.0, 0.0, 1.0)); My XCoordinate, YCoordinate and ZCoordinate values remain constant over the whole code and the values of Roll, Pitch, Yaw change and yet when the Roll, Pitch, Yaw are changed, the position of the camera's eye is being changed. Even though I defined the eye's position as osg::Vec3(XCoordinate,YCoordinate,ZCoordinate). Seems a bit odd for me to understand why this is happening. Does anyone have any suggestions? Thanks

Share this post


Link to post
Share on other sites
Advertisement
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!