Need help with camera view keeping charactor object in view

Started by
4 comments, last by sha1962 12 years ago
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.
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.
Thank you for the quick response, have you any suggestions of books to read up on Ray test
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.
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.
forgot to mention i program in delphi and not much info out there.

This topic is closed to new replies.

Advertisement