예제 #1
0
        public SSAnimationStateMachineSkeletalController addStateMachine(SSAnimationStateMachine description,
                                                                         int[] topLevelJoints = null)
        {
            var smController = new SSAnimationStateMachineSkeletalController(description, topLevelJoints);

            addController(smController);
            return(smController);
        }
예제 #2
0
        /// <summary>
        /// Adds the state machine that will control the mesh.
        /// </summary>
        /// <param name="stateMachine">
        /// A runtime state machine component that can be used to trigger animation state transitions on demand,
        /// from keyboard etc.
        /// </param>
        public SSAnimationStateMachineSkeletalController addStateMachine(
            SSAnimationStateMachine stateMachine)
        {
            var newSMRuntime = new SSAnimationStateMachineSkeletalController(stateMachine);

            _channelControllers.Add(newSMRuntime);
            return(newSMRuntime);
        }
예제 #3
0
        /// <summary>
        /// This can be used to loop an animation without having to set up a state machine explicitly
        /// For a more sophisticated control use AddController()
        /// </summary>
        public void playAnimationLoop(SSSkeletalAnimation anim, float transitionTime = 0f,
                                      int[] topLevelJoints = null)
        {
            _hierarchy.verifyAnimation(anim);
            var loopSM = new SSAnimationStateMachine();

            loopSM.addState("default", anim, true);
            loopSM.addAnimationEndsTransition("default", "default", transitionTime);
            if (topLevelJoints == null)
            {
                topLevelJoints = _hierarchy.topLevelJoints;
            }
            var loopController = new SSAnimationStateMachineSkeletalController(loopSM, topLevelJoints);

            addController(loopController);
        }
        public SSAnimationStateMachineSkeletalController(
			SSAnimationStateMachine description,
			params int[] topLevelJoints)
        {
            _smDescription = description;
            if (topLevelJoints != null && topLevelJoints.Length > 0) {
                _topLevelActiveJoints = new List<int> (topLevelJoints);
            }
            foreach (var state in _smDescription.states.Values) {
                if (state.isDefault) {
                    _forceState (state);
                    return;
                }
            }
            var errMsg = "no default state is specified.";
            System.Console.WriteLine (errMsg);
            throw new Exception (errMsg);
        }
        public SSAnimationStateMachineSkeletalController(
            SSAnimationStateMachine description,
            params int[] topLevelJoints)
        {
            _smDescription = description;
            if (topLevelJoints != null && topLevelJoints.Length > 0)
            {
                _topLevelActiveJoints = new List <int> (topLevelJoints);
            }
            foreach (var state in _smDescription.states.Values)
            {
                if (state.isDefault)
                {
                    _forceState(state);
                    return;
                }
            }
            var errMsg = "no default state is specified.";

            System.Console.WriteLine(errMsg);
            throw new Exception(errMsg);
        }
        protected void _requestTransition(
			SSAnimationStateMachine.TransitionInfo transition, float transitionTime)
        {
            _activeState = transition.target;

            if (_activeState.animation == null) {
                if (transitionTime == 0) {
                    _interChannelFadeIntensity = 0f;
                    _interChannelFadeVelocity = 0f;
                } else {
                    _interChannelFadeVelocity = -_interChannelFadeIntensity / transitionTime;
                }
            } else { // animation != null
                if (transitionTime == 0) {
                    _interChannelFadeIntensity = 1f;
                    _interChannelFadeVelocity = 0f;
                } else {
                    _interChannelFadeVelocity = (1f - _interChannelFadeIntensity) / transitionTime;
                }
            }

            _channelManager.playAnimation(_activeState.animation, transitionTime);
        }
        protected void _forceState(SSAnimationStateMachine.AnimationState targetState)
        {
            _activeState = targetState;

            _interChannelFadeVelocity = 0f;
            if (_activeState.animation == null) {
                _interChannelFadeIntensity = 0f;
            } else {
                _interChannelFadeIntensity = 1f;
            }

            _channelManager.playAnimation(_activeState.animation, 0f);
        }
예제 #8
0
 public SSAnimationStateMachineSkeletalController addStateMachine(SSAnimationStateMachine description,
                                                                  params string[] topLevelJointNames)
 {
     return(addStateMachine(description, _hierarchy.jointIndices(topLevelJointNames)));
 }