Created
July 6, 2021 02:58
-
-
Save thatcosmonaut/9ed36c551c69ebf6989444992c928d78 to your computer and use it in GitHub Desktop.
an orthographic camera example for FNA
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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