VTK  9.2.6
vtkOpenVRRenderWindow.h
Go to the documentation of this file.
1/*=========================================================================
2
3Program: Visualization Toolkit
4Module: vtkOpenVRRenderWindow.h
5
6Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7All rights reserved.
8See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10This software is distributed WITHOUT ANY WARRANTY; without even
11the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12PURPOSE. See the above copyright notice for more information.
13
14=========================================================================*/
51
52#ifndef vtkOpenVRRenderWindow_h
53#define vtkOpenVRRenderWindow_h
54
55#include "vtkEventData.h" // for enums
56#include "vtkOpenVROverlay.h" // used for ivars
57#include "vtkRenderingOpenVRModule.h" // For export macro
58#include "vtkSmartPointer.h" // used for ivars
59#include "vtkVRRenderWindow.h"
60
61#include <openvr.h> // for ivars
62
63class vtkMatrix4x4;
64class vtkOpenVRModel;
65
66class VTKRENDERINGOPENVR_EXPORT vtkOpenVRRenderWindow : public vtkVRRenderWindow
67{
68public:
71
75 static bool IsHMDPresent();
76
80 void Initialize() override;
81
86 void ReleaseGraphicsResources(vtkWindow* renWin) override;
87
91 vr::IVRSystem* GetHMD() { return this->HMD; }
92
97
102 void Render() override;
103
108 void StereoMidpoint() override;
109
114 void StereoRenderComplete() override;
115
120
121 /*
122 * Get the overlay to use on the VR dashboard.
123 */
125
131 void UpdateHMDMatrixPose() override;
132
136 void SetMatrixFromOpenVRPose(vtkMatrix4x4* result, const vr::TrackedDevicePose_t& vrPose);
137
141 vr::IVRRenderModels* GetOpenVRRenderModels() { return this->OpenVRRenderModels; }
142
146 void RenderModels() override;
147
148 uint32_t GetDeviceHandleForOpenVRHandle(vr::TrackedDeviceIndex_t index);
149 vtkEventDataDevice GetDeviceForOpenVRHandle(vr::TrackedDeviceIndex_t ohandle);
150
151protected:
153 ~vtkOpenVRRenderWindow() override = default;
154
155 std::string GetWindowTitleFromAPI() override;
156 bool GetSizeFromAPI() override;
157
158 bool CreateFramebuffers(uint32_t viewCount = 2) override;
159 bool CreateOneFramebuffer(int nWidth, int nHeight, FramebufferDesc& framebufferDesc);
160
164 std::string GetTrackedDeviceString(vr::IVRSystem* pHmd, vr::TrackedDeviceIndex_t unDevice,
165 vr::TrackedDeviceProperty prop, vr::TrackedPropertyError* peError = nullptr);
166
170 vtkOpenVRModel* FindOrLoadRenderModel(const char* modelName);
171
173 vr::IVRSystem* HMD = nullptr;
174 vr::IVRRenderModels* OpenVRRenderModels = nullptr;
175
176private:
178 void operator=(const vtkOpenVRRenderWindow&) = delete;
179};
180
181#endif
represent and manipulate 4x4 transformation matrices
OpenVR device model.
OpenVR overlay.
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::IVRSystem * GetHMD()
Get the system pointer.
static vtkOpenVRRenderWindow * New()
~vtkOpenVRRenderWindow() override=default
vtkRenderWindowInteractor * MakeRenderWindowInteractor() override
Create an interactor specific to OpenVR to control renderers in this window.
void RenderModels() override
Render the controller and base station models.
vr::IVRRenderModels * GetOpenVRRenderModels()
Get the openVR Render Models.
uint32_t GetDeviceHandleForOpenVRHandle(vr::TrackedDeviceIndex_t index)
std::string GetWindowTitleFromAPI() override
vtkOpenVRModel * FindOrLoadRenderModel(const char *modelName)
Find a render model that has already been loaded or load a new one.
bool CreateOneFramebuffer(int nWidth, int nHeight, FramebufferDesc &framebufferDesc)
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.
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.
void Render() override
Overridden to not release resources that would interfere with an external application's rendering.
vr::IVRRenderModels * OpenVRRenderModels
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.
Hold a reference to a vtkObjectBase instance.
window superclass for vtkRenderWindow
Definition vtkWindow.h:39
vtkEventDataDevice
platform-independent event data structures