Sign in to follow this  

First Person View

This topic is 2816 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 AliG

Share this post


Link to post
Share on other sites

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