/// <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; } } }
/// <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; } } }