Time for action – the stationary camera
To implement a stationary camera in Mars Runner, perform the following steps:
1. Create a new class file in the
Mars Runner
project calledCamera.cs
.2. Add the following
using
declaration to theCamera
class file:using Microsoft.Xna.Framework;
3. Add the following fields to the
Camera
class:#region Fields private Vector3 position = Vector3.Zero; private float rotation; private Vector3 lookAt; private Vector3 baseCameraReference = new Vector3(0, 0, 1); private bool needViewResync = true; private Matrix cachedViewMatrix; #endregion
4. Add the following properties to the
Camera
class:#region Properties public Matrix Projection { get; private set; } public Matrix WideProjection { get; private set; } public Vector3 Position { get { return position; } set { position = value; updateLookAt(); } } public float Rotation { get { return rotation; } set { rotation = value; ...