○ドワーフのアニメータを作成した後、ファイルに保存されているアニメーションをロードします。ModelAnimator.Animations プロパティはコンテントパイプラインからロードされたアニメーションのコレクションを含みます。
○一つのアニメーションを再生させるために、新しい AnimationController クラスを作成します。ただ単にアニメーションを渡すだけです。
○アニメーションを再生するには dwarfAnimator.BonePoses に保存されている BonePose オブジェクトを列挙し、それらの CurrentController プロパティに適切な AnimationController を設定します。
○利便性を考慮し、全てのボーンのアニメーションを再生させるメソッドを作成して下さい。
  1. // Add this as a new method
  2. private void RunController(ModelAnimator animator, AnimationController controller)
  3. {
  4. foreach (BonePose p in animator.BonePoses)
  5. {
  6. p.CurrentController = controller;
  7. p.CurrentBlendController = null;
  8. }
  9. }
  10.  
○p.CurrentBlendController は、今は無視して下さい。
○LoadGraphicsContent メソッドで「立ち」状態のアニメーションを作成し、再生して下さい。
  1. // Add this as a member variable
  2. AnimationController idle;
  3.  
  1. // Add this in LoadGraphicsContent
  2. idle = new AnimationController(this,
  3. dwarfAnimator.Animations["idle0"]);
  4. RunController(dwarfAnimator,idle);
  5.  
○Great!ドワーフのアニメーション再生することができました。次に進む前にチュートリアルで使用する残りのコントローラを作成して下さい。
  1. // Add these as member variables
  2. AnimationController walk, run, nod, crouch, stayCrouched;
  3.  
  1. // Add this in LoadGraphicsContent
  2. run = new AnimationController(this, dwarfAnimator.Animations["run"]);
  3. walk = new AnimationController(this, dwarfAnimator.Animations["walk"]);
  4. crouch = new AnimationController(this, dwarfAnimator.Animations["crouchDown"]);
  5. stayCrouched = new AnimationController(this, dwarfAnimator.Animations["stayCrouched"]);
  6. nod = new AnimationController(this, dwarfAnimator.Animations["nodHead"]);
  7.  

最終更新:2009年06月21日 12:45