dev in the making

game development, maya and code by brainzizi

Posts Tagged ‘camera

zCamera keyframes and interpolation

leave a comment »

In my camera keyframe following project, I’m using this structure to record keyframes:

TimeSpan Key;
Vector3 Position;
Quaternion Rotation;
float FocalDistance;
zInterpolationType PositionInterpolation;
zInterpolationType FocalDistanceInterpolation;

I’m saving these in 2 lists, one containing the timespan, and the otherone containing zCameraKey (which contains other data from the previous code).

When interpolating between those keyframes you have to be sure it’s first of all smooth. This is a bit harder to achieve, considering you must interpolate 3 things: position (vector3), rotation (quaternion) and focal distance (float). The results are done smoothest with the following: Position interpolation is done using Catmull-Rom XNA built in function. Rotation is interpolated using Slerp – also XNA built in, and focal distance also Catmull-Rom. But the smoothness can be still broken with keyframes with variable distance / time ratio. Why? Because of the speed of change. This can be dealt with, but I should change my entire keyframe following system to achieve that, so I’m giving that up. The designer or whoever is setting up animation cameras should take care of that.

As the saying goes: That’s not a bug. That’s a feature.

Yeah… Because you now control the speed of change. Not some silly algorithm. If you want a smooth camera that doesn’t care about the spacing of the keyframes, use Graphic Runner’s Camera animation @ http://graphicsrunner.blogspot.com/2008/05/camera-animation-part-ii.html.

Also I frapsed some keyframe following action in low res on youtube, check it out: http://www.youtube.com/watch?v=seUiYPo_V1k

Also a couple of the latest screens from zCamera:

Written by brainzizizi

08.09.2009 at 21:00

Posted in xna

Tagged with , , , ,

zCamera

leave a comment »

I’m having a blast playing with camera code in XNA. This is the third time I’m writing my own camera, and after I experimented a bit with various camera implementations including Quaternion rotation, Matrix rotation, frame-by-frame rotation, I can now say that I get the basic principles of every camera. And my goal is to make a light camera framework, with a couple of build in cameras and code for easier writing your own camera. Last night was really productive, as I wrote some messy debug code using the vector renderer component from Ziggyware which I’ve tweaked a bit to draw bounding frustrums and alike.

I’ll release the source when I write some more camera types, but first a couple of screen shots:

The package will consist of two projects: zCamera and zCameraPlayground which uses an early version of zGui, my gui framework for debugging purposes.

PS.
The model I used is the model from XNA’s Normal Map sample. If you see a problem in that, please leave a comment.

Written by brainzizizi

08.08.2009 at 12:22

Posted in xna

Tagged with , , , , , ,