Kav/Camera.cs

33 lines
970 B
C#
Raw Normal View History

2020-08-04 09:32:02 +00:00
using Microsoft.Xna.Framework;
namespace Kav
{
public class Camera
{
public Matrix Transform { get; set; }
public Matrix Projection { get; set; }
public Matrix View {
get
{
return Matrix.CreateLookAt(Transform.Translation, Transform.Forward, Transform.Up);
}
}
public float FOV { get; set; } = 75f;
public float AspectRatio { get; set; } = 1920 / 1080;
public float NearPlane { get; set; } = 0.1f;
public float FarPlane { get; set; } = 200f;
public Camera(Vector3 position, Quaternion orientation)
{
Transform = Matrix.CreateFromQuaternion(orientation) * Matrix.CreateTranslation(position.X, position.Y, position.Z);
Projection = Matrix.CreatePerspectiveFieldOfView(
FOV,
AspectRatio,
NearPlane,
FarPlane
);
}
}
}