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
20 v3 position = v3{0.0f, 0.0f, 0.0f};
21
23 {
24 .yaw = 0.0_rad,
25 .pitch = 0.0_rad,
26 .roll = 0.0_rad
27 };
28};
29
32{
33 float size = 100.0f;
34
35 float near = 0.1f;
36 float far = 100.0f;
37
38 v3 position = v3{0.0f, 0.0f, 0.0f};
39
41 {
42 .yaw = 0.0_rad,
43 .pitch = 0.0_rad,
44 .roll = 0.0_rad
45 };
46};
47
60
62// Functions
63
66
67// todo(Gustav): the meaning of this function is unclear... move closer to usage or remove?
69
71CompiledCamera compile(const Camera&, const Size& window_size);
72
74CompiledCamera compile(const OrthoCamera&, const Size& window_size);
75
76// todo(Gustav): also include depth, what happens if the position is behind?
78v2 screen_from_world(const CompiledCamera& cam, const v3& world_pos, const v2& resolution);
79
83} // namespace eu::render
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:4
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:19
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:51
m4 clip_from_view
also known as projection matrix
Definition camera.h:53
m4 view_from_world
also known as view matrix
Definition camera.h:56
A orthographic camera representation.
Definition camera.h:32
a 2d vector
Definition vec2.h:17
a 3d vector
Definition vec3.h:27