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 =========================================================================*/
55 #ifndef vtkOpenVRRenderWindow_h
56 #define vtkOpenVRRenderWindow_h
57 
58 #include "vtkEventData.h" // for enums
59 #include "vtkOpenVROverlay.h" // used for ivars
60 #include "vtkRenderingOpenVRModule.h" // For export macro
61 #include "vtkSmartPointer.h" // used for ivars
62 #include "vtkVRRenderWindow.h"
63 
64 #include <openvr.h> // for ivars
65 
66 class vtkMatrix4x4;
67 class vtkOpenVRModel;
68 
69 class VTKRENDERINGOPENVR_EXPORT vtkOpenVRRenderWindow : public vtkVRRenderWindow
70 {
71 public:
72  static vtkOpenVRRenderWindow* New();
74 
78  static bool IsHMDPresent();
79 
83  void Initialize() override;
84 
89  void ReleaseGraphicsResources(vtkWindow* renWin) override;
90 
94  vr::IVRSystem* GetHMD() { return this->HMD; }
95 
100 
105  void Render() override;
106 
111  void StereoMidpoint() override;
112 
117  void StereoRenderComplete() override;
118 
122  void RenderOverlay();
123 
124  /*
125  * Get the overlay to use on the VR dashboard.
126  */
127  vtkGetSmartPointerMacro(DashboardOverlay, vtkOpenVROverlay);
128 
134  void UpdateHMDMatrixPose() override;
135 
139  void SetMatrixFromOpenVRPose(vtkMatrix4x4* result, const vr::TrackedDevicePose_t& vrPose);
140 
144  vr::IVRRenderModels* GetOpenVRRenderModels() { return this->OpenVRRenderModels; }
145 
149  void RenderModels() override;
150 
151  uint32_t GetDeviceHandleForOpenVRHandle(vr::TrackedDeviceIndex_t index);
152  vtkEventDataDevice GetDeviceForOpenVRHandle(vr::TrackedDeviceIndex_t ohandle);
153 
154 protected:
156  ~vtkOpenVRRenderWindow() override = default;
157 
159  bool GetSizeFromAPI() override;
160 
161  bool CreateFramebuffers(uint32_t viewCount = 2) override;
162  bool CreateOneFramebuffer(int nWidth, int nHeight, FramebufferDesc& framebufferDesc);
163 
167  std::string GetTrackedDeviceString(vr::IVRSystem* pHmd, vr::TrackedDeviceIndex_t unDevice,
168  vr::TrackedDeviceProperty prop, vr::TrackedPropertyError* peError = nullptr);
169 
173  vtkOpenVRModel* FindOrLoadRenderModel(const char* modelName);
174 
176  vr::IVRSystem* HMD = nullptr;
177  vr::IVRRenderModels* OpenVRRenderModels = nullptr;
178 
179 private:
181  void operator=(const vtkOpenVRRenderWindow&) = delete;
182 };
183 
184 #endif
vtkSmartPointer< vtkOpenVROverlay > DashboardOverlay
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:41
virtual void RenderModels()=0
Render the controller and base station models.
static vtkRenderWindow * New()
Construct an instance of vtkRenderWindow with its screen size set to 300x300, borders turned on...
VR rendering window.
vtkRenderWindowInteractor * MakeRenderWindowInteractor() override=0
Create an interactor to control renderers in this window.
virtual bool CreateFramebuffers(uint32_t viewCount=2)=0
window superclass for vtkRenderWindow
Definition: vtkWindow.h:38
platform-independent render window interaction including picking and frame rate control.
vr::IVRRenderModels * GetOpenVRRenderModels()
Get the openVR Render Models.
virtual std::string GetWindowTitleFromAPI()
OpenVR overlay.
void Initialize() override
Initialize the rendering window.
vtkEventDataDevice
platform-independent event data structures
Definition: vtkEventData.h:25
virtual bool GetSizeFromAPI()=0
Attempt to get the size of the display from the API and store it in this->Size.
void Render() override
Overridden to not release resources that would interfere with an external application's rendering...
OpenVR rendering window.
virtual void StereoRenderComplete()
Handles work required once both views have been rendered when using stereo rendering.
void ReleaseGraphicsResources(vtkWindow *) override
Free up any graphics resources associated with this window a value of nullptr means the context may a...
virtual void UpdateHMDMatrixPose()
Update the HMD pose.
OpenVR device model.
void StereoMidpoint() override
Intermediate method performs operations required between the rendering of the left and right eye...
vr::IVRSystem * GetHMD()
Get the system pointer.