Chapter 11: Creating a First-Person Camera

Quiz Answers

  1. When performing a yaw rotation with a camera, what camera vector(s) rotate(s)? What axis would you rotate on?

    • In a yaw, the only vector that changes is the camera direction. You rotate the direction vector around the camera's up vector.

  2. When performing a roll rotation with a camera, what camera vector(s) rotate(s)? What axis would you rotate on?

    • In a roll, the only vector that changes is the camera's up vector. You rotate the up vector around the camera's direction vector.

  3. When performing a pitch rotation with a camera, what camera vector(s) rotate(s)? What axis would you rotate on?

    • In a pitch, the direction vector always changes and, depending on whether you're creating a land-based camera or a flight-simulator camera, you may also rotate the up vector. You rotate both of these vectors around the cross product of the camera's up and direction vectors.

  4. How many licks does it take to get to the Tootsie Roll center of a Tootsie Pop?

    • The world may never know.

Exercise Answer

  1. Remember that to move a 3D camera forward, you use the following code:

        cameraPosition += cameraDirection * speed;

    There is a small problem with this method, however, when it's applied to land-based cameras. Essentially, to eliminate the ability to "fly" when looking up, you remove the Y component of the cameraDirection vector prior to moving the camera with this line of code. This causes your camera to stay at the same Y value, which keeps the camera on the ground.

Get Learning XNA 3.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.