コード例 #1
0
 internal static void UpdateTangentsFromMode(MovieCurve curve)
 {
     for (int i = 0; i < curve.curve.length; i++)
     {
         TangentUtility.Internal_UpdateTangents(curve, i);
     }
 }
コード例 #2
0
        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);
        }
コード例 #3
0
 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);
 }
コード例 #4
0
        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);
        }
コード例 #5
0
 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);
 }
コード例 #6
0
        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);
        }
コード例 #7
0
        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);
                }
            }
        }
コード例 #8
0
 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);
 }
コード例 #9
0
        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);
        }
コード例 #10
0
 internal static bool GetKeyBroken(MovieCurve curve, int index)
 {
     return((curve.GetTangentMode(index) & TangentUtility.kBrokenMask) != 0);
 }
コード例 #11
0
 internal static TangentUtility.TangentMode GetKeyRightTangentMode(MovieCurve curve, int index)
 {
     return((TangentUtility.TangentMode)((curve.GetTangentMode(index) & TangentUtility.kRightTangentMask) >> 5));
 }