Engine²
Open-source game engine written in C++.
Loading...
Searching...
No Matches
CameraMovement::Resource::CameraManager Class Reference

CameraManager is a resource that manages the active camera entity. More...

#include <CameraManager.hpp>

Public Member Functions

 CameraManager (Engine::Core &core)
 ~CameraManager ()=default
void SetActiveCamera (Engine::Entity entity)
 Set the active camera entity.
Engine::Entity GetActiveCamera () const
 Get the active camera entity.
bool HasValidCamera () const
 Check if the camera entity is set and valid.
void SetMovementSpeed (float speed)
 Set the movement speed of the camera.
float GetMovementSpeed () const
 Get the movement speed of the camera.
void SetMouseSensitivity (float sensitivity)
 Set the mouse sensitivity of the camera.
float GetMouseSensitivity () const
 Get the mouse sensitivity of the camera.
void SetLastMousePosition (double x, double y)
 Set the last mouse position.
double GetLastMouseX () const
 Get the last mouse X position.
double GetLastMouseY () const
 Get the last mouse Y position.
void SetMouseDragging (bool dragging)
 Set whether the mouse is being dragged.
bool IsMouseDragging () const
 Check if the mouse is being dragged.
void SetOriginRotation (const glm::quat &rotation)
 Set the origin rotation (used for mouse dragging).
const glm::quat & GetOriginRotation () const
 Get the origin rotation.
void SetWasCursorMasked (bool masked)
 Set whether the cursor was masked in the previous frame.
bool WasCursorMasked () const
 Check if the cursor was masked in the previous frame.
Engine::CoreGetCore ()
 Get the core reference.
void SetJoystickId (int joystickId)
 Set the joystick ID to use for camera control.
int GetJoystickId () const
 Get the joystick ID used for camera control.
void SetBehavior (std::shared_ptr< CameraMovement::Utils::ICameraBehavior > behavior)
 Set the camera behavior instance.
std::shared_ptr< CameraMovement::Utils::ICameraBehaviorGetBehavior () const
 Get the current camera behavior instance.

Private Attributes

Engine::Core_core
std::optional< Engine::Entity_cameraEntity = std::nullopt
float _movementSpeed = 5.0f
float _mouseSensitivity = 0.002f
double _lastMouseX = 0.0
double _lastMouseY = 0.0
bool _isMouseDragging = false
bool _wasCursorMasked = false
glm::quat _originRotation = glm::quat(1.0f, 0.0f, 0.0f, 0.0f)
int _joystickId = GLFW_JOYSTICK_1
std::shared_ptr< CameraMovement::Utils::ICameraBehavior_behavior = nullptr

Detailed Description

CameraManager is a resource that manages the active camera entity.

The camera entity must have both a Transform and a Camera component. This resource is initialized with late binding - the camera entity is set after plugin binding.

Constructor & Destructor Documentation

◆ CameraManager()

CameraMovement::Resource::CameraManager::CameraManager ( Engine::Core & core)
inlineexplicit

◆ ~CameraManager()

CameraMovement::Resource::CameraManager::~CameraManager ( )
default

Member Function Documentation

◆ GetActiveCamera()

Engine::Entity CameraMovement::Resource::CameraManager::GetActiveCamera ( ) const
inline

Get the active camera entity.

Returns
The active camera entity.
Exceptions
CameraMovementErrorif the camera entity is not set or invalid.

◆ GetBehavior()

std::shared_ptr< CameraMovement::Utils::ICameraBehavior > CameraMovement::Resource::CameraManager::GetBehavior ( ) const
inline

Get the current camera behavior instance.

Returns
Shared pointer to the current ICameraBehavior, or nullptr if none is set.

◆ GetCore()

Engine::Core & CameraMovement::Resource::CameraManager::GetCore ( )
inline

Get the core reference.

Returns
The core reference.

◆ GetJoystickId()

int CameraMovement::Resource::CameraManager::GetJoystickId ( ) const
inline

Get the joystick ID used for camera control.

Returns
The GLFW joystick ID.

◆ GetLastMouseX()

double CameraMovement::Resource::CameraManager::GetLastMouseX ( ) const
inline

Get the last mouse X position.

Returns
The last mouse X position.

◆ GetLastMouseY()

double CameraMovement::Resource::CameraManager::GetLastMouseY ( ) const
inline

Get the last mouse Y position.

Returns
The last mouse Y position.

◆ GetMouseSensitivity()

float CameraMovement::Resource::CameraManager::GetMouseSensitivity ( ) const
inline

Get the mouse sensitivity of the camera.

Returns
The mouse sensitivity.

◆ GetMovementSpeed()

float CameraMovement::Resource::CameraManager::GetMovementSpeed ( ) const
inline

Get the movement speed of the camera.

Returns
The movement speed.

◆ GetOriginRotation()

const glm::quat & CameraMovement::Resource::CameraManager::GetOriginRotation ( ) const
inline

Get the origin rotation.

Returns
The origin rotation.

◆ HasValidCamera()

bool CameraMovement::Resource::CameraManager::HasValidCamera ( ) const
inline

Check if the camera entity is set and valid.

Returns
True if the camera is set and valid, false otherwise.

◆ IsMouseDragging()

bool CameraMovement::Resource::CameraManager::IsMouseDragging ( ) const
inline

Check if the mouse is being dragged.

Returns
True if dragging, false otherwise.

◆ SetActiveCamera()

void CameraMovement::Resource::CameraManager::SetActiveCamera ( Engine::Entity entity)
inline

Set the active camera entity.

Parameters
entityThe entity to use as the camera.
Exceptions
CameraMovementErrorif the entity is invalid or missing required components.

◆ SetBehavior()

void CameraMovement::Resource::CameraManager::SetBehavior ( std::shared_ptr< CameraMovement::Utils::ICameraBehavior > behavior)
inline

Set the camera behavior instance.

Parameters
behaviorShared pointer to an implementation of ICameraBehavior.

◆ SetJoystickId()

void CameraMovement::Resource::CameraManager::SetJoystickId ( int joystickId)
inline

Set the joystick ID to use for camera control.

Parameters
joystickIdThe GLFW joystick ID (e.g., GLFW_JOYSTICK_1).

◆ SetLastMousePosition()

void CameraMovement::Resource::CameraManager::SetLastMousePosition ( double x,
double y )
inline

Set the last mouse position.

Parameters
xThe x position.
yThe y position.

◆ SetMouseDragging()

void CameraMovement::Resource::CameraManager::SetMouseDragging ( bool dragging)
inline

Set whether the mouse is being dragged.

Parameters
draggingTrue if dragging, false otherwise.

◆ SetMouseSensitivity()

void CameraMovement::Resource::CameraManager::SetMouseSensitivity ( float sensitivity)
inline

Set the mouse sensitivity of the camera.

Parameters
sensitivityThe mouse sensitivity.

◆ SetMovementSpeed()

void CameraMovement::Resource::CameraManager::SetMovementSpeed ( float speed)
inline

Set the movement speed of the camera.

Parameters
speedThe movement speed.

◆ SetOriginRotation()

void CameraMovement::Resource::CameraManager::SetOriginRotation ( const glm::quat & rotation)
inline

Set the origin rotation (used for mouse dragging).

Parameters
rotationThe origin rotation.

◆ SetWasCursorMasked()

void CameraMovement::Resource::CameraManager::SetWasCursorMasked ( bool masked)
inline

Set whether the cursor was masked in the previous frame.

Parameters
maskedTrue if cursor was masked, false otherwise.

◆ WasCursorMasked()

bool CameraMovement::Resource::CameraManager::WasCursorMasked ( ) const
inline

Check if the cursor was masked in the previous frame.

Returns
True if cursor was masked, false otherwise.

Member Data Documentation

◆ _behavior

std::shared_ptr<CameraMovement::Utils::ICameraBehavior> CameraMovement::Resource::CameraManager::_behavior = nullptr
private

◆ _cameraEntity

std::optional<Engine::Entity> CameraMovement::Resource::CameraManager::_cameraEntity = std::nullopt
private

◆ _core

Engine::Core& CameraMovement::Resource::CameraManager::_core
private

◆ _isMouseDragging

bool CameraMovement::Resource::CameraManager::_isMouseDragging = false
private

◆ _joystickId

int CameraMovement::Resource::CameraManager::_joystickId = GLFW_JOYSTICK_1
private

◆ _lastMouseX

double CameraMovement::Resource::CameraManager::_lastMouseX = 0.0
private

◆ _lastMouseY

double CameraMovement::Resource::CameraManager::_lastMouseY = 0.0
private

◆ _mouseSensitivity

float CameraMovement::Resource::CameraManager::_mouseSensitivity = 0.002f
private

◆ _movementSpeed

float CameraMovement::Resource::CameraManager::_movementSpeed = 5.0f
private

◆ _originRotation

glm::quat CameraMovement::Resource::CameraManager::_originRotation = glm::quat(1.0f, 0.0f, 0.0f, 0.0f)
private

◆ _wasCursorMasked

bool CameraMovement::Resource::CameraManager::_wasCursorMasked = false
private

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