persona-3-dual
A DS demake of Persona 3
Loading...
Searching...
No Matches
CameraSystem.hpp
Go to the documentation of this file.
1
10
11#pragma once
12
13#include "core/geometry.hpp"
14#include "core/routerIDs.hpp"
18#include "types/CameraTypes.hpp"
19
20#include <aegis/system.hpp>
21#include <etl/vector.h>
22
23// !Todo replace floats with fixed point math for camera position and target position.
24
25class CameraSystem : public ae::SystemRouter<CameraSystem,
26 Event::ConfigureCamera,
27 Event::SetCameraMode,
28 Event::SetCameraPath,
29 Event::SetCharacterPosition,
30 Event::StartCamera,
31 Event::StopCamera>,
32 public ae::Singleton<CameraSystem>
33{
34 public:
35 void init() override;
36
37 void shutdown() override;
38
45 void update(ae::q20_12_t /*dt*/) override;
46
58 void on_receive(const Event::ConfigureCamera& config);
59
66 void on_receive(const Event::SetCameraMode& msg);
67
78 void on_receive(const Event::SetCameraPath& msg);
79
86
92 void on_receive(const Event::StartCamera& msg);
93
99 void on_receive(const Event::StopCamera& msg);
100
109 void on_receive_unknown(const etl::imessage& msg)
110 {
111 }
112
115 {
116 return mode;
117 }
118
120 ae::q20_12_t getAngle() const
121 {
122 return angle;
123 }
124
126 bool isPathComplete() const
127 {
128 return pathDone;
129 }
130
140 ae::q20_12_t getMovementAngle() const;
141
156 {
157 return camPos;
158 }
159
160 private:
161 friend class Singleton<CameraSystem>;
163 {
164 }
165
166 MathManager& math = MathManager::getInstance();
167
169
172
174 // TODO: remove camPos in favour of Event pub/sub?
176 ae::q20_12_t angle{0};
177 ae::q20_12_t distance{1.5};
178 ae::q20_12_t height{0.6};
179 ae::q20_12_t lookAhead{0.5};
180 ae::q20_12_t angleIncrement{0.05};
181 ae::q20_12_t freeCameraSpeed{0.02};
182 bool isRotationLocked = false;
183
184 // Path playback state
185 const CameraPath* path = nullptr;
186 int pathFrame = 0;
188 bool pathDone = false;
189
190 // Free mode state
191 bool freeInitialised = false;
192};
Events for CameraSystem.
CameraMode
Controls how the camera behaves each frame.
Generic events used across multiple systems.
ae::q20_12_t getMovementAngle() const
Returns the angle that maps the UP key to "move away from camera".
CameraMode getMode() const
Returns the current camera mode.
bool isPathComplete() const
Returns true once the Path playback has reached its last keyframe.
ae::q20_12_t angleIncrement
ae::q20_12_t lookAhead
CameraMode mode
void on_receive(const Event::ConfigureCamera &config)
ETL message handler to configure the camera settings.
ae::q20_12_t angle
const CameraPath * path
ae::q20_12_t height
Vec3< ae::q20_12_t > targetPos
void shutdown() override
Event::CameraPosition getCameraPosition() const
Returns the camera position.
MathManager & math
ae::q20_12_t getAngle() const
Returns the current orbit angle in radians.
void init() override
ae::q20_12_t freeCameraSpeed
Vec3< ae::q20_12_t > currentPos
void update(ae::q20_12_t) override
Core update loop that advances camera state and broadcasts the resulting gluLookAt arguments.
Event::CameraPosition camPos
ae::q20_12_t distance
CharacterPosition charPos
void on_receive_unknown(const etl::imessage &msg)
Fallback handler for unhandled ETL messages.
Holds routerIDs used for systems.
constexpr etl::message_router_id_t kCameraSystemRouterID
Definition routerIDs.hpp:10
An ordered list of keyframes defining a camera animation.
Output of CameraSystem::update(ae::q20_12_t), consumed by gluLookAt().
All parameters needed to configure a CameraSystem in one call.
Set the CameraMode.
Sets the pointer to a CameraPath.
Event payload to set the character position data.
Activates the CameraSystem update loop.
Deactivates the CameraSystem update loop.