CHAPTER 2 ■ SETTING UP DIFFERENT CAMERA MODES IN YOUR 3D WORLD
66
As the height is retrieved from a neighboring vertex, this code will cause your cam-
era to hop each time you cross a triangle, because the GetClippedHeightAt method will
return a different value. To make sure the transitions are smooth, you may want to use the
GetExactHeightAt method of the Terrainobject, as explained in recipe 5-9. This method will
give the height of the point exactly below the camera for any point on your terrain:
float terrainHeight = terrain.GetExactHeightAt(fpsCam.Position.X,
➥
-fpsCam.Position.Z);
You will appreciate this enhancement whenever your camera or Model is moving slowly
over the terrain.
Camera-Wall Collision
A wall in general consists of only ...