Toast Engine
Loading...
Searching...
No Matches
camera.hpp
Go to the documentation of this file.
1
8
9#pragma once
10
11#include "node_3d.hpp"
13
14#include <toast/export.hpp>
15
16namespace toast {
17
20struct Ray {
21 glm::vec3 origin;
22 glm::vec3 direction;
23};
24
25class [[ToastNode, Icon("Camera")]] TOAST_API Camera : public Node3D {
26 friend class CameraController;
27
28public:
29 Camera() = default;
30
31 ~Camera() override;
32
33public:
34 [[Reflect, Unit("°")]]
35 float fov = 75.f;
36
37 [[Reflect, Unit("m")]]
38 float near_plane = 0.01f;
39
40 [[Reflect, Unit("m")]]
41 float far_plane = 5000.f;
42
43 void setActiveCamera();
44
45 [[nodiscard]]
46 auto isMainCamera() const noexcept -> bool {
47 return m_is_main_camera;
48 }
49
50 [[nodiscard]]
51 auto getView() const -> glm::mat4;
52 [[nodiscard]]
53 auto getProjection(float aspect) const -> glm::mat4;
54
60 [[nodiscard]]
61 auto screenPointToRay(glm::vec2 screen_px, glm::vec2 viewport_size) const noexcept -> Ray;
62
63 signals::Signal<Box<Node>> set_as_main;
64
65private:
66 void updateInspectorMessages() override;
67 void begin();
68 void end();
69 void onEnable();
70 void onDisable();
71
73 [[Reflect, Name("Is Main Camera?")]]
74 bool m_is_main_camera = false;
75
76 [[Reflect, ReadOnly]]
77 bool m_is_active = false;
78
79 bool m_registered_proxy = false;
80
81 friend class INodeOwner;
82};
83}
auto screenPointToRay(glm::vec2 screen_px, glm::vec2 viewport_size) const noexcept -> Ray
Unprojects a viewport-space pixel into a world-space ray.
Definition camera.cpp:99
Definition node_3d.hpp:25
Definition reflect.hpp:244
Node with 3D spatial transforms.
World-space ray, @TODO: Move to some other engine part.
Definition camera.hpp:20