public static bool Read(BinaryReader reader, KeyFrameWithInterpolation frame) { if (!KeyFrame.Read(reader, frame)) { return(false); } int type = reader.ReadByte(); if (!Enum.IsDefined(typeof(InterpolationTypes), type)) { return(false); } frame.m_InterpolationType = (InterpolationTypes)type; switch (frame.m_InterpolationType) { case KeyFrame.InterpolationTypes.Mirrored: case KeyFrame.InterpolationTypes.Asymmetric: case KeyFrame.InterpolationTypes.Disconnected: case KeyFrame.InterpolationTypes.Hold: frame.m_Interpolator = ValueTimeCurveInterpolator.Read(reader, frame.m_InterpolationType); break; default: frame.m_Interpolator = null; break; } return(true); }
public static bool Read(BinaryReader reader, KeyFrameInt frame) { if (!KeyFrameWithInterpolation.Read(reader, frame)) { return(false); } frame.m_Value = reader.ReadInt32(); return(true); }
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); }
public static KeyFrame Read(BinaryReader reader, ActorComponent component) { KeyFrameVertexDeform frame = new KeyFrameVertexDeform(); if (!KeyFrameWithInterpolation.Read(reader, frame)) { return(null); } ActorImage imageNode = component as ActorImage; frame.m_Vertices = new float[imageNode.VertexCount * 2]; Actor.ReadFloat32Array(reader, frame.m_Vertices); imageNode.DoesAnimationVertexDeform = true; return(frame); }
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); }
abstract public bool SetNextFrame(KeyFrameWithInterpolation frame, KeyFrame nextFrame);
public override bool SetNextFrame(KeyFrameWithInterpolation frame, KeyFrame nextFrame) { return(false); }