O'Reilly logo

Learning XNA 3.0 by Aaron Reed

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 11. Creating a First-Person Camera

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.

Components of a Moving 3D 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 Chapter 9 and Chapter 10 we discussed setting up a 3D camera and the basic components that make up a camera in XNA 3D. You created a camera GameComponent, which you added to your solutions in previous chapters to enable you to see the triangles and spaceship models you've drawn.

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required