Jump to content
  • Advertisement
Sign in to follow this  
sha1962

OpenGL Need help with camera view keeping charactor object in view

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

Really need some help, have started opengl, I Have created object loader, Gameloop, collision routine.s etc, But I am stumped on how to keep the main charactor object in view, for instance when it goes behind a wall or a part of the terrain that is closer.

Share this post


Link to post
Share on other sites
Advertisement
Do a ray test from the point within the main character object that is the center of the camera's focus (its head, its feet, wherever you point the camera at) to the location of the camera if it is allowed to be at its furthest distance (ie, no occlusion). If an intersection with blocking geometry is tested, snap the camera to the point of intersection nearest to the character; otherwise, the camera may be allowed to translate out to its furthest distance, either instantly or with over-time motion to reduce the disorienting snapping of the camera.

Share this post


Link to post
Share on other sites
Just about any 3D primer or text, or any of several thousand page hits on google for 3D ray intersection or ray hit testing. Many third-party APIs such as Ogre, Urho3D, Irrlicht, etc... will have ray testing capabilities built in. You could check their implementations out if you desire.

The basics of it are that you construct a ray (remember, a ray is a portion of a line segment starting at a point an extending in one direction to infinity) then calculate intersections of that ray with the various quads and triangles of your world geometry. The math is relatively simple, but the actual details of it will depend a great deal on the overall structure of your scene.

Share this post


Link to post
Share on other sites
thanks a gain, i allready do a collision test with world to get height, wikk have to read and adapt, i have been doing a lot of reading, hardest part is getting my head around it , now i realize i have to do another sort of collision test, many thanks just needed a point in the right direction.

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!