Camera Component Update
April 13, 2008
I’ve updated my XNA camera component quite a bit.
Initially, moves were handled by passing in a new position vector, a new lookat vector, and the time required for the camera to get there. This was pretty horrible because it required a lot of calculations for very little payoff. The biggest problem, though, was that certain moves were handled incorrectly. For example, if I simply wanted the camera to turn around and look the other direction, the math wouldn’t necessarily turn in the direction I wanted. So a simple 10 degree left turn might be processed as a 350 right turn. Horrible.
What I have now is a much simpler system wherein moves are passed in as relative position translations, and relative xyz rotations. Not only does this allow full control over the direction the camera turns, it also allows for a few other things, such as really simple absolute moves — there is only the intermediate step of subtracting the ultimate translation and rotation from the current translation and rotation in order to turn it into a relative move. This also allows for zero error pause moves. Just pass in two zero vectors.
Most importantly, though, the math is guaranteed to be correct, which means that the view and up vectors are rotated using the same matrix. The result is an end to weird projection errors after a couple moves.
The video below demonstrates a couple moves:






Comments
Got something to say?