Kav/Cameras/Camera.cs

43 lines
1.2 KiB
C#
Raw Normal View History

2020-08-04 09:32:02 +00:00
using Microsoft.Xna.Framework;
namespace Kav
{
public struct PerspectiveCamera
2020-08-04 09:32:02 +00:00
{
public Matrix View { get; }
2020-08-06 06:58:18 +00:00
public Matrix Projection { get; }
2020-08-04 09:32:02 +00:00
public Vector3 Position { get; }
public Vector3 Forward { get; }
public Vector3 Up { get; }
2020-12-10 01:47:54 +00:00
public Vector3 Right { get; }
public float FieldOfView { get; }
public float AspectRatio { get; }
public float NearPlane { get; }
public float FarPlane { get; }
public PerspectiveCamera(
Vector3 position,
Vector3 forward,
Vector3 up,
float fieldOfView,
float aspectRatio,
float nearPlane,
float farPlane
) {
Position = position;
Forward = forward;
Up = up;
2020-12-10 01:47:54 +00:00
Right = Vector3.Cross(forward, up);
View = Matrix.CreateLookAt(Position, Position + Forward, Up);
FieldOfView = fieldOfView;
AspectRatio = aspectRatio;
NearPlane = nearPlane;
FarPlane = farPlane;
Projection = Matrix.CreatePerspectiveFieldOfView(FieldOfView, AspectRatio, NearPlane, FarPlane);
2020-08-04 09:32:02 +00:00
}
}
}