persona-3-dual
A DS demake of Persona 3
Loading...
Searching...
No Matches
CameraSystem Class Reference

#include <CameraSystem.hpp>

Inheritance diagram for CameraSystem:
Collaboration diagram for CameraSystem:

Public Member Functions

void init () override
void shutdown () override
void update (ae::q20_12_t) override
 Core update loop that advances camera state and broadcasts the resulting gluLookAt arguments.
void on_receive (const Event::ConfigureCamera &config)
 ETL message handler to configure the camera settings.
void on_receive (const Event::SetCameraMode &msg)
 ETL message handler to set the active camera mode at runtime.
void on_receive (const Event::SetCameraPath &msg)
 ETL message handler to set the path used by CameraMode::Path and rewinds playback.
void on_receive (const Event::SetCharacterPosition &msg)
 ETL message handler to set the character position.
void on_receive (const Event::StartCamera &msg)
 ETL message handler to make the Camera active.
void on_receive (const Event::StopCamera &msg)
 ETL message handler to disable the Camera.
void on_receive_unknown (const etl::imessage &msg)
 Fallback handler for unhandled ETL messages.
CameraMode getMode () const
 Returns the current camera mode.
ae::q20_12_t getAngle () const
 Returns the current orbit angle in radians.
bool isPathComplete () const
 Returns true once the Path playback has reached its last keyframe.
ae::q20_12_t getMovementAngle () const
 Returns the angle that maps the UP key to "move away from camera".
Event::CameraPosition getCameraPosition () const
 Returns the camera position.

Private Member Functions

 CameraSystem ()

Private Attributes

MathManager & math = MathManager::getInstance()
CameraMode mode = CameraMode::Follow
Vec3< ae::q20_12_t > currentPos = {}
Vec3< ae::q20_12_t > targetPos = {}
CharacterPosition charPos
Event::CameraPosition camPos = {}
ae::q20_12_t angle {0}
ae::q20_12_t distance {1.5}
ae::q20_12_t height {0.6}
ae::q20_12_t lookAhead {0.5}
ae::q20_12_t angleIncrement {0.05}
ae::q20_12_t freeCameraSpeed {0.02}
bool isRotationLocked = false
const CameraPath * path = nullptr
int pathFrame = 0
int pathKeyIndex = 0
bool pathDone = false
bool freeInitialised = false

Friends

class Singleton< CameraSystem >

Detailed Description

Definition at line 25 of file CameraSystem.hpp.

Constructor & Destructor Documentation

◆ CameraSystem()

CameraSystem::CameraSystem ( )
inlineprivate

Definition at line 162 of file CameraSystem.hpp.

Member Function Documentation

◆ getAngle()

ae::q20_12_t CameraSystem::getAngle ( ) const
inline

Returns the current orbit angle in radians.

Definition at line 120 of file CameraSystem.hpp.

◆ getCameraPosition()

Event::CameraPosition CameraSystem::getCameraPosition ( ) const
inline

Returns the camera position.

camPos gets updated in the CameraSystem:update(ae::q20_12_t) loop. This is a temporary helper function that should get removed while certain parts of the game still do not comply with aegis-engine.

Todo
In practice, code that needs to recieve the CameraPosition should capture CameraPosition as a Event, which automatically gets broadcasted during the CameraSystem::update(ae::q20_12_t) loop.
Returns
The latest camera position.

Definition at line 155 of file CameraSystem.hpp.

◆ getMode()

CameraMode CameraSystem::getMode ( ) const
inline

Returns the current camera mode.

Definition at line 114 of file CameraSystem.hpp.

◆ getMovementAngle()

ae::q20_12_t CameraSystem::getMovementAngle ( ) const

Returns the angle that maps the UP key to "move away from camera".

For Follow/Free returns the current orbit angle. For CCTV/Static computes atan2 from the fixed eye position toward the character, so movement direction stays correct regardless of where the camera is mounted.

Returns
Angle in radians.

Definition at line 56 of file CameraSystem.cpp.

◆ init()

void CameraSystem::init ( )
override

Definition at line 69 of file CameraSystem.cpp.

◆ isPathComplete()

bool CameraSystem::isPathComplete ( ) const
inline

Returns true once the Path playback has reached its last keyframe.

Definition at line 126 of file CameraSystem.hpp.

◆ on_receive() [1/6]

void CameraSystem::on_receive ( const Event::ConfigureCamera & config)

ETL message handler to configure the camera settings.

Resets all tuning parameters and mode from config. Call this after setupCamera() sets up the room-specific CameraConfig.

Required to call in order to enable the CameraSystem

Parameters
configThe event payload containing the camera configuration to apply.

Definition at line 4 of file CameraSystem.cpp.

◆ on_receive() [2/6]

void CameraSystem::on_receive ( const Event::SetCameraMode & msg)

ETL message handler to set the active camera mode at runtime.

Parameters
msgThe event payload containing the camera mode to apply.

Definition at line 18 of file CameraSystem.cpp.

◆ on_receive() [3/6]

void CameraSystem::on_receive ( const Event::SetCameraPath & msg)

ETL message handler to set the path used by CameraMode::Path and rewinds playback.

Call this before switching mode to Path. The pointer must remain valid for the lifetime of the playback.

Parameters
msgThe event payload containing the pointer to the CameraPath to play. Must not be null

Definition at line 33 of file CameraSystem.cpp.

◆ on_receive() [4/6]

void CameraSystem::on_receive ( const Event::SetCharacterPosition & msg)

ETL message handler to set the character position.

Parameters
msgThe event payload containing the pointer to CharacterPosition

Definition at line 41 of file CameraSystem.cpp.

◆ on_receive() [5/6]

void CameraSystem::on_receive ( const Event::StartCamera & msg)

ETL message handler to make the Camera active.

Parameters
msgThe event payload (unused)

Definition at line 46 of file CameraSystem.cpp.

◆ on_receive() [6/6]

void CameraSystem::on_receive ( const Event::StopCamera & msg)

ETL message handler to disable the Camera.

Parameters
msgThe event payload (unused)

Definition at line 51 of file CameraSystem.cpp.

◆ on_receive_unknown()

void CameraSystem::on_receive_unknown ( const etl::imessage & msg)
inline

Fallback handler for unhandled ETL messages.

Required by the ETL message router interface. Safely ignores any messages routed to the CameraSystem that do not have a specific handler.

Parameters
msgThe unhandled incoming message (unused).

Definition at line 109 of file CameraSystem.hpp.

◆ shutdown()

void CameraSystem::shutdown ( )
override

Definition at line 74 of file CameraSystem.cpp.

◆ update()

void CameraSystem::update ( ae::q20_12_t )
override

Core update loop that advances camera state and broadcasts the resulting gluLookAt arguments.

Parameters
dtFixed-point delta time passed from the aegis engine loop (currently unused).

Definition at line 79 of file CameraSystem.cpp.

◆ Singleton< CameraSystem >

friend class Singleton< CameraSystem >
friend

Definition at line 155 of file CameraSystem.hpp.

Member Data Documentation

◆ angle

ae::q20_12_t CameraSystem::angle {0}
private

Definition at line 176 of file CameraSystem.hpp.

◆ angleIncrement

ae::q20_12_t CameraSystem::angleIncrement {0.05}
private

Definition at line 180 of file CameraSystem.hpp.

◆ camPos

Event::CameraPosition CameraSystem::camPos = {}
private

Definition at line 175 of file CameraSystem.hpp.

◆ charPos

CharacterPosition CameraSystem::charPos
private

Definition at line 173 of file CameraSystem.hpp.

◆ currentPos

Vec3<ae::q20_12_t> CameraSystem::currentPos = {}
private

Definition at line 170 of file CameraSystem.hpp.

◆ distance

ae::q20_12_t CameraSystem::distance {1.5}
private

Definition at line 177 of file CameraSystem.hpp.

◆ freeCameraSpeed

ae::q20_12_t CameraSystem::freeCameraSpeed {0.02}
private

Definition at line 181 of file CameraSystem.hpp.

◆ freeInitialised

bool CameraSystem::freeInitialised = false
private

Definition at line 191 of file CameraSystem.hpp.

◆ height

ae::q20_12_t CameraSystem::height {0.6}
private

Definition at line 178 of file CameraSystem.hpp.

◆ isRotationLocked

bool CameraSystem::isRotationLocked = false
private

Definition at line 182 of file CameraSystem.hpp.

◆ lookAhead

ae::q20_12_t CameraSystem::lookAhead {0.5}
private

Definition at line 179 of file CameraSystem.hpp.

◆ math

MathManager& CameraSystem::math = MathManager::getInstance()
private

Definition at line 166 of file CameraSystem.hpp.

◆ mode

CameraMode CameraSystem::mode = CameraMode::Follow
private

Definition at line 168 of file CameraSystem.hpp.

◆ path

const CameraPath* CameraSystem::path = nullptr
private

Definition at line 185 of file CameraSystem.hpp.

◆ pathDone

bool CameraSystem::pathDone = false
private

Definition at line 188 of file CameraSystem.hpp.

◆ pathFrame

int CameraSystem::pathFrame = 0
private

Definition at line 186 of file CameraSystem.hpp.

◆ pathKeyIndex

int CameraSystem::pathKeyIndex = 0
private

Definition at line 187 of file CameraSystem.hpp.

◆ targetPos

Vec3<ae::q20_12_t> CameraSystem::targetPos = {}
private

Definition at line 171 of file CameraSystem.hpp.


The documentation for this class was generated from the following files: