All dressed up and no place to go…

So today I made a bit of a funny mistake. I thought that I had to give a co-op presentation today about what I did during my summer work term. So I got all dressed up (well, somewhat dressed up) this morning and walked to school. It was then that I got an email reminding me that my presentation was supposed to be next Tuesday, not today. Silly me.

In programming land, last night I managed to do a bit more work on my Camera GameService. I have been thinking about how to handle full 3D movement, including rolling the camera. This gets a bit tricky. I sort of wanted to avoid using quaternions, as I really don’t know a lot about them (not really a good excuse, I know). So anyway, I thought up the following scheme:

XNA has a function to build the view matrix using a position vector (where the camera is located), a “lookat” point (what the camera is looking at), and an “up” vector, which points upwards. When you start to roll the camera from side to side, the up vector moves around, and no longer always faces directly up. In previous attempts at doing stuff in 3D, I would keep track of the position and lookat points, but always have the “up” vector face directly up. This works, but not when you want to roll.

My solution (at this point) is to keep a lookat vector, a position, and a “right” vector – a point which is always to the “right” of the camera. When you look up and down (pitch) or side to side (yaw), only the lookat vector is altered. When you roll, only the “right” vector is altered (in a similar manner to the lookat vector). Anyway, you take the cross product of the lookat and “right” vector to get the “up” vector. In theory, this should work like a charm.

Little did I know, after talking with Ravuya, that this is basically what a quaternion does. Silly me! Either way, I am stoked to find the time to try this out to see if it really does work the way I think it should in theory.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s