ezEngine  Milestone 9
VRInterface.h
1 #pragma once
2 
3 #include <Core/ResourceManager/ResourceHandle.h>
5 #include <GameEngine/GameEngineDLL.h>
6 #include <RendererFoundation/RendererFoundationDLL.h>
7 
9 class ezViewHandle;
10 class ezCamera;
11 class ezGALTextureHandle;
12 class ezWorld;
13 
14 struct ezHMDInfo
15 {
16  ezString m_sDeviceName;
17  ezString m_sDeviceDriver;
18  ezMat4 m_mat4eyePosLeft;
19  ezMat4 m_mat4eyePosRight;
20  ezVec2U32 m_vEyeRenderTargetSize;
21 };
22 
23 
25 {
26  typedef ezUInt8 StorageType;
27  enum Enum : ezUInt8
28  {
29  HMD,
30  LeftController,
31  RightController,
32  DeviceID0,
33  DeviceID1,
34  DeviceID2,
35  DeviceID3,
36  DeviceID4,
37  DeviceID5,
38  DeviceID6,
39  DeviceID7,
40  DeviceID8,
41  DeviceID9,
42  DeviceID10,
43  DeviceID11,
44  DeviceID12,
45  DeviceID13,
46  DeviceID14,
47  DeviceID15,
48  Default = HMD,
49  };
50 };
52 
58 {
59  typedef ezUInt8 StorageType;
60  enum Enum : ezUInt8
61  {
64  Default = Standing,
65  };
66 };
68 
69 typedef ezInt8 ezVRDeviceID;
76 {
77  enum class Type : ezUInt8
78  {
79  HMD,
80  Controller,
81  Tracker,
82  Reference,
83  Unknown,
84  };
85 
86  ezMat4 m_mPose;
87  ezVec3 m_vPosition;
88  ezQuat m_qRotation;
89  ezVec3 m_vVelocity;
90  ezVec3 m_vAngularVelocity;
91  Type m_Type = Type::Unknown;
92  bool m_bPoseIsValid = false;
93  bool m_bDeviceIsConnected = false;
94 };
95 
97 {
98  enum class Type : ezUInt8
99  {
100  DeviceAdded,
101  DeviceRemoved,
102  };
103 
104  Type m_Type;
105  ezVRDeviceID uiDeviceID = 0;
106 };
107 
109 {
110 public:
113  virtual bool IsHmdPresent() const = 0;
114 
117 
121  virtual bool Initialize() = 0;
123  virtual void Deinitialize() = 0;
125  virtual bool IsInitialized() const = 0;
126 
130 
132  virtual const ezHMDInfo& GetHmdInfo() const = 0;
133 
135  virtual void GetDeviceList(ezHybridArray<ezVRDeviceID, 64>& out_Devices) const = 0;
138  virtual ezVRDeviceID GetDeviceIDByType(ezVRDeviceType::Enum type) const = 0;
140  virtual const ezVRDeviceState& GetDeviceState(ezVRDeviceID iDeviceID) const = 0;
144 
148 
151  virtual ezViewHandle CreateVRView(const ezRenderPipelineResourceHandle& hRenderPipeline, ezCamera* pCamera,
152  ezGALMSAASampleCount::Enum msaaCount = ezGALMSAASampleCount::None) = 0;
154  virtual ezViewHandle GetVRView() const = 0;
156  virtual bool DestroyVRView() = 0;
157 
159  virtual bool SupportsCompanionView() = 0;
163  virtual bool SetCompanionViewRenderTarget(ezGALTextureHandle hRenderTarget) = 0;
164  virtual ezGALTextureHandle GetCompanionViewRenderTarget() const = 0;
165 
167 };
A camera class that stores the orientation and some basic camera settings.
Definition: Camera.h:37
Enum
Definition: VRInterface.h:60
virtual ezEvent< const ezVRDeviceEvent & > & DeviceEvents()=0
Returns the device event. Register to it to be informed of device (dis-)connects. ...
Defines the stage space used for the VR experience.
Definition: VRInterface.h:57
Definition: HybridArray.h:79
Definition: VRInterface.h:24
Definition: Event.h:136
virtual const ezHMDInfo & GetHmdInfo() const =0
Returns general HMD information.
Definition: VRInterface.h:108
Definition: RendererFoundationDLL.h:318
virtual void GetDeviceList(ezHybridArray< ezVRDeviceID, 64 > &out_Devices) const =0
Fills out a list of valid (connected) device IDs.
virtual bool IsHmdPresent() const =0
Returns whether an HMD is available. Can be used to decide whether it makes sense to call Initialize ...
virtual bool SupportsCompanionView()=0
Returns true if SetCompanionViewRenderTarget is supported.
Tracking poses will be relative to the center of the stage space at ground level. ...
Definition: VRInterface.h:63
virtual ezViewHandle CreateVRView(const ezRenderPipelineResourceHandle &hRenderPipeline, ezCamera *pCamera, ezGALMSAASampleCount::Enum msaaCount=ezGALMSAASampleCount::None)=0
Creates a VR view using the given render pipeline and camera. The camera is automatically updated wit...
virtual bool Initialize()=0
Initializes the VR system. This can be quite time consuming as it will generally start supporting app...
#define EZ_DECLARE_REFLECTABLE_TYPE(Linkage, TYPE)
Declares a type to be statically reflectable. Insert this into the header of a type to enable reflect...
Definition: StaticRTTI.h:123
virtual void Deinitialize()=0
Shuts down the VR system again.
virtual ezVRDeviceID GetDeviceIDByType(ezVRDeviceType::Enum type) const =0
Returns the deviceID for a specific type of device. If the device is not connected, -1 is returned instead.
virtual ezViewHandle GetVRView() const =0
Returns the VR view.
Definition: VRInterface.h:14
Definition: VRInterface.h:96
virtual bool IsInitialized() const =0
Returns whether the VR system is initialized.
A world encapsulates a scene graph of game objects and various component managers and their component...
Definition: World.h:18
virtual bool DestroyVRView()=0
Destroys the VR view.
Definition: Declarations.h:53
virtual bool SetCompanionViewRenderTarget(ezGALTextureHandle hRenderTarget)=0
Set a texture that the two eye images should be copied to. hRenderTarget must be a valid 2D texture t...
virtual const ezVRDeviceState & GetDeviceState(ezVRDeviceID iDeviceID) const =0
Returns the current device state for a valid device ID.
A device&#39;s pose state.
Definition: VRInterface.h:75
Tracking poses will be relative to a seated head position.
Definition: VRInterface.h:62