4 using System.Collections.Generic;
5 using System.Collections.Specialized;
7 using SiliconStudio.Core.Serialization.Converters;
8 using SiliconStudio.Paradox.DataModel;
9 using SiliconStudio.Paradox.EntityModel;
10 using SiliconStudio.Paradox.Games;
11 using SiliconStudio.Core;
12 using SiliconStudio.Core.Collections;
13 using SiliconStudio.Core.Serialization.Contents;
15 namespace SiliconStudio.
Paradox.Engine
24 [DataContract(
"AnimationComponent")]
27 private readonly Dictionary<string, AnimationClip> animations;
28 private readonly TrackingCollection<PlayingAnimation> playingAnimations;
35 animations =
new Dictionary<string, AnimationClip>();
36 playingAnimations =
new TrackingCollection<PlayingAnimation>();
37 playingAnimations.CollectionChanged += playingAnimations_CollectionChanged;
42 if (e.
Action == NotifyCollectionChangedAction.Remove)
45 var evaluator = item.Evaluator;
46 if (evaluator != null)
48 Blender.ReleaseEvaluator(evaluator);
49 item.Evaluator = null;
55 public Dictionary<string, AnimationClip> Animations
57 get {
return animations; }
64 public void Play(
string name)
66 PlayingAnimations.Clear();
67 PlayingAnimations.Add(
new PlayingAnimation(
this, name) { CurrentTime = TimeSpan.Zero, Weight = 1.0f });
76 public void Crossfade(
string name, TimeSpan fadeTimeSpan)
78 if (!Animations.ContainsKey(name))
79 throw new ArgumentException(
"name");
82 foreach (var otherPlayingAnimation
in PlayingAnimations)
84 otherPlayingAnimation.WeightTarget = 0.0f;
85 otherPlayingAnimation.RemainingTime = fadeTimeSpan;
89 Blend(name, 1.0f, fadeTimeSpan);
99 public void Blend(
string name,
float desiredWeight, TimeSpan fadeTimeSpan)
101 if (!Animations.ContainsKey(name))
102 throw new ArgumentException(
"name");
104 var playingAnimation =
new PlayingAnimation(
this, name) { CurrentTime = TimeSpan.Zero, Weight = 0.0f };
105 PlayingAnimations.Add(playingAnimation);
107 if (fadeTimeSpan > TimeSpan.Zero)
109 playingAnimation.WeightTarget = desiredWeight;
110 playingAnimation.RemainingTime = fadeTimeSpan;
114 playingAnimation.Weight = desiredWeight;
124 public TrackingCollection<PlayingAnimation> PlayingAnimations
126 get {
return playingAnimations; }
void Crossfade(string name, TimeSpan fadeTimeSpan)
Crossfades to a new animation.
Base class for converters to/from a data type.
Add animation capabilities to an Entity. It will usually apply to ModelComponent.ModelViewHierarchy ...
object Item
Gets the added or removed item (if dictionary, value only).
NotifyCollectionChangedAction Action
Gets the type of action performed. Allowed values are NotifyCollectionChangedAction.Add and NotifyCollectionChangedAction.Remove.
Performs animation blending. For now, all AnimationClip must target the same skeleton.
void Blend(string name, float desiredWeight, TimeSpan fadeTimeSpan)
Blends progressively a new animation.
Blend
Blend option. A blend option identifies the data source and an optional pre-blend operation...
A class that represents a tag propety.
PlayingAnimation NewPlayingAnimation(string name)
void Play(string name)
Plays right away the animation with the specified name, instantly removing all other blended animatio...