Thursday, February 01, 2007

XNA 3D Animation: It works!

Hi Guys!

Before I say anything, I just wanna show you guys something, to illustrate the result of 4 sleepless nights...
Behold...
Models in XNA!!!! Animated!

Model Trial 1: Nissan Car (Without Image textures)





Model Trial 2: Helicopter (With Image Textures)



Model Trial 3: Truck (With Image Textures)


All of these models are freely available from the net, and converted from .3ds format to .fbx using Maya.

A quick run through of work-flow to create, animate and export to XNA:

1. Get your Models (duh!)

2. If the Models has textures, please copy them to the folder where your XNA Content assets will be included (I will explain the significance of this later on)

3. Now this is the most Tedious part: Apparently XNA only accepts textures whose resolutions are power of 2 ( see here for details), in other words, 2,4,8,16,32,64,128,256,512 etc, so if one of your texture is say, 300x500, please open using photo shop and resize it to say, 256x512. This is very Important! Otherwise the models will not be able to be imported into XNA, and I will have a hard time debugging which textures to fix later on.

4. Before you start animating, please test that the models will indeed run in XNA. I will (or Erik will :P) write a simple utility to test out whether the model and the textures are importable by XNA.

5. If the models is fine, then you can start animating the models.

6. When ready to Export to XNA, use the File->ExportAll Option from Maya to export to .fbx file. This is the settings which works all the time (so far) for me:


7. Export your models to the Content->Textures/ whatever path of the XNA source code which you are dedicating for Textures(Even if you are not coding it, please set it to the working directory, otherwise I will have to open one by one the FBX and do a replace and search for all). We will go through this in details later on.


8. Test the animation in XNA. For Multiple Animations, We have no choice but to create a second animation based on the same model, but when you export, just click "Export Animation-Only", like follow:
9. Save this to a Separate .fbx file. At this moment, it seems like the only way to have multiple animation in one .fbx is by opening up the animation only-.fbx and copying the animation information manually to the other .fbx which contains the model/ textures information. Until we can write a tools to automate this, we have to do this manually, so remember, rule of thumb:
- First animation : Export All
- Second animation onwards : Export Animation Only
- I will then integrate all the animation manually into the first animation file (the one which is to be imported)

10. At this moment, I am facing a problem with loading a model with lots of bones, because apparently the Animation Component library which I am using has a limitation of 56 bones

///
/// The max number of bones in the effects matrix palette.
///

public const int PALETTE_SIZE = 56;

I am not sure whether we would face this problem or not, but as we go along, we might need to investigate why, and how come the moment I change that value, the whole thing doesn't work anymore.

I think so far it looks quite promising:
  • We can load .FBX without having to export to the dreadful .x format.
  • We can load the textures, although a bit laborious as we have to manually change the texture resolutions to be powers of 2
  • We can embed more than one animations in one .fbx, again, laborious as we have to manually embed the animation one by one
  • The models render smoothly in XNA, so hopefully as we put more models on the screen at the same time, the performance will not suffer so much.
I will keep you guys updated for more developments!

-Donny

1 Comments:

Blogger alex said...

Cool! Hopefully XNA will be installed in the labs by today, so soon we should be able to try pushing content to the xbox... :)

7:31 AM  

Post a Comment

<< Home