このデモのために、ドワーフの後ろを着いていくだけのとてもシンプルなカメラを作成します。
○これらのメンバ変数を追加して下さい。
// Add these as member variables
// This stores the cameras position relative to the dwarf
Vector3 camOffset = new Vector3(0, 15, -20);
Vector3 dwarfPosition = Vector3.Zero;
Matrix rotation = Matrix.Identity;
○Update メソッドでドワーフのワールド行列とビュー行列を更新し、カメラはドワーフの方を向け、そして camOffset を足し合わせて下さい。
// Add this to the Update method
dwarfAnimator.World = rotation * Matrix.CreateTranslation(dwarfPosition);
view = Matrix.CreateLookAt(
dwarfAnimator.World.Translation+camOffset,
dwarfAnimator.World.Translation,
Vector3.Up);
○また Update メソッドで両方のモデルのエフェクトを更新して下さい。
// Add this to the Update method
foreach (ModelMesh mesh in dwarfAnimator.Model.Meshes)
foreach (BasicPaletteEffect effect in mesh.Effects)
effect.View = view;
foreach (ModelMesh mesh in ground.Model.Meshes)
foreach (BasicEffect effect in mesh.Effects)
effect.View = view;
最終更新:2009年06月21日 12:48