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.

Jason

No comments:

Post a Comment