internal static void UpdateTangentsFromMode(MovieCurve curve) { for (int i = 0; i < curve.curve.length; i++) { TangentUtility.Internal_UpdateTangents(curve, i); } }
internal static void SetKeyRightTangentMode(ref MovieCurve curve, int index, TangentUtility.TangentMode tangentMode) { int curTangentMode = curve.GetTangentMode(index); curTangentMode &= ~TangentUtility.kRightTangentMask; curTangentMode |= (int)((int)tangentMode << 5); curve.SetTangentMode(index, curTangentMode); }
internal static void UpdateTangentsFromModeSurrounding(MovieCurve curve, int index) { TangentUtility.Internal_UpdateTangents(curve, index - 2); TangentUtility.Internal_UpdateTangents(curve, index - 1); TangentUtility.Internal_UpdateTangents(curve, index); TangentUtility.Internal_UpdateTangents(curve, index + 1); TangentUtility.Internal_UpdateTangents(curve, index + 2); }
internal static XElement SerializeCurve(MovieCurve curve) { XElement elem = new XElement("MovieCurve", curve.keyframes.Select((key, i) => SerializeKeyframe(key, curve.GetTangentMode(i)))); elem.SetAttributeValue("name", curve.name); elem.SetAttributeValue("preWrapMode", (int)curve.curve.preWrapMode); elem.SetAttributeValue("postWrapMode", (int)curve.curve.postWrapMode); return(elem); }
public static void SetKeyBroken(MovieCurve curve, int index, bool broken) { if (curve == null) { throw new ArgumentNullException("curve"); } if (index < 0 || index >= curve.curve.length) { throw new ArgumentException("Index out of bounds."); } TangentUtility.SetKeyBroken(ref curve, index, broken); // curve.curve.MoveKey(index, key); TangentUtility.UpdateTangentsFromModeSurrounding(curve, index); }
internal static void SetKeyBroken(ref MovieCurve curve, int index, bool broken) { int curTangentMode = curve.GetTangentMode(index); if (broken) { curTangentMode |= TangentUtility.kBrokenMask; } else { curTangentMode &= ~TangentUtility.kBrokenMask; } curve.SetTangentMode(index, curTangentMode); }
private static void Internal_UpdateTangents(MovieCurve movieCurve, int index) { AnimationCurve curve = movieCurve.curve; if (index >= 0 && index < curve.length) { Keyframe key = curve[index]; var leftTang = TangentUtility.GetKeyLeftTangentMode(movieCurve, index); var rightTang = TangentUtility.GetKeyRightTangentMode(movieCurve, index); if (leftTang == TangentUtility.TangentMode.Linear && index >= 1) { key.inTangent = TangentUtility.Internal_CalculateLinearTangent(curve, index, index - 1); curve.MoveKey(index, key); } if (rightTang == TangentUtility.TangentMode.Linear && index + 1 < curve.length) { key.outTangent = TangentUtility.Internal_CalculateLinearTangent(curve, index, index + 1); curve.MoveKey(index, key); } // if (TangentUtility.GetKeyLeftTangentMode(key) == TangentUtility.TangentMode.ClampedAuto || TangentUtility.GetKeyRightTangentMode(key) == TangentUtility.TangentMode.ClampedAuto) // { // TangentUtility.Internal_CalculateAutoTangent(curve, index); // } if (leftTang == TangentUtility.TangentMode.Auto || rightTang == TangentUtility.TangentMode.Auto) { curve.SmoothTangents(index, 0f); } if (leftTang == TangentUtility.TangentMode.Free && rightTang == TangentUtility.TangentMode.Free && !TangentUtility.GetKeyBroken(movieCurve, index)) { key.outTangent = key.inTangent; curve.MoveKey(index, key); } if (leftTang == TangentUtility.TangentMode.Constant) { key.inTangent = float.PositiveInfinity; curve.MoveKey(index, key); } if (rightTang == TangentUtility.TangentMode.Constant) { key.outTangent = float.PositiveInfinity; curve.MoveKey(index, key); } } }
public static void SetKeyRightTangentMode(MovieCurve curve, int index, TangentUtility.TangentMode tangentMode) { if (curve == null) { throw new ArgumentNullException("curve"); } if (index < 0 || index >= curve.curve.length) { throw new ArgumentException("Index out of bounds."); } if (tangentMode != TangentUtility.TangentMode.Free) { TangentUtility.SetKeyBroken(curve, index, true); } TangentUtility.SetKeyRightTangentMode(ref curve, index, tangentMode); // curve.MoveKey(index, key); TangentUtility.UpdateTangentsFromModeSurrounding(curve, index); }
internal static MovieCurve DeserializeCurve(XElement elem) { MovieCurve curve = new MovieCurve(); var keys = from e in elem.Elements() select DeserializeKeyframe(e); curve.name = elem.Attribute("name").Value; curve.tangentModes = elem.Elements().Select(e => GetIntAttr(e, "tangentMode")).ToList(); AnimationCurve animCurve = new AnimationCurve(keys.ToArray()); animCurve.preWrapMode = (WrapMode)GetIntAttr(elem, "preWrapMode"); animCurve.postWrapMode = (WrapMode)GetIntAttr(elem, "postWrapMode"); curve.curve = animCurve; return(curve); }
internal static bool GetKeyBroken(MovieCurve curve, int index) { return((curve.GetTangentMode(index) & TangentUtility.kBrokenMask) != 0); }
internal static TangentUtility.TangentMode GetKeyRightTangentMode(MovieCurve curve, int index) { return((TangentUtility.TangentMode)((curve.GetTangentMode(index) & TangentUtility.kRightTangentMask) >> 5)); }