matf-rg-engine  1.0.0
Base for project for the Computer Graphics course at Faculty of Mathematics, University of Belgrade
Public Types | Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | List of all members
engine::graphics::Camera Class Reference

Camera processes input and calculates the corresponding Euler Angles, Vectors and Matrices for use in OpenGL. More...

#include <Camera.hpp>

Public Types

enum  Movement {
  None , FORWARD , BACKWARD , LEFT ,
  RIGHT , UP , DOWN
}
 Defines several possible options for camera movement. Used as abstraction to stay away from window-system specific input methods. More...
 

Public Member Functions

 Camera (glm::vec3 position=glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3 up=glm::vec3(0.0f, 1.0f, 0.0f), float yaw=YAW, float pitch=PITCH)
 constructor with vectors. More...
 
 Camera (float posX, float posY, float posZ, float upX, float upY, float upZ, float yaw, float pitch)
 constructor with scalar values. More...
 
glm::mat4 view_matrix () const
 
void move_camera (Movement direction, float deltaTime)
 Processes input received from any keyboard-like input system. Accepts input parameter in the form of camera defined ENUM (to abstract it from windowing systems). More...
 
void rotate_camera (float x_offset, float y_offset, bool constrainPitch=true)
 Processes input received from a mouse input system. Expects the offset value in both the x and y direction. More...
 
void zoom (float offset)
 Processes input received from a mouse scroll-wheel event. Only requires to be input on the vertical wheel-axis. More...
 

Public Attributes

glm::vec3 Position {}
 Defines a position in World-Space of where the Camera is located. More...
 
glm::vec3 Front {}
 Defines a vector in which the camera is pointed relative to the Camera::Position. More...
 
glm::vec3 Up {}
 Defines the Up vector in the World-Space. More...
 
glm::vec3 Right {}
 Defines the camera Right vector. More...
 
glm::vec3 WorldUp {}
 Defines the up orientation of the World-Space. More...
 
float Yaw {}
 
float Pitch {}
 
float MovementSpeed {}
 Used in Camera::move_camera. The higher the value the faster the camera will move on keyboard action. More...
 
float MouseSensitivity {}
 Used in Camera::rotate_camera. The higher the value the faster the camera will move on mouse action. More...
 
float Zoom {}
 Defines camera FOV. More...
 

Static Public Attributes

static constexpr float YAW = -90.0f
 Default camera values. More...
 
static constexpr float PITCH = 0.0f
 
static constexpr float SPEED = 2.5f
 
static constexpr float SENSITIVITY = 0.1f
 
static constexpr float ZOOM = 45.0f
 

Private Member Functions

void update_camera_vectors ()
 Calculates the front vector from the Camera's (updated) Euler Angles. More...
 

Detailed Description

Camera processes input and calculates the corresponding Euler Angles, Vectors and Matrices for use in OpenGL.

Member Enumeration Documentation

◆ Movement

Defines several possible options for camera movement. Used as abstraction to stay away from window-system specific input methods.

Enumerator
None 
FORWARD 
BACKWARD 
LEFT 
RIGHT 
UP 
DOWN 

Constructor & Destructor Documentation

◆ Camera() [1/2]

engine::graphics::Camera::Camera ( glm::vec3  position = glm::vec3(0.0f, 0.0f, 0.0f),
glm::vec3  up = glm::vec3(0.0f, 1.0f, 0.0f),
float  yaw = YAW,
float  pitch = PITCH 
)
explicit

constructor with vectors.

◆ Camera() [2/2]

engine::graphics::Camera::Camera ( float  posX,
float  posY,
float  posZ,
float  upX,
float  upY,
float  upZ,
float  yaw,
float  pitch 
)

constructor with scalar values.

Member Function Documentation

◆ view_matrix()

glm::mat4 engine::graphics::Camera::view_matrix ( ) const
Returns
returns the view matrix calculated using Euler Angles and the LookAt Matrix.

◆ move_camera()

void engine::graphics::Camera::move_camera ( Movement  direction,
float  deltaTime 
)

Processes input received from any keyboard-like input system. Accepts input parameter in the form of camera defined ENUM (to abstract it from windowing systems).

◆ rotate_camera()

void engine::graphics::Camera::rotate_camera ( float  x_offset,
float  y_offset,
bool  constrainPitch = true 
)

Processes input received from a mouse input system. Expects the offset value in both the x and y direction.

◆ zoom()

void engine::graphics::Camera::zoom ( float  offset)

Processes input received from a mouse scroll-wheel event. Only requires to be input on the vertical wheel-axis.

◆ update_camera_vectors()

void engine::graphics::Camera::update_camera_vectors ( )
private

Calculates the front vector from the Camera's (updated) Euler Angles.

Member Data Documentation

◆ YAW

constexpr float engine::graphics::Camera::YAW = -90.0f
staticconstexpr

Default camera values.

◆ PITCH

constexpr float engine::graphics::Camera::PITCH = 0.0f
staticconstexpr

◆ SPEED

constexpr float engine::graphics::Camera::SPEED = 2.5f
staticconstexpr

◆ SENSITIVITY

constexpr float engine::graphics::Camera::SENSITIVITY = 0.1f
staticconstexpr

◆ ZOOM

constexpr float engine::graphics::Camera::ZOOM = 45.0f
staticconstexpr

◆ Position

glm::vec3 engine::graphics::Camera::Position {}

Defines a position in World-Space of where the Camera is located.

◆ Front

glm::vec3 engine::graphics::Camera::Front {}

Defines a vector in which the camera is pointed relative to the Camera::Position.

◆ Up

glm::vec3 engine::graphics::Camera::Up {}

Defines the Up vector in the World-Space.

◆ Right

glm::vec3 engine::graphics::Camera::Right {}

Defines the camera Right vector.

◆ WorldUp

glm::vec3 engine::graphics::Camera::WorldUp {}

Defines the up orientation of the World-Space.

◆ Yaw

float engine::graphics::Camera::Yaw {}

◆ Pitch

float engine::graphics::Camera::Pitch {}

◆ MovementSpeed

float engine::graphics::Camera::MovementSpeed {}

Used in Camera::move_camera. The higher the value the faster the camera will move on keyboard action.

◆ MouseSensitivity

float engine::graphics::Camera::MouseSensitivity {}

Used in Camera::rotate_camera. The higher the value the faster the camera will move on mouse action.

◆ Zoom

float engine::graphics::Camera::Zoom {}

Defines camera FOV.


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