Brenta Engine 1.2
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...
 
struct  config
 

Public Types

enum class  camera_type { aircraft , spherical }
 
enum class  projection_type { perspective , orthographic }
 
enum class  camera_movement { forward , backward , left , right }
 Camera movement directions. More...
 

Public Member Functions

 camera ()=default
 Default constructor.
 
 camera (config conf)
 Constructor.
 
camera::camera_type get_camera_type ()
 
camera::projection_type get_projection_type ()
 
glm::vec3 get_position ()
 
glm::vec3 get_world_up ()
 
glm::vec3 get_center ()
 
float get_movement_speed ()
 
float get_mouse_sensitivity ()
 
float get_zoom ()
 
types::spherical_coordinates get_spherical_coordinates ()
 
types::euler_angles get_euler_angles ()
 
glm::mat4 get_view_matrix ()
 
glm::mat4 get_projection_matrix (int window_width, int window_height)
 
glm::vec3 get_front ()
 
glm::vec3 get_up ()
 
glm::vec3 get_right ()
 
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 (camera::camera_type camera_type)
 
void set_projection_type (camera::projection_type projection_type)
 
void set_world_up (glm::vec3 world_up)
 
void set_center (glm::vec3 center)
 
void set_movement_speed (float movement_speed)
 
void set_mouse_sensitivity (float mouse_sensitivity)
 
void set_zoom (float zoom)
 
void set_spherical_coordinates (types::spherical_coordinates spherical_coordinates)
 
void set_euler_angles (types::euler_angles euler_angles)
 
void set_front (glm::vec3 front)
 
void set_up (glm::vec3 up)
 
void set_right (glm::vec3 right)
 
void set_position (glm::vec3 position)
 
void set_first_mouse (bool first_mouse)
 
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

projection_type proj_type
 
camera_type cam_type
 
glm::vec3 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
 
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 prthographic.

Definition at line 96 of file camera.hpp.

Member Enumeration Documentation

◆ camera_movement

Camera movement directions.

Used to store the direction of the camera movement when reacting to keyboard input.

Definition at line 118 of file camera.hpp.

◆ camera_type

enum class brenta::camera::camera_type
strong

Definition at line 100 of file camera.hpp.

◆ projection_type

enum class brenta::camera::projection_type
strong

Definition at line 106 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 ( config conf)

Constructor.

Full constructor that initializes the camera with the specified values.

Definition at line 12 of file camera.cpp.

Member Function Documentation

◆ get_camera_type()

camera::camera_type camera::get_camera_type ( )

Definition at line 105 of file camera.cpp.

◆ get_center()

glm::vec3 camera::get_center ( )

Definition at line 145 of file camera.cpp.

◆ get_euler_angles()

types::euler_angles camera::get_euler_angles ( )

Definition at line 196 of file camera.cpp.

◆ get_first_mouse()

bool camera::get_first_mouse ( )

Get the first mouse flag.

Returns
boolean flag

Definition at line 236 of file camera.cpp.

◆ get_front()

glm::vec3 camera::get_front ( )

Definition at line 206 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 246 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 256 of file camera.cpp.

◆ get_mouse_sensitivity()

float camera::get_mouse_sensitivity ( )

Definition at line 165 of file camera.cpp.

◆ get_movement_speed()

float camera::get_movement_speed ( )

Definition at line 155 of file camera.cpp.

◆ get_position()

glm::vec3 camera::get_position ( )

Definition at line 125 of file camera.cpp.

◆ get_projection_matrix()

glm::mat4 camera::get_projection_matrix ( int window_width,
int window_height )

Definition at line 55 of file camera.cpp.

◆ get_projection_type()

camera::projection_type camera::get_projection_type ( )

Definition at line 115 of file camera.cpp.

◆ get_right()

glm::vec3 camera::get_right ( )

Definition at line 226 of file camera.cpp.

◆ get_spherical_coordinates()

types::spherical_coordinates camera::get_spherical_coordinates ( )

Definition at line 185 of file camera.cpp.

◆ get_up()

glm::vec3 camera::get_up ( )

Definition at line 216 of file camera.cpp.

◆ get_view_matrix()

glm::mat4 camera::get_view_matrix ( )

Definition at line 42 of file camera.cpp.

◆ get_world_up()

glm::vec3 camera::get_world_up ( )

Definition at line 135 of file camera.cpp.

◆ get_zoom()

float camera::get_zoom ( )

Definition at line 175 of file camera.cpp.

◆ set_camera_type()

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

Definition at line 110 of file camera.cpp.

◆ set_center()

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

Definition at line 150 of file camera.cpp.

◆ set_euler_angles()

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

Definition at line 201 of file camera.cpp.

◆ set_first_mouse()

void camera::set_first_mouse ( bool first_mouse)

Definition at line 241 of file camera.cpp.

◆ set_front()

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

Definition at line 211 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 251 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 261 of file camera.cpp.

◆ set_mouse_sensitivity()

void camera::set_mouse_sensitivity ( float mouse_sensitivity)

Definition at line 170 of file camera.cpp.

◆ set_movement_speed()

void camera::set_movement_speed ( float movement_speed)

Definition at line 160 of file camera.cpp.

◆ set_position()

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

Definition at line 130 of file camera.cpp.

◆ set_projection_type()

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

Definition at line 120 of file camera.cpp.

◆ set_right()

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

Definition at line 231 of file camera.cpp.

◆ set_spherical_coordinates()

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

Definition at line 190 of file camera.cpp.

◆ set_up()

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

Definition at line 221 of file camera.cpp.

◆ set_world_up()

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

Definition at line 140 of file camera.cpp.

◆ set_zoom()

void camera::set_zoom ( float zoom)

Definition at line 180 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 sets the correct position of the camera from the spherical coordinates.

Definition at line 74 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 90 of file camera.cpp.

Field Documentation

◆ cam_type

camera_type brenta::camera::cam_type

Definition at line 127 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 141 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 167 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 192 of file camera.hpp.

◆ front

glm::vec3 brenta::camera::front

Front vector.

This vector represents the front direction of the camera.

Definition at line 173 of file camera.hpp.

◆ last_x

float brenta::camera::last_x

Last x position of the mouse.

Definition at line 196 of file camera.hpp.

◆ last_y

float brenta::camera::last_y

Last y position of the mouse.

Definition at line 200 of file camera.hpp.

◆ mouse_sensitivity

float brenta::camera::mouse_sensitivity

Definition at line 146 of file camera.hpp.

◆ movement_speed

float brenta::camera::movement_speed

Space translational movement speed.

Definition at line 145 of file camera.hpp.

◆ position

glm::vec3 brenta::camera::position

Definition at line 128 of file camera.hpp.

◆ proj_type

projection_type brenta::camera::proj_type

Definition at line 126 of file camera.hpp.

◆ right

glm::vec3 brenta::camera::right

Right vector.

This vector represents the right direction of the camera.

Definition at line 185 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 159 of file camera.hpp.

◆ up

glm::vec3 brenta::camera::up

Up vector.

This vector represents the up direction of the camera.

Definition at line 179 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 134 of file camera.hpp.

◆ zoom

float brenta::camera::zoom

Zoom level (field of view)

Definition at line 150 of file camera.hpp.


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