2020-08-04 09:32:02 +00:00
|
|
|
using Microsoft.Xna.Framework;
|
|
|
|
|
|
|
|
namespace Kav
|
|
|
|
{
|
2020-10-01 19:46:25 +00:00
|
|
|
public struct PerspectiveCamera
|
2020-08-04 09:32:02 +00:00
|
|
|
{
|
2020-10-01 19:46:25 +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-10-01 19:46:25 +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; }
|
2020-10-01 19:46:25 +00:00
|
|
|
|
|
|
|
public float FieldOfView { get; }
|
|
|
|
public float AspectRatio { get; }
|
|
|
|
public float NearPlane { get; }
|
|
|
|
public float FarPlane { get; }
|
|
|
|
|
2020-12-05 02:51:59 +00:00
|
|
|
public PerspectiveCamera(
|
|
|
|
Vector3 position,
|
|
|
|
Vector3 forward,
|
|
|
|
Vector3 up,
|
|
|
|
float fieldOfView,
|
|
|
|
float aspectRatio,
|
|
|
|
float nearPlane,
|
|
|
|
float farPlane
|
|
|
|
) {
|
2020-10-01 19:46:25 +00:00
|
|
|
Position = position;
|
|
|
|
Forward = forward;
|
|
|
|
Up = up;
|
2020-12-10 01:47:54 +00:00
|
|
|
Right = Vector3.Cross(forward, up);
|
2020-10-01 19:46:25 +00:00
|
|
|
View = Matrix.CreateLookAt(Position, Position + Forward, Up);
|
|
|
|
|
|
|
|
FieldOfView = fieldOfView;
|
|
|
|
AspectRatio = aspectRatio;
|
|
|
|
NearPlane = nearPlane;
|
2020-12-05 02:51:59 +00:00
|
|
|
FarPlane = farPlane;
|
2020-10-01 19:46:25 +00:00
|
|
|
Projection = Matrix.CreatePerspectiveFieldOfView(FieldOfView, AspectRatio, NearPlane, FarPlane);
|
2020-08-04 09:32:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|