Skip to content

Instantly share code, notes, and snippets.

@thatcosmonaut
Created July 6, 2021 02:58
Show Gist options
  • Save thatcosmonaut/9ed36c551c69ebf6989444992c928d78 to your computer and use it in GitHub Desktop.
Save thatcosmonaut/9ed36c551c69ebf6989444992c928d78 to your computer and use it in GitHub Desktop.
an orthographic camera example for FNA
public struct OrthographicCamera : ICamera
{
public Matrix View { get; }
public Matrix Projection { get; }
public Vector3 Position { get; }
public Vector3 Forward { get; }
public Vector3 Up { get; }
public Vector3 Right { get; }
public float Width { get; }
public float Height { get; }
public float NearPlane { get; }
public float FarPlane { get; }
public OrthographicCamera(
Vector3 position,
Vector3 forward,
Vector3 up,
float width,
float height,
float nearPlane,
float farPlane
) {
Position = position;
Forward = forward;
Up = up;
Right = Vector3.Cross(forward, up);
View = Matrix.CreateLookAt(Position, Position + Forward, Up);
Width = width;
Height = height;
NearPlane = nearPlane;
FarPlane = farPlane;
Projection = Matrix.CreateOrthographicOffCenter(
0,
Width,
Height,
0,
nearPlane,
farPlane
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment