Friday, June 27, 2008

Exporting DirectX Files for Animation

There are two approaches to writing DirectX files. The first is to take your geometry and animation data and stuff it into the D3DX Mesh classes and use Saving functionality. The second approach is to skip the D3DX classes and write a file directly that conforms to the .x format specifications.

I chose to write my own. I found the documentation and examples for loading D3DX classes inadequate when writing an exporter. Every book/article(msdn site, 3D Game Programming With DirectX 9.0, Managed DirectX 9 KickStart, etc.) will have a chapter on how a Bone hierarchy works and then it will show you the "Tiny.X" file and how to load it from file and animate it. But, where are the good examples (Managed code) and documentation on how to initialize and use these objects when you have all the data already? There are only a few and most are written in outdated versions. Since I didn't build my model and animation classes on D3DX classes, filling those objects did not appeal to me.

I worked on the format for a few days. I was able to export static meshes quite well. In fact, I had better results with the .x file I wrote then with the one written by the D3DX classes, which I had previously used to export static meshes. The ones from D3DX didn't load well in the newer Mesh Viewer that comes with the DirectX SDK. It only worked in the old one.

Exporting the Animated Meshes has proven more difficult but I am seeing some good results. I've been tinkering with the transformations and I got it really close. With a little time and some files I'll be exporting.

Happy Coding.


Wednesday, June 18, 2008

DirectX Character Animation II

In this animation I've upgraded the model a little. There is the stand, walk, run, and swing sequence. Here's the video:


I've also fixed the lighting as you can see in this video. The next one will be fully textured I promise!

Happy Coding!


Tuesday, June 10, 2008

DirectX Character Animation

I've made a little progress on my animation system. I made a test model I like to call Fred and attached him to an animated skeleton. See Video.

I know the character isn't that pretty but the important thing is that his skin isn't flying around the screen and he is performing the cheesy walk sequence. Although I haven't transformed the normals yet so his lighting is really bad. Next step is to fix normals and start working on weighted blends.

Later I'll support .x format so I'm going to take a close look at the "Simple Animation" demo from microsoft and utilize their AnimationController and D3DFrame structure. I did find that DirectX render state does support vertex blending with the D3DRS_VERTEXBLEND flag. You can read about it here:

Happy Coding!
(Note I'm not DXJas anymore because microsoft stopped supporting MDX and that upset me. Their alternative was to use XNA or roll your own. XNA Rocks though! Don't get me started...) :)