Rehti MMORPG  1.0.0
Rehti MMORPG is a free and open source MMORPG game.
Camera Class Reference

#include <Camera.hpp>

Collaboration diagram for Camera:
Collaboration graph

Public Member Functions

 Camera (glm::vec3 targetPos, float width, float height, float fovRad=glm::quarter_pi< float >(), float near=0.1f, float far=100.f, float sensitivity=0.01f)
 Constructor for the camera. More...
 
glm::mat4 getViewMatrix () const
 Returns the view matrix of the camera, which is the inverse of the model matrix of the camera. This matrix places objects in the space of the camera. More...
 
glm::mat4 getOrientation () const
 Returns the orientation of the camera. More...
 
glm::mat4 getProjectionMatrix () const
 Returns the projection matrix of the camera. More...
 
glm::vec3 getCameraRay (double x, double y) const
 Returns the camera ray in world space. More...
 
glm::mat4 getWorldToScreenMatrix () const
 Returns the world to screen matrix. More...
 
uint32_t getUboSize ()
 Returns the size of the camera's UBO. More...
 
void orbitRotate (glm::vec2 rotationVec)
 rotates the camera around the target. More...
 
void zoom (float zoomAmount)
 Zooms the camera by the given amount. More...
 
void registerCameraControls (GLFWwindow *window)
 Registers the camera controls to the given window. More...
 
void setSensitivity (float newSensitivity, float newZoomSens)
 sets the sensitivity of the camera. More...
 
void moveLocation (glm::vec3 movement)
 Moves the camera by the given vector. More...
 
void move (glm::vec3 movement)
 Moves both the camera and the camera target by the given vector. More...
 
void setLocation (glm::vec3 location)
 Sets the camera location to the given location. More...
 
void setTargetAndCamera (glm::vec3 location)
 Sets the camera target to the given location and moves camera by the same amount. More...
 
glm::vec3 getLocation () const
 Returns the location of the camera. More...
 
glm::vec3 getForward () const
 Returns the forward direction of the camera. More...
 
glm::vec3 getRight () const
 Returns the right direction of the camera. More...
 
glm::vec3 getUp () const
 Returns the up direction of the camera. More...
 
glm::vec2 getSensitivities () const
 Returns the sensitivity of the camera. More...
 

Static Public Attributes

static bool canMove = false
 

Private Member Functions

glm::mat4 getCameraMatrixOrigon () const
 returns the camera matrix with the target as the origon. More...
 

Static Private Member Functions

static void cursorPosCallback (GLFWwindow *pWindow, double xpos, double ypos)
 Callback for registering mouse movement. More...
 
static void scrollCallback (GLFWwindow *pWindow, double xOffSet, double yOffSet)
 callback for registering mouse scroll More...
 

Private Attributes

glm::mat4 cameraMatrixM
 
glm::mat4 projectionM
 
glm::vec3 targetM
 
float sensitivityM
 
float zoomSensitivityM
 
float zoomM
 
float widthM
 
float heightM
 

Static Private Attributes

static double mouseX = 0
 
static double mouseY = 0
 
static std::function< void(glm::vec2)> cameraUpdateCallback = nullptr
 Callback for updating the camera. More...
 
static std::function< void(float)> cameraZoomCallback = nullptr
 Callback for updating the camera. More...
 

Detailed Description

@ brief Camera class that enables orbiting around a target. This class allows querying for view and projection matrices or a combination of both.

Constructor & Destructor Documentation

◆ Camera()

Camera::Camera ( glm::vec3  targetPos,
float  width,
float  height,
float  fovRad = glm::quarter_pi<float>(),
float  near = 0.1f,
float  far = 100.f,
float  sensitivity = 0.01f 
)

Constructor for the camera.

Parameters
targetTarget to follow. TODO Changed later
widthWidth of the screen
heightHeight of the screen
fovRadField of view in radians, defaults to quarter pi = 45 degrees
nearNear plane distance
farFar plane distance
sensitivitySensitivity of the camera
Here is the call graph for this function:

Member Function Documentation

◆ cursorPosCallback()

void Camera::cursorPosCallback ( GLFWwindow *  pWindow,
double  xpos,
double  ypos 
)
staticprivate

Callback for registering mouse movement.

Here is the caller graph for this function:

◆ getCameraMatrixOrigon()

glm::mat4 Camera::getCameraMatrixOrigon ( ) const
private

returns the camera matrix with the target as the origon.

Returns
matrix
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getCameraRay()

glm::vec3 Camera::getCameraRay ( double  x,
double  y 
) const

Returns the camera ray in world space.

Returns
Camera ray in world space.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getForward()

glm::vec3 Camera::getForward ( ) const

Returns the forward direction of the camera.

Returns
the forward direction of the camera.
Here is the caller graph for this function:

◆ getLocation()

glm::vec3 Camera::getLocation ( ) const

Returns the location of the camera.

Returns
the location of the camera.
Here is the caller graph for this function:

◆ getOrientation()

glm::mat4 Camera::getOrientation ( ) const

Returns the orientation of the camera.

Returns
orientation of the camera as a matrix

◆ getProjectionMatrix()

glm::mat4 Camera::getProjectionMatrix ( ) const

Returns the projection matrix of the camera.

Returns
The projection matrix

◆ getRight()

glm::vec3 Camera::getRight ( ) const

Returns the right direction of the camera.

Returns
the right direction of the camera.
Here is the caller graph for this function:

◆ getSensitivities()

glm::vec2 Camera::getSensitivities ( ) const

Returns the sensitivity of the camera.

Returns
the sensitivity of the camera.

◆ getUboSize()

uint32_t Camera::getUboSize ( )

Returns the size of the camera's UBO.

Returns
Size of the camera's UBO.
Here is the caller graph for this function:

◆ getUp()

glm::vec3 Camera::getUp ( ) const

Returns the up direction of the camera.

Returns
the up direction of the camera.

◆ getViewMatrix()

glm::mat4 Camera::getViewMatrix ( ) const

Returns the view matrix of the camera, which is the inverse of the model matrix of the camera. This matrix places objects in the space of the camera.

Returns
The view matrix
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getWorldToScreenMatrix()

glm::mat4 Camera::getWorldToScreenMatrix ( ) const

Returns the world to screen matrix.

Returns
World to screen matrix.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ move()

void Camera::move ( glm::vec3  movement)

Moves both the camera and the camera target by the given vector.

Here is the call graph for this function:

◆ moveLocation()

void Camera::moveLocation ( glm::vec3  movement)

Moves the camera by the given vector.

Parameters
movement
Here is the caller graph for this function:

◆ orbitRotate()

void Camera::orbitRotate ( glm::vec2  rotationVec)

rotates the camera around the target.

Parameters
rotationVecto rotate the camera by.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ registerCameraControls()

void Camera::registerCameraControls ( GLFWwindow *  window)

Registers the camera controls to the given window.

Parameters
window
Here is the call graph for this function:

◆ scrollCallback()

void Camera::scrollCallback ( GLFWwindow *  pWindow,
double  xOffSet,
double  yOffSet 
)
staticprivate

callback for registering mouse scroll

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setLocation()

void Camera::setLocation ( glm::vec3  location)

Sets the camera location to the given location.

Parameters
location
Here is the caller graph for this function:

◆ setSensitivity()

void Camera::setSensitivity ( float  newSensitivity,
float  newZoomSens 
)

sets the sensitivity of the camera.

Parameters
newSensitivityof the camera movement
newZoomSensis the zoom sensitivity

◆ setTargetAndCamera()

void Camera::setTargetAndCamera ( glm::vec3  location)

Sets the camera target to the given location and moves camera by the same amount.

Parameters
location
Here is the call graph for this function:
Here is the caller graph for this function:

◆ zoom()

void Camera::zoom ( float  zoomAmount)

Zooms the camera by the given amount.

Parameters
zoomAmount
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ cameraMatrixM

glm::mat4 Camera::cameraMatrixM
private

◆ cameraUpdateCallback

std::function< void(glm::vec2)> Camera::cameraUpdateCallback = nullptr
staticprivate

Callback for updating the camera.

◆ cameraZoomCallback

std::function< void(float)> Camera::cameraZoomCallback = nullptr
staticprivate

Callback for updating the camera.

◆ canMove

bool Camera::canMove = false
static

◆ heightM

float Camera::heightM
private

◆ mouseX

double Camera::mouseX = 0
staticprivate

◆ mouseY

double Camera::mouseY = 0
staticprivate

◆ projectionM

glm::mat4 Camera::projectionM
private

◆ sensitivityM

float Camera::sensitivityM
private

◆ targetM

glm::vec3 Camera::targetM
private

◆ widthM

float Camera::widthM
private

◆ zoomM

float Camera::zoomM
private

◆ zoomSensitivityM

float Camera::zoomSensitivityM
private

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