Brenta Engine 1.1
|
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. | |
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.
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.
The camera can have two types of projection: PERSPECTIVE or ORTHOGRAPHIC.
Definition at line 147 of file camera.hpp.
|
default |
Default constructor.
This constructor initializes the camera with default values.
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.
enums::camera_type camera::get_camera_type | ( | ) |
glm::vec3 camera::get_center | ( | ) |
Get the center of the sphere.
Definition at line 178 of file camera.cpp.
types::euler_angles camera::get_euler_angles | ( | ) |
Get the euler angles of the camera.
Definition at line 229 of file camera.cpp.
bool camera::get_first_mouse | ( | ) |
glm::vec3 camera::get_front | ( | ) |
float camera::get_last_x | ( | ) |
Get the last x position of the mouse.
Definition at line 279 of file camera.cpp.
float camera::get_last_y | ( | ) |
Get the last y position of the mouse.
Definition at line 289 of file camera.cpp.
float camera::get_mouse_sensitivity | ( | ) |
float camera::get_movement_speed | ( | ) |
glm::vec3 camera::get_position | ( | ) |
Get the position of the camera.
Definition at line 158 of file camera.cpp.
glm::mat4 camera::get_projection_matrix | ( | ) |
enums::projection_type camera::get_projection_type | ( | ) |
glm::vec3 camera::get_right | ( | ) |
types::spherical_coordinates camera::get_spherical_coordinates | ( | ) |
Get the spherical coordinates of the camera.
Definition at line 218 of file camera.cpp.
glm::vec3 camera::get_up | ( | ) |
glm::mat4 camera::get_view_matrix | ( | ) |
glm::vec3 camera::get_world_up | ( | ) |
float camera::get_zoom | ( | ) |
void camera::set_camera_type | ( | enums::camera_type | camera_type | ) |
Set the camera type.
camera_type | The camera type |
Definition at line 143 of file camera.cpp.
void camera::set_center | ( | glm::vec3 | center | ) |
Set the center of the sphere.
center | The center of the sphere |
Definition at line 183 of file camera.cpp.
void camera::set_euler_angles | ( | types::euler_angles | euler_angles | ) |
Set the euler angles of the camera.
eulerAngles | The euler angles of the camera |
Definition at line 234 of file camera.cpp.
void camera::set_first_mouse | ( | bool | first_mouse | ) |
Set the first mouse flag.
firstMouse | The first mouse flag |
Definition at line 274 of file camera.cpp.
void camera::set_front | ( | glm::vec3 | front | ) |
void camera::set_last_x | ( | float | last_x | ) |
Set the last x position of the mouse.
lastX | The last x position of the mouse |
Definition at line 284 of file camera.cpp.
void camera::set_last_y | ( | float | last_y | ) |
Set the last y position of the mouse.
lastY | The last y position of the mouse |
Definition at line 294 of file camera.cpp.
void camera::set_mouse_sensitivity | ( | float | mouse_sensitivity | ) |
Set the mouse sensitivity.
mouseSensitivity | The mouse sensitivity |
Definition at line 203 of file camera.cpp.
void camera::set_movement_speed | ( | float | movement_speed | ) |
Set the movement speed.
movementSpeed | The movement speed |
Definition at line 193 of file camera.cpp.
void camera::set_position | ( | glm::vec3 | position | ) |
Set the position of the camera.
position | The position of the camera |
Definition at line 163 of file camera.cpp.
void camera::set_projection_type | ( | enums::projection_type | projection_type | ) |
Set the projection type.
projection_type | The projection type |
Definition at line 153 of file camera.cpp.
void camera::set_right | ( | glm::vec3 | right | ) |
void camera::set_spherical_coordinates | ( | types::spherical_coordinates | spherical_coordinates | ) |
Set the spherical coordinates of the camera.
sphericalCoordinates | The spherical coordinates of the camera |
Definition at line 223 of file camera.cpp.
void camera::set_up | ( | glm::vec3 | up | ) |
void camera::set_world_up | ( | glm::vec3 | world_up | ) |
Set the world up vector.
worldUp | The world up vector |
Definition at line 173 of file camera.cpp.
void camera::set_zoom | ( | float | zoom | ) |
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.
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.
enums::camera_type brenta::camera::camera_type |
Camera type.
Definition at line 157 of file camera.hpp.
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.
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.
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.
glm::vec3 brenta::camera::front |
Front vector.
This vector represents the front direction of the camera.
Definition at line 209 of file camera.hpp.
float brenta::camera::last_x |
Last x position of the mouse.
Definition at line 232 of file camera.hpp.
float brenta::camera::last_y |
Last y position of the mouse.
Definition at line 236 of file camera.hpp.
float brenta::camera::mouse_sensitivity |
Mouse sensitivity.
Definition at line 182 of file camera.hpp.
float brenta::camera::movement_speed |
Space translational movement speed.
Definition at line 178 of file camera.hpp.
glm::vec3 brenta::camera::position |
Camera position.
Definition at line 161 of file camera.hpp.
enums::projection_type brenta::camera::projection_type |
Projection type.
Definition at line 153 of file camera.hpp.
glm::vec3 brenta::camera::right |
Right vector.
This vector represents the right direction of the camera.
Definition at line 221 of file camera.hpp.
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.
glm::vec3 brenta::camera::up |
Up vector.
This vector represents the up direction of the camera.
Definition at line 215 of file camera.hpp.
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.
float brenta::camera::zoom |
Zoom level (field of view)
Definition at line 186 of file camera.hpp.