Now lets create a model animator for the dwarf that will allow us to view the dwarf and animate it.

Viewing the Dwarf with a ModelAnimator object

    // Add these as member variables
    ModelAnimator dwarfAnimator;
    Matrix view;
    protected override void LoadGraphicsContent(bool loadAllContent)
    {
        if (loadAllContent)
        {
            Model model = content.Load<Model>("dwarfmodel");
            dwarfAnimator = new ModelAnimator(this, model);
            Viewport port = graphics.GraphicsDevice.Viewport;
            view = Matrix.CreateLookAt(
                new Vector3(0, 15, -20), Vector3.Zero, Vector3.Up);
            Matrix projection = Matrix.CreatePerspectiveFieldOfView(
                MathHelper.PiOver4, (float)port.Width / port.Height, .1f, 100000f);

            foreach (ModelMesh mesh in model.Meshes)
            {
                foreach (BasicPaletteEffect effect in mesh.Effects)
                {
                    effect.View = view;
                    effect.Projection = projection;
                }
            }
        }

    }

Possible Questions