45 lines
1.2 KiB
C#
45 lines
1.2 KiB
C#
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; } = MathHelper.PiOver4;
|
|
public float AspectRatio { get; set; } = 1920f / 1080f;
|
|
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
|
|
);
|
|
}
|
|
|
|
public Camera(Matrix transform)
|
|
{
|
|
Transform = transform;
|
|
Projection = Matrix.CreatePerspectiveFieldOfView(
|
|
FOV,
|
|
AspectRatio,
|
|
NearPlane,
|
|
FarPlane
|
|
);
|
|
}
|
|
}
|
|
}
|