示例#1
0
        public float GetValue(float time, IAnimationTimer animationTimer, InterpolatorDelegate interpolator)
        {
            if (!this.keyframes.Any())
            {
                return(0);
            }

            KeyValuePair <float, float> minTime = this.keyframes.First();
            KeyValuePair <float, float> maxTime = this.keyframes.Last();

            float startTime = StartingTime;

            time = startTime + AnimationTimer.Value(time, FinishingTime - startTime);

            if (time <= minTime.Key)
            {
                return(minTime.Value);
            }

            if (time >= maxTime.Key)
            {
                return(maxTime.Value);
            }

            KeyValuePair <float, float> prevTime = this.keyframes.First(kf => kf.Key >= time);
            KeyValuePair <float, float> succTime = this.keyframes.First(kf => kf.Key > prevTime.Value);

            float dt = succTime.Key - prevTime.Key;
            float t  = (time - prevTime.Key) / dt;

            return(interpolator.Invoke(t, prevTime.Value, succTime.Value));
        }
示例#2
0
        public Timeline(IAnimationTimer animationTimer, InterpolatorDelegate interpolator)
        {
            this.keyframes = new SortedDictionary <float, float>();

            AnimationTimer = animationTimer;
            Interpolator   = interpolator;
        }
 public MyAnimatedProperty(string name, InterpolatorDelegate interpolator)
     : this()
 {
     m_name = name;
     if (interpolator != null)
     {
         Interpolator = interpolator;
     }
 }
 public MyAnimatedProperty(string name, bool interpolateAfterEnd, InterpolatorDelegate interpolator)
     : this()
 {
     m_name = name;
     m_interpolateAfterEnd = interpolateAfterEnd;
     if (interpolator != null)
     {
         Interpolator = interpolator;
     }
 }
 public MyAnimatedPropertyEnum(string name, InterpolatorDelegate interpolator, Type enumType, List <string> enumStrings)
     : base(name, interpolator)
 {
     m_enumType    = enumType;
     m_enumStrings = enumStrings;
 }
 public MyAnimatedPropertyInt(string name, InterpolatorDelegate interpolator)
     : base(name, interpolator)
 {
 }
示例#7
0
 public MyAnimatedPropertyTransparentMaterial(string name, InterpolatorDelegate interpolator)
     : base(name, false, interpolator)
 {
 }
 public MyAnimatedPropertyVector4(string name, InterpolatorDelegate interpolator)
     : base(name, false, interpolator)
 {
 }
 public MyAnimatedPropertyVector3(string name, bool interpolateAfterEnd, InterpolatorDelegate interpolator)
     : base(name, interpolateAfterEnd, interpolator)
 {
 }