Ejemplo n.º 1
0
        public void Compute(Frame frame)
        {
            Frame current  = frame;
            Frame previous = Module.GetPreviousKey(current);
            Frame next     = Module.GetNextKey(current);

            if (Module.IsKey(frame))
            {
                Values[current.Index - 1] = GetValue(current);

                if (previous != frame)
                {
                    float valA = GetValue(previous);
                    float valB = GetValue(current);
                    for (int i = previous.Index; i < current.Index; i++)
                    {
                        float weight = (float)(i - previous.Index) / (float)(frame.Index - previous.Index);
                        Values[i - 1] = (1f - weight) * valA + weight * valB;
                    }
                }

                if (next != frame)
                {
                    float valA = GetValue(current);
                    float valB = GetValue(next);
                    for (int i = current.Index + 1; i <= next.Index; i++)
                    {
                        float weight = (float)(i - current.Index) / (float)(next.Index - current.Index);
                        Values[i - 1] = (1f - weight) * valA + weight * valB;
                    }
                }
            }
            else
            {
                float valA = GetValue(previous);
                float valB = GetValue(next);
                for (int i = previous.Index; i <= next.Index; i++)
                {
                    float weight = (float)(i - previous.Index) / (float)(next.Index - previous.Index);
                    Values[i - 1] = (1f - weight) * valA + weight * valB;
                }
            }
        }