/// <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) }; }
protected virtual void ReadAnimation(ref ModelAnimation animation) { Serialize(ref animation.Name); Serialize(ref animation.Duration); Serialize(ref animation.Channels); }
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; }