Exporting DirectX animations for XNA

I have looked up a few posts on this forum and have read many people share their successes with being able to export their animations in a DirectX file and view them in DirectXViewer. I have tried everything that I could find that other people had tried but have not met with any success.

I can see my model in the viewer, stuck in whatever pose I exported it in, but it will not animate, however the UV mapped textures on it are perfect. I have doubled checked and all my vertices are are in one and only one vertex group. The only bone that does not have any vertices is the master bone. I read the documentation for the exporter and the only thing I have not done is view my model in MView only because it doesn’t appear to be available for download anywhere. I even tried one other exporter that I could find and it kind of animated the model… except it only moved half of the vertices, creating this giant pokey throbbing thing… with not texture mapped to it. I opened the Direct X file and am not one hundred percent sure what I should be looking for, but I do not see any assignments for bones, any animations sets or anything that suggests animation, except for a transform matrix which is way to small to record the action that I created and baked to my model.

When I export I select only the mesh, have a different window open for scripts to that I can see the 3d window and I press the animation button (of course)

I even created a simpler mesh of just a cube with a limb sticking out of it to try everything on a smaller scale to see if I was missing anything, and it still does not work.

Does anyone have any ideas? I think I’ve tried everything I could think of. I’ve heard some of you say it can be done, is there anything I’m missing?

Any help would be much appreciated.


Post the .blend of your simple cube trial and I’ll take a look, tell you what needs changed to get it working and from there you can work on your more complex model.

One thing to note you must attach the model to the armature by parenting. No other method will work. Select your mesh, shift select the armature and Ctrl-P to parent.

Anyway, getting a cube to animate with the .X exporter is pretty simple so lets get that working and you can take it from there.


That would be wonderful. Thank you very much. This is the link to where I had to post the file.


Ok, that was easy :slight_smile:

The DirectX exporter will only support one “action”. If you have more than one action it get’s confused and the animation will fail. You had action and action.baked. I deleted action.baked and the animation (action) now works.

How to delete an action is a bit strange… here goes.

  1. Hitting the “X” beside an action will just unlink it, it’s still there in case you want to reactivate it, so…
  2. With your mouse in the Action editor window hit Shift-F4.
  3. Now select “…”(to go up one level in the directory structure)
  4. Now open the “Action” Directory
  5. You should see two actions in your case, “Action” and “Action.Baked”. Right click “Action.Baked” so it turns purple and then press “F” to make the number of users go to zero (I had to do this a couple of times for it to work).
  6. Cancel the file manager.
  7. Save the .blend file and reopen. The “Action.Baked” should be gone now, if not do it again.
  8. Export the file as you have been doing to .x and open in mview.exe and you will see the animation has now been exported.

I’ve uploaded a corrected .blend file and .x to here…

Now obviously you’ll want more than on animation in your real file like walk, run, idle, fight, die etc. So, you can either create all the frames as one action and then code an extraxctanimsequence type in your game application or you can create a seperate blend file for each of the animations, export seperate.x files and then open in a text editor (these .x files are human readable) to merge the animations into one file. All you need to do is google for the DirectX file format specs to see how simple the specification is and give it a go. Try it with your simple cube file first to see if you can add another animation to an existing file, it’s not that difficult.

Hope this helps, but honestly though as far as I know XNA supports .fbx which is probably a better exporter as it is actively being developed still and will almost certainly receive attention during the Apricot open game project which aims to develop better pipleines from Blender to other game engines (not just Crystal Space).


yep, wishing to see der_tons’ *.md5 into all builds as well as b3d and fbx… (just wishing :wink: ). A good number of engines also use x…

Information for those that are unaware,

FBX export is already in all official Blender builds File–>Export–>Autodesk FBX (.fbx), there was a good page on the wiki with a detailed analysis of files imported to different packages and a sample character file but I can never find anything on the wiki.:frowning:

.b3d export (my favourite) is just a download away…


Thanks to Diego (Gandalf) it’s rock solid, even exports actions made in the NLA editor which is fantastic. Eg create a walk animation action, and an action of holding a gun then create an NLA strip and hey presto you have an animation of walking while holding a gun for free. Very powerful stuff.


yep, I knew that :slight_smile: …Is really cool. (I just hope they(md5, b3d) keep being compatible with newer Blender releases) .One thing I’d really like is b3d being able to export lightmaps. Is possible in other tools, but I don’t know if that kind of export is already possible in blender, or if Diego did that support in the exporter…

I believe Diego is working on adding support for Blender’s second set of UV co-ords in a new release of his exporter script. If that was to happen I’d be over the moon as I could lightmap levels in Blender and export it straight to .b3d (.b3d is one of the few formats that supports 2 sets of UV co-ords) and never have to use Gile[s] (standalone lightmapper) again.

Reading the logs on the fabled Blender 2.50 release it appears that the changes to Blender (event refactor) are so far reaching that everything will be broken to some extent and will need to be updated to work with all future releases. Certainly Ideasman (Blender-Python developer)mentioned the python api would need rewritten from scratch to interface with Blender’s new internal structure. This is a bit worrying but I’m sure the devs will figure it all out eventually. Certainly I predict that there will be an extended period of running Blender 2.45 in tandem with 2.50 and beyond for some time.


yep, let’s hope those formats keep supported.

BTW, now you put me in doubt, but I think b3d format even supports 4 uv channels, that is, you would be able to do lightmapping but also multi layered texturing, great for terrain blends. But one at a time, one can do the blends by some nice tricks, while lightmapping is more tedious to fake.Sometimes imposible.

I have giles too, and have the same hope than you :slight_smile:
Not that I don’t like it, but would prefer to use Blender.

Hey that’s awesome! It almost worked for me! so that means I’m closer.

So I got my file to be exactly like yours, except but when I exported it I couldn’t get the animations to work. So then I tested your .x file, and that did work. so then I tried exporting your .blend file and that didn’t work. So then I exported your .blend file using the secondary .x exporter and that did export that animation, but the normals were flipped and the lighting was dark. After playing around with the settings I got it to export perfectly. So then I went back to my file but could not get it to export the same way. either the normals are always flipped, or the lighting is too dark.

So my question is, did you use the default .x exporter in blender to export the model? if so, then I am wondering if I am doing it right. I select only the mesh, have the animation button selected and the Flip z is usually selected and then I just export the selection. Is this right? is that what you do?

But I am glad that it was something so simple. I think that the problem with my more complex model may be very simple as well, instead of being a problem with two many actions I think it will be with too many meshes, I always tried to delete the meshes by just pressing delete or x, but I noticed that I could still view them after deleting them, I’m going to try to delete them with this shift-f4 method now.

Also, I noticed that the reason that you needed to remove the action twice was because both the mesh and the armature were users of the action. Just something small to try to catch in case any one else has the same problems I do and reads these forums.

also, here is a link to the secondary exporter I have been using.


Again, thanks for the help, please let me know if I’m doing this wrong.


I use the default .x exporter in official Blender releases as it it always works for me :wink:

I exported with the following options:
Flip norm-Off
Swap zy-Off
Flip z- On
Speed -On (25 frames per second)
Export All <— this seems to be important as I’ve always had trouble with the other options.

One more quirk to tell you about the DirectX exporter :eyebrowlift2:. You can only export successfully once per session! If you have Blender open and export the model to .x and then open it in mview it will work, but if you then re-export the same model (even with a different file name) but change nothing it’ll fail to open in mview. Bizzare, but that’s the way it is. Save your .blend, shut down Blender and re-open in Blender to get another successful export.

Like I said, XNA supports .fbx, seriously consider using that format. It will be improved upon and supported in the future from within Blender (fingers crossed, along with fully implemented collada support). If even Microsoft supports it that should tell you something.

Note to all Game Asset Developers- Support Apricot by pre-ordering a DVD


oh… it looks like I actually forgot to post my last post…

well I got the cube to work, which is kind of exciting. I can’t get my model to work. But yeah, it turns out I wasn’t clicking the speed button. Makes sense in hindsight.

So I am considering .fbx the reason however that I wanted to use .x was because I wanted to be able to see my animations and see that they were working before I tried programming with them, just so that if anything goes wrong I can debug things step by step instead of having to guess if it’s my code, my models, my xml documents or what is going wrong. It would just be nice to know that the models are working. when I load my .fbx models as of right now they don’t animate in my program, but then, neither does my .x files even though they animate in the viewer, so I guess I have to study the formats a little and look at some code to figure out how to call the animations.

Sorry, just thinking out loud I guess.

But do you know of any .fbx viewers that would allow me to see my animations? It would be nicer right now then trying to figure out how to write my own.

2 Things.

  1. I’ve used the directx settings above and they work. Sort of. The model does animate using the XNA Skinned Sample tutorial However, it seems only animate at the keyframe. So you do not see the model animate until the keyframe is reached. So it maybe that you need to bake it. Any advice on leaving the baked animiation in the actions list and getting rid of the other. (the action I used to make the baked action) Because Blender seems to only export 1 animation.
  2. When i export to fbx and run it in the skinned model sample it looks like the model was in a car crash. Are there any settings that anyone knows of that work when exporting?


  1. Just delete the “action” and leave “action.BAKED” and see if that works. Does your .x file animate correctly in mview.exe? If so then it’s XNAs handling of .x that is wrong (we can’t assume that microsoft can support their own formats correctly, see below). Mview.exe was part of the official DirectX SDK and if it shows the animation correctly then it’s pretty much defacto OK as a .x file. You can resave the model from mview.exe for a 100% guarantee.

  2. Again we can’t guarantee XNA’s interpretation of the .fbx format is correct (microsoft don’t exactly have a good reputation for following other people’s standards). Visit the page below for a detailed analysis of Blender’s ability to export true, correct .fbx along with a sample file to try. We know the exported file works in the heavyweight 3D applications so if it fails with XNA then that’ll be down to microsoft to fix.



Thanks Ardee,
Your deletion of the action did the trick. Sort of. The animation seems to overcompensate. But it’s a start.