Brenta Engine 1.1
Loading...
Searching...
No Matches
brenta::camera Class Reference

The Camera class. More...

#include <camera.hpp>

Data Structures

class  builder
 Builder pattern for the Camera class. More...
 

Public Member Functions

 camera ()=default
 Default constructor.
 
 camera (enums::camera_type camera_type, enums::projection_type projection_type, glm::vec3 position, glm::vec3 world_up, glm::vec3 center, float movement_speed, float mouse_sensitivity, float zoom, types::spherical_coordinates spherical_coordinates, types::euler_angles euler_angles, glm::vec3 front, glm::vec3 up, glm::vec3 right)
 Constructor.
 
enums::camera_type get_camera_type ()
 Get the camera type.
 
enums::projection_type get_projection_type ()
 Get the projection type.
 
glm::vec3 get_position ()
 Get the position of the camera.
 
glm::vec3 get_world_up ()
 Get the world up vector.
 
glm::vec3 get_center ()
 Get the center of the sphere.
 
float get_movement_speed ()
 Get the movement speed.
 
float get_mouse_sensitivity ()
 Get the mouse sensitivity.
 
float get_zoom ()
 Get the zoom level.
 
types::spherical_coordinates get_spherical_coordinates ()
 Get the spherical coordinates of the camera.
 
types::euler_angles get_euler_angles ()
 Get the euler angles of the camera.
 
glm::mat4 get_view_matrix ()
 Get the view matrix.
 
glm::mat4 get_projection_matrix ()
 Get the projection matrix.
 
glm::vec3 get_front ()
 Get the front vector.
 
glm::vec3 get_up ()
 Get the up vector.
 
glm::vec3 get_right ()
 Get the right vector.
 
bool get_first_mouse ()
 Get the first mouse flag.
 
float get_last_x ()
 Get the last x position of the mouse.
 
float get_last_y ()
 Get the last y position of the mouse.
 
void set_camera_type (enums::camera_type camera_type)
 Set the camera type.
 
void set_projection_type (enums::projection_type projection_type)
 Set the projection type.
 
void set_world_up (glm::vec3 world_up)
 Set the world up vector.
 
void set_center (glm::vec3 center)
 Set the center of the sphere.
 
void set_movement_speed (float movement_speed)
 Set the movement speed.
 
void set_mouse_sensitivity (float mouse_sensitivity)
 Set the mouse sensitivity.
 
void set_zoom (float zoom)
 Set the zoom level.
 
void set_spherical_coordinates (types::spherical_coordinates spherical_coordinates)
 Set the spherical coordinates of the camera.
 
void set_euler_angles (types::euler_angles euler_angles)
 Set the euler angles of the camera.
 
void set_front (glm::vec3 front)
 Set the front vector.
 
void set_up (glm::vec3 up)
 Set the up vector.
 
void set_right (glm::vec3 right)
 Set the right vector.
 
void set_position (glm::vec3 position)
 Set the position of the camera.
 
void set_first_mouse (bool first_mouse)
 Set the first mouse flag.
 
void set_last_x (float last_x)
 Set the last x position of the mouse.
 
void set_last_y (float last_y)
 Set the last y position of the mouse.
 
void update_camera_euler ()
 Update the camera euler angles.
 
void spherical_to_cartesian ()
 Update the camera spherical coordinates.
 

Data Fields

enums::projection_type projection_type
 Projection type.
 
enums::camera_type camera_type
 Camera type.
 
glm::vec3 position
 Camera position.
 
glm::vec3 world_up
 The world up vector.
 
glm::vec3 center
 The center of the spehere.
 
float movement_speed
 Space translational movement speed.
 
float mouse_sensitivity
 Mouse sensitivity.
 
float zoom
 Zoom level (field of view)
 
types::spherical_coordinates spherical_coordinates
 Spherical coordinates.
 
types::euler_angles euler_angles
 Euler angles.
 
glm::vec3 front
 Front vector.
 
glm::vec3 up
 Up vector.
 
glm::vec3 right
 Right vector.
 
bool first_mouse = true
 Is the first mouse movement?
 
float last_x
 Last x position of the mouse.
 
float last_y
 Last y position of the mouse.
 

Detailed Description

The Camera class.

This class represents a camera in the 3D world. It is used to define the position, orientation and projection of the camera. The class provides a Builder pattern to create a camera object, and it export a default global camera called "camera" that needs to be defined somewhere in the Brenta namespace.

Camera type

The camera can be of two types: AIRCRAFT or SPHERICAL. The AIRCRAFT type is used to represent a camera that moves in the world space, while the SPHERICAL type is used to represent a camera that rotates around a center point. They use respectively euler angles and spherical coordinates to represent the position of the camera.

Projection

The camera can have two types of projection: PERSPECTIVE or ORTHOGRAPHIC.

Definition at line 147 of file camera.hpp.

Constructor & Destructor Documentation

◆ camera() [1/2]

brenta::camera::camera ( )
default

Default constructor.

This constructor initializes the camera with default values.

◆ camera() [2/2]

camera::camera ( enums::camera_type camera_type,
enums::projection_type projection_type,
glm::vec3 position,
glm::vec3 world_up,
glm::vec3 center,
float movement_speed,
float mouse_sensitivity,
float zoom,
types::spherical_coordinates spherical_coordinates,
types::euler_angles euler_angles,
glm::vec3 front,
glm::vec3 up,
glm::vec3 right )

Constructor.

Full constructor that initializes the camera with the specified values.

Definition at line 36 of file camera.cpp.

Member Function Documentation

◆ get_camera_type()

enums::camera_type camera::get_camera_type ( )

Get the camera type.

Returns
The camera type

Definition at line 138 of file camera.cpp.

◆ get_center()

glm::vec3 camera::get_center ( )

Get the center of the sphere.

Returns
The center of the sphere

Definition at line 178 of file camera.cpp.

◆ get_euler_angles()

types::euler_angles camera::get_euler_angles ( )

Get the euler angles of the camera.

Returns
The euler angles of the camera

Definition at line 229 of file camera.cpp.

◆ get_first_mouse()

bool camera::get_first_mouse ( )

Get the first mouse flag.

Returns
boolean flag

Definition at line 269 of file camera.cpp.

◆ get_front()

glm::vec3 camera::get_front ( )

Get the front vector.

Returns
The front vector

Definition at line 239 of file camera.cpp.

◆ get_last_x()

float camera::get_last_x ( )

Get the last x position of the mouse.

Returns
The last x position of the mouse

Definition at line 279 of file camera.cpp.

◆ get_last_y()

float camera::get_last_y ( )

Get the last y position of the mouse.

Returns
The last y position of the mouse

Definition at line 289 of file camera.cpp.

◆ get_mouse_sensitivity()

float camera::get_mouse_sensitivity ( )

Get the mouse sensitivity.

Returns
The mouse sensitivity

Definition at line 198 of file camera.cpp.

◆ get_movement_speed()

float camera::get_movement_speed ( )

Get the movement speed.

Returns
The movement speed

Definition at line 188 of file camera.cpp.

◆ get_position()

glm::vec3 camera::get_position ( )

Get the position of the camera.

Returns
The position of the camera

Definition at line 158 of file camera.cpp.

◆ get_projection_matrix()

glm::mat4 camera::get_projection_matrix ( )

Get the projection matrix.

Returns
The projection matrix

Definition at line 88 of file camera.cpp.

◆ get_projection_type()

enums::projection_type camera::get_projection_type ( )

Get the projection type.

Returns
The projection type

Definition at line 148 of file camera.cpp.

◆ get_right()

glm::vec3 camera::get_right ( )

Get the right vector.

Returns
The right vector

Definition at line 259 of file camera.cpp.

◆ get_spherical_coordinates()

types::spherical_coordinates camera::get_spherical_coordinates ( )

Get the spherical coordinates of the camera.

Returns
The spherical coordinates of the camera

Definition at line 218 of file camera.cpp.

◆ get_up()

glm::vec3 camera::get_up ( )

Get the up vector.

Returns
The up vector

Definition at line 249 of file camera.cpp.

◆ get_view_matrix()

glm::mat4 camera::get_view_matrix ( )

Get the view matrix.

Returns
The view matrix

Definition at line 74 of file camera.cpp.

◆ get_world_up()

glm::vec3 camera::get_world_up ( )

Get the world up vector.

Returns
The world up vector

Definition at line 168 of file camera.cpp.

◆ get_zoom()

float camera::get_zoom ( )

Get the zoom level.

Returns
The zoom level

Definition at line 208 of file camera.cpp.

◆ set_camera_type()

void camera::set_camera_type ( enums::camera_type camera_type)

Set the camera type.

Parameters
camera_typeThe camera type

Definition at line 143 of file camera.cpp.

◆ set_center()

void camera::set_center ( glm::vec3 center)

Set the center of the sphere.

Parameters
centerThe center of the sphere

Definition at line 183 of file camera.cpp.

◆ set_euler_angles()

void camera::set_euler_angles ( types::euler_angles euler_angles)

Set the euler angles of the camera.

Parameters
eulerAnglesThe euler angles of the camera

Definition at line 234 of file camera.cpp.

◆ set_first_mouse()

void camera::set_first_mouse ( bool first_mouse)

Set the first mouse flag.

Parameters
firstMouseThe first mouse flag

Definition at line 274 of file camera.cpp.

◆ set_front()

void camera::set_front ( glm::vec3 front)

Set the front vector.

Parameters
frontThe front vector

Definition at line 244 of file camera.cpp.

◆ set_last_x()

void camera::set_last_x ( float last_x)

Set the last x position of the mouse.

Parameters
lastXThe last x position of the mouse

Definition at line 284 of file camera.cpp.

◆ set_last_y()

void camera::set_last_y ( float last_y)

Set the last y position of the mouse.

Parameters
lastYThe last y position of the mouse

Definition at line 294 of file camera.cpp.

◆ set_mouse_sensitivity()

void camera::set_mouse_sensitivity ( float mouse_sensitivity)

Set the mouse sensitivity.

Parameters
mouseSensitivityThe mouse sensitivity

Definition at line 203 of file camera.cpp.

◆ set_movement_speed()

void camera::set_movement_speed ( float movement_speed)

Set the movement speed.

Parameters
movementSpeedThe movement speed

Definition at line 193 of file camera.cpp.

◆ set_position()

void camera::set_position ( glm::vec3 position)

Set the position of the camera.

Parameters
positionThe position of the camera

Definition at line 163 of file camera.cpp.

◆ set_projection_type()

void camera::set_projection_type ( enums::projection_type projection_type)

Set the projection type.

Parameters
projection_typeThe projection type

Definition at line 153 of file camera.cpp.

◆ set_right()

void camera::set_right ( glm::vec3 right)

Set the right vector.

Parameters
rightThe right vector

Definition at line 264 of file camera.cpp.

◆ set_spherical_coordinates()

void camera::set_spherical_coordinates ( types::spherical_coordinates spherical_coordinates)

Set the spherical coordinates of the camera.

Parameters
sphericalCoordinatesThe spherical coordinates of the camera

Definition at line 223 of file camera.cpp.

◆ set_up()

void camera::set_up ( glm::vec3 up)

Set the up vector.

Parameters
upThe up vector

Definition at line 254 of file camera.cpp.

◆ set_world_up()

void camera::set_world_up ( glm::vec3 world_up)

Set the world up vector.

Parameters
worldUpThe world up vector

Definition at line 173 of file camera.cpp.

◆ set_zoom()

void camera::set_zoom ( float zoom)

Set the zoom level.

Parameters
zoomThe zoom level

Definition at line 213 of file camera.cpp.

◆ spherical_to_cartesian()

void camera::spherical_to_cartesian ( )

Update the camera spherical coordinates.

This function needs to be called every time the camera spherical coordinates are updated. It the correct position of the camera from the spherical coordinates.

Definition at line 107 of file camera.cpp.

◆ update_camera_euler()

void camera::update_camera_euler ( )

Update the camera euler angles.

This function needs to be called every time the camera euler angles are updated. It calculates the correct front, up and right vectors from the euler angles.

Definition at line 123 of file camera.cpp.

Field Documentation

◆ camera_type

enums::camera_type brenta::camera::camera_type

Camera type.

Definition at line 157 of file camera.hpp.

◆ center

glm::vec3 brenta::camera::center

The center of the spehere.

When using a spherical camera, this is the center of the sphere the camera is rotating around.

Definition at line 174 of file camera.hpp.

◆ euler_angles

types::euler_angles brenta::camera::euler_angles

Euler angles.

If the camera is of type AIRCRAFT, these are the euler angles of the camera. Euler angles are used to represent the orientation of a rigid body in 3D space, those are yaw, pitch and roll.

Definition at line 203 of file camera.hpp.

◆ first_mouse

bool brenta::camera::first_mouse = true

Is the first mouse movement?

This flag is used to check if the mouse movement is the first movement of the camera.

Definition at line 228 of file camera.hpp.

◆ front

glm::vec3 brenta::camera::front

Front vector.

This vector represents the front direction of the camera.

Definition at line 209 of file camera.hpp.

◆ last_x

float brenta::camera::last_x

Last x position of the mouse.

Definition at line 232 of file camera.hpp.

◆ last_y

float brenta::camera::last_y

Last y position of the mouse.

Definition at line 236 of file camera.hpp.

◆ mouse_sensitivity

float brenta::camera::mouse_sensitivity

Mouse sensitivity.

Definition at line 182 of file camera.hpp.

◆ movement_speed

float brenta::camera::movement_speed

Space translational movement speed.

Definition at line 178 of file camera.hpp.

◆ position

glm::vec3 brenta::camera::position

Camera position.

Definition at line 161 of file camera.hpp.

◆ projection_type

enums::projection_type brenta::camera::projection_type

Projection type.

Definition at line 153 of file camera.hpp.

◆ right

glm::vec3 brenta::camera::right

Right vector.

This vector represents the right direction of the camera.

Definition at line 221 of file camera.hpp.

◆ spherical_coordinates

types::spherical_coordinates brenta::camera::spherical_coordinates

Spherical coordinates.

If the camera is of type SPHERICAL, these are the spherical coordinates of the camera. Spherical coordinates are used to represent the position of a point in 3D space, those are theta, phi and radius.

Definition at line 195 of file camera.hpp.

◆ up

glm::vec3 brenta::camera::up

Up vector.

This vector represents the up direction of the camera.

Definition at line 215 of file camera.hpp.

◆ world_up

glm::vec3 brenta::camera::world_up

The world up vector.

This vector defines the up direction in the world space.

Definition at line 167 of file camera.hpp.

◆ zoom

float brenta::camera::zoom

Zoom level (field of view)

Definition at line 186 of file camera.hpp.


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