KarmaEngine
Game Engine for practical learning and research purposes
Loading...
Searching...
No Matches
Karma::Camera Class Reference

Base class of Camera. More...

#include <Camera.h>

Inheritance diagram for Karma::Camera:

Public Member Functions

 Camera (const glm::vec3 &initialCameraPosition)
 Default constructor.
 
virtual ~Camera ()
 Destructor.
 
const glm::vec3 & GetPosition () const
 Getter for current position of the Camers.
 
float GetRotation () const
 Getter for current rotation.
 
void LeftMouseButtonPressed ()
 Differentiates between single button press and drag.
 
void LeftMouseButtonReleased ()
 Setting m_IsLeftMouseButtonPressed to false.
 
void ComputeCameraFront ()
 Computes the pointing vector of the camera (outward positive) given the current pitch, and roll. (no yaw)
 
void SetPosition (const glm::vec3 &position)
 Sets the current position of the Camera.
 
void SetRotation (float rotation)
 Sets the current rotation of the Camera.
 
void SetCameraFront (const glm::vec3 &front)
 Set the front vector of Camera.
 
void SetCameraUp (const glm::vec3 &up)
 Set the up vector of Camera.
 
void MoveForward (float amount)
 Translate in the direction of front vector.
 
void MoveSideways (float amount)
 Move sideways in the direction of cross product of front vector and up vector.
 
void MoveUp (float amount)
 Move in the direction of Up.
 
void RotateAboutYAxis (float amount)
 Rotate about Y-axis.
 
void RotateAboutXAxis (float amount)
 Rotate about X-axis.
 
const glm::mat4 & GetProjectionMatrix () const
 Getter for ProjectionMatrix.
 
const glm::mat4 & GetViewMatirx () const
 Getter for ViewMatrix.
 

Protected Member Functions

void InitializePitchRoll ()
 

Protected Attributes

glm::mat4 m_ProjectionMatrix
 
glm::mat4 m_ViewMatrix
 
glm::vec3 m_Position
 
glm::vec3 m_CameraFront
 
glm::vec3 m_CameraUp
 
float m_Rotation = 0.0f
 
bool m_IsLeftMouseButtonPressed = false
 
float m_LastMouseX
 
float m_LastMouseY
 
const float m_Sensitivity = 0.1f
 
float m_Roll = 0.0f
 
float m_Pitch = 0.0f
 

Detailed Description

Base class of Camera.

Todo
This class needs major revamp with reparenting(?) with AActor, just like Unreal Engine's CameraActor

Constructor & Destructor Documentation

◆ Camera()

Karma::Camera::Camera ( const glm::vec3 & initialCameraPosition)

Default constructor.

Parameters
initialCameraPositionPosition to spawn camera at
Since
Karma 1.0.0

◆ ~Camera()

Karma::Camera::~Camera ( )
virtual

Destructor.

Since
Karma 1.0.0

Member Function Documentation

◆ ComputeCameraFront()

void Karma::Camera::ComputeCameraFront ( )

Computes the pointing vector of the camera (outward positive) given the current pitch, and roll. (no yaw)

Since
Karma 1.0.0

◆ GetPosition()

const glm::vec3 & Karma::Camera::GetPosition ( ) const
inline

Getter for current position of the Camers.

Returns
glm::vec3 m_Position
Todo
Use different data structure, provided in Ganit/Transform.h
Since
Karma 1.0.0

◆ GetProjectionMatrix()

const glm::mat4 & Karma::Camera::GetProjectionMatrix ( ) const
inline

Getter for ProjectionMatrix.

Since
Karma 1.0.0

◆ GetRotation()

float Karma::Camera::GetRotation ( ) const
inline

Getter for current rotation.

Returns
float m_Rotation
Since
Karma 1.0.0

◆ GetViewMatirx()

const glm::mat4 & Karma::Camera::GetViewMatirx ( ) const
inline

Getter for ViewMatrix.

Since
Karma 1.0.0

◆ LeftMouseButtonPressed()

void Karma::Camera::LeftMouseButtonPressed ( )

Differentiates between single button press and drag.

If drag is detected then the relevant orientation of the Camera is computed and applied, by setting m_Pitch and m_Roll, else the status m_IsLeftMouseButtonPressed is set.

See also
KarmaAppInputPolling
Since
Karma 1.0.0

◆ LeftMouseButtonReleased()

void Karma::Camera::LeftMouseButtonReleased ( )

Setting m_IsLeftMouseButtonPressed to false.

Since
Karma 1.0.0

◆ MoveForward()

void Karma::Camera::MoveForward ( float amount)

Translate in the direction of front vector.

Parameters
amountThe magnitude of the translation in front direction
Since
Karma 1.0.0

◆ MoveSideways()

void Karma::Camera::MoveSideways ( float amount)

Move sideways in the direction of cross product of front vector and up vector.

Parameters
amountThe magnitude of the translation in the side direction
Since
Karma 1.0.0

◆ MoveUp()

void Karma::Camera::MoveUp ( float amount)

Move in the direction of Up.

Parameters
amountThe magnitude of translation
Since
Karma 1.0.0

◆ RotateAboutXAxis()

void Karma::Camera::RotateAboutXAxis ( float amount)

Rotate about X-axis.

Parameters
amountThe magnitude of the angle of rotation
Since
Karma 1.0.0

◆ RotateAboutYAxis()

void Karma::Camera::RotateAboutYAxis ( float amount)

Rotate about Y-axis.

Parameters
amountThe magnitude of the angle of rotation
Since
Karma 1.0.0

◆ SetCameraFront()

void Karma::Camera::SetCameraFront ( const glm::vec3 & front)
inline

Set the front vector of Camera.

Parameters
frontThe value to set the front vector to
Since
Karma 1.0.0

◆ SetCameraUp()

void Karma::Camera::SetCameraUp ( const glm::vec3 & up)
inline

Set the up vector of Camera.

Parameters
upThe value to set the up vector to
Since
Karma 1.0.0

◆ SetPosition()

void Karma::Camera::SetPosition ( const glm::vec3 & position)

Sets the current position of the Camera.

Parameters
positionThe position to set to
Since
Karma 1.0.0

◆ SetRotation()

void Karma::Camera::SetRotation ( float rotation)
inline

Sets the current rotation of the Camera.

Parameters
rotationThe rotation to be se
Deprecated
m_Rotation is no longer used for the orientation. See m_Pitch and m_Roll.
Since
Karma 1.0.0

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