Skip to Main Content
Learning XNA 3.0
book

Learning XNA 3.0

by Aaron Reed
November 2008
Beginner content levelBeginner
510 pages
16h 24m
English
O'Reilly Media, Inc.
Content preview from Learning XNA 3.0

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.

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning XNA 4.0

Learning XNA 4.0

Aaron Reed
Beginning C# 7 Programming with Visual Studio 2017

Beginning C# 7 Programming with Visual Studio 2017

Benjamin Perkins, Jacob Vibe Hammer, Jon D. Reid

Publisher Resources

ISBN: 9780596154905Supplemental ContentErrata Page