Euphoria
camera.h
Go to the documentation of this file.
1#pragma once
2
3#include "eu/render/space.h"
4
5namespace eu::render
6{
7
11
12// todo(Gustav): rename to PerspectiveCamera? or PerspCamera?
14struct Camera
15{
16 An fov = 45.0_deg;
17 float near = 0.1f;
18 float far = 100.0f;
19
21};
22
25{
26 float size = 100.0f;
27
28 float near = 0.1f;
29 float far = 100.0f;
30
31 v3 position = v3{0.0f, 0.0f, 0.0f};
32
34 {
35 .yaw = 0.0_rad,
36 .pitch = 0.0_rad,
37 .roll = 0.0_rad
38 };
39};
40
53
55// Functions
56
59
60// todo(Gustav): the meaning of this function is unclear... move closer to usage or remove?
62
64CompiledCamera compile(const Camera&, const Size& window_size);
65
67CompiledCamera compile(const OrthoCamera&, const Size& window_size);
68
69// todo(Gustav): also include depth, what happens if the position is behind?
71v2 screen_from_world(const CompiledCamera& cam, const v3& world_pos, const v2& resolution);
72
76} // namespace eu::render
constexpr m4 m4_identity
The identity matrix.
Definition mat4.h:190
m4 create_view_from_world_mat(const v3 &pos, const CameraVectors &cv)
v2 screen_from_world(const CompiledCamera &cam, const v3 &world_pos, const v2 &resolution)
Calculate the screen coordinate of a 3d world position.
CompiledCamera compile(const Camera &, const Size &window_size)
"Compile" a camera to a perspective so it can be used in rendering.
CameraVectors create_vectors(const Camera &camera)
Capture the current local space of the camera.
Definition ui.h:8
An angle in both degrees and radians.
Definition angle.h:13
a size
Definition size.h:11
yaw + pitch + roll
Definition axisangle.h:33
4x4 matrix
Definition mat4.h:26
a 3d unit (vector)
Definition vec3.h:94
A temporary view of the local space of a camera.
Definition space.h:8
The current perspective camera representation.
Definition camera.h:15
A "compiled" camera for use in rendering.
Definition camera.h:44
m4 clip_from_view
also known as projection matrix
Definition camera.h:46
m4 view_from_world
also known as view matrix
Definition camera.h:49
A orthographic camera representation.
Definition camera.h:25
a 2d vector
Definition vec2.h:17
a 3d vector
Definition vec3.h:27