Max
Max

Reputation: 271

Different ways to initialize camera view matrix

What are some of the ways you can create the view matrix for a camera in XNA?

So far I've only seen the createLookAt() method and was curious as to what else was possible.

It appears on the MSDN site that creatLookAt() is the only matrix method for constructing a view matrix.

EDIT:

Here's a good tutorial on how the world matrix is composed.

Upvotes: 0

Views: 323

Answers (1)

Steve H
Steve H

Reputation: 5529

A view matrix is nothing more than a typical matrix (representing a world space orientation and position) that happens to be inverted.

If you know how to create a typical world space matrix, simply invert it and it becomes a view matrix.

For instance, in Xna:

Matrix m = Matrix.CreateYawPitchRoll(yawFloat, pitchFloat, rollFloat) * Matrix.CreateTranslation(someVector3);

Matrix myViewMatrix = Matrix.Invert(m);

myViewMatrix will work as expected in your effects.

Upvotes: 2

Related Questions