Top

An XNA Camera Component

April 1, 2008

I’m currently working on a camera component for XNA.  Ideally I’d like it to be really complete, but I know that ultimately it’s just going to contain the functionality I need for YotD:BI.  At any rate, here’s a little description of what it will do, and a video of the camera in action.

Immediately, I need my camera to support just a few types of movement:

  • MoveTo: move to a new location and fix attention on a new point over n milliseconds.
  • JumpTo: move to a new location and fix attention on a new point now.
  • QueueMove:  queue up a new location,  lookat point and time frame to be processed after any remaining moves are complete.
  • Third Person: simple 3rd person perspective camera
  • First Person: simple 1st person perpective camera

Modes 4 and 5 are pretty cut and dry, so I decided to start with 1-3.  Creating the view matrix with CreateLookAt requires a position vector, a lookat point vector, and an Up vector.  The toughest part of this is recalculating the Up vector.  One way to do this is to maintain three vectors (forward, up, and right) and calculate all of them after each move.  I shortcutted this, by simply calculating the x,y, and z rotation for the current move, but I may end up having to go back to a system like that.

At any rate, this isn’t a full write up.  Check out the demo video below to see the effect of queuing up 10 moves, some of which simply move the camera, some of which move the look at point, and some of which do both.

Comments

Got something to say?

You must be logged in to post a comment.

Bottom