fbx with no animations?

Nov 12, 2009 at 8:06 PM

hello i'm testing the project, i have exported my model to fbx format and when i put into the tutorial 11, "model animation" when i try to run it the compiler throw an exeption because the animationIndex value is -1, i have try the fbx file into the quicktime viewer and it show fine, somebody can tell me how to fix this ? there is a custom setting to export the file ? thenk you in advance for the help.

Nov 13, 2009 at 8:26 AM
Edited Nov 13, 2009 at 9:52 AM

Hi Daimaku,

The animationIndex variable is set on line 56 of Model Animation.cs in Tutorial 11. The specific line looks like this:

int animationIndex = animationController.AnimationIndex("Walk");

The string that is passed to AnimationController.AnimationIndex needs to be the name of an animation that is contained within the FBX file. If the string is not found, I assume this methods returns -1 to indicate an error occurred. My guess is that when you exported the FBX the animation sequence wasn't named Walk.

If you're unsure of the name of the animation sequences contained in the FBX file, you could use a method that looks something like the following:


private void PrintAvailableAnimations(AnimationController controller)
    for (int i=0; i < controller.AnimationCount; i++)
        Xen.Ex.Graphics.Content.AnimationData data = controller.GetAnimationData(i);

        System.Diagnostics.Debug.WriteLine("Index " + i + ": " + data.Name);



This will print to Visual Studio's Output window the name and index of all the animations contained in the FBX file you've loaded.

I hope this helps! If there's anything that's unclear (when I try to explain things at 1 in the morning, things aren't always clear), let me know.



Edit: Fixed the code per StatusUnknown's message below.

I can't believe I missed the AnimationCount property. I swear I spent a full minute looking through the AnimationController doc for some kind of property that stored the number of animations... And, yea, the IndexOutOfRangeException was a horrible kludge to get him something that would list the animations, not anything to be used anywhere near production code.

This is why I don't let myself near professional code after midnight.


Nov 13, 2009 at 9:31 AM

ncallaway, the animation controller does have an AnimationCount property. You should never, *ever* use exceptions for control flow. Also, the ModelData, stores a collection of the animation data objects.