public IEntityState FindCurrentState(float time) { if (!Visible || Data == null) { // die; return(null); } Frameset frameset = FindFrameset(time); if (frameset == null) { return(null); } int nextIndex; for (nextIndex = 1; nextIndex < frameset.Keyframes.Count; nextIndex++) { if (frameset.Keyframes[nextIndex].Time >= time) { break; } } Keyframe current = frameset.Keyframes[nextIndex - 1]; Keyframe target = frameset.Keyframes[nextIndex]; float t = (time - current.Time) / (target.Time - current.Time); return(Data.Interpolate(t, current.State, target.State, current.InterpMode)); }
public bool Undo() { Layer SelectedLayer = Program.ActiveProject.Layers[LayerIndex]; SelectedLayer.Framesets.Insert(FramesetIndex, RemovedFrameset); SelectedLayer.Framesets = SelectedLayer.Framesets.OrderBy(o => o.EndTime).ToList(); Frameset SelectedFrameset = SelectedLayer.Framesets[FramesetIndex]; Program.MainTimeline.ClearSelection(); Program.MainTimeline.selectedItems.Select(SelectedLayer, SelectedFrameset); if (PrevSelectedKeyframe != -1) { Program.MainTimeline.selectedItems.Select(SelectedFrameset.Keyframes[PrevSelectedKeyframe]); } else { Program.MainTimeline.selectedItems.Select(SelectionType.BlankFrame, PrevSelectedIndex); } Program.MainTimeline.GLContext.Invalidate(); return(true); }
public void Clear(SelectionType type) { switch (type) { case SelectionType.Layer: SelectedLayer = null; SelectedFrameset = null; SelectedKeyframe = null; SelectedFrameTime = -1; break; case SelectionType.Frameset: SelectedFrameset = null; SelectedKeyframe = null; SelectedFrameTime = -1; break; case SelectionType.Keyframe: SelectedKeyframe = null; break; case SelectionType.BlankFrame: SelectedFrameTime = -1; break; case SelectionType.NullFrame: SelectedFrameTime = -1; break; default: throw new ArgumentException("Unrecognized enum type!"); } Current &= ~type; }
public bool Undo() { Layer currentLayer = Program.ActiveProject.Layers[LayerIndex]; Frameset currentFrameset = currentLayer.Framesets[FramesetIndex]; // Move by -MoveAmount only if it hasn't already been moved there if (currentFrameset.Keyframes[0].Time == endMoveLocation) { int MoveAmount = endMoveLocation - startMoveLocation; foreach (Keyframe frame in currentFrameset.Keyframes) { frame.Time = (uint)(frame.Time - MoveAmount); } currentLayer.Framesets = currentLayer.Framesets.OrderBy(o => o.EndTime).ToList(); Program.MainTimeline.ClearSelection(); Program.MainTimeline.selectedItems.Select(currentLayer, currentFrameset, currentFrameset.Keyframes[0]); Program.MainTimeline.GLContext.Invalidate(); } return(true); }
public KeyframeChangeInterpModeAction(Layer l, Frameset f, Keyframe frame, EntityInterpolationMode target) { LayerIndex = Program.ActiveProject.Layers.IndexOf(l); FramesetIndex = l.Framesets.IndexOf(f); KeyframeIndex = f.Keyframes.IndexOf(frame); TargetMode = target; }
public FramesetRemoveAction(Layer l, Frameset f) { LayerIndex = Program.ActiveProject.Layers.IndexOf(l); FramesetIndex = l.Framesets.IndexOf(f); RemovedFrameset = f; }
public Tuple <int, Frameset, Keyframe> FindAtTime(int time) { Frameset frameset = null; Keyframe frame = null; foreach (Frameset f in SelectedLayer.Framesets) { if (f.StartTime <= time && f.EndTime >= time) { frameset = f; break; } } if (frameset == null) { return(new Tuple <int, Frameset, Keyframe>(0, null, null)); // null frame } foreach (Keyframe k in frameset.Keyframes) { if (k.Time == time) { frame = k; break; } } if (frame == null) { return(new Tuple <int, Frameset, Keyframe>(1, frameset, null)); // blank frame } return(new Tuple <int, Frameset, Keyframe>(2, frameset, frame)); // keyframe }
public FramesetMoveAction(Layer l, Frameset f, int startLocation, int endLocation) { LayerIndex = Program.ActiveProject.Layers.IndexOf(l); FramesetIndex = l.Framesets.IndexOf(f); startMoveLocation = startLocation; endMoveLocation = endLocation; }
public KeyframeRemoveAction(Layer layer, Frameset frameset, Keyframe frame) { LayerIndex = Program.ActiveProject.Layers.IndexOf(layer); FramesetIndex = layer.Framesets.IndexOf(frameset); RemovedKeyframe = frame; RemovedKeyframeIndex = frameset.Keyframes.IndexOf(RemovedKeyframe); }
public KeyframeAddAction(Layer l, Frameset f, uint targ, IEntityState start, IEntityState end, float interpolation) { LayerIndex = Program.ActiveProject.Layers.IndexOf(l); FramesetIndex = l.Framesets.IndexOf(f); Time = targ; State = start.Interpolate(end, interpolation); }
public void Clear() { Current = SelectionType.None; SelectedLayer = null; SelectedFrameset = null; SelectedKeyframe = null; SelectedFrameTime = -1; }
public KeyframeMoveAction(Layer layer, Frameset frameset, Keyframe frame, uint time) { LayerIndex = Program.ActiveProject.Layers.IndexOf(layer); FramesetIndex = layer.Framesets.IndexOf(frameset); KeyframeIndex = frameset.Keyframes.IndexOf(frame); TargetKeyframe = frame; OriginalTime = time; NewTime = frame.Time; }
public bool Undo() { Frameset TargetFrameset = Program.ActiveProject.Layers[LayerIndex].Framesets[FramesetIndex]; TargetKeyframe.Time = OriginalTime; TargetFrameset.Keyframes = TargetFrameset.Keyframes.OrderBy(o => o.Time).ToList(); Program.MainTimeline.ClearSelection(); Program.MainTimeline.selectedItems.Select(Program.ActiveProject.Layers[LayerIndex], TargetFrameset, TargetKeyframe); Program.MainTimeline.GLContext.Invalidate(); return(true); }
public bool Do() { Frameset TargetFrameset = Program.ActiveProject.Layers[LayerIndex].Framesets[FramesetIndex]; TargetFrameset.Keyframes.RemoveAt(RemovedKeyframeIndex); TargetFrameset.Keyframes = TargetFrameset.Keyframes.OrderBy(o => o.Time).ToList(); Program.MainTimeline.selectedItems.Clear(SelectionType.Keyframe); Program.MainTimeline.selectedItems.Select(SelectionType.BlankFrame, (int)RemovedKeyframe.Time); Program.MainTimeline.GLContext.Invalidate(); return(true); }
public Frameset FindFrameset(float time) { for (int i = 0; i < Framesets.Count; i++) { Frameset currentSet = Framesets[i]; if (time >= currentSet.StartTime && time <= currentSet.EndTime) { return(currentSet); } } return(null); }
public bool Undo() { Layer TargetLayer = Program.ActiveProject.Layers[LayerIndex]; Frameset TargetFrameset = TargetLayer.Framesets[FramesetIndex]; TargetFrameset.Keyframes.RemoveAt(AddedFrameIndex); Program.MainTimeline.ClearSelection(); Program.MainTimeline.selectedItems.Select(SelectionType.BlankFrame, PrevSelectedFrame); AddedFrame = null; PrevSelectedFrame = -1; Program.MainTimeline.GLContext.Invalidate(); return(true); }
public void Select(params ISaveable[] objs) { foreach (ISaveable obj in objs) { SelectionType type = SelectionType.None; if (obj.GetType() == typeof(Layer)) { SelectedLayer = obj as Layer; type = SelectionType.Layer; } else if (obj.GetType() == typeof(Frameset)) { SelectedFrameset = obj as Frameset; type = SelectionType.Frameset; } else if (obj.GetType() == typeof(Keyframe)) { SelectedKeyframe = obj as Keyframe; type = SelectionType.Keyframe; if ((SelectionType.BlankFrame & Current) != 0) { Current &= ~SelectionType.BlankFrame; } if ((SelectionType.NullFrame & Current) != 0) { Current &= ~SelectionType.NullFrame; } Program.Form_Canvas.UpdateStickFigurePair(); Program.Form_Properties.UpdateStickFigurePanel(); } else { throw new ArgumentException("Attempting to select an unknown type!"); } if ((type & Current) == 0) { Current |= type; } } Program.Form_Properties.SelectionChanged(Current); }
public bool Do() { PrevSelectedIndex = Program.MainTimeline.selectedTime; PrevSelectedKeyframe = Program.MainTimeline.SelectedKeyframe == null ? -1 : RemovedFrameset.Keyframes.IndexOf(Program.MainTimeline.SelectedKeyframe); Layer SelectedLayer = Program.ActiveProject.Layers[LayerIndex]; Frameset SelectedFrameset = SelectedLayer.Framesets[FramesetIndex]; SelectedLayer.Framesets.RemoveAt(FramesetIndex); SelectedLayer.Framesets = SelectedLayer.Framesets.OrderBy(o => o.EndTime).ToList(); Program.MainTimeline.ClearSelection(); Program.MainTimeline.selectedItems.Select(SelectedLayer, SelectedFrameset); Program.MainTimeline.GLContext.Invalidate(); return(true); }
public bool Do() { Frameset TargetFrameset = Program.ActiveProject.Layers[LayerIndex].Framesets[FramesetIndex]; if (TargetFrameset.Keyframes.IndexOf(TargetKeyframe) == -1) { TargetFrameset.Keyframes.Insert(KeyframeIndex, TargetKeyframe); } TargetKeyframe.Time = NewTime; TargetFrameset.Keyframes = TargetFrameset.Keyframes.OrderBy(o => o.Time).ToList(); Program.MainTimeline.ClearSelection(); Program.MainTimeline.selectedItems.Select(Program.ActiveProject.Layers[LayerIndex], TargetFrameset, TargetKeyframe); Program.MainTimeline.GLContext.Invalidate(); return(true); }
public bool Do() { Layer TargetLayer = Program.ActiveProject.Layers[LayerIndex]; Frameset TargetFrameset = TargetLayer.Framesets[FramesetIndex]; AddedFrame = new Keyframe(Time, State.Copy(), EntityInterpolationMode.Linear); PrevSelectedFrame = Program.MainTimeline.selectedTime; Program.MainTimeline.ClearSelection(); Program.MainTimeline.selectedItems.Select(TargetLayer, TargetFrameset, AddedFrame); TargetFrameset.Keyframes.Add(AddedFrame); TargetFrameset.Keyframes = TargetFrameset.Keyframes.OrderBy(o => o.Time).ToList(); AddedFrameIndex = TargetFrameset.Keyframes.IndexOf(AddedFrame); Program.MainTimeline.GLContext.Invalidate(); return(true); }
public bool Do() { Layer SelectedLayer = Program.ActiveProject.Layers[LayerIndex]; Frameset fs = new Frameset(); fs.Keyframes.Add(new Keyframe((uint)PrevSelectedIndex, SelectedLayer.Data.CreateRefState(), EntityInterpolationMode.Linear)); fs.Keyframes.Add(new Keyframe((uint)PrevSelectedIndex + 1, SelectedLayer.Data.CreateRefState(), EntityInterpolationMode.Linear)); SelectedLayer.Framesets.Add(fs); SelectedLayer.Framesets = SelectedLayer.Framesets.OrderBy(o => o.EndTime).ToList(); FramesetIndex = SelectedLayer.Framesets.IndexOf(fs); Program.MainTimeline.ClearSelection(); Program.MainTimeline.selectedItems.Select(SelectedLayer, fs, fs.Keyframes[0]); Program.MainTimeline.GLContext.Invalidate(); return(true); }
public Keyframe FindPrevKeyframe(float time) { Frameset frameset = FindFrameset(time); if (frameset == null) { return(null); } int nextIndex; for (nextIndex = 1; nextIndex < frameset.Keyframes.Count; nextIndex++) { if (frameset.Keyframes[nextIndex].Time >= time) { break; } } return(frameset.Keyframes[nextIndex - 1]); }
public bool Do() { Layer SelectedLayer = Program.ActiveProject.Layers[LayerIndex]; Frameset fs = new Frameset(); fs.Keyframes.Add(new Keyframe((uint)PrevSelectedIndex, SelectedLayer.Data.CreateRefState(), EntityInterpolationMode.Linear)); fs.Keyframes.Add(new Keyframe((uint)PrevSelectedIndex + 1, SelectedLayer.Data.CreateRefState(), EntityInterpolationMode.Linear)); SelectedLayer.Framesets.Add(fs); SelectedLayer.Framesets = SelectedLayer.Framesets.OrderBy(o => o.EndTime).ToList(); FramesetIndex = SelectedLayer.Framesets.IndexOf(fs); Program.MainTimeline.ClearSelection(); Program.MainTimeline.selectedItems.Select(SelectedLayer, fs, fs.Keyframes[0]); Program.MainTimeline.GLContext.Invalidate(); return true; }