HIRO_DRAW
Computer Graphics Structures library
hiro::draw::VisualCamera Class Reference

A wrapper over view matrix, providing intuitive control. More...

Public Types

using CallbackOnChange = std::function< void(void)>
 

Public Member Functions

 VisualCamera ()
 Creates orbiting camera looking from position (0,0,10), up vector directing positive Y axis.
 
void CopyView (const hiro::draw::VisualCamera &source_camera)
 Sets up view to exactly match the one of specified camera.
 
const glm_ext::TransMat4 & GetViewMatrix () const
 Returns current view matrix.
 
glm::vec3 GetForward () const
 Returns forward vector of camera orientation.
 
glm::vec3 GetRight () const
 Returns right vector of camera orientation.
 
glm::vec3 GetUp () const
 Returns up vector of camera orientation.
 
void SetPosition (const glm::vec3 &camera_position)
 Set position of camera.
 
void AlignUpVector (const glm::vec3 &vector)
 Sets up up vector to match specified.
 
void LookInDirection (const glm::vec3 &new_forward)
 Sets up forward vector to match specified.
 
void LookAt (const glm::vec3 &point_of_interest, const glm::vec3 &up)
 Sets look direction of camera so that it looks from the actual position at defined point of interest.
 
void SetPositionAndLookAt (const glm::vec3 &camera_position, const glm::vec3 &point_of_interest, const glm::vec3 &up)
 Set position of camera and sets look direction of camera so that it looks from the actual position at defined point of interest.
 
glm::vec3 GetPosition () const
 Returns actual position of camera.
 
void Rotate (const glm::quat &rot)
 Rotates camera by a specified quaternion.
 
void Dolly (const float distance)
 Moves forward.
 
void Crab (const float distance)
 Moves right.
 
void Boom (const float distance)
 Moves up.
 
void Pan (const float angle)
 Rotates towards left side.
 
void Tilt (const float angle)
 Rotates towards top side.
 
void Roll (const float angle)
 Rotates around its view direction, counter-clockwise.
 
void Move (const glm::vec3 &move_vector)
 Moves camera position by a specified 3D vector.
 
void ReadFromStream (std::istream &str)
 Loads all state values from stream.
 
void WriteToStream (std::ostream &str)
 Saves all state values to stream.
 
void SubscribeChange (const hiro::draw::VisualCamera::CallbackOnChange &listener)
 Subscribes specified function to be called whenever camera changes.
 
void Reset ()
 Resets all camera values to default.
 

Protected Member Functions

void UpdateCameraSpace ()
 

Protected Attributes

glm::vec3 position_ = glm::vec3(0.0f)
 
glm::vec3 basis_z_ = glm::vec3(0.0f, 0.0f, -1.0f)
 
glm::vec3 basis_y_ = glm::vec3(0.0f, 1.0f, 0.0f)
 
glm_ext::TransMat4 view_matrix_
 
std::vector< hiro::draw::VisualCamera::CallbackOnChange > listeners_
 

Detailed Description

A wrapper over view matrix, providing intuitive control.

Position - defines position of camera on CameraMode::MOVE_FREE and target point on other modes. Displacement - distance to camera position, non zero only when mode is not CameraMode::MOVE_FREE.