Exporting FBX Files From Maya for XNA

by George Tsouris

Visual Artist: Give-Up Games

 

            Microsoft has made it easier for aspiring animators, modelers, and programmers to get together and create video games for Windows or Xbox with their XNA framework. One challenge, however, is that with so many 3d programs and software, there are a glut of file formats that are all incompatible with each other. The folks at Microsoft have decided to limit the file formats that can be used within the XNA framework to a few universal ones.

            One popular file format supported by XNA for 3d content is fbx. However, it can be less than intuitive to save fbx files for use in XNA, especially from Maya. This tutorial is going to teach you how to export your 3d content (models and animation) from Maya to the fbx format for use in the XNA framework. This already assumes that you have created a model with or without animation in Maya, and are ready to use it in your video game.

            I have made a simple mannequin with about 300 frames (about ten seconds) of animation. The mannequin performs several different actions within the scene file. He walks, jumps, stands idle, throws something, kicks, and dies. This was a request by the programmer based on how he created the content player in XNA. All the different actions will then be clipped and put into action as the programmer sees fit. However, your programmer might have written his game engine to implement  animation differently. You will still be able to export a model with animation following the same directions here.

 

FBX2010 plugin

 

            You will need to install an up-to-date fbx exporter plugin for Maya. The FBX2010 plugin can be found at the Autodesk website at this address:

 

http://usa.autodesk.com/adsk/servlet/item?siteID=123112&id=11259183

 

From the list of plugins on the page, you will be able to find the one that corresponds to your version of Maya and your operating system. Once you have downloaded the appropriate plugin, you can install it by opening it, and following the on-screen directions. Now you are ready to work in Maya.

 

Model and Textures

 

            Open the Maya scene that you want to export for use in XNA. You need to make sure that the textures are all in the right location. My mannequin has a simple green texture. I need to make sure that the file is pointing to the right place so that when I give the fbx file to programmer, the fbx file will be able to find the green texture. The programmer and I have agreed that we want the textures to be located in a folder called “textures”. In your Maya scene, open the Attribute Editor by pressing ctrl-A. In the Attribute Editor, make sure the scene file is pointing to the right place for the green texture:

 

textures/green.jpg

 

In order for this to work, I have to put the green.jpg file in the “textures” folder in my Maya project. Now when I give fbx file and the texture file to the programmer, he will put the green.jpg file in his “textures” folder, and the fbx file will find it in the XNA framework. Remember to make sure that all of the textures in your Maya scene are in the right location for your programmer to find, or the fbx file will not be able to find them in XNA, and the model will not have any textures in XNA.

            At this point, if you do not have any animation for your model, you are ready to export the model, and you can skip to the Exporting section of this article. If you do have animation on your model, here is how we are going to prepare the file for fbx exporting.

 

Animation

 

            You are going to want to make sure that the timeline at the bottom is set to the full size of the animation. In my case, the animation starts on frame 1, and lasts until frame 300.

 

 

            Now you need to select the root bone of the character's skeleton. Then right click the selected bone, and choose “Select Hierarchy.” This will select the root bone, and all of the other bones the character's skeleton. All of the bones in the skeleton will turn white when they are all selected. Even if you have created an animation rig for your character, you are still going to want to select the root bone, and all of its hierarchy, but not the rig.

 

 

            With all the bones in the character's skeleton selected, you are now going to bake the animation. To do this, click the square next to Edit → Keys → Bake Simulation. The dialog box will open up. If you have a rig, you are want to make sure that “Driven Channels” is checked, as well as “Heirarchy.” You can now push the “Bake” button at the bottom of the dialogue box. The screen will scrub through the animation, and you will notice that every single frame now has its own keys.

 

 

            With all the bones keyed at every frame, you can now delete every element of your animation rig if you have one. Because you baked the animation to the bones, the rig is no longer needed.

            The last step before exporting is to go to the bind pose on the first frame. Go to the first frame of your animation. In my case, it is frame 1. Make sure that you are in Animation mode in Maya. Now select Skin → Go To Bind Pose. The character model will then go to the pose that you originally had when you skinned the model. The Maya scene file is now ready to export to fbx.

 

Exporting

 

            After we have prepared the model and the animation for exporting, you can finally export the Maya scene to an fbx file. Click File → Export All. The save dialogue box will come up, and you name the file whatever you wish, then click the Export button. An fbx exporter dialogue box then comes up.

             The fbx exporter dialogue box has a lot of different options, but there is no need to worry. You can leave most of the preset selections just as they are. However, at the bottom of the dialogue box, you have to select the appropriate fbx exporter, FBX2010, which is the plugin we installed at the beginning of this tutorial. At the bottom of the dialogue box, press the Export button, and we are all done. (A warning box may come up. You can disregard anything it says, and close that window.)

 

 

Conclusion

 

            You can now deliver the new fbx file, and the textures for that file to your programmer for use in the XNA framework. Here is a summary of the steps to export fbx files from Maya for use in XNA.

  1. Install the FBX2010 plugin for Maya.
  2. Make sure the Maya scene file points to the correct location for all textures.
  3. Stretch the timeline to cover all of your animation.
  4. Select the root bone and the hierarchy and bake the animation. Delete your rig.
  5. Move the scene to the first frame, and go to bind pose.
  6. Export All to fbx using the FBX2010 plugin.
  7. Deliver the fbx file and the corresponding textures to your programmer.



Have Questions?

Send Us an Email by clicking here