Esempio n. 1
0
        /// <summary>
        /// Construct self from a model and active animation name.
        /// </summary>
        /// <param name="model"></param>
        /// <param name="animName"></param>
        public ModelAnim(FBXModel model, string animName)
        {
            ActiveAnimation = new AnimatorList(model);
            if (ActiveAnimation.NotEmpty)
            {
                AnimationInstance sample = ActiveAnimation.Sample;
                ActiveController = SimpleController.TryMake(sample, animName, sample.FirstAnimationName);

                if (ActiveController != null)
                {
                    ActiveAnimation.ApplyController(ActiveController);

                    IdleAnimation = new AnimatorList(model);
                    Debug.Assert(IdleAnimation.NotEmpty, "Could make active but not idle?");
                    sample         = IdleAnimation.Sample;
                    IdleController = SimpleController.TryMake(sample, "idle", null);
                    if (IdleController != null)
                    {
                        IdleAnimation.ApplyController(IdleController);
                    }
                    else
                    {
                        IdleAnimation = null;
                    }
                }
                else
                {
                    ActiveAnimation = null;
                }
            }
        }
Esempio n. 2
0
        public override void InitDeviceResources(GraphicsDevice device)
        {
            base.InitDeviceResources(device);
            _animators = new AnimatorList(StaticActor.Model);
            /// All animators in the stack should have the same set of animations.
            AnimationInstance animator = _animators.Sample;

            // TODO (****)  Do we need this check???
            if (animator.HasAnimation("full_running"))
            {
                // Add individual animations to blend controller.
                idleController = SimpleController.TryMake(animator, "full_running");
                SetAnimation(idleController);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Load up our animations and bind to the given model.
        /// </summary>
        /// <param name="sro"></param>
        private void LoadAnimations(FBXModel sro)
        {
            Debug.Assert(SharedAnim != null, "Must set SharedAnim to class's shared animation in constructor.");
            if (SharedAnim.ActiveAnimator == null)
            {
                SharedAnim.ActiveAnimator = new AnimatorList(sro);
            }
            _animators = SharedAnim.ActiveAnimator;
            AnimatorList      animList = SharedAnim.ActiveAnimator;
            AnimationInstance animator = animList.Sample;

            if (animator != null && animator.HasAnimation(SharedAnim.ActiveName))
            {
                if (SharedAnim.ActiveController == null)
                {
                    SharedAnim.ActiveController = SimpleController.TryMake(animator, SharedAnim.ActiveName);
                    AnimActive();
                }
            }
            else
            {
                animList.ApplyController(null);
            }
            if (SharedAnim.IdleAnimator == null)
            {
                SharedAnim.IdleAnimator = new AnimatorList(sro);
                AnimationInstance sharedIdle = SharedAnim.IdleAnimator.Sample;
                if ((sharedIdle != null) && sharedIdle.HasAnimation(SharedAnim.IdleName))
                {
                    SharedAnim.IdleController = SimpleController.TryMake(
                        sharedIdle,
                        SharedAnim.IdleName);
                }
                if (SharedAnim.IdleController != null)
                {
                    AnimIdle();
                }
                else
                {
                    SharedAnim.IdleAnimator = null;
                }
            }
        }