Specialised KeyFrame which stores any numeric value.
Inheritance: KeyFrame
Ejemplo n.º 1
0
        public override KeyFrame GetInterpolatedKeyFrame(float timeIndex, KeyFrame kf)
        {
            NumericKeyFrame kret = (NumericKeyFrame)kf;

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

            float 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, targetAnimable.Type,
                                                                    k1.NumericValue, k2.NumericValue);
            }
            return(kf);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 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>
		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 );

		}