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

Cameras

So, now that you understand coordinate systems, let's talk about cameras. As mentioned previously, drawing a scene in 3D is much like recording a movie with a handheld camera. You have to define where the camera is located, what it's pointing at, and various other properties.

These properties are stored in a Matrix object. Matrices are fairly complex mathematical entities that are well beyond the scope of this chapter and the book in general. Suffice it to say that matrices are at the heart of almost everything you do in 3D graphics. Fortunately, XNA handles all the hairy matrix details behind the scenes, and at this point, you really don't need to concern yourself with how it all unfolds. For now, just understand that a matrix or two can represent a camera.

There are two Matrix objects that make up a camera in XNA: the view and projection matrices. The view matrix holds information that determines where the camera sits in the world, what direction it's pointing in, and what its orientation is. The projection matrix holds information that determines properties of the camera based on the angle of the view, how far the camera can see, and so forth. This matrix represents the transformation from the 3D world to the 2D plane of the screen.

To create a view matrix, you use a static method from the Matrix class called CreateLookAt. This method returns a Matrix object and accepts the parameters listed in Table 9-1.

Table 9-1. Parameters of Matrix.CreateLookAt

Parameter

Type

Description ...

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