galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
Loading...
Searching...
No Matches
galaxy::Camera Class Referencefinal

Orthographic 2D camera. More...

#include <Camera.hpp>

+ Collaboration diagram for galaxy::Camera:

Classes

struct  Data
 Camera data. More...
 

Public Member Functions

 Camera () noexcept
 Constructor.
 
 Camera (Camera &&) noexcept
 Move constructor.
 
Cameraoperator= (Camera &&) noexcept
 Move assignment operator.
 
 Camera (const Camera &) noexcept
 Copy constructor.
 
Cameraoperator= (const Camera &) noexcept
 Copy assignment operator.
 
 ~Camera () noexcept
 Destructor.
 
void set_projection (const float left, const float right, const float bottom, const float top) noexcept
 Set camera projection.
 
void move (const float x, const float y) noexcept
 Move position.
 
void move_x (const float x) noexcept
 Move on x axis.
 
void move_y (const float y) noexcept
 Move on y axis.
 
void rotate (const float degrees) noexcept
 Rotate entity.
 
void scale (const float scale) noexcept
 Set entity scale.
 
void set_scale_horizontal (const float x) noexcept
 Set entity scale.
 
void set_scale_vertical (const float y) noexcept
 Set entity scale.
 
void set_rotation (const float degrees) noexcept
 Set camera rotation.
 
void set_positon (const float x, const float y) noexcept
 Set postion of camera.
 
void set_positon_horizontal (const float x) noexcept
 Set postion of camera.
 
void set_positon_vertical (const float y) noexcept
 Set postion of camera.
 
void set_origin (const float x, const float y) noexcept
 Set the origin point.
 
void reset () noexcept
 Reset transform.
 
const glm::vec2 & get_pos () const noexcept
 Get stored position.
 
float get_rotation () const noexcept
 Get stored rotation.
 
const glm::vec2 & get_scale () const noexcept
 Get stored scale.
 
const glm::vec2 & get_origin () const noexcept
 Get origin point.
 
glm::mat4 & get_transform () noexcept
 Retrieve internal transformation matrix.
 
const glm::mat4 & get_model_view () noexcept
 Retrieve internal transformation matrix.
 
const glm::mat4 & get_proj () noexcept
 Get the Camera projection.
 
Dataget_data () noexcept
 Get camera view and proj.
 

Public Attributes

bool m_allow_rotation
 Allow camera to rotate.
 
float m_translation_speed
 Movement speed.
 
float m_rotation_speed
 Rotational speed.
 

Private Member Functions

void recalculate () noexcept
 Recalculates the model view matrix.
 

Private Attributes

Data m_data
 Camera data.
 
glm::vec2 m_pos
 Cached for easy retrieval. Pos.
 
float m_rotation
 Cached for easy retrieval. Rotation.
 
glm::vec2 m_scale
 Cached for easy retrieval. Scale.
 
glm::vec2 m_origin
 Transform origin point.
 
bool m_dirty
 Flag to see if transform needs to be recalculated.
 
glm::mat4 m_transform
 Combined transform.
 

Detailed Description

Orthographic 2D camera.

Definition at line 19 of file Camera.hpp.

Constructor & Destructor Documentation

◆ Camera() [1/3]

galaxy::Camera::Camera ( )
noexcept

Constructor.

Definition at line 20 of file Camera.cpp.

◆ Camera() [2/3]

galaxy::Camera::Camera ( Camera && c)
noexcept

Move constructor.

Definition at line 32 of file Camera.cpp.

◆ Camera() [3/3]

galaxy::Camera::Camera ( const Camera & c)
noexcept

Copy constructor.

Definition at line 67 of file Camera.cpp.

◆ ~Camera()

galaxy::Camera::~Camera ( )
noexcept

Destructor.

Definition at line 102 of file Camera.cpp.

Member Function Documentation

◆ operator=() [1/2]

Camera & galaxy::Camera::operator= ( Camera && c)
noexcept

Move assignment operator.

Definition at line 47 of file Camera.cpp.

◆ operator=() [2/2]

Camera & galaxy::Camera::operator= ( const Camera & c)
noexcept

Copy assignment operator.

Definition at line 82 of file Camera.cpp.

◆ set_projection()

void galaxy::Camera::set_projection ( const float left,
const float right,
const float bottom,
const float top )
noexcept

Set camera projection.

By default sets origin to center of right, bottom.

Parameters
leftLeft point of ortho perspective.
rightRight point of ortho perspective.
bottomBottom point of ortho perspective.
topTop point of ortho perspective.

Definition at line 106 of file Camera.cpp.

◆ move()

void galaxy::Camera::move ( const float x,
const float y )
noexcept

Move position.

Parameters
xHow far to translate on x axis.
yHow far to translate on y axis.

Definition at line 117 of file Camera.cpp.

◆ move_x()

void galaxy::Camera::move_x ( const float x)
noexcept

Move on x axis.

Parameters
xHow far to translate on x axis.

Definition at line 125 of file Camera.cpp.

◆ move_y()

void galaxy::Camera::move_y ( const float y)
noexcept

Move on y axis.

Parameters
yHow far to translate on y axis.

Definition at line 131 of file Camera.cpp.

◆ rotate()

void galaxy::Camera::rotate ( const float degrees)
noexcept

Rotate entity.

Parameters
degreesAdditive. Min 0, max 360.

Definition at line 137 of file Camera.cpp.

◆ scale()

void galaxy::Camera::scale ( const float scale)
noexcept

Set entity scale.

Parameters
scaleValue to scale by.

Definition at line 145 of file Camera.cpp.

+ Here is the caller graph for this function:

◆ set_scale_horizontal()

void galaxy::Camera::set_scale_horizontal ( const float x)
noexcept

Set entity scale.

Parameters
xValue to scale horizontal axis by.

Definition at line 153 of file Camera.cpp.

◆ set_scale_vertical()

void galaxy::Camera::set_scale_vertical ( const float y)
noexcept

Set entity scale.

Parameters
yValue to scale vertical axis by.

Definition at line 159 of file Camera.cpp.

◆ set_rotation()

void galaxy::Camera::set_rotation ( const float degrees)
noexcept

Set camera rotation.

Parameters
degreesMin 0, max 360.

Definition at line 165 of file Camera.cpp.

◆ set_positon()

void galaxy::Camera::set_positon ( const float x,
const float y )
noexcept

Set postion of camera.

Parameters
xX axis.
yY axis.

Definition at line 171 of file Camera.cpp.

◆ set_positon_horizontal()

void galaxy::Camera::set_positon_horizontal ( const float x)
noexcept

Set postion of camera.

Parameters
xX axis.

Definition at line 179 of file Camera.cpp.

◆ set_positon_vertical()

void galaxy::Camera::set_positon_vertical ( const float y)
noexcept

Set postion of camera.

Parameters
yY axis.

Definition at line 185 of file Camera.cpp.

◆ set_origin()

void galaxy::Camera::set_origin ( const float x,
const float y )
noexcept

Set the origin point.

Only affects rotation and scale.

Parameters
xX position to set origin to.
yY position to set origin to.

Definition at line 191 of file Camera.cpp.

◆ reset()

void galaxy::Camera::reset ( )
noexcept

Reset transform.

Definition at line 199 of file Camera.cpp.

◆ get_pos()

const glm::vec2 & galaxy::Camera::get_pos ( ) const
nodiscardnoexcept

Get stored position.

Returns
Const glm::vec2 reference.

Definition at line 209 of file Camera.cpp.

◆ get_rotation()

float galaxy::Camera::get_rotation ( ) const
nodiscardnoexcept

Get stored rotation.

Returns
Float.

Definition at line 214 of file Camera.cpp.

◆ get_scale()

const glm::vec2 & galaxy::Camera::get_scale ( ) const
nodiscardnoexcept

Get stored scale.

Returns
Const glm::vec2 reference.

Definition at line 219 of file Camera.cpp.

◆ get_origin()

const glm::vec2 & galaxy::Camera::get_origin ( ) const
nodiscardnoexcept

Get origin point.

Returns
Const glm::vec2 reference.

Definition at line 224 of file Camera.cpp.

◆ get_transform()

glm::mat4 & galaxy::Camera::get_transform ( )
nodiscardnoexcept

Retrieve internal transformation matrix.

Returns
glm::mat4 reference.

Definition at line 229 of file Camera.cpp.

+ Here is the call graph for this function:

◆ get_model_view()

const glm::mat4 & galaxy::Camera::get_model_view ( )
nodiscardnoexcept

Retrieve internal transformation matrix.

Returns
Reference to internal glm::mat4.

Definition at line 235 of file Camera.cpp.

+ Here is the call graph for this function:

◆ get_proj()

const glm::mat4 & galaxy::Camera::get_proj ( )
nodiscardnoexcept

Get the Camera projection.

Returns
Const glm::mat4 reference.

Definition at line 241 of file Camera.cpp.

◆ get_data()

Camera::Data & galaxy::Camera::get_data ( )
nodiscardnoexcept

Get camera view and proj.

Returns
Reference to camera data.

Definition at line 246 of file Camera.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ recalculate()

void galaxy::Camera::recalculate ( )
privatenoexcept

Recalculates the model view matrix.

Definition at line 252 of file Camera.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_allow_rotation

bool galaxy::Camera::m_allow_rotation

Allow camera to rotate.

Definition at line 248 of file Camera.hpp.

◆ m_translation_speed

float galaxy::Camera::m_translation_speed

Movement speed.

Definition at line 253 of file Camera.hpp.

◆ m_rotation_speed

float galaxy::Camera::m_rotation_speed

Rotational speed.

Definition at line 258 of file Camera.hpp.

◆ m_data

Data galaxy::Camera::m_data
private

Camera data.

Definition at line 264 of file Camera.hpp.

◆ m_pos

glm::vec2 galaxy::Camera::m_pos
private

Cached for easy retrieval. Pos.

Definition at line 270 of file Camera.hpp.

◆ m_rotation

float galaxy::Camera::m_rotation
private

Cached for easy retrieval. Rotation.

Definition at line 276 of file Camera.hpp.

◆ m_scale

glm::vec2 galaxy::Camera::m_scale
private

Cached for easy retrieval. Scale.

Definition at line 282 of file Camera.hpp.

◆ m_origin

glm::vec2 galaxy::Camera::m_origin
private

Transform origin point.

Definition at line 287 of file Camera.hpp.

◆ m_dirty

bool galaxy::Camera::m_dirty
private

Flag to see if transform needs to be recalculated.

Definition at line 292 of file Camera.hpp.

◆ m_transform

glm::mat4 galaxy::Camera::m_transform
private

Combined transform.

Definition at line 297 of file Camera.hpp.


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