Exemple #1
0
        public void AddKey(float time, ref Vector3 vp, ref Quaternion vr, ref Vector3 vs, GOECurvInterpolationType pt = GOECurvInterpolationType.Linear, GOECurvInterpolationType rt = GOECurvInterpolationType.Linear, GOECurvInterpolationType st = GOECurvInterpolationType.Linear)
        {
            GOECurvKeyFrame kf = new GOECurvKeyFrame();

            kf.Time     = time;
            kf.Position = vp;
            kf.Rotation = vr;
            kf.Scale    = vs;
            kf.PositionInterpolationType = pt;
            kf.RotationInterpolationType = rt;
            kf.ScaleInterpolationType    = st;

            int left, right;
            GOECurveFindIndexResults b = FindIndexByTime(time, out left, out right);

            if (b == GOECurveFindIndexResults.AfterAllKeyFrame || b == GOECurveFindIndexResults.FailedNoKeyFrame)
            {
                keyFrames.Add(kf);
            }
            else if (b == GOECurveFindIndexResults.BeforeAllKeyFrame)
            {
                KeyFrames.Insert(0, kf);
            }
            else
            {
                keyFrames.Insert(left + 1, kf);
            }

            if (EditorGameObject)
            {
                kf.EnsureEditorGO(EditorGameObject);
                UnityEditor.Selection.activeGameObject = kf.EditorGameObject;
            }
        }
Exemple #2
0
        public void SampleByTime(float t, out Vector3 pos, out Quaternion q, out Vector3 s)
        {
            int left = 0, right = 0;

            pos = Vector3.zero;
            q   = Quaternion.identity;
            s   = Vector3.one;
            GOECurveFindIndexResults b = FindIndexByTime(t, out left, out right);

            if (b > GOECurveFindIndexResults.FailedNoKeyFrame)
            {
                GOECurvKeyFrame          l          = keyFrames[left];
                GOECurvKeyFrame          r          = keyFrames[right];
                GOECurvInterpolationType interpMode = l.PositionInterpolationType;
                pos = SampleKeyByTime(t, l, r, interpMode, l.Position, r.Position);

                interpMode = l.RotationInterpolationType;

                if (interpMode == GOECurvInterpolationType.Const || left == right)
                {
                    q = l.Rotation;
                }
                else if (interpMode == GOECurvInterpolationType.Linear)
                {
                    Quaternion ql, qr;
                    ql = l.Rotation;
                    qr = r.Rotation;
                    q  = Quaternion.Slerp(ql, qr, (t - l.Time) / (r.Time - l.Time));
                }

                interpMode = l.ScaleInterpolationType;
                s          = SampleKeyByTime(t, l, r, interpMode, l.Scale, r.Scale);
            }
        }
Exemple #3
0
        public void MoveKey(int keyIdx, float time)
        {
            GOECurvKeyFrame kf = keyFrames[keyIdx];

            kf.Time = time;
            keyFrames.RemoveAt(keyIdx);

            int left, right;
            GOECurveFindIndexResults b = FindIndexByTime(time, out left, out right);

            if (b == GOECurveFindIndexResults.AfterAllKeyFrame || b == GOECurveFindIndexResults.FailedNoKeyFrame)
            {
                keyFrames.Add(kf);
            }
            else
            {
                keyFrames.Insert(left + 1, kf);
            }
        }