I’ve been working on a new project for the recently released Windows Phone 7 SDK; Specifically XNA 4.0. I was experimenting with the updated 3D support in XNA. I downloaded the skinned model sample (link) and was pleasantly surprised how easily it integrated into my project. In just a few minutes I had Dude walking along the screen of the phone emulator.

I then started working on getting models of my own into the XNA framework. The task of getting 3D models, especially animations, out of your preferred 3D modelling package and into XNA is a black art and should only be attempted by the brave and tenacious.

My preferred modelling tool is blender. I finally settled on the Direct X .X exporter. The FBX exporter has all kinds of issues with animations and is not well supported. The Direct X exporter, if used judiciously, will yield acceptable results.

Once I got my model ready and exported I verified its correctness using the Direct X Viewer that comes with the Direct X SDK. Everything looked good. Time to try it out in XNA.

To my horror my animation was choppy! It only moved every second or so and made large choppy movements. I quickly realized that the skinned model code provided in the XNA sample doesn’t interpolate between key frames! The Dude model provided in the sample has every animation frame explicitly written out. That seemed unacceptable to me so I set out to enhance the animation player to interpolate between key frames.

It wasn’t too hard and a couple hours later my animation was nice and smooth. In order to validate my modeling work within the XNA framework easily I modified the WinFormsContentLoader sample to use my updated animation library. Despite the name this viewer will display .X files as well as .FBX files.

FBX Viewer screen shot

I’ve uploaded the modified content loader here. The interpolation logic is in the AnimationClipKeyFrameInterpolator.cs file. The download includes Dude.FBX as well as SwingDing.X which was my initial test model. You can turn interpolation on and off via the options menu. You’ll notice that there is no difference with Dude as there are so many frames! But with SwingDing it makes all the difference.

Enjoy and happy coding!