#region File Description //----------------------------------------------------------------------------- // RigidAnimationPlayer.cs // // Microsoft XNA Community Game Platform // Copyright (C) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- #endregion using System; using Microsoft.Xna.Framework; namespace CustomModelAnimation { /// /// This animation player knows how to play an animation on a rigid model, applying transformations /// to each of the objects in the model over time /// public class RigidAnimationPlayer : ModelAnimationPlayerBase { // This is an array of the transforms to each object in the model Matrix[] boneTransforms; /// /// Create a new rigid animation player /// /// Number of bones (objects) in the model public RigidAnimationPlayer(int count) { if (count <= 0) throw new Exception("Bad arguments to model animation player"); this.boneTransforms = new Matrix[count]; } /// /// Initializes all the bone transforms to the identity /// protected override void InitClip() { for (int i = 0; i < this.boneTransforms.Length; i++) this.boneTransforms[i] = Matrix.Identity; } /// /// Sets the key frame for a bone to a transform /// /// Keyframe to set protected override void SetKeyframe(ModelKeyframe keyframe) { this.boneTransforms[keyframe.Bone] = keyframe.Transform; } /// /// Gets the current bone transform matrices for the animation /// public Matrix[] GetBoneTransforms() { return boneTransforms; } } }