private void CropAt(float delta, float time) { var keyframeOps = new KeyframesOperation(_clip); foreach (var target in _clip.GetAllTargets()) { // TODO: Create new keyframe if missing from evaluate curve var snapshots = target .GetAllKeyframesTime() .Where(t => t < time || t >= time - delta) .Select(t => { var newTime = t < time ? t : t + delta; return(new SnapshotAt { time = newTime, snapshot = target.GetSnapshot(t) }); }) .ToList(); keyframeOps.RemoveAll(target, true); foreach (var s in snapshots) { target.SetSnapshot(s.time, s.snapshot); } target.AddEdgeFramesIfMissing(_clip.animationLength); } }
public void Loop(float newAnimationLength) { var keyframeOps = new KeyframesOperation(_clip); var originalAnimationLength = _clip.animationLength; _clip.animationLength = newAnimationLength; foreach (var target in _clip.GetAllTargets()) { var snapshots = target .GetAllKeyframesTime() .Select(t => new SnapshotAt { time = t, snapshot = target.GetSnapshot(t) }) .ToList(); snapshots.RemoveAt(snapshots.Count - 1); keyframeOps.RemoveAll(target, true); float time = 0f; var iteration = 0; var i = 0; while (true) { var snapshot = snapshots[i++]; time = snapshot.time + (iteration * originalAnimationLength); if (time > newAnimationLength) { break; } target.SetSnapshot(time, snapshot.snapshot); if (i >= snapshots.Count) { i = 0; iteration++; } } target.AddEdgeFramesIfMissing(_clip.animationLength); } }
public void Stretch(float newAnimationLength) { var keyframeOps = new KeyframesOperation(_clip); var originalAnimationLength = _clip.animationLength; _clip.animationLength = newAnimationLength; var ratio = newAnimationLength / originalAnimationLength; foreach (var target in _clip.GetAllTargets()) { var snapshots = target .GetAllKeyframesTime() .Select(t => new SnapshotAt { time = t, snapshot = target.GetSnapshot(t) }) .ToList(); keyframeOps.RemoveAll(target, true); foreach (var s in snapshots) { target.SetSnapshot((s.time * ratio).Snap(), s.snapshot); } } }
private void ExtendAt(float delta, float time) { var keyframeOps = new KeyframesOperation(_clip); var originalAnimationLength = _clip.animationLength; foreach (var target in _clip.GetAllTargets()) { // TODO: Create new keyframe if missing from evaluate curve var snapshots = target .GetAllKeyframesTime() .Select(t => new SnapshotAt { time = t < time ? t : t + delta, snapshot = target.GetSnapshot(t) }) .ToList(); keyframeOps.RemoveAll(target, true); foreach (var s in snapshots) { target.SetSnapshot(s.time, s.snapshot); } target.AddEdgeFramesIfMissing(_clip.animationLength); } }