public void Smooth(Frame frame) { Frame previous = Module.GetPreviousKey(frame); Frame next = Module.GetNextKey(frame); float weight = (frame.Timestamp - previous.Timestamp) / (next.Timestamp - previous.Timestamp); float value = (1f - weight) * GetValue(previous) + weight * GetValue(next); SetValue(frame, value); }
public void Compute(Frame frame) { Frame current = frame; Frame previous = Module.GetPreviousKey(current); previous = previous == null?Module.Data.GetFrame(1) : previous; Frame next = Module.GetNextKey(current); next = next == null?Module.Data.GetFrame(Module.Data.GetTotalFrames()) : next; if (Module.IsKey(frame)) { //Current Frame Values[current.Index - 1] = GetValue(current); //Previous Frames 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; } } //Next Frames 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; } } }