Kav/Cameras/Camera.cs

34 lines
1.0 KiB
C#
Raw Normal View History

2020-08-04 09:32:02 +00:00
using Microsoft.Xna.Framework;
namespace Kav
{
2020-09-18 11:00:53 +00:00
public struct PerspectiveCamera
2020-08-04 09:32:02 +00:00
{
2020-09-18 11:00:53 +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
2020-09-18 11:00:53 +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)
2020-08-05 19:15:22 +00:00
{
2020-09-18 11:00:53 +00:00
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
}
}
}