VTK  9.2.6
vtkOpenVRRenderWindow.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3 Program: Visualization Toolkit
4 Module: vtkOpenVRRenderWindow.h
5 
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
144 #ifndef vtkOpenVRRenderWindow_h
145 #define vtkOpenVRRenderWindow_h
146 
147 #include "vtkEventData.h" // for enums
148 #include "vtkOpenVROverlay.h" // used for ivars
149 #include "vtkRenderingOpenVRModule.h" // For export macro
150 #include "vtkSmartPointer.h" // used for ivars
151 #include "vtkVRRenderWindow.h"
152 
153 #include <openvr.h> // for ivars
154 
155 class vtkMatrix4x4;
156 class vtkOpenVRModel;
157 
158 class VTKRENDERINGOPENVR_EXPORT vtkOpenVRRenderWindow : public vtkVRRenderWindow
159 {
160 public:
163 
167  static bool IsHMDPresent();
168 
172  void Initialize() override;
173 
178  void ReleaseGraphicsResources(vtkWindow* renWin) override;
179 
183  vr::IVRSystem* GetHMD() { return this->HMD; }
184 
189 
194  void Render() override;
195 
200  void StereoMidpoint() override;
201 
206  void StereoRenderComplete() override;
207 
212 
213  /*
214  * Get the overlay to use on the VR dashboard.
215  */
217 
223  void UpdateHMDMatrixPose() override;
224 
228  void SetMatrixFromOpenVRPose(vtkMatrix4x4* result, const vr::TrackedDevicePose_t& vrPose);
229 
233  vr::IVRRenderModels* GetOpenVRRenderModels() { return this->OpenVRRenderModels; }
234 
238  void RenderModels() override;
239 
240  uint32_t GetDeviceHandleForOpenVRHandle(vr::TrackedDeviceIndex_t index);
241  vtkEventDataDevice GetDeviceForOpenVRHandle(vr::TrackedDeviceIndex_t ohandle);
242 
243 protected:
245  ~vtkOpenVRRenderWindow() override = default;
246 
248  bool GetSizeFromAPI() override;
249 
250  bool CreateFramebuffers(uint32_t viewCount = 2) override;
251  bool CreateOneFramebuffer(int nWidth, int nHeight, FramebufferDesc& framebufferDesc);
252 
256  std::string GetTrackedDeviceString(vr::IVRSystem* pHmd, vr::TrackedDeviceIndex_t unDevice,
257  vr::TrackedDeviceProperty prop, vr::TrackedPropertyError* peError = nullptr);
258 
262  vtkOpenVRModel* FindOrLoadRenderModel(const char* modelName);
263 
265  vr::IVRSystem* HMD = nullptr;
266  vr::IVRRenderModels* OpenVRRenderModels = nullptr;
267 
268 private:
270  void operator=(const vtkOpenVRRenderWindow&) = delete;
271 };
272 
273 #endif
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:151
OpenVR device model.
OpenVR overlay.
OpenVR rendering window.
vtkEventDataDevice GetDeviceForOpenVRHandle(vr::TrackedDeviceIndex_t ohandle)
bool GetSizeFromAPI() override
Attempt to get the size of the display from the API and store it in this->Size.
void UpdateHMDMatrixPose() override
Update the HMD pose based on hardware pose and physical to world transform.
vr::IVRRenderModels * GetOpenVRRenderModels()
Get the openVR Render Models.
~vtkOpenVRRenderWindow() override=default
void RenderModels() override
Render the controller and base station models.
uint32_t GetDeviceHandleForOpenVRHandle(vr::TrackedDeviceIndex_t index)
std::string GetWindowTitleFromAPI() override
bool CreateOneFramebuffer(int nWidth, int nHeight, FramebufferDesc &framebufferDesc)
static vtkOpenVRRenderWindow * New()
bool CreateFramebuffers(uint32_t viewCount=2) override
void StereoRenderComplete() override
Handles work required once both views have been rendered when using stereo rendering.
void ReleaseGraphicsResources(vtkWindow *renWin) override
Free up any graphics resources associated with this window a value of nullptr means the context may a...
void SetMatrixFromOpenVRPose(vtkMatrix4x4 *result, const vr::TrackedDevicePose_t &vrPose)
Convert an OpenVR pose struct to a vtkMatrix4x4 object.
void RenderOverlay()
Draw the overlay.
vtkSmartPointer< vtkOpenVROverlay > DashboardOverlay
void StereoMidpoint() override
Intermediate method performs operations required between the rendering of the left and right eye.
vtkGetSmartPointerMacro(DashboardOverlay, vtkOpenVROverlay)
void Initialize() override
Initialize the rendering window.
vtkRenderWindowInteractor * MakeRenderWindowInteractor() override
Create an interactor specific to OpenVR to control renderers in this window.
std::string GetTrackedDeviceString(vr::IVRSystem *pHmd, vr::TrackedDeviceIndex_t unDevice, vr::TrackedDeviceProperty prop, vr::TrackedPropertyError *peError=nullptr)
Convert a device index to a human-readable string.
vr::IVRSystem * GetHMD()
Get the system pointer.
vtkOpenVRModel * FindOrLoadRenderModel(const char *modelName)
Find a render model that has already been loaded or load a new one.
void Render() override
Overridden to not release resources that would interfere with an external application's rendering.
static bool IsHMDPresent()
Returns true if the system believes that an HMD is present on the system.
platform-independent render window interaction including picking and frame rate control.
VR rendering window.
window superclass for vtkRenderWindow
Definition: vtkWindow.h:39
@ index
Definition: vtkX3D.h:252
@ string
Definition: vtkX3D.h:496
vtkEventDataDevice
platform-independent event data structures
Definition: vtkEventData.h:26