Brenta Engine 1.0
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::CameraType camera_type, Enums::ProjectionType projection_type, glm::vec3 position, glm::vec3 worldUp, glm::vec3 center, float movementSpeed, float mouseSensitivity, float zoom, Types::SphericalCoordinates sphericalCoordinates, Types::EulerAngles eulerAngles, glm::vec3 front, glm::vec3 up, glm::vec3 right)
 Constructor.
 
Enums::CameraType GetCameraType ()
 Get the camera type.
 
Enums::ProjectionType GetProjectionType ()
 Get the projection type.
 
glm::vec3 GetPosition ()
 Get the position of the camera.
 
glm::vec3 GetWorldUp ()
 Get the world up vector.
 
glm::vec3 GetCenter ()
 Get the center of the sphere.
 
float GetMovementSpeed ()
 Get the movement speed.
 
float GetMouseSensitivity ()
 Get the mouse sensitivity.
 
float GetZoom ()
 Get the zoom level.
 
Types::SphericalCoordinates GetSphericalCoordinates ()
 Get the spherical coordinates of the camera.
 
Types::EulerAngles GetEulerAngles ()
 Get the euler angles of the camera.
 
glm::mat4 GetViewMatrix ()
 Get the view matrix.
 
glm::mat4 GetProjectionMatrix ()
 Get the projection matrix.
 
glm::vec3 GetFront ()
 Get the front vector.
 
glm::vec3 GetUp ()
 Get the up vector.
 
glm::vec3 GetRight ()
 Get the right vector.
 
bool GetFirstMouse ()
 Get the first mouse flag.
 
float GetLastX ()
 Get the last x position of the mouse.
 
float GetLastY ()
 Get the last y position of the mouse.
 
void SetCameraType (Enums::CameraType camera_type)
 Set the camera type.
 
void SetProjectionType (Enums::ProjectionType projection_type)
 Set the projection type.
 
void SetWorldUp (glm::vec3 worldUp)
 Set the world up vector.
 
void SetCenter (glm::vec3 center)
 Set the center of the sphere.
 
void SetMovementSpeed (float movementSpeed)
 Set the movement speed.
 
void SetMouseSensitivity (float mouseSensitivity)
 Set the mouse sensitivity.
 
void SetZoom (float zoom)
 Set the zoom level.
 
void SetSphericalCoordinates (Types::SphericalCoordinates sphericalCoordinates)
 Set the spherical coordinates of the camera.
 
void SetEulerAngles (Types::EulerAngles eulerAngles)
 Set the euler angles of the camera.
 
void SetFront (glm::vec3 front)
 Set the front vector.
 
void SetUp (glm::vec3 up)
 Set the up vector.
 
void SetRight (glm::vec3 right)
 Set the right vector.
 
void SetPosition (glm::vec3 position)
 Set the position of the camera.
 
void SetFirstMouse (bool firstMouse)
 Set the first mouse flag.
 
void SetLastX (float lastX)
 Set the last x position of the mouse.
 
void SetLastY (float lastY)
 Set the last y position of the mouse.
 
void updateCameraEuler ()
 Update the camera euler angles.
 
void SphericalToCartesian ()
 Update the camera spherical coordinates.
 

Data Fields

Enums::ProjectionType ProjectionType
 Projection type.
 
Enums::CameraType CameraType
 Camera type.
 
glm::vec3 Position
 Camera position.
 
glm::vec3 WorldUp
 The world up vector.
 
glm::vec3 center
 The center of the spehere.
 
float MovementSpeed
 Space translational movement speed.
 
float MouseSensitivity
 Mouse sensitivity.
 
float Zoom
 Zoom level (field of view)
 
Types::SphericalCoordinates sphericalCoordinates
 Spherical coordinates.
 
Types::EulerAngles eulerAngles
 Euler angles.
 
glm::vec3 Front
 Front vector.
 
glm::vec3 Up
 Up vector.
 
glm::vec3 Right
 Right vector.
 
bool firstMouse = true
 Is the first mouse movement?
 
float lastX
 Last x position of the mouse.
 
float lastY
 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 119 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::CameraType camera_type,
Enums::ProjectionType projection_type,
glm::vec3 position,
glm::vec3 worldUp,
glm::vec3 center,
float movementSpeed,
float mouseSensitivity,
float zoom,
Types::SphericalCoordinates sphericalCoordinates,
Types::EulerAngles eulerAngles,
glm::vec3 front,
glm::vec3 up,
glm::vec3 right )

Constructor.

Full constructor that initializes the camera with the specified values.

Definition at line 37 of file camera.cpp.

Member Function Documentation

◆ GetCameraType()

Enums::CameraType Camera::GetCameraType ( )

Get the camera type.

Returns
The camera type

Definition at line 135 of file camera.cpp.

◆ GetCenter()

glm::vec3 Camera::GetCenter ( )

Get the center of the sphere.

Returns
The center of the sphere

Definition at line 175 of file camera.cpp.

◆ GetEulerAngles()

Types::EulerAngles Camera::GetEulerAngles ( )

Get the euler angles of the camera.

Returns
The euler angles of the camera

Definition at line 226 of file camera.cpp.

◆ GetFirstMouse()

bool Camera::GetFirstMouse ( )

Get the first mouse flag.

Returns
boolean flag

Definition at line 266 of file camera.cpp.

◆ GetFront()

glm::vec3 Camera::GetFront ( )

Get the front vector.

Returns
The front vector

Definition at line 236 of file camera.cpp.

◆ GetLastX()

float Camera::GetLastX ( )

Get the last x position of the mouse.

Returns
The last x position of the mouse

Definition at line 276 of file camera.cpp.

◆ GetLastY()

float Camera::GetLastY ( )

Get the last y position of the mouse.

Returns
The last y position of the mouse

Definition at line 286 of file camera.cpp.

◆ GetMouseSensitivity()

float Camera::GetMouseSensitivity ( )

Get the mouse sensitivity.

Returns
The mouse sensitivity

Definition at line 195 of file camera.cpp.

◆ GetMovementSpeed()

float Camera::GetMovementSpeed ( )

Get the movement speed.

Returns
The movement speed

Definition at line 185 of file camera.cpp.

◆ GetPosition()

glm::vec3 Camera::GetPosition ( )

Get the position of the camera.

Returns
The position of the camera

Definition at line 155 of file camera.cpp.

◆ GetProjectionMatrix()

glm::mat4 Camera::GetProjectionMatrix ( )

Get the projection matrix.

Returns
The projection matrix

Definition at line 88 of file camera.cpp.

◆ GetProjectionType()

Enums::ProjectionType Camera::GetProjectionType ( )

Get the projection type.

Returns
The projection type

Definition at line 145 of file camera.cpp.

◆ GetRight()

glm::vec3 Camera::GetRight ( )

Get the right vector.

Returns
The right vector

Definition at line 256 of file camera.cpp.

◆ GetSphericalCoordinates()

Types::SphericalCoordinates Camera::GetSphericalCoordinates ( )

Get the spherical coordinates of the camera.

Returns
The spherical coordinates of the camera

Definition at line 215 of file camera.cpp.

◆ GetUp()

glm::vec3 Camera::GetUp ( )

Get the up vector.

Returns
The up vector

Definition at line 246 of file camera.cpp.

◆ GetViewMatrix()

glm::mat4 Camera::GetViewMatrix ( )

Get the view matrix.

Returns
The view matrix

Definition at line 75 of file camera.cpp.

◆ GetWorldUp()

glm::vec3 Camera::GetWorldUp ( )

Get the world up vector.

Returns
The world up vector

Definition at line 165 of file camera.cpp.

◆ GetZoom()

float Camera::GetZoom ( )

Get the zoom level.

Returns
The zoom level

Definition at line 205 of file camera.cpp.

◆ SetCameraType()

void Camera::SetCameraType ( Enums::CameraType camera_type)

Set the camera type.

Parameters
camera_typeThe camera type

Definition at line 140 of file camera.cpp.

◆ SetCenter()

void Camera::SetCenter ( glm::vec3 center)

Set the center of the sphere.

Parameters
centerThe center of the sphere

Definition at line 180 of file camera.cpp.

◆ SetEulerAngles()

void Camera::SetEulerAngles ( Types::EulerAngles eulerAngles)

Set the euler angles of the camera.

Parameters
eulerAnglesThe euler angles of the camera

Definition at line 231 of file camera.cpp.

◆ SetFirstMouse()

void Camera::SetFirstMouse ( bool firstMouse)

Set the first mouse flag.

Parameters
firstMouseThe first mouse flag

Definition at line 271 of file camera.cpp.

◆ SetFront()

void Camera::SetFront ( glm::vec3 front)

Set the front vector.

Parameters
frontThe front vector

Definition at line 241 of file camera.cpp.

◆ SetLastX()

void Camera::SetLastX ( float lastX)

Set the last x position of the mouse.

Parameters
lastXThe last x position of the mouse

Definition at line 281 of file camera.cpp.

◆ SetLastY()

void Camera::SetLastY ( float lastY)

Set the last y position of the mouse.

Parameters
lastYThe last y position of the mouse

Definition at line 291 of file camera.cpp.

◆ SetMouseSensitivity()

void Camera::SetMouseSensitivity ( float mouseSensitivity)

Set the mouse sensitivity.

Parameters
mouseSensitivityThe mouse sensitivity

Definition at line 200 of file camera.cpp.

◆ SetMovementSpeed()

void Camera::SetMovementSpeed ( float movementSpeed)

Set the movement speed.

Parameters
movementSpeedThe movement speed

Definition at line 190 of file camera.cpp.

◆ SetPosition()

void Camera::SetPosition ( glm::vec3 position)

Set the position of the camera.

Parameters
positionThe position of the camera

Definition at line 160 of file camera.cpp.

◆ SetProjectionType()

void Camera::SetProjectionType ( Enums::ProjectionType projection_type)

Set the projection type.

Parameters
projection_typeThe projection type

Definition at line 150 of file camera.cpp.

◆ SetRight()

void Camera::SetRight ( glm::vec3 right)

Set the right vector.

Parameters
rightThe right vector

Definition at line 261 of file camera.cpp.

◆ SetSphericalCoordinates()

void Camera::SetSphericalCoordinates ( Types::SphericalCoordinates sphericalCoordinates)

Set the spherical coordinates of the camera.

Parameters
sphericalCoordinatesThe spherical coordinates of the camera

Definition at line 220 of file camera.cpp.

◆ SetUp()

void Camera::SetUp ( glm::vec3 up)

Set the up vector.

Parameters
upThe up vector

Definition at line 251 of file camera.cpp.

◆ SetWorldUp()

void Camera::SetWorldUp ( glm::vec3 worldUp)

Set the world up vector.

Parameters
worldUpThe world up vector

Definition at line 170 of file camera.cpp.

◆ SetZoom()

void Camera::SetZoom ( float zoom)

Set the zoom level.

Parameters
zoomThe zoom level

Definition at line 210 of file camera.cpp.

◆ SphericalToCartesian()

void Camera::SphericalToCartesian ( )

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.

◆ updateCameraEuler()

void Camera::updateCameraEuler ( )

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 120 of file camera.cpp.

Field Documentation

◆ CameraType

Enums::CameraType Brenta::Camera::CameraType

Camera type.

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

◆ eulerAngles

Types::EulerAngles Brenta::Camera::eulerAngles

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 175 of file camera.hpp.

◆ firstMouse

bool Brenta::Camera::firstMouse = 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 200 of file camera.hpp.

◆ Front

glm::vec3 Brenta::Camera::Front

Front vector.

This vector represents the front direction of the camera.

Definition at line 181 of file camera.hpp.

◆ lastX

float Brenta::Camera::lastX

Last x position of the mouse.

Definition at line 204 of file camera.hpp.

◆ lastY

float Brenta::Camera::lastY

Last y position of the mouse.

Definition at line 208 of file camera.hpp.

◆ MouseSensitivity

float Brenta::Camera::MouseSensitivity

Mouse sensitivity.

Definition at line 154 of file camera.hpp.

◆ MovementSpeed

float Brenta::Camera::MovementSpeed

Space translational movement speed.

Definition at line 150 of file camera.hpp.

◆ Position

glm::vec3 Brenta::Camera::Position

Camera position.

Definition at line 133 of file camera.hpp.

◆ ProjectionType

Enums::ProjectionType Brenta::Camera::ProjectionType

Projection type.

Definition at line 125 of file camera.hpp.

◆ Right

glm::vec3 Brenta::Camera::Right

Right vector.

This vector represents the right direction of the camera.

Definition at line 193 of file camera.hpp.

◆ sphericalCoordinates

Types::SphericalCoordinates Brenta::Camera::sphericalCoordinates

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 167 of file camera.hpp.

◆ Up

glm::vec3 Brenta::Camera::Up

Up vector.

This vector represents the up direction of the camera.

Definition at line 187 of file camera.hpp.

◆ WorldUp

glm::vec3 Brenta::Camera::WorldUp

The world up vector.

This vector defines the up direction in the world space.

Definition at line 139 of file camera.hpp.

◆ Zoom

float Brenta::Camera::Zoom

Zoom level (field of view)

Definition at line 158 of file camera.hpp.


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