Пример #1
0
        public override KeyFrame GetInterpolatedKeyFrame(float timeIndex, KeyFrame kf)
        {
            var kret = (NumericKeyFrame)kf;

            // Keyframe pointers
            KeyFrame        kBase1, kBase2;
            NumericKeyFrame k1, k2;
            short           firstKeyIndex;

            var t = GetKeyFramesAtTime(timeIndex, out kBase1, out kBase2, out firstKeyIndex);

            k1 = (NumericKeyFrame)kBase1;
            k2 = (NumericKeyFrame)kBase2;

            if (t == 0.0f)
            {
                // Just use k1
                kret.NumericValue = k1.NumericValue;
            }
            else
            {
                // Interpolate by t
                kret.NumericValue = AnimableValue.InterpolateValues(t, this.targetAnimable.Type, k1.NumericValue, k2.NumericValue);
            }
            return(kf);
        }
Пример #2
0
        /// <summary>
        ///		Creates a new NumericAnimationTrack automatically associated with a Numeric.
        /// </summary>
        /// <param name="index">Handle to give the track, used for accessing the track later.</param>
        /// <param name="animable">AnimableValue which will be affected by this track.</param>
        /// <returns></returns>
        public NumericAnimationTrack CreateNumericTrack(ushort handle, AnimableValue animable)
        {
            // create a new track and set it's target
            NumericAnimationTrack track = CreateNumericTrack(handle);

            track.TargetAnimable = animable;

            return(track);
        }
Пример #3
0
        /// <summary> Applies an animation track to a given animable value. </summary>
        /// <param name="anim">The AnimableValue to which to apply the animation </param>
        /// <param name="time">The time position in the animation to apply. </param>
        /// <param name="weight">The influence to give to this track, 1.0 for full influence, less to blend with
        ///        other animations. </param>
        /// <param name="scale">The scale to apply to translations and scalings, useful for
        ///        adapting an animation to a different size target. </param>
        private void ApplyToAnimable(AnimableValue anim, float time, float weight, float scale)
        {
            // Nothing to do if no keyframes
            if (keyFrameList.Count == 0)
            {
                return;
            }

            var kf = new NumericKeyFrame(null, time);

            GetInterpolatedKeyFrame(time, kf);
            // add to existing. Weights are not relative, but treated as
            // absolute multipliers for the animation
            var v   = weight * scale;
            var val = AnimableValue.MultiplyFloat(anim.Type, v, kf.NumericValue);

            anim.ApplyDeltaValue(val);
        }
Пример #4
0
 public NumericAnimationTrack(Animation parent, AnimableValue targetAnimable)
     : base(parent)
 {
     this.targetAnimable = targetAnimable;
 }
Пример #5
0
		/// <summary>
		///		Creates a new NumericAnimationTrack automatically associated with a Numeric. 
		/// </summary>
        /// <param name="handle">Handle to give the track, used for accessing the track later.</param>
		/// <param name="animable">AnimableValue which will be affected by this track.</param>
		/// <returns></returns>
		public NumericAnimationTrack CreateNumericTrack( ushort handle, AnimableValue animable )
		{
			// create a new track and set it's target
			NumericAnimationTrack track = CreateNumericTrack( handle );
			track.TargetAnimable = animable;

			return track;
		}
Пример #6
0
		/// <summary> Applies an animation track to a given animable value. </summary>
		/// <param name="anim">The AnimableValue to which to apply the animation </param>
        /// <param name="time">The time position in the animation to apply. </param>
		/// <param name="weight">The influence to give to this track, 1.0 for full influence, less to blend with
		///        other animations. </param>
		/// <param name="scale">The scale to apply to translations and scalings, useful for 
		///        adapting an animation to a different size target. </param>
		void ApplyToAnimable( AnimableValue anim, float time, float weight, float scale )
		{
			// Nothing to do if no keyframes
			if ( keyFrameList.Count == 0 )
				return;

			NumericKeyFrame kf = new NumericKeyFrame( null, time );
			GetInterpolatedKeyFrame( time, kf );
			// add to existing. Weights are not relative, but treated as
			// absolute multipliers for the animation
			float v = weight * scale;
			Object val = AnimableValue.MultiplyFloat( anim.Type, v, kf.NumericValue );

			anim.ApplyDeltaValue( val );

		}
Пример #7
0
		public NumericAnimationTrack( Animation parent, AnimableValue targetAnimable )
			: base( parent )
		{
			this.targetAnimable = targetAnimable;
		}