Time for action – the ArcBallCamera class – part 1
1. Add a new class to the Tank Battles project by right-clicking on the project in Solution Explorer and selecting Add | Class....
2. Ensure that Visual C# | Code is selected under Installed Templates and select the Class template.
3. Enter
ArcBallCamera.cs
as the name of the class file.4. Add the following
using
directive to the top of theArcBallCamera.c
s
file:using Microsoft.Xna.Framework;
5. Add the following fields to the
ArcBallCamera
class:#region Fields private Vector3 cameraPosition = Vector3.Zero; private Vector3 targetPosition = Vector3.Zero; private float elevation; private float rotation; private float minDistance; private float maxDistance; private float viewDistance = 12f; private Vector3 baseCameraReference = new Vector3(0, 0, 1); private bool needViewResync = true; private Matrix cachedViewMatrix; #endregion
6. Add the following properties to the
ArcBallCamera
class:#region Properties public Matrix Projection { get; private...