/// <summary> /// Stretches or compresses all frames of the animation to fit a new frame count. /// </summary> public void Resize(int newFrameCount) { KeyframeEntry kfe = null; float ratio = (float)newFrameCount / (float)FrameCount; foreach (SRT0EntryNode n in Children) { foreach (SRT0TextureNode e in n.Children) { KeyframeCollection newCollection = new KeyframeCollection(5, newFrameCount + (Loop ? 1 : 0), 1, 1); for (int x = 0; x < FrameCount; x++) { int newFrame = (int)((float)x * ratio + 0.5f); float frameRatio = newFrame == 0 ? 0 : (float)x / (float)newFrame; for (int i = 0; i < 5; i++) { if ((kfe = e.GetKeyframe(i, x)) != null) { newCollection.SetFrameValue(i, newFrame, kfe._value)._tangent = kfe._tangent * (float.IsNaN(frameRatio) ? 1 : frameRatio); } } } e._keyframes = newCollection; } } FrameCount = newFrameCount; }
public KeyframeEntry SetKeyframe(int arrayIndex, int index, float value) { bool exists = Keyframes.GetKeyframe(arrayIndex, index) != null; KeyframeEntry k = Keyframes.SetFrameValue(arrayIndex, index, value); if (!exists && !_generateTangents) { k.GenerateTangent(); } if (_generateTangents) { k.GenerateTangent(); k._prev.GenerateTangent(); k._next.GenerateTangent(); } SignalPropertyChange(); return(k); }
/// <summary> /// Stretches or compresses all frames of the animation to fit a new frame count. /// </summary> public void Resize(int newFrameCount) { KeyframeEntry kfe = null; float ratio = (float)newFrameCount / (float)FrameCount; foreach (CHR0EntryNode e in Children) { KeyframeCollection newCollection = new KeyframeCollection(newFrameCount); for (int x = 0; x < FrameCount; x++) { int newFrame = (int)((float)x * ratio + 0.5f); float frameRatio = newFrame == 0 ? 0 : (float)x / (float)newFrame; for (int i = 0x10; i < 0x19; i++) { if ((kfe = e.GetKeyframe((KeyFrameMode)i, x)) != null) { newCollection.SetFrameValue((KeyFrameMode)i, newFrame, kfe._value)._tangent = kfe._tangent * (float.IsNaN(frameRatio) ? 1 : frameRatio); } } } e._keyframes = newCollection; } FrameCount = newFrameCount; }