One of the most important things in a 3D game is the camera. Choosing the best type of camera and implementing it correctly can make or break a game. It matters as much as the storyline, audio, or graphics quality. Although the camera implementation is of paramount importance, in many ways it is a matter of personal preference—a camera that works well for some gamers may not be preferred by others. Many games, therefore, allow players to switch in and out of different camera angles, allowing them to choose the camera that best fits their style of play.
In this chapter, we’ll implement a first-person camera and discuss issues related to moving that camera in 3D space (as in a flight simulator) versus moving a land-based camera.
In this chapter, you’ll be starting with the code you finished in Chapter 10. Open that project for use throughout the rest of this chapter.
In Chapters 9 and 10, we discussed setting up a 3D camera
and the basic components that make up a camera in XNA 3D. You created a
GameComponent, which you added
to your solutions in previous chapters to enable you to see the
triangles and spaceship models you drew.
As a quick review, the camera is made up of two different matrices: the projection matrix and the view matrix. The projection matrix defines the camera’s viewing frustum, or field of view. Remember that the field of view defines an area in front of the camera that is visible to the ...