Applying animation from one .x file onto a model in another .x file

Topics: Developer Forum
Feb 17, 2007 at 1:15 AM
How would you go about applying an animation stored in one .x file onto a model in another file? The models have the same bone structure (and almost the same geometry).

(Application: These are some "legacy" .x files that I no longer have the 3DStudio MAX files for. We originally exported the animations in different .x files which each contain the model.)

Thanks -- having great success getting these working with the library today!
Feb 17, 2007 at 2:51 AM
Edited Feb 17, 2007 at 3:03 AM
If either the custom importer or XNA importer can import your model, you should be able to do it. Here is an example that I hope is clear enough. I haven't tested this, but it should work:
            Model mainModel = content.Load<Model>("MyMainModel");
            // This model stores the animation
            Model animationModel = content.Load<Model>("ModelWithAnimation");
            ModelAnimator mainAnimator = new ModelAnimator(this, mainModel);
            ModelAnimator dummyAnimator = new ModelAnimator(this, animationModel);
            // Remove from the game components so it doesn't render or sit around in
            // memory
            mainAnimator.Animations.Add("My Animation Name",

In addition to having the same bone structure, the bones also must have the same names.
Feb 17, 2007 at 8:32 PM
This worked perfectly! Thank you!