VTK  9.3.1
vtkOpenVRRenderWindow.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
35 #ifndef vtkOpenVRRenderWindow_h
36 #define vtkOpenVRRenderWindow_h
37 
38 #include "vtkEventData.h" // for enums
39 #include "vtkOpenVROverlay.h" // used for ivars
40 #include "vtkRenderingOpenVRModule.h" // For export macro
41 #include "vtkSmartPointer.h" // used for ivars
42 #include "vtkVRRenderWindow.h"
43 
44 #include <openvr.h> // for ivars
45 
46 VTK_ABI_NAMESPACE_BEGIN
47 class vtkMatrix4x4;
48 class vtkOpenVRModel;
49 
50 class VTKRENDERINGOPENVR_EXPORT vtkOpenVRRenderWindow : public vtkVRRenderWindow
51 {
52 public:
53  static vtkOpenVRRenderWindow* New();
55 
59  static bool IsHMDPresent();
60 
64  void Initialize() override;
65 
71  void Finalize() override;
72 
76  vr::IVRSystem* GetHMD() { return this->HMD; }
77 
82 
87  void Render() override;
88 
93  void StereoMidpoint() override;
94 
99  void StereoRenderComplete() override;
100 
104  void RenderOverlay();
105 
106  /*
107  * Get the overlay to use on the VR dashboard.
108  */
109  vtkGetSmartPointerMacro(DashboardOverlay, vtkOpenVROverlay);
110 
116  void UpdateHMDMatrixPose() override;
117 
121  void SetMatrixFromOpenVRPose(vtkMatrix4x4* result, const vr::TrackedDevicePose_t& vrPose);
122 
126  vr::IVRRenderModels* GetOpenVRRenderModels() { return this->OpenVRRenderModels; }
127 
131  void RenderModels() override;
132 
133  uint32_t GetDeviceHandleForOpenVRHandle(vr::TrackedDeviceIndex_t index);
134  vtkEventDataDevice GetDeviceForOpenVRHandle(vr::TrackedDeviceIndex_t ohandle);
135 
136 protected:
138  ~vtkOpenVRRenderWindow() override;
139 
141  bool GetSizeFromAPI() override;
142 
143  bool CreateFramebuffers(uint32_t viewCount = 2) override;
144  void RenderFramebuffer(FramebufferDesc& framebufferDesc) override;
145  bool CreateOneFramebuffer(int nWidth, int nHeight, FramebufferDesc& framebufferDesc);
146 
150  std::string GetTrackedDeviceString(vr::IVRSystem* pHmd, vr::TrackedDeviceIndex_t unDevice,
151  vr::TrackedDeviceProperty prop, vr::TrackedPropertyError* peError = nullptr);
152 
156  vtkOpenVRModel* FindOrLoadRenderModel(const char* modelName);
157 
159  vr::IVRSystem* HMD = nullptr;
160  vr::IVRRenderModels* OpenVRRenderModels = nullptr;
161 
162 private:
164  void operator=(const vtkOpenVRRenderWindow&) = delete;
165 };
166 
167 VTK_ABI_NAMESPACE_END
168 #endif
vtkSmartPointer< vtkOpenVROverlay > DashboardOverlay
virtual void RenderFramebuffer(FramebufferDesc &framebufferDesc)=0
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:30
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 void Finalize()
Finalize the rendering process.
virtual bool CreateFramebuffers(uint32_t viewCount=2)=0
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.
virtual void Initialize()
Initialize the rendering window.
vtkEventDataDevice
platform-independent event data structures
Definition: vtkEventData.h:14
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.
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.