https://github.com/simulation-tree/cameras
https://github.com/simulation-tree/cameras
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/simulation-tree/cameras
- Owner: simulation-tree
- Created: 2024-08-31T18:48:34.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-09-24T03:04:10.000Z (9 months ago)
- Last Synced: 2025-12-09T23:23:57.307Z (6 months ago)
- Language: C#
- Homepage:
- Size: 49.8 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Cameras
Cameras for rendering.
### Projection data
Extending from the `rendering` project, an extension method is available to fetch
the projection and view matrices from a `Camera`:
```cs
using World world = new World();
Camera mainCamera = new(world, CameraFieldOfView.FromDegrees(90f));
CameraProjection cameraProjection = mainCamera.GetProjection();
(Matrix4x4 projection, Matrix4x4 view) = cameraProjection;
```
### Ray from screen point
When a screen point is available, a ray can be calculated from the camera's perspective:
```cs
Vector2 mousePosition = ...
Vector2 screenPoint = camera.Destination.GetScreenPointFromPosition(mousePosition);
(Vector3 origin, Vector3 direction) = cameraProjection.GetRayFromScreenPoint(screenPoint);
```