This project is read-only.
  • Create a windows game library project, and add references to Microsoft.Xna.Framework.Content.Pipeline and Xclna.Xna.Animation.Content
  • Compile the project into a dll by building it. The dll will appear in the projectDirectory/bin/debug/ directory
  • Add this compiled dll as a content pipeline reference to your current project that displays the animated dwarf
  • Now every time you recompile the new library project, the dll will automatically be updated in your game project.
  • Create a new processor that inherits AnimatedModelProcessor and override the ReplaceBasicEffects method. This method is called after all other processing has occurred. Note that you can set your own effects in other ways:
    public class MyProcessor : AnimatedModelProcessor
        protected override void ReplaceBasicEffect(SkinningType skinningType,
            Microsoft.Xna.Framework.Content.Pipeline.Processors.ModelMeshPartContent meshPart)
  • Now, fill in the ReplaceBasicEffect method with the following code. Note that "string myEffectPath" should be set to the absolute file path of your effect:
    // Make sure we don't replace the basic effect on unskinned models
    // This check should almost always be optional.
    if (skinningType != SkinningType.None)
        // The absolute file path of your effect
        string myEffectPath = _absolute file path of your effect_;

        // Create the effect material content
        EffectMaterialContent myEffectContent = new EffectMaterialContent();
        myEffectContent.Effect = new ExternalReference<EffectContent>(myEffectPath);
        MaterialProcessor processor = new MaterialProcessor();

        // Process the material so that it is using a compiled effect
        processor.Process(myEffectContent, base.ProcessorContext);

        // The textures have already been processed for you.  If you want to change how they
        // are processed you can override the ConvertMaterial method provided in XNA
        TextureReferenceDictionary textureDict = meshPart.Material.Textures;
        foreach (string key in textureDict.Keys)
            myEffectContent.Textures.Add("BasicTexture", textureDict[key]);
        meshPart.Material = myEffectContent;
  • Set the content processor for dwarfmodel.x to "MyProcessor" in your game project
  • Finally, set the view and projection matrices to the correct value in the LoadGraphicsContent method:
    // Add this to the LoadGraphicsContent method
    foreach (ModelMesh mesh in model.Meshes)
        for (int i = 0; i < mesh.MeshParts.Count; i++)
            ModelMeshPart part = mesh.MeshParts[i];

Last edited Mar 8, 2007 at 1:01 AM by dastle, version 4


No comments yet.