public void SetAnimation(string animation)
{
try
{
if (mCurrentAnimationController != null)
FlatRedBallServices.Game.Services.RemoveService(typeof(AnimationController));
mCurrentAnimationController =
new AnimationController(FlatRedBallServices.Game,
mModelAnimator.Animations[animation]);
}
catch (KeyNotFoundException e)
{
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.Append("Cannot find an animation named ").Append(animation);
stringBuilder.AppendLine("The following animations are defined for this model:");
for(int i = 0; i < mModelAnimator.Animations.Count; i++)
{
stringBuilder.AppendLine(mModelAnimator.Animations[i].Name );
}
throw new System.ArgumentException(stringBuilder.ToString());
}
foreach (BonePose p in mModelAnimator.BonePoses)
{
p.CurrentController = mCurrentAnimationController;
p.CurrentBlendController = null;
}
}