public float CurveValue(KeyProperty prev, KeyProperty next, int frame, int prevFrame, int nextFrame) { Vector2 A = new Vector2(prevFrame, prev.value); Vector2 D = new Vector2(nextFrame, next.value); Vector2 B = A + new Vector2(prev.outTanX, prev.outTanY); Vector2 C = D - new Vector2(next.inTanX, next.inTanY); return(Bezier.EvaluateBezier(A, B, C, D, frame)); }
public static KeyFrame GetKey(AnimationSet set, int frame) { KeyProperty px = GetProperty(set, AnimatableProperty.PositionX, frame); KeyProperty py = GetProperty(set, AnimatableProperty.PositionY, frame); KeyProperty pz = GetProperty(set, AnimatableProperty.PositionZ, frame); KeyProperty rx = GetProperty(set, AnimatableProperty.RotationX, frame); KeyProperty ry = GetProperty(set, AnimatableProperty.RotationY, frame); KeyProperty rz = GetProperty(set, AnimatableProperty.RotationZ, frame); return(new KeyFrame() { frame = frame, posX = px, posY = py, posZ = pz, rotX = rx, rotY = ry, rotZ = rz }); }
private static KeyProperty GetProperty(AnimationSet set, AnimatableProperty property, int frame) { Curve curve = set.GetCurve(property); if (curve.GetKeyIndex(frame, out int index)) { KeyProperty key = new KeyProperty() { value = curve.keys[index].value, inTanX = curve.keys[index].inTangent.x, inTanY = curve.keys[index].inTangent.y, outTanX = curve.keys[index].outTangent.x, outTanY = curve.keys[index].outTangent.y }; return(key); } else { KeyProperty key = new KeyProperty(); return(key); } }