HIRO_DRAW
Computer Graphics Structures library
VisualCameraController.h
1 /*
2  Copyright (C) Skeletex Research, s.r.o. - All Rights Reserved
3  Unauthorized copying of this file, via any medium is strictly prohibited
4  Proprietary and confidential
5 */
6 #ifndef HIRO_DRAW_VISUAL_CAMERA_CONTROLLER_H
7 #define HIRO_DRAW_VISUAL_CAMERA_CONTROLLER_H
8 #include <GLW/WindowEventObserver.h>
9 #include <HIRO_DRAW/Scene.h>
10 
11 
12 
13 namespace hiro::draw
14 {
15 
17  enum class CameraMode
18  {
19  move_free = 0,
20  orbit_free = 1,
21  orbit_x = 2,
22  orbit_x_inv = 3,
23  orbit_y = 4,
24  orbit_y_inv = 5,
25  orbit_z = 6,
26  orbit_z_inv = 7
27  };
28 
37  class HIRO_DRAW_API VisualCameraController : public glw::WindowEventObserver
38  {
39  public:
45  using OnCameraChangeCallback = std::function<void(uint32_t)>;
46 
49 
51 
53  void SetScenes(const std::vector<hiro::draw::PScene> &scenes);
54 
56  void AddScene(const hiro::draw::PScene &scene);
57 
59  void Update(double delta_time);
60 
62  void SetCameraMode(uint32_t scene_id, hiro::draw::CameraMode mode);
63 
65  hiro::draw::CameraMode GetCameraMode(uint32_t scene_id) const;
66 
73  void SetCameraPoi(uint32_t scene_id, const glm::vec3 &poi);
74 
76  glm::vec3 GetCameraPoi(uint32_t scene_id) const;
77 
79  void SetCameraGroup(const std::set<uint32_t> &scene_ids);
80 
82  const std::set<uint32_t> &GetCameraGroup() const;
83 
89  void UpdateGroupedCameras(const uint32_t source_scene_id) const;
90 
92  void SubscribeEventCameraChanged(const hiro::draw::VisualCameraController::OnCameraChangeCallback &func);
93 
94  void SetCameraSensitivity(float sens);
95 
96  float GetCameraSensitivity();
97 
98  protected:
99  virtual void OnMouseMove(double xpos, double ypos) override;
100  virtual void OnMouseDown(int button, int mods) override;
101  virtual void OnMouseUp(int button, int mods) override;
102 
103  virtual void NotifyOnCameraChange(uint32_t scene_id);
104 
105  virtual void OnMouseWheel(double xoffset, double yoffset) override;
106  virtual void OnKeyDown(int key, int mods, bool is_repeat) override;
107  virtual void OnKeyUp(int key, int mods) override;
108 
109  private:
110  struct Impl;
111  std::unique_ptr<hiro::draw::VisualCameraController::Impl> m;
112 
113  // Returns index of scene over whose viewport is mouse cursor. Returns -1 if cursor is not over any scene viewport.
114  int32_t GetSceneUnderMousePos();
115  };
116 
117 }
118 
119 #endif /* !HIRO_DRAW_VISUAL_CAMERA_CONTROLLER_H */
ORBIT_FREE, with up vector fixed to negative X.
Camera orbits defined 3D point.
ORBIT_FREE, with up vector fixed to positive Y.
std::function< void(uint32_t)> OnCameraChangeCallback
Callback function which is called each time a scene camera changes it&#39;s state.
Definition: VisualCameraController.h:45
ORBIT_FREE, with up vector fixed to negative Y.
ORBIT_FREE, with up vector fixed to positive X.
Cinematic mode. Camera can be moved freely.
Extensions for object visualization. Implements a higher level of OpenGL rendering.
Definition: API.h:20
ORBIT_FREE, with up vector fixed to positive Z.
ORBIT_FREE, with up vector fixed to negative Z.
CameraMode
Defines camera manipulation behavior.
Definition: VisualCameraController.h:17
Provides an automatic interface to camera manipulation by runtime user interaction.
Definition: VisualCameraController.h:37