Kav/Cameras/Camera.cs

41 lines
1.1 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; }
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;
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
}
}
}