Toast Engine
Toggle main menu visibility
Loading...
Searching...
No Matches
camera_controller.hpp
1
8
9
#pragma once
10
#include "
camera.hpp
"
11
#include "
toast/events/signals.hpp
"
12
13
#include <glm/glm.hpp>
14
#include <limits>
15
#include <
toast/export.hpp
>
16
#include <
toast/world/node.hpp
>
17
18
namespace
toast {
19
20
class
Node3D
;
21
22
enum class
TransitionType : uint8_t {
23
linear = 0,
24
spherical = 1,
25
};
26
39
class
[[ToastNode, Icon(
"Camera"
)]] TOAST_API
CameraController
:
public
Node {
40
private
:
41
[[
Reflect
, ReadOnly, Name(
"Active Camera"
)]]
42
std::string m_active_camera_name;
43
44
public
:
45
[[
Reflect
]]
46
void
setActiveCamera(
Box<Camera>
c);
47
48
[[
Reflect
]]
49
void
setActiveCamera(
UID
uid
);
50
51
[[
Reflect
]]
52
void
setActiveCamera(std::string_view
name
);
53
54
[[
Reflect
]]
55
auto
getActiveCamera() ->
Box<Camera>
;
56
57
[[
Reflect
]]
58
auto
getActiveCameraIndex() -> uint8_t;
59
60
[[
Reflect
]]
61
bool
do_transition =
false
;
62
63
[[
Reflect
, Enum(
"Linear"
,
"Spherical"
)]]
64
TransitionType transition_type = TransitionType::linear;
65
66
[[
Reflect
, Unit(
"s"
)]]
67
float
transition_time = 1.0f;
68
69
[[
Reflect
, Unit(
"%"
), Range(0, 50)]]
70
float
ease_in = 0.0f;
71
72
[[
Reflect
, Unit(
"%"
), Range(0, 50)]]
73
float
ease_out = 0.0f;
74
75
[[
Reflect
, Name(
"Look At Target"
)]]
76
Box<Node3D>
look_target;
77
78
[[
Reflect
, Button(
"Previous Camera"
)]]
79
void
prev();
80
81
[[
Reflect
, Button(
"Next Camera"
)]]
82
void
next();
83
88
void
addCamera
(
Camera
& camera);
89
void
removeCamera(
Camera
& camera);
90
void
clearCameras();
91
92
signals::Signal<Box<Node>> main_camera_changed;
93
94
private
:
95
static
constexpr
uint8_t no_active_camera = std::numeric_limits<uint8_t>::max();
96
97
std::vector<Box<Camera>> m_cameras;
98
uint8_t m_active_camera_index = no_active_camera;
99
100
Box<Camera>
m_transition_camera;
101
glm::vec3 m_transition_start = glm::vec3(0.0f);
102
glm::vec3 m_transition_end = glm::vec3(0.0f);
103
glm::vec3 m_transition_center = glm::vec3(0.0f);
104
float
m_transition_elapsed = 0.0f;
105
float
m_transition_duration = 0.0f;
106
float
m_transition_ease_in = 0.0f;
107
float
m_transition_ease_out = 0.0f;
108
TransitionType m_transition_type = TransitionType::linear;
109
bool
m_transition_active =
false
;
110
111
void
init();
112
void
begin();
113
void
end();
114
void
onEnable();
115
void
onDisable();
116
void
tick();
117
void
stopTransition(
bool
restore_camera_position);
118
};
119
120
}
camera.hpp
TODO: Brief description of the file's purpose.
toast::Box
Intrusive reference-counted handle to a Node.
Definition
box.hpp:35
toast::CameraController
Manages switching between different active cameras.
Definition
camera_controller.hpp:39
toast::CameraController::addCamera
void addCamera(Camera &camera)
Definition
camera_controller.cpp:189
toast::Camera
Definition
camera.hpp:25
toast::Node3D
Definition
node_3d.hpp:25
toast::Node::name
auto name() const noexcept -> std::string_view
Display name. Siblings may share one - this is not an identifier.
Definition
node.cpp:45
toast::Node::uid
auto uid() const noexcept -> const UID &
Stable unique identifier, assigned at construction or deserialization. Never changes.
Definition
node.cpp:37
toast::Reflect
Definition
reflect.hpp:244
export.hpp
node.hpp
Base object type for the scene graph.
signals.hpp
toast::UID
Definition
uid.hpp:20
engine
src
toast
world
camera_controller.hpp
Generated by
1.17.0