コード例 #1
0
ファイル: Layer.cs プロジェクト: qoh/TISFAT-Zero
        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));
        }
コード例 #2
0
ファイル: Frameset.cs プロジェクト: qoh/TISFAT-Zero
        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);
        }
コード例 #3
0
        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;
        }
コード例 #4
0
ファイル: Frameset.cs プロジェクト: qoh/TISFAT-Zero
        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);
        }
コード例 #5
0
ファイル: Keyframe.cs プロジェクト: qoh/TISFAT-Zero
 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;
 }
コード例 #6
0
ファイル: Frameset.cs プロジェクト: qoh/TISFAT-Zero
        public FramesetRemoveAction(Layer l, Frameset f)
        {
            LayerIndex    = Program.ActiveProject.Layers.IndexOf(l);
            FramesetIndex = l.Framesets.IndexOf(f);

            RemovedFrameset = f;
        }
コード例 #7
0
        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
        }
コード例 #8
0
ファイル: Frameset.cs プロジェクト: qoh/TISFAT-Zero
        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;
        }
コード例 #9
0
ファイル: Keyframe.cs プロジェクト: qoh/TISFAT-Zero
        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);
        }
コード例 #10
0
ファイル: Keyframe.cs プロジェクト: qoh/TISFAT-Zero
        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);
        }
コード例 #11
0
ファイル: Keyframe.cs プロジェクト: noshbar/TISFAT-Zero
        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);
        }
コード例 #12
0
        public void Clear()
        {
            Current = SelectionType.None;

            SelectedLayer     = null;
            SelectedFrameset  = null;
            SelectedKeyframe  = null;
            SelectedFrameTime = -1;
        }
コード例 #13
0
ファイル: Keyframe.cs プロジェクト: qoh/TISFAT-Zero
        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;
        }
コード例 #14
0
ファイル: Keyframe.cs プロジェクト: qoh/TISFAT-Zero
        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);
        }
コード例 #15
0
ファイル: Keyframe.cs プロジェクト: qoh/TISFAT-Zero
        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);
        }
コード例 #16
0
ファイル: Layer.cs プロジェクト: qoh/TISFAT-Zero
        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);
        }
コード例 #17
0
ファイル: Keyframe.cs プロジェクト: qoh/TISFAT-Zero
        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);
        }
コード例 #18
0
        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);
        }
コード例 #19
0
ファイル: Frameset.cs プロジェクト: qoh/TISFAT-Zero
        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);
        }
コード例 #20
0
ファイル: Keyframe.cs プロジェクト: qoh/TISFAT-Zero
        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);
        }
コード例 #21
0
ファイル: Keyframe.cs プロジェクト: qoh/TISFAT-Zero
        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);
        }
コード例 #22
0
ファイル: Frameset.cs プロジェクト: qoh/TISFAT-Zero
        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);
        }
コード例 #23
0
ファイル: Layer.cs プロジェクト: qoh/TISFAT-Zero
        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]);
        }
コード例 #24
0
ファイル: Keyframe.cs プロジェクト: noshbar/TISFAT-Zero
        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;
        }
コード例 #25
0
ファイル: Frameset.cs プロジェクト: noshbar/TISFAT-Zero
        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;
        }
コード例 #26
0
ファイル: Keyframe.cs プロジェクト: noshbar/TISFAT-Zero
 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;
 }
コード例 #27
0
ファイル: Frameset.cs プロジェクト: noshbar/TISFAT-Zero
        public FramesetRemoveAction(Layer l, Frameset f)
        {
            LayerIndex = Program.ActiveProject.Layers.IndexOf(l);
            FramesetIndex = l.Framesets.IndexOf(f);

            RemovedFrameset = f;
        }
コード例 #28
0
ファイル: Keyframe.cs プロジェクト: noshbar/TISFAT-Zero
        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);
        }
コード例 #29
0
ファイル: Frameset.cs プロジェクト: noshbar/TISFAT-Zero
        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;
        }