Exemplo n.º 1
0
        public virtual void Nudge(ref CompoundCommand cmds, NudgeDirection direction, float timeDelta, float valueDelta)
        {
            foreach (var kf in KeyframeViews)
            {
                if (kf.Model.Selected.Value)
                {
                    switch (direction)
                    {
                    case NudgeDirection.Back:
                        cmds.Append(Command.Set(kf.Model.Time, kf.Model.Time.Value - timeDelta));
                        break;

                    case NudgeDirection.Forward:
                        cmds.Append(Command.Set(kf.Model.Time, kf.Model.Time.Value + timeDelta));
                        break;
                    }
                }
            }
        }
    public IEnumerator Nudge(NudgeDirection _nudgeDirection)
    {
        // if we're already nudging left, don't add another over the top
        if (nudgeDirection == _nudgeDirection || _nudgeDirection == NudgeDirection.NONE)
            yield break;

        // start nudging left
        nudgeDirection = _nudgeDirection;
        nudging = true;
        Vector3 nudgeVector = Vector3.zero;
        switch (nudgeDirection) {
        case NudgeDirection.LEFT:
            nudgeVector = Vector3.left;
            break;
        case NudgeDirection.RIGHT:
            nudgeVector = Vector3.right;
            break;
        case NudgeDirection.UP:
            nudgeVector = Vector3.up;
            break;
        case NudgeDirection.DOWN:
            nudgeVector = Vector3.down;
            break;
        }
        nudgeVector = .1f * (targetRotation * nudgeVector);

        for (float i = 0.2f; i < 1f; i+=0.2f) {
            // make sure nobody else has nudged us another way
            if (nudgeDirection == _nudgeDirection) {
                nudge = nudgeVector * (Mathf.Sin (Mathf.PI * i));
                yield return null;
            } else {
                // if a different direction has started, stop this one
                yield break;
            }
        }

        // if we get here uninterrupted, finish the nudging so another left could start
        nudgeDirection = NudgeDirection.NONE;
        nudging = false;
        nudge = Vector3.zero;
    }
Exemplo n.º 3
0
        public override void Nudge(ref CompoundCommand cmds, NudgeDirection direction, float timeDelta, float valueDelta)
        {
            base.Nudge(ref cmds, direction, timeDelta, valueDelta);

            foreach (var kf in Keyframes.Where(x => x.Model.Selected.Value))
            {
                switch (direction)
                {
                case NudgeDirection.Up:
                    var newValue = (float)VMath.Clamp(kf.Model.Value.Value + valueDelta, Model.Minimum.Value, Model.Maximum.Value);
                    cmds.Append(Command.Set(kf.Model.Value, newValue));
                    break;

                case NudgeDirection.Down:
                    newValue = (float)VMath.Clamp(kf.Model.Value.Value - valueDelta, Model.Minimum.Value, Model.Maximum.Value);
                    cmds.Append(Command.Set(kf.Model.Value, newValue));
                    break;
                }
            }
        }
Exemplo n.º 4
0
 public NudgeNode(XmlTreeView view, XmlTreeNode node, NudgeDirection dir)
 {
     this.node = node;
     this.dir = dir;
     this.view = view;
 }
Exemplo n.º 5
0
        void Nudge(NudgeDirection direction, bool shift, bool ctrl, bool alt)
        {
            var timeDelta = 1f/Timeliner.Timer.FPS;
            var valueDelta = 0.01f;

            if (shift)
                timeDelta *= Timeliner.Timer.FPS; //to nudge a whole second

            var step = alt ? 10f : 0.1f;
            if (shift)
                valueDelta *= step;
            if (ctrl)
                valueDelta *= step;

            var kfSelected = false;
            foreach(var track in Timeliner.TimelineView.Tracks)
            {
                kfSelected = track.KeyframeViews.Any(kf => kf.Model.Selected.Value);
                if (kfSelected)
                    break;
            }

            if (kfSelected)
            {
                var cmds = new CompoundCommand();
                foreach(var track in Timeliner.TimelineView.Tracks)
                    track.Nudge(ref cmds, direction, timeDelta, valueDelta);
                Context.History.Insert(cmds);
            }
            else
            {
                var currentTime = Timeliner.Timer.Time;
                switch (direction)
                {
                    case NudgeDirection.Back:
                        Timeliner.Timer.Time -= timeDelta;
                        break;
                    case NudgeDirection.Forward:
                        Timeliner.Timer.Time += timeDelta;
                        break;
                    case NudgeDirection.Up:
                        //find next kf
                        var nextKeyframe = Timeliner.TimelineView.Tracks.SelectMany(track => track.KeyframeViews).OrderBy(kf => kf.Model.Time.Value).First(kf => kf.Model.Time.Value > currentTime);
                        if (nextKeyframe != null)
                            Timeliner.Timer.Time = nextKeyframe.Model.Time.Value;
                        break;
                    case NudgeDirection.Down:
                        //find prev kf
                        var lastKeyframe = Timeliner.TimelineView.Tracks.SelectMany(track => track.KeyframeViews).OrderByDescending(kf => kf.Model.Time.Value).First(kf => kf.Model.Time.Value < currentTime);
                        if (lastKeyframe != null)
                            Timeliner.Timer.Time = lastKeyframe.Model.Time.Value;
                        break;
                }
            }
        }
Exemplo n.º 6
0
        void Nudge(NudgeDirection direction, bool shift, bool ctrl, bool alt)
        {
            var timeDelta  = 1f / Timeliner.Timer.FPS;
            var valueDelta = 0.01f;

            if (shift)
            {
                timeDelta *= Timeliner.Timer.FPS; //to nudge a whole second
            }
            var step = alt ? 10f : 0.1f;

            if (shift)
            {
                valueDelta *= step;
            }
            if (ctrl)
            {
                valueDelta *= step;
            }

            var kfSelected = false;

            foreach (var track in Timeliner.TimelineView.Tracks)
            {
                kfSelected = track.KeyframeViews.Any(kf => kf.Model.Selected.Value);
                if (kfSelected)
                {
                    break;
                }
            }

            if (kfSelected)
            {
                var cmds = new CompoundCommand();
                foreach (var track in Timeliner.TimelineView.Tracks)
                {
                    track.Nudge(ref cmds, direction, timeDelta, valueDelta);
                }
                Context.History.Insert(cmds);
            }
            else
            {
                var currentTime = Timeliner.Timer.Time;
                switch (direction)
                {
                case NudgeDirection.Back:
                    Timeliner.Timer.Time -= timeDelta;
                    break;

                case NudgeDirection.Forward:
                    Timeliner.Timer.Time += timeDelta;
                    break;

                case NudgeDirection.Up:
                    //find next kf
                    var nextKeyframe = Timeliner.TimelineView.Tracks.SelectMany(track => track.KeyframeViews).OrderBy(kf => kf.Model.Time.Value).First(kf => kf.Model.Time.Value > currentTime);
                    if (nextKeyframe != null)
                    {
                        Timeliner.Timer.Time = nextKeyframe.Model.Time.Value;
                    }
                    break;

                case NudgeDirection.Down:
                    //find prev kf
                    var lastKeyframe = Timeliner.TimelineView.Tracks.SelectMany(track => track.KeyframeViews).OrderByDescending(kf => kf.Model.Time.Value).First(kf => kf.Model.Time.Value < currentTime);
                    if (lastKeyframe != null)
                    {
                        Timeliner.Timer.Time = lastKeyframe.Model.Time.Value;
                    }
                    break;
                }
            }
        }
Exemplo n.º 7
0
        public override void Nudge(ref CompoundCommand cmds, NudgeDirection direction, float timeDelta, float valueDelta)
        {
            base.Nudge(ref cmds, direction, timeDelta, valueDelta);

            foreach(var kf in Keyframes.Where(x => x.Model.Selected.Value))
            {
                switch (direction)
                {
                    case NudgeDirection.Up:
                        var newValue = (float) VMath.Clamp(kf.Model.Value.Value + valueDelta, Model.Minimum.Value, Model.Maximum.Value);
                        cmds.Append(Command.Set(kf.Model.Value, newValue));
                        break;
                    case NudgeDirection.Down:
                        newValue = (float) VMath.Clamp(kf.Model.Value.Value - valueDelta, Model.Minimum.Value, Model.Maximum.Value);
                        cmds.Append(Command.Set(kf.Model.Value, newValue));
                        break;
                }
            }
        }
Exemplo n.º 8
0
 public virtual void Nudge(ref CompoundCommand cmds, NudgeDirection direction, float timeDelta, float valueDelta)
 {
     foreach(var kf in KeyframeViews)
     {
         if (kf.Model.Selected.Value)
             switch (direction)
         {
             case NudgeDirection.Back:
                 cmds.Append(Command.Set(kf.Model.Time, kf.Model.Time.Value - timeDelta));
                 break;
             case NudgeDirection.Forward:
                 cmds.Append(Command.Set(kf.Model.Time, kf.Model.Time.Value + timeDelta));
                 break;
         }
     }
 }