public static StreamedCurveKey CalculateStreamedFrame(AnimationCurveTpl <Float> curve, int lhsIndex, int rhsIndex, float timeOffset) { IReadOnlyList <KeyframeTpl <Float> > keyframes = curve.Curve; KeyframeTpl <Float> lhs = keyframes[lhsIndex]; int curveKeyIndex = lhsIndex; KeyframeTpl <Float> rhs = keyframes[rhsIndex]; float frameTime = lhs.Time + timeOffset; //TimeEnd = rhs.Time + timeOffset; float deltaTime = rhs.Time - lhs.Time; if (deltaTime < 0.00009999999747378752) { deltaTime = 0.000099999997f; } float deltaValue = rhs.Value.Value - lhs.Value.Value; float inverseTime = 1.0f / (deltaTime * deltaTime); float outTangent = lhs.OutSlope.Value * deltaTime; float inTangent = rhs.InSlope.Value * deltaTime; float curveKeyCoefX = (inTangent + outTangent - deltaValue - deltaValue) * inverseTime / deltaTime; float curveKeyCoefY = inverseTime * (deltaValue + deltaValue + deltaValue - outTangent - outTangent - inTangent); float curveKeyCoefZ = lhs.OutSlope.Value; float curveKeyValue = lhs.Value.Value; if (lhs.OutSlope.Value == float.PositiveInfinity || rhs.InSlope.Value == float.PositiveInfinity) { curveKeyCoefX = 0.0f; curveKeyCoefY = 0.0f; curveKeyCoefZ = 0.0f; curveKeyValue = lhs.Value.Value; } Vector3f curveKeyCoef = new Vector3f(curveKeyCoefX, curveKeyCoefY, curveKeyCoefZ); StreamedCurveKey curveKey = new StreamedCurveKey(curveKeyIndex, curveKeyValue, curveKeyCoef); return(curveKey); }
public AnimationCurveTpl(AnimationCurveTpl <T> copy) : this(copy.Curve) { PreInfinity = copy.PreInfinity; PostInfinity = copy.PostInfinity; RotationOrder = copy.RotationOrder; }
public FloatCurve(string path, string attribute, ClassIDType classID, PPtr <MonoScript> script, IReadOnlyList <KeyframeTpl <Float> > keyframes) { Path = path; Attribute = attribute; ClassID = classID; Script = script; Curve = new AnimationCurveTpl <Float>(keyframes); }
public FloatCurve(string path, string attribute, ClassIDType classID, PPtr <MonoScript> script) { Path = path; Attribute = attribute; ClassID = classID; Script = script; Curve = new AnimationCurveTpl <Float>(false); }
public FloatCurve(string path, IReadOnlyList <KeyframeTpl <Float> > keyframes) { Curve = new AnimationCurveTpl <Float>(keyframes); Attribute = string.Empty; Path = path; ClassID = 0; Script = default; }
public static void GenerateTypeTree(TypeTreeContext context, string name) { context.AddNode(nameof(Vector3Curve), name); context.BeginChildren(); AnimationCurveTpl <Vector3f> .GenerateTypeTree(context, name, Vector3f.GenerateTypeTree); context.AddString(PathName); context.EndChildren(); }
public static void GenerateTypeTree(TypeTreeContext context, string name) { context.AddNode(nameof(QuaternionCurve), name); context.BeginChildren(); AnimationCurveTpl <Quaternionf> .GenerateTypeTree(context, CurveName, Quaternionf.GenerateTypeTree); context.AddString(PathName); context.EndChildren(); }
public static void GenerateTypeTree(TypeTreeContext context, string name) { context.AddNode(nameof(PPtrCurve), name); context.BeginChildren(); AnimationCurveTpl <Float> .GenerateTypeTree(context, name, Float.GenerateTypeTree); context.AddString(AttributeName); context.AddString(PathName); context.AddNode(TypeTreeUtils.TypeStarName, ClassIDName, sizeof(int)); context.AddPPtr(nameof(MonoScript), ScriptName); context.EndChildren(); }
public QuaternionCurve Unpack() { int[] timesValues = Times.Unpack(); float[] times = new float[timesValues.Length]; for (int i = 0; i < times.Length; i++) { times[i] = timesValues[i] * 0.01f; } Quaternionf[] rotations = Values.Unpack(); float[] slopes = Slopes.Unpack(); KeyframeTpl <Quaternionf>[] keyframes = new KeyframeTpl <Quaternionf> [rotations.Length]; for (int i = 0, j = 4; i < rotations.Length; i++, j += 4) { float time = times[i]; Quaternionf rotation = rotations[i]; Quaternionf inSlope = new Quaternionf(slopes[j - 4], slopes[j - 3], slopes[j - 2], slopes[j - 1]); Quaternionf outSlope = new Quaternionf(slopes[j + 0], slopes[j + 1], slopes[j + 2], slopes[j + 3]); keyframes[i] = new KeyframeTpl <Quaternionf>(time, rotation, inSlope, outSlope, KeyframeTpl <Quaternionf> .DefaultQuaternionWeight); } AnimationCurveTpl <Quaternionf> curve = new AnimationCurveTpl <Quaternionf>(keyframes, PreInfinity, PostInfinity); return(new QuaternionCurve(Path, curve)); }
public Vector3Curve(string path, IReadOnlyList <KeyframeTpl <Vector3f> > keyframes) { Path = path; Curve = new AnimationCurveTpl <Vector3f>(keyframes); }
public Vector3Curve(string path) { Path = path; Curve = new AnimationCurveTpl <Vector3f>(false); }
public QuaternionCurve(string path, AnimationCurveTpl <Quaternionf> curve) { Path = path; Curve = curve; }
public QuaternionCurve(string path, IReadOnlyList <KeyframeTpl <Quaternionf> > keyframes) { Path = path; Curve = new AnimationCurveTpl <Quaternionf>(keyframes); }
public QuaternionCurve(string path) { Path = path; Curve = new AnimationCurveTpl <Quaternionf>(false); }