예제 #1
0
        /// <summary>
        /// Starts a new animation.
        /// </summary>
        /// <param name="model">The animated model.</param>
        /// <param name="animation">The animation to play.</param>
        public void StartAnimation(Model model, ModelAnimation animation)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            if (animation == null)
            {
                throw new ArgumentNullException("animation");
            }

            animationStates[model] = new AnimationState
            {
                Model = model,
                Animation = animation,
                ChannelMap = BuildChannelMap(model, animation)
            };
        }
예제 #2
0
 protected virtual void ReadAnimation(ref ModelAnimation animation)
 {
     Serialize(ref animation.Name);
     Serialize(ref animation.Duration);
     Serialize(ref animation.Channels);
 }
예제 #3
0
        private int[] BuildChannelMap(Model model, ModelAnimation animation)
        {
            var channelMap = new int[animation.Channels.Count];

            for (int i = 0; i < animation.Channels.Count; i++)
            {
                channelMap[i] = -1;
                foreach (var bone in model.Bones)
                {
                    if (bone.Name == animation.Channels[i].BoneName)
                    {
                        channelMap[i] = bone.Index;
                        break;
                    }
                }
            }

            return channelMap;
        }