Saturday, June 23, 2012

Basic Animations

I started off constructing my basic engine. This involved setting up of the keyboard, camera handling, creation of various buffers, rendertargets etc. This was like the standard way of creating the engine.

I wanted to learn about how animations are done in graphics. So I started looking at various examples that involved animation a model based on some clip and keyframe animation and I came across the simple format from Microsoft - X Format.


http://paulbourke.net/dataformats/directx/ is a good reference for the .X Format.

Step 1: Load and render the mesh from .X file:
This step will help us see what the mesh will look like in a T-Pose.

Step 2: Load the skeleton from the .X file:
This step will load the skeleton the from the file which will be used to skin the skeleton

Step 3: Perform GPU Skinning and use weights from .X file:
A shader performs this step.

Step 4: Load the animation clips and apply movement data to the skeleton
Once this step is done, then the skeleton will be animated, which in turns animates the model. The principles of Articulated figures is used in this step.

Here is a snapshot of what the model and the skeleton looks like:
 I should give credit to Microsoft for providing this model from their DirectX SDK.

Step 5: Now I use the keyboard input to identify what animation clip to play. For Eg: if i press "Up" it plays the walk animation. If no  key is pressed, it plays the idle animation.

Only issue here is that the skeleton would suddenly start the next animation which results in a "pop" in the movement.

One way to get rid of this pop is to perform a Linear Interpolation (lerp) for some time between both the animations, during the transition. This results in a much smoother change, and looks much better. Below is a video of that demonstration.

This was my first step :). More to come soon.

No comments: