Esempio n. 1
0
        private List <ICommand> SetupSingleAnimation(OperatorPart opPart, double keyframeTime)
        {
            var context = new OperatorPartContext()
            {
                Time = (float)keyframeTime
            };
            float currentValue = opPart.Eval(context).Value;

            // this command is needed to restore the original value correctly when undoing this, for doing it it's redundant
            var setValueCommand = new SetFloatValueCommand(opPart, currentValue);

            var compOp            = opPart.Parent.Parent;
            var addCurveOpCommand = new AddOperatorCommand(compOp, CurveID, 100, 100, 100, false);
            var curveOpInstanceId = addCurveOpCommand.AddedInstanceID;
            var addTimeOpCommand  = new AddOperatorCommand(compOp, CurrentTimeID, 100, 100, 100, false);

            var curveMetaOp = MetaManager.Instance.GetMetaOperator(CurveID);
            var timeMetaOp  = MetaManager.Instance.GetMetaOperator(CurrentTimeID);

            var timeToCurve = new MetaConnection(addTimeOpCommand.AddedInstanceID, timeMetaOp.Outputs[0].ID,
                                                 addCurveOpCommand.AddedInstanceID, curveMetaOp.Inputs[0].ID);
            var connectionTimeToCurveCommand = new InsertConnectionCommand(compOp.Definition, timeToCurve, 0);

            var curveToCurrent = new MetaConnection(addCurveOpCommand.AddedInstanceID, curveMetaOp.Outputs[0].ID,
                                                    opPart.Parent.ID, opPart.ID);
            var connectionCurveToCurrentCommand = new InsertConnectionCommand(compOp.Definition, curveToCurrent, 0);

            var addKeyframeCommand = new AddOrUpdateKeyframeCommand(keyframeTime, currentValue, compOp, curveOpInstanceId, curveMetaOp.Inputs[0].ID);

            return(new List <ICommand>()
            {
                setValueCommand,
                addCurveOpCommand,
                addTimeOpCommand,
                connectionTimeToCurveCommand,
                connectionCurveToCurrentCommand,
                addKeyframeCommand
            });
        }
Esempio n. 2
0
        public SetValueGroupCommand(IEnumerable <Entry> entries, double globalTime, string name = "Set Value Group")
        {
            _name = name;

            foreach (var entry in entries)
            {
                ICommand cmd;

                var isControlAnimated = false;

                OperatorPart animationOpPart = Animation.GetRegardingAnimationOpPart(entry.OpPart);
                isControlAnimated = animationOpPart != null;

                if (isControlAnimated)
                {
                    cmd = new AddOrUpdateKeyframeCommand(globalTime, entry.Value.Val, entry.OpPart);
                }
                else
                {
                    cmd = new UpdateOperatorPartValueFunctionCommand(entry.OpPart, entry.Value);
                }
                _commands.Add(cmd);
            }
        }