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

Provides an automatic interface to camera manipulation by runtime user interaction. More...

Inherits WindowEventObserver.

Public Types

using OnCameraChangeCallback = std::function< void(uint32_t)>
 Callback function which is called each time a scene camera changes it's state. More...
 

Public Member Functions

 VisualCameraController ()
 Creates object with no scene to manipulate with.
 
void SetScenes (const std::vector< hiro::draw::PScene > &scenes)
 Set scenes, whose internal cameras are to be controlled by mouse.
 
void AddScene (const hiro::draw::PScene &scene)
 Add scene to the list of scenes, whose internal cameras are to be controlled by mouse.
 
void Update (double delta_time)
 Update all controlled cameras once a render cycle. Obligatory for smoothened and animated cameras.
 
void SetCameraMode (uint32_t scene_id, hiro::draw::CameraMode mode)
 Changes behavioral mode for a camera of specified scene.
 
hiro::draw::CameraMode GetCameraMode (uint32_t scene_id) const
 Returns behavioral mode for a camera of specified scene.
 
void SetCameraPoi (uint32_t scene_id, const glm::vec3 &poi)
 Sets up point of interest for camera, which will automatically look at the point. More...
 
glm::vec3 GetCameraPoi (uint32_t scene_id) const
 Returns point of interest for camera.
 
void SetCameraGroup (const std::set< uint32_t > &scene_ids)
 Sets up group of scene ids, whose cameras are grouped and behave simultaneously.
 
const std::set< uint32_t > & GetCameraGroup () const
 Returns group of scene ids, whose cameras are grouped and behave simultaneously.
 
void UpdateGroupedCameras (const uint32_t source_scene_id) const
 All cameras in group with source scene are updated by a camera of source scene. More...
 
void SubscribeEventCameraChanged (const hiro::draw::VisualCameraController::OnCameraChangeCallback &func)
 Sets up optional callback function, which will be called each time a scene camera changes it's state.
 
void SetCameraSensitivity (float sens)
 
float GetCameraSensitivity ()
 

Protected Member Functions

virtual void OnMouseMove (double xpos, double ypos) override
 
virtual void OnMouseDown (int button, int mods) override
 
virtual void OnMouseUp (int button, int mods) override
 
virtual void NotifyOnCameraChange (uint32_t scene_id)
 
virtual void OnMouseWheel (double xoffset, double yoffset) override
 
virtual void OnKeyDown (int key, int mods, bool is_repeat) override
 
virtual void OnKeyUp (int key, int mods) override
 

Detailed Description

Provides an automatic interface to camera manipulation by runtime user interaction.

For each Scene added to CameraController, an interaction is enabled. Cameras can be grouped in order to control multiple using a single action.

A method Update needs to be called every frame in order to function properly.

Member Typedef Documentation

◆ OnCameraChangeCallback

using hiro::draw::VisualCameraController::OnCameraChangeCallback = std::function<void(uint32_t)>

Callback function which is called each time a scene camera changes it's state.

First parameter defines an index of the scene for which the change happened.

Member Function Documentation

◆ SetCameraPoi()

void hiro::draw::VisualCameraController::SetCameraPoi ( uint32_t  scene_id,
const glm::vec3 &  poi 
)

Sets up point of interest for camera, which will automatically look at the point.

If camera mode is set to one of orbital modes, camera will orbit the point.

◆ UpdateGroupedCameras()

void hiro::draw::VisualCameraController::UpdateGroupedCameras ( const uint32_t  source_scene_id) const

All cameras in group with source scene are updated by a camera of source scene.

This method needs to be called when camera of source scene is changed manually, in order to work correctly.