The Animation Library allows you to specify the local transform to use for any bone and override the animation transforms for that bone. As an example, let's make the dwarf hold his weapon upside down.
  • To get a reference to the BonePose, which is named weapon, use
  • Set the CurrentAnimation to null. This will make the bone use the DefaultTransform property for rendering.
  • We want the translation component of our new matrix to be equal to the original translation so it looks like he is holding his weapon.
  • To turn the weapon upside down, rotate it by PI radians on the X axis and then by PI radians on the Y axis
  • Add the code at the end of the Update method
  • Here is the code:
    // Add this to the end of the Update method
    BonePose weapon = dwarfAnimator.BonePoses["weapon"];
    weapon.CurrentController = null;
    weapon.CurrentBlendController = null;
    weapon.DefaultTransform =
        Matrix.CreateRotationX(MathHelper.Pi) * 
        Matrix.CreateRotationY(MathHelper.Pi) *
  • Setting the Blend Animation to null is optional at the moment, but I put it in for a safety check for when we get to animation blending later.

Last edited Mar 7, 2007 at 8:49 PM by dastle, version 5


No comments yet.