このデモのために、ドワーフの後ろを着いていくだけのとてもシンプルなカメラを作成します。

○これらのメンバ変数を追加して下さい。
  1. // Add these as member variables
  2. // This stores the cameras position relative to the dwarf
  3. Vector3 camOffset = new Vector3(0, 15, -20);
  4. Vector3 dwarfPosition = Vector3.Zero;
  5. Matrix rotation = Matrix.Identity;
  6.  
○Update メソッドでドワーフのワールド行列とビュー行列を更新し、カメラはドワーフの方を向け、そして camOffset を足し合わせて下さい。
  1. // Add this to the Update method
  2. dwarfAnimator.World = rotation * Matrix.CreateTranslation(dwarfPosition);
  3. view = Matrix.CreateLookAt(
  4. dwarfAnimator.World.Translation+camOffset,
  5. dwarfAnimator.World.Translation,
  6. Vector3.Up);
  7.  
○また Update メソッドで両方のモデルのエフェクトを更新して下さい。
  1. // Add this to the Update method
  2. foreach (ModelMesh mesh in dwarfAnimator.Model.Meshes)
  3. foreach (BasicPaletteEffect effect in mesh.Effects)
  4. effect.View = view;
  5.  
  6. foreach (ModelMesh mesh in ground.Model.Meshes)
  7. foreach (BasicEffect effect in mesh.Effects)
  8. effect.View = view;
  9.  

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