140 XrActionSet actionSet{ XR_NULL_HANDLE };
141 std::vector<XrAction> buttonAction;
142 std::vector<XrAction> touchAction;
143 std::vector<XrAction> analogAction;
144 std::vector<std::vector<bool> > buttonStates;
145 std::vector<std::vector<bool> > touchStates;
146 std::vector<std::vector<float> > analogStates;
148 XrAction poseAction{ XR_NULL_HANDLE };
149 XrAction vibrateAction{ XR_NULL_HANDLE };
151 std::array<XrPath, MAX_VR_CONTROLLERS> handSubactionPath;
152 std::array<XrSpace, MAX_VR_CONTROLLERS> handSpace;
153 std::array<float, MAX_VR_CONTROLLERS> handScale = { {1.0f, 1.0f} };
154 std::array<XrBool32, MAX_VR_CONTROLLERS> handActive;
155 std::array<bool, MAX_VR_CONTROLLERS> handVisible;
156 std::array<Vector3, MAX_VR_CONTROLLERS> handPos;
157 std::array<Quaternion, MAX_VR_CONTROLLERS> handQuat;
158 std::array<Vector3, MAX_VR_CONTROLLERS> handVelocity;
159 std::array<Vector3, MAX_VR_CONTROLLERS> handAngularVelocity;
174 std::string mAppName;
175 std::shared_ptr<IPlatform> mPlatform;
176 std::shared_ptr<IRenderer> mRenderer;
177 RenderSystem mRendererType;
178 XrInstance mInstance;
180 XrSystemId mSystemId;
181 XrSessionState mState;
182 XrViewConfigurationType mViewType;
185 std::string mDeviceName;
187 std::vector<XrView> mViews;
188 std::vector<XrViewConfigurationView> mViewconfigViews;
189 std::vector<XrCompositionLayerProjectionView> mProjectionViews;
190 XrEnvironmentBlendMode mBlendMode;
191 int mExtensionsEnable;
194 std::vector<XrSwapchain> mSwapchains;
195 std::vector<Vector2i> mSwapchainsSize;
204 bool system_supported;
205 PFN_xrLocateHandJointsEXT pfnLocateHandJointsEXT;
206 std::array<XrHandTrackerEXT, 2> trackers;
207 std::array<std::array<Position, MAX_HAND_JOINTS>, 2> bones;
214 XrPassthroughFB passthroughFeature;
215 XrPassthroughLayerFB passthroughLayer;
216 PFN_xrCreatePassthroughFB pfnXrCreatePassthroughFBX;
217 PFN_xrDestroyPassthroughFB pfnXrDestroyPassthroughFBX;
218 PFN_xrCreatePassthroughLayerFB pfnXrCreatePassthroughLayerFBX;
219 PFN_xrPassthroughStartFB pfnXrPassthroughStartFBX;
220 PFN_xrPassthroughPauseFB pfnXrPassthroughPauseFBX;
221 PFN_xrPassthroughLayerPauseFB pfnXrPassthroughLayerResumeFBX;
222 PFN_xrPassthroughLayerResumeFB pfnXrPassthroughLayerPauseFBX;
223 PFN_xrDestroyPassthroughLayerFB pfnXrDestroyPassthroughLayerFBX;
224 PFN_xrPassthroughLayerSetStyleFB pfnXrPassthroughLayerSetStyleFB;
230 XrPassthroughHTC passthroughFeature;
231 XrCompositionLayerPassthroughHTC passthroughLayer;
232 PFN_xrCreatePassthroughHTC pfnXrCreatePassthroughHTC;
233 PFN_xrDestroyPassthroughHTC pfnXrDestroyPassthroughHTC;
241 ControllerType mLastControllerType;
242 std::array<ControllerType, MAX_VR_CONTROLLERS> mControllerType;
245 std::array<float, 2> mFov;
246 long long mFrameIndex;
249 XrTime mPredictedDisplayTime;
251 bool mSessionRunning;
252 bool mRequestRestart;
254 bool mPassthroughEnable;
261 sOpenXr(RenderSystem rsys = XR_OPENGL_RENDERER,
float scaleRatio = 1.0f);
268 static sOpenXr* CreateInstance(RenderSystem rsys = XR_OPENGL_RENDERER,
float scale = 1.0f);
272 XrInstance GetXrInstance();
273 XrSession GetXrSession();
278 void SetScaleRatio(
float ratio);
280 bool GetHmdPosition(
Vector3 &vec);
281 XrTime GetPredictedDisplayTime();
282 void SetExtensions(
int extensions);
284 std::string GetHmdName();
285 bool GetProjectionMatrix(VrEye eye,
float nearclip,
float farclip,
Matrix4 &mat);
286 bool GetStereoTextureSize(
unsigned int &w,
unsigned int &h);
287 float GetStereoConfigFovY();
288 float GetStereoConfigIPD();
290 void UpdateTextures(SCOL_PTR_TYPE leftTexture, SCOL_PTR_TYPE rightTexture);
291 void SetState(
bool state);
293 bool GetControllerVisibility(
int id);
294 Vector3 GetControllerPosition(
int id);
296 Vector3 GetControllerVelocity(
int id);
297 Vector3 GetControllerAngularVelocity(
int id);
298 void SetControllerVibration(
int id,
float value);
300 std::vector<bool> GetControllerButtonsState(
int id);
301 std::vector<bool> GetControllerTouchesState(
int id);
302 std::vector<float> GetControllerAnalogState(
int id);
303 std::array<Position, MAX_HAND_JOINTS> GetControllerBones(
int id,
bool &ret);
304 int GetControllerType(
int id);
305 bool IsPassthroughSupported();
306 bool SetPassthroughState(
bool state);
307 RenderSystem GetRenderer();
308 void SetRenderer(RenderSystem renderer);
309 void SetAppName(std::string name);
310 bool SetSceneBlendMode(XrEnvironmentBlendMode mode);
312 void printSupportedViewConfigs();
313 void printViewconfigViewInfo();
314 void printReferenceSpaces();
318 bool processEvents();
319 void processActions();
320 bool initControllers();
321 void updateControllers(XrFrameState frameState);
322 void getControllerOffset(ControllerType type, VrController side,
bool skeletal,
Vector3 &vec,
Quaternion &quat);
323 bool updatePassthrough();
324 bool createPassthrough();
325 void cleanPassthrough();