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
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
22 Ypr rotation = Ypr{ 0.0_rad, 0.0_rad, 0.0_rad };
23};
24
27{
28 float size = 100.0f;
29
30 float near = 0.1f;
31 float far = 100.0f;
32
33 v3 position = v3{0.0f, 0.0f, 0.0f};
34
35 Ypr rotation = Ypr{ 0.0_rad, 0.0_rad, 0.0_rad };
36};
37
50
52// Functions
53
56
57// todo(Gustav): the meaning of this function is unclear... move closer to usage or remove?
59
61CompiledCamera compile(const Camera&, const Size& window_size);
62
64CompiledCamera compile(const OrthoCamera&, const Size& window_size);
65
66// todo(Gustav): also include depth, what happens if the position is behind?
69
73} // 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 (inclusive) range between two values.
Definition range.h:19
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:10
The current perspective camera representation.
Definition camera.h:15
A "compiled" camera for use in rendering.
Definition camera.h:41
m4 clip_from_view
also known as projection matrix
Definition camera.h:43
m4 view_from_world
also known as view matrix
Definition camera.h:46
A orthographic camera representation.
Definition camera.h:27
a 2d vector
Definition vec2.h:17
a 3d vector
Definition vec3.h:27