Esempio n. 1
0
        public KeyMap AddKey(double frame, double warpFrame)
        {
            KeyMap map = new KeyMap(frame, warpFrame);

            if (mKeys.Count == 0)
            {
                mKeys.Add(map);
            }
            else
            {
                KeyMap after = GetMapAfter(warpFrame);
                if (warpFrame < after.WarpKey)
                {
                    mKeys.Insert(after.Index, map);
                }
                else
                {
                    mKeys.Insert(after.Index + 1, map);
                }
            }

            SetIndices();

            return(map);
        }
Esempio n. 2
0
        public double GetWarped(double key)
        {
            KeyMap before = GetMapBefore(key);

            if (before.WarpKey == key)
            {
                return(before.RealKey);
            }

            KeyMap after = GetMapAfter(key);

            if (after.WarpKey == key)
            {
                return(after.RealKey);
            }

            if (before == after) //Out of bounds
            {
                if (after.Index == (int)(mKeys.Count - 1))
                {
                    return(before.RealKey + 1);
                }

                return(before.RealKey);
            }

            return(Blend(before.RealKey, after.RealKey, (key - before.WarpKey) / (after.WarpKey - before.WarpKey)));
        }
Esempio n. 3
0
        public void MoveKey(double frame, double warpFrame)
        {
            KeyMap after = GetClosest(frame);

            after.WarpKey = warpFrame;

            mKeys.Sort();
            SetIndices();
        }
Esempio n. 4
0
        public void RemoveKey(double warpFrame)
        {
            if (mKeys.Count > 2)
            {
                KeyMap after = GetClosest(warpFrame);
                mKeys.Remove(after);
            }

            SetIndices();
        }
Esempio n. 5
0
        private KeyMap GetMapBefore(double key)
        {
            KeyMap mapBefore = mKeys[0];

            foreach (KeyMap map in mKeys)
            {
                if (map.WarpKey > key)
                {
                    return(mapBefore);
                }

                mapBefore = map;
            }

            return(mapBefore);
        }
Esempio n. 6
0
        public KeyMap GetClosest(double key)
        {
            KeyMap before = GetMapBefore(key);

            if (before.WarpKey == key)
            {
                return(before);
            }

            KeyMap after = GetMapAfter(key);

            if (after.WarpKey == key)
            {
                return(after);
            }

            if (key - before.WarpKey < after.WarpKey - key)
            {
                return(before);
            }

            return(after);
        }