Engines/FlatRedBallXNA/FlatRedBall.Content/ModelAnimation/X File/XModelImporter.cs
// template AnimationSet
// {
//     [ Animation ]
// } 
/// <summary>
/// Imports an animation set that is added to the AnimationContentDictionary of
/// the root frame.
/// </summary>
Imports an animation set that is added to the AnimationContentDictionary of
the root frame.
Imports an animation set that is added to the AnimationContentDictionary of the root frame .
private void ImportAnimationSet()
        {
            AnimationContent animSet = new AnimationContent();
            animSet.Name = tokens.ReadName();
            if (animSet.Name == null)
                animSet.Name = "Animation" + root.Animations.Count.ToString();
            for (string next = tokens.NextToken(); next != "}"; next = tokens.NextToken())
            {
                if (next == "Animation")
                {
                    string boneName;
                    AnimationChannel anim = ImportAnimationChannel(out boneName);
                    if (boneName == null)
                        throw new Exception("Animation in file is not attached to any joint");
                    if (anim[anim.Count - 1].Time > animSet.Duration)
                        animSet.Duration = anim[anim.Count - 1].Time;
                    animSet.Channels.Add(boneName, anim);
                }
                else if (next == "{")
                    tokens.SkipNode();
            }
            if (root.Animations.ContainsKey(animSet.Name))
            {
                string error = "Attempting to add " + animSet.Name + " but it already exists.";
                throw new Exception(error);
            }
            root.Animations.Add(animSet.Name, animSet);
        }
private void ImportAnimationSet ( ) { AnimationContent animSet = new AnimationContent ( ) ; animSet . Name = tokens . ReadName ( ) ; if ( animSet . Name == null ) animSet . Name = " " + root . Animations . Count . ToString ( ) ; for ( string next = tokens . NextToken ( ) ; next != " " ; next = tokens . NextToken ( ) ) { if ( next == " " ) { string boneName ; AnimationChannel anim = ImportAnimationChannel ( out boneName ) ; if ( boneName == null ) throw new Exception ( " " ) ; if ( anim [ anim . Count - 1 ] . Time > animSet . Duration ) animSet . Duration = anim [ anim . Count - 1 ] . Time ; animSet . Channels . Add ( boneName , anim ) ; } else if ( next == " " ) tokens . SkipNode ( ) ; } if ( root . Animations . ContainsKey ( animSet . Name ) ) { string error = " " + animSet . Name + " " ; throw new Exception ( error ) ; } root . Animations . Add ( animSet . Name , animSet ) ; }
Imports an animation set that is added to the AnimationContentDictionary of
the root frame.
Imports an animation set that is added to the AnimationContentDictionary of the root frame .
// Give each animation a unique name // Fill in all the channels of the animation.  Each channel refers to  // a single bone's role in the animation. // Every channel must be attached to a bone! // Make sure that the duration of the animation is set to the  // duration of the longest animation channel // skip nodes we are uninterested in //skeletonRoot = MeshHelper.FindSkeleton(root); //skeletonRoot.Animations.Add(animSet.Name, animSet);