iMSTK
Interactive Medical Simulation Toolkit
VRCameraControl.h
1 /*
2 ** This file is part of the Interactive Medical Simulation Toolkit (iMSTK)
3 ** iMSTK is distributed under the Apache License, Version 2.0.
4 ** See accompanying NOTICE for details.
5 */
6 
7 #pragma once
8 
9 #include "imstkDeviceControl.h"
10 #include "imstkMath.h"
11 
12 namespace imstk
13 {
14 class Camera;
15 class OpenVRDeviceClient;
16 class SceneManager;
17 } // namespace imstk
18 
19 using namespace imstk;
20 
29 {
30 public:
31  VRCameraControl(const std::string& name = "VRCameraControl") : DeviceControl(name) { }
32  ~VRCameraControl() override = default;
33 
34 public:
38  double getTranslateSpeedScale() const { return m_translateSpeedScale; }
39  void setTranslateSpeedScale(const double translateSpeedScale)
40  {
41  m_translateSpeedScale = translateSpeedScale;
42  }
43 
45 
49  double getRotateSpeedScale() const { return m_rotateSpeedScale; }
50  void setRotateSpeedScale(const double rotateSpeedScale)
51  {
52  m_rotateSpeedScale = rotateSpeedScale;
53  }
54 
56 
60  double getVerticalSpeedScale() const { return m_translateVerticalSpeedScale; }
61  void setVerticalSpeedScale(double verticalSpeed)
62  {
63  m_translateVerticalSpeedScale = verticalSpeed;
64  }
65 
67 
71  std::shared_ptr<OpenVRDeviceClient> getTranslateDevice() const { return m_translateDevice; }
72  void setTranslateDevice(std::shared_ptr<OpenVRDeviceClient> translateDevice)
73  {
74  m_translateDevice = translateDevice;
75  }
76 
78 
82  std::shared_ptr<OpenVRDeviceClient> getRotateDevice() const { return m_rotateDevice; }
83  void setRotateDevice(std::shared_ptr<OpenVRDeviceClient> rotateDevice)
84  {
85  m_rotateDevice = rotateDevice;
86  }
87 
89 
90  const Mat4d& getDeltaTransform() { return m_deltaTransform; }
91 
95  void setCamera(std::shared_ptr<Camera> camera) { m_camera = camera; }
96  std::shared_ptr<Camera> getCamera() const { return m_camera; }
97 
98 public:
99  void printControls() override;
100 
104  void update(const double& dt) override;
105 
106 protected:
107  std::shared_ptr<OpenVRDeviceClient> m_translateDevice = nullptr;
108  std::shared_ptr<OpenVRDeviceClient> m_rotateDevice = nullptr;
109 
110  std::shared_ptr<Camera> m_camera = nullptr;
111 
112  // User changeable values
113  double m_rotateSpeedScale = 1.0;
114  double m_translateSpeedScale = 1.0;
115  double m_translateVerticalSpeedScale = 1.0;
116  Mat4d m_deltaTransform = Mat4d::Identity();
117 };
While the DeviceClient provides quantities from the device, the control defines what to do with those...
std::shared_ptr< OpenVRDeviceClient > getRotateDevice() const
Get/Set the device that can rotate the camera around Y.
double getTranslateSpeedScale() const
Get/Set how fast the camera translates along XZ plane.
double getVerticalSpeedScale() const
Get/Set the vertical speed, how fast you move along Y.
Compound Geometry.
double getRotateSpeedScale() const
Get/Set how fast the camera rotates around Y.
This class provides quantities for the specified VR device The devices creation is tied to the viewer...
void setCamera(std::shared_ptr< Camera > camera)
Get/Set the camera to be controlled.
std::shared_ptr< OpenVRDeviceClient > getTranslateDevice() const
Get/Set the device that can translate the camera along XZ.
Produces a perpsective transformation matrix.
Definition: imstkCamera.h:58
Scene manager module manages multiple scenes and runs the active one.
Defines a control scheme to move the camera with joysticks. Relative to world space with Y up...