Пример #1
0
        public override void ApplyInterpolation(ActorComponent component, float time, KeyFrame toFrame, float mix)
        {
            switch (m_InterpolationType)
            {
            case KeyFrame.InterpolationTypes.Mirrored:
            case KeyFrame.InterpolationTypes.Asymmetric:
            case KeyFrame.InterpolationTypes.Disconnected:
            {
                ValueTimeCurveInterpolator interpolator = m_Interpolator as ValueTimeCurveInterpolator;
                if (interpolator != null)
                {
                    float v = (float)interpolator.Get((double)time);
                    SetValue(component, v, mix);
                }
                break;
            }

            case KeyFrame.InterpolationTypes.Hold:
            {
                SetValue(component, m_Value, mix);
                break;
            }

            case KeyFrame.InterpolationTypes.Linear:
            {
                KeyFrameNumeric to = toFrame as KeyFrameNumeric;

                float f = (time - m_Time) / (to.m_Time - m_Time);
                SetValue(component, m_Value * (1.0f - f) + to.m_Value * f, mix);
                break;
            }
            }
        }
Пример #2
0
        public static KeyFrame Read(BinaryReader reader, ActorComponent component)
        {
            KeyFrameConstraintStrength frame = new KeyFrameConstraintStrength();

            if (KeyFrameNumeric.Read(reader, frame))
            {
                return(frame);
            }
            return(null);
        }
Пример #3
0
        public static KeyFrame Read(BinaryReader reader, ActorComponent component)
        {
            KeyFrameOpacity frame = new KeyFrameOpacity();

            if (KeyFrameNumeric.Read(reader, frame))
            {
                return(frame);
            }
            return(null);
        }
Пример #4
0
        public override bool SetNextFrame(KeyFrameWithInterpolation frame, KeyFrame nextFrame)
        {
            // This frame is a hold, return false to remove the interpolator.
            // We store it in the first place as when it gets called as the nextFrame parameter (in a previous call)
            // we still read out the in factor and in value (see below where nextInValue and nextInFactor are defined).
            if (frame.InterpolationType == KeyFrame.InterpolationTypes.Hold)
            {
                return(false);
            }

            // Just a sanity check really, both keyframes need to be numeric.
            KeyFrameNumeric ourFrame = frame as KeyFrameNumeric;
            KeyFrameNumeric next     = nextFrame as KeyFrameNumeric;

            if (ourFrame == null || next == null)
            {
                return(false);
            }

            // We are not gauranteed to have a next interpolator (usually when the next keyframe is linear).
            ValueTimeCurveInterpolator nextInterpolator = null;

            float timeRange = next.Time - ourFrame.Time;
            float outTime   = (float)(ourFrame.Time + timeRange * m_OutFactor);

            float  nextInValue  = 0.0f;
            double nextInFactor = 0.0f;

            // Get the invalue and infactor from the next interpolator (this is where hold keyframes get their interpolator values processed too).
            if ((nextInterpolator = next.Interpolator as ValueTimeCurveInterpolator) != null)
            {
                nextInValue  = nextInterpolator.m_InValue;
                nextInFactor = nextInterpolator.m_InFactor;
                //this._Curve = new BezierAnimationCurve([this._Time, this._Value], [outTime, this._OutValue], [inTime, nxt._InValue], [nxt._Time, nxt._Value]);
            }
            else
            {
                // Happens when next is linear.
                nextInValue = next.Value;
            }

            float inTime = (float)(next.Time - timeRange * nextInFactor);

            // Finally we can generate the curve.
            InitializeCurve(ourFrame.Time, ourFrame.Value, outTime, m_OutValue, inTime, nextInValue, next.Time, next.Value);
            //this._Curve = new BezierAnimationCurve([ourFrame.Time, ourFrame.Value], [outTime, m_OutValue], [inTime, nextInValue], [next.Time, next.Value]);
            return(true);
        }
Пример #5
0
        public static bool Read(BinaryReader reader, KeyFrameNumeric frame)
        {
            if (!KeyFrameWithInterpolation.Read(reader, frame))
            {
                return(false);
            }
            frame.m_Value = reader.ReadSingle();

            /*if(frame.m_Interpolator != null)
             * {
             *      // TODO: in the future, this could also be a progression curve.
             *      ValueTimeCurveInterpolator vtci = frame.m_Interpolator as ValueTimeCurveInterpolator;
             *      if(vtci != null)
             *      {
             *              vtci.SetKeyFrameValue(m_Value);
             *      }
             * }*/
            return(true);
        }