From ddbb1e793f1bb74c28f48ace06673ab895c6c800 Mon Sep 17 00:00:00 2001 From: Starcommander Date: Thu, 23 Feb 2023 23:45:15 +0100 Subject: [PATCH 01/18] Copy jme3-vr to jme3-xr and cleanup native libs. --- jme3-xr/build.gradle | 29 + .../main/java/com/jme3/app/VRAppState.java | 626 +++++ .../main/java/com/jme3/app/VRApplication.java | 1504 +++++++++++ .../main/java/com/jme3/app/VRConstants.java | 174 ++ .../main/java/com/jme3/app/VREnvironment.java | 543 ++++ .../com/jme3/input/lwjgl/GlfwKeyInputVR.java | 153 ++ .../jme3/input/lwjgl/GlfwMouseInputVR.java | 332 +++ .../jme3/input/vr/AbstractVRMouseManager.java | 226 ++ .../jme3/input/vr/AbstractVRViewManager.java | 226 ++ .../com/jme3/input/vr/AnalogActionState.java | 48 + .../com/jme3/input/vr/DigitalActionState.java | 19 + .../main/java/com/jme3/input/vr/HmdType.java | 68 + .../main/java/com/jme3/input/vr/VRAPI.java | 183 ++ .../main/java/com/jme3/input/vr/VRBounds.java | 17 + .../java/com/jme3/input/vr/VRInputAPI.java | 377 +++ .../java/com/jme3/input/vr/VRInputType.java | 149 ++ .../com/jme3/input/vr/VRMouseManager.java | 111 + .../jme3/input/vr/VRTrackedController.java | 48 + .../java/com/jme3/input/vr/VRViewManager.java | 172 ++ .../input/vr/lwjgl_openvr/LWJGLOpenVR.java | 434 +++ .../LWJGLOpenVRAnalogActionData.java | 34 + .../vr/lwjgl_openvr/LWJGLOpenVRBounds.java | 50 + .../LWJGLOpenVRDigitalActionData.java | 34 + .../vr/lwjgl_openvr/LWJGLOpenVRInput.java | 703 +++++ .../lwjgl_openvr/LWJGLOpenVRMouseManager.java | 107 + .../LWJGLOpenVRTrackedController.java | 96 + .../lwjgl_openvr/LWJGLOpenVRViewManager.java | 569 ++++ .../input/vr/oculus/OculusMouseManager.java | 106 + .../com/jme3/input/vr/oculus/OculusVR.java | 663 +++++ .../jme3/input/vr/oculus/OculusVRInput.java | 370 +++ .../input/vr/oculus/OculusViewManager.java | 340 +++ .../jme3/input/vr/oculus/package-info.java | 35 + .../java/com/jme3/input/vr/openvr/OpenVR.java | 584 +++++ .../jme3/input/vr/openvr/OpenVRBounds.java | 56 + .../com/jme3/input/vr/openvr/OpenVRInput.java | 498 ++++ .../input/vr/openvr/OpenVRMouseManager.java | 106 + .../vr/openvr/OpenVRTrackedController.java | 95 + .../input/vr/openvr/OpenVRViewManager.java | 733 ++++++ .../jme3/input/vr/openvr/package-info.java | 35 + .../java/com/jme3/input/vr/osvr/OSVR.java | 459 ++++ .../com/jme3/input/vr/osvr/OSVRInput.java | 347 +++ .../jme3/input/vr/osvr/OSVRMouseManager.java | 106 + .../jme3/input/vr/osvr/OSVRViewManager.java | 867 ++++++ .../com/jme3/input/vr/osvr/package-info.java | 36 + .../java/com/jme3/input/vr/package-info.java | 35 + .../main/java/com/jme3/post/CartoonSSAO.java | 155 ++ .../main/java/com/jme3/post/FilterUtil.java | 48 + .../java/com/jme3/post/PreNormalCaching.java | 72 + .../main/java/com/jme3/scene/CenterQuad.java | 173 ++ .../jme3/shadow/AbstractShadowFilterVR.java | 320 +++ .../jme3/shadow/AbstractShadowRendererVR.java | 839 ++++++ .../DirectionalLightShadowFilterVR.java | 172 ++ .../DirectionalLightShadowRendererVR.java | 308 +++ .../InstancedDirectionalShadowFilter.java | 66 + .../VRDirectionalLightShadowRenderer.java | 78 + .../system/jopenvr/AppOverrideKeys_t.java | 50 + .../jme3/system/jopenvr/COpenVRContext.java | 110 + .../jme3/system/jopenvr/CVRSettingHelper.java | 43 + .../CameraVideoStreamFrameHeader_t.java | 53 + .../jopenvr/Compositor_CumulativeStats.java | 44 + .../jopenvr/Compositor_FrameTiming.java | 54 + .../jopenvr/Compositor_OverlaySettings.java | 44 + .../system/jopenvr/D3D12TextureData_t.java | 54 + .../jopenvr/DistortionCoordinates_t.java | 64 + .../jopenvr/DriverDirectMode_FrameTiming.java | 42 + .../jme3/system/jopenvr/HiddenAreaMesh_t.java | 44 + .../com/jme3/system/jopenvr/HmdColor_t.java | 40 + .../jme3/system/jopenvr/HmdMatrix33_t.java | 44 + .../jme3/system/jopenvr/HmdMatrix34_t.java | 44 + .../jme3/system/jopenvr/HmdMatrix44_t.java | 44 + .../com/jme3/system/jopenvr/HmdQuad_t.java | 44 + .../jme3/system/jopenvr/HmdQuaternion_t.java | 40 + .../jme3/system/jopenvr/HmdQuaternionf_t.java | 40 + .../com/jme3/system/jopenvr/HmdRect2_t.java | 42 + .../com/jme3/system/jopenvr/HmdVector2_t.java | 44 + .../com/jme3/system/jopenvr/HmdVector3_t.java | 44 + .../jme3/system/jopenvr/HmdVector3d_t.java | 44 + .../com/jme3/system/jopenvr/HmdVector4_t.java | 44 + .../com/jme3/system/jopenvr/ImuSample_t.java | 46 + .../jopenvr/InputAnalogActionData_t.java | 52 + .../jopenvr/InputDigitalActionData_t.java | 44 + .../system/jopenvr/InputOriginInfo_t.java | 52 + .../system/jopenvr/InputPoseActionData_t.java | 44 + .../jopenvr/InputSkeletalActionData_t.java | 40 + .../jopenvr/IntersectionMaskCircle_t.java | 38 + .../jopenvr/IntersectionMaskRectangle_t.java | 40 + .../jme3/system/jopenvr/JOpenVRLibrary.java | 2332 +++++++++++++++++ .../system/jopenvr/NotificationBitmap_t.java | 48 + .../com/jme3/system/jopenvr/OpenVRUtil.java | 779 ++++++ .../jopenvr/RenderModel_ComponentState_t.java | 46 + .../RenderModel_ControllerMode_State_t.java | 34 + .../jopenvr/RenderModel_TextureMap_t.java | 46 + .../system/jopenvr/RenderModel_Vertex_t.java | 52 + .../jme3/system/jopenvr/RenderModel_t.java | 59 + .../system/jopenvr/SpatialAnchorPose_t.java | 36 + .../com/jme3/system/jopenvr/Texture_t.java | 56 + .../system/jopenvr/TrackedDevicePose_t.java | 57 + .../system/jopenvr/VRActiveActionSet_t.java | 50 + .../system/jopenvr/VRBoneTransform_t.java | 42 + .../system/jopenvr/VRControllerAxis_t.java | 36 + .../system/jopenvr/VRControllerState_t.java | 50 + .../jopenvr/VREvent_ApplicationLaunch_t.java | 36 + .../system/jopenvr/VREvent_Chaperone_t.java | 36 + .../system/jopenvr/VREvent_Controller_t.java | 34 + .../jme3/system/jopenvr/VREvent_Data_t.java | 135 + .../system/jopenvr/VREvent_DualAnalog_t.java | 49 + .../VREvent_EditingCameraSurface_t.java | 36 + .../jopenvr/VREvent_HapticVibration_t.java | 42 + .../VREvent_InputActionManifestLoad_t.java | 40 + .../jopenvr/VREvent_InputBindingLoad_t.java | 42 + .../jme3/system/jopenvr/VREvent_Ipd_t.java | 34 + .../system/jopenvr/VREvent_Keyboard_t.java | 46 + .../jopenvr/VREvent_MessageOverlay_t.java | 34 + .../jme3/system/jopenvr/VREvent_Mouse_t.java | 38 + .../jopenvr/VREvent_Notification_t.java | 36 + .../system/jopenvr/VREvent_Overlay_t.java | 36 + .../jopenvr/VREvent_PerformanceTest_t.java | 34 + .../system/jopenvr/VREvent_Process_t.java | 38 + .../system/jopenvr/VREvent_Property_t.java | 45 + .../system/jopenvr/VREvent_Reserved_t.java | 40 + .../jopenvr/VREvent_ScreenshotProgress_t.java | 34 + .../system/jopenvr/VREvent_Screenshot_t.java | 36 + .../jme3/system/jopenvr/VREvent_Scroll_t.java | 38 + .../VREvent_SeatedZeroPoseReset_t.java | 34 + .../jopenvr/VREvent_SpatialAnchor_t.java | 36 + .../jme3/system/jopenvr/VREvent_Status_t.java | 34 + .../jopenvr/VREvent_TouchPadMove_t.java | 44 + .../system/jopenvr/VREvent_WebConsole_t.java | 36 + .../com/jme3/system/jopenvr/VREvent_t.java | 49 + ...erlayIntersectionMaskPrimitive_Data_t.java | 39 + .../VROverlayIntersectionMaskPrimitive_t.java | 45 + .../VROverlayIntersectionParams_t.java | 49 + .../VROverlayIntersectionResults_t.java | 48 + .../system/jopenvr/VRTextureBounds_t.java | 40 + .../system/jopenvr/VRTextureDepthInfo_t.java | 50 + .../system/jopenvr/VRTextureWithDepth_t.java | 36 + .../jopenvr/VRTextureWithPoseAndDepth_t.java | 36 + .../system/jopenvr/VRTextureWithPose_t.java | 36 + .../system/jopenvr/VRVulkanTextureData_t.java | 59 + .../jopenvr/VR_IVRApplications_FnTable.java | 217 ++ .../jopenvr/VR_IVRChaperoneSetup_FnTable.java | 152 ++ .../jopenvr/VR_IVRChaperone_FnTable.java | 100 + .../jopenvr/VR_IVRCompositor_FnTable.java | 291 ++ .../jopenvr/VR_IVRDriverManager_FnTable.java | 59 + .../VR_IVRExtendedDisplay_FnTable.java | 60 + .../jopenvr/VR_IVRIOBuffer_FnTable.java | 77 + .../system/jopenvr/VR_IVRInput_FnTable.java | 140 + .../jopenvr/VR_IVRNotifications_FnTable.java | 52 + .../system/jopenvr/VR_IVROverlay_FnTable.java | 526 ++++ .../jopenvr/VR_IVRRenderModels_FnTable.java | 146 ++ .../jopenvr/VR_IVRResources_FnTable.java | 51 + .../jopenvr/VR_IVRScreenshots_FnTable.java | 92 + .../jopenvr/VR_IVRSettings_FnTable.java | 103 + .../jopenvr/VR_IVRSpatialAnchors_FnTable.java | 68 + .../system/jopenvr/VR_IVRSystem_FnTable.java | 317 +++ .../jopenvr/VR_IVRTrackedCamera_FnTable.java | 105 + .../com/jme3/system/lwjgl/LwjglContextVR.java | 310 +++ .../com/jme3/system/lwjgl/LwjglDisplayVR.java | 54 + .../system/lwjgl/LwjglOffscreenBufferVR.java | 50 + .../com/jme3/system/lwjgl/LwjglWindowVR.java | 621 +++++ .../osvrclientkit/OsvrClientKitLibrary.java | 380 +++ .../OSVR_AccelerationReport.java | 37 + .../OSVR_AccelerationState.java | 49 + .../OSVR_AnalogReport.java | 37 + .../OSVR_AngularAccelerationReport.java | 37 + .../OSVR_AngularVelocityReport.java | 37 + .../OSVR_ButtonReport.java | 37 + .../OSVR_DirectionReport.java | 41 + .../OSVR_EyeTracker2DReport.java | 41 + .../OSVR_EyeTracker3DReport.java | 41 + .../OSVR_EyeTracker3DState.java | 49 + .../OSVR_EyeTrackerBlinkReport.java | 41 + .../OSVR_IncrementalQuaternion.java | 37 + .../OSVR_LinearAccelerationReport.java | 37 + .../OSVR_LinearVelocityReport.java | 37 + .../OSVR_Location2DReport.java | 41 + .../OSVR_NaviPositionReport.java | 41 + .../OSVR_NaviVelocityReport.java | 41 + .../OSVR_OrientationReport.java | 37 + .../osvrclientreporttypes/OSVR_Pose3.java | 41 + .../OSVR_PoseReport.java | 37 + .../OSVR_PositionReport.java | 37 + .../OSVR_Quaternion.java | 37 + .../osvr/osvrclientreporttypes/OSVR_Vec2.java | 37 + .../osvr/osvrclientreporttypes/OSVR_Vec3.java | 37 + .../OSVR_VelocityReport.java | 37 + .../OSVR_VelocityState.java | 49 + .../OsvrClientReportTypesLibrary.java | 79 + .../osvr/osvrdisplay/OsvrDisplayLibrary.java | 851 ++++++ .../osvrinterface/OsvrInterfaceLibrary.java | 24 + .../osvrmatrixconventions/OSVR_Pose3.java | 41 + .../OSVR_Quaternion.java | 37 + .../osvr/osvrmatrixconventions/OSVR_Vec3.java | 37 + .../OsvrMatrixConventionsLibrary.java | 192 ++ .../OSVR_ProjectionMatrix.java | 45 + .../osvr/osvrrendermanager/OSVR_RGB.java | 37 + .../osvrrendermanager/OSVR_RenderParams.java | 53 + .../OSVR_ViewportDescription.java | 49 + .../OsvrRenderManagerLibrary.java | 117 + .../OSVR_GraphicsLibraryOpenGL.java | 35 + .../OSVR_OpenGLContextParams.java | 57 + .../OSVR_OpenGLToolkitFunctions.java | 92 + .../OSVR_OpenResultsOpenGL.java | 48 + .../OSVR_ProjectionMatrix.java | 45 + .../osvrrendermanageropengl/OSVR_RGB.java | 37 + .../OSVR_RenderBufferOpenGL.java | 35 + .../OSVR_RenderInfoOpenGL.java | 48 + .../OSVR_RenderParams.java | 53 + .../OSVR_ViewportDescription.java | 49 + .../OsvrRenderManagerOpenGLLibrary.java | 169 ++ .../osvr/osvrtimevalue/OSVR_TimeValue.java | 41 + .../osvrtimevalue/OsvrTimeValueLibrary.java | 119 + .../com/jme3/util/VRGUIPositioningMode.java | 15 + .../main/java/com/jme3/util/VRGuiManager.java | 467 ++++ .../src/main/java/com/jme3/util/VRUtil.java | 101 + jme3-xr/src/main/java/test/TestInitHmd.java | 59 + .../Common/MatDefs/VR/CartoonSSAO.frag | 109 + .../Common/MatDefs/VR/CartoonSSAO.j3md | 47 + .../Common/MatDefs/VR/GuiOverlay.frag | 10 + .../Common/MatDefs/VR/GuiOverlay.j3md | 38 + .../Common/MatDefs/VR/GuiOverlay.vert | 12 + .../Common/MatDefs/VR/GuiOverlay15.frag | 13 + .../Common/MatDefs/VR/GuiOverlay15.vert | 14 + .../resources/Common/MatDefs/VR/OpenVR.frag | 22 + .../resources/Common/MatDefs/VR/OpenVR.j3md | 33 + .../resources/Common/MatDefs/VR/OpenVR.vert | 17 + .../resources/Common/MatDefs/VR/OpenVR15.frag | 24 + .../resources/Common/MatDefs/VR/OpenVR15.vert | 17 + .../Common/MatDefs/VR/PostShadowFilter.frag | 184 ++ .../Common/MatDefs/VR/PostShadowFilter.j3md | 99 + .../Common/MatDefs/VR/PostShadowFilter.vert | 11 + .../resources/Common/MatDefs/VR/Unshaded.frag | 21 + .../resources/Common/MatDefs/VR/Unshaded.j3md | 45 + .../resources/Common/MatDefs/VR/Unshaded.vert | 27 + .../resources/Common/MatDefs/VR/normal.frag | 9 + .../resources/Common/MatDefs/VR/normal.vert | 19 + .../Common/ShaderLib/InstanceVR.glsllib | 126 + .../main/resources/Common/Util/gui_mesh.j3o | Bin 0 -> 4995 bytes .../resources/Common/Util/gui_mesh.j3odata | 3 + .../src/main/resources/Common/Util/mouse.png | Bin 0 -> 2115 bytes 240 files changed, 30472 insertions(+) create mode 100644 jme3-xr/build.gradle create mode 100644 jme3-xr/src/main/java/com/jme3/app/VRAppState.java create mode 100644 jme3-xr/src/main/java/com/jme3/app/VRApplication.java create mode 100644 jme3-xr/src/main/java/com/jme3/app/VRConstants.java create mode 100644 jme3-xr/src/main/java/com/jme3/app/VREnvironment.java create mode 100644 jme3-xr/src/main/java/com/jme3/input/lwjgl/GlfwKeyInputVR.java create mode 100644 jme3-xr/src/main/java/com/jme3/input/lwjgl/GlfwMouseInputVR.java create mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/AbstractVRMouseManager.java create mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/AbstractVRViewManager.java create mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/AnalogActionState.java create mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/DigitalActionState.java create mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/HmdType.java create mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/VRAPI.java create mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/VRBounds.java create mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/VRInputAPI.java create mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/VRInputType.java create mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/VRMouseManager.java create mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/VRTrackedController.java create mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/VRViewManager.java create mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVR.java create mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRAnalogActionData.java create mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRBounds.java create mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRDigitalActionData.java create mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRInput.java create mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRMouseManager.java create mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRTrackedController.java create mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRViewManager.java create mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/oculus/OculusMouseManager.java create mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/oculus/OculusVR.java create mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/oculus/OculusVRInput.java create mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/oculus/OculusViewManager.java create mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/oculus/package-info.java create mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/openvr/OpenVR.java create mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/openvr/OpenVRBounds.java create mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/openvr/OpenVRInput.java create mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/openvr/OpenVRMouseManager.java create mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/openvr/OpenVRTrackedController.java create mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/openvr/OpenVRViewManager.java create mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/openvr/package-info.java create mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/osvr/OSVR.java create mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/osvr/OSVRInput.java create mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/osvr/OSVRMouseManager.java create mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/osvr/OSVRViewManager.java create mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/osvr/package-info.java create mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/package-info.java create mode 100644 jme3-xr/src/main/java/com/jme3/post/CartoonSSAO.java create mode 100644 jme3-xr/src/main/java/com/jme3/post/FilterUtil.java create mode 100644 jme3-xr/src/main/java/com/jme3/post/PreNormalCaching.java create mode 100644 jme3-xr/src/main/java/com/jme3/scene/CenterQuad.java create mode 100644 jme3-xr/src/main/java/com/jme3/shadow/AbstractShadowFilterVR.java create mode 100644 jme3-xr/src/main/java/com/jme3/shadow/AbstractShadowRendererVR.java create mode 100644 jme3-xr/src/main/java/com/jme3/shadow/DirectionalLightShadowFilterVR.java create mode 100644 jme3-xr/src/main/java/com/jme3/shadow/DirectionalLightShadowRendererVR.java create mode 100644 jme3-xr/src/main/java/com/jme3/shadow/InstancedDirectionalShadowFilter.java create mode 100644 jme3-xr/src/main/java/com/jme3/shadow/VRDirectionalLightShadowRenderer.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/AppOverrideKeys_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/COpenVRContext.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/CVRSettingHelper.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/CameraVideoStreamFrameHeader_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/Compositor_CumulativeStats.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/Compositor_FrameTiming.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/Compositor_OverlaySettings.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/D3D12TextureData_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/DistortionCoordinates_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/DriverDirectMode_FrameTiming.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/HiddenAreaMesh_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdColor_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdMatrix33_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdMatrix34_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdMatrix44_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdQuad_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdQuaternion_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdQuaternionf_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdRect2_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdVector2_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdVector3_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdVector3d_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdVector4_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/ImuSample_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/InputAnalogActionData_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/InputDigitalActionData_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/InputOriginInfo_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/InputPoseActionData_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/InputSkeletalActionData_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/IntersectionMaskCircle_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/IntersectionMaskRectangle_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/JOpenVRLibrary.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/NotificationBitmap_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/OpenVRUtil.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/RenderModel_ComponentState_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/RenderModel_ControllerMode_State_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/RenderModel_TextureMap_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/RenderModel_Vertex_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/RenderModel_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/SpatialAnchorPose_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/Texture_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/TrackedDevicePose_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VRActiveActionSet_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VRBoneTransform_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VRControllerAxis_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VRControllerState_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_ApplicationLaunch_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Chaperone_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Controller_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Data_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_DualAnalog_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_EditingCameraSurface_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_HapticVibration_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_InputActionManifestLoad_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_InputBindingLoad_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Ipd_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Keyboard_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_MessageOverlay_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Mouse_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Notification_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Overlay_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_PerformanceTest_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Process_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Property_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Reserved_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_ScreenshotProgress_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Screenshot_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Scroll_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_SeatedZeroPoseReset_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_SpatialAnchor_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Status_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_TouchPadMove_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_WebConsole_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VROverlayIntersectionMaskPrimitive_Data_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VROverlayIntersectionMaskPrimitive_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VROverlayIntersectionParams_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VROverlayIntersectionResults_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VRTextureBounds_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VRTextureDepthInfo_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VRTextureWithDepth_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VRTextureWithPoseAndDepth_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VRTextureWithPose_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VRVulkanTextureData_t.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRApplications_FnTable.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRChaperoneSetup_FnTable.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRChaperone_FnTable.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRCompositor_FnTable.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRDriverManager_FnTable.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRExtendedDisplay_FnTable.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRIOBuffer_FnTable.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRInput_FnTable.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRNotifications_FnTable.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVROverlay_FnTable.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRRenderModels_FnTable.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRResources_FnTable.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRScreenshots_FnTable.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRSettings_FnTable.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRSpatialAnchors_FnTable.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRSystem_FnTable.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRTrackedCamera_FnTable.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/lwjgl/LwjglContextVR.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/lwjgl/LwjglDisplayVR.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/lwjgl/LwjglOffscreenBufferVR.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/lwjgl/LwjglWindowVR.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientkit/OsvrClientKitLibrary.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_AccelerationReport.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_AccelerationState.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_AnalogReport.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_AngularAccelerationReport.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_AngularVelocityReport.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_ButtonReport.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_DirectionReport.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_EyeTracker2DReport.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_EyeTracker3DReport.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_EyeTracker3DState.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_EyeTrackerBlinkReport.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_IncrementalQuaternion.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_LinearAccelerationReport.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_LinearVelocityReport.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_Location2DReport.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_NaviPositionReport.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_NaviVelocityReport.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_OrientationReport.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_Pose3.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_PoseReport.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_PositionReport.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_Quaternion.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_Vec2.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_Vec3.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_VelocityReport.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_VelocityState.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OsvrClientReportTypesLibrary.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrdisplay/OsvrDisplayLibrary.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrinterface/OsvrInterfaceLibrary.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrmatrixconventions/OSVR_Pose3.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrmatrixconventions/OSVR_Quaternion.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrmatrixconventions/OSVR_Vec3.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrmatrixconventions/OsvrMatrixConventionsLibrary.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanager/OSVR_ProjectionMatrix.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanager/OSVR_RGB.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanager/OSVR_RenderParams.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanager/OSVR_ViewportDescription.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanager/OsvrRenderManagerLibrary.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_GraphicsLibraryOpenGL.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_OpenGLContextParams.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_OpenGLToolkitFunctions.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_OpenResultsOpenGL.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_ProjectionMatrix.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_RGB.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_RenderBufferOpenGL.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_RenderInfoOpenGL.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_RenderParams.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_ViewportDescription.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OsvrRenderManagerOpenGLLibrary.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrtimevalue/OSVR_TimeValue.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrtimevalue/OsvrTimeValueLibrary.java create mode 100644 jme3-xr/src/main/java/com/jme3/util/VRGUIPositioningMode.java create mode 100644 jme3-xr/src/main/java/com/jme3/util/VRGuiManager.java create mode 100644 jme3-xr/src/main/java/com/jme3/util/VRUtil.java create mode 100644 jme3-xr/src/main/java/test/TestInitHmd.java create mode 100644 jme3-xr/src/main/resources/Common/MatDefs/VR/CartoonSSAO.frag create mode 100644 jme3-xr/src/main/resources/Common/MatDefs/VR/CartoonSSAO.j3md create mode 100644 jme3-xr/src/main/resources/Common/MatDefs/VR/GuiOverlay.frag create mode 100644 jme3-xr/src/main/resources/Common/MatDefs/VR/GuiOverlay.j3md create mode 100644 jme3-xr/src/main/resources/Common/MatDefs/VR/GuiOverlay.vert create mode 100644 jme3-xr/src/main/resources/Common/MatDefs/VR/GuiOverlay15.frag create mode 100644 jme3-xr/src/main/resources/Common/MatDefs/VR/GuiOverlay15.vert create mode 100644 jme3-xr/src/main/resources/Common/MatDefs/VR/OpenVR.frag create mode 100644 jme3-xr/src/main/resources/Common/MatDefs/VR/OpenVR.j3md create mode 100644 jme3-xr/src/main/resources/Common/MatDefs/VR/OpenVR.vert create mode 100644 jme3-xr/src/main/resources/Common/MatDefs/VR/OpenVR15.frag create mode 100644 jme3-xr/src/main/resources/Common/MatDefs/VR/OpenVR15.vert create mode 100644 jme3-xr/src/main/resources/Common/MatDefs/VR/PostShadowFilter.frag create mode 100644 jme3-xr/src/main/resources/Common/MatDefs/VR/PostShadowFilter.j3md create mode 100644 jme3-xr/src/main/resources/Common/MatDefs/VR/PostShadowFilter.vert create mode 100644 jme3-xr/src/main/resources/Common/MatDefs/VR/Unshaded.frag create mode 100644 jme3-xr/src/main/resources/Common/MatDefs/VR/Unshaded.j3md create mode 100644 jme3-xr/src/main/resources/Common/MatDefs/VR/Unshaded.vert create mode 100644 jme3-xr/src/main/resources/Common/MatDefs/VR/normal.frag create mode 100644 jme3-xr/src/main/resources/Common/MatDefs/VR/normal.vert create mode 100644 jme3-xr/src/main/resources/Common/ShaderLib/InstanceVR.glsllib create mode 100644 jme3-xr/src/main/resources/Common/Util/gui_mesh.j3o create mode 100644 jme3-xr/src/main/resources/Common/Util/gui_mesh.j3odata create mode 100644 jme3-xr/src/main/resources/Common/Util/mouse.png diff --git a/jme3-xr/build.gradle b/jme3-xr/build.gradle new file mode 100644 index 0000000000..6fbc20d209 --- /dev/null +++ b/jme3-xr/build.gradle @@ -0,0 +1,29 @@ +dependencies { + api project(':jme3-core') + api project(':jme3-lwjgl3') + api project(':jme3-desktop') + api project(':jme3-effects') + + // https://mvnrepository.com/artifact/net.java.dev.jna/jna + implementation 'net.java.dev.jna:jna:5.10.0' + implementation 'com.nativelibs4java:jnaerator-runtime:0.12' + + // Native LibOVR/Oculus support + api "org.lwjgl:lwjgl-ovr:${lwjgl3Version}" + runtimeOnly "org.lwjgl:lwjgl-ovr:${lwjgl3Version}:natives-windows" + + // Native OpenVR/LWJGL support + api "org.lwjgl:lwjgl-openvr:${lwjgl3Version}" + implementation "org.lwjgl:lwjgl-openvr:${lwjgl3Version}:natives-linux" + implementation "org.lwjgl:lwjgl-openvr:${lwjgl3Version}:natives-macos" + runtimeOnly "org.lwjgl:lwjgl-openvr:${lwjgl3Version}:natives-windows" + runtimeOnly "org.lwjgl:lwjgl-openvr:${lwjgl3Version}:natives-linux" + runtimeOnly "org.lwjgl:lwjgl-openvr:${lwjgl3Version}:natives-macos" +} + +javadoc { + // Disable doclint for JDK8+. + if (JavaVersion.current().isJava8Compatible()){ + options.addStringOption('Xdoclint:none', '-quiet') + } +} diff --git a/jme3-xr/src/main/java/com/jme3/app/VRAppState.java b/jme3-xr/src/main/java/com/jme3/app/VRAppState.java new file mode 100644 index 0000000000..fa0956b2b2 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/app/VRAppState.java @@ -0,0 +1,626 @@ +package com.jme3.app; + +/* + * Copyright (c) 2009-2021 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +import com.jme3.app.Application; +import com.jme3.app.state.AbstractAppState; +import com.jme3.app.state.AppStateManager; +import com.jme3.input.vr.VRAPI; +import com.jme3.input.vr.VRInputAPI; +import com.jme3.input.vr.VRMouseManager; +import com.jme3.input.vr.VRViewManager; +import com.jme3.math.ColorRGBA; +import com.jme3.math.Quaternion; +import com.jme3.math.Vector3f; +import com.jme3.post.PreNormalCaching; +import com.jme3.renderer.RenderManager; +import com.jme3.renderer.ViewPort; +import com.jme3.scene.Spatial; +import com.jme3.system.AppSettings; +import com.jme3.util.VRGUIPositioningMode; +import com.jme3.util.VRGuiManager; + +import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.util.Locale; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * A JMonkey app state dedicated to Virtual Reality. + * An application that want to use VR devices (HTC vive, ...) has to use this app state.
+ * As this app state and the main {@link Application application} have to share {@link AppSettings application settings}, + * the common way to use this app state is:
+ * + * Attaching an instance of this app state to an already started application may cause crashes. + * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr + */ +public class VRAppState extends AbstractAppState { + public static final String ID = "VRAppState"; + private static final Logger logger = Logger.getLogger(VRAppState.class.getName()); + + /** + * Is the application has not to start within VR mode (default is false). + */ + public boolean DISABLE_VR = false; + + private float fFar = 1000f; + private float fNear = 0.1f; + private int xWin = 1920; + private int yWin = 1080; + + private float resMult = 1f; + + /* + where is the headset pointing, after all rotations are combined? + depends on observer rotation, if any + */ + private Quaternion tempq = new Quaternion(); + + private Application application = null; + private AppStateManager stateManager = null; + private AppSettings settings = null; + + private VREnvironment environment = null; + + /** + * Create a new default VR app state that relies on the given {@link VREnvironment VR environment}. + * @param environment the {@link VREnvironment VR environment} that this app state is using. + */ + public VRAppState(VREnvironment environment) { + super(ID); + + this.environment = environment; + + this.setSettings(environment.getSettings()); + } + + /** + * Create a new VR app state with given settings. The app state relies on the given {@link VREnvironment VR environment}. + * @param settings the settings to use. + * @param environment the {@link VREnvironment VR environment} that this app state is using. + */ + public VRAppState(AppSettings settings, VREnvironment environment){ + this(environment); + this.settings = settings; + processSettings(settings); + } + + /** + * Simple update of the app state, this method should contain any spatial updates. + * This method is called by the {@link #update(float) update()} method and should not be called manually. + * @param tpf the application time. + */ + public void simpleUpdate(float tpf) { + return; + } + + /** + * Rendering callback of the app state. This method is called by the {@link #update(float) update()} method and should not be called manually. + * @param renderManager the {@link RenderManager render manager}. + */ + public void simpleRender(RenderManager renderManager) { + PreNormalCaching.resetCache(environment.isInVR()); + } + + /** + * Set the frustum values for the application. + * @param near the frustum near value. + * @param far the frustum far value. + */ + public void setFrustrumNearFar(float near, float far) { + fNear = near; + fFar = far; + } + + /** + * Set the mirror window size in pixel. + * @param width the width of the mirror window in pixel. + * @param height the height of the mirror window in pixel. + */ + public void setMirrorWindowSize(int width, int height) { + xWin = width; + yWin = height; + } + + /** + * Set the resolution multiplier. + * @param val the resolution multiplier. + */ + public void setResolutionMultiplier(float val) { + resMult = val; + if( environment.getVRViewManager() != null ){ + environment.getVRViewManager().setResolutionMultiplier(resMult); + } + } + + /** + * Move filters from the main scene into the eye's. + * This removes filters from the main scene. + */ + public void moveScreenProcessingToVR() { + environment.getVRViewManager().moveScreenProcessingToEyes(); + } + + /** + * Get the observer final rotation within the scene. + * @return the observer final rotation within the scene. + * @see #getFinalObserverPosition() + */ + public Quaternion getFinalObserverRotation() { + if( environment.getVRViewManager() == null ) { + if( environment.getObserver() == null ) { + return environment.getCamera().getRotation(); + } else { + return ((Spatial)environment.getObserver()).getWorldRotation(); + } + } + + if( environment.getObserver() == null ) { + tempq.set(environment.getDummyCamera().getRotation()); + } else { + tempq.set(((Spatial)environment.getObserver()).getWorldRotation()); + } + return tempq.multLocal(environment.getVRHardware().getOrientation()); + } + + /** + * Get the observer final position within the scene. + * @return the observer position. + * @see #getFinalObserverRotation() + */ + public Vector3f getFinalObserverPosition() { + if( environment.getVRViewManager() == null ) { + if( environment.getObserver() == null ) { + return environment.getCamera().getLocation(); + } else{ + return ((Spatial)environment.getObserver()).getWorldTranslation(); + } + } + + Vector3f pos = environment.getVRHardware().getPosition(); + if( environment.getObserver() == null ) { + environment.getDummyCamera().getRotation().mult(pos, pos); + return pos.addLocal(environment.getDummyCamera().getLocation()); + } else { + ((Spatial)environment.getObserver()).getWorldRotation().mult(pos, pos); + return pos.addLocal(((Spatial)environment.getObserver()).getWorldTranslation()); + } + } + + /** + * Get the VR headset left viewport. + * @return the VR headset left viewport. + * @see #getRightViewPort() + */ + public ViewPort getLeftViewPort() { + if( environment.getVRViewManager() == null ){ + return application.getViewPort(); + } + + return environment.getVRViewManager().getLeftViewPort(); + } + + /** + * Get the VR headset right viewport. + * @return the VR headset right viewport. + * @see #getLeftViewPort() + */ + public ViewPort getRightViewPort() { + if( environment.getVRViewManager() == null ){ + return application.getViewPort(); + } + return environment.getVRViewManager().getRightViewPort(); + } + + /** + * Set the background color for both left and right view ports. + * @param clr the background color. + */ + public void setBackgroundColors(ColorRGBA clr) { + if( environment.getVRViewManager() == null ) { + application.getViewPort().setBackgroundColor(clr); + } else if( environment.getVRViewManager().getLeftViewPort() != null ) { + environment.getVRViewManager().getLeftViewPort().setBackgroundColor(clr); + + if( environment.getVRViewManager().getRightViewPort() != null ){ + environment.getVRViewManager().getRightViewPort().setBackgroundColor(clr); + } + } + } + + /** + * Get the {@link Application} to which this app state is attached. + * @return the {@link Application} to which this app state is attached. + * @see #getStateManager() + */ + public Application getApplication(){ + return application; + } + + /** + * Get the {@link AppStateManager state manager} to which this app state is attached. + * @return the {@link AppStateManager state manager} to which this app state is attached. + * @see #getApplication() + */ + public AppStateManager getStateManager(){ + return stateManager; + } + + /** + * Get the scene observer. If no observer has been set, this method returns the application camera. + * @return the scene observer. + * @see #setObserver(Spatial) + */ + public Object getObserver() { + return environment.getObserver(); + } + + /** + * Set the scene observer. The VR headset will be linked to it. If no observer is set, the VR headset is linked to the application camera. + * @param observer the scene observer. + */ + public void setObserver(Spatial observer) { + environment.setObserver(observer); + } + + /** + * Check if the rendering is instanced (see Geometry instancing). + * @return true if the rendering is instanced and false otherwise. + */ + public boolean isInstanceRendering() { + return environment.isInstanceRendering(); + } + + /** + * Return the {@link VREnvironment VR environment} on which this app state relies. + * @return the {@link VREnvironment VR environment} on which this app state relies. + */ + public VREnvironment getVREnvironment(){ + return environment; + } + + /** + * Get the VR underlying hardware. + * @return the VR underlying hardware. + */ + public VRAPI getVRHardware() { + return getVREnvironment().getVRHardware(); + } + + /** + * Get the VR dedicated input. + * @return the VR dedicated input. + */ + public VRInputAPI getVRinput() { + if( getVREnvironment().getVRHardware() == null ){ + return null; + } + + return getVREnvironment().getVRHardware().getVRinput(); + } + + /** + * Get the VR view manager. + * @return the VR view manager. + */ + public VRViewManager getVRViewManager() { + return getVREnvironment().getVRViewManager(); + } + + /** + * Get the GUI manager attached to this app state. + * @return the GUI manager attached to this app state. + */ + public VRGuiManager getVRGUIManager(){ + return getVREnvironment().getVRGUIManager(); + } + + /** + * Get the VR mouse manager attached to this app state. + * @return the VR mouse manager attached to this application. + */ + public VRMouseManager getVRMouseManager(){ + return getVREnvironment().getVRMouseManager(); + } + + /** + * Get the {@link AppSettings settings} attached to this app state. + * @return the {@link AppSettings settings} attached to this app state. + * @see #setSettings(AppSettings) + */ + public AppSettings getSettings(){ + return settings; + } + + /** + * Set the {@link AppSettings settings} attached to this app state. + * @param settings the {@link AppSettings settings} attached to this app state. + * @see #getSettings() + */ + public void setSettings(AppSettings settings){ + this.settings = settings; + processSettings(settings); + } + + @Override + public void update(float tpf) { + + // update VR pose & cameras + if( environment.getVRViewManager() != null ) { + environment.getVRViewManager().update(tpf); + } else if( environment.getObserver() != null ) { + environment.getCamera().setFrame(((Spatial)environment.getObserver()).getWorldTranslation(), ((Spatial)environment.getObserver()).getWorldRotation()); + } + + if( environment.isInVR() == false || environment.getVRGUIManager().getPositioningMode() == VRGUIPositioningMode.MANUAL ) { + // only update geometric state here if GUI is in manual mode, or not in VR + // it will get updated automatically in the view manager update otherwise + // TODO isn't this done by SimpleApplication? + for (Spatial spatial : application.getGuiViewPort().getScenes()) { + //spatial.updateLogicalState(tpf); + spatial.updateGeometricState(); + } + } + + // use the analog control on the first tracked controller to push around the mouse + environment.getVRMouseManager().updateAnalogAsMouse(0, null, null, null, tpf); + } + + @Override + public void render(RenderManager rm) { + super.render(rm); + + // update compositor + if( environment.getVRViewManager() != null ) { + environment.getVRViewManager().render(); + } + } + + @Override + public void postRender() { + super.postRender(); + + // update compositor + if( environment.getVRViewManager() != null ) { + environment.getVRViewManager().postRender(); + } + } + + @Override + public void initialize(AppStateManager stateManager, Application app) { + super.initialize(stateManager, app); + + this.application = app; + this.stateManager = stateManager; + + // disable annoying warnings about GUI stuff being updated, which is normal behavior + // for late GUI placement for VR purposes + Logger.getLogger("com.jme3").setLevel(Level.SEVERE); + + app.getCamera().setFrustumFar(fFar); + app.getCamera().setFrustumNear(fNear); + + if( environment.isInVR() ) { + logger.config("VR mode enabled."); + + if( environment.getVRHardware() != null ) { + environment.getVRHardware().initVRCompositor(environment.compositorAllowed()); + } else { + logger.warning("No VR system found."); + } + + environment.getVRViewManager().setResolutionMultiplier(resMult); + //inputManager.addMapping(RESET_HMD, new KeyTrigger(KeyInput.KEY_F9)); + //setLostFocusBehavior(LostFocusBehavior.Disabled); + } else { + logger.config("VR mode disabled."); + //viewPort.attachScene(rootNode); + //guiViewPort.attachScene(guiNode); + } + + if( environment.getVRViewManager() != null ) { + environment.getVRViewManager().initialize(); + } + } + + @Override + public void stateAttached(AppStateManager stateManager) { + super.stateAttached(stateManager); //To change body of generated methods, choose Tools | Templates. + + if (settings == null) { + settings = new AppSettings(true); + logger.config("Using default settings."); + } else { + logger.config("Using given settings."); + } + + // Attach VR environment to the application + if (!environment.isInitialized()){ + environment.initialize(); + } + + if (environment.isInitialized()){ + environment.atttach(this, stateManager.getApplication()); + } else { + logger.severe("Cannot attach VR environment to the VR app state as its not initialized."); + } + + GraphicsDevice defDev = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); + + if( environment.isInVR() && !environment.compositorAllowed() ) { + // "easy extended" mode + // setup experimental JFrame on external device + // first, find the VR device + GraphicsDevice VRdev = null; + GraphicsDevice[] devs = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices(); + // pick the display that isn't the default one + for(GraphicsDevice gd : devs) { + if( gd != defDev ) { + VRdev = gd; + break; + } + } + + // did we get the VR device? + if( VRdev != null ) { + // set properties for VR acceleration + try { + java.awt.DisplayMode useDM = null; + int max = 0; + for(java.awt.DisplayMode dm : VRdev.getDisplayModes()) { + int check = dm.getHeight() + dm.getWidth() + dm.getRefreshRate() + dm.getBitDepth(); + if( check > max ) { + max = check; + useDM = dm; + } + } + + // create a window for the VR device + settings.setWidth(useDM.getWidth()); + settings.setHeight(useDM.getHeight()); + settings.setBitsPerPixel(useDM.getBitDepth()); + settings.setFrequency(useDM.getRefreshRate()); + settings.setSwapBuffers(true); + settings.setVSync(true); // allow vsync on this display + stateManager.getApplication().setSettings(settings); + logger.config("Updated underlying application settings."); + + //VRdev.setFullScreenWindow(VRwindow); + // make sure we are in the right display mode + if( VRdev.getDisplayMode().equals(useDM) == false ) { + VRdev.setDisplayMode(useDM); + } + + return; + } catch(Exception e) { + logger.log(Level.SEVERE, e.getMessage(), e); + } + } else { + logger.config("Cannot access to external screen."); + } + } else { + if (!environment.isInVR()){ + logger.config("Cannot switch to VR mode (VR disabled by user)."); + } else if (!environment.compositorAllowed()){ + logger.warning("Cannot switch to VR mode (VR not supported)."); + } + } + + if( !environment.isInVR() ) { + //FIXME: Handling GLFW workaround on MacOS + boolean macOs = false; + if (macOs) { + // GLFW workaround on macs + settings.setFrequency(defDev.getDisplayMode().getRefreshRate()); + settings.setDepthBits(24); + settings.setVSync(true); + // try and read resolution from file in local dir + File resfile = new File("resolution.txt"); + if( resfile.exists() ) { + try { + BufferedReader br = new BufferedReader(new FileReader(resfile)); + settings.setWidth(Integer.parseInt(br.readLine())); + settings.setHeight(Integer.parseInt(br.readLine())); + try { + settings.setFullscreen(br.readLine().toLowerCase(Locale.ENGLISH).contains("full")); + } catch(Exception e) { + settings.setFullscreen(false); + } + br.close(); + } catch(Exception e) { + settings.setWidth(1280); + settings.setHeight(720); + } + } else { + settings.setWidth(1280); + settings.setHeight(720); + settings.setFullscreen(false); + } + settings.setResizable(false); + } + settings.setSwapBuffers(true); + } else { + // use basic mirroring window, skip settings window + settings.setSamples(1); + settings.setWidth(xWin); + settings.setHeight(yWin); + settings.setBitsPerPixel(32); + settings.setFrameRate(0); + settings.setFrequency(environment.getVRHardware().getDisplayFrequency()); + settings.setFullscreen(false); + settings.setVSync(false); // stop vsyncing on primary monitor! + settings.setSwapBuffers(environment.isSwapBuffers()); + } + + // Updating application settings + stateManager.getApplication().setSettings(settings); + logger.config("Updated underlying application settings."); + } + + @Override + public void cleanup() { + if( environment.getVRHardware() != null ) { + environment.getVRHardware().destroy(); + } + + this.application = null; + this.stateManager = null; + } + + @Override + public void stateDetached(AppStateManager stateManager) { + super.stateDetached(stateManager); + } + + /** + * Process the attached settings and apply changes to this app state. + * @param settings the app settings to process. + */ + protected void processSettings(AppSettings settings){ + if (settings != null){ + + if (settings.get(VRConstants.SETTING_DISABLE_VR) != null){ + DISABLE_VR = settings.getBoolean(VRConstants.SETTING_DISABLE_VR); + } + } + } +} \ No newline at end of file diff --git a/jme3-xr/src/main/java/com/jme3/app/VRApplication.java b/jme3-xr/src/main/java/com/jme3/app/VRApplication.java new file mode 100644 index 0000000000..02ab733230 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/app/VRApplication.java @@ -0,0 +1,1504 @@ +package com.jme3.app; + +import com.jme3.app.AppTask; +import com.jme3.app.Application; +import com.jme3.app.LegacyApplication; +import com.jme3.app.LostFocusBehavior; +import com.jme3.app.ResetStatsState; +import com.jme3.app.SimpleApplication; +import com.jme3.app.state.AppState; +import com.jme3.app.state.AppStateManager; +import com.jme3.asset.AssetManager; +import com.jme3.audio.AudioContext; +import com.jme3.audio.AudioRenderer; +import com.jme3.audio.Listener; +import com.jme3.input.InputManager; +import com.jme3.input.JoyInput; +import com.jme3.input.KeyInput; +import com.jme3.input.MouseInput; +import com.jme3.input.TouchInput; +import com.jme3.input.controls.KeyTrigger; +import com.jme3.input.vr.VRAPI; +import com.jme3.input.vr.VRInputAPI; +import com.jme3.input.vr.openvr.OpenVR; +import com.jme3.input.vr.openvr.OpenVRMouseManager; +import com.jme3.input.vr.openvr.OpenVRViewManager; +import com.jme3.input.vr.osvr.OSVR; +import com.jme3.math.ColorRGBA; +import com.jme3.math.Quaternion; +import com.jme3.math.Vector3f; +import com.jme3.post.PreNormalCaching; +import com.jme3.profile.AppProfiler; +import com.jme3.renderer.Camera; +import com.jme3.renderer.RenderManager; +import com.jme3.renderer.Renderer; +import com.jme3.renderer.ViewPort; +import com.jme3.renderer.queue.RenderQueue.Bucket; +import com.jme3.scene.Node; +import com.jme3.scene.Spatial; +import com.jme3.scene.Spatial.CullHint; +import com.jme3.system.AppSettings; +import com.jme3.system.JmeContext; +import com.jme3.system.JmeContext.Type; +import com.jme3.system.jopenvr.JOpenVRLibrary; +import com.jme3.system.JmeSystem; +import com.jme3.system.NanoTimer; +import com.jme3.system.SystemListener; +import com.jme3.system.Timer; +import com.jme3.system.lwjgl.LwjglDisplayVR; +import com.jme3.system.lwjgl.LwjglOffscreenBufferVR; +import com.jme3.util.VRGUIPositioningMode; +import com.jme3.util.VRGuiManager; + +import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Locale; +import java.util.concurrent.Callable; +import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.concurrent.Future; +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.lwjgl.system.Platform; + +/** + * A JMonkey application dedicated to Virtual Reality. An application that use VR devices (HTC vive, ...) has to extend this one.
+ *

+ * This class is no more functional and is deprecated. Please use {@link VRAppState VRAppState} instead. + * @author reden - phr00t - https://github.com/phr00t + * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr + * @deprecated use {@link VRAppState VRAppState} instead. + */ +public abstract class VRApplication implements Application, SystemListener { + private static final Logger logger = Logger.getLogger(LegacyApplication.class.getName()); + + /** + * The default FOV. + */ + public float DEFAULT_FOV = 108f; + + /** + * The default aspect ratio. + */ + public float DEFAULT_ASPECT = 1f; + + /** + * Is the application is based on OSVR (default is false). + */ + public boolean CONSTRUCT_WITH_OSVR = false; + + /** + * Is the application has not to start within VR mode (default is false). + */ + public boolean DISABLE_VR = false; + + /** + * VR application configuration parameters. + * @author reden - phr00t - https://github.com/phr00t + * @author Julien Seinturier - (c) 2016 - JOrigin project - http:/www.jorigin.org + * + */ + public static enum PreconfigParameter { + /** + * Is the SteamVR compositor is used (kinda needed at the moment) + */ + USE_VR_COMPOSITOR, + + /** + * Render two eyes, regardless of VR API detection. + */ + FORCE_VR_MODE, + + /** + * Invert the eyes. + */ + FLIP_EYES, + + /** + * Show GUI even if it is behind objects. + */ + SET_GUI_OVERDRAW, + + /** + * + */ + SET_GUI_CURVED_SURFACE, + + /** + * Display a mirror rendering on the screen. Runs faster when set to false. + */ + ENABLE_MIRROR_WINDOW, + + /** + * + */ + PREFER_OPENGL3, + + /** + * Disable VR rendering, regardless VR API and devices are presents. + */ + DISABLE_VR, + + /** + * + */ + SEATED_EXPERIENCE, + + /** + * Remove GUI node from the application. + */ + NO_GUI, + + /** + * Faster VR rendering, requires some vertex shader changes (see Common/MatDefs/VR/Unshaded.j3md) + */ + INSTANCE_VR_RENDERING, + + /** + * + */ + FORCE_DISABLE_MSAA + } + + private VRAPI vrHardware = null; + private VRGuiManager guiManager = null; + private OpenVRMouseManager mouseManager = null; + private OpenVRViewManager viewManager = null; + + private String OS; + + private Camera dummyCam; + private Spatial observer; + private boolean VRSupportedOS; + private boolean forceVR; + private boolean disableSwapBuffers = true; + private boolean tryOpenGL3 = true; + private boolean seated; + private boolean nogui; + private boolean instanceVR; + private boolean forceDisableMSAA; + + // things taken from LegacyApplication + private AppStateManager stateManager; + private Camera cam; + private AppSettings settings; + private JmeContext context; + private float speed = 1f; + private AudioRenderer audioRenderer; + private LostFocusBehavior lostFocusBehavior = LostFocusBehavior.ThrottleOnLostFocus; + private final ConcurrentLinkedQueue> taskQueue = new ConcurrentLinkedQueue<>(); + private Timer timer = new NanoTimer(); + private boolean paused = false, inputEnabled = true; + private InputManager inputManager; + private RenderManager renderManager; + private ViewPort viewPort; + private ViewPort guiViewPort; + private AssetManager assetManager; + private Renderer renderer; + private Listener listener; + private MouseInput mouseInput; + private KeyInput keyInput; + private JoyInput joyInput; + private TouchInput touchInput; + + protected Node guiNode, rootNode; + + private float fFar = 1000f, fNear = 1f; + private int xWin = 1280, yWin = 720; + + private float resMult = 1f; + + private boolean useCompositor = true, compositorOS; + private final String RESET_HMD = "ResetHMD"; + + /** + * Create a new VR application and attach the given {@link AppState app states}.
+ * The application scene is made of a {@link #getRootNode() root node} that holds the scene spatials + * and a {@link #getGuiNode() GUI node} that is the root of the Graphical user interface. + * @param initialStates the {@link AppState app states} to attach to the application. + */ + public VRApplication(AppState... initialStates) { + this(); + + if (initialStates != null) { + for (AppState a : initialStates) { + if (a != null) { + stateManager.attach(a); + } + } + } + } + + /** + * Create a new VR application.
+ * The application scene is made of a {@link #getRootNode() root node} that holds the scene spatials + * and a {@link #getGuiNode() GUI node} that is the root of the Graphical user interface. + */ + public VRApplication() { + super(); + + rootNode = new Node("root"); + guiNode = new Node("guiNode"); + + guiNode.setQueueBucket(Bucket.Gui); + guiNode.setCullHint(CullHint.Never); + dummyCam = new Camera(0, 0); + + initStateManager(); + + // Create the GUI manager. + guiManager = new VRGuiManager(null); + + // Create a new view manager. + viewManager = new OpenVRViewManager(null); + + // Create a new mouse manager. + mouseManager = new OpenVRMouseManager(null); + + // we are going to use OpenVR now, not the Oculus Rift + // OpenVR does support the Rift + OS = System.getProperty("os.name", "generic").toLowerCase(Locale.ENGLISH); + VRSupportedOS = !OS.contains("nux") && System.getProperty("sun.arch.data.model").equalsIgnoreCase("64"); //for the moment, linux/unix causes crashes, 64-bit only + compositorOS = OS.contains("indows"); + + if( !VRSupportedOS ) { + logger.warning("Non-supported OS: " + OS + ", architecture: " + System.getProperty("sun.arch.data.model")); + } else if( DISABLE_VR ) { + logger.warning("VR disabled via code."); + } else if( VRSupportedOS && DISABLE_VR == false ) { + if( CONSTRUCT_WITH_OSVR ) { + //FIXME: WARNING !! + vrHardware = new OSVR(null); + logger.config("Creating OSVR wrapper [SUCCESS]"); + } else { + //FIXME: WARNING !! + vrHardware = new OpenVR(null); + logger.config("Creating OpenVR wrapper [SUCCESS]"); + } + if( vrHardware.initialize() ) { + setPauseOnLostFocus(false); + } + } + } + + /** + * Get the VR underlying hardware. + * @return the VR underlying hardware. + */ + public VRAPI getVRHardware() { + return vrHardware; + } + + /** + * Get the VR dedicated input. + * @return the VR dedicated input. + */ + public VRInputAPI getVRinput() { + if( vrHardware == null ) return null; + return vrHardware.getVRinput(); + } + + /** + * Get the VR view manager. + * @return the VR view manager. + */ + public OpenVRViewManager getVRViewManager() { + return viewManager; + } + + /** + * Get the GUI manager attached to this application. + * @return the GUI manager attached to this application. + */ + public VRGuiManager getVRGUIManager(){ + return guiManager; + } + + /** + * Get the VR mouse manager attached to this application. + * @return the VR mouse manager attached to this application. + */ + public OpenVRMouseManager getVRMouseManager(){ + return mouseManager; + } + + /** + * Set the frustum values for the application. + * @param near the frustum near value. + * @param far the frustum far value. + */ + public void setFrustrumNearFar(float near, float far) { + fNear = near; + fFar = far; + } + + /** + * Set the mirror window size in pixel. + * @param width the width of the mirror window in pixel. + * @param height the height of the mirror window in pixel. + */ + public void setMirrorWindowSize(int width, int height) { + xWin = width; + yWin = height; + } + + /** + * Set the resolution multiplier. + * @param val the resolution multiplier. + */ + public void setResolutionMultiplier(float val) { + resMult = val; + if( viewManager != null ) viewManager.setResolutionMultiplier(resMult); + } + + + /** + * Is the SteamVR compositor is active. + * @return true if the SteamVR compositor is active and false otherwise. + */ + public boolean compositorAllowed() { + return useCompositor && compositorOS; + } + + /** + * Get if the system currently support VR. + * @return true if the system currently support VR and false otherwise. + */ + public boolean isOSVRSupported() { + return VRSupportedOS; + } + + /** + * Simple update of the application, this method should contain {@link #getRootNode() root node} updates. + * This method is called by the {@link #update() update()} method and should not be called manually. + * @param tpf the application time. + */ + public void simpleUpdate(float tpf) { } + + /** + * Rendering callback of the application. This method is called by the {@link #update() update()} method and should not be called manually. + * @param renderManager the {@link RenderManager render manager}. + */ + public void simpleRender(RenderManager renderManager) { + PreNormalCaching.resetCache(isInVR()); + } + + + /** + we do NOT want to get and modify the distortion scene camera, so + return the left viewport camera instead if we are in VR mode + */ + @Override + public Camera getCamera() { + if( isInVR() && viewManager != null && viewManager.getLeftCamera() != null ) { + return dummyCam; + } + return cam; + } + + /** + * Get the application internal camera. + * @return the application internal camera. + * @see #getCamera() + */ + public Camera getBaseCamera() { + return cam; + } + + @Override + public JmeContext getContext(){ + return context; + } + + @Override + public AssetManager getAssetManager(){ + return assetManager; + } + + @Override + public InputManager getInputManager(){ + return inputManager; + } + + @Override + public AppStateManager getStateManager() { + return stateManager; + } + + @Override + public RenderManager getRenderManager() { + return renderManager; + } + + @Override + public Renderer getRenderer(){ + return renderer; + } + + @Override + public AudioRenderer getAudioRenderer() { + return audioRenderer; + } + + @Override + public Listener getListener() { + return listener; + } + + @Override + public Timer getTimer(){ + return timer; + } + + /** + * Handle the error given in parameters by creating a log entry and a dialog window. Internal use only. + */ + @Override + public void handleError(String errMsg, Throwable t){ + // Print error to log. + logger.log(Level.SEVERE, errMsg, t); + // Display error message on screen if not in headless mode + if (context.getType() != JmeContext.Type.Headless) { + if (t != null) { + JmeSystem.handleErrorMessage(errMsg + "\n" + t.getClass().getSimpleName() + + (t.getMessage() != null ? ": " + t.getMessage() : "")); + } else { + JmeSystem.handleErrorMessage(errMsg); + } + } + + stop(); // stop the application + } + + + /** + * Force the focus gain for the application. Internal use only. + */ + @Override + public void gainFocus(){ + if (lostFocusBehavior != LostFocusBehavior.Disabled) { + if (lostFocusBehavior == LostFocusBehavior.PauseOnLostFocus) { + paused = false; + } + context.setAutoFlushFrames(true); + if (inputManager != null) { + inputManager.reset(); + } + } + } + + /** + * Force the focus lost for the application. Internal use only. + */ + @Override + public void loseFocus(){ + if (lostFocusBehavior != LostFocusBehavior.Disabled){ + if (lostFocusBehavior == LostFocusBehavior.PauseOnLostFocus) { + paused = true; + } + context.setAutoFlushFrames(false); + } + } + + /** + * Reshape the display window. Internal use only. + */ + @Override + public void reshape(int w, int h){ + if (renderManager != null) { + renderManager.notifyReshape(w, h); + } + } + + /** + * Request the application to close. Internal use only. + */ + @Override + public void requestClose(boolean esc){ + context.destroy(false); + } + + /** + * Set the {@link AppSettings display settings} to define the display created. + *

+ * Examples of display parameters include display frame {@link AppSettings#getWidth() width} and {@link AppSettings#getHeight() height}, + * pixel {@link AppSettings#getBitsPerPixel() color bit depth}, {@link AppSettings#getDepthBits() z-buffer bits}, {@link AppSettings#getSamples() anti-aliasing samples}, {@link AppSettings#getFrequency() update frequency}, ... + *

If this method is called while the application is already running, then + * {@link #restart() } must be called to apply the settings to the display. + * + * @param settings The settings to set. + */ + @Override + public void setSettings(AppSettings settings){ + this.settings = settings; + if (context != null && settings.useInput() != inputEnabled){ + // may need to create or destroy input based + // on settings change + inputEnabled = !inputEnabled; + if (inputEnabled){ + initInput(); + }else{ + destroyInput(); + } + }else{ + inputEnabled = settings.useInput(); + } + } + + /** + * Sets the {@link Timer} implementation that will be used for calculating + * frame times.

+ * By default, Application will use the Timer as returned by the current {@link JmeContext} implementation. + * @param timer the timer to use. + */ + @Override + public void setTimer(Timer timer){ + this.timer = timer; + + if (timer != null) { + timer.reset(); + } + + if (renderManager != null) { + renderManager.setTimer(timer); + } + } + + /** + * Determine the application's behavior when unfocused. + * @return The lost focus behavior of the application. + */ + @Override + public LostFocusBehavior getLostFocusBehavior() { + return lostFocusBehavior; + } + + /** + * Change the application's behavior when unfocused. By default, the application will + * {@link LostFocusBehavior#ThrottleOnLostFocus throttle the update loop} + * so as to not take 100% CPU usage when it is not in focus, e.g. + * alt-tabbed, minimized, or obstructed by another window. + * + * @param lostFocusBehavior The new {@link LostFocusBehavior lost focus behavior} to use. + */ + @Override + public void setLostFocusBehavior(LostFocusBehavior lostFocusBehavior) { + this.lostFocusBehavior = lostFocusBehavior; + } + + /** + * Get if the application has to pause then it lost the focus. + * @return true if pause on lost focus is enabled, false otherwise. + * @see #getLostFocusBehavior() + */ + @Override + public boolean isPauseOnLostFocus() { + return getLostFocusBehavior() == LostFocusBehavior.PauseOnLostFocus; + } + + /** + * Enable or disable pause on lost focus. + *

+ * By default, pause on lost focus is enabled. + * If enabled, the application will stop updating + * when it loses focus or becomes inactive (e.g. alt-tab). + * For online or real-time applications, this might not be preferable, + * so this feature should be set to disabled. For other applications, + * it is best to keep it on so that CPU usage is not used when + * not necessary. + * + * @param pauseOnLostFocus true to enable pause on lost focus, false + * otherwise. + * + * @see #setLostFocusBehavior(com.jme3.app.LostFocusBehavior) + */ + @Override + public void setPauseOnLostFocus(boolean pauseOnLostFocus) { + if (pauseOnLostFocus) { + setLostFocusBehavior(LostFocusBehavior.PauseOnLostFocus); + } else { + setLostFocusBehavior(LostFocusBehavior.Disabled); + } + } + + @Override + public void start() { + logger.config("Starting application..."); + + // set some default settings in-case + // settings dialog is not shown + boolean loadSettings = false; + if (settings == null) { + setSettings(new AppSettings(true)); + loadSettings = true; + } + + GraphicsDevice defDev = null; + try { + GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); + defDev = ge.getDefaultScreenDevice(); + } catch (Throwable e1) { + logger.log(Level.SEVERE, "Cannot access default screen device: "+e1.getMessage(), e1); + } + + if( isInVR() && !compositorAllowed() ) { + logger.warning("VR Composition is not allowed."); + // "easy extended" mode + // TO-DO: JFrame was removed in LWJGL 3, need to use new GLFW library to pick "monitor" display of VR device + // first, find the VR device + GraphicsDevice VRdev = null; + GraphicsDevice[] devs = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices(); + // pick the display that isn't the default one + for(GraphicsDevice gd : devs) { + if( gd != defDev ) { + VRdev = gd; + break; + } + } + // did we get the VR device? + if( VRdev != null ) { + // set properties for VR acceleration + try { + java.awt.DisplayMode useDM = null; + int max = 0; + for(java.awt.DisplayMode dm : VRdev.getDisplayModes()) { + int check = dm.getHeight() + dm.getWidth() + dm.getRefreshRate() + dm.getBitDepth(); + if( check > max ) { + max = check; + useDM = dm; + } + } + // create a window for the VR device + settings.setWidth(useDM.getWidth()); + settings.setHeight(useDM.getHeight()); + settings.setBitsPerPixel(useDM.getBitDepth()); + settings.setFrequency(useDM.getRefreshRate()); + settings.setSwapBuffers(true); + settings.setVSync(true); // allow vsync on this display + setSettings(settings); + //VRdev.setFullScreenWindow(VRwindow); + // make sure we are in the right display mode + if( VRdev.getDisplayMode().equals(useDM) == false ) { + VRdev.setDisplayMode(useDM); + } + // make a blank cursor to hide it + //BufferedImage cursorImg = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB); + //Cursor blankCursor = Toolkit.getDefaultToolkit().createCustomCursor(cursorImg, new Point(0, 0), "blank cursor"); + //VRwindow.setCursor(blankCursor); + //jmeCanvas.getCanvas().setCursor(blankCursor); + //VRwindow.pack(); + //VRwindow.setVisible(true); + //startCanvas(); + logger.config("Starting application [SUCCESS]"); + return; + } catch(Exception e) { + logger.log(Level.SEVERE, "Error during application start: "+e.getMessage(), e); + } + } + } + + if( !isInVR() ) { + logger.config("VR mode disabled."); + + // not in VR, show settings dialog + if (!JmeSystem.showSettingsDialog(settings, loadSettings)) { + logger.config("Starting application [SUCCESS]"); + return; + } + + + settings.setSwapBuffers(true); + } else { + logger.config("VR mode enabled."); + + // use basic mirroring window, skip settings window + settings.setWidth(xWin); + settings.setHeight(yWin); + settings.setBitsPerPixel(24); + settings.setFrameRate(0); // never sleep in main loop + settings.setFrequency(vrHardware.getDisplayFrequency()); + settings.setFullscreen(false); + settings.setVSync(false); // stop vsyncing on primary monitor! + settings.setSwapBuffers(!disableSwapBuffers || vrHardware instanceof OSVR); + settings.setTitle("Put Headset On Now: " + settings.getTitle()); + settings.setResizable(true); + } + + if( forceDisableMSAA ) { + logger.config("Disabling multisampling."); + // disable multisampling, which is more likely to break things than be useful + settings.setSamples(1); + } + + // set opengl mode + if( tryOpenGL3 ) { + logger.config("Using LWJGL OpenGL 3.2 renderer."); + settings.setRenderer(AppSettings.LWJGL_OPENGL32); + } else { + logger.config("Using LWJGL OpenGL 2 renderer."); + settings.setRenderer(AppSettings.LWJGL_OPENGL2); + } + + + setSettings(settings); + start(JmeContext.Type.Display, false); + + // disable annoying warnings about GUI stuff being updated, which is normal behavior + // for late GUI placement for VR purposes + Logger.getLogger("com.jme3").setLevel(Level.SEVERE); + } + + /** + * Starts the application in {@link com.jme3.system.JmeContext.Type#Display display} mode. + * @param waitFor if true, the method will wait until the application is started. + * @see #start(com.jme3.system.JmeContext.Type, boolean) + */ + @Override + public void start(boolean waitFor){ + start(JmeContext.Type.Display, waitFor); + } + + /** + * Starts the application. + * Creating a rendering context and executing the main loop in a separate thread. + * @param contextType the {@link com.jme3.system.JmeContext.Type type} of the context to create. + * @param waitFor if true, the method will wait until the application is started. + * @throws IllegalArgumentException if the context type is not supported. + */ + public void start(JmeContext.Type contextType, boolean waitFor){ + if (context != null && context.isCreated()){ + logger.warning("start() called when application already created!"); + return; + } + + if (settings == null){ + settings = new AppSettings(true); + } + + logger.log(Level.FINE, "Starting application: {0}", getClass().getName()); + + // Create VR dedicated context + if (contextType == Type.Display){ + context = new LwjglDisplayVR(); + context.setSettings(settings); + } else if (contextType == Type.OffscreenSurface){ + context = new LwjglOffscreenBufferVR(); + context.setSettings(settings); + } else { + logger.severe("Unsupported context type \""+contextType+"\". Supported are \"Display\" and \"OffscreenSurface\""); + throw new IllegalArgumentException("Unsupported context type \""+contextType+"\". Supported are \"Display\" and \"OffscreenSurface\""); + } + + context.setSystemListener(this); + context.create(waitFor); + } + + /** + * Move filters from the main scene into the eye's. + * This removes filters from the main scene. + */ + public void moveScreenProcessingToVR() { + if( isInVR() ) { + viewManager.moveScreenProcessingToEyes(); + } + } + + /** + * Set VR application {@link PreconfigParameter specific parameter}. + * If making changes to default values, this must be called before the VRApplication starts + * @param parm the parameter to set. + * @param value the value of the parameter. + */ + public void preconfigureVRApp(PreconfigParameter parm, boolean value) { + switch( parm ) { + case SET_GUI_OVERDRAW: + guiManager.setGuiOverdraw(value); + break; + case SET_GUI_CURVED_SURFACE: + guiManager.setCurvedSurface(value); + break; + case FORCE_VR_MODE: + forceVR = value; + break; + //case USE_CUSTOM_DISTORTION: //deprecated, always using a render manager + // VRViewManager._setCustomDistortion(value); + // break; + case USE_VR_COMPOSITOR: + useCompositor = value; + if( value == false ) disableSwapBuffers = false; + break; + case FLIP_EYES: + if( vrHardware == null ) return; + vrHardware.setFlipEyes(value); + break; + case INSTANCE_VR_RENDERING: + instanceVR = value; + break; + case ENABLE_MIRROR_WINDOW: + if( useCompositor == false ) { + disableSwapBuffers = false; + } else disableSwapBuffers = !value; + break; + case PREFER_OPENGL3: + tryOpenGL3 = value; + break; + case DISABLE_VR: + DISABLE_VR = value; + break; + case NO_GUI: + nogui = value; + break; + case SEATED_EXPERIENCE: + seated = value; + break; + case FORCE_DISABLE_MSAA: + forceDisableMSAA = value; + break; + } + } + + /** + * Can be used to change seated experience during runtime. + * @param isSeated true if designed for sitting, false for standing/roomscale + * @see #isSeatedExperience() + */ + public void setSeatedExperience(boolean isSeated) { + seated = isSeated; + if( vrHardware instanceof OpenVR ) { + if( vrHardware.getCompositor() == null ) return; + if( seated ) { + ((OpenVR) vrHardware).getCompositor().SetTrackingSpace.apply(JOpenVRLibrary.ETrackingUniverseOrigin.ETrackingUniverseOrigin_TrackingUniverseSeated); + } else { + ((OpenVR) vrHardware).getCompositor().SetTrackingSpace.apply(JOpenVRLibrary.ETrackingUniverseOrigin.ETrackingUniverseOrigin_TrackingUniverseStanding); + } + } + } + + /** + * Check if the application is configured as a seated experience. + * @return true if the application is configured as a seated experience and false otherwise. + * @see #setSeatedExperience(boolean) + */ + public boolean isSeatedExperience() { + return seated; + } + + /** + * Reset headset pose if seating experience. + */ + public void resetSeatedPose(){ + if( VRSupportedOS == false || isSeatedExperience() == false ) return; + vrHardware.reset(); + } + + /** + * Check if the rendering is instanced (see Geometry instancing). + * @return true if the rendering is instanced and false otherwise. + */ + public boolean isInstanceVRRendering() { + return instanceVR && isInVR(); + } + + /** + * Check if the VR mode is enabled. + * @return true if the VR mode is enabled and false otherwise. + */ + public boolean isInVR() { + return DISABLE_VR == false && (forceVR || VRSupportedOS && vrHardware != null && vrHardware.isInitialized()); + } + + + /** + * Get the GUI node from the application. + * @return the GUI node from the application. + * @see #setGuiNode(Node) + */ + public Node getGuiNode(){ + return guiNode; + } + + /** + * Set the GUI node that is displayed within the GUI viewport. + * Calling this method involve clearing all the scenes previously attached to the gui viewport. + * @param node the GUI node to attach. + * @see #getGuiNode() + */ + public void setGuiNode(Node node){ + if (node != null){ + if (guiViewPort != null){ + enqueue(new Callable(){ + + @Override + public Object call() throws Exception { + guiViewPort.clearScenes(); + guiViewPort.attachScene(node); + guiNode = node; + return null; + } + + }); + + } else { + throw new IllegalArgumentException("GUI view port is not initialized."); + } + } + } + + /** + * Get the root node of the application. + * @return the root node of the application. + */ + public Node getRootNode() { + return rootNode; + } + + /** + * Check if the application has a GUI overlay attached. + * @return true if the application has a GUI overlay attached and false otherwise. + */ + public boolean hasTraditionalGUIOverlay() { + return !nogui; + } + + /** + * Get the scene observer. If no observer has been set, this method return the application {@link #getCamera() camera}. + * @return the scene observer. + * @see #setObserver(Spatial) + */ + public Object getObserver() { + if( observer == null ) { + return getCamera(); + } + return observer; + } + + /** + * Set the scene observer. The VR headset will be linked to it. If no observer is set, the VR headset is linked to the application {@link #getCamera() camera}. + * @param observer the scene observer. + */ + public void setObserver(Spatial observer) { + this.observer = observer; + } + + /* + where is the headset pointing, after all rotations are combined? + depends on observer rotation, if any + */ + private static Quaternion tempq = new Quaternion(); + + /** + * Get the observer final rotation within the scene. + * @return the observer final rotation within the scene. + * @see #getFinalObserverPosition() + */ + public Quaternion getFinalObserverRotation() { + if( viewManager == null ) { + if( observer == null ) { + return getCamera().getRotation(); + } else return observer.getWorldRotation(); + } + if( observer == null ) { + tempq.set(dummyCam.getRotation()); + } else { + tempq.set(observer.getWorldRotation()); + } + return tempq.multLocal(vrHardware.getOrientation()); + } + + /** + * Get the observer final position within the scene. + * @return the observer position. + * @see #getFinalObserverRotation() + */ + public Vector3f getFinalObserverPosition() { + if( viewManager == null ) { + if( observer == null ) { + return getCamera().getLocation(); + } else return observer.getWorldTranslation(); + } + Vector3f pos = vrHardware.getPosition(); + if( observer == null ) { + dummyCam.getRotation().mult(pos, pos); + return pos.addLocal(dummyCam.getLocation()); + } else { + observer.getWorldRotation().mult(pos, pos); + return pos.addLocal(observer.getWorldTranslation()); + } + } + + /** + * Set the VR headset height from the ground. + * @param amount the VR headset height from the ground. + * @see #getVRHeightAdjustment() + */ + public void setVRHeightAdjustment(float amount) { + if( viewManager != null ) viewManager.setHeightAdjustment(amount); + } + + /** + * Get the VR headset height from the ground. + * @return the VR headset height from the ground. + * @see #setVRHeightAdjustment(float) + */ + public float getVRHeightAdjustment() { + if( viewManager != null ) return viewManager.getHeightAdjustment(); + return 0f; + } + + /** + * Get the VR headset left viewport. + * @return the VR headset left viewport. + * @see #getRightViewPort() + */ + public ViewPort getLeftViewPort() { + if( viewManager == null ) return getViewPort(); + return viewManager.getLeftViewPort(); + } + + /** + * Get the VR headset right viewport. + * @return the VR headset right viewport. + * @see #getLeftViewPort() + */ + public ViewPort getRightViewPort() { + if( viewManager == null ) return getViewPort(); + return viewManager.getRightViewPort(); + } + + /** + * Set the background color for both left and right view ports. + * @param clr the background color. + */ + public void setBackgroundColors(ColorRGBA clr) { + if( viewManager == null ) { + getViewPort().setBackgroundColor(clr); + } else if( viewManager.getLeftViewPort() != null ) { + viewManager.getLeftViewPort().setBackgroundColor(clr); + if( viewManager.getRightViewPort() != null ) viewManager.getRightViewPort().setBackgroundColor(clr); + } + } + + /** + * Runs tasks enqueued via {@link #enqueue(Callable)} + */ + protected void runQueuedTasks() { + AppTask task; + while( (task = taskQueue.poll()) != null ) { + if (!task.isCancelled()) { + task.invoke(); + } + } + } + + @Override + public void update() { + // Make sure the audio renderer is available to callables + AudioContext.setAudioRenderer(audioRenderer); + + runQueuedTasks(); + + if (speed != 0 && !paused) { + + timer.update(); + + if (inputEnabled){ + inputManager.update(timer.getTimePerFrame()); + } + + if (audioRenderer != null){ + audioRenderer.update(timer.getTimePerFrame()); + } + } + + if (speed == 0 || paused) { + try { + Thread.sleep(50); // throttle the CPU when paused + } catch (InterruptedException ex) { + Logger.getLogger(SimpleApplication.class.getName()).log(Level.SEVERE, null, ex); + } + return; + } + + float tpf = timer.getTimePerFrame() * speed; + + // update states + stateManager.update(tpf); + + // simple update and root node + simpleUpdate(tpf); + + + // render states + stateManager.render(renderManager); + + // update VR pose & cameras + if( viewManager != null ) { + viewManager.update(tpf); + } else if( observer != null ) { + getCamera().setFrame(observer.getWorldTranslation(), observer.getWorldRotation()); + } + + //FIXME: check if this code is necessary. + // Updates scene and gui states. + rootNode.updateLogicalState(tpf); + guiNode.updateLogicalState(tpf); + + rootNode.updateGeometricState(); + + if( isInVR() == false || guiManager.getPositioningMode() == VRGUIPositioningMode.MANUAL ) { + // Update geometric state here only if GUI is in manual mode, or not in VR. + // Otherwise it will get updated automatically in the view-manager update. + guiNode.updateGeometricState(); + } + + renderManager.render(tpf, context.isRenderable()); + simpleRender(renderManager); + stateManager.postRender(); + + // update compositor? + if( viewManager != null ) { + viewManager.postRender(); + } + } + + private void initAssetManager(){ + URL assetCfgUrl = null; + + if (settings != null){ + String assetCfg = settings.getString("AssetConfigURL"); + if (assetCfg != null){ + try { + assetCfgUrl = new URL(assetCfg); + } catch (MalformedURLException ex) { + } + if (assetCfgUrl == null) { + assetCfgUrl = LegacyApplication.class.getClassLoader().getResource(assetCfg); + if (assetCfgUrl == null) { + logger.log(Level.SEVERE, "Unable to access AssetConfigURL in asset config:{0}", assetCfg); + return; + } + } + } + } + if (assetCfgUrl == null) { + assetCfgUrl = JmeSystem.getPlatformAssetConfigURL(); + } + if (assetManager == null){ + assetManager = JmeSystem.newAssetManager(assetCfgUrl); + logger.config("Created asset manager from "+assetCfgUrl); + } + } + + private void initDisplay(){ + // acquire important objects + // from the context + settings = context.getSettings(); + + // Only reset the timer if a user has not already provided one + if (timer == null) { + timer = context.getTimer(); + } + + renderer = context.getRenderer(); + } + + private void initAudio(){ + if (settings.getAudioRenderer() != null && context.getType() != JmeContext.Type.Headless){ + audioRenderer = JmeSystem.newAudioRenderer(settings); + audioRenderer.initialize(); + AudioContext.setAudioRenderer(audioRenderer); + + listener = new Listener(); + audioRenderer.setListener(listener); + } + } + + /** + * Creates the camera to use for rendering. Default values are perspective + * projection with 45° field of view, with near and far values 1 and 1000 + * units respectively. + */ + private void initCamera(){ + cam = new Camera(settings.getWidth(), settings.getHeight()); + + cam.setFrustumPerspective(45f, (float)cam.getWidth() / cam.getHeight(), 1f, 1000f); + cam.setLocation(new Vector3f(0f, 0f, 10f)); + cam.lookAt(new Vector3f(0f, 0f, 0f), Vector3f.UNIT_Y); + + renderManager = new RenderManager(renderer); + //Remy - 09/14/2010 set the timer in the renderManager + renderManager.setTimer(timer); + + viewPort = renderManager.createMainView("Default", cam); + viewPort.setClearFlags(true, true, true); + + // Create a new cam for the gui + Camera guiCam = new Camera(settings.getWidth(), settings.getHeight()); + guiViewPort = renderManager.createPostView("Gui Default", guiCam); + guiViewPort.setClearFlags(false, false, false); + } + + /** + * Initializes mouse and keyboard input. Also + * initializes joystick input if joysticks are enabled in the + * AppSettings. + */ + private void initInput(){ + mouseInput = context.getMouseInput(); + if (mouseInput != null) + mouseInput.initialize(); + + keyInput = context.getKeyInput(); + if (keyInput != null) + keyInput.initialize(); + + touchInput = context.getTouchInput(); + if (touchInput != null) + touchInput.initialize(); + + if (settings.useJoysticks()){ + joyInput = context.getJoyInput(); + if (joyInput != null) + joyInput.initialize(); + } + + inputManager = new InputManager(mouseInput, keyInput, joyInput, touchInput); + } + + private void initStateManager(){ + stateManager = new AppStateManager(this); + + // Always register a ResetStatsState to make sure + // that the stats are cleared every frame + stateManager.attach(new ResetStatsState()); + } + + /** + * Do not call manually. + * Callback from ContextListener. + *

+ * Initializes the Application, by creating a display and + * default camera. If display settings are not specified, a default + * 640x480 display is created. Default values are used for the camera; + * perspective projection with 45° field of view, with near + * and far values 1 and 1000 units respectively. + */ + private void initialize_internal(){ + if (assetManager == null){ + initAssetManager(); + } + + initDisplay(); + initCamera(); + + if (inputEnabled){ + initInput(); + } + initAudio(); + + // update timer so that the next delta is not too large +// timer.update(); + timer.reset(); + + // user code here + } + + @Override + public void initialize() { + logger.config("Initialize VR application..."); + + initialize_internal(); + cam.setFrustumFar(fFar); + cam.setFrustumNear(fNear); + dummyCam = cam.clone(); + if( isInVR() ) { + logger.config("VR mode enabled."); + + if( vrHardware != null ) { + vrHardware.initVRCompositor(compositorAllowed()); + } else { + logger.warning("No VR system found."); + } + + //FIXME: WARNING !! + viewManager = new OpenVRViewManager(null); + viewManager.setResolutionMultiplier(resMult); + inputManager.addMapping(RESET_HMD, new KeyTrigger(KeyInput.KEY_F9)); + setLostFocusBehavior(LostFocusBehavior.Disabled); + } else { + logger.config("VR mode disabled."); + viewPort.attachScene(rootNode); + guiViewPort.attachScene(guiNode); + } + + if( viewManager != null ) { + viewManager.initialize(); + } + + simpleInitApp(); + + // any filters created, move them now + if( viewManager != null ) { + viewManager.moveScreenProcessingToEyes(); + + // print out camera information + if( isInVR() ) { + logger.info("VR Initialization Information"); + if( viewManager.getLeftCamera() != null ){ + logger.info("camLeft: " + viewManager.getLeftCamera().toString()); + } + + if( viewManager.getRightCamera() != null ){ + logger.info("camRight: " + viewManager.getRightCamera().toString()); + } + } + } + } + + /** + * Initialize the application. This method has to be overridden by implementations. + */ + public abstract void simpleInitApp(); + + /** + * Destroy the application (release all resources). + */ + @Override + public void destroy() { + if( vrHardware != null ) { + vrHardware.destroy(); + vrHardware = null; + } + DISABLE_VR = true; + stateManager.cleanup(); + + destroyInput(); + if (audioRenderer != null) + audioRenderer.cleanup(); + + timer.reset(); + Runtime.getRuntime().exit(0); + } + + protected void destroyInput(){ + if (mouseInput != null) + mouseInput.destroy(); + + if (keyInput != null) + keyInput.destroy(); + + if (joyInput != null) + joyInput.destroy(); + + if (touchInput != null) + touchInput.destroy(); + + inputManager = null; + } + + @Override + public ViewPort getGuiViewPort() { + return guiViewPort; + } + + @Override + public ViewPort getViewPort() { + return viewPort; + } + + @Override + public Future enqueue(Callable callable) { + AppTask task = new AppTask<>(callable); + taskQueue.add(task); + return task; + } + + /** + * Enqueues a runnable object to execute in the jME3 + * rendering thread. + *

+ * Runnables are executed right at the beginning of the main loop. + * They are executed even if the application is currently paused + * or out of focus. + * + * @param runnable The runnable to run in the main jME3 thread + */ + @Override + public void enqueue(Runnable runnable){ + enqueue(new RunnableWrapper(runnable)); + } + + private class RunnableWrapper implements Callable{ + private final Runnable runnable; + + public RunnableWrapper(Runnable runnable){ + this.runnable = runnable; + } + + @Override + public Object call(){ + runnable.run(); + return null; + } + } + + /** + * Requests the context to close, shutting down the main loop + * and making necessary cleanup operations. + * + * Same as calling stop(false) + * + * @see #stop(boolean) + */ + @Override + public void stop(){ + stop(false); + } + + /** + * Requests the context to close, shutting down the main loop + * and making necessary cleanup operations. + * After the application has stopped, it cannot be used anymore. + */ + @Override + public void stop(boolean waitFor){ + logger.log(Level.FINE, "Closing application: {0}", getClass().getName()); + context.destroy(waitFor); + } + + /** + * Restarts the context, applying any changed settings. + *

+ * Changes to the {@link AppSettings} of this Application are not + * applied immediately; calling this method forces the context + * to restart, applying the new settings. + */ + @Override + public void restart(){ + context.setSettings(settings); + context.restart(); + } + + /** + * Sets an AppProfiler hook that will be called back for + * specific steps within a single update frame. Value defaults + * to null. + */ + @Override + public void setAppProfiler(AppProfiler prof) { + return; + } + + /** + * Returns the current AppProfiler hook, or null if none is set. + */ + @Override + public AppProfiler getAppProfiler() { + return null; + } +} diff --git a/jme3-xr/src/main/java/com/jme3/app/VRConstants.java b/jme3-xr/src/main/java/com/jme3/app/VRConstants.java new file mode 100644 index 0000000000..d6ed724766 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/app/VRConstants.java @@ -0,0 +1,174 @@ +package com.jme3.app; + +import java.util.HashMap; +import com.jme3.system.AppSettings; + +/** + * Some constants dedicated to the VR module. + * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr + * @since 3.1.0 + */ +public class VRConstants { + /** + * An AppSettings parameter that set if the VR compositor has to be used. + *

+ * Type: boolean
+ * Usage: {@link AppSettings appSettings}.{@link HashMap#put(Object, Object) put}(VRConstants.SETTING_USE_COMPOSITOR, value) + */ + public static final String SETTING_USE_COMPOSITOR = "VRUseCompositor"; + + /** + * An AppSettings parameter that set if the rendering has to use two eyes, + * regardless of VR API detection (turning this setting on without a VR system should lead to errors). + *

+ * Type: boolean
+ * Usage: {@link AppSettings appSettings}.{@link HashMap#put(Object, Object) put}(VRConstants.SETTING_VR_FORCE, value) + */ + public static final String SETTING_VR_FORCE = "VRForce"; + + /** + * An AppSettings parameter that set to invert the eyes of the HMD. + * Type: boolean
+ * Usage: {@link AppSettings appSettings}.{@link HashMap#put(Object, Object) put}(VRConstants.SETTING_FLIP_EYES, value) + */ + public static final String SETTING_FLIP_EYES = "VRFlipEyes"; + + /** + * An AppSettings parameter that set if the GUI has to be displayed even if it is behind objects. + * Type: boolean
+ * Usage: {@link AppSettings appSettings}.{@link HashMap#put(Object, Object) put}(VRConstants.SETTING_GUI_OVERDRAW, value) + * + */ + public static final String SETTING_GUI_OVERDRAW = "VRGUIOverdraw"; + + /** + * An AppSettings parameter that set if the GUI surface has to be curved. + * Type: boolean
+ * Usage: {@link AppSettings appSettings}.{@link HashMap#put(Object, Object) put}(VRConstants.SETTING_GUI_CURVED_SURFACE, value) + */ + public static final String SETTING_GUI_CURVED_SURFACE = "VRGUICurvedSurface"; + + /** + * An AppSettings parameter that set if a mirror rendering has to be displayed on the screen. + * Runs faster when set to false. + * Type: boolean
+ * Usage: {@link AppSettings appSettings}.{@link HashMap#put(Object, Object) put}(VRConstants.SETTING_ENABLE_MIRROR_WINDOW, value) + */ + public static final String SETTING_ENABLE_MIRROR_WINDOW = "VREnableMirrorWindow"; + + /** + * An AppSettings parameter that set if the VR rendering has to be disabled, + * regardless VR API and devices are presents. + * Type: boolean
+ * Usage: {@link AppSettings appSettings}.{@link HashMap#put(Object, Object) put}(VRConstants.SETTING_DISABLE_VR, value) + */ + public static final String SETTING_DISABLE_VR = "VRDisable"; + + + /** + * An AppSettings parameter that set if the VR user is seated. + * Type: boolean
+ * Usage: {@link AppSettings appSettings}.{@link HashMap#put(Object, Object) put}(VRConstants.SETTING_SEATED_EXPERIENCE, value) + */ + public static final String SETTING_SEATED_EXPERIENCE = "VRSeatedExperience"; + + /** + * An AppSettings parameter that set if the GUI has to be ignored. + * Type: boolean
+ * Usage: {@link AppSettings appSettings}.{@link HashMap#put(Object, Object) put}(VRConstants.SETTING_NO_GUI, value) + */ + public static final String SETTING_NO_GUI = "VRNoGUI"; + + /** + * An AppSettings parameter that set if instance rendering has to be used. + * This setting requires some vertex shader changes (see Common/MatDefs/VR/Unshaded.j3md). + * Type: boolean
+ * Usage: {@link AppSettings appSettings}.{@link HashMap#put(Object, Object) put}(VRConstants.SETTING_INSTANCE_RENDERING, value) + */ + public static final String SETTING_INSTANCE_RENDERING = "VRInstanceRendering"; + + /** + * An AppSettings parameter that set if Multi Sample Anti Aliasing has to be enabled. + * Type: boolean
+ * Usage: {@link AppSettings appSettings}.{@link HashMap#put(Object, Object) put}(VRConstants.SETTING_DISABLE_MSAA, value) + */ + public static final String SETTING_DISABLE_MSAA = "VRDisableMSAA"; + + /** + * An AppSettings parameter that set the default field of view (FOV) value. + * Type: float
+ * Usage: {@link AppSettings appSettings}.{@link HashMap#put(Object, Object) put}(VRConstants.SETTING_DEFAULT_FOV, value) + */ + public static final String SETTING_DEFAULT_FOV = "VRDefaultFOV"; + + /** + * An AppSettings parameter that set the default aspect ratio. + * Type: float
+ * Usage: {@link AppSettings appSettings}.{@link HashMap#put(Object, Object) put}(VRConstants.SETTING_DEFAULT_ASPECT_RATIO, value) + */ + public static final String SETTING_DEFAULT_ASPECT_RATIO = "VRDefaultAspectRatio"; + + /** + * An AppSettings parameter that specifies the underlying VR API. Possible values are:
+ *

    + *
  • {@link VRConstants#SETTING_VRAPI_OPENVR_VALUE SETTING_VRAPI_OPENVR_VALUE}: Use OpenVR binding. + *
  • {@link VRConstants#SETTING_VRAPI_OSVR_VALUE SETTING_VRAPI_OSVR_VALUE}: Use OSVR binding. + *
  • {@link VRConstants#SETTING_VRAPI_OPENVR_LWJGL_VALUE SETTING_VRAPI_OPENVR_LWJGL_VALUE}: Use OpenVR binding from LWJGL. + *
  • {@link VRConstants#SETTING_VRAPI_OCULUSVR_VALUE SETTING_VRAPI_OCULUSVR_VALUE}: Use Oculus Rift binding binding. + *
+ * Type: int
+ * Usage: {@link AppSettings appSettings}.{@link HashMap#put(Object, Object) put}(VRConstants.SETTING_VRAPI, value) + */ + public static final String SETTING_VRAPI = "VRAPI"; + + /** + * The identifier of the OpenVR system. + * + * Deprecated as only the lwjgl OpenVr version has been upgraded to modern action based inputs + * + * @see #SETTING_VRAPI_OSVR_VALUE + * @see #SETTING_VRAPI_OPENVR_LWJGL_VALUE + * @see #SETTING_VRAPI_OCULUSVR_VALUE + */ + @Deprecated + public static final int SETTING_VRAPI_OPENVR_VALUE = 1; + + /** + * The identifier of the OSVR system. + * + * Deprecated as an OpenVr system should be used instead for a non vender specific api + * + * @see #SETTING_VRAPI_OPENVR_VALUE + * @see #SETTING_VRAPI_OPENVR_LWJGL_VALUE + * @see #SETTING_VRAPI_OCULUSVR_VALUE + */ + @Deprecated + public static final int SETTING_VRAPI_OSVR_VALUE = 2; + + /** + * The identifier of the OpenVR from LWJGL system. + * + * @see #SETTING_VRAPI_OPENVR_VALUE + * @see #SETTING_VRAPI_OSVR_VALUE + * @see #SETTING_VRAPI_OCULUSVR_VALUE + */ + public static final int SETTING_VRAPI_OPENVR_LWJGL_VALUE = 3; + + /** + * The identifier of the Oculus Rift system. + * + * Deprecated as an OpenVr system should be used instead (and the rift itself is discontinued) + * + * @see #SETTING_VRAPI_OPENVR_VALUE + * @see #SETTING_VRAPI_OSVR_VALUE + * @see #SETTING_VRAPI_OPENVR_LWJGL_VALUE + */ + @Deprecated + public static final int SETTING_VRAPI_OCULUSVR_VALUE = 4; + + /** + * A private constructor to inhibit instantiation of this class. + */ + private VRConstants() { + } +} diff --git a/jme3-xr/src/main/java/com/jme3/app/VREnvironment.java b/jme3-xr/src/main/java/com/jme3/app/VREnvironment.java new file mode 100644 index 0000000000..6dd41d6cde --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/app/VREnvironment.java @@ -0,0 +1,543 @@ +package com.jme3.app; + +import java.util.Locale; +import java.util.logging.Level; +import java.util.logging.Logger; + +import com.jme3.app.state.AppState; +import com.jme3.input.vr.VRAPI; +import com.jme3.input.vr.VRBounds; +import com.jme3.input.vr.VRInputAPI; +import com.jme3.input.vr.VRMouseManager; +import com.jme3.input.vr.VRViewManager; +import com.jme3.input.vr.lwjgl_openvr.LWJGLOpenVR; +import com.jme3.input.vr.lwjgl_openvr.LWJGLOpenVRMouseManager; +import com.jme3.input.vr.lwjgl_openvr.LWJGLOpenVRViewManager; +import com.jme3.input.vr.oculus.OculusMouseManager; +import com.jme3.input.vr.oculus.OculusVR; +import com.jme3.input.vr.oculus.OculusViewManager; +import com.jme3.input.vr.openvr.OpenVR; +import com.jme3.input.vr.openvr.OpenVRMouseManager; +import com.jme3.input.vr.openvr.OpenVRViewManager; +import com.jme3.input.vr.osvr.OSVR; +import com.jme3.input.vr.osvr.OSVRViewManager; +import com.jme3.renderer.Camera; +import com.jme3.scene.Spatial; +import com.jme3.system.AppSettings; +import com.jme3.system.jopenvr.JOpenVRLibrary; +import com.jme3.util.VRGuiManager; + +/** + * + * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr + * + */ +public class VREnvironment { + private static final Logger logger = Logger.getLogger(VREnvironment.class.getName()); + + private VRAPI hardware = null; + private VRGuiManager guiManager = null; + private VRMouseManager mouseManager = null; + private VRViewManager viewManager = null; + + private VRBounds bounds = null; + + /** + * The underlying system VR API. By default, set to {@link VRConstants#SETTING_VRAPI_OPENVR_VALUE}. + */ + public int vrBinding = VRConstants.SETTING_VRAPI_OPENVR_VALUE; + + private boolean seated = false; + + private Spatial observer = null; + + private boolean forceVR = false; + + private boolean vrSupportedOS = false; + + private boolean nogui = false; + + private boolean compositorOS; + + private boolean useCompositor = true; + + private boolean instanceRendering = false; + + private boolean disableSwapBuffers = true; + + private float defaultFOV = 108f; + + private float defaultAspect = 1f; + + private AppSettings settings = null; + + private Application application = null; + + private Camera dummyCam = null; + + private AppState app = null; + + private boolean initialized = false; + + public VREnvironment(AppSettings settings){ + this.settings = settings; + + bounds = null; + + processSettings(); + } + + /** + * Get the VR underlying hardware. + * @return the VR underlying hardware. + */ + public VRAPI getVRHardware() { + return hardware; + } + + /** + * Set the VR bounds. + * @see #getVRBounds() + */ + public void setVRBounds(VRBounds bounds){ + this.bounds = bounds; + } + + /** + * Get the VR bounds. + * @return the VR bounds. + * @see #setVRBounds(VRBounds) + */ + public VRBounds getVRBounds(){ + return bounds; + } + + /** + * Get the VR dedicated input. + * @return the VR dedicated input. + */ + public VRInputAPI getVRinput() { + if( hardware == null ){ + return null; + } + + return hardware.getVRinput(); + } + + /** + * Get the VR view manager. + * @return the VR view manager. + */ + public VRViewManager getVRViewManager() { + return viewManager; + } + + /** + * Get the GUI manager attached to this environment. + * @return the GUI manager attached to this environment. + */ + public VRGuiManager getVRGUIManager(){ + return guiManager; + } + + /** + * Get the VR mouse manager attached to this environment. + * @return the VR mouse manager attached to this environment. + */ + public VRMouseManager getVRMouseManager(){ + return mouseManager; + } + + /** + * Can be used to change seated experience during runtime. + * @param isSeated true if designed for sitting, false for standing/roomscale + * @see #isSeatedExperience() + */ + public void setSeatedExperience(boolean isSeated) { + seated = isSeated; + if( hardware instanceof OpenVR ) { + if( hardware.getCompositor() == null ) { + return; + } + + if( seated ) { + ((OpenVR)hardware).getCompositor().SetTrackingSpace.apply(JOpenVRLibrary.ETrackingUniverseOrigin.ETrackingUniverseOrigin_TrackingUniverseSeated); + } else { + ((OpenVR)hardware).getCompositor().SetTrackingSpace.apply(JOpenVRLibrary.ETrackingUniverseOrigin.ETrackingUniverseOrigin_TrackingUniverseStanding); + } + } else if (hardware instanceof LWJGLOpenVR) { + if( hardware.isInitialized() ) { + ((LWJGLOpenVR)hardware).setTrackingSpace(seated); + } + } + } + + /** + * Check if the application is configured as a seated experience. + * @return true if the application is configured as a seated experience and false otherwise. + * @see #setSeatedExperience(boolean) + */ + public boolean isSeatedExperience() { + return seated; + } + + /** + * Set the VR headset height from the ground. + * @param amount the VR headset height from the ground. + * @see #getVRHeightAdjustment() + */ + public void setVRHeightAdjustment(float amount) { + if( viewManager != null ){ + viewManager.setHeightAdjustment(amount); + } + } + + /** + * Get the VR headset height from the ground. + * @return the VR headset height from the ground. + * @see #setVRHeightAdjustment(float) + */ + public float getVRHeightAdjustment() { + if( viewManager != null ){ + return viewManager.getHeightAdjustment(); + } + return 0f; + } + + /** + * Get the scene observer. If no observer has been set, this method return the application {@link #getCamera() camera}. + * @return the scene observer. + * @see #setObserver(Spatial) + */ + public Object getObserver() { + if( observer == null ) { + if (application != null){ + return application.getCamera(); + } else { + throw new IllegalStateException("VR environment is not attached to any application."); + } + } + return observer; + } + + /** + * Set the scene observer. The VR headset will be linked to it. If no observer is set, the VR headset is linked to the application {@link #getCamera() camera}. + * @param observer the scene observer. + */ + public void setObserver(Spatial observer) { + this.observer = observer; + } + + /** + * Get the default Field Of View (FOV) value. + * @return the default Field Of View (FOV) value. + * @see #setDefaultFOV(float) + */ + public float getDefaultFOV() { + return defaultFOV; + } + + /** + * Set the default Field Of View (FOV) value. + * @param defaultFOV the default Field Of View (FOV) value. + * @see #getDefaultFOV() + */ + public void setDefaultFOV(float defaultFOV) { + this.defaultFOV = defaultFOV; + } + + /** + * Get the default aspect ratio. + * @return the default aspect ratio. + * @see #setDefaultAspect(float) + */ + public float getDefaultAspect() { + return defaultAspect; + } + + /** + * Set the default aspect ratio. + * @param defaultAspect the default aspect ratio. + * @see #getDefaultAspect() + */ + public void setDefaultAspect(float defaultAspect) { + this.defaultAspect = defaultAspect; + } + + /** + * Get the {@link AppSettings settings} attached to this environment. + * @return the {@link AppSettings settings} attached to this environment. + * @see #setSettings(AppSettings) + */ + public AppSettings getSettings(){ + return settings; + } + + /** + * Set the {@link AppSettings settings} attached to this environment. + * @param settings the {@link AppSettings settings} attached to this environment. + * @see #getSettings() + */ + public void setSettings(AppSettings settings){ + this.settings = settings; + processSettings(); + } + + /** + * Get if the system currently support VR. + * @return true if the system currently support VR and false otherwise. + */ + public boolean isVRSupported() { + return vrSupportedOS; + } + + /** + * Check if the VR mode is enabled. + * @return true if the VR mode is enabled and false otherwise. + */ + public boolean isInVR() { + return (forceVR || vrSupportedOS && hardware != null && hardware.isInitialized() && isInitialized()); + } + + /** + * Check if the rendering is instanced (see Geometry instancing). + * @return true if the rendering is instanced and false otherwise. + */ + public boolean isInstanceRendering() { + return instanceRendering; + } + + public boolean isSwapBuffers(){ + return disableSwapBuffers; + } + + /** + * Check if the application has a GUI overlay attached. + * @return true if the application has a GUI overlay attached and false otherwise. + */ + public boolean hasTraditionalGUIOverlay() { + return !nogui; + } + + /** + * Check if the VR environment is initialized. A call to the {@link #initialize() initialize()} method should set this value to true + * @return true if the VR environment is initialized and false otherwise. + */ + public boolean isInitialized(){ + return initialized; + } + + /** + * Is the VR compositor is active. + * @return true if the VR compositor is active and false otherwise. + */ + public boolean compositorAllowed() { + return useCompositor && compositorOS; + } + + /** + * Reset headset pose if seating experience. + */ + public void resetSeatedPose(){ + if( vrSupportedOS == false || isSeatedExperience() == false ){ + return; + } + getVRHardware().reset(); + } + + public AppState getAppState(){ + return app; + } + + public Application getApplication(){ + return application; + } + + /** + * Get the {@link Camera camera} used for rendering. + * If the VR mode is {@link #isInVR() active}, this method return a dummy camera, otherwise, + * this method return the camera of the attached application. + * @return the camera attached used for rendering. + */ + public Camera getCamera() { + if( isInVR() && getVRViewManager() != null && getVRViewManager().getLeftCamera() != null ) { + return getDummyCamera(); + } + + return application.getCamera(); + } + + public Camera getDummyCamera(){ + if (dummyCam == null){ + if (application != null){ + if (application.getCamera() != null){ + dummyCam = application.getCamera().clone(); + } else { + if ((settings != null) && (settings.getWidth() != 0) && (settings.getHeight() != 0)){ + dummyCam = new Camera(settings.getWidth(), settings.getHeight()); + } else { + dummyCam = new Camera(0, 0); + } + } + } else { + throw new IllegalStateException("VR environment is not attached to any application."); + } + } + return dummyCam; + } + + /** + * Attach the VR environment to the given app state and application. + * This method should be called within the {@link AppState#stateAttached(com.jme3.app.state.AppStateManager) stateAttached(com.jme3.app.state.AppStateManager)} method + * from the app state. + * @param appState the app state to attach. + * @param application the application to attach. + */ + public void atttach(AppState appState, Application application){ + this.application = application; + this.app = appState; + + // Instantiate view manager + if (vrBinding == VRConstants.SETTING_VRAPI_OPENVR_VALUE){ + viewManager = new OpenVRViewManager(this); + } else if (vrBinding == VRConstants.SETTING_VRAPI_OSVR_VALUE){ + viewManager = new OSVRViewManager(this); + } else if (vrBinding == VRConstants.SETTING_VRAPI_OCULUSVR_VALUE) { + viewManager = new OculusViewManager(this); + } else if (vrBinding == VRConstants.SETTING_VRAPI_OPENVR_LWJGL_VALUE) { + viewManager = new LWJGLOpenVRViewManager(this); + } else { + logger.severe("Cannot instantiate view manager, unknown VRAPI type: "+vrBinding); + } + } + + /** + * Initialize this VR environment. This method enable the system bindings and configure all the VR system modules. + * A call to this method has to be made before any use of VR capabilities. + * @return true if the VR environment is successfully initialized and false otherwise. + */ + public boolean initialize(){ + logger.config("Initializing VR environment."); + + initialized = false; + + // we are going to use OpenVR now, not the Oculus Rift + // OpenVR does support the Rift + String OS = System.getProperty("os.name", "generic").toLowerCase(Locale.ENGLISH); + vrSupportedOS = System.getProperty("sun.arch.data.model").equalsIgnoreCase("64"); //64-bit only + compositorOS = OS.contains("indows") || OS.contains("nux"); + + if (OS.contains("nux") && vrBinding != VRConstants.SETTING_VRAPI_OPENVR_LWJGL_VALUE){ + logger.severe("Only LWJGL VR backend is currently (partially) supported on Linux."); + vrSupportedOS = false; + } + + if( vrSupportedOS) { + if( vrBinding == VRConstants.SETTING_VRAPI_OSVR_VALUE ) { + guiManager = new VRGuiManager(this); + mouseManager = new OpenVRMouseManager(this); + + hardware = new OSVR(this); + initialized = true; + logger.config("Creating OSVR wrapper [SUCCESS]"); + } else if( vrBinding == VRConstants.SETTING_VRAPI_OPENVR_VALUE ) { + guiManager = new VRGuiManager(this); + mouseManager = new OpenVRMouseManager(this); + + hardware = new OpenVR(this); + initialized = true; + logger.config("Creating OpenVR wrapper [SUCCESS]"); + } else if (vrBinding == VRConstants.SETTING_VRAPI_OCULUSVR_VALUE) { + guiManager = new VRGuiManager(this); + mouseManager = new OculusMouseManager(this); + + hardware = new OculusVR(this); + initialized = true; + logger.config("Creating Oculus Rift wrapper [SUCCESS]"); + } else if (vrBinding == VRConstants.SETTING_VRAPI_OPENVR_LWJGL_VALUE) { + guiManager = new VRGuiManager(this); + mouseManager = new LWJGLOpenVRMouseManager(this); + + hardware = new LWJGLOpenVR(this); + initialized = true; + logger.config("Creating OpenVR/LWJGL wrapper [SUCCESS]"); + } else { + logger.config("Cannot create VR binding: "+vrBinding+" [FAILED]"); + logger.log(Level.SEVERE, "Cannot initialize VR environment [FAILED]"); + } + + if( hardware.initialize() ) { + initialized &= true; + logger.config("VR native wrapper initialized [SUCCESS]"); + } else { + initialized &= false; + logger.warning("VR native wrapper initialized [FAILED]"); + logger.log(Level.SEVERE, "Cannot initialize VR environment [FAILED]"); + } + } else { + logger.log(Level.SEVERE, "System does not support VR capabilities."); + logger.log(Level.SEVERE, "Cannot initialize VR environment [FAILED]"); + } + + return initialized; + } + + private void processSettings(){ + if (settings != null){ + if (settings.get(VRConstants.SETTING_USE_COMPOSITOR) != null){ + useCompositor = settings.getBoolean(VRConstants.SETTING_USE_COMPOSITOR); + if( useCompositor == false ){ + disableSwapBuffers = false; + } + } + + if (settings.get(VRConstants.SETTING_ENABLE_MIRROR_WINDOW) != null){ + if( useCompositor == false ) { + disableSwapBuffers = false; + } else { + disableSwapBuffers = !settings.getBoolean(VRConstants.SETTING_ENABLE_MIRROR_WINDOW); + } + } + + if (settings.get(VRConstants.SETTING_GUI_OVERDRAW) != null){ + getVRGUIManager().setGuiOverdraw(settings.getBoolean(VRConstants.SETTING_GUI_OVERDRAW)); + } + + if (settings.get(VRConstants.SETTING_GUI_CURVED_SURFACE) != null){ + getVRGUIManager().setCurvedSurface(settings.getBoolean(VRConstants.SETTING_GUI_CURVED_SURFACE)); + } + + if (settings.get(VRConstants.SETTING_NO_GUI) != null){ + nogui = settings.getBoolean(VRConstants.SETTING_NO_GUI); + } + + if (settings.get(VRConstants.SETTING_VRAPI) != null){ + vrBinding = settings.getInteger(VRConstants.SETTING_VRAPI); + }else{ + vrBinding = VRConstants.SETTING_VRAPI_OPENVR_LWJGL_VALUE; //this is the binding that is best supported so makes sense to be the default + } + + if (settings.get(VRConstants.SETTING_SEATED_EXPERIENCE) != null){ + seated = settings.getBoolean(VRConstants.SETTING_SEATED_EXPERIENCE); + } + + if (settings.get(VRConstants.SETTING_INSTANCE_RENDERING) != null){ + instanceRendering = settings.getBoolean(VRConstants.SETTING_INSTANCE_RENDERING); + } + + if (settings.get(VRConstants.SETTING_DEFAULT_FOV) != null){ + defaultFOV = settings.getFloat(VRConstants.SETTING_DEFAULT_FOV); + } + + if (settings.get(VRConstants.SETTING_DEFAULT_ASPECT_RATIO) != null){ + defaultAspect = settings.getFloat(VRConstants.SETTING_DEFAULT_ASPECT_RATIO); + } + + if (settings.get(VRConstants.SETTING_FLIP_EYES) != null){ + if( getVRHardware() != null ){ + getVRHardware().setFlipEyes(settings.getBoolean(VRConstants.SETTING_FLIP_EYES)); + } + } + } + } +} diff --git a/jme3-xr/src/main/java/com/jme3/input/lwjgl/GlfwKeyInputVR.java b/jme3-xr/src/main/java/com/jme3/input/lwjgl/GlfwKeyInputVR.java new file mode 100644 index 0000000000..6d4f5d6691 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/input/lwjgl/GlfwKeyInputVR.java @@ -0,0 +1,153 @@ +package com.jme3.input.lwjgl; + +/* + * Copyright (c) 2009-2021 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import com.jme3.input.KeyInput; +import com.jme3.input.RawInputListener; +import com.jme3.input.event.KeyInputEvent; +import com.jme3.system.lwjgl.LwjglWindowVR; + +import org.lwjgl.glfw.GLFWKeyCallback; + +import java.util.LinkedList; +import java.util.Queue; +import java.util.logging.Logger; + +import static org.lwjgl.glfw.GLFW.*; + +/** + * A key input that wraps GLFW underlying components. + * @author reden - phr00t - https://github.com/phr00t + * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr + * + */ +public class GlfwKeyInputVR implements KeyInput { + + private static final Logger logger = Logger.getLogger(GlfwKeyInput.class.getName()); + + private LwjglWindowVR context; + private RawInputListener listener; + private boolean initialized, shift_pressed; + private GLFWKeyCallback keyCallback; + private Queue keyInputEvents = new LinkedList<>(); + + /** + * Create a new input attached to the given {@link LwjglWindowVR context}. + * @param context the context to attach to this input. + */ + public GlfwKeyInputVR(LwjglWindowVR context) { + this.context = context; + } + + @Override + public void initialize() { + if (!context.isRenderable()) { + return; + } + + glfwSetKeyCallback(context.getWindowHandle(), keyCallback = new GLFWKeyCallback() { + @Override + public void invoke(long window, int key, int scancode, int action, int mods) { + scancode = GlfwKeyMap.toJmeKeyCode(key); + if( key == GLFW_KEY_LEFT_SHIFT || key == GLFW_KEY_RIGHT_SHIFT ) { + shift_pressed = (action == GLFW_PRESS); + } else if( key >= 'A' && key <= 'Z' && !shift_pressed ) { + key += 32; // make lowercase + } else if( key >= 'a' && key <= 'z' && shift_pressed ) { + key -= 32; // make uppercase + } + final KeyInputEvent evt = new KeyInputEvent(scancode, (char) key, GLFW_PRESS == action, GLFW_REPEAT == action); + evt.setTime(getInputTimeNanos()); + keyInputEvents.add(evt); + } + }); + + glfwSetInputMode(context.getWindowHandle(), GLFW_STICKY_KEYS, 1); + + initialized = true; + logger.fine("Keyboard created."); + } + + /** + * Get the key count. + * @return the key count. + */ + public int getKeyCount() { + // This might not be correct + return GLFW_KEY_LAST - GLFW_KEY_SPACE; + } + + @Override + public void update() { + if (!context.isRenderable()) { + return; + } + + while (!keyInputEvents.isEmpty()) { + listener.onKeyEvent(keyInputEvents.poll()); + } + } + + @Override + public void destroy() { + if (!context.isRenderable()) { + return; + } + + keyCallback.free(); + + logger.fine("Keyboard destroyed."); + } + + @Override + public boolean isInitialized() { + return initialized; + } + + @Override + public void setInputListener(RawInputListener listener) { + this.listener = listener; + } + + @Override + public long getInputTimeNanos() { + return (long) (glfwGetTime() * 1000000000); + } + + @Override + public String getKeyName(int jmeKey) { + int glfwKey = GlfwKeyMap.fromJmeKeyCode(jmeKey); + return glfwGetKeyName(glfwKey, 0); + } + +} diff --git a/jme3-xr/src/main/java/com/jme3/input/lwjgl/GlfwMouseInputVR.java b/jme3-xr/src/main/java/com/jme3/input/lwjgl/GlfwMouseInputVR.java new file mode 100644 index 0000000000..8566ca3a04 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/input/lwjgl/GlfwMouseInputVR.java @@ -0,0 +1,332 @@ +package com.jme3.input.lwjgl; + +/* + * Copyright (c) 2009-2021 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import com.jme3.cursors.plugins.JmeCursor; +import com.jme3.input.MouseInput; +import com.jme3.input.RawInputListener; +import com.jme3.input.event.MouseButtonEvent; +import com.jme3.input.event.MouseMotionEvent; +import com.jme3.system.lwjgl.LwjglWindowVR; +import com.jme3.util.BufferUtils; + +import org.lwjgl.glfw.GLFWCursorPosCallback; +import org.lwjgl.glfw.GLFWMouseButtonCallback; +import org.lwjgl.glfw.GLFWScrollCallback; + +import java.nio.ByteBuffer; +import java.nio.IntBuffer; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.Map; +import java.util.Queue; +import java.util.logging.Logger; + +import static org.lwjgl.glfw.GLFW.*; +import org.lwjgl.glfw.GLFWImage; +import org.lwjgl.system.MemoryUtil; + +/** + * Captures mouse input using GLFW callbacks. It then temporarily stores these in event queues which are processed in the + * {@link #update()} method. Due to some of the GLFW button IDs, there is a conversion method in this class which will + * convert the GLFW left, middle and right mouse button to JME3 left, middle and right button codes.

+ * This class support modifications dedicated to VR rendering. + * @author Daniel Johansson (dannyjo) + * @author reden - phr00t - https://github.com/phr00t + * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr * @author Julien Seinturier - (c) 2016 - JOrigin project - http:/www.jorigin.org + */ +public class GlfwMouseInputVR implements MouseInput { + + private static final Logger logger = Logger.getLogger(GlfwMouseInputVR.class.getName()); + + private static final int WHEEL_SCALE = 120; + + private LwjglWindowVR context; + private RawInputListener listener; + private boolean cursorVisible = true; + private int mouseX, xDelta; + private int mouseY, yDelta; + private int mouseWheel; + private boolean initialized; + private GLFWCursorPosCallback cursorPosCallback; + private GLFWScrollCallback scrollCallback; + private GLFWMouseButtonCallback mouseButtonCallback; + private Queue mouseMotionEvents = new LinkedList<>(); + private Queue mouseButtonEvents = new LinkedList<>(); + + private Map jmeToGlfwCursorMap = new HashMap<>(); + + /** + * Create a new mouse input attached to the given {@link LwjglWindowVR context}. + * @param context the context to which to attach the input. + */ + public GlfwMouseInputVR(LwjglWindowVR context) { + this.context = context; + } + + private void onCursorPos(long window, double xpos, double ypos) { + int x = (int) Math.round(xpos); + int y = context.getSettings().getHeight() - (int) Math.round(ypos); + + if (mouseX == 0) { + mouseX = x; + } + + if (mouseY == 0) { + mouseY = y; + } + + xDelta = x - mouseX; + yDelta = y - mouseY; + mouseX = x; + mouseY = y; + + if (xDelta != 0 || yDelta != 0) { + final MouseMotionEvent mouseMotionEvent = new MouseMotionEvent(x, y, xDelta, yDelta, mouseWheel, 0); + mouseMotionEvent.setTime(getInputTimeNanos()); + mouseMotionEvents.add(mouseMotionEvent); + } + } + + private void onWheelScroll(long window, double xOffset, double yOffset) { + mouseWheel += yOffset; + + final MouseMotionEvent mouseMotionEvent = new MouseMotionEvent(mouseX, mouseY, 0, 0, mouseWheel, (int) Math.round(yOffset)); + mouseMotionEvent.setTime(getInputTimeNanos()); + mouseMotionEvents.add(mouseMotionEvent); + } + private void onMouseButton(final long window, final int button, final int action, final int mods) { + final MouseButtonEvent mouseButtonEvent = new MouseButtonEvent(convertButton(button), action == GLFW_PRESS, mouseX, mouseY); + mouseButtonEvent.setTime(getInputTimeNanos()); + mouseButtonEvents.add(mouseButtonEvent); + } + + @Override + public void initialize() { + glfwSetCursorPosCallback(context.getWindowHandle(), cursorPosCallback = new GLFWCursorPosCallback() { + @Override + public void invoke(long window, double xpos, double ypos) { + onCursorPos(window, xpos, ypos); + } + }); + + glfwSetScrollCallback(context.getWindowHandle(), scrollCallback = new GLFWScrollCallback() { + @Override + public void invoke(final long window, final double xOffset, final double yOffset) { + onWheelScroll(window, xOffset, yOffset * WHEEL_SCALE); + } + }); + + glfwSetMouseButtonCallback(context.getWindowHandle(), mouseButtonCallback = new GLFWMouseButtonCallback() { + @Override + public void invoke(final long window, final int button, final int action, final int mods) { + onMouseButton(window, button, action, mods); + } + }); + + setCursorVisible(cursorVisible); + logger.fine("Mouse created."); + initialized = true; + } + + /** + * Set the position of the cursor on the display. + * @param x the x position of the cursor (pixel). + * @param y the y position of the cursor (pixel). + */ + public void setCursorPosition(int x, int y) { + if (!context.isRenderable()) { + return; + } + + glfwSetCursorPos(context.getWindowHandle(), x, y); + } + + /** + * Hide the active cursor within the display. + */ + public void hideActiveCursor() { + if (!context.isRenderable()) { + return; + } + + if (cursorVisible) { + glfwSetInputMode(context.getWindowHandle(), GLFW_CURSOR, GLFW_CURSOR_HIDDEN); + } + } + + /** + * Get the last delta in x (pixel). + * @return the last delta in x (pixel). + * @see #getLastDeltaY() + */ + public int getLastDeltaX() { + return xDelta; + } + + /** + * Get the last delta in y (pixel). + * @return the last delta in y (pixel). + * @see #getLastDeltaX() + */ + public int getLastDeltaY() { + return yDelta; + } + + /** + * Clear the last x and y deltas. + * @see #getLastDeltaX() + * @see #getLastDeltaY() + */ + public void clearDeltas() { + xDelta = 0; + yDelta = 0; + } + + /** + * Check if the input is initialized. + * @return true if the input is initialized and false otherwise. + */ + @Override + public boolean isInitialized() { + return initialized; + } + + @Override + public int getButtonCount() { + return GLFW_MOUSE_BUTTON_LAST + 1; + } + + @Override + public void update() { + while (!mouseMotionEvents.isEmpty()) { + listener.onMouseMotionEvent(mouseMotionEvents.poll()); + } + + while (!mouseButtonEvents.isEmpty()) { + listener.onMouseButtonEvent(mouseButtonEvents.poll()); + } + } + + @Override + public void destroy() { + if (!context.isRenderable()) { + return; + } + + cursorPosCallback.free(); + scrollCallback.free(); + mouseButtonCallback.free(); + + for (long glfwCursor : jmeToGlfwCursorMap.values()) { + glfwDestroyCursor(glfwCursor); + } + + logger.fine("Mouse destroyed."); + } + + @Override + public void setCursorVisible(boolean visible) { + cursorVisible = visible; + + if (!context.isRenderable()) { + return; + } + + if (cursorVisible) { + glfwSetInputMode(context.getWindowHandle(), GLFW_CURSOR, GLFW_CURSOR_NORMAL); + } else { + glfwSetInputMode(context.getWindowHandle(), GLFW_CURSOR, GLFW_CURSOR_DISABLED); + } + } + + @Override + public void setInputListener(RawInputListener listener) { + this.listener = listener; + } + + @Override + public long getInputTimeNanos() { + return (long) (glfwGetTime() * 1000000000); + } + + private long createGlfwCursor(JmeCursor jmeCursor) { + GLFWImage glfwImage = new GLFWImage(BufferUtils.createByteBuffer(GLFWImage.SIZEOF)); + + // TODO: currently animated cursors are not supported + IntBuffer imageData = jmeCursor.getImagesData(); + ByteBuffer buf = BufferUtils.createByteBuffer(imageData.capacity() * 4); + buf.asIntBuffer().put(imageData); + + glfwImage.set(jmeCursor.getWidth(), jmeCursor.getHeight(), buf); + + return glfwCreateCursor(glfwImage, jmeCursor.getXHotSpot(), jmeCursor.getYHotSpot()); + } + + @Override + public void setNativeCursor(JmeCursor jmeCursor) { + if (jmeCursor != null) { + Long glfwCursor = jmeToGlfwCursorMap.get(jmeCursor); + + if (glfwCursor == null) { + glfwCursor = createGlfwCursor(jmeCursor); + jmeToGlfwCursorMap.put(jmeCursor, glfwCursor); + } + + glfwSetCursor(context.getWindowHandle(), glfwCursor); + } else { + glfwSetCursor(context.getWindowHandle(), MemoryUtil.NULL); + } + } + + /** + * Simply converts the GLFW button code to a JME button code. If there is no + * match it just returns the GLFW button code. Bear in mind GLFW supports 8 + * different mouse buttons. + * + * @param glfwButton the raw GLFW button index. + * @return the mapped {@link MouseInput} button id. + */ + private int convertButton(final int glfwButton) { + switch (glfwButton) { + case GLFW_MOUSE_BUTTON_LEFT: + return MouseInput.BUTTON_LEFT; + case GLFW_MOUSE_BUTTON_MIDDLE: + return MouseInput.BUTTON_MIDDLE; + case GLFW_MOUSE_BUTTON_RIGHT: + return MouseInput.BUTTON_RIGHT; + default: + return glfwButton; + } + } +} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/AbstractVRMouseManager.java b/jme3-xr/src/main/java/com/jme3/input/vr/AbstractVRMouseManager.java new file mode 100644 index 0000000000..6be4cae9fb --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/input/vr/AbstractVRMouseManager.java @@ -0,0 +1,226 @@ +package com.jme3.input.vr; + +import java.util.logging.Logger; + +import org.lwjgl.glfw.GLFW; + +import com.jme3.app.VREnvironment; +import com.jme3.input.MouseInput; +import com.jme3.input.lwjgl.GlfwMouseInputVR; +import com.jme3.material.RenderState.BlendMode; +import com.jme3.math.Vector2f; +import com.jme3.system.AppSettings; +import com.jme3.system.lwjgl.LwjglWindow; +import com.jme3.texture.Texture; +import com.jme3.texture.Texture2D; +import com.jme3.ui.Picture; + +/** + * An abstract implementation of a {@link VRMouseManager}. This class should be overridden by specific hardware implementation of VR devices. + * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr + * + */ +public abstract class AbstractVRMouseManager implements VRMouseManager { + private static final Logger logger = Logger.getLogger(AbstractVRMouseManager.class.getName()); + + private VREnvironment environment = null; + + private boolean vrMouseEnabled = true; + private boolean mouseAttached = false; + private Picture mouseImage; + private int recentCenterCount = 0; + + protected final Vector2f cursorPos = new Vector2f(); + + private float ySize, sensitivity = 8f, acceleration = 2f; + + private boolean thumbstickMode; + private float moveScale = 1f; + + /** + * Create a new AbstractVRMouseManager attached to the given {@link VREnvironment VR environment}. + * @param environment the {@link VREnvironment VR environment} that this manager is attached to. + */ + public AbstractVRMouseManager(VREnvironment environment) { + this.environment = environment; + } + + @Override + public void initialize() { + logger.config("Initializing VR mouse manager."); + + // load default mouse image + mouseImage = new Picture("mouse"); + setImage("Common/Util/mouse.png"); + // hide default cursor by making it invisible + + MouseInput mi = environment.getApplication().getContext().getMouseInput(); + if( mi instanceof GlfwMouseInputVR ){ + ((GlfwMouseInputVR)mi).hideActiveCursor(); + } + centerMouse(); + + logger.config("Initialized VR mouse manager [SUCCESS]"); + } + + @Override + public VREnvironment getVREnvironment() { + return environment; + } + + @Override + public void setVRMouseEnabled(boolean enabled) { + vrMouseEnabled = enabled; + } + + @Override + public void setThumbstickMode(boolean set) { + thumbstickMode = set; + } + + @Override + public boolean isThumbstickMode() { + return thumbstickMode; + } + + @Override + public void setSpeed(float sensitivity, float acceleration) { + this.sensitivity = sensitivity; + this.acceleration = acceleration; + } + + @Override + public float getSpeedSensitivity() { + return sensitivity; + } + + @Override + public float getSpeedAcceleration() { + return acceleration; + } + + @Override + public float getMouseMoveScale() { + return moveScale; + } + + @Override + public void setMouseMoveScale(float set) { + moveScale = set; + } + + @Override + public void setImage(String texture) { + if (environment != null){ + + if (environment.getApplication() != null){ + if( environment.isInVR() == false ){ + Texture tex = environment.getApplication().getAssetManager().loadTexture(texture); + mouseImage.setTexture(environment.getApplication().getAssetManager(), (Texture2D)tex, true); + ySize = tex.getImage().getHeight(); + mouseImage.setHeight(ySize); + mouseImage.setWidth(tex.getImage().getWidth()); + mouseImage.getMaterial().getAdditionalRenderState().setBlendMode(BlendMode.Alpha); + mouseImage.getMaterial().getAdditionalRenderState().setDepthWrite(false); + } else { + Texture tex = environment.getApplication().getAssetManager().loadTexture(texture); + mouseImage.setTexture(environment.getApplication().getAssetManager(), (Texture2D)tex, true); + ySize = tex.getImage().getHeight(); + mouseImage.setHeight(ySize); + mouseImage.setWidth(tex.getImage().getWidth()); + mouseImage.getMaterial().getAdditionalRenderState().setBlendMode(BlendMode.Alpha); + mouseImage.getMaterial().getAdditionalRenderState().setDepthWrite(false); + } + } else { + throw new IllegalStateException("This VR environment is not attached to any application."); + } + + } else { + throw new IllegalStateException("This VR view manager is not attached to any VR environment."); + } + } + + + @Override + public Vector2f getCursorPosition() { + + if (environment != null){ + if (environment.getApplication() != null){ + if( environment.isInVR() ) { + return cursorPos; + } + + return environment.getApplication().getInputManager().getCursorPosition(); + } else { + throw new IllegalStateException("This VR environment is not attached to any application."); + } + } else { + throw new IllegalStateException("This VR view manager is not attached to any VR environment."); + } + } + + @Override + public void centerMouse() { + if (environment != null){ + if (environment.getApplication() != null){ + // set mouse in center of the screen if newly added + Vector2f size = environment.getVRGUIManager().getCanvasSize(); + MouseInput mi = environment.getApplication().getContext().getMouseInput(); + AppSettings as = environment.getApplication().getContext().getSettings(); + if( mi instanceof GlfwMouseInputVR ) ((GlfwMouseInputVR)mi).setCursorPosition((int)(as.getWidth() / 2f), (int)(as.getHeight() / 2f)); + if( environment.isInVR() ) { + cursorPos.x = size.x / 2f; + cursorPos.y = size.y / 2f; + recentCenterCount = 2; + } + } else { + throw new IllegalStateException("This VR environment is not attached to any application."); + } + } else { + throw new IllegalStateException("This VR view manager is not attached to any VR environment."); + } + } + + @Override + public void update(float tpf) { + // if we are showing the cursor, add our picture as it + if( vrMouseEnabled && environment.getApplication().getInputManager().isCursorVisible() ) { + if(!mouseAttached) { + mouseAttached = true; + environment.getApplication().getGuiViewPort().attachScene(mouseImage); + centerMouse(); + // the "real" mouse pointer should stay hidden + if (environment.getApplication().getContext() instanceof LwjglWindow){ + GLFW.glfwSetInputMode(((LwjglWindow)environment.getApplication().getContext()).getWindowHandle(), GLFW.GLFW_CURSOR, GLFW.GLFW_CURSOR_DISABLED); + } + } + // handle mouse movements, which may be in addition to (or exclusive from) tracked movement + MouseInput mi = environment.getApplication().getContext().getMouseInput(); + if( mi instanceof GlfwMouseInputVR ) { + if( recentCenterCount <= 0 ) { + //Vector2f winratio = VRGuiManager.getCanvasToWindowRatio(); + cursorPos.x += ((GlfwMouseInputVR)mi).getLastDeltaX();// * winratio.x; + cursorPos.y += ((GlfwMouseInputVR)mi).getLastDeltaY();// * winratio.y; + if( cursorPos.x < 0f ) cursorPos.x = 0f; + if( cursorPos.y < 0f ) cursorPos.y = 0f; + if( cursorPos.x > environment.getVRGUIManager().getCanvasSize().x ) cursorPos.x = environment.getVRGUIManager().getCanvasSize().x; + if( cursorPos.y > environment.getVRGUIManager().getCanvasSize().y ) cursorPos.y = environment.getVRGUIManager().getCanvasSize().y; + } else recentCenterCount--; + ((GlfwMouseInputVR)mi).clearDeltas(); + } + // ok, update the cursor graphic position + Vector2f currentPos = getCursorPosition(); + mouseImage.setLocalTranslation(currentPos.x, currentPos.y - ySize, environment.getVRGUIManager().getGuiDistance() + 1f); + + mouseImage.updateGeometricState(); + + } else if(mouseAttached) { + mouseAttached = false; + environment.getApplication().getGuiViewPort().detachScene(mouseImage); + + // Use the setCursorVisible implementation to show the cursor again, depending on the state of cursorVisible + boolean cursorVisible = environment.getApplication().getInputManager().isCursorVisible(); + environment.getApplication().getContext().getMouseInput().setCursorVisible(cursorVisible); + } + } +} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/AbstractVRViewManager.java b/jme3-xr/src/main/java/com/jme3/input/vr/AbstractVRViewManager.java new file mode 100644 index 0000000000..03868cedf7 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/input/vr/AbstractVRViewManager.java @@ -0,0 +1,226 @@ +package com.jme3.input.vr; + +import com.jme3.app.VREnvironment; +import com.jme3.post.CartoonSSAO; +import com.jme3.post.Filter; +import com.jme3.post.FilterPostProcessor; +import com.jme3.post.FilterUtil; +import com.jme3.post.SceneProcessor; +import com.jme3.post.filters.FogFilter; +import com.jme3.post.filters.TranslucentBucketFilter; +import com.jme3.post.ssao.SSAOFilter; +import com.jme3.renderer.Camera; +import com.jme3.renderer.ViewPort; +import com.jme3.shadow.DirectionalLightShadowFilter; +import com.jme3.shadow.VRDirectionalLightShadowRenderer; +import com.jme3.texture.Texture2D; + +/** + * A VR view manager. This class holds methods that enable to submit 3D views to the VR compositor. + * System-dependent classes should extend this one. + * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr + */ +public abstract class AbstractVRViewManager implements VRViewManager { + //private static final Logger logger = Logger.getLogger(AbstractVRViewManager.class.getName()); + + protected VREnvironment environment = null; + + protected Camera leftCamera; + protected ViewPort leftViewPort; + protected FilterPostProcessor leftPostProcessor; + protected Texture2D leftEyeTexture; + protected Texture2D leftEyeDepth; + + protected Camera rightCamera; + protected ViewPort rightViewPort; + protected FilterPostProcessor rightPostProcessor; + protected Texture2D rightEyeTexture; + protected Texture2D rightEyeDepth; + + protected ViewPort mirrorViewPort; + + private float resMult = 1f; + + private float heightAdjustment; + + @Override + public Camera getLeftCamera() { + return leftCamera; + } + + @Override + public Camera getRightCamera() { + return rightCamera; + } + + @Override + public ViewPort getLeftViewPort() { + return leftViewPort; + } + + @Override + public ViewPort getRightViewPort() { + return rightViewPort; + } + + /** + * Get the {@link ViewPort view port} attached to the mirror display. + * @return the view port attached to the mirror display. + */ + @Override + public ViewPort getMirrorViewPort() { + return mirrorViewPort; + } + + + @Override + public Texture2D getLeftTexture(){ + return leftEyeTexture; + } + + @Override + public Texture2D getRightTexture(){ + return rightEyeTexture; + } + + @Override + public Texture2D getLeftDepth(){ + return leftEyeDepth; + } + + @Override + public Texture2D getRightDepth(){ + return rightEyeDepth; + } + + @Override + public FilterPostProcessor getLeftPostProcessor(){ + return leftPostProcessor; + } + + @Override + public FilterPostProcessor getRightPostProcessor(){ + return rightPostProcessor; + } + + @Override + public float getResolutionMuliplier() { + return resMult; + } + + @Override + public void setResolutionMultiplier(float resMult) { + this.resMult = resMult; + } + + @Override + public float getHeightAdjustment() { + return heightAdjustment; + } + + @Override + public void setHeightAdjustment(float amount) { + heightAdjustment = amount; + } + + @Override + public VREnvironment getVREnvironment(){ + return environment; + } + + /** + * Handles moving filters from the main view to each eye + */ + @Override + public void moveScreenProcessingToEyes() { + if (environment != null){ + if( getRightViewPort() == null ){ + return; + } + + if (environment.getApplication() != null){ + syncScreenProcessing(environment.getApplication().getViewPort()); + environment.getApplication().getViewPort().clearProcessors(); + } else { + throw new IllegalStateException("The VR environment is not attached to any application."); + } + + } else { + throw new IllegalStateException("This VR view manager is not attached to any VR environment."); + } + } + + /** + * Sets the two views to use the list of {@link SceneProcessor processors}. + * @param sourceViewport the {@link ViewPort viewport} that contains the processors to use. + */ + public void syncScreenProcessing(ViewPort sourceViewport) { + if (environment != null){ + if( getRightViewPort() == null ){ + return; + } + + if (environment.getApplication() != null){ + // set up post-processing filters + if( getRightPostProcessor() == null ) { + rightPostProcessor = new FilterPostProcessor(environment.getApplication().getAssetManager()); + leftPostProcessor = new FilterPostProcessor(environment.getApplication().getAssetManager()); + } + // clear out all filters & processors, to start from scratch + getRightPostProcessor().removeAllFilters(); + getLeftPostProcessor().removeAllFilters(); + getLeftViewPort().clearProcessors(); + getRightViewPort().clearProcessors(); + // if we have no processors to sync, don't add the FilterPostProcessor + if( sourceViewport.getProcessors().isEmpty() ) return; + // add post processors we just made, which are empty + getLeftViewPort().addProcessor(getLeftPostProcessor()); + getRightViewPort().addProcessor(getRightPostProcessor()); + // Go through all of the filters in the processors list, + // add them to the left viewport processor, and clone them to the right. + for(SceneProcessor sceneProcessor : sourceViewport.getProcessors()) { + if (sceneProcessor instanceof FilterPostProcessor) { + for(Filter f : ((FilterPostProcessor)sceneProcessor).getFilterList() ) { + if( f instanceof TranslucentBucketFilter ) { + // just remove this filter, we will add it at the end manually + ((FilterPostProcessor)sceneProcessor).removeFilter(f); + } else { + getLeftPostProcessor().addFilter(f); + // clone to the right + Filter f2; + if(f instanceof FogFilter){ + f2 = FilterUtil.cloneFogFilter((FogFilter)f); + } else if (f instanceof CartoonSSAO ) { + f2 = new CartoonSSAO((CartoonSSAO)f); + } else if (f instanceof SSAOFilter){ + f2 = FilterUtil.cloneSSAOFilter((SSAOFilter)f); + } else if (f instanceof DirectionalLightShadowFilter){ + f2 = FilterUtil.cloneDirectionalLightShadowFilter(environment.getApplication().getAssetManager(), (DirectionalLightShadowFilter)f); + } else { + f2 = f; // dof, bloom, light scattering etc. + } + getRightPostProcessor().addFilter(f2); + } + } + } else if (sceneProcessor instanceof VRDirectionalLightShadowRenderer) { + // shadow processing + // TODO: make right shadow processor use same left shadow maps for performance + VRDirectionalLightShadowRenderer dlsr = (VRDirectionalLightShadowRenderer) sceneProcessor; + VRDirectionalLightShadowRenderer dlsrRight = dlsr.clone(); + dlsrRight.setLight(dlsr.getLight()); + getRightViewPort().getProcessors().add(0, dlsrRight); + getLeftViewPort().getProcessors().add(0, sceneProcessor); + } + } + // make sure each has a translucent filter renderer + getLeftPostProcessor().addFilter(new TranslucentBucketFilter()); + getRightPostProcessor().addFilter(new TranslucentBucketFilter()); + } else { + throw new IllegalStateException("The VR environment is not attached to any application."); + } + + } else { + throw new IllegalStateException("This VR view manager is not attached to any VR environment."); + } + } +} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/AnalogActionState.java b/jme3-xr/src/main/java/com/jme3/input/vr/AnalogActionState.java new file mode 100644 index 0000000000..8cf519ff0b --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/input/vr/AnalogActionState.java @@ -0,0 +1,48 @@ +package com.jme3.input.vr; + +public class AnalogActionState{ + + /** + * The X coordinate of the analog data (typically between -1 and 1 for joystick coordinates or 0 and 1 for + * trigger pulls) + */ + public final float x; + + /** + * The Y coordinate of the analog data (typically between -1 and 1) + * + * Will be zero if the analog action doesn't have at least 2 dimensions + */ + public final float y; + + /** + * The Z coordinate of the analog data (typically between -1 and 1) + * + * Will be zero if the analog action doesn't have at least 3 dimensions + */ + public final float z; + + /** + * The change in the X coordinate since the last frame + */ + public final float deltaX; + + /** + * The change in the Y coordinate since the last frame + */ + public final float deltaY; + + /** + * The change in the Z coordinate since the last frame + */ + public final float deltaZ; + + public AnalogActionState(float x, float y, float z, float deltaX, float deltaY, float deltaZ){ + this.x = x; + this.y = y; + this.z = z; + this.deltaX = deltaX; + this.deltaY = deltaY; + this.deltaZ = deltaZ; + } +} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/DigitalActionState.java b/jme3-xr/src/main/java/com/jme3/input/vr/DigitalActionState.java new file mode 100644 index 0000000000..1da865eecf --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/input/vr/DigitalActionState.java @@ -0,0 +1,19 @@ +package com.jme3.input.vr; + +public class DigitalActionState{ + + /** + * The current value of this action + */ + public final boolean state; + + /** + * If since the last loop the value of this action has changed + */ + public final boolean changed; + + public DigitalActionState(boolean state, boolean changed){ + this.state = state; + this.changed = changed; + } +} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/HmdType.java b/jme3-xr/src/main/java/com/jme3/input/vr/HmdType.java new file mode 100644 index 0000000000..8dfe9b9365 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/input/vr/HmdType.java @@ -0,0 +1,68 @@ +package com.jme3.input.vr; + +/** + * The type of VR Head Mounted Device (HMD) + * @author reden - phr00t - https://github.com/phr00t + * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr + */ +public enum HmdType { + /** + * HTC vive Head Mounted Device (HMD). + */ + HTC_VIVE, + + /** + * Valve Index Head Mounted Device (HMD). + */ + VALVE_INDEX, + + /** + * Oculus Rift Head Mounted Device (HMD). + */ + OCULUS_RIFT, + + /** + * OSVR generic Head Mounted Device (HMD). + */ + OSVR, + + /** + * FOVE Head Mounted Device (HMD). + */ + FOVE, + + /** + * STARVR Head Mounted Device (HMD). + */ + STARVR, + + /** + * GameFace Head Mounted Device (HMD). + */ + GAMEFACE, + + /** + * PlayStation VR (formerly Morpheus) Head Mounted Device (HMD). + */ + MORPHEUS, + + /** + * Samsung GearVR Head Mounted Device (HMD). + */ + GEARVR, + + /** + * a null Head Mounted Device (HMD). + */ + NULL, + + /** + * a none Head Mounted Device (HMD). + */ + NONE, + + /** + * a not referenced Head Mounted Device (HMD). + */ + OTHER +} \ No newline at end of file diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/VRAPI.java b/jme3-xr/src/main/java/com/jme3/input/vr/VRAPI.java new file mode 100644 index 0000000000..e2afa0e789 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/input/vr/VRAPI.java @@ -0,0 +1,183 @@ +package com.jme3.input.vr; + +import com.jme3.math.Matrix4f; +import com.jme3.math.Quaternion; +import com.jme3.math.Vector2f; +import com.jme3.math.Vector3f; +import com.jme3.renderer.Camera; + +/** + * An interface that represents a VR system. This interface has to be implemented in order to wrap underlying VR system (OpenVR, OSVR, ...) + * @author reden - phr00t - https://github.com/phr00t + * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr + */ +public interface VRAPI { + /** + * Initialize this object from a VR system. All the native bindings to underlying VR system should be done within this method. + * @return true if the initialization is a success and false otherwise. + */ + public boolean initialize(); + + /** + * Initialize the VR compositor that will be used for rendering. + * @param allowed true if the use of VR compositor is allowed and false otherwise. + * @return true if the initialization is a success and false otherwise. + */ + public boolean initVRCompositor(boolean allowed); + + /** + * Get the object that wraps natively the VR system. + * @return the object that wraps natively the VR system. + */ + public Object getVRSystem(); + + /** + * Get the object that wraps natively the VR compositor. + * @return the object that wraps natively the VR system. + */ + public Object getCompositor(); + + /** + * Get the name of the underlying VR system. + * @return the name of the underlying VR system. + */ + public String getName(); + + /** + * Get the input provided by the underlying VR system. + * @return the input provided by the underlying VR system. + */ + public VRInputAPI getVRinput(); + + /** + * Flip the left and right eye. + * @param set true if the eyes has to be flipped and false otherwise. + */ + public void setFlipEyes(boolean set); + + /** + * Set if latency information has to be logged. + * @param set true if latency information has to be logged and false otherwise. + */ + public void printLatencyInfoToConsole(boolean set); + + /** + * Get the Head Mounted Device (HMD) display frequency. + * @return the Head Mounted Device (HMD) display frequency. + */ + public int getDisplayFrequency(); + + /** + * Close the link with underlying VR system and free all attached resources. + */ + public void destroy(); + + /** + * Check if the VR API is initialized. + * @return true if the VR API is initialized and false otherwise. + * @see #initialize() + */ + public boolean isInitialized(); + + /** + * Reset the VR system. After a call to this method, the current position of the HMD should be + * the origin (i-e the observer without any combined transformation). + */ + public void reset(); + + /** + * Get the size of a Head Mounted Device (HMD) rendering area in pixels. + * @param store the size of a Head Mounted Device (HMD) rendering area in pixels (modified). + */ + public void getRenderSize(Vector2f store); + + //public float getFOV(int dir); + + /** + * Get the Head Mounted Device (HMD) interpupilar distance in meters. + * @return the Head Mounted Device (HMD) interpupilar distance in meters. + */ + public float getInterpupillaryDistance(); + + /** + * Get the Head Mounted Device (HMD) orientation. + * @return the Head Mounted Device (HMD) orientation. + */ + public Quaternion getOrientation(); + + /** + * Get the Head Mounted Device (HMD) position. + * @return the Head Mounted Device (HMD) orientation. + */ + public Vector3f getPosition(); + + /** + * Get the Head Mounted Device (HMD) position and orientation. + * @param storePos the Head Mounted Device (HMD) position (modified). + * @param storeRot the Head Mounted Device (HMD) rotation (modified). + */ + public void getPositionAndOrientation(Vector3f storePos, Quaternion storeRot); + + /** + * Update Head Mounted Device (HMD) pose internal storage. This method should be called before other calls to HMD position/orientation access. + */ + public void updatePose(); + + /** + * Get the Head Mounted Device (HMD) left eye projection matrix. + * @param cam the camera attached to the left eye. + * @return the Head Mounted Device (HMD) left eye projection matrix. + */ + public Matrix4f getHMDMatrixProjectionLeftEye(Camera cam); + + /** + * Get the Head Mounted Device (HMD) right eye projection matrix. + * @param cam the camera attached to the right eye. + * @return the Head Mounted Device (HMD) right eye projection matrix. + */ + public Matrix4f getHMDMatrixProjectionRightEye(Camera cam); + + /** + * Get the Head Mounted Device (HMD) left eye pose (position of the eye from the head) as a {@link Vector3f vector}. + * @return the Head Mounted Device (HMD) left eye pose as a {@link Vector3f vector}. + */ + public Vector3f getHMDVectorPoseLeftEye(); + + /** + * Get the Head Mounted Device (HMD) right eye pose (position of the eye from the head) as a {@link Vector3f vector}. + * @return the Head Mounted Device (HMD) right eye pose as a {@link Vector3f vector}. + */ + public Vector3f getHMDVectorPoseRightEye(); + + /** + * Returns the transform between the view space and left eye space. + * Eye space is the per-eye flavor of view space that provides stereo disparity. + * Instead of Model * View * Projection the model is Model * View * Eye * Projection. + * Normally View and Eye will be multiplied together and treated as View. + * This matrix incorporates the user's interpupillary distance (IPD). + * @return the transform between the view space and eye space. + */ + public Matrix4f getHMDMatrixPoseLeftEye(); + + /** + * Returns the transform between the view space and right eye space. + * Eye space is the per-eye flavor of view space that provides stereo disparity. + * Instead of Model * View * Projection the model is Model * View * Eye * Projection. + * Normally View and Eye will be multiplied together and treated as View. + * This matrix incorporates the user's interpupillary distance (IPD). + * @return the transform between the view space and eye space. + */ + public Matrix4f getHMDMatrixPoseRightEye(); + + /** + * Get the Head Mounted Device (HMD) type. + * @return the Head Mounted Device (HMD) type. + */ + public HmdType getType(); + + /** + * Get the seated to absolute position. + * @return the seated to absolute position. + */ + public Vector3f getSeatedToAbsolutePosition(); +} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/VRBounds.java b/jme3-xr/src/main/java/com/jme3/input/vr/VRBounds.java new file mode 100644 index 0000000000..179dbb1b08 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/input/vr/VRBounds.java @@ -0,0 +1,17 @@ +package com.jme3.input.vr; + +import com.jme3.math.Vector2f; + +/** + * This interface describes the VR playground bounds. + * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr + * + */ +public interface VRBounds { + + /** + * Get the size of the VR playground. + * @return the size of the VR playground. + */ + public Vector2f getPlaySize(); +} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/VRInputAPI.java b/jme3-xr/src/main/java/com/jme3/input/vr/VRInputAPI.java new file mode 100644 index 0000000000..53d99a8014 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/input/vr/VRInputAPI.java @@ -0,0 +1,377 @@ +package com.jme3.input.vr; + +import com.jme3.math.Quaternion; +import com.jme3.math.Vector2f; +import com.jme3.math.Vector3f; + +/** + * An interface that represents a VR input (typically a VR device such as a controller). + * @author reden - phr00t - https://github.com/phr00t + * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr + */ +public interface VRInputAPI { + + /** + * Registers an action manifest. An actions manifest is a file that defines "actions" a player can make. + * (An action is an abstract version of a button press). The action manifest may then also include references to + * further files that define default mappings between those actions and physical buttons on the VR controllers. + * + * Note that registering an actions manifest will deactivate legacy inputs (i.e. methods such as {@link #isButtonDown} + * will no longer work + * + * See https://github.com/ValveSoftware/openvr/wiki/Action-manifest for documentation on how to create an + * action manifest + * + * This option is only relevant to OpenVR + * + * @param actionManifestAbsolutePath + * the absolute file path to an actions manifest + * @param startingActiveActionSet + * the actions in the manifest are divided into action sets (groups) by their prefix (e.g. "/actions/main"). + * These action sets can be turned off and on per frame. This argument sets the action set that will be + * active now. The active action sets can be later be changed by calling {@link #setActiveActionSet}. + * Note that at present only a single set at a time is supported + * + */ + default void registerActionManifest( String actionManifestAbsolutePath, String startingActiveActionSet ){ + throw new UnsupportedOperationException("Action manifests are not supported for the currently used VR API"); + } + + /** + * Updates the active action set (the action group that will have their states available to be polled). + * + * Note that this update will not take effect until the next loop + * Note that at present only a single set at a time is supported + * + * @param activeActionSet + * the actions in the manifest are divided into action sets (groups) by their prefix (e.g. "/actions/main"). + * These action sets can be turned off and on per frame. This argument sets the action set that will be + * active now. + */ + default void setActiveActionSet( String activeActionSet ){ + throw new UnsupportedOperationException("Action manifests are not supported for the currently used VR API"); + } + + /** + * Gets the current state of the action (abstract version of a button press). + * + * This is called for digital style actions (a button is pressed, or not) + * + * This method is commonly called when it's not important which hand the action is bound to (e.g. if a button press + * is opening your inventory that could be bound to either left or right hand and that would not matter). + * + * If the handedness matters use {@link #getDigitalActionState(String, String)} + * + * {@link #registerActionManifest} must have been called before using this method. + * + * @param actionName The name of the action. Will be something like /actions/main/in/openInventory + * @return the DigitalActionState that has details on if the state has changed, what the state is etc. + */ + default DigitalActionState getDigitalActionState( String actionName ){ + return getDigitalActionState(actionName, null); + } + + /** + * Gets the current state of the action (abstract version of a button press). + * + * This is called for digital style actions (a button is pressed, or not) + * + * This method is commonly called when it is important which hand the action is found on. For example while + * holding a weapon a button may be bound to "eject magazine" to allow you to load a new one, but that would only + * want to take effect on the hand that is holding the weapon + * + * Note that restrictToInput only restricts, it must still be bound to the input you want to receive the input from in + * the action manifest default bindings. + * + * {@link #registerActionManifest} must have been called before using this method. + * + * @param actionName The name of the action. E.g. /actions/main/in/openInventory + * @param restrictToInput the input to restrict the action to. E.g. /user/hand/right. Or null, which means "any input" + * @return the DigitalActionState that has details on if the state has changed, what the state is etc. + */ + default DigitalActionState getDigitalActionState( String actionName, String restrictToInput ){ + throw new UnsupportedOperationException("Action manifests are not supported for the currently used VR API"); + } + + /** + * Gets the current state of the action (abstract version of a button press). + * + * This is called for analog style actions (most commonly joysticks, but button pressure can also be mapped in analog). + * + * This method is commonly called when it's not important which hand the action is bound to (e.g. if the thumb stick + * is controlling a third-person character in-game that could be bound to either left or right hand and that would + * not matter). + * + * If the handedness matters use {@link #getAnalogActionState(String, String)} + * + * {@link #registerActionManifest} must have been called before using this method. + * + * @param actionName The name of the action. E.g. /actions/main/in/openInventory + * @return the DigitalActionState that has details on if the state has changed, what the state is etc. + */ + default AnalogActionState getAnalogActionState( String actionName ){ + return getAnalogActionState(actionName, null); + } + + /** + * Gets the current state of the action (abstract version of a button press). + * + * This is called for analog style actions (most commonly joysticks, but button pressure can also be mapped in analog). + * + * This method is commonly called when it is important which hand the action is found on. For example an "in universe" + * joystick that has a hat control might (while you are holding it) bind to the on-controller hat, but only on the hand + * holding it + * + * Note that restrictToInput only restricts, it must still be bound to the input you want to receive the input from in + * the action manifest default bindings. + * + * {@link #registerActionManifest} must have been called before using this method. + * + * @param actionName The name of the action. E.g. /actions/main/in/openInventory + * @param restrictToInput the input to restrict the action to. E.g. /user/hand/right. Or null, which means "any input" + * @return the DigitalActionState that has details on if the state has changed, what the state is etc. + */ + default AnalogActionState getAnalogActionState( String actionName, String restrictToInput ){ + throw new UnsupportedOperationException("Action manifests are not supported for the currently used VR API"); + } + + /** + * Check if the given button is down (more generally if the given input type is activated). + * + * Deprecated as should use an actions manifest approach. See {@link #registerActionManifest}. Note; action based will only work with the OpenVR api + * + * @param controllerIndex the index of the controller to check. + * @param checkButton the button / input to check. + * @return true if the button / input is down / activated and false otherwise. + */ + @Deprecated + public boolean isButtonDown(int controllerIndex, VRInputType checkButton); + + /** + * Check if the given button / input from the given controller has been just pressed / activated. + * + * Deprecated as should use an actions manifest approach. See {@link #registerActionManifest}. Note; action based will only work with the OpenVR api + * + * @param controllerIndex the index of the controller. + * @param checkButton the button / input to check. + * @return true if the given button / input from the given controller has been just pressed / activated and false otherwise. + */ + @Deprecated + public boolean wasButtonPressedSinceLastCall(int controllerIndex, VRInputType checkButton); + + /** + * Reset the current activation of the inputs. After a call to this method, all input activation is considered as new activation. + * @see #wasButtonPressedSinceLastCall(int, VRInputType) + * + * Deprecated as should use an actions manifest approach. See {@link #registerActionManifest}. Note; action based will only work with the OpenVR api + */ + @Deprecated + public void resetInputSinceLastCall(); + + /** + * Get the controller axis delta from the last value. + * + * Deprecated as should use an actions manifest approach. See {@link #registerActionManifest}. Note; action based will only work with the OpenVR api + * + * @param controllerIndex the index of the controller. + * @param forAxis the axis. + * @return the controller axis delta from the last call. + */ + @Deprecated + public Vector2f getAxisDeltaSinceLastCall(int controllerIndex, VRInputType forAxis); + + /** + * Get the controller velocity on all axes. + * @param controllerIndex the index of the controller. + * @return the controller velocity on all axes. + * @see #getAngularVelocity(int) + */ + public Vector3f getVelocity(int controllerIndex); + + /** + * Get the controller angular velocity on all axes. + * @param controllerIndex the index of the controller. + * @return the controller angular velocity on all axes. + * @see #getVelocity(int) + */ + public Vector3f getAngularVelocity(int controllerIndex); + + /** + * Get the axis value for the given input on the given controller. + * This value is the {@link #getAxisRaw(int, VRInputType) raw value} multiplied by the {@link #getAxisMultiplier() axis multiplier}. + * + * Deprecated as should use an actions manifest approach. See {@link #registerActionManifest}. Note; action based will only work with the OpenVR api + * + * @param controllerIndex the index of the controller. + * @param forAxis the axis. + * @return the axis value for the given input on the given controller. + * @see #getAxisRaw(int, VRInputType) + * @see #getAxisMultiplier() + */ + @Deprecated + public Vector2f getAxis(int controllerIndex, VRInputType forAxis); + + /** + * Get the axis value for the given input on the given controller. + * + * Deprecated as should use an actions manifest approach. See {@link #registerActionManifest} Note; action based will only work with the OpenVR api + * + * @param controllerIndex the index of the controller. + * @param forAxis the axis. + * @return the axis value for the given input on the given controller. + * @see #getAxis(int, VRInputType) + */ + @Deprecated + public Vector2f getAxisRaw(int controllerIndex, VRInputType forAxis); + + /** + * Initialize the input. + * @return true if the initialization is successful and false otherwise. + */ + public boolean init(); + + /** + * Get the number of tracked controllers (for example, hand controllers) attached to the VR system. + * @return the number of controllers attached to the VR system. + * @see #getTrackedController(int) + */ + public int getTrackedControllerCount(); + + /** + * Get a tracked controller (for example, a hand controller) that is attached to the VR system. + * @param index the index of the controller. + * @return the tracked controller (for example, a hand controller) that is attached to the VR system. + * @see #getTrackedControllerCount() + */ + public VRTrackedController getTrackedController(int index); + + /** + * Update the connected controllers. + * This method should be used just after the initialization of the input. + */ + public void updateConnectedControllers(); + + /** + * Update the controller states. + * This method should be called before accessing any controller data. + */ + public void updateControllerStates(); + + /** + * Get the native wrapping of a controller state. + * @param index the index of the controller. + * @return the native wrapping of a controller state. + */ + public Object getRawControllerState(int index); + + /** + * Swap the two hands (exchange the hands' controller 1 and 2 indices). + */ + public void swapHands(); + + /** + * Get the controller axis multiplier. + * The controller axis raw data (trackpad, trigger, ...) value is multiplied by the one given in parameter. + * @return the controller axis multiplier. + * @see #setAxisMultiplier(float) + */ + public float getAxisMultiplier(); + + /** + * Set the controller axis multiplier. + * The controller axis raw data (trackpad, trigger, ...) value is multiplied by the one given in parameter. + * @param set the controller axis multiplier. + * @see #getAxisMultiplier() + */ + public void setAxisMultiplier(float set); + + //public Matrix4f getPoseForInputDevice(int index); + + /** + * Check if the VR system has the focus and if it's not used by other process. + * @return true if the VR system has the focus and false otherwise. + */ + public boolean isInputFocused(); + + /** + * Check if the input device is actually tracked (i-e if we can obtain a pose from the input). + * @param index the index of the controller. + * @return true if the input device is actually tracked and false otherwise. + */ + public boolean isInputDeviceTracking(int index); + + /** + * Get the orientation of the input. + * @param index the index of the controller. + * @return the orientation of the input. + */ + public Quaternion getOrientation(int index); + + /** + * Get the position of the input. + * @param index the index of the controller. + * @return the position of the input. + */ + public Vector3f getPosition(int index); + + /** + * Get where is the controller pointing, after all rotations are combined. + * This position should include observer rotation from the VR application. + * @param index the index of the controller. + * @return the rotation of the input after all positional tracking is complete. + */ + public Quaternion getFinalObserverRotation(int index); + + /** + * Get the position of the input after all positional tracking is complete. + * This position should include observer position from the VR application. + * @param index the index of the controller. + * @return the position of the input after all positional tracking is complete. + */ + public Vector3f getFinalObserverPosition(int index); + + /** + * Trigger a haptic pulse on the selected controller for the duration given in parameters (in seconds). + * + * Deprecated, use triggerHapticAction instead (as it has more options and doesn't use deprecated methods) + * + * @param controllerIndex the index of the controller. + * @param seconds the duration of the pulse in seconds. + */ + @Deprecated + public void triggerHapticPulse(int controllerIndex, float seconds); + + /** + * Triggers a haptic action (aka a vibration). + * + * Note if you want a haptic action in only one hand that is done either by only binding the action to one hand in + * the action manifest's standard bindings or by binding to both and using {@link #triggerHapticAction(String, float, float, float, String)} + * to control which input it gets set to at run time + * + * @param actionName The name of the action. Will be something like /actions/main/out/vibrate + * @param duration how long in seconds the + * @param frequency in cycles per second + * @param amplitude between 0 and 1 + */ + default void triggerHapticAction( String actionName, float duration, float frequency, float amplitude){ + triggerHapticAction( actionName, duration, frequency, amplitude, null ); + } + + /** + * Triggers a haptic action (aka a vibration) restricted to just one input (e.g. left or right hand). + * + * Note that restrictToInput only restricts, it must still be bound to the input you want to send the haptic to in + * the action manifest default bindings. + * + * This method is typically used to bind the haptic to both hands then decide at run time which hand to sent to * + * + * @param actionName The name of the action. Will be something like /actions/main/out/vibrate + * @param duration how long in seconds the + * @param frequency in cycles per second + * @param amplitude between 0 and 1 + * @param restrictToInput the input to restrict the action to. E.g. /user/hand/right, /user/hand/left. Or null, which means "any input" + */ + default void triggerHapticAction( String actionName, float duration, float frequency, float amplitude, String restrictToInput){ + throw new UnsupportedOperationException("Action manifests are not supported for the currently used VR API"); + } +} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/VRInputType.java b/jme3-xr/src/main/java/com/jme3/input/vr/VRInputType.java new file mode 100644 index 0000000000..f4e145c708 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/input/vr/VRInputType.java @@ -0,0 +1,149 @@ +package com.jme3.input.vr; + +/** + * The type of a VR input. This enumeration enables to determine which part of the VR device is involved within input callback. + * @author reden - phr00t - https://github.com/phr00t + * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr + * + * Deprecated, use the LWJGL openVR bindings and use actions instead + * + */ +@Deprecated +public enum VRInputType { + /** + * an HTC vive trigger axis (about Vive controller). + */ + ViveTriggerAxis(0), + + /** + * an HTC vive trackpad axis (about Vive controller). + */ + ViveTrackpadAxis(1), + + /** + * an HTC vive grip button (about Vive controller). + */ + ViveGripButton(2), + + /** + * an HTC vive menu button (about Vive controller). + */ + ViveMenuButton(3), + + /** + * The thumbstick on the Oculus Touch controllers. + * + * Unlike the Vive controllers where the touchpad is commonly used + * as a virtual DPad, you should avoid using the thumbstick for purposes + * that do not require analog input. + */ + OculusThumbstickAxis(0), + + /** + * The trigger button on the Oculus Touch controllers. + * + * This is the button under the user's index finger, and should not be used to + * pick up objects. See the + * Oculus Developer documentation. + */ + OculusTriggerAxis(0), + + /** + * The 'grab' button on the Oculus Touch controllers. + * + * This button should only (unless you have a compelling reason otherwise) be used to pick up objects. + */ + OculusGripAxis(0), + + /** + * The upper buttons on the Oculus Touch controllers - B on the right controller, and Y on the left. + */ + OculusTopButton(org.lwjgl.ovr.OVR.ovrButton_B | org.lwjgl.ovr.OVR.ovrButton_Y), + + /** + * The lower (not counting menu) buttons on the Oculus Touch + * controllers - A on the right controller, and X on the left. + */ + OculusBottomButton(org.lwjgl.ovr.OVR.ovrButton_A | org.lwjgl.ovr.OVR.ovrButton_X), + + /** + * The 'click' button on the Oculus Touch thumbsticks. + */ + OculusThumbstickButton(org.lwjgl.ovr.OVR.ovrButton_LThumb | org.lwjgl.ovr.OVR.ovrButton_RThumb), + + /** + * The game-usable menu button, under and to the left of the 'X' button on the left controller. + * + * Most games use this to pause - it preferably should be used for at least that purpose, and is + * uncomfortable to rest your thumb on (in games where you suddenly have to pause/open a menu). + */ + OculusMenuButton(org.lwjgl.ovr.OVR.ovrButton_Enter), + + /** + * The capacitive touch sensors on the top buttons (Y and B) of the Oculus Touch. + */ + OculusTopTouch(org.lwjgl.ovr.OVR.ovrTouch_B | org.lwjgl.ovr.OVR.ovrTouch_Y), + + /** + * The capacitive touch sensors on the lower buttons (X and A) of the Oculus Touch. + */ + OculusBottomTouch(org.lwjgl.ovr.OVR.ovrTouch_A | org.lwjgl.ovr.OVR.ovrTouch_X), + + /** + * The capacitive touch sensors on the thumbsticks of the Oculus Touch. + */ + OculusThumbstickTouch(org.lwjgl.ovr.OVR.ovrTouch_LThumb | org.lwjgl.ovr.OVR.ovrTouch_RThumb), + + /** + * The capacitive touch sensors on the thumbrests of the Oculus Touch - this is a textured pad + * on the Oculus Touch controller next to the ABXY buttons for users to reset their thumbs on. + * + * While it probably goes without saying, only use this for gesture support and do not bind game + * elements to it. + */ + OculusThumbrestTouch(org.lwjgl.ovr.OVR.ovrTouch_LThumbRest | org.lwjgl.ovr.OVR.ovrTouch_RThumbRest), + + /** + * The state of a software calculation based on the capacitive touch sensor values that determine if + * the user has lifted their thumb off the controller, and can be used for gesture support. + * + * This should be used instead of calculating this yourself based on the touch results of all the other + * parts of the controller. + */ + OculusThumbUp(org.lwjgl.ovr.OVR.ovrTouch_LThumbUp | org.lwjgl.ovr.OVR.ovrTouch_RThumbUp), + + /** + * Is the user resting their finger on the trigger of an Oculus Touch controller? + */ + OculusIndexTouch(org.lwjgl.ovr.OVR.ovrTouch_LIndexPointing | org.lwjgl.ovr.OVR.ovrTouch_RIndexPointing), + + /** + * Is the user pointing their finger forwards, as if to press a button? + * + * This is internally calculated from proximity and filtering is applied - it should be used rather + * than !OculusIndexTouch, as it will probably lead to better results. + */ + OculusIndexPointing(org.lwjgl.ovr.OVR.ovrTouch_LIndexPointing | org.lwjgl.ovr.OVR.ovrTouch_RIndexPointing); + + /** + * The value that codes the input type. + */ + private final int value; + + /** + * Construct a new input type with the given code. + * @param value the code of the input type. + */ + private VRInputType(int value) { + this.value = value; + } + + /** + * Get the value (code) of the input type. + * @return the value (code) of the input type. + */ + public int getValue() { + return value; + } +} \ No newline at end of file diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/VRMouseManager.java b/jme3-xr/src/main/java/com/jme3/input/vr/VRMouseManager.java new file mode 100644 index 0000000000..b6923388f2 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/input/vr/VRMouseManager.java @@ -0,0 +1,111 @@ +package com.jme3.input.vr; + +import com.jme3.app.VREnvironment; +import com.jme3.input.controls.AnalogListener; +import com.jme3.math.Vector2f; + +/** + * A class dedicated to the handling of the mouse within VR environment. + * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr + */ +public interface VRMouseManager { + /** + * Initialize the VR mouse manager. + */ + public void initialize(); + + /** + * Get the {@link VREnvironment VR Environment} to which this manager is attached. + * @return the {@link VREnvironment VR Environment} to which this manager is attached. + */ + public VREnvironment getVREnvironment(); + + /** + * Set if the mouse cursor should be used in the VR view. + * @param enabled true if the mouse cursor should be displayed in VR and false otherwise. + */ + public void setVRMouseEnabled(boolean enabled); + + /** + * Set if the VR device controller is used within thumb stick mode. + * @param set true if the VR device controller is used within thumb stick mode and false otherwise. + */ + public void setThumbstickMode(boolean set); + + /** + * Get if the VR device controller is used within thumb stick mode. + * @return true if the VR device controller is used within thumb stick mode and false otherwise. + */ + public boolean isThumbstickMode(); + + /** + * Set the speed of the mouse. + * @param sensitivity the sensitivity of the mouse. + * @param acceleration the acceleration of the mouse. + * @see #getSpeedAcceleration() + * @see #getSpeedSensitivity() + */ + public void setSpeed(float sensitivity, float acceleration); + + /** + * Get the sensitivity of the mouse. + * @return the sensitivity of the mouse. + * @see #setSpeed(float, float) + */ + public float getSpeedSensitivity(); + + /** + * Get the acceleration of the mouse. + * @return the acceleration of the mouse. + * @see #setSpeed(float, float) + */ + public float getSpeedAcceleration(); + + /** + * Get the move scale. + * return the move scale. + * @see #setMouseMoveScale(float) + */ + public float getMouseMoveScale(); + + /** + * Set the mouse move scale. + * @param set the mouse move scale. + * @see #getMouseMoveScale() + */ + public void setMouseMoveScale(float set); + + /** + * Set the image to use as mouse cursor. The given string describe an asset that the underlying application asset manager has to load. + * @param texture the image to use as mouse cursor. + */ + public void setImage(String texture); + + /** + * Update analog controller as it was a mouse controller. + * @param inputIndex the index of the controller attached to the VR system. + * @param mouseListener the JMonkey mouse listener to trigger. + * @param mouseXName the mouseX identifier. + * @param mouseYName the mouseY identifier + * @param tpf the time per frame. + */ + public void updateAnalogAsMouse(int inputIndex, AnalogListener mouseListener, String mouseXName, String mouseYName, float tpf); + + /** + * Get the actual cursor position. + * @return the actual cursor position. + */ + public Vector2f getCursorPosition(); + + /** + * Center the mouse on the display. + */ + public void centerMouse(); + + /** + * Update the mouse manager. This method should not be called manually. + * The standard behavior for this method is to be called from the {@link VRViewManager#update(float) update method} of the attached {@link VRViewManager VR view manager}. + * @param tpf the time per frame. + */ + public void update(float tpf); +} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/VRTrackedController.java b/jme3-xr/src/main/java/com/jme3/input/vr/VRTrackedController.java new file mode 100644 index 0000000000..e5133d2e38 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/input/vr/VRTrackedController.java @@ -0,0 +1,48 @@ +package com.jme3.input.vr; + +import com.jme3.math.Matrix4f; +import com.jme3.math.Quaternion; +import com.jme3.math.Vector3f; + +/** + * TODO + * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr + */ +public interface VRTrackedController { + /** + * Get the controller name. + * @return the controller name. + */ + public String getControllerName(); + + /** + * Get the controller manufacturer. + * @return the controller manufacturer. + */ + public String getControllerManufacturer(); + + /** + * Get the position of the tracked device. This value is the translation component of the device {@link #getPose() pose}. + * @return the position of the tracked device. + * @see #getOrientation() + * @see #getPose() + */ + public Vector3f getPosition(); + + /** + * Get the orientation of the tracked device. This value is the rotation component of the device {@link #getPose() pose}. + * @return the orientation of the tracked device. + * @see #getPosition() + * @see #getPose() + */ + public Quaternion getOrientation(); + + /** + * Get the pose of the tracked device. + * The pose is a 4x4 matrix than combine the {@link #getPosition() position} and the {@link #getOrientation() orientation} of the device. + * @return the pose of the tracked device. + * @see #getPosition() + * @see #getOrientation() + */ + public Matrix4f getPose(); +} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/VRViewManager.java b/jme3-xr/src/main/java/com/jme3/input/vr/VRViewManager.java new file mode 100644 index 0000000000..87aaadff90 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/input/vr/VRViewManager.java @@ -0,0 +1,172 @@ +package com.jme3.input.vr; + +import com.jme3.app.VRAppState; +import com.jme3.app.VREnvironment; +import com.jme3.app.state.AppState; +import com.jme3.post.FilterPostProcessor; +import com.jme3.renderer.Camera; +import com.jme3.renderer.ViewPort; +import com.jme3.texture.Texture2D; + +/** + * A VR view manager. This interface describes methods that enable to submit 3D views to the VR compositor. + * @author reden - phr00t - https://github.com/phr00t + * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr + */ +public interface VRViewManager { + + /** + * The name of the left view. + */ + public final static String LEFT_VIEW_NAME = "Left View"; + + /** + * The name of the right view. + */ + public final static String RIGHT_VIEW_NAME = "Right View"; + + /** + * Get the {@link Camera camera} attached to the left eye. + * @return the {@link Camera camera} attached to the left eye. + * @see #getRightCamera() + */ + public Camera getLeftCamera(); + + /** + * Get the {@link Camera camera} attached to the right eye. + * @return the {@link Camera camera} attached to the right eye. + * @see #getLeftCamera() + */ + public Camera getRightCamera(); + + /** + * Get the {@link ViewPort viewport} attached to the left eye. + * @return the {@link ViewPort viewport} attached to the left eye. + * @see #getRightViewPort() + */ + public ViewPort getLeftViewPort(); + + + /** + * Get the {@link ViewPort viewport} attached to the right eye. + * @return the {@link ViewPort viewport} attached to the right eye. + * @see #getLeftViewPort() + */ + public ViewPort getRightViewPort(); + + /** + * Get the {@link ViewPort view port} attached to the mirror display. + * @return the view port attached to the mirror display. + * @see #getLeftViewPort() + * @see #getRightViewPort() + */ + public ViewPort getMirrorViewPort(); + + /** + * Get the texture attached to the left eye. + * @return the texture attached to the left eye. + * @see #getRightTexture() + */ + public Texture2D getLeftTexture(); + + /** + * Get the texture attached to the right eye. + * @return the texture attached to the right eye. + * @see #getLeftTexture() + */ + public Texture2D getRightTexture(); + + /** + * Get the depth texture attached to the left eye. + * @return the texture attached to the left eye. + * @see #getRightTexture() + */ + public Texture2D getLeftDepth(); + + /** + * Get the depth texture attached to the right eye. + * @return the texture attached to the right eye. + * @see #getLeftTexture() + */ + public Texture2D getRightDepth(); + + /** + * Get the {@link FilterPostProcessor filter post processor} attached to the left eye. + * @return the {@link FilterPostProcessor filter post processor} attached to the left eye. + * @see #getRightPostProcessor() + */ + public FilterPostProcessor getLeftPostProcessor(); + + /** + * Get the {@link FilterPostProcessor filter post processor} attached to the right eye. + * @return the {@link FilterPostProcessor filter post processor} attached to the right eye. + * @see #getLeftPostProcessor() + */ + public FilterPostProcessor getRightPostProcessor(); + + /** + * Get the resolution multiplier. + * @return the resolution multiplier. + * @see #setResolutionMultiplier(float) + */ + public float getResolutionMuliplier(); + + /** + * Set the resolution multiplier. + * @param resMult the resolution multiplier. + * @see #getResolutionMuliplier() + */ + public void setResolutionMultiplier(float resMult); + + /** + * Get the height adjustment to apply to the cameras before rendering. + * @return the height adjustment to apply to the cameras before rendering. + * @see #setHeightAdjustment(float) + */ + public float getHeightAdjustment(); + + /** + * Set the height adjustment to apply to the cameras before rendering. + * @param amount the height adjustment to apply to the cameras before rendering. + * @see #getHeightAdjustment() + */ + public void setHeightAdjustment(float amount); + + /** + * Get the {@link VREnvironment VR environment} to which the view manager is attached. + * @return the {@link VREnvironment VR environment} to which the view manager is attached. + */ + public VREnvironment getVREnvironment(); + + /** + * Initialize the VR view manager. This method should be called after the attachment of a {@link VREnvironment VR environment} to an application. + */ + public void initialize(); + + /** + * Update the VR view manager. + * This method is called by the attached {@link VRAppState app state} and should not be called manually. + * @param tpf the time per frame. + */ + public void update(float tpf); + + /** + * This method contains action to be done during the rendering phase. + * This method should be called for example from the {@link com.jme3.app.state.AppState#render(com.jme3.renderer.RenderManager) render} method of an {@link com.jme3.app.state.AppState app state}. + * @see #postRender() + */ + public void render(); + + /** + * Send the rendering result as textures to the two eyes. + * This method should be called after all the rendering operations + * (for example at the end of the {@link AppState#postRender() postRender()} method of the attached app state.) + * @see #render() + */ + public void postRender(); + + /** + * Handles moving filters from the main view to each eye. + */ + public void moveScreenProcessingToEyes(); +} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVR.java b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVR.java new file mode 100644 index 0000000000..30c4ec2c99 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVR.java @@ -0,0 +1,434 @@ +package com.jme3.input.vr.lwjgl_openvr; + +import com.jme3.app.VREnvironment; +import com.jme3.input.vr.HmdType; +import com.jme3.input.vr.VRAPI; +import com.jme3.math.Matrix4f; +import com.jme3.math.Quaternion; +import com.jme3.math.Vector2f; +import com.jme3.math.Vector3f; +import com.jme3.renderer.Camera; +import com.jme3.util.VRUtil; + +import java.nio.IntBuffer; +import java.util.Locale; +import java.util.logging.Level; +import java.util.logging.Logger; +import org.lwjgl.BufferUtils; +import org.lwjgl.openvr.*; + +/** + * A class that wraps an OpenVR system. + * @author reden - phr00t + * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr + * @author Rickard Edén + */ +public class LWJGLOpenVR implements VRAPI { + private static final Logger logger = Logger.getLogger(LWJGLOpenVR.class.getName()); + + private static boolean initSuccess = false; + private static boolean flipEyes = false; + + private IntBuffer hmdDisplayFrequency; + private TrackedDevicePose.Buffer trackedDevicePose; + protected TrackedDevicePose[] hmdTrackedDevicePoses; + + protected IntBuffer hmdErrorStore = BufferUtils.createIntBuffer(1); + + private final Quaternion rotStore = new Quaternion(); + private final Vector3f posStore = new Vector3f(); + + protected Matrix4f[] poseMatrices; + + private final Matrix4f hmdPose = Matrix4f.IDENTITY.clone(); + private Matrix4f hmdProjectionLeftEye; + private Matrix4f hmdProjectionRightEye; + private Matrix4f hmdPoseLeftEye; + private Matrix4f hmdPoseRightEye; + + private Vector3f hmdPoseLeftEyeVec, hmdPoseRightEyeVec, hmdSeatToStand; + + private LWJGLOpenVRInput VRinput; + + private VREnvironment environment = null; + + /** + * Convert specific OpenVR {@link org.lwjgl.openvr.HmdMatrix34 HmdMatrix34} into JME {@link Matrix4f Matrix4f} + * @param hmdMatrix the input matrix + * @param mat the converted matrix + * @return the converted matrix + */ + public static Matrix4f convertSteamVRMatrix3ToMatrix4f(org.lwjgl.openvr.HmdMatrix34 hmdMatrix, Matrix4f mat){ + mat.set(hmdMatrix.m(0), hmdMatrix.m(1), hmdMatrix.m(2), hmdMatrix.m(3), + hmdMatrix.m(4), hmdMatrix.m(5), hmdMatrix.m(6), hmdMatrix.m(7), + hmdMatrix.m(8), hmdMatrix.m(9), hmdMatrix.m(10), hmdMatrix.m(11), + 0f, 0f, 0f, 1f); + return mat; + } + + /** + * Convert specific OpenVR {@link org.lwjgl.openvr.HmdMatrix34 HmdMatrix34_t} into JME {@link Matrix4f Matrix4f} + * @param hmdMatrix the input matrix + * @param mat the converted matrix + * @return the converted matrix + */ + public static Matrix4f convertSteamVRMatrix4ToMatrix4f(org.lwjgl.openvr.HmdMatrix44 hmdMatrix, Matrix4f mat){ + mat.set(hmdMatrix.m(0), hmdMatrix.m(1), hmdMatrix.m(2), hmdMatrix.m(3), + hmdMatrix.m(4), hmdMatrix.m(5), hmdMatrix.m(6), hmdMatrix.m(7), + hmdMatrix.m(8), hmdMatrix.m(9), hmdMatrix.m(10), hmdMatrix.m(11), + hmdMatrix.m(12), hmdMatrix.m(13), hmdMatrix.m(14), hmdMatrix.m(15)); + return mat; + } + + /** + * Create a new OpenVR system + * attached to the given {@link VREnvironment VR environment}. + * @param environment the VR environment to which this API is attached. + */ + public LWJGLOpenVR(VREnvironment environment){ + this.environment = environment; + } + + @Override + public LWJGLOpenVRInput getVRinput() { + return VRinput; + } + + @Override + public Object getVRSystem() { + throw new UnsupportedOperationException("Not yet implemented!"); + } + + @Override + public Object getCompositor() { + throw new UnsupportedOperationException("Not yet implemented!"); + } + + @Override + public String getName() { + return "OpenVR/LWJGL"; + } + + @Override + public void setFlipEyes(boolean set) { + flipEyes = set; + } + + @Override + public void printLatencyInfoToConsole(boolean set) { + // not implemented + } + + @Override + public int getDisplayFrequency() { + if( hmdDisplayFrequency == null ) return 0; + return hmdDisplayFrequency.get(0); + } + + @Override + public boolean initialize() { + logger.config("Initializing OpenVR system..."); + + // Init the native linking to the OpenVR library. + + int result = VR.VR_InitInternal(hmdErrorStore, VR.EVRApplicationType_VRApplication_Scene); + + if(hmdErrorStore.get(0) != VR.EVRInitError_VRInitError_None) { + logger.severe("OpenVR Initialize Result: " + VR.VR_GetVRInitErrorAsEnglishDescription(hmdErrorStore.get(0))); + logger.severe("Initializing OpenVR system [FAILED]"); + return false; + } else { + logger.config("OpenVR initialized & VR connected."); + org.lwjgl.openvr.OpenVR.create(result); + logger.info("Model Number : " + VRSystem.VRSystem_GetStringTrackedDeviceProperty( + VR.k_unTrackedDeviceIndex_Hmd, VR.ETrackedDeviceProperty_Prop_ModelNumber_String, hmdErrorStore)); + logger.info("Serial Number: " + VRSystem.VRSystem_GetStringTrackedDeviceProperty( + VR.k_unTrackedDeviceIndex_Hmd, VR.ETrackedDeviceProperty_Prop_SerialNumber_String, hmdErrorStore)); + + hmdDisplayFrequency = BufferUtils.createIntBuffer(1); + hmdDisplayFrequency.put(VR.ETrackedDeviceProperty_Prop_DisplayFrequency_Float); + + trackedDevicePose = TrackedDevicePose.create(VR.k_unMaxTrackedDeviceCount); + hmdTrackedDevicePoses = new TrackedDevicePose[VR.k_unMaxTrackedDeviceCount]; + poseMatrices = new Matrix4f[VR.k_unMaxTrackedDeviceCount]; + for(int i=0;i 0){ + if(hmdErrorStore.get(0) == VR.EVRInitError_VRInitError_None){ + setTrackingSpace(environment.isSeatedExperience() ); + logger.config("OpenVR Compositor initialized"); + } else { + logger.severe("OpenVR Compositor error: " + hmdErrorStore.get(0)); + } + } else { + logger.log(Level.SEVERE, "Cannot get generic interface for \""+VR.IVRCompositor_Version+"\", "+VR.VR_GetVRInitErrorAsEnglishDescription(hmdErrorStore.get(0))+" ("+hmdErrorStore.get(0)+")"); + } + } + return true; + } + + /** + * Initialize the headset camera. + * @param allowed true is the use of the headset camera is allowed and false otherwise. + * @return token for camera + */ + public long initCamera(boolean allowed) { + hmdErrorStore.put(0, VR.EVRInitError_VRInitError_None); // clear the error store + if( allowed) { + long result = VR.VR_GetGenericInterface(VR.IVRTrackedCamera_Version, hmdErrorStore); + if (result > 0){ + if(hmdErrorStore.get(0) == VR.EVRInitError_VRInitError_None ){ + logger.config("OpenVR Camera initialized"); + } + return result; + } else { + logger.severe("Failed to initialize camera"); + } + } + return 0; + } + + @Override + public void destroy() { + VR.VR_ShutdownInternal(); + } + + @Override + public boolean isInitialized() { + return initSuccess; + } + + @Override + public void reset() { + VRChaperone.VRChaperone_ResetZeroPose(VR.ETrackingUniverseOrigin_TrackingUniverseSeated); + hmdSeatToStand = null; + } + + @Override + public void getRenderSize(Vector2f store) { + IntBuffer w = BufferUtils.createIntBuffer(1); + IntBuffer h = BufferUtils.createIntBuffer(1); + VRSystem.VRSystem_GetRecommendedRenderTargetSize(w, h); + logger.config("Recommended render width : " + w.get(0)); + logger.config("Recommended render height: " + h.get(0)); + store.x = w.get(0); + store.y = h.get(0); + } + + @Override + public float getInterpupillaryDistance() { + throw new UnsupportedOperationException("Not yet implemented!"); + } + + @Override + public Quaternion getOrientation() { + VRUtil.convertMatrix4toQuat(hmdPose, rotStore); + return rotStore; + } + + @Override + public Vector3f getPosition() { + // the hmdPose comes in rotated funny, fix that here + hmdPose.toTranslationVector(posStore); + posStore.x = -posStore.x; + posStore.z = -posStore.z; + return posStore; + } + + @Override + public void getPositionAndOrientation(Vector3f storePos, Quaternion storeRot) { + hmdPose.toTranslationVector(storePos); + storePos.x = -storePos.x; + storePos.z = -storePos.z; + storeRot.set(getOrientation()); + } + + @Override + public void updatePose(){ + int result = VRCompositor.nVRCompositor_WaitGetPoses(trackedDevicePose.address(), trackedDevicePose.remaining(), 0, 0); + // NPE when calling without a gamePoseArray. Issue filed with lwjgl #418 +// int result = VRCompositor.VRCompositor_WaitGetPoses(trackedDevicePose, null); + environment.getVRinput().updateControllerStates(); + + // read pose data from native + for (int nDevice = 0; nDevice < VR.k_unMaxTrackedDeviceCount; ++nDevice ){ + if( hmdTrackedDevicePoses[nDevice].bPoseIsValid() ){ + convertSteamVRMatrix3ToMatrix4f(hmdTrackedDevicePoses[nDevice].mDeviceToAbsoluteTracking(), poseMatrices[nDevice]); + } + } + + if ( hmdTrackedDevicePoses[VR.k_unTrackedDeviceIndex_Hmd].bPoseIsValid()){ + hmdPose.set(poseMatrices[VR.k_unTrackedDeviceIndex_Hmd]); + } else { + hmdPose.set(Matrix4f.IDENTITY); + } + } + + @Override + public Matrix4f getHMDMatrixProjectionLeftEye(Camera cam){ + if( hmdProjectionLeftEye != null ) { + return hmdProjectionLeftEye; + } else { + HmdMatrix44 mat = HmdMatrix44.create(); + mat = VRSystem.VRSystem_GetProjectionMatrix(VR.EVREye_Eye_Left, cam.getFrustumNear(), cam.getFrustumFar(), mat); + hmdProjectionLeftEye = new Matrix4f(); + convertSteamVRMatrix4ToMatrix4f(mat, hmdProjectionLeftEye); + return hmdProjectionLeftEye; + } + } + + @Override + public Matrix4f getHMDMatrixProjectionRightEye(Camera cam){ + if( hmdProjectionRightEye != null ) { + return hmdProjectionRightEye; + } else { + HmdMatrix44 mat = HmdMatrix44.create(); + mat = VRSystem.VRSystem_GetProjectionMatrix(VR.EVREye_Eye_Right, cam.getFrustumNear(), cam.getFrustumFar(), mat); + hmdProjectionRightEye = new Matrix4f(); + convertSteamVRMatrix4ToMatrix4f(mat, hmdProjectionRightEye); + return hmdProjectionRightEye; + } + } + + @Override + public Vector3f getHMDVectorPoseLeftEye() { + if( hmdPoseLeftEyeVec == null ) { + hmdPoseLeftEyeVec = getHMDMatrixPoseLeftEye().toTranslationVector(); + // set default IPD if none or broken + if( hmdPoseLeftEyeVec.x <= 0.080f * -0.5f || hmdPoseLeftEyeVec.x >= 0.040f * -0.5f ) { + hmdPoseLeftEyeVec.x = 0.065f * -0.5f; + } + if( flipEyes == false ) hmdPoseLeftEyeVec.x *= -1f; // it seems these need flipping + } + return hmdPoseLeftEyeVec; + } + + @Override + public Vector3f getHMDVectorPoseRightEye() { + if( hmdPoseRightEyeVec == null ) { + hmdPoseRightEyeVec = getHMDMatrixPoseRightEye().toTranslationVector(); + // set default IPD if none or broken + if( hmdPoseRightEyeVec.x >= 0.080f * 0.5f || hmdPoseRightEyeVec.x <= 0.040f * 0.5f ) { + hmdPoseRightEyeVec.x = 0.065f * 0.5f; + } + if( flipEyes == false ) hmdPoseRightEyeVec.x *= -1f; // it seems these need flipping + } + return hmdPoseRightEyeVec; + } + + @Override + public Vector3f getSeatedToAbsolutePosition() { + if( environment.isSeatedExperience() == false ) return Vector3f.ZERO; + if( hmdSeatToStand == null ) { + hmdSeatToStand = new Vector3f(); + + HmdMatrix34 mat = HmdMatrix34.create(); + VRSystem.VRSystem_GetSeatedZeroPoseToStandingAbsoluteTrackingPose(mat); + Matrix4f tempMatrix = new Matrix4f(); + convertSteamVRMatrix3ToMatrix4f(mat, tempMatrix); + tempMatrix.toTranslationVector(hmdSeatToStand); + } + return hmdSeatToStand; + } + + @Override + public Matrix4f getHMDMatrixPoseLeftEye(){ + if( hmdPoseLeftEye != null ) { + return hmdPoseLeftEye; + } else { + HmdMatrix34 mat = HmdMatrix34.create(); + VRSystem.VRSystem_GetEyeToHeadTransform(VR.EVREye_Eye_Left, mat); + hmdPoseLeftEye = new Matrix4f(); + return convertSteamVRMatrix3ToMatrix4f(mat, hmdPoseLeftEye); + } + } + + @Override + public Matrix4f getHMDMatrixPoseRightEye(){ + if( hmdPoseRightEye != null ) { + return hmdPoseRightEye; + } else { + HmdMatrix34 mat = HmdMatrix34.create(); + VRSystem.VRSystem_GetEyeToHeadTransform(VR.EVREye_Eye_Right, mat); + hmdPoseRightEye = new Matrix4f(); + return convertSteamVRMatrix3ToMatrix4f(mat, hmdPoseRightEye); + } + } + + @Override + public HmdType getType() { + String completeName = ""; + String name = VRSystem.VRSystem_GetStringTrackedDeviceProperty(VR.k_unTrackedDeviceIndex_Hmd, + VR.ETrackedDeviceProperty_Prop_ManufacturerName_String, + 128, hmdErrorStore); + if( hmdErrorStore.get(0) == 0 ) completeName += name; + String number = VRSystem.VRSystem_GetStringTrackedDeviceProperty(VR.k_unTrackedDeviceIndex_Hmd, + VR.ETrackedDeviceProperty_Prop_ModelNumber_String, + 128, hmdErrorStore); + if( hmdErrorStore.get(0) == 0 ) completeName += " " + number; + if( completeName.length() > 0 ) { + completeName = completeName.toLowerCase(Locale.ENGLISH).trim(); + if( completeName.contains("htc") || completeName.contains("vive") ) { + return HmdType.HTC_VIVE; + } else if ( completeName.contains("index") ) { + return HmdType.VALVE_INDEX; + } else if( completeName.contains("osvr") ) { + return HmdType.OSVR; + } else if( completeName.contains("oculus") || completeName.contains("rift") || + completeName.contains("dk1") || completeName.contains("dk2") || completeName.contains("cv1") ) { + return HmdType.OCULUS_RIFT; + } else if( completeName.contains("fove") ) { + return HmdType.FOVE; + } else if( completeName.contains("game") && completeName.contains("face") ) { + return HmdType.GAMEFACE; + } else if( completeName.contains("morpheus") ) { + return HmdType.MORPHEUS; + } else if( completeName.contains("gear") ) { + return HmdType.GEARVR; + } else if( completeName.contains("star") ) { + return HmdType.STARVR; + } else if( completeName.contains("null") ) { + return HmdType.NULL; + } + } + return HmdType.OTHER; + } + + public void setTrackingSpace(boolean isSeated){ + if( isSeated) { + VRCompositor.VRCompositor_SetTrackingSpace(VR.ETrackingUniverseOrigin_TrackingUniverseSeated); + } else { + VRCompositor.VRCompositor_SetTrackingSpace(VR.ETrackingUniverseOrigin_TrackingUniverseStanding); + } + } + + + public Matrix4f[] getPoseMatrices() { + return poseMatrices; + } +} \ No newline at end of file diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRAnalogActionData.java b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRAnalogActionData.java new file mode 100644 index 0000000000..aa702fc13a --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRAnalogActionData.java @@ -0,0 +1,34 @@ +package com.jme3.input.vr.lwjgl_openvr; + +import org.lwjgl.openvr.InputAnalogActionData; + +/** + * This is a set of reusable parts that are used when accessing an analogue action + * (Analogue meaning something like a trigger pull or joystick coordinate) + */ +public class LWJGLOpenVRAnalogActionData{ + + /** + * This is the address string for the action. It will be something like /actions/main/in/openInventory + */ + String actionName; + + /** + * The handle used to request the action's state from LWJGL. + * + * It is how the action is addressed efficiently + */ + long actionHandle; + + /** + * This is a LWJGL object that will have the actions state passed into it. It is mapped to native memory so we + * don't want to keep creating new ones. + */ + InputAnalogActionData actionData; + + public LWJGLOpenVRAnalogActionData(String actionName, long actionHandle, InputAnalogActionData actionData){ + this.actionName = actionName; + this.actionHandle = actionHandle; + this.actionData = actionData; + } +} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRBounds.java b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRBounds.java new file mode 100644 index 0000000000..cce7aec17b --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRBounds.java @@ -0,0 +1,50 @@ +package com.jme3.input.vr.lwjgl_openvr; + +import com.jme3.input.vr.VRAPI; +import com.jme3.input.vr.VRBounds; +import com.jme3.math.Vector2f; +import com.jme3.util.BufferUtils; +import java.nio.FloatBuffer; + +import java.util.logging.Logger; + +/** + * A class that represents VR world bounds. + * @author reden - phr00t - https://github.com/phr00t + * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr + * @author Rickard Edén + */ +public class LWJGLOpenVRBounds implements VRBounds { + private static Logger logger = Logger.getLogger(LWJGLOpenVRBounds.class.getName()); + + private Vector2f playSize; + private boolean setup = false; + + /** + * Initialize the VR bounds. + * @return true if the initialization is a success and false otherwise. + */ + public boolean init(VRAPI api) { + logger.config("Initialize VR bounds..."); + + if( !setup ) { +// vrChaperone = new VR_IVRChaperone_FnTable(JOpenVRLibrary.VR_GetGenericInterface(JOpenVRLibrary.IVRChaperone_Version, api.hmdErrorStore).getPointer()); + FloatBuffer fbX = BufferUtils.createFloatBuffer(1); + FloatBuffer fbZ = BufferUtils.createFloatBuffer(1); + org.lwjgl.openvr.VRChaperone.VRChaperone_GetPlayAreaSize(fbX, fbZ); + + playSize = new Vector2f(fbX.get(0), fbZ.get(0)); + setup = true; + logger.config("Initialize VR bounds [SUCCESS]"); + return true; // init success + } + + logger.config("Initialize VR bounds already done."); + return true; // already initialized + } + + @Override + public Vector2f getPlaySize() { + return playSize; + } +} \ No newline at end of file diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRDigitalActionData.java b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRDigitalActionData.java new file mode 100644 index 0000000000..75b1a100ed --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRDigitalActionData.java @@ -0,0 +1,34 @@ +package com.jme3.input.vr.lwjgl_openvr; + +import org.lwjgl.openvr.InputDigitalActionData; + +/** + * This is a set of reusable parts that are used when accessing a digital action + * (Digital meaning something like a button press, that is either on or off) + */ +public class LWJGLOpenVRDigitalActionData{ + + /** + * This is the address string for the action. It will be something like /actions/main/in/openInventory + */ + String actionName; + + /** + * The handle used to request the action's state from LWJGL. + * + * It is how the action is addressed efficiently + */ + long actionHandle; + + /** + * This is a LWJGL object that will have the actions state passed into it. It is mapped to native memory so we + * don't want to keep creating new ones. + */ + InputDigitalActionData actionData; + + public LWJGLOpenVRDigitalActionData(String actionName, long actionHandle, InputDigitalActionData actionData){ + this.actionName = actionName; + this.actionHandle = actionHandle; + this.actionData = actionData; + } +} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRInput.java b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRInput.java new file mode 100644 index 0000000000..04d5e9dd38 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRInput.java @@ -0,0 +1,703 @@ +package com.jme3.input.vr.lwjgl_openvr; + +import java.nio.LongBuffer; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.logging.Logger; + +import com.jme3.app.VREnvironment; +import com.jme3.input.vr.AnalogActionState; +import com.jme3.input.vr.DigitalActionState; +import com.jme3.input.vr.VRInputAPI; +import com.jme3.input.vr.VRInputType; +import com.jme3.input.vr.VRTrackedController; +import com.jme3.input.vr.VRViewManager; +import com.jme3.math.Quaternion; +import com.jme3.math.Vector2f; +import com.jme3.math.Vector3f; +import com.jme3.renderer.Camera; +import com.jme3.scene.Spatial; +import com.jme3.util.VRUtil; +import java.nio.IntBuffer; +import org.lwjgl.BufferUtils; +import org.lwjgl.openvr.HmdVector3; +import org.lwjgl.openvr.InputAnalogActionData; +import org.lwjgl.openvr.InputDigitalActionData; +import org.lwjgl.openvr.VR; +import org.lwjgl.openvr.VRActiveActionSet; +import org.lwjgl.openvr.VRControllerState; +import org.lwjgl.openvr.VRInput; +import org.lwjgl.openvr.VRSystem; + +/* +make helper functions to pull the following easily from raw data (DONE) +trigger: +Controller#1, Axis#0 X: 0.0, Y: 0.0 +Controller#1, Axis#1 X: 1.0, Y: 0.0 +Controller#1, Axis#2 X: 0.0, Y: 0.0 +Controller#1, Axis#3 X: 0.0, Y: 0.0 +Controller#1, Axis#4 X: 0.0, Y: 0.0 +Button press: 8589934592 (when full), touch: 8589934592 +touchpad (upper left): +Controller#1, Axis#0 X: -0.6059755, Y: 0.2301706 +Controller#1, Axis#1 X: 0.0, Y: 0.0 +Controller#1, Axis#2 X: 0.0, Y: 0.0 +Controller#1, Axis#3 X: 0.0, Y: 0.0 +Controller#1, Axis#4 X: 0.0, Y: 0.0 +Button press: 4294967296 (when pressed in), touch: 4294967296 +grip: +Controller#1, Axis#0 X: 0.0, Y: 0.0 +Controller#1, Axis#1 X: 0.0, Y: 0.0 +Controller#1, Axis#2 X: 0.0, Y: 0.0 +Controller#1, Axis#3 X: 0.0, Y: 0.0 +Controller#1, Axis#4 X: 0.0, Y: 0.0 +Button press: 4, touch: 4 +thumb: +Controller#1, Axis#0 X: 0.0, Y: 0.0 +Controller#1, Axis#1 X: 0.0, Y: 0.0 +Controller#1, Axis#2 X: 0.0, Y: 0.0 +Controller#1, Axis#3 X: 0.0, Y: 0.0 +Controller#1, Axis#4 X: 0.0, Y: 0.0 +Button press: 2, touch: 2 + */ +/** + * A class that wraps an + * OpenVR + * input.
+ * null values will be returned if no valid pose exists, or that + * input device isn't available user code should check for null + * values. + * + * @author reden - phr00t + * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr + * @author Rickard Edén + */ +public class LWJGLOpenVRInput implements VRInputAPI { + + private static final Logger logger = Logger.getLogger(LWJGLOpenVRInput.class.getName()); + + /** + * Deprecated as used controller specific values. Should use Actions manifest instead + */ + @Deprecated + private final VRControllerState[] cStates = new VRControllerState[VR.k_unMaxTrackedDeviceCount]; + + private final Quaternion[] rotStore = new Quaternion[VR.k_unMaxTrackedDeviceCount]; + + private final Vector3f[] posStore = new Vector3f[VR.k_unMaxTrackedDeviceCount]; + + private static final int[] controllerIndex = new int[VR.k_unMaxTrackedDeviceCount]; + + private int controllerCount = 0; + + private final Vector2f tempAxis = new Vector2f(), temp2Axis = new Vector2f(); + + private final Vector2f[] lastCallAxis = new Vector2f[VR.k_unMaxTrackedDeviceCount]; + + /** + * Deprecated as used controller specific values. Should use Actions manifest instead + */ + @Deprecated + private final boolean[][] buttonDown = new boolean[VR.k_unMaxTrackedDeviceCount][16]; + + /** + * A map of the action name to the objects/data required to read states from lwjgl + */ + private final Map digitalActions = new HashMap<>(); + + /** + * A map of the action name to the objects/data required to read states from lwjgl + */ + private final Map analogActions = new HashMap<>(); + + /** + * A map of the action name to the handle of a haptic action + */ + private final Map hapticActionHandles = new HashMap<>(); + + /** + * A map of the action set name to the handle that is used to refer to it when talking to LWJGL + */ + private final Map actionSetHandles = new HashMap<>(); + + /** + * A map of input names (e.g. /user/hand/right) to the handle used to address it. + * + * Note that null is a special case that maps to VR.k_ulInvalidInputValueHandle and means "any input" + */ + private final Map inputHandles = new HashMap<>(); + + private float axisMultiplier = 1f; + + private final Vector3f tempVel = new Vector3f(); + + private final Quaternion tempq = new Quaternion(); + + private final VREnvironment environment; + + private List trackedControllers = null; + + /** + * A lwjgl object that contains handles to the active action sets (is used each frame to tell lwjgl which actions to + * fetch states back for) + */ + private VRActiveActionSet.Buffer activeActionSets; + + InputMode inputMode = InputMode.LEGACY; + + private enum InputMode{ + /** + * Simple bitfield, no way to map new controllers + */ + LEGACY, + /** + * Actions manifest based. + */ + ACTION_BASED; + } + + /** + * Create a new + * OpenVR + * input attached to the given VR environment. + * + * @param environment the VR environment to which the input is attached. + */ + public LWJGLOpenVRInput(VREnvironment environment) { + this.environment = environment; + + inputHandles.put(null, VR.k_ulInvalidInputValueHandle); + } + + @Override + public void registerActionManifest(String actionManifestAbsolutePath, String startingActiveActionSets){ + inputMode = InputMode.ACTION_BASED; + int errorCode = VRInput.VRInput_SetActionManifestPath(actionManifestAbsolutePath); + + if ( errorCode != 0 ) + { + logger.warning( "An error code of " + errorCode + " was reported while registering an action manifest" ); + } + setActiveActionSet(startingActiveActionSets); + } + + @Override + public void setActiveActionSet(String actionSet){ + assert inputMode == InputMode.ACTION_BASED : "registerActionManifest must be called before attempting to fetch action states"; + + + long actionSetHandle; + if (actionSetHandles.containsKey(actionSet)){ + actionSetHandle = actionSetHandles.get(actionSet); + }else{ + LongBuffer longBuffer = BufferUtils.createLongBuffer(1); + int errorCode = VRInput.VRInput_GetActionHandle(actionSet, longBuffer); + if ( errorCode != 0 ) + { + logger.warning( "An error code of " + errorCode + " was reported while fetching an action set handle for " + actionSet ); + } + actionSetHandle = longBuffer.get(0); + actionSetHandles.put(actionSet,actionSetHandle); + } + + //Todo: this seems to imply that you could have multiple active action sets at once (Although I was not able to get that to work), allow multiple action sets + activeActionSets = VRActiveActionSet.create(1); + activeActionSets.ulActionSet(actionSetHandle); + activeActionSets.ulRestrictedToDevice(VR.k_ulInvalidInputValueHandle); // both hands + } + + @Override + public DigitalActionState getDigitalActionState(String actionName, String restrictToInput){ + assert inputMode == InputMode.ACTION_BASED : "registerActionManifest must be called before attempting to fetch action states"; + + LWJGLOpenVRDigitalActionData actionDataObjects = digitalActions.get(actionName); + if (actionDataObjects == null){ + //this is the first time the action has been used. We must obtain a handle to it to efficiently fetch it in future + long handle = fetchActionHandle(actionName); + actionDataObjects = new LWJGLOpenVRDigitalActionData(actionName, handle, InputDigitalActionData.create()); + digitalActions.put(actionName, actionDataObjects); + } + int errorCode = VRInput.VRInput_GetDigitalActionData(actionDataObjects.actionHandle, actionDataObjects.actionData, getOrFetchInputHandle(restrictToInput)); + + if (errorCode == VR.EVRInputError_VRInputError_WrongType){ + throw new RuntimeException("Attempted to fetch a non-digital state as if it is digital"); + }else if (errorCode!=0){ + logger.warning( "An error code of " + errorCode + " was reported while fetching an action state for " + actionName ); + } + + return new DigitalActionState(actionDataObjects.actionData.bState(), actionDataObjects.actionData.bChanged()); + } + + @Override + public AnalogActionState getAnalogActionState(String actionName, String restrictToInput ){ + assert inputMode == InputMode.ACTION_BASED : "registerActionManifest must be called before attempting to fetch action states"; + + LWJGLOpenVRAnalogActionData actionDataObjects = analogActions.get(actionName); + if (actionDataObjects == null){ + //this is the first time the action has been used. We must obtain a handle to it to efficiently fetch it in future + long handle = fetchActionHandle(actionName); + actionDataObjects = new LWJGLOpenVRAnalogActionData(actionName, handle, InputAnalogActionData.create()); + analogActions.put(actionName, actionDataObjects); + } + int errorCode = VRInput.VRInput_GetAnalogActionData(actionDataObjects.actionHandle, actionDataObjects.actionData, getOrFetchInputHandle(restrictToInput)); + + if (errorCode == VR.EVRInputError_VRInputError_WrongType){ + throw new RuntimeException("Attempted to fetch a non-analog state as if it is analog"); + }else if (errorCode!=0){ + logger.warning( "An error code of " + errorCode + " was reported while fetching an action state for " + actionName ); + } + + return new AnalogActionState(actionDataObjects.actionData.x(), actionDataObjects.actionData.y(), actionDataObjects.actionData.z(), actionDataObjects.actionData.deltaX(), actionDataObjects.actionData.deltaY(), actionDataObjects.actionData.deltaZ()); + } + + @Override + public float getAxisMultiplier() { + return axisMultiplier; + } + + @Override + public void setAxisMultiplier(float set) { + axisMultiplier = set; + } + + @Override + public void swapHands() { + if (controllerCount != 2) { + return; + } + int temp = controllerIndex[0]; + controllerIndex[0] = controllerIndex[1]; + controllerIndex[1] = temp; + } + + @Override + public boolean isButtonDown(int controllerIndex, VRInputType checkButton) { + assert inputMode != InputMode.ACTION_BASED : "registerActionManifest has been called, legacy button access disabled"; + VRControllerState cs = cStates[LWJGLOpenVRInput.controllerIndex[controllerIndex]]; + switch (checkButton) { + default: + return false; + case ViveGripButton: + return (cs.ulButtonPressed() & 4) != 0; + case ViveMenuButton: + return (cs.ulButtonPressed() & 2) != 0; + case ViveTrackpadAxis: + return (cs.ulButtonPressed() & 4294967296l) != 0; + case ViveTriggerAxis: + return (cs.ulButtonPressed() & 8589934592l) != 0; + } + } + + @Override + public boolean wasButtonPressedSinceLastCall(int controllerIndex, VRInputType checkButton) { + boolean buttonDownNow = isButtonDown(controllerIndex, checkButton); + int checkButtonValue = checkButton.getValue(); + int cIndex = LWJGLOpenVRInput.controllerIndex[controllerIndex]; + boolean retval = buttonDownNow == true && buttonDown[cIndex][checkButtonValue] == false; + buttonDown[cIndex][checkButtonValue] = buttonDownNow; + return retval; + } + + @Override + public void resetInputSinceLastCall() { + for (int i = 0; i < lastCallAxis.length; i++) { + lastCallAxis[i].x = 0f; + lastCallAxis[i].y = 0f; + } + for (int i = 0; i < VR.k_unMaxTrackedDeviceCount; i++) { + for (int j = 0; j < 16; j++) { + buttonDown[i][j] = false; + } + } + } + + @Override + public Vector2f getAxisDeltaSinceLastCall(int controllerIndex, VRInputType forAxis) { + int axisIndex = forAxis.getValue(); + temp2Axis.set(lastCallAxis[axisIndex]); + lastCallAxis[axisIndex].set(getAxis(controllerIndex, forAxis)); + if ((temp2Axis.x != 0f || temp2Axis.y != 0f) && (lastCallAxis[axisIndex].x != 0f || lastCallAxis[axisIndex].y != 0f)) { + temp2Axis.subtractLocal(lastCallAxis[axisIndex]); + } else { + // move made from rest, don't count as a delta move + temp2Axis.x = 0f; + temp2Axis.y = 0f; + } + return temp2Axis; + } + + @Override + public Vector3f getVelocity(int controllerIndex) { + + if (environment != null) { + + if (environment.getVRHardware() instanceof LWJGLOpenVR) { + int index = LWJGLOpenVRInput.controllerIndex[controllerIndex]; +// if( needsNewVelocity[index] ) { + HmdVector3 tempVec = ((LWJGLOpenVR) environment.getVRHardware()).hmdTrackedDevicePoses[index].vVelocity(); +// needsNewVelocity[index] = false; +// } + tempVel.x = tempVec.v(0); + tempVel.y = tempVec.v(1); + tempVel.z = tempVec.v(2); + return tempVel; + } else { + throw new IllegalStateException("VR hardware " + environment.getVRHardware().getClass().getSimpleName() + " is not a subclass of " + LWJGLOpenVR.class.getSimpleName()); + } + } else { + throw new IllegalStateException("VR input is not attached to a VR environment."); + } + } + + @Override + public Vector3f getAngularVelocity(int controllerIndex) { + + if (environment != null) { + + if (environment.getVRHardware() instanceof LWJGLOpenVR) { + + int index = LWJGLOpenVRInput.controllerIndex[controllerIndex]; + HmdVector3 tempVec = ((LWJGLOpenVR) environment.getVRHardware()).hmdTrackedDevicePoses[index].vAngularVelocity(); +// needsNewVelocity[index] = false; +// } + tempVel.x = tempVec.v(0); + tempVel.y = tempVec.v(1); + tempVel.z = tempVec.v(2); + return tempVel; + } else { + throw new IllegalStateException("VR hardware " + environment.getVRHardware().getClass().getSimpleName() + " is not a subclass of " + LWJGLOpenVR.class.getSimpleName()); + } + } else { + throw new IllegalStateException("VR input is not attached to a VR environment."); + } + + } + + @Override + public Vector2f getAxisRaw(int controllerIndex, VRInputType forAxis) { + VRControllerState cs = cStates[LWJGLOpenVRInput.controllerIndex[controllerIndex]]; + switch (forAxis) { + default: + return null; + case ViveTriggerAxis: + tempAxis.x = cs.rAxis(1).x(); + tempAxis.y = tempAxis.x; + break; + case ViveTrackpadAxis: + tempAxis.x = cs.rAxis(0).x(); + tempAxis.y = cs.rAxis(0).y(); + break; + } + return tempAxis; + } + + @Override + public Vector2f getAxis(int controllerIndex, VRInputType forAxis) { + getAxisRaw(controllerIndex, forAxis); + tempAxis.x *= axisMultiplier; + tempAxis.y *= axisMultiplier; + return tempAxis; + } + + @Override + public boolean init() { + + logger.config("Initialize OpenVR input."); + + for (int i = 0; i < VR.k_unMaxTrackedDeviceCount; i++) { + rotStore[i] = new Quaternion(); + posStore[i] = new Vector3f(); + cStates[i] = VRControllerState.create(); + lastCallAxis[i] = new Vector2f(); + logger.config(" Input " + (i + 1) + "/" + VR.k_unMaxTrackedDeviceCount + " bound."); + } + + return true; + } + + @Override + public VRTrackedController getTrackedController(int index) { + if (trackedControllers != null) { + if ((trackedControllers.size() > 0) && (index < trackedControllers.size())) { + return trackedControllers.get(index); + } + } + + return null; + } + + @Override + public int getTrackedControllerCount() { + return controllerCount; + } + + @Override + public VRControllerState getRawControllerState(int index) { + if (isInputDeviceTracking(index) == false) { + return null; + } + return cStates[controllerIndex[index]]; + } + + @Override + public boolean isInputFocused() { + if (environment != null){ + // not a 100% match, but the closest I can find in LWJGL. Doc seems to confirm this too. + return VRSystem.VRSystem_IsInputAvailable(); + //return ((VR_IVRSystem_FnTable)environment.getVRHardware().getVRSystem()).IsInputFocusCapturedByAnotherProcess.apply() == 0; + } else { + throw new IllegalStateException("VR input is not attached to a VR environment."); + } + } + + @Override + public boolean isInputDeviceTracking(int index) { + if (index < 0 || index >= controllerCount) { + return false; + } + + if (environment != null) { + + if (environment.getVRHardware() instanceof LWJGLOpenVR) { + return ((LWJGLOpenVR) environment.getVRHardware()).hmdTrackedDevicePoses[controllerIndex[index]].bPoseIsValid(); + } else { + throw new IllegalStateException("VR hardware " + environment.getVRHardware().getClass().getSimpleName() + " is not a subclass of " + LWJGLOpenVR.class.getSimpleName()); + } + } else { + throw new IllegalStateException("VR input is not attached to a VR environment."); + } + } + + @Override + public Quaternion getOrientation(int index) { + if (isInputDeviceTracking(index) == false) { + return null; + } + + if (environment != null) { + + if (environment.getVRHardware() instanceof LWJGLOpenVR) { + index = controllerIndex[index]; + VRUtil.convertMatrix4toQuat(((LWJGLOpenVR) environment.getVRHardware()).poseMatrices[index], rotStore[index]); + return rotStore[index]; + } else { + throw new IllegalStateException("VR hardware " + environment.getVRHardware().getClass().getSimpleName() + " is not a subclass of " + LWJGLOpenVR.class.getSimpleName()); + } + } else { + throw new IllegalStateException("VR input is not attached to a VR environment."); + } + } + + @Override + public Vector3f getPosition(int index) { + if (isInputDeviceTracking(index) == false) { + return null; + } + + if (environment != null) { + + if (environment.getVRHardware() instanceof LWJGLOpenVR) { + // the hmdPose comes in rotated funny, fix that here + index = controllerIndex[index]; + ((LWJGLOpenVR) environment.getVRHardware()).poseMatrices[index].toTranslationVector(posStore[index]); + posStore[index].x = -posStore[index].x; + posStore[index].z = -posStore[index].z; + return posStore[index]; + } else { + throw new IllegalStateException("VR hardware " + environment.getVRHardware().getClass().getSimpleName() + " is not a subclass of " + LWJGLOpenVR.class.getSimpleName()); + } + } else { + throw new IllegalStateException("VR input is not attached to a VR environment."); + } + + } + + @Override + public Quaternion getFinalObserverRotation(int index) { + + if (environment != null) { + VRViewManager vrvm = environment.getVRViewManager(); + + if (vrvm != null) { + if (isInputDeviceTracking(index) == false) { + return null; + } + + Object obs = environment.getObserver(); + if (obs instanceof Camera) { + tempq.set(((Camera) obs).getRotation()); + } else { + tempq.set(((Spatial) obs).getWorldRotation()); + } + + return tempq.multLocal(getOrientation(index)); + } else { + throw new IllegalStateException("VR environment has no valid view manager."); + } + + } else { + throw new IllegalStateException("VR input is not attached to a VR environment."); + } + } + + @Override + public Vector3f getFinalObserverPosition(int index) { + + if (environment != null) { + VRViewManager vrvm = environment.getVRViewManager(); + + if (vrvm != null) { + if (isInputDeviceTracking(index) == false) { + return null; + } + Object obs = environment.getObserver(); + Vector3f pos = getPosition(index); + if (obs instanceof Camera) { + ((Camera) obs).getRotation().mult(pos, pos); + return pos.addLocal(((Camera) obs).getLocation()); + } else { + ((Spatial) obs).getWorldRotation().mult(pos, pos); + return pos.addLocal(((Spatial) obs).getWorldTranslation()); + } + } else { + throw new IllegalStateException("VR environment has no valid view manager."); + } + + } else { + throw new IllegalStateException("VR input is not attached to a VR environment."); + } + } + + @Override + public void triggerHapticPulse(int controllerIndex, float seconds) { + if (environment.isInVR() == false || isInputDeviceTracking(controllerIndex) == false) { + return; + } + + // apparently only axis ID of 0 works + VRSystem.VRSystem_TriggerHapticPulse(LWJGLOpenVRInput.controllerIndex[controllerIndex], + 0, (short) Math.round(3f * seconds / 1e-3f)); + } + + @Override + public void triggerHapticAction(String actionName, float duration, float frequency, float amplitude, String restrictToInput ){ + long hapticActionHandle; + if (!hapticActionHandles.containsKey(actionName)){ + //this is the first time the action has been used. We must obtain a handle to it to efficiently fetch it in future + hapticActionHandle = fetchActionHandle(actionName); + hapticActionHandles.put(actionName, hapticActionHandle); + }else{ + hapticActionHandle = hapticActionHandles.get(actionName); + } + + VRInput.VRInput_TriggerHapticVibrationAction(hapticActionHandle, 0, duration, frequency, amplitude, getOrFetchInputHandle(restrictToInput)); + } + + @Override + public void updateConnectedControllers() { + logger.config("Updating connected controllers."); + + if (environment != null) { + controllerCount = 0; + for (int i = 0; i < VR.k_unMaxTrackedDeviceCount; i++) { + int classCallback = VRSystem.VRSystem_GetTrackedDeviceClass(i); + if (classCallback == VR.ETrackedDeviceClass_TrackedDeviceClass_Controller || classCallback == VR.ETrackedDeviceClass_TrackedDeviceClass_GenericTracker) { + IntBuffer error = BufferUtils.createIntBuffer(1); + String controllerName = "Unknown"; + String manufacturerName = "Unknown"; + controllerName = VRSystem.VRSystem_GetStringTrackedDeviceProperty(i, VR.ETrackedDeviceProperty_Prop_TrackingSystemName_String, error); + manufacturerName = VRSystem.VRSystem_GetStringTrackedDeviceProperty(i, VR.ETrackedDeviceProperty_Prop_ManufacturerName_String, error); + + if (error.get(0) != 0) { + logger.warning("Error getting controller information " + controllerName + " " + manufacturerName + "Code (" + error.get(0) + ")"); + } + controllerIndex[controllerCount] = i; + + // Adding tracked controller to control. + if (trackedControllers == null) { + trackedControllers = new ArrayList(VR.k_unMaxTrackedDeviceCount); + } + trackedControllers.add(new LWJGLOpenVRTrackedController(i, this, controllerName, manufacturerName, environment)); + + // Send a Haptic pulse to the controller + triggerHapticPulse(controllerCount, 1.0f); + + controllerCount++; + logger.config(" Tracked controller " + (i + 1) + "/" + VR.k_unMaxTrackedDeviceCount + " " + controllerName + " (" + manufacturerName + ") attached."); + } else { + logger.config(" Controller " + (i + 1) + "/" + VR.k_unMaxTrackedDeviceCount + " ignored."); + } + } + } else { + throw new IllegalStateException("VR input is not attached to a VR environment."); + } + } + + @Override + public void updateControllerStates() { + + if (environment != null) { + switch(inputMode){ + case ACTION_BASED: + int errorCode = VRInput.VRInput_UpdateActionState(activeActionSets, VRActiveActionSet.SIZEOF); + if(errorCode!=0){ + logger.warning("An error code of " + errorCode + " was returned while upding the action states"); + } + break; + case LEGACY: + for (int i = 0; i < controllerCount; i++) { + int index = controllerIndex[i]; + VRSystem.VRSystem_GetControllerState(index, cStates[index], 64); + cStates[index].ulButtonPressed(); + cStates[index].rAxis(); + } + break; + } + + } else { + throw new IllegalStateException("VR input is not attached to a VR environment."); + } + + } + + /** + * Converts an action name (as it appears in the action manifest) to a handle (long) that the rest of the + * lwjgl (and openVR) wants to talk in + * @param actionName The name of the action. Will be something like /actions/main/in/openInventory + * @return a long that is the handle that can be used to refer to the action + */ + private long fetchActionHandle( String actionName ){ + LongBuffer longBuffer = BufferUtils.createLongBuffer(1); + int errorCode = VRInput.VRInput_GetActionHandle(actionName, longBuffer); + if (errorCode !=0 ){ + logger.warning( "An error code of " + errorCode + " was reported while registering an action manifest" ); + } + return longBuffer.get(0); + } + + /** + * Given an input name returns the handle to address it. + * + * If a cached handle is available it is returned, if not it is fetched from openVr + * + * @param inputName the input name, e.g. /user/hand/right. Or null, which means "any input" + * @return the input handle + */ + public long getOrFetchInputHandle( String inputName ){ + if(!inputHandles.containsKey(inputName)){ + LongBuffer longBuffer = BufferUtils.createLongBuffer(1); + + int errorCode = VRInput.VRInput_GetInputSourceHandle(inputName, longBuffer); + if (errorCode !=0 ){ + logger.warning( "An error code of " + errorCode + " was reported while fetching an input manifest" ); + } + long handle = longBuffer.get(0); + inputHandles.put(inputName, handle); + } + + return inputHandles.get(inputName); + } + +} \ No newline at end of file diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRMouseManager.java b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRMouseManager.java new file mode 100644 index 0000000000..a21b2e3052 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRMouseManager.java @@ -0,0 +1,107 @@ +package com.jme3.input.vr.lwjgl_openvr; + +import com.jme3.app.VREnvironment; +import com.jme3.input.controls.AnalogListener; +import com.jme3.input.vr.AbstractVRMouseManager; +import com.jme3.input.vr.VRInputType; +import com.jme3.math.Vector2f; + + +/** + * A class dedicated to the handling of the mouse within VR environment. + * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr + */ +public class LWJGLOpenVRMouseManager extends AbstractVRMouseManager { + private final int AVERAGE_AMNT = 4; + + private int avgCounter; + + private final float[] lastXmv = new float[AVERAGE_AMNT]; + + private final float[] lastYmv = new float[AVERAGE_AMNT]; + + /** + * Create a new VR mouse manager within the given {@link VREnvironment VR environment}. + * @param environment the VR environment of the mouse manager. + */ + public LWJGLOpenVRMouseManager(VREnvironment environment){ + super(environment); + } + + + @Override + public void updateAnalogAsMouse(int inputIndex, AnalogListener mouseListener, String mouseXName, String mouseYName, float tpf) { + if (getVREnvironment() != null){ + if (getVREnvironment().getApplication() != null){ + // got a tracked controller to use as the "mouse" + if( getVREnvironment().isInVR() == false || + getVREnvironment().getVRinput() == null || + getVREnvironment().getVRinput().isInputDeviceTracking(inputIndex) == false ){ + return; + } + + Vector2f tpDelta; + // TODO option to use Touch joysticks + if( isThumbstickMode() ) { + tpDelta = getVREnvironment().getVRinput().getAxis(inputIndex, VRInputType.ViveTrackpadAxis); + } else { + tpDelta = getVREnvironment().getVRinput().getAxisDeltaSinceLastCall(inputIndex, VRInputType.ViveTrackpadAxis); + } + + float xAmount = (float)Math.pow(Math.abs(tpDelta.x) * getSpeedSensitivity(), getSpeedAcceleration()); + float yAmount = (float)Math.pow(Math.abs(tpDelta.y) * getSpeedSensitivity(), getSpeedAcceleration()); + + if( tpDelta.x < 0f ){ + xAmount = -xAmount; + } + + if( tpDelta.y < 0f ){ + yAmount = -yAmount; + } + + xAmount *= getMouseMoveScale(); + yAmount *= getMouseMoveScale(); + + if( mouseListener != null ) { + if( tpDelta.x != 0f && mouseXName != null ) mouseListener.onAnalog(mouseXName, xAmount * 0.2f, tpf); + if( tpDelta.y != 0f && mouseYName != null ) mouseListener.onAnalog(mouseYName, yAmount * 0.2f, tpf); + } + + if( getVREnvironment().getApplication().getInputManager().isCursorVisible() ) { + int index = (avgCounter+1) % AVERAGE_AMNT; + lastXmv[index] = xAmount * 133f; + lastYmv[index] = yAmount * 133f; + cursorPos.x -= avg(lastXmv); + cursorPos.y -= avg(lastYmv); + Vector2f maxsize = getVREnvironment().getVRGUIManager().getCanvasSize(); + + if( cursorPos.x > maxsize.x ){ + cursorPos.x = maxsize.x; + } + + if( cursorPos.x < 0f ){ + cursorPos.x = 0f; + } + + if( cursorPos.y > maxsize.y ){ + cursorPos.y = maxsize.y; + } + + if( cursorPos.y < 0f ){ + cursorPos.y = 0f; + } + } + } else { + throw new IllegalStateException("This VR environment is not attached to any application."); + } + } else { + throw new IllegalStateException("This VR view manager is not attached to any VR environment."); + } + } + + private float avg(float[] arr) { + float amt = 0f; + for(float f : arr) amt += f; + return amt / arr.length; + } +} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRTrackedController.java b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRTrackedController.java new file mode 100644 index 0000000000..c0705f0864 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRTrackedController.java @@ -0,0 +1,96 @@ +package com.jme3.input.vr.lwjgl_openvr; + +import com.jme3.app.VREnvironment; +import com.jme3.input.vr.VRInputAPI; +import com.jme3.input.vr.VRTrackedController; +import com.jme3.math.Matrix4f; +import com.jme3.math.Quaternion; +import com.jme3.math.Vector3f; + +/** + * A controller that is tracked within the VR environment. Such a controller can provide its position within the VR space. + * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr + * @author Rickard Edén + */ +public class LWJGLOpenVRTrackedController implements VRTrackedController{ + /** + * The index of the controller within the underlying VR API. + */ + private int controllerIndex = -1; + + /** + * The underlying VRAPI. + */ + private VRInputAPI hardware = null; + + /** + * The name of the controller. + */ + private String name; + + private VREnvironment environment; + + /** + * Wrap a new VR tracked controller on an OpenVR system. + * @param controllerIndex the index of the controller within the underlying VR system. + * @param hardware the underlying VR system. + * @param name the name of the controller. + * @param manufacturer the manufacturer of the controller. + * @param environment the VR environment. + */ + public LWJGLOpenVRTrackedController(int controllerIndex, VRInputAPI hardware, String name, String manufacturer, VREnvironment environment){ + this.controllerIndex = controllerIndex; + this.hardware = hardware; + + this.name = name; + this.manufacturer = manufacturer; + + this.environment = environment; + } + + /** + * The manufacturer of the controller. + */ + private String manufacturer; + + @Override + public Vector3f getPosition() { + if (hardware != null){ + return hardware.getPosition(controllerIndex); + } else { + throw new IllegalStateException("No underlying VR API."); + } + } + + @Override + public Quaternion getOrientation() { + if (hardware != null){ + return hardware.getOrientation(controllerIndex); + } else { + throw new IllegalStateException("No underlying VR API."); + } + } + + @Override + public Matrix4f getPose(){ + if (environment != null){ + if (hardware != null){ + return ((LWJGLOpenVR)environment.getVRHardware()).getPoseMatrices()[controllerIndex]; + } else { + throw new IllegalStateException("No underlying VR API."); + } + } else { + throw new IllegalStateException("VR tracked device is not attached to any environment."); + } + } + + @Override + public String getControllerName() { + return name; + } + + @Override + public String getControllerManufacturer() { + return manufacturer; + } +} \ No newline at end of file diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRViewManager.java b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRViewManager.java new file mode 100644 index 0000000000..2b658e53f4 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRViewManager.java @@ -0,0 +1,569 @@ +package com.jme3.input.vr.lwjgl_openvr; + +import com.jme3.app.VREnvironment; +import com.jme3.input.vr.AbstractVRViewManager; +import com.jme3.input.vr.VRAPI; +import com.jme3.math.ColorRGBA; +import com.jme3.math.Quaternion; +import com.jme3.math.Vector2f; +import com.jme3.math.Vector3f; +import com.jme3.renderer.Camera; +import com.jme3.renderer.ViewPort; +import com.jme3.renderer.queue.RenderQueue.Bucket; +import com.jme3.scene.Spatial; +import com.jme3.texture.FrameBuffer; +import com.jme3.texture.Image; +import com.jme3.texture.Texture2D; +import com.jme3.ui.Picture; +import com.jme3.util.VRGUIPositioningMode; + +import java.util.Iterator; +import java.util.logging.Logger; +import org.lwjgl.openvr.VRTextureBounds; +import org.lwjgl.openvr.Texture; +import org.lwjgl.openvr.VR; +import org.lwjgl.openvr.VRCompositor; + +/** + * A VR view manager based on OpenVR. This class enable to submit 3D views to + * the VR compositor. + * + * @author reden - phr00t + * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr + * @author Rickard Edén + */ +public class LWJGLOpenVRViewManager extends AbstractVRViewManager { + + private static final Logger logger = Logger.getLogger(LWJGLOpenVRViewManager.class.getName()); + + // OpenVR values + private VRTextureBounds leftTextureBounds; + private Texture leftTextureType; + + private VRTextureBounds rightTextureBounds; + private Texture rightTextureType; + + private Texture2D dualEyeTex; + + //final & temp values for camera calculations + private final Vector3f finalPosition = new Vector3f(); + private final Quaternion finalRotation = new Quaternion(); + private final Vector3f hmdPos = new Vector3f(); + private final Quaternion hmdRot = new Quaternion(); + + /** + * Create a new VR view manager attached to the given + * {@link VREnvironment VR environment}. + * + * @param environment the {@link VREnvironment VR environment} to which this + * view manager is attached. + */ + public LWJGLOpenVRViewManager(VREnvironment environment) { + this.environment = environment; + } + + /** + * Get the identifier of the left eye texture. + * + * @return the identifier of the left eye texture. + * @see #getRightTexId() + * @see #getFullTexId() + */ + protected int getLeftTexId() { + return getLeftTexture().getImage().getId(); + } + + /** + * Get the identifier of the right eye texture. + * + * @return the identifier of the right eye texture. + * @see #getLeftTexId() + * @see #getFullTexId() + */ + protected int getRightTexId() { + return getRightTexture().getImage().getId(); + } + + /** + * Get the identifier of the full (dual eye) texture. + * + * @return the identifier of the full (dual eye) texture. + * @see #getLeftTexId() + * @see #getRightTexId() + */ + private int getFullTexId() { + return dualEyeTex.getImage().getId(); + } + + /** + * Initialize the system binds of the textures. + */ + private void initTextureSubmitStructs() { + leftTextureType = Texture.create(); + rightTextureType = Texture.create(); + + if (environment != null) { + if (environment.getVRHardware() instanceof LWJGLOpenVR) { + leftTextureBounds = VRTextureBounds.create(); + rightTextureBounds = VRTextureBounds.create(); + // left eye + leftTextureBounds.set(0f, 0f, 0.5f, 1f); + // right eye + rightTextureBounds.set(0.5f, 0f, 1f, 1f); + // texture type + leftTextureType.set(-1, VR.ETextureType_TextureType_OpenGL, VR.EColorSpace_ColorSpace_Gamma); + rightTextureType.set(-1, VR.ETextureType_TextureType_OpenGL, VR.EColorSpace_ColorSpace_Gamma); + + } + } else { + throw new IllegalStateException("This VR view manager is not attached to any VR environment."); + } + } + + /** + * updatePose can be called here because appstates are always called before the main renderer. This way we get the latest pose close to when it's supposed to render + */ + @Override + public void render() { + if (environment != null) { + // grab the observer + Object obs = environment.getObserver(); + Quaternion objRot; + Vector3f objPos; + if (obs instanceof Camera) { + objRot = ((Camera) obs).getRotation(); + objPos = ((Camera) obs).getLocation(); + } else { + objRot = ((Spatial) obs).getWorldRotation(); + objPos = ((Spatial) obs).getWorldTranslation(); + } + // grab the hardware handle + VRAPI dev = environment.getVRHardware(); + if (dev != null) { + + // update the HMD's position & orientation + dev.updatePose(); + dev.getPositionAndOrientation(hmdPos, hmdRot); + + if (obs != null) { + // update hmdPos based on obs rotation + finalRotation.set(objRot); + finalRotation.mult(hmdPos, hmdPos); + finalRotation.multLocal(hmdRot); + } + + finalizeCamera(dev.getHMDVectorPoseLeftEye(), objPos, getLeftCamera()); + finalizeCamera(dev.getHMDVectorPoseRightEye(), objPos, getRightCamera()); + } else { + getLeftCamera().setFrame(objPos, objRot); + getRightCamera().setFrame(objPos, objRot); + } + } + } + + @Override + public void postRender() { + + if (environment != null) { + if (environment.isInVR()) { + VRAPI api = environment.getVRHardware(); + // using the compositor... + int errl = 0, errr = 0; + if (environment.isInstanceRendering()) { + if (leftTextureType.handle() == -1 || leftTextureType.handle() != getFullTexId()) { + leftTextureType.set(getFullTexId(), leftTextureType.eType(), leftTextureType.eColorSpace()); + } else { + if (api instanceof LWJGLOpenVR) { + int submitFlag = VR.EVRSubmitFlags_Submit_Default; + errr = VRCompositor.VRCompositor_Submit(VR.EVREye_Eye_Right, rightTextureType, rightTextureBounds, submitFlag); + errl = VRCompositor.VRCompositor_Submit(VR.EVREye_Eye_Left, leftTextureType, leftTextureBounds, submitFlag); + } + } + } else if (leftTextureType.handle() == -1 || rightTextureType.handle() == -1 + || leftTextureType.handle() != getLeftTexId() || rightTextureType.handle() != getRightTexId()) { + leftTextureType.set(getLeftTexId(), leftTextureType.eType(), leftTextureType.eColorSpace()); + rightTextureType.set(getRightTexId(), leftTextureType.eType(), leftTextureType.eColorSpace()); + } else { + if (api instanceof LWJGLOpenVR) { + int submitFlag = VR.EVRSubmitFlags_Submit_Default; + errr = VRCompositor.VRCompositor_Submit(VR.EVREye_Eye_Right, rightTextureType, null, submitFlag); + errl = VRCompositor.VRCompositor_Submit(VR.EVREye_Eye_Left, leftTextureType, null, submitFlag); + } else { + + } + } + + if (errl != 0) { + logger.severe("Submit to left compositor error: " + " (" + Integer.toString(errl) + ")"); + logger.severe(" Texture handle: " + leftTextureType.handle()); + + logger.severe(" Left eye texture " + leftEyeTexture.getName() + " (" + leftEyeTexture.getImage().getId() + ")"); + logger.severe(" Type: " + leftEyeTexture.getType()); + logger.severe(" Size: " + leftEyeTexture.getImage().getWidth() + "x" + leftEyeTexture.getImage().getHeight()); + logger.severe(" Image depth: " + leftEyeTexture.getImage().getDepth()); + logger.severe(" Image format: " + leftEyeTexture.getImage().getFormat()); + logger.severe(" Image color space: " + leftEyeTexture.getImage().getColorSpace()); + + } + + if (errr != 0) { + logger.severe("Submit to right compositor error: " + " (" + Integer.toString(errl) + ")"); +// logger.severe(" Texture color space: "+OpenVRUtil.getEColorSpaceString(rightTextureType.eColorSpace)); +// logger.severe(" Texture type: "+OpenVRUtil.getETextureTypeString(rightTextureType.eType)); + logger.severe(" Texture handle: " + rightTextureType.handle()); + + logger.severe(" Right eye texture " + rightEyeTexture.getName() + " (" + rightEyeTexture.getImage().getId() + ")"); + logger.severe(" Type: " + rightEyeTexture.getType()); + logger.severe(" Size: " + rightEyeTexture.getImage().getWidth() + "x" + rightEyeTexture.getImage().getHeight()); + logger.severe(" Image depth: " + rightEyeTexture.getImage().getDepth()); + logger.severe(" Image format: " + rightEyeTexture.getImage().getFormat()); + logger.severe(" Image color space: " + rightEyeTexture.getImage().getColorSpace()); + } + } + } else { + throw new IllegalStateException("This VR view manager is not attached to any VR environment."); + } + + VRCompositor.VRCompositor_PostPresentHandoff(); + + } + + @Override + public void initialize() { + + logger.config("Initializing VR view manager."); + + if (environment != null) { + + initTextureSubmitStructs(); + setupCamerasAndViews(); + setupVRScene(); + moveScreenProcessingToEyes(); + + if (environment.hasTraditionalGUIOverlay()) { + + environment.getVRMouseManager().initialize(); + + // update the pose to position the gui correctly on start + update(0f); + environment.getVRGUIManager().positionGui(); + } + + logger.config("Initialized VR view manager [SUCCESS]"); + + } else { + throw new IllegalStateException("This VR view manager is not attached to any VR environment."); + } + } + + /** + * Prepare the size of the given {@link Camera camera} to adapt it to the + * underlying rendering context. + * + * @param cam the {@link Camera camera} to prepare. + * @param xMult the camera width multiplier. + */ + private void prepareCameraSize(Camera cam, float xMult) { + + if (environment != null) { + + if (environment.getApplication() != null) { + Vector2f size = new Vector2f(); + VRAPI vrhmd = environment.getVRHardware(); + + if (vrhmd == null) { + size.x = 1280f; + size.y = 720f; + } else { + vrhmd.getRenderSize(size); + } + + if (size.x < environment.getApplication().getContext().getSettings().getWidth()) { + size.x = environment.getApplication().getContext().getSettings().getWidth(); + } + if (size.y < environment.getApplication().getContext().getSettings().getHeight()) { + size.y = environment.getApplication().getContext().getSettings().getHeight(); + } + + if (environment.isInstanceRendering()) { + size.x *= 2f; + } + + // other adjustments + size.x *= xMult; + size.x *= getResolutionMuliplier(); + size.y *= getResolutionMuliplier(); + + if (cam.getWidth() != size.x || cam.getHeight() != size.y) { + cam.resize((int) size.x, (int) size.y, false); + } + } else { + throw new IllegalStateException("This VR environment is not attached to any application."); + } + + } else { + throw new IllegalStateException("This VR view manager is not attached to any VR environment."); + } + + } + + /** + * Replaces rootNode with the distortion mesh as the main camera's scene. + */ + private void setupVRScene() { + + if (environment != null) { + if (environment.getApplication() != null) { + // no special scene to set up if we are doing instancing + if (environment.isInstanceRendering()) { + // distortion has to be done with compositor here... we want only one pass on our end! + if (environment.getApplication().getContext().getSettings().isSwapBuffers()) { + setupMirrorBuffers(environment.getCamera(), dualEyeTex, true); + } + return; + } + + leftEyeTexture = (Texture2D) getLeftViewPort().getOutputFrameBuffer().getColorBuffer().getTexture(); + rightEyeTexture = (Texture2D) getRightViewPort().getOutputFrameBuffer().getColorBuffer().getTexture(); + leftEyeDepth = (Texture2D) getLeftViewPort().getOutputFrameBuffer().getDepthBuffer().getTexture(); + rightEyeDepth = (Texture2D) getRightViewPort().getOutputFrameBuffer().getDepthBuffer().getTexture(); + + // main viewport is either going to be a distortion scene or nothing + // mirroring is handled by copying framebuffers + Iterator spatialIter = environment.getApplication().getViewPort().getScenes().iterator(); + while (spatialIter.hasNext()) { + environment.getApplication().getViewPort().detachScene(spatialIter.next()); + } + + spatialIter = environment.getApplication().getGuiViewPort().getScenes().iterator(); + while (spatialIter.hasNext()) { + environment.getApplication().getGuiViewPort().detachScene(spatialIter.next()); + } + + // only setup distortion scene if compositor isn't running (or using custom mesh distortion option) + if (environment.getApplication().getContext().getSettings().isSwapBuffers()) { + setupMirrorBuffers(environment.getCamera(), leftEyeTexture, false); + + } + } else { + throw new IllegalStateException("This VR environment is not attached to any application."); + } + } else { + throw new IllegalStateException("This VR view manager is not attached to any VR environment."); + } + } + + @Override + public void update(float tpf) { + + if (environment != null) { + + if (environment.hasTraditionalGUIOverlay()) { + // update the mouse? + environment.getVRMouseManager().update(tpf); + + // update GUI position? + if (environment.getVRGUIManager().isWantsReposition() || environment.getVRGUIManager().getPositioningMode() != VRGUIPositioningMode.MANUAL) { + environment.getVRGUIManager().positionGuiNow(tpf); + environment.getVRGUIManager().updateGuiQuadGeometricState(); + } + } + } else { + throw new IllegalStateException("This VR view manager is not attached to any VR environment."); + } + } + + /** + * Place the camera within the scene. + * + * @param eyePos the eye position. + * @param obsPosition the observer position. + * @param cam the camera to place. + */ + private void finalizeCamera(Vector3f eyePos, Vector3f obsPosition, Camera cam) { + finalRotation.mult(eyePos, finalPosition); + finalPosition.addLocal(hmdPos); + if (obsPosition != null) { + finalPosition.addLocal(obsPosition); + } + finalPosition.y += getHeightAdjustment(); + cam.setFrame(finalPosition, finalRotation); + } + + private void setupCamerasAndViews() { + + if (environment != null) { + // get desired frustum from original camera + Camera origCam = environment.getCamera(); + float fFar = origCam.getFrustumFar(); + float fNear = origCam.getFrustumNear(); + + // restore frustum on distortion scene cam, if needed + if (environment.isInstanceRendering()) { + leftCamera = origCam; + } else if (environment.compositorAllowed() == false) { + origCam.setFrustumFar(100f); + origCam.setFrustumNear(1f); + leftCamera = origCam.clone(); + prepareCameraSize(origCam, 2f); + } else { + leftCamera = origCam.clone(); + } + + getLeftCamera().setFrustumPerspective(environment.getDefaultFOV(), environment.getDefaultAspect(), fNear, fFar); + + prepareCameraSize(getLeftCamera(), 1f); + if (environment.getVRHardware() != null) { + getLeftCamera().setProjectionMatrix(environment.getVRHardware().getHMDMatrixProjectionLeftEye(getLeftCamera())); + } + //org.lwjgl.opengl.GL11.glEnable(org.lwjgl.opengl.GL30.GL_FRAMEBUFFER_SRGB); + + if (!environment.isInstanceRendering()) { + leftViewPort = setupViewBuffers(getLeftCamera(), LEFT_VIEW_NAME); + rightCamera = getLeftCamera().clone(); + if (environment.getVRHardware() != null) { + getRightCamera().setProjectionMatrix(environment.getVRHardware().getHMDMatrixProjectionRightEye(getRightCamera())); + } + rightViewPort = setupViewBuffers(getRightCamera(), RIGHT_VIEW_NAME); + } else { + + if (environment.getApplication() != null) { + + logger.severe("THIS CODE NEED CHANGES !!!"); + leftViewPort = environment.getApplication().getViewPort(); + //leftViewport.attachScene(app.getRootNode()); + rightCamera = getLeftCamera().clone(); + if (environment.getVRHardware() != null) { + getRightCamera().setProjectionMatrix(environment.getVRHardware().getHMDMatrixProjectionRightEye(getRightCamera())); + } + + org.lwjgl.opengl.GL11.glEnable(org.lwjgl.opengl.GL30.GL_CLIP_DISTANCE0); + + //FIXME: [jme-vr] Fix with JMonkey next release + //RenderManager._VRInstancing_RightCamProjection = camRight.getViewProjectionMatrix(); + setupFinalFullTexture(environment.getApplication().getViewPort().getCamera()); + } else { + throw new IllegalStateException("This VR environment is not attached to any application."); + } + + } + + // setup gui + environment.getVRGUIManager().setupGui(getLeftCamera(), getRightCamera(), getLeftViewPort(), getRightViewPort()); + + if (environment.getVRHardware() != null) { + // call these to cache the results internally + environment.getVRHardware().getHMDMatrixPoseLeftEye(); + environment.getVRHardware().getHMDMatrixPoseRightEye(); + } + } else { + throw new IllegalStateException("This VR view manager is not attached to any VR environment."); + } + } + + private ViewPort setupMirrorBuffers(Camera cam, Texture2D tex, boolean expand) { + + if (environment != null) { + if (environment.getApplication() != null) { + Camera clonecam = cam.clone(); + ViewPort viewPort = environment.getApplication().getRenderManager().createPostView("MirrorView", clonecam); + clonecam.setParallelProjection(true); + viewPort.setClearFlags(true, true, true); + viewPort.setBackgroundColor(ColorRGBA.Black); + Picture pic = new Picture("fullscene"); + pic.setLocalTranslation(-0.75f, -0.5f, 0f); + if (expand) { + pic.setLocalScale(3f, 1f, 1f); + } else { + pic.setLocalScale(1.5f, 1f, 1f); + } + pic.setQueueBucket(Bucket.Opaque); + pic.setTexture(environment.getApplication().getAssetManager(), tex, false); + viewPort.attachScene(pic); + viewPort.setOutputFrameBuffer(null); + + pic.updateGeometricState(); + + return viewPort; + } else { + throw new IllegalStateException("This VR environment is not attached to any application."); + } + } else { + throw new IllegalStateException("This VR view manager is not attached to any VR environment."); + } + } + + private void setupFinalFullTexture(Camera cam) { + + if (environment != null) { + if (environment.getApplication() != null) { + // create offscreen framebuffer + FrameBuffer out = new FrameBuffer(cam.getWidth(), cam.getHeight(), 1); + //offBuffer.setSrgb(true); + + //setup framebuffer's texture + dualEyeTex = new Texture2D(cam.getWidth(), cam.getHeight(), Image.Format.RGBA8); + dualEyeTex.setMinFilter(Texture2D.MinFilter.BilinearNoMipMaps); + dualEyeTex.setMagFilter(Texture2D.MagFilter.Bilinear); + + logger.config("Dual eye texture " + dualEyeTex.getName() + " (" + dualEyeTex.getImage().getId() + ")"); + logger.config(" Type: " + dualEyeTex.getType()); + logger.config(" Size: " + dualEyeTex.getImage().getWidth() + "x" + dualEyeTex.getImage().getHeight()); + logger.config(" Image depth: " + dualEyeTex.getImage().getDepth()); + logger.config(" Image format: " + dualEyeTex.getImage().getFormat()); + logger.config(" Image color space: " + dualEyeTex.getImage().getColorSpace()); + + //setup framebuffer to use texture + out.setDepthBuffer(Image.Format.Depth); + out.setColorTexture(dualEyeTex); + + ViewPort viewPort = environment.getApplication().getViewPort(); + viewPort.setClearFlags(true, true, true); + viewPort.setBackgroundColor(ColorRGBA.Black); + viewPort.setOutputFrameBuffer(out); + } else { + throw new IllegalStateException("This VR environment is not attached to any application."); + } + } else { + throw new IllegalStateException("This VR view manager is not attached to any VR environment."); + } + } + + private ViewPort setupViewBuffers(Camera cam, String viewName) { + + if (environment != null) { + if (environment.getApplication() != null) { + // create offscreen framebuffer + FrameBuffer offBufferLeft = new FrameBuffer(cam.getWidth(), cam.getHeight(), 1); + //offBufferLeft.setSrgb(true); + + //setup framebuffer's texture + Texture2D offTex = new Texture2D(cam.getWidth(), cam.getHeight(), Image.Format.RGBA8); + offTex.setMinFilter(Texture2D.MinFilter.BilinearNoMipMaps); + offTex.setMagFilter(Texture2D.MagFilter.Bilinear); + + //setup framebuffer to use texture + offBufferLeft.setDepthBuffer(Image.Format.Depth); + offBufferLeft.setColorTexture(offTex); + + ViewPort viewPort = environment.getApplication().getRenderManager().createPreView(viewName, cam); + viewPort.setClearFlags(true, true, true); + viewPort.setBackgroundColor(ColorRGBA.Black); + + Iterator spatialIter = environment.getApplication().getViewPort().getScenes().iterator(); + while (spatialIter.hasNext()) { + viewPort.attachScene(spatialIter.next()); + } + + //set viewport to render to offscreen framebuffer + viewPort.setOutputFrameBuffer(offBufferLeft); + return viewPort; + } else { + throw new IllegalStateException("This VR environment is not attached to any application."); + } + } else { + throw new IllegalStateException("This VR view manager is not attached to any VR environment."); + } + } + +} \ No newline at end of file diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/oculus/OculusMouseManager.java b/jme3-xr/src/main/java/com/jme3/input/vr/oculus/OculusMouseManager.java new file mode 100644 index 0000000000..fc52ee467a --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/input/vr/oculus/OculusMouseManager.java @@ -0,0 +1,106 @@ +package com.jme3.input.vr.oculus; + +import com.jme3.app.VREnvironment; +import com.jme3.input.controls.AnalogListener; +import com.jme3.input.vr.AbstractVRMouseManager; +import com.jme3.input.vr.VRInputType; +import com.jme3.math.Vector2f; + +/** + * A class dedicated to the mouse handling within Oculus Rift based VR experience. + * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr + * + */ +public class OculusMouseManager extends AbstractVRMouseManager { + private final int AVERAGE_AMNT = 4; + + private int avgCounter; + + private final float[] lastXmv = new float[AVERAGE_AMNT]; + + private final float[] lastYmv = new float[AVERAGE_AMNT]; + + /** + * Create a new VR mouse manager within the given {@link VREnvironment VR environment}. + * @param environment the VR environment of the mouse manager. + */ + public OculusMouseManager(VREnvironment environment){ + super(environment); + } + + @Override + public void updateAnalogAsMouse(int inputIndex, AnalogListener mouseListener, String mouseXName, String mouseYName, float tpf) { + if (getVREnvironment() != null){ + if (getVREnvironment().getApplication() != null){ + // got a tracked controller to use as the "mouse" + if( getVREnvironment().isInVR() == false || + getVREnvironment().getVRinput() == null || + getVREnvironment().getVRinput().isInputDeviceTracking(inputIndex) == false ){ + return; + } + + Vector2f tpDelta; + // TODO option to use Touch joysticks + if( isThumbstickMode() ) { + tpDelta = getVREnvironment().getVRinput().getAxis(inputIndex, VRInputType.OculusThumbstickAxis); + } else { + tpDelta = getVREnvironment().getVRinput().getAxisDeltaSinceLastCall(inputIndex, VRInputType.OculusThumbstickAxis); + } + + float Xamount = (float)Math.pow(Math.abs(tpDelta.x) * getSpeedSensitivity(), getSpeedAcceleration()); + float Yamount = (float)Math.pow(Math.abs(tpDelta.y) * getSpeedSensitivity(), getSpeedAcceleration()); + + if( tpDelta.x < 0f ){ + Xamount = -Xamount; + } + + if( tpDelta.y < 0f ){ + Yamount = -Yamount; + } + + Xamount *= getMouseMoveScale(); + Yamount *= getMouseMoveScale(); + + if( mouseListener != null ) { + if( tpDelta.x != 0f && mouseXName != null ) mouseListener.onAnalog(mouseXName, Xamount * 0.2f, tpf); + if( tpDelta.y != 0f && mouseYName != null ) mouseListener.onAnalog(mouseYName, Yamount * 0.2f, tpf); + } + + if( getVREnvironment().getApplication().getInputManager().isCursorVisible() ) { + int index = (avgCounter+1) % AVERAGE_AMNT; + lastXmv[index] = Xamount * 133f; + lastYmv[index] = Yamount * 133f; + cursorPos.x -= avg(lastXmv); + cursorPos.y -= avg(lastYmv); + Vector2f maxsize = getVREnvironment().getVRGUIManager().getCanvasSize(); + + if( cursorPos.x > maxsize.x ){ + cursorPos.x = maxsize.x; + } + + if( cursorPos.x < 0f ){ + cursorPos.x = 0f; + } + + if( cursorPos.y > maxsize.y ){ + cursorPos.y = maxsize.y; + } + + if( cursorPos.y < 0f ){ + cursorPos.y = 0f; + } + } + } else { + throw new IllegalStateException("This VR environment is not attached to any application."); + } + } else { + throw new IllegalStateException("This VR view manager is not attached to any VR environment."); + } + } + + private float avg(float[] arr) { + float amt = 0f; + for(float f : arr) amt += f; + return amt / arr.length; + } +} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/oculus/OculusVR.java b/jme3-xr/src/main/java/com/jme3/input/vr/oculus/OculusVR.java new file mode 100644 index 0000000000..75c14c1647 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/input/vr/oculus/OculusVR.java @@ -0,0 +1,663 @@ +package com.jme3.input.vr.oculus; + +import com.jme3.app.VREnvironment; +import com.jme3.input.vr.HmdType; +import com.jme3.input.vr.VRAPI; +import com.jme3.math.*; +import com.jme3.renderer.Camera; +import com.jme3.texture.*; +import org.lwjgl.*; +import org.lwjgl.ovr.*; + +import java.nio.IntBuffer; +import java.util.logging.Logger; + +import static org.lwjgl.BufferUtils.createPointerBuffer; +import static org.lwjgl.ovr.OVR.*; +import static org.lwjgl.ovr.OVRErrorCode.ovrSuccess; +import static org.lwjgl.ovr.OVRUtil.ovr_Detect; +import static org.lwjgl.system.MemoryUtil.*; + +/** + * Oculus VR (LibOVR 1.3.0) Native support. + *

+ * A few notes about the Oculus coordinate system: + *

    + *
  • Matrices should be transposed
  • + *
  • Quaternions should be inverted
  • + *
  • Vectors should have their X and Z axes flipped, but apparently not Y.
  • + *
+ * + * @author Campbell Suter (znix@znix.xyz) + */ +public class OculusVR implements VRAPI { + + private static final Logger LOGGER = Logger.getLogger(OculusVR.class.getName()); + + private final VREnvironment environment; + private boolean initialized; + + /** + * Pointer to the HMD object + */ + private long session; + + /** + * Information about the VR session (should the app quit, is + * it visible or is the universal menu open, etcetera) + */ + private OVRSessionStatus sessionStatus; + + /** + * HMD information, such as product name and manufacturer. + */ + private OVRHmdDesc hmdDesc; + + /** + * The horizontal resolution of the HMD + */ + private int resolutionW; + + /** + * The vertical resolution of the HMD + */ + private int resolutionH; + + /** + * Field-of-view data for each eye (how many degrees from the + * center can the user see). + */ + private final OVRFovPort fovPorts[] = new OVRFovPort[2]; + + /** + * Data about each eye to be rendered - in particular, the + * offset from the center of the HMD to the eye. + */ + private final OVREyeRenderDesc eyeRenderDesc[] = new OVREyeRenderDesc[2]; + + /** + * Store the projections for each eye, so we don't have to malloc + * and recalculate them each frame. + */ + private final OVRMatrix4f[] projections = new OVRMatrix4f[2]; + + /** + * Store the poses for each eye, relative to the HMD. + * + * @see #getHMDMatrixPoseLeftEye() + */ + private final Matrix4f[] hmdRelativeEyePoses = new Matrix4f[2]; + + /** + * Store the positions for each eye, relative to the HMD. + * + * @see #getHMDVectorPoseLeftEye() + */ + private final Vector3f[] hmdRelativeEyePositions = new Vector3f[2]; + + /** + * The current state of the tracked components (HMD, touch) + */ + private OVRTrackingState trackingState; + + /** + * The position and orientation of the user's head. + */ + private OVRPosef headPose; + + /** + * The state of the Touch controllers. + */ + private OculusVRInput input; + + // The size of the texture drawn onto the HMD + private int textureW; + private int textureH; + + // Layers to render into + private PointerBuffer layers; + private OVRLayerEyeFov layer0; + + /** + * Chain texture set thing. + */ + private long chains[]; + + /** + * Frame buffers we can draw into. + */ + private FrameBuffer framebuffers[][]; + + public OculusVR(VREnvironment environment) { + this.environment = environment; + } + + @Override + public OculusVRInput getVRinput() { + return input; + } + + @Override + public String getName() { + return "OVR"; + } + + @Override + public int getDisplayFrequency() { + // TODO find correct frequency. I'm not sure + // if LibOVR has a way to do that, though. + return 60; + } + + @Override + public boolean initialize() { + // Check to make sure the HMD is connected + OVRDetectResult detect = OVRDetectResult.calloc(); + ovr_Detect(0, detect); + boolean connected = detect.IsOculusHMDConnected(); + LOGGER.config("OVRDetectResult.IsOculusHMDConnected = " + connected); + LOGGER.config("OVRDetectResult.IsOculusServiceRunning = " + detect.IsOculusServiceRunning()); + detect.free(); + + if (!connected) { + LOGGER.info("Oculus Rift not connected"); + return false; + } + + initialized = true; + + // Set up the HMD + OVRLogCallback callback = new OVRLogCallback() { + @Override + public void invoke(long userData, int level, long message) { + LOGGER.fine("LibOVR [" + userData + "] [" + level + "] " + memASCII(message)); + } + }; + OVRInitParams initParams = OVRInitParams.calloc(); + initParams.LogCallback(callback); + if (ovr_Initialize(initParams) != ovrSuccess) { + LOGGER.severe("LibOVR Init Failed"); + return false; // TODO fix memory leak - destroy() is not called + } + LOGGER.config("LibOVR Version " + ovr_GetVersionString()); + initParams.free(); + + // Get access to the HMD + LOGGER.info("Initialize HMD Session"); + PointerBuffer pHmd = memAllocPointer(1); + OVRGraphicsLuid luid = OVRGraphicsLuid.calloc(); + if (ovr_Create(pHmd, luid) != ovrSuccess) { + LOGGER.severe("Failed to create HMD"); + return false; // TODO fix memory leak - destroy() is not called + } + session = pHmd.get(0); + memFree(pHmd); + luid.free(); + sessionStatus = OVRSessionStatus.calloc(); + + // Get the information about the HMD + LOGGER.fine("Get HMD properties"); + hmdDesc = OVRHmdDesc.malloc(); + ovr_GetHmdDesc(session, hmdDesc); + if (hmdDesc.Type() == ovrHmd_None) { + LOGGER.warning("No HMD connected"); + return false; // TODO fix memory leak - destroy() is not called + } + + resolutionW = hmdDesc.Resolution().w(); + resolutionH = hmdDesc.Resolution().h(); + + LOGGER.config("HMD Properties: " + + "\t Manufacturer: " + hmdDesc.ManufacturerString() + + "\t Product: " + hmdDesc.ProductNameString() + + "\t Serial: " // + hmdDesc.SerialNumberString() // Hidden for privacy reasons + + "\t Type: " + hmdDesc.Type() + + "\t Resolution (total): " + resolutionW + "," + resolutionH); + + if (resolutionW == 0) { + LOGGER.severe("HMD width=0 : aborting"); + return false; // TODO fix memory leak - destroy() is not called + } + + // Find the FOV for each eye + for (int eye = 0; eye < 2; eye++) { + fovPorts[eye] = hmdDesc.DefaultEyeFov(eye); + } + + // Get the pose for each eye, and cache it for later. + for (int eye = 0; eye < 2; eye++) { + // Create the projection objects + projections[eye] = OVRMatrix4f.malloc(); + hmdRelativeEyePoses[eye] = new Matrix4f(); + hmdRelativeEyePositions[eye] = new Vector3f(); + + // Find the eye render information - we use this in the + // view manager for giving LibOVR its timewarp information. + eyeRenderDesc[eye] = OVREyeRenderDesc.malloc(); + ovr_GetRenderDesc(session, eye, fovPorts[eye], eyeRenderDesc[eye]); + + // Get the pose of the eye + OVRPosef pose = eyeRenderDesc[eye].HmdToEyePose(); + + // Get the position and rotation of the eye + vecO2J(pose.Position(), hmdRelativeEyePositions[eye]); + Quaternion rotation = quatO2J(pose.Orientation(), new Quaternion()); + + // Put it into a matrix for the get eye pose functions + hmdRelativeEyePoses[eye].loadIdentity(); + hmdRelativeEyePoses[eye].setTranslation(hmdRelativeEyePositions[eye]); + hmdRelativeEyePoses[eye].setRotationQuaternion(rotation); + } + + // Recenter the HMD. The game itself should do this too, but just in case / before they do. + reset(); + + // Do this so others relying on our texture size (the GUI in particular) get it correct. + findHMDTextureSize(); + + // Allocate the memory for the tracking state - we actually + // set it up later, but Input uses it so calloc it now. + trackingState = OVRTrackingState.calloc(); + + // Set up the input + input = new OculusVRInput(this, session, sessionStatus, trackingState); + + // TODO find some way to get in ovrTrackingOrigin_FloorLevel + + // throw new UnsupportedOperationException("Not yet implemented!"); + return true; + } + + @Override + public void updatePose() { + double ftiming = ovr_GetPredictedDisplayTime(session, 0); + ovr_GetTrackingState(session, ftiming, true, trackingState); + ovr_GetSessionStatus(session, sessionStatus); + + input.updateControllerStates(); + + headPose = trackingState.HeadPose().ThePose(); + } + + @Override + public boolean isInitialized() { + return initialized; + } + + @Override + public void destroy() { + // fovPorts: contents are managed by LibOVR, no need to do anything. + + // Clean up the input + input.dispose(); + + // Check if we've set up rendering - if so, clean that up. + if (chains != null) { + // Destroy our set of huge buffer images. + for (long chain : chains) { + ovr_DestroyTextureSwapChain(session, chain); + } + + // Free up the layer + layer0.free(); + + // The layers array apparently takes care of itself (and crashes if we try to free it) + } + + for (OVREyeRenderDesc eye : eyeRenderDesc) { + eye.free(); + } + for (OVRMatrix4f projection : projections) { + projection.free(); + } + + hmdDesc.free(); + trackingState.free(); + sessionStatus.free(); + + // Wrap everything up + ovr_Destroy(session); + ovr_Shutdown(); + } + + @Override + public void reset() { + // Reset the coordinate system - where the user's head is now is facing forwards from [0,0,0] + ovr_RecenterTrackingOrigin(session); + } + + @Override + public void getRenderSize(Vector2f store) { + if (!isInitialized()) { + throw new IllegalStateException("Cannot call getRenderSize() before initialized!"); + } + store.x = textureW; + store.y = textureH; + } + + @Override + public float getInterpupillaryDistance() { + return 0.065f; // TODO + } + + @Override + public Quaternion getOrientation() { + return quatO2J(headPose.Orientation(), new Quaternion()); + } + + @Override + public Vector3f getPosition() { + return vecO2J(headPose.Position(), new Vector3f()); + } + + @Override + public void getPositionAndOrientation(Vector3f storePos, Quaternion storeRot) { + storePos.set(getPosition()); + storeRot.set(getOrientation()); + } + + private Matrix4f calculateProjection(int eye, Camera cam) { + Matrix4f mat = new Matrix4f(); + + // Get LibOVR to find the correct projection + OVRUtil.ovrMatrix4f_Projection(fovPorts[eye], cam.getFrustumNear(), cam.getFrustumFar(), OVRUtil.ovrProjection_None, projections[eye]); + + matrixO2J(projections[eye], mat); + + return mat; + } + + @Override + public Matrix4f getHMDMatrixProjectionLeftEye(Camera cam) { + return calculateProjection(ovrEye_Left, cam); + } + + @Override + public Matrix4f getHMDMatrixProjectionRightEye(Camera cam) { + return calculateProjection(ovrEye_Right, cam); + } + + @Override + public Vector3f getHMDVectorPoseLeftEye() { + return hmdRelativeEyePositions[ovrEye_Left]; + } + + @Override + public Vector3f getHMDVectorPoseRightEye() { + return hmdRelativeEyePositions[ovrEye_Right]; + } + + @Override + public Vector3f getSeatedToAbsolutePosition() { + throw new UnsupportedOperationException(); + } + + @Override + public Matrix4f getHMDMatrixPoseLeftEye() { + return hmdRelativeEyePoses[ovrEye_Left]; + } + + @Override + public Matrix4f getHMDMatrixPoseRightEye() { + return hmdRelativeEyePoses[ovrEye_Left]; + } + + @Override + public HmdType getType() { + return HmdType.OCULUS_RIFT; + } + + @Override + public boolean initVRCompositor(boolean set) { + if (!set) { + throw new UnsupportedOperationException("Cannot use LibOVR without compositor!"); + } + + setupLayers(); + + framebuffers = new FrameBuffer[2][]; + for (int eye = 0; eye < 2; eye++) + setupFramebuffers(eye); + + // TODO move initialization code here from VRViewManagerOculus + return true; + } + + @Override + public void printLatencyInfoToConsole(boolean set) { + throw new UnsupportedOperationException("Not yet implemented!"); + } + + @Override + public void setFlipEyes(boolean set) { + throw new UnsupportedOperationException("Not yet implemented!"); + } + + @Override + public Void getCompositor() { + throw new UnsupportedOperationException("Not yet implemented!"); + } + + @Override + public Void getVRSystem() { + throw new UnsupportedOperationException("Not yet implemented!"); + } + + // Rendering-type stuff + + public void findHMDTextureSize() { + // Texture sizes + float pixelScaling = 1.0f; // pixelsPerDisplayPixel + + OVRSizei leftTextureSize = OVRSizei.malloc(); + ovr_GetFovTextureSize(session, ovrEye_Left, fovPorts[ovrEye_Left], pixelScaling, leftTextureSize); + + OVRSizei rightTextureSize = OVRSizei.malloc(); + ovr_GetFovTextureSize(session, ovrEye_Right, fovPorts[ovrEye_Right], pixelScaling, rightTextureSize); + + if (leftTextureSize.w() != rightTextureSize.w()) { + throw new IllegalStateException("Texture sizes do not match [horizontal]"); + } + if (leftTextureSize.h() != rightTextureSize.h()) { + throw new IllegalStateException("Texture sizes do not match [vertical]"); + } + + textureW = leftTextureSize.w(); + textureH = leftTextureSize.h(); + + leftTextureSize.free(); + rightTextureSize.free(); + } + + private long setupTextureChain() { + // Set up the information for the texture buffer chain thing + OVRTextureSwapChainDesc swapChainDesc = OVRTextureSwapChainDesc.calloc() + .Type(ovrTexture_2D) + .ArraySize(1) + .Format(OVR_FORMAT_R8G8B8A8_UNORM_SRGB) + .Width(textureW) + .Height(textureH) + .MipLevels(1) + .SampleCount(1) + .StaticImage(false); // ovrFalse + + // Create the chain + PointerBuffer textureSetPB = createPointerBuffer(1); + if (OVRGL.ovr_CreateTextureSwapChainGL(session, swapChainDesc, textureSetPB) != ovrSuccess) { + throw new RuntimeException("Failed to create Swap Texture Set"); + } + swapChainDesc.free(); + + return textureSetPB.get(); // TODO is this a memory leak? + } + + public void setupLayers() { + //Layers + layer0 = OVRLayerEyeFov.calloc(); + layer0.Header().Type(ovrLayerType_EyeFov); + layer0.Header().Flags(ovrLayerFlag_TextureOriginAtBottomLeft); + + chains = new long[2]; + for (int eye = 0; eye < 2; eye++) { + long eyeChain = setupTextureChain(); + chains[eye] = eyeChain; + + OVRRecti viewport = OVRRecti.calloc(); + viewport.Pos().x(0); + viewport.Pos().y(0); + viewport.Size().w(textureW); + viewport.Size().h(textureH); + + layer0.ColorTexture(eye, eyeChain); + layer0.Viewport(eye, viewport); + layer0.Fov(eye, fovPorts[eye]); + + viewport.free(); + // we update pose only when we have it in the render loop + } + + layers = createPointerBuffer(1); + layers.put(0, layer0); + } + + /** + * Create a framebuffer for an eye. + */ + public void setupFramebuffers(int eye) { + // Find the chain length + IntBuffer length = BufferUtils.createIntBuffer(1); + ovr_GetTextureSwapChainLength(session, chains[eye], length); + int chainLength = length.get(); + + LOGGER.fine("HMD Eye #" + eye + " texture chain length: " + chainLength); + + // Create the frame buffers + framebuffers[eye] = new FrameBuffer[chainLength]; + for (int i = 0; i < chainLength; i++) { + // find the GL texture ID for this texture + IntBuffer textureIdB = BufferUtils.createIntBuffer(1); + OVRGL.ovr_GetTextureSwapChainBufferGL(session, chains[eye], i, textureIdB); + int textureId = textureIdB.get(); + + // TODO less hacky way of getting our texture into JMonkeyEngine + Image img = new Image(); + img.setId(textureId); + img.setFormat(Image.Format.RGBA8); + img.setWidth(textureW); + img.setHeight(textureH); + + Texture2D tex = new Texture2D(img); + + FrameBuffer buffer = new FrameBuffer(textureW, textureH, 1); + buffer.setDepthBuffer(Image.Format.Depth); + buffer.setColorTexture(tex); + + framebuffers[eye][i] = buffer; + } + } + + // UTILITIES + // TODO move to helper class + + /** + * Copy the values from a LibOVR matrix into a jMonkeyEngine matrix. + * + * @param from The matrix to copy from. + * @param to The matrix to copy to. + * @return The {@code to} argument. + */ + public static Matrix4f matrixO2J(OVRMatrix4f from, Matrix4f to) { + to.loadIdentity(); // For the additional columns (unless I'm badly misunderstanding matrices) + + for (int x = 0; x < 4; x++) { + for (int y = 0; y < 4; y++) { + float val = from.M(x + y * 4); // TODO verify this + to.set(x, y, val); + } + } + + to.transposeLocal(); // jME vs LibOVR coordinate spaces - Yay! + + return to; + } + + /** + * Copy the values from a LibOVR quaternion into a jMonkeyEngine quaternion. + * + * @param from The quaternion to copy from. + * @param to The quaternion to copy to. + * @return The {@code to} argument. + */ + public static Quaternion quatO2J(OVRQuatf from, Quaternion to) { + // jME and LibOVR do their coordinate spaces differently for rotations, so flip Y and W (thanks, jMonkeyVR). + to.set( + from.x(), + -from.y(), + from.z(), + -from.w() + ); + + to.normalizeLocal(); + + return to; + } + + /** + * Copy the values from a LibOVR vector into a jMonkeyEngine vector. + * + * @param from The vector to copy from. + * @param to The vector to copy to. + * @return The {@code to} argument. + */ + public static Vector3f vecO2J(OVRVector3f from, Vector3f to) { + // jME and LibOVR disagree on which way X and Z are, too. + to.set( + -from.x(), + from.y(), + -from.z() + ); + + return to; + } + + // Getters, intended for VRViewManager. + + public long getSessionPointer() { + return session; + } + + public long getChain(int eye) { + return chains[eye]; + } + + public FrameBuffer[] getFramebuffers(int eye) { + return framebuffers[eye]; + } + + public PointerBuffer getLayers() { + return layers; + } + + public OVRLayerEyeFov getLayer0() { + return layer0; + } + + public OVRFovPort getFovPort() { + return fovPorts[ovrEye_Left]; // TODO checking the left and right eyes match + } + + public OVRPosef getHeadPose() { + return headPose; + } + + public OVRPosef getEyePose(int eye) { + return eyeRenderDesc[eye].HmdToEyePose(); + } + + public VREnvironment getEnvironment() { + return environment; + } +} + +/* vim: set ts=4 softtabstop=0 sw=4 expandtab: */ + diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/oculus/OculusVRInput.java b/jme3-xr/src/main/java/com/jme3/input/vr/oculus/OculusVRInput.java new file mode 100644 index 0000000000..f2ce772fbb --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/input/vr/oculus/OculusVRInput.java @@ -0,0 +1,370 @@ +package com.jme3.input.vr.oculus; + +import com.jme3.app.VREnvironment; +import com.jme3.input.vr.VRInputAPI; +import com.jme3.input.vr.VRInputType; +import com.jme3.input.vr.VRTrackedController; +import com.jme3.math.*; +import com.jme3.renderer.Camera; +import com.jme3.scene.Spatial; + +import org.lwjgl.ovr.*; + +import static org.lwjgl.ovr.OVR.*; + +public class OculusVRInput implements VRInputAPI { + // State control + private final OVRInputState inputState; + private final OVRSessionStatus sessionStatus; + private final OVRTrackingState trackingState; + private final OculusVR hardware; + private long session; + + // Setup values + private float axisMultiplier = 1; + + // Cached stuff + private int buttons, touch; + + // Used to calculate sinceLastCall stuff + private int lastButtons, lastTouch; + private final Vector2f[][] lastAxes; + + /** + * The state data (linear and angular velocity and acceleration) for each hand + */ + private OVRPoseStatef[] handStates; + + /** + * The position and orientation of the Touch controllers. + */ + private OVRPosef[] handPoses; + + /** + * The object forms of the tracked controllers. + */ + private final OculusController[] controllers = { + new OculusController(0), + new OculusController(1) + }; + + public OculusVRInput(OculusVR hardware, long session, + OVRSessionStatus sessionStatus, OVRTrackingState trackingState) { + this.hardware = hardware; + this.session = session; + this.sessionStatus = sessionStatus; + this.trackingState = trackingState; + + inputState = OVRInputState.calloc(); + + handStates = new OVRPoseStatef[ovrHand_Count]; + handPoses = new OVRPosef[handStates.length]; + lastAxes = new Vector2f[handStates.length][3]; // trigger+grab+thumbstick for each hand. + } + + public void dispose() { + inputState.free(); + session = 0; // Crashing > undefined behaviour if this object is incorrectly accessed again. + } + + @Override + public void updateControllerStates() { + // Handle buttons, axes + ovr_GetInputState(session, ovrControllerType_Touch, inputState); + buttons = inputState.Buttons(); + touch = inputState.Touches(); + + // Get the touch controller poses + // TODO what if no touch controllers are available? + for (int hand = 0; hand < handPoses.length; hand++) { + handStates[hand] = trackingState.HandPoses(hand); + handPoses[hand] = handStates[hand].ThePose(); + } + } + + private Vector3f cv(OVRVector3f in) { + // TODO do we want to reuse vectors rather than making new ones? + // TODO OpenVRInput does this, but it will probably cause some bugs. + return OculusVR.vecO2J(in, new Vector3f()); // This also fixes the coordinate space transform issues. + } + + private Vector2f cv(OVRVector2f in) { + // TODO do we want to reuse vectors rather than making new ones? + // TODO OpenVRInput does this, but it will probably cause some bugs. + return new Vector2f(in.x(), in.y()); + } + + private Quaternion cq(OVRQuatf in) { + // TODO do we want to reuse quaternions rather than making new ones? + // TODO OpenVRInput does this, but it will probably cause some bugs. + return OculusVR.quatO2J(in, new Quaternion()); // This also fixes the coordinate space transform issues. + } + + private Vector2f axis(float input) { + // See above comments about reusing vectors + return new Vector2f(input, input); + } + + // Tracking (position, rotation, velocity, status) + + @Override + public Vector3f getPosition(int index) { + return cv(handPoses[index].Position()); + } + + @Override + public Vector3f getVelocity(int controllerIndex) { + return cv(handStates[controllerIndex].LinearVelocity()); + } + + @Override + public Quaternion getOrientation(int index) { + return cq(handPoses[index].Orientation()); + } + + @Override + public Vector3f getAngularVelocity(int controllerIndex) { + return cv(handStates[controllerIndex].AngularVelocity()); + } + + @Override + public Quaternion getFinalObserverRotation(int index) { + // Copied from OpenVRInput + + VREnvironment env = hardware.getEnvironment(); + OculusViewManager vrvm = (OculusViewManager) hardware.getEnvironment().getVRViewManager(); + + Object obs = env.getObserver(); + Quaternion tempQuaternion = new Quaternion(); // TODO move to class scope? + if (obs instanceof Camera) { + tempQuaternion.set(((Camera) obs).getRotation()); + } else { + tempQuaternion.set(((Spatial) obs).getWorldRotation()); + } + + return tempQuaternion.multLocal(getOrientation(index)); + } + + @Override + public Vector3f getFinalObserverPosition(int index) { + // Copied from OpenVRInput + + VREnvironment env = hardware.getEnvironment(); + OculusViewManager vrvm = (OculusViewManager) hardware.getEnvironment().getVRViewManager(); + + Object obs = env.getObserver(); + Vector3f pos = getPosition(index); + if (obs instanceof Camera) { + ((Camera) obs).getRotation().mult(pos, pos); + return pos.addLocal(((Camera) obs).getLocation()); + } else { + ((Spatial) obs).getWorldRotation().mult(pos, pos); + return pos.addLocal(((Spatial) obs).getWorldTranslation()); + } + } + + @Override + public boolean isInputDeviceTracking(int index) { + int flags = trackingState.HandStatusFlags(index); + return (flags & ovrStatus_PositionTracked) != 0; // TODO do we require orientation as well? + } + + // Input Getters + + @Override + public Vector2f getAxis(int controllerIndex, VRInputType forAxis) { + Vector2f result = getAxisRaw(controllerIndex, forAxis); + return result == null ? null : result.multLocal(axisMultiplier); + } + + @Override + public Vector2f getAxisRaw(int controllerIndex, VRInputType forAxis) { + switch (forAxis) { + case OculusThumbstickAxis: + return cv(inputState.Thumbstick(controllerIndex)); + case OculusTriggerAxis: + return axis(inputState.IndexTrigger(controllerIndex)); + case OculusGripAxis: + return axis(inputState.HandTrigger(controllerIndex)); + default: + return null; + } + } + + @Override + public boolean isButtonDown(int controllerIndex, VRInputType checkButton) { + return isButtonDownForStatus(controllerIndex, checkButton, buttons, touch); + } + + public boolean isButtonDownForStatus(int controllerIndex, VRInputType checkButton, int buttons, int touch) { + int buttonMask = (controllerIndex == ovrHand_Left) ? ovrButton_LMask : ovrButton_RMask; + int touchMask = (controllerIndex == ovrHand_Left) ? + (ovrTouch_LButtonMask + ovrTouch_LPoseMask) : + (ovrTouch_RButtonMask + ovrTouch_RPoseMask); + + switch (checkButton) { + default: + return false; + + case OculusTopButton: // Physical buttons + case OculusBottomButton: + case OculusThumbstickButton: + case OculusMenuButton: + return (buttons & buttonMask & checkButton.getValue()) != 0; + + case OculusTopTouch: // Standard capacitive buttons + case OculusBottomTouch: + case OculusThumbstickTouch: + case OculusThumbrestTouch: + case OculusIndexTouch: + case OculusThumbUp: // Calculated/virtual capacitive buttons + case OculusIndexPointing: + return (touch & touchMask & checkButton.getValue()) != 0; + } + } + + // Since-last-call stuff + + @Override + public void resetInputSinceLastCall() { + lastButtons = 0; + lastTouch = 0; + } + + @Override + public boolean wasButtonPressedSinceLastCall(int controllerIndex, VRInputType checkButton) { + boolean wasPressed = isButtonDownForStatus(controllerIndex, checkButton, lastButtons, lastTouch); + lastButtons = buttons; + lastTouch = touch; + return !wasPressed && isButtonDown(controllerIndex, checkButton); + } + + @Override + public Vector2f getAxisDeltaSinceLastCall(int controllerIndex, VRInputType forAxis) { + int index; + switch (forAxis) { + case OculusTriggerAxis: + index = 0; + break; + case OculusGripAxis: + index = 1; + break; + case OculusThumbstickAxis: + index = 2; + break; + default: + return null; + } + + Vector2f last = lastAxes[controllerIndex][index]; + if (last == null) { + last = lastAxes[controllerIndex][index] = new Vector2f(); + } + + Vector2f current = getAxis(controllerIndex, forAxis); + + // TODO could this lead to accuracy problems? + current.subtractLocal(last); + last.addLocal(current); + + return current; + } + + // Misc + + @Override + public boolean init() { + throw new UnsupportedOperationException("Input initialized at creation time"); + } + + @Override + public void updateConnectedControllers() { + throw new UnsupportedOperationException("Automatically done by LibOVR (I think?)"); + } + + @Override + public float getAxisMultiplier() { + return axisMultiplier; + } + + @Override + public void setAxisMultiplier(float axisMultiplier) { + this.axisMultiplier = axisMultiplier; + } + + @Override + public void triggerHapticPulse(int controllerIndex, float seconds) { + // TODO: How do we time so we can turn the feedback off? + } + + @Override + public boolean isInputFocused() { + return sessionStatus.IsVisible(); // TODO do we need HmdMounted, or is it counted in IsVisible + } + + @Override + public Object getRawControllerState(int index) { + throw new UnsupportedOperationException("Cannot get raw controller state!"); + } + + @Override + public void swapHands() { + // Do nothing. + // TODO although OSVR and OpenVR if it has more than two controllers both do nothing, shouldn't we be + // TODO throwing an exception or something? + } + + @Override + public int getTrackedControllerCount() { + // TODO: Shouldn't we be seeing if the user has the touch controllers first? + return 2; + } + + @Override + public VRTrackedController getTrackedController(int index) { + return controllers[index]; + } + + /** + * The object form representation of a controller. + */ + public class OculusController implements VRTrackedController { + + /** + * The ID of the hand to track + */ + private int hand; + + public OculusController(int hand) { + this.hand = hand; + } + + @Override + public String getControllerName() { + return "Touch"; // TODO + } + + @Override + public String getControllerManufacturer() { + return "Oculus"; // TODO + } + + @Override + public Vector3f getPosition() { + return OculusVRInput.this.getPosition(hand); + } + + @Override + public Quaternion getOrientation() { + return OculusVRInput.this.getOrientation(hand); + } + + @Override + public Matrix4f getPose() { + Matrix4f mat = new Matrix4f(); + mat.setRotationQuaternion(getOrientation()); + mat.setTranslation(getPosition()); + return mat; + } + } +} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/oculus/OculusViewManager.java b/jme3-xr/src/main/java/com/jme3/input/vr/oculus/OculusViewManager.java new file mode 100644 index 0000000000..6ebbab1cf9 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/input/vr/oculus/OculusViewManager.java @@ -0,0 +1,340 @@ +/* + * Copyright (c) 2009-2018 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.input.vr.oculus; + +import com.jme3.app.VREnvironment; +import com.jme3.input.vr.AbstractVRViewManager; +import com.jme3.input.vr.VRAPI; +import com.jme3.math.*; +import com.jme3.renderer.Camera; +import com.jme3.renderer.ViewPort; +import com.jme3.scene.Spatial; +import com.jme3.util.BufferUtils; +import com.jme3.util.VRGUIPositioningMode; + +import java.nio.IntBuffer; +import java.util.Iterator; +import java.util.Objects; + +import org.lwjgl.ovr.OVRFovPort; +import org.lwjgl.ovr.OVRPosef; +import org.lwjgl.ovr.OVRUtil; + +import static org.lwjgl.ovr.OVR.*; +import static org.lwjgl.ovr.OVRErrorCode.*; + +/** + * A rendering system for Oculus's LibOVR API. + * + * @author Campbell Suter (znix@znix.xyz) + */ +public class OculusViewManager extends AbstractVRViewManager { + + private final VREnvironment environment; + private final OculusVR hardware; + + // Copied from OSVR + //final & temp values for camera calculations + private final Vector3f finalPosition = new Vector3f(); + private final Quaternion finalRotation = new Quaternion(); + private final Vector3f hmdPos = new Vector3f(); + private final Quaternion hmdRot = new Quaternion(); + + public OculusViewManager(VREnvironment environment) { + this.environment = environment; + + VRAPI hardware = environment.getVRHardware(); + Objects.requireNonNull(hardware, "Attached VR Hardware cannot be null"); + if (!(hardware instanceof OculusVR)) { + throw new IllegalStateException("Cannot use Oculus VR view manager on non-Oculus hardware state!"); + } + + this.hardware = (OculusVR) hardware; + + if (!environment.compositorAllowed()) { + throw new UnsupportedOperationException("Cannot render without compositor on LibOVR"); + } + } + + @Override + public void initialize() { + setupCamerasAndViews(); + + if (environment.hasTraditionalGUIOverlay()) { + + environment.getVRMouseManager().initialize(); + + // update the pose to position the gui correctly on start + update(0f); + environment.getVRGUIManager().positionGui(); + } + } + + private long session() { + return hardware.getSessionPointer(); + } + + @Override + public void update(float tpf) { + // TODO + + hardware.updatePose(); + + // TODO deduplicate + if (environment == null) { + throw new IllegalStateException("This VR view manager is not attached to any VR environment."); + } + + // grab the observer + Object obs = environment.getObserver(); + Quaternion objRot; + Vector3f objPos; + if (obs instanceof Camera) { + objRot = ((Camera) obs).getRotation(); + objPos = ((Camera) obs).getLocation(); + } else { + objRot = ((Spatial) obs).getWorldRotation(); + objPos = ((Spatial) obs).getWorldTranslation(); + } + + // update the HMD's position & orientation + hardware.getPositionAndOrientation(hmdPos, hmdRot); + if (obs != null) { + // update hmdPos based on obs rotation + finalRotation.set(objRot); + finalRotation.mult(hmdPos, hmdPos); + finalRotation.multLocal(hmdRot); + } + + // Update both eye cameras + finalizeCamera(hardware.getHMDVectorPoseLeftEye(), objPos, leftCamera); + finalizeCamera(hardware.getHMDVectorPoseRightEye(), objPos, rightCamera); + + // Update the main camera, so it shows the same basic view the HMD is getting + // TODO: Do this in VRAppState, so it works on all HMDs. + // I only have a Rift, so I can't test it on anything else. + if(!environment.isInstanceRendering()) { // We use the app camera as the left camera here + // TODO: Double up on rendering and use one eye, to reduce GPU load rendering the scene again. + // TODO: Snip at the image to remove the distorted corners from a very high FOV. + finalizeCamera(Vector3f.ZERO, objPos, environment.getApplication().getCamera()); + } + + if (environment.hasTraditionalGUIOverlay()) { + // update the mouse? + environment.getVRMouseManager().update(tpf); + + // update GUI position? + if (environment.getVRGUIManager().isWantsReposition() || environment.getVRGUIManager().getPositioningMode() != VRGUIPositioningMode.MANUAL) { + environment.getVRGUIManager().positionGuiNow(tpf); + environment.getVRGUIManager().updateGuiQuadGeometricState(); + } + } + } + + /** + * Place the camera within the scene. + * + * @param eyePos the eye position. + * @param obsPosition the observer position. + * @param cam the camera to place. + */ + private void finalizeCamera(Vector3f eyePos, Vector3f obsPosition, Camera cam) { + finalRotation.mult(eyePos, finalPosition); + finalPosition.addLocal(hmdPos); + if (obsPosition != null) { + finalPosition.addLocal(obsPosition); + } + finalPosition.y += getHeightAdjustment(); + cam.setFrame(finalPosition, finalRotation); + } + + @Override + public void render() { + + // Calculate the render pose (translation/rotation) for each eye. + // LibOVR takes the difference between this and the real position of each eye at display time + // to apply AZW (timewarp). + + OVRPosef.Buffer hmdToEyeOffsets = OVRPosef.calloc(2); + hmdToEyeOffsets.put(0, hardware.getEyePose(ovrEye_Left)); + hmdToEyeOffsets.put(1, hardware.getEyePose(ovrEye_Right)); + + //calculate eye poses + OVRUtil.ovr_CalcEyePoses(hardware.getHeadPose(), hmdToEyeOffsets, hardware.getLayer0().RenderPose()); + hmdToEyeOffsets.free(); + + for (int eye = 0; eye < 2; eye++) { + IntBuffer currentIndexB = BufferUtils.createIntBuffer(1); + ovr_GetTextureSwapChainCurrentIndex(session(), hardware.getChain(eye), currentIndexB); + int index = currentIndexB.get(); + + // Constantly (each frame) rotating through a series of + // frame buffers, so make sure we write into the correct one. + (eye == ovrEye_Left ? leftViewPort : rightViewPort).setOutputFrameBuffer(hardware.getFramebuffers(eye)[index]); + } + + // Now the game will render into the buffers given to us by LibOVR + } + + @Override + public void postRender() { + // We're done with our textures now - the game is done drawing into them. + for (int eye = 0; eye < 2; eye++) { + ovr_CommitTextureSwapChain(session(), hardware.getChain(eye)); + } + + // Send the result to the HMD + int result = ovr_SubmitFrame(session(), 0, null, hardware.getLayers()); + if (result != ovrSuccess) { + throw new IllegalStateException("Failed to submit frame!"); + } + } + + /* + ********************************************************* + * Show's over, now it's just boring camera stuff etc. * + ********************************************************* + */ + + /** + * Set up the cameras and views for each eye and the mirror display. + */ + private void setupCamerasAndViews() { + // TODO: Use LobOVR IPD etc + if (environment != null) { + // get desired frustum from original camera + Camera origCam = environment.getCamera(); + float fFar = origCam.getFrustumFar(); + float fNear = origCam.getFrustumNear(); + + // restore frustum on distortion scene cam, if needed + if (environment.isInstanceRendering()) { + leftCamera = origCam; + } else { + leftCamera = origCam.clone(); + } + + OVRFovPort fp = hardware.getFovPort(); + float hFov = fp.LeftTan() + fp.RightTan(); + float vFov = fp.UpTan() + fp.DownTan(); + getLeftCamera().setFrustumPerspective(hFov / FastMath.TWO_PI * 360, vFov / hFov, fNear, fFar); + + prepareCameraSize(getLeftCamera(), 1f); + if (environment.getVRHardware() != null) { + getLeftCamera().setProjectionMatrix(environment.getVRHardware().getHMDMatrixProjectionLeftEye(getLeftCamera())); + } + //org.lwjgl.opengl.GL11.glEnable(org.lwjgl.opengl.GL30.GL_FRAMEBUFFER_SRGB); + + if (!environment.isInstanceRendering()) { + leftViewPort = setupViewBuffers(getLeftCamera(), LEFT_VIEW_NAME); + rightCamera = getLeftCamera().clone(); + if (environment.getVRHardware() != null) { + getRightCamera().setProjectionMatrix(environment.getVRHardware().getHMDMatrixProjectionRightEye(getRightCamera())); + } + rightViewPort = setupViewBuffers(getRightCamera(), RIGHT_VIEW_NAME); + } else if (environment.getApplication() != null) { + throw new UnsupportedOperationException("Not yet implemented!"); + } else { + throw new IllegalStateException("This VR environment is not attached to any application."); + } + + // setup gui + environment.getVRGUIManager().setupGui(getLeftCamera(), getRightCamera(), getLeftViewPort(), getRightViewPort()); + } else { + throw new IllegalStateException("This VR view manager is not attached to any VR environment."); + } + } + + private void prepareCameraSize(Camera cam, float xMult) { + // TODO this function is identical to that in VRViewManagerOpenVR; merge the two. + if (environment != null) { + if (environment.getApplication() != null) { + Vector2f size = new Vector2f(); + VRAPI vrhmd = environment.getVRHardware(); + + if (vrhmd == null) { + size.x = 1280f; + size.y = 720f; + } else { + vrhmd.getRenderSize(size); + } + + if (size.x < environment.getApplication().getContext().getSettings().getWidth()) { + size.x = environment.getApplication().getContext().getSettings().getWidth(); + } + if (size.y < environment.getApplication().getContext().getSettings().getHeight()) { + size.y = environment.getApplication().getContext().getSettings().getHeight(); + } + + if (environment.isInstanceRendering()) { + size.x *= 2f; + } + + // other adjustments + size.x *= xMult; + size.x *= getResolutionMuliplier(); + size.y *= getResolutionMuliplier(); + + if (cam.getWidth() != size.x || cam.getHeight() != size.y) { + cam.resize((int) size.x, (int) size.y, false); + } + } else { + throw new IllegalStateException("This VR environment is not attached to any application."); + } + } else { + throw new IllegalStateException("This VR view manager is not attached to any VR environment."); + } + } + + private ViewPort setupViewBuffers(Camera cam, String viewName) { + // TODO this function is identical to that in VRViewManagerOpenVR; merge the two. + if (environment != null) { + if (environment.getApplication() != null) { + ViewPort viewPort = environment.getApplication().getRenderManager().createPreView(viewName, cam); + viewPort.setClearFlags(true, true, true); + viewPort.setBackgroundColor(ColorRGBA.Black); + + Iterator spatialIter = environment.getApplication().getViewPort().getScenes().iterator(); + while (spatialIter.hasNext()) { + viewPort.attachScene(spatialIter.next()); + } + + // The target view buffer will be set during prerender. + return viewPort; + } else { + throw new IllegalStateException("This VR environment is not attached to any application."); + } + } else { + throw new IllegalStateException("This VR view manager is not attached to any VR environment."); + } + } +} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/oculus/package-info.java b/jme3-xr/src/main/java/com/jme3/input/vr/oculus/package-info.java new file mode 100644 index 0000000000..ab7b1bbb89 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/input/vr/oculus/package-info.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2021 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +/** + * user-input classes for Oculus Rift headsets + */ +package com.jme3.input.vr.oculus; diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/openvr/OpenVR.java b/jme3-xr/src/main/java/com/jme3/input/vr/openvr/OpenVR.java new file mode 100644 index 0000000000..4489bd9f99 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/input/vr/openvr/OpenVR.java @@ -0,0 +1,584 @@ +package com.jme3.input.vr.openvr; + +import com.jme3.app.VREnvironment; +import com.jme3.input.vr.HmdType; +import com.jme3.input.vr.VRAPI; +import com.jme3.math.Matrix4f; +import com.jme3.math.Quaternion; +import com.jme3.math.Vector2f; +import com.jme3.math.Vector3f; +import com.jme3.renderer.Camera; +import com.jme3.system.jopenvr.HmdMatrix34_t; +import com.jme3.system.jopenvr.HmdMatrix44_t; +import com.jme3.system.jopenvr.JOpenVRLibrary; +import com.jme3.system.jopenvr.OpenVRUtil; +import com.jme3.system.jopenvr.TrackedDevicePose_t; +import com.jme3.system.jopenvr.VR_IVRCompositor_FnTable; +import com.jme3.system.jopenvr.VR_IVRSystem_FnTable; +import com.jme3.system.jopenvr.VR_IVRTrackedCamera_FnTable; +import com.jme3.util.VRUtil; +import com.sun.jna.Memory; +import com.sun.jna.Pointer; +import com.sun.jna.ptr.FloatByReference; +import com.sun.jna.ptr.IntByReference; +import com.sun.jna.ptr.LongByReference; + +import java.nio.IntBuffer; +import java.util.Locale; +import java.util.concurrent.TimeUnit; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * A class that wraps an OpenVR system. + * @author reden - phr00t - https://github.com/phr00t + * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr + */ +public class OpenVR implements VRAPI { + private static final Logger logger = Logger.getLogger(OpenVR.class.getName()); + + private static VR_IVRCompositor_FnTable compositorFunctions; + private static VR_IVRSystem_FnTable vrSystemFunctions; + private static VR_IVRTrackedCamera_FnTable cameraFunctions; + + private static boolean initSuccess = false; + private static boolean flipEyes = false; + + private IntBuffer hmdDisplayFrequency; + private TrackedDevicePose_t.ByReference hmdTrackedDevicePoseReference; + protected TrackedDevicePose_t[] hmdTrackedDevicePoses; + + protected IntByReference hmdErrorStore; + + private final Quaternion rotStore = new Quaternion(); + private final Vector3f posStore = new Vector3f(); + + private static FloatByReference tlastVsync; + + /** + * The actual frame count. + */ + public static LongByReference _tframeCount; + + // for debugging latency + private int frames = 0; + + protected Matrix4f[] poseMatrices; + + private final Matrix4f hmdPose = Matrix4f.IDENTITY.clone(); + private Matrix4f hmdProjectionLeftEye; + private Matrix4f hmdProjectionRightEye; + private Matrix4f hmdPoseLeftEye; + private Matrix4f hmdPoseRightEye; + + private Vector3f hmdPoseLeftEyeVec, hmdPoseRightEyeVec, hmdSeatToStand; + + private float vsyncToPhotons; + private double timePerFrame, frameCountRun; + private long frameCount; + private OpenVRInput vrInput; + + private VREnvironment environment = null; + + /** + * Convert specific OpenVR {@link com.jme3.system.jopenvr.HmdMatrix34_t HmdMatrix34_t} into JME {@link Matrix4f Matrix4f} + * @param hmdMatrix the input matrix + * @param mat the converted matrix + * @return the converted matrix + */ + public static Matrix4f convertSteamVRMatrix3ToMatrix4f(com.jme3.system.jopenvr.HmdMatrix34_t hmdMatrix, Matrix4f mat){ + mat.set(hmdMatrix.m[0], hmdMatrix.m[1], hmdMatrix.m[2], hmdMatrix.m[3], + hmdMatrix.m[4], hmdMatrix.m[5], hmdMatrix.m[6], hmdMatrix.m[7], + hmdMatrix.m[8], hmdMatrix.m[9], hmdMatrix.m[10], hmdMatrix.m[11], + 0f, 0f, 0f, 1f); + return mat; + } + + /** + * Convert specific OpenVR {@link com.jme3.system.jopenvr.HmdMatrix44_t HmdMatrix34_t} into JME {@link Matrix4f Matrix4f} + * @param hmdMatrix the input matrix + * @param mat the converted matrix + * @return the converted matrix + */ + public static Matrix4f convertSteamVRMatrix4ToMatrix4f(com.jme3.system.jopenvr.HmdMatrix44_t hmdMatrix, Matrix4f mat){ + mat.set(hmdMatrix.m[0], hmdMatrix.m[1], hmdMatrix.m[2], hmdMatrix.m[3], + hmdMatrix.m[4], hmdMatrix.m[5], hmdMatrix.m[6], hmdMatrix.m[7], + hmdMatrix.m[8], hmdMatrix.m[9], hmdMatrix.m[10], hmdMatrix.m[11], + hmdMatrix.m[12], hmdMatrix.m[13], hmdMatrix.m[14], hmdMatrix.m[15]); + return mat; + } + + /** + * Create a new OpenVR system + * attached to the given {@link VREnvironment VR environment}. + * @param environment the VR environment to which this API is attached. + */ + public OpenVR(VREnvironment environment){ + this.environment = environment; + } + + @Override + public OpenVRInput getVRinput() { + return vrInput; + } + + @Override + public VR_IVRSystem_FnTable getVRSystem() { + return vrSystemFunctions; + } + + @Override + public VR_IVRCompositor_FnTable getCompositor() { + return compositorFunctions; + } + + public VR_IVRTrackedCamera_FnTable getTrackedCamera(){ + return cameraFunctions; + } + + @Override + public String getName() { + return "OpenVR"; + } + + private static long latencyWaitTime = 0; + + @Override + public void setFlipEyes(boolean set) { + flipEyes = set; + } + + private boolean enableDebugLatency = false; + + @Override + public void printLatencyInfoToConsole(boolean set) { + enableDebugLatency = set; + } + + @Override + public int getDisplayFrequency() { + if( hmdDisplayFrequency == null ) return 0; + return hmdDisplayFrequency.get(0); + } + + @Override + public boolean initialize() { + logger.config("Initializing OpenVR system..."); + + hmdErrorStore = new IntByReference(); + vrSystemFunctions = null; + + // Init the native linking to the OpenVR library. + try{ + JOpenVRLibrary.init(); + } catch(Throwable t){ + logger.log(Level.SEVERE, "Cannot link to OpenVR system library: "+t.getMessage(), t); + return false; + } + + JOpenVRLibrary.VR_InitInternal(hmdErrorStore, JOpenVRLibrary.EVRApplicationType.EVRApplicationType_VRApplication_Scene); + + if( hmdErrorStore.getValue() == 0 ) { + vrSystemFunctions = new VR_IVRSystem_FnTable(JOpenVRLibrary.VR_GetGenericInterface(JOpenVRLibrary.IVRSystem_Version, hmdErrorStore).getPointer()); + } + + if( vrSystemFunctions == null || hmdErrorStore.getValue() != 0 ) { + logger.severe("OpenVR Initialize Result: " + JOpenVRLibrary.VR_GetVRInitErrorAsEnglishDescription(hmdErrorStore.getValue()).getString(0)); + logger.severe("Initializing OpenVR system [FAILED]"); + return false; + } else { + logger.config("OpenVR initialized & VR connected."); + + vrSystemFunctions.setAutoSynch(false); + vrSystemFunctions.read(); + + tlastVsync = new FloatByReference(); + _tframeCount = new LongByReference(); + + hmdDisplayFrequency = IntBuffer.allocate(1); + hmdDisplayFrequency.put(JOpenVRLibrary.ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DisplayFrequency_Float); + hmdTrackedDevicePoseReference = new TrackedDevicePose_t.ByReference(); + hmdTrackedDevicePoses = (TrackedDevicePose_t[])hmdTrackedDevicePoseReference.toArray(JOpenVRLibrary.k_unMaxTrackedDeviceCount); + poseMatrices = new Matrix4f[JOpenVRLibrary.k_unMaxTrackedDeviceCount]; + for(int i=0;itrue is the use of the headset camera is allowed and false otherwise. + */ + public void initCamera(boolean allowed) { + hmdErrorStore.setValue(0); // clear the error store + + if( allowed && vrSystemFunctions != null ) { + IntByReference intptr = JOpenVRLibrary.VR_GetGenericInterface(JOpenVRLibrary.IVRTrackedCamera_Version, hmdErrorStore); + if (intptr != null){ + cameraFunctions = new VR_IVRTrackedCamera_FnTable(intptr.getPointer()); + if(cameraFunctions != null && hmdErrorStore.getValue() == 0 ){ + cameraFunctions.setAutoSynch(false); + cameraFunctions.read(); + logger.config("OpenVR Camera initialized"); + } + } + } + } + + @Override + public void destroy() { + JOpenVRLibrary.VR_ShutdownInternal(); + } + + @Override + public boolean isInitialized() { + return initSuccess; + } + + @Override + public void reset() { + if( vrSystemFunctions == null ) return; + vrSystemFunctions.ResetSeatedZeroPose.apply(); + hmdSeatToStand = null; + } + + @Override + public void getRenderSize(Vector2f store) { + if( vrSystemFunctions == null ) { + // 1344x1512 + store.x = 1344f; + store.y = 1512f; + } else { + IntByReference x = new IntByReference(); + IntByReference y = new IntByReference(); + vrSystemFunctions.GetRecommendedRenderTargetSize.apply(x, y); + store.x = x.getValue(); + store.y = y.getValue(); + } + } + /* + @Override + public float getFOV(int dir) { + float val = 0f; + if( vrsystemFunctions != null ) { + val = vrsystemFunctions.GetFloatTrackedDeviceProperty.apply(JOpenVRLibrary.k_unTrackedDeviceIndex_Hmd, dir, hmdErrorStore); + } + // verification of number + if( val == 0f ) { + return 55f; + } else if( val <= 10f ) { + // most likely a radian number + return val * 57.2957795f; + } + return val; + } + */ + + @Override + public float getInterpupillaryDistance() { + if( vrSystemFunctions == null ) return 0.065f; + return vrSystemFunctions.GetFloatTrackedDeviceProperty.apply(JOpenVRLibrary.k_unTrackedDeviceIndex_Hmd, JOpenVRLibrary.ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_UserIpdMeters_Float, hmdErrorStore); + } + + @Override + public Quaternion getOrientation() { + VRUtil.convertMatrix4toQuat(hmdPose, rotStore); + return rotStore; + } + + @Override + public Vector3f getPosition() { + // the hmdPose comes in rotated funny, fix that here + hmdPose.toTranslationVector(posStore); + posStore.x = -posStore.x; + posStore.z = -posStore.z; + return posStore; + } + + @Override + public void getPositionAndOrientation(Vector3f storePos, Quaternion storeRot) { + hmdPose.toTranslationVector(storePos); + storePos.x = -storePos.x; + storePos.z = -storePos.z; + storeRot.set(getOrientation()); + } + + @Override + public void updatePose(){ + if(vrSystemFunctions == null) return; + if(compositorFunctions != null) { + compositorFunctions.WaitGetPoses.apply(hmdTrackedDevicePoseReference, JOpenVRLibrary.k_unMaxTrackedDeviceCount, null, 0); + } else { + // wait + if( latencyWaitTime > 0 ) VRUtil.sleepNanos(latencyWaitTime); + + vrSystemFunctions.GetTimeSinceLastVsync.apply(tlastVsync, _tframeCount); + float fSecondsUntilPhotons = (float)timePerFrame - tlastVsync.getValue() + vsyncToPhotons; + + if( enableDebugLatency ) { + if( frames == 10 ) { + System.out.println("Waited (nanos): " + Long.toString(latencyWaitTime)); + System.out.println("Predict ahead time: " + Float.toString(fSecondsUntilPhotons)); + } + frames = (frames + 1) % 60; + } + + // handle skipping frame stuff + long nowCount = _tframeCount.getValue(); + if( nowCount - frameCount > 1 ) { + // skipped a frame! + if( enableDebugLatency ) System.out.println("Frame skipped!"); + frameCountRun = 0; + if( latencyWaitTime > 0 ) { + latencyWaitTime -= TimeUnit.MILLISECONDS.toNanos(1); + if( latencyWaitTime < 0 ) latencyWaitTime = 0; + } + } else if( latencyWaitTime < timePerFrame * 1000000000.0 ) { + // didn't skip a frame, lets try waiting longer to improve latency + frameCountRun++; + latencyWaitTime += Math.round(Math.pow(frameCountRun / 10.0, 2.0)); + } + + frameCount = nowCount; + + vrSystemFunctions.GetDeviceToAbsoluteTrackingPose.apply( + environment.isSeatedExperience()?JOpenVRLibrary.ETrackingUniverseOrigin.ETrackingUniverseOrigin_TrackingUniverseSeated: + JOpenVRLibrary.ETrackingUniverseOrigin.ETrackingUniverseOrigin_TrackingUniverseStanding, + fSecondsUntilPhotons, hmdTrackedDevicePoseReference, JOpenVRLibrary.k_unMaxTrackedDeviceCount); + } + + // deal with controllers being plugged in and out + // causing an invalid memory crash... skipping for now + /*boolean hasEvent = false; + while( JOpenVRLibrary.VR_IVRSystem_PollNextEvent(OpenVR.getVRSystemInstance(), tempEvent) != 0 ) { + // Wait until the events are clear. + hasEvent = true; + } + if( hasEvent ) { + // an event probably changed controller state + VRInput._updateConnectedControllers(); + }*/ + //update controllers pose information + environment.getVRinput().updateControllerStates(); + + // read pose data from native + for (int nDevice = 0; nDevice < JOpenVRLibrary.k_unMaxTrackedDeviceCount; ++nDevice ){ + hmdTrackedDevicePoses[nDevice].readField("bPoseIsValid"); + if( hmdTrackedDevicePoses[nDevice].bPoseIsValid != 0 ){ + hmdTrackedDevicePoses[nDevice].readField("mDeviceToAbsoluteTracking"); + convertSteamVRMatrix3ToMatrix4f(hmdTrackedDevicePoses[nDevice].mDeviceToAbsoluteTracking, poseMatrices[nDevice]); + } + } + + if ( hmdTrackedDevicePoses[JOpenVRLibrary.k_unTrackedDeviceIndex_Hmd].bPoseIsValid != 0 ){ + hmdPose.set(poseMatrices[JOpenVRLibrary.k_unTrackedDeviceIndex_Hmd]); + } else { + hmdPose.set(Matrix4f.IDENTITY); + } + } + + @Override + public Matrix4f getHMDMatrixProjectionLeftEye(Camera cam){ + if( hmdProjectionLeftEye != null ) { + return hmdProjectionLeftEye; + } else if(vrSystemFunctions == null){ + return cam.getProjectionMatrix(); + } else { + HmdMatrix44_t mat = vrSystemFunctions.GetProjectionMatrix.apply(JOpenVRLibrary.EVREye.EVREye_Eye_Left, cam.getFrustumNear(), cam.getFrustumFar()); + hmdProjectionLeftEye = new Matrix4f(); + convertSteamVRMatrix4ToMatrix4f(mat, hmdProjectionLeftEye); + return hmdProjectionLeftEye; + } + } + + @Override + public Matrix4f getHMDMatrixProjectionRightEye(Camera cam){ + if( hmdProjectionRightEye != null ) { + return hmdProjectionRightEye; + } else if(vrSystemFunctions == null){ + return cam.getProjectionMatrix(); + } else { + HmdMatrix44_t mat = vrSystemFunctions.GetProjectionMatrix.apply(JOpenVRLibrary.EVREye.EVREye_Eye_Right, cam.getFrustumNear(), cam.getFrustumFar()); + hmdProjectionRightEye = new Matrix4f(); + convertSteamVRMatrix4ToMatrix4f(mat, hmdProjectionRightEye); + return hmdProjectionRightEye; + } + } + + @Override + public Vector3f getHMDVectorPoseLeftEye() { + if( hmdPoseLeftEyeVec == null ) { + hmdPoseLeftEyeVec = getHMDMatrixPoseLeftEye().toTranslationVector(); + // set default IPD if none or broken + if( hmdPoseLeftEyeVec.x <= 0.080f * -0.5f || hmdPoseLeftEyeVec.x >= 0.040f * -0.5f ) { + hmdPoseLeftEyeVec.x = 0.065f * -0.5f; + } + if( flipEyes == false ) hmdPoseLeftEyeVec.x *= -1f; // it seems these need flipping + } + return hmdPoseLeftEyeVec; + } + + @Override + public Vector3f getHMDVectorPoseRightEye() { + if( hmdPoseRightEyeVec == null ) { + hmdPoseRightEyeVec = getHMDMatrixPoseRightEye().toTranslationVector(); + // set default IPD if none or broken + if( hmdPoseRightEyeVec.x >= 0.080f * 0.5f || hmdPoseRightEyeVec.x <= 0.040f * 0.5f ) { + hmdPoseRightEyeVec.x = 0.065f * 0.5f; + } + if( flipEyes == false ) hmdPoseRightEyeVec.x *= -1f; // it seems these need flipping + } + return hmdPoseRightEyeVec; + } + + @Override + public Vector3f getSeatedToAbsolutePosition() { + if( environment.isSeatedExperience() == false ) return Vector3f.ZERO; + if( hmdSeatToStand == null ) { + hmdSeatToStand = new Vector3f(); + HmdMatrix34_t mat = vrSystemFunctions.GetSeatedZeroPoseToStandingAbsoluteTrackingPose.apply(); + Matrix4f tempMatrix = new Matrix4f(); + convertSteamVRMatrix3ToMatrix4f(mat, tempMatrix); + tempMatrix.toTranslationVector(hmdSeatToStand); + } + return hmdSeatToStand; + } + + @Override + public Matrix4f getHMDMatrixPoseLeftEye(){ + if( hmdPoseLeftEye != null ) { + return hmdPoseLeftEye; + } else if(vrSystemFunctions == null) { + return Matrix4f.IDENTITY; + } else { + HmdMatrix34_t mat = vrSystemFunctions.GetEyeToHeadTransform.apply(JOpenVRLibrary.EVREye.EVREye_Eye_Left); + hmdPoseLeftEye = new Matrix4f(); + return convertSteamVRMatrix3ToMatrix4f(mat, hmdPoseLeftEye); + } + } + + @Override + public HmdType getType() { + if( vrSystemFunctions != null ) { + Pointer str1 = new Memory(128); + Pointer str2 = new Memory(128); + String completeName = ""; + vrSystemFunctions.GetStringTrackedDeviceProperty.apply(JOpenVRLibrary.k_unTrackedDeviceIndex_Hmd, + JOpenVRLibrary.ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_ManufacturerName_String, + str1, 128, hmdErrorStore); + if( hmdErrorStore.getValue() == 0 ) completeName += str1.getString(0); + vrSystemFunctions.GetStringTrackedDeviceProperty.apply(JOpenVRLibrary.k_unTrackedDeviceIndex_Hmd, + JOpenVRLibrary.ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_ModelNumber_String, + str2, 128, hmdErrorStore); + if( hmdErrorStore.getValue() == 0 ) completeName += " " + str2.getString(0); + if( completeName.length() > 0 ) { + completeName = completeName.toLowerCase(Locale.ENGLISH).trim(); + if( completeName.contains("htc") || completeName.contains("vive") ) { + return HmdType.HTC_VIVE; + } else if ( completeName.contains("index") ) { + return HmdType.VALVE_INDEX; + } else if( completeName.contains("osvr") ) { + return HmdType.OSVR; + } else if( completeName.contains("oculus") || completeName.contains("rift") || + completeName.contains("dk1") || completeName.contains("dk2") || completeName.contains("cv1") ) { + return HmdType.OCULUS_RIFT; + } else if( completeName.contains("fove") ) { + return HmdType.FOVE; + } else if( completeName.contains("game") && completeName.contains("face") ) { + return HmdType.GAMEFACE; + } else if( completeName.contains("morpheus") ) { + return HmdType.MORPHEUS; + } else if( completeName.contains("gear") ) { + return HmdType.GEARVR; + } else if( completeName.contains("star") ) { + return HmdType.STARVR; + } else if( completeName.contains("null") ) { + return HmdType.NULL; + } + } + } else return HmdType.NONE; + return HmdType.OTHER; + } + + @Override + public Matrix4f getHMDMatrixPoseRightEye(){ + if( hmdPoseRightEye != null ) { + return hmdPoseRightEye; + } else if(vrSystemFunctions == null) { + return Matrix4f.IDENTITY; + } else { + HmdMatrix34_t mat = vrSystemFunctions.GetEyeToHeadTransform.apply(JOpenVRLibrary.EVREye.EVREye_Eye_Right); + hmdPoseRightEye = new Matrix4f(); + return convertSteamVRMatrix3ToMatrix4f(mat, hmdPoseRightEye); + } + } +} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/openvr/OpenVRBounds.java b/jme3-xr/src/main/java/com/jme3/input/vr/openvr/OpenVRBounds.java new file mode 100644 index 0000000000..ed53274888 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/input/vr/openvr/OpenVRBounds.java @@ -0,0 +1,56 @@ +package com.jme3.input.vr.openvr; + +import com.jme3.input.vr.VRBounds; +import com.jme3.math.Vector2f; +import com.jme3.system.jopenvr.JOpenVRLibrary; +import com.jme3.system.jopenvr.VR_IVRChaperone_FnTable; +import com.sun.jna.ptr.FloatByReference; + +import java.util.logging.Logger; + +/** + * A class that represents VR world bounds. + * @author reden - phr00t - https://github.com/phr00t + * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr + */ +public class OpenVRBounds implements VRBounds { + private static Logger logger = Logger.getLogger(OpenVRBounds.class.getName()); + + private VR_IVRChaperone_FnTable vrChaperone; + private Vector2f playSize; + + /** + * Initialize the VR bounds. + * @return true if the initialization is a success and false otherwise. + */ + public boolean init(OpenVR api) { + logger.config("Initialize VR bounds..."); + + if( vrChaperone == null ) { + vrChaperone = new VR_IVRChaperone_FnTable(JOpenVRLibrary.VR_GetGenericInterface(JOpenVRLibrary.IVRChaperone_Version, api.hmdErrorStore).getPointer()); + if( vrChaperone != null ) { + vrChaperone.setAutoSynch(false); + vrChaperone.read(); + FloatByReference fbX = new FloatByReference(); + FloatByReference fbZ = new FloatByReference(); + vrChaperone.GetPlayAreaSize.apply(fbX, fbZ); + playSize = new Vector2f(fbX.getValue(), fbZ.getValue()); + + logger.config("Initialize VR bounds [SUCCESS]"); + return true; // init success + } + + logger.warning("Initialize VR bounds [FAILED]."); + return false; // failed to init + } + + logger.config("Initialize VR bounds already done."); + return true; // already initialized + } + + @Override + public Vector2f getPlaySize() { + return playSize; + } +} + diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/openvr/OpenVRInput.java b/jme3-xr/src/main/java/com/jme3/input/vr/openvr/OpenVRInput.java new file mode 100644 index 0000000000..6e4e536aec --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/input/vr/openvr/OpenVRInput.java @@ -0,0 +1,498 @@ +package com.jme3.input.vr.openvr; + +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; + +import com.jme3.app.VREnvironment; +import com.jme3.input.vr.VRInputAPI; +import com.jme3.input.vr.VRInputType; +import com.jme3.input.vr.VRTrackedController; +import com.jme3.math.Quaternion; +import com.jme3.math.Vector2f; +import com.jme3.math.Vector3f; +import com.jme3.renderer.Camera; +import com.jme3.scene.Spatial; +import com.jme3.system.jopenvr.JOpenVRLibrary; +import com.jme3.system.jopenvr.OpenVRUtil; +import com.jme3.system.jopenvr.VRControllerState_t; +import com.jme3.system.jopenvr.VR_IVRSystem_FnTable; +import com.jme3.util.VRUtil; + +/* +make helper functions to pull the following easily from raw data (DONE) + +trigger: +Controller#1, Axis#0 X: 0.0, Y: 0.0 +Controller#1, Axis#1 X: 1.0, Y: 0.0 +Controller#1, Axis#2 X: 0.0, Y: 0.0 +Controller#1, Axis#3 X: 0.0, Y: 0.0 +Controller#1, Axis#4 X: 0.0, Y: 0.0 +Button press: 8589934592 (when full), touch: 8589934592 + +touchpad (upper left): +Controller#1, Axis#0 X: -0.6059755, Y: 0.2301706 +Controller#1, Axis#1 X: 0.0, Y: 0.0 +Controller#1, Axis#2 X: 0.0, Y: 0.0 +Controller#1, Axis#3 X: 0.0, Y: 0.0 +Controller#1, Axis#4 X: 0.0, Y: 0.0 +Button press: 4294967296 (when pressed in), touch: 4294967296 + +grip: +Controller#1, Axis#0 X: 0.0, Y: 0.0 +Controller#1, Axis#1 X: 0.0, Y: 0.0 +Controller#1, Axis#2 X: 0.0, Y: 0.0 +Controller#1, Axis#3 X: 0.0, Y: 0.0 +Controller#1, Axis#4 X: 0.0, Y: 0.0 +Button press: 4, touch: 4 + +thumb: +Controller#1, Axis#0 X: 0.0, Y: 0.0 +Controller#1, Axis#1 X: 0.0, Y: 0.0 +Controller#1, Axis#2 X: 0.0, Y: 0.0 +Controller#1, Axis#3 X: 0.0, Y: 0.0 +Controller#1, Axis#4 X: 0.0, Y: 0.0 +Button press: 2, touch: 2 + +*/ + +/** + * A class that wraps an OpenVR input.
+ * null values will be returned if no valid pose exists, or that input device isn't available + * user code should check for null values. + * @author reden - phr00t - https://github.com/phr00t + * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr + */ +public class OpenVRInput implements VRInputAPI { + private static final Logger logger = Logger.getLogger(OpenVRInput.class.getName()); + + private final VRControllerState_t[] cStates = new VRControllerState_t[JOpenVRLibrary.k_unMaxTrackedDeviceCount]; + + private final Quaternion[] rotStore = new Quaternion[JOpenVRLibrary.k_unMaxTrackedDeviceCount]; + + private final Vector3f[] posStore = new Vector3f[JOpenVRLibrary.k_unMaxTrackedDeviceCount]; + + private static final int[] controllerIndex = new int[JOpenVRLibrary.k_unMaxTrackedDeviceCount]; + + private int controllerCount = 0; + + private final Vector2f tempAxis = new Vector2f(), temp2Axis = new Vector2f(); + + private final Vector2f lastCallAxis[] = new Vector2f[JOpenVRLibrary.k_unMaxTrackedDeviceCount]; + + private final boolean needsNewVelocity[] = new boolean[JOpenVRLibrary.k_unMaxTrackedDeviceCount]; + + private final boolean needsNewAngVelocity[] = new boolean[JOpenVRLibrary.k_unMaxTrackedDeviceCount]; + + private final boolean buttonDown[][] = new boolean[JOpenVRLibrary.k_unMaxTrackedDeviceCount][16]; + + private float axisMultiplier = 1f; + + private final Vector3f tempVel = new Vector3f(); + + private final Quaternion tempQuaternion = new Quaternion(); + + private VREnvironment environment; + + private List trackedControllers = null; + + /** + * Create a new OpenVR input attached to the given VR environment. + * @param environment the VR environment to which the input is attached. + */ + public OpenVRInput(VREnvironment environment){ + this.environment = environment; + } + + @Override + public float getAxisMultiplier() { + return axisMultiplier; + } + + @Override + public void setAxisMultiplier(float set) { + axisMultiplier = set; + } + + @Override + public void swapHands() { + if( controllerCount != 2 ) return; + int temp = controllerIndex[0]; + controllerIndex[0] = controllerIndex[1]; + controllerIndex[1] = temp; + } + + @Override + public boolean isButtonDown(int controllerIndex, VRInputType checkButton) { + VRControllerState_t cs = cStates[OpenVRInput.controllerIndex[controllerIndex]]; + switch( checkButton ) { + default: + return false; + case ViveGripButton: + return (cs.ulButtonPressed & 4) != 0; + case ViveMenuButton: + return (cs.ulButtonPressed & 2) != 0; + case ViveTrackpadAxis: + return (cs.ulButtonPressed & 4294967296l) != 0; + case ViveTriggerAxis: + return (cs.ulButtonPressed & 8589934592l) != 0; + } + } + + @Override + public boolean wasButtonPressedSinceLastCall(int controllerIndex, VRInputType checkButton) { + boolean buttonDownNow = isButtonDown(controllerIndex, checkButton); + int checkButtonValue = checkButton.getValue(); + int cIndex = OpenVRInput.controllerIndex[controllerIndex]; + boolean retval = buttonDownNow == true && buttonDown[cIndex][checkButtonValue] == false; + buttonDown[cIndex][checkButtonValue] = buttonDownNow; + return retval; + } + + @Override + public void resetInputSinceLastCall() { + for(int i=0;i 0) && (index < trackedControllers.size())){ + return trackedControllers.get(index); + } + } + + return null; + } + + @Override + public int getTrackedControllerCount() { + return controllerCount; + } + + @Override + public VRControllerState_t getRawControllerState(int index) { + if( isInputDeviceTracking(index) == false ) return null; + return cStates[controllerIndex[index]]; + } + + //public Matrix4f getPoseForInputDevice(int index) { + // if( isInputDeviceTracking(index) == false ) return null; + // return OpenVR.poseMatrices[controllerIndex[index]]; + //} + + @Override + public boolean isInputFocused() { + if (environment != null){ + return ((VR_IVRSystem_FnTable)environment.getVRHardware().getVRSystem()).IsInputAvailable.apply() == 0; + } else { + throw new IllegalStateException("VR input is not attached to a VR environment."); + } + } + + @Override + public boolean isInputDeviceTracking(int index) { + if( index < 0 || index >= controllerCount ){ + return false; + } + + if (environment != null){ + if (environment.getVRHardware() instanceof OpenVR){ + return ((OpenVR)environment.getVRHardware()).hmdTrackedDevicePoses[controllerIndex[index]].bPoseIsValid != 0; + } else { + throw new IllegalStateException("VR hardware "+environment.getVRHardware().getClass().getSimpleName()+" is not a subclass of "+OpenVR.class.getSimpleName()); + } + } else { + throw new IllegalStateException("VR input is not attached to a VR environment."); + } + } + + @Override + public Quaternion getOrientation(int index) { + if( isInputDeviceTracking(index) == false ){ + return null; + } + + if (environment != null){ + + if (environment.getVRHardware() instanceof OpenVR){ + index = controllerIndex[index]; + VRUtil.convertMatrix4toQuat(((OpenVR)environment.getVRHardware()).poseMatrices[index], rotStore[index]); + return rotStore[index]; + } else { + throw new IllegalStateException("VR hardware "+environment.getVRHardware().getClass().getSimpleName()+" is not a subclass of "+OpenVR.class.getSimpleName()); + } + } else { + throw new IllegalStateException("VR input is not attached to a VR environment."); + } + } + + @Override + public Vector3f getPosition(int index) { + if( isInputDeviceTracking(index) == false ){ + return null; + } + + if (environment != null){ + if (environment.getVRHardware() instanceof OpenVR){ + // the hmdPose comes in rotated funny, fix that here + index = controllerIndex[index]; + ((OpenVR)environment.getVRHardware()).poseMatrices[index].toTranslationVector(posStore[index]); + posStore[index].x = -posStore[index].x; + posStore[index].z = -posStore[index].z; + return posStore[index]; + } else { + throw new IllegalStateException("VR hardware "+environment.getVRHardware().getClass().getSimpleName()+" is not a subclass of "+OpenVR.class.getSimpleName()); + } + } else { + throw new IllegalStateException("VR input is not attached to a VR environment."); + } + } + + @Override + public Quaternion getFinalObserverRotation(int index) { + if (environment != null){ + OpenVRViewManager vrvm = (OpenVRViewManager)environment.getVRViewManager(); + + if (vrvm != null){ + if(isInputDeviceTracking(index) == false ){ + return null; + } + + Object obs = environment.getObserver(); + if( obs instanceof Camera ) { + tempQuaternion.set(((Camera)obs).getRotation()); + } else { + tempQuaternion.set(((Spatial)obs).getWorldRotation()); + } + + return tempQuaternion.multLocal(getOrientation(index)); + } else { + throw new IllegalStateException("VR environment has no valid view manager."); + } + + } else { + throw new IllegalStateException("VR input is not attached to a VR environment."); + } + } + + @Override + public Vector3f getFinalObserverPosition(int index) { + if (environment != null){ + OpenVRViewManager vrvm = (OpenVRViewManager)environment.getVRViewManager(); + + if (vrvm != null){ + if(isInputDeviceTracking(index) == false ){ + return null; + } + Object obs = environment.getObserver(); + Vector3f pos = getPosition(index); + if( obs instanceof Camera ) { + ((Camera)obs).getRotation().mult(pos, pos); + return pos.addLocal(((Camera)obs).getLocation()); + } else { + ((Spatial)obs).getWorldRotation().mult(pos, pos); + return pos.addLocal(((Spatial)obs).getWorldTranslation()); + } + } else { + throw new IllegalStateException("VR environment has no valid view manager."); + } + + } else { + throw new IllegalStateException("VR input is not attached to a VR environment."); + } + } + + @Override + public void triggerHapticPulse(int controllerIndex, float seconds) { + if( environment.isInVR() == false || isInputDeviceTracking(controllerIndex) == false ){ + return; + } + + // apparently only axis ID of 0 works + ((VR_IVRSystem_FnTable)environment.getVRHardware().getVRSystem()).TriggerHapticPulse.apply(OpenVRInput.controllerIndex[controllerIndex], + 0, (short)Math.round(3f * seconds / 1e-3f)); + } + + @Override + public void updateConnectedControllers() { + logger.config("Updating connected controllers."); + + if (environment != null){ + controllerCount = 0; + for(int i=0;i(JOpenVRLibrary.k_unMaxTrackedDeviceCount); + } + trackedControllers.add(new OpenVRTrackedController(i, this, controllerName, manufacturerName, environment)); + + // Send a Haptic pulse to the controller + triggerHapticPulse(controllerCount, 1.0f); + + controllerCount++; + logger.config(" Tracked controller "+(i+1)+"/"+JOpenVRLibrary.k_unMaxTrackedDeviceCount+" "+controllerName+" ("+manufacturerName+") attached."); + } else { + logger.config(" Controller "+(i+1)+"/"+JOpenVRLibrary.k_unMaxTrackedDeviceCount+" ignored."); + } + } + } else { + throw new IllegalStateException("VR input is not attached to a VR environment."); + } + } + + @Override + public void updateControllerStates() { + if (environment != null){ + for(int i=0;ihttp://www.seinturier.fr + */ +public class OpenVRMouseManager extends AbstractVRMouseManager { + private final int AVERAGE_AMNT = 4; + + private int avgCounter; + + private final float[] lastXmv = new float[AVERAGE_AMNT]; + + private final float[] lastYmv = new float[AVERAGE_AMNT]; + + /** + * Create a new VR mouse manager within the given {@link VREnvironment VR environment}. + * @param environment the VR environment of the mouse manager. + */ + public OpenVRMouseManager(VREnvironment environment){ + super(environment); + } + + @Override + public void updateAnalogAsMouse(int inputIndex, AnalogListener mouseListener, String mouseXName, String mouseYName, float tpf) { + if (getVREnvironment() != null){ + if (getVREnvironment().getApplication() != null){ + // got a tracked controller to use as the "mouse" + if( getVREnvironment().isInVR() == false || + getVREnvironment().getVRinput() == null || + getVREnvironment().getVRinput().isInputDeviceTracking(inputIndex) == false ){ + return; + } + + Vector2f tpDelta; + // TODO option to use Touch joysticks + if( isThumbstickMode() ) { + tpDelta = getVREnvironment().getVRinput().getAxis(inputIndex, VRInputType.ViveTrackpadAxis); + } else { + tpDelta = getVREnvironment().getVRinput().getAxisDeltaSinceLastCall(inputIndex, VRInputType.ViveTrackpadAxis); + } + + float xAmount = (float)Math.pow(Math.abs(tpDelta.x) * getSpeedSensitivity(), getSpeedAcceleration()); + float yAmount = (float)Math.pow(Math.abs(tpDelta.y) * getSpeedSensitivity(), getSpeedAcceleration()); + + if( tpDelta.x < 0f ){ + xAmount = -xAmount; + } + + if( tpDelta.y < 0f ){ + yAmount = -yAmount; + } + + xAmount *= getMouseMoveScale(); + yAmount *= getMouseMoveScale(); + + if( mouseListener != null ) { + if( tpDelta.x != 0f && mouseXName != null ) mouseListener.onAnalog(mouseXName, xAmount * 0.2f, tpf); + if( tpDelta.y != 0f && mouseYName != null ) mouseListener.onAnalog(mouseYName, yAmount * 0.2f, tpf); + } + + if( getVREnvironment().getApplication().getInputManager().isCursorVisible() ) { + int index = (avgCounter+1) % AVERAGE_AMNT; + lastXmv[index] = xAmount * 133f; + lastYmv[index] = yAmount * 133f; + cursorPos.x -= avg(lastXmv); + cursorPos.y -= avg(lastYmv); + Vector2f maxsize = getVREnvironment().getVRGUIManager().getCanvasSize(); + + if( cursorPos.x > maxsize.x ){ + cursorPos.x = maxsize.x; + } + + if( cursorPos.x < 0f ){ + cursorPos.x = 0f; + } + + if( cursorPos.y > maxsize.y ){ + cursorPos.y = maxsize.y; + } + + if( cursorPos.y < 0f ){ + cursorPos.y = 0f; + } + } + } else { + throw new IllegalStateException("This VR environment is not attached to any application."); + } + } else { + throw new IllegalStateException("This VR view manager is not attached to any VR environment."); + } + } + + private float avg(float[] arr) { + float amt = 0f; + for(float f : arr) amt += f; + return amt / arr.length; + } +} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/openvr/OpenVRTrackedController.java b/jme3-xr/src/main/java/com/jme3/input/vr/openvr/OpenVRTrackedController.java new file mode 100644 index 0000000000..bcd521e891 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/input/vr/openvr/OpenVRTrackedController.java @@ -0,0 +1,95 @@ +package com.jme3.input.vr.openvr; + +import com.jme3.app.VREnvironment; +import com.jme3.input.vr.VRTrackedController; +import com.jme3.math.Matrix4f; +import com.jme3.math.Quaternion; +import com.jme3.math.Vector3f; + +/** + * A controller that is tracked within the VR environment. Such a controller can provide its position within the VR space. + * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr + * + */ +public class OpenVRTrackedController implements VRTrackedController{ + /** + * The index of the controller within the underlying VR API. + */ + private int controllerIndex = -1; + + /** + * The underlying VRAPI. + */ + private OpenVRInput hardware = null; + + /** + * The name of the controller. + */ + private String name; + + private VREnvironment environment; + + /** + * Wrap a new VR tracked controller on an OpenVR system. + * @param controllerIndex the index of the controller within the underlying VR system. + * @param hardware the underlying VR system. + * @param name the name of the controller. + * @param manufacturer the manufacturer of the controller. + * @param environment the VR environment. + */ + public OpenVRTrackedController(int controllerIndex, OpenVRInput hardware, String name, String manufacturer, VREnvironment environment){ + this.controllerIndex = controllerIndex; + this.hardware = hardware; + + this.name = name; + this.manufacturer = manufacturer; + + this.environment = environment; + } + + /** + * The manufacturer of the controller. + */ + private String manufacturer; + + @Override + public Vector3f getPosition() { + if (hardware != null){ + return hardware.getPosition(controllerIndex); + } else { + throw new IllegalStateException("No underlying VR API."); + } + } + + @Override + public Quaternion getOrientation() { + if (hardware != null){ + return hardware.getOrientation(controllerIndex); + } else { + throw new IllegalStateException("No underlying VR API."); + } + } + + @Override + public Matrix4f getPose(){ + if (environment != null){ + if (hardware != null){ + return ((OpenVR)environment.getVRHardware()).poseMatrices[controllerIndex]; + } else { + throw new IllegalStateException("No underlying VR API."); + } + } else { + throw new IllegalStateException("VR tracked device is not attached to any environment."); + } + } + + @Override + public String getControllerName() { + return name; + } + + @Override + public String getControllerManufacturer() { + return manufacturer; + } +} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/openvr/OpenVRViewManager.java b/jme3-xr/src/main/java/com/jme3/input/vr/openvr/OpenVRViewManager.java new file mode 100644 index 0000000000..c6d0237321 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/input/vr/openvr/OpenVRViewManager.java @@ -0,0 +1,733 @@ +package com.jme3.input.vr.openvr; + +import com.jme3.app.VREnvironment; +import com.jme3.input.vr.AbstractVRViewManager; +import com.jme3.input.vr.VRAPI; +import com.jme3.material.Material; +import com.jme3.math.ColorRGBA; +import com.jme3.math.Quaternion; +import com.jme3.math.Vector2f; +import com.jme3.math.Vector3f; +import com.jme3.renderer.Camera; +import com.jme3.renderer.ViewPort; +import com.jme3.renderer.queue.RenderQueue.Bucket; +import com.jme3.scene.Geometry; +import com.jme3.scene.Mesh; +import com.jme3.scene.Node; +import com.jme3.scene.Spatial; +import com.jme3.scene.VertexBuffer; +import com.jme3.system.jopenvr.DistortionCoordinates_t; +import com.jme3.system.jopenvr.JOpenVRLibrary; +import com.jme3.system.jopenvr.OpenVRUtil; +import com.jme3.system.jopenvr.Texture_t; +import com.jme3.system.jopenvr.VRTextureBounds_t; +import com.jme3.system.jopenvr.VR_IVRSystem_FnTable; +import com.jme3.texture.FrameBuffer; +import com.jme3.texture.Image; +import com.jme3.texture.Texture; +import com.jme3.texture.Texture2D; +import com.jme3.ui.Picture; +import com.jme3.util.VRGUIPositioningMode; + +import java.util.Iterator; +import java.util.logging.Logger; + +/** + * A VR view manager based on OpenVR. This class enable to submit 3D views to the VR compositor. + * @author reden - phr00t - https://github.com/phr00t + * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr + */ +public class OpenVRViewManager extends AbstractVRViewManager { + private static final Logger logger = Logger.getLogger(OpenVRViewManager.class.getName()); + + // OpenVR values + private VRTextureBounds_t leftTextureBounds; + private Texture_t leftTextureType; + + private VRTextureBounds_t rightTextureBounds; + private Texture_t rightTextureType; + + private Texture2D dualEyeTex; + + //final & temp values for camera calculations + private final Vector3f finalPosition = new Vector3f(); + private final Quaternion finalRotation = new Quaternion(); + private final Vector3f hmdPos = new Vector3f(); + private final Quaternion hmdRot = new Quaternion(); + + /** + * Create a new VR view manager attached to the given {@link VREnvironment VR environment}. + * @param environment the {@link VREnvironment VR environment} to which this view manager is attached. + */ + public OpenVRViewManager(VREnvironment environment){ + this.environment = environment; + } + + /** + * Get the identifier of the left eye texture. + * @return the identifier of the left eye texture. + * @see #getRightTexId() + * @see #getFullTexId() + */ + protected int getLeftTexId() { + return getLeftTexture().getImage().getId(); + } + + /** + * Get the identifier of the right eye texture. + * @return the identifier of the right eye texture. + * @see #getLeftTexId() + * @see #getFullTexId() + */ + protected int getRightTexId() { + return getRightTexture().getImage().getId(); + } + + /** + * Get the identifier of the full (dual eye) texture. + * @return the identifier of the full (dual eye) texture. + * @see #getLeftTexId() + * @see #getRightTexId() + */ + private int getFullTexId() { + return dualEyeTex.getImage().getId(); + } + + /** + * Initialize the system binds of the textures. + */ + private void initTextureSubmitStructs() { + leftTextureType = new Texture_t(); + rightTextureType = new Texture_t(); + + if (environment != null){ + if( environment.getVRHardware() instanceof OpenVR ) { + leftTextureBounds = new VRTextureBounds_t(); + rightTextureBounds = new VRTextureBounds_t(); + // left eye + leftTextureBounds.uMax = 0.5f; + leftTextureBounds.uMin = 0f; + leftTextureBounds.vMax = 1f; + leftTextureBounds.vMin = 0f; + leftTextureBounds.setAutoSynch(false); + leftTextureBounds.setAutoRead(false); + leftTextureBounds.setAutoWrite(false); + leftTextureBounds.write(); + // right eye + rightTextureBounds.uMax = 1f; + rightTextureBounds.uMin = 0.5f; + rightTextureBounds.vMax = 1f; + rightTextureBounds.vMin = 0f; + rightTextureBounds.setAutoSynch(false); + rightTextureBounds.setAutoRead(false); + rightTextureBounds.setAutoWrite(false); + rightTextureBounds.write(); + // texture type + leftTextureType.eColorSpace = JOpenVRLibrary.EColorSpace.EColorSpace_ColorSpace_Gamma; + leftTextureType.eType = JOpenVRLibrary.ETextureType.ETextureType_TextureType_OpenGL; + leftTextureType.setAutoSynch(false); + leftTextureType.setAutoRead(false); + leftTextureType.setAutoWrite(false); + leftTextureType.handle = -1; + rightTextureType.eColorSpace = JOpenVRLibrary.EColorSpace.EColorSpace_ColorSpace_Gamma; + rightTextureType.eType = JOpenVRLibrary.ETextureType.ETextureType_TextureType_OpenGL; + rightTextureType.setAutoSynch(false); + rightTextureType.setAutoRead(false); + rightTextureType.setAutoWrite(false); + rightTextureType.handle = -1; + + logger.config("Init eyes native texture binds"); + logger.config(" Left eye texture"); + logger.config(" address: "+leftTextureType.getPointer()); + logger.config(" size: "+leftTextureType.size()+" bytes"); + logger.config(" color space: "+OpenVRUtil.getEColorSpaceString(leftTextureType.eColorSpace)); + logger.config(" type: "+OpenVRUtil.getETextureTypeString(leftTextureType.eType)); + logger.config(" auto read: "+leftTextureType.getAutoRead()); + logger.config(" auto write: "+leftTextureType.getAutoWrite()); + logger.config(" handle address: "+leftTextureType.handle); + logger.config(" handle value: "+leftTextureType.handle); + logger.config(""); + logger.config(" Right eye texture"); + logger.config(" address: "+rightTextureType.getPointer()); + logger.config(" size: "+rightTextureType.size()+" bytes"); + logger.config(" color space: "+OpenVRUtil.getEColorSpaceString(rightTextureType.eColorSpace)); + logger.config(" type: "+OpenVRUtil.getETextureTypeString(rightTextureType.eType)); + logger.config(" auto read: "+rightTextureType.getAutoRead()); + logger.config(" auto write: "+rightTextureType.getAutoWrite()); + logger.config(" handle address: "+rightTextureType.handle); + logger.config(" handle value: "+rightTextureType.handle); + } + } else { + throw new IllegalStateException("This VR view manager is not attached to any VR environment."); + } + } + + @Override + public void render() { + } + + @Override + public void postRender() { + if (environment != null){ + if( environment.isInVR() ) { + VRAPI api = environment.getVRHardware(); + if( api.getCompositor() != null ) { + // using the compositor... + int errl = 0, errr = 0; + if( environment.isInstanceRendering() ) { + if( leftTextureType.handle == -1 || leftTextureType.handle != getFullTexId() ) { + leftTextureType.handle = getFullTexId(); + if( leftTextureType.handle != -1 ) { + leftTextureType.write(); + } + } else { + if( api instanceof OpenVR ) { + int submitFlag = JOpenVRLibrary.EVRSubmitFlags.EVRSubmitFlags_Submit_Default; + errr = ((OpenVR)api).getCompositor().Submit.apply(JOpenVRLibrary.EVREye.EVREye_Eye_Right, leftTextureType, rightTextureBounds, submitFlag); + errl = ((OpenVR)api).getCompositor().Submit.apply(JOpenVRLibrary.EVREye.EVREye_Eye_Left, leftTextureType, leftTextureBounds, submitFlag); + } + } + } else if( leftTextureType.handle == -1 || rightTextureType.handle == -1 || + leftTextureType.handle != getLeftTexId() || rightTextureType.handle != getRightTexId() ) { + leftTextureType.handle = getLeftTexId(); + if( leftTextureType.handle != -1 ) { + logger.fine("Writing Left texture to native memory at " + leftTextureType.getPointer()); + leftTextureType.write(); + } + rightTextureType.handle = getRightTexId(); + if( rightTextureType.handle != -1 ) { + logger.fine("Writing Right texture to native memory at " + leftTextureType.getPointer()); + rightTextureType.write(); + } + } else { + if( api instanceof OpenVR ) { + errl = ((OpenVR)api).getCompositor().Submit.apply(JOpenVRLibrary.EVREye.EVREye_Eye_Left, leftTextureType, null, + JOpenVRLibrary.EVRSubmitFlags.EVRSubmitFlags_Submit_Default); + errr = ((OpenVR)api).getCompositor().Submit.apply(JOpenVRLibrary.EVREye.EVREye_Eye_Right, rightTextureType, null, + JOpenVRLibrary.EVRSubmitFlags.EVRSubmitFlags_Submit_Default); + } else { + + } + } + + if( errl != 0 ){ + logger.severe("Submit to left compositor error: " + OpenVRUtil.getEVRCompositorErrorString(errl)+" ("+Integer.toString(errl)+")"); + logger.severe(" Texture color space: "+OpenVRUtil.getEColorSpaceString(leftTextureType.eColorSpace)); + logger.severe(" Texture type: "+OpenVRUtil.getETextureTypeString(leftTextureType.eType)); + logger.severe(" Texture handle: "+leftTextureType.handle); + + logger.severe(" Left eye texture "+leftEyeTexture.getName()+" ("+leftEyeTexture.getImage().getId()+")"); + logger.severe(" Type: "+leftEyeTexture.getType()); + logger.severe(" Size: "+leftEyeTexture.getImage().getWidth()+"x"+leftEyeTexture.getImage().getHeight()); + logger.severe(" Image depth: "+leftEyeTexture.getImage().getDepth()); + logger.severe(" Image format: "+leftEyeTexture.getImage().getFormat()); + logger.severe(" Image color space: "+leftEyeTexture.getImage().getColorSpace()); + } + + if( errr != 0 ){ + logger.severe("Submit to right compositor error: " + OpenVRUtil.getEVRCompositorErrorString(errl)+" ("+Integer.toString(errl)+")"); + logger.severe(" Texture color space: "+OpenVRUtil.getEColorSpaceString(rightTextureType.eColorSpace)); + logger.severe(" Texture type: "+OpenVRUtil.getETextureTypeString(rightTextureType.eType)); + logger.severe(" Texture handle: "+rightTextureType.handle); + + logger.severe(" Right eye texture "+rightEyeTexture.getName()+" ("+rightEyeTexture.getImage().getId()+")"); + logger.severe(" Type: "+rightEyeTexture.getType()); + logger.severe(" Size: "+rightEyeTexture.getImage().getWidth()+"x"+rightEyeTexture.getImage().getHeight()); + logger.severe(" Image depth: "+rightEyeTexture.getImage().getDepth()); + logger.severe(" Image format: "+rightEyeTexture.getImage().getFormat()); + logger.severe(" Image color space: "+rightEyeTexture.getImage().getColorSpace()); + } + } + } + } else { + throw new IllegalStateException("This VR view manager is not attached to any VR environment."); + } + } + + @Override + public void initialize() { + logger.config("Initializing VR view manager."); + + if (environment != null){ + initTextureSubmitStructs(); + setupCamerasAndViews(); + setupVRScene(); + moveScreenProcessingToEyes(); + + if( environment.hasTraditionalGUIOverlay() ) { + environment.getVRMouseManager().initialize(); + + // update the pose to position the gui correctly on start + update(0f); + environment.getVRGUIManager().positionGui(); + } + + logger.config("Initialized VR view manager [SUCCESS]"); + + } else { + throw new IllegalStateException("This VR view manager is not attached to any VR environment."); + } + } + + /** + * Prepare the size of the given {@link Camera camera} to adapt it to the underlying rendering context. + * @param cam the {@link Camera camera} to prepare. + * @param xMult the camera width multiplier. + */ + private void prepareCameraSize(Camera cam, float xMult) { + if (environment != null){ + + if (environment.getApplication() != null){ + Vector2f size = new Vector2f(); + VRAPI vrhmd = environment.getVRHardware(); + + if( vrhmd == null ) { + size.x = 1280f; + size.y = 720f; + } else { + vrhmd.getRenderSize(size); + } + + if( size.x < environment.getApplication().getContext().getSettings().getWidth() ) { + size.x = environment.getApplication().getContext().getSettings().getWidth(); + } + if( size.y < environment.getApplication().getContext().getSettings().getHeight() ) { + size.y = environment.getApplication().getContext().getSettings().getHeight(); + } + + if( environment.isInstanceRendering() ){ + size.x *= 2f; + } + + // other adjustments + size.x *= xMult; + size.x *= getResolutionMuliplier(); + size.y *= getResolutionMuliplier(); + + if( cam.getWidth() != size.x || cam.getHeight() != size.y ){ + cam.resize((int)size.x, (int)size.y, false); + } + } else { + throw new IllegalStateException("This VR environment is not attached to any application."); + } + + } else { + throw new IllegalStateException("This VR view manager is not attached to any VR environment."); + } + } + + /** + * Replaces rootNode with the distortion mesh as the main camera's scene. + */ + private void setupVRScene(){ + if (environment != null){ + if (environment.getApplication() != null){ + // no special scene to set up if we are doing instancing + if( environment.isInstanceRendering() ) { + // distortion has to be done with compositor here... we want only one pass on our end! + if( environment.getApplication().getContext().getSettings().isSwapBuffers() ) { + setupMirrorBuffers(environment.getCamera(), dualEyeTex, true); + } + return; + } + + leftEyeTexture = (Texture2D) getLeftViewPort().getOutputFrameBuffer().getColorBuffer().getTexture(); + rightEyeTexture = (Texture2D)getRightViewPort().getOutputFrameBuffer().getColorBuffer().getTexture(); + leftEyeDepth = (Texture2D) getLeftViewPort().getOutputFrameBuffer().getDepthBuffer().getTexture(); + rightEyeDepth = (Texture2D)getRightViewPort().getOutputFrameBuffer().getDepthBuffer().getTexture(); + + // main viewport is either going to be a distortion scene or nothing + // mirroring is handled by copying framebuffers + Iterator spatialIter = environment.getApplication().getViewPort().getScenes().iterator(); + while(spatialIter.hasNext()){ + environment.getApplication().getViewPort().detachScene(spatialIter.next()); + } + + spatialIter = environment.getApplication().getGuiViewPort().getScenes().iterator(); + while(spatialIter.hasNext()){ + environment.getApplication().getGuiViewPort().detachScene(spatialIter.next()); + } + + // only setup distortion scene if compositor isn't running (or using custom mesh distortion option) + if( environment.getVRHardware().getCompositor() == null ) { + Node distortionScene = new Node(); + Material leftMat = new Material(environment.getApplication().getAssetManager(), "Common/MatDefs/VR/OpenVR.j3md"); + leftMat.setTexture("Texture", leftEyeTexture); + Geometry leftEye = new Geometry("box", setupDistortionMesh(JOpenVRLibrary.EVREye.EVREye_Eye_Left, environment.getVRHardware())); + leftEye.setMaterial(leftMat); + distortionScene.attachChild(leftEye); + + Material rightMat = new Material(environment.getApplication().getAssetManager(), "Common/MatDefs/VR/OpenVR.j3md"); + rightMat.setTexture("Texture", rightEyeTexture); + Geometry rightEye = new Geometry("box", setupDistortionMesh(JOpenVRLibrary.EVREye.EVREye_Eye_Right, environment.getVRHardware())); + rightEye.setMaterial(rightMat); + distortionScene.attachChild(rightEye); + + distortionScene.updateGeometricState(); + + environment.getApplication().getViewPort().attachScene(distortionScene); + + //if( useCustomDistortion ) setupFinalFullTexture(app.getViewPort().getCamera()); + } + + if( environment.getApplication().getContext().getSettings().isSwapBuffers() ) { + setupMirrorBuffers(environment.getCamera(), leftEyeTexture, false); + } + } else { + throw new IllegalStateException("This VR environment is not attached to any application."); + } + } else { + throw new IllegalStateException("This VR view manager is not attached to any VR environment."); + } + } + + @Override + public void update(float tpf) { + if (environment != null){ + // grab the observer + Object obs = environment.getObserver(); + Quaternion objRot; + Vector3f objPos; + if( obs instanceof Camera ) { + objRot = ((Camera)obs).getRotation(); + objPos = ((Camera)obs).getLocation(); + } else { + objRot = ((Spatial)obs).getWorldRotation(); + objPos = ((Spatial)obs).getWorldTranslation(); + } + // grab the hardware handle + VRAPI dev = environment.getVRHardware(); + if( dev != null ) { + // update the HMD's position & orientation + dev.updatePose(); + dev.getPositionAndOrientation(hmdPos, hmdRot); +/* + // TOREMOVE + Vector3f v = dev.getVRinput().getTrackedController(0).getPosition(); + Quaternion q = dev.getVRinput().getTrackedController(0).getOrientation(); + if ((v != null)&&(q != null)){ + hmdPos.set(v); + hmdRot.set(q); + } + + logger.severe("HMD controller "); + logger.severe(" Position "+hmdPos); + logger.severe(" Orientation "+hmdRot); + + VRTrackedController tc = null; + for(int i = 0; i < dev.getVRinput().getTrackedControllerCount(); i++){ + tc = dev.getVRinput().getTrackedController(i); + logger.severe("Tracked controller "+i+": "+tc.getControllerName()); + logger.severe(" Position "+tc.getPosition()); + logger.severe(" Orientation "+tc.getOrientation()); + logger.severe(""); + } +*/ + // TOREMOVE + + if( obs != null ) { + // update hmdPos based on obs rotation + finalRotation.set(objRot); + finalRotation.mult(hmdPos, hmdPos); + finalRotation.multLocal(hmdRot); + } + + finalizeCamera(dev.getHMDVectorPoseLeftEye(), objPos, getLeftCamera()); + finalizeCamera(dev.getHMDVectorPoseRightEye(), objPos, getRightCamera()); + } else { + getLeftCamera().setFrame(objPos, objRot); + getRightCamera().setFrame(objPos, objRot); + } + + if( environment.hasTraditionalGUIOverlay() ) { + // update the mouse? + environment.getVRMouseManager().update(tpf); + + // update GUI position? + if( environment.getVRGUIManager().isWantsReposition() || environment.getVRGUIManager().getPositioningMode() != VRGUIPositioningMode.MANUAL ) { + environment.getVRGUIManager().positionGuiNow(tpf); + environment.getVRGUIManager().updateGuiQuadGeometricState(); + } + } + } else { + throw new IllegalStateException("This VR view manager is not attached to any VR environment."); + } + } + + /** + * Place the camera within the scene. + * @param eyePos the eye position. + * @param obsPosition the observer position. + * @param cam the camera to place. + */ + private void finalizeCamera(Vector3f eyePos, Vector3f obsPosition, Camera cam) { + finalRotation.mult(eyePos, finalPosition); + finalPosition.addLocal(hmdPos); + if( obsPosition != null ) finalPosition.addLocal(obsPosition); + finalPosition.y += getHeightAdjustment(); + cam.setFrame(finalPosition, finalRotation); + } + + private void setupCamerasAndViews() { + if (environment != null){ + // get desired frustum from original camera + Camera origCam = environment.getCamera(); + float fFar = origCam.getFrustumFar(); + float fNear = origCam.getFrustumNear(); + + // restore frustum on distortion scene cam, if needed + if( environment.isInstanceRendering() ) { + leftCamera = origCam; + } else if( environment.compositorAllowed() == false ) { + origCam.setFrustumFar(100f); + origCam.setFrustumNear(1f); + leftCamera = origCam.clone(); + prepareCameraSize(origCam, 2f); + } else { + leftCamera = origCam.clone(); + } + + getLeftCamera().setFrustumPerspective(environment.getDefaultFOV(), environment.getDefaultAspect(), fNear, fFar); + + prepareCameraSize(getLeftCamera(), 1f); + if( environment.getVRHardware() != null ) { + getLeftCamera().setProjectionMatrix(environment.getVRHardware().getHMDMatrixProjectionLeftEye(getLeftCamera())); + } + //org.lwjgl.opengl.GL11.glEnable(org.lwjgl.opengl.GL30.GL_FRAMEBUFFER_SRGB); + + if( !environment.isInstanceRendering()) { + leftViewPort = setupViewBuffers(getLeftCamera(), LEFT_VIEW_NAME); + rightCamera = getLeftCamera().clone(); + if( environment.getVRHardware() != null ){ + getRightCamera().setProjectionMatrix(environment.getVRHardware().getHMDMatrixProjectionRightEye(getRightCamera())); + } + rightViewPort = setupViewBuffers(getRightCamera(), RIGHT_VIEW_NAME); + } else { + if (environment.getApplication() != null){ + + logger.severe("THIS CODE NEED CHANGES !!!"); + leftViewPort = environment.getApplication().getViewPort(); + //leftViewport.attachScene(app.getRootNode()); + rightCamera = getLeftCamera().clone(); + if( environment.getVRHardware() != null ){ + getRightCamera().setProjectionMatrix(environment.getVRHardware().getHMDMatrixProjectionRightEye(getRightCamera())); + } + + org.lwjgl.opengl.GL11.glEnable(org.lwjgl.opengl.GL30.GL_CLIP_DISTANCE0); + + //FIXME: [jme-vr] Fix with JMonkey next release + //RenderManager._VRInstancing_RightCamProjection = camRight.getViewProjectionMatrix(); + setupFinalFullTexture(environment.getApplication().getViewPort().getCamera()); + } else { + throw new IllegalStateException("This VR environment is not attached to any application."); + } + } + + // setup gui + environment.getVRGUIManager().setupGui(getLeftCamera(), getRightCamera(), getLeftViewPort(), getRightViewPort()); + + if( environment.getVRHardware() != null ) { + // call these to cache the results internally + environment.getVRHardware().getHMDMatrixPoseLeftEye(); + environment.getVRHardware().getHMDMatrixPoseRightEye(); + } + } else { + throw new IllegalStateException("This VR view manager is not attached to any VR environment."); + } + } + + private ViewPort setupMirrorBuffers(Camera cam, Texture tex, boolean expand) { + if (environment != null){ + if (environment.getApplication() != null){ + Camera cloneCam = cam.clone(); + ViewPort viewPort = environment.getApplication().getRenderManager().createPostView("MirrorView", cloneCam); + cloneCam.setParallelProjection(true); + viewPort.setClearFlags(true, true, true); + viewPort.setBackgroundColor(ColorRGBA.Black); + Picture pic = new Picture("fullscene"); + pic.setLocalTranslation(-0.75f, -0.5f, 0f); + if( expand ) { + pic.setLocalScale(3f, 1f, 1f); + } else { + pic.setLocalScale(1.5f, 1f, 1f); + } + pic.setQueueBucket(Bucket.Opaque); + pic.setTexture(environment.getApplication().getAssetManager(), (Texture2D)tex, false); + viewPort.attachScene(pic); + viewPort.setOutputFrameBuffer(null); + + pic.updateGeometricState(); + + return viewPort; + } else { + throw new IllegalStateException("This VR environment is not attached to any application."); + } + } else { + throw new IllegalStateException("This VR view manager is not attached to any VR environment."); + } + } + + private void setupFinalFullTexture(Camera cam) { + if (environment != null){ + if (environment.getApplication() != null){ + // create offscreen framebuffer + FrameBuffer out = new FrameBuffer(cam.getWidth(), cam.getHeight(), 1); + //offBuffer.setSrgb(true); + + //setup framebuffer's texture + dualEyeTex = new Texture2D(cam.getWidth(), cam.getHeight(), Image.Format.RGBA8); + dualEyeTex.setMinFilter(Texture.MinFilter.BilinearNoMipMaps); + dualEyeTex.setMagFilter(Texture.MagFilter.Bilinear); + + logger.config("Dual eye texture "+dualEyeTex.getName()+" ("+dualEyeTex.getImage().getId()+")"); + logger.config(" Type: "+dualEyeTex.getType()); + logger.config(" Size: "+dualEyeTex.getImage().getWidth()+"x"+dualEyeTex.getImage().getHeight()); + logger.config(" Image depth: "+dualEyeTex.getImage().getDepth()); + logger.config(" Image format: "+dualEyeTex.getImage().getFormat()); + logger.config(" Image color space: "+dualEyeTex.getImage().getColorSpace()); + + //setup framebuffer to use texture + out.setDepthBuffer(Image.Format.Depth); + out.setColorTexture(dualEyeTex); + + ViewPort viewPort = environment.getApplication().getViewPort(); + viewPort.setClearFlags(true, true, true); + viewPort.setBackgroundColor(ColorRGBA.Black); + viewPort.setOutputFrameBuffer(out); + } else { + throw new IllegalStateException("This VR environment is not attached to any application."); + } + } else { + throw new IllegalStateException("This VR view manager is not attached to any VR environment."); + } + } + + private ViewPort setupViewBuffers(Camera cam, String viewName){ + if (environment != null){ + if (environment.getApplication() != null){ + // create offscreen framebuffer + FrameBuffer offBufferLeft = new FrameBuffer(cam.getWidth(), cam.getHeight(), 1); + //offBufferLeft.setSrgb(true); + + //setup framebuffer's texture + Texture2D offTex = new Texture2D(cam.getWidth(), cam.getHeight(), Image.Format.RGBA8); + offTex.setMinFilter(Texture.MinFilter.BilinearNoMipMaps); + offTex.setMagFilter(Texture.MagFilter.Bilinear); + + //setup framebuffer to use texture + offBufferLeft.setDepthBuffer(Image.Format.Depth); + offBufferLeft.setColorTexture(offTex); + + ViewPort viewPort = environment.getApplication().getRenderManager().createPreView(viewName, cam); + viewPort.setClearFlags(true, true, true); + viewPort.setBackgroundColor(ColorRGBA.Black); + + Iterator spatialIter = environment.getApplication().getViewPort().getScenes().iterator(); + while(spatialIter.hasNext()){ + viewPort.attachScene(spatialIter.next()); + } + + //set viewport to render to offscreen framebuffer + viewPort.setOutputFrameBuffer(offBufferLeft); + return viewPort; + } else { + throw new IllegalStateException("This VR environment is not attached to any application."); + } + } else { + throw new IllegalStateException("This VR view manager is not attached to any VR environment."); + } + } + + /** + * Set up a distortion mesh for the stereo view. + * @param eye the eye to apply. + * @param api the underlying VR api + * @return the distorted mesh. + */ + public static Mesh setupDistortionMesh(int eye, VRAPI api) { + Mesh distortionMesh = new Mesh(); + float m_iLensGridSegmentCountH = 43, m_iLensGridSegmentCountV = 43; + + float w = 1f / (m_iLensGridSegmentCountH - 1f); + float h = 1f / (m_iLensGridSegmentCountV - 1f); + + float u, v; + + float verts[] = new float[(int) (m_iLensGridSegmentCountV * m_iLensGridSegmentCountH) * 3]; + + float texcoordR[] = new float[(int) (m_iLensGridSegmentCountV * m_iLensGridSegmentCountH) * 2]; + float texcoordG[] = new float[(int) (m_iLensGridSegmentCountV * m_iLensGridSegmentCountH) * 2]; + float texcoordB[] = new float[(int) (m_iLensGridSegmentCountV * m_iLensGridSegmentCountH) * 2]; + + int vertPos = 0, coordPos = 0; + + float Xoffset = eye == JOpenVRLibrary.EVREye.EVREye_Eye_Left ? -1f : 0; + for (int y = 0; y < m_iLensGridSegmentCountV; y++) { + for (int x = 0; x < m_iLensGridSegmentCountH; x++) { + u = x * w; + v = 1 - y * h; + verts[vertPos] = Xoffset + u; // x + verts[vertPos + 1] = -1 + 2 * y * h; // y + verts[vertPos + 2] = 0f; // z + vertPos += 3; + + DistortionCoordinates_t dc0 = new DistortionCoordinates_t(); + if( api.getVRSystem() == null ) { + // default to no distortion + texcoordR[coordPos] = u; + texcoordR[coordPos + 1] = 1 - v; + texcoordG[coordPos] = u; + texcoordG[coordPos + 1] = 1 - v; + texcoordB[coordPos] = u; + texcoordB[coordPos + 1] = 1 - v; + } else { + ((VR_IVRSystem_FnTable)api.getVRSystem()).ComputeDistortion.apply(eye, u, v, dc0); + + texcoordR[coordPos] = dc0.rfRed[0]; + texcoordR[coordPos + 1] = 1 - dc0.rfRed[1]; + texcoordG[coordPos] = dc0.rfGreen[0]; + texcoordG[coordPos + 1] = 1 - dc0.rfGreen[1]; + texcoordB[coordPos] = dc0.rfBlue[0]; + texcoordB[coordPos + 1] = 1 - dc0.rfBlue[1]; + } + + coordPos += 2; + } + } + + // have UV coordinates & positions, now set up indices + + int[] indices = new int[(int) ((m_iLensGridSegmentCountV - 1) * (m_iLensGridSegmentCountH - 1)) * 6]; + int indexPos = 0; + int a, b, c, d; + + int offset = 0; + for (int y = 0; y < m_iLensGridSegmentCountV - 1; y++) { + for (int x = 0; x < m_iLensGridSegmentCountH - 1; x++) { + a = (int) (m_iLensGridSegmentCountH * y + x + offset); + b = (int) (m_iLensGridSegmentCountH * y + x + 1 + offset); + c = (int) ((y + 1) * m_iLensGridSegmentCountH + x + 1 + offset); + d = (int) ((y + 1) * m_iLensGridSegmentCountH + x + offset); + + indices[indexPos] = a; + indices[indexPos + 1] = b; + indices[indexPos + 2] = c; + + indices[indexPos + 3] = a; + indices[indexPos + 4] = c; + indices[indexPos + 5] = d; + + indexPos += 6; + } + } + + // OK, create the mesh + distortionMesh.setBuffer(VertexBuffer.Type.Position, 3, verts); + distortionMesh.setBuffer(VertexBuffer.Type.Index, 1, indices); + distortionMesh.setBuffer(VertexBuffer.Type.TexCoord, 2, texcoordR); + distortionMesh.setBuffer(VertexBuffer.Type.TexCoord2, 2, texcoordG); + distortionMesh.setBuffer(VertexBuffer.Type.TexCoord3, 2, texcoordB); + distortionMesh.setStatic(); + return distortionMesh; + } +} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/openvr/package-info.java b/jme3-xr/src/main/java/com/jme3/input/vr/openvr/package-info.java new file mode 100644 index 0000000000..e74abe7d49 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/input/vr/openvr/package-info.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2021 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +/** + * user-input classes for devices that use the OpenVR API + */ +package com.jme3.input.vr.openvr; diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/osvr/OSVR.java b/jme3-xr/src/main/java/com/jme3/input/vr/osvr/OSVR.java new file mode 100644 index 0000000000..c8da65a4f1 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/input/vr/osvr/OSVR.java @@ -0,0 +1,459 @@ +/* + +https://github.com/sensics/OSVR-RenderManager/blob/master/examples/RenderManagerOpenGLCAPIExample.cpp + +- JVM crashes often. Placing breakpoints during initialization clears it up most of the time (WHY!?) + - OSVR is just unstable. Any way to improve things? +- Render manager looks good, but left eye seems stretched. + + */ +package com.jme3.input.vr.osvr; + +import com.jme3.app.VREnvironment; +import com.jme3.input.vr.HmdType; +import com.jme3.input.vr.VRAPI; +import com.jme3.input.vr.VRInputAPI; +import com.jme3.math.Matrix4f; +import com.jme3.math.Quaternion; +import com.jme3.math.Vector2f; +import com.jme3.math.Vector3f; +import com.jme3.renderer.Camera; +import com.jme3.system.osvr.osvrclientkit.OsvrClientKitLibrary; +import com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary; +import com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig; +import com.jme3.system.osvr.osvrmatrixconventions.OSVR_Pose3; +import com.jme3.system.osvr.osvrrendermanageropengl.OSVR_OpenResultsOpenGL; +import com.jme3.system.osvr.osvrrendermanageropengl.OSVR_RenderBufferOpenGL; +import com.jme3.system.osvr.osvrrendermanageropengl.OSVR_RenderInfoOpenGL; +import com.jme3.system.osvr.osvrrendermanageropengl.OSVR_RenderParams; +import com.jme3.system.osvr.osvrrendermanageropengl.OSVR_ViewportDescription; +import com.jme3.system.osvr.osvrrendermanageropengl.OsvrRenderManagerOpenGLLibrary; +import com.ochafik.lang.jnaerator.runtime.NativeSize; +import com.ochafik.lang.jnaerator.runtime.NativeSizeByReference; +import com.sun.jna.Pointer; +import com.sun.jna.ptr.PointerByReference; +import java.nio.FloatBuffer; +import java.util.logging.Logger; + +/** + * A class that wraps an OSVR system. + * @author reden - phr00t - https://github.com/phr00t + * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr + */ +public class OSVR implements VRAPI { + private static final Logger logger = Logger.getLogger(OSVR.class.getName()); + + /** + * The first viewer index. + */ + public static final int FIRST_VIEWER = 0; + + /** + * The left eye index. + */ + public static final int EYE_LEFT = 0; + + /** + * The right eye index. + */ + public static final int EYE_RIGHT = 1; + + /** + * The size of the left eye. + */ + public static final NativeSize EYE_LEFT_SIZE = new NativeSize(EYE_LEFT); + + /** + * The size of the right eye. + */ + public static final NativeSize EYE_RIGHT_SIZE = new NativeSize(EYE_RIGHT); + + /** + * The default J String. + */ + public static byte[] defaultJString = { 'j', (byte)0 }; + + /** + * The default OpenGL String. + */ + public static byte[] OpenGLString = { 'O', 'p', 'e', 'n', 'G', 'L', (byte)0 }; + + private final Matrix4f[] eyeMatrix = new Matrix4f[2]; + + private PointerByReference grabRM; + private PointerByReference grabRMOGL; + private PointerByReference grabRIC; + + OSVR_RenderParams.ByValue renderParams; + OsvrClientKitLibrary.OSVR_ClientContext context; + com.jme3.system.osvr.osvrrendermanageropengl.OSVR_GraphicsLibraryOpenGL.ByValue graphicsLibrary; + Pointer renderManager, renderManagerOpenGL, renderInfoCollection, registerBufferState; + OSVRInput VRinput; + NativeSize numRenderInfo; + NativeSizeByReference grabNumInfo = new NativeSizeByReference(); + OSVR_RenderInfoOpenGL.ByValue eyeLeftInfo, eyeRightInfo; + Matrix4f hmdPoseLeftEye; + Matrix4f hmdPoseRightEye; + Vector3f hmdPoseLeftEyeVec, hmdPoseRightEyeVec, hmdSeatToStand; + OSVR_DisplayConfig displayConfig; + OSVR_Pose3 hmdPose = new OSVR_Pose3(); + Vector3f storePos = new Vector3f(); + Quaternion storeRot = new Quaternion(); + PointerByReference presentState = new PointerByReference(); + OSVR_OpenResultsOpenGL openResults = new OSVR_OpenResultsOpenGL(); + + long glfwContext; + long renderManagerContext; + long wglGLFW; + long wglRM; + + boolean initSuccess = false; + boolean flipEyes = false; + + private VREnvironment environment = null; + + /** + * Create a new OSVR system attached to the given {@link VREnvironment VR environment}. + * @param environment the {@link VREnvironment VR environment} to which the input is attached. + */ + public OSVR(VREnvironment environment){ + this.environment = environment; + } + + /** + * Access to the underlying OSVR structures. + * @param leftView the left viewport. + * @param rightView the right viewport. + * @param leftBuffer the left buffer. + * @param rightBuffer the right buffer. + * @return true if the structure are accessible and false otherwise. + */ + public boolean handleRenderBufferPresent(OSVR_ViewportDescription.ByValue leftView, OSVR_ViewportDescription.ByValue rightView, + OSVR_RenderBufferOpenGL.ByValue leftBuffer, OSVR_RenderBufferOpenGL.ByValue rightBuffer) { + if( eyeLeftInfo == null || eyeRightInfo == null ) return false; + byte retval; + OsvrRenderManagerOpenGLLibrary.osvrRenderManagerStartPresentRenderBuffers(presentState); + getEyeInfo(); + OsvrRenderManagerOpenGLLibrary.osvrRenderManagerPresentRenderBufferOpenGL(presentState.getValue(), leftBuffer, eyeLeftInfo, leftView); + OsvrRenderManagerOpenGLLibrary.osvrRenderManagerPresentRenderBufferOpenGL(presentState.getValue(), rightBuffer, eyeRightInfo, rightView); + retval = OsvrRenderManagerOpenGLLibrary.osvrRenderManagerFinishPresentRenderBuffers(renderManager, presentState.getValue(), renderParams, (byte)0); + return retval == 0; // only check the last error, since if something errored above, the last call won't work & all calls will log to syserr + } + + @Override + public boolean initialize() { + logger.config("Initialize OSVR system."); + + hmdPose.setAutoSynch(false); + context = OsvrClientKitLibrary.osvrClientInit(defaultJString, 0); + VRinput = new OSVRInput(environment); + initSuccess = context != null && VRinput.init(); + if( initSuccess ) { + PointerByReference grabDisplay = new PointerByReference(); + byte retval = OsvrDisplayLibrary.osvrClientGetDisplay(context, grabDisplay); + if( retval != 0 ) { + System.out.println("OSVR Get Display Error: " + retval); + initSuccess = false; + return false; + } + displayConfig = new OSVR_DisplayConfig(grabDisplay.getValue()); + System.out.println("Waiting for the display to fully start up, including receiving initial pose update..."); + int i = 400; + while (OsvrDisplayLibrary.osvrClientCheckDisplayStartup(displayConfig) != 0) { + if( i-- < 0 ) { + System.out.println("Couldn't get display startup update in time, continuing anyway..."); + break; + } + OsvrClientKitLibrary.osvrClientUpdate(context); + try { + Thread.sleep(5); + } catch(Exception e) { } + } + System.out.println("OK, display startup status is good!"); + } + return initSuccess; + } + + + /** + * Grab the current GLFW context. + */ + public void grabGLFWContext() { + // get current context + wglGLFW = org.lwjgl.opengl.WGL.wglGetCurrentContext(); + glfwContext = org.lwjgl.glfw.GLFW.glfwGetCurrentContext(); + } + + /** + * Enable context sharing. + * @return true if the context is successfully shared and false otherwise. + */ + public boolean shareContext() { + if( org.lwjgl.opengl.WGL.wglShareLists(wglRM, wglGLFW)) { + System.out.println("Context sharing success!"); + return true; + } else { + System.out.println("Context sharing problem..."); + return false; + } + } + + @Override + public boolean initVRCompositor(boolean allowed) { + if( !allowed || renderManager != null ) return false; + grabGLFWContext(); + graphicsLibrary = new com.jme3.system.osvr.osvrrendermanageropengl.OSVR_GraphicsLibraryOpenGL.ByValue(); + graphicsLibrary.toolkit = null; + graphicsLibrary.setAutoSynch(false); + grabRM = new PointerByReference(); grabRMOGL = new PointerByReference(); + byte retval = OsvrRenderManagerOpenGLLibrary.osvrCreateRenderManagerOpenGL(context, OpenGLString, graphicsLibrary, grabRM, grabRMOGL); + if( retval == 0 ) { + renderManager = grabRM.getValue(); renderManagerOpenGL = grabRMOGL.getValue(); + if( renderManager == null || renderManagerOpenGL == null ) { + System.out.println("Render Manager Created NULL, error!"); + return false; + } + openResults.setAutoSynch(false); + retval = OsvrRenderManagerOpenGLLibrary.osvrRenderManagerOpenDisplayOpenGL(renderManager, openResults); + if( retval == 0 ) { + wglRM = org.lwjgl.opengl.WGL.wglGetCurrentContext(); + renderManagerContext = org.lwjgl.glfw.GLFW.glfwGetCurrentContext(); + shareContext(); + OsvrClientKitLibrary.osvrClientUpdate(context); + renderParams = new OSVR_RenderParams.ByValue(); + renderParams.setAutoSynch(false); + OsvrRenderManagerOpenGLLibrary.osvrRenderManagerGetDefaultRenderParams(renderParams); + grabRIC = new PointerByReference(); + retval = OsvrRenderManagerOpenGLLibrary.osvrRenderManagerGetRenderInfoCollection(renderManager, renderParams, grabRIC); + if( retval == 0 ) { + renderInfoCollection = grabRIC.getValue(); + OsvrRenderManagerOpenGLLibrary.osvrRenderManagerGetNumRenderInfoInCollection(renderInfoCollection, grabNumInfo); + numRenderInfo = grabNumInfo.getValue(); + eyeLeftInfo = new OSVR_RenderInfoOpenGL.ByValue(); + eyeRightInfo = new OSVR_RenderInfoOpenGL.ByValue(); + eyeLeftInfo.setAutoSynch(false); + eyeRightInfo.setAutoSynch(false); + return true; + } + OsvrRenderManagerOpenGLLibrary.osvrDestroyRenderManager(renderManager); + System.out.println("OSVR Render Manager Info Collection Error: " + retval); + return false; + } + OsvrRenderManagerOpenGLLibrary.osvrDestroyRenderManager(renderManager); + System.out.println("OSVR Open Render Manager Display Error: " + retval); + return false; + } + System.out.println("OSVR Create Render Manager Error: " + retval); + return false; + } + + @Override + public OsvrClientKitLibrary.OSVR_ClientContext getVRSystem() { + return context; + } + + @Override + public Pointer getCompositor() { + return renderManager; + } + + @Override + public String getName() { + return "OSVR"; + } + + @Override + public VRInputAPI getVRinput() { + return VRinput; + } + + @Override + public void setFlipEyes(boolean set) { + flipEyes = set; + } + + @Override + public void printLatencyInfoToConsole(boolean set) { + } + + @Override + public int getDisplayFrequency() { + return 60; //debug display frequency + } + + @Override + public void destroy() { + if( renderManager != null ) OsvrRenderManagerOpenGLLibrary.osvrDestroyRenderManager(renderManager); + if( displayConfig != null ) OsvrDisplayLibrary.osvrClientFreeDisplay(displayConfig); + } + + @Override + public boolean isInitialized() { + return initSuccess; + } + + @Override + public void reset() { + // TODO: no native OSVR reset function + // may need to take current position and negate it from future values + } + + @Override + public void getRenderSize(Vector2f store) { + if( eyeLeftInfo == null || eyeLeftInfo.viewport.width == 0.0 ) { + store.x = 1280f; store.y = 720f; + } else { + store.x = (float)eyeLeftInfo.viewport.width; + store.y = (float)eyeLeftInfo.viewport.height; + } + } + + /** + * Read and update the eye info from the underlying OSVR system. + */ + public void getEyeInfo() { + OsvrRenderManagerOpenGLLibrary.osvrRenderManagerGetRenderInfoFromCollectionOpenGL(renderInfoCollection, EYE_LEFT_SIZE, eyeLeftInfo); + OsvrRenderManagerOpenGLLibrary.osvrRenderManagerGetRenderInfoFromCollectionOpenGL(renderInfoCollection, EYE_RIGHT_SIZE, eyeRightInfo); + eyeLeftInfo.read(); eyeRightInfo.read(); + } +/* + @Override + public float getFOV(int dir) { + return 105f; //default FOV + } +*/ + @Override + public float getInterpupillaryDistance() { + return 0.065f; //default IPD + } + + @Override + public Quaternion getOrientation() { + storeRot.set((float)-hmdPose.rotation.data[1], + (float)hmdPose.rotation.data[2], + (float)-hmdPose.rotation.data[3], + (float)hmdPose.rotation.data[0]); + if( storeRot.equals(Quaternion.ZERO) ) storeRot.set(Quaternion.DIRECTION_Z); + return storeRot; + } + + @Override + public Vector3f getPosition() { + storePos.x = (float)-hmdPose.translation.data[0]; + storePos.y = (float)hmdPose.translation.data[1]; + storePos.z = (float)-hmdPose.translation.data[2]; + return storePos; + } + + @Override + public void getPositionAndOrientation(Vector3f storePos, Quaternion storeRot) { + storePos.x = (float)-hmdPose.translation.data[0]; + storePos.y = (float)hmdPose.translation.data[1]; + storePos.z = (float)-hmdPose.translation.data[2]; + storeRot.set((float)-hmdPose.rotation.data[1], + (float)hmdPose.rotation.data[2], + (float)-hmdPose.rotation.data[3], + (float)hmdPose.rotation.data[0]); + if( storeRot.equals(Quaternion.ZERO) ) storeRot.set(Quaternion.DIRECTION_Z); + } + + @Override + public void updatePose() { + if( context == null || displayConfig == null ) return; + OsvrClientKitLibrary.osvrClientUpdate(context); + OsvrDisplayLibrary.osvrClientGetViewerPose(displayConfig, FIRST_VIEWER, hmdPose.getPointer()); + VRinput.updateControllerStates(); + hmdPose.read(); + } + + @Override + public Matrix4f getHMDMatrixProjectionLeftEye(Camera cam) { + if( eyeLeftInfo == null ) return cam.getProjectionMatrix(); + if( eyeMatrix[EYE_LEFT] == null ) { + FloatBuffer tfb = FloatBuffer.allocate(16); + com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.osvrClientGetViewerEyeSurfaceProjectionMatrixf(displayConfig, 0, (byte)EYE_LEFT, 0, cam.getFrustumNear(), cam.getFrustumFar(), (short)0, tfb); + eyeMatrix[EYE_LEFT] = new Matrix4f(); + eyeMatrix[EYE_LEFT].set(tfb.get(0), tfb.get(4), tfb.get(8), tfb.get(12), + tfb.get(1), tfb.get(5), tfb.get(9), tfb.get(13), + tfb.get(2), tfb.get(6), tfb.get(10), tfb.get(14), + tfb.get(3), tfb.get(7), tfb.get(11), tfb.get(15)); + } + return eyeMatrix[EYE_LEFT]; + } + + @Override + public Matrix4f getHMDMatrixProjectionRightEye(Camera cam) { + if( eyeRightInfo == null ) return cam.getProjectionMatrix(); + if( eyeMatrix[EYE_RIGHT] == null ) { + FloatBuffer tfb = FloatBuffer.allocate(16); + com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.osvrClientGetViewerEyeSurfaceProjectionMatrixf(displayConfig, 0, (byte)EYE_RIGHT, 0, cam.getFrustumNear(), cam.getFrustumFar(), (short)0, tfb); + eyeMatrix[EYE_RIGHT] = new Matrix4f(); + eyeMatrix[EYE_RIGHT].set(tfb.get(0), tfb.get(4), tfb.get(8), tfb.get(12), + tfb.get(1), tfb.get(5), tfb.get(9), tfb.get(13), + tfb.get(2), tfb.get(6), tfb.get(10), tfb.get(14), + tfb.get(3), tfb.get(7), tfb.get(11), tfb.get(15)); + } + return eyeMatrix[EYE_RIGHT]; + } + + @Override + public Vector3f getHMDVectorPoseLeftEye() { + if( hmdPoseLeftEyeVec == null ) { + hmdPoseLeftEyeVec = new Vector3f(); + hmdPoseLeftEyeVec.x = 0.065f * -0.5f; + if( flipEyes == false ) hmdPoseLeftEyeVec.x *= -1f; // it seems these need flipping + } + return hmdPoseLeftEyeVec; + } + + @Override + public Vector3f getHMDVectorPoseRightEye() { + if( hmdPoseRightEyeVec == null ) { + hmdPoseRightEyeVec = new Vector3f(); + hmdPoseRightEyeVec.x = 0.065f * 0.5f; + if( flipEyes == false ) hmdPoseRightEyeVec.x *= -1f; // it seems these need flipping + } + return hmdPoseRightEyeVec; + } + + @Override + public Vector3f getSeatedToAbsolutePosition() { + return Vector3f.ZERO; + } + + @Override + public Matrix4f getHMDMatrixPoseLeftEye() { + // not actually used internally... + /*if( hmdPoseLeftEye != null ) { + return hmdPoseLeftEye; + } else { + FloatBuffer mat = FloatBuffer.allocate(16); + OsvrDisplayLibrary.osvrClientGetViewerEyeViewMatrixf(displayConfig, FIRST_VIEWER, (byte)EYE_LEFT, + (short)(OsvrMatrixConventionsLibrary.OSVR_MatrixVectorFlags.OSVR_MATRIX_COLVECTORS | + OsvrMatrixConventionsLibrary.OSVR_MatrixOrderingFlags.OSVR_MATRIX_COLMAJOR), tempfb); + hmdPoseLeftEye = new Matrix4f(tempfb.array()); + return hmdPoseLeftEye; + }*/ + return null; + } + + @Override + public Matrix4f getHMDMatrixPoseRightEye() { + // not actually used internally... + /*if( hmdPoseRightEye != null ) { + return hmdPoseRightEye; + } else { + OsvrDisplayLibrary.osvrClientGetViewerEyeViewMatrixf(displayConfig, FIRST_VIEWER, (byte)EYE_RIGHT, + (short)(OsvrMatrixConventionsLibrary.OSVR_MatrixVectorFlags.OSVR_MATRIX_COLVECTORS | + OsvrMatrixConventionsLibrary.OSVR_MatrixOrderingFlags.OSVR_MATRIX_COLMAJOR), tempfb); + hmdPoseRightEye = new Matrix4f(tempfb.array()); + return hmdPoseRightEye; + }*/ + return null; + } + + @Override + public HmdType getType() { + return HmdType.OSVR; + } +} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/osvr/OSVRInput.java b/jme3-xr/src/main/java/com/jme3/input/vr/osvr/OSVRInput.java new file mode 100644 index 0000000000..44bdf97e10 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/input/vr/osvr/OSVRInput.java @@ -0,0 +1,347 @@ +package com.jme3.input.vr.osvr; + +import java.util.logging.Logger; + +import com.jme3.app.VREnvironment; +import com.jme3.input.vr.VRInputAPI; +import com.jme3.input.vr.VRInputType; +import com.jme3.input.vr.VRTrackedController; +import com.jme3.math.Quaternion; +import com.jme3.math.Vector2f; +import com.jme3.math.Vector3f; +import com.jme3.renderer.Camera; +import com.jme3.scene.Spatial; +import com.jme3.system.osvr.osvrclientkit.OsvrClientKitLibrary; +import com.jme3.system.osvr.osvrclientkit.OsvrClientKitLibrary.OSVR_ClientInterface; +import com.jme3.system.osvr.osvrclientreporttypes.OSVR_AnalogReport; +import com.jme3.system.osvr.osvrclientreporttypes.OSVR_ButtonReport; +import com.jme3.system.osvr.osvrclientreporttypes.OSVR_Pose3; +import com.jme3.system.osvr.osvrinterface.OsvrInterfaceLibrary; +import com.jme3.system.osvr.osvrtimevalue.OSVR_TimeValue; +import com.sun.jna.Callback; +import com.sun.jna.Pointer; +import com.sun.jna.ptr.PointerByReference; + + +/** + * A class that wraps an OSVR input. + * @author reden - phr00t - https://github.com/phr00t + * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr + */ +public class OSVRInput implements VRInputAPI { + private static final Logger logger = Logger.getLogger(OSVRInput.class.getName()); + + // position example: https://github.com/OSVR/OSVR-Core/blob/master/examples/clients/TrackerState.c + // button example: https://github.com/OSVR/OSVR-Core/blob/master/examples/clients/ButtonCallback.c + // analog example: https://github.com/OSVR/OSVR-Core/blob/master/examples/clients/AnalogCallback.c + + private static final int ANALOG_COUNT = 3, BUTTON_COUNT = 7, CHANNEL_COUNT = 3; + + OSVR_ClientInterface[][] buttons; + OSVR_ClientInterface[][][] analogs; + OSVR_ClientInterface[] hands; + + OSVR_Pose3[] handState; + Callback buttonHandler, analogHandler; + OSVR_TimeValue tv = new OSVR_TimeValue(); + boolean[] isHandTracked = new boolean[2]; + + private float[][][] analogState; + private float[][] buttonState; + + private final Quaternion tempq = new Quaternion(); + private final Vector3f tempv = new Vector3f(); + private final Vector2f temp2 = new Vector2f(); + private final boolean[][] buttonDown = new boolean[16][16]; + + private static final Vector2f temp2Axis = new Vector2f(); + private static final Vector2f lastCallAxis[] = new Vector2f[16]; + private static float axisMultiplier = 1f; + + private VREnvironment environment = null; + + /** + * Get the system String that identifies a controller. + * @param left is the controller is the left one (false if the right controller is needed). + * @param index the index of the controller. + * @return the system String that identifies the controller. + */ + public static byte[] getButtonString(boolean left, byte index) { + if( left ) { + return new byte[] { '/', 'c', 'o', 'n', 't', 'r', 'o', 'l', 'l', 'e', 'r', '/', 'l', 'e', 'f', 't', '/', index, (byte)0 }; + } + return new byte[] { '/', 'c', 'o', 'n', 't', 'r', 'o', 'l', 'l', 'e', 'r', '/', 'r', 'i', 'g', 'h', 't', '/', index, (byte)0 }; + } + + /** + * The left-hand system String. + */ + public static byte[] leftHand = { '/', 'm', 'e', '/', 'h', 'a', 'n', 'd', 's', '/', 'l', 'e', 'f', 't', (byte)0 }; + + /** + * The right-hand system String. + */ + public static byte[] rightHand = { '/', 'm', 'e', '/', 'h', 'a', 'n', 'd', 's', '/', 'r', 'i', 'g', 'h', 't', (byte)0 }; + + + /** + * Create a new OSVR input attached to the given {@link VREnvironment VR environment}. + * @param environment the {@link VREnvironment VR environment} to which the input is attached. + */ + public OSVRInput(VREnvironment environment){ + this.environment = environment; + } + + @Override + public boolean isButtonDown(int controllerIndex, VRInputType checkButton) { + return buttonState[controllerIndex][checkButton.getValue()] != 0f; + } + + @Override + public boolean wasButtonPressedSinceLastCall(int controllerIndex, VRInputType checkButton) { + boolean buttonDownNow = isButtonDown(controllerIndex, checkButton); + int checkButtonValue = checkButton.getValue(); + boolean retval = buttonDownNow == true && buttonDown[controllerIndex][checkButtonValue] == false; + buttonDown[controllerIndex][checkButtonValue] = buttonDownNow; + return retval; + } + + @Override + public void resetInputSinceLastCall() { + for(int i=0;ihttp://www.seinturier.fr + */ +public class OSVRMouseManager extends AbstractVRMouseManager { + private final int AVERAGE_AMNT = 4; + + private int avgCounter; + + private final float[] lastXmv = new float[AVERAGE_AMNT]; + + private final float[] lastYmv = new float[AVERAGE_AMNT]; + + /** + * Create a new VR mouse manager within the given {@link VREnvironment VR environment}. + * @param environment the VR environment of the mouse manager. + */ + public OSVRMouseManager(VREnvironment environment){ + super(environment); + } + + @Override + public void updateAnalogAsMouse(int inputIndex, AnalogListener mouseListener, String mouseXName, String mouseYName, float tpf) { + + if (getVREnvironment() != null){ + if (getVREnvironment().getApplication() != null){ + // got a tracked controller to use as the "mouse" + if( getVREnvironment().isInVR() == false || + getVREnvironment().getVRinput() == null || + getVREnvironment().getVRinput().isInputDeviceTracking(inputIndex) == false ){ + return; + } + + Vector2f tpDelta; + // TODO option to use Touch joysticks + if( isThumbstickMode() ) { + tpDelta = getVREnvironment().getVRinput().getAxis(inputIndex, VRInputType.ViveTrackpadAxis); + } else { + tpDelta = getVREnvironment().getVRinput().getAxisDeltaSinceLastCall(inputIndex, VRInputType.ViveTrackpadAxis); + } + + float Xamount = (float)Math.pow(Math.abs(tpDelta.x) * getSpeedSensitivity(), getSpeedAcceleration()); + float Yamount = (float)Math.pow(Math.abs(tpDelta.y) * getSpeedSensitivity(), getSpeedAcceleration()); + + if( tpDelta.x < 0f ){ + Xamount = -Xamount; + } + + if( tpDelta.y < 0f ){ + Yamount = -Yamount; + } + + Xamount *= getMouseMoveScale(); + Yamount *= getMouseMoveScale(); + + if( mouseListener != null ) { + if( tpDelta.x != 0f && mouseXName != null ) mouseListener.onAnalog(mouseXName, Xamount * 0.2f, tpf); + if( tpDelta.y != 0f && mouseYName != null ) mouseListener.onAnalog(mouseYName, Yamount * 0.2f, tpf); + } + + if( getVREnvironment().getApplication().getInputManager().isCursorVisible() ) { + int index = (avgCounter+1) % AVERAGE_AMNT; + lastXmv[index] = Xamount * 133f; + lastYmv[index] = Yamount * 133f; + cursorPos.x -= avg(lastXmv); + cursorPos.y -= avg(lastYmv); + Vector2f maxsize = getVREnvironment().getVRGUIManager().getCanvasSize(); + + if( cursorPos.x > maxsize.x ){ + cursorPos.x = maxsize.x; + } + + if( cursorPos.x < 0f ){ + cursorPos.x = 0f; + } + + if( cursorPos.y > maxsize.y ){ + cursorPos.y = maxsize.y; + } + + if( cursorPos.y < 0f ){ + cursorPos.y = 0f; + } + } + } else { + throw new IllegalStateException("This VR environment is not attached to any application."); + } + } else { + throw new IllegalStateException("This VR view manager is not attached to any VR environment."); + } + } + + private float avg(float[] arr) { + float amt = 0f; + for(float f : arr) amt += f; + return amt / arr.length; + } +} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/osvr/OSVRViewManager.java b/jme3-xr/src/main/java/com/jme3/input/vr/osvr/OSVRViewManager.java new file mode 100644 index 0000000000..a3310c67e2 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/input/vr/osvr/OSVRViewManager.java @@ -0,0 +1,867 @@ +package com.jme3.input.vr.osvr; + +import java.awt.GraphicsEnvironment; +import java.util.Iterator; +import java.util.logging.Logger; + +import com.jme3.app.VREnvironment; +import com.jme3.input.vr.AbstractVRViewManager; +import com.jme3.input.vr.VRAPI; +import com.jme3.input.vr.openvr.OpenVRViewManager; +import com.jme3.material.Material; +import com.jme3.math.ColorRGBA; +import com.jme3.math.Quaternion; +import com.jme3.math.Vector2f; +import com.jme3.math.Vector3f; +import com.jme3.post.CartoonSSAO; +import com.jme3.post.Filter; +import com.jme3.post.FilterPostProcessor; +import com.jme3.post.FilterUtil; +import com.jme3.post.SceneProcessor; +import com.jme3.post.filters.FogFilter; +import com.jme3.post.filters.TranslucentBucketFilter; +import com.jme3.post.ssao.SSAOFilter; +import com.jme3.renderer.Camera; +import com.jme3.renderer.ViewPort; +import com.jme3.renderer.queue.RenderQueue.Bucket; +import com.jme3.scene.Geometry; +import com.jme3.scene.Mesh; +import com.jme3.scene.Node; +import com.jme3.scene.Spatial; +import com.jme3.scene.VertexBuffer; +import com.jme3.shadow.DirectionalLightShadowFilter; +import com.jme3.shadow.VRDirectionalLightShadowRenderer; +import com.jme3.system.jopenvr.DistortionCoordinates_t; +import com.jme3.system.jopenvr.JOpenVRLibrary; +import com.jme3.system.jopenvr.OpenVRUtil; +import com.jme3.system.jopenvr.Texture_t; +import com.jme3.system.jopenvr.VR_IVRSystem_FnTable; +import com.jme3.system.lwjgl.LwjglWindow; +import com.jme3.system.osvr.osvrrendermanageropengl.OSVR_RenderBufferOpenGL; +import com.jme3.system.osvr.osvrrendermanageropengl.OSVR_ViewportDescription; +import com.jme3.system.osvr.osvrrendermanageropengl.OsvrRenderManagerOpenGLLibrary; +import com.jme3.texture.FrameBuffer; +import com.jme3.texture.Image; +import com.jme3.texture.Texture; +import com.jme3.texture.Texture2D; +import com.jme3.ui.Picture; +import com.jme3.util.VRGUIPositioningMode; +import com.sun.jna.Pointer; +import com.sun.jna.ptr.PointerByReference; + +/** + * + * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr + * + */ +public class OSVRViewManager extends AbstractVRViewManager{ + private static final Logger logger = Logger.getLogger(OpenVRViewManager.class.getName()); + + // OpenVR values + private Texture_t leftTextureType; + private Texture_t rightTextureType; + + // OSVR values + OSVR_RenderBufferOpenGL.ByValue[] osvr_renderBuffer; + OSVR_ViewportDescription.ByValue osvr_viewDescFull; + OSVR_ViewportDescription.ByValue osvr_viewDescLeft; + OSVR_ViewportDescription.ByValue osvr_viewDescRight; + Pointer osvr_rmBufferState; + + private Texture2D dualEyeTex; + + private final PointerByReference grabRBS = new PointerByReference(); + + //final & temp values for camera calculations + private final Vector3f finalPosition = new Vector3f(); + private final Quaternion finalRotation = new Quaternion(); + private final Vector3f hmdPos = new Vector3f(); + private final Quaternion hmdRot = new Quaternion(); + + /** + * Create a new VR view manager attached to the given {@link VREnvironment VR environment}. + * @param environment the {@link VREnvironment VR environment} to which this view manager is attached. + */ + public OSVRViewManager(VREnvironment environment){ + this.environment = environment; + } + + /** + * Get the identifier of the left eye texture. + * @return the identifier of the left eye texture. + * @see #getRightTexId() + * @see #getFullTexId() + */ + protected int getLeftTexId() { + return leftEyeTexture.getImage().getId(); + } + + /** + * Get the identifier of the right eye texture. + * @return the identifier of the right eye texture. + * @see #getLeftTexId() + * @see #getFullTexId() + */ + protected int getRightTexId() { + return rightEyeTexture.getImage().getId(); + } + + /** + * Get the identifier of the full (dual eye) texture. + * @return the identifier of the full (dual eye) texture. + * @see #getLeftTexId() + * @see #getRightTexId() + */ + private int getFullTexId() { + return dualEyeTex.getImage().getId(); + } + + /** + * Initialize the system binds of the textures. + */ + private void initTextureSubmitStructs() { + leftTextureType = new Texture_t(); + rightTextureType = new Texture_t(); + + // must be OSVR + osvr_renderBuffer = new OSVR_RenderBufferOpenGL.ByValue[2]; + osvr_renderBuffer[OSVR.EYE_LEFT] = new OSVR_RenderBufferOpenGL.ByValue(); + osvr_renderBuffer[OSVR.EYE_RIGHT] = new OSVR_RenderBufferOpenGL.ByValue(); + osvr_renderBuffer[OSVR.EYE_LEFT].setAutoSynch(false); + osvr_renderBuffer[OSVR.EYE_RIGHT].setAutoSynch(false); + osvr_viewDescFull = new OSVR_ViewportDescription.ByValue(); + osvr_viewDescFull.setAutoSynch(false); + osvr_viewDescFull.left = osvr_viewDescFull.lower = 0.0; + osvr_viewDescFull.width = osvr_viewDescFull.height = 1.0; + osvr_viewDescLeft = new OSVR_ViewportDescription.ByValue(); + osvr_viewDescLeft.setAutoSynch(false); + osvr_viewDescLeft.left = osvr_viewDescLeft.lower = 0.0; + osvr_viewDescLeft.width = 0.5; + osvr_viewDescLeft.height = 1.0; + osvr_viewDescRight = new OSVR_ViewportDescription.ByValue(); + osvr_viewDescRight.setAutoSynch(false); + osvr_viewDescRight.left = 0.5; + osvr_viewDescRight.lower = 0.0; + osvr_viewDescRight.width = 0.5; + osvr_viewDescRight.height = 1.0; + osvr_viewDescRight.write(); + osvr_viewDescLeft.write(); + osvr_viewDescFull.write(); + osvr_renderBuffer[OSVR.EYE_LEFT].depthStencilBufferName = -1; + osvr_renderBuffer[OSVR.EYE_LEFT].colorBufferName = -1; + osvr_renderBuffer[OSVR.EYE_RIGHT].depthStencilBufferName = -1; + osvr_renderBuffer[OSVR.EYE_RIGHT].colorBufferName = -1; + } + + /** + * Register the OSVR OpenGL buffer. + * @param buf the OSVR OpenGL buffer. + */ + private void registerOSVRBuffer(OSVR_RenderBufferOpenGL.ByValue buf) { + if (environment != null){ + OsvrRenderManagerOpenGLLibrary.osvrRenderManagerStartRegisterRenderBuffers(grabRBS); + OsvrRenderManagerOpenGLLibrary.osvrRenderManagerRegisterRenderBufferOpenGL(grabRBS.getValue(), buf); + OsvrRenderManagerOpenGLLibrary.osvrRenderManagerFinishRegisterRenderBuffers(((OSVR)environment.getVRHardware()).getCompositor(), grabRBS.getValue(), (byte)0); + + } else { + throw new IllegalStateException("This VR view manager is not attached to any VR environment."); + } + } + + /** + * Send the textures to the two eyes. + */ + @Override + public void postRender() { + if (environment != null){ + if( environment.isInVR() ) { + VRAPI api = environment.getVRHardware(); + if( api.getCompositor() != null ) { + // using the compositor... + int errl = 0, errr = 0; + if( environment.isInstanceRendering() ) { + if( leftTextureType.handle == -1 || leftTextureType.handle != getFullTexId() ) { + leftTextureType.handle = getFullTexId(); + if( leftTextureType.handle != -1 ) { + leftTextureType.write(); + if( api instanceof OSVR ) { + osvr_renderBuffer[OSVR.EYE_LEFT].colorBufferName = leftTextureType.handle; + osvr_renderBuffer[OSVR.EYE_LEFT].depthStencilBufferName = dualEyeTex.getImage().getId(); + osvr_renderBuffer[OSVR.EYE_LEFT].write(); + registerOSVRBuffer(osvr_renderBuffer[OSVR.EYE_LEFT]); + } + } + } else { + if( api instanceof OSVR ) { + ((OSVR)api).handleRenderBufferPresent(osvr_viewDescLeft, osvr_viewDescRight, + osvr_renderBuffer[OSVR.EYE_LEFT], osvr_renderBuffer[OSVR.EYE_LEFT]); + } + } + } else if( leftTextureType.handle == -1 || rightTextureType.handle == -1 || + leftTextureType.handle != getLeftTexId() || rightTextureType.handle != getRightTexId() ) { + leftTextureType.handle = getLeftTexId(); + if( leftTextureType.handle != -1 ) { + logger.fine("Writing Left texture to native memory at " + leftTextureType.getPointer()); + leftTextureType.write(); + if( api instanceof OSVR ) { + osvr_renderBuffer[OSVR.EYE_LEFT].colorBufferName = leftTextureType.handle; + if( leftEyeDepth != null ) osvr_renderBuffer[OSVR.EYE_LEFT].depthStencilBufferName = leftEyeDepth.getImage().getId(); + osvr_renderBuffer[OSVR.EYE_LEFT].write(); + registerOSVRBuffer(osvr_renderBuffer[OSVR.EYE_LEFT]); + } + } + rightTextureType.handle = getRightTexId(); + if( rightTextureType.handle != -1 ) { + logger.fine("Writing Right texture to native memory at " + leftTextureType.getPointer()); + rightTextureType.write(); + if( api instanceof OSVR ) { + osvr_renderBuffer[OSVR.EYE_RIGHT].colorBufferName = rightTextureType.handle; + if( rightEyeDepth != null ) osvr_renderBuffer[OSVR.EYE_RIGHT].depthStencilBufferName = rightEyeDepth.getImage().getId(); + osvr_renderBuffer[OSVR.EYE_RIGHT].write(); + registerOSVRBuffer(osvr_renderBuffer[OSVR.EYE_RIGHT]); + } + } + } else { + if( api instanceof OSVR ) { + ((OSVR)api).handleRenderBufferPresent(osvr_viewDescFull, osvr_viewDescFull, + osvr_renderBuffer[OSVR.EYE_LEFT], osvr_renderBuffer[OSVR.EYE_RIGHT]); + } + } + + if( errl != 0 ){ + logger.severe("Submit to left compositor error: " + OpenVRUtil.getEVRCompositorErrorString(errl)+" ("+Integer.toString(errl)+")"); + logger.severe(" Texture color space: "+OpenVRUtil.getEColorSpaceString(leftTextureType.eColorSpace)); + logger.severe(" Texture type: "+OpenVRUtil.getETextureTypeString(leftTextureType.eType)); + logger.severe(" Texture handle: "+leftTextureType.handle); + + logger.severe(" Left eye texture "+leftEyeTexture.getName()+" ("+leftEyeTexture.getImage().getId()+")"); + logger.severe(" Type: "+leftEyeTexture.getType()); + logger.severe(" Size: "+leftEyeTexture.getImage().getWidth()+"x"+leftEyeTexture.getImage().getHeight()); + logger.severe(" Image depth: "+leftEyeTexture.getImage().getDepth()); + logger.severe(" Image format: "+leftEyeTexture.getImage().getFormat()); + logger.severe(" Image color space: "+leftEyeTexture.getImage().getColorSpace()); + } + + if( errr != 0 ){ + logger.severe("Submit to right compositor error: " + OpenVRUtil.getEVRCompositorErrorString(errl)+" ("+Integer.toString(errl)+")"); + logger.severe(" Texture color space: "+OpenVRUtil.getEColorSpaceString(rightTextureType.eColorSpace)); + logger.severe(" Texture type: "+OpenVRUtil.getETextureTypeString(rightTextureType.eType)); + logger.severe(" Texture handle: "+rightTextureType.handle); + + logger.severe(" Right eye texture "+rightEyeTexture.getName()+" ("+rightEyeTexture.getImage().getId()+")"); + logger.severe(" Type: "+rightEyeTexture.getType()); + logger.severe(" Size: "+rightEyeTexture.getImage().getWidth()+"x"+rightEyeTexture.getImage().getHeight()); + logger.severe(" Image depth: "+rightEyeTexture.getImage().getDepth()); + logger.severe(" Image format: "+rightEyeTexture.getImage().getFormat()); + logger.severe(" Image color space: "+rightEyeTexture.getImage().getColorSpace()); + } + } + } + } else { + throw new IllegalStateException("This VR view manager is not attached to any VR environment."); + } + } + + /** + * Initialize the VR view manager. + */ + @Override + public void initialize() { + logger.config("Initializing VR view manager."); + + if (environment != null){ + initTextureSubmitStructs(); + setupCamerasAndViews(); + setupVRScene(); + moveScreenProcessingToEyes(); + if( environment.hasTraditionalGUIOverlay() ) { + + environment.getVRMouseManager().initialize(); + + // update the pose to position the gui correctly on start + update(0f); + environment.getVRGUIManager().positionGui(); + } + + if (environment.getApplication() != null){ + // if we are OSVR, our primary mirror window needs to be the same size as the render manager's output... + if( environment.getVRHardware() instanceof OSVR ) { + int origWidth = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDisplayMode().getWidth(); + int origHeight = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDisplayMode().getHeight(); + long window = ((LwjglWindow)environment.getApplication().getContext()).getWindowHandle(); + Vector2f windowSize = new Vector2f(); + environment.getVRHardware().getRenderSize(windowSize); + windowSize.x = Math.max(windowSize.x * 2f, leftCamera.getWidth()); + org.lwjgl.glfw.GLFW.glfwSetWindowSize(window, (int)windowSize.x, (int)windowSize.y); + environment.getApplication().getContext().getSettings().setResolution((int)windowSize.x, (int)windowSize.y); + + if (environment.getApplication().getRenderManager() != null) { + environment.getApplication().getRenderManager().notifyReshape((int)windowSize.x, (int)windowSize.y); + } + + org.lwjgl.glfw.GLFW.glfwSetWindowPos(window, origWidth - (int)windowSize.x, 32); + + org.lwjgl.glfw.GLFW.glfwFocusWindow(window); + + org.lwjgl.glfw.GLFW.glfwSetCursorPos(window, origWidth / 2.0, origHeight / 2.0); + + logger.config("Initialized VR view manager [SUCCESS]"); + } else { + throw new IllegalStateException("Underlying VR hardware should be "+OSVR.class.getSimpleName()); + } + } else { + throw new IllegalStateException("This VR environment is not attached to any application."); + } + } else { + throw new IllegalStateException("This VR view manager is not attached to any VR environment."); + } + } + + /** + * Prepare the size of the given {@link Camera camera} to adapt it to the underlying rendering context. + * @param cam the {@link Camera camera} to prepare. + * @param xMult the camera width multiplier. + */ + private void prepareCameraSize(Camera cam, float xMult) { + if (environment != null){ + if (environment.getApplication() != null){ + + } else { + throw new IllegalStateException("This VR environment is not attached to any application."); + } + + Vector2f size = new Vector2f(); + VRAPI vrhmd = environment.getVRHardware(); + + if( vrhmd == null ) { + size.x = 1280f; + size.y = 720f; + } else { + vrhmd.getRenderSize(size); + } + + if( size.x < environment.getApplication().getContext().getSettings().getWidth() ) { + size.x = environment.getApplication().getContext().getSettings().getWidth(); + } + if( size.y < environment.getApplication().getContext().getSettings().getHeight() ) { + size.y = environment.getApplication().getContext().getSettings().getHeight(); + } + + if( environment.isInstanceRendering() ){ + size.x *= 2f; + } + + // other adjustments + size.x *= xMult; + size.x *= getResolutionMuliplier(); + size.y *= getResolutionMuliplier(); + + if( cam.getWidth() != size.x || cam.getHeight() != size.y ){ + cam.resize((int)size.x, (int)size.y, false); + } + } else { + throw new IllegalStateException("This VR view manager is not attached to any VR environment."); + } + } + + /** + * Replaces rootNode with the distortion mesh as the main camera's scene. + */ + private void setupVRScene(){ + if (environment != null){ + if (environment.getApplication() != null){ + // no special scene to set up if we are doing instancing + if( environment.isInstanceRendering() ) { + // distortion has to be done with compositor here... we want only one pass on our end! + if( environment.getApplication().getContext().getSettings().isSwapBuffers() ) { + setupMirrorBuffers(environment.getCamera(), dualEyeTex, true); + } + return; + } + + leftEyeTexture = (Texture2D) getLeftViewPort().getOutputFrameBuffer().getColorBuffer().getTexture(); + rightEyeTexture = (Texture2D)getRightViewPort().getOutputFrameBuffer().getColorBuffer().getTexture(); + leftEyeDepth = (Texture2D) getLeftViewPort().getOutputFrameBuffer().getDepthBuffer().getTexture(); + rightEyeDepth = (Texture2D)getRightViewPort().getOutputFrameBuffer().getDepthBuffer().getTexture(); + + // main viewport is either going to be a distortion scene or nothing + // mirroring is handled by copying framebuffers + Iterator spatialIter = environment.getApplication().getViewPort().getScenes().iterator(); + while(spatialIter.hasNext()){ + environment.getApplication().getViewPort().detachScene(spatialIter.next()); + } + + spatialIter = environment.getApplication().getGuiViewPort().getScenes().iterator(); + while(spatialIter.hasNext()){ + environment.getApplication().getGuiViewPort().detachScene(spatialIter.next()); + } + + // only setup distortion scene if compositor isn't running (or using custom mesh distortion option) + if( environment.getVRHardware().getCompositor() == null ) { + Node distortionScene = new Node(); + Material leftMat = new Material(environment.getApplication().getAssetManager(), "Common/MatDefs/VR/OpenVR.j3md"); + leftMat.setTexture("Texture", leftEyeTexture); + Geometry leftEye = new Geometry("box", setupDistortionMesh(JOpenVRLibrary.EVREye.EVREye_Eye_Left, environment.getVRHardware())); + leftEye.setMaterial(leftMat); + distortionScene.attachChild(leftEye); + + Material rightMat = new Material(environment.getApplication().getAssetManager(), "Common/MatDefs/VR/OpenVR.j3md"); + rightMat.setTexture("Texture", rightEyeTexture); + Geometry rightEye = new Geometry("box", setupDistortionMesh(JOpenVRLibrary.EVREye.EVREye_Eye_Right, environment.getVRHardware())); + rightEye.setMaterial(rightMat); + distortionScene.attachChild(rightEye); + + distortionScene.updateGeometricState(); + + environment.getApplication().getViewPort().attachScene(distortionScene); + + //if( useCustomDistortion ) setupFinalFullTexture(app.getViewPort().getCamera()); + } + + if( environment.getApplication().getContext().getSettings().isSwapBuffers() ) { + setupMirrorBuffers(environment.getCamera(), leftEyeTexture, false); + } + } else { + throw new IllegalStateException("This VR environment is not attached to any application."); + } + } else { + throw new IllegalStateException("This VR view manager is not attached to any VR environment."); + } + } + + /** + * Update the VR view manager. + * This method is called by the attached VR application and should not be called manually. + * @param tpf the time per frame. + */ + @Override + public void update(float tpf) { + if (environment != null){ + // grab the observer + Object obs = environment.getObserver(); + Quaternion objRot; + Vector3f objPos; + if( obs instanceof Camera ) { + objRot = ((Camera)obs).getRotation(); + objPos = ((Camera)obs).getLocation(); + } else { + objRot = ((Spatial)obs).getWorldRotation(); + objPos = ((Spatial)obs).getWorldTranslation(); + } + // grab the hardware handle + VRAPI dev = environment.getVRHardware(); + if( dev != null ) { + // update the HMD's position & orientation + dev.updatePose(); + dev.getPositionAndOrientation(hmdPos, hmdRot); + if( obs != null ) { + // update hmdPos based on obs rotation + finalRotation.set(objRot); + finalRotation.mult(hmdPos, hmdPos); + finalRotation.multLocal(hmdRot); + } + + finalizeCamera(dev.getHMDVectorPoseLeftEye(), objPos, leftCamera); + finalizeCamera(dev.getHMDVectorPoseRightEye(), objPos, rightCamera); + } else { + leftCamera.setFrame(objPos, objRot); + rightCamera.setFrame(objPos, objRot); + } + + if( environment.hasTraditionalGUIOverlay() ) { + // update the mouse? + environment.getVRMouseManager().update(tpf); + + // update GUI position? + if( environment.getVRGUIManager().isWantsReposition() || environment.getVRGUIManager().getPositioningMode() != VRGUIPositioningMode.MANUAL ) { + environment.getVRGUIManager().positionGuiNow(tpf); + environment.getVRGUIManager().updateGuiQuadGeometricState(); + } + } + } else { + throw new IllegalStateException("This VR view manager is not attached to any VR environment."); + } + } + + /** + * Place the camera within the scene. + * @param eyePos the eye position. + * @param obsPosition the observer position. + * @param cam the camera to place. + */ + private void finalizeCamera(Vector3f eyePos, Vector3f obsPosition, Camera cam) { + finalRotation.mult(eyePos, finalPosition); + finalPosition.addLocal(hmdPos); + if( obsPosition != null ){ + finalPosition.addLocal(obsPosition); + } + finalPosition.y += getHeightAdjustment(); + cam.setFrame(finalPosition, finalRotation); + } + + /** + * Handles moving filters from the main view to each eye + */ + @Override + public void moveScreenProcessingToEyes() { + if( getRightViewPort() == null ){ + return; + } + + if (environment != null){ + if (environment.getApplication() != null){ + + syncScreenProcessing(environment.getApplication().getViewPort()); + environment.getApplication().getViewPort().clearProcessors(); + } else { + throw new IllegalStateException("This VR environment is not attached to any application."); + } + } else { + throw new IllegalStateException("This VR view manager is not attached to any VR environment."); + } + } + + /** + * Sets the two views to use the list of {@link SceneProcessor processors}. + * @param sourceViewport the {@link ViewPort viewport} that contains the processors to use. + */ + @Override + public void syncScreenProcessing(ViewPort sourceViewport) { + if( getRightViewPort() == null ){ + return; + } + + if (environment != null){ + if (environment.getApplication() != null){ + // set up post-processing filters + if( rightPostProcessor == null ) { + rightPostProcessor = new FilterPostProcessor(environment.getApplication().getAssetManager()); + leftPostProcessor = new FilterPostProcessor(environment.getApplication().getAssetManager()); + } + // clear out all filters & processors, to start from scratch + rightPostProcessor.removeAllFilters(); + leftPostProcessor.removeAllFilters(); + getLeftViewPort().clearProcessors(); + getRightViewPort().clearProcessors(); + // if we have no processors to sync, don't add the FilterPostProcessor + if( sourceViewport.getProcessors().isEmpty() ) return; + // add post processors we just made, which are empty + getLeftViewPort().addProcessor(leftPostProcessor); + getRightViewPort().addProcessor(rightPostProcessor); + // go through all of the filters in the processors list + // add them to the left viewport processor & clone them to the right + for(SceneProcessor sceneProcessor : sourceViewport.getProcessors()) { + if (sceneProcessor instanceof FilterPostProcessor) { + for(Filter f : ((FilterPostProcessor)sceneProcessor).getFilterList() ) { + if( f instanceof TranslucentBucketFilter ) { + // just remove this filter, we will add it at the end manually + ((FilterPostProcessor)sceneProcessor).removeFilter(f); + } else { + leftPostProcessor.addFilter(f); + // clone to the right + Filter f2; + if(f instanceof FogFilter){ + f2 = FilterUtil.cloneFogFilter((FogFilter)f); + } else if (f instanceof CartoonSSAO ) { + f2 = new CartoonSSAO((CartoonSSAO)f); + } else if (f instanceof SSAOFilter){ + f2 = FilterUtil.cloneSSAOFilter((SSAOFilter)f); + } else if (f instanceof DirectionalLightShadowFilter){ + f2 = FilterUtil.cloneDirectionalLightShadowFilter(environment.getApplication().getAssetManager(), (DirectionalLightShadowFilter)f); + } else { + f2 = f; // DoF, bloom, light scattering etc. + } + rightPostProcessor.addFilter(f2); + } + } + } else if (sceneProcessor instanceof VRDirectionalLightShadowRenderer) { + // shadow processing + // TODO: make right shadow processor use same left shadow maps for performance + VRDirectionalLightShadowRenderer dlsr = (VRDirectionalLightShadowRenderer) sceneProcessor; + VRDirectionalLightShadowRenderer dlsrRight = dlsr.clone(); + dlsrRight.setLight(dlsr.getLight()); + getRightViewPort().getProcessors().add(0, dlsrRight); + getLeftViewPort().getProcessors().add(0, sceneProcessor); + } + } + // make sure each has a translucent filter renderer + leftPostProcessor.addFilter(new TranslucentBucketFilter()); + rightPostProcessor.addFilter(new TranslucentBucketFilter()); + } else { + throw new IllegalStateException("This VR environment is not attached to any application."); + } + } else { + throw new IllegalStateException("This VR view manager is not attached to any VR environment."); + } + } + + private void setupCamerasAndViews() { + if (environment != null){ + if (environment.getApplication() != null){ + // get desired frustum from original camera + Camera origCam = environment.getCamera(); + float fFar = origCam.getFrustumFar(); + float fNear = origCam.getFrustumNear(); + + // if we are using OSVR get the eye info here + if( environment.getVRHardware() instanceof OSVR ) { + ((OSVR)environment.getVRHardware()).getEyeInfo(); + } + + // restore frustum on distortion scene cam, if needed + if( environment.isInstanceRendering() ) { + leftCamera = origCam; + } else if( environment.compositorAllowed() == false ) { + origCam.setFrustumFar(100f); + origCam.setFrustumNear(1f); + leftCamera = origCam.clone(); + prepareCameraSize(origCam, 2f); + } else { + leftCamera = origCam.clone(); + } + + leftCamera.setFrustumPerspective(environment.getDefaultFOV(), environment.getDefaultAspect(), fNear, fFar); + + prepareCameraSize(leftCamera, 1f); + if( environment.getVRHardware() != null ) leftCamera.setProjectionMatrix(environment.getVRHardware().getHMDMatrixProjectionLeftEye(leftCamera)); + //org.lwjgl.opengl.GL11.glEnable(org.lwjgl.opengl.GL30.GL_FRAMEBUFFER_SRGB); + + if( !environment.isInstanceRendering()) { + leftViewPort = setupViewBuffers(leftCamera, LEFT_VIEW_NAME); + rightCamera = leftCamera.clone(); + if( environment.getVRHardware() != null ){ + rightCamera.setProjectionMatrix(environment.getVRHardware().getHMDMatrixProjectionRightEye(rightCamera)); + } + rightViewPort = setupViewBuffers(rightCamera, RIGHT_VIEW_NAME); + } else { + System.err.println("[VRViewManager] THIS CODE NEED CHANGES !!!"); + leftViewPort = environment.getApplication().getViewPort(); + //leftViewport.attachScene(app.getRootNode()); + rightCamera = leftCamera.clone(); + if( environment.getVRHardware() != null ){ + rightCamera.setProjectionMatrix(environment.getVRHardware().getHMDMatrixProjectionRightEye(rightCamera)); + } + + org.lwjgl.opengl.GL11.glEnable(org.lwjgl.opengl.GL30.GL_CLIP_DISTANCE0); + + //FIXME: [jme-vr] Fix with JMonkey next release + //RenderManager._VRInstancing_RightCamProjection = camRight.getViewProjectionMatrix(); + setupFinalFullTexture(environment.getApplication().getViewPort().getCamera()); + } + + // setup gui + environment.getVRGUIManager().setupGui(leftCamera, rightCamera, getLeftViewPort(), getRightViewPort()); + + if( environment.getVRHardware() != null ) { + // call these to cache the results internally + environment.getVRHardware().getHMDMatrixPoseLeftEye(); + environment.getVRHardware().getHMDMatrixPoseRightEye(); + } + } else { + throw new IllegalStateException("This VR environment is not attached to any application."); + } + } else { + throw new IllegalStateException("This VR view manager is not attached to any VR environment."); + } + } + + private ViewPort setupMirrorBuffers(Camera cam, Texture tex, boolean expand) { + if (environment != null){ + if (environment.getApplication() != null){ + Camera cloneCam = cam.clone(); + ViewPort viewPort = environment.getApplication().getRenderManager().createPostView("MirrorView", cloneCam); + cloneCam.setParallelProjection(true); + viewPort.setClearFlags(true, true, true); + viewPort.setBackgroundColor(ColorRGBA.Black); + Picture pic = new Picture("fullscene"); + pic.setLocalTranslation(-0.75f, -0.5f, 0f); + if( expand ) { + pic.setLocalScale(3f, 1f, 1f); + } else { + pic.setLocalScale(1.5f, 1f, 1f); + } + pic.setQueueBucket(Bucket.Opaque); + pic.setTexture(environment.getApplication().getAssetManager(), (Texture2D)tex, false); + viewPort.attachScene(pic); + viewPort.setOutputFrameBuffer(null); + + pic.updateGeometricState(); + + return viewPort; + } else { + throw new IllegalStateException("This VR environment is not attached to any application."); + } + } else { + throw new IllegalStateException("This VR view manager is not attached to any VR environment."); + } + } + + private void setupFinalFullTexture(Camera cam) { + if (environment != null){ + if (environment.getApplication() != null){ + // create offscreen framebuffer + FrameBuffer out = new FrameBuffer(cam.getWidth(), cam.getHeight(), 1); + //offBuffer.setSrgb(true); + + //setup framebuffer's texture + dualEyeTex = new Texture2D(cam.getWidth(), cam.getHeight(), Image.Format.RGBA8); + dualEyeTex.setMinFilter(Texture.MinFilter.BilinearNoMipMaps); + dualEyeTex.setMagFilter(Texture.MagFilter.Bilinear); + + logger.config("Dual eye texture "+dualEyeTex.getName()+" ("+dualEyeTex.getImage().getId()+")"); + logger.config(" Type: "+dualEyeTex.getType()); + logger.config(" Size: "+dualEyeTex.getImage().getWidth()+"x"+dualEyeTex.getImage().getHeight()); + logger.config(" Image depth: "+dualEyeTex.getImage().getDepth()); + logger.config(" Image format: "+dualEyeTex.getImage().getFormat()); + logger.config(" Image color space: "+dualEyeTex.getImage().getColorSpace()); + + //setup framebuffer to use texture + out.setDepthBuffer(Image.Format.Depth); + out.setColorTexture(dualEyeTex); + + ViewPort viewPort = environment.getApplication().getViewPort(); + viewPort.setClearFlags(true, true, true); + viewPort.setBackgroundColor(ColorRGBA.Black); + viewPort.setOutputFrameBuffer(out); + } else { + throw new IllegalStateException("This VR environment is not attached to any application."); + } + } else { + throw new IllegalStateException("This VR view manager is not attached to any VR environment."); + } + } + + private ViewPort setupViewBuffers(Camera cam, String viewName){ + if (environment != null){ + if (environment.getApplication() != null){ + // create offscreen framebuffer + FrameBuffer offBufferLeft = new FrameBuffer(cam.getWidth(), cam.getHeight(), 1); + //offBufferLeft.setSrgb(true); + + //setup framebuffer's texture + Texture2D offTex = new Texture2D(cam.getWidth(), cam.getHeight(), Image.Format.RGBA8); + offTex.setMinFilter(Texture.MinFilter.BilinearNoMipMaps); + offTex.setMagFilter(Texture.MagFilter.Bilinear); + + //setup framebuffer to use texture + offBufferLeft.setDepthBuffer(Image.Format.Depth); + offBufferLeft.setColorTexture(offTex); + + ViewPort viewPort = environment.getApplication().getRenderManager().createPreView(viewName, cam); + viewPort.setClearFlags(true, true, true); + viewPort.setBackgroundColor(ColorRGBA.Black); + + Iterator spatialIter = environment.getApplication().getViewPort().getScenes().iterator(); + while(spatialIter.hasNext()){ + viewPort.attachScene(spatialIter.next()); + } + + //set viewport to render to offscreen framebuffer + viewPort.setOutputFrameBuffer(offBufferLeft); + return viewPort; + } else { + throw new IllegalStateException("This VR environment is not attached to any application."); + } + } else { + throw new IllegalStateException("This VR view manager is not attached to any VR environment."); + } + } + + /** + * Set up a distortion mesh for the stereo view. + * @param eye the eye to apply. + * @param api the underlying VR api + * @return the distorted mesh. + */ + public static Mesh setupDistortionMesh(int eye, VRAPI api) { + Mesh distortionMesh = new Mesh(); + float m_iLensGridSegmentCountH = 43, m_iLensGridSegmentCountV = 43; + + float w = 1f / (m_iLensGridSegmentCountH - 1f); + float h = 1f / (m_iLensGridSegmentCountV - 1f); + + float u, v; + + float verts[] = new float[(int) (m_iLensGridSegmentCountV * m_iLensGridSegmentCountH) * 3]; + + float texcoordR[] = new float[(int) (m_iLensGridSegmentCountV * m_iLensGridSegmentCountH) * 2]; + float texcoordG[] = new float[(int) (m_iLensGridSegmentCountV * m_iLensGridSegmentCountH) * 2]; + float texcoordB[] = new float[(int) (m_iLensGridSegmentCountV * m_iLensGridSegmentCountH) * 2]; + + int vertPos = 0, coordPos = 0; + + float Xoffset = eye == JOpenVRLibrary.EVREye.EVREye_Eye_Left ? -1f : 0; + for (int y = 0; y < m_iLensGridSegmentCountV; y++) { + for (int x = 0; x < m_iLensGridSegmentCountH; x++) { + u = x * w; + v = 1 - y * h; + verts[vertPos] = Xoffset + u; // x + verts[vertPos + 1] = -1 + 2 * y * h; // y + verts[vertPos + 2] = 0f; // z + vertPos += 3; + + DistortionCoordinates_t dc0 = new DistortionCoordinates_t(); + if( api.getVRSystem() == null ) { + // default to no distortion + texcoordR[coordPos] = u; + texcoordR[coordPos + 1] = 1 - v; + texcoordG[coordPos] = u; + texcoordG[coordPos + 1] = 1 - v; + texcoordB[coordPos] = u; + texcoordB[coordPos + 1] = 1 - v; + } else { + ((VR_IVRSystem_FnTable)api.getVRSystem()).ComputeDistortion.apply(eye, u, v, dc0); + + texcoordR[coordPos] = dc0.rfRed[0]; + texcoordR[coordPos + 1] = 1 - dc0.rfRed[1]; + texcoordG[coordPos] = dc0.rfGreen[0]; + texcoordG[coordPos + 1] = 1 - dc0.rfGreen[1]; + texcoordB[coordPos] = dc0.rfBlue[0]; + texcoordB[coordPos + 1] = 1 - dc0.rfBlue[1]; + } + + coordPos += 2; + } + } + + // have UV coordinates & positions, now set up indices + + int[] indices = new int[(int) ((m_iLensGridSegmentCountV - 1) * (m_iLensGridSegmentCountH - 1)) * 6]; + int indexPos = 0; + int a, b, c, d; + + int offset = 0; + for (int y = 0; y < m_iLensGridSegmentCountV - 1; y++) { + for (int x = 0; x < m_iLensGridSegmentCountH - 1; x++) { + a = (int) (m_iLensGridSegmentCountH * y + x + offset); + b = (int) (m_iLensGridSegmentCountH * y + x + 1 + offset); + c = (int) ((y + 1) * m_iLensGridSegmentCountH + x + 1 + offset); + d = (int) ((y + 1) * m_iLensGridSegmentCountH + x + offset); + + indices[indexPos] = a; + indices[indexPos + 1] = b; + indices[indexPos + 2] = c; + + indices[indexPos + 3] = a; + indices[indexPos + 4] = c; + indices[indexPos + 5] = d; + + indexPos += 6; + } + } + + // OK, create the mesh + distortionMesh.setBuffer(VertexBuffer.Type.Position, 3, verts); + distortionMesh.setBuffer(VertexBuffer.Type.Index, 1, indices); + distortionMesh.setBuffer(VertexBuffer.Type.TexCoord, 2, texcoordR); + distortionMesh.setBuffer(VertexBuffer.Type.TexCoord2, 2, texcoordG); + distortionMesh.setBuffer(VertexBuffer.Type.TexCoord3, 2, texcoordB); + distortionMesh.setStatic(); + return distortionMesh; + } + + @Override + public void render() { + // TODO Auto-generated method stub + } +} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/osvr/package-info.java b/jme3-xr/src/main/java/com/jme3/input/vr/osvr/package-info.java new file mode 100644 index 0000000000..fb1c9ca58d --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/input/vr/osvr/package-info.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2021 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +/** + * user-input classes for devices that use the Open Source Virtual Reality + * (OSVR) API + */ +package com.jme3.input.vr.osvr; diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/package-info.java b/jme3-xr/src/main/java/com/jme3/input/vr/package-info.java new file mode 100644 index 0000000000..b260858f81 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/input/vr/package-info.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2021 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +/** + * user-input classes for Virtual Reality (VR) applications + */ +package com.jme3.input.vr; diff --git a/jme3-xr/src/main/java/com/jme3/post/CartoonSSAO.java b/jme3-xr/src/main/java/com/jme3/post/CartoonSSAO.java new file mode 100644 index 0000000000..82c45001dd --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/post/CartoonSSAO.java @@ -0,0 +1,155 @@ +package com.jme3.post; + +import com.jme3.asset.AssetManager; +import com.jme3.material.Material; +import com.jme3.math.Vector2f; +import com.jme3.math.Vector3f; +import com.jme3.post.Filter; +import com.jme3.renderer.RenderManager; +import com.jme3.renderer.ViewPort; +import com.jme3.renderer.queue.RenderQueue; +import com.jme3.texture.Image.Format; + +/** + * A Cartoon Screen Space Ambient Occlusion filter with instance rendering capabilities. + * @author reden - phr00t - https://github.com/phr00t + * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr + * + */ +public class CartoonSSAO extends Filter{ + private Pass normalPass; + private Vector3f frustumCorner; + private Vector2f frustumNearFar; + private boolean useOutline = true; + private float downsample = 1f, applyDistance = 0.0005f; + + private boolean instancedRendering = false; + + RenderManager renderManager; + ViewPort viewPort; + + /** + * Create a Screen Space Ambient Occlusion Filter. + * @param instancedRendering true if this filter has to use instance rendering and false (default) otherwise. + */ + public CartoonSSAO(boolean instancedRendering) { + super("CartoonSSAO"); + this.instancedRendering = instancedRendering; + } + + /** + * Create a Screen Space Ambient Occlusion Filter. + * @param downsample factor to divide resolution by for filter, >1 increases speed but degrades quality. + * @param instancedRendering true if this filter has to use instance rendering and false (default) otherwise. + */ + public CartoonSSAO(float downsample, boolean instancedRendering) { + this(instancedRendering); + this.downsample = downsample; + } + + /** + * Create a Screen Space Ambient Occlusion Filter from the given one (by copy). + * @param cloneFrom the original filter. + */ + public CartoonSSAO(CartoonSSAO cloneFrom) { + this(cloneFrom.downsample, cloneFrom.instancedRendering); + } + + @Override + protected boolean isRequiresDepthTexture() { + return true; + } + + @Override + protected void postQueue(RenderQueue renderQueue) { + PreNormalCaching.getPreNormals(renderManager, normalPass, viewPort); + } + + /** + * Set if outline has to be enabled. + * @param set true if the outline has to be enabled and false otherwise. + * @see #isOutlineEnabled() + */ + public void setOutlineEnabled(boolean set) { + useOutline = set; + if( material != null ) { + if( useOutline ) { + material.clearParam("disableOutline"); + } else { + material.setBoolean("disableOutline", true); + } + } + } + + /** + * Is outline rendering is enabled. + * @return true if the outline is enabled and false otherwise. + * @see #setOutlineEnabled(boolean) + */ + public boolean isOutlineEnabled() { + return useOutline; + } + + /** + * Set the down sampling value. + * @param downsample the down sampling value. + * @see #getDownsampling() + */ + public void setDownsampling(float downsample) { + this.downsample = downsample; + } + + /** + * Get the down sampling value. + * @return the down sampling value. + * @see #setDownsampling(float) + */ + public float getDownsampling() { + return this.downsample; + } + + @Override + protected Material getMaterial() { + return material; + } + + /** + * Set the distance of the material. + * @param dist the distance of the material. + */ + public void setDistance(float dist) { + applyDistance = dist; + if( material != null ) material.setFloat("Distance", dist); + } + + @Override + protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) { + this.renderManager = renderManager; + this.viewPort = vp; + + int screenWidth = Math.round(w / downsample); + int screenHeight = Math.round(h / downsample); + + normalPass = new Pass(); + normalPass.init(renderManager.getRenderer(), screenWidth, screenHeight, Format.RGBA8, Format.Depth); + + frustumNearFar = new Vector2f(); + + float farY = (vp.getCamera().getFrustumTop() / vp.getCamera().getFrustumNear()) * vp.getCamera().getFrustumFar(); + float farX = farY * (screenWidth / (float) screenHeight); + frustumCorner = new Vector3f(farX, farY, vp.getCamera().getFrustumFar()); + frustumNearFar.x = vp.getCamera().getFrustumNear(); + frustumNearFar.y = vp.getCamera().getFrustumFar(); + + //ssao Pass + material = new Material(manager, "Common/MatDefs/VR/CartoonSSAO.j3md"); + material.setTexture("Normals", normalPass.getRenderedTexture()); + + material.setVector3("FrustumCorner", frustumCorner); + material.setVector2("FrustumNearFar", frustumNearFar); + material.setFloat("Distance", applyDistance); + if( useOutline == false ) material.setBoolean("disableOutline", true); + if( instancedRendering ) material.setBoolean("useInstancing", true); + } + +} \ No newline at end of file diff --git a/jme3-xr/src/main/java/com/jme3/post/FilterUtil.java b/jme3-xr/src/main/java/com/jme3/post/FilterUtil.java new file mode 100644 index 0000000000..d8d2778742 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/post/FilterUtil.java @@ -0,0 +1,48 @@ +package com.jme3.post; + +import com.jme3.asset.AssetManager; +import com.jme3.post.filters.FogFilter; +import com.jme3.post.ssao.SSAOFilter; +import com.jme3.shadow.DirectionalLightShadowFilter; + +/** + * + * @author Rickard + */ +public class FilterUtil { + /** + * A private constructor to inhibit instantiation of this class. + */ + private FilterUtil() { + } + + public static FogFilter cloneFogFilter(FogFilter fogFilter){ + FogFilter filterClone = new FogFilter(); + filterClone.setFogColor(fogFilter.getFogColor()); + filterClone.setFogDensity(fogFilter.getFogDensity()); + filterClone.setFogDistance(fogFilter.getFogDistance()); + filterClone.setName(fogFilter.getName() + " Clone"); + + return filterClone; + } + + public static SSAOFilter cloneSSAOFilter(SSAOFilter filter){ + SSAOFilter clone = new SSAOFilter(); + clone.setSampleRadius(filter.getSampleRadius()); + clone.setIntensity(filter.getIntensity()); + clone.setScale(filter.getScale()); + clone.setBias(filter.getBias()); + return clone; + } + + public static DirectionalLightShadowFilter cloneDirectionalLightShadowFilter(AssetManager assetManager, DirectionalLightShadowFilter filter){ + DirectionalLightShadowFilter clone = new DirectionalLightShadowFilter(assetManager, 512, 3); + clone.setLight(filter.getLight()); + clone.setLambda(filter.getLambda()); + clone.setShadowIntensity(filter.getShadowIntensity()); + clone.setEdgeFilteringMode(filter.getEdgeFilteringMode()); +// clone.setEnabled(filter.isEnabled()); + return clone; + } + +} diff --git a/jme3-xr/src/main/java/com/jme3/post/PreNormalCaching.java b/jme3-xr/src/main/java/com/jme3/post/PreNormalCaching.java new file mode 100644 index 0000000000..b2250e8d76 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/post/PreNormalCaching.java @@ -0,0 +1,72 @@ +package com.jme3.post; + +import com.jme3.post.Filter.Pass; +import com.jme3.renderer.Caps; +import com.jme3.renderer.RenderManager; +import com.jme3.renderer.Renderer; +import com.jme3.renderer.ViewPort; +import com.jme3.texture.FrameBuffer; + +/** + * Pre normal caching class. + * @author reden - phr00t - https://github.com/phr00t + * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr + */ +public class PreNormalCaching { + + private static FrameBuffer cachedPreNormals; + private static int lastNormalPassesCount, curCount; + + /** + * A private constructor to inhibit instantiation of this class. + */ + private PreNormalCaching() { + } + + /** + * Get pre-normals from the given rendering. + * @param renderManager the render manager. + * @param normalPass the normal pass. + * @param viewPort the viewport. + */ + public static void getPreNormals(RenderManager renderManager, Pass normalPass, ViewPort viewPort) { + curCount++; + // do we already have a valid cache to set the framebuffer to? + Renderer r = renderManager.getRenderer(); + if( cachedPreNormals != null ) { + r.copyFrameBuffer(cachedPreNormals, normalPass.getRenderFrameBuffer(),true, false); + } else { + // let's make the prenormals + r.setFrameBuffer(normalPass.getRenderFrameBuffer()); + renderManager.getRenderer().clearBuffers(true, true, true); + if( renderManager.getRenderer().getCaps().contains(Caps.GLSL150) ) { + renderManager.setForcedTechnique("PreNormalPass15"); + } else { + renderManager.setForcedTechnique("PreNormalPass"); + } + renderManager.renderViewPortQueues(viewPort, false); + renderManager.setForcedTechnique(null); + // if we should cache this, do it now + if( lastNormalPassesCount > 1 ) { + cachedPreNormals = normalPass.getRenderFrameBuffer(); + } + } + renderManager.getRenderer().setFrameBuffer(viewPort.getOutputFrameBuffer()); + } + + /** + * Reset the cache + * @param stereo true if the rendering is stereo based and false otherwise. + */ + public static void resetCache(boolean stereo) { + if( stereo == false ) { + // only use this feature if we are NOT in VR + // we can't use the same normal information for another eye, + // because it will be different! + lastNormalPassesCount = curCount; + } + cachedPreNormals = null; + curCount = 0; + } + +} diff --git a/jme3-xr/src/main/java/com/jme3/scene/CenterQuad.java b/jme3-xr/src/main/java/com/jme3/scene/CenterQuad.java new file mode 100644 index 0000000000..e2911eba6f --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/scene/CenterQuad.java @@ -0,0 +1,173 @@ +/* + * Copyright (c) 2009-2021 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.scene; + +import com.jme3.export.InputCapsule; +import com.jme3.export.JmeExporter; +import com.jme3.export.JmeImporter; +import com.jme3.export.OutputCapsule; +import com.jme3.scene.VertexBuffer.Type; +import java.io.IOException; + +/** + * A static, indexed, Triangles-mode mesh for an axis-aligned rectangle in the + * X-Y plane. + * + *

The rectangle extends from (-width/2, -height/2, 0) to + * (width/2, height/2, 0) with normals set to (0,0,1). + * + *

This differs from com.jme3.scene.shape.Quad because it puts + * (0,0,0) at the rectangle's center instead of in a corner. + * + * @author Kirill Vainer + * @deprecated use com.jme3.scene.shape.CenterQuad + */ +@Deprecated +public class CenterQuad extends Mesh { + + public static CenterQuad UnitQuad = new CenterQuad(0.5f, 0.5f); + public static Mesh CenterSplitQuad; + + private float width; + private float height; + + /** + * Create a quad with the given width and height. The quad + * is always created in the XY plane. + * + * @param width The X extent or width + * @param height The Y extent or width + */ + public CenterQuad(float width, float height){ + updateGeometry(width, height); + } + + /** + * Create a quad with the given width and height. The quad + * is always created in the XY plane. + * + * @param width The X extent or width + * @param height The Y extent or width + * @param flipCoords If true, the texture coordinates will be flipped + * along the Y axis. + */ + public CenterQuad(float width, float height, boolean flipCoords){ + updateGeometry(width, height, flipCoords); + this.setStatic(); + } + + /** + * For serialization only. Do not use. + */ + protected CenterQuad() { + } + + public float getHeight() { + return height; + } + + public float getWidth() { + return width; + } + + public void updateGeometry(float width, float height){ + updateGeometry(width, height, false); + } + + public void updateGeometry(float width, float height, boolean flipCoords) { + this.width = width; + this.height = height; + setBuffer(Type.Position, 3, new float[]{-width/2, -height/2, 0, + width/2, -height/2, 0, + width/2, height/2, 0, + -width/2, height/2, 0 + }); + + + if (flipCoords){ + setBuffer(Type.TexCoord, 2, new float[]{0, 1, + 1, 1, + 1, 0, + 0, 0}); + }else{ + setBuffer(Type.TexCoord, 2, new float[]{0, 0, + 1, 0, + 1, 1, + 0, 1}); + } + setBuffer(Type.Normal, 3, new float[]{0, 0, 1, + 0, 0, 1, + 0, 0, 1, + 0, 0, 1}); + if (height < 0){ + setBuffer(Type.Index, 3, new short[]{0, 2, 1, + 0, 3, 2}); + }else{ + setBuffer(Type.Index, 3, new short[]{0, 1, 2, + 0, 2, 3}); + } + + updateBound(); + } + + /** + * De-serializes from the specified importer, for example when loading from + * a J3O file. + * + * @param importer the importer to use (not null) + * @throws IOException from the importer + */ + @Override + public void read(JmeImporter importer) throws IOException { + super.read(importer); + InputCapsule capsule = importer.getCapsule(this); + + width = capsule.readFloat("width", 0f); + height = capsule.readFloat("height", 0f); + } + + /** + * Serializes to the specified exporter, for example when saving to a J3O + * file. The current instance is unaffected. + * + * @param exporter the exporter to use (not null) + * @throws IOException from the exporter + */ + @Override + public void write(JmeExporter exporter) throws IOException { + super.write(exporter); + OutputCapsule capsule = exporter.getCapsule(this); + + capsule.write(width, "width", 0f); + capsule.write(height, "height", 0f); + } +} diff --git a/jme3-xr/src/main/java/com/jme3/shadow/AbstractShadowFilterVR.java b/jme3-xr/src/main/java/com/jme3/shadow/AbstractShadowFilterVR.java new file mode 100644 index 0000000000..3144a417e0 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/shadow/AbstractShadowFilterVR.java @@ -0,0 +1,320 @@ +package com.jme3.shadow; + +/* + * Copyright (c) 2009-2021 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import com.jme3.asset.AssetManager; +import com.jme3.export.JmeExporter; +import com.jme3.export.JmeImporter; +import com.jme3.material.Material; +import com.jme3.material.RenderState; +import com.jme3.math.Matrix4f; +import com.jme3.math.Vector4f; +import com.jme3.post.Filter; +import com.jme3.renderer.RenderManager; +import com.jme3.renderer.ViewPort; +import com.jme3.renderer.queue.RenderQueue; +import com.jme3.texture.FrameBuffer; + +import java.io.IOException; + +/** + * Generic abstract filter that holds common implementations for the different + * shadow filters. + * + * @author Rémy Bouquet aka Nehon + * @author reden - phr00t - https://github.com/phr00t + * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr + * @param the type of the underlying renderer (subclass of {@link AbstractShadowRendererVR}). + */ +public abstract class AbstractShadowFilterVR extends Filter { + + protected T shadowRenderer; + protected ViewPort viewPort; + + /** + * Abstract class constructor + * + * @param manager the application asset manager + * @param shadowMapSize the size of the rendered shadowmaps (512,1024,2048, + * etc...) + * @param shadowRenderer the shadowRenderer to use for this Filter + */ + @SuppressWarnings("all") + protected AbstractShadowFilterVR(AssetManager manager, int shadowMapSize, T shadowRenderer) { + super("Post Shadow"); + material = new Material(manager, "Common/MatDefs/Shadow/PostShadowFilter.j3md"); + this.shadowRenderer = shadowRenderer; + this.shadowRenderer.setPostShadowMaterial(material); + + //this is legacy setting for shadows with backface shadows + this.shadowRenderer.setRenderBackFacesShadows(true); + } + + @SuppressWarnings("all") + protected AbstractShadowFilterVR(AssetManager manager, int shadowMapSize, T shadowRenderer, String useMatDef) { + super("Post Shadow"); + material = new Material(manager, useMatDef); + this.shadowRenderer = shadowRenderer; + this.shadowRenderer.setPostShadowMaterial(material); + } + + @Override + protected Material getMaterial() { + return material; + } + + @Override + protected boolean isRequiresDepthTexture() { + return true; + } + + /** + * Get the {@link Material material} used by this filter. + * @return the {@link Material material} used by this filter. + */ + public Material getShadowMaterial() { + return material; + } + + Vector4f tmpv = new Vector4f(); + + @Override + protected void preFrame(float tpf) { + shadowRenderer.preFrame(tpf); + material.setMatrix4("ViewProjectionMatrixInverse", viewPort.getCamera().getViewProjectionMatrix().invert()); + Matrix4f m = viewPort.getCamera().getViewProjectionMatrix(); + material.setVector4("ViewProjectionMatrixRow2", tmpv.set(m.m20, m.m21, m.m22, m.m23)); + + } + + @Override + protected void postQueue(RenderQueue queue) { + shadowRenderer.postQueue(queue); + if(shadowRenderer.skipPostPass){ + //removing the shadow map so that the post pass is skipped + material.setTexture("ShadowMap0", null); + } + } + + @Override + protected void postFrame(RenderManager renderManager, ViewPort viewPort, FrameBuffer prevFilterBuffer, FrameBuffer sceneBuffer) { + if(!shadowRenderer.skipPostPass){ + shadowRenderer.setPostShadowParams(); + } + } + + @Override + protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) { + shadowRenderer.needsfallBackMaterial = true; + shadowRenderer.initialize(renderManager, vp); + this.viewPort = vp; + } + + /** + * How far the shadows are rendered in the view + * + * @see #setShadowZExtend(float zFar) + * @return shadowZExtend + */ + public float getShadowZExtend() { + return shadowRenderer.getShadowZExtend(); + } + + /** + * Set the distance from the eye where the shadows will be rendered default + * value is dynamically computed to the shadow casters/receivers union bound + * zFar, capped to view frustum far value. + * + * @param zFar the zFar values that override the computed one + */ + public void setShadowZExtend(float zFar) { + shadowRenderer.setShadowZExtend(zFar); + } + + /** + * Define the length over which the shadow will fade out when using a + * shadowZextend + * + * @param length the fade length in world units + */ + public void setShadowZFadeLength(float length) { + shadowRenderer.setShadowZFadeLength(length); + } + + /** + * get the length over which the shadow will fade out when using a + * shadowZextend + * + * @return the fade length in world units + */ + public float getShadowZFadeLength() { + return shadowRenderer.getShadowZFadeLength(); + } + + /** + * returns the shadow intensity + * + * @see #setShadowIntensity(float shadowIntensity) + * @return shadowIntensity + */ + public float getShadowIntensity() { + return shadowRenderer.getShadowIntensity(); + } + + /** + * Set the shadowIntensity, the value should be between 0 and 1, a 0 value + * gives a bright and invisible shadow, a 1 value gives a pitch black + * shadow, default is 0.7 + * + * @param shadowIntensity the darkness of the shadow + */ + final public void setShadowIntensity(float shadowIntensity) { + shadowRenderer.setShadowIntensity(shadowIntensity); + } + + /** + * returns the edges thickness
+ * + * @see #setEdgesThickness(int edgesThickness) + * @return edgesThickness + */ + public int getEdgesThickness() { + return shadowRenderer.getEdgesThickness(); + } + + /** + * Sets the shadow edge thickness. Default is 1. Setting it to lower values + * can help to reduce the jagged effect of the shadow edges. + * @param edgesThickness the edge thickness. + */ + public void setEdgesThickness(int edgesThickness) { + shadowRenderer.setEdgesThickness(edgesThickness); + } + + /** + * isFlushQueues does nothing and is kept only for backward compatibility. + * @return false + * @deprecated does nothing and is kept only for backward compatibility. + */ + @Deprecated + public boolean isFlushQueues() { + return shadowRenderer.isFlushQueues(); + } + + /** + * Sets the shadow compare mode (see {@link CompareMode} for more info). + * @param compareMode the compare mode. + */ + final public void setShadowCompareMode(CompareMode compareMode) { + shadowRenderer.setShadowCompareMode(compareMode); + } + + /** + * Get the shadow compare mode. + * + * @return the shadow compare mode. + * @see CompareMode + */ + public CompareMode getShadowCompareMode() { + return shadowRenderer.getShadowCompareMode(); + } + + /** + * Sets the filtering mode for shadow edges see {@link EdgeFilteringMode} for more info + * @param filterMode the filtering mode for shadow edges. + */ + final public void setEdgeFilteringMode(EdgeFilteringMode filterMode) { + shadowRenderer.setEdgeFilteringMode(filterMode); + } + + /** + * + * WARNING this parameter is defaulted to true for the shadow filter. Setting it to true, may produce edges artifacts on shadows.
+ *
+ * Set to true if you want back faces shadows on geometries. + * Note that back faces shadows will be blended over dark lighten areas and may produce overly dark lighting.
+ *
+ * Setting this parameter will override this parameter for ALL materials in the scene. + * This also will automatically adjust the face cull mode and the PolyOffset of the pre shadow pass. + * You can modify them by using {@link #getPreShadowForcedRenderState()}.
+ *
+ * If you want to set it differently for each material in the scene you have to use the ShadowRenderer instead + * of the shadow filter. + * + * @param renderBackFacesShadows true if back faces shadows on geometries have to be rendered and false otherwise. + */ + public void setRenderBackFacesShadows(Boolean renderBackFacesShadows) { + shadowRenderer.setRenderBackFacesShadows(renderBackFacesShadows); + } + + /** + * Is this filter renders back faces shadows. + * @return true if this filter renders back faces shadows and false otherwise. + */ + public boolean isRenderBackFacesShadows() { + return shadowRenderer.isRenderBackFacesShadows(); + } + + /** + * Get the pre-shadows pass render state. + * use it to adjust the RenderState parameters of the pre shadow pass. + * Note that this will be overridden if the preShadow technique in the material has a ForcedRenderState + * @return the pre shadow render state. + */ + public RenderState getPreShadowForcedRenderState() { + return shadowRenderer.getPreShadowForcedRenderState(); + } + + + /** + * Get the edge filtering mode. + * @return the edge filtering mode. + */ + public EdgeFilteringMode getEdgeFilteringMode() { + return shadowRenderer.getEdgeFilteringMode(); + } + + @Override + public void write(JmeExporter ex) throws IOException { + super.write(ex); + //OutputCapsule oc = ex.getCapsule(this); + + } + + @Override + public void read(JmeImporter im) throws IOException { + super.read(im); + //InputCapsule ic = im.getCapsule(this); + + } +} diff --git a/jme3-xr/src/main/java/com/jme3/shadow/AbstractShadowRendererVR.java b/jme3-xr/src/main/java/com/jme3/shadow/AbstractShadowRendererVR.java new file mode 100644 index 0000000000..7338864dd8 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/shadow/AbstractShadowRendererVR.java @@ -0,0 +1,839 @@ +package com.jme3.shadow; + +/* + * Copyright (c) 2009-2021 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import com.jme3.asset.AssetManager; +import com.jme3.export.*; +import com.jme3.light.LightFilter; +import com.jme3.light.NullLightFilter; +import com.jme3.material.Material; +import com.jme3.material.RenderState; +import com.jme3.math.ColorRGBA; +import com.jme3.math.Matrix4f; +import com.jme3.math.Vector2f; +import com.jme3.math.Vector3f; +import com.jme3.post.SceneProcessor; +import com.jme3.profile.AppProfiler; +import com.jme3.renderer.Camera; +import com.jme3.renderer.RenderManager; +import com.jme3.renderer.Renderer; +import com.jme3.renderer.ViewPort; +import com.jme3.renderer.queue.GeometryList; +import com.jme3.renderer.queue.OpaqueComparator; +import com.jme3.renderer.queue.RenderQueue; +import com.jme3.renderer.queue.RenderQueue.ShadowMode; +import com.jme3.scene.Geometry; +import com.jme3.scene.Spatial; +import com.jme3.scene.debug.WireFrustum; +import com.jme3.texture.FrameBuffer; +import com.jme3.texture.Image.Format; +import com.jme3.texture.Texture.MagFilter; +import com.jme3.texture.Texture.MinFilter; +import com.jme3.texture.Texture.ShadowCompareMode; +import com.jme3.texture.Texture2D; +import com.jme3.texture.FrameBuffer.FrameBufferTarget; +import com.jme3.ui.Picture; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +/** + * Abstract shadow renderer that holds commons feature to have for a shadow + * renderer. + * + * @author Rémy Bouquet aka Nehon + * @author reden - phr00t - https://github.com/phr00t + * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr + */ +public abstract class AbstractShadowRendererVR implements SceneProcessor, Savable { + private static final LightFilter NULL_LIGHT_FILTER = new NullLightFilter(); + protected int nbShadowMaps = 1; + protected float shadowMapSize; + protected float shadowIntensity = 0.7f; + protected RenderManager renderManager; + protected ViewPort viewPort; + protected FrameBuffer[] shadowFB; + protected Texture2D[] shadowMaps; + protected Texture2D dummyTex; + protected Material preshadowMat; + protected Material postshadowMat; + protected Matrix4f[] lightViewProjectionsMatrices; + protected AssetManager assetManager; + protected boolean debug = false; + protected float edgesThickness = 1.0f; + protected EdgeFilteringMode edgeFilteringMode = EdgeFilteringMode.Bilinear; + protected CompareMode shadowCompareMode = CompareMode.Hardware; + protected Picture[] dispPic; + protected RenderState forcedRenderState = new RenderState(); + protected boolean renderBackFacesShadows; + + protected AppProfiler profiler = null; + + /** + * true if the fallback material should be used, otherwise false + */ + protected boolean needsfallBackMaterial = false; + /** + * name of the post material technique + */ + protected String postTechniqueName = "PostShadow"; + /** + * list of materials for post shadow queue geometries + */ + protected List matCache = new ArrayList<>(); + protected GeometryList lightReceivers = new GeometryList(new OpaqueComparator()); + protected GeometryList shadowMapOccluders = new GeometryList(new OpaqueComparator()); + private String[] shadowMapStringCache; + private String[] lightViewStringCache; + /** + * fade shadows at distance + */ + protected float zFarOverride = 0; + protected Vector2f fadeInfo; + protected float fadeLength; + protected Camera frustumCam; + /** + * true to skip the post pass when there are no shadow casters + */ + protected boolean skipPostPass; + + /** + * used for serialization + */ + protected AbstractShadowRendererVR(){ + } + + /** + * Create an abstract shadow renderer. Subclasses invoke this constructor. + * + * @param assetManager the application asset manager + * @param shadowMapSize the size of the rendered shadow maps (512,1024,2048, + * etc...) + * @param nbShadowMaps the number of shadow maps rendered (the more shadow + * maps the more quality, the fewer fps). + */ + protected AbstractShadowRendererVR(AssetManager assetManager, int shadowMapSize, int nbShadowMaps) { + + this.assetManager = assetManager; + this.nbShadowMaps = nbShadowMaps; + this.shadowMapSize = shadowMapSize; + init(assetManager, nbShadowMaps, shadowMapSize); + + } + + private void init(AssetManager assetManager, int nbShadowMaps, int shadowMapSize) { + this.postshadowMat = new Material(assetManager, "Common/MatDefs/Shadow/PostShadow.j3md"); + shadowFB = new FrameBuffer[nbShadowMaps]; + shadowMaps = new Texture2D[nbShadowMaps]; + dispPic = new Picture[nbShadowMaps]; + lightViewProjectionsMatrices = new Matrix4f[nbShadowMaps]; + shadowMapStringCache = new String[nbShadowMaps]; + lightViewStringCache = new String[nbShadowMaps]; + + //DO NOT COMMENT THIS (It prevents the OSX incomplete read buffer crash.) + dummyTex = new Texture2D(shadowMapSize, shadowMapSize, Format.RGBA8); + + preshadowMat = new Material(assetManager, "Common/MatDefs/Shadow/PreShadow.j3md"); + postshadowMat.setFloat("ShadowMapSize", shadowMapSize); + + for (int i = 0; i < nbShadowMaps; i++) { + lightViewProjectionsMatrices[i] = new Matrix4f(); + shadowFB[i] = new FrameBuffer(shadowMapSize, shadowMapSize, 1); + shadowMaps[i] = new Texture2D(shadowMapSize, shadowMapSize, Format.Depth); + + shadowFB[i].setDepthTarget(FrameBufferTarget.newTarget(shadowMaps[i])); + + //DO NOT COMMENT THIS (It prevents the OSX incomplete read buffer crash.) + shadowFB[i].addColorTarget(FrameBufferTarget.newTarget(dummyTex)); + shadowMapStringCache[i] = "ShadowMap" + i; + lightViewStringCache[i] = "LightViewProjectionMatrix" + i; + + postshadowMat.setTexture(shadowMapStringCache[i], shadowMaps[i]); + + //quads for debugging purposes + dispPic[i] = new Picture("Picture" + i); + dispPic[i].setTexture(assetManager, shadowMaps[i], false); + } + + setShadowCompareMode(shadowCompareMode); + setEdgeFilteringMode(edgeFilteringMode); + setShadowIntensity(shadowIntensity); + initForcedRenderState(); + setRenderBackFacesShadows(isRenderBackFacesShadows()); + } + + protected void initForcedRenderState() { + forcedRenderState.setFaceCullMode(RenderState.FaceCullMode.Front); + forcedRenderState.setColorWrite(false); + forcedRenderState.setDepthWrite(true); + forcedRenderState.setDepthTest(true); + } + + /** + * set the post shadow material for this renderer + * + * @param postShadowMat + */ + protected final void setPostShadowMaterial(Material postShadowMat) { + this.postshadowMat = postShadowMat; + postshadowMat.setFloat("ShadowMapSize", shadowMapSize); + for (int i = 0; i < nbShadowMaps; i++) { + postshadowMat.setTexture(shadowMapStringCache[i], shadowMaps[i]); + } + setShadowCompareMode(shadowCompareMode); + setEdgeFilteringMode(edgeFilteringMode); + setShadowIntensity(shadowIntensity); + } + + /** + * Sets the filtering mode for shadow edges. See {@link EdgeFilteringMode} + * for more info. + * + * @param filterMode the desired filter mode (not null) + */ + final public void setEdgeFilteringMode(EdgeFilteringMode filterMode) { + if (filterMode == null) { + throw new IllegalArgumentException("filterMode cannot be null"); + } + + this.edgeFilteringMode = filterMode; + postshadowMat.setInt("FilterMode", filterMode.getMaterialParamValue()); + postshadowMat.setFloat("PCFEdge", edgesThickness); + if (shadowCompareMode == CompareMode.Hardware) { + for (Texture2D shadowMap : shadowMaps) { + if (filterMode == EdgeFilteringMode.Bilinear) { + shadowMap.setMagFilter(MagFilter.Bilinear); + shadowMap.setMinFilter(MinFilter.BilinearNoMipMaps); + } else { + shadowMap.setMagFilter(MagFilter.Nearest); + shadowMap.setMinFilter(MinFilter.NearestNoMipMaps); + } + } + } + } + + /** + * Get the edge filtering mode. + * @return the edge filtering mode. + */ + public EdgeFilteringMode getEdgeFilteringMode() { + return edgeFilteringMode; + } + + /** + * Sets the shadow compare mode. See {@link CompareMode} for more info. + * + * @param compareMode the desired compare mode (not null) + */ + final public void setShadowCompareMode(CompareMode compareMode) { + if (compareMode == null) { + throw new IllegalArgumentException("Shadow compare mode cannot be null"); + } + + this.shadowCompareMode = compareMode; + for (Texture2D shadowMap : shadowMaps) { + if (compareMode == CompareMode.Hardware) { + shadowMap.setShadowCompareMode(ShadowCompareMode.LessOrEqual); + if (edgeFilteringMode == EdgeFilteringMode.Bilinear) { + shadowMap.setMagFilter(MagFilter.Bilinear); + shadowMap.setMinFilter(MinFilter.BilinearNoMipMaps); + } else { + shadowMap.setMagFilter(MagFilter.Nearest); + shadowMap.setMinFilter(MinFilter.NearestNoMipMaps); + } + } else { + shadowMap.setShadowCompareMode(ShadowCompareMode.Off); + shadowMap.setMagFilter(MagFilter.Nearest); + shadowMap.setMinFilter(MinFilter.NearestNoMipMaps); + } + } + postshadowMat.setBoolean("HardwareShadows", compareMode == CompareMode.Hardware); + } + + /** + * returns the shadow compare mode + * + * @see CompareMode + * @return the shadowCompareMode + */ + public CompareMode getShadowCompareMode() { + return shadowCompareMode; + } + + /** + * debug function to create a visible frustum + */ + protected Geometry createFrustum(Vector3f[] pts, int i) { + WireFrustum frustum = new WireFrustum(pts); + Geometry frustumMdl = new Geometry("f", frustum); + frustumMdl.setCullHint(Spatial.CullHint.Never); + frustumMdl.setShadowMode(ShadowMode.Off); + Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); + mat.getAdditionalRenderState().setWireframe(true); + frustumMdl.setMaterial(mat); + switch (i) { + case 0: + frustumMdl.getMaterial().setColor("Color", ColorRGBA.Pink); + break; + case 1: + frustumMdl.getMaterial().setColor("Color", ColorRGBA.Red); + break; + case 2: + frustumMdl.getMaterial().setColor("Color", ColorRGBA.Green); + break; + case 3: + frustumMdl.getMaterial().setColor("Color", ColorRGBA.Blue); + break; + default: + frustumMdl.getMaterial().setColor("Color", ColorRGBA.White); + break; + } + + frustumMdl.updateGeometricState(); + return frustumMdl; + } + + /** + * Initialize this shadow renderer prior to its first update. + * + * @param rm the render manager + * @param vp the viewport + */ + @Override + public void initialize(RenderManager rm, ViewPort vp) { + renderManager = rm; + viewPort = vp; + postTechniqueName = "PostShadow"; + if(zFarOverride>0 && frustumCam == null){ + initFrustumCam(); + } + } + + /** + * delegates the initialization of the frustum cam to child renderers + */ + protected abstract void initFrustumCam(); + + /** + * Test whether this shadow renderer has been initialized. + * + * @return true if initialized, otherwise false + */ + @Override + public boolean isInitialized() { + return viewPort != null; + } + + /** + * Invoked once per frame to update the shadow cams according to the light + * view. + * + * @param viewCam the scene cam + */ + protected abstract void updateShadowCams(Camera viewCam); + + /** + * Returns a subclass-specific geometryList containing the occluders to be + * rendered in the shadow map + * + * @param shadowMapIndex the index of the shadow map being rendered + * @param shadowMapOccluders the list of occluders + * @return a list of occluders + */ + protected abstract GeometryList getOccludersToRender(int shadowMapIndex, GeometryList shadowMapOccluders); + + /** + * return the shadow camera to use for rendering the shadow map according + * the given index + * + * @param shadowMapIndex the index of the shadow map being rendered + * @return the shadowCam + */ + protected abstract Camera getShadowCam(int shadowMapIndex); + + @Override + public void setProfiler(AppProfiler profiler) { + this.profiler = profiler; + } + + /** + * responsible for displaying the frustum of the shadow cam for debug + * purpose + * + * @param shadowMapIndex + */ + protected void doDisplayFrustumDebug(int shadowMapIndex) { + } + + @SuppressWarnings("fallthrough") + @Override + public void postQueue(RenderQueue rq) { + lightReceivers.clear(); + skipPostPass = false; + if ( !checkCulling(viewPort.getCamera()) ) { + skipPostPass = true; + return; + } + + updateShadowCams(viewPort.getCamera()); + + Renderer r = renderManager.getRenderer(); + renderManager.setForcedMaterial(preshadowMat); + renderManager.setForcedTechnique("PreShadow"); + + for (int shadowMapIndex = 0; shadowMapIndex < nbShadowMaps; shadowMapIndex++) { + + if (debugfrustums) { + doDisplayFrustumDebug(shadowMapIndex); + } + renderShadowMap(shadowMapIndex); + + } + + debugfrustums = false; + + //restore setting for future rendering + r.setFrameBuffer(viewPort.getOutputFrameBuffer()); + renderManager.setForcedMaterial(null); + renderManager.setForcedTechnique(null); + renderManager.setCamera(viewPort.getCamera(), false); + } + + protected void renderShadowMap(int shadowMapIndex) { + shadowMapOccluders = getOccludersToRender(shadowMapIndex, shadowMapOccluders); + Camera shadowCam = getShadowCam(shadowMapIndex); + + //saving light view projection matrix for this split + lightViewProjectionsMatrices[shadowMapIndex].set(shadowCam.getViewProjectionMatrix()); + renderManager.setCamera(shadowCam, false); + + renderManager.getRenderer().setFrameBuffer(shadowFB[shadowMapIndex]); + renderManager.getRenderer().clearBuffers(true, true, true); + renderManager.setForcedRenderState(forcedRenderState); + + // render shadow casters to shadow map and disables the lightfilter + LightFilter tmpLightFilter = renderManager.getLightFilter(); + renderManager.setLightFilter(NULL_LIGHT_FILTER); + viewPort.getQueue().renderShadowQueue(shadowMapOccluders, renderManager, shadowCam, true); + renderManager.setLightFilter(tmpLightFilter); + renderManager.setForcedRenderState(null); + } + boolean debugfrustums = false; + + /** + * Force the frustum to be displayed. + */ + public void displayFrustum() { + debugfrustums = true; + } + + /** + * For debugging purposes, display depth shadow maps. + */ + protected void displayShadowMap(Renderer r) { + Camera cam = viewPort.getCamera(); + renderManager.setCamera(cam, true); + int h = cam.getHeight(); + for (int i = 0; i < dispPic.length; i++) { + dispPic[i].setPosition((128 * i) + (150 + 64 * (i + 1)), h / 20f); + dispPic[i].setWidth(128); + dispPic[i].setHeight(128); + dispPic[i].updateGeometricState(); + renderManager.renderGeometry(dispPic[i]); + } + renderManager.setCamera(cam, false); + } + + /** + * For debugging purposes, "snapshot" the current frustum to the scene. + */ + public void displayDebug() { + debug = true; + } + + protected abstract void getReceivers(GeometryList lightReceivers); + + @Override + public void postFrame(FrameBuffer out) { + if (skipPostPass) { + return; + } + if (debug) { + displayShadowMap(renderManager.getRenderer()); + } + + getReceivers(lightReceivers); + + if (lightReceivers.size() != 0) { + //setting params to receiving geometry list + setMatParams(lightReceivers); + + Camera cam = viewPort.getCamera(); + //If some materials in the scene do not have a post shadow technique, use the fallback material. + if (needsfallBackMaterial) { + renderManager.setForcedMaterial(postshadowMat); + } + + //forcing the post shadow technique and render state + renderManager.setForcedTechnique(postTechniqueName); + + //rendering the post shadow pass + viewPort.getQueue().renderShadowQueue(lightReceivers, renderManager, cam, false); + + //resetting renderManager settings + renderManager.setForcedTechnique(null); + renderManager.setForcedMaterial(null); + renderManager.setCamera(cam, false); + + //clearing the params in case there are some other shadow renderers + clearMatParams(); + } + } + + /** + * This method is called once per frame and is responsible for clearing any + * material parameters that subclasses may need to clear on the post material. + * + * @param material the material that was used for the post shadow pass + */ + protected abstract void clearMaterialParameters(Material material); + + private void clearMatParams(){ + for (Material mat : matCache) { + //clearing only necessary params, the others may be set by other + //renderers + //Note that j start at 1 because other shadow renderers will have + //at least 1 shadow map and will set it on each frame anyway. + for (int j = 1; j < nbShadowMaps; j++) { + mat.clearParam(lightViewStringCache[j]); + } + for (int j = 1; j < nbShadowMaps; j++) { + mat.clearParam(shadowMapStringCache[j]); + } + mat.clearParam("FadeInfo"); + clearMaterialParameters(mat); + } + //No need to clear the postShadowMat params as the instance is locale to each renderer + } + + /** + * This method is called once per frame and is responsible for setting any + * material parameters that subclasses may need to set on the post material. + * + * @param material the material to use for the post shadow pass + */ + protected abstract void setMaterialParameters(Material material); + + private void setMatParams(GeometryList l) { + //iterate through all the geometries of the list to gather the materials + + buildMatCache(l); + + //iterating through the mat cache and setting the parameters + for (Material mat : matCache) { + + mat.setFloat("ShadowMapSize", shadowMapSize); + + for (int j = 0; j < nbShadowMaps; j++) { + mat.setMatrix4(lightViewStringCache[j], lightViewProjectionsMatrices[j]); + } + for (int j = 0; j < nbShadowMaps; j++) { + mat.setTexture(shadowMapStringCache[j], shadowMaps[j]); + } + mat.setBoolean("HardwareShadows", shadowCompareMode == CompareMode.Hardware); + mat.setInt("FilterMode", edgeFilteringMode.getMaterialParamValue()); + mat.setFloat("PCFEdge", edgesThickness); + mat.setFloat("ShadowIntensity", shadowIntensity); + mat.setBoolean("BackfaceShadows", renderBackFacesShadows); + + if (fadeInfo != null) { + mat.setVector2("FadeInfo", fadeInfo); + } + + setMaterialParameters(mat); + } + + //At least one material of the receiving geoms does not support the post shadow technique, + //so we fall back to the forced material solution. (Transparent shadows won't be supported for these objects.) + if (needsfallBackMaterial) { + setPostShadowParams(); + } + + } + + private void buildMatCache(GeometryList l) { + matCache.clear(); + for (int i = 0; i < l.size(); i++) { + Material mat = l.get(i).getMaterial(); + //checking if the material has the post technique and adding it to the material cache + if (mat.getMaterialDef().getTechniqueDefs(postTechniqueName) != null) { + if (!matCache.contains(mat)) { + matCache.add(mat); + } + } else { + needsfallBackMaterial = true; + } + } + } + + /** + * for internal use only + */ + protected void setPostShadowParams() { + setMaterialParameters(postshadowMat); + for (int j = 0; j < nbShadowMaps; j++) { + postshadowMat.setMatrix4(lightViewStringCache[j], lightViewProjectionsMatrices[j]); + postshadowMat.setTexture(shadowMapStringCache[j], shadowMaps[j]); + } + if (fadeInfo != null) { + postshadowMat.setVector2("FadeInfo", fadeInfo); + } + postshadowMat.setBoolean("BackfaceShadows", renderBackFacesShadows); + } + + /** + * How far the shadows are rendered in the view + * + * @see #setShadowZExtend(float zFar) + * @return shadowZExtend + */ + public float getShadowZExtend() { + return zFarOverride; + } + + /** + * Set the distance from the eye where the shadows will be rendered default + * value is dynamically computed to the shadow casters/receivers union bound + * zFar, capped to view frustum far value. + * + * @param zFar the zFar values that override the computed one + */ + public void setShadowZExtend(float zFar) { + this.zFarOverride = zFar; + if(zFarOverride == 0){ + fadeInfo = null; + frustumCam = null; + }else{ + if (fadeInfo != null) { + fadeInfo.set(zFarOverride - fadeLength, 1f / fadeLength); + } + if(frustumCam == null && viewPort != null){ + initFrustumCam(); + } + } + } + + /** + * Define the length over which the shadow will fade out when using a + * shadowZextend This is useful to make dynamic shadows fade into baked + * shadows in the distance. + * + * @param length the fade length in world units + */ + public void setShadowZFadeLength(float length) { + if (length == 0) { + fadeInfo = null; + fadeLength = 0; + postshadowMat.clearParam("FadeInfo"); + } else { + if (zFarOverride == 0) { + fadeInfo = new Vector2f(0, 0); + } else { + fadeInfo = new Vector2f(zFarOverride - length, 1.0f / length); + } + fadeLength = length; + postshadowMat.setVector2("FadeInfo", fadeInfo); + } + } + + /** + * get the length over which the shadow will fade out when using a + * shadowZextend + * + * @return the fade length in world units + */ + public float getShadowZFadeLength() { + if (fadeInfo != null) { + return zFarOverride - fadeInfo.x; + } + return 0f; + } + + /** + * returns true if the light source bounding box is in the view frustum + * @return true if box in frustum + */ + protected abstract boolean checkCulling(Camera viewCam); + + @Override + public void preFrame(float tpf) { + } + + @Override + public void cleanup() { + } + + @Override + public void reshape(ViewPort vp, int w, int h) { + } + + /** + * Returns the shadow intensity. + * + * @see #setShadowIntensity(float shadowIntensity) + * @return shadowIntensity + */ + public float getShadowIntensity() { + return shadowIntensity; + } + + /** + * Set the shadowIntensity. The value should be between 0 and 1. A 0 value + * gives a bright and invisible shadow, a 1 value gives a pitch black + * shadow. The default is 0.7 + * + * @param shadowIntensity the darkness of the shadow + */ + final public void setShadowIntensity(float shadowIntensity) { + this.shadowIntensity = shadowIntensity; + postshadowMat.setFloat("ShadowIntensity", shadowIntensity); + } + + /** + * returns the edges thickness + * + * @see #setEdgesThickness(int edgesThickness) + * @return edgesThickness + */ + public int getEdgesThickness() { + return (int) (edgesThickness * 10); + } + + /** + * Sets the shadow edge thickness. Default is 1. Setting it to lower values + * can help to reduce the jagged effect of the shadow edges. + * @param edgesThickness the shadow edge thickness. + */ + public void setEdgesThickness(int edgesThickness) { + this.edgesThickness = Math.max(1, Math.min(edgesThickness, 10)); + this.edgesThickness *= 0.1f; + postshadowMat.setFloat("PCFEdge", edgesThickness); + } + + /** + * This method does nothing now and is kept only for backward compatibility. + * @return false + * @deprecated This method does nothing now and is kept only for backward compatibility. + */ + @Deprecated + public boolean isFlushQueues() { return false; } + + /** + * Returns the pre shadows pass render state. + * use it to adjust the RenderState parameters of the pre shadow pass. + * Note that this will be overridden if the preShadow technique in the material has a ForcedRenderState + * @return the pre shadow render state. + */ + public RenderState getPreShadowForcedRenderState() { + return forcedRenderState; + } + + /** + * Set to true if you want back faces shadows on geometries. + * Note that back faces shadows will be blended over dark lighten areas and may produce overly dark lighting. + * + * Also note that setting this parameter will override this parameter for ALL materials in the scene. + * You can alternatively change this parameter on a single material using {@link Material#setBoolean(String, boolean)} + * + * This also will automatically adjust the faceCullMode and the PolyOffset of the pre shadow pass. + * You can modify them by using {@link #getPreShadowForcedRenderState()} + * + * @param renderBackFacesShadows true or false. + */ + public void setRenderBackFacesShadows(Boolean renderBackFacesShadows) { + this.renderBackFacesShadows = renderBackFacesShadows; + if(renderBackFacesShadows) { + getPreShadowForcedRenderState().setPolyOffset(5, 3); + getPreShadowForcedRenderState().setFaceCullMode(RenderState.FaceCullMode.Back); + }else{ + getPreShadowForcedRenderState().setPolyOffset(0, 0); + getPreShadowForcedRenderState().setFaceCullMode(RenderState.FaceCullMode.Front); + } + } + + /** + * if this processor renders back faces shadows + * + * @return true if this processor renders back faces shadows + */ + public boolean isRenderBackFacesShadows() { + return renderBackFacesShadows; + } + + /** + * De-serialize this instance, for example when loading from a J3O file. + * + * @param im importer (not null) + */ + @Override + public void read(JmeImporter im) throws IOException { + InputCapsule ic = im.getCapsule(this); + assetManager = im.getAssetManager(); + nbShadowMaps = ic.readInt("nbShadowMaps", 1); + shadowMapSize = ic.readFloat("shadowMapSize", 0f); + shadowIntensity = ic.readFloat("shadowIntensity", 0.7f); + edgeFilteringMode = ic.readEnum("edgeFilteringMode", EdgeFilteringMode.class, EdgeFilteringMode.Bilinear); + shadowCompareMode = ic.readEnum("shadowCompareMode", CompareMode.class, CompareMode.Hardware); + init(assetManager, nbShadowMaps, (int) shadowMapSize); + edgesThickness = ic.readFloat("edgesThickness", 1.0f); + postshadowMat.setFloat("PCFEdge", edgesThickness); + + } + + /** + * Serialize this instance, for example when saving to a J3O file. + * + * @param ex exporter (not null) + */ + @Override + public void write(JmeExporter ex) throws IOException { + OutputCapsule oc = ex.getCapsule(this); + oc.write(nbShadowMaps, "nbShadowMaps", 1); + oc.write(shadowMapSize, "shadowMapSize", 0); + oc.write(shadowIntensity, "shadowIntensity", 0.7f); + oc.write(edgeFilteringMode, "edgeFilteringMode", EdgeFilteringMode.Bilinear); + oc.write(shadowCompareMode, "shadowCompareMode", CompareMode.Hardware); + oc.write(edgesThickness, "edgesThickness", 1.0f); + } +} diff --git a/jme3-xr/src/main/java/com/jme3/shadow/DirectionalLightShadowFilterVR.java b/jme3-xr/src/main/java/com/jme3/shadow/DirectionalLightShadowFilterVR.java new file mode 100644 index 0000000000..7d9adc02f6 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/shadow/DirectionalLightShadowFilterVR.java @@ -0,0 +1,172 @@ +package com.jme3.shadow; + +/* + * Copyright (c) 2009-2018 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import com.jme3.asset.AssetManager; +import com.jme3.export.InputCapsule; +import com.jme3.export.JmeExporter; +import com.jme3.export.JmeImporter; +import com.jme3.export.OutputCapsule; +import com.jme3.light.DirectionalLight; +import java.io.IOException; + +/** + * + * This Filter does basically the same as a DirectionalLightShadowRenderer + * except it renders the post shadow pass as a fullscreen quad pass instead of a + * geometry pass. It's mostly faster than PssmShadowRenderer as long as you have + * more than about ten shadow receiving objects. The expense is the drawback + * that the shadow Receive mode set on spatial is ignored. So basically all and + * only objects that render depth in the scene receive shadows. See this post + * for more details + * http://jmonkeyengine.org/groups/general-2/forum/topic/silly-question-about-shadow-rendering/#post-191599 + * + * API is basically the same as the PssmShadowRenderer; + * + * @author Rémy Bouquet aka Nehon + * @author reden - phr00t - https://github.com/phr00t + * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr + */ +public class DirectionalLightShadowFilterVR extends AbstractShadowFilterVR { + + /** + * Creates a DirectionalLightShadowFilter Shadow Filter More info on the + * technique at http://http.developer.nvidia.com/GPUGems3/gpugems3_ch10.html + * + * @param assetManager the application asset manager + * @param shadowMapSize the size of the rendered shadowmaps (512, 1024, 2048, + * etcetera) + * @param nbSplits the number of shadow maps rendered (More shadow maps yield + * better quality, fewer fps.) + */ + public DirectionalLightShadowFilterVR(AssetManager assetManager, int shadowMapSize, int nbSplits) { + super(assetManager, shadowMapSize, new DirectionalLightShadowRendererVR(assetManager, shadowMapSize, nbSplits)); + } + + /** + * Creates a DirectionalLight shadow filter. More info on the + * technique at http://http.developer.nvidia.com/GPUGems3/gpugems3_ch10.html. + * + * @param assetManager the application's asset manager + * @param shadowMapSize the size of the rendered shadowmaps (512, 1024, 2048, etc...) + * @param nbSplits the number of shadow maps rendered (More shadow maps yield + * better quality, fewer fps.) + * @param useMatDef the material to attach to this filter. + */ + public DirectionalLightShadowFilterVR(AssetManager assetManager, int shadowMapSize, int nbSplits, String useMatDef) { + super(assetManager, shadowMapSize, new DirectionalLightShadowRendererVR(assetManager, shadowMapSize, nbSplits), useMatDef); + } + + /** + * return the light used to cast shadows + * + * @return the DirectionalLight + */ + public DirectionalLight getLight() { + return shadowRenderer.getLight(); + } + + /** + * Sets the light to use to cast shadows + * + * @param light a DirectionalLight + */ + public void setLight(DirectionalLight light) { + shadowRenderer.setLight(light); + } + + /** + * returns the lambda parameter + * + * @see #setLambda(float lambda) + * @return lambda + */ + public float getLambda() { + return shadowRenderer.getLambda(); + } + + /** + * Adjusts the partition of the shadow extend into shadow maps. + * Lambda is usually between 0 and 1. + * A low value gives a more linear partition, + * resulting in consistent shadow quality over the extend, + * but near shadows could look very jagged. + * A high value gives a more logarithmic partition, + * resulting in high quality for near shadows, + * but quality decreases rapidly with distance. + * The default value is 0.65 (the theoretical optimum). + * + * @param lambda the lambda value. + */ + public void setLambda(float lambda) { + shadowRenderer.setLambda(lambda); + } + + /** + * Check if stabilization is enabled. + * @return true if the stabilization is enabled and false otherwise. + * @see #setEnabledStabilization(boolean) + */ + public boolean isEnabledStabilization() { + return shadowRenderer.isEnabledStabilization(); + } + + /** + * Enables the stabilization of the shadow's edges. (default is true) + * This prevents shadow edges from flickering when the camera moves. + * However, it can lead to some loss of shadow quality in particular scenes. + * + * @param stabilize true if the stabilization has to be enabled and false otherwise. + * @see #isEnabledStabilization() + */ + public void setEnabledStabilization(boolean stabilize) { + shadowRenderer.setEnabledStabilization(stabilize); + } + + @Override + public void write(JmeExporter ex) throws IOException { + super.write(ex); + OutputCapsule oc = ex.getCapsule(this); + oc.write(shadowRenderer, "shadowRenderer", null); + + } + + @Override + public void read(JmeImporter im) throws IOException { + super.read(im); + InputCapsule ic = im.getCapsule(this); + shadowRenderer = (DirectionalLightShadowRendererVR) ic.readSavable("shadowRenderer", null); + } +} diff --git a/jme3-xr/src/main/java/com/jme3/shadow/DirectionalLightShadowRendererVR.java b/jme3-xr/src/main/java/com/jme3/shadow/DirectionalLightShadowRendererVR.java new file mode 100644 index 0000000000..d0676eebb8 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/shadow/DirectionalLightShadowRendererVR.java @@ -0,0 +1,308 @@ +package com.jme3.shadow; + +/* + * Copyright (c) 2009-2021 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import com.jme3.asset.AssetManager; +import com.jme3.export.InputCapsule; +import com.jme3.export.JmeExporter; +import com.jme3.export.JmeImporter; +import com.jme3.export.OutputCapsule; +import com.jme3.light.DirectionalLight; +import com.jme3.material.Material; +import com.jme3.math.ColorRGBA; +import com.jme3.math.Vector2f; +import com.jme3.math.Vector3f; +import com.jme3.renderer.Camera; +import com.jme3.renderer.queue.GeometryList; +import com.jme3.renderer.queue.RenderQueue; +import com.jme3.scene.Node; +import com.jme3.scene.Spatial; + +import java.io.IOException; + +/** + * DirectionalLightShadowRenderer renderer use Parallel Split Shadow Mapping + * technique (pssm)
It splits the view frustum in several parts and compute + * a shadow map for each one.
splits are distributed so that the closer they + * are from the camera, the smaller they are to maximize the resolution used of + * the shadow map.
This results in a better quality shadow than standard + * shadow mapping.
for more information on this read http://http.developer.nvidia.com/GPUGems3/gpugems3_ch10.html
+ * + * @author Rémy Bouquet aka Nehon + * @author reden - phr00t - https://github.com/phr00t + * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr + */ +public class DirectionalLightShadowRendererVR extends AbstractShadowRendererVR { + + protected float lambda = 0.65f; + protected Camera shadowCam; + protected ColorRGBA splits; + protected float[] splitsArray; + protected DirectionalLight light; + protected Vector3f[] points = new Vector3f[8]; + //Holding the info for fading shadows in the far distance + private boolean stabilize = true; + + /** + * Used for serialization use + * DirectionalLightShadowRenderer#DirectionalLightShadowRenderer(AssetManager + * assetManager, int shadowMapSize, int nbSplits) + */ + public DirectionalLightShadowRendererVR() { + super(); + } + + /** + * Creates a DirectionalLight shadow renderer. More info on the technique at http://http.developer.nvidia.com/GPUGems3/gpugems3_ch10.html + * + * @param assetManager the application's asset manager + * @param shadowMapSize the size of the rendered shadowmaps (512, 1024, 2048, + * etcetera) + * @param nbSplits the number of shadow maps rendered (More shadow maps yield + * better quality, fewer fps.) + */ + public DirectionalLightShadowRendererVR(AssetManager assetManager, int shadowMapSize, int nbSplits) { + super(assetManager, shadowMapSize, nbSplits); + init(nbSplits, shadowMapSize); + } + + private void init(int nbSplits, int shadowMapSize) { + nbShadowMaps = Math.max(Math.min(nbSplits, 4), 1); + if (nbShadowMaps != nbSplits) { + throw new IllegalArgumentException("Number of splits must be between 1 and 4. Given value : " + nbSplits); + } + splits = new ColorRGBA(); + splitsArray = new float[nbSplits + 1]; + shadowCam = new Camera(shadowMapSize, shadowMapSize); + shadowCam.setParallelProjection(true); + for (int i = 0; i < points.length; i++) { + points[i] = new Vector3f(); + } + } + + @Override + protected void initFrustumCam() { + //nothing to do + } + + /** + * return the light used to cast shadows + * @return the DirectionalLight + */ + public DirectionalLight getLight() { + return light; + } + + /** + * Sets the light to use to cast shadows + * @param light a DirectionalLight + */ + public void setLight(DirectionalLight light) { + this.light = light; + } + + @Override + protected void updateShadowCams(Camera viewCam) { + + float zFar = zFarOverride; + if (zFar == 0) { + zFar = viewCam.getFrustumFar(); + } + + //We prevent computing the frustum points and splits with zeroed or negative near clip value + float frustumNear = Math.max(viewCam.getFrustumNear(), 0.001f); + ShadowUtil.updateFrustumPoints(viewCam, frustumNear, zFar, 1.0f, points); + + //shadowCam.setDirection(direction); + shadowCam.getRotation().lookAt(light.getDirection(), shadowCam.getUp()); + shadowCam.update(); + shadowCam.updateViewProjection(); + + PssmShadowUtil.updateFrustumSplits(splitsArray, frustumNear, zFar, lambda); + + // in parallel projection shadow position goe from 0 to 1 + if(viewCam.isParallelProjection()){ + for (int i = 0; i < nbShadowMaps; i++) { + splitsArray[i] = splitsArray[i]/(zFar- frustumNear); + } + } + + switch (splitsArray.length) { + case 5: + splits.a = splitsArray[4]; + case 4: + splits.b = splitsArray[3]; + case 3: + splits.g = splitsArray[2]; + case 2: + case 1: + splits.r = splitsArray[1]; + break; + } + + } + + @Override + protected GeometryList getOccludersToRender(int shadowMapIndex, GeometryList shadowMapOccluders) { + + // update frustum points based on current camera and split + ShadowUtil.updateFrustumPoints(viewPort.getCamera(), splitsArray[shadowMapIndex], splitsArray[shadowMapIndex + 1], 1.0f, points); + + //Updating shadow cam with current split frusta + if (lightReceivers.size()==0) { + for (Spatial scene : viewPort.getScenes()) { + ShadowUtil.getGeometriesInCamFrustum(scene, viewPort.getCamera(), RenderQueue.ShadowMode.Receive, lightReceivers); + } + } + ShadowUtil.updateShadowCamera(viewPort, lightReceivers, shadowCam, points, shadowMapOccluders, stabilize?shadowMapSize:0); + + return shadowMapOccluders; + } + + @Override + protected void getReceivers(GeometryList lightReceivers) { + if (lightReceivers.size()==0) { + for (Spatial scene : viewPort.getScenes()) { + ShadowUtil.getGeometriesInCamFrustum(scene, viewPort.getCamera(), RenderQueue.ShadowMode.Receive, lightReceivers); + } + } + } + + @Override + protected Camera getShadowCam(int shadowMapIndex) { + return shadowCam; + } + + @Override + protected void doDisplayFrustumDebug(int shadowMapIndex) { + ((Node) viewPort.getScenes().get(0)).attachChild(createFrustum(points, shadowMapIndex)); + ShadowUtil.updateFrustumPoints2(shadowCam, points); + ((Node) viewPort.getScenes().get(0)).attachChild(createFrustum(points, shadowMapIndex)); + } + + @Override + protected void setMaterialParameters(Material material) { + material.setColor("Splits", splits); + material.setVector3("LightDir", light.getDirection()); + if (fadeInfo != null) { + material.setVector2("FadeInfo", fadeInfo); + } + } + + @Override + protected void clearMaterialParameters(Material material) { + material.clearParam("Splits"); + material.clearParam("FadeInfo"); + material.clearParam("LightDir"); + } + + /** + * returns the lambda parameter see #setLambda(float lambda) + * + * @return lambda + */ + public float getLambda() { + return lambda; + } + + /** + * Adjusts the partition of the shadow extend into shadow maps. + * Lambda is usually between 0 and 1. + * A low value gives a more linear partition, + * resulting in consistent shadow quality over the extend, + * but near shadows could look very jagged. + * A high value gives a more logarithmic partition, + * resulting in high quality for near shadows, + * but quality decreases rapidly with distance. + * The default value is 0.65 (the theoretical optimum). + * + * @param lambda the lambda value. + */ + public void setLambda(float lambda) { + this.lambda = lambda; + } + + /** + * Check if the stabilization is enabled. + * @return true if stabilization is enabled and false otherwise. + */ + public boolean isEnabledStabilization() { + return stabilize; + } + + /** + * Enables the stabilization of the shadow's edges. (default is true) + * This prevents shadow edges from flickering when the camera moves. + * However, it can lead to some loss of shadow quality in particular scenes. + * + * @param stabilize true if stabilization has to be enabled and false otherwise. + */ + public void setEnabledStabilization(boolean stabilize) { + this.stabilize = stabilize; + } + + @Override + public void read(JmeImporter im) throws IOException { + super.read(im); + InputCapsule ic = im.getCapsule(this); + lambda = ic.readFloat("lambda", 0.65f); + zFarOverride = ic.readInt("zFarOverride", 0); + light = (DirectionalLight) ic.readSavable("light", null); + fadeInfo = (Vector2f) ic.readSavable("fadeInfo", null); + fadeLength = ic.readFloat("fadeLength", 0f); + init(nbShadowMaps, (int) shadowMapSize); + } + + @Override + public void write(JmeExporter ex) throws IOException { + super.write(ex); + OutputCapsule oc = ex.getCapsule(this); + oc.write(lambda, "lambda", 0.65f); + oc.write(zFarOverride, "zFarOverride", 0); + oc.write(light, "light", null); + oc.write(fadeInfo, "fadeInfo", null); + oc.write(fadeLength, "fadeLength", 0f); + } + + /** + * Directional light is always in the view frustum + * @param viewCam + * @return true + */ + @Override + protected boolean checkCulling(Camera viewCam) { + return true; + } +} diff --git a/jme3-xr/src/main/java/com/jme3/shadow/InstancedDirectionalShadowFilter.java b/jme3-xr/src/main/java/com/jme3/shadow/InstancedDirectionalShadowFilter.java new file mode 100644 index 0000000000..a848409f70 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/shadow/InstancedDirectionalShadowFilter.java @@ -0,0 +1,66 @@ +package com.jme3.shadow; + +import com.jme3.app.Application; +import com.jme3.math.Matrix4f; +import com.jme3.math.Vector4f; +import com.jme3.renderer.Camera; + +/** + * An instanced version of the {@link DirectionalLightShadowFilterVR directional light shadow filter}. + * @author reden - phr00t - https://github.com/phr00t + * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr + */ +public class InstancedDirectionalShadowFilter extends DirectionalLightShadowFilterVR { + private final Vector4f temp4f = new Vector4f(), temp4f2 = new Vector4f(); + + private boolean instanceRendering = false; + + private Camera rightCamera = null; + + /** + * Create a new instanced version of the {@link DirectionalLightShadowFilterVR directional light shadow filter}. + * @param application the application that this filter is attached to. + * @param camera + * @param shadowMapSize the size of the rendered shadowmaps (512, 1024, 2048, etcetera) + * @param nbSplits the number of shadow maps rendered (More shadow maps yield + * better quality, fewer frames per second.) + * @param instancedRendering true if this filter has to use instance rendering and false otherwise. + * @param rightCamera the camera used as right eye in stereo rendering mode. + */ + public InstancedDirectionalShadowFilter(Application application, Camera camera, int shadowMapSize, int nbSplits, boolean instancedRendering, Camera rightCamera) { + super(application.getAssetManager(), shadowMapSize, nbSplits, "Common/MatDefs/VR/PostShadowFilter.j3md"); + this.instanceRendering = instancedRendering; + this.rightCamera = rightCamera; + } + + @Override + protected void preFrame(float tpf) { + shadowRenderer.preFrame(tpf); + if( instanceRendering ) { + material.setMatrix4("ViewProjectionMatrixInverseRight", rightCamera.getViewProjectionMatrix().invert()); + Matrix4f m = rightCamera.getViewProjectionMatrix(); + material.setVector4("ViewProjectionMatrixRow2Right", temp4f2.set(m.m20, m.m21, m.m22, m.m23)); + } + material.setMatrix4("ViewProjectionMatrixInverse", viewPort.getCamera().getViewProjectionMatrix().invert()); + Matrix4f m = viewPort.getCamera().getViewProjectionMatrix(); + material.setVector4("ViewProjectionMatrixRow2", temp4f.set(m.m20, m.m21, m.m22, m.m23)); + } + + /** + * Get if this filter is using instance rendering. + * @return true if this filter is using instance rendering and false otherwise. + * @see #setInstanceRendering(boolean) + */ + public boolean isInstanceRendering() { + return instanceRendering; + } + + /** + * Set if this filter has to use instance rendering. + * @param instanceRendering true if this filter has to use instance rendering and false otherwise. + * @see #isInstanceRendering() + */ + public void setInstanceRendering(boolean instanceRendering) { + this.instanceRendering = instanceRendering; + } +} diff --git a/jme3-xr/src/main/java/com/jme3/shadow/VRDirectionalLightShadowRenderer.java b/jme3-xr/src/main/java/com/jme3/shadow/VRDirectionalLightShadowRenderer.java new file mode 100644 index 0000000000..39ecdaed96 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/shadow/VRDirectionalLightShadowRenderer.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2009-2021 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.shadow; + +import com.jme3.asset.AssetManager; +import com.jme3.shadow.DirectionalLightShadowRenderer; + +/** + * DirectionalLightShadowRenderer renderer use Parallel Split Shadow Mapping + * technique (pssm)
It splits the view frustum in several parts and compute + * a shadow map for each one.
splits are distributed so that the closer they + * are from the camera, the smaller they are to maximize the resolution used of + * the shadow map.
This results in a better quality shadow than standard + * shadow mapping.
for more information on this read http://http.developer.nvidia.com/GPUGems3/gpugems3_ch10.html
+ * + * @author Rémy Bouquet aka Nehon + */ +public class VRDirectionalLightShadowRenderer extends DirectionalLightShadowRenderer { + + /** + * Create an OculusDirectionalLightShadowRenderer More info on the technique at http://http.developer.nvidia.com/GPUGems3/gpugems3_ch10.html + * + * @param assetManager the application asset manager + * @param shadowMapSize the size of the rendered shadowmaps (512,1024,2048, + * etc...) + * @param nbSplits the number of shadow maps rendered (More shadow maps + * result in higher quality, fewer fps.) + */ + public VRDirectionalLightShadowRenderer(AssetManager assetManager, int shadowMapSize, int nbSplits) { + super(assetManager, shadowMapSize, nbSplits); + } + + @Override + public VRDirectionalLightShadowRenderer clone() { + VRDirectionalLightShadowRenderer clone = new VRDirectionalLightShadowRenderer(assetManager, (int)shadowMapSize, nbShadowMaps); + clone.setEdgeFilteringMode(getEdgeFilteringMode()); + clone.setEdgesThickness(getEdgesThickness()); + clone.setEnabledStabilization(isEnabledStabilization()); + clone.setLambda(getLambda()); + clone.setLight(getLight()); + clone.setShadowCompareMode(getShadowCompareMode()); + clone.setShadowIntensity(getShadowIntensity()); + clone.setShadowZExtend(getShadowZExtend()); + clone.setShadowZFadeLength(getShadowZFadeLength()); + return clone; + } +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/AppOverrideKeys_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/AppOverrideKeys_t.java new file mode 100644 index 0000000000..f88400e2bd --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/AppOverrideKeys_t.java @@ -0,0 +1,50 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1485
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class AppOverrideKeys_t extends Structure { + /** + * const char *
+ * C type : char* + */ + public Pointer pchKey; + /** + * const char *
+ * C type : char* + */ + public Pointer pchValue; + public AppOverrideKeys_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("pchKey", "pchValue"); + } + /** + * @param pchKey const char *
+ * C type : char*
+ * @param pchValue const char *
+ * C type : char* + */ + public AppOverrideKeys_t(Pointer pchKey, Pointer pchValue) { + super(); + this.pchKey = pchKey; + this.pchValue = pchValue; + } + public AppOverrideKeys_t(Pointer peer) { + super(peer); + } + public static class ByReference extends AppOverrideKeys_t implements Structure.ByReference { + + }; + public static class ByValue extends AppOverrideKeys_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/COpenVRContext.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/COpenVRContext.java new file mode 100644 index 0000000000..5c3d4fc08e --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/COpenVRContext.java @@ -0,0 +1,110 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import com.sun.jna.ptr.IntByReference; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1670
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class COpenVRContext extends Structure { + /** + * class vr::IVRSystem *
+ * C type : intptr_t + */ + public IntByReference m_pVRSystem; + /** + * class vr::IVRChaperone *
+ * C type : intptr_t + */ + public IntByReference m_pVRChaperone; + /** + * class vr::IVRChaperoneSetup *
+ * C type : intptr_t + */ + public IntByReference m_pVRChaperoneSetup; + /** + * class vr::IVRCompositor *
+ * C type : intptr_t + */ + public IntByReference m_pVRCompositor; + /** + * class vr::IVROverlay *
+ * C type : intptr_t + */ + public IntByReference m_pVROverlay; + /** + * class vr::IVRResources *
+ * C type : intptr_t + */ + public IntByReference m_pVRResources; + /** + * class vr::IVRRenderModels *
+ * C type : intptr_t + */ + public IntByReference m_pVRRenderModels; + /** + * class vr::IVRExtendedDisplay *
+ * C type : intptr_t + */ + public IntByReference m_pVRExtendedDisplay; + /** + * class vr::IVRSettings *
+ * C type : intptr_t + */ + public IntByReference m_pVRSettings; + /** + * class vr::IVRApplications *
+ * C type : intptr_t + */ + public IntByReference m_pVRApplications; + /** + * class vr::IVRTrackedCamera *
+ * C type : intptr_t + */ + public IntByReference m_pVRTrackedCamera; + /** + * class vr::IVRScreenshots *
+ * C type : intptr_t + */ + public IntByReference m_pVRScreenshots; + /** + * class vr::IVRDriverManager *
+ * C type : intptr_t + */ + public IntByReference m_pVRDriverManager; + /** + * class vr::IVRInput *
+ * C type : intptr_t + */ + public IntByReference m_pVRInput; + /** + * class vr::IVRIOBuffer *
+ * C type : intptr_t + */ + public IntByReference m_pVRIOBuffer; + /** + * class vr::IVRSpatialAnchors *
+ * C type : intptr_t + */ + public IntByReference m_pVRSpatialAnchors; + public COpenVRContext() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("m_pVRSystem", "m_pVRChaperone", "m_pVRChaperoneSetup", "m_pVRCompositor", "m_pVROverlay", "m_pVRResources", "m_pVRRenderModels", "m_pVRExtendedDisplay", "m_pVRSettings", "m_pVRApplications", "m_pVRTrackedCamera", "m_pVRScreenshots", "m_pVRDriverManager", "m_pVRInput", "m_pVRIOBuffer", "m_pVRSpatialAnchors"); + } + public COpenVRContext(Pointer peer) { + super(peer); + } + public static class ByReference extends COpenVRContext implements Structure.ByReference { + + }; + public static class ByValue extends COpenVRContext implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/CVRSettingHelper.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/CVRSettingHelper.java new file mode 100644 index 0000000000..5be90516cb --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/CVRSettingHelper.java @@ -0,0 +1,43 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import com.sun.jna.ptr.IntByReference; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1592
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class CVRSettingHelper extends Structure { + /** + * class vr::IVRSettings *
+ * C type : intptr_t + */ + public IntByReference m_pSettings; + public CVRSettingHelper() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("m_pSettings"); + } + /** + * @param m_pSettings class vr::IVRSettings *
+ * C type : intptr_t + */ + public CVRSettingHelper(IntByReference m_pSettings) { + super(); + this.m_pSettings = m_pSettings; + } + public CVRSettingHelper(Pointer peer) { + super(peer); + } + public static class ByReference extends CVRSettingHelper implements Structure.ByReference { + + }; + public static class ByValue extends CVRSettingHelper implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/CameraVideoStreamFrameHeader_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/CameraVideoStreamFrameHeader_t.java new file mode 100644 index 0000000000..ebbc398bd6 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/CameraVideoStreamFrameHeader_t.java @@ -0,0 +1,53 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1466
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class CameraVideoStreamFrameHeader_t extends Structure { + /** + * C type : EVRTrackedCameraFrameType + */ + public int eFrameType; + public int nWidth; + public int nHeight; + public int nBytesPerPixel; + public int nFrameSequence; + /** C type : TrackedDevicePose_t */ + public TrackedDevicePose_t standingTrackedDevicePose; + public CameraVideoStreamFrameHeader_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("eFrameType", "nWidth", "nHeight", "nBytesPerPixel", "nFrameSequence", "standingTrackedDevicePose"); + } + /** + * @param eFrameType @see JOpenVRLibrary.EVRTrackedCameraFrameType
+ * C type : EVRTrackedCameraFrameType
+ * @param standingTrackedDevicePose C type : TrackedDevicePose_t + */ + public CameraVideoStreamFrameHeader_t(int eFrameType, int nWidth, int nHeight, int nBytesPerPixel, int nFrameSequence, TrackedDevicePose_t standingTrackedDevicePose) { + super(); + this.eFrameType = eFrameType; + this.nWidth = nWidth; + this.nHeight = nHeight; + this.nBytesPerPixel = nBytesPerPixel; + this.nFrameSequence = nFrameSequence; + this.standingTrackedDevicePose = standingTrackedDevicePose; + } + public CameraVideoStreamFrameHeader_t(Pointer peer) { + super(peer); + } + public static class ByReference extends CameraVideoStreamFrameHeader_t implements Structure.ByReference { + + }; + public static class ByValue extends CameraVideoStreamFrameHeader_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/Compositor_CumulativeStats.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/Compositor_CumulativeStats.java new file mode 100644 index 0000000000..3b426b7b8f --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/Compositor_CumulativeStats.java @@ -0,0 +1,44 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1528
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class Compositor_CumulativeStats extends Structure { + public int m_nPid; + public int m_nNumFramePresents; + public int m_nNumDroppedFrames; + public int m_nNumReprojectedFrames; + public int m_nNumFramePresentsOnStartup; + public int m_nNumDroppedFramesOnStartup; + public int m_nNumReprojectedFramesOnStartup; + public int m_nNumLoading; + public int m_nNumFramePresentsLoading; + public int m_nNumDroppedFramesLoading; + public int m_nNumReprojectedFramesLoading; + public int m_nNumTimedOut; + public int m_nNumFramePresentsTimedOut; + public int m_nNumDroppedFramesTimedOut; + public int m_nNumReprojectedFramesTimedOut; + public Compositor_CumulativeStats() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("m_nPid", "m_nNumFramePresents", "m_nNumDroppedFrames", "m_nNumReprojectedFrames", "m_nNumFramePresentsOnStartup", "m_nNumDroppedFramesOnStartup", "m_nNumReprojectedFramesOnStartup", "m_nNumLoading", "m_nNumFramePresentsLoading", "m_nNumDroppedFramesLoading", "m_nNumReprojectedFramesLoading", "m_nNumTimedOut", "m_nNumFramePresentsTimedOut", "m_nNumDroppedFramesTimedOut", "m_nNumReprojectedFramesTimedOut"); + } + public Compositor_CumulativeStats(Pointer peer) { + super(peer); + } + public static class ByReference extends Compositor_CumulativeStats implements Structure.ByReference { + + }; + public static class ByValue extends Compositor_CumulativeStats implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/Compositor_FrameTiming.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/Compositor_FrameTiming.java new file mode 100644 index 0000000000..ede38a055b --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/Compositor_FrameTiming.java @@ -0,0 +1,54 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1511
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class Compositor_FrameTiming extends Structure { + public int m_nSize; + public int m_nFrameIndex; + public int m_nNumFramePresents; + public int m_nNumMisPresented; + public int m_nNumDroppedFrames; + public int m_nReprojectionFlags; + public double m_flSystemTimeInSeconds; + public float m_flPreSubmitGpuMs; + public float m_flPostSubmitGpuMs; + public float m_flTotalRenderGpuMs; + public float m_flCompositorRenderGpuMs; + public float m_flCompositorRenderCpuMs; + public float m_flCompositorIdleCpuMs; + public float m_flClientFrameIntervalMs; + public float m_flPresentCallCpuMs; + public float m_flWaitForPresentCpuMs; + public float m_flSubmitFrameMs; + public float m_flWaitGetPosesCalledMs; + public float m_flNewPosesReadyMs; + public float m_flNewFrameReadyMs; + public float m_flCompositorUpdateStartMs; + public float m_flCompositorUpdateEndMs; + public float m_flCompositorRenderStartMs; + /** C type : TrackedDevicePose_t */ + public TrackedDevicePose_t m_HmdPose; + public Compositor_FrameTiming() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("m_nSize", "m_nFrameIndex", "m_nNumFramePresents", "m_nNumMisPresented", "m_nNumDroppedFrames", "m_nReprojectionFlags", "m_flSystemTimeInSeconds", "m_flPreSubmitGpuMs", "m_flPostSubmitGpuMs", "m_flTotalRenderGpuMs", "m_flCompositorRenderGpuMs", "m_flCompositorRenderCpuMs", "m_flCompositorIdleCpuMs", "m_flClientFrameIntervalMs", "m_flPresentCallCpuMs", "m_flWaitForPresentCpuMs", "m_flSubmitFrameMs", "m_flWaitGetPosesCalledMs", "m_flNewPosesReadyMs", "m_flNewFrameReadyMs", "m_flCompositorUpdateStartMs", "m_flCompositorUpdateEndMs", "m_flCompositorRenderStartMs", "m_HmdPose"); + } + public Compositor_FrameTiming(Pointer peer) { + super(peer); + } + public static class ByReference extends Compositor_FrameTiming implements Structure.ByReference { + + }; + public static class ByValue extends Compositor_FrameTiming implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/Compositor_OverlaySettings.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/Compositor_OverlaySettings.java new file mode 100644 index 0000000000..3afba14f1d --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/Compositor_OverlaySettings.java @@ -0,0 +1,44 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1452
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class Compositor_OverlaySettings extends Structure { + public int size; + public byte curved; + public byte antialias; + public float scale; + public float distance; + public float alpha; + public float uOffset; + public float vOffset; + public float uScale; + public float vScale; + public float gridDivs; + public float gridWidth; + public float gridScale; + /** C type : HmdMatrix44_t */ + public HmdMatrix44_t transform; + public Compositor_OverlaySettings() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("size", "curved", "antialias", "scale", "distance", "alpha", "uOffset", "vOffset", "uScale", "vScale", "gridDivs", "gridWidth", "gridScale", "transform"); + } + public Compositor_OverlaySettings(Pointer peer) { + super(peer); + } + public static class ByReference extends Compositor_OverlaySettings implements Structure.ByReference { + + }; + public static class ByValue extends Compositor_OverlaySettings implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/D3D12TextureData_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/D3D12TextureData_t.java new file mode 100644 index 0000000000..c902ad237a --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/D3D12TextureData_t.java @@ -0,0 +1,54 @@ +package com.jme3.system.jopenvr; +import com.jme3.system.jopenvr.JOpenVRLibrary.ID3D12CommandQueue; +import com.jme3.system.jopenvr.JOpenVRLibrary.ID3D12Resource; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1301
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class D3D12TextureData_t extends Structure { + /** + * struct ID3D12Resource *
+ * C type : ID3D12Resource* + */ + public ID3D12Resource m_pResource; + /** + * struct ID3D12CommandQueue *
+ * C type : ID3D12CommandQueue* + */ + public ID3D12CommandQueue m_pCommandQueue; + public int m_nNodeMask; + public D3D12TextureData_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("m_pResource", "m_pCommandQueue", "m_nNodeMask"); + } + /** + * @param m_pResource struct ID3D12Resource *
+ * C type : ID3D12Resource*
+ * @param m_pCommandQueue struct ID3D12CommandQueue *
+ * C type : ID3D12CommandQueue* + */ + public D3D12TextureData_t(ID3D12Resource m_pResource, ID3D12CommandQueue m_pCommandQueue, int m_nNodeMask) { + super(); + this.m_pResource = m_pResource; + this.m_pCommandQueue = m_pCommandQueue; + this.m_nNodeMask = m_nNodeMask; + } + public D3D12TextureData_t(Pointer peer) { + super(peer); + } + public static class ByReference extends D3D12TextureData_t implements Structure.ByReference { + + }; + public static class ByValue extends D3D12TextureData_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/DistortionCoordinates_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/DistortionCoordinates_t.java new file mode 100644 index 0000000000..59e0ab3dd1 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/DistortionCoordinates_t.java @@ -0,0 +1,64 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1237
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class DistortionCoordinates_t extends Structure { + /** + * float[2]
+ * C type : float[2] + */ + public float[] rfRed = new float[2]; + /** + * float[2]
+ * C type : float[2] + */ + public float[] rfGreen = new float[2]; + /** + * float[2]
+ * C type : float[2] + */ + public float[] rfBlue = new float[2]; + public DistortionCoordinates_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("rfRed", "rfGreen", "rfBlue"); + } + /** + * @param rfRed float[2]
+ * C type : float[2]
+ * @param rfGreen float[2]
+ * C type : float[2]
+ * @param rfBlue float[2]
+ * C type : float[2] + */ + public DistortionCoordinates_t(float rfRed[], float rfGreen[], float rfBlue[]) { + super(); + if ((rfRed.length != this.rfRed.length)) + throw new IllegalArgumentException("Wrong array size !"); + this.rfRed = rfRed; + if ((rfGreen.length != this.rfGreen.length)) + throw new IllegalArgumentException("Wrong array size !"); + this.rfGreen = rfGreen; + if ((rfBlue.length != this.rfBlue.length)) + throw new IllegalArgumentException("Wrong array size !"); + this.rfBlue = rfBlue; + } + public DistortionCoordinates_t(Pointer peer) { + super(peer); + } + public static class ByReference extends DistortionCoordinates_t implements Structure.ByReference { + + }; + public static class ByValue extends DistortionCoordinates_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/DriverDirectMode_FrameTiming.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/DriverDirectMode_FrameTiming.java new file mode 100644 index 0000000000..4b89bc4746 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/DriverDirectMode_FrameTiming.java @@ -0,0 +1,42 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1473
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class DriverDirectMode_FrameTiming extends Structure { + public int m_nSize; + public int m_nNumFramePresents; + public int m_nNumMisPresented; + public int m_nNumDroppedFrames; + public int m_nReprojectionFlags; + public DriverDirectMode_FrameTiming() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("m_nSize", "m_nNumFramePresents", "m_nNumMisPresented", "m_nNumDroppedFrames", "m_nReprojectionFlags"); + } + public DriverDirectMode_FrameTiming(int m_nSize, int m_nNumFramePresents, int m_nNumMisPresented, int m_nNumDroppedFrames, int m_nReprojectionFlags) { + super(); + this.m_nSize = m_nSize; + this.m_nNumFramePresents = m_nNumFramePresents; + this.m_nNumMisPresented = m_nNumMisPresented; + this.m_nNumDroppedFrames = m_nNumDroppedFrames; + this.m_nReprojectionFlags = m_nReprojectionFlags; + } + public DriverDirectMode_FrameTiming(Pointer peer) { + super(peer); + } + public static class ByReference extends DriverDirectMode_FrameTiming implements Structure.ByReference { + + }; + public static class ByValue extends DriverDirectMode_FrameTiming implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/HiddenAreaMesh_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/HiddenAreaMesh_t.java new file mode 100644 index 0000000000..2844685d11 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/HiddenAreaMesh_t.java @@ -0,0 +1,44 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1425
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class HiddenAreaMesh_t extends Structure { + /** + * const struct vr::HmdVector2_t *
+ * C type : HmdVector2_t* + */ + public com.jme3.system.jopenvr.HmdVector2_t.ByReference pVertexData; + public int unTriangleCount; + public HiddenAreaMesh_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("pVertexData", "unTriangleCount"); + } + /** + * @param pVertexData const struct vr::HmdVector2_t *
+ * C type : HmdVector2_t* + */ + public HiddenAreaMesh_t(com.jme3.system.jopenvr.HmdVector2_t.ByReference pVertexData, int unTriangleCount) { + super(); + this.pVertexData = pVertexData; + this.unTriangleCount = unTriangleCount; + } + public HiddenAreaMesh_t(Pointer peer) { + super(peer); + } + public static class ByReference extends HiddenAreaMesh_t implements Structure.ByReference { + + }; + public static class ByValue extends HiddenAreaMesh_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdColor_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdColor_t.java new file mode 100644 index 0000000000..6387f1f0f7 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdColor_t.java @@ -0,0 +1,40 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1221
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class HmdColor_t extends Structure { + public float r; + public float g; + public float b; + public float a; + public HmdColor_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("r", "g", "b", "a"); + } + public HmdColor_t(float r, float g, float b, float a) { + super(); + this.r = r; + this.g = g; + this.b = b; + this.a = a; + } + public HmdColor_t(Pointer peer) { + super(peer); + } + public static class ByReference extends HmdColor_t implements Structure.ByReference { + + }; + public static class ByValue extends HmdColor_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdMatrix33_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdMatrix33_t.java new file mode 100644 index 0000000000..25e7f8d670 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdMatrix33_t.java @@ -0,0 +1,44 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1183
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class HmdMatrix33_t extends Structure { + /** + * float[3][3]
+ * C type : float[3][3] + */ + public float[] m = new float[((3) * (3))]; + public HmdMatrix33_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("m"); + } + /** + * @param m float[3][3]
+ * C type : float[3][3] + */ + public HmdMatrix33_t(float m[]) { + super(); + if ((m.length != this.m.length)) + throw new IllegalArgumentException("Wrong array size !"); + this.m = m; + } + public HmdMatrix33_t(Pointer peer) { + super(peer); + } + public static class ByReference extends HmdMatrix33_t implements Structure.ByReference { + + }; + public static class ByValue extends HmdMatrix33_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdMatrix34_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdMatrix34_t.java new file mode 100644 index 0000000000..175bc07f75 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdMatrix34_t.java @@ -0,0 +1,44 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1179
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class HmdMatrix34_t extends Structure { + /** + * float[3][4]
+ * C type : float[3][4] + */ + public float[] m = new float[((3) * (4))]; + public HmdMatrix34_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("m"); + } + /** + * @param m float[3][4]
+ * C type : float[3][4] + */ + public HmdMatrix34_t(float m[]) { + super(); + if ((m.length != this.m.length)) + throw new IllegalArgumentException("Wrong array size !"); + this.m = m; + } + public HmdMatrix34_t(Pointer peer) { + super(peer); + } + public static class ByReference extends HmdMatrix34_t implements Structure.ByReference { + + }; + public static class ByValue extends HmdMatrix34_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdMatrix44_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdMatrix44_t.java new file mode 100644 index 0000000000..2243e8f5fa --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdMatrix44_t.java @@ -0,0 +1,44 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1187
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class HmdMatrix44_t extends Structure { + /** + * float[4][4]
+ * C type : float[4][4] + */ + public float[] m = new float[((4) * (4))]; + public HmdMatrix44_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("m"); + } + /** + * @param m float[4][4]
+ * C type : float[4][4] + */ + public HmdMatrix44_t(float m[]) { + super(); + if ((m.length != this.m.length)) + throw new IllegalArgumentException("Wrong array size !"); + this.m = m; + } + public HmdMatrix44_t(Pointer peer) { + super(peer); + } + public static class ByReference extends HmdMatrix44_t implements Structure.ByReference { + + }; + public static class ByValue extends HmdMatrix44_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdQuad_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdQuad_t.java new file mode 100644 index 0000000000..28abf8f754 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdQuad_t.java @@ -0,0 +1,44 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1225
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class HmdQuad_t extends Structure { + /** + * struct vr::HmdVector3_t[4]
+ * C type : HmdVector3_t[4] + */ + public HmdVector3_t[] vCorners = new HmdVector3_t[4]; + public HmdQuad_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("vCorners"); + } + /** + * @param vCorners struct vr::HmdVector3_t[4]
+ * C type : HmdVector3_t[4] + */ + public HmdQuad_t(HmdVector3_t vCorners[]) { + super(); + if ((vCorners.length != this.vCorners.length)) + throw new IllegalArgumentException("Wrong array size !"); + this.vCorners = vCorners; + } + public HmdQuad_t(Pointer peer) { + super(peer); + } + public static class ByReference extends HmdQuad_t implements Structure.ByReference { + + }; + public static class ByValue extends HmdQuad_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdQuaternion_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdQuaternion_t.java new file mode 100644 index 0000000000..d26c2acfef --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdQuaternion_t.java @@ -0,0 +1,40 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1209
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class HmdQuaternion_t extends Structure { + public double w; + public double x; + public double y; + public double z; + public HmdQuaternion_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("w", "x", "y", "z"); + } + public HmdQuaternion_t(double w, double x, double y, double z) { + super(); + this.w = w; + this.x = x; + this.y = y; + this.z = z; + } + public HmdQuaternion_t(Pointer peer) { + super(peer); + } + public static class ByReference extends HmdQuaternion_t implements Structure.ByReference { + + }; + public static class ByValue extends HmdQuaternion_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdQuaternionf_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdQuaternionf_t.java new file mode 100644 index 0000000000..b24d5c071d --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdQuaternionf_t.java @@ -0,0 +1,40 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1215
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class HmdQuaternionf_t extends Structure { + public float w; + public float x; + public float y; + public float z; + public HmdQuaternionf_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("w", "x", "y", "z"); + } + public HmdQuaternionf_t(float w, float x, float y, float z) { + super(); + this.w = w; + this.x = x; + this.y = y; + this.z = z; + } + public HmdQuaternionf_t(Pointer peer) { + super(peer); + } + public static class ByReference extends HmdQuaternionf_t implements Structure.ByReference { + + }; + public static class ByValue extends HmdQuaternionf_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdRect2_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdRect2_t.java new file mode 100644 index 0000000000..a8c25431db --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdRect2_t.java @@ -0,0 +1,42 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1229
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class HmdRect2_t extends Structure { + /** C type : HmdVector2_t */ + public HmdVector2_t vTopLeft; + /** C type : HmdVector2_t */ + public HmdVector2_t vBottomRight; + public HmdRect2_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("vTopLeft", "vBottomRight"); + } + /** + * @param vTopLeft C type : HmdVector2_t
+ * @param vBottomRight C type : HmdVector2_t + */ + public HmdRect2_t(HmdVector2_t vTopLeft, HmdVector2_t vBottomRight) { + super(); + this.vTopLeft = vTopLeft; + this.vBottomRight = vBottomRight; + } + public HmdRect2_t(Pointer peer) { + super(peer); + } + public static class ByReference extends HmdRect2_t implements Structure.ByReference { + + }; + public static class ByValue extends HmdRect2_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdVector2_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdVector2_t.java new file mode 100644 index 0000000000..f66240574d --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdVector2_t.java @@ -0,0 +1,44 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1203
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class HmdVector2_t extends Structure { + /** + * float[2]
+ * C type : float[2] + */ + public float[] v = new float[2]; + public HmdVector2_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("v"); + } + /** + * @param v float[2]
+ * C type : float[2] + */ + public HmdVector2_t(float v[]) { + super(); + if ((v.length != this.v.length)) + throw new IllegalArgumentException("Wrong array size !"); + this.v = v; + } + public HmdVector2_t(Pointer peer) { + super(peer); + } + public static class ByReference extends HmdVector2_t implements Structure.ByReference { + + }; + public static class ByValue extends HmdVector2_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdVector3_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdVector3_t.java new file mode 100644 index 0000000000..92ad299605 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdVector3_t.java @@ -0,0 +1,44 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1191
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class HmdVector3_t extends Structure { + /** + * float[3]
+ * C type : float[3] + */ + public float[] v = new float[3]; + public HmdVector3_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("v"); + } + /** + * @param v float[3]
+ * C type : float[3] + */ + public HmdVector3_t(float v[]) { + super(); + if ((v.length != this.v.length)) + throw new IllegalArgumentException("Wrong array size !"); + this.v = v; + } + public HmdVector3_t(Pointer peer) { + super(peer); + } + public static class ByReference extends HmdVector3_t implements Structure.ByReference { + + }; + public static class ByValue extends HmdVector3_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdVector3d_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdVector3d_t.java new file mode 100644 index 0000000000..7bde50647c --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdVector3d_t.java @@ -0,0 +1,44 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1199
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class HmdVector3d_t extends Structure { + /** + * double[3]
+ * C type : double[3] + */ + public double[] v = new double[3]; + public HmdVector3d_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("v"); + } + /** + * @param v double[3]
+ * C type : double[3] + */ + public HmdVector3d_t(double v[]) { + super(); + if ((v.length != this.v.length)) + throw new IllegalArgumentException("Wrong array size !"); + this.v = v; + } + public HmdVector3d_t(Pointer peer) { + super(peer); + } + public static class ByReference extends HmdVector3d_t implements Structure.ByReference { + + }; + public static class ByValue extends HmdVector3d_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdVector4_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdVector4_t.java new file mode 100644 index 0000000000..1db01177cf --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdVector4_t.java @@ -0,0 +1,44 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1195
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class HmdVector4_t extends Structure { + /** + * float[4]
+ * C type : float[4] + */ + public float[] v = new float[4]; + public HmdVector4_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("v"); + } + /** + * @param v float[4]
+ * C type : float[4] + */ + public HmdVector4_t(float v[]) { + super(); + if ((v.length != this.v.length)) + throw new IllegalArgumentException("Wrong array size !"); + this.v = v; + } + public HmdVector4_t(Pointer peer) { + super(peer); + } + public static class ByReference extends HmdVector4_t implements Structure.ByReference { + + }; + public static class ByValue extends HmdVector4_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/ImuSample_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/ImuSample_t.java new file mode 100644 index 0000000000..1cadc4b7f2 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/ImuSample_t.java @@ -0,0 +1,46 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1479
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class ImuSample_t extends Structure { + public double fSampleTime; + /** C type : HmdVector3d_t */ + public HmdVector3d_t vAccel; + /** C type : HmdVector3d_t */ + public HmdVector3d_t vGyro; + public int unOffScaleFlags; + public ImuSample_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("fSampleTime", "vAccel", "vGyro", "unOffScaleFlags"); + } + /** + * @param vAccel C type : HmdVector3d_t
+ * @param vGyro C type : HmdVector3d_t + */ + public ImuSample_t(double fSampleTime, HmdVector3d_t vAccel, HmdVector3d_t vGyro, int unOffScaleFlags) { + super(); + this.fSampleTime = fSampleTime; + this.vAccel = vAccel; + this.vGyro = vGyro; + this.unOffScaleFlags = unOffScaleFlags; + } + public ImuSample_t(Pointer peer) { + super(peer); + } + public static class ByReference extends ImuSample_t implements Structure.ByReference { + + }; + public static class ByValue extends ImuSample_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/InputAnalogActionData_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/InputAnalogActionData_t.java new file mode 100644 index 0000000000..7f7a2a6922 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/InputAnalogActionData_t.java @@ -0,0 +1,52 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1603
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class InputAnalogActionData_t extends Structure { + public byte bActive; + /** C type : VRInputValueHandle_t */ + public long activeOrigin; + public float x; + public float y; + public float z; + public float deltaX; + public float deltaY; + public float deltaZ; + public float fUpdateTime; + public InputAnalogActionData_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("bActive", "activeOrigin", "x", "y", "z", "deltaX", "deltaY", "deltaZ", "fUpdateTime"); + } + /** @param activeOrigin C type : VRInputValueHandle_t */ + public InputAnalogActionData_t(byte bActive, long activeOrigin, float x, float y, float z, float deltaX, float deltaY, float deltaZ, float fUpdateTime) { + super(); + this.bActive = bActive; + this.activeOrigin = activeOrigin; + this.x = x; + this.y = y; + this.z = z; + this.deltaX = deltaX; + this.deltaY = deltaY; + this.deltaZ = deltaZ; + this.fUpdateTime = fUpdateTime; + } + public InputAnalogActionData_t(Pointer peer) { + super(peer); + } + public static class ByReference extends InputAnalogActionData_t implements Structure.ByReference { + + }; + public static class ByValue extends InputAnalogActionData_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/InputDigitalActionData_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/InputDigitalActionData_t.java new file mode 100644 index 0000000000..3b212e44af --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/InputDigitalActionData_t.java @@ -0,0 +1,44 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1610
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class InputDigitalActionData_t extends Structure { + public byte bActive; + /** C type : VRInputValueHandle_t */ + public long activeOrigin; + public byte bState; + public byte bChanged; + public float fUpdateTime; + public InputDigitalActionData_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("bActive", "activeOrigin", "bState", "bChanged", "fUpdateTime"); + } + /** @param activeOrigin C type : VRInputValueHandle_t */ + public InputDigitalActionData_t(byte bActive, long activeOrigin, byte bState, byte bChanged, float fUpdateTime) { + super(); + this.bActive = bActive; + this.activeOrigin = activeOrigin; + this.bState = bState; + this.bChanged = bChanged; + this.fUpdateTime = fUpdateTime; + } + public InputDigitalActionData_t(Pointer peer) { + super(peer); + } + public static class ByReference extends InputDigitalActionData_t implements Structure.ByReference { + + }; + public static class ByValue extends InputDigitalActionData_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/InputOriginInfo_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/InputOriginInfo_t.java new file mode 100644 index 0000000000..eff72867ae --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/InputOriginInfo_t.java @@ -0,0 +1,52 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1626
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class InputOriginInfo_t extends Structure { + /** C type : VRInputValueHandle_t */ + public long devicePath; + /** C type : TrackedDeviceIndex_t */ + public int trackedDeviceIndex; + /** + * char[128]
+ * C type : char*[128] + */ + public Pointer[] rchRenderModelComponentName = new Pointer[128]; + public InputOriginInfo_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("devicePath", "trackedDeviceIndex", "rchRenderModelComponentName"); + } + /** + * @param devicePath C type : VRInputValueHandle_t
+ * @param trackedDeviceIndex C type : TrackedDeviceIndex_t
+ * @param rchRenderModelComponentName char[128]
+ * C type : char*[128] + */ + public InputOriginInfo_t(long devicePath, int trackedDeviceIndex, Pointer rchRenderModelComponentName[]) { + super(); + this.devicePath = devicePath; + this.trackedDeviceIndex = trackedDeviceIndex; + if ((rchRenderModelComponentName.length != this.rchRenderModelComponentName.length)) + throw new IllegalArgumentException("Wrong array size !"); + this.rchRenderModelComponentName = rchRenderModelComponentName; + } + public InputOriginInfo_t(Pointer peer) { + super(peer); + } + public static class ByReference extends InputOriginInfo_t implements Structure.ByReference { + + }; + public static class ByValue extends InputOriginInfo_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/InputPoseActionData_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/InputPoseActionData_t.java new file mode 100644 index 0000000000..bc375f1a57 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/InputPoseActionData_t.java @@ -0,0 +1,44 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1615
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class InputPoseActionData_t extends Structure { + public byte bActive; + /** C type : VRInputValueHandle_t */ + public long activeOrigin; + /** C type : TrackedDevicePose_t */ + public TrackedDevicePose_t pose; + public InputPoseActionData_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("bActive", "activeOrigin", "pose"); + } + /** + * @param activeOrigin C type : VRInputValueHandle_t
+ * @param pose C type : TrackedDevicePose_t + */ + public InputPoseActionData_t(byte bActive, long activeOrigin, TrackedDevicePose_t pose) { + super(); + this.bActive = bActive; + this.activeOrigin = activeOrigin; + this.pose = pose; + } + public InputPoseActionData_t(Pointer peer) { + super(peer); + } + public static class ByReference extends InputPoseActionData_t implements Structure.ByReference { + + }; + public static class ByValue extends InputPoseActionData_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/InputSkeletalActionData_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/InputSkeletalActionData_t.java new file mode 100644 index 0000000000..8d1f26514b --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/InputSkeletalActionData_t.java @@ -0,0 +1,40 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1620
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class InputSkeletalActionData_t extends Structure { + public byte bActive; + /** C type : VRInputValueHandle_t */ + public long activeOrigin; + public int boneCount; + public InputSkeletalActionData_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("bActive", "activeOrigin", "boneCount"); + } + /** @param activeOrigin C type : VRInputValueHandle_t */ + public InputSkeletalActionData_t(byte bActive, long activeOrigin, int boneCount) { + super(); + this.bActive = bActive; + this.activeOrigin = activeOrigin; + this.boneCount = boneCount; + } + public InputSkeletalActionData_t(Pointer peer) { + super(peer); + } + public static class ByReference extends InputSkeletalActionData_t implements Structure.ByReference { + + }; + public static class ByValue extends InputSkeletalActionData_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/IntersectionMaskCircle_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/IntersectionMaskCircle_t.java new file mode 100644 index 0000000000..8c994f84ba --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/IntersectionMaskCircle_t.java @@ -0,0 +1,38 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1552
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class IntersectionMaskCircle_t extends Structure { + public float m_flCenterX; + public float m_flCenterY; + public float m_flRadius; + public IntersectionMaskCircle_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("m_flCenterX", "m_flCenterY", "m_flRadius"); + } + public IntersectionMaskCircle_t(float m_flCenterX, float m_flCenterY, float m_flRadius) { + super(); + this.m_flCenterX = m_flCenterX; + this.m_flCenterY = m_flCenterY; + this.m_flRadius = m_flRadius; + } + public IntersectionMaskCircle_t(Pointer peer) { + super(peer); + } + public static class ByReference extends IntersectionMaskCircle_t implements Structure.ByReference { + + }; + public static class ByValue extends IntersectionMaskCircle_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/IntersectionMaskRectangle_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/IntersectionMaskRectangle_t.java new file mode 100644 index 0000000000..e33a836db9 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/IntersectionMaskRectangle_t.java @@ -0,0 +1,40 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1547
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class IntersectionMaskRectangle_t extends Structure { + public float m_flTopLeftX; + public float m_flTopLeftY; + public float m_flWidth; + public float m_flHeight; + public IntersectionMaskRectangle_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("m_flTopLeftX", "m_flTopLeftY", "m_flWidth", "m_flHeight"); + } + public IntersectionMaskRectangle_t(float m_flTopLeftX, float m_flTopLeftY, float m_flWidth, float m_flHeight) { + super(); + this.m_flTopLeftX = m_flTopLeftX; + this.m_flTopLeftY = m_flTopLeftY; + this.m_flWidth = m_flWidth; + this.m_flHeight = m_flHeight; + } + public IntersectionMaskRectangle_t(Pointer peer) { + super(peer); + } + public static class ByReference extends IntersectionMaskRectangle_t implements Structure.ByReference { + + }; + public static class ByValue extends IntersectionMaskRectangle_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/JOpenVRLibrary.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/JOpenVRLibrary.java new file mode 100644 index 0000000000..4a00707fed --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/JOpenVRLibrary.java @@ -0,0 +1,2332 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Library; +import com.sun.jna.Native; +import com.sun.jna.NativeLibrary; +import com.sun.jna.Pointer; +import com.sun.jna.PointerType; +import com.sun.jna.ptr.IntByReference; + +import java.nio.IntBuffer; +import java.util.logging.Logger; +/** + * JNA Wrapper for library JOpenVR
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class JOpenVRLibrary implements Library { + private static final Logger logger = Logger.getLogger(JOpenVRLibrary.class.getName()); + + private static String JNA_LIBRARY_NAME; + private static NativeLibrary JNA_NATIVE_LIB; + + /** + * The system property that specifies an implementation of OpenVR (openvr_api file) to use. + * This property has to be set at the program launch using -D connector. + * If this property is not set, the embedded library is loaded. + */ + public static final String JNA_OPENVR_LIBRARY_PATH = "openvr.library.path"; + + /** + * Init the native binding to the underlying system library. + */ + public static void init() throws UnsatisfiedLinkError { + Native.unregister(JOpenVRLibrary.class); + + String path = System.getProperty(JNA_OPENVR_LIBRARY_PATH); + if (path != null){ + + JNA_LIBRARY_NAME = path; + + logger.config("Using OpenVR implementation located at "+JNA_LIBRARY_NAME); + + JNA_NATIVE_LIB = NativeLibrary.getInstance(JOpenVRLibrary.JNA_LIBRARY_NAME); + Native.register(JOpenVRLibrary.class, JOpenVRLibrary.JNA_NATIVE_LIB); + } else { + + JNA_LIBRARY_NAME = "openvr_api"; + + logger.config("Using embedded OpenVR implementation "+JOpenVRLibrary.JNA_LIBRARY_NAME); + + JNA_NATIVE_LIB = NativeLibrary.getInstance(JOpenVRLibrary.JNA_LIBRARY_NAME); + Native.register(JOpenVRLibrary.class, JOpenVRLibrary.JNA_NATIVE_LIB); + } + } + + /** + * Get the name of the underlying system library. + * @return the name of the underlying system library. + */ + public static String getSystemLibraryName(){ + return ""+JNA_LIBRARY_NAME; + } + + + /** + * native declaration : headers\openvr_capi.h:229
+ * enum values + */ + public static interface EVREye { + /** native declaration : headers\openvr_capi.h:227 */ + public static final int EVREye_Eye_Left = 0; + /** native declaration : headers\openvr_capi.h:228 */ + public static final int EVREye_Eye_Right = 1; + }; + /** + * native declaration : headers\openvr_capi.h:239
+ * enum values + */ + public static interface ETextureType { + /** native declaration : headers\openvr_capi.h:231 */ + public static final int ETextureType_TextureType_Invalid = -1; + /** native declaration : headers\openvr_capi.h:232 */ + public static final int ETextureType_TextureType_DirectX = 0; + /** native declaration : headers\openvr_capi.h:233 */ + public static final int ETextureType_TextureType_OpenGL = 1; + /** native declaration : headers\openvr_capi.h:234 */ + public static final int ETextureType_TextureType_Vulkan = 2; + /** native declaration : headers\openvr_capi.h:235 */ + public static final int ETextureType_TextureType_IOSurface = 3; + /** native declaration : headers\openvr_capi.h:236 */ + public static final int ETextureType_TextureType_DirectX12 = 4; + /** native declaration : headers\openvr_capi.h:237 */ + public static final int ETextureType_TextureType_DXGISharedHandle = 5; + /** native declaration : headers\openvr_capi.h:238 */ + public static final int ETextureType_TextureType_Metal = 6; + }; + /** + * native declaration : headers\openvr_capi.h:244
+ * enum values + */ + public static interface EColorSpace { + /** native declaration : headers\openvr_capi.h:241 */ + public static final int EColorSpace_ColorSpace_Auto = 0; + /** native declaration : headers\openvr_capi.h:242 */ + public static final int EColorSpace_ColorSpace_Gamma = 1; + /** native declaration : headers\openvr_capi.h:243 */ + public static final int EColorSpace_ColorSpace_Linear = 2; + }; + /** + * native declaration : headers\openvr_capi.h:251
+ * enum values + */ + public static interface ETrackingResult { + /** native declaration : headers\openvr_capi.h:246 */ + public static final int ETrackingResult_TrackingResult_Uninitialized = 1; + /** native declaration : headers\openvr_capi.h:247 */ + public static final int ETrackingResult_TrackingResult_Calibrating_InProgress = 100; + /** native declaration : headers\openvr_capi.h:248 */ + public static final int ETrackingResult_TrackingResult_Calibrating_OutOfRange = 101; + /** native declaration : headers\openvr_capi.h:249 */ + public static final int ETrackingResult_TrackingResult_Running_OK = 200; + /** native declaration : headers\openvr_capi.h:250 */ + public static final int ETrackingResult_TrackingResult_Running_OutOfRange = 201; + }; + /** + * native declaration : headers\openvr_capi.h:260
+ * enum values + */ + public static interface ETrackedDeviceClass { + /** native declaration : headers\openvr_capi.h:253 */ + public static final int ETrackedDeviceClass_TrackedDeviceClass_Invalid = 0; + /** native declaration : headers\openvr_capi.h:254 */ + public static final int ETrackedDeviceClass_TrackedDeviceClass_HMD = 1; + /** native declaration : headers\openvr_capi.h:255 */ + public static final int ETrackedDeviceClass_TrackedDeviceClass_Controller = 2; + /** native declaration : headers\openvr_capi.h:256 */ + public static final int ETrackedDeviceClass_TrackedDeviceClass_GenericTracker = 3; + /** native declaration : headers\openvr_capi.h:257 */ + public static final int ETrackedDeviceClass_TrackedDeviceClass_TrackingReference = 4; + /** native declaration : headers\openvr_capi.h:258 */ + public static final int ETrackedDeviceClass_TrackedDeviceClass_DisplayRedirect = 5; + /** native declaration : headers\openvr_capi.h:259 */ + public static final int ETrackedDeviceClass_TrackedDeviceClass_Max = 6; + }; + /** + * native declaration : headers\openvr_capi.h:267
+ * enum values + */ + public static interface ETrackedControllerRole { + /** native declaration : headers\openvr_capi.h:262 */ + public static final int ETrackedControllerRole_TrackedControllerRole_Invalid = 0; + /** native declaration : headers\openvr_capi.h:263 */ + public static final int ETrackedControllerRole_TrackedControllerRole_LeftHand = 1; + /** native declaration : headers\openvr_capi.h:264 */ + public static final int ETrackedControllerRole_TrackedControllerRole_RightHand = 2; + /** native declaration : headers\openvr_capi.h:265 */ + public static final int ETrackedControllerRole_TrackedControllerRole_OptOut = 3; + /** native declaration : headers\openvr_capi.h:266 */ + public static final int ETrackedControllerRole_TrackedControllerRole_Max = 4; + }; + /** + * native declaration : headers\openvr_capi.h:272
+ * enum values + */ + public static interface ETrackingUniverseOrigin { + /** native declaration : headers\openvr_capi.h:269 */ + public static final int ETrackingUniverseOrigin_TrackingUniverseSeated = 0; + /** native declaration : headers\openvr_capi.h:270 */ + public static final int ETrackingUniverseOrigin_TrackingUniverseStanding = 1; + /** native declaration : headers\openvr_capi.h:271 */ + public static final int ETrackingUniverseOrigin_TrackingUniverseRawAndUncalibrated = 2; + }; + /** + * native declaration : headers\openvr_capi.h:432
+ * enum values + */ + public static interface ETrackedDeviceProperty { + /** native declaration : headers\openvr_capi.h:274 */ + public static final int ETrackedDeviceProperty_Prop_Invalid = 0; + /** native declaration : headers\openvr_capi.h:275 */ + public static final int ETrackedDeviceProperty_Prop_TrackingSystemName_String = 1000; + /** native declaration : headers\openvr_capi.h:276 */ + public static final int ETrackedDeviceProperty_Prop_ModelNumber_String = 1001; + /** native declaration : headers\openvr_capi.h:277 */ + public static final int ETrackedDeviceProperty_Prop_SerialNumber_String = 1002; + /** native declaration : headers\openvr_capi.h:278 */ + public static final int ETrackedDeviceProperty_Prop_RenderModelName_String = 1003; + /** native declaration : headers\openvr_capi.h:279 */ + public static final int ETrackedDeviceProperty_Prop_WillDriftInYaw_Bool = 1004; + /** native declaration : headers\openvr_capi.h:280 */ + public static final int ETrackedDeviceProperty_Prop_ManufacturerName_String = 1005; + /** native declaration : headers\openvr_capi.h:281 */ + public static final int ETrackedDeviceProperty_Prop_TrackingFirmwareVersion_String = 1006; + /** native declaration : headers\openvr_capi.h:282 */ + public static final int ETrackedDeviceProperty_Prop_HardwareRevision_String = 1007; + /** native declaration : headers\openvr_capi.h:283 */ + public static final int ETrackedDeviceProperty_Prop_AllWirelessDongleDescriptions_String = 1008; + /** native declaration : headers\openvr_capi.h:284 */ + public static final int ETrackedDeviceProperty_Prop_ConnectedWirelessDongle_String = 1009; + /** native declaration : headers\openvr_capi.h:285 */ + public static final int ETrackedDeviceProperty_Prop_DeviceIsWireless_Bool = 1010; + /** native declaration : headers\openvr_capi.h:286 */ + public static final int ETrackedDeviceProperty_Prop_DeviceIsCharging_Bool = 1011; + /** native declaration : headers\openvr_capi.h:287 */ + public static final int ETrackedDeviceProperty_Prop_DeviceBatteryPercentage_Float = 1012; + /** native declaration : headers\openvr_capi.h:288 */ + public static final int ETrackedDeviceProperty_Prop_StatusDisplayTransform_Matrix34 = 1013; + /** native declaration : headers\openvr_capi.h:289 */ + public static final int ETrackedDeviceProperty_Prop_Firmware_UpdateAvailable_Bool = 1014; + /** native declaration : headers\openvr_capi.h:290 */ + public static final int ETrackedDeviceProperty_Prop_Firmware_ManualUpdate_Bool = 1015; + /** native declaration : headers\openvr_capi.h:291 */ + public static final int ETrackedDeviceProperty_Prop_Firmware_ManualUpdateURL_String = 1016; + /** native declaration : headers\openvr_capi.h:292 */ + public static final int ETrackedDeviceProperty_Prop_HardwareRevision_Uint64 = 1017; + /** native declaration : headers\openvr_capi.h:293 */ + public static final int ETrackedDeviceProperty_Prop_FirmwareVersion_Uint64 = 1018; + /** native declaration : headers\openvr_capi.h:294 */ + public static final int ETrackedDeviceProperty_Prop_FPGAVersion_Uint64 = 1019; + /** native declaration : headers\openvr_capi.h:295 */ + public static final int ETrackedDeviceProperty_Prop_VRCVersion_Uint64 = 1020; + /** native declaration : headers\openvr_capi.h:296 */ + public static final int ETrackedDeviceProperty_Prop_RadioVersion_Uint64 = 1021; + /** native declaration : headers\openvr_capi.h:297 */ + public static final int ETrackedDeviceProperty_Prop_DongleVersion_Uint64 = 1022; + /** native declaration : headers\openvr_capi.h:298 */ + public static final int ETrackedDeviceProperty_Prop_BlockServerShutdown_Bool = 1023; + /** native declaration : headers\openvr_capi.h:299 */ + public static final int ETrackedDeviceProperty_Prop_CanUnifyCoordinateSystemWithHmd_Bool = 1024; + /** native declaration : headers\openvr_capi.h:300 */ + public static final int ETrackedDeviceProperty_Prop_ContainsProximitySensor_Bool = 1025; + /** native declaration : headers\openvr_capi.h:301 */ + public static final int ETrackedDeviceProperty_Prop_DeviceProvidesBatteryStatus_Bool = 1026; + /** native declaration : headers\openvr_capi.h:302 */ + public static final int ETrackedDeviceProperty_Prop_DeviceCanPowerOff_Bool = 1027; + /** native declaration : headers\openvr_capi.h:303 */ + public static final int ETrackedDeviceProperty_Prop_Firmware_ProgrammingTarget_String = 1028; + /** native declaration : headers\openvr_capi.h:304 */ + public static final int ETrackedDeviceProperty_Prop_DeviceClass_Int32 = 1029; + /** native declaration : headers\openvr_capi.h:305 */ + public static final int ETrackedDeviceProperty_Prop_HasCamera_Bool = 1030; + /** native declaration : headers\openvr_capi.h:306 */ + public static final int ETrackedDeviceProperty_Prop_DriverVersion_String = 1031; + /** native declaration : headers\openvr_capi.h:307 */ + public static final int ETrackedDeviceProperty_Prop_Firmware_ForceUpdateRequired_Bool = 1032; + /** native declaration : headers\openvr_capi.h:308 */ + public static final int ETrackedDeviceProperty_Prop_ViveSystemButtonFixRequired_Bool = 1033; + /** native declaration : headers\openvr_capi.h:309 */ + public static final int ETrackedDeviceProperty_Prop_ParentDriver_Uint64 = 1034; + /** native declaration : headers\openvr_capi.h:310 */ + public static final int ETrackedDeviceProperty_Prop_ResourceRoot_String = 1035; + /** native declaration : headers\openvr_capi.h:311 */ + public static final int ETrackedDeviceProperty_Prop_RegisteredDeviceType_String = 1036; + /** native declaration : headers\openvr_capi.h:312 */ + public static final int ETrackedDeviceProperty_Prop_InputProfilePath_String = 1037; + /** native declaration : headers\openvr_capi.h:313 */ + public static final int ETrackedDeviceProperty_Prop_NeverTracked_Bool = 1038; + /** native declaration : headers\openvr_capi.h:314 */ + public static final int ETrackedDeviceProperty_Prop_NumCameras_Int32 = 1039; + /** native declaration : headers\openvr_capi.h:315 */ + public static final int ETrackedDeviceProperty_Prop_CameraFrameLayout_Int32 = 1040; + /** native declaration : headers\openvr_capi.h:316 */ + public static final int ETrackedDeviceProperty_Prop_ReportsTimeSinceVSync_Bool = 2000; + /** native declaration : headers\openvr_capi.h:317 */ + public static final int ETrackedDeviceProperty_Prop_SecondsFromVsyncToPhotons_Float = 2001; + /** native declaration : headers\openvr_capi.h:318 */ + public static final int ETrackedDeviceProperty_Prop_DisplayFrequency_Float = 2002; + /** native declaration : headers\openvr_capi.h:319 */ + public static final int ETrackedDeviceProperty_Prop_UserIpdMeters_Float = 2003; + /** native declaration : headers\openvr_capi.h:320 */ + public static final int ETrackedDeviceProperty_Prop_CurrentUniverseId_Uint64 = 2004; + /** native declaration : headers\openvr_capi.h:321 */ + public static final int ETrackedDeviceProperty_Prop_PreviousUniverseId_Uint64 = 2005; + /** native declaration : headers\openvr_capi.h:322 */ + public static final int ETrackedDeviceProperty_Prop_DisplayFirmwareVersion_Uint64 = 2006; + /** native declaration : headers\openvr_capi.h:323 */ + public static final int ETrackedDeviceProperty_Prop_IsOnDesktop_Bool = 2007; + /** native declaration : headers\openvr_capi.h:324 */ + public static final int ETrackedDeviceProperty_Prop_DisplayMCType_Int32 = 2008; + /** native declaration : headers\openvr_capi.h:325 */ + public static final int ETrackedDeviceProperty_Prop_DisplayMCOffset_Float = 2009; + /** native declaration : headers\openvr_capi.h:326 */ + public static final int ETrackedDeviceProperty_Prop_DisplayMCScale_Float = 2010; + /** native declaration : headers\openvr_capi.h:327 */ + public static final int ETrackedDeviceProperty_Prop_EdidVendorID_Int32 = 2011; + /** native declaration : headers\openvr_capi.h:328 */ + public static final int ETrackedDeviceProperty_Prop_DisplayMCImageLeft_String = 2012; + /** native declaration : headers\openvr_capi.h:329 */ + public static final int ETrackedDeviceProperty_Prop_DisplayMCImageRight_String = 2013; + /** native declaration : headers\openvr_capi.h:330 */ + public static final int ETrackedDeviceProperty_Prop_DisplayGCBlackClamp_Float = 2014; + /** native declaration : headers\openvr_capi.h:331 */ + public static final int ETrackedDeviceProperty_Prop_EdidProductID_Int32 = 2015; + /** native declaration : headers\openvr_capi.h:332 */ + public static final int ETrackedDeviceProperty_Prop_CameraToHeadTransform_Matrix34 = 2016; + /** native declaration : headers\openvr_capi.h:333 */ + public static final int ETrackedDeviceProperty_Prop_DisplayGCType_Int32 = 2017; + /** native declaration : headers\openvr_capi.h:334 */ + public static final int ETrackedDeviceProperty_Prop_DisplayGCOffset_Float = 2018; + /** native declaration : headers\openvr_capi.h:335 */ + public static final int ETrackedDeviceProperty_Prop_DisplayGCScale_Float = 2019; + /** native declaration : headers\openvr_capi.h:336 */ + public static final int ETrackedDeviceProperty_Prop_DisplayGCPrescale_Float = 2020; + /** native declaration : headers\openvr_capi.h:337 */ + public static final int ETrackedDeviceProperty_Prop_DisplayGCImage_String = 2021; + /** native declaration : headers\openvr_capi.h:338 */ + public static final int ETrackedDeviceProperty_Prop_LensCenterLeftU_Float = 2022; + /** native declaration : headers\openvr_capi.h:339 */ + public static final int ETrackedDeviceProperty_Prop_LensCenterLeftV_Float = 2023; + /** native declaration : headers\openvr_capi.h:340 */ + public static final int ETrackedDeviceProperty_Prop_LensCenterRightU_Float = 2024; + /** native declaration : headers\openvr_capi.h:341 */ + public static final int ETrackedDeviceProperty_Prop_LensCenterRightV_Float = 2025; + /** native declaration : headers\openvr_capi.h:342 */ + public static final int ETrackedDeviceProperty_Prop_UserHeadToEyeDepthMeters_Float = 2026; + /** native declaration : headers\openvr_capi.h:343 */ + public static final int ETrackedDeviceProperty_Prop_CameraFirmwareVersion_Uint64 = 2027; + /** native declaration : headers\openvr_capi.h:344 */ + public static final int ETrackedDeviceProperty_Prop_CameraFirmwareDescription_String = 2028; + /** native declaration : headers\openvr_capi.h:345 */ + public static final int ETrackedDeviceProperty_Prop_DisplayFPGAVersion_Uint64 = 2029; + /** native declaration : headers\openvr_capi.h:346 */ + public static final int ETrackedDeviceProperty_Prop_DisplayBootloaderVersion_Uint64 = 2030; + /** native declaration : headers\openvr_capi.h:347 */ + public static final int ETrackedDeviceProperty_Prop_DisplayHardwareVersion_Uint64 = 2031; + /** native declaration : headers\openvr_capi.h:348 */ + public static final int ETrackedDeviceProperty_Prop_AudioFirmwareVersion_Uint64 = 2032; + /** native declaration : headers\openvr_capi.h:349 */ + public static final int ETrackedDeviceProperty_Prop_CameraCompatibilityMode_Int32 = 2033; + /** native declaration : headers\openvr_capi.h:350 */ + public static final int ETrackedDeviceProperty_Prop_ScreenshotHorizontalFieldOfViewDegrees_Float = 2034; + /** native declaration : headers\openvr_capi.h:351 */ + public static final int ETrackedDeviceProperty_Prop_ScreenshotVerticalFieldOfViewDegrees_Float = 2035; + /** native declaration : headers\openvr_capi.h:352 */ + public static final int ETrackedDeviceProperty_Prop_DisplaySuppressed_Bool = 2036; + /** native declaration : headers\openvr_capi.h:353 */ + public static final int ETrackedDeviceProperty_Prop_DisplayAllowNightMode_Bool = 2037; + /** native declaration : headers\openvr_capi.h:354 */ + public static final int ETrackedDeviceProperty_Prop_DisplayMCImageWidth_Int32 = 2038; + /** native declaration : headers\openvr_capi.h:355 */ + public static final int ETrackedDeviceProperty_Prop_DisplayMCImageHeight_Int32 = 2039; + /** native declaration : headers\openvr_capi.h:356 */ + public static final int ETrackedDeviceProperty_Prop_DisplayMCImageNumChannels_Int32 = 2040; + /** native declaration : headers\openvr_capi.h:357 */ + public static final int ETrackedDeviceProperty_Prop_DisplayMCImageData_Binary = 2041; + /** native declaration : headers\openvr_capi.h:358 */ + public static final int ETrackedDeviceProperty_Prop_SecondsFromPhotonsToVblank_Float = 2042; + /** native declaration : headers\openvr_capi.h:359 */ + public static final int ETrackedDeviceProperty_Prop_DriverDirectModeSendsVsyncEvents_Bool = 2043; + /** native declaration : headers\openvr_capi.h:360 */ + public static final int ETrackedDeviceProperty_Prop_DisplayDebugMode_Bool = 2044; + /** native declaration : headers\openvr_capi.h:361 */ + public static final int ETrackedDeviceProperty_Prop_GraphicsAdapterLuid_Uint64 = 2045; + /** native declaration : headers\openvr_capi.h:362 */ + public static final int ETrackedDeviceProperty_Prop_DriverProvidedChaperonePath_String = 2048; + /** native declaration : headers\openvr_capi.h:363 */ + public static final int ETrackedDeviceProperty_Prop_ExpectedTrackingReferenceCount_Int32 = 2049; + /** native declaration : headers\openvr_capi.h:364 */ + public static final int ETrackedDeviceProperty_Prop_ExpectedControllerCount_Int32 = 2050; + /** native declaration : headers\openvr_capi.h:365 */ + public static final int ETrackedDeviceProperty_Prop_NamedIconPathControllerLeftDeviceOff_String = 2051; + /** native declaration : headers\openvr_capi.h:366 */ + public static final int ETrackedDeviceProperty_Prop_NamedIconPathControllerRightDeviceOff_String = 2052; + /** native declaration : headers\openvr_capi.h:367 */ + public static final int ETrackedDeviceProperty_Prop_NamedIconPathTrackingReferenceDeviceOff_String = 2053; + /** native declaration : headers\openvr_capi.h:368 */ + public static final int ETrackedDeviceProperty_Prop_DoNotApplyPrediction_Bool = 2054; + /** native declaration : headers\openvr_capi.h:369 */ + public static final int ETrackedDeviceProperty_Prop_CameraToHeadTransforms_Matrix34_Array = 2055; + /** native declaration : headers\openvr_capi.h:370 */ + public static final int ETrackedDeviceProperty_Prop_DistortionMeshResolution_Int32 = 2056; + /** native declaration : headers\openvr_capi.h:371 */ + public static final int ETrackedDeviceProperty_Prop_DriverIsDrawingControllers_Bool = 2057; + /** native declaration : headers\openvr_capi.h:372 */ + public static final int ETrackedDeviceProperty_Prop_DriverRequestsApplicationPause_Bool = 2058; + /** native declaration : headers\openvr_capi.h:373 */ + public static final int ETrackedDeviceProperty_Prop_DriverRequestsReducedRendering_Bool = 2059; + /** native declaration : headers\openvr_capi.h:374 */ + public static final int ETrackedDeviceProperty_Prop_MinimumIpdStepMeters_Float = 2060; + /** native declaration : headers\openvr_capi.h:375 */ + public static final int ETrackedDeviceProperty_Prop_AudioBridgeFirmwareVersion_Uint64 = 2061; + /** native declaration : headers\openvr_capi.h:376 */ + public static final int ETrackedDeviceProperty_Prop_ImageBridgeFirmwareVersion_Uint64 = 2062; + /** native declaration : headers\openvr_capi.h:377 */ + public static final int ETrackedDeviceProperty_Prop_ImuToHeadTransform_Matrix34 = 2063; + /** native declaration : headers\openvr_capi.h:378 */ + public static final int ETrackedDeviceProperty_Prop_ImuFactoryGyroBias_Vector3 = 2064; + /** native declaration : headers\openvr_capi.h:379 */ + public static final int ETrackedDeviceProperty_Prop_ImuFactoryGyroScale_Vector3 = 2065; + /** native declaration : headers\openvr_capi.h:380 */ + public static final int ETrackedDeviceProperty_Prop_ImuFactoryAccelerometerBias_Vector3 = 2066; + /** native declaration : headers\openvr_capi.h:381 */ + public static final int ETrackedDeviceProperty_Prop_ImuFactoryAccelerometerScale_Vector3 = 2067; + /** native declaration : headers\openvr_capi.h:382 */ + public static final int ETrackedDeviceProperty_Prop_ConfigurationIncludesLighthouse20Features_Bool = 2069; + /** native declaration : headers\openvr_capi.h:383 */ + public static final int ETrackedDeviceProperty_Prop_DriverRequestedMuraCorrectionMode_Int32 = 2200; + /** native declaration : headers\openvr_capi.h:384 */ + public static final int ETrackedDeviceProperty_Prop_DriverRequestedMuraFeather_InnerLeft_Int32 = 2201; + /** native declaration : headers\openvr_capi.h:385 */ + public static final int ETrackedDeviceProperty_Prop_DriverRequestedMuraFeather_InnerRight_Int32 = 2202; + /** native declaration : headers\openvr_capi.h:386 */ + public static final int ETrackedDeviceProperty_Prop_DriverRequestedMuraFeather_InnerTop_Int32 = 2203; + /** native declaration : headers\openvr_capi.h:387 */ + public static final int ETrackedDeviceProperty_Prop_DriverRequestedMuraFeather_InnerBottom_Int32 = 2204; + /** native declaration : headers\openvr_capi.h:388 */ + public static final int ETrackedDeviceProperty_Prop_DriverRequestedMuraFeather_OuterLeft_Int32 = 2205; + /** native declaration : headers\openvr_capi.h:389 */ + public static final int ETrackedDeviceProperty_Prop_DriverRequestedMuraFeather_OuterRight_Int32 = 2206; + /** native declaration : headers\openvr_capi.h:390 */ + public static final int ETrackedDeviceProperty_Prop_DriverRequestedMuraFeather_OuterTop_Int32 = 2207; + /** native declaration : headers\openvr_capi.h:391 */ + public static final int ETrackedDeviceProperty_Prop_DriverRequestedMuraFeather_OuterBottom_Int32 = 2208; + /** native declaration : headers\openvr_capi.h:392 */ + public static final int ETrackedDeviceProperty_Prop_AttachedDeviceId_String = 3000; + /** native declaration : headers\openvr_capi.h:393 */ + public static final int ETrackedDeviceProperty_Prop_SupportedButtons_Uint64 = 3001; + /** native declaration : headers\openvr_capi.h:394 */ + public static final int ETrackedDeviceProperty_Prop_Axis0Type_Int32 = 3002; + /** native declaration : headers\openvr_capi.h:395 */ + public static final int ETrackedDeviceProperty_Prop_Axis1Type_Int32 = 3003; + /** native declaration : headers\openvr_capi.h:396 */ + public static final int ETrackedDeviceProperty_Prop_Axis2Type_Int32 = 3004; + /** native declaration : headers\openvr_capi.h:397 */ + public static final int ETrackedDeviceProperty_Prop_Axis3Type_Int32 = 3005; + /** native declaration : headers\openvr_capi.h:398 */ + public static final int ETrackedDeviceProperty_Prop_Axis4Type_Int32 = 3006; + /** native declaration : headers\openvr_capi.h:399 */ + public static final int ETrackedDeviceProperty_Prop_ControllerRoleHint_Int32 = 3007; + /** native declaration : headers\openvr_capi.h:400 */ + public static final int ETrackedDeviceProperty_Prop_FieldOfViewLeftDegrees_Float = 4000; + /** native declaration : headers\openvr_capi.h:401 */ + public static final int ETrackedDeviceProperty_Prop_FieldOfViewRightDegrees_Float = 4001; + /** native declaration : headers\openvr_capi.h:402 */ + public static final int ETrackedDeviceProperty_Prop_FieldOfViewTopDegrees_Float = 4002; + /** native declaration : headers\openvr_capi.h:403 */ + public static final int ETrackedDeviceProperty_Prop_FieldOfViewBottomDegrees_Float = 4003; + /** native declaration : headers\openvr_capi.h:404 */ + public static final int ETrackedDeviceProperty_Prop_TrackingRangeMinimumMeters_Float = 4004; + /** native declaration : headers\openvr_capi.h:405 */ + public static final int ETrackedDeviceProperty_Prop_TrackingRangeMaximumMeters_Float = 4005; + /** native declaration : headers\openvr_capi.h:406 */ + public static final int ETrackedDeviceProperty_Prop_ModeLabel_String = 4006; + /** native declaration : headers\openvr_capi.h:407 */ + public static final int ETrackedDeviceProperty_Prop_IconPathName_String = 5000; + /** native declaration : headers\openvr_capi.h:408 */ + public static final int ETrackedDeviceProperty_Prop_NamedIconPathDeviceOff_String = 5001; + /** native declaration : headers\openvr_capi.h:409 */ + public static final int ETrackedDeviceProperty_Prop_NamedIconPathDeviceSearching_String = 5002; + /** native declaration : headers\openvr_capi.h:410 */ + public static final int ETrackedDeviceProperty_Prop_NamedIconPathDeviceSearchingAlert_String = 5003; + /** native declaration : headers\openvr_capi.h:411 */ + public static final int ETrackedDeviceProperty_Prop_NamedIconPathDeviceReady_String = 5004; + /** native declaration : headers\openvr_capi.h:412 */ + public static final int ETrackedDeviceProperty_Prop_NamedIconPathDeviceReadyAlert_String = 5005; + /** native declaration : headers\openvr_capi.h:413 */ + public static final int ETrackedDeviceProperty_Prop_NamedIconPathDeviceNotReady_String = 5006; + /** native declaration : headers\openvr_capi.h:414 */ + public static final int ETrackedDeviceProperty_Prop_NamedIconPathDeviceStandby_String = 5007; + /** native declaration : headers\openvr_capi.h:415 */ + public static final int ETrackedDeviceProperty_Prop_NamedIconPathDeviceAlertLow_String = 5008; + /** native declaration : headers\openvr_capi.h:416 */ + public static final int ETrackedDeviceProperty_Prop_DisplayHiddenArea_Binary_Start = 5100; + /** native declaration : headers\openvr_capi.h:417 */ + public static final int ETrackedDeviceProperty_Prop_DisplayHiddenArea_Binary_End = 5150; + /** native declaration : headers\openvr_capi.h:418 */ + public static final int ETrackedDeviceProperty_Prop_ParentContainer = 5151; + /** native declaration : headers\openvr_capi.h:419 */ + public static final int ETrackedDeviceProperty_Prop_UserConfigPath_String = 6000; + /** native declaration : headers\openvr_capi.h:420 */ + public static final int ETrackedDeviceProperty_Prop_InstallPath_String = 6001; + /** native declaration : headers\openvr_capi.h:421 */ + public static final int ETrackedDeviceProperty_Prop_HasDisplayComponent_Bool = 6002; + /** native declaration : headers\openvr_capi.h:422 */ + public static final int ETrackedDeviceProperty_Prop_HasControllerComponent_Bool = 6003; + /** native declaration : headers\openvr_capi.h:423 */ + public static final int ETrackedDeviceProperty_Prop_HasCameraComponent_Bool = 6004; + /** native declaration : headers\openvr_capi.h:424 */ + public static final int ETrackedDeviceProperty_Prop_HasDriverDirectModeComponent_Bool = 6005; + /** native declaration : headers\openvr_capi.h:425 */ + public static final int ETrackedDeviceProperty_Prop_HasVirtualDisplayComponent_Bool = 6006; + /** native declaration : headers\openvr_capi.h:426 */ + public static final int ETrackedDeviceProperty_Prop_HasSpatialAnchorsSupport_Bool = 6007; + /** native declaration : headers\openvr_capi.h:427 */ + public static final int ETrackedDeviceProperty_Prop_ControllerType_String = 7000; + /** native declaration : headers\openvr_capi.h:428 */ + public static final int ETrackedDeviceProperty_Prop_LegacyInputProfile_String = 7001; + /** native declaration : headers\openvr_capi.h:429 */ + public static final int ETrackedDeviceProperty_Prop_VendorSpecific_Reserved_Start = 10000; + /** native declaration : headers\openvr_capi.h:430 */ + public static final int ETrackedDeviceProperty_Prop_VendorSpecific_Reserved_End = 10999; + /** native declaration : headers\openvr_capi.h:431 */ + public static final int ETrackedDeviceProperty_Prop_TrackedDeviceProperty_Max = 1000000; + }; + /** + * native declaration : headers\openvr_capi.h:447
+ * enum values + */ + public static interface ETrackedPropertyError { + /** native declaration : headers\openvr_capi.h:434 */ + public static final int ETrackedPropertyError_TrackedProp_Success = 0; + /** native declaration : headers\openvr_capi.h:435 */ + public static final int ETrackedPropertyError_TrackedProp_WrongDataType = 1; + /** native declaration : headers\openvr_capi.h:436 */ + public static final int ETrackedPropertyError_TrackedProp_WrongDeviceClass = 2; + /** native declaration : headers\openvr_capi.h:437 */ + public static final int ETrackedPropertyError_TrackedProp_BufferTooSmall = 3; + /** native declaration : headers\openvr_capi.h:438 */ + public static final int ETrackedPropertyError_TrackedProp_UnknownProperty = 4; + /** native declaration : headers\openvr_capi.h:439 */ + public static final int ETrackedPropertyError_TrackedProp_InvalidDevice = 5; + /** native declaration : headers\openvr_capi.h:440 */ + public static final int ETrackedPropertyError_TrackedProp_CouldNotContactServer = 6; + /** native declaration : headers\openvr_capi.h:441 */ + public static final int ETrackedPropertyError_TrackedProp_ValueNotProvidedByDevice = 7; + /** native declaration : headers\openvr_capi.h:442 */ + public static final int ETrackedPropertyError_TrackedProp_StringExceedsMaximumLength = 8; + /** native declaration : headers\openvr_capi.h:443 */ + public static final int ETrackedPropertyError_TrackedProp_NotYetAvailable = 9; + /** native declaration : headers\openvr_capi.h:444 */ + public static final int ETrackedPropertyError_TrackedProp_PermissionDenied = 10; + /** native declaration : headers\openvr_capi.h:445 */ + public static final int ETrackedPropertyError_TrackedProp_InvalidOperation = 11; + /** native declaration : headers\openvr_capi.h:446 */ + public static final int ETrackedPropertyError_TrackedProp_CannotWriteToWildcards = 12; + }; + /** + * native declaration : headers\openvr_capi.h:455
+ * enum values + */ + public static interface EVRSubmitFlags { + /** native declaration : headers\openvr_capi.h:449 */ + public static final int EVRSubmitFlags_Submit_Default = 0; + /** native declaration : headers\openvr_capi.h:450 */ + public static final int EVRSubmitFlags_Submit_LensDistortionAlreadyApplied = 1; + /** native declaration : headers\openvr_capi.h:451 */ + public static final int EVRSubmitFlags_Submit_GlRenderBuffer = 2; + /** native declaration : headers\openvr_capi.h:452 */ + public static final int EVRSubmitFlags_Submit_Reserved = 4; + /** native declaration : headers\openvr_capi.h:453 */ + public static final int EVRSubmitFlags_Submit_TextureWithPose = 8; + /** native declaration : headers\openvr_capi.h:454 */ + public static final int EVRSubmitFlags_Submit_TextureWithDepth = 16; + }; + /** + * native declaration : headers\openvr_capi.h:466
+ * enum values + */ + public static interface EVRState { + /** native declaration : headers\openvr_capi.h:457 */ + public static final int EVRState_VRState_Undefined = -1; + /** native declaration : headers\openvr_capi.h:458 */ + public static final int EVRState_VRState_Off = 0; + /** native declaration : headers\openvr_capi.h:459 */ + public static final int EVRState_VRState_Searching = 1; + /** native declaration : headers\openvr_capi.h:460 */ + public static final int EVRState_VRState_Searching_Alert = 2; + /** native declaration : headers\openvr_capi.h:461 */ + public static final int EVRState_VRState_Ready = 3; + /** native declaration : headers\openvr_capi.h:462 */ + public static final int EVRState_VRState_Ready_Alert = 4; + /** native declaration : headers\openvr_capi.h:463 */ + public static final int EVRState_VRState_NotReady = 5; + /** native declaration : headers\openvr_capi.h:464 */ + public static final int EVRState_VRState_Standby = 6; + /** native declaration : headers\openvr_capi.h:465 */ + public static final int EVRState_VRState_Ready_Alert_Low = 7; + }; + /** + * native declaration : headers\openvr_capi.h:616
+ * enum values + */ + public static interface EVREventType { + /** native declaration : headers\openvr_capi.h:468 */ + public static final int EVREventType_VREvent_None = 0; + /** native declaration : headers\openvr_capi.h:469 */ + public static final int EVREventType_VREvent_TrackedDeviceActivated = 100; + /** native declaration : headers\openvr_capi.h:470 */ + public static final int EVREventType_VREvent_TrackedDeviceDeactivated = 101; + /** native declaration : headers\openvr_capi.h:471 */ + public static final int EVREventType_VREvent_TrackedDeviceUpdated = 102; + /** native declaration : headers\openvr_capi.h:472 */ + public static final int EVREventType_VREvent_TrackedDeviceUserInteractionStarted = 103; + /** native declaration : headers\openvr_capi.h:473 */ + public static final int EVREventType_VREvent_TrackedDeviceUserInteractionEnded = 104; + /** native declaration : headers\openvr_capi.h:474 */ + public static final int EVREventType_VREvent_IpdChanged = 105; + /** native declaration : headers\openvr_capi.h:475 */ + public static final int EVREventType_VREvent_EnterStandbyMode = 106; + /** native declaration : headers\openvr_capi.h:476 */ + public static final int EVREventType_VREvent_LeaveStandbyMode = 107; + /** native declaration : headers\openvr_capi.h:477 */ + public static final int EVREventType_VREvent_TrackedDeviceRoleChanged = 108; + /** native declaration : headers\openvr_capi.h:478 */ + public static final int EVREventType_VREvent_WatchdogWakeUpRequested = 109; + /** native declaration : headers\openvr_capi.h:479 */ + public static final int EVREventType_VREvent_LensDistortionChanged = 110; + /** native declaration : headers\openvr_capi.h:480 */ + public static final int EVREventType_VREvent_PropertyChanged = 111; + /** native declaration : headers\openvr_capi.h:481 */ + public static final int EVREventType_VREvent_WirelessDisconnect = 112; + /** native declaration : headers\openvr_capi.h:482 */ + public static final int EVREventType_VREvent_WirelessReconnect = 113; + /** native declaration : headers\openvr_capi.h:483 */ + public static final int EVREventType_VREvent_ButtonPress = 200; + /** native declaration : headers\openvr_capi.h:484 */ + public static final int EVREventType_VREvent_ButtonUnpress = 201; + /** native declaration : headers\openvr_capi.h:485 */ + public static final int EVREventType_VREvent_ButtonTouch = 202; + /** native declaration : headers\openvr_capi.h:486 */ + public static final int EVREventType_VREvent_ButtonUntouch = 203; + /** native declaration : headers\openvr_capi.h:487 */ + public static final int EVREventType_VREvent_DualAnalog_Press = 250; + /** native declaration : headers\openvr_capi.h:488 */ + public static final int EVREventType_VREvent_DualAnalog_Unpress = 251; + /** native declaration : headers\openvr_capi.h:489 */ + public static final int EVREventType_VREvent_DualAnalog_Touch = 252; + /** native declaration : headers\openvr_capi.h:490 */ + public static final int EVREventType_VREvent_DualAnalog_Untouch = 253; + /** native declaration : headers\openvr_capi.h:491 */ + public static final int EVREventType_VREvent_DualAnalog_Move = 254; + /** native declaration : headers\openvr_capi.h:492 */ + public static final int EVREventType_VREvent_DualAnalog_ModeSwitch1 = 255; + /** native declaration : headers\openvr_capi.h:493 */ + public static final int EVREventType_VREvent_DualAnalog_ModeSwitch2 = 256; + /** native declaration : headers\openvr_capi.h:494 */ + public static final int EVREventType_VREvent_DualAnalog_Cancel = 257; + /** native declaration : headers\openvr_capi.h:495 */ + public static final int EVREventType_VREvent_MouseMove = 300; + /** native declaration : headers\openvr_capi.h:496 */ + public static final int EVREventType_VREvent_MouseButtonDown = 301; + /** native declaration : headers\openvr_capi.h:497 */ + public static final int EVREventType_VREvent_MouseButtonUp = 302; + /** native declaration : headers\openvr_capi.h:498 */ + public static final int EVREventType_VREvent_FocusEnter = 303; + /** native declaration : headers\openvr_capi.h:499 */ + public static final int EVREventType_VREvent_FocusLeave = 304; + /** native declaration : headers\openvr_capi.h:500 */ + public static final int EVREventType_VREvent_Scroll = 305; + /** native declaration : headers\openvr_capi.h:501 */ + public static final int EVREventType_VREvent_TouchPadMove = 306; + /** native declaration : headers\openvr_capi.h:502 */ + public static final int EVREventType_VREvent_OverlayFocusChanged = 307; + /** native declaration : headers\openvr_capi.h:503 */ + public static final int EVREventType_VREvent_InputFocusCaptured = 400; + /** native declaration : headers\openvr_capi.h:504 */ + public static final int EVREventType_VREvent_InputFocusReleased = 401; + /** native declaration : headers\openvr_capi.h:505 */ + public static final int EVREventType_VREvent_SceneFocusLost = 402; + /** native declaration : headers\openvr_capi.h:506 */ + public static final int EVREventType_VREvent_SceneFocusGained = 403; + /** native declaration : headers\openvr_capi.h:507 */ + public static final int EVREventType_VREvent_SceneApplicationChanged = 404; + /** native declaration : headers\openvr_capi.h:508 */ + public static final int EVREventType_VREvent_SceneFocusChanged = 405; + /** native declaration : headers\openvr_capi.h:509 */ + public static final int EVREventType_VREvent_InputFocusChanged = 406; + /** native declaration : headers\openvr_capi.h:510 */ + public static final int EVREventType_VREvent_SceneApplicationSecondaryRenderingStarted = 407; + /** native declaration : headers\openvr_capi.h:511 */ + public static final int EVREventType_VREvent_SceneApplicationUsingWrongGraphicsAdapter = 408; + /** native declaration : headers\openvr_capi.h:512 */ + public static final int EVREventType_VREvent_ActionBindingReloaded = 409; + /** native declaration : headers\openvr_capi.h:513 */ + public static final int EVREventType_VREvent_HideRenderModels = 410; + /** native declaration : headers\openvr_capi.h:514 */ + public static final int EVREventType_VREvent_ShowRenderModels = 411; + /** native declaration : headers\openvr_capi.h:515 */ + public static final int EVREventType_VREvent_ConsoleOpened = 420; + /** native declaration : headers\openvr_capi.h:516 */ + public static final int EVREventType_VREvent_ConsoleClosed = 421; + /** native declaration : headers\openvr_capi.h:517 */ + public static final int EVREventType_VREvent_OverlayShown = 500; + /** native declaration : headers\openvr_capi.h:518 */ + public static final int EVREventType_VREvent_OverlayHidden = 501; + /** native declaration : headers\openvr_capi.h:519 */ + public static final int EVREventType_VREvent_DashboardActivated = 502; + /** native declaration : headers\openvr_capi.h:520 */ + public static final int EVREventType_VREvent_DashboardDeactivated = 503; + /** native declaration : headers\openvr_capi.h:521 */ + public static final int EVREventType_VREvent_DashboardThumbSelected = 504; + /** native declaration : headers\openvr_capi.h:522 */ + public static final int EVREventType_VREvent_DashboardRequested = 505; + /** native declaration : headers\openvr_capi.h:523 */ + public static final int EVREventType_VREvent_ResetDashboard = 506; + /** native declaration : headers\openvr_capi.h:524 */ + public static final int EVREventType_VREvent_RenderToast = 507; + /** native declaration : headers\openvr_capi.h:525 */ + public static final int EVREventType_VREvent_ImageLoaded = 508; + /** native declaration : headers\openvr_capi.h:526 */ + public static final int EVREventType_VREvent_ShowKeyboard = 509; + /** native declaration : headers\openvr_capi.h:527 */ + public static final int EVREventType_VREvent_HideKeyboard = 510; + /** native declaration : headers\openvr_capi.h:528 */ + public static final int EVREventType_VREvent_OverlayGamepadFocusGained = 511; + /** native declaration : headers\openvr_capi.h:529 */ + public static final int EVREventType_VREvent_OverlayGamepadFocusLost = 512; + /** native declaration : headers\openvr_capi.h:530 */ + public static final int EVREventType_VREvent_OverlaySharedTextureChanged = 513; + /** native declaration : headers\openvr_capi.h:531 */ + public static final int EVREventType_VREvent_ScreenshotTriggered = 516; + /** native declaration : headers\openvr_capi.h:532 */ + public static final int EVREventType_VREvent_ImageFailed = 517; + /** native declaration : headers\openvr_capi.h:533 */ + public static final int EVREventType_VREvent_DashboardOverlayCreated = 518; + /** native declaration : headers\openvr_capi.h:534 */ + public static final int EVREventType_VREvent_SwitchGamepadFocus = 519; + /** native declaration : headers\openvr_capi.h:535 */ + public static final int EVREventType_VREvent_RequestScreenshot = 520; + /** native declaration : headers\openvr_capi.h:536 */ + public static final int EVREventType_VREvent_ScreenshotTaken = 521; + /** native declaration : headers\openvr_capi.h:537 */ + public static final int EVREventType_VREvent_ScreenshotFailed = 522; + /** native declaration : headers\openvr_capi.h:538 */ + public static final int EVREventType_VREvent_SubmitScreenshotToDashboard = 523; + /** native declaration : headers\openvr_capi.h:539 */ + public static final int EVREventType_VREvent_ScreenshotProgressToDashboard = 524; + /** native declaration : headers\openvr_capi.h:540 */ + public static final int EVREventType_VREvent_PrimaryDashboardDeviceChanged = 525; + /** native declaration : headers\openvr_capi.h:541 */ + public static final int EVREventType_VREvent_RoomViewShown = 526; + /** native declaration : headers\openvr_capi.h:542 */ + public static final int EVREventType_VREvent_RoomViewHidden = 527; + /** native declaration : headers\openvr_capi.h:543 */ + public static final int EVREventType_VREvent_Notification_Shown = 600; + /** native declaration : headers\openvr_capi.h:544 */ + public static final int EVREventType_VREvent_Notification_Hidden = 601; + /** native declaration : headers\openvr_capi.h:545 */ + public static final int EVREventType_VREvent_Notification_BeginInteraction = 602; + /** native declaration : headers\openvr_capi.h:546 */ + public static final int EVREventType_VREvent_Notification_Destroyed = 603; + /** native declaration : headers\openvr_capi.h:547 */ + public static final int EVREventType_VREvent_Quit = 700; + /** native declaration : headers\openvr_capi.h:548 */ + public static final int EVREventType_VREvent_ProcessQuit = 701; + /** native declaration : headers\openvr_capi.h:549 */ + public static final int EVREventType_VREvent_QuitAborted_UserPrompt = 702; + /** native declaration : headers\openvr_capi.h:550 */ + public static final int EVREventType_VREvent_QuitAcknowledged = 703; + /** native declaration : headers\openvr_capi.h:551 */ + public static final int EVREventType_VREvent_DriverRequestedQuit = 704; + /** native declaration : headers\openvr_capi.h:552 */ + public static final int EVREventType_VREvent_ChaperoneDataHasChanged = 800; + /** native declaration : headers\openvr_capi.h:553 */ + public static final int EVREventType_VREvent_ChaperoneUniverseHasChanged = 801; + /** native declaration : headers\openvr_capi.h:554 */ + public static final int EVREventType_VREvent_ChaperoneTempDataHasChanged = 802; + /** native declaration : headers\openvr_capi.h:555 */ + public static final int EVREventType_VREvent_ChaperoneSettingsHaveChanged = 803; + /** native declaration : headers\openvr_capi.h:556 */ + public static final int EVREventType_VREvent_SeatedZeroPoseReset = 804; + /** native declaration : headers\openvr_capi.h:557 */ + public static final int EVREventType_VREvent_AudioSettingsHaveChanged = 820; + /** native declaration : headers\openvr_capi.h:558 */ + public static final int EVREventType_VREvent_BackgroundSettingHasChanged = 850; + /** native declaration : headers\openvr_capi.h:559 */ + public static final int EVREventType_VREvent_CameraSettingsHaveChanged = 851; + /** native declaration : headers\openvr_capi.h:560 */ + public static final int EVREventType_VREvent_ReprojectionSettingHasChanged = 852; + /** native declaration : headers\openvr_capi.h:561 */ + public static final int EVREventType_VREvent_ModelSkinSettingsHaveChanged = 853; + /** native declaration : headers\openvr_capi.h:562 */ + public static final int EVREventType_VREvent_EnvironmentSettingsHaveChanged = 854; + /** native declaration : headers\openvr_capi.h:563 */ + public static final int EVREventType_VREvent_PowerSettingsHaveChanged = 855; + /** native declaration : headers\openvr_capi.h:564 */ + public static final int EVREventType_VREvent_EnableHomeAppSettingsHaveChanged = 856; + /** native declaration : headers\openvr_capi.h:565 */ + public static final int EVREventType_VREvent_SteamVRSectionSettingChanged = 857; + /** native declaration : headers\openvr_capi.h:566 */ + public static final int EVREventType_VREvent_LighthouseSectionSettingChanged = 858; + /** native declaration : headers\openvr_capi.h:567 */ + public static final int EVREventType_VREvent_NullSectionSettingChanged = 859; + /** native declaration : headers\openvr_capi.h:568 */ + public static final int EVREventType_VREvent_UserInterfaceSectionSettingChanged = 860; + /** native declaration : headers\openvr_capi.h:569 */ + public static final int EVREventType_VREvent_NotificationsSectionSettingChanged = 861; + /** native declaration : headers\openvr_capi.h:570 */ + public static final int EVREventType_VREvent_KeyboardSectionSettingChanged = 862; + /** native declaration : headers\openvr_capi.h:571 */ + public static final int EVREventType_VREvent_PerfSectionSettingChanged = 863; + /** native declaration : headers\openvr_capi.h:572 */ + public static final int EVREventType_VREvent_DashboardSectionSettingChanged = 864; + /** native declaration : headers\openvr_capi.h:573 */ + public static final int EVREventType_VREvent_WebInterfaceSectionSettingChanged = 865; + /** native declaration : headers\openvr_capi.h:574 */ + public static final int EVREventType_VREvent_TrackersSectionSettingChanged = 866; + /** native declaration : headers\openvr_capi.h:575 */ + public static final int EVREventType_VREvent_StatusUpdate = 900; + /** native declaration : headers\openvr_capi.h:576 */ + public static final int EVREventType_VREvent_WebInterface_InstallDriverCompleted = 950; + /** native declaration : headers\openvr_capi.h:577 */ + public static final int EVREventType_VREvent_MCImageUpdated = 1000; + /** native declaration : headers\openvr_capi.h:578 */ + public static final int EVREventType_VREvent_FirmwareUpdateStarted = 1100; + /** native declaration : headers\openvr_capi.h:579 */ + public static final int EVREventType_VREvent_FirmwareUpdateFinished = 1101; + /** native declaration : headers\openvr_capi.h:580 */ + public static final int EVREventType_VREvent_KeyboardClosed = 1200; + /** native declaration : headers\openvr_capi.h:581 */ + public static final int EVREventType_VREvent_KeyboardCharInput = 1201; + /** native declaration : headers\openvr_capi.h:582 */ + public static final int EVREventType_VREvent_KeyboardDone = 1202; + /** native declaration : headers\openvr_capi.h:583 */ + public static final int EVREventType_VREvent_ApplicationTransitionStarted = 1300; + /** native declaration : headers\openvr_capi.h:584 */ + public static final int EVREventType_VREvent_ApplicationTransitionAborted = 1301; + /** native declaration : headers\openvr_capi.h:585 */ + public static final int EVREventType_VREvent_ApplicationTransitionNewAppStarted = 1302; + /** native declaration : headers\openvr_capi.h:586 */ + public static final int EVREventType_VREvent_ApplicationListUpdated = 1303; + /** native declaration : headers\openvr_capi.h:587 */ + public static final int EVREventType_VREvent_ApplicationMimeTypeLoad = 1304; + /** native declaration : headers\openvr_capi.h:588 */ + public static final int EVREventType_VREvent_ApplicationTransitionNewAppLaunchComplete = 1305; + /** native declaration : headers\openvr_capi.h:589 */ + public static final int EVREventType_VREvent_ProcessConnected = 1306; + /** native declaration : headers\openvr_capi.h:590 */ + public static final int EVREventType_VREvent_ProcessDisconnected = 1307; + /** native declaration : headers\openvr_capi.h:591 */ + public static final int EVREventType_VREvent_Compositor_MirrorWindowShown = 1400; + /** native declaration : headers\openvr_capi.h:592 */ + public static final int EVREventType_VREvent_Compositor_MirrorWindowHidden = 1401; + /** native declaration : headers\openvr_capi.h:593 */ + public static final int EVREventType_VREvent_Compositor_ChaperoneBoundsShown = 1410; + /** native declaration : headers\openvr_capi.h:594 */ + public static final int EVREventType_VREvent_Compositor_ChaperoneBoundsHidden = 1411; + /** native declaration : headers\openvr_capi.h:595 */ + public static final int EVREventType_VREvent_TrackedCamera_StartVideoStream = 1500; + /** native declaration : headers\openvr_capi.h:596 */ + public static final int EVREventType_VREvent_TrackedCamera_StopVideoStream = 1501; + /** native declaration : headers\openvr_capi.h:597 */ + public static final int EVREventType_VREvent_TrackedCamera_PauseVideoStream = 1502; + /** native declaration : headers\openvr_capi.h:598 */ + public static final int EVREventType_VREvent_TrackedCamera_ResumeVideoStream = 1503; + /** native declaration : headers\openvr_capi.h:599 */ + public static final int EVREventType_VREvent_TrackedCamera_EditingSurface = 1550; + /** native declaration : headers\openvr_capi.h:600 */ + public static final int EVREventType_VREvent_PerformanceTest_EnableCapture = 1600; + /** native declaration : headers\openvr_capi.h:601 */ + public static final int EVREventType_VREvent_PerformanceTest_DisableCapture = 1601; + /** native declaration : headers\openvr_capi.h:602 */ + public static final int EVREventType_VREvent_PerformanceTest_FidelityLevel = 1602; + /** native declaration : headers\openvr_capi.h:603 */ + public static final int EVREventType_VREvent_MessageOverlay_Closed = 1650; + /** native declaration : headers\openvr_capi.h:604 */ + public static final int EVREventType_VREvent_MessageOverlayCloseRequested = 1651; + /** native declaration : headers\openvr_capi.h:605 */ + public static final int EVREventType_VREvent_Input_HapticVibration = 1700; + /** native declaration : headers\openvr_capi.h:606 */ + public static final int EVREventType_VREvent_Input_BindingLoadFailed = 1701; + /** native declaration : headers\openvr_capi.h:607 */ + public static final int EVREventType_VREvent_Input_BindingLoadSuccessful = 1702; + /** native declaration : headers\openvr_capi.h:608 */ + public static final int EVREventType_VREvent_Input_ActionManifestReloaded = 1703; + /** native declaration : headers\openvr_capi.h:609 */ + public static final int EVREventType_VREvent_Input_ActionManifestLoadFailed = 1704; + /** native declaration : headers\openvr_capi.h:610 */ + public static final int EVREventType_VREvent_SpatialAnchors_PoseUpdated = 1800; + /** native declaration : headers\openvr_capi.h:611 */ + public static final int EVREventType_VREvent_SpatialAnchors_DescriptorUpdated = 1801; + /** native declaration : headers\openvr_capi.h:612 */ + public static final int EVREventType_VREvent_SpatialAnchors_RequestPoseUpdate = 1802; + /** native declaration : headers\openvr_capi.h:613 */ + public static final int EVREventType_VREvent_SpatialAnchors_RequestDescriptorUpdate = 1803; + /** native declaration : headers\openvr_capi.h:614 */ + public static final int EVREventType_VREvent_VendorSpecific_Reserved_Start = 10000; + /** native declaration : headers\openvr_capi.h:615 */ + public static final int EVREventType_VREvent_VendorSpecific_Reserved_End = 19999; + }; + /** + * native declaration : headers\openvr_capi.h:623
+ * enum values + */ + public static interface EDeviceActivityLevel { + /** native declaration : headers\openvr_capi.h:618 */ + public static final int EDeviceActivityLevel_k_EDeviceActivityLevel_Unknown = -1; + /** native declaration : headers\openvr_capi.h:619 */ + public static final int EDeviceActivityLevel_k_EDeviceActivityLevel_Idle = 0; + /** native declaration : headers\openvr_capi.h:620 */ + public static final int EDeviceActivityLevel_k_EDeviceActivityLevel_UserInteraction = 1; + /** native declaration : headers\openvr_capi.h:621 */ + public static final int EDeviceActivityLevel_k_EDeviceActivityLevel_UserInteraction_Timeout = 2; + /** native declaration : headers\openvr_capi.h:622 */ + public static final int EDeviceActivityLevel_k_EDeviceActivityLevel_Standby = 3; + }; + /** + * native declaration : headers\openvr_capi.h:646
+ * enum values + */ + public static interface EVRButtonId { + /** native declaration : headers\openvr_capi.h:625 */ + public static final int EVRButtonId_k_EButton_System = 0; + /** native declaration : headers\openvr_capi.h:626 */ + public static final int EVRButtonId_k_EButton_ApplicationMenu = 1; + /** native declaration : headers\openvr_capi.h:627 */ + public static final int EVRButtonId_k_EButton_Grip = 2; + /** native declaration : headers\openvr_capi.h:628 */ + public static final int EVRButtonId_k_EButton_DPad_Left = 3; + /** native declaration : headers\openvr_capi.h:629 */ + public static final int EVRButtonId_k_EButton_DPad_Up = 4; + /** native declaration : headers\openvr_capi.h:630 */ + public static final int EVRButtonId_k_EButton_DPad_Right = 5; + /** native declaration : headers\openvr_capi.h:631 */ + public static final int EVRButtonId_k_EButton_DPad_Down = 6; + /** native declaration : headers\openvr_capi.h:632 */ + public static final int EVRButtonId_k_EButton_A = 7; + /** native declaration : headers\openvr_capi.h:633 */ + public static final int EVRButtonId_k_EButton_ProximitySensor = 31; + /** native declaration : headers\openvr_capi.h:634 */ + public static final int EVRButtonId_k_EButton_Axis0 = 32; + /** native declaration : headers\openvr_capi.h:635 */ + public static final int EVRButtonId_k_EButton_Axis1 = 33; + /** native declaration : headers\openvr_capi.h:636 */ + public static final int EVRButtonId_k_EButton_Axis2 = 34; + /** native declaration : headers\openvr_capi.h:637 */ + public static final int EVRButtonId_k_EButton_Axis3 = 35; + /** native declaration : headers\openvr_capi.h:638 */ + public static final int EVRButtonId_k_EButton_Axis4 = 36; + /** native declaration : headers\openvr_capi.h:639 */ + public static final int EVRButtonId_k_EButton_SteamVR_Touchpad = 32; + /** native declaration : headers\openvr_capi.h:640 */ + public static final int EVRButtonId_k_EButton_SteamVR_Trigger = 33; + /** native declaration : headers\openvr_capi.h:641 */ + public static final int EVRButtonId_k_EButton_Dashboard_Back = 2; + /** native declaration : headers\openvr_capi.h:642 */ + public static final int EVRButtonId_k_EButton_Knuckles_A = 2; + /** native declaration : headers\openvr_capi.h:643 */ + public static final int EVRButtonId_k_EButton_Knuckles_B = 1; + /** native declaration : headers\openvr_capi.h:644 */ + public static final int EVRButtonId_k_EButton_Knuckles_JoyStick = 35; + /** native declaration : headers\openvr_capi.h:645 */ + public static final int EVRButtonId_k_EButton_Max = 64; + }; + /** + * native declaration : headers\openvr_capi.h:651
+ * enum values + */ + public static interface EVRMouseButton { + /** native declaration : headers\openvr_capi.h:648 */ + public static final int EVRMouseButton_VRMouseButton_Left = 1; + /** native declaration : headers\openvr_capi.h:649 */ + public static final int EVRMouseButton_VRMouseButton_Right = 2; + /** native declaration : headers\openvr_capi.h:650 */ + public static final int EVRMouseButton_VRMouseButton_Middle = 4; + }; + /** + * native declaration : headers\openvr_capi.h:655
+ * enum values + */ + public static interface EDualAnalogWhich { + /** native declaration : headers\openvr_capi.h:653 */ + public static final int EDualAnalogWhich_k_EDualAnalog_Left = 0; + /** native declaration : headers\openvr_capi.h:654 */ + public static final int EDualAnalogWhich_k_EDualAnalog_Right = 1; + }; + /** + * native declaration : headers\openvr_capi.h:674
+ * enum values + */ + public static interface EVRInputError { + /** native declaration : headers\openvr_capi.h:657 */ + public static final int EVRInputError_VRInputError_None = 0; + /** native declaration : headers\openvr_capi.h:658 */ + public static final int EVRInputError_VRInputError_NameNotFound = 1; + /** native declaration : headers\openvr_capi.h:659 */ + public static final int EVRInputError_VRInputError_WrongType = 2; + /** native declaration : headers\openvr_capi.h:660 */ + public static final int EVRInputError_VRInputError_InvalidHandle = 3; + /** native declaration : headers\openvr_capi.h:661 */ + public static final int EVRInputError_VRInputError_InvalidParam = 4; + /** native declaration : headers\openvr_capi.h:662 */ + public static final int EVRInputError_VRInputError_NoSteam = 5; + /** native declaration : headers\openvr_capi.h:663 */ + public static final int EVRInputError_VRInputError_MaxCapacityReached = 6; + /** native declaration : headers\openvr_capi.h:664 */ + public static final int EVRInputError_VRInputError_IPCError = 7; + /** native declaration : headers\openvr_capi.h:665 */ + public static final int EVRInputError_VRInputError_NoActiveActionSet = 8; + /** native declaration : headers\openvr_capi.h:666 */ + public static final int EVRInputError_VRInputError_InvalidDevice = 9; + /** native declaration : headers\openvr_capi.h:667 */ + public static final int EVRInputError_VRInputError_InvalidSkeleton = 10; + /** native declaration : headers\openvr_capi.h:668 */ + public static final int EVRInputError_VRInputError_InvalidBoneCount = 11; + /** native declaration : headers\openvr_capi.h:669 */ + public static final int EVRInputError_VRInputError_InvalidCompressedData = 12; + /** native declaration : headers\openvr_capi.h:670 */ + public static final int EVRInputError_VRInputError_NoData = 13; + /** native declaration : headers\openvr_capi.h:671 */ + public static final int EVRInputError_VRInputError_BufferTooSmall = 14; + /** native declaration : headers\openvr_capi.h:672 */ + public static final int EVRInputError_VRInputError_MismatchedActionManifest = 15; + /** native declaration : headers\openvr_capi.h:673 */ + public static final int EVRInputError_VRInputError_MissingSkeletonData = 16; + }; + /** + * native declaration : headers\openvr_capi.h:690
+ * enum values + */ + public static interface EVRSpatialAnchorError { + /** native declaration : headers\openvr_capi.h:676 */ + public static final int EVRSpatialAnchorError_VRSpatialAnchorError_Success = 0; + /** native declaration : headers\openvr_capi.h:677 */ + public static final int EVRSpatialAnchorError_VRSpatialAnchorError_Internal = 1; + /** native declaration : headers\openvr_capi.h:678 */ + public static final int EVRSpatialAnchorError_VRSpatialAnchorError_UnknownHandle = 2; + /** native declaration : headers\openvr_capi.h:679 */ + public static final int EVRSpatialAnchorError_VRSpatialAnchorError_ArrayTooSmall = 3; + /** native declaration : headers\openvr_capi.h:680 */ + public static final int EVRSpatialAnchorError_VRSpatialAnchorError_InvalidDescriptorChar = 4; + /** native declaration : headers\openvr_capi.h:681 */ + public static final int EVRSpatialAnchorError_VRSpatialAnchorError_NotYetAvailable = 5; + /** native declaration : headers\openvr_capi.h:682 */ + public static final int EVRSpatialAnchorError_VRSpatialAnchorError_NotAvailableInThisUniverse = 6; + /** native declaration : headers\openvr_capi.h:683 */ + public static final int EVRSpatialAnchorError_VRSpatialAnchorError_PermanentlyUnavailable = 7; + /** native declaration : headers\openvr_capi.h:684 */ + public static final int EVRSpatialAnchorError_VRSpatialAnchorError_WrongDriver = 8; + /** native declaration : headers\openvr_capi.h:685 */ + public static final int EVRSpatialAnchorError_VRSpatialAnchorError_DescriptorTooLong = 9; + /** native declaration : headers\openvr_capi.h:686 */ + public static final int EVRSpatialAnchorError_VRSpatialAnchorError_Unknown = 10; + /** native declaration : headers\openvr_capi.h:687 */ + public static final int EVRSpatialAnchorError_VRSpatialAnchorError_NoRoomCalibration = 11; + /** native declaration : headers\openvr_capi.h:688 */ + public static final int EVRSpatialAnchorError_VRSpatialAnchorError_InvalidArgument = 12; + /** native declaration : headers\openvr_capi.h:689 */ + public static final int EVRSpatialAnchorError_VRSpatialAnchorError_UnknownDriver = 13; + }; + /** + * native declaration : headers\openvr_capi.h:696
+ * enum values + */ + public static interface EHiddenAreaMeshType { + /** native declaration : headers\openvr_capi.h:692 */ + public static final int EHiddenAreaMeshType_k_eHiddenAreaMesh_Standard = 0; + /** native declaration : headers\openvr_capi.h:693 */ + public static final int EHiddenAreaMeshType_k_eHiddenAreaMesh_Inverse = 1; + /** native declaration : headers\openvr_capi.h:694 */ + public static final int EHiddenAreaMeshType_k_eHiddenAreaMesh_LineLoop = 2; + /** native declaration : headers\openvr_capi.h:695 */ + public static final int EHiddenAreaMeshType_k_eHiddenAreaMesh_Max = 3; + }; + /** + * native declaration : headers\openvr_capi.h:702
+ * enum values + */ + public static interface EVRControllerAxisType { + /** native declaration : headers\openvr_capi.h:698 */ + public static final int EVRControllerAxisType_k_eControllerAxis_None = 0; + /** native declaration : headers\openvr_capi.h:699 */ + public static final int EVRControllerAxisType_k_eControllerAxis_TrackPad = 1; + /** native declaration : headers\openvr_capi.h:700 */ + public static final int EVRControllerAxisType_k_eControllerAxis_Joystick = 2; + /** native declaration : headers\openvr_capi.h:701 */ + public static final int EVRControllerAxisType_k_eControllerAxis_Trigger = 3; + }; + /** + * native declaration : headers\openvr_capi.h:706
+ * enum values + */ + public static interface EVRControllerEventOutputType { + /** native declaration : headers\openvr_capi.h:704 */ + public static final int EVRControllerEventOutputType_ControllerEventOutput_OSEvents = 0; + /** native declaration : headers\openvr_capi.h:705 */ + public static final int EVRControllerEventOutputType_ControllerEventOutput_VREvents = 1; + }; + /** + * native declaration : headers\openvr_capi.h:714
+ * enum values + */ + public static interface ECollisionBoundsStyle { + /** native declaration : headers\openvr_capi.h:708 */ + public static final int ECollisionBoundsStyle_COLLISION_BOUNDS_STYLE_BEGINNER = 0; + /** native declaration : headers\openvr_capi.h:709 */ + public static final int ECollisionBoundsStyle_COLLISION_BOUNDS_STYLE_INTERMEDIATE = 1; + /** native declaration : headers\openvr_capi.h:710 */ + public static final int ECollisionBoundsStyle_COLLISION_BOUNDS_STYLE_SQUARES = 2; + /** native declaration : headers\openvr_capi.h:711 */ + public static final int ECollisionBoundsStyle_COLLISION_BOUNDS_STYLE_ADVANCED = 3; + /** native declaration : headers\openvr_capi.h:712 */ + public static final int ECollisionBoundsStyle_COLLISION_BOUNDS_STYLE_NONE = 4; + /** native declaration : headers\openvr_capi.h:713 */ + public static final int ECollisionBoundsStyle_COLLISION_BOUNDS_STYLE_COUNT = 5; + }; + /** + * native declaration : headers\openvr_capi.h:740
+ * enum values + */ + public static interface EVROverlayError { + /** native declaration : headers\openvr_capi.h:716 */ + public static final int EVROverlayError_VROverlayError_None = 0; + /** native declaration : headers\openvr_capi.h:717 */ + public static final int EVROverlayError_VROverlayError_UnknownOverlay = 10; + /** native declaration : headers\openvr_capi.h:718 */ + public static final int EVROverlayError_VROverlayError_InvalidHandle = 11; + /** native declaration : headers\openvr_capi.h:719 */ + public static final int EVROverlayError_VROverlayError_PermissionDenied = 12; + /** native declaration : headers\openvr_capi.h:720 */ + public static final int EVROverlayError_VROverlayError_OverlayLimitExceeded = 13; + /** native declaration : headers\openvr_capi.h:721 */ + public static final int EVROverlayError_VROverlayError_WrongVisibilityType = 14; + /** native declaration : headers\openvr_capi.h:722 */ + public static final int EVROverlayError_VROverlayError_KeyTooLong = 15; + /** native declaration : headers\openvr_capi.h:723 */ + public static final int EVROverlayError_VROverlayError_NameTooLong = 16; + /** native declaration : headers\openvr_capi.h:724 */ + public static final int EVROverlayError_VROverlayError_KeyInUse = 17; + /** native declaration : headers\openvr_capi.h:725 */ + public static final int EVROverlayError_VROverlayError_WrongTransformType = 18; + /** native declaration : headers\openvr_capi.h:726 */ + public static final int EVROverlayError_VROverlayError_InvalidTrackedDevice = 19; + /** native declaration : headers\openvr_capi.h:727 */ + public static final int EVROverlayError_VROverlayError_InvalidParameter = 20; + /** native declaration : headers\openvr_capi.h:728 */ + public static final int EVROverlayError_VROverlayError_ThumbnailCantBeDestroyed = 21; + /** native declaration : headers\openvr_capi.h:729 */ + public static final int EVROverlayError_VROverlayError_ArrayTooSmall = 22; + /** native declaration : headers\openvr_capi.h:730 */ + public static final int EVROverlayError_VROverlayError_RequestFailed = 23; + /** native declaration : headers\openvr_capi.h:731 */ + public static final int EVROverlayError_VROverlayError_InvalidTexture = 24; + /** native declaration : headers\openvr_capi.h:732 */ + public static final int EVROverlayError_VROverlayError_UnableToLoadFile = 25; + /** native declaration : headers\openvr_capi.h:733 */ + public static final int EVROverlayError_VROverlayError_KeyboardAlreadyInUse = 26; + /** native declaration : headers\openvr_capi.h:734 */ + public static final int EVROverlayError_VROverlayError_NoNeighbor = 27; + /** native declaration : headers\openvr_capi.h:735 */ + public static final int EVROverlayError_VROverlayError_TooManyMaskPrimitives = 29; + /** native declaration : headers\openvr_capi.h:736 */ + public static final int EVROverlayError_VROverlayError_BadMaskPrimitive = 30; + /** native declaration : headers\openvr_capi.h:737 */ + public static final int EVROverlayError_VROverlayError_TextureAlreadyLocked = 31; + /** native declaration : headers\openvr_capi.h:738 */ + public static final int EVROverlayError_VROverlayError_TextureLockCapacityReached = 32; + /** native declaration : headers\openvr_capi.h:739 */ + public static final int EVROverlayError_VROverlayError_TextureNotLocked = 33; + }; + /** + * native declaration : headers\openvr_capi.h:751
+ * enum values + */ + public static interface EVRApplicationType { + /** native declaration : headers\openvr_capi.h:742 */ + public static final int EVRApplicationType_VRApplication_Other = 0; + /** native declaration : headers\openvr_capi.h:743 */ + public static final int EVRApplicationType_VRApplication_Scene = 1; + /** native declaration : headers\openvr_capi.h:744 */ + public static final int EVRApplicationType_VRApplication_Overlay = 2; + /** native declaration : headers\openvr_capi.h:745 */ + public static final int EVRApplicationType_VRApplication_Background = 3; + /** native declaration : headers\openvr_capi.h:746 */ + public static final int EVRApplicationType_VRApplication_Utility = 4; + /** native declaration : headers\openvr_capi.h:747 */ + public static final int EVRApplicationType_VRApplication_VRMonitor = 5; + /** native declaration : headers\openvr_capi.h:748 */ + public static final int EVRApplicationType_VRApplication_SteamWatchdog = 6; + /** native declaration : headers\openvr_capi.h:749 */ + public static final int EVRApplicationType_VRApplication_Bootstrapper = 7; + /** native declaration : headers\openvr_capi.h:750 */ + public static final int EVRApplicationType_VRApplication_Max = 8; + }; + /** + * native declaration : headers\openvr_capi.h:756
+ * enum values + */ + public static interface EVRFirmwareError { + /** native declaration : headers\openvr_capi.h:753 */ + public static final int EVRFirmwareError_VRFirmwareError_None = 0; + /** native declaration : headers\openvr_capi.h:754 */ + public static final int EVRFirmwareError_VRFirmwareError_Success = 1; + /** native declaration : headers\openvr_capi.h:755 */ + public static final int EVRFirmwareError_VRFirmwareError_Fail = 2; + }; + /** + * native declaration : headers\openvr_capi.h:763
+ * enum values + */ + public static interface EVRNotificationError { + /** native declaration : headers\openvr_capi.h:758 */ + public static final int EVRNotificationError_VRNotificationError_OK = 0; + /** native declaration : headers\openvr_capi.h:759 */ + public static final int EVRNotificationError_VRNotificationError_InvalidNotificationId = 100; + /** native declaration : headers\openvr_capi.h:760 */ + public static final int EVRNotificationError_VRNotificationError_NotificationQueueFull = 101; + /** native declaration : headers\openvr_capi.h:761 */ + public static final int EVRNotificationError_VRNotificationError_InvalidOverlayHandle = 102; + /** native declaration : headers\openvr_capi.h:762 */ + public static final int EVRNotificationError_VRNotificationError_SystemWithUserValueAlreadyExists = 103; + }; + /** + * native declaration : headers\openvr_capi.h:767
+ * enum values + */ + public static interface EVRSkeletalMotionRange { + /** native declaration : headers\openvr_capi.h:765 */ + public static final int EVRSkeletalMotionRange_VRSkeletalMotionRange_WithController = 0; + /** native declaration : headers\openvr_capi.h:766 */ + public static final int EVRSkeletalMotionRange_VRSkeletalMotionRange_WithoutController = 1; + }; + /** + * native declaration : headers\openvr_capi.h:857
+ * enum values + */ + public static interface EVRInitError { + /** native declaration : headers\openvr_capi.h:769 */ + public static final int EVRInitError_VRInitError_None = 0; + /** native declaration : headers\openvr_capi.h:770 */ + public static final int EVRInitError_VRInitError_Unknown = 1; + /** native declaration : headers\openvr_capi.h:771 */ + public static final int EVRInitError_VRInitError_Init_InstallationNotFound = 100; + /** native declaration : headers\openvr_capi.h:772 */ + public static final int EVRInitError_VRInitError_Init_InstallationCorrupt = 101; + /** native declaration : headers\openvr_capi.h:773 */ + public static final int EVRInitError_VRInitError_Init_VRClientDLLNotFound = 102; + /** native declaration : headers\openvr_capi.h:774 */ + public static final int EVRInitError_VRInitError_Init_FileNotFound = 103; + /** native declaration : headers\openvr_capi.h:775 */ + public static final int EVRInitError_VRInitError_Init_FactoryNotFound = 104; + /** native declaration : headers\openvr_capi.h:776 */ + public static final int EVRInitError_VRInitError_Init_InterfaceNotFound = 105; + /** native declaration : headers\openvr_capi.h:777 */ + public static final int EVRInitError_VRInitError_Init_InvalidInterface = 106; + /** native declaration : headers\openvr_capi.h:778 */ + public static final int EVRInitError_VRInitError_Init_UserConfigDirectoryInvalid = 107; + /** native declaration : headers\openvr_capi.h:779 */ + public static final int EVRInitError_VRInitError_Init_HmdNotFound = 108; + /** native declaration : headers\openvr_capi.h:780 */ + public static final int EVRInitError_VRInitError_Init_NotInitialized = 109; + /** native declaration : headers\openvr_capi.h:781 */ + public static final int EVRInitError_VRInitError_Init_PathRegistryNotFound = 110; + /** native declaration : headers\openvr_capi.h:782 */ + public static final int EVRInitError_VRInitError_Init_NoConfigPath = 111; + /** native declaration : headers\openvr_capi.h:783 */ + public static final int EVRInitError_VRInitError_Init_NoLogPath = 112; + /** native declaration : headers\openvr_capi.h:784 */ + public static final int EVRInitError_VRInitError_Init_PathRegistryNotWritable = 113; + /** native declaration : headers\openvr_capi.h:785 */ + public static final int EVRInitError_VRInitError_Init_AppInfoInitFailed = 114; + /** native declaration : headers\openvr_capi.h:786 */ + public static final int EVRInitError_VRInitError_Init_Retry = 115; + /** native declaration : headers\openvr_capi.h:787 */ + public static final int EVRInitError_VRInitError_Init_InitCanceledByUser = 116; + /** native declaration : headers\openvr_capi.h:788 */ + public static final int EVRInitError_VRInitError_Init_AnotherAppLaunching = 117; + /** native declaration : headers\openvr_capi.h:789 */ + public static final int EVRInitError_VRInitError_Init_SettingsInitFailed = 118; + /** native declaration : headers\openvr_capi.h:790 */ + public static final int EVRInitError_VRInitError_Init_ShuttingDown = 119; + /** native declaration : headers\openvr_capi.h:791 */ + public static final int EVRInitError_VRInitError_Init_TooManyObjects = 120; + /** native declaration : headers\openvr_capi.h:792 */ + public static final int EVRInitError_VRInitError_Init_NoServerForBackgroundApp = 121; + /** native declaration : headers\openvr_capi.h:793 */ + public static final int EVRInitError_VRInitError_Init_NotSupportedWithCompositor = 122; + /** native declaration : headers\openvr_capi.h:794 */ + public static final int EVRInitError_VRInitError_Init_NotAvailableToUtilityApps = 123; + /** native declaration : headers\openvr_capi.h:795 */ + public static final int EVRInitError_VRInitError_Init_Internal = 124; + /** native declaration : headers\openvr_capi.h:796 */ + public static final int EVRInitError_VRInitError_Init_HmdDriverIdIsNone = 125; + /** native declaration : headers\openvr_capi.h:797 */ + public static final int EVRInitError_VRInitError_Init_HmdNotFoundPresenceFailed = 126; + /** native declaration : headers\openvr_capi.h:798 */ + public static final int EVRInitError_VRInitError_Init_VRMonitorNotFound = 127; + /** native declaration : headers\openvr_capi.h:799 */ + public static final int EVRInitError_VRInitError_Init_VRMonitorStartupFailed = 128; + /** native declaration : headers\openvr_capi.h:800 */ + public static final int EVRInitError_VRInitError_Init_LowPowerWatchdogNotSupported = 129; + /** native declaration : headers\openvr_capi.h:801 */ + public static final int EVRInitError_VRInitError_Init_InvalidApplicationType = 130; + /** native declaration : headers\openvr_capi.h:802 */ + public static final int EVRInitError_VRInitError_Init_NotAvailableToWatchdogApps = 131; + /** native declaration : headers\openvr_capi.h:803 */ + public static final int EVRInitError_VRInitError_Init_WatchdogDisabledInSettings = 132; + /** native declaration : headers\openvr_capi.h:804 */ + public static final int EVRInitError_VRInitError_Init_VRDashboardNotFound = 133; + /** native declaration : headers\openvr_capi.h:805 */ + public static final int EVRInitError_VRInitError_Init_VRDashboardStartupFailed = 134; + /** native declaration : headers\openvr_capi.h:806 */ + public static final int EVRInitError_VRInitError_Init_VRHomeNotFound = 135; + /** native declaration : headers\openvr_capi.h:807 */ + public static final int EVRInitError_VRInitError_Init_VRHomeStartupFailed = 136; + /** native declaration : headers\openvr_capi.h:808 */ + public static final int EVRInitError_VRInitError_Init_RebootingBusy = 137; + /** native declaration : headers\openvr_capi.h:809 */ + public static final int EVRInitError_VRInitError_Init_FirmwareUpdateBusy = 138; + /** native declaration : headers\openvr_capi.h:810 */ + public static final int EVRInitError_VRInitError_Init_FirmwareRecoveryBusy = 139; + /** native declaration : headers\openvr_capi.h:811 */ + public static final int EVRInitError_VRInitError_Init_USBServiceBusy = 140; + /** native declaration : headers\openvr_capi.h:812 */ + public static final int EVRInitError_VRInitError_Init_VRWebHelperStartupFailed = 141; + /** native declaration : headers\openvr_capi.h:813 */ + public static final int EVRInitError_VRInitError_Init_TrackerManagerInitFailed = 142; + /** native declaration : headers\openvr_capi.h:814 */ + public static final int EVRInitError_VRInitError_Driver_Failed = 200; + /** native declaration : headers\openvr_capi.h:815 */ + public static final int EVRInitError_VRInitError_Driver_Unknown = 201; + /** native declaration : headers\openvr_capi.h:816 */ + public static final int EVRInitError_VRInitError_Driver_HmdUnknown = 202; + /** native declaration : headers\openvr_capi.h:817 */ + public static final int EVRInitError_VRInitError_Driver_NotLoaded = 203; + /** native declaration : headers\openvr_capi.h:818 */ + public static final int EVRInitError_VRInitError_Driver_RuntimeOutOfDate = 204; + /** native declaration : headers\openvr_capi.h:819 */ + public static final int EVRInitError_VRInitError_Driver_HmdInUse = 205; + /** native declaration : headers\openvr_capi.h:820 */ + public static final int EVRInitError_VRInitError_Driver_NotCalibrated = 206; + /** native declaration : headers\openvr_capi.h:821 */ + public static final int EVRInitError_VRInitError_Driver_CalibrationInvalid = 207; + /** native declaration : headers\openvr_capi.h:822 */ + public static final int EVRInitError_VRInitError_Driver_HmdDisplayNotFound = 208; + /** native declaration : headers\openvr_capi.h:823 */ + public static final int EVRInitError_VRInitError_Driver_TrackedDeviceInterfaceUnknown = 209; + /** native declaration : headers\openvr_capi.h:824 */ + public static final int EVRInitError_VRInitError_Driver_HmdDriverIdOutOfBounds = 211; + /** native declaration : headers\openvr_capi.h:825 */ + public static final int EVRInitError_VRInitError_Driver_HmdDisplayMirrored = 212; + /** native declaration : headers\openvr_capi.h:826 */ + public static final int EVRInitError_VRInitError_IPC_ServerInitFailed = 300; + /** native declaration : headers\openvr_capi.h:827 */ + public static final int EVRInitError_VRInitError_IPC_ConnectFailed = 301; + /** native declaration : headers\openvr_capi.h:828 */ + public static final int EVRInitError_VRInitError_IPC_SharedStateInitFailed = 302; + /** native declaration : headers\openvr_capi.h:829 */ + public static final int EVRInitError_VRInitError_IPC_CompositorInitFailed = 303; + /** native declaration : headers\openvr_capi.h:830 */ + public static final int EVRInitError_VRInitError_IPC_MutexInitFailed = 304; + /** native declaration : headers\openvr_capi.h:831 */ + public static final int EVRInitError_VRInitError_IPC_Failed = 305; + /** native declaration : headers\openvr_capi.h:832 */ + public static final int EVRInitError_VRInitError_IPC_CompositorConnectFailed = 306; + /** native declaration : headers\openvr_capi.h:833 */ + public static final int EVRInitError_VRInitError_IPC_CompositorInvalidConnectResponse = 307; + /** native declaration : headers\openvr_capi.h:834 */ + public static final int EVRInitError_VRInitError_IPC_ConnectFailedAfterMultipleAttempts = 308; + /** native declaration : headers\openvr_capi.h:835 */ + public static final int EVRInitError_VRInitError_Compositor_Failed = 400; + /** native declaration : headers\openvr_capi.h:836 */ + public static final int EVRInitError_VRInitError_Compositor_D3D11HardwareRequired = 401; + /** native declaration : headers\openvr_capi.h:837 */ + public static final int EVRInitError_VRInitError_Compositor_FirmwareRequiresUpdate = 402; + /** native declaration : headers\openvr_capi.h:838 */ + public static final int EVRInitError_VRInitError_Compositor_OverlayInitFailed = 403; + /** native declaration : headers\openvr_capi.h:839 */ + public static final int EVRInitError_VRInitError_Compositor_ScreenshotsInitFailed = 404; + /** native declaration : headers\openvr_capi.h:840 */ + public static final int EVRInitError_VRInitError_Compositor_UnableToCreateDevice = 405; + /** native declaration : headers\openvr_capi.h:841 */ + public static final int EVRInitError_VRInitError_VendorSpecific_UnableToConnectToOculusRuntime = 1000; + /** native declaration : headers\openvr_capi.h:842 */ + public static final int EVRInitError_VRInitError_VendorSpecific_WindowsNotInDevMode = 1001; + /** native declaration : headers\openvr_capi.h:843 */ + public static final int EVRInitError_VRInitError_VendorSpecific_HmdFound_CantOpenDevice = 1101; + /** native declaration : headers\openvr_capi.h:844 */ + public static final int EVRInitError_VRInitError_VendorSpecific_HmdFound_UnableToRequestConfigStart = 1102; + /** native declaration : headers\openvr_capi.h:845 */ + public static final int EVRInitError_VRInitError_VendorSpecific_HmdFound_NoStoredConfig = 1103; + /** native declaration : headers\openvr_capi.h:846 */ + public static final int EVRInitError_VRInitError_VendorSpecific_HmdFound_ConfigTooBig = 1104; + /** native declaration : headers\openvr_capi.h:847 */ + public static final int EVRInitError_VRInitError_VendorSpecific_HmdFound_ConfigTooSmall = 1105; + /** native declaration : headers\openvr_capi.h:848 */ + public static final int EVRInitError_VRInitError_VendorSpecific_HmdFound_UnableToInitZLib = 1106; + /** native declaration : headers\openvr_capi.h:849 */ + public static final int EVRInitError_VRInitError_VendorSpecific_HmdFound_CantReadFirmwareVersion = 1107; + /** native declaration : headers\openvr_capi.h:850 */ + public static final int EVRInitError_VRInitError_VendorSpecific_HmdFound_UnableToSendUserDataStart = 1108; + /** native declaration : headers\openvr_capi.h:851 */ + public static final int EVRInitError_VRInitError_VendorSpecific_HmdFound_UnableToGetUserDataStart = 1109; + /** native declaration : headers\openvr_capi.h:852 */ + public static final int EVRInitError_VRInitError_VendorSpecific_HmdFound_UnableToGetUserDataNext = 1110; + /** native declaration : headers\openvr_capi.h:853 */ + public static final int EVRInitError_VRInitError_VendorSpecific_HmdFound_UserDataAddressRange = 1111; + /** native declaration : headers\openvr_capi.h:854 */ + public static final int EVRInitError_VRInitError_VendorSpecific_HmdFound_UserDataError = 1112; + /** native declaration : headers\openvr_capi.h:855 */ + public static final int EVRInitError_VRInitError_VendorSpecific_HmdFound_ConfigFailedSanityCheck = 1113; + /** native declaration : headers\openvr_capi.h:856 */ + public static final int EVRInitError_VRInitError_Steam_SteamInstallationNotFound = 2000; + }; + /** + * native declaration : headers\openvr_capi.h:865
+ * enum values + */ + public static interface EVRScreenshotType { + /** native declaration : headers\openvr_capi.h:859 */ + public static final int EVRScreenshotType_VRScreenshotType_None = 0; + /** native declaration : headers\openvr_capi.h:860 */ + public static final int EVRScreenshotType_VRScreenshotType_Mono = 1; + /** native declaration : headers\openvr_capi.h:861 */ + public static final int EVRScreenshotType_VRScreenshotType_Stereo = 2; + /** native declaration : headers\openvr_capi.h:862 */ + public static final int EVRScreenshotType_VRScreenshotType_Cubemap = 3; + /** native declaration : headers\openvr_capi.h:863 */ + public static final int EVRScreenshotType_VRScreenshotType_MonoPanorama = 4; + /** native declaration : headers\openvr_capi.h:864 */ + public static final int EVRScreenshotType_VRScreenshotType_StereoPanorama = 5; + }; + /** + * native declaration : headers\openvr_capi.h:869
+ * enum values + */ + public static interface EVRScreenshotPropertyFilenames { + /** native declaration : headers\openvr_capi.h:867 */ + public static final int EVRScreenshotPropertyFilenames_VRScreenshotPropertyFilenames_Preview = 0; + /** native declaration : headers\openvr_capi.h:868 */ + public static final int EVRScreenshotPropertyFilenames_VRScreenshotPropertyFilenames_VR = 1; + }; + /** + * native declaration : headers\openvr_capi.h:888
+ * enum values + */ + public static interface EVRTrackedCameraError { + /** native declaration : headers\openvr_capi.h:871 */ + public static final int EVRTrackedCameraError_VRTrackedCameraError_None = 0; + /** native declaration : headers\openvr_capi.h:872 */ + public static final int EVRTrackedCameraError_VRTrackedCameraError_OperationFailed = 100; + /** native declaration : headers\openvr_capi.h:873 */ + public static final int EVRTrackedCameraError_VRTrackedCameraError_InvalidHandle = 101; + /** native declaration : headers\openvr_capi.h:874 */ + public static final int EVRTrackedCameraError_VRTrackedCameraError_InvalidFrameHeaderVersion = 102; + /** native declaration : headers\openvr_capi.h:875 */ + public static final int EVRTrackedCameraError_VRTrackedCameraError_OutOfHandles = 103; + /** native declaration : headers\openvr_capi.h:876 */ + public static final int EVRTrackedCameraError_VRTrackedCameraError_IPCFailure = 104; + /** native declaration : headers\openvr_capi.h:877 */ + public static final int EVRTrackedCameraError_VRTrackedCameraError_NotSupportedForThisDevice = 105; + /** native declaration : headers\openvr_capi.h:878 */ + public static final int EVRTrackedCameraError_VRTrackedCameraError_SharedMemoryFailure = 106; + /** native declaration : headers\openvr_capi.h:879 */ + public static final int EVRTrackedCameraError_VRTrackedCameraError_FrameBufferingFailure = 107; + /** native declaration : headers\openvr_capi.h:880 */ + public static final int EVRTrackedCameraError_VRTrackedCameraError_StreamSetupFailure = 108; + /** native declaration : headers\openvr_capi.h:881 */ + public static final int EVRTrackedCameraError_VRTrackedCameraError_InvalidGLTextureId = 109; + /** native declaration : headers\openvr_capi.h:882 */ + public static final int EVRTrackedCameraError_VRTrackedCameraError_InvalidSharedTextureHandle = 110; + /** native declaration : headers\openvr_capi.h:883 */ + public static final int EVRTrackedCameraError_VRTrackedCameraError_FailedToGetGLTextureId = 111; + /** native declaration : headers\openvr_capi.h:884 */ + public static final int EVRTrackedCameraError_VRTrackedCameraError_SharedTextureFailure = 112; + /** native declaration : headers\openvr_capi.h:885 */ + public static final int EVRTrackedCameraError_VRTrackedCameraError_NoFrameAvailable = 113; + /** native declaration : headers\openvr_capi.h:886 */ + public static final int EVRTrackedCameraError_VRTrackedCameraError_InvalidArgument = 114; + /** native declaration : headers\openvr_capi.h:887 */ + public static final int EVRTrackedCameraError_VRTrackedCameraError_InvalidFrameBufferSize = 115; + }; + /** + * native declaration : headers\openvr_capi.h:894
+ * enum values + */ + public static interface EVRTrackedCameraFrameLayout { + /** native declaration : headers\openvr_capi.h:890 */ + public static final int EVRTrackedCameraFrameLayout_Mono = 1; + /** native declaration : headers\openvr_capi.h:891 */ + public static final int EVRTrackedCameraFrameLayout_Stereo = 2; + /** native declaration : headers\openvr_capi.h:892 */ + public static final int EVRTrackedCameraFrameLayout_VerticalLayout = 16; + /** native declaration : headers\openvr_capi.h:893 */ + public static final int EVRTrackedCameraFrameLayout_HorizontalLayout = 32; + }; + /** + * native declaration : headers\openvr_capi.h:900
+ * enum values + */ + public static interface EVRTrackedCameraFrameType { + /** native declaration : headers\openvr_capi.h:896 */ + public static final int EVRTrackedCameraFrameType_VRTrackedCameraFrameType_Distorted = 0; + /** native declaration : headers\openvr_capi.h:897 */ + public static final int EVRTrackedCameraFrameType_VRTrackedCameraFrameType_Undistorted = 1; + /** native declaration : headers\openvr_capi.h:898 */ + public static final int EVRTrackedCameraFrameType_VRTrackedCameraFrameType_MaximumUndistorted = 2; + /** native declaration : headers\openvr_capi.h:899 */ + public static final int EVRTrackedCameraFrameType_MAX_CAMERA_FRAME_TYPES = 3; + }; + /** + * native declaration : headers\openvr_capi.h:905
+ * enum values + */ + public static interface EVSync { + /** native declaration : headers\openvr_capi.h:902 */ + public static final int EVSync_VSync_None = 0; + /** native declaration : headers\openvr_capi.h:903 */ + public static final int EVSync_VSync_WaitRender = 1; + /** native declaration : headers\openvr_capi.h:904 */ + public static final int EVSync_VSync_NoWaitRender = 2; + }; + /** + * native declaration : headers\openvr_capi.h:909
+ * enum values + */ + public static interface EVRMuraCorrectionMode { + /** native declaration : headers\openvr_capi.h:907 */ + public static final int EVRMuraCorrectionMode_Default = 0; + /** native declaration : headers\openvr_capi.h:908 */ + public static final int EVRMuraCorrectionMode_NoCorrection = 1; + }; + /** + * native declaration : headers\openvr_capi.h:917
+ * enum values + */ + public static interface Imu_OffScaleFlags { + /** native declaration : headers\openvr_capi.h:911 */ + public static final int Imu_OffScaleFlags_OffScale_AccelX = 1; + /** native declaration : headers\openvr_capi.h:912 */ + public static final int Imu_OffScaleFlags_OffScale_AccelY = 2; + /** native declaration : headers\openvr_capi.h:913 */ + public static final int Imu_OffScaleFlags_OffScale_AccelZ = 4; + /** native declaration : headers\openvr_capi.h:914 */ + public static final int Imu_OffScaleFlags_OffScale_GyroX = 8; + /** native declaration : headers\openvr_capi.h:915 */ + public static final int Imu_OffScaleFlags_OffScale_GyroY = 16; + /** native declaration : headers\openvr_capi.h:916 */ + public static final int Imu_OffScaleFlags_OffScale_GyroZ = 32; + }; + /** + * native declaration : headers\openvr_capi.h:940
+ * enum values + */ + public static interface EVRApplicationError { + /** native declaration : headers\openvr_capi.h:919 */ + public static final int EVRApplicationError_VRApplicationError_None = 0; + /** native declaration : headers\openvr_capi.h:920 */ + public static final int EVRApplicationError_VRApplicationError_AppKeyAlreadyExists = 100; + /** native declaration : headers\openvr_capi.h:921 */ + public static final int EVRApplicationError_VRApplicationError_NoManifest = 101; + /** native declaration : headers\openvr_capi.h:922 */ + public static final int EVRApplicationError_VRApplicationError_NoApplication = 102; + /** native declaration : headers\openvr_capi.h:923 */ + public static final int EVRApplicationError_VRApplicationError_InvalidIndex = 103; + /** native declaration : headers\openvr_capi.h:924 */ + public static final int EVRApplicationError_VRApplicationError_UnknownApplication = 104; + /** native declaration : headers\openvr_capi.h:925 */ + public static final int EVRApplicationError_VRApplicationError_IPCFailed = 105; + /** native declaration : headers\openvr_capi.h:926 */ + public static final int EVRApplicationError_VRApplicationError_ApplicationAlreadyRunning = 106; + /** native declaration : headers\openvr_capi.h:927 */ + public static final int EVRApplicationError_VRApplicationError_InvalidManifest = 107; + /** native declaration : headers\openvr_capi.h:928 */ + public static final int EVRApplicationError_VRApplicationError_InvalidApplication = 108; + /** native declaration : headers\openvr_capi.h:929 */ + public static final int EVRApplicationError_VRApplicationError_LaunchFailed = 109; + /** native declaration : headers\openvr_capi.h:930 */ + public static final int EVRApplicationError_VRApplicationError_ApplicationAlreadyStarting = 110; + /** native declaration : headers\openvr_capi.h:931 */ + public static final int EVRApplicationError_VRApplicationError_LaunchInProgress = 111; + /** native declaration : headers\openvr_capi.h:932 */ + public static final int EVRApplicationError_VRApplicationError_OldApplicationQuitting = 112; + /** native declaration : headers\openvr_capi.h:933 */ + public static final int EVRApplicationError_VRApplicationError_TransitionAborted = 113; + /** native declaration : headers\openvr_capi.h:934 */ + public static final int EVRApplicationError_VRApplicationError_IsTemplate = 114; + /** native declaration : headers\openvr_capi.h:935 */ + public static final int EVRApplicationError_VRApplicationError_SteamVRIsExiting = 115; + /** native declaration : headers\openvr_capi.h:936 */ + public static final int EVRApplicationError_VRApplicationError_BufferTooSmall = 200; + /** native declaration : headers\openvr_capi.h:937 */ + public static final int EVRApplicationError_VRApplicationError_PropertyNotSet = 201; + /** native declaration : headers\openvr_capi.h:938 */ + public static final int EVRApplicationError_VRApplicationError_UnknownProperty = 202; + /** native declaration : headers\openvr_capi.h:939 */ + public static final int EVRApplicationError_VRApplicationError_InvalidParameter = 203; + }; + /** + * native declaration : headers\openvr_capi.h:959
+ * enum values + */ + public static interface EVRApplicationProperty { + /** native declaration : headers\openvr_capi.h:942 */ + public static final int EVRApplicationProperty_VRApplicationProperty_Name_String = 0; + /** native declaration : headers\openvr_capi.h:943 */ + public static final int EVRApplicationProperty_VRApplicationProperty_LaunchType_String = 11; + /** native declaration : headers\openvr_capi.h:944 */ + public static final int EVRApplicationProperty_VRApplicationProperty_WorkingDirectory_String = 12; + /** native declaration : headers\openvr_capi.h:945 */ + public static final int EVRApplicationProperty_VRApplicationProperty_BinaryPath_String = 13; + /** native declaration : headers\openvr_capi.h:946 */ + public static final int EVRApplicationProperty_VRApplicationProperty_Arguments_String = 14; + /** native declaration : headers\openvr_capi.h:947 */ + public static final int EVRApplicationProperty_VRApplicationProperty_URL_String = 15; + /** native declaration : headers\openvr_capi.h:948 */ + public static final int EVRApplicationProperty_VRApplicationProperty_Description_String = 50; + /** native declaration : headers\openvr_capi.h:949 */ + public static final int EVRApplicationProperty_VRApplicationProperty_NewsURL_String = 51; + /** native declaration : headers\openvr_capi.h:950 */ + public static final int EVRApplicationProperty_VRApplicationProperty_ImagePath_String = 52; + /** native declaration : headers\openvr_capi.h:951 */ + public static final int EVRApplicationProperty_VRApplicationProperty_Source_String = 53; + /** native declaration : headers\openvr_capi.h:952 */ + public static final int EVRApplicationProperty_VRApplicationProperty_ActionManifestURL_String = 54; + /** native declaration : headers\openvr_capi.h:953 */ + public static final int EVRApplicationProperty_VRApplicationProperty_IsDashboardOverlay_Bool = 60; + /** native declaration : headers\openvr_capi.h:954 */ + public static final int EVRApplicationProperty_VRApplicationProperty_IsTemplate_Bool = 61; + /** native declaration : headers\openvr_capi.h:955 */ + public static final int EVRApplicationProperty_VRApplicationProperty_IsInstanced_Bool = 62; + /** native declaration : headers\openvr_capi.h:956 */ + public static final int EVRApplicationProperty_VRApplicationProperty_IsInternal_Bool = 63; + /** native declaration : headers\openvr_capi.h:957 */ + public static final int EVRApplicationProperty_VRApplicationProperty_WantsCompositorPauseInStandby_Bool = 64; + /** native declaration : headers\openvr_capi.h:958 */ + public static final int EVRApplicationProperty_VRApplicationProperty_LastLaunchTime_Uint64 = 70; + }; + /** + * native declaration : headers\openvr_capi.h:965
+ * enum values + */ + public static interface EVRApplicationTransitionState { + /** native declaration : headers\openvr_capi.h:961 */ + public static final int EVRApplicationTransitionState_VRApplicationTransition_None = 0; + /** native declaration : headers\openvr_capi.h:962 */ + public static final int EVRApplicationTransitionState_VRApplicationTransition_OldAppQuitSent = 10; + /** native declaration : headers\openvr_capi.h:963 */ + public static final int EVRApplicationTransitionState_VRApplicationTransition_WaitingForExternalLaunch = 11; + /** native declaration : headers\openvr_capi.h:964 */ + public static final int EVRApplicationTransitionState_VRApplicationTransition_NewAppLaunched = 20; + }; + /** + * native declaration : headers\openvr_capi.h:977
+ * enum values + */ + public static interface ChaperoneCalibrationState { + /** native declaration : headers\openvr_capi.h:967 */ + public static final int ChaperoneCalibrationState_OK = 1; + /** native declaration : headers\openvr_capi.h:968 */ + public static final int ChaperoneCalibrationState_Warning = 100; + /** native declaration : headers\openvr_capi.h:969 */ + public static final int ChaperoneCalibrationState_Warning_BaseStationMayHaveMoved = 101; + /** native declaration : headers\openvr_capi.h:970 */ + public static final int ChaperoneCalibrationState_Warning_BaseStationRemoved = 102; + /** native declaration : headers\openvr_capi.h:971 */ + public static final int ChaperoneCalibrationState_Warning_SeatedBoundsInvalid = 103; + /** native declaration : headers\openvr_capi.h:972 */ + public static final int ChaperoneCalibrationState_Error = 200; + /** native declaration : headers\openvr_capi.h:973 */ + public static final int ChaperoneCalibrationState_Error_BaseStationUninitialized = 201; + /** native declaration : headers\openvr_capi.h:974 */ + public static final int ChaperoneCalibrationState_Error_BaseStationConflict = 202; + /** native declaration : headers\openvr_capi.h:975 */ + public static final int ChaperoneCalibrationState_Error_PlayAreaInvalid = 203; + /** native declaration : headers\openvr_capi.h:976 */ + public static final int ChaperoneCalibrationState_Error_CollisionBoundsInvalid = 204; + }; + /** + * native declaration : headers\openvr_capi.h:981
+ * enum values + */ + public static interface EChaperoneConfigFile { + /** native declaration : headers\openvr_capi.h:979 */ + public static final int EChaperoneConfigFile_Live = 1; + /** native declaration : headers\openvr_capi.h:980 */ + public static final int EChaperoneConfigFile_Temp = 2; + }; + /** + * native declaration : headers\openvr_capi.h:984
+ * enum values + */ + public static interface EChaperoneImportFlags { + /** native declaration : headers\openvr_capi.h:983 */ + public static final int EChaperoneImportFlags_EChaperoneImport_BoundsOnly = 1; + }; + /** + * native declaration : headers\openvr_capi.h:998
+ * enum values + */ + public static interface EVRCompositorError { + /** native declaration : headers\openvr_capi.h:986 */ + public static final int EVRCompositorError_VRCompositorError_None = 0; + /** native declaration : headers\openvr_capi.h:987 */ + public static final int EVRCompositorError_VRCompositorError_RequestFailed = 1; + /** native declaration : headers\openvr_capi.h:988 */ + public static final int EVRCompositorError_VRCompositorError_IncompatibleVersion = 100; + /** native declaration : headers\openvr_capi.h:989 */ + public static final int EVRCompositorError_VRCompositorError_DoNotHaveFocus = 101; + /** native declaration : headers\openvr_capi.h:990 */ + public static final int EVRCompositorError_VRCompositorError_InvalidTexture = 102; + /** native declaration : headers\openvr_capi.h:991 */ + public static final int EVRCompositorError_VRCompositorError_IsNotSceneApplication = 103; + /** native declaration : headers\openvr_capi.h:992 */ + public static final int EVRCompositorError_VRCompositorError_TextureIsOnWrongDevice = 104; + /** native declaration : headers\openvr_capi.h:993 */ + public static final int EVRCompositorError_VRCompositorError_TextureUsesUnsupportedFormat = 105; + /** native declaration : headers\openvr_capi.h:994 */ + public static final int EVRCompositorError_VRCompositorError_SharedTexturesNotSupported = 106; + /** native declaration : headers\openvr_capi.h:995 */ + public static final int EVRCompositorError_VRCompositorError_IndexOutOfRange = 107; + /** native declaration : headers\openvr_capi.h:996 */ + public static final int EVRCompositorError_VRCompositorError_AlreadySubmitted = 108; + /** native declaration : headers\openvr_capi.h:997 */ + public static final int EVRCompositorError_VRCompositorError_InvalidBounds = 109; + }; + /** + * native declaration : headers\openvr_capi.h:1003
+ * enum values + */ + public static interface EVRCompositorTimingMode { + /** native declaration : headers\openvr_capi.h:1000 */ + public static final int EVRCompositorTimingMode_VRCompositorTimingMode_Implicit = 0; + /** native declaration : headers\openvr_capi.h:1001 */ + public static final int EVRCompositorTimingMode_VRCompositorTimingMode_Explicit_RuntimePerformsPostPresentHandoff = 1; + /** native declaration : headers\openvr_capi.h:1002 */ + public static final int EVRCompositorTimingMode_VRCompositorTimingMode_Explicit_ApplicationPerformsPostPresentHandoff = 2; + }; + /** + * native declaration : headers\openvr_capi.h:1008
+ * enum values + */ + public static interface VROverlayInputMethod { + /** native declaration : headers\openvr_capi.h:1005 */ + public static final int VROverlayInputMethod_None = 0; + /** native declaration : headers\openvr_capi.h:1006 */ + public static final int VROverlayInputMethod_Mouse = 1; + /** native declaration : headers\openvr_capi.h:1007 */ + public static final int VROverlayInputMethod_DualAnalog = 2; + }; + /** + * native declaration : headers\openvr_capi.h:1014
+ * enum values + */ + public static interface VROverlayTransformType { + /** native declaration : headers\openvr_capi.h:1010 */ + public static final int VROverlayTransformType_VROverlayTransform_Absolute = 0; + /** native declaration : headers\openvr_capi.h:1011 */ + public static final int VROverlayTransformType_VROverlayTransform_TrackedDeviceRelative = 1; + /** native declaration : headers\openvr_capi.h:1012 */ + public static final int VROverlayTransformType_VROverlayTransform_SystemOverlay = 2; + /** native declaration : headers\openvr_capi.h:1013 */ + public static final int VROverlayTransformType_VROverlayTransform_TrackedComponent = 3; + }; + /** + * native declaration : headers\openvr_capi.h:1032
+ * enum values + */ + public static interface VROverlayFlags { + /** native declaration : headers\openvr_capi.h:1016 */ + public static final int VROverlayFlags_None = 0; + /** native declaration : headers\openvr_capi.h:1017 */ + public static final int VROverlayFlags_Curved = 1; + /** native declaration : headers\openvr_capi.h:1018 */ + public static final int VROverlayFlags_RGSS4X = 2; + /** native declaration : headers\openvr_capi.h:1019 */ + public static final int VROverlayFlags_NoDashboardTab = 3; + /** native declaration : headers\openvr_capi.h:1020 */ + public static final int VROverlayFlags_AcceptsGamepadEvents = 4; + /** native declaration : headers\openvr_capi.h:1021 */ + public static final int VROverlayFlags_ShowGamepadFocus = 5; + /** native declaration : headers\openvr_capi.h:1022 */ + public static final int VROverlayFlags_SendVRScrollEvents = 6; + /** native declaration : headers\openvr_capi.h:1023 */ + public static final int VROverlayFlags_SendVRTouchpadEvents = 7; + /** native declaration : headers\openvr_capi.h:1024 */ + public static final int VROverlayFlags_ShowTouchPadScrollWheel = 8; + /** native declaration : headers\openvr_capi.h:1025 */ + public static final int VROverlayFlags_TransferOwnershipToInternalProcess = 9; + /** native declaration : headers\openvr_capi.h:1026 */ + public static final int VROverlayFlags_SideBySide_Parallel = 10; + /** native declaration : headers\openvr_capi.h:1027 */ + public static final int VROverlayFlags_SideBySide_Crossed = 11; + /** native declaration : headers\openvr_capi.h:1028 */ + public static final int VROverlayFlags_Panorama = 12; + /** native declaration : headers\openvr_capi.h:1029 */ + public static final int VROverlayFlags_StereoPanorama = 13; + /** native declaration : headers\openvr_capi.h:1030 */ + public static final int VROverlayFlags_SortWithNonSceneOverlays = 14; + /** native declaration : headers\openvr_capi.h:1031 */ + public static final int VROverlayFlags_VisibleInDashboard = 15; + }; + /** + * native declaration : headers\openvr_capi.h:1041
+ * enum values + */ + public static interface VRMessageOverlayResponse { + /** native declaration : headers\openvr_capi.h:1034 */ + public static final int VRMessageOverlayResponse_ButtonPress_0 = 0; + /** native declaration : headers\openvr_capi.h:1035 */ + public static final int VRMessageOverlayResponse_ButtonPress_1 = 1; + /** native declaration : headers\openvr_capi.h:1036 */ + public static final int VRMessageOverlayResponse_ButtonPress_2 = 2; + /** native declaration : headers\openvr_capi.h:1037 */ + public static final int VRMessageOverlayResponse_ButtonPress_3 = 3; + /** native declaration : headers\openvr_capi.h:1038 */ + public static final int VRMessageOverlayResponse_CouldntFindSystemOverlay = 4; + /** native declaration : headers\openvr_capi.h:1039 */ + public static final int VRMessageOverlayResponse_CouldntFindOrCreateClientOverlay = 5; + /** native declaration : headers\openvr_capi.h:1040 */ + public static final int VRMessageOverlayResponse_ApplicationQuit = 6; + }; + /** + * native declaration : headers\openvr_capi.h:1046
+ * enum values + */ + public static interface EGamepadTextInputMode { + /** native declaration : headers\openvr_capi.h:1043 */ + public static final int EGamepadTextInputMode_k_EGamepadTextInputModeNormal = 0; + /** native declaration : headers\openvr_capi.h:1044 */ + public static final int EGamepadTextInputMode_k_EGamepadTextInputModePassword = 1; + /** native declaration : headers\openvr_capi.h:1045 */ + public static final int EGamepadTextInputMode_k_EGamepadTextInputModeSubmit = 2; + }; + /** + * native declaration : headers\openvr_capi.h:1050
+ * enum values + */ + public static interface EGamepadTextInputLineMode { + /** native declaration : headers\openvr_capi.h:1048 */ + public static final int EGamepadTextInputLineMode_k_EGamepadTextInputLineModeSingleLine = 0; + /** native declaration : headers\openvr_capi.h:1049 */ + public static final int EGamepadTextInputLineMode_k_EGamepadTextInputLineModeMultipleLines = 1; + }; + /** + * native declaration : headers\openvr_capi.h:1057
+ * enum values + */ + public static interface EOverlayDirection { + /** native declaration : headers\openvr_capi.h:1052 */ + public static final int EOverlayDirection_OverlayDirection_Up = 0; + /** native declaration : headers\openvr_capi.h:1053 */ + public static final int EOverlayDirection_OverlayDirection_Down = 1; + /** native declaration : headers\openvr_capi.h:1054 */ + public static final int EOverlayDirection_OverlayDirection_Left = 2; + /** native declaration : headers\openvr_capi.h:1055 */ + public static final int EOverlayDirection_OverlayDirection_Right = 3; + /** native declaration : headers\openvr_capi.h:1056 */ + public static final int EOverlayDirection_OverlayDirection_Count = 4; + }; + /** + * native declaration : headers\openvr_capi.h:1061
+ * enum values + */ + public static interface EVROverlayIntersectionMaskPrimitiveType { + /** native declaration : headers\openvr_capi.h:1059 */ + public static final int EVROverlayIntersectionMaskPrimitiveType_OverlayIntersectionPrimitiveType_Rectangle = 0; + /** native declaration : headers\openvr_capi.h:1060 */ + public static final int EVROverlayIntersectionMaskPrimitiveType_OverlayIntersectionPrimitiveType_Circle = 1; + }; + /** + * native declaration : headers\openvr_capi.h:1076
+ * enum values + */ + public static interface EVRRenderModelError { + /** native declaration : headers\openvr_capi.h:1063 */ + public static final int EVRRenderModelError_VRRenderModelError_None = 0; + /** native declaration : headers\openvr_capi.h:1064 */ + public static final int EVRRenderModelError_VRRenderModelError_Loading = 100; + /** native declaration : headers\openvr_capi.h:1065 */ + public static final int EVRRenderModelError_VRRenderModelError_NotSupported = 200; + /** native declaration : headers\openvr_capi.h:1066 */ + public static final int EVRRenderModelError_VRRenderModelError_InvalidArg = 300; + /** native declaration : headers\openvr_capi.h:1067 */ + public static final int EVRRenderModelError_VRRenderModelError_InvalidModel = 301; + /** native declaration : headers\openvr_capi.h:1068 */ + public static final int EVRRenderModelError_VRRenderModelError_NoShapes = 302; + /** native declaration : headers\openvr_capi.h:1069 */ + public static final int EVRRenderModelError_VRRenderModelError_MultipleShapes = 303; + /** native declaration : headers\openvr_capi.h:1070 */ + public static final int EVRRenderModelError_VRRenderModelError_TooManyVertices = 304; + /** native declaration : headers\openvr_capi.h:1071 */ + public static final int EVRRenderModelError_VRRenderModelError_MultipleTextures = 305; + /** native declaration : headers\openvr_capi.h:1072 */ + public static final int EVRRenderModelError_VRRenderModelError_BufferTooSmall = 306; + /** native declaration : headers\openvr_capi.h:1073 */ + public static final int EVRRenderModelError_VRRenderModelError_NotEnoughNormals = 307; + /** native declaration : headers\openvr_capi.h:1074 */ + public static final int EVRRenderModelError_VRRenderModelError_NotEnoughTexCoords = 308; + /** native declaration : headers\openvr_capi.h:1075 */ + public static final int EVRRenderModelError_VRRenderModelError_InvalidTexture = 400; + }; + /** + * native declaration : headers\openvr_capi.h:1083
+ * enum values + */ + public static interface EVRComponentProperty { + /** native declaration : headers\openvr_capi.h:1078 */ + public static final int EVRComponentProperty_VRComponentProperty_IsStatic = 1; + /** native declaration : headers\openvr_capi.h:1079 */ + public static final int EVRComponentProperty_VRComponentProperty_IsVisible = 2; + /** native declaration : headers\openvr_capi.h:1080 */ + public static final int EVRComponentProperty_VRComponentProperty_IsTouched = 4; + /** native declaration : headers\openvr_capi.h:1081 */ + public static final int EVRComponentProperty_VRComponentProperty_IsPressed = 8; + /** native declaration : headers\openvr_capi.h:1082 */ + public static final int EVRComponentProperty_VRComponentProperty_IsScrolled = 16; + }; + /** + * native declaration : headers\openvr_capi.h:1088
+ * enum values + */ + public static interface EVRNotificationType { + /** native declaration : headers\openvr_capi.h:1085 */ + public static final int EVRNotificationType_Transient = 0; + /** native declaration : headers\openvr_capi.h:1086 */ + public static final int EVRNotificationType_Persistent = 1; + /** native declaration : headers\openvr_capi.h:1087 */ + public static final int EVRNotificationType_Transient_SystemWithUserValue = 2; + }; + /** + * native declaration : headers\openvr_capi.h:1095
+ * enum values + */ + public static interface EVRNotificationStyle { + /** native declaration : headers\openvr_capi.h:1090 */ + public static final int EVRNotificationStyle_None = 0; + /** native declaration : headers\openvr_capi.h:1091 */ + public static final int EVRNotificationStyle_Application = 100; + /** native declaration : headers\openvr_capi.h:1092 */ + public static final int EVRNotificationStyle_Contact_Disabled = 200; + /** native declaration : headers\openvr_capi.h:1093 */ + public static final int EVRNotificationStyle_Contact_Enabled = 201; + /** native declaration : headers\openvr_capi.h:1094 */ + public static final int EVRNotificationStyle_Contact_Active = 202; + }; + /** + * native declaration : headers\openvr_capi.h:1103
+ * enum values + */ + public static interface EVRSettingsError { + /** native declaration : headers\openvr_capi.h:1097 */ + public static final int EVRSettingsError_VRSettingsError_None = 0; + /** native declaration : headers\openvr_capi.h:1098 */ + public static final int EVRSettingsError_VRSettingsError_IPCFailed = 1; + /** native declaration : headers\openvr_capi.h:1099 */ + public static final int EVRSettingsError_VRSettingsError_WriteFailed = 2; + /** native declaration : headers\openvr_capi.h:1100 */ + public static final int EVRSettingsError_VRSettingsError_ReadFailed = 3; + /** native declaration : headers\openvr_capi.h:1101 */ + public static final int EVRSettingsError_VRSettingsError_JsonParseFailed = 4; + /** native declaration : headers\openvr_capi.h:1102 */ + public static final int EVRSettingsError_VRSettingsError_UnsetSettingHasNoDefault = 5; + }; + /** + * native declaration : headers\openvr_capi.h:1111
+ * enum values + */ + public static interface EVRScreenshotError { + /** native declaration : headers\openvr_capi.h:1105 */ + public static final int EVRScreenshotError_VRScreenshotError_None = 0; + /** native declaration : headers\openvr_capi.h:1106 */ + public static final int EVRScreenshotError_VRScreenshotError_RequestFailed = 1; + /** native declaration : headers\openvr_capi.h:1107 */ + public static final int EVRScreenshotError_VRScreenshotError_IncompatibleVersion = 100; + /** native declaration : headers\openvr_capi.h:1108 */ + public static final int EVRScreenshotError_VRScreenshotError_NotFound = 101; + /** native declaration : headers\openvr_capi.h:1109 */ + public static final int EVRScreenshotError_VRScreenshotError_BufferTooSmall = 102; + /** native declaration : headers\openvr_capi.h:1110 */ + public static final int EVRScreenshotError_VRScreenshotError_ScreenshotAlreadyInProgress = 108; + }; + /** + * native declaration : headers\openvr_capi.h:1116
+ * enum values + */ + public static interface EVRSkeletalTransformSpace { + /** native declaration : headers\openvr_capi.h:1113 */ + public static final int EVRSkeletalTransformSpace_VRSkeletalTransformSpace_Model = 0; + /** native declaration : headers\openvr_capi.h:1114 */ + public static final int EVRSkeletalTransformSpace_VRSkeletalTransformSpace_Parent = 1; + /** native declaration : headers\openvr_capi.h:1115 */ + public static final int EVRSkeletalTransformSpace_VRSkeletalTransformSpace_Additive = 2; + }; + /** + * native declaration : headers\openvr_capi.h:1120
+ * enum values + */ + public static interface EVRInputFilterCancelType { + /** native declaration : headers\openvr_capi.h:1118 */ + public static final int EVRInputFilterCancelType_VRInputFilterCancel_Timers = 0; + /** native declaration : headers\openvr_capi.h:1119 */ + public static final int EVRInputFilterCancelType_VRInputFilterCancel_Momentum = 1; + }; + /** + * native declaration : headers\openvr_capi.h:1129
+ * enum values + */ + public static interface EIOBufferError { + /** native declaration : headers\openvr_capi.h:1122 */ + public static final int EIOBufferError_IOBuffer_Success = 0; + /** native declaration : headers\openvr_capi.h:1123 */ + public static final int EIOBufferError_IOBuffer_OperationFailed = 100; + /** native declaration : headers\openvr_capi.h:1124 */ + public static final int EIOBufferError_IOBuffer_InvalidHandle = 101; + /** native declaration : headers\openvr_capi.h:1125 */ + public static final int EIOBufferError_IOBuffer_InvalidArgument = 102; + /** native declaration : headers\openvr_capi.h:1126 */ + public static final int EIOBufferError_IOBuffer_PathExists = 103; + /** native declaration : headers\openvr_capi.h:1127 */ + public static final int EIOBufferError_IOBuffer_PathDoesNotExist = 104; + /** native declaration : headers\openvr_capi.h:1128 */ + public static final int EIOBufferError_IOBuffer_Permission = 105; + }; + /** + * native declaration : headers\openvr_capi.h:1134
+ * enum values + */ + public static interface EIOBufferMode { + /** native declaration : headers\openvr_capi.h:1131 */ + public static final int EIOBufferMode_IOBufferMode_Read = 1; + /** native declaration : headers\openvr_capi.h:1132 */ + public static final int EIOBufferMode_IOBufferMode_Write = 2; + /** native declaration : headers\openvr_capi.h:1133 */ + public static final int EIOBufferMode_IOBufferMode_Create = 512; + }; + /** OpenVR Constants */ + public static final long k_nDriverNone = 4294967295L; + public static final int k_unMaxDriverDebugResponseSize = 32768; + public static final int k_unTrackedDeviceIndex_Hmd = 0; + public static final int k_unMaxTrackedDeviceCount = 64; + public static final int k_unTrackedDeviceIndexOther = -2; + public static final long k_unTrackedDeviceIndexInvalid = 4294967295L; + public static final long k_ulInvalidPropertyContainer = 0; + public static final int k_unInvalidPropertyTag = 0; + public static final long k_ulInvalidDriverHandle = 0; + public static final int k_unFloatPropertyTag = 1; + public static final int k_unInt32PropertyTag = 2; + public static final int k_unUint64PropertyTag = 3; + public static final int k_unBoolPropertyTag = 4; + public static final int k_unStringPropertyTag = 5; + public static final int k_unHmdMatrix34PropertyTag = 20; + public static final int k_unHmdMatrix44PropertyTag = 21; + public static final int k_unHmdVector3PropertyTag = 22; + public static final int k_unHmdVector4PropertyTag = 23; + public static final int k_unHiddenAreaPropertyTag = 30; + public static final int k_unPathHandleInfoTag = 31; + public static final int k_unActionPropertyTag = 32; + public static final int k_unInputValuePropertyTag = 33; + public static final int k_unWildcardPropertyTag = 34; + public static final int k_unHapticVibrationPropertyTag = 35; + public static final int k_unSkeletonPropertyTag = 36; + public static final int k_unSpatialAnchorPosePropertyTag = 40; + public static final int k_unOpenVRInternalReserved_Start = 1000; + public static final int k_unOpenVRInternalReserved_End = 10000; + public static final int k_unMaxPropertyStringSize = 32768; + public static final long k_ulInvalidActionHandle = 0; + public static final long k_ulInvalidActionSetHandle = 0; + public static final long k_ulInvalidInputValueHandle = 0; + public static final int k_unControllerStateAxisCount = 5; + public static final long k_ulOverlayHandleInvalid = 0; + public static final int k_unScreenshotHandleInvalid = 0; + public static final int k_unMaxApplicationKeyLength = 128; + public static final int k_unVROverlayMaxKeyLength = 128; + public static final int k_unVROverlayMaxNameLength = 128; + public static final int k_unMaxOverlayCount = 64; + public static final int k_unMaxOverlayIntersectionMaskPrimitivesCount = 32; + public static final int k_unNotificationTextMaxSize = 256; + public static final int k_unMaxSettingsKeyLength = 128; + public static final int k_unMaxActionNameLength = 64; + public static final int k_unMaxActionSetNameLength = 64; + public static final int k_unMaxActionOriginCount = 16; + public static final long k_ulInvalidIOBufferHandle = 0; + public static final int k_ulInvalidSpatialAnchorHandle = 0; + + + public static final String IVRSystem_Version = "IVRSystem_019"; + public static final String IVRExtendedDisplay_Version = "IVRExtendedDisplay_001"; + public static final String IVRTrackedCamera_Version = "IVRTrackedCamera_003"; + public static final String k_pch_MimeType_HomeApp = "vr/home"; + public static final String k_pch_MimeType_GameTheater = "vr/game_theater"; + public static final String IVRApplications_Version = "IVRApplications_006"; + public static final String IVRChaperone_Version = "IVRChaperone_003"; + public static final String IVRChaperoneSetup_Version = "IVRChaperoneSetup_005"; + public static final String IVRCompositor_Version = "IVRCompositor_022"; + public static final String IVROverlay_Version = "IVROverlay_018"; + public static final String k_pch_Controller_Component_GDC2015 = "gdc2015"; + public static final String k_pch_Controller_Component_Base = "base"; + public static final String k_pch_Controller_Component_Tip = "tip"; + public static final String k_pch_Controller_Component_HandGrip = "handgrip"; + public static final String k_pch_Controller_Component_Status = "status"; + public static final String IVRRenderModels_Version = "IVRRenderModels_006"; + public static final String IVRNotifications_Version = "IVRNotifications_002"; + public static final String IVRSettings_Version = "IVRSettings_002"; + public static final String k_pch_SteamVR_Section = "steamvr"; + public static final String k_pch_SteamVR_RequireHmd_String = "requireHmd"; + public static final String k_pch_SteamVR_ForcedDriverKey_String = "forcedDriver"; + public static final String k_pch_SteamVR_ForcedHmdKey_String = "forcedHmd"; + public static final String k_pch_SteamVR_DisplayDebug_Bool = "displayDebug"; + public static final String k_pch_SteamVR_DebugProcessPipe_String = "debugProcessPipe"; + public static final String k_pch_SteamVR_DisplayDebugX_Int32 = "displayDebugX"; + public static final String k_pch_SteamVR_DisplayDebugY_Int32 = "displayDebugY"; + public static final String k_pch_SteamVR_SendSystemButtonToAllApps_Bool = "sendSystemButtonToAllApps"; + public static final String k_pch_SteamVR_LogLevel_Int32 = "loglevel"; + public static final String k_pch_SteamVR_IPD_Float = "ipd"; + public static final String k_pch_SteamVR_Background_String = "background"; + public static final String k_pch_SteamVR_BackgroundUseDomeProjection_Bool = "backgroundUseDomeProjection"; + public static final String k_pch_SteamVR_BackgroundCameraHeight_Float = "backgroundCameraHeight"; + public static final String k_pch_SteamVR_BackgroundDomeRadius_Float = "backgroundDomeRadius"; + public static final String k_pch_SteamVR_GridColor_String = "gridColor"; + public static final String k_pch_SteamVR_PlayAreaColor_String = "playAreaColor"; + public static final String k_pch_SteamVR_ShowStage_Bool = "showStage"; + public static final String k_pch_SteamVR_ActivateMultipleDrivers_Bool = "activateMultipleDrivers"; + public static final String k_pch_SteamVR_DirectMode_Bool = "directMode"; + public static final String k_pch_SteamVR_DirectModeEdidVid_Int32 = "directModeEdidVid"; + public static final String k_pch_SteamVR_DirectModeEdidPid_Int32 = "directModeEdidPid"; + public static final String k_pch_SteamVR_UsingSpeakers_Bool = "usingSpeakers"; + public static final String k_pch_SteamVR_SpeakersForwardYawOffsetDegrees_Float = "speakersForwardYawOffsetDegrees"; + public static final String k_pch_SteamVR_BaseStationPowerManagement_Bool = "basestationPowerManagement"; + public static final String k_pch_SteamVR_NeverKillProcesses_Bool = "neverKillProcesses"; + public static final String k_pch_SteamVR_SupersampleScale_Float = "supersampleScale"; + public static final String k_pch_SteamVR_AllowAsyncReprojection_Bool = "allowAsyncReprojection"; + public static final String k_pch_SteamVR_AllowReprojection_Bool = "allowInterleavedReprojection"; + public static final String k_pch_SteamVR_ForceReprojection_Bool = "forceReprojection"; + public static final String k_pch_SteamVR_ForceFadeOnBadTracking_Bool = "forceFadeOnBadTracking"; + public static final String k_pch_SteamVR_DefaultMirrorView_Int32 = "defaultMirrorView"; + public static final String k_pch_SteamVR_ShowMirrorView_Bool = "showMirrorView"; + public static final String k_pch_SteamVR_MirrorViewGeometry_String = "mirrorViewGeometry"; + public static final String k_pch_SteamVR_StartMonitorFromAppLaunch = "startMonitorFromAppLaunch"; + public static final String k_pch_SteamVR_StartCompositorFromAppLaunch_Bool = "startCompositorFromAppLaunch"; + public static final String k_pch_SteamVR_StartDashboardFromAppLaunch_Bool = "startDashboardFromAppLaunch"; + public static final String k_pch_SteamVR_StartOverlayAppsFromDashboard_Bool = "startOverlayAppsFromDashboard"; + public static final String k_pch_SteamVR_EnableHomeApp = "enableHomeApp"; + public static final String k_pch_SteamVR_CycleBackgroundImageTimeSec_Int32 = "CycleBackgroundImageTimeSec"; + public static final String k_pch_SteamVR_RetailDemo_Bool = "retailDemo"; + public static final String k_pch_SteamVR_IpdOffset_Float = "ipdOffset"; + public static final String k_pch_SteamVR_AllowSupersampleFiltering_Bool = "allowSupersampleFiltering"; + public static final String k_pch_SteamVR_SupersampleManualOverride_Bool = "supersampleManualOverride"; + public static final String k_pch_SteamVR_EnableLinuxVulkanAsync_Bool = "enableLinuxVulkanAsync"; + public static final String k_pch_SteamVR_AllowDisplayLockedMode_Bool = "allowDisplayLockedMode"; + public static final String k_pch_SteamVR_HaveStartedTutorialForNativeChaperoneDriver_Bool = "haveStartedTutorialForNativeChaperoneDriver"; + public static final String k_pch_SteamVR_ForceWindows32bitVRMonitor = "forceWindows32BitVRMonitor"; + public static final String k_pch_SteamVR_DebugInput = "debugInput"; + public static final String k_pch_SteamVR_LegacyInputRebinding = "legacyInputRebinding"; + public static final String k_pch_SteamVR_DebugInputBinding = "debugInputBinding"; + public static final String k_pch_SteamVR_InputBindingUIBlock = "inputBindingUI"; + public static final String k_pch_SteamVR_RenderCameraMode = "renderCameraMode"; + public static final String k_pch_Lighthouse_Section = "driver_lighthouse"; + public static final String k_pch_Lighthouse_DisableIMU_Bool = "disableimu"; + public static final String k_pch_Lighthouse_DisableIMUExceptHMD_Bool = "disableimuexcepthmd"; + public static final String k_pch_Lighthouse_UseDisambiguation_String = "usedisambiguation"; + public static final String k_pch_Lighthouse_DisambiguationDebug_Int32 = "disambiguationdebug"; + public static final String k_pch_Lighthouse_PrimaryBasestation_Int32 = "primarybasestation"; + public static final String k_pch_Lighthouse_DBHistory_Bool = "dbhistory"; + public static final String k_pch_Lighthouse_EnableBluetooth_Bool = "enableBluetooth"; + public static final String k_pch_Lighthouse_PowerManagedBaseStations_String = "PowerManagedBaseStations"; + public static final String k_pch_Null_Section = "driver_null"; + public static final String k_pch_Null_SerialNumber_String = "serialNumber"; + public static final String k_pch_Null_ModelNumber_String = "modelNumber"; + public static final String k_pch_Null_WindowX_Int32 = "windowX"; + public static final String k_pch_Null_WindowY_Int32 = "windowY"; + public static final String k_pch_Null_WindowWidth_Int32 = "windowWidth"; + public static final String k_pch_Null_WindowHeight_Int32 = "windowHeight"; + public static final String k_pch_Null_RenderWidth_Int32 = "renderWidth"; + public static final String k_pch_Null_RenderHeight_Int32 = "renderHeight"; + public static final String k_pch_Null_SecondsFromVsyncToPhotons_Float = "secondsFromVsyncToPhotons"; + public static final String k_pch_Null_DisplayFrequency_Float = "displayFrequency"; + public static final String k_pch_UserInterface_Section = "userinterface"; + public static final String k_pch_UserInterface_StatusAlwaysOnTop_Bool = "StatusAlwaysOnTop"; + public static final String k_pch_UserInterface_MinimizeToTray_Bool = "MinimizeToTray"; + public static final String k_pch_UserInterface_Screenshots_Bool = "screenshots"; + public static final String k_pch_UserInterface_ScreenshotType_Int = "screenshotType"; + public static final String k_pch_Notifications_Section = "notifications"; + public static final String k_pch_Notifications_DoNotDisturb_Bool = "DoNotDisturb"; + public static final String k_pch_Keyboard_Section = "keyboard"; + public static final String k_pch_Keyboard_TutorialCompletions = "TutorialCompletions"; + public static final String k_pch_Keyboard_ScaleX = "ScaleX"; + public static final String k_pch_Keyboard_ScaleY = "ScaleY"; + public static final String k_pch_Keyboard_OffsetLeftX = "OffsetLeftX"; + public static final String k_pch_Keyboard_OffsetRightX = "OffsetRightX"; + public static final String k_pch_Keyboard_OffsetY = "OffsetY"; + public static final String k_pch_Keyboard_Smoothing = "Smoothing"; + public static final String k_pch_Perf_Section = "perfcheck"; + public static final String k_pch_Perf_HeuristicActive_Bool = "heuristicActive"; + public static final String k_pch_Perf_NotifyInHMD_Bool = "warnInHMD"; + public static final String k_pch_Perf_NotifyOnlyOnce_Bool = "warnOnlyOnce"; + public static final String k_pch_Perf_AllowTimingStore_Bool = "allowTimingStore"; + public static final String k_pch_Perf_SaveTimingsOnExit_Bool = "saveTimingsOnExit"; + public static final String k_pch_Perf_TestData_Float = "perfTestData"; + public static final String k_pch_Perf_LinuxGPUProfiling_Bool = "linuxGPUProfiling"; + public static final String k_pch_CollisionBounds_Section = "collisionBounds"; + public static final String k_pch_CollisionBounds_Style_Int32 = "CollisionBoundsStyle"; + public static final String k_pch_CollisionBounds_GroundPerimeterOn_Bool = "CollisionBoundsGroundPerimeterOn"; + public static final String k_pch_CollisionBounds_CenterMarkerOn_Bool = "CollisionBoundsCenterMarkerOn"; + public static final String k_pch_CollisionBounds_PlaySpaceOn_Bool = "CollisionBoundsPlaySpaceOn"; + public static final String k_pch_CollisionBounds_FadeDistance_Float = "CollisionBoundsFadeDistance"; + public static final String k_pch_CollisionBounds_ColorGammaR_Int32 = "CollisionBoundsColorGammaR"; + public static final String k_pch_CollisionBounds_ColorGammaG_Int32 = "CollisionBoundsColorGammaG"; + public static final String k_pch_CollisionBounds_ColorGammaB_Int32 = "CollisionBoundsColorGammaB"; + public static final String k_pch_CollisionBounds_ColorGammaA_Int32 = "CollisionBoundsColorGammaA"; + public static final String k_pch_Camera_Section = "camera"; + public static final String k_pch_Camera_EnableCamera_Bool = "enableCamera"; + public static final String k_pch_Camera_EnableCameraInDashboard_Bool = "enableCameraInDashboard"; + public static final String k_pch_Camera_EnableCameraForCollisionBounds_Bool = "enableCameraForCollisionBounds"; + public static final String k_pch_Camera_EnableCameraForRoomView_Bool = "enableCameraForRoomView"; + public static final String k_pch_Camera_BoundsColorGammaR_Int32 = "cameraBoundsColorGammaR"; + public static final String k_pch_Camera_BoundsColorGammaG_Int32 = "cameraBoundsColorGammaG"; + public static final String k_pch_Camera_BoundsColorGammaB_Int32 = "cameraBoundsColorGammaB"; + public static final String k_pch_Camera_BoundsColorGammaA_Int32 = "cameraBoundsColorGammaA"; + public static final String k_pch_Camera_BoundsStrength_Int32 = "cameraBoundsStrength"; + public static final String k_pch_Camera_RoomViewMode_Int32 = "cameraRoomViewMode"; + public static final String k_pch_audio_Section = "audio"; + public static final String k_pch_audio_OnPlaybackDevice_String = "onPlaybackDevice"; + public static final String k_pch_audio_OnRecordDevice_String = "onRecordDevice"; + public static final String k_pch_audio_OnPlaybackMirrorDevice_String = "onPlaybackMirrorDevice"; + public static final String k_pch_audio_OffPlaybackDevice_String = "offPlaybackDevice"; + public static final String k_pch_audio_OffRecordDevice_String = "offRecordDevice"; + public static final String k_pch_audio_VIVEHDMIGain = "viveHDMIGain"; + public static final String k_pch_Power_Section = "power"; + public static final String k_pch_Power_PowerOffOnExit_Bool = "powerOffOnExit"; + public static final String k_pch_Power_TurnOffScreensTimeout_Float = "turnOffScreensTimeout"; + public static final String k_pch_Power_TurnOffControllersTimeout_Float = "turnOffControllersTimeout"; + public static final String k_pch_Power_ReturnToWatchdogTimeout_Float = "returnToWatchdogTimeout"; + public static final String k_pch_Power_AutoLaunchSteamVROnButtonPress = "autoLaunchSteamVROnButtonPress"; + public static final String k_pch_Power_PauseCompositorOnStandby_Bool = "pauseCompositorOnStandby"; + public static final String k_pch_Dashboard_Section = "dashboard"; + public static final String k_pch_Dashboard_EnableDashboard_Bool = "enableDashboard"; + public static final String k_pch_Dashboard_ArcadeMode_Bool = "arcadeMode"; + public static final String k_pch_Dashboard_EnableWebUI = "webUI"; + public static final String k_pch_Dashboard_EnableWebUIDevTools = "webUIDevTools"; + public static final String k_pch_Dashboard_EnableWebUIDashboardReplacement = "webUIDashboard"; + public static final String k_pch_modelskin_Section = "modelskins"; + public static final String k_pch_Driver_Enable_Bool = "enable"; + public static final String k_pch_WebInterface_Section = "WebInterface"; + public static final String k_pch_WebInterface_WebEnable_Bool = "WebEnable"; + public static final String k_pch_WebInterface_WebPort_String = "WebPort"; + public static final String k_pch_TrackingOverride_Section = "TrackingOverrides"; + public static final String k_pch_App_BindingAutosaveURLSuffix_String = "AutosaveURL"; + public static final String k_pch_App_BindingCurrentURLSuffix_String = "CurrentURL"; + public static final String k_pch_App_NeedToUpdateAutosaveSuffix_Bool = "NeedToUpdateAutosave"; + public static final String k_pch_App_ActionManifestURL_String = "ActionManifestURL"; + public static final String k_pch_Trackers_Section = "trackers"; + public static final String IVRScreenshots_Version = "IVRScreenshots_001"; + public static final String IVRResources_Version = "IVRResources_001"; + public static final String IVRDriverManager_Version = "IVRDriverManager_001"; + public static final String IVRInput_Version = "IVRInput_004"; + public static final String IVRIOBuffer_Version = "IVRIOBuffer_001"; + public static final String IVRSpatialAnchors_Version = "IVRSpatialAnchors_001"; + + + /** + * Global entry points
+ * Original signature : intptr_t VR_InitInternal(EVRInitError*, EVRApplicationType)
+ * native declaration : headers\openvr_capi.h:2378
+ * @deprecated use the safer methods {@link #VR_InitInternal(java.nio.IntBuffer, int)} and {@link #VR_InitInternal(com.sun.jna.ptr.IntByReference, int)} instead + */ + @Deprecated + public static native IntByReference VR_InitInternal(IntByReference peError, int eType); + /** + * Global entry points
+ * Original signature : intptr_t VR_InitInternal(EVRInitError*, EVRApplicationType)
+ * native declaration : headers\openvr_capi.h:2378 + */ + public static native IntByReference VR_InitInternal(IntBuffer peError, int eType); + /** + * Original signature : void VR_ShutdownInternal()
+ * native declaration : headers\openvr_capi.h:2380 + */ + public static native void VR_ShutdownInternal(); + /** + * Original signature : bool VR_IsHmdPresent()
+ * native declaration : headers\openvr_capi.h:2382 + */ + public static native byte VR_IsHmdPresent(); + /** + * Original signature : intptr_t VR_GetGenericInterface(const char*, EVRInitError*)
+ * native declaration : headers\openvr_capi.h:2384
+ * @deprecated use the safer method + * {@link #VR_GetGenericInterface(java.lang.String, com.sun.jna.ptr.IntByReference)} + * instead + */ + @Deprecated + public static native IntByReference VR_GetGenericInterface(Pointer pchInterfaceVersion, IntByReference peError); + /** + * Original signature : intptr_t VR_GetGenericInterface(const char*, EVRInitError*)
+ * native declaration : headers\openvr_capi.h:2384 + */ + public static native IntByReference VR_GetGenericInterface(String pchInterfaceVersion, IntByReference peError); + /** + * Original signature : bool VR_IsRuntimeInstalled()
+ * native declaration : headers\openvr_capi.h:2386 + */ + public static native byte VR_IsRuntimeInstalled(); + /** + * Original signature : char* VR_GetVRInitErrorAsSymbol(EVRInitError)
+ * native declaration : headers\openvr_capi.h:2388 + */ + public static native Pointer VR_GetVRInitErrorAsSymbol(int error); + /** + * Original signature : char* VR_GetVRInitErrorAsEnglishDescription(EVRInitError)
+ * native declaration : headers\openvr_capi.h:2390 + */ + public static native Pointer VR_GetVRInitErrorAsEnglishDescription(int error); + public static class VkQueue_T extends PointerType { + public VkQueue_T(Pointer address) { + super(address); + } + public VkQueue_T() { + super(); + } + }; + public static class VkPhysicalDevice_T extends PointerType { + public VkPhysicalDevice_T(Pointer address) { + super(address); + } + public VkPhysicalDevice_T() { + super(); + } + }; + public static class VkInstance_T extends PointerType { + public VkInstance_T(Pointer address) { + super(address); + } + public VkInstance_T() { + super(); + } + }; + public static class ID3D12CommandQueue extends PointerType { + public ID3D12CommandQueue(Pointer address) { + super(address); + } + public ID3D12CommandQueue() { + super(); + } + }; + public static class ID3D12Resource extends PointerType { + public ID3D12Resource(Pointer address) { + super(address); + } + public ID3D12Resource() { + super(); + } + }; + public static class VkDevice_T extends PointerType { + public VkDevice_T(Pointer address) { + super(address); + } + public VkDevice_T() { + super(); + } + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/NotificationBitmap_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/NotificationBitmap_t.java new file mode 100644 index 0000000000..b9aaffe311 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/NotificationBitmap_t.java @@ -0,0 +1,48 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1588
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class NotificationBitmap_t extends Structure { + /** + * void *
+ * C type : void* + */ + public Pointer m_pImageData; + public int m_nWidth; + public int m_nHeight; + public int m_nBytesPerPixel; + public NotificationBitmap_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("m_pImageData", "m_nWidth", "m_nHeight", "m_nBytesPerPixel"); + } + /** + * @param m_pImageData void *
+ * C type : void* + */ + public NotificationBitmap_t(Pointer m_pImageData, int m_nWidth, int m_nHeight, int m_nBytesPerPixel) { + super(); + this.m_pImageData = m_pImageData; + this.m_nWidth = m_nWidth; + this.m_nHeight = m_nHeight; + this.m_nBytesPerPixel = m_nBytesPerPixel; + } + public NotificationBitmap_t(Pointer peer) { + super(peer); + } + public static class ByReference extends NotificationBitmap_t implements Structure.ByReference { + + }; + public static class ByValue extends NotificationBitmap_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/OpenVRUtil.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/OpenVRUtil.java new file mode 100644 index 0000000000..2d075cf80a --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/OpenVRUtil.java @@ -0,0 +1,779 @@ +package com.jme3.system.jopenvr; + +import com.jme3.input.vr.openvr.OpenVRInput; +import com.jme3.system.jopenvr.JOpenVRLibrary.EColorSpace; +import com.jme3.system.jopenvr.JOpenVRLibrary.ETextureType; +import com.jme3.system.jopenvr.JOpenVRLibrary.ETrackedDeviceProperty; +import com.jme3.system.jopenvr.JOpenVRLibrary.ETrackedPropertyError; +import com.jme3.system.jopenvr.JOpenVRLibrary.EVRCompositorError; +import com.jme3.system.jopenvr.JOpenVRLibrary.EVRInitError; +import com.sun.jna.Memory; +import com.sun.jna.Pointer; +import com.sun.jna.ptr.IntByReference; + +/** + * A utility class that provide helper methods for OpenVR system. + * @author Julien Seinturier - 2017 - http://www.seinturier.fr + */ +public class OpenVRUtil { + /** + * A private constructor to inhibit instantiation of this class. + */ + private OpenVRUtil() { + } + + /** + * Get the value of the given string {@link JOpenVRLibrary.ETrackedDeviceProperty property} attached to the given device. + * @param system the underlying OpenVR system. + * @param deviceIndex the index of the device to query. + * @param property the property to query. + * @param bufferSize the size of the buffer to use for storing native string. + * @return the value of the given string property attached to the given device. + * @see OpenVRInput#getTrackedControllerCount() + * @see JOpenVRLibrary.ETrackedDeviceProperty + * @see #getTrackedDeviceStringProperty(VR_IVRSystem_FnTable, int, int) + */ + public static String getTrackedDeviceStringProperty(VR_IVRSystem_FnTable system, int deviceIndex, int property, int bufferSize){ + String str =""; + + int unBufferSize = 256; + Pointer pchValue = new Memory(unBufferSize); + IntByReference pError = new IntByReference(); + + system.GetStringTrackedDeviceProperty.apply(deviceIndex, property, pchValue, unBufferSize, pError); + + if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_Success){ + str = pchValue.getString(0); + } else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_BufferTooSmall){ + throw new IllegalArgumentException("Cannot access property \""+getETrackedDevicePropertyString(property)+"\" ("+property+") for device "+deviceIndex+": "+getETrackedPropertyErrorString(pError.getValue())+" ("+pError.getValue()+")"); + } else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_CouldNotContactServer){ + throw new IllegalArgumentException("Cannot access property \""+getETrackedDevicePropertyString(property)+"\" ("+property+") for device "+deviceIndex+": "+getETrackedPropertyErrorString(pError.getValue())+" ("+pError.getValue()+")"); + } else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_InvalidDevice){ + throw new IllegalArgumentException("Cannot access property \""+getETrackedDevicePropertyString(property)+"\" ("+property+") for device "+deviceIndex+": "+getETrackedPropertyErrorString(pError.getValue())+" ("+pError.getValue()+")"); + } else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_InvalidOperation){ + throw new IllegalArgumentException("Cannot access property \""+getETrackedDevicePropertyString(property)+"\" ("+property+") for device "+deviceIndex+": "+getETrackedPropertyErrorString(pError.getValue())+" ("+pError.getValue()+")"); + } else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_NotYetAvailable){ + throw new IllegalArgumentException("Cannot access property \""+getETrackedDevicePropertyString(property)+"\" ("+property+") for device "+deviceIndex+": "+getETrackedPropertyErrorString(pError.getValue())+" ("+pError.getValue()+")"); + } else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_PermissionDenied){ + throw new IllegalArgumentException("Cannot access property \""+getETrackedDevicePropertyString(property)+"\" ("+property+") for device "+deviceIndex+": "+getETrackedPropertyErrorString(pError.getValue())+" ("+pError.getValue()+")"); + } else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_StringExceedsMaximumLength){ + throw new IllegalArgumentException("Cannot access property \""+getETrackedDevicePropertyString(property)+"\" ("+property+") for device "+deviceIndex+": "+getETrackedPropertyErrorString(pError.getValue())+" ("+pError.getValue()+")"); + } else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_UnknownProperty){ + throw new IllegalArgumentException("Cannot access property \""+getETrackedDevicePropertyString(property)+"\" ("+property+") for device "+deviceIndex+": "+getETrackedPropertyErrorString(pError.getValue())+" ("+pError.getValue()+")"); + } else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_ValueNotProvidedByDevice){ + throw new IllegalArgumentException("Cannot access property \""+getETrackedDevicePropertyString(property)+"\" ("+property+") for device "+deviceIndex+": "+getETrackedPropertyErrorString(pError.getValue())+" ("+pError.getValue()+")"); + } else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_WrongDataType){ + throw new IllegalArgumentException("Cannot access property \""+getETrackedDevicePropertyString(property)+"\" ("+property+") for device "+deviceIndex+": "+getETrackedPropertyErrorString(pError.getValue())+" ("+pError.getValue()+")"); + } else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_WrongDeviceClass){ + throw new IllegalArgumentException("Cannot access property \""+getETrackedDevicePropertyString(property)+"\" ("+property+") for device "+deviceIndex+": "+getETrackedPropertyErrorString(pError.getValue())+" ("+pError.getValue()+")"); + } else { + throw new IllegalArgumentException("Cannot access property \""+getETrackedDevicePropertyString(property)+"\" ("+property+") for device "+deviceIndex+": "+getETrackedPropertyErrorString(pError.getValue())+" ("+pError.getValue()+")"); + } + + return str; + } + + /** + * Get the value of the given string {@link JOpenVRLibrary.ETrackedDeviceProperty property} attached to the given device. + * @param system the underlying OpenVR system. + * @param deviceIndex the index of the device to query. + * @param property the property to query. + * @return the value of the given string property attached to the given device. + * @see OpenVRInput#getTrackedControllerCount() + * @see JOpenVRLibrary.ETrackedDeviceProperty + * @see #getTrackedDeviceStringProperty(VR_IVRSystem_FnTable, int, int, int) + */ + public static String getTrackedDeviceStringProperty(VR_IVRSystem_FnTable system, int deviceIndex, int property){ + return getTrackedDeviceStringProperty(system, deviceIndex, property, 256); + } + + /** + * Get the String description of the given {@link ETrackedPropertyError string tracked property error}. + * @param error the string tracked property error. + * @return the String description of the given string tracked property error. + */ + public static String getETrackedPropertyErrorString(int error){ + String str =""; + + switch(error){ + case ETrackedPropertyError.ETrackedPropertyError_TrackedProp_Success: + str = "Success"; + break; + case ETrackedPropertyError.ETrackedPropertyError_TrackedProp_WrongDataType: + str = "Wrong data type"; + break; + case ETrackedPropertyError.ETrackedPropertyError_TrackedProp_WrongDeviceClass: + str = "Wrong device class"; + break; + case ETrackedPropertyError.ETrackedPropertyError_TrackedProp_BufferTooSmall: + str = "Buffer too small"; + break; + case ETrackedPropertyError.ETrackedPropertyError_TrackedProp_UnknownProperty: + str = "Unknown property"; + break; + case ETrackedPropertyError.ETrackedPropertyError_TrackedProp_InvalidDevice: + str = "Invalid device"; + break; + case ETrackedPropertyError.ETrackedPropertyError_TrackedProp_CouldNotContactServer: + str = "Could not contact server"; + break; + case ETrackedPropertyError.ETrackedPropertyError_TrackedProp_ValueNotProvidedByDevice: + str = "Value not provided by device"; + break; + case ETrackedPropertyError.ETrackedPropertyError_TrackedProp_StringExceedsMaximumLength: + str = "String exceed maximum length"; + break; + case ETrackedPropertyError.ETrackedPropertyError_TrackedProp_NotYetAvailable: + str = "Not yet available"; + break; + case ETrackedPropertyError.ETrackedPropertyError_TrackedProp_PermissionDenied: + str = "Permission denied"; + break; + case ETrackedPropertyError.ETrackedPropertyError_TrackedProp_InvalidOperation: + str = "Invalid operation"; + break; + default: + str = "Not handled error"; + } + + return str; + } + + /** + * Get the description of the given {@link EColorSpace color space}. + * @param eColorSpace the color space. + * @return the description of the given color space. + */ + public static String getEColorSpaceString(int eColorSpace){ + String str = ""; + + switch(eColorSpace){ + case EColorSpace.EColorSpace_ColorSpace_Auto: + str = "Auto"; + break; + case EColorSpace.EColorSpace_ColorSpace_Gamma: + str = "Gamma"; + break; + case EColorSpace.EColorSpace_ColorSpace_Linear: + str = "Linear"; + break; + default: + str = "Unknown ("+eColorSpace+")"; + } + + return str; + } + + /** + * Get the description of the given {@link ETextureType texture type}. + * @param type the texture type + * @return the description of the given texture type. + */ + public static String getETextureTypeString(int type){ + + String str = ""; + + switch(type){ + case ETextureType.ETextureType_TextureType_DirectX: + str = "DirectX"; + break; + case ETextureType.ETextureType_TextureType_OpenGL: + str = "OpenGL"; + break; + case ETextureType.ETextureType_TextureType_Vulkan: + str = "Vulkan"; + break; + case ETextureType.ETextureType_TextureType_IOSurface: + str = "IOSurface"; + break; + case ETextureType.ETextureType_TextureType_DirectX12: + str = "DirectX12"; + break; + default: + str = "Unknown ("+type+")"; + } + + return str; + } + + /** + * Get the description of the given {@link EVRCompositorError EVR compositor error}. + * @param error the EVR compositor error. + * @return the description of the given EVR compositor error. + */ + public static String getEVRCompositorErrorString(int error){ + String str =""; + + switch(error){ + case EVRCompositorError.EVRCompositorError_VRCompositorError_None: + str = "None"; + break; + case EVRCompositorError.EVRCompositorError_VRCompositorError_RequestFailed: + str = "Request failed"; + break; + case EVRCompositorError.EVRCompositorError_VRCompositorError_IncompatibleVersion: + str = "Incompatible version"; + break; + case EVRCompositorError.EVRCompositorError_VRCompositorError_DoNotHaveFocus: + str = "Do not have focus"; + break; + case EVRCompositorError.EVRCompositorError_VRCompositorError_InvalidTexture: + str = "Invalid texture"; + break; + case EVRCompositorError.EVRCompositorError_VRCompositorError_IsNotSceneApplication: + str = "Is not scene application"; + break; + case EVRCompositorError.EVRCompositorError_VRCompositorError_TextureIsOnWrongDevice: + str = "Texture is on wrong device"; + break; + case EVRCompositorError.EVRCompositorError_VRCompositorError_TextureUsesUnsupportedFormat: + str = "Texture uses unsupported format"; + break; + case EVRCompositorError.EVRCompositorError_VRCompositorError_SharedTexturesNotSupported: + str = "Shared textures not supported"; + break; + case EVRCompositorError.EVRCompositorError_VRCompositorError_IndexOutOfRange: + str = "Index out of range"; + break; + case EVRCompositorError.EVRCompositorError_VRCompositorError_AlreadySubmitted: + str = "Already submitted"; + break; + } + return str; + } + + /** + * Get the description of the given {@link EVRInitError EVR init error}. + * @param error the EVR init error. + * @return the description of the given EVR init error. + */ + public static String getEVRInitErrorString(int error){ + String str = ""; + + switch(error){ + + + case EVRInitError.EVRInitError_VRInitError_None: + str="None"; + break; + case EVRInitError.EVRInitError_VRInitError_Unknown: + str="Unknown"; + break; + case EVRInitError.EVRInitError_VRInitError_Init_InstallationNotFound: + str="Installation not found"; + break; + case EVRInitError.EVRInitError_VRInitError_Init_InstallationCorrupt: + str="Installation corrupt"; + break; + case EVRInitError.EVRInitError_VRInitError_Init_VRClientDLLNotFound: + str="VR Client DLL not found"; + break; + case EVRInitError.EVRInitError_VRInitError_Init_FileNotFound: + str="File not found"; + break; + case EVRInitError.EVRInitError_VRInitError_Init_FactoryNotFound: + str="Factory not found"; + break; + case EVRInitError.EVRInitError_VRInitError_Init_InterfaceNotFound: + str="Interface not found"; + break; + case EVRInitError.EVRInitError_VRInitError_Init_InvalidInterface: + str="Invalid interface"; + break; + case EVRInitError.EVRInitError_VRInitError_Init_UserConfigDirectoryInvalid: + str="User config directory invalid"; + break; + case EVRInitError.EVRInitError_VRInitError_Init_HmdNotFound: + str="HMD not found"; + break; + case EVRInitError.EVRInitError_VRInitError_Init_NotInitialized: + str="Not initialized"; + break; + case EVRInitError.EVRInitError_VRInitError_Init_PathRegistryNotFound: + str="Path registry not found"; + break; + case EVRInitError.EVRInitError_VRInitError_Init_NoConfigPath: + str="No config path"; + break; + case EVRInitError.EVRInitError_VRInitError_Init_NoLogPath: + str="No log path"; + break; + case EVRInitError.EVRInitError_VRInitError_Init_PathRegistryNotWritable: + str="Path registry not writable"; + break; + case EVRInitError.EVRInitError_VRInitError_Init_AppInfoInitFailed: + str="AppInfo init failed"; + break; + case EVRInitError.EVRInitError_VRInitError_Init_Retry: + str="Init retry"; + break; + case EVRInitError.EVRInitError_VRInitError_Init_InitCanceledByUser: + str="Init canceled by user"; + break; + case EVRInitError.EVRInitError_VRInitError_Init_AnotherAppLaunching: + str="Another app launching"; + break; + case EVRInitError.EVRInitError_VRInitError_Init_SettingsInitFailed: + str="Setting init failed"; + break; + case EVRInitError.EVRInitError_VRInitError_Init_ShuttingDown: + str="Shutting down"; + break; + case EVRInitError.EVRInitError_VRInitError_Init_TooManyObjects: + str="Too many objects"; + break; + case EVRInitError.EVRInitError_VRInitError_Init_NoServerForBackgroundApp: + str="No server background app"; + break; + case EVRInitError.EVRInitError_VRInitError_Init_NotSupportedWithCompositor: + str="Not supported with compositor"; + break; + case EVRInitError.EVRInitError_VRInitError_Init_NotAvailableToUtilityApps: + str="Not available to utility apps"; + break; + case EVRInitError.EVRInitError_VRInitError_Init_Internal: + str="Internal"; + break; + case EVRInitError.EVRInitError_VRInitError_Init_HmdDriverIdIsNone: + str="Driver Id is None"; + break; + case EVRInitError.EVRInitError_VRInitError_Init_HmdNotFoundPresenceFailed: + str="HMD not found presence failed"; + break; + case EVRInitError.EVRInitError_VRInitError_Init_VRMonitorNotFound: + str="VR monitor not found"; + break; + case EVRInitError.EVRInitError_VRInitError_Init_VRMonitorStartupFailed: + str="VR monitor startup failed"; + break; + case EVRInitError.EVRInitError_VRInitError_Init_LowPowerWatchdogNotSupported: + str="Low power watchdog not supported"; + break; + case EVRInitError.EVRInitError_VRInitError_Init_InvalidApplicationType: + str="Invalid application type"; + break; + case EVRInitError.EVRInitError_VRInitError_Init_NotAvailableToWatchdogApps: + str="Not available to watchdog apps"; + break; + case EVRInitError.EVRInitError_VRInitError_Init_WatchdogDisabledInSettings: + str="Watchdog disabled in settings"; + break; + case EVRInitError.EVRInitError_VRInitError_Init_VRDashboardNotFound: + str="VR dashboard not found"; + break; + case EVRInitError.EVRInitError_VRInitError_Init_VRDashboardStartupFailed: + str="VR dashboard setup failed"; + break; + case EVRInitError.EVRInitError_VRInitError_Driver_Failed: + str="Driver failed"; + break; + case EVRInitError.EVRInitError_VRInitError_Driver_Unknown: + str="Driver unknown"; + break; + case EVRInitError.EVRInitError_VRInitError_Driver_HmdUnknown: + str="HMD unknown"; + break; + case EVRInitError.EVRInitError_VRInitError_Driver_NotLoaded: + str="Driver not loaded"; + break; + case EVRInitError.EVRInitError_VRInitError_Driver_RuntimeOutOfDate: + str="Driver runtime out of date"; + break; + case EVRInitError.EVRInitError_VRInitError_Driver_HmdInUse: + str="HMD in use"; + break; + case EVRInitError.EVRInitError_VRInitError_Driver_NotCalibrated: + str="Not calibrated"; + break; + case EVRInitError.EVRInitError_VRInitError_Driver_CalibrationInvalid: + str="Calibration invalid"; + break; + case EVRInitError.EVRInitError_VRInitError_Driver_HmdDisplayNotFound: + str="HMD display not found"; + break; + case EVRInitError.EVRInitError_VRInitError_Driver_TrackedDeviceInterfaceUnknown: + str="Tracked device interface unknown"; + break; + case EVRInitError.EVRInitError_VRInitError_Driver_HmdDriverIdOutOfBounds: + str="HMD driver Id out of bounds"; + break; + case EVRInitError.EVRInitError_VRInitError_Driver_HmdDisplayMirrored: + str="HMD display mirrored"; + break; + case EVRInitError.EVRInitError_VRInitError_IPC_ServerInitFailed: + str=""; + break; + case EVRInitError.EVRInitError_VRInitError_IPC_ConnectFailed: str=""; break; + case EVRInitError.EVRInitError_VRInitError_IPC_SharedStateInitFailed: str=""; break; + case EVRInitError.EVRInitError_VRInitError_IPC_CompositorInitFailed: str=""; break; + case EVRInitError.EVRInitError_VRInitError_IPC_MutexInitFailed: str=""; break; + case EVRInitError.EVRInitError_VRInitError_IPC_Failed: str=""; break; + case EVRInitError.EVRInitError_VRInitError_IPC_CompositorConnectFailed: str=""; break; + case EVRInitError.EVRInitError_VRInitError_IPC_CompositorInvalidConnectResponse: str=""; break; + case EVRInitError.EVRInitError_VRInitError_IPC_ConnectFailedAfterMultipleAttempts: str=""; break; + case EVRInitError.EVRInitError_VRInitError_Compositor_Failed: str=""; break; + case EVRInitError.EVRInitError_VRInitError_Compositor_D3D11HardwareRequired: str=""; break; + case EVRInitError.EVRInitError_VRInitError_Compositor_FirmwareRequiresUpdate: str=""; break; + case EVRInitError.EVRInitError_VRInitError_Compositor_OverlayInitFailed: str=""; break; + case EVRInitError.EVRInitError_VRInitError_Compositor_ScreenshotsInitFailed: str=""; break; + case EVRInitError.EVRInitError_VRInitError_VendorSpecific_UnableToConnectToOculusRuntime: str=""; break; + case EVRInitError.EVRInitError_VRInitError_VendorSpecific_HmdFound_CantOpenDevice: str=""; break; + case EVRInitError.EVRInitError_VRInitError_VendorSpecific_HmdFound_UnableToRequestConfigStart: str=""; break; + case EVRInitError.EVRInitError_VRInitError_VendorSpecific_HmdFound_NoStoredConfig: str=""; break; + case EVRInitError.EVRInitError_VRInitError_VendorSpecific_HmdFound_ConfigTooBig: str=""; break; + case EVRInitError.EVRInitError_VRInitError_VendorSpecific_HmdFound_ConfigTooSmall: str=""; break; + case EVRInitError.EVRInitError_VRInitError_VendorSpecific_HmdFound_UnableToInitZLib: str=""; break; + case EVRInitError.EVRInitError_VRInitError_VendorSpecific_HmdFound_CantReadFirmwareVersion: str=""; break; + case EVRInitError.EVRInitError_VRInitError_VendorSpecific_HmdFound_UnableToSendUserDataStart: str=""; break; + case EVRInitError.EVRInitError_VRInitError_VendorSpecific_HmdFound_UnableToGetUserDataStart: str=""; break; + case EVRInitError.EVRInitError_VRInitError_VendorSpecific_HmdFound_UnableToGetUserDataNext: str=""; break; + case EVRInitError.EVRInitError_VRInitError_VendorSpecific_HmdFound_UserDataAddressRange: str=""; break; + case EVRInitError.EVRInitError_VRInitError_VendorSpecific_HmdFound_UserDataError: str=""; break; + case EVRInitError.EVRInitError_VRInitError_VendorSpecific_HmdFound_ConfigFailedSanityCheck: str=""; break; + case EVRInitError.EVRInitError_VRInitError_Steam_SteamInstallationNotFound: str=""; break; + default: + } + + return str; + } + + /** + * Get the description of the given tracked device property. + * @param property the tracked device property. + * @return the description of the given tracked device property. + */ + public static String getETrackedDevicePropertyString(int property){ + String str = ""; + + switch(property){ + + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_Invalid: + str = "Invalid"; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_TrackingSystemName_String: + str = "Tracking system name"; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_ModelNumber_String: + str = "Model number"; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_SerialNumber_String: + str = "Serial number"; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_RenderModelName_String: + str = "Render model name"; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_WillDriftInYaw_Bool: + str = "Will drift in yaw"; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_ManufacturerName_String: + str = "Manufacturer name"; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_TrackingFirmwareVersion_String: + str = "Tracking firmware version"; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_HardwareRevision_String: + str = "Hardware revision"; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_AllWirelessDongleDescriptions_String: + str = "All wireless dongle descriptions"; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_ConnectedWirelessDongle_String: + str = "Connect wireless dongle"; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DeviceIsWireless_Bool: + str = "Device is wireless"; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DeviceIsCharging_Bool: + str = "Device is charging"; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DeviceBatteryPercentage_Float: + str = "Device battery percentage"; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_StatusDisplayTransform_Matrix34: + str = "Status display transform"; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_Firmware_UpdateAvailable_Bool: + str = "Update available"; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_Firmware_ManualUpdate_Bool: + str = "Firmware manual update"; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_Firmware_ManualUpdateURL_String: + str = "Firmware manual update URL"; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_HardwareRevision_Uint64: + str = "Hardware revision"; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_FirmwareVersion_Uint64: + str = "Firmware version"; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_FPGAVersion_Uint64: + str = "FPGA version"; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_VRCVersion_Uint64: + str = "VRC version"; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_RadioVersion_Uint64: + str = "Radio version"; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DongleVersion_Uint64: + str = "Dongle version"; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_BlockServerShutdown_Bool: + str = "Block server shutdown"; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_CanUnifyCoordinateSystemWithHmd_Bool: + str = "Can unify coordinate system with HMD"; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_ContainsProximitySensor_Bool: + str = "Contains proximity sensor"; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DeviceProvidesBatteryStatus_Bool: + str = "Device provides battery status"; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DeviceCanPowerOff_Bool: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_Firmware_ProgrammingTarget_String: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DeviceClass_Int32: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_HasCamera_Bool: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DriverVersion_String: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_Firmware_ForceUpdateRequired_Bool: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_ViveSystemButtonFixRequired_Bool: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_ParentDriver_Uint64: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_ReportsTimeSinceVSync_Bool: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_SecondsFromVsyncToPhotons_Float: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DisplayFrequency_Float: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_UserIpdMeters_Float: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_CurrentUniverseId_Uint64: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_PreviousUniverseId_Uint64: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DisplayFirmwareVersion_Uint64: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_IsOnDesktop_Bool: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DisplayMCType_Int32: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DisplayMCOffset_Float: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DisplayMCScale_Float: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_EdidVendorID_Int32: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DisplayMCImageLeft_String: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DisplayMCImageRight_String: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DisplayGCBlackClamp_Float: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_EdidProductID_Int32: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_CameraToHeadTransform_Matrix34: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DisplayGCType_Int32: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DisplayGCOffset_Float: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DisplayGCScale_Float: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DisplayGCPrescale_Float: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DisplayGCImage_String: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_LensCenterLeftU_Float: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_LensCenterLeftV_Float: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_LensCenterRightU_Float: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_LensCenterRightV_Float: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_UserHeadToEyeDepthMeters_Float: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_CameraFirmwareVersion_Uint64: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_CameraFirmwareDescription_String: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DisplayFPGAVersion_Uint64: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DisplayBootloaderVersion_Uint64: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DisplayHardwareVersion_Uint64: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_AudioFirmwareVersion_Uint64: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_CameraCompatibilityMode_Int32: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_ScreenshotHorizontalFieldOfViewDegrees_Float: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_ScreenshotVerticalFieldOfViewDegrees_Float: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DisplaySuppressed_Bool: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DisplayAllowNightMode_Bool: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DisplayMCImageWidth_Int32: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DisplayMCImageHeight_Int32: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DisplayMCImageNumChannels_Int32: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DisplayMCImageData_Binary: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_AttachedDeviceId_String: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_SupportedButtons_Uint64: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_Axis0Type_Int32: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_Axis1Type_Int32: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_Axis2Type_Int32: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_Axis3Type_Int32: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_Axis4Type_Int32: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_ControllerRoleHint_Int32: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_FieldOfViewLeftDegrees_Float: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_FieldOfViewRightDegrees_Float: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_FieldOfViewTopDegrees_Float: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_FieldOfViewBottomDegrees_Float: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_TrackingRangeMinimumMeters_Float: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_TrackingRangeMaximumMeters_Float: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_ModeLabel_String: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_IconPathName_String: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_NamedIconPathDeviceOff_String: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_NamedIconPathDeviceSearching_String: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_NamedIconPathDeviceSearchingAlert_String: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_NamedIconPathDeviceReady_String: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_NamedIconPathDeviceReadyAlert_String: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_NamedIconPathDeviceNotReady_String: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_NamedIconPathDeviceStandby_String: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_NamedIconPathDeviceAlertLow_String: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DisplayHiddenArea_Binary_Start: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DisplayHiddenArea_Binary_End: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_UserConfigPath_String: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_InstallPath_String: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_VendorSpecific_Reserved_Start: + str = ""; + break; + case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_VendorSpecific_Reserved_End: + str = ""; + break; + } + + + return str; + } +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/RenderModel_ComponentState_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/RenderModel_ComponentState_t.java new file mode 100644 index 0000000000..7e72d93c88 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/RenderModel_ComponentState_t.java @@ -0,0 +1,46 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1557
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class RenderModel_ComponentState_t extends Structure { + /** C type : HmdMatrix34_t */ + public HmdMatrix34_t mTrackingToComponentRenderModel; + /** C type : HmdMatrix34_t */ + public HmdMatrix34_t mTrackingToComponentLocal; + /** C type : VRComponentProperties */ + public int uProperties; + public RenderModel_ComponentState_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("mTrackingToComponentRenderModel", "mTrackingToComponentLocal", "uProperties"); + } + /** + * @param mTrackingToComponentRenderModel C type : HmdMatrix34_t
+ * @param mTrackingToComponentLocal C type : HmdMatrix34_t
+ * @param uProperties C type : VRComponentProperties + */ + public RenderModel_ComponentState_t(HmdMatrix34_t mTrackingToComponentRenderModel, HmdMatrix34_t mTrackingToComponentLocal, int uProperties) { + super(); + this.mTrackingToComponentRenderModel = mTrackingToComponentRenderModel; + this.mTrackingToComponentLocal = mTrackingToComponentLocal; + this.uProperties = uProperties; + } + public RenderModel_ComponentState_t(Pointer peer) { + super(peer); + } + public static class ByReference extends RenderModel_ComponentState_t implements Structure.ByReference { + + }; + public static class ByValue extends RenderModel_ComponentState_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/RenderModel_ControllerMode_State_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/RenderModel_ControllerMode_State_t.java new file mode 100644 index 0000000000..cf1eac008f --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/RenderModel_ControllerMode_State_t.java @@ -0,0 +1,34 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1581
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class RenderModel_ControllerMode_State_t extends Structure { + public byte bScrollWheelVisible; + public RenderModel_ControllerMode_State_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("bScrollWheelVisible"); + } + public RenderModel_ControllerMode_State_t(byte bScrollWheelVisible) { + super(); + this.bScrollWheelVisible = bScrollWheelVisible; + } + public RenderModel_ControllerMode_State_t(Pointer peer) { + super(peer); + } + public static class ByReference extends RenderModel_ControllerMode_State_t implements Structure.ByReference { + + }; + public static class ByValue extends RenderModel_ControllerMode_State_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/RenderModel_TextureMap_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/RenderModel_TextureMap_t.java new file mode 100644 index 0000000000..41670df53b --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/RenderModel_TextureMap_t.java @@ -0,0 +1,46 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1569
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class RenderModel_TextureMap_t extends Structure { + public short unWidth; + public short unHeight; + /** + * const uint8_t *
+ * C type : uint8_t* + */ + public Pointer rubTextureMapData; + public RenderModel_TextureMap_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("unWidth", "unHeight", "rubTextureMapData"); + } + /** + * @param rubTextureMapData const uint8_t *
+ * C type : uint8_t* + */ + public RenderModel_TextureMap_t(short unWidth, short unHeight, Pointer rubTextureMapData) { + super(); + this.unWidth = unWidth; + this.unHeight = unHeight; + this.rubTextureMapData = rubTextureMapData; + } + public RenderModel_TextureMap_t(Pointer peer) { + super(peer); + } + public static class ByReference extends RenderModel_TextureMap_t implements Structure.ByReference { + + }; + public static class ByValue extends RenderModel_TextureMap_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/RenderModel_Vertex_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/RenderModel_Vertex_t.java new file mode 100644 index 0000000000..17fac6dd53 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/RenderModel_Vertex_t.java @@ -0,0 +1,52 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1563
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class RenderModel_Vertex_t extends Structure { + /** C type : HmdVector3_t */ + public HmdVector3_t vPosition; + /** C type : HmdVector3_t */ + public HmdVector3_t vNormal; + /** + * float[2]
+ * C type : float[2] + */ + public float[] rfTextureCoord = new float[2]; + public RenderModel_Vertex_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("vPosition", "vNormal", "rfTextureCoord"); + } + /** + * @param vPosition C type : HmdVector3_t
+ * @param vNormal C type : HmdVector3_t
+ * @param rfTextureCoord float[2]
+ * C type : float[2] + */ + public RenderModel_Vertex_t(HmdVector3_t vPosition, HmdVector3_t vNormal, float rfTextureCoord[]) { + super(); + this.vPosition = vPosition; + this.vNormal = vNormal; + if ((rfTextureCoord.length != this.rfTextureCoord.length)) + throw new IllegalArgumentException("Wrong array size !"); + this.rfTextureCoord = rfTextureCoord; + } + public RenderModel_Vertex_t(Pointer peer) { + super(peer); + } + public static class ByReference extends RenderModel_Vertex_t implements Structure.ByReference { + + }; + public static class ByValue extends RenderModel_Vertex_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/RenderModel_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/RenderModel_t.java new file mode 100644 index 0000000000..9828f148fe --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/RenderModel_t.java @@ -0,0 +1,59 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import com.sun.jna.ptr.ShortByReference; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1578
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class RenderModel_t extends Structure { + /** + * const struct vr::RenderModel_Vertex_t *
+ * C type : RenderModel_Vertex_t* + */ + public com.jme3.system.jopenvr.RenderModel_Vertex_t.ByReference rVertexData; + public int unVertexCount; + /** + * const uint16_t *
+ * C type : uint16_t* + */ + public ShortByReference rIndexData; + public int unTriangleCount; + /** C type : TextureID_t */ + public int diffuseTextureId; + public RenderModel_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("rVertexData", "unVertexCount", "rIndexData", "unTriangleCount", "diffuseTextureId"); + } + /** + * @param rVertexData const struct vr::RenderModel_Vertex_t *
+ * C type : RenderModel_Vertex_t*
+ * @param rIndexData const uint16_t *
+ * C type : uint16_t*
+ * @param diffuseTextureId C type : TextureID_t + */ + public RenderModel_t(com.jme3.system.jopenvr.RenderModel_Vertex_t.ByReference rVertexData, int unVertexCount, ShortByReference rIndexData, int unTriangleCount, int diffuseTextureId) { + super(); + this.rVertexData = rVertexData; + this.unVertexCount = unVertexCount; + this.rIndexData = rIndexData; + this.unTriangleCount = unTriangleCount; + this.diffuseTextureId = diffuseTextureId; + } + public RenderModel_t(Pointer peer) { + super(peer); + } + public static class ByReference extends RenderModel_t implements Structure.ByReference { + + }; + public static class ByValue extends RenderModel_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/SpatialAnchorPose_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/SpatialAnchorPose_t.java new file mode 100644 index 0000000000..2d3fc2cfdb --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/SpatialAnchorPose_t.java @@ -0,0 +1,36 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1636
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class SpatialAnchorPose_t extends Structure { + /** C type : HmdMatrix34_t */ + public HmdMatrix34_t mAnchorToAbsoluteTracking; + public SpatialAnchorPose_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("mAnchorToAbsoluteTracking"); + } + /** @param mAnchorToAbsoluteTracking C type : HmdMatrix34_t */ + public SpatialAnchorPose_t(HmdMatrix34_t mAnchorToAbsoluteTracking) { + super(); + this.mAnchorToAbsoluteTracking = mAnchorToAbsoluteTracking; + } + public SpatialAnchorPose_t(Pointer peer) { + super(peer); + } + public static class ByReference extends SpatialAnchorPose_t implements Structure.ByReference { + + }; + public static class ByValue extends SpatialAnchorPose_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/Texture_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/Texture_t.java new file mode 100644 index 0000000000..fc6cfeb95e --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/Texture_t.java @@ -0,0 +1,56 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1247
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class Texture_t extends Structure { + /** + * void *
+ * C type : void* + */ + public int handle; + /** + * C type : ETextureType + */ + public int eType; + /** + * C type : EColorSpace + */ + public int eColorSpace; + public Texture_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("handle", "eType", "eColorSpace"); + } + /** + * @param handle void *
+ * C type : void*
+ * @param eType @see JOpenVRLibrary.ETextureType
+ * C type : ETextureType
+ * @param eColorSpace @see JOpenVRLibrary.EColorSpace
+ * C type : EColorSpace + */ + public Texture_t(int handle, int eType, int eColorSpace) { + super(); + this.handle = handle; + this.eType = eType; + this.eColorSpace = eColorSpace; + } + public Texture_t(Pointer peer) { + super(peer); + } + public static class ByReference extends Texture_t implements Structure.ByReference { + + }; + public static class ByValue extends Texture_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/TrackedDevicePose_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/TrackedDevicePose_t.java new file mode 100644 index 0000000000..d2a39b1184 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/TrackedDevicePose_t.java @@ -0,0 +1,57 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1257
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class TrackedDevicePose_t extends Structure { + /** C type : HmdMatrix34_t */ + public HmdMatrix34_t mDeviceToAbsoluteTracking; + /** C type : HmdVector3_t */ + public HmdVector3_t vVelocity; + /** C type : HmdVector3_t */ + public HmdVector3_t vAngularVelocity; + /** + * C type : ETrackingResult + */ + public int eTrackingResult; + public byte bPoseIsValid; + public byte bDeviceIsConnected; + public TrackedDevicePose_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("mDeviceToAbsoluteTracking", "vVelocity", "vAngularVelocity", "eTrackingResult", "bPoseIsValid", "bDeviceIsConnected"); + } + /** + * @param mDeviceToAbsoluteTracking C type : HmdMatrix34_t
+ * @param vVelocity C type : HmdVector3_t
+ * @param vAngularVelocity C type : HmdVector3_t
+ * @param eTrackingResult @see JOpenVRLibrary.ETrackingResult
+ * C type : ETrackingResult + */ + public TrackedDevicePose_t(HmdMatrix34_t mDeviceToAbsoluteTracking, HmdVector3_t vVelocity, HmdVector3_t vAngularVelocity, int eTrackingResult, byte bPoseIsValid, byte bDeviceIsConnected) { + super(); + this.mDeviceToAbsoluteTracking = mDeviceToAbsoluteTracking; + this.vVelocity = vVelocity; + this.vAngularVelocity = vAngularVelocity; + this.eTrackingResult = eTrackingResult; + this.bPoseIsValid = bPoseIsValid; + this.bDeviceIsConnected = bDeviceIsConnected; + } + public TrackedDevicePose_t(Pointer peer) { + super(peer); + } + public static class ByReference extends TrackedDevicePose_t implements Structure.ByReference { + + }; + public static class ByValue extends TrackedDevicePose_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRActiveActionSet_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRActiveActionSet_t.java new file mode 100644 index 0000000000..49720d038e --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRActiveActionSet_t.java @@ -0,0 +1,50 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1633
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VRActiveActionSet_t extends Structure { + /** C type : VRActionSetHandle_t */ + public long ulActionSet; + /** C type : VRInputValueHandle_t */ + public long ulRestrictedToDevice; + /** C type : VRActionSetHandle_t */ + public long ulSecondaryActionSet; + public int unPadding; + public int nPriority; + public VRActiveActionSet_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("ulActionSet", "ulRestrictedToDevice", "ulSecondaryActionSet", "unPadding", "nPriority"); + } + /** + * @param ulActionSet C type : VRActionSetHandle_t
+ * @param ulRestrictedToDevice C type : VRInputValueHandle_t
+ * @param ulSecondaryActionSet C type : VRActionSetHandle_t + */ + public VRActiveActionSet_t(long ulActionSet, long ulRestrictedToDevice, long ulSecondaryActionSet, int unPadding, int nPriority) { + super(); + this.ulActionSet = ulActionSet; + this.ulRestrictedToDevice = ulRestrictedToDevice; + this.ulSecondaryActionSet = ulSecondaryActionSet; + this.unPadding = unPadding; + this.nPriority = nPriority; + } + public VRActiveActionSet_t(Pointer peer) { + super(peer); + } + public static class ByReference extends VRActiveActionSet_t implements Structure.ByReference { + + }; + public static class ByValue extends VRActiveActionSet_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRBoneTransform_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRBoneTransform_t.java new file mode 100644 index 0000000000..e6e7626d24 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRBoneTransform_t.java @@ -0,0 +1,42 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1456
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VRBoneTransform_t extends Structure { + /** C type : HmdVector4_t */ + public HmdVector4_t position; + /** C type : HmdQuaternionf_t */ + public HmdQuaternionf_t orientation; + public VRBoneTransform_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("position", "orientation"); + } + /** + * @param position C type : HmdVector4_t
+ * @param orientation C type : HmdQuaternionf_t + */ + public VRBoneTransform_t(HmdVector4_t position, HmdQuaternionf_t orientation) { + super(); + this.position = position; + this.orientation = orientation; + } + public VRBoneTransform_t(Pointer peer) { + super(peer); + } + public static class ByReference extends VRBoneTransform_t implements Structure.ByReference { + + }; + public static class ByValue extends VRBoneTransform_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRControllerAxis_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRControllerAxis_t.java new file mode 100644 index 0000000000..41f0e13665 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRControllerAxis_t.java @@ -0,0 +1,36 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1429
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VRControllerAxis_t extends Structure { + public float x; + public float y; + public VRControllerAxis_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("x", "y"); + } + public VRControllerAxis_t(float x, float y) { + super(); + this.x = x; + this.y = y; + } + public VRControllerAxis_t(Pointer peer) { + super(peer); + } + public static class ByReference extends VRControllerAxis_t implements Structure.ByReference { + + }; + public static class ByValue extends VRControllerAxis_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRControllerState_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRControllerState_t.java new file mode 100644 index 0000000000..9adc41c7d2 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRControllerState_t.java @@ -0,0 +1,50 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1436
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VRControllerState_t extends Structure { + public int unPacketNum; + public long ulButtonPressed; + public long ulButtonTouched; + /** + * struct vr::VRControllerAxis_t[5]
+ * C type : VRControllerAxis_t[5] + */ + public VRControllerAxis_t[] rAxis = new VRControllerAxis_t[5]; + public VRControllerState_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("unPacketNum", "ulButtonPressed", "ulButtonTouched", "rAxis"); + } + /** + * @param rAxis struct vr::VRControllerAxis_t[5]
+ * C type : VRControllerAxis_t[5] + */ + public VRControllerState_t(int unPacketNum, long ulButtonPressed, long ulButtonTouched, VRControllerAxis_t rAxis[]) { + super(); + this.unPacketNum = unPacketNum; + this.ulButtonPressed = ulButtonPressed; + this.ulButtonTouched = ulButtonTouched; + if ((rAxis.length != this.rAxis.length)) + throw new IllegalArgumentException("Wrong array size !"); + this.rAxis = rAxis; + } + public VRControllerState_t(Pointer peer) { + super(peer); + } + public static class ByReference extends VRControllerState_t implements Structure.ByReference { + + }; + public static class ByValue extends VRControllerState_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_ApplicationLaunch_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_ApplicationLaunch_t.java new file mode 100644 index 0000000000..845ca8799c --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_ApplicationLaunch_t.java @@ -0,0 +1,36 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1373
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VREvent_ApplicationLaunch_t extends Structure { + public int pid; + public int unArgsHandle; + public VREvent_ApplicationLaunch_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("pid", "unArgsHandle"); + } + public VREvent_ApplicationLaunch_t(int pid, int unArgsHandle) { + super(); + this.pid = pid; + this.unArgsHandle = unArgsHandle; + } + public VREvent_ApplicationLaunch_t(Pointer peer) { + super(peer); + } + public static class ByReference extends VREvent_ApplicationLaunch_t implements Structure.ByReference { + + }; + public static class ByValue extends VREvent_ApplicationLaunch_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Chaperone_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Chaperone_t.java new file mode 100644 index 0000000000..92e97a4580 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Chaperone_t.java @@ -0,0 +1,36 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1350
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VREvent_Chaperone_t extends Structure { + public long m_nPreviousUniverse; + public long m_nCurrentUniverse; + public VREvent_Chaperone_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("m_nPreviousUniverse", "m_nCurrentUniverse"); + } + public VREvent_Chaperone_t(long m_nPreviousUniverse, long m_nCurrentUniverse) { + super(); + this.m_nPreviousUniverse = m_nPreviousUniverse; + this.m_nCurrentUniverse = m_nCurrentUniverse; + } + public VREvent_Chaperone_t(Pointer peer) { + super(peer); + } + public static class ByReference extends VREvent_Chaperone_t implements Structure.ByReference { + + }; + public static class ByValue extends VREvent_Chaperone_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Controller_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Controller_t.java new file mode 100644 index 0000000000..e7959582cc --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Controller_t.java @@ -0,0 +1,34 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1304
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VREvent_Controller_t extends Structure { + public int button; + public VREvent_Controller_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("button"); + } + public VREvent_Controller_t(int button) { + super(); + this.button = button; + } + public VREvent_Controller_t(Pointer peer) { + super(peer); + } + public static class ByReference extends VREvent_Controller_t implements Structure.ByReference { + + }; + public static class ByValue extends VREvent_Controller_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Data_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Data_t.java new file mode 100644 index 0000000000..983a7da823 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Data_t.java @@ -0,0 +1,135 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Union; +/** + * native declaration : headers\openvr_capi.h:1686
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VREvent_Data_t extends Union { + /** C type : VREvent_Reserved_t */ + public VREvent_Reserved_t reserved; + /** C type : VREvent_Controller_t */ + public VREvent_Controller_t controller; + /** C type : VREvent_Mouse_t */ + public VREvent_Mouse_t mouse; + /** C type : VREvent_Scroll_t */ + public VREvent_Scroll_t scroll; + /** C type : VREvent_Process_t */ + public VREvent_Process_t process; + /** C type : VREvent_Notification_t */ + public VREvent_Notification_t notification; + /** C type : VREvent_Overlay_t */ + public VREvent_Overlay_t overlay; + /** C type : VREvent_Status_t */ + public VREvent_Status_t status; + /** C type : VREvent_Keyboard_t */ + public VREvent_Keyboard_t keyboard; + /** C type : VREvent_Ipd_t */ + public VREvent_Ipd_t ipd; + /** C type : VREvent_Chaperone_t */ + public VREvent_Chaperone_t chaperone; + /** C type : VREvent_PerformanceTest_t */ + public VREvent_PerformanceTest_t performanceTest; + /** C type : VREvent_TouchPadMove_t */ + public VREvent_TouchPadMove_t touchPadMove; + /** C type : VREvent_SeatedZeroPoseReset_t */ + public VREvent_SeatedZeroPoseReset_t seatedZeroPoseReset; + public VREvent_Data_t() { + super(); + } + /** @param reserved C type : VREvent_Reserved_t */ + public VREvent_Data_t(VREvent_Reserved_t reserved) { + super(); + this.reserved = reserved; + setType(VREvent_Reserved_t.class); + } + /** @param controller C type : VREvent_Controller_t */ + public VREvent_Data_t(VREvent_Controller_t controller) { + super(); + this.controller = controller; + setType(VREvent_Controller_t.class); + } + /** @param mouse C type : VREvent_Mouse_t */ + public VREvent_Data_t(VREvent_Mouse_t mouse) { + super(); + this.mouse = mouse; + setType(VREvent_Mouse_t.class); + } + /** @param scroll C type : VREvent_Scroll_t */ + public VREvent_Data_t(VREvent_Scroll_t scroll) { + super(); + this.scroll = scroll; + setType(VREvent_Scroll_t.class); + } + /** @param process C type : VREvent_Process_t */ + public VREvent_Data_t(VREvent_Process_t process) { + super(); + this.process = process; + setType(VREvent_Process_t.class); + } + /** @param notification C type : VREvent_Notification_t */ + public VREvent_Data_t(VREvent_Notification_t notification) { + super(); + this.notification = notification; + setType(VREvent_Notification_t.class); + } + /** @param overlay C type : VREvent_Overlay_t */ + public VREvent_Data_t(VREvent_Overlay_t overlay) { + super(); + this.overlay = overlay; + setType(VREvent_Overlay_t.class); + } + /** @param status C type : VREvent_Status_t */ + public VREvent_Data_t(VREvent_Status_t status) { + super(); + this.status = status; + setType(VREvent_Status_t.class); + } + /** @param keyboard C type : VREvent_Keyboard_t */ + public VREvent_Data_t(VREvent_Keyboard_t keyboard) { + super(); + this.keyboard = keyboard; + setType(VREvent_Keyboard_t.class); + } + /** @param ipd C type : VREvent_Ipd_t */ + public VREvent_Data_t(VREvent_Ipd_t ipd) { + super(); + this.ipd = ipd; + setType(VREvent_Ipd_t.class); + } + /** @param chaperone C type : VREvent_Chaperone_t */ + public VREvent_Data_t(VREvent_Chaperone_t chaperone) { + super(); + this.chaperone = chaperone; + setType(VREvent_Chaperone_t.class); + } + /** @param performanceTest C type : VREvent_PerformanceTest_t */ + public VREvent_Data_t(VREvent_PerformanceTest_t performanceTest) { + super(); + this.performanceTest = performanceTest; + setType(VREvent_PerformanceTest_t.class); + } + /** @param touchPadMove C type : VREvent_TouchPadMove_t */ + public VREvent_Data_t(VREvent_TouchPadMove_t touchPadMove) { + super(); + this.touchPadMove = touchPadMove; + setType(VREvent_TouchPadMove_t.class); + } + /** @param seatedZeroPoseReset C type : VREvent_SeatedZeroPoseReset_t */ + public VREvent_Data_t(VREvent_SeatedZeroPoseReset_t seatedZeroPoseReset) { + super(); + this.seatedZeroPoseReset = seatedZeroPoseReset; + setType(VREvent_SeatedZeroPoseReset_t.class); + } + public VREvent_Data_t(Pointer peer) { + super(peer); + } + public static class ByReference extends VREvent_Data_t implements com.sun.jna.Structure.ByReference { + + }; + public static class ByValue extends VREvent_Data_t implements com.sun.jna.Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_DualAnalog_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_DualAnalog_t.java new file mode 100644 index 0000000000..f5e45f5b24 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_DualAnalog_t.java @@ -0,0 +1,49 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1395
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VREvent_DualAnalog_t extends Structure { + public float x; + public float y; + public float transformedX; + public float transformedY; + /** + * C type : EDualAnalogWhich + */ + public int which; + public VREvent_DualAnalog_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("x", "y", "transformedX", "transformedY", "which"); + } + /** + * @param which @see JOpenVRLibrary.EDualAnalogWhich
+ * C type : EDualAnalogWhich + */ + public VREvent_DualAnalog_t(float x, float y, float transformedX, float transformedY, int which) { + super(); + this.x = x; + this.y = y; + this.transformedX = transformedX; + this.transformedY = transformedY; + this.which = which; + } + public VREvent_DualAnalog_t(Pointer peer) { + super(peer); + } + public static class ByReference extends VREvent_DualAnalog_t implements Structure.ByReference { + + }; + public static class ByValue extends VREvent_DualAnalog_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_EditingCameraSurface_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_EditingCameraSurface_t.java new file mode 100644 index 0000000000..5a54cdd582 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_EditingCameraSurface_t.java @@ -0,0 +1,36 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1377
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VREvent_EditingCameraSurface_t extends Structure { + public long overlayHandle; + public int nVisualMode; + public VREvent_EditingCameraSurface_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("overlayHandle", "nVisualMode"); + } + public VREvent_EditingCameraSurface_t(long overlayHandle, int nVisualMode) { + super(); + this.overlayHandle = overlayHandle; + this.nVisualMode = nVisualMode; + } + public VREvent_EditingCameraSurface_t(Pointer peer) { + super(peer); + } + public static class ByReference extends VREvent_EditingCameraSurface_t implements Structure.ByReference { + + }; + public static class ByValue extends VREvent_EditingCameraSurface_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_HapticVibration_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_HapticVibration_t.java new file mode 100644 index 0000000000..7175e4c862 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_HapticVibration_t.java @@ -0,0 +1,42 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1402
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VREvent_HapticVibration_t extends Structure { + public long containerHandle; + public long componentHandle; + public float fDurationSeconds; + public float fFrequency; + public float fAmplitude; + public VREvent_HapticVibration_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("containerHandle", "componentHandle", "fDurationSeconds", "fFrequency", "fAmplitude"); + } + public VREvent_HapticVibration_t(long containerHandle, long componentHandle, float fDurationSeconds, float fFrequency, float fAmplitude) { + super(); + this.containerHandle = containerHandle; + this.componentHandle = componentHandle; + this.fDurationSeconds = fDurationSeconds; + this.fFrequency = fFrequency; + this.fAmplitude = fAmplitude; + } + public VREvent_HapticVibration_t(Pointer peer) { + super(peer); + } + public static class ByReference extends VREvent_HapticVibration_t implements Structure.ByReference { + + }; + public static class ByValue extends VREvent_HapticVibration_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_InputActionManifestLoad_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_InputActionManifestLoad_t.java new file mode 100644 index 0000000000..427eddfbc2 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_InputActionManifestLoad_t.java @@ -0,0 +1,40 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1417
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VREvent_InputActionManifestLoad_t extends Structure { + public long pathAppKey; + public long pathMessage; + public long pathMessageParam; + public long pathManifestPath; + public VREvent_InputActionManifestLoad_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("pathAppKey", "pathMessage", "pathMessageParam", "pathManifestPath"); + } + public VREvent_InputActionManifestLoad_t(long pathAppKey, long pathMessage, long pathMessageParam, long pathManifestPath) { + super(); + this.pathAppKey = pathAppKey; + this.pathMessage = pathMessage; + this.pathMessageParam = pathMessageParam; + this.pathManifestPath = pathManifestPath; + } + public VREvent_InputActionManifestLoad_t(Pointer peer) { + super(peer); + } + public static class ByReference extends VREvent_InputActionManifestLoad_t implements Structure.ByReference { + + }; + public static class ByValue extends VREvent_InputActionManifestLoad_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_InputBindingLoad_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_InputBindingLoad_t.java new file mode 100644 index 0000000000..9b88905847 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_InputBindingLoad_t.java @@ -0,0 +1,42 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1411
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VREvent_InputBindingLoad_t extends Structure { + /** C type : PropertyContainerHandle_t */ + public long ulAppContainer; + public long pathMessage; + public long pathUrl; + public long pathControllerType; + public VREvent_InputBindingLoad_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("ulAppContainer", "pathMessage", "pathUrl", "pathControllerType"); + } + /** @param ulAppContainer C type : PropertyContainerHandle_t */ + public VREvent_InputBindingLoad_t(long ulAppContainer, long pathMessage, long pathUrl, long pathControllerType) { + super(); + this.ulAppContainer = ulAppContainer; + this.pathMessage = pathMessage; + this.pathUrl = pathUrl; + this.pathControllerType = pathControllerType; + } + public VREvent_InputBindingLoad_t(Pointer peer) { + super(peer); + } + public static class ByReference extends VREvent_InputBindingLoad_t implements Structure.ByReference { + + }; + public static class ByValue extends VREvent_InputBindingLoad_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Ipd_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Ipd_t.java new file mode 100644 index 0000000000..afc05f74ea --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Ipd_t.java @@ -0,0 +1,34 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1346
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VREvent_Ipd_t extends Structure { + public float ipdMeters; + public VREvent_Ipd_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("ipdMeters"); + } + public VREvent_Ipd_t(float ipdMeters) { + super(); + this.ipdMeters = ipdMeters; + } + public VREvent_Ipd_t(Pointer peer) { + super(peer); + } + public static class ByReference extends VREvent_Ipd_t implements Structure.ByReference { + + }; + public static class ByValue extends VREvent_Ipd_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Keyboard_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Keyboard_t.java new file mode 100644 index 0000000000..9cf8c64ed3 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Keyboard_t.java @@ -0,0 +1,46 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1343
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VREvent_Keyboard_t extends Structure { + /** + * char[8]
+ * C type : char*[8] + */ + public Pointer[] cNewInput = new Pointer[8]; + public long uUserValue; + public VREvent_Keyboard_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("cNewInput", "uUserValue"); + } + /** + * @param cNewInput char[8]
+ * C type : char*[8] + */ + public VREvent_Keyboard_t(Pointer cNewInput[], long uUserValue) { + super(); + if ((cNewInput.length != this.cNewInput.length)) + throw new IllegalArgumentException("Wrong array size !"); + this.cNewInput = cNewInput; + this.uUserValue = uUserValue; + } + public VREvent_Keyboard_t(Pointer peer) { + super(peer); + } + public static class ByReference extends VREvent_Keyboard_t implements Structure.ByReference { + + }; + public static class ByValue extends VREvent_Keyboard_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_MessageOverlay_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_MessageOverlay_t.java new file mode 100644 index 0000000000..b0fe1b8c2e --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_MessageOverlay_t.java @@ -0,0 +1,34 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1380
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VREvent_MessageOverlay_t extends Structure { + public int unVRMessageOverlayResponse; + public VREvent_MessageOverlay_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("unVRMessageOverlayResponse"); + } + public VREvent_MessageOverlay_t(int unVRMessageOverlayResponse) { + super(); + this.unVRMessageOverlayResponse = unVRMessageOverlayResponse; + } + public VREvent_MessageOverlay_t(Pointer peer) { + super(peer); + } + public static class ByReference extends VREvent_MessageOverlay_t implements Structure.ByReference { + + }; + public static class ByValue extends VREvent_MessageOverlay_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Mouse_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Mouse_t.java new file mode 100644 index 0000000000..d20db8c841 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Mouse_t.java @@ -0,0 +1,38 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1309
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VREvent_Mouse_t extends Structure { + public float x; + public float y; + public int button; + public VREvent_Mouse_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("x", "y", "button"); + } + public VREvent_Mouse_t(float x, float y, int button) { + super(); + this.x = x; + this.y = y; + this.button = button; + } + public VREvent_Mouse_t(Pointer peer) { + super(peer); + } + public static class ByReference extends VREvent_Mouse_t implements Structure.ByReference { + + }; + public static class ByValue extends VREvent_Mouse_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Notification_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Notification_t.java new file mode 100644 index 0000000000..fa67bd5e7c --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Notification_t.java @@ -0,0 +1,36 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1326
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VREvent_Notification_t extends Structure { + public long ulUserValue; + public int notificationId; + public VREvent_Notification_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("ulUserValue", "notificationId"); + } + public VREvent_Notification_t(long ulUserValue, int notificationId) { + super(); + this.ulUserValue = ulUserValue; + this.notificationId = notificationId; + } + public VREvent_Notification_t(Pointer peer) { + super(peer); + } + public static class ByReference extends VREvent_Notification_t implements Structure.ByReference { + + }; + public static class ByValue extends VREvent_Notification_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Overlay_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Overlay_t.java new file mode 100644 index 0000000000..683c485ab7 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Overlay_t.java @@ -0,0 +1,36 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1335
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VREvent_Overlay_t extends Structure { + public long overlayHandle; + public long devicePath; + public VREvent_Overlay_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("overlayHandle", "devicePath"); + } + public VREvent_Overlay_t(long overlayHandle, long devicePath) { + super(); + this.overlayHandle = overlayHandle; + this.devicePath = devicePath; + } + public VREvent_Overlay_t(Pointer peer) { + super(peer); + } + public static class ByReference extends VREvent_Overlay_t implements Structure.ByReference { + + }; + public static class ByValue extends VREvent_Overlay_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_PerformanceTest_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_PerformanceTest_t.java new file mode 100644 index 0000000000..13f14852cc --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_PerformanceTest_t.java @@ -0,0 +1,34 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1359
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VREvent_PerformanceTest_t extends Structure { + public int m_nFidelityLevel; + public VREvent_PerformanceTest_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("m_nFidelityLevel"); + } + public VREvent_PerformanceTest_t(int m_nFidelityLevel) { + super(); + this.m_nFidelityLevel = m_nFidelityLevel; + } + public VREvent_PerformanceTest_t(Pointer peer) { + super(peer); + } + public static class ByReference extends VREvent_PerformanceTest_t implements Structure.ByReference { + + }; + public static class ByValue extends VREvent_PerformanceTest_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Process_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Process_t.java new file mode 100644 index 0000000000..0e7f9ae2fb --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Process_t.java @@ -0,0 +1,38 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1331
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VREvent_Process_t extends Structure { + public int pid; + public int oldPid; + public byte bForced; + public VREvent_Process_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("pid", "oldPid", "bForced"); + } + public VREvent_Process_t(int pid, int oldPid, byte bForced) { + super(); + this.pid = pid; + this.oldPid = oldPid; + this.bForced = bForced; + } + public VREvent_Process_t(Pointer peer) { + super(peer); + } + public static class ByReference extends VREvent_Process_t implements Structure.ByReference { + + }; + public static class ByValue extends VREvent_Process_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Property_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Property_t.java new file mode 100644 index 0000000000..be84aa3129 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Property_t.java @@ -0,0 +1,45 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1386
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VREvent_Property_t extends Structure { + /** C type : PropertyContainerHandle_t */ + public long container; + /** + * C type : ETrackedDeviceProperty + */ + public int prop; + public VREvent_Property_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("container", "prop"); + } + /** + * @param container C type : PropertyContainerHandle_t
+ * @param prop @see JOpenVRLibrary.ETrackedDeviceProperty
+ * C type : ETrackedDeviceProperty + */ + public VREvent_Property_t(long container, int prop) { + super(); + this.container = container; + this.prop = prop; + } + public VREvent_Property_t(Pointer peer) { + super(peer); + } + public static class ByReference extends VREvent_Property_t implements Structure.ByReference { + + }; + public static class ByValue extends VREvent_Property_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Reserved_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Reserved_t.java new file mode 100644 index 0000000000..13f0c8d822 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Reserved_t.java @@ -0,0 +1,40 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1356
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VREvent_Reserved_t extends Structure { + public long reserved0; + public long reserved1; + public long reserved2; + public long reserved3; + public VREvent_Reserved_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("reserved0", "reserved1", "reserved2", "reserved3"); + } + public VREvent_Reserved_t(long reserved0, long reserved1, long reserved2, long reserved3) { + super(); + this.reserved0 = reserved0; + this.reserved1 = reserved1; + this.reserved2 = reserved2; + this.reserved3 = reserved3; + } + public VREvent_Reserved_t(Pointer peer) { + super(peer); + } + public static class ByReference extends VREvent_Reserved_t implements Structure.ByReference { + + }; + public static class ByValue extends VREvent_Reserved_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_ScreenshotProgress_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_ScreenshotProgress_t.java new file mode 100644 index 0000000000..b0511dbc24 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_ScreenshotProgress_t.java @@ -0,0 +1,34 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1369
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VREvent_ScreenshotProgress_t extends Structure { + public float progress; + public VREvent_ScreenshotProgress_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("progress"); + } + public VREvent_ScreenshotProgress_t(float progress) { + super(); + this.progress = progress; + } + public VREvent_ScreenshotProgress_t(Pointer peer) { + super(peer); + } + public static class ByReference extends VREvent_ScreenshotProgress_t implements Structure.ByReference { + + }; + public static class ByValue extends VREvent_ScreenshotProgress_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Screenshot_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Screenshot_t.java new file mode 100644 index 0000000000..c35acd1390 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Screenshot_t.java @@ -0,0 +1,36 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1366
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VREvent_Screenshot_t extends Structure { + public int handle; + public int type; + public VREvent_Screenshot_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("handle", "type"); + } + public VREvent_Screenshot_t(int handle, int type) { + super(); + this.handle = handle; + this.type = type; + } + public VREvent_Screenshot_t(Pointer peer) { + super(peer); + } + public static class ByReference extends VREvent_Screenshot_t implements Structure.ByReference { + + }; + public static class ByValue extends VREvent_Screenshot_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Scroll_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Scroll_t.java new file mode 100644 index 0000000000..1d29ea839b --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Scroll_t.java @@ -0,0 +1,38 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1314
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VREvent_Scroll_t extends Structure { + public float xdelta; + public float ydelta; + public int repeatCount; + public VREvent_Scroll_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("xdelta", "ydelta", "repeatCount"); + } + public VREvent_Scroll_t(float xdelta, float ydelta, int repeatCount) { + super(); + this.xdelta = xdelta; + this.ydelta = ydelta; + this.repeatCount = repeatCount; + } + public VREvent_Scroll_t(Pointer peer) { + super(peer); + } + public static class ByReference extends VREvent_Scroll_t implements Structure.ByReference { + + }; + public static class ByValue extends VREvent_Scroll_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_SeatedZeroPoseReset_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_SeatedZeroPoseReset_t.java new file mode 100644 index 0000000000..cb7c9f62c5 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_SeatedZeroPoseReset_t.java @@ -0,0 +1,34 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1362
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VREvent_SeatedZeroPoseReset_t extends Structure { + public byte bResetBySystemMenu; + public VREvent_SeatedZeroPoseReset_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("bResetBySystemMenu"); + } + public VREvent_SeatedZeroPoseReset_t(byte bResetBySystemMenu) { + super(); + this.bResetBySystemMenu = bResetBySystemMenu; + } + public VREvent_SeatedZeroPoseReset_t(Pointer peer) { + super(peer); + } + public static class ByReference extends VREvent_SeatedZeroPoseReset_t implements Structure.ByReference { + + }; + public static class ByValue extends VREvent_SeatedZeroPoseReset_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_SpatialAnchor_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_SpatialAnchor_t.java new file mode 100644 index 0000000000..eeb51f2e26 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_SpatialAnchor_t.java @@ -0,0 +1,36 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1420
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VREvent_SpatialAnchor_t extends Structure { + /** C type : SpatialAnchorHandle_t */ + public int unHandle; + public VREvent_SpatialAnchor_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("unHandle"); + } + /** @param unHandle C type : SpatialAnchorHandle_t */ + public VREvent_SpatialAnchor_t(int unHandle) { + super(); + this.unHandle = unHandle; + } + public VREvent_SpatialAnchor_t(Pointer peer) { + super(peer); + } + public static class ByReference extends VREvent_SpatialAnchor_t implements Structure.ByReference { + + }; + public static class ByValue extends VREvent_SpatialAnchor_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Status_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Status_t.java new file mode 100644 index 0000000000..d16d2c0727 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Status_t.java @@ -0,0 +1,34 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1338
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VREvent_Status_t extends Structure { + public int statusState; + public VREvent_Status_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("statusState"); + } + public VREvent_Status_t(int statusState) { + super(); + this.statusState = statusState; + } + public VREvent_Status_t(Pointer peer) { + super(peer); + } + public static class ByReference extends VREvent_Status_t implements Structure.ByReference { + + }; + public static class ByValue extends VREvent_Status_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_TouchPadMove_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_TouchPadMove_t.java new file mode 100644 index 0000000000..dd123e0d3b --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_TouchPadMove_t.java @@ -0,0 +1,44 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1322
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VREvent_TouchPadMove_t extends Structure { + public byte bFingerDown; + public float flSecondsFingerDown; + public float fValueXFirst; + public float fValueYFirst; + public float fValueXRaw; + public float fValueYRaw; + public VREvent_TouchPadMove_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("bFingerDown", "flSecondsFingerDown", "fValueXFirst", "fValueYFirst", "fValueXRaw", "fValueYRaw"); + } + public VREvent_TouchPadMove_t(byte bFingerDown, float flSecondsFingerDown, float fValueXFirst, float fValueYFirst, float fValueXRaw, float fValueYRaw) { + super(); + this.bFingerDown = bFingerDown; + this.flSecondsFingerDown = flSecondsFingerDown; + this.fValueXFirst = fValueXFirst; + this.fValueYFirst = fValueYFirst; + this.fValueXRaw = fValueXRaw; + this.fValueYRaw = fValueYRaw; + } + public VREvent_TouchPadMove_t(Pointer peer) { + super(peer); + } + public static class ByReference extends VREvent_TouchPadMove_t implements Structure.ByReference { + + }; + public static class ByValue extends VREvent_TouchPadMove_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_WebConsole_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_WebConsole_t.java new file mode 100644 index 0000000000..21d9bdf390 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_WebConsole_t.java @@ -0,0 +1,36 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1405
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VREvent_WebConsole_t extends Structure { + /** C type : WebConsoleHandle_t */ + public long webConsoleHandle; + public VREvent_WebConsole_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("webConsoleHandle"); + } + /** @param webConsoleHandle C type : WebConsoleHandle_t */ + public VREvent_WebConsole_t(long webConsoleHandle) { + super(); + this.webConsoleHandle = webConsoleHandle; + } + public VREvent_WebConsole_t(Pointer peer) { + super(peer); + } + public static class ByReference extends VREvent_WebConsole_t implements Structure.ByReference { + + }; + public static class ByValue extends VREvent_WebConsole_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_t.java new file mode 100644 index 0000000000..843f9da821 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_t.java @@ -0,0 +1,49 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * An event posted by the server to all running applications
+ * native declaration : headers\openvr_capi.h:1694
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VREvent_t extends Structure { + /** EVREventType enum */ + public int eventType; + /** C type : TrackedDeviceIndex_t */ + public int trackedDeviceIndex; + public float eventAgeSeconds; + /** C type : VREvent_Data_t */ + public VREvent_Data_t data; + public VREvent_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("eventType", "trackedDeviceIndex", "eventAgeSeconds", "data"); + } + /** + * @param eventType EVREventType enum
+ * @param trackedDeviceIndex C type : TrackedDeviceIndex_t
+ * @param data C type : VREvent_Data_t + */ + public VREvent_t(int eventType, int trackedDeviceIndex, float eventAgeSeconds, VREvent_Data_t data) { + super(); + this.eventType = eventType; + this.trackedDeviceIndex = trackedDeviceIndex; + this.eventAgeSeconds = eventAgeSeconds; + this.data = data; + } + public VREvent_t(Pointer peer) { + super(peer); + } + public static class ByReference extends VREvent_t implements Structure.ByReference { + + }; + public static class ByValue extends VREvent_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VROverlayIntersectionMaskPrimitive_Data_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VROverlayIntersectionMaskPrimitive_Data_t.java new file mode 100644 index 0000000000..9020bf2852 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VROverlayIntersectionMaskPrimitive_Data_t.java @@ -0,0 +1,39 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Union; +/** + * native declaration : headers\openvr_capi.h:1698
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VROverlayIntersectionMaskPrimitive_Data_t extends Union { + /** C type : IntersectionMaskRectangle_t */ + public IntersectionMaskRectangle_t m_Rectangle; + /** C type : IntersectionMaskCircle_t */ + public IntersectionMaskCircle_t m_Circle; + public VROverlayIntersectionMaskPrimitive_Data_t() { + super(); + } + /** @param m_Rectangle C type : IntersectionMaskRectangle_t */ + public VROverlayIntersectionMaskPrimitive_Data_t(IntersectionMaskRectangle_t m_Rectangle) { + super(); + this.m_Rectangle = m_Rectangle; + setType(IntersectionMaskRectangle_t.class); + } + /** @param m_Circle C type : IntersectionMaskCircle_t */ + public VROverlayIntersectionMaskPrimitive_Data_t(IntersectionMaskCircle_t m_Circle) { + super(); + this.m_Circle = m_Circle; + setType(IntersectionMaskCircle_t.class); + } + public VROverlayIntersectionMaskPrimitive_Data_t(Pointer peer) { + super(peer); + } + public static class ByReference extends VROverlayIntersectionMaskPrimitive_Data_t implements com.sun.jna.Structure.ByReference { + + }; + public static class ByValue extends VROverlayIntersectionMaskPrimitive_Data_t implements com.sun.jna.Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VROverlayIntersectionMaskPrimitive_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VROverlayIntersectionMaskPrimitive_t.java new file mode 100644 index 0000000000..e0396fda97 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VROverlayIntersectionMaskPrimitive_t.java @@ -0,0 +1,45 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1702
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VROverlayIntersectionMaskPrimitive_t extends Structure { + /** + * C type : EVROverlayIntersectionMaskPrimitiveType + */ + public int m_nPrimitiveType; + /** C type : VROverlayIntersectionMaskPrimitive_Data_t */ + public VROverlayIntersectionMaskPrimitive_Data_t m_Primitive; + public VROverlayIntersectionMaskPrimitive_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("m_nPrimitiveType", "m_Primitive"); + } + /** + * @param m_nPrimitiveType @see JOpenVRLibrary.EVROverlayIntersectionMaskPrimitiveType
+ * C type : EVROverlayIntersectionMaskPrimitiveType
+ * @param m_Primitive C type : VROverlayIntersectionMaskPrimitive_Data_t + */ + public VROverlayIntersectionMaskPrimitive_t(int m_nPrimitiveType, VROverlayIntersectionMaskPrimitive_Data_t m_Primitive) { + super(); + this.m_nPrimitiveType = m_nPrimitiveType; + this.m_Primitive = m_Primitive; + } + public VROverlayIntersectionMaskPrimitive_t(Pointer peer) { + super(peer); + } + public static class ByReference extends VROverlayIntersectionMaskPrimitive_t implements Structure.ByReference { + + }; + public static class ByValue extends VROverlayIntersectionMaskPrimitive_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VROverlayIntersectionParams_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VROverlayIntersectionParams_t.java new file mode 100644 index 0000000000..053942a0e3 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VROverlayIntersectionParams_t.java @@ -0,0 +1,49 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1535
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VROverlayIntersectionParams_t extends Structure { + /** C type : HmdVector3_t */ + public HmdVector3_t vSource; + /** C type : HmdVector3_t */ + public HmdVector3_t vDirection; + /** + * C type : ETrackingUniverseOrigin + */ + public int eOrigin; + public VROverlayIntersectionParams_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("vSource", "vDirection", "eOrigin"); + } + /** + * @param vSource C type : HmdVector3_t
+ * @param vDirection C type : HmdVector3_t
+ * @param eOrigin @see JOpenVRLibrary.ETrackingUniverseOrigin
+ * C type : ETrackingUniverseOrigin + */ + public VROverlayIntersectionParams_t(HmdVector3_t vSource, HmdVector3_t vDirection, int eOrigin) { + super(); + this.vSource = vSource; + this.vDirection = vDirection; + this.eOrigin = eOrigin; + } + public VROverlayIntersectionParams_t(Pointer peer) { + super(peer); + } + public static class ByReference extends VROverlayIntersectionParams_t implements Structure.ByReference { + + }; + public static class ByValue extends VROverlayIntersectionParams_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VROverlayIntersectionResults_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VROverlayIntersectionResults_t.java new file mode 100644 index 0000000000..7fa5b020f2 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VROverlayIntersectionResults_t.java @@ -0,0 +1,48 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1541
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VROverlayIntersectionResults_t extends Structure { + /** C type : HmdVector3_t */ + public HmdVector3_t vPoint; + /** C type : HmdVector3_t */ + public HmdVector3_t vNormal; + /** C type : HmdVector2_t */ + public HmdVector2_t vUVs; + public float fDistance; + public VROverlayIntersectionResults_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("vPoint", "vNormal", "vUVs", "fDistance"); + } + /** + * @param vPoint C type : HmdVector3_t
+ * @param vNormal C type : HmdVector3_t
+ * @param vUVs C type : HmdVector2_t + */ + public VROverlayIntersectionResults_t(HmdVector3_t vPoint, HmdVector3_t vNormal, HmdVector2_t vUVs, float fDistance) { + super(); + this.vPoint = vPoint; + this.vNormal = vNormal; + this.vUVs = vUVs; + this.fDistance = fDistance; + } + public VROverlayIntersectionResults_t(Pointer peer) { + super(peer); + } + public static class ByReference extends VROverlayIntersectionResults_t implements Structure.ByReference { + + }; + public static class ByValue extends VROverlayIntersectionResults_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRTextureBounds_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRTextureBounds_t.java new file mode 100644 index 0000000000..88c779846c --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRTextureBounds_t.java @@ -0,0 +1,40 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1263
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VRTextureBounds_t extends Structure { + public float uMin; + public float vMin; + public float uMax; + public float vMax; + public VRTextureBounds_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("uMin", "vMin", "uMax", "vMax"); + } + public VRTextureBounds_t(float uMin, float vMin, float uMax, float vMax) { + super(); + this.uMin = uMin; + this.vMin = vMin; + this.uMax = uMax; + this.vMax = vMax; + } + public VRTextureBounds_t(Pointer peer) { + super(peer); + } + public static class ByReference extends VRTextureBounds_t implements Structure.ByReference { + + }; + public static class ByValue extends VRTextureBounds_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRTextureDepthInfo_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRTextureDepthInfo_t.java new file mode 100644 index 0000000000..89f42f80be --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRTextureDepthInfo_t.java @@ -0,0 +1,50 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1272
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VRTextureDepthInfo_t extends Structure { + /** + * void *
+ * C type : void* + */ + public Pointer handle; + /** C type : HmdMatrix44_t */ + public HmdMatrix44_t mProjection; + /** C type : HmdVector2_t */ + public HmdVector2_t vRange; + public VRTextureDepthInfo_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("handle", "mProjection", "vRange"); + } + /** + * @param handle void *
+ * C type : void*
+ * @param mProjection C type : HmdMatrix44_t
+ * @param vRange C type : HmdVector2_t + */ + public VRTextureDepthInfo_t(Pointer handle, HmdMatrix44_t mProjection, HmdVector2_t vRange) { + super(); + this.handle = handle; + this.mProjection = mProjection; + this.vRange = vRange; + } + public VRTextureDepthInfo_t(Pointer peer) { + super(peer); + } + public static class ByReference extends VRTextureDepthInfo_t implements Structure.ByReference { + + }; + public static class ByValue extends VRTextureDepthInfo_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRTextureWithDepth_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRTextureWithDepth_t.java new file mode 100644 index 0000000000..0601b2b7a3 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRTextureWithDepth_t.java @@ -0,0 +1,36 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1275
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VRTextureWithDepth_t extends Structure { + /** C type : VRTextureDepthInfo_t */ + public VRTextureDepthInfo_t depth; + public VRTextureWithDepth_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("depth"); + } + /** @param depth C type : VRTextureDepthInfo_t */ + public VRTextureWithDepth_t(VRTextureDepthInfo_t depth) { + super(); + this.depth = depth; + } + public VRTextureWithDepth_t(Pointer peer) { + super(peer); + } + public static class ByReference extends VRTextureWithDepth_t implements Structure.ByReference { + + }; + public static class ByValue extends VRTextureWithDepth_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRTextureWithPoseAndDepth_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRTextureWithPoseAndDepth_t.java new file mode 100644 index 0000000000..bbe447ba2c --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRTextureWithPoseAndDepth_t.java @@ -0,0 +1,36 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1278
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VRTextureWithPoseAndDepth_t extends Structure { + /** C type : VRTextureDepthInfo_t */ + public VRTextureDepthInfo_t depth; + public VRTextureWithPoseAndDepth_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("depth"); + } + /** @param depth C type : VRTextureDepthInfo_t */ + public VRTextureWithPoseAndDepth_t(VRTextureDepthInfo_t depth) { + super(); + this.depth = depth; + } + public VRTextureWithPoseAndDepth_t(Pointer peer) { + super(peer); + } + public static class ByReference extends VRTextureWithPoseAndDepth_t implements Structure.ByReference { + + }; + public static class ByValue extends VRTextureWithPoseAndDepth_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRTextureWithPose_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRTextureWithPose_t.java new file mode 100644 index 0000000000..8eff35c066 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRTextureWithPose_t.java @@ -0,0 +1,36 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1266
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VRTextureWithPose_t extends Structure { + /** C type : HmdMatrix34_t */ + public HmdMatrix34_t mDeviceToAbsoluteTracking; + public VRTextureWithPose_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("mDeviceToAbsoluteTracking"); + } + /** @param mDeviceToAbsoluteTracking C type : HmdMatrix34_t */ + public VRTextureWithPose_t(HmdMatrix34_t mDeviceToAbsoluteTracking) { + super(); + this.mDeviceToAbsoluteTracking = mDeviceToAbsoluteTracking; + } + public VRTextureWithPose_t(Pointer peer) { + super(peer); + } + public static class ByReference extends VRTextureWithPose_t implements Structure.ByReference { + + }; + public static class ByValue extends VRTextureWithPose_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRVulkanTextureData_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRVulkanTextureData_t.java new file mode 100644 index 0000000000..9ac3eb08bf --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRVulkanTextureData_t.java @@ -0,0 +1,59 @@ +package com.jme3.system.jopenvr; +import com.jme3.system.jopenvr.JOpenVRLibrary.VkDevice_T; +import com.jme3.system.jopenvr.JOpenVRLibrary.VkInstance_T; +import com.jme3.system.jopenvr.JOpenVRLibrary.VkPhysicalDevice_T; +import com.jme3.system.jopenvr.JOpenVRLibrary.VkQueue_T; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1294
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VRVulkanTextureData_t extends Structure { + public long m_nImage; + /** + * struct VkDevice_T *
+ * C type : VkDevice_T* + */ + public VkDevice_T m_pDevice; + /** + * struct VkPhysicalDevice_T *
+ * C type : VkPhysicalDevice_T* + */ + public VkPhysicalDevice_T m_pPhysicalDevice; + /** + * struct VkInstance_T *
+ * C type : VkInstance_T* + */ + public VkInstance_T m_pInstance; + /** + * struct VkQueue_T *
+ * C type : VkQueue_T* + */ + public VkQueue_T m_pQueue; + public int m_nQueueFamilyIndex; + public int m_nWidth; + public int m_nHeight; + public int m_nFormat; + public int m_nSampleCount; + public VRVulkanTextureData_t() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("m_nImage", "m_pDevice", "m_pPhysicalDevice", "m_pInstance", "m_pQueue", "m_nQueueFamilyIndex", "m_nWidth", "m_nHeight", "m_nFormat", "m_nSampleCount"); + } + public VRVulkanTextureData_t(Pointer peer) { + super(peer); + } + public static class ByReference extends VRVulkanTextureData_t implements Structure.ByReference { + + }; + public static class ByValue extends VRVulkanTextureData_t implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRApplications_FnTable.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRApplications_FnTable.java new file mode 100644 index 0000000000..eed61b3e02 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRApplications_FnTable.java @@ -0,0 +1,217 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Callback; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import com.sun.jna.ptr.IntByReference; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1897
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VR_IVRApplications_FnTable extends Structure { + /** C type : AddApplicationManifest_callback* */ + public VR_IVRApplications_FnTable.AddApplicationManifest_callback AddApplicationManifest; + /** C type : RemoveApplicationManifest_callback* */ + public VR_IVRApplications_FnTable.RemoveApplicationManifest_callback RemoveApplicationManifest; + /** C type : IsApplicationInstalled_callback* */ + public VR_IVRApplications_FnTable.IsApplicationInstalled_callback IsApplicationInstalled; + /** C type : GetApplicationCount_callback* */ + public VR_IVRApplications_FnTable.GetApplicationCount_callback GetApplicationCount; + /** C type : GetApplicationKeyByIndex_callback* */ + public VR_IVRApplications_FnTable.GetApplicationKeyByIndex_callback GetApplicationKeyByIndex; + /** C type : GetApplicationKeyByProcessId_callback* */ + public VR_IVRApplications_FnTable.GetApplicationKeyByProcessId_callback GetApplicationKeyByProcessId; + /** C type : LaunchApplication_callback* */ + public VR_IVRApplications_FnTable.LaunchApplication_callback LaunchApplication; + /** C type : LaunchTemplateApplication_callback* */ + public VR_IVRApplications_FnTable.LaunchTemplateApplication_callback LaunchTemplateApplication; + /** C type : LaunchApplicationFromMimeType_callback* */ + public VR_IVRApplications_FnTable.LaunchApplicationFromMimeType_callback LaunchApplicationFromMimeType; + /** C type : LaunchDashboardOverlay_callback* */ + public VR_IVRApplications_FnTable.LaunchDashboardOverlay_callback LaunchDashboardOverlay; + /** C type : CancelApplicationLaunch_callback* */ + public VR_IVRApplications_FnTable.CancelApplicationLaunch_callback CancelApplicationLaunch; + /** C type : IdentifyApplication_callback* */ + public VR_IVRApplications_FnTable.IdentifyApplication_callback IdentifyApplication; + /** C type : GetApplicationProcessId_callback* */ + public VR_IVRApplications_FnTable.GetApplicationProcessId_callback GetApplicationProcessId; + /** C type : GetApplicationsErrorNameFromEnum_callback* */ + public VR_IVRApplications_FnTable.GetApplicationsErrorNameFromEnum_callback GetApplicationsErrorNameFromEnum; + /** C type : GetApplicationPropertyString_callback* */ + public VR_IVRApplications_FnTable.GetApplicationPropertyString_callback GetApplicationPropertyString; + /** C type : GetApplicationPropertyBool_callback* */ + public VR_IVRApplications_FnTable.GetApplicationPropertyBool_callback GetApplicationPropertyBool; + /** C type : GetApplicationPropertyUint64_callback* */ + public VR_IVRApplications_FnTable.GetApplicationPropertyUint64_callback GetApplicationPropertyUint64; + /** C type : SetApplicationAutoLaunch_callback* */ + public VR_IVRApplications_FnTable.SetApplicationAutoLaunch_callback SetApplicationAutoLaunch; + /** C type : GetApplicationAutoLaunch_callback* */ + public VR_IVRApplications_FnTable.GetApplicationAutoLaunch_callback GetApplicationAutoLaunch; + /** C type : SetDefaultApplicationForMimeType_callback* */ + public VR_IVRApplications_FnTable.SetDefaultApplicationForMimeType_callback SetDefaultApplicationForMimeType; + /** C type : GetDefaultApplicationForMimeType_callback* */ + public VR_IVRApplications_FnTable.GetDefaultApplicationForMimeType_callback GetDefaultApplicationForMimeType; + /** C type : GetApplicationSupportedMimeTypes_callback* */ + public VR_IVRApplications_FnTable.GetApplicationSupportedMimeTypes_callback GetApplicationSupportedMimeTypes; + /** C type : GetApplicationsThatSupportMimeType_callback* */ + public VR_IVRApplications_FnTable.GetApplicationsThatSupportMimeType_callback GetApplicationsThatSupportMimeType; + /** C type : GetApplicationLaunchArguments_callback* */ + public VR_IVRApplications_FnTable.GetApplicationLaunchArguments_callback GetApplicationLaunchArguments; + /** C type : GetStartingApplication_callback* */ + public VR_IVRApplications_FnTable.GetStartingApplication_callback GetStartingApplication; + /** C type : GetTransitionState_callback* */ + public VR_IVRApplications_FnTable.GetTransitionState_callback GetTransitionState; + /** C type : PerformApplicationPrelaunchCheck_callback* */ + public VR_IVRApplications_FnTable.PerformApplicationPrelaunchCheck_callback PerformApplicationPrelaunchCheck; + /** C type : GetApplicationsTransitionStateNameFromEnum_callback* */ + public VR_IVRApplications_FnTable.GetApplicationsTransitionStateNameFromEnum_callback GetApplicationsTransitionStateNameFromEnum; + /** C type : IsQuitUserPromptRequested_callback* */ + public VR_IVRApplications_FnTable.IsQuitUserPromptRequested_callback IsQuitUserPromptRequested; + /** C type : LaunchInternalProcess_callback* */ + public VR_IVRApplications_FnTable.LaunchInternalProcess_callback LaunchInternalProcess; + /** C type : GetCurrentSceneProcessId_callback* */ + public VR_IVRApplications_FnTable.GetCurrentSceneProcessId_callback GetCurrentSceneProcessId; + /** native declaration : headers\openvr_capi.h:1866 */ + public interface AddApplicationManifest_callback extends Callback { + int apply(Pointer pchApplicationManifestFullPath, byte bTemporary); + }; + /** native declaration : headers\openvr_capi.h:1867 */ + public interface RemoveApplicationManifest_callback extends Callback { + int apply(Pointer pchApplicationManifestFullPath); + }; + /** native declaration : headers\openvr_capi.h:1868 */ + public interface IsApplicationInstalled_callback extends Callback { + byte apply(Pointer pchAppKey); + }; + /** native declaration : headers\openvr_capi.h:1869 */ + public interface GetApplicationCount_callback extends Callback { + int apply(); + }; + /** native declaration : headers\openvr_capi.h:1870 */ + public interface GetApplicationKeyByIndex_callback extends Callback { + int apply(int unApplicationIndex, Pointer pchAppKeyBuffer, int unAppKeyBufferLen); + }; + /** native declaration : headers\openvr_capi.h:1871 */ + public interface GetApplicationKeyByProcessId_callback extends Callback { + int apply(int unProcessId, Pointer pchAppKeyBuffer, int unAppKeyBufferLen); + }; + /** native declaration : headers\openvr_capi.h:1872 */ + public interface LaunchApplication_callback extends Callback { + int apply(Pointer pchAppKey); + }; + /** native declaration : headers\openvr_capi.h:1873 */ + public interface LaunchTemplateApplication_callback extends Callback { + int apply(Pointer pchTemplateAppKey, Pointer pchNewAppKey, AppOverrideKeys_t pKeys, int unKeys); + }; + /** native declaration : headers\openvr_capi.h:1874 */ + public interface LaunchApplicationFromMimeType_callback extends Callback { + int apply(Pointer pchMimeType, Pointer pchArgs); + }; + /** native declaration : headers\openvr_capi.h:1875 */ + public interface LaunchDashboardOverlay_callback extends Callback { + int apply(Pointer pchAppKey); + }; + /** native declaration : headers\openvr_capi.h:1876 */ + public interface CancelApplicationLaunch_callback extends Callback { + byte apply(Pointer pchAppKey); + }; + /** native declaration : headers\openvr_capi.h:1877 */ + public interface IdentifyApplication_callback extends Callback { + int apply(int unProcessId, Pointer pchAppKey); + }; + /** native declaration : headers\openvr_capi.h:1878 */ + public interface GetApplicationProcessId_callback extends Callback { + int apply(Pointer pchAppKey); + }; + /** native declaration : headers\openvr_capi.h:1879 */ + public interface GetApplicationsErrorNameFromEnum_callback extends Callback { + Pointer apply(int error); + }; + /** native declaration : headers\openvr_capi.h:1880 */ + public interface GetApplicationPropertyString_callback extends Callback { + int apply(Pointer pchAppKey, int eProperty, Pointer pchPropertyValueBuffer, int unPropertyValueBufferLen, IntByReference peError); + }; + /** native declaration : headers\openvr_capi.h:1881 */ + public interface GetApplicationPropertyBool_callback extends Callback { + byte apply(Pointer pchAppKey, int eProperty, IntByReference peError); + }; + /** native declaration : headers\openvr_capi.h:1882 */ + public interface GetApplicationPropertyUint64_callback extends Callback { + long apply(Pointer pchAppKey, int eProperty, IntByReference peError); + }; + /** native declaration : headers\openvr_capi.h:1883 */ + public interface SetApplicationAutoLaunch_callback extends Callback { + int apply(Pointer pchAppKey, byte bAutoLaunch); + }; + /** native declaration : headers\openvr_capi.h:1884 */ + public interface GetApplicationAutoLaunch_callback extends Callback { + byte apply(Pointer pchAppKey); + }; + /** native declaration : headers\openvr_capi.h:1885 */ + public interface SetDefaultApplicationForMimeType_callback extends Callback { + int apply(Pointer pchAppKey, Pointer pchMimeType); + }; + /** native declaration : headers\openvr_capi.h:1886 */ + public interface GetDefaultApplicationForMimeType_callback extends Callback { + byte apply(Pointer pchMimeType, Pointer pchAppKeyBuffer, int unAppKeyBufferLen); + }; + /** native declaration : headers\openvr_capi.h:1887 */ + public interface GetApplicationSupportedMimeTypes_callback extends Callback { + byte apply(Pointer pchAppKey, Pointer pchMimeTypesBuffer, int unMimeTypesBuffer); + }; + /** native declaration : headers\openvr_capi.h:1888 */ + public interface GetApplicationsThatSupportMimeType_callback extends Callback { + int apply(Pointer pchMimeType, Pointer pchAppKeysThatSupportBuffer, int unAppKeysThatSupportBuffer); + }; + /** native declaration : headers\openvr_capi.h:1889 */ + public interface GetApplicationLaunchArguments_callback extends Callback { + int apply(int unHandle, Pointer pchArgs, int unArgs); + }; + /** native declaration : headers\openvr_capi.h:1890 */ + public interface GetStartingApplication_callback extends Callback { + int apply(Pointer pchAppKeyBuffer, int unAppKeyBufferLen); + }; + /** native declaration : headers\openvr_capi.h:1891 */ + public interface GetTransitionState_callback extends Callback { + int apply(); + }; + /** native declaration : headers\openvr_capi.h:1892 */ + public interface PerformApplicationPrelaunchCheck_callback extends Callback { + int apply(Pointer pchAppKey); + }; + /** native declaration : headers\openvr_capi.h:1893 */ + public interface GetApplicationsTransitionStateNameFromEnum_callback extends Callback { + Pointer apply(int state); + }; + /** native declaration : headers\openvr_capi.h:1894 */ + public interface IsQuitUserPromptRequested_callback extends Callback { + byte apply(); + }; + /** native declaration : headers\openvr_capi.h:1895 */ + public interface LaunchInternalProcess_callback extends Callback { + int apply(Pointer pchBinaryPath, Pointer pchArguments, Pointer pchWorkingDirectory); + }; + /** native declaration : headers\openvr_capi.h:1896 */ + public interface GetCurrentSceneProcessId_callback extends Callback { + int apply(); + }; + public VR_IVRApplications_FnTable() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("AddApplicationManifest", "RemoveApplicationManifest", "IsApplicationInstalled", "GetApplicationCount", "GetApplicationKeyByIndex", "GetApplicationKeyByProcessId", "LaunchApplication", "LaunchTemplateApplication", "LaunchApplicationFromMimeType", "LaunchDashboardOverlay", "CancelApplicationLaunch", "IdentifyApplication", "GetApplicationProcessId", "GetApplicationsErrorNameFromEnum", "GetApplicationPropertyString", "GetApplicationPropertyBool", "GetApplicationPropertyUint64", "SetApplicationAutoLaunch", "GetApplicationAutoLaunch", "SetDefaultApplicationForMimeType", "GetDefaultApplicationForMimeType", "GetApplicationSupportedMimeTypes", "GetApplicationsThatSupportMimeType", "GetApplicationLaunchArguments", "GetStartingApplication", "GetTransitionState", "PerformApplicationPrelaunchCheck", "GetApplicationsTransitionStateNameFromEnum", "IsQuitUserPromptRequested", "LaunchInternalProcess", "GetCurrentSceneProcessId"); + } + public VR_IVRApplications_FnTable(Pointer peer) { + super(peer); + } + public static class ByReference extends VR_IVRApplications_FnTable implements Structure.ByReference { + + }; + public static class ByValue extends VR_IVRApplications_FnTable implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRChaperoneSetup_FnTable.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRChaperoneSetup_FnTable.java new file mode 100644 index 0000000000..5795f54df7 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRChaperoneSetup_FnTable.java @@ -0,0 +1,152 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Callback; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import com.sun.jna.ptr.FloatByReference; +import com.sun.jna.ptr.IntByReference; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1957
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VR_IVRChaperoneSetup_FnTable extends Structure { + /** C type : CommitWorkingCopy_callback* */ + public VR_IVRChaperoneSetup_FnTable.CommitWorkingCopy_callback CommitWorkingCopy; + /** C type : RevertWorkingCopy_callback* */ + public VR_IVRChaperoneSetup_FnTable.RevertWorkingCopy_callback RevertWorkingCopy; + /** C type : GetWorkingPlayAreaSize_callback* */ + public VR_IVRChaperoneSetup_FnTable.GetWorkingPlayAreaSize_callback GetWorkingPlayAreaSize; + /** C type : GetWorkingPlayAreaRect_callback* */ + public VR_IVRChaperoneSetup_FnTable.GetWorkingPlayAreaRect_callback GetWorkingPlayAreaRect; + /** C type : GetWorkingCollisionBoundsInfo_callback* */ + public VR_IVRChaperoneSetup_FnTable.GetWorkingCollisionBoundsInfo_callback GetWorkingCollisionBoundsInfo; + /** C type : GetLiveCollisionBoundsInfo_callback* */ + public VR_IVRChaperoneSetup_FnTable.GetLiveCollisionBoundsInfo_callback GetLiveCollisionBoundsInfo; + /** C type : GetWorkingSeatedZeroPoseToRawTrackingPose_callback* */ + public VR_IVRChaperoneSetup_FnTable.GetWorkingSeatedZeroPoseToRawTrackingPose_callback GetWorkingSeatedZeroPoseToRawTrackingPose; + /** C type : GetWorkingStandingZeroPoseToRawTrackingPose_callback* */ + public VR_IVRChaperoneSetup_FnTable.GetWorkingStandingZeroPoseToRawTrackingPose_callback GetWorkingStandingZeroPoseToRawTrackingPose; + /** C type : SetWorkingPlayAreaSize_callback* */ + public VR_IVRChaperoneSetup_FnTable.SetWorkingPlayAreaSize_callback SetWorkingPlayAreaSize; + /** C type : SetWorkingCollisionBoundsInfo_callback* */ + public VR_IVRChaperoneSetup_FnTable.SetWorkingCollisionBoundsInfo_callback SetWorkingCollisionBoundsInfo; + /** C type : SetWorkingSeatedZeroPoseToRawTrackingPose_callback* */ + public VR_IVRChaperoneSetup_FnTable.SetWorkingSeatedZeroPoseToRawTrackingPose_callback SetWorkingSeatedZeroPoseToRawTrackingPose; + /** C type : SetWorkingStandingZeroPoseToRawTrackingPose_callback* */ + public VR_IVRChaperoneSetup_FnTable.SetWorkingStandingZeroPoseToRawTrackingPose_callback SetWorkingStandingZeroPoseToRawTrackingPose; + /** C type : ReloadFromDisk_callback* */ + public VR_IVRChaperoneSetup_FnTable.ReloadFromDisk_callback ReloadFromDisk; + /** C type : GetLiveSeatedZeroPoseToRawTrackingPose_callback* */ + public VR_IVRChaperoneSetup_FnTable.GetLiveSeatedZeroPoseToRawTrackingPose_callback GetLiveSeatedZeroPoseToRawTrackingPose; + /** C type : SetWorkingCollisionBoundsTagsInfo_callback* */ + public VR_IVRChaperoneSetup_FnTable.SetWorkingCollisionBoundsTagsInfo_callback SetWorkingCollisionBoundsTagsInfo; + /** C type : GetLiveCollisionBoundsTagsInfo_callback* */ + public VR_IVRChaperoneSetup_FnTable.GetLiveCollisionBoundsTagsInfo_callback GetLiveCollisionBoundsTagsInfo; + /** C type : SetWorkingPhysicalBoundsInfo_callback* */ + public VR_IVRChaperoneSetup_FnTable.SetWorkingPhysicalBoundsInfo_callback SetWorkingPhysicalBoundsInfo; + /** C type : GetLivePhysicalBoundsInfo_callback* */ + public VR_IVRChaperoneSetup_FnTable.GetLivePhysicalBoundsInfo_callback GetLivePhysicalBoundsInfo; + /** C type : ExportLiveToBuffer_callback* */ + public VR_IVRChaperoneSetup_FnTable.ExportLiveToBuffer_callback ExportLiveToBuffer; + /** C type : ImportFromBufferToWorking_callback* */ + public VR_IVRChaperoneSetup_FnTable.ImportFromBufferToWorking_callback ImportFromBufferToWorking; + /** native declaration : headers\openvr_capi.h:1937 */ + public interface CommitWorkingCopy_callback extends Callback { + byte apply(int configFile); + }; + /** native declaration : headers\openvr_capi.h:1938 */ + public interface RevertWorkingCopy_callback extends Callback { + void apply(); + }; + /** native declaration : headers\openvr_capi.h:1939 */ + public interface GetWorkingPlayAreaSize_callback extends Callback { + byte apply(FloatByReference pSizeX, FloatByReference pSizeZ); + }; + /** native declaration : headers\openvr_capi.h:1940 */ + public interface GetWorkingPlayAreaRect_callback extends Callback { + byte apply(HmdQuad_t rect); + }; + /** native declaration : headers\openvr_capi.h:1941 */ + public interface GetWorkingCollisionBoundsInfo_callback extends Callback { + byte apply(HmdQuad_t pQuadsBuffer, IntByReference punQuadsCount); + }; + /** native declaration : headers\openvr_capi.h:1942 */ + public interface GetLiveCollisionBoundsInfo_callback extends Callback { + byte apply(HmdQuad_t pQuadsBuffer, IntByReference punQuadsCount); + }; + /** native declaration : headers\openvr_capi.h:1943 */ + public interface GetWorkingSeatedZeroPoseToRawTrackingPose_callback extends Callback { + byte apply(HmdMatrix34_t pmatSeatedZeroPoseToRawTrackingPose); + }; + /** native declaration : headers\openvr_capi.h:1944 */ + public interface GetWorkingStandingZeroPoseToRawTrackingPose_callback extends Callback { + byte apply(HmdMatrix34_t pmatStandingZeroPoseToRawTrackingPose); + }; + /** native declaration : headers\openvr_capi.h:1945 */ + public interface SetWorkingPlayAreaSize_callback extends Callback { + void apply(float sizeX, float sizeZ); + }; + /** native declaration : headers\openvr_capi.h:1946 */ + public interface SetWorkingCollisionBoundsInfo_callback extends Callback { + void apply(HmdQuad_t pQuadsBuffer, int unQuadsCount); + }; + /** native declaration : headers\openvr_capi.h:1947 */ + public interface SetWorkingSeatedZeroPoseToRawTrackingPose_callback extends Callback { + void apply(HmdMatrix34_t pMatSeatedZeroPoseToRawTrackingPose); + }; + /** native declaration : headers\openvr_capi.h:1948 */ + public interface SetWorkingStandingZeroPoseToRawTrackingPose_callback extends Callback { + void apply(HmdMatrix34_t pMatStandingZeroPoseToRawTrackingPose); + }; + /** native declaration : headers\openvr_capi.h:1949 */ + public interface ReloadFromDisk_callback extends Callback { + void apply(int configFile); + }; + /** native declaration : headers\openvr_capi.h:1950 */ + public interface GetLiveSeatedZeroPoseToRawTrackingPose_callback extends Callback { + byte apply(HmdMatrix34_t pmatSeatedZeroPoseToRawTrackingPose); + }; + /** native declaration : headers\openvr_capi.h:1951 */ + public interface SetWorkingCollisionBoundsTagsInfo_callback extends Callback { + void apply(Pointer pTagsBuffer, int unTagCount); + }; + /** native declaration : headers\openvr_capi.h:1952 */ + public interface GetLiveCollisionBoundsTagsInfo_callback extends Callback { + byte apply(Pointer pTagsBuffer, IntByReference punTagCount); + }; + /** native declaration : headers\openvr_capi.h:1953 */ + public interface SetWorkingPhysicalBoundsInfo_callback extends Callback { + byte apply(HmdQuad_t pQuadsBuffer, int unQuadsCount); + }; + /** native declaration : headers\openvr_capi.h:1954 */ + public interface GetLivePhysicalBoundsInfo_callback extends Callback { + byte apply(HmdQuad_t pQuadsBuffer, IntByReference punQuadsCount); + }; + /** native declaration : headers\openvr_capi.h:1955 */ + public interface ExportLiveToBuffer_callback extends Callback { + byte apply(Pointer pBuffer, IntByReference pnBufferLength); + }; + /** native declaration : headers\openvr_capi.h:1956 */ + public interface ImportFromBufferToWorking_callback extends Callback { + byte apply(Pointer pBuffer, int nImportFlags); + }; + public VR_IVRChaperoneSetup_FnTable() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("CommitWorkingCopy", "RevertWorkingCopy", "GetWorkingPlayAreaSize", "GetWorkingPlayAreaRect", "GetWorkingCollisionBoundsInfo", "GetLiveCollisionBoundsInfo", "GetWorkingSeatedZeroPoseToRawTrackingPose", "GetWorkingStandingZeroPoseToRawTrackingPose", "SetWorkingPlayAreaSize", "SetWorkingCollisionBoundsInfo", "SetWorkingSeatedZeroPoseToRawTrackingPose", "SetWorkingStandingZeroPoseToRawTrackingPose", "ReloadFromDisk", "GetLiveSeatedZeroPoseToRawTrackingPose", "SetWorkingCollisionBoundsTagsInfo", "GetLiveCollisionBoundsTagsInfo", "SetWorkingPhysicalBoundsInfo", "GetLivePhysicalBoundsInfo", "ExportLiveToBuffer", "ImportFromBufferToWorking"); + } + public VR_IVRChaperoneSetup_FnTable(Pointer peer) { + super(peer); + } + public static class ByReference extends VR_IVRChaperoneSetup_FnTable implements Structure.ByReference { + + }; + public static class ByValue extends VR_IVRChaperoneSetup_FnTable implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRChaperone_FnTable.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRChaperone_FnTable.java new file mode 100644 index 0000000000..1a575c6c09 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRChaperone_FnTable.java @@ -0,0 +1,100 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Callback; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import com.sun.jna.ptr.FloatByReference; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1915
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VR_IVRChaperone_FnTable extends Structure { + /** C type : GetCalibrationState_callback* */ + public VR_IVRChaperone_FnTable.GetCalibrationState_callback GetCalibrationState; + /** C type : GetPlayAreaSize_callback* */ + public VR_IVRChaperone_FnTable.GetPlayAreaSize_callback GetPlayAreaSize; + /** C type : GetPlayAreaRect_callback* */ + public VR_IVRChaperone_FnTable.GetPlayAreaRect_callback GetPlayAreaRect; + /** C type : ReloadInfo_callback* */ + public VR_IVRChaperone_FnTable.ReloadInfo_callback ReloadInfo; + /** C type : SetSceneColor_callback* */ + public VR_IVRChaperone_FnTable.SetSceneColor_callback SetSceneColor; + /** C type : GetBoundsColor_callback* */ + public VR_IVRChaperone_FnTable.GetBoundsColor_callback GetBoundsColor; + /** C type : AreBoundsVisible_callback* */ + public VR_IVRChaperone_FnTable.AreBoundsVisible_callback AreBoundsVisible; + /** C type : ForceBoundsVisible_callback* */ + public VR_IVRChaperone_FnTable.ForceBoundsVisible_callback ForceBoundsVisible; + /** native declaration : headers\openvr_capi.h:1907 */ + public interface GetCalibrationState_callback extends Callback { + int apply(); + }; + /** native declaration : headers\openvr_capi.h:1908 */ + public interface GetPlayAreaSize_callback extends Callback { + byte apply(FloatByReference pSizeX, FloatByReference pSizeZ); + }; + /** native declaration : headers\openvr_capi.h:1909 */ + public interface GetPlayAreaRect_callback extends Callback { + byte apply(HmdQuad_t rect); + }; + /** native declaration : headers\openvr_capi.h:1910 */ + public interface ReloadInfo_callback extends Callback { + void apply(); + }; + /** native declaration : headers\openvr_capi.h:1911 */ + public interface SetSceneColor_callback extends Callback { + void apply(HmdColor_t.ByValue color); + }; + /** native declaration : headers\openvr_capi.h:1912 */ + public interface GetBoundsColor_callback extends Callback { + void apply(HmdColor_t pOutputColorArray, int nNumOutputColors, float flCollisionBoundsFadeDistance, HmdColor_t pOutputCameraColor); + }; + /** native declaration : headers\openvr_capi.h:1913 */ + public interface AreBoundsVisible_callback extends Callback { + byte apply(); + }; + /** native declaration : headers\openvr_capi.h:1914 */ + public interface ForceBoundsVisible_callback extends Callback { + void apply(byte bForce); + }; + public VR_IVRChaperone_FnTable() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("GetCalibrationState", "GetPlayAreaSize", "GetPlayAreaRect", "ReloadInfo", "SetSceneColor", "GetBoundsColor", "AreBoundsVisible", "ForceBoundsVisible"); + } + /** + * @param GetCalibrationState C type : GetCalibrationState_callback*
+ * @param GetPlayAreaSize C type : GetPlayAreaSize_callback*
+ * @param GetPlayAreaRect C type : GetPlayAreaRect_callback*
+ * @param ReloadInfo C type : ReloadInfo_callback*
+ * @param SetSceneColor C type : SetSceneColor_callback*
+ * @param GetBoundsColor C type : GetBoundsColor_callback*
+ * @param AreBoundsVisible C type : AreBoundsVisible_callback*
+ * @param ForceBoundsVisible C type : ForceBoundsVisible_callback* + */ + public VR_IVRChaperone_FnTable(VR_IVRChaperone_FnTable.GetCalibrationState_callback GetCalibrationState, VR_IVRChaperone_FnTable.GetPlayAreaSize_callback GetPlayAreaSize, VR_IVRChaperone_FnTable.GetPlayAreaRect_callback GetPlayAreaRect, VR_IVRChaperone_FnTable.ReloadInfo_callback ReloadInfo, VR_IVRChaperone_FnTable.SetSceneColor_callback SetSceneColor, VR_IVRChaperone_FnTable.GetBoundsColor_callback GetBoundsColor, VR_IVRChaperone_FnTable.AreBoundsVisible_callback AreBoundsVisible, VR_IVRChaperone_FnTable.ForceBoundsVisible_callback ForceBoundsVisible) { + super(); + this.GetCalibrationState = GetCalibrationState; + this.GetPlayAreaSize = GetPlayAreaSize; + this.GetPlayAreaRect = GetPlayAreaRect; + this.ReloadInfo = ReloadInfo; + this.SetSceneColor = SetSceneColor; + this.GetBoundsColor = GetBoundsColor; + this.AreBoundsVisible = AreBoundsVisible; + this.ForceBoundsVisible = ForceBoundsVisible; + } + public VR_IVRChaperone_FnTable(Pointer peer) { + super(peer); + } + public static class ByReference extends VR_IVRChaperone_FnTable implements Structure.ByReference { + + }; + public static class ByValue extends VR_IVRChaperone_FnTable implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRCompositor_FnTable.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRCompositor_FnTable.java new file mode 100644 index 0000000000..53a3039437 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRCompositor_FnTable.java @@ -0,0 +1,291 @@ +package com.jme3.system.jopenvr; +import com.jme3.system.jopenvr.JOpenVRLibrary.VkPhysicalDevice_T; +import com.sun.jna.Callback; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import com.sun.jna.ptr.IntByReference; +import com.sun.jna.ptr.PointerByReference; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:2045
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VR_IVRCompositor_FnTable extends Structure { + /** C type : SetTrackingSpace_callback* */ + public VR_IVRCompositor_FnTable.SetTrackingSpace_callback SetTrackingSpace; + /** C type : GetTrackingSpace_callback* */ + public VR_IVRCompositor_FnTable.GetTrackingSpace_callback GetTrackingSpace; + /** C type : WaitGetPoses_callback* */ + public VR_IVRCompositor_FnTable.WaitGetPoses_callback WaitGetPoses; + /** C type : GetLastPoses_callback* */ + public VR_IVRCompositor_FnTable.GetLastPoses_callback GetLastPoses; + /** C type : GetLastPoseForTrackedDeviceIndex_callback* */ + public VR_IVRCompositor_FnTable.GetLastPoseForTrackedDeviceIndex_callback GetLastPoseForTrackedDeviceIndex; + /** C type : Submit_callback* */ + public VR_IVRCompositor_FnTable.Submit_callback Submit; + /** C type : ClearLastSubmittedFrame_callback* */ + public VR_IVRCompositor_FnTable.ClearLastSubmittedFrame_callback ClearLastSubmittedFrame; + /** C type : PostPresentHandoff_callback* */ + public VR_IVRCompositor_FnTable.PostPresentHandoff_callback PostPresentHandoff; + /** C type : GetFrameTiming_callback* */ + public VR_IVRCompositor_FnTable.GetFrameTiming_callback GetFrameTiming; + /** C type : GetFrameTimings_callback* */ + public VR_IVRCompositor_FnTable.GetFrameTimings_callback GetFrameTimings; + /** C type : GetFrameTimeRemaining_callback* */ + public VR_IVRCompositor_FnTable.GetFrameTimeRemaining_callback GetFrameTimeRemaining; + /** C type : GetCumulativeStats_callback* */ + public VR_IVRCompositor_FnTable.GetCumulativeStats_callback GetCumulativeStats; + /** C type : FadeToColor_callback* */ + public VR_IVRCompositor_FnTable.FadeToColor_callback FadeToColor; + /** C type : GetCurrentFadeColor_callback* */ + public VR_IVRCompositor_FnTable.GetCurrentFadeColor_callback GetCurrentFadeColor; + /** C type : FadeGrid_callback* */ + public VR_IVRCompositor_FnTable.FadeGrid_callback FadeGrid; + /** C type : GetCurrentGridAlpha_callback* */ + public VR_IVRCompositor_FnTable.GetCurrentGridAlpha_callback GetCurrentGridAlpha; + /** C type : SetSkyboxOverride_callback* */ + public VR_IVRCompositor_FnTable.SetSkyboxOverride_callback SetSkyboxOverride; + /** C type : ClearSkyboxOverride_callback* */ + public VR_IVRCompositor_FnTable.ClearSkyboxOverride_callback ClearSkyboxOverride; + /** C type : CompositorBringToFront_callback* */ + public VR_IVRCompositor_FnTable.CompositorBringToFront_callback CompositorBringToFront; + /** C type : CompositorGoToBack_callback* */ + public VR_IVRCompositor_FnTable.CompositorGoToBack_callback CompositorGoToBack; + /** C type : CompositorQuit_callback* */ + public VR_IVRCompositor_FnTable.CompositorQuit_callback CompositorQuit; + /** C type : IsFullscreen_callback* */ + public VR_IVRCompositor_FnTable.IsFullscreen_callback IsFullscreen; + /** C type : GetCurrentSceneFocusProcess_callback* */ + public VR_IVRCompositor_FnTable.GetCurrentSceneFocusProcess_callback GetCurrentSceneFocusProcess; + /** C type : GetLastFrameRenderer_callback* */ + public VR_IVRCompositor_FnTable.GetLastFrameRenderer_callback GetLastFrameRenderer; + /** C type : CanRenderScene_callback* */ + public VR_IVRCompositor_FnTable.CanRenderScene_callback CanRenderScene; + /** C type : ShowMirrorWindow_callback* */ + public VR_IVRCompositor_FnTable.ShowMirrorWindow_callback ShowMirrorWindow; + /** C type : HideMirrorWindow_callback* */ + public VR_IVRCompositor_FnTable.HideMirrorWindow_callback HideMirrorWindow; + /** C type : IsMirrorWindowVisible_callback* */ + public VR_IVRCompositor_FnTable.IsMirrorWindowVisible_callback IsMirrorWindowVisible; + /** C type : CompositorDumpImages_callback* */ + public VR_IVRCompositor_FnTable.CompositorDumpImages_callback CompositorDumpImages; + /** C type : ShouldAppRenderWithLowResources_callback* */ + public VR_IVRCompositor_FnTable.ShouldAppRenderWithLowResources_callback ShouldAppRenderWithLowResources; + /** C type : ForceInterleavedReprojectionOn_callback* */ + public VR_IVRCompositor_FnTable.ForceInterleavedReprojectionOn_callback ForceInterleavedReprojectionOn; + /** C type : ForceReconnectProcess_callback* */ + public VR_IVRCompositor_FnTable.ForceReconnectProcess_callback ForceReconnectProcess; + /** C type : SuspendRendering_callback* */ + public VR_IVRCompositor_FnTable.SuspendRendering_callback SuspendRendering; + /** C type : GetMirrorTextureD3D11_callback* */ + public VR_IVRCompositor_FnTable.GetMirrorTextureD3D11_callback GetMirrorTextureD3D11; + /** C type : ReleaseMirrorTextureD3D11_callback* */ + public VR_IVRCompositor_FnTable.ReleaseMirrorTextureD3D11_callback ReleaseMirrorTextureD3D11; + /** C type : GetMirrorTextureGL_callback* */ + public VR_IVRCompositor_FnTable.GetMirrorTextureGL_callback GetMirrorTextureGL; + /** C type : ReleaseSharedGLTexture_callback* */ + public VR_IVRCompositor_FnTable.ReleaseSharedGLTexture_callback ReleaseSharedGLTexture; + /** C type : LockGLSharedTextureForAccess_callback* */ + public VR_IVRCompositor_FnTable.LockGLSharedTextureForAccess_callback LockGLSharedTextureForAccess; + /** C type : UnlockGLSharedTextureForAccess_callback* */ + public VR_IVRCompositor_FnTable.UnlockGLSharedTextureForAccess_callback UnlockGLSharedTextureForAccess; + /** C type : GetVulkanInstanceExtensionsRequired_callback* */ + public VR_IVRCompositor_FnTable.GetVulkanInstanceExtensionsRequired_callback GetVulkanInstanceExtensionsRequired; + /** C type : GetVulkanDeviceExtensionsRequired_callback* */ + public VR_IVRCompositor_FnTable.GetVulkanDeviceExtensionsRequired_callback GetVulkanDeviceExtensionsRequired; + /** C type : SetExplicitTimingMode_callback* */ + public VR_IVRCompositor_FnTable.SetExplicitTimingMode_callback SetExplicitTimingMode; + /** C type : SubmitExplicitTimingData_callback* */ + public VR_IVRCompositor_FnTable.SubmitExplicitTimingData_callback SubmitExplicitTimingData; + /** native declaration : headers\openvr_capi.h:2002 */ + public interface SetTrackingSpace_callback extends Callback { + void apply(int eOrigin); + }; + /** native declaration : headers\openvr_capi.h:2003 */ + public interface GetTrackingSpace_callback extends Callback { + int apply(); + }; + /** native declaration : headers\openvr_capi.h:2004 */ + public interface WaitGetPoses_callback extends Callback { + int apply(TrackedDevicePose_t pRenderPoseArray, int unRenderPoseArrayCount, TrackedDevicePose_t pGamePoseArray, int unGamePoseArrayCount); + }; + /** native declaration : headers\openvr_capi.h:2005 */ + public interface GetLastPoses_callback extends Callback { + int apply(TrackedDevicePose_t pRenderPoseArray, int unRenderPoseArrayCount, TrackedDevicePose_t pGamePoseArray, int unGamePoseArrayCount); + }; + /** native declaration : headers\openvr_capi.h:2006 */ + public interface GetLastPoseForTrackedDeviceIndex_callback extends Callback { + int apply(int unDeviceIndex, TrackedDevicePose_t pOutputPose, TrackedDevicePose_t pOutputGamePose); + }; + /** native declaration : headers\openvr_capi.h:2007 */ + public interface Submit_callback extends Callback { + int apply(int eEye, Texture_t pTexture, VRTextureBounds_t pBounds, int nSubmitFlags); + }; + /** native declaration : headers\openvr_capi.h:2008 */ + public interface ClearLastSubmittedFrame_callback extends Callback { + void apply(); + }; + /** native declaration : headers\openvr_capi.h:2009 */ + public interface PostPresentHandoff_callback extends Callback { + void apply(); + }; + /** native declaration : headers\openvr_capi.h:2010 */ + public interface GetFrameTiming_callback extends Callback { + byte apply(Compositor_FrameTiming pTiming, int unFramesAgo); + }; + /** native declaration : headers\openvr_capi.h:2011 */ + public interface GetFrameTimings_callback extends Callback { + int apply(Compositor_FrameTiming pTiming, int nFrames); + }; + /** native declaration : headers\openvr_capi.h:2012 */ + public interface GetFrameTimeRemaining_callback extends Callback { + float apply(); + }; + /** native declaration : headers\openvr_capi.h:2013 */ + public interface GetCumulativeStats_callback extends Callback { + void apply(Compositor_CumulativeStats pStats, int nStatsSizeInBytes); + }; + /** native declaration : headers\openvr_capi.h:2014 */ + public interface FadeToColor_callback extends Callback { + void apply(float fSeconds, float fRed, float fGreen, float fBlue, float fAlpha, byte bBackground); + }; + /** native declaration : headers\openvr_capi.h:2015 */ + public interface GetCurrentFadeColor_callback extends Callback { + com.jme3.system.jopenvr.HmdColor_t.ByValue apply(byte bBackground); + }; + /** native declaration : headers\openvr_capi.h:2016 */ + public interface FadeGrid_callback extends Callback { + void apply(float fSeconds, byte bFadeIn); + }; + /** native declaration : headers\openvr_capi.h:2017 */ + public interface GetCurrentGridAlpha_callback extends Callback { + float apply(); + }; + /** native declaration : headers\openvr_capi.h:2018 */ + public interface SetSkyboxOverride_callback extends Callback { + int apply(Texture_t pTextures, int unTextureCount); + }; + /** native declaration : headers\openvr_capi.h:2019 */ + public interface ClearSkyboxOverride_callback extends Callback { + void apply(); + }; + /** native declaration : headers\openvr_capi.h:2020 */ + public interface CompositorBringToFront_callback extends Callback { + void apply(); + }; + /** native declaration : headers\openvr_capi.h:2021 */ + public interface CompositorGoToBack_callback extends Callback { + void apply(); + }; + /** native declaration : headers\openvr_capi.h:2022 */ + public interface CompositorQuit_callback extends Callback { + void apply(); + }; + /** native declaration : headers\openvr_capi.h:2023 */ + public interface IsFullscreen_callback extends Callback { + byte apply(); + }; + /** native declaration : headers\openvr_capi.h:2024 */ + public interface GetCurrentSceneFocusProcess_callback extends Callback { + int apply(); + }; + /** native declaration : headers\openvr_capi.h:2025 */ + public interface GetLastFrameRenderer_callback extends Callback { + int apply(); + }; + /** native declaration : headers\openvr_capi.h:2026 */ + public interface CanRenderScene_callback extends Callback { + byte apply(); + }; + /** native declaration : headers\openvr_capi.h:2027 */ + public interface ShowMirrorWindow_callback extends Callback { + void apply(); + }; + /** native declaration : headers\openvr_capi.h:2028 */ + public interface HideMirrorWindow_callback extends Callback { + void apply(); + }; + /** native declaration : headers\openvr_capi.h:2029 */ + public interface IsMirrorWindowVisible_callback extends Callback { + byte apply(); + }; + /** native declaration : headers\openvr_capi.h:2030 */ + public interface CompositorDumpImages_callback extends Callback { + void apply(); + }; + /** native declaration : headers\openvr_capi.h:2031 */ + public interface ShouldAppRenderWithLowResources_callback extends Callback { + byte apply(); + }; + /** native declaration : headers\openvr_capi.h:2032 */ + public interface ForceInterleavedReprojectionOn_callback extends Callback { + void apply(byte bOverride); + }; + /** native declaration : headers\openvr_capi.h:2033 */ + public interface ForceReconnectProcess_callback extends Callback { + void apply(); + }; + /** native declaration : headers\openvr_capi.h:2034 */ + public interface SuspendRendering_callback extends Callback { + void apply(byte bSuspend); + }; + /** native declaration : headers\openvr_capi.h:2035 */ + public interface GetMirrorTextureD3D11_callback extends Callback { + int apply(int eEye, Pointer pD3D11DeviceOrResource, PointerByReference ppD3D11ShaderResourceView); + }; + /** native declaration : headers\openvr_capi.h:2036 */ + public interface ReleaseMirrorTextureD3D11_callback extends Callback { + void apply(Pointer pD3D11ShaderResourceView); + }; + /** native declaration : headers\openvr_capi.h:2037 */ + public interface GetMirrorTextureGL_callback extends Callback { + int apply(int eEye, IntByReference pglTextureId, PointerByReference pglSharedTextureHandle); + }; + /** native declaration : headers\openvr_capi.h:2038 */ + public interface ReleaseSharedGLTexture_callback extends Callback { + byte apply(int glTextureId, Pointer glSharedTextureHandle); + }; + /** native declaration : headers\openvr_capi.h:2039 */ + public interface LockGLSharedTextureForAccess_callback extends Callback { + void apply(Pointer glSharedTextureHandle); + }; + /** native declaration : headers\openvr_capi.h:2040 */ + public interface UnlockGLSharedTextureForAccess_callback extends Callback { + void apply(Pointer glSharedTextureHandle); + }; + /** native declaration : headers\openvr_capi.h:2041 */ + public interface GetVulkanInstanceExtensionsRequired_callback extends Callback { + int apply(Pointer pchValue, int unBufferSize); + }; + /** native declaration : headers\openvr_capi.h:2042 */ + public interface GetVulkanDeviceExtensionsRequired_callback extends Callback { + int apply(VkPhysicalDevice_T pPhysicalDevice, Pointer pchValue, int unBufferSize); + }; + /** native declaration : headers\openvr_capi.h:2043 */ + public interface SetExplicitTimingMode_callback extends Callback { + void apply(int eTimingMode); + }; + /** native declaration : headers\openvr_capi.h:2044 */ + public interface SubmitExplicitTimingData_callback extends Callback { + int apply(); + }; + public VR_IVRCompositor_FnTable() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("SetTrackingSpace", "GetTrackingSpace", "WaitGetPoses", "GetLastPoses", "GetLastPoseForTrackedDeviceIndex", "Submit", "ClearLastSubmittedFrame", "PostPresentHandoff", "GetFrameTiming", "GetFrameTimings", "GetFrameTimeRemaining", "GetCumulativeStats", "FadeToColor", "GetCurrentFadeColor", "FadeGrid", "GetCurrentGridAlpha", "SetSkyboxOverride", "ClearSkyboxOverride", "CompositorBringToFront", "CompositorGoToBack", "CompositorQuit", "IsFullscreen", "GetCurrentSceneFocusProcess", "GetLastFrameRenderer", "CanRenderScene", "ShowMirrorWindow", "HideMirrorWindow", "IsMirrorWindowVisible", "CompositorDumpImages", "ShouldAppRenderWithLowResources", "ForceInterleavedReprojectionOn", "ForceReconnectProcess", "SuspendRendering", "GetMirrorTextureD3D11", "ReleaseMirrorTextureD3D11", "GetMirrorTextureGL", "ReleaseSharedGLTexture", "LockGLSharedTextureForAccess", "UnlockGLSharedTextureForAccess", "GetVulkanInstanceExtensionsRequired", "GetVulkanDeviceExtensionsRequired", "SetExplicitTimingMode", "SubmitExplicitTimingData"); + } + public VR_IVRCompositor_FnTable(Pointer peer) { + super(peer); + } + public static class ByReference extends VR_IVRCompositor_FnTable implements Structure.ByReference { + + }; + public static class ByValue extends VR_IVRCompositor_FnTable implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRDriverManager_FnTable.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRDriverManager_FnTable.java new file mode 100644 index 0000000000..13e444730b --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRDriverManager_FnTable.java @@ -0,0 +1,59 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Callback; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:2313
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VR_IVRDriverManager_FnTable extends Structure { + /** C type : GetDriverCount_callback* */ + public VR_IVRDriverManager_FnTable.GetDriverCount_callback GetDriverCount; + /** C type : GetDriverName_callback* */ + public VR_IVRDriverManager_FnTable.GetDriverName_callback GetDriverName; + /** C type : GetDriverHandle_callback* */ + public VR_IVRDriverManager_FnTable.GetDriverHandle_callback GetDriverHandle; + /** native declaration : headers\openvr_capi.h:2310 */ + public interface GetDriverCount_callback extends Callback { + int apply(); + }; + /** native declaration : headers\openvr_capi.h:2311 */ + public interface GetDriverName_callback extends Callback { + int apply(int nDriver, Pointer pchValue, int unBufferSize); + }; + /** native declaration : headers\openvr_capi.h:2312 */ + public interface GetDriverHandle_callback extends Callback { + long apply(Pointer pchDriverName); + }; + public VR_IVRDriverManager_FnTable() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("GetDriverCount", "GetDriverName", "GetDriverHandle"); + } + /** + * @param GetDriverCount C type : GetDriverCount_callback*
+ * @param GetDriverName C type : GetDriverName_callback*
+ * @param GetDriverHandle C type : GetDriverHandle_callback* + */ + public VR_IVRDriverManager_FnTable(VR_IVRDriverManager_FnTable.GetDriverCount_callback GetDriverCount, VR_IVRDriverManager_FnTable.GetDriverName_callback GetDriverName, VR_IVRDriverManager_FnTable.GetDriverHandle_callback GetDriverHandle) { + super(); + this.GetDriverCount = GetDriverCount; + this.GetDriverName = GetDriverName; + this.GetDriverHandle = GetDriverHandle; + } + public VR_IVRDriverManager_FnTable(Pointer peer) { + super(peer); + } + public static class ByReference extends VR_IVRDriverManager_FnTable implements Structure.ByReference { + + }; + public static class ByValue extends VR_IVRDriverManager_FnTable implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRExtendedDisplay_FnTable.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRExtendedDisplay_FnTable.java new file mode 100644 index 0000000000..2b04732a73 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRExtendedDisplay_FnTable.java @@ -0,0 +1,60 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Callback; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import com.sun.jna.ptr.IntByReference; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1807
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VR_IVRExtendedDisplay_FnTable extends Structure { + /** C type : GetWindowBounds_callback* */ + public VR_IVRExtendedDisplay_FnTable.GetWindowBounds_callback GetWindowBounds; + /** C type : GetEyeOutputViewport_callback* */ + public VR_IVRExtendedDisplay_FnTable.GetEyeOutputViewport_callback GetEyeOutputViewport; + /** C type : GetDXGIOutputInfo_callback* */ + public VR_IVRExtendedDisplay_FnTable.GetDXGIOutputInfo_callback GetDXGIOutputInfo; + /** native declaration : headers\openvr_capi.h:1804 */ + public interface GetWindowBounds_callback extends Callback { + void apply(IntByReference pnX, IntByReference pnY, IntByReference pnWidth, IntByReference pnHeight); + }; + /** native declaration : headers\openvr_capi.h:1805 */ + public interface GetEyeOutputViewport_callback extends Callback { + void apply(int eEye, IntByReference pnX, IntByReference pnY, IntByReference pnWidth, IntByReference pnHeight); + }; + /** native declaration : headers\openvr_capi.h:1806 */ + public interface GetDXGIOutputInfo_callback extends Callback { + void apply(IntByReference pnAdapterIndex, IntByReference pnAdapterOutputIndex); + }; + public VR_IVRExtendedDisplay_FnTable() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("GetWindowBounds", "GetEyeOutputViewport", "GetDXGIOutputInfo"); + } + /** + * @param GetWindowBounds C type : GetWindowBounds_callback*
+ * @param GetEyeOutputViewport C type : GetEyeOutputViewport_callback*
+ * @param GetDXGIOutputInfo C type : GetDXGIOutputInfo_callback* + */ + public VR_IVRExtendedDisplay_FnTable(VR_IVRExtendedDisplay_FnTable.GetWindowBounds_callback GetWindowBounds, VR_IVRExtendedDisplay_FnTable.GetEyeOutputViewport_callback GetEyeOutputViewport, VR_IVRExtendedDisplay_FnTable.GetDXGIOutputInfo_callback GetDXGIOutputInfo) { + super(); + this.GetWindowBounds = GetWindowBounds; + this.GetEyeOutputViewport = GetEyeOutputViewport; + this.GetDXGIOutputInfo = GetDXGIOutputInfo; + } + public VR_IVRExtendedDisplay_FnTable(Pointer peer) { + super(peer); + } + public static class ByReference extends VR_IVRExtendedDisplay_FnTable implements Structure.ByReference { + + }; + public static class ByValue extends VR_IVRExtendedDisplay_FnTable implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRIOBuffer_FnTable.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRIOBuffer_FnTable.java new file mode 100644 index 0000000000..5a6b9291d0 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRIOBuffer_FnTable.java @@ -0,0 +1,77 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Callback; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import com.sun.jna.ptr.IntByReference; +import com.sun.jna.ptr.LongByReference; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:2363
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VR_IVRIOBuffer_FnTable extends Structure { + /** C type : Open_callback* */ + public VR_IVRIOBuffer_FnTable.Open_callback Open; + /** C type : Close_callback* */ + public VR_IVRIOBuffer_FnTable.Close_callback Close; + /** C type : Read_callback* */ + public VR_IVRIOBuffer_FnTable.Read_callback Read; + /** C type : Write_callback* */ + public VR_IVRIOBuffer_FnTable.Write_callback Write; + /** C type : PropertyContainer_callback* */ + public VR_IVRIOBuffer_FnTable.PropertyContainer_callback PropertyContainer; + /** native declaration : headers\openvr_capi.h:2358 */ + public interface Open_callback extends Callback { + int apply(Pointer pchPath, int mode, int unElementSize, int unElements, LongByReference pulBuffer); + }; + /** native declaration : headers\openvr_capi.h:2359 */ + public interface Close_callback extends Callback { + int apply(long ulBuffer); + }; + /** native declaration : headers\openvr_capi.h:2360 */ + public interface Read_callback extends Callback { + int apply(long ulBuffer, Pointer pDst, int unBytes, IntByReference punRead); + }; + /** native declaration : headers\openvr_capi.h:2361 */ + public interface Write_callback extends Callback { + int apply(long ulBuffer, Pointer pSrc, int unBytes); + }; + /** native declaration : headers\openvr_capi.h:2362 */ + public interface PropertyContainer_callback extends Callback { + long apply(long ulBuffer); + }; + public VR_IVRIOBuffer_FnTable() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("Open", "Close", "Read", "Write", "PropertyContainer"); + } + /** + * @param Open C type : Open_callback*
+ * @param Close C type : Close_callback*
+ * @param Read C type : Read_callback*
+ * @param Write C type : Write_callback*
+ * @param PropertyContainer C type : PropertyContainer_callback* + */ + public VR_IVRIOBuffer_FnTable(VR_IVRIOBuffer_FnTable.Open_callback Open, VR_IVRIOBuffer_FnTable.Close_callback Close, VR_IVRIOBuffer_FnTable.Read_callback Read, VR_IVRIOBuffer_FnTable.Write_callback Write, VR_IVRIOBuffer_FnTable.PropertyContainer_callback PropertyContainer) { + super(); + this.Open = Open; + this.Close = Close; + this.Read = Read; + this.Write = Write; + this.PropertyContainer = PropertyContainer; + } + public VR_IVRIOBuffer_FnTable(Pointer peer) { + super(peer); + } + public static class ByReference extends VR_IVRIOBuffer_FnTable implements Structure.ByReference { + + }; + public static class ByValue extends VR_IVRIOBuffer_FnTable implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRInput_FnTable.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRInput_FnTable.java new file mode 100644 index 0000000000..44987cc991 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRInput_FnTable.java @@ -0,0 +1,140 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Callback; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import com.sun.jna.ptr.IntByReference; +import com.sun.jna.ptr.LongByReference; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:2351
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VR_IVRInput_FnTable extends Structure { + /** C type : SetActionManifestPath_callback* */ + public VR_IVRInput_FnTable.SetActionManifestPath_callback SetActionManifestPath; + /** C type : GetActionSetHandle_callback* */ + public VR_IVRInput_FnTable.GetActionSetHandle_callback GetActionSetHandle; + /** C type : GetActionHandle_callback* */ + public VR_IVRInput_FnTable.GetActionHandle_callback GetActionHandle; + /** C type : GetInputSourceHandle_callback* */ + public VR_IVRInput_FnTable.GetInputSourceHandle_callback GetInputSourceHandle; + /** C type : UpdateActionState_callback* */ + public VR_IVRInput_FnTable.UpdateActionState_callback UpdateActionState; + /** C type : GetDigitalActionData_callback* */ + public VR_IVRInput_FnTable.GetDigitalActionData_callback GetDigitalActionData; + /** C type : GetAnalogActionData_callback* */ + public VR_IVRInput_FnTable.GetAnalogActionData_callback GetAnalogActionData; + /** C type : GetPoseActionData_callback* */ + public VR_IVRInput_FnTable.GetPoseActionData_callback GetPoseActionData; + /** C type : GetSkeletalActionData_callback* */ + public VR_IVRInput_FnTable.GetSkeletalActionData_callback GetSkeletalActionData; + /** C type : GetSkeletalBoneData_callback* */ + public VR_IVRInput_FnTable.GetSkeletalBoneData_callback GetSkeletalBoneData; + /** C type : GetSkeletalBoneDataCompressed_callback* */ + public VR_IVRInput_FnTable.GetSkeletalBoneDataCompressed_callback GetSkeletalBoneDataCompressed; + /** C type : DecompressSkeletalBoneData_callback* */ + public VR_IVRInput_FnTable.DecompressSkeletalBoneData_callback DecompressSkeletalBoneData; + /** C type : TriggerHapticVibrationAction_callback* */ + public VR_IVRInput_FnTable.TriggerHapticVibrationAction_callback TriggerHapticVibrationAction; + /** C type : GetActionOrigins_callback* */ + public VR_IVRInput_FnTable.GetActionOrigins_callback GetActionOrigins; + /** C type : GetOriginLocalizedName_callback* */ + public VR_IVRInput_FnTable.GetOriginLocalizedName_callback GetOriginLocalizedName; + /** C type : GetOriginTrackedDeviceInfo_callback* */ + public VR_IVRInput_FnTable.GetOriginTrackedDeviceInfo_callback GetOriginTrackedDeviceInfo; + /** C type : ShowActionOrigins_callback* */ + public VR_IVRInput_FnTable.ShowActionOrigins_callback ShowActionOrigins; + /** C type : ShowBindingsForActionSet_callback* */ + public VR_IVRInput_FnTable.ShowBindingsForActionSet_callback ShowBindingsForActionSet; + /** native declaration : headers\openvr_capi.h:2333 */ + public interface SetActionManifestPath_callback extends Callback { + int apply(Pointer pchActionManifestPath); + }; + /** native declaration : headers\openvr_capi.h:2334 */ + public interface GetActionSetHandle_callback extends Callback { + int apply(Pointer pchActionSetName, LongByReference pHandle); + }; + /** native declaration : headers\openvr_capi.h:2335 */ + public interface GetActionHandle_callback extends Callback { + int apply(Pointer pchActionName, LongByReference pHandle); + }; + /** native declaration : headers\openvr_capi.h:2336 */ + public interface GetInputSourceHandle_callback extends Callback { + int apply(Pointer pchInputSourcePath, LongByReference pHandle); + }; + /** native declaration : headers\openvr_capi.h:2337 */ + public interface UpdateActionState_callback extends Callback { + int apply(VRActiveActionSet_t pSets, int unSizeOfVRSelectedActionSet_t, int unSetCount); + }; + /** native declaration : headers\openvr_capi.h:2338 */ + public interface GetDigitalActionData_callback extends Callback { + int apply(long action, InputDigitalActionData_t pActionData, int unActionDataSize, long ulRestrictToDevice); + }; + /** native declaration : headers\openvr_capi.h:2339 */ + public interface GetAnalogActionData_callback extends Callback { + int apply(long action, InputAnalogActionData_t pActionData, int unActionDataSize, long ulRestrictToDevice); + }; + /** native declaration : headers\openvr_capi.h:2340 */ + public interface GetPoseActionData_callback extends Callback { + int apply(long action, int eOrigin, float fPredictedSecondsFromNow, InputPoseActionData_t pActionData, int unActionDataSize, long ulRestrictToDevice); + }; + /** native declaration : headers\openvr_capi.h:2341 */ + public interface GetSkeletalActionData_callback extends Callback { + int apply(long action, InputSkeletalActionData_t pActionData, int unActionDataSize, long ulRestrictToDevice); + }; + /** native declaration : headers\openvr_capi.h:2342 */ + public interface GetSkeletalBoneData_callback extends Callback { + int apply(long action, int eTransformSpace, int eMotionRange, VRBoneTransform_t pTransformArray, int unTransformArrayCount, long ulRestrictToDevice); + }; + /** native declaration : headers\openvr_capi.h:2343 */ + public interface GetSkeletalBoneDataCompressed_callback extends Callback { + int apply(long action, int eTransformSpace, int eMotionRange, Pointer pvCompressedData, int unCompressedSize, IntByReference punRequiredCompressedSize, long ulRestrictToDevice); + }; + /** native declaration : headers\openvr_capi.h:2344 */ + public interface DecompressSkeletalBoneData_callback extends Callback { + int apply(Pointer pvCompressedBuffer, int unCompressedBufferSize, IntByReference peTransformSpace, VRBoneTransform_t pTransformArray, int unTransformArrayCount); + }; + /** native declaration : headers\openvr_capi.h:2345 */ + public interface TriggerHapticVibrationAction_callback extends Callback { + int apply(long action, float fStartSecondsFromNow, float fDurationSeconds, float fFrequency, float fAmplitude, long ulRestrictToDevice); + }; + /** native declaration : headers\openvr_capi.h:2346 */ + public interface GetActionOrigins_callback extends Callback { + int apply(long actionSetHandle, long digitalActionHandle, LongByReference originsOut, int originOutCount); + }; + /** native declaration : headers\openvr_capi.h:2347 */ + public interface GetOriginLocalizedName_callback extends Callback { + int apply(long origin, Pointer pchNameArray, int unNameArraySize); + }; + /** native declaration : headers\openvr_capi.h:2348 */ + public interface GetOriginTrackedDeviceInfo_callback extends Callback { + int apply(long origin, InputOriginInfo_t pOriginInfo, int unOriginInfoSize); + }; + /** native declaration : headers\openvr_capi.h:2349 */ + public interface ShowActionOrigins_callback extends Callback { + int apply(long actionSetHandle, long ulActionHandle); + }; + /** native declaration : headers\openvr_capi.h:2350 */ + public interface ShowBindingsForActionSet_callback extends Callback { + int apply(VRActiveActionSet_t pSets, int unSizeOfVRSelectedActionSet_t, int unSetCount, long originToHighlight); + }; + public VR_IVRInput_FnTable() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("SetActionManifestPath", "GetActionSetHandle", "GetActionHandle", "GetInputSourceHandle", "UpdateActionState", "GetDigitalActionData", "GetAnalogActionData", "GetPoseActionData", "GetSkeletalActionData", "GetSkeletalBoneData", "GetSkeletalBoneDataCompressed", "DecompressSkeletalBoneData", "TriggerHapticVibrationAction", "GetActionOrigins", "GetOriginLocalizedName", "GetOriginTrackedDeviceInfo", "ShowActionOrigins", "ShowBindingsForActionSet"); + } + public VR_IVRInput_FnTable(Pointer peer) { + super(peer); + } + public static class ByReference extends VR_IVRInput_FnTable implements Structure.ByReference { + + }; + public static class ByValue extends VR_IVRInput_FnTable implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRNotifications_FnTable.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRNotifications_FnTable.java new file mode 100644 index 0000000000..7e15f3591d --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRNotifications_FnTable.java @@ -0,0 +1,52 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Callback; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import com.sun.jna.ptr.IntByReference; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:2257
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VR_IVRNotifications_FnTable extends Structure { + /** C type : CreateNotification_callback* */ + public VR_IVRNotifications_FnTable.CreateNotification_callback CreateNotification; + /** C type : RemoveNotification_callback* */ + public VR_IVRNotifications_FnTable.RemoveNotification_callback RemoveNotification; + /** native declaration : headers\openvr_capi.h:2255 */ + public interface CreateNotification_callback extends Callback { + int apply(long ulOverlayHandle, long ulUserValue, int type, Pointer pchText, int style, NotificationBitmap_t pImage, IntByReference pNotificationId); + }; + /** native declaration : headers\openvr_capi.h:2256 */ + public interface RemoveNotification_callback extends Callback { + int apply(int notificationId); + }; + public VR_IVRNotifications_FnTable() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("CreateNotification", "RemoveNotification"); + } + /** + * @param CreateNotification C type : CreateNotification_callback*
+ * @param RemoveNotification C type : RemoveNotification_callback* + */ + public VR_IVRNotifications_FnTable(VR_IVRNotifications_FnTable.CreateNotification_callback CreateNotification, VR_IVRNotifications_FnTable.RemoveNotification_callback RemoveNotification) { + super(); + this.CreateNotification = CreateNotification; + this.RemoveNotification = RemoveNotification; + } + public VR_IVRNotifications_FnTable(Pointer peer) { + super(peer); + } + public static class ByReference extends VR_IVRNotifications_FnTable implements Structure.ByReference { + + }; + public static class ByValue extends VR_IVRNotifications_FnTable implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVROverlay_FnTable.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVROverlay_FnTable.java new file mode 100644 index 0000000000..f9405bb07d --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVROverlay_FnTable.java @@ -0,0 +1,526 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Callback; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import com.sun.jna.ptr.FloatByReference; +import com.sun.jna.ptr.IntByReference; +import com.sun.jna.ptr.LongByReference; +import com.sun.jna.ptr.PointerByReference; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:2211
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VR_IVROverlay_FnTable extends Structure { + /** C type : FindOverlay_callback* */ + public VR_IVROverlay_FnTable.FindOverlay_callback FindOverlay; + /** C type : CreateOverlay_callback* */ + public VR_IVROverlay_FnTable.CreateOverlay_callback CreateOverlay; + /** C type : DestroyOverlay_callback* */ + public VR_IVROverlay_FnTable.DestroyOverlay_callback DestroyOverlay; + /** C type : SetHighQualityOverlay_callback* */ + public VR_IVROverlay_FnTable.SetHighQualityOverlay_callback SetHighQualityOverlay; + /** C type : GetHighQualityOverlay_callback* */ + public VR_IVROverlay_FnTable.GetHighQualityOverlay_callback GetHighQualityOverlay; + /** C type : GetOverlayKey_callback* */ + public VR_IVROverlay_FnTable.GetOverlayKey_callback GetOverlayKey; + /** C type : GetOverlayName_callback* */ + public VR_IVROverlay_FnTable.GetOverlayName_callback GetOverlayName; + /** C type : SetOverlayName_callback* */ + public VR_IVROverlay_FnTable.SetOverlayName_callback SetOverlayName; + /** C type : GetOverlayImageData_callback* */ + public VR_IVROverlay_FnTable.GetOverlayImageData_callback GetOverlayImageData; + /** C type : GetOverlayErrorNameFromEnum_callback* */ + public VR_IVROverlay_FnTable.GetOverlayErrorNameFromEnum_callback GetOverlayErrorNameFromEnum; + /** C type : SetOverlayRenderingPid_callback* */ + public VR_IVROverlay_FnTable.SetOverlayRenderingPid_callback SetOverlayRenderingPid; + /** C type : GetOverlayRenderingPid_callback* */ + public VR_IVROverlay_FnTable.GetOverlayRenderingPid_callback GetOverlayRenderingPid; + /** C type : SetOverlayFlag_callback* */ + public VR_IVROverlay_FnTable.SetOverlayFlag_callback SetOverlayFlag; + /** C type : GetOverlayFlag_callback* */ + public VR_IVROverlay_FnTable.GetOverlayFlag_callback GetOverlayFlag; + /** C type : SetOverlayColor_callback* */ + public VR_IVROverlay_FnTable.SetOverlayColor_callback SetOverlayColor; + /** C type : GetOverlayColor_callback* */ + public VR_IVROverlay_FnTable.GetOverlayColor_callback GetOverlayColor; + /** C type : SetOverlayAlpha_callback* */ + public VR_IVROverlay_FnTable.SetOverlayAlpha_callback SetOverlayAlpha; + /** C type : GetOverlayAlpha_callback* */ + public VR_IVROverlay_FnTable.GetOverlayAlpha_callback GetOverlayAlpha; + /** C type : SetOverlayTexelAspect_callback* */ + public VR_IVROverlay_FnTable.SetOverlayTexelAspect_callback SetOverlayTexelAspect; + /** C type : GetOverlayTexelAspect_callback* */ + public VR_IVROverlay_FnTable.GetOverlayTexelAspect_callback GetOverlayTexelAspect; + /** C type : SetOverlaySortOrder_callback* */ + public VR_IVROverlay_FnTable.SetOverlaySortOrder_callback SetOverlaySortOrder; + /** C type : GetOverlaySortOrder_callback* */ + public VR_IVROverlay_FnTable.GetOverlaySortOrder_callback GetOverlaySortOrder; + /** C type : SetOverlayWidthInMeters_callback* */ + public VR_IVROverlay_FnTable.SetOverlayWidthInMeters_callback SetOverlayWidthInMeters; + /** C type : GetOverlayWidthInMeters_callback* */ + public VR_IVROverlay_FnTable.GetOverlayWidthInMeters_callback GetOverlayWidthInMeters; + /** C type : SetOverlayAutoCurveDistanceRangeInMeters_callback* */ + public VR_IVROverlay_FnTable.SetOverlayAutoCurveDistanceRangeInMeters_callback SetOverlayAutoCurveDistanceRangeInMeters; + /** C type : GetOverlayAutoCurveDistanceRangeInMeters_callback* */ + public VR_IVROverlay_FnTable.GetOverlayAutoCurveDistanceRangeInMeters_callback GetOverlayAutoCurveDistanceRangeInMeters; + /** C type : SetOverlayTextureColorSpace_callback* */ + public VR_IVROverlay_FnTable.SetOverlayTextureColorSpace_callback SetOverlayTextureColorSpace; + /** C type : GetOverlayTextureColorSpace_callback* */ + public VR_IVROverlay_FnTable.GetOverlayTextureColorSpace_callback GetOverlayTextureColorSpace; + /** C type : SetOverlayTextureBounds_callback* */ + public VR_IVROverlay_FnTable.SetOverlayTextureBounds_callback SetOverlayTextureBounds; + /** C type : GetOverlayTextureBounds_callback* */ + public VR_IVROverlay_FnTable.GetOverlayTextureBounds_callback GetOverlayTextureBounds; + /** C type : GetOverlayRenderModel_callback* */ + public VR_IVROverlay_FnTable.GetOverlayRenderModel_callback GetOverlayRenderModel; + /** C type : SetOverlayRenderModel_callback* */ + public VR_IVROverlay_FnTable.SetOverlayRenderModel_callback SetOverlayRenderModel; + /** C type : GetOverlayTransformType_callback* */ + public VR_IVROverlay_FnTable.GetOverlayTransformType_callback GetOverlayTransformType; + /** C type : SetOverlayTransformAbsolute_callback* */ + public VR_IVROverlay_FnTable.SetOverlayTransformAbsolute_callback SetOverlayTransformAbsolute; + /** C type : GetOverlayTransformAbsolute_callback* */ + public VR_IVROverlay_FnTable.GetOverlayTransformAbsolute_callback GetOverlayTransformAbsolute; + /** C type : SetOverlayTransformTrackedDeviceRelative_callback* */ + public VR_IVROverlay_FnTable.SetOverlayTransformTrackedDeviceRelative_callback SetOverlayTransformTrackedDeviceRelative; + /** C type : GetOverlayTransformTrackedDeviceRelative_callback* */ + public VR_IVROverlay_FnTable.GetOverlayTransformTrackedDeviceRelative_callback GetOverlayTransformTrackedDeviceRelative; + /** C type : SetOverlayTransformTrackedDeviceComponent_callback* */ + public VR_IVROverlay_FnTable.SetOverlayTransformTrackedDeviceComponent_callback SetOverlayTransformTrackedDeviceComponent; + /** C type : GetOverlayTransformTrackedDeviceComponent_callback* */ + public VR_IVROverlay_FnTable.GetOverlayTransformTrackedDeviceComponent_callback GetOverlayTransformTrackedDeviceComponent; + /** C type : GetOverlayTransformOverlayRelative_callback* */ + public VR_IVROverlay_FnTable.GetOverlayTransformOverlayRelative_callback GetOverlayTransformOverlayRelative; + /** C type : SetOverlayTransformOverlayRelative_callback* */ + public VR_IVROverlay_FnTable.SetOverlayTransformOverlayRelative_callback SetOverlayTransformOverlayRelative; + /** C type : ShowOverlay_callback* */ + public VR_IVROverlay_FnTable.ShowOverlay_callback ShowOverlay; + /** C type : HideOverlay_callback* */ + public VR_IVROverlay_FnTable.HideOverlay_callback HideOverlay; + /** C type : IsOverlayVisible_callback* */ + public VR_IVROverlay_FnTable.IsOverlayVisible_callback IsOverlayVisible; + /** C type : GetTransformForOverlayCoordinates_callback* */ + public VR_IVROverlay_FnTable.GetTransformForOverlayCoordinates_callback GetTransformForOverlayCoordinates; + /** C type : PollNextOverlayEvent_callback* */ + public VR_IVROverlay_FnTable.PollNextOverlayEvent_callback PollNextOverlayEvent; + /** C type : GetOverlayInputMethod_callback* */ + public VR_IVROverlay_FnTable.GetOverlayInputMethod_callback GetOverlayInputMethod; + /** C type : SetOverlayInputMethod_callback* */ + public VR_IVROverlay_FnTable.SetOverlayInputMethod_callback SetOverlayInputMethod; + /** C type : GetOverlayMouseScale_callback* */ + public VR_IVROverlay_FnTable.GetOverlayMouseScale_callback GetOverlayMouseScale; + /** C type : SetOverlayMouseScale_callback* */ + public VR_IVROverlay_FnTable.SetOverlayMouseScale_callback SetOverlayMouseScale; + /** C type : ComputeOverlayIntersection_callback* */ + public VR_IVROverlay_FnTable.ComputeOverlayIntersection_callback ComputeOverlayIntersection; + /** C type : IsHoverTargetOverlay_callback* */ + public VR_IVROverlay_FnTable.IsHoverTargetOverlay_callback IsHoverTargetOverlay; + /** C type : GetGamepadFocusOverlay_callback* */ + public VR_IVROverlay_FnTable.GetGamepadFocusOverlay_callback GetGamepadFocusOverlay; + /** C type : SetGamepadFocusOverlay_callback* */ + public VR_IVROverlay_FnTable.SetGamepadFocusOverlay_callback SetGamepadFocusOverlay; + /** C type : SetOverlayNeighbor_callback* */ + public VR_IVROverlay_FnTable.SetOverlayNeighbor_callback SetOverlayNeighbor; + /** C type : MoveGamepadFocusToNeighbor_callback* */ + public VR_IVROverlay_FnTable.MoveGamepadFocusToNeighbor_callback MoveGamepadFocusToNeighbor; + /** C type : SetOverlayDualAnalogTransform_callback* */ + public VR_IVROverlay_FnTable.SetOverlayDualAnalogTransform_callback SetOverlayDualAnalogTransform; + /** C type : GetOverlayDualAnalogTransform_callback* */ + public VR_IVROverlay_FnTable.GetOverlayDualAnalogTransform_callback GetOverlayDualAnalogTransform; + /** C type : SetOverlayTexture_callback* */ + public VR_IVROverlay_FnTable.SetOverlayTexture_callback SetOverlayTexture; + /** C type : ClearOverlayTexture_callback* */ + public VR_IVROverlay_FnTable.ClearOverlayTexture_callback ClearOverlayTexture; + /** C type : SetOverlayRaw_callback* */ + public VR_IVROverlay_FnTable.SetOverlayRaw_callback SetOverlayRaw; + /** C type : SetOverlayFromFile_callback* */ + public VR_IVROverlay_FnTable.SetOverlayFromFile_callback SetOverlayFromFile; + /** C type : GetOverlayTexture_callback* */ + public VR_IVROverlay_FnTable.GetOverlayTexture_callback GetOverlayTexture; + /** C type : ReleaseNativeOverlayHandle_callback* */ + public VR_IVROverlay_FnTable.ReleaseNativeOverlayHandle_callback ReleaseNativeOverlayHandle; + /** C type : GetOverlayTextureSize_callback* */ + public VR_IVROverlay_FnTable.GetOverlayTextureSize_callback GetOverlayTextureSize; + /** C type : CreateDashboardOverlay_callback* */ + public VR_IVROverlay_FnTable.CreateDashboardOverlay_callback CreateDashboardOverlay; + /** C type : IsDashboardVisible_callback* */ + public VR_IVROverlay_FnTable.IsDashboardVisible_callback IsDashboardVisible; + /** C type : IsActiveDashboardOverlay_callback* */ + public VR_IVROverlay_FnTable.IsActiveDashboardOverlay_callback IsActiveDashboardOverlay; + /** C type : SetDashboardOverlaySceneProcess_callback* */ + public VR_IVROverlay_FnTable.SetDashboardOverlaySceneProcess_callback SetDashboardOverlaySceneProcess; + /** C type : GetDashboardOverlaySceneProcess_callback* */ + public VR_IVROverlay_FnTable.GetDashboardOverlaySceneProcess_callback GetDashboardOverlaySceneProcess; + /** C type : ShowDashboard_callback* */ + public VR_IVROverlay_FnTable.ShowDashboard_callback ShowDashboard; + /** C type : GetPrimaryDashboardDevice_callback* */ + public VR_IVROverlay_FnTable.GetPrimaryDashboardDevice_callback GetPrimaryDashboardDevice; + /** C type : ShowKeyboard_callback* */ + public VR_IVROverlay_FnTable.ShowKeyboard_callback ShowKeyboard; + /** C type : ShowKeyboardForOverlay_callback* */ + public VR_IVROverlay_FnTable.ShowKeyboardForOverlay_callback ShowKeyboardForOverlay; + /** C type : GetKeyboardText_callback* */ + public VR_IVROverlay_FnTable.GetKeyboardText_callback GetKeyboardText; + /** C type : HideKeyboard_callback* */ + public VR_IVROverlay_FnTable.HideKeyboard_callback HideKeyboard; + /** C type : SetKeyboardTransformAbsolute_callback* */ + public VR_IVROverlay_FnTable.SetKeyboardTransformAbsolute_callback SetKeyboardTransformAbsolute; + /** C type : SetKeyboardPositionForOverlay_callback* */ + public VR_IVROverlay_FnTable.SetKeyboardPositionForOverlay_callback SetKeyboardPositionForOverlay; + /** C type : SetOverlayIntersectionMask_callback* */ + public VR_IVROverlay_FnTable.SetOverlayIntersectionMask_callback SetOverlayIntersectionMask; + /** C type : GetOverlayFlags_callback* */ + public VR_IVROverlay_FnTable.GetOverlayFlags_callback GetOverlayFlags; + /** C type : ShowMessageOverlay_callback* */ + public VR_IVROverlay_FnTable.ShowMessageOverlay_callback ShowMessageOverlay; + /** C type : CloseMessageOverlay_callback* */ + public VR_IVROverlay_FnTable.CloseMessageOverlay_callback CloseMessageOverlay; + /** native declaration : headers\openvr_capi.h:2129 */ + public interface FindOverlay_callback extends Callback { + int apply(Pointer pchOverlayKey, LongByReference pOverlayHandle); + }; + /** native declaration : headers\openvr_capi.h:2130 */ + public interface CreateOverlay_callback extends Callback { + int apply(Pointer pchOverlayKey, Pointer pchOverlayName, LongByReference pOverlayHandle); + }; + /** native declaration : headers\openvr_capi.h:2131 */ + public interface DestroyOverlay_callback extends Callback { + int apply(long ulOverlayHandle); + }; + /** native declaration : headers\openvr_capi.h:2132 */ + public interface SetHighQualityOverlay_callback extends Callback { + int apply(long ulOverlayHandle); + }; + /** native declaration : headers\openvr_capi.h:2133 */ + public interface GetHighQualityOverlay_callback extends Callback { + long apply(); + }; + /** native declaration : headers\openvr_capi.h:2134 */ + public interface GetOverlayKey_callback extends Callback { + int apply(long ulOverlayHandle, Pointer pchValue, int unBufferSize, IntByReference pError); + }; + /** native declaration : headers\openvr_capi.h:2135 */ + public interface GetOverlayName_callback extends Callback { + int apply(long ulOverlayHandle, Pointer pchValue, int unBufferSize, IntByReference pError); + }; + /** native declaration : headers\openvr_capi.h:2136 */ + public interface SetOverlayName_callback extends Callback { + int apply(long ulOverlayHandle, Pointer pchName); + }; + /** native declaration : headers\openvr_capi.h:2137 */ + public interface GetOverlayImageData_callback extends Callback { + int apply(long ulOverlayHandle, Pointer pvBuffer, int unBufferSize, IntByReference punWidth, IntByReference punHeight); + }; + /** native declaration : headers\openvr_capi.h:2138 */ + public interface GetOverlayErrorNameFromEnum_callback extends Callback { + Pointer apply(int error); + }; + /** native declaration : headers\openvr_capi.h:2139 */ + public interface SetOverlayRenderingPid_callback extends Callback { + int apply(long ulOverlayHandle, int unPID); + }; + /** native declaration : headers\openvr_capi.h:2140 */ + public interface GetOverlayRenderingPid_callback extends Callback { + int apply(long ulOverlayHandle); + }; + /** native declaration : headers\openvr_capi.h:2141 */ + public interface SetOverlayFlag_callback extends Callback { + int apply(long ulOverlayHandle, int eOverlayFlag, byte bEnabled); + }; + /** native declaration : headers\openvr_capi.h:2142 */ + public interface GetOverlayFlag_callback extends Callback { + int apply(long ulOverlayHandle, int eOverlayFlag, Pointer pbEnabled); + }; + /** native declaration : headers\openvr_capi.h:2143 */ + public interface SetOverlayColor_callback extends Callback { + int apply(long ulOverlayHandle, float fRed, float fGreen, float fBlue); + }; + /** native declaration : headers\openvr_capi.h:2144 */ + public interface GetOverlayColor_callback extends Callback { + int apply(long ulOverlayHandle, FloatByReference pfRed, FloatByReference pfGreen, FloatByReference pfBlue); + }; + /** native declaration : headers\openvr_capi.h:2145 */ + public interface SetOverlayAlpha_callback extends Callback { + int apply(long ulOverlayHandle, float fAlpha); + }; + /** native declaration : headers\openvr_capi.h:2146 */ + public interface GetOverlayAlpha_callback extends Callback { + int apply(long ulOverlayHandle, FloatByReference pfAlpha); + }; + /** native declaration : headers\openvr_capi.h:2147 */ + public interface SetOverlayTexelAspect_callback extends Callback { + int apply(long ulOverlayHandle, float fTexelAspect); + }; + /** native declaration : headers\openvr_capi.h:2148 */ + public interface GetOverlayTexelAspect_callback extends Callback { + int apply(long ulOverlayHandle, FloatByReference pfTexelAspect); + }; + /** native declaration : headers\openvr_capi.h:2149 */ + public interface SetOverlaySortOrder_callback extends Callback { + int apply(long ulOverlayHandle, int unSortOrder); + }; + /** native declaration : headers\openvr_capi.h:2150 */ + public interface GetOverlaySortOrder_callback extends Callback { + int apply(long ulOverlayHandle, IntByReference punSortOrder); + }; + /** native declaration : headers\openvr_capi.h:2151 */ + public interface SetOverlayWidthInMeters_callback extends Callback { + int apply(long ulOverlayHandle, float fWidthInMeters); + }; + /** native declaration : headers\openvr_capi.h:2152 */ + public interface GetOverlayWidthInMeters_callback extends Callback { + int apply(long ulOverlayHandle, FloatByReference pfWidthInMeters); + }; + /** native declaration : headers\openvr_capi.h:2153 */ + public interface SetOverlayAutoCurveDistanceRangeInMeters_callback extends Callback { + int apply(long ulOverlayHandle, float fMinDistanceInMeters, float fMaxDistanceInMeters); + }; + /** native declaration : headers\openvr_capi.h:2154 */ + public interface GetOverlayAutoCurveDistanceRangeInMeters_callback extends Callback { + int apply(long ulOverlayHandle, FloatByReference pfMinDistanceInMeters, FloatByReference pfMaxDistanceInMeters); + }; + /** native declaration : headers\openvr_capi.h:2155 */ + public interface SetOverlayTextureColorSpace_callback extends Callback { + int apply(long ulOverlayHandle, int eTextureColorSpace); + }; + /** native declaration : headers\openvr_capi.h:2156 */ + public interface GetOverlayTextureColorSpace_callback extends Callback { + int apply(long ulOverlayHandle, IntByReference peTextureColorSpace); + }; + /** native declaration : headers\openvr_capi.h:2157 */ + public interface SetOverlayTextureBounds_callback extends Callback { + int apply(long ulOverlayHandle, VRTextureBounds_t pOverlayTextureBounds); + }; + /** native declaration : headers\openvr_capi.h:2158 */ + public interface GetOverlayTextureBounds_callback extends Callback { + int apply(long ulOverlayHandle, VRTextureBounds_t pOverlayTextureBounds); + }; + /** native declaration : headers\openvr_capi.h:2159 */ + public interface GetOverlayRenderModel_callback extends Callback { + int apply(long ulOverlayHandle, Pointer pchValue, int unBufferSize, HmdColor_t pColor, IntByReference pError); + }; + /** native declaration : headers\openvr_capi.h:2160 */ + public interface SetOverlayRenderModel_callback extends Callback { + int apply(long ulOverlayHandle, Pointer pchRenderModel, HmdColor_t pColor); + }; + /** native declaration : headers\openvr_capi.h:2161 */ + public interface GetOverlayTransformType_callback extends Callback { + int apply(long ulOverlayHandle, IntByReference peTransformType); + }; + /** native declaration : headers\openvr_capi.h:2162 */ + public interface SetOverlayTransformAbsolute_callback extends Callback { + int apply(long ulOverlayHandle, int eTrackingOrigin, HmdMatrix34_t pmatTrackingOriginToOverlayTransform); + }; + /** native declaration : headers\openvr_capi.h:2163 */ + public interface GetOverlayTransformAbsolute_callback extends Callback { + int apply(long ulOverlayHandle, IntByReference peTrackingOrigin, HmdMatrix34_t pmatTrackingOriginToOverlayTransform); + }; + /** native declaration : headers\openvr_capi.h:2164 */ + public interface SetOverlayTransformTrackedDeviceRelative_callback extends Callback { + int apply(long ulOverlayHandle, int unTrackedDevice, HmdMatrix34_t pmatTrackedDeviceToOverlayTransform); + }; + /** native declaration : headers\openvr_capi.h:2165 */ + public interface GetOverlayTransformTrackedDeviceRelative_callback extends Callback { + int apply(long ulOverlayHandle, IntByReference punTrackedDevice, HmdMatrix34_t pmatTrackedDeviceToOverlayTransform); + }; + /** native declaration : headers\openvr_capi.h:2166 */ + public interface SetOverlayTransformTrackedDeviceComponent_callback extends Callback { + int apply(long ulOverlayHandle, int unDeviceIndex, Pointer pchComponentName); + }; + /** native declaration : headers\openvr_capi.h:2167 */ + public interface GetOverlayTransformTrackedDeviceComponent_callback extends Callback { + int apply(long ulOverlayHandle, IntByReference punDeviceIndex, Pointer pchComponentName, int unComponentNameSize); + }; + /** native declaration : headers\openvr_capi.h:2168 */ + public interface GetOverlayTransformOverlayRelative_callback extends Callback { + int apply(long ulOverlayHandle, LongByReference ulOverlayHandleParent, HmdMatrix34_t pmatParentOverlayToOverlayTransform); + }; + /** native declaration : headers\openvr_capi.h:2169 */ + public interface SetOverlayTransformOverlayRelative_callback extends Callback { + int apply(long ulOverlayHandle, long ulOverlayHandleParent, HmdMatrix34_t pmatParentOverlayToOverlayTransform); + }; + /** native declaration : headers\openvr_capi.h:2170 */ + public interface ShowOverlay_callback extends Callback { + int apply(long ulOverlayHandle); + }; + /** native declaration : headers\openvr_capi.h:2171 */ + public interface HideOverlay_callback extends Callback { + int apply(long ulOverlayHandle); + }; + /** native declaration : headers\openvr_capi.h:2172 */ + public interface IsOverlayVisible_callback extends Callback { + byte apply(long ulOverlayHandle); + }; + /** native declaration : headers\openvr_capi.h:2173 */ + public interface GetTransformForOverlayCoordinates_callback extends Callback { + int apply(long ulOverlayHandle, int eTrackingOrigin, HmdVector2_t.ByValue coordinatesInOverlay, HmdMatrix34_t pmatTransform); + }; + /** native declaration : headers\openvr_capi.h:2174 */ + public interface PollNextOverlayEvent_callback extends Callback { + byte apply(long ulOverlayHandle, VREvent_t pEvent, int uncbVREvent); + }; + /** native declaration : headers\openvr_capi.h:2175 */ + public interface GetOverlayInputMethod_callback extends Callback { + int apply(long ulOverlayHandle, IntByReference peInputMethod); + }; + /** native declaration : headers\openvr_capi.h:2176 */ + public interface SetOverlayInputMethod_callback extends Callback { + int apply(long ulOverlayHandle, int eInputMethod); + }; + /** native declaration : headers\openvr_capi.h:2177 */ + public interface GetOverlayMouseScale_callback extends Callback { + int apply(long ulOverlayHandle, HmdVector2_t pvecMouseScale); + }; + /** native declaration : headers\openvr_capi.h:2178 */ + public interface SetOverlayMouseScale_callback extends Callback { + int apply(long ulOverlayHandle, HmdVector2_t pvecMouseScale); + }; + /** native declaration : headers\openvr_capi.h:2179 */ + public interface ComputeOverlayIntersection_callback extends Callback { + byte apply(long ulOverlayHandle, VROverlayIntersectionParams_t pParams, VROverlayIntersectionResults_t pResults); + }; + /** native declaration : headers\openvr_capi.h:2180 */ + public interface IsHoverTargetOverlay_callback extends Callback { + byte apply(long ulOverlayHandle); + }; + /** native declaration : headers\openvr_capi.h:2181 */ + public interface GetGamepadFocusOverlay_callback extends Callback { + long apply(); + }; + /** native declaration : headers\openvr_capi.h:2182 */ + public interface SetGamepadFocusOverlay_callback extends Callback { + int apply(long ulNewFocusOverlay); + }; + /** native declaration : headers\openvr_capi.h:2183 */ + public interface SetOverlayNeighbor_callback extends Callback { + int apply(int eDirection, long ulFrom, long ulTo); + }; + /** native declaration : headers\openvr_capi.h:2184 */ + public interface MoveGamepadFocusToNeighbor_callback extends Callback { + int apply(int eDirection, long ulFrom); + }; + /** native declaration : headers\openvr_capi.h:2185 */ + public interface SetOverlayDualAnalogTransform_callback extends Callback { + int apply(long ulOverlay, int eWhich, HmdVector2_t vCenter, float fRadius); + }; + /** native declaration : headers\openvr_capi.h:2186 */ + public interface GetOverlayDualAnalogTransform_callback extends Callback { + int apply(long ulOverlay, int eWhich, HmdVector2_t pvCenter, FloatByReference pfRadius); + }; + /** native declaration : headers\openvr_capi.h:2187 */ + public interface SetOverlayTexture_callback extends Callback { + int apply(long ulOverlayHandle, Texture_t pTexture); + }; + /** native declaration : headers\openvr_capi.h:2188 */ + public interface ClearOverlayTexture_callback extends Callback { + int apply(long ulOverlayHandle); + }; + /** native declaration : headers\openvr_capi.h:2189 */ + public interface SetOverlayRaw_callback extends Callback { + int apply(long ulOverlayHandle, Pointer pvBuffer, int unWidth, int unHeight, int unDepth); + }; + /** native declaration : headers\openvr_capi.h:2190 */ + public interface SetOverlayFromFile_callback extends Callback { + int apply(long ulOverlayHandle, Pointer pchFilePath); + }; + /** native declaration : headers\openvr_capi.h:2191 */ + public interface GetOverlayTexture_callback extends Callback { + int apply(long ulOverlayHandle, PointerByReference pNativeTextureHandle, Pointer pNativeTextureRef, IntByReference pWidth, IntByReference pHeight, IntByReference pNativeFormat, IntByReference pAPIType, IntByReference pColorSpace, VRTextureBounds_t pTextureBounds); + }; + /** native declaration : headers\openvr_capi.h:2192 */ + public interface ReleaseNativeOverlayHandle_callback extends Callback { + int apply(long ulOverlayHandle, Pointer pNativeTextureHandle); + }; + /** native declaration : headers\openvr_capi.h:2193 */ + public interface GetOverlayTextureSize_callback extends Callback { + int apply(long ulOverlayHandle, IntByReference pWidth, IntByReference pHeight); + }; + /** native declaration : headers\openvr_capi.h:2194 */ + public interface CreateDashboardOverlay_callback extends Callback { + int apply(Pointer pchOverlayKey, Pointer pchOverlayFriendlyName, LongByReference pMainHandle, LongByReference pThumbnailHandle); + }; + /** native declaration : headers\openvr_capi.h:2195 */ + public interface IsDashboardVisible_callback extends Callback { + byte apply(); + }; + /** native declaration : headers\openvr_capi.h:2196 */ + public interface IsActiveDashboardOverlay_callback extends Callback { + byte apply(long ulOverlayHandle); + }; + /** native declaration : headers\openvr_capi.h:2197 */ + public interface SetDashboardOverlaySceneProcess_callback extends Callback { + int apply(long ulOverlayHandle, int unProcessId); + }; + /** native declaration : headers\openvr_capi.h:2198 */ + public interface GetDashboardOverlaySceneProcess_callback extends Callback { + int apply(long ulOverlayHandle, IntByReference punProcessId); + }; + /** native declaration : headers\openvr_capi.h:2199 */ + public interface ShowDashboard_callback extends Callback { + void apply(Pointer pchOverlayToShow); + }; + /** native declaration : headers\openvr_capi.h:2200 */ + public interface GetPrimaryDashboardDevice_callback extends Callback { + int apply(); + }; + /** native declaration : headers\openvr_capi.h:2201 */ + public interface ShowKeyboard_callback extends Callback { + int apply(int eInputMode, int eLineInputMode, Pointer pchDescription, int unCharMax, Pointer pchExistingText, byte bUseMinimalMode, long uUserValue); + }; + /** native declaration : headers\openvr_capi.h:2202 */ + public interface ShowKeyboardForOverlay_callback extends Callback { + int apply(long ulOverlayHandle, int eInputMode, int eLineInputMode, Pointer pchDescription, int unCharMax, Pointer pchExistingText, byte bUseMinimalMode, long uUserValue); + }; + /** native declaration : headers\openvr_capi.h:2203 */ + public interface GetKeyboardText_callback extends Callback { + int apply(Pointer pchText, int cchText); + }; + /** native declaration : headers\openvr_capi.h:2204 */ + public interface HideKeyboard_callback extends Callback { + void apply(); + }; + /** native declaration : headers\openvr_capi.h:2205 */ + public interface SetKeyboardTransformAbsolute_callback extends Callback { + void apply(int eTrackingOrigin, HmdMatrix34_t pmatTrackingOriginToKeyboardTransform); + }; + /** native declaration : headers\openvr_capi.h:2206 */ + public interface SetKeyboardPositionForOverlay_callback extends Callback { + void apply(long ulOverlayHandle, com.jme3.system.jopenvr.HmdRect2_t.ByValue avoidRect); + }; + /** native declaration : headers\openvr_capi.h:2207 */ + public interface SetOverlayIntersectionMask_callback extends Callback { + int apply(long ulOverlayHandle, VROverlayIntersectionMaskPrimitive_t pMaskPrimitives, int unNumMaskPrimitives, int unPrimitiveSize); + }; + /** native declaration : headers\openvr_capi.h:2208 */ + public interface GetOverlayFlags_callback extends Callback { + int apply(long ulOverlayHandle, IntByReference pFlags); + }; + /** native declaration : headers\openvr_capi.h:2209 */ + public interface ShowMessageOverlay_callback extends Callback { + int apply(Pointer pchText, Pointer pchCaption, Pointer pchButton0Text, Pointer pchButton1Text, Pointer pchButton2Text, Pointer pchButton3Text); + }; + /** native declaration : headers\openvr_capi.h:2210 */ + public interface CloseMessageOverlay_callback extends Callback { + void apply(); + }; + public VR_IVROverlay_FnTable() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("FindOverlay", "CreateOverlay", "DestroyOverlay", "SetHighQualityOverlay", "GetHighQualityOverlay", "GetOverlayKey", "GetOverlayName", "SetOverlayName", "GetOverlayImageData", "GetOverlayErrorNameFromEnum", "SetOverlayRenderingPid", "GetOverlayRenderingPid", "SetOverlayFlag", "GetOverlayFlag", "SetOverlayColor", "GetOverlayColor", "SetOverlayAlpha", "GetOverlayAlpha", "SetOverlayTexelAspect", "GetOverlayTexelAspect", "SetOverlaySortOrder", "GetOverlaySortOrder", "SetOverlayWidthInMeters", "GetOverlayWidthInMeters", "SetOverlayAutoCurveDistanceRangeInMeters", "GetOverlayAutoCurveDistanceRangeInMeters", "SetOverlayTextureColorSpace", "GetOverlayTextureColorSpace", "SetOverlayTextureBounds", "GetOverlayTextureBounds", "GetOverlayRenderModel", "SetOverlayRenderModel", "GetOverlayTransformType", "SetOverlayTransformAbsolute", "GetOverlayTransformAbsolute", "SetOverlayTransformTrackedDeviceRelative", "GetOverlayTransformTrackedDeviceRelative", "SetOverlayTransformTrackedDeviceComponent", "GetOverlayTransformTrackedDeviceComponent", "GetOverlayTransformOverlayRelative", "SetOverlayTransformOverlayRelative", "ShowOverlay", "HideOverlay", "IsOverlayVisible", "GetTransformForOverlayCoordinates", "PollNextOverlayEvent", "GetOverlayInputMethod", "SetOverlayInputMethod", "GetOverlayMouseScale", "SetOverlayMouseScale", "ComputeOverlayIntersection", "IsHoverTargetOverlay", "GetGamepadFocusOverlay", "SetGamepadFocusOverlay", "SetOverlayNeighbor", "MoveGamepadFocusToNeighbor", "SetOverlayDualAnalogTransform", "GetOverlayDualAnalogTransform", "SetOverlayTexture", "ClearOverlayTexture", "SetOverlayRaw", "SetOverlayFromFile", "GetOverlayTexture", "ReleaseNativeOverlayHandle", "GetOverlayTextureSize", "CreateDashboardOverlay", "IsDashboardVisible", "IsActiveDashboardOverlay", "SetDashboardOverlaySceneProcess", "GetDashboardOverlaySceneProcess", "ShowDashboard", "GetPrimaryDashboardDevice", "ShowKeyboard", "ShowKeyboardForOverlay", "GetKeyboardText", "HideKeyboard", "SetKeyboardTransformAbsolute", "SetKeyboardPositionForOverlay", "SetOverlayIntersectionMask", "GetOverlayFlags", "ShowMessageOverlay", "CloseMessageOverlay"); + } + public VR_IVROverlay_FnTable(Pointer peer) { + super(peer); + } + public static class ByReference extends VR_IVROverlay_FnTable implements Structure.ByReference { + + }; + public static class ByValue extends VR_IVROverlay_FnTable implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRRenderModels_FnTable.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRRenderModels_FnTable.java new file mode 100644 index 0000000000..3d448c307e --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRRenderModels_FnTable.java @@ -0,0 +1,146 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Callback; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import com.sun.jna.ptr.IntByReference; +import com.sun.jna.ptr.PointerByReference; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:2251
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VR_IVRRenderModels_FnTable extends Structure { + /** C type : LoadRenderModel_Async_callback* */ + public VR_IVRRenderModels_FnTable.LoadRenderModel_Async_callback LoadRenderModel_Async; + /** C type : FreeRenderModel_callback* */ + public VR_IVRRenderModels_FnTable.FreeRenderModel_callback FreeRenderModel; + /** C type : LoadTexture_Async_callback* */ + public VR_IVRRenderModels_FnTable.LoadTexture_Async_callback LoadTexture_Async; + /** C type : FreeTexture_callback* */ + public VR_IVRRenderModels_FnTable.FreeTexture_callback FreeTexture; + /** C type : LoadTextureD3D11_Async_callback* */ + public VR_IVRRenderModels_FnTable.LoadTextureD3D11_Async_callback LoadTextureD3D11_Async; + /** C type : LoadIntoTextureD3D11_Async_callback* */ + public VR_IVRRenderModels_FnTable.LoadIntoTextureD3D11_Async_callback LoadIntoTextureD3D11_Async; + /** C type : FreeTextureD3D11_callback* */ + public VR_IVRRenderModels_FnTable.FreeTextureD3D11_callback FreeTextureD3D11; + /** C type : GetRenderModelName_callback* */ + public VR_IVRRenderModels_FnTable.GetRenderModelName_callback GetRenderModelName; + /** C type : GetRenderModelCount_callback* */ + public VR_IVRRenderModels_FnTable.GetRenderModelCount_callback GetRenderModelCount; + /** C type : GetComponentCount_callback* */ + public VR_IVRRenderModels_FnTable.GetComponentCount_callback GetComponentCount; + /** C type : GetComponentName_callback* */ + public VR_IVRRenderModels_FnTable.GetComponentName_callback GetComponentName; + /** C type : GetComponentButtonMask_callback* */ + public VR_IVRRenderModels_FnTable.GetComponentButtonMask_callback GetComponentButtonMask; + /** C type : GetComponentRenderModelName_callback* */ + public VR_IVRRenderModels_FnTable.GetComponentRenderModelName_callback GetComponentRenderModelName; + /** C type : GetComponentStateForDevicePath_callback* */ + public VR_IVRRenderModels_FnTable.GetComponentStateForDevicePath_callback GetComponentStateForDevicePath; + /** C type : GetComponentState_callback* */ + public VR_IVRRenderModels_FnTable.GetComponentState_callback GetComponentState; + /** C type : RenderModelHasComponent_callback* */ + public VR_IVRRenderModels_FnTable.RenderModelHasComponent_callback RenderModelHasComponent; + /** C type : GetRenderModelThumbnailURL_callback* */ + public VR_IVRRenderModels_FnTable.GetRenderModelThumbnailURL_callback GetRenderModelThumbnailURL; + /** C type : GetRenderModelOriginalPath_callback* */ + public VR_IVRRenderModels_FnTable.GetRenderModelOriginalPath_callback GetRenderModelOriginalPath; + /** C type : GetRenderModelErrorNameFromEnum_callback* */ + public VR_IVRRenderModels_FnTable.GetRenderModelErrorNameFromEnum_callback GetRenderModelErrorNameFromEnum; + /** native declaration : headers\openvr_capi.h:2232 */ + public interface LoadRenderModel_Async_callback extends Callback { + int apply(Pointer pchRenderModelName, PointerByReference ppRenderModel); + }; + /** native declaration : headers\openvr_capi.h:2233 */ + public interface FreeRenderModel_callback extends Callback { + void apply(RenderModel_t pRenderModel); + }; + /** native declaration : headers\openvr_capi.h:2234 */ + public interface LoadTexture_Async_callback extends Callback { + int apply(int textureId, PointerByReference ppTexture); + }; + /** native declaration : headers\openvr_capi.h:2235 */ + public interface FreeTexture_callback extends Callback { + void apply(RenderModel_TextureMap_t pTexture); + }; + /** native declaration : headers\openvr_capi.h:2236 */ + public interface LoadTextureD3D11_Async_callback extends Callback { + int apply(int textureId, Pointer pD3D11Device, PointerByReference ppD3D11Texture2D); + }; + /** native declaration : headers\openvr_capi.h:2237 */ + public interface LoadIntoTextureD3D11_Async_callback extends Callback { + int apply(int textureId, Pointer pDstTexture); + }; + /** native declaration : headers\openvr_capi.h:2238 */ + public interface FreeTextureD3D11_callback extends Callback { + void apply(Pointer pD3D11Texture2D); + }; + /** native declaration : headers\openvr_capi.h:2239 */ + public interface GetRenderModelName_callback extends Callback { + int apply(int unRenderModelIndex, Pointer pchRenderModelName, int unRenderModelNameLen); + }; + /** native declaration : headers\openvr_capi.h:2240 */ + public interface GetRenderModelCount_callback extends Callback { + int apply(); + }; + /** native declaration : headers\openvr_capi.h:2241 */ + public interface GetComponentCount_callback extends Callback { + int apply(Pointer pchRenderModelName); + }; + /** native declaration : headers\openvr_capi.h:2242 */ + public interface GetComponentName_callback extends Callback { + int apply(Pointer pchRenderModelName, int unComponentIndex, Pointer pchComponentName, int unComponentNameLen); + }; + /** native declaration : headers\openvr_capi.h:2243 */ + public interface GetComponentButtonMask_callback extends Callback { + long apply(Pointer pchRenderModelName, Pointer pchComponentName); + }; + /** native declaration : headers\openvr_capi.h:2244 */ + public interface GetComponentRenderModelName_callback extends Callback { + int apply(Pointer pchRenderModelName, Pointer pchComponentName, Pointer pchComponentRenderModelName, int unComponentRenderModelNameLen); + }; + /** native declaration : headers\openvr_capi.h:2245 */ + public interface GetComponentStateForDevicePath_callback extends Callback { + byte apply(Pointer pchRenderModelName, Pointer pchComponentName, long devicePath, RenderModel_ControllerMode_State_t pState, RenderModel_ComponentState_t pComponentState); + }; + /** native declaration : headers\openvr_capi.h:2246 */ + public interface GetComponentState_callback extends Callback { + byte apply(Pointer pchRenderModelName, Pointer pchComponentName, VRControllerState_t pControllerState, RenderModel_ControllerMode_State_t pState, RenderModel_ComponentState_t pComponentState); + }; + /** native declaration : headers\openvr_capi.h:2247 */ + public interface RenderModelHasComponent_callback extends Callback { + byte apply(Pointer pchRenderModelName, Pointer pchComponentName); + }; + /** native declaration : headers\openvr_capi.h:2248 */ + public interface GetRenderModelThumbnailURL_callback extends Callback { + int apply(Pointer pchRenderModelName, Pointer pchThumbnailURL, int unThumbnailURLLen, IntByReference peError); + }; + /** native declaration : headers\openvr_capi.h:2249 */ + public interface GetRenderModelOriginalPath_callback extends Callback { + int apply(Pointer pchRenderModelName, Pointer pchOriginalPath, int unOriginalPathLen, IntByReference peError); + }; + /** native declaration : headers\openvr_capi.h:2250 */ + public interface GetRenderModelErrorNameFromEnum_callback extends Callback { + Pointer apply(int error); + }; + public VR_IVRRenderModels_FnTable() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("LoadRenderModel_Async", "FreeRenderModel", "LoadTexture_Async", "FreeTexture", "LoadTextureD3D11_Async", "LoadIntoTextureD3D11_Async", "FreeTextureD3D11", "GetRenderModelName", "GetRenderModelCount", "GetComponentCount", "GetComponentName", "GetComponentButtonMask", "GetComponentRenderModelName", "GetComponentStateForDevicePath", "GetComponentState", "RenderModelHasComponent", "GetRenderModelThumbnailURL", "GetRenderModelOriginalPath", "GetRenderModelErrorNameFromEnum"); + } + public VR_IVRRenderModels_FnTable(Pointer peer) { + super(peer); + } + public static class ByReference extends VR_IVRRenderModels_FnTable implements Structure.ByReference { + + }; + public static class ByValue extends VR_IVRRenderModels_FnTable implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRResources_FnTable.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRResources_FnTable.java new file mode 100644 index 0000000000..1533e094c8 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRResources_FnTable.java @@ -0,0 +1,51 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Callback; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:2305
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VR_IVRResources_FnTable extends Structure { + /** C type : LoadSharedResource_callback* */ + public VR_IVRResources_FnTable.LoadSharedResource_callback LoadSharedResource; + /** C type : GetResourceFullPath_callback* */ + public VR_IVRResources_FnTable.GetResourceFullPath_callback GetResourceFullPath; + /** native declaration : headers\openvr_capi.h:2303 */ + public interface LoadSharedResource_callback extends Callback { + int apply(Pointer pchResourceName, Pointer pchBuffer, int unBufferLen); + }; + /** native declaration : headers\openvr_capi.h:2304 */ + public interface GetResourceFullPath_callback extends Callback { + int apply(Pointer pchResourceName, Pointer pchResourceTypeDirectory, Pointer pchPathBuffer, int unBufferLen); + }; + public VR_IVRResources_FnTable() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("LoadSharedResource", "GetResourceFullPath"); + } + /** + * @param LoadSharedResource C type : LoadSharedResource_callback*
+ * @param GetResourceFullPath C type : GetResourceFullPath_callback* + */ + public VR_IVRResources_FnTable(VR_IVRResources_FnTable.LoadSharedResource_callback LoadSharedResource, VR_IVRResources_FnTable.GetResourceFullPath_callback GetResourceFullPath) { + super(); + this.LoadSharedResource = LoadSharedResource; + this.GetResourceFullPath = GetResourceFullPath; + } + public VR_IVRResources_FnTable(Pointer peer) { + super(peer); + } + public static class ByReference extends VR_IVRResources_FnTable implements Structure.ByReference { + + }; + public static class ByValue extends VR_IVRResources_FnTable implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRScreenshots_FnTable.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRScreenshots_FnTable.java new file mode 100644 index 0000000000..058637d0d4 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRScreenshots_FnTable.java @@ -0,0 +1,92 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Callback; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import com.sun.jna.ptr.IntByReference; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:2299
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VR_IVRScreenshots_FnTable extends Structure { + /** C type : RequestScreenshot_callback* */ + public VR_IVRScreenshots_FnTable.RequestScreenshot_callback RequestScreenshot; + /** C type : HookScreenshot_callback* */ + public VR_IVRScreenshots_FnTable.HookScreenshot_callback HookScreenshot; + /** C type : GetScreenshotPropertyType_callback* */ + public VR_IVRScreenshots_FnTable.GetScreenshotPropertyType_callback GetScreenshotPropertyType; + /** C type : GetScreenshotPropertyFilename_callback* */ + public VR_IVRScreenshots_FnTable.GetScreenshotPropertyFilename_callback GetScreenshotPropertyFilename; + /** C type : UpdateScreenshotProgress_callback* */ + public VR_IVRScreenshots_FnTable.UpdateScreenshotProgress_callback UpdateScreenshotProgress; + /** C type : TakeStereoScreenshot_callback* */ + public VR_IVRScreenshots_FnTable.TakeStereoScreenshot_callback TakeStereoScreenshot; + /** C type : SubmitScreenshot_callback* */ + public VR_IVRScreenshots_FnTable.SubmitScreenshot_callback SubmitScreenshot; + /** native declaration : headers\openvr_capi.h:2292 */ + public interface RequestScreenshot_callback extends Callback { + int apply(IntByReference pOutScreenshotHandle, int type, Pointer pchPreviewFilename, Pointer pchVRFilename); + }; + /** native declaration : headers\openvr_capi.h:2293 */ + public interface HookScreenshot_callback extends Callback { + int apply(IntByReference pSupportedTypes, int numTypes); + }; + /** native declaration : headers\openvr_capi.h:2294 */ + public interface GetScreenshotPropertyType_callback extends Callback { + int apply(int screenshotHandle, IntByReference pError); + }; + /** native declaration : headers\openvr_capi.h:2295 */ + public interface GetScreenshotPropertyFilename_callback extends Callback { + int apply(int screenshotHandle, int filenameType, Pointer pchFilename, int cchFilename, IntByReference pError); + }; + /** native declaration : headers\openvr_capi.h:2296 */ + public interface UpdateScreenshotProgress_callback extends Callback { + int apply(int screenshotHandle, float flProgress); + }; + /** native declaration : headers\openvr_capi.h:2297 */ + public interface TakeStereoScreenshot_callback extends Callback { + int apply(IntByReference pOutScreenshotHandle, Pointer pchPreviewFilename, Pointer pchVRFilename); + }; + /** native declaration : headers\openvr_capi.h:2298 */ + public interface SubmitScreenshot_callback extends Callback { + int apply(int screenshotHandle, int type, Pointer pchSourcePreviewFilename, Pointer pchSourceVRFilename); + }; + public VR_IVRScreenshots_FnTable() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("RequestScreenshot", "HookScreenshot", "GetScreenshotPropertyType", "GetScreenshotPropertyFilename", "UpdateScreenshotProgress", "TakeStereoScreenshot", "SubmitScreenshot"); + } + /** + * @param RequestScreenshot C type : RequestScreenshot_callback*
+ * @param HookScreenshot C type : HookScreenshot_callback*
+ * @param GetScreenshotPropertyType C type : GetScreenshotPropertyType_callback*
+ * @param GetScreenshotPropertyFilename C type : GetScreenshotPropertyFilename_callback*
+ * @param UpdateScreenshotProgress C type : UpdateScreenshotProgress_callback*
+ * @param TakeStereoScreenshot C type : TakeStereoScreenshot_callback*
+ * @param SubmitScreenshot C type : SubmitScreenshot_callback* + */ + public VR_IVRScreenshots_FnTable(VR_IVRScreenshots_FnTable.RequestScreenshot_callback RequestScreenshot, VR_IVRScreenshots_FnTable.HookScreenshot_callback HookScreenshot, VR_IVRScreenshots_FnTable.GetScreenshotPropertyType_callback GetScreenshotPropertyType, VR_IVRScreenshots_FnTable.GetScreenshotPropertyFilename_callback GetScreenshotPropertyFilename, VR_IVRScreenshots_FnTable.UpdateScreenshotProgress_callback UpdateScreenshotProgress, VR_IVRScreenshots_FnTable.TakeStereoScreenshot_callback TakeStereoScreenshot, VR_IVRScreenshots_FnTable.SubmitScreenshot_callback SubmitScreenshot) { + super(); + this.RequestScreenshot = RequestScreenshot; + this.HookScreenshot = HookScreenshot; + this.GetScreenshotPropertyType = GetScreenshotPropertyType; + this.GetScreenshotPropertyFilename = GetScreenshotPropertyFilename; + this.UpdateScreenshotProgress = UpdateScreenshotProgress; + this.TakeStereoScreenshot = TakeStereoScreenshot; + this.SubmitScreenshot = SubmitScreenshot; + } + public VR_IVRScreenshots_FnTable(Pointer peer) { + super(peer); + } + public static class ByReference extends VR_IVRScreenshots_FnTable implements Structure.ByReference { + + }; + public static class ByValue extends VR_IVRScreenshots_FnTable implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRSettings_FnTable.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRSettings_FnTable.java new file mode 100644 index 0000000000..ebbe247fb9 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRSettings_FnTable.java @@ -0,0 +1,103 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Callback; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import com.sun.jna.ptr.IntByReference; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:2283
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VR_IVRSettings_FnTable extends Structure { + /** C type : GetSettingsErrorNameFromEnum_callback* */ + public VR_IVRSettings_FnTable.GetSettingsErrorNameFromEnum_callback GetSettingsErrorNameFromEnum; + /** C type : Sync_callback* */ + public VR_IVRSettings_FnTable.Sync_callback Sync; + /** C type : SetBool_callback* */ + public VR_IVRSettings_FnTable.SetBool_callback SetBool; + /** C type : SetInt32_callback* */ + public VR_IVRSettings_FnTable.SetInt32_callback SetInt32; + /** C type : SetFloat_callback* */ + public VR_IVRSettings_FnTable.SetFloat_callback SetFloat; + /** C type : SetString_callback* */ + public VR_IVRSettings_FnTable.SetString_callback SetString; + /** C type : GetBool_callback* */ + public VR_IVRSettings_FnTable.GetBool_callback GetBool; + /** C type : GetInt32_callback* */ + public VR_IVRSettings_FnTable.GetInt32_callback GetInt32; + /** C type : GetFloat_callback* */ + public VR_IVRSettings_FnTable.GetFloat_callback GetFloat; + /** C type : GetString_callback* */ + public VR_IVRSettings_FnTable.GetString_callback GetString; + /** C type : RemoveSection_callback* */ + public VR_IVRSettings_FnTable.RemoveSection_callback RemoveSection; + /** C type : RemoveKeyInSection_callback* */ + public VR_IVRSettings_FnTable.RemoveKeyInSection_callback RemoveKeyInSection; + /** native declaration : headers\openvr_capi.h:2271 */ + public interface GetSettingsErrorNameFromEnum_callback extends Callback { + Pointer apply(int eError); + }; + /** native declaration : headers\openvr_capi.h:2272 */ + public interface Sync_callback extends Callback { + byte apply(byte bForce, IntByReference peError); + }; + /** native declaration : headers\openvr_capi.h:2273 */ + public interface SetBool_callback extends Callback { + void apply(Pointer pchSection, Pointer pchSettingsKey, byte bValue, IntByReference peError); + }; + /** native declaration : headers\openvr_capi.h:2274 */ + public interface SetInt32_callback extends Callback { + void apply(Pointer pchSection, Pointer pchSettingsKey, int nValue, IntByReference peError); + }; + /** native declaration : headers\openvr_capi.h:2275 */ + public interface SetFloat_callback extends Callback { + void apply(Pointer pchSection, Pointer pchSettingsKey, float flValue, IntByReference peError); + }; + /** native declaration : headers\openvr_capi.h:2276 */ + public interface SetString_callback extends Callback { + void apply(Pointer pchSection, Pointer pchSettingsKey, Pointer pchValue, IntByReference peError); + }; + /** native declaration : headers\openvr_capi.h:2277 */ + public interface GetBool_callback extends Callback { + byte apply(Pointer pchSection, Pointer pchSettingsKey, IntByReference peError); + }; + /** native declaration : headers\openvr_capi.h:2278 */ + public interface GetInt32_callback extends Callback { + int apply(Pointer pchSection, Pointer pchSettingsKey, IntByReference peError); + }; + /** native declaration : headers\openvr_capi.h:2279 */ + public interface GetFloat_callback extends Callback { + float apply(Pointer pchSection, Pointer pchSettingsKey, IntByReference peError); + }; + /** native declaration : headers\openvr_capi.h:2280 */ + public interface GetString_callback extends Callback { + void apply(Pointer pchSection, Pointer pchSettingsKey, Pointer pchValue, int unValueLen, IntByReference peError); + }; + /** native declaration : headers\openvr_capi.h:2281 */ + public interface RemoveSection_callback extends Callback { + void apply(Pointer pchSection, IntByReference peError); + }; + /** native declaration : headers\openvr_capi.h:2282 */ + public interface RemoveKeyInSection_callback extends Callback { + void apply(Pointer pchSection, Pointer pchSettingsKey, IntByReference peError); + }; + public VR_IVRSettings_FnTable() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("GetSettingsErrorNameFromEnum", "Sync", "SetBool", "SetInt32", "SetFloat", "SetString", "GetBool", "GetInt32", "GetFloat", "GetString", "RemoveSection", "RemoveKeyInSection"); + } + public VR_IVRSettings_FnTable(Pointer peer) { + super(peer); + } + public static class ByReference extends VR_IVRSettings_FnTable implements Structure.ByReference { + + }; + public static class ByValue extends VR_IVRSettings_FnTable implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRSpatialAnchors_FnTable.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRSpatialAnchors_FnTable.java new file mode 100644 index 0000000000..3b28c8da19 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRSpatialAnchors_FnTable.java @@ -0,0 +1,68 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Callback; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import com.sun.jna.ptr.IntByReference; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:2373
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VR_IVRSpatialAnchors_FnTable extends Structure { + /** C type : CreateSpatialAnchorFromDescriptor_callback* */ + public VR_IVRSpatialAnchors_FnTable.CreateSpatialAnchorFromDescriptor_callback CreateSpatialAnchorFromDescriptor; + /** C type : CreateSpatialAnchorFromPose_callback* */ + public VR_IVRSpatialAnchors_FnTable.CreateSpatialAnchorFromPose_callback CreateSpatialAnchorFromPose; + /** C type : GetSpatialAnchorPose_callback* */ + public VR_IVRSpatialAnchors_FnTable.GetSpatialAnchorPose_callback GetSpatialAnchorPose; + /** C type : GetSpatialAnchorDescriptor_callback* */ + public VR_IVRSpatialAnchors_FnTable.GetSpatialAnchorDescriptor_callback GetSpatialAnchorDescriptor; + /** native declaration : headers\openvr_capi.h:2369 */ + public interface CreateSpatialAnchorFromDescriptor_callback extends Callback { + int apply(Pointer pchDescriptor, IntByReference pHandleOut); + }; + /** native declaration : headers\openvr_capi.h:2370 */ + public interface CreateSpatialAnchorFromPose_callback extends Callback { + int apply(int unDeviceIndex, int eOrigin, SpatialAnchorPose_t pPose, IntByReference pHandleOut); + }; + /** native declaration : headers\openvr_capi.h:2371 */ + public interface GetSpatialAnchorPose_callback extends Callback { + int apply(int unHandle, int eOrigin, SpatialAnchorPose_t pPoseOut); + }; + /** native declaration : headers\openvr_capi.h:2372 */ + public interface GetSpatialAnchorDescriptor_callback extends Callback { + int apply(int unHandle, Pointer pchDescriptorOut, IntByReference punDescriptorBufferLenInOut); + }; + public VR_IVRSpatialAnchors_FnTable() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("CreateSpatialAnchorFromDescriptor", "CreateSpatialAnchorFromPose", "GetSpatialAnchorPose", "GetSpatialAnchorDescriptor"); + } + /** + * @param CreateSpatialAnchorFromDescriptor C type : CreateSpatialAnchorFromDescriptor_callback*
+ * @param CreateSpatialAnchorFromPose C type : CreateSpatialAnchorFromPose_callback*
+ * @param GetSpatialAnchorPose C type : GetSpatialAnchorPose_callback*
+ * @param GetSpatialAnchorDescriptor C type : GetSpatialAnchorDescriptor_callback* + */ + public VR_IVRSpatialAnchors_FnTable(VR_IVRSpatialAnchors_FnTable.CreateSpatialAnchorFromDescriptor_callback CreateSpatialAnchorFromDescriptor, VR_IVRSpatialAnchors_FnTable.CreateSpatialAnchorFromPose_callback CreateSpatialAnchorFromPose, VR_IVRSpatialAnchors_FnTable.GetSpatialAnchorPose_callback GetSpatialAnchorPose, VR_IVRSpatialAnchors_FnTable.GetSpatialAnchorDescriptor_callback GetSpatialAnchorDescriptor) { + super(); + this.CreateSpatialAnchorFromDescriptor = CreateSpatialAnchorFromDescriptor; + this.CreateSpatialAnchorFromPose = CreateSpatialAnchorFromPose; + this.GetSpatialAnchorPose = GetSpatialAnchorPose; + this.GetSpatialAnchorDescriptor = GetSpatialAnchorDescriptor; + } + public VR_IVRSpatialAnchors_FnTable(Pointer peer) { + super(peer); + } + public static class ByReference extends VR_IVRSpatialAnchors_FnTable implements Structure.ByReference { + + }; + public static class ByValue extends VR_IVRSpatialAnchors_FnTable implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRSystem_FnTable.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRSystem_FnTable.java new file mode 100644 index 0000000000..8257d23a4f --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRSystem_FnTable.java @@ -0,0 +1,317 @@ +package com.jme3.system.jopenvr; +import com.jme3.system.jopenvr.JOpenVRLibrary.VkInstance_T; +import com.sun.jna.Callback; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import com.sun.jna.ptr.FloatByReference; +import com.sun.jna.ptr.IntByReference; +import com.sun.jna.ptr.LongByReference; +import java.util.Arrays; +import java.util.List; +/** + * OpenVR Function Pointer Tables
+ * native declaration : headers\openvr_capi.h:1799
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VR_IVRSystem_FnTable extends Structure { + /** C type : GetRecommendedRenderTargetSize_callback* */ + public VR_IVRSystem_FnTable.GetRecommendedRenderTargetSize_callback GetRecommendedRenderTargetSize; + /** C type : GetProjectionMatrix_callback* */ + public VR_IVRSystem_FnTable.GetProjectionMatrix_callback GetProjectionMatrix; + /** C type : GetProjectionRaw_callback* */ + public VR_IVRSystem_FnTable.GetProjectionRaw_callback GetProjectionRaw; + /** C type : ComputeDistortion_callback* */ + public VR_IVRSystem_FnTable.ComputeDistortion_callback ComputeDistortion; + /** C type : GetEyeToHeadTransform_callback* */ + public VR_IVRSystem_FnTable.GetEyeToHeadTransform_callback GetEyeToHeadTransform; + /** C type : GetTimeSinceLastVsync_callback* */ + public VR_IVRSystem_FnTable.GetTimeSinceLastVsync_callback GetTimeSinceLastVsync; + /** C type : GetD3D9AdapterIndex_callback* */ + public VR_IVRSystem_FnTable.GetD3D9AdapterIndex_callback GetD3D9AdapterIndex; + /** C type : GetDXGIOutputInfo_callback* */ + public com.jme3.system.jopenvr.VR_IVRExtendedDisplay_FnTable.GetDXGIOutputInfo_callback GetDXGIOutputInfo; + /** C type : GetOutputDevice_callback* */ + public VR_IVRSystem_FnTable.GetOutputDevice_callback GetOutputDevice; + /** C type : IsDisplayOnDesktop_callback* */ + public VR_IVRSystem_FnTable.IsDisplayOnDesktop_callback IsDisplayOnDesktop; + /** C type : SetDisplayVisibility_callback* */ + public VR_IVRSystem_FnTable.SetDisplayVisibility_callback SetDisplayVisibility; + /** C type : GetDeviceToAbsoluteTrackingPose_callback* */ + public VR_IVRSystem_FnTable.GetDeviceToAbsoluteTrackingPose_callback GetDeviceToAbsoluteTrackingPose; + /** C type : ResetSeatedZeroPose_callback* */ + public VR_IVRSystem_FnTable.ResetSeatedZeroPose_callback ResetSeatedZeroPose; + /** C type : GetSeatedZeroPoseToStandingAbsoluteTrackingPose_callback* */ + public VR_IVRSystem_FnTable.GetSeatedZeroPoseToStandingAbsoluteTrackingPose_callback GetSeatedZeroPoseToStandingAbsoluteTrackingPose; + /** C type : GetRawZeroPoseToStandingAbsoluteTrackingPose_callback* */ + public VR_IVRSystem_FnTable.GetRawZeroPoseToStandingAbsoluteTrackingPose_callback GetRawZeroPoseToStandingAbsoluteTrackingPose; + /** C type : GetSortedTrackedDeviceIndicesOfClass_callback* */ + public VR_IVRSystem_FnTable.GetSortedTrackedDeviceIndicesOfClass_callback GetSortedTrackedDeviceIndicesOfClass; + /** C type : GetTrackedDeviceActivityLevel_callback* */ + public VR_IVRSystem_FnTable.GetTrackedDeviceActivityLevel_callback GetTrackedDeviceActivityLevel; + /** C type : ApplyTransform_callback* */ + public VR_IVRSystem_FnTable.ApplyTransform_callback ApplyTransform; + /** C type : GetTrackedDeviceIndexForControllerRole_callback* */ + public VR_IVRSystem_FnTable.GetTrackedDeviceIndexForControllerRole_callback GetTrackedDeviceIndexForControllerRole; + /** C type : GetControllerRoleForTrackedDeviceIndex_callback* */ + public VR_IVRSystem_FnTable.GetControllerRoleForTrackedDeviceIndex_callback GetControllerRoleForTrackedDeviceIndex; + /** C type : GetTrackedDeviceClass_callback* */ + public VR_IVRSystem_FnTable.GetTrackedDeviceClass_callback GetTrackedDeviceClass; + /** C type : IsTrackedDeviceConnected_callback* */ + public VR_IVRSystem_FnTable.IsTrackedDeviceConnected_callback IsTrackedDeviceConnected; + /** C type : GetBoolTrackedDeviceProperty_callback* */ + public VR_IVRSystem_FnTable.GetBoolTrackedDeviceProperty_callback GetBoolTrackedDeviceProperty; + /** C type : GetFloatTrackedDeviceProperty_callback* */ + public VR_IVRSystem_FnTable.GetFloatTrackedDeviceProperty_callback GetFloatTrackedDeviceProperty; + /** C type : GetInt32TrackedDeviceProperty_callback* */ + public VR_IVRSystem_FnTable.GetInt32TrackedDeviceProperty_callback GetInt32TrackedDeviceProperty; + /** C type : GetUint64TrackedDeviceProperty_callback* */ + public VR_IVRSystem_FnTable.GetUint64TrackedDeviceProperty_callback GetUint64TrackedDeviceProperty; + /** C type : GetMatrix34TrackedDeviceProperty_callback* */ + public VR_IVRSystem_FnTable.GetMatrix34TrackedDeviceProperty_callback GetMatrix34TrackedDeviceProperty; + /** C type : GetArrayTrackedDeviceProperty_callback* */ + public VR_IVRSystem_FnTable.GetArrayTrackedDeviceProperty_callback GetArrayTrackedDeviceProperty; + /** C type : GetStringTrackedDeviceProperty_callback* */ + public VR_IVRSystem_FnTable.GetStringTrackedDeviceProperty_callback GetStringTrackedDeviceProperty; + /** C type : GetPropErrorNameFromEnum_callback* */ + public VR_IVRSystem_FnTable.GetPropErrorNameFromEnum_callback GetPropErrorNameFromEnum; + /** C type : PollNextEvent_callback* */ + public VR_IVRSystem_FnTable.PollNextEvent_callback PollNextEvent; + /** C type : PollNextEventWithPose_callback* */ + public VR_IVRSystem_FnTable.PollNextEventWithPose_callback PollNextEventWithPose; + /** C type : GetEventTypeNameFromEnum_callback* */ + public VR_IVRSystem_FnTable.GetEventTypeNameFromEnum_callback GetEventTypeNameFromEnum; + /** C type : GetHiddenAreaMesh_callback* */ + public VR_IVRSystem_FnTable.GetHiddenAreaMesh_callback GetHiddenAreaMesh; + /** C type : GetControllerState_callback* */ + public VR_IVRSystem_FnTable.GetControllerState_callback GetControllerState; + /** C type : GetControllerStateWithPose_callback* */ + public VR_IVRSystem_FnTable.GetControllerStateWithPose_callback GetControllerStateWithPose; + /** C type : TriggerHapticPulse_callback* */ + public VR_IVRSystem_FnTable.TriggerHapticPulse_callback TriggerHapticPulse; + /** C type : GetButtonIdNameFromEnum_callback* */ + public VR_IVRSystem_FnTable.GetButtonIdNameFromEnum_callback GetButtonIdNameFromEnum; + /** C type : GetControllerAxisTypeNameFromEnum_callback* */ + public VR_IVRSystem_FnTable.GetControllerAxisTypeNameFromEnum_callback GetControllerAxisTypeNameFromEnum; + /** C type : IsInputAvailable_callback* */ + public VR_IVRSystem_FnTable.IsInputAvailable_callback IsInputAvailable; + /** C type : IsSteamVRDrawingControllers_callback* */ + public VR_IVRSystem_FnTable.IsSteamVRDrawingControllers_callback IsSteamVRDrawingControllers; + /** C type : ShouldApplicationPause_callback* */ + public VR_IVRSystem_FnTable.ShouldApplicationPause_callback ShouldApplicationPause; + /** C type : ShouldApplicationReduceRenderingWork_callback* */ + public VR_IVRSystem_FnTable.ShouldApplicationReduceRenderingWork_callback ShouldApplicationReduceRenderingWork; + /** C type : DriverDebugRequest_callback* */ + public VR_IVRSystem_FnTable.DriverDebugRequest_callback DriverDebugRequest; + /** C type : PerformFirmwareUpdate_callback* */ + public VR_IVRSystem_FnTable.PerformFirmwareUpdate_callback PerformFirmwareUpdate; + /** C type : AcknowledgeQuit_Exiting_callback* */ + public VR_IVRSystem_FnTable.AcknowledgeQuit_Exiting_callback AcknowledgeQuit_Exiting; + /** C type : AcknowledgeQuit_UserPrompt_callback* */ + public VR_IVRSystem_FnTable.AcknowledgeQuit_UserPrompt_callback AcknowledgeQuit_UserPrompt; + /** native declaration : headers\openvr_capi.h:1752 */ + public interface GetRecommendedRenderTargetSize_callback extends Callback { + void apply(IntByReference pnWidth, IntByReference pnHeight); + }; + /** native declaration : headers\openvr_capi.h:1753 */ + public interface GetProjectionMatrix_callback extends Callback { + com.jme3.system.jopenvr.HmdMatrix44_t.ByValue apply(int eEye, float fNearZ, float fFarZ); + }; + /** native declaration : headers\openvr_capi.h:1754 */ + public interface GetProjectionRaw_callback extends Callback { + void apply(int eEye, FloatByReference pfLeft, FloatByReference pfRight, FloatByReference pfTop, FloatByReference pfBottom); + }; + /** native declaration : headers\openvr_capi.h:1755 */ + public interface ComputeDistortion_callback extends Callback { + byte apply(int eEye, float fU, float fV, DistortionCoordinates_t pDistortionCoordinates); + }; + /** native declaration : headers\openvr_capi.h:1756 */ + public interface GetEyeToHeadTransform_callback extends Callback { + HmdMatrix34_t.ByValue apply(int eEye); + }; + /** native declaration : headers\openvr_capi.h:1757 */ + public interface GetTimeSinceLastVsync_callback extends Callback { + byte apply(FloatByReference pfSecondsSinceLastVsync, LongByReference pulFrameCounter); + }; + /** native declaration : headers\openvr_capi.h:1758 */ + public interface GetD3D9AdapterIndex_callback extends Callback { + int apply(); + }; + /** native declaration : headers\openvr_capi.h:1759 */ + public interface GetDXGIOutputInfo_callback extends Callback { + void apply(IntByReference pnAdapterIndex); + }; + /** native declaration : headers\openvr_capi.h:1760 */ + public interface GetOutputDevice_callback extends Callback { + void apply(LongByReference pnDevice, int textureType, VkInstance_T pInstance); + }; + /** native declaration : headers\openvr_capi.h:1761 */ + public interface IsDisplayOnDesktop_callback extends Callback { + byte apply(); + }; + /** native declaration : headers\openvr_capi.h:1762 */ + public interface SetDisplayVisibility_callback extends Callback { + byte apply(byte bIsVisibleOnDesktop); + }; + /** native declaration : headers\openvr_capi.h:1763 */ + public interface GetDeviceToAbsoluteTrackingPose_callback extends Callback { + void apply(int eOrigin, float fPredictedSecondsToPhotonsFromNow, TrackedDevicePose_t pTrackedDevicePoseArray, int unTrackedDevicePoseArrayCount); + }; + /** native declaration : headers\openvr_capi.h:1764 */ + public interface ResetSeatedZeroPose_callback extends Callback { + void apply(); + }; + /** native declaration : headers\openvr_capi.h:1765 */ + public interface GetSeatedZeroPoseToStandingAbsoluteTrackingPose_callback extends Callback { + HmdMatrix34_t.ByValue apply(); + }; + /** native declaration : headers\openvr_capi.h:1766 */ + public interface GetRawZeroPoseToStandingAbsoluteTrackingPose_callback extends Callback { + HmdMatrix34_t.ByValue apply(); + }; + /** native declaration : headers\openvr_capi.h:1767 */ + public interface GetSortedTrackedDeviceIndicesOfClass_callback extends Callback { + int apply(int eTrackedDeviceClass, IntByReference punTrackedDeviceIndexArray, int unTrackedDeviceIndexArrayCount, int unRelativeToTrackedDeviceIndex); + }; + /** native declaration : headers\openvr_capi.h:1768 */ + public interface GetTrackedDeviceActivityLevel_callback extends Callback { + int apply(int unDeviceId); + }; + /** native declaration : headers\openvr_capi.h:1769 */ + public interface ApplyTransform_callback extends Callback { + void apply(TrackedDevicePose_t pOutputPose, TrackedDevicePose_t pTrackedDevicePose, HmdMatrix34_t pTransform); + }; + /** native declaration : headers\openvr_capi.h:1770 */ + public interface GetTrackedDeviceIndexForControllerRole_callback extends Callback { + int apply(int unDeviceType); + }; + /** native declaration : headers\openvr_capi.h:1771 */ + public interface GetControllerRoleForTrackedDeviceIndex_callback extends Callback { + int apply(int unDeviceIndex); + }; + /** native declaration : headers\openvr_capi.h:1772 */ + public interface GetTrackedDeviceClass_callback extends Callback { + int apply(int unDeviceIndex); + }; + /** native declaration : headers\openvr_capi.h:1773 */ + public interface IsTrackedDeviceConnected_callback extends Callback { + byte apply(int unDeviceIndex); + }; + /** native declaration : headers\openvr_capi.h:1774 */ + public interface GetBoolTrackedDeviceProperty_callback extends Callback { + byte apply(int unDeviceIndex, int prop, IntByReference pError); + }; + /** native declaration : headers\openvr_capi.h:1775 */ + public interface GetFloatTrackedDeviceProperty_callback extends Callback { + float apply(int unDeviceIndex, int prop, IntByReference pError); + }; + /** native declaration : headers\openvr_capi.h:1776 */ + public interface GetInt32TrackedDeviceProperty_callback extends Callback { + int apply(int unDeviceIndex, int prop, IntByReference pError); + }; + /** native declaration : headers\openvr_capi.h:1777 */ + public interface GetUint64TrackedDeviceProperty_callback extends Callback { + long apply(int unDeviceIndex, int prop, IntByReference pError); + }; + /** native declaration : headers\openvr_capi.h:1778 */ + public interface GetMatrix34TrackedDeviceProperty_callback extends Callback { + HmdMatrix34_t.ByValue apply(int unDeviceIndex, int prop, IntByReference pError); + }; + /** native declaration : headers\openvr_capi.h:1779 */ + public interface GetArrayTrackedDeviceProperty_callback extends Callback { + int apply(int unDeviceIndex, int prop, int propType, Pointer pBuffer, int unBufferSize, IntByReference pError); + }; + /** native declaration : headers\openvr_capi.h:1780 */ + public interface GetStringTrackedDeviceProperty_callback extends Callback { + int apply(int unDeviceIndex, int prop, Pointer pchValue, int unBufferSize, IntByReference pError); + }; + /** native declaration : headers\openvr_capi.h:1781 */ + public interface GetPropErrorNameFromEnum_callback extends Callback { + Pointer apply(int error); + }; + /** native declaration : headers\openvr_capi.h:1782 */ + public interface PollNextEvent_callback extends Callback { + byte apply(VREvent_t pEvent, int uncbVREvent); + }; + /** native declaration : headers\openvr_capi.h:1783 */ + public interface PollNextEventWithPose_callback extends Callback { + byte apply(int eOrigin, VREvent_t pEvent, int uncbVREvent, TrackedDevicePose_t pTrackedDevicePose); + }; + /** native declaration : headers\openvr_capi.h:1784 */ + public interface GetEventTypeNameFromEnum_callback extends Callback { + Pointer apply(int eType); + }; + /** native declaration : headers\openvr_capi.h:1785 */ + public interface GetHiddenAreaMesh_callback extends Callback { + com.jme3.system.jopenvr.HiddenAreaMesh_t.ByValue apply(int eEye, int type); + }; + /** native declaration : headers\openvr_capi.h:1786 */ + public interface GetControllerState_callback extends Callback { + byte apply(int unControllerDeviceIndex, VRControllerState_t pControllerState, int unControllerStateSize); + }; + /** native declaration : headers\openvr_capi.h:1787 */ + public interface GetControllerStateWithPose_callback extends Callback { + byte apply(int eOrigin, int unControllerDeviceIndex, VRControllerState_t pControllerState, int unControllerStateSize, TrackedDevicePose_t pTrackedDevicePose); + }; + /** native declaration : headers\openvr_capi.h:1788 */ + public interface TriggerHapticPulse_callback extends Callback { + void apply(int unControllerDeviceIndex, int unAxisId, short usDurationMicroSec); + }; + /** native declaration : headers\openvr_capi.h:1789 */ + public interface GetButtonIdNameFromEnum_callback extends Callback { + Pointer apply(int eButtonId); + }; + /** native declaration : headers\openvr_capi.h:1790 */ + public interface GetControllerAxisTypeNameFromEnum_callback extends Callback { + Pointer apply(int eAxisType); + }; + /** native declaration : headers\openvr_capi.h:1791 */ + public interface IsInputAvailable_callback extends Callback { + byte apply(); + }; + /** native declaration : headers\openvr_capi.h:1792 */ + public interface IsSteamVRDrawingControllers_callback extends Callback { + byte apply(); + }; + /** native declaration : headers\openvr_capi.h:1793 */ + public interface ShouldApplicationPause_callback extends Callback { + byte apply(); + }; + /** native declaration : headers\openvr_capi.h:1794 */ + public interface ShouldApplicationReduceRenderingWork_callback extends Callback { + byte apply(); + }; + /** native declaration : headers\openvr_capi.h:1795 */ + public interface DriverDebugRequest_callback extends Callback { + int apply(int unDeviceIndex, Pointer pchRequest, Pointer pchResponseBuffer, int unResponseBufferSize); + }; + /** native declaration : headers\openvr_capi.h:1796 */ + public interface PerformFirmwareUpdate_callback extends Callback { + int apply(int unDeviceIndex); + }; + /** native declaration : headers\openvr_capi.h:1797 */ + public interface AcknowledgeQuit_Exiting_callback extends Callback { + void apply(); + }; + /** native declaration : headers\openvr_capi.h:1798 */ + public interface AcknowledgeQuit_UserPrompt_callback extends Callback { + void apply(); + }; + public VR_IVRSystem_FnTable() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("GetRecommendedRenderTargetSize", "GetProjectionMatrix", "GetProjectionRaw", "ComputeDistortion", "GetEyeToHeadTransform", "GetTimeSinceLastVsync", "GetD3D9AdapterIndex", "GetDXGIOutputInfo", "GetOutputDevice", "IsDisplayOnDesktop", "SetDisplayVisibility", "GetDeviceToAbsoluteTrackingPose", "ResetSeatedZeroPose", "GetSeatedZeroPoseToStandingAbsoluteTrackingPose", "GetRawZeroPoseToStandingAbsoluteTrackingPose", "GetSortedTrackedDeviceIndicesOfClass", "GetTrackedDeviceActivityLevel", "ApplyTransform", "GetTrackedDeviceIndexForControllerRole", "GetControllerRoleForTrackedDeviceIndex", "GetTrackedDeviceClass", "IsTrackedDeviceConnected", "GetBoolTrackedDeviceProperty", "GetFloatTrackedDeviceProperty", "GetInt32TrackedDeviceProperty", "GetUint64TrackedDeviceProperty", "GetMatrix34TrackedDeviceProperty", "GetArrayTrackedDeviceProperty", "GetStringTrackedDeviceProperty", "GetPropErrorNameFromEnum", "PollNextEvent", "PollNextEventWithPose", "GetEventTypeNameFromEnum", "GetHiddenAreaMesh", "GetControllerState", "GetControllerStateWithPose", "TriggerHapticPulse", "GetButtonIdNameFromEnum", "GetControllerAxisTypeNameFromEnum", "IsInputAvailable", "IsSteamVRDrawingControllers", "ShouldApplicationPause", "ShouldApplicationReduceRenderingWork", "DriverDebugRequest", "PerformFirmwareUpdate", "AcknowledgeQuit_Exiting", "AcknowledgeQuit_UserPrompt"); + } + public VR_IVRSystem_FnTable(Pointer peer) { + super(peer); + } + public static class ByReference extends VR_IVRSystem_FnTable implements Structure.ByReference { + + }; + public static class ByValue extends VR_IVRSystem_FnTable implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRTrackedCamera_FnTable.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRTrackedCamera_FnTable.java new file mode 100644 index 0000000000..42ba86816b --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRTrackedCamera_FnTable.java @@ -0,0 +1,105 @@ +package com.jme3.system.jopenvr; +import com.sun.jna.Callback; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import com.sun.jna.ptr.IntByReference; +import com.sun.jna.ptr.LongByReference; +import com.sun.jna.ptr.PointerByReference; +import java.util.Arrays; +import java.util.List; +/** + * native declaration : headers\openvr_capi.h:1833
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VR_IVRTrackedCamera_FnTable extends Structure { + /** C type : GetCameraErrorNameFromEnum_callback* */ + public VR_IVRTrackedCamera_FnTable.GetCameraErrorNameFromEnum_callback GetCameraErrorNameFromEnum; + /** C type : HasCamera_callback* */ + public VR_IVRTrackedCamera_FnTable.HasCamera_callback HasCamera; + /** C type : GetCameraFrameSize_callback* */ + public VR_IVRTrackedCamera_FnTable.GetCameraFrameSize_callback GetCameraFrameSize; + /** C type : GetCameraIntrinsics_callback* */ + public VR_IVRTrackedCamera_FnTable.GetCameraIntrinsics_callback GetCameraIntrinsics; + /** C type : GetCameraProjection_callback* */ + public VR_IVRTrackedCamera_FnTable.GetCameraProjection_callback GetCameraProjection; + /** C type : AcquireVideoStreamingService_callback* */ + public VR_IVRTrackedCamera_FnTable.AcquireVideoStreamingService_callback AcquireVideoStreamingService; + /** C type : ReleaseVideoStreamingService_callback* */ + public VR_IVRTrackedCamera_FnTable.ReleaseVideoStreamingService_callback ReleaseVideoStreamingService; + /** C type : GetVideoStreamFrameBuffer_callback* */ + public VR_IVRTrackedCamera_FnTable.GetVideoStreamFrameBuffer_callback GetVideoStreamFrameBuffer; + /** C type : GetVideoStreamTextureSize_callback* */ + public VR_IVRTrackedCamera_FnTable.GetVideoStreamTextureSize_callback GetVideoStreamTextureSize; + /** C type : GetVideoStreamTextureD3D11_callback* */ + public VR_IVRTrackedCamera_FnTable.GetVideoStreamTextureD3D11_callback GetVideoStreamTextureD3D11; + /** C type : GetVideoStreamTextureGL_callback* */ + public VR_IVRTrackedCamera_FnTable.GetVideoStreamTextureGL_callback GetVideoStreamTextureGL; + /** C type : ReleaseVideoStreamTextureGL_callback* */ + public VR_IVRTrackedCamera_FnTable.ReleaseVideoStreamTextureGL_callback ReleaseVideoStreamTextureGL; + /** native declaration : headers\openvr_capi.h:1821 */ + public interface GetCameraErrorNameFromEnum_callback extends Callback { + Pointer apply(int eCameraError); + }; + /** native declaration : headers\openvr_capi.h:1822 */ + public interface HasCamera_callback extends Callback { + int apply(int nDeviceIndex, Pointer pHasCamera); + }; + /** native declaration : headers\openvr_capi.h:1823 */ + public interface GetCameraFrameSize_callback extends Callback { + int apply(int nDeviceIndex, int eFrameType, IntByReference pnWidth, IntByReference pnHeight, IntByReference pnFrameBufferSize); + }; + /** native declaration : headers\openvr_capi.h:1824 */ + public interface GetCameraIntrinsics_callback extends Callback { + int apply(int nDeviceIndex, int eFrameType, HmdVector2_t pFocalLength, HmdVector2_t pCenter); + }; + /** native declaration : headers\openvr_capi.h:1825 */ + public interface GetCameraProjection_callback extends Callback { + int apply(int nDeviceIndex, int eFrameType, float flZNear, float flZFar, HmdMatrix44_t pProjection); + }; + /** native declaration : headers\openvr_capi.h:1826 */ + public interface AcquireVideoStreamingService_callback extends Callback { + int apply(int nDeviceIndex, LongByReference pHandle); + }; + /** native declaration : headers\openvr_capi.h:1827 */ + public interface ReleaseVideoStreamingService_callback extends Callback { + int apply(long hTrackedCamera); + }; + /** native declaration : headers\openvr_capi.h:1828 */ + public interface GetVideoStreamFrameBuffer_callback extends Callback { + int apply(long hTrackedCamera, int eFrameType, Pointer pFrameBuffer, int nFrameBufferSize, CameraVideoStreamFrameHeader_t pFrameHeader, int nFrameHeaderSize); + }; + /** native declaration : headers\openvr_capi.h:1829 */ + public interface GetVideoStreamTextureSize_callback extends Callback { + int apply(int nDeviceIndex, int eFrameType, VRTextureBounds_t pTextureBounds, IntByReference pnWidth, IntByReference pnHeight); + }; + /** native declaration : headers\openvr_capi.h:1830 */ + public interface GetVideoStreamTextureD3D11_callback extends Callback { + int apply(long hTrackedCamera, int eFrameType, Pointer pD3D11DeviceOrResource, PointerByReference ppD3D11ShaderResourceView, CameraVideoStreamFrameHeader_t pFrameHeader, int nFrameHeaderSize); + }; + /** native declaration : headers\openvr_capi.h:1831 */ + public interface GetVideoStreamTextureGL_callback extends Callback { + int apply(long hTrackedCamera, int eFrameType, IntByReference pglTextureId, CameraVideoStreamFrameHeader_t pFrameHeader, int nFrameHeaderSize); + }; + /** native declaration : headers\openvr_capi.h:1832 */ + public interface ReleaseVideoStreamTextureGL_callback extends Callback { + int apply(long hTrackedCamera, int glTextureId); + }; + public VR_IVRTrackedCamera_FnTable() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("GetCameraErrorNameFromEnum", "HasCamera", "GetCameraFrameSize", "GetCameraIntrinsics", "GetCameraProjection", "AcquireVideoStreamingService", "ReleaseVideoStreamingService", "GetVideoStreamFrameBuffer", "GetVideoStreamTextureSize", "GetVideoStreamTextureD3D11", "GetVideoStreamTextureGL", "ReleaseVideoStreamTextureGL"); + } + public VR_IVRTrackedCamera_FnTable(Pointer peer) { + super(peer); + } + public static class ByReference extends VR_IVRTrackedCamera_FnTable implements Structure.ByReference { + + }; + public static class ByValue extends VR_IVRTrackedCamera_FnTable implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/lwjgl/LwjglContextVR.java b/jme3-xr/src/main/java/com/jme3/system/lwjgl/LwjglContextVR.java new file mode 100644 index 0000000000..aa02e3ab19 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/lwjgl/LwjglContextVR.java @@ -0,0 +1,310 @@ +package com.jme3.system.lwjgl; + +/* + * Copyright (c) 2009-2023 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +import com.jme3.input.lwjgl.GlfwJoystickInput; +import com.jme3.input.lwjgl.GlfwKeyInputVR; +import com.jme3.input.lwjgl.GlfwMouseInputVR; +import com.jme3.renderer.Renderer; +import com.jme3.renderer.RendererException; +import com.jme3.renderer.lwjgl.LwjglGL; +import com.jme3.renderer.lwjgl.LwjglGLExt; +import com.jme3.renderer.lwjgl.LwjglGLFboEXT; +import com.jme3.renderer.lwjgl.LwjglGLFboGL3; +import com.jme3.renderer.opengl.*; +import com.jme3.system.*; + +import org.lwjgl.glfw.GLFW; +import org.lwjgl.opengl.ARBDebugOutput; +import org.lwjgl.opengl.ARBFramebufferObject; +import org.lwjgl.opengl.EXTFramebufferMultisample; +import org.lwjgl.opengl.GLCapabilities; + +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.logging.Level; +import java.util.logging.Logger; + +import static org.lwjgl.opengl.GL.createCapabilities; +import static org.lwjgl.opengl.GL11.glGetInteger; + +/** + * A VR oriented LWJGL implementation of a graphics context. + * @author reden - phr00t - https://github.com/phr00t + * @author Julien Seinturier - (c) 2016 - JOrigin project - http:/www.jorigin.org + */ +public abstract class LwjglContextVR implements JmeContext { + + private static final Logger logger = Logger.getLogger(LwjglContextVR.class.getName()); + + protected static final String THREAD_NAME = "jME3 Main"; + + protected AtomicBoolean created = new AtomicBoolean(false); + protected AtomicBoolean renderable = new AtomicBoolean(false); + protected final Object createdLock = new Object(); + + protected AppSettings settings = new AppSettings(true); + protected Renderer renderer; + protected GlfwKeyInputVR keyInput; + protected GlfwMouseInputVR mouseInput; + protected GlfwJoystickInput joyInput; + protected Timer timer; + protected SystemListener listener; + + /** + * Accesses the listener that receives events related to this context. + * + * @return the pre-existing instance + */ + @Override + public SystemListener getSystemListener() { + return listener; + } + + @Override + public void setSystemListener(SystemListener listener) { + this.listener = listener; + } + + protected void printContextInitInfo() { + logger.log(Level.INFO, "LWJGL {0} context running on thread {1}\n" + + " * Graphics Adapter: GLFW {2}", + new Object[]{Integer.toString(org.lwjgl.Version.VERSION_MAJOR), Thread.currentThread().getName(), GLFW.glfwGetVersionString()}); + } + + protected int determineMaxSamples() { + // If we already have a valid context, determine samples using current context. + logger.log(Level.SEVERE, "glfwExtensionSupported(\"GL_ARB_framebuffer_object\"): "+GLFW.glfwExtensionSupported("GL_ARB_framebuffer_object")); + logger.log(Level.SEVERE, "glfwExtensionSupported(\"GL_EXT_framebuffer_multisample\"): "+GLFW.glfwExtensionSupported("GL_ARB_framebuffer_object")); + + if (GLFW.glfwExtensionSupported("GL_ARB_framebuffer_object")) { + return glGetInteger(ARBFramebufferObject.GL_MAX_SAMPLES); + } else if (GLFW.glfwExtensionSupported("GL_EXT_framebuffer_multisample")) { + return glGetInteger(EXTFramebufferMultisample.GL_MAX_SAMPLES_EXT); + } + + return Integer.MAX_VALUE; + } + + protected void loadNatives() { + if (JmeSystem.isLowPermissions()) { + return; + } + + if ("LWJGL".equals(settings.getAudioRenderer())) { + NativeLibraryLoader.loadNativeLibrary("openal-lwjgl3", true); + } + + if (NativeLibraryLoader.isUsingNativeBullet()) { + NativeLibraryLoader.loadNativeLibrary("bulletjme", true); + } + + NativeLibraryLoader.loadNativeLibrary("glfw-lwjgl3", true); + NativeLibraryLoader.loadNativeLibrary("jemalloc-lwjgl3", true); + NativeLibraryLoader.loadNativeLibrary("lwjgl3", true); + } + + /** + * Check if the display is a retina display. + * @return true if the display is a retina display and false otherwise. + */ + public boolean isRetinaDisplay() { + return GLFW.glfwGetVersionString().contains("retina"); + } + + protected int getNumSamplesToUse() { + int samples = 0; + if (settings.getSamples() > 1) { + samples = settings.getSamples(); + final int supportedSamples = determineMaxSamples(); + if (supportedSamples < samples) { + logger.log(Level.WARNING, + "Couldn't satisfy antialiasing samples requirement: x{0}. " + + "Video hardware only supports: x{1}", + new Object[]{samples, supportedSamples}); + + samples = supportedSamples; + } + } + return samples; + } + + protected void initContextFirstTime() { + final GLCapabilities capabilities = createCapabilities(settings.getRenderer().equals(AppSettings.LWJGL_OPENGL32)); + + if (!capabilities.OpenGL20) { + throw new RendererException("OpenGL 2.0 or higher is required for jMonkeyEngine"); + } + + if (settings.getRenderer().equals(AppSettings.LWJGL_OPENGL2) + || settings.getRenderer().equals(AppSettings.LWJGL_OPENGL32)) { + GL gl = new LwjglGL(); + GLExt glext = new LwjglGLExt(); + GLFbo glfbo; + + if (capabilities.OpenGL30) { + glfbo = new LwjglGLFboGL3(); + } else { + glfbo = new LwjglGLFboEXT(); + } + + if (settings.isGraphicsDebug()) { + gl = (GL) GLDebug.createProxy(gl, gl, GL.class, GL2.class, GL3.class, GL4.class); + glext = (GLExt) GLDebug.createProxy(gl, glext, GLExt.class); + glfbo = (GLFbo) GLDebug.createProxy(gl, glfbo, GLFbo.class); + } + + if (settings.isGraphicsTiming()) { + GLTimingState timingState = new GLTimingState(); + gl = (GL) GLTiming.createGLTiming(gl, timingState, GL.class, GL2.class, GL3.class, GL4.class); + glext = (GLExt) GLTiming.createGLTiming(glext, timingState, GLExt.class); + glfbo = (GLFbo) GLTiming.createGLTiming(glfbo, timingState, GLFbo.class); + } + + if (settings.isGraphicsTrace()) { + gl = (GL) GLTracer.createDesktopGlTracer(gl, GL.class, GL2.class, GL3.class, GL4.class); + glext = (GLExt) GLTracer.createDesktopGlTracer(glext, GLExt.class); + glfbo = (GLFbo) GLTracer.createDesktopGlTracer(glfbo, GLFbo.class); + } + + renderer = new GLRenderer(gl, glext, glfbo); + renderer.initialize(); + } else { + throw new UnsupportedOperationException("Unsupported renderer: " + settings.getRenderer()); + } + + if (capabilities.GL_ARB_debug_output && settings.isGraphicsDebug()) { + ARBDebugOutput.glDebugMessageCallbackARB(new LwjglGLDebugOutputHandler(), 0); + } + + renderer.setMainFrameBufferSrgb(settings.isGammaCorrection()); + renderer.setLinearizeSrgbImages(settings.isGammaCorrection()); + + // Init input + if (keyInput != null) { + keyInput.initialize(); + } + + if (mouseInput != null) { + mouseInput.initialize(); + } + + if (joyInput != null) { + joyInput.initialize(); + } + renderable.set(true); + } + + /** + * Context internal destroy. + */ + public void internalDestroy() { + renderer = null; + timer = null; + renderable.set(false); + synchronized (createdLock) { + created.set(false); + createdLock.notifyAll(); + } + } + + /** + * Context internal create. + */ + public void internalCreate() { + synchronized (createdLock) { + created.set(true); + createdLock.notifyAll(); + } + + initContextFirstTime(); + } + + /** + * Create the context. + */ + public void create() { + create(false); + } + + /** + * Destroy the context. + */ + public void destroy() { + destroy(false); + } + + /** + * + * @param createdVal + */ + protected void waitFor(boolean createdVal) { + synchronized (createdLock) { + while (created.get() != createdVal) { + try { + createdLock.wait(); + } catch (InterruptedException ignored) { + } + } + } + } + + @Override + public boolean isCreated() { + return created.get(); + } + + @Override + public boolean isRenderable() { + return renderable.get(); + } + + @Override + public void setSettings(AppSettings settings) { + this.settings.copyFrom(settings); + } + + @Override + public AppSettings getSettings() { + return settings; + } + + @Override + public Renderer getRenderer() { + return renderer; + } + + @Override + public Timer getTimer() { + return timer; + } + +} diff --git a/jme3-xr/src/main/java/com/jme3/system/lwjgl/LwjglDisplayVR.java b/jme3-xr/src/main/java/com/jme3/system/lwjgl/LwjglDisplayVR.java new file mode 100644 index 0000000000..5df00bf08f --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/lwjgl/LwjglDisplayVR.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2009-2012 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.system.lwjgl; + +import com.jme3.opencl.Context; + +/** + * A VR oriented LWJGL display. + * @author Daniel Johansson + * @author reden - phr00t - https://github.com/phr00t + * @author Julien Seinturier - (c) 2016 - JOrigin project - http:/www.jorigin.org + */ +public class LwjglDisplayVR extends LwjglWindowVR { + /** + * Create a new VR oriented LWJGL display. + */ + public LwjglDisplayVR() { + super(Type.Display); + } + + @Override + public Context getOpenCLContext() { + return null; + } +} diff --git a/jme3-xr/src/main/java/com/jme3/system/lwjgl/LwjglOffscreenBufferVR.java b/jme3-xr/src/main/java/com/jme3/system/lwjgl/LwjglOffscreenBufferVR.java new file mode 100644 index 0000000000..234d36d8de --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/lwjgl/LwjglOffscreenBufferVR.java @@ -0,0 +1,50 @@ +package com.jme3.system.lwjgl; + +/* + * Copyright (c) 2009-2012 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import com.jme3.system.JmeContext; + +/** + * A VR oriented LWJGL offscreen buffer. + * @author Daniel Johansson + * @author reden - phr00t - https://github.com/phr00t + * @author Julien Seinturier - (c) 2016 - JOrigin project - http:/www.jorigin.org + */ +public class LwjglOffscreenBufferVR extends LwjglWindow { + /** + * Create a new VR oriented LWJGL offscreen buffer. + */ + public LwjglOffscreenBufferVR() { + super(JmeContext.Type.OffscreenSurface); + } +} diff --git a/jme3-xr/src/main/java/com/jme3/system/lwjgl/LwjglWindowVR.java b/jme3-xr/src/main/java/com/jme3/system/lwjgl/LwjglWindowVR.java new file mode 100644 index 0000000000..5c21cd6e92 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/lwjgl/LwjglWindowVR.java @@ -0,0 +1,621 @@ +package com.jme3.system.lwjgl; + +/* + * Copyright (c) 2009-2023 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import com.jme3.input.JoyInput; +import com.jme3.input.KeyInput; +import com.jme3.input.MouseInput; +import com.jme3.input.TouchInput; +import com.jme3.input.lwjgl.GlfwJoystickInput; +import com.jme3.input.lwjgl.GlfwKeyInputVR; +import com.jme3.input.lwjgl.GlfwMouseInputVR; +import com.jme3.system.AppSettings; +import com.jme3.system.JmeContext; +import com.jme3.system.JmeSystem; +import com.jme3.system.NanoTimer; + +import org.lwjgl.glfw.*; + +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.logging.Level; +import java.util.logging.Logger; +import org.lwjgl.Version; + +import static org.lwjgl.glfw.GLFW.*; +import static org.lwjgl.opengl.GL11.GL_FALSE; +import static org.lwjgl.system.MemoryUtil.NULL; + +/** + * A wrapper class over the GLFW framework in LWJGL 3. + * + * @author Daniel Johansson + * @author reden - phr00t - https://github.com/phr00t + * @author Julien Seinturier - (c) 2016 - JOrigin project - http:/www.jorigin.org + */ +public abstract class LwjglWindowVR extends LwjglContextVR implements Runnable { + + private static final Logger LOGGER = Logger.getLogger(LwjglWindowVR.class.getName()); + + protected AtomicBoolean needClose = new AtomicBoolean(false); + protected final AtomicBoolean needRestart = new AtomicBoolean(false); + protected boolean wasActive = false; + protected boolean autoFlush = true; + protected boolean allowSwapBuffers = false; + private long window = NULL; + private final JmeContext.Type type; + private int frameRateLimit = -1; + private double frameSleepTime; + + private GLFWErrorCallback errorCallback; + private GLFWWindowSizeCallback windowSizeCallback; + private GLFWWindowFocusCallback windowFocusCallback; + private Thread mainThread; + + // reusable arrays for GLFW calls + final private int width[] = new int[1]; + final private int height[] = new int[1]; + + /** + * Create a new wrapper class over the GLFW framework in LWJGL 3. + * @param type the {@link com.jme3.system.JmeContext.Type type} of the display. + */ + public LwjglWindowVR(final JmeContext.Type type) { + if (!JmeContext.Type.Display.equals(type) && !JmeContext.Type.OffscreenSurface.equals(type) && !JmeContext.Type.Canvas.equals(type)) { + throw new IllegalArgumentException("Unsupported type '" + type.name() + "' provided"); + } + + this.type = type; + } + + /** + * @return Type.Display or Type.Canvas + */ + @Override + public JmeContext.Type getType() { + return type; + } + + /** + * Set the title if it's a windowed display + * + * @param title the title to set + */ + @Override + public void setTitle(final String title) { + if (created.get() && window != NULL) { + glfwSetWindowTitle(window, title); + } + } + + /** + * Restart if it's a windowed or full-screen display. + */ + @Override + public void restart() { + if (created.get()) { + needRestart.set(true); + } else { + LOGGER.warning("Display is not created, cannot restart window."); + } + } + + /** + * Apply the settings, changing resolution, etc. + * + * @param settings the settings to apply when creating the context. + */ + protected void createContext(final AppSettings settings) { + glfwSetErrorCallback(errorCallback = new GLFWErrorCallback() { + @Override + public void invoke(int error, long description) { + final String message = GLFWErrorCallback.getDescription(description); + listener.handleError(message, new Exception(message)); + } + }); + + if ( glfwInit() == false ) { + throw new IllegalStateException("Unable to initialize GLFW"); + } + + glfwDefaultWindowHints(); + + // just use defaults, which should provide the best compatibility + /*if (settings.getRenderer().equals(AppSettings.LWJGL_OPENGL3)) { + glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); + glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_FALSE); + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); + } else { + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2); + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); + }*/ + + if (settings.getBoolean("RendererDebug")) { + glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GLFW_TRUE); + } + + if (settings.isGammaCorrection()) { + glfwWindowHint(GLFW_SRGB_CAPABLE, GLFW_TRUE); + } + + glfwWindowHint(GLFW_VISIBLE, GL_FALSE); + glfwWindowHint(GLFW_RESIZABLE, settings.isResizable() ? GLFW_TRUE : GLFW_FALSE); + glfwWindowHint(GLFW_DOUBLEBUFFER, GLFW_TRUE); + glfwWindowHint(GLFW_DEPTH_BITS, settings.getDepthBits()); + glfwWindowHint(GLFW_STENCIL_BITS, settings.getStencilBits()); + glfwWindowHint(GLFW_SAMPLES, settings.getSamples()); + glfwWindowHint(GLFW_STEREO, settings.useStereo3D() ? GLFW_TRUE : GLFW_FALSE); + glfwWindowHint(GLFW_REFRESH_RATE, settings.getFrequency()); + + if (settings.getBitsPerPixel() == 24) { + glfwWindowHint(GLFW_RED_BITS, 8); + glfwWindowHint(GLFW_GREEN_BITS, 8); + glfwWindowHint(GLFW_BLUE_BITS, 8); + } else if (settings.getBitsPerPixel() == 16) { + glfwWindowHint(GLFW_RED_BITS, 5); + glfwWindowHint(GLFW_GREEN_BITS, 6); + glfwWindowHint(GLFW_BLUE_BITS, 5); + } + + glfwWindowHint(GLFW_ALPHA_BITS, settings.getAlphaBits()); + + // TODO: Add support for monitor selection + long monitor = NULL; + + if (settings.isFullscreen()) { + monitor = glfwGetPrimaryMonitor(); + } + + final GLFWVidMode videoMode = glfwGetVideoMode(glfwGetPrimaryMonitor()); + + if (settings.getWidth() <= 0 || settings.getHeight() <= 0) { + settings.setResolution(videoMode.width(), videoMode.height()); + } + + window = glfwCreateWindow(settings.getWidth(), settings.getHeight(), settings.getTitle(), monitor, NULL); + + if (window == NULL) { + throw new RuntimeException("Failed to create the GLFW window"); + } + + glfwSetWindowFocusCallback(window, windowFocusCallback = new GLFWWindowFocusCallback() { + + @Override + public void invoke(long window, boolean focused) { + if (wasActive != focused) { + if (wasActive == false) { + listener.gainFocus(); + timer.reset(); + wasActive = true; + } else { + listener.loseFocus(); + wasActive = false; + } + } + } + }); + + // Center the window + if( Type.Display.equals(type) ) { + if (!settings.isFullscreen()) { + glfwSetWindowPos(window, + (videoMode.width() - settings.getWidth()) / 2, + (videoMode.height() - settings.getHeight()) / 2); + } + } + + // Make the OpenGL context current + glfwMakeContextCurrent(window); + + // Enable vsync + if (settings.isVSync()) { + glfwSwapInterval(1); + } else { + glfwSwapInterval(0); + } + + // Make the window visible + if (Type.Display.equals(type)) { + glfwShowWindow(window); + glfwFocusWindow(window); + } + + // Add a resize callback which delegates to the listener + glfwSetWindowSizeCallback(window, windowSizeCallback = new GLFWWindowSizeCallback() { + @Override + public void invoke(final long window, final int width, final int height) { + settings.setResolution(width, height); + listener.reshape(width, height); + } + }); + + allowSwapBuffers = settings.isSwapBuffers(); + + // TODO: When GLFW 3.2 is released and included in LWJGL 3.x then we should hopefully be able to set the window icon. + } + + /** + * Destroy the context. + */ + protected void destroyContext() { + try { + if (renderer != null) { + renderer.cleanup(); + } + + if (errorCallback != null) { + errorCallback.free(); + errorCallback = null; + } + + if (windowSizeCallback != null) { + windowSizeCallback.free(); + windowSizeCallback = null; + } + + if (windowFocusCallback != null) { + windowFocusCallback.free(); + windowFocusCallback = null; + } + + if (window != NULL) { + glfwDestroyWindow(window); + window = NULL; + } + } catch (Exception ex) { + listener.handleError("Failed to destroy context", ex); + } + } + + @Override + public void create(boolean waitFor) { + if (created.get()) { + LOGGER.warning("create() called when display is already created!"); + return; + } + + mainThread = Thread.currentThread(); + run(); + } + + /** + * Does LWJGL display initialization in the OpenGL thread + */ + protected boolean initInThread() { + try { + if (!JmeSystem.isLowPermissions()) { + // Enable uncaught exception handler only for current thread + Thread.currentThread().setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread thread, Throwable thrown) { + listener.handleError("Uncaught exception thrown in " + thread.toString(), thrown); + if (needClose.get()) { + // listener.handleError() has requested the + // context to close. Satisfy request. + deinitInThread(); + } + } + }); + } + + loadNatives(); + timer = new NanoTimer(); + + // For canvas, this will create a PBuffer, + // allowing us to query information. + // When the canvas context becomes available, it will + // be replaced seamlessly. + createContext(settings); + printContextInitInfo(); + + created.set(true); + super.internalCreate(); + } catch (Exception ex) { + try { + if (window != NULL) { + glfwDestroyWindow(window); + window = NULL; + } + } catch (Exception ex2) { + LOGGER.log(Level.WARNING, null, ex2); + } + + listener.handleError("Failed to create display", ex); + return false; // if we failed to create display, do not continue + } + + listener.initialize(); + return true; + } + + /** + * execute one iteration of the render loop in the OpenGL thread + */ + protected void runLoop() { + // If a restart is required, lets recreate the context. + if (needRestart.getAndSet(false)) { + try { + destroyContext(); + createContext(settings); + } catch (Exception ex) { + LOGGER.log(Level.SEVERE, "Failed to set display settings!", ex); + } + + LOGGER.fine("Display restarted."); + } + + if (!created.get()) { + throw new IllegalStateException(); + } + + listener.update(); + + // All this does is call glfwSwapBuffers(). + // If the canvas is not active, there's no need to waste time + // doing that. + if (renderable.get()) { + // calls swap buffers, etc. + try { + if (allowSwapBuffers && autoFlush) { + glfwSwapBuffers(window); + } + } catch (Throwable ex) { + listener.handleError("Error while swapping buffers", ex); + } + } + + // Subclasses just call GLObjectManager. Clean up objects here. + // It is safe ... for now. + if (renderer != null) { + renderer.postFrame(); + } + + if (autoFlush) { + if (frameRateLimit != getSettings().getFrameRate()) { + setFrameRateLimit(getSettings().getFrameRate()); + } + } else if (frameRateLimit != 20) { + setFrameRateLimit(20); + } + + // If software frame rate limiting has been asked for, lets calculate sleep time based on a base value calculated + // from 1000 / frameRateLimit in milliseconds subtracting the time it has taken to render last frame. + // This gives an approximate limit within 3 fps of the given frame rate limit. + if (frameRateLimit > 0) { + final double sleep = frameSleepTime - (timer.getTimePerFrame() / 1000.0); + final long sleepMillis = (long) sleep; + final int additionalNanos = (int) ((sleep - sleepMillis) * 1000000.0); + + if (sleepMillis >= 0 && additionalNanos >= 0) { + try { + Thread.sleep(sleepMillis, additionalNanos); + } catch (InterruptedException ignored) { + } + } + } + + glfwPollEvents(); + } + + private void setFrameRateLimit(int frameRateLimit) { + this.frameRateLimit = frameRateLimit; + frameSleepTime = 1000.0 / this.frameRateLimit; + } + + /** + * De-initialize in the OpenGL thread. + */ + + protected void deinitInThread() { + listener.destroy(); + + destroyContext(); + super.internalDestroy(); + + LOGGER.fine("Display destroyed."); + } + + @Override + public void run() { + if (listener == null) { + throw new IllegalStateException("SystemListener is not set on context!" + + "Must set with JmeContext.setSystemListener()."); + } + + LOGGER.log(Level.FINE, "Using LWJGL {0}", Version.getVersion()); + + if (!initInThread()) { + LOGGER.log(Level.SEVERE, "Display initialization failed. Cannot continue."); + return; + } + + while (true) { + + runLoop(); + + if (needClose.get()) { + break; + } + + if (glfwWindowShouldClose(window) == true) { + listener.requestClose(false); + } + } + + deinitInThread(); + } + + @Override + public JoyInput getJoyInput() { + if (joyInput == null) { + joyInput = new GlfwJoystickInput(); + } + return joyInput; + } + + @Override + public MouseInput getMouseInput() { + if (mouseInput == null) { + mouseInput = new GlfwMouseInputVR(this); + } + return mouseInput; + } + + @Override + public KeyInput getKeyInput() { + if (keyInput == null) { + keyInput = new GlfwKeyInputVR(this); + } + + return keyInput; + } + + @Override + public TouchInput getTouchInput() { + return null; + } + + @Override + public void setAutoFlushFrames(boolean enabled) { + this.autoFlush = enabled; + } + + @Override + public void destroy(boolean waitFor) { + needClose.set(true); + if (mainThread == Thread.currentThread()) { + // Ignore waitFor. + return; + } + + if (waitFor) { + waitFor(false); + } + } + + /** + * Get the window handle. + * @return the window handle as an internal GLFW identifier. + */ + public long getWindowHandle() { + return window; + } + + /** + * Returns the height of the framebuffer. + * + * @return the height (in pixels) + */ + @Override + public int getFramebufferHeight() { + glfwGetFramebufferSize(window, width, height); + int result = height[0]; + return result; + } + + /** + * Returns the width of the framebuffer. + * + * @return the width (in pixels) + */ + @Override + public int getFramebufferWidth() { + glfwGetFramebufferSize(window, width, height); + int result = width[0]; + return result; + } + + /** + * Returns the screen X coordinate of the left edge of the content area. + * + * @return the screen X coordinate + */ + @Override + public int getWindowXPosition() { + glfwGetWindowPos(window, width, height); + int result = width[0]; + return result; + } + + /** + * Returns the screen Y coordinate of the top edge of the content area. + * + * @return the screen Y coordinate + */ + @Override + public int getWindowYPosition() { + glfwGetWindowPos(window, width, height); + int result = height[0]; + return result; + } + + // TODO: Implement support for window icon when GLFW supports it. + /* + private ByteBuffer[] imagesToByteBuffers(Object[] images) { + ByteBuffer[] out = new ByteBuffer[images.length]; + for (int i = 0; i < images.length; i++) { + BufferedImage image = (BufferedImage) images[i]; + out[i] = imageToByteBuffer(image); + } + return out; + } + + private ByteBuffer imageToByteBuffer(BufferedImage image) { + if (image.getType() != BufferedImage.TYPE_INT_ARGB_PRE) { + BufferedImage convertedImage = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_ARGB_PRE); + Graphics2D g = convertedImage.createGraphics(); + double width = image.getWidth() * (double) 1; + double height = image.getHeight() * (double) 1; + g.drawImage(image, (int) ((convertedImage.getWidth() - width) / 2), + (int) ((convertedImage.getHeight() - height) / 2), + (int) (width), (int) (height), null); + g.dispose(); + image = convertedImage; + } + + byte[] imageBuffer = new byte[image.getWidth() * image.getHeight() * 4]; + int counter = 0; + for (int i = 0; i < image.getHeight(); i++) { + for (int j = 0; j < image.getWidth(); j++) { + int colorSpace = image.getRGB(j, i); + imageBuffer[counter + 0] = (byte) ((colorSpace << 8) >> 24); + imageBuffer[counter + 1] = (byte) ((colorSpace << 16) >> 24); + imageBuffer[counter + 2] = (byte) ((colorSpace << 24) >> 24); + imageBuffer[counter + 3] = (byte) (colorSpace >> 24); + counter += 4; + } + } + return ByteBuffer.wrap(imageBuffer); + } + */ +} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientkit/OsvrClientKitLibrary.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientkit/OsvrClientKitLibrary.java new file mode 100644 index 0000000000..dd8792e399 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientkit/OsvrClientKitLibrary.java @@ -0,0 +1,380 @@ +package com.jme3.system.osvr.osvrclientkit; +import com.sun.jna.Callback; +import com.sun.jna.Library; +import com.sun.jna.Native; +import com.sun.jna.NativeLibrary; +import com.sun.jna.Pointer; +import com.sun.jna.PointerType; +import com.sun.jna.ptr.PointerByReference; +/** + * JNA Wrapper for library osvrClientKit
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class OsvrClientKitLibrary implements Library { + public static final String JNA_LIBRARY_NAME = "osvrClientKit"; + public static final NativeLibrary JNA_NATIVE_LIB = NativeLibrary.getInstance(OsvrClientKitLibrary.JNA_LIBRARY_NAME); + static { + Native.register(OsvrClientKitLibrary.class, OsvrClientKitLibrary.JNA_NATIVE_LIB); + } + /** + * Initialize the library. + * @param applicationIdentifier A null terminated string identifying your
+ * application. Reverse DNS format strongly suggested.
+ * @param flags initialization options (reserved) - pass 0 for now.
+ * @return Client context - will be needed for subsequent calls
+ * Original signature : OSVR_ClientContext osvrClientInit(const char[], uint32_t)
+ * @deprecated use the safer method + * {@link #osvrClientInit(byte[], int)} + * instead + */ + @Deprecated + public static native OsvrClientKitLibrary.OSVR_ClientContext osvrClientInit(Pointer applicationIdentifier, int flags); + /** + * Initialize the library. + * @param applicationIdentifier A null terminated string identifying your
+ * application. Reverse DNS format strongly suggested.
+ * @param flags initialization options (reserved) - pass 0 for now.
+ * @return Client context - will be needed for subsequent calls
+ * Original signature : OSVR_ClientContext osvrClientInit(const char[], uint32_t) + */ + public static native OsvrClientKitLibrary.OSVR_ClientContext osvrClientInit(byte applicationIdentifier[], int flags); + /** + * Updates the state of the context - call regularly in your mainloop. + * @param ctx Client context
+ * Original signature : OSVR_ReturnCode osvrClientUpdate(OSVR_ClientContext)
+ * @deprecated use the safer method + * {@link #osvrClientUpdate(OsvrClientKitLibrary.OSVR_ClientContext)} + * instead + */ + @Deprecated + public static native byte osvrClientUpdate(Pointer ctx); + /** + * Updates the state of the context - call regularly in your mainloop. + * @param ctx Client context
+ * Original signature : OSVR_ReturnCode osvrClientUpdate(OSVR_ClientContext) + */ + public static native byte osvrClientUpdate(OsvrClientKitLibrary.OSVR_ClientContext ctx); + /** + * Checks to see if the client context is fully started up and connected + * properly to a server.
+ * If this reports that the client context is not OK, there may not be a server
+ * running, or you may just have to call osvrClientUpdate() a few times to
+ * permit startup to finish. The return value of this call will not change from
+ * failure to success without calling osvrClientUpdate().
+ * @param ctx Client context
+ * @return OSVR_RETURN_FAILURE if not yet fully connected/initialized, or if
+ * some other error (null context) occurs.
+ * Original signature : OSVR_ReturnCode osvrClientCheckStatus(OSVR_ClientContext)
+ * @deprecated use the safer method + * {@link #osvrClientCheckStatus(com.jme3.system.osvr.osvrclientkit.OsvrClientKitLibrary.OSVR_ClientContext)} + * instead + */ + @Deprecated + public static native byte osvrClientCheckStatus(Pointer ctx); + /** + * Checks to see if the client context is fully started up and connected + * properly to a server.
+ * If this reports that the client context is not OK, there may not be a server
+ * running, or you may just have to call osvrClientUpdate() a few times to
+ * permit startup to finish. The return value of this call will not change from
+ * failure to success without calling osvrClientUpdate().
+ * @param ctx Client context
+ * @return OSVR_RETURN_FAILURE if not yet fully connected/initialized, or if
+ * some other error (null context) occurs.
+ * Original signature : OSVR_ReturnCode osvrClientCheckStatus(OSVR_ClientContext) + */ + public static native byte osvrClientCheckStatus(OsvrClientKitLibrary.OSVR_ClientContext ctx); + /** + * Shut down the library. + * @param ctx Client context
+ * Original signature : OSVR_ReturnCode osvrClientShutdown(OSVR_ClientContext)
+ * @deprecated use the safer method + * {@link #osvrClientShutdown(OsvrClientKitLibrary.OSVR_ClientContext)} + * instead + */ + @Deprecated + public static native byte osvrClientShutdown(Pointer ctx); + /** + * Shut down the library. + * @param ctx Client context
+ * Original signature : OSVR_ReturnCode osvrClientShutdown(OSVR_ClientContext) + */ + public static native byte osvrClientShutdown(OsvrClientKitLibrary.OSVR_ClientContext ctx); + /** + * Log a message from the client. + * Original signature : void osvrClientLog(OSVR_ClientContext, OSVR_LogLevel, const char*)
+ * @deprecated use the safer method + * {@link #osvrClientLog(com.jme3.system.osvr.osvrclientkit.OsvrClientKitLibrary.OSVR_ClientContext, int, java.lang.String)} + * instead + */ + @Deprecated + public static native void osvrClientLog(Pointer ctx, int severity, Pointer message); + /** + * Log a message from the client. + * Original signature : void osvrClientLog(OSVR_ClientContext, OSVR_LogLevel, const char*) + */ + public static native void osvrClientLog(OsvrClientKitLibrary.OSVR_ClientContext ctx, int severity, String message); + /** + * Get the interface associated with the given path. + * @param ctx Client context
+ * @param path A resource path (null-terminated string)
+ * @param iface The interface object. May be freed when no longer needed,
+ * otherwise it will be freed when the context is closed.
+ * Original signature : OSVR_ReturnCode osvrClientGetInterface(OSVR_ClientContext, const char[], OSVR_ClientInterface*)
+ * @deprecated use the safer method + * {@link #osvrClientGetInterface(com.jme3.system.osvr.osvrclientkit.OsvrClientKitLibrary.OSVR_ClientContext, byte[], com.sun.jna.ptr.PointerByReference)} + * instead + */ + @Deprecated + public static native byte osvrClientGetInterface(Pointer ctx, Pointer path, Pointer iface); + /** + * Get the interface associated with the given path. + * @param ctx Client context
+ * @param path A resource path (null-terminated string)
+ * @param iface The interface object. May be freed when no longer needed,
+ * otherwise it will be freed when the context is closed.
+ * Original signature : OSVR_ReturnCode osvrClientGetInterface(OSVR_ClientContext, const char[], OSVR_ClientInterface*) + */ + public static native byte osvrClientGetInterface(OsvrClientKitLibrary.OSVR_ClientContext ctx, byte path[], PointerByReference iface); + /** + * Get the interface associated with the given path. + * @param ctx Client context
+ * @param path A resource path (null-terminated string)
+ * @param iface The interface object. May be freed when no longer needed,
+ * otherwise it will be freed when the context is closed.
+ * Original signature : OSVR_ReturnCode osvrClientGetInterface(OSVR_ClientContext, const char[], OSVR_ClientInterface*) + */ + public static native byte osvrClientGetInterface(Pointer ctx, Pointer path, PointerByReference iface); + /** + * Free an interface object before context closure. + * @param ctx Client context
+ * @param iface The interface object
+ * @return OSVR_RETURN_SUCCESS unless a null context or interface was passed
+ * or the given interface was not found in the context (i.e. had already been
+ * freed)
+ * Original signature : OSVR_ReturnCode osvrClientFreeInterface(OSVR_ClientContext, OSVR_ClientInterface)
+ * @deprecated use the safer method + * {@link #osvrClientFreeInterface(com.jme3.system.osvr.osvrclientkit.OsvrClientKitLibrary.OSVR_ClientContext, com.jme3.system.osvr.osvrclientkit.OsvrClientKitLibrary.OSVR_ClientInterface)} + * instead + */ + @Deprecated + public static native byte osvrClientFreeInterface(Pointer ctx, Pointer iface); + /** + * Free an interface object before context closure. + * @param ctx Client context
+ * @param iface The interface object
+ * @return OSVR_RETURN_SUCCESS unless a null context or interface was passed
+ * or the given interface was not found in the context (i.e. had already been
+ * freed)
+ * Original signature : OSVR_ReturnCode osvrClientFreeInterface(OSVR_ClientContext, OSVR_ClientInterface) + */ + public static native byte osvrClientFreeInterface(OsvrClientKitLibrary.OSVR_ClientContext ctx, OsvrClientKitLibrary.OSVR_ClientInterface iface); + /** + * Original signature : OSVR_ReturnCode osvrRegisterPoseCallback(OSVR_ClientInterface, OSVR_PoseCallback, void*)
+ * @deprecated use the safer method + * {@link #osvrRegisterPoseCallback(OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} + * instead + */ + @Deprecated + public static native byte osvrRegisterPoseCallback(Pointer iface, Pointer cb, Pointer userdata); + /** Original signature : OSVR_ReturnCode osvrRegisterPoseCallback(OSVR_ClientInterface, OSVR_PoseCallback, void*) */ + public static native byte osvrRegisterPoseCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Pointer cb, Pointer userdata); + /** + * Original signature : OSVR_ReturnCode osvrRegisterPositionCallback(OSVR_ClientInterface, OSVR_PositionCallback, void*)
+ * @deprecated use the safer method + * {@link #osvrRegisterPositionCallback(OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} + * instead + */ + @Deprecated + public static native byte osvrRegisterPositionCallback(Pointer iface, Pointer cb, Pointer userdata); + /** Original signature : OSVR_ReturnCode osvrRegisterPositionCallback(OSVR_ClientInterface, OSVR_PositionCallback, void*) */ + public static native byte osvrRegisterPositionCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Pointer cb, Pointer userdata); + /** + * Original signature : OSVR_ReturnCode osvrRegisterOrientationCallback(OSVR_ClientInterface, OSVR_OrientationCallback, void*)
+ * @deprecated use the safer method + * {@link #osvrRegisterOrientationCallback(OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} + * instead + */ + @Deprecated + public static native byte osvrRegisterOrientationCallback(Pointer iface, Pointer cb, Pointer userdata); + /** Original signature : OSVR_ReturnCode osvrRegisterOrientationCallback(OSVR_ClientInterface, OSVR_OrientationCallback, void*) */ + public static native byte osvrRegisterOrientationCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Pointer cb, Pointer userdata); + /** + * Original signature : OSVR_ReturnCode osvrRegisterVelocityCallback(OSVR_ClientInterface, OSVR_VelocityCallback, void*)
+ * @deprecated use the safer method + * {@link #osvrRegisterVelocityCallback(OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} + * instead + */ + @Deprecated + public static native byte osvrRegisterVelocityCallback(Pointer iface, Pointer cb, Pointer userdata); + /** Original signature : OSVR_ReturnCode osvrRegisterVelocityCallback(OSVR_ClientInterface, OSVR_VelocityCallback, void*) */ + public static native byte osvrRegisterVelocityCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Pointer cb, Pointer userdata); + /** + * Original signature : OSVR_ReturnCode osvrRegisterLinearVelocityCallback(OSVR_ClientInterface, OSVR_LinearVelocityCallback, void*)
+ * @deprecated use the safer method + * {@link #osvrRegisterLinearVelocityCallback(OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} + * instead + */ + @Deprecated + public static native byte osvrRegisterLinearVelocityCallback(Pointer iface, Pointer cb, Pointer userdata); + /** Original signature : OSVR_ReturnCode osvrRegisterLinearVelocityCallback(OSVR_ClientInterface, OSVR_LinearVelocityCallback, void*) */ + public static native byte osvrRegisterLinearVelocityCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Pointer cb, Pointer userdata); + /** + * Original signature : OSVR_ReturnCode osvrRegisterAngularVelocityCallback(OSVR_ClientInterface, OSVR_AngularVelocityCallback, void*)
+ * @deprecated use the safer method + * {@link #osvrRegisterAngularVelocityCallback(OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} + * instead + */ + @Deprecated + public static native byte osvrRegisterAngularVelocityCallback(Pointer iface, Pointer cb, Pointer userdata); + /** Original signature : OSVR_ReturnCode osvrRegisterAngularVelocityCallback(OSVR_ClientInterface, OSVR_AngularVelocityCallback, void*) */ + public static native byte osvrRegisterAngularVelocityCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Pointer cb, Pointer userdata); + /** + * Original signature : OSVR_ReturnCode osvrRegisterAccelerationCallback(OSVR_ClientInterface, OSVR_AccelerationCallback, void*)
+ * @deprecated use the safer method + * {@link #osvrRegisterAccelerationCallback(OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} + * instead + */ + @Deprecated + public static native byte osvrRegisterAccelerationCallback(Pointer iface, Pointer cb, Pointer userdata); + /** Original signature : OSVR_ReturnCode osvrRegisterAccelerationCallback(OSVR_ClientInterface, OSVR_AccelerationCallback, void*) */ + public static native byte osvrRegisterAccelerationCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Pointer cb, Pointer userdata); + /** + * Original signature : OSVR_ReturnCode osvrRegisterLinearAccelerationCallback(OSVR_ClientInterface, OSVR_LinearAccelerationCallback, void*)
+ * @deprecated use the safer method + * {@link #osvrRegisterLinearAccelerationCallback(OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} + * instead + */ + @Deprecated + public static native byte osvrRegisterLinearAccelerationCallback(Pointer iface, Pointer cb, Pointer userdata); + /** Original signature : OSVR_ReturnCode osvrRegisterLinearAccelerationCallback(OSVR_ClientInterface, OSVR_LinearAccelerationCallback, void*) */ + public static native byte osvrRegisterLinearAccelerationCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Pointer cb, Pointer userdata); + /** + * Original signature : OSVR_ReturnCode osvrRegisterAngularAccelerationCallback(OSVR_ClientInterface, OSVR_AngularAccelerationCallback, void*)
+ * @deprecated use the safer method + * {@link #osvrRegisterAngularAccelerationCallback(OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} + * instead + */ + @Deprecated + public static native byte osvrRegisterAngularAccelerationCallback(Pointer iface, Pointer cb, Pointer userdata); + /** Original signature : OSVR_ReturnCode osvrRegisterAngularAccelerationCallback(OSVR_ClientInterface, OSVR_AngularAccelerationCallback, void*) */ + public static native byte osvrRegisterAngularAccelerationCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Pointer cb, Pointer userdata); + /** + * Original signature : OSVR_ReturnCode osvrRegisterButtonCallback(OSVR_ClientInterface, OSVR_ButtonCallback, void*)
+ * @deprecated use the safer method + * {@link #osvrRegisterButtonCallback(com.jme3.system.osvr.osvrclientkit.OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Callback, com.sun.jna.Pointer)} + * instead + */ + @Deprecated + public static native byte osvrRegisterButtonCallback(Pointer iface, Pointer cb, Pointer userdata); + /** Original signature : OSVR_ReturnCode osvrRegisterButtonCallback(OSVR_ClientInterface, OSVR_ButtonCallback, void*) */ + public static native byte osvrRegisterButtonCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Callback cb, Pointer userdata); + /** + * Original signature : OSVR_ReturnCode osvrRegisterAnalogCallback(OSVR_ClientInterface, OSVR_AnalogCallback, void*)
+ * @deprecated use the safer method + * {@link #osvrRegisterAnalogCallback(com.jme3.system.osvr.osvrclientkit.OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Callback, com.sun.jna.Pointer)} + * instead + */ + @Deprecated + public static native byte osvrRegisterAnalogCallback(Pointer iface, Pointer cb, Pointer userdata); + /** Original signature : OSVR_ReturnCode osvrRegisterAnalogCallback(OSVR_ClientInterface, OSVR_AnalogCallback, void*) */ + public static native byte osvrRegisterAnalogCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Callback cb, Pointer userdata); + /** + * Original signature : OSVR_ReturnCode osvrRegisterImagingCallback(OSVR_ClientInterface, OSVR_ImagingCallback, void*)
+ * @deprecated use the safer method + * {@link #osvrRegisterImagingCallback(OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} + * instead + */ + @Deprecated + public static native byte osvrRegisterImagingCallback(Pointer iface, Pointer cb, Pointer userdata); + /** Original signature : OSVR_ReturnCode osvrRegisterImagingCallback(OSVR_ClientInterface, OSVR_ImagingCallback, void*) */ + public static native byte osvrRegisterImagingCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Pointer cb, Pointer userdata); + /** + * Original signature : OSVR_ReturnCode osvrRegisterLocation2DCallback(OSVR_ClientInterface, OSVR_Location2DCallback, void*)
+ * @deprecated use the safer method + * {@link #osvrRegisterLocation2DCallback(OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} + * instead + */ + @Deprecated + public static native byte osvrRegisterLocation2DCallback(Pointer iface, Pointer cb, Pointer userdata); + /** Original signature : OSVR_ReturnCode osvrRegisterLocation2DCallback(OSVR_ClientInterface, OSVR_Location2DCallback, void*) */ + public static native byte osvrRegisterLocation2DCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Pointer cb, Pointer userdata); + /** + * Original signature : OSVR_ReturnCode osvrRegisterDirectionCallback(OSVR_ClientInterface, OSVR_DirectionCallback, void*)
+ * @deprecated use the safer method + * {@link #osvrRegisterDirectionCallback(OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} + * instead + */ + @Deprecated + public static native byte osvrRegisterDirectionCallback(Pointer iface, Pointer cb, Pointer userdata); + /** Original signature : OSVR_ReturnCode osvrRegisterDirectionCallback(OSVR_ClientInterface, OSVR_DirectionCallback, void*) */ + public static native byte osvrRegisterDirectionCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Pointer cb, Pointer userdata); + /** + * Original signature : OSVR_ReturnCode osvrRegisterEyeTracker2DCallback(OSVR_ClientInterface, OSVR_EyeTracker2DCallback, void*)
+ * @deprecated use the safer method + * {@link #osvrRegisterEyeTracker2DCallback(OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} + * instead + */ + @Deprecated + public static native byte osvrRegisterEyeTracker2DCallback(Pointer iface, Pointer cb, Pointer userdata); + /** Original signature : OSVR_ReturnCode osvrRegisterEyeTracker2DCallback(OSVR_ClientInterface, OSVR_EyeTracker2DCallback, void*) */ + public static native byte osvrRegisterEyeTracker2DCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Pointer cb, Pointer userdata); + /** + * Original signature : OSVR_ReturnCode osvrRegisterEyeTracker3DCallback(OSVR_ClientInterface, OSVR_EyeTracker3DCallback, void*)
+ * @deprecated use the safer method + * {@link #osvrRegisterEyeTracker3DCallback(OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} + * instead + */ + @Deprecated + public static native byte osvrRegisterEyeTracker3DCallback(Pointer iface, Pointer cb, Pointer userdata); + /** Original signature : OSVR_ReturnCode osvrRegisterEyeTracker3DCallback(OSVR_ClientInterface, OSVR_EyeTracker3DCallback, void*) */ + public static native byte osvrRegisterEyeTracker3DCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Pointer cb, Pointer userdata); + /** + * Original signature : OSVR_ReturnCode osvrRegisterEyeTrackerBlinkCallback(OSVR_ClientInterface, OSVR_EyeTrackerBlinkCallback, void*)
+ * @deprecated use the safer method + * {@link #osvrRegisterEyeTrackerBlinkCallback(OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} + * instead + */ + @Deprecated + public static native byte osvrRegisterEyeTrackerBlinkCallback(Pointer iface, Pointer cb, Pointer userdata); + /** Original signature : OSVR_ReturnCode osvrRegisterEyeTrackerBlinkCallback(OSVR_ClientInterface, OSVR_EyeTrackerBlinkCallback, void*) */ + public static native byte osvrRegisterEyeTrackerBlinkCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Pointer cb, Pointer userdata); + /** + * Original signature : OSVR_ReturnCode osvrRegisterNaviVelocityCallback(OSVR_ClientInterface, OSVR_NaviVelocityCallback, void*)
+ * @deprecated use the safer method + * {@link #osvrRegisterNaviVelocityCallback(OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} + * instead + */ + @Deprecated + public static native byte osvrRegisterNaviVelocityCallback(Pointer iface, Pointer cb, Pointer userdata); + /** Original signature : OSVR_ReturnCode osvrRegisterNaviVelocityCallback(OSVR_ClientInterface, OSVR_NaviVelocityCallback, void*) */ + public static native byte osvrRegisterNaviVelocityCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Pointer cb, Pointer userdata); + /** + * Original signature : OSVR_ReturnCode osvrRegisterNaviPositionCallback(OSVR_ClientInterface, OSVR_NaviPositionCallback, void*)
+ * @deprecated use the safer method + * {@link #osvrRegisterNaviPositionCallback(OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} + * instead + */ + @Deprecated + public static native byte osvrRegisterNaviPositionCallback(Pointer iface, Pointer cb, Pointer userdata); + /** Original signature : OSVR_ReturnCode osvrRegisterNaviPositionCallback(OSVR_ClientInterface, OSVR_NaviPositionCallback, void*) */ + public static native byte osvrRegisterNaviPositionCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Pointer cb, Pointer userdata); + public static class OSVR_ClientContext extends PointerType { + public OSVR_ClientContext(Pointer address) { + super(address); + } + public OSVR_ClientContext() { + super(); + } + }; + public static class OSVR_ClientInterface extends PointerType { + public OSVR_ClientInterface(Pointer address) { + super(address); + } + public OSVR_ClientInterface() { + super(); + } + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_AccelerationReport.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_AccelerationReport.java new file mode 100644 index 0000000000..c6ba614d1d --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_AccelerationReport.java @@ -0,0 +1,37 @@ +package com.jme3.system.osvr.osvrclientreporttypes; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class OSVR_AccelerationReport extends Structure { + public int sensor; + /** C type : OSVR_AccelerationState */ + public OSVR_AccelerationState state; + public OSVR_AccelerationReport() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("sensor", "state"); + } + /** @param state C type : OSVR_AccelerationState */ + public OSVR_AccelerationReport(int sensor, OSVR_AccelerationState state) { + super(); + this.sensor = sensor; + this.state = state; + } + public OSVR_AccelerationReport(Pointer peer) { + super(peer); + } + public static class ByReference extends OSVR_AccelerationReport implements Structure.ByReference { + + }; + public static class ByValue extends OSVR_AccelerationReport implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_AccelerationState.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_AccelerationState.java new file mode 100644 index 0000000000..379a7972b4 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_AccelerationState.java @@ -0,0 +1,49 @@ +package com.jme3.system.osvr.osvrclientreporttypes; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class OSVR_AccelerationState extends Structure { + /** C type : OSVR_LinearAccelerationState */ + public OSVR_Vec3 linearAcceleration; + /** C type : OSVR_CBool */ + public byte linearAccelerationValid; + /** C type : OSVR_AngularAccelerationState */ + public OSVR_IncrementalQuaternion angularAcceleration; + /** C type : OSVR_CBool */ + public byte angularAccelerationValid; + public OSVR_AccelerationState() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("linearAcceleration", "linearAccelerationValid", "angularAcceleration", "angularAccelerationValid"); + } + /** + * @param linearAcceleration C type : OSVR_LinearAccelerationState
+ * @param linearAccelerationValid C type : OSVR_CBool
+ * @param angularAcceleration C type : OSVR_AngularAccelerationState
+ * @param angularAccelerationValid C type : OSVR_CBool + */ + public OSVR_AccelerationState(OSVR_Vec3 linearAcceleration, byte linearAccelerationValid, OSVR_IncrementalQuaternion angularAcceleration, byte angularAccelerationValid) { + super(); + this.linearAcceleration = linearAcceleration; + this.linearAccelerationValid = linearAccelerationValid; + this.angularAcceleration = angularAcceleration; + this.angularAccelerationValid = angularAccelerationValid; + } + public OSVR_AccelerationState(Pointer peer) { + super(peer); + } + public static class ByReference extends OSVR_AccelerationState implements Structure.ByReference { + + }; + public static class ByValue extends OSVR_AccelerationState implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_AnalogReport.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_AnalogReport.java new file mode 100644 index 0000000000..8b5aca7d1c --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_AnalogReport.java @@ -0,0 +1,37 @@ +package com.jme3.system.osvr.osvrclientreporttypes; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class OSVR_AnalogReport extends Structure { + public int sensor; + /** C type : OSVR_AnalogState */ + public double state; + public OSVR_AnalogReport() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("sensor", "state"); + } + /** @param state C type : OSVR_AnalogState */ + public OSVR_AnalogReport(int sensor, double state) { + super(); + this.sensor = sensor; + this.state = state; + } + public OSVR_AnalogReport(Pointer peer) { + super(peer); + } + public static class ByReference extends OSVR_AnalogReport implements Structure.ByReference { + + }; + public static class ByValue extends OSVR_AnalogReport implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_AngularAccelerationReport.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_AngularAccelerationReport.java new file mode 100644 index 0000000000..c7a3821dd7 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_AngularAccelerationReport.java @@ -0,0 +1,37 @@ +package com.jme3.system.osvr.osvrclientreporttypes; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class OSVR_AngularAccelerationReport extends Structure { + public int sensor; + /** C type : OSVR_AngularAccelerationState */ + public OSVR_IncrementalQuaternion state; + public OSVR_AngularAccelerationReport() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("sensor", "state"); + } + /** @param state C type : OSVR_AngularAccelerationState */ + public OSVR_AngularAccelerationReport(int sensor, OSVR_IncrementalQuaternion state) { + super(); + this.sensor = sensor; + this.state = state; + } + public OSVR_AngularAccelerationReport(Pointer peer) { + super(peer); + } + public static class ByReference extends OSVR_AngularAccelerationReport implements Structure.ByReference { + + }; + public static class ByValue extends OSVR_AngularAccelerationReport implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_AngularVelocityReport.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_AngularVelocityReport.java new file mode 100644 index 0000000000..bb526b7b1c --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_AngularVelocityReport.java @@ -0,0 +1,37 @@ +package com.jme3.system.osvr.osvrclientreporttypes; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class OSVR_AngularVelocityReport extends Structure { + public int sensor; + /** C type : OSVR_AngularVelocityState */ + public OSVR_IncrementalQuaternion state; + public OSVR_AngularVelocityReport() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("sensor", "state"); + } + /** @param state C type : OSVR_AngularVelocityState */ + public OSVR_AngularVelocityReport(int sensor, OSVR_IncrementalQuaternion state) { + super(); + this.sensor = sensor; + this.state = state; + } + public OSVR_AngularVelocityReport(Pointer peer) { + super(peer); + } + public static class ByReference extends OSVR_AngularVelocityReport implements Structure.ByReference { + + }; + public static class ByValue extends OSVR_AngularVelocityReport implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_ButtonReport.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_ButtonReport.java new file mode 100644 index 0000000000..4988433679 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_ButtonReport.java @@ -0,0 +1,37 @@ +package com.jme3.system.osvr.osvrclientreporttypes; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class OSVR_ButtonReport extends Structure { + public int sensor; + /** C type : OSVR_ButtonState */ + public byte state; + public OSVR_ButtonReport() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("sensor", "state"); + } + /** @param state C type : OSVR_ButtonState */ + public OSVR_ButtonReport(int sensor, byte state) { + super(); + this.sensor = sensor; + this.state = state; + } + public OSVR_ButtonReport(Pointer peer) { + super(peer); + } + public static class ByReference extends OSVR_ButtonReport implements Structure.ByReference { + + }; + public static class ByValue extends OSVR_ButtonReport implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_DirectionReport.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_DirectionReport.java new file mode 100644 index 0000000000..70af9a36ba --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_DirectionReport.java @@ -0,0 +1,41 @@ +package com.jme3.system.osvr.osvrclientreporttypes; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class OSVR_DirectionReport extends Structure { + /** C type : OSVR_ChannelCount */ + public int sensor; + /** C type : OSVR_DirectionState */ + public OSVR_Vec3 direction; + public OSVR_DirectionReport() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("sensor", "direction"); + } + /** + * @param sensor C type : OSVR_ChannelCount
+ * @param direction C type : OSVR_DirectionState + */ + public OSVR_DirectionReport(int sensor, OSVR_Vec3 direction) { + super(); + this.sensor = sensor; + this.direction = direction; + } + public OSVR_DirectionReport(Pointer peer) { + super(peer); + } + public static class ByReference extends OSVR_DirectionReport implements Structure.ByReference { + + }; + public static class ByValue extends OSVR_DirectionReport implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_EyeTracker2DReport.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_EyeTracker2DReport.java new file mode 100644 index 0000000000..f72a176f70 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_EyeTracker2DReport.java @@ -0,0 +1,41 @@ +package com.jme3.system.osvr.osvrclientreporttypes; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class OSVR_EyeTracker2DReport extends Structure { + /** C type : OSVR_ChannelCount */ + public int sensor; + /** C type : OSVR_EyeTracker2DState */ + public OSVR_Vec2 state; + public OSVR_EyeTracker2DReport() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("sensor", "state"); + } + /** + * @param sensor C type : OSVR_ChannelCount
+ * @param state C type : OSVR_EyeTracker2DState + */ + public OSVR_EyeTracker2DReport(int sensor, OSVR_Vec2 state) { + super(); + this.sensor = sensor; + this.state = state; + } + public OSVR_EyeTracker2DReport(Pointer peer) { + super(peer); + } + public static class ByReference extends OSVR_EyeTracker2DReport implements Structure.ByReference { + + }; + public static class ByValue extends OSVR_EyeTracker2DReport implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_EyeTracker3DReport.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_EyeTracker3DReport.java new file mode 100644 index 0000000000..93af317c37 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_EyeTracker3DReport.java @@ -0,0 +1,41 @@ +package com.jme3.system.osvr.osvrclientreporttypes; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class OSVR_EyeTracker3DReport extends Structure { + /** C type : OSVR_ChannelCount */ + public int sensor; + /** C type : OSVR_EyeTracker3DState */ + public OSVR_EyeTracker3DState state; + public OSVR_EyeTracker3DReport() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("sensor", "state"); + } + /** + * @param sensor C type : OSVR_ChannelCount
+ * @param state C type : OSVR_EyeTracker3DState + */ + public OSVR_EyeTracker3DReport(int sensor, OSVR_EyeTracker3DState state) { + super(); + this.sensor = sensor; + this.state = state; + } + public OSVR_EyeTracker3DReport(Pointer peer) { + super(peer); + } + public static class ByReference extends OSVR_EyeTracker3DReport implements Structure.ByReference { + + }; + public static class ByValue extends OSVR_EyeTracker3DReport implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_EyeTracker3DState.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_EyeTracker3DState.java new file mode 100644 index 0000000000..29da57b206 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_EyeTracker3DState.java @@ -0,0 +1,49 @@ +package com.jme3.system.osvr.osvrclientreporttypes; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class OSVR_EyeTracker3DState extends Structure { + /** C type : OSVR_CBool */ + public byte directionValid; + /** C type : OSVR_DirectionState */ + public OSVR_Vec3 direction; + /** C type : OSVR_CBool */ + public byte basePointValid; + /** C type : OSVR_PositionState */ + public OSVR_Vec3 basePoint; + public OSVR_EyeTracker3DState() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("directionValid", "direction", "basePointValid", "basePoint"); + } + /** + * @param directionValid C type : OSVR_CBool
+ * @param direction C type : OSVR_DirectionState
+ * @param basePointValid C type : OSVR_CBool
+ * @param basePoint C type : OSVR_PositionState + */ + public OSVR_EyeTracker3DState(byte directionValid, OSVR_Vec3 direction, byte basePointValid, OSVR_Vec3 basePoint) { + super(); + this.directionValid = directionValid; + this.direction = direction; + this.basePointValid = basePointValid; + this.basePoint = basePoint; + } + public OSVR_EyeTracker3DState(Pointer peer) { + super(peer); + } + public static class ByReference extends OSVR_EyeTracker3DState implements Structure.ByReference { + + }; + public static class ByValue extends OSVR_EyeTracker3DState implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_EyeTrackerBlinkReport.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_EyeTrackerBlinkReport.java new file mode 100644 index 0000000000..0ad5f64361 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_EyeTrackerBlinkReport.java @@ -0,0 +1,41 @@ +package com.jme3.system.osvr.osvrclientreporttypes; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class OSVR_EyeTrackerBlinkReport extends Structure { + /** C type : OSVR_ChannelCount */ + public int sensor; + /** C type : OSVR_EyeTrackerBlinkState */ + public byte state; + public OSVR_EyeTrackerBlinkReport() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("sensor", "state"); + } + /** + * @param sensor C type : OSVR_ChannelCount
+ * @param state C type : OSVR_EyeTrackerBlinkState + */ + public OSVR_EyeTrackerBlinkReport(int sensor, byte state) { + super(); + this.sensor = sensor; + this.state = state; + } + public OSVR_EyeTrackerBlinkReport(Pointer peer) { + super(peer); + } + public static class ByReference extends OSVR_EyeTrackerBlinkReport implements Structure.ByReference { + + }; + public static class ByValue extends OSVR_EyeTrackerBlinkReport implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_IncrementalQuaternion.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_IncrementalQuaternion.java new file mode 100644 index 0000000000..07cb64c949 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_IncrementalQuaternion.java @@ -0,0 +1,37 @@ +package com.jme3.system.osvr.osvrclientreporttypes; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class OSVR_IncrementalQuaternion extends Structure { + /** C type : OSVR_Quaternion */ + public OSVR_Quaternion incrementalRotation; + public double dt; + public OSVR_IncrementalQuaternion() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("incrementalRotation", "dt"); + } + /** @param incrementalRotation C type : OSVR_Quaternion */ + public OSVR_IncrementalQuaternion(OSVR_Quaternion incrementalRotation, double dt) { + super(); + this.incrementalRotation = incrementalRotation; + this.dt = dt; + } + public OSVR_IncrementalQuaternion(Pointer peer) { + super(peer); + } + public static class ByReference extends OSVR_IncrementalQuaternion implements Structure.ByReference { + + }; + public static class ByValue extends OSVR_IncrementalQuaternion implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_LinearAccelerationReport.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_LinearAccelerationReport.java new file mode 100644 index 0000000000..4baffbd65d --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_LinearAccelerationReport.java @@ -0,0 +1,37 @@ +package com.jme3.system.osvr.osvrclientreporttypes; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class OSVR_LinearAccelerationReport extends Structure { + public int sensor; + /** C type : OSVR_LinearAccelerationState */ + public OSVR_Vec3 state; + public OSVR_LinearAccelerationReport() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("sensor", "state"); + } + /** @param state C type : OSVR_LinearAccelerationState */ + public OSVR_LinearAccelerationReport(int sensor, OSVR_Vec3 state) { + super(); + this.sensor = sensor; + this.state = state; + } + public OSVR_LinearAccelerationReport(Pointer peer) { + super(peer); + } + public static class ByReference extends OSVR_LinearAccelerationReport implements Structure.ByReference { + + }; + public static class ByValue extends OSVR_LinearAccelerationReport implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_LinearVelocityReport.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_LinearVelocityReport.java new file mode 100644 index 0000000000..c40b3e74ae --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_LinearVelocityReport.java @@ -0,0 +1,37 @@ +package com.jme3.system.osvr.osvrclientreporttypes; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class OSVR_LinearVelocityReport extends Structure { + public int sensor; + /** C type : OSVR_LinearVelocityState */ + public OSVR_Vec3 state; + public OSVR_LinearVelocityReport() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("sensor", "state"); + } + /** @param state C type : OSVR_LinearVelocityState */ + public OSVR_LinearVelocityReport(int sensor, OSVR_Vec3 state) { + super(); + this.sensor = sensor; + this.state = state; + } + public OSVR_LinearVelocityReport(Pointer peer) { + super(peer); + } + public static class ByReference extends OSVR_LinearVelocityReport implements Structure.ByReference { + + }; + public static class ByValue extends OSVR_LinearVelocityReport implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_Location2DReport.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_Location2DReport.java new file mode 100644 index 0000000000..8c05d755a8 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_Location2DReport.java @@ -0,0 +1,41 @@ +package com.jme3.system.osvr.osvrclientreporttypes; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class OSVR_Location2DReport extends Structure { + /** C type : OSVR_ChannelCount */ + public int sensor; + /** C type : OSVR_Location2DState */ + public OSVR_Vec2 location; + public OSVR_Location2DReport() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("sensor", "location"); + } + /** + * @param sensor C type : OSVR_ChannelCount
+ * @param location C type : OSVR_Location2DState + */ + public OSVR_Location2DReport(int sensor, OSVR_Vec2 location) { + super(); + this.sensor = sensor; + this.location = location; + } + public OSVR_Location2DReport(Pointer peer) { + super(peer); + } + public static class ByReference extends OSVR_Location2DReport implements Structure.ByReference { + + }; + public static class ByValue extends OSVR_Location2DReport implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_NaviPositionReport.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_NaviPositionReport.java new file mode 100644 index 0000000000..47cb3d563a --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_NaviPositionReport.java @@ -0,0 +1,41 @@ +package com.jme3.system.osvr.osvrclientreporttypes; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class OSVR_NaviPositionReport extends Structure { + /** C type : OSVR_ChannelCount */ + public int sensor; + /** C type : OSVR_NaviPositionState */ + public OSVR_Vec2 state; + public OSVR_NaviPositionReport() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("sensor", "state"); + } + /** + * @param sensor C type : OSVR_ChannelCount
+ * @param state C type : OSVR_NaviPositionState + */ + public OSVR_NaviPositionReport(int sensor, OSVR_Vec2 state) { + super(); + this.sensor = sensor; + this.state = state; + } + public OSVR_NaviPositionReport(Pointer peer) { + super(peer); + } + public static class ByReference extends OSVR_NaviPositionReport implements Structure.ByReference { + + }; + public static class ByValue extends OSVR_NaviPositionReport implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_NaviVelocityReport.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_NaviVelocityReport.java new file mode 100644 index 0000000000..ff07a8a0a2 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_NaviVelocityReport.java @@ -0,0 +1,41 @@ +package com.jme3.system.osvr.osvrclientreporttypes; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class OSVR_NaviVelocityReport extends Structure { + /** C type : OSVR_ChannelCount */ + public int sensor; + /** C type : OSVR_NaviVelocityState */ + public OSVR_Vec2 state; + public OSVR_NaviVelocityReport() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("sensor", "state"); + } + /** + * @param sensor C type : OSVR_ChannelCount
+ * @param state C type : OSVR_NaviVelocityState + */ + public OSVR_NaviVelocityReport(int sensor, OSVR_Vec2 state) { + super(); + this.sensor = sensor; + this.state = state; + } + public OSVR_NaviVelocityReport(Pointer peer) { + super(peer); + } + public static class ByReference extends OSVR_NaviVelocityReport implements Structure.ByReference { + + }; + public static class ByValue extends OSVR_NaviVelocityReport implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_OrientationReport.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_OrientationReport.java new file mode 100644 index 0000000000..7b8dc7bde0 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_OrientationReport.java @@ -0,0 +1,37 @@ +package com.jme3.system.osvr.osvrclientreporttypes; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class OSVR_OrientationReport extends Structure { + public int sensor; + /** C type : OSVR_OrientationState */ + public OSVR_Quaternion rotation; + public OSVR_OrientationReport() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("sensor", "rotation"); + } + /** @param rotation C type : OSVR_OrientationState */ + public OSVR_OrientationReport(int sensor, OSVR_Quaternion rotation) { + super(); + this.sensor = sensor; + this.rotation = rotation; + } + public OSVR_OrientationReport(Pointer peer) { + super(peer); + } + public static class ByReference extends OSVR_OrientationReport implements Structure.ByReference { + + }; + public static class ByValue extends OSVR_OrientationReport implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_Pose3.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_Pose3.java new file mode 100644 index 0000000000..5dacd27388 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_Pose3.java @@ -0,0 +1,41 @@ +package com.jme3.system.osvr.osvrclientreporttypes; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class OSVR_Pose3 extends Structure { + /** C type : OSVR_Vec3 */ + public OSVR_Vec3 translation; + /** C type : OSVR_Quaternion */ + public OSVR_Quaternion rotation; + public OSVR_Pose3() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("translation", "rotation"); + } + /** + * @param translation C type : OSVR_Vec3
+ * @param rotation C type : OSVR_Quaternion + */ + public OSVR_Pose3(OSVR_Vec3 translation, OSVR_Quaternion rotation) { + super(); + this.translation = translation; + this.rotation = rotation; + } + public OSVR_Pose3(Pointer peer) { + super(peer); + } + public static class ByReference extends OSVR_Pose3 implements Structure.ByReference { + + }; + public static class ByValue extends OSVR_Pose3 implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_PoseReport.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_PoseReport.java new file mode 100644 index 0000000000..e39eea50f6 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_PoseReport.java @@ -0,0 +1,37 @@ +package com.jme3.system.osvr.osvrclientreporttypes; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class OSVR_PoseReport extends Structure { + public int sensor; + /** C type : OSVR_PoseState */ + public OSVR_Pose3 pose; + public OSVR_PoseReport() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("sensor", "pose"); + } + /** @param pose C type : OSVR_PoseState */ + public OSVR_PoseReport(int sensor, OSVR_Pose3 pose) { + super(); + this.sensor = sensor; + this.pose = pose; + } + public OSVR_PoseReport(Pointer peer) { + super(peer); + } + public static class ByReference extends OSVR_PoseReport implements Structure.ByReference { + + }; + public static class ByValue extends OSVR_PoseReport implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_PositionReport.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_PositionReport.java new file mode 100644 index 0000000000..d93fc4a1fe --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_PositionReport.java @@ -0,0 +1,37 @@ +package com.jme3.system.osvr.osvrclientreporttypes; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class OSVR_PositionReport extends Structure { + public int sensor; + /** C type : OSVR_PositionState */ + public OSVR_Vec3 xyz; + public OSVR_PositionReport() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("sensor", "xyz"); + } + /** @param xyz C type : OSVR_PositionState */ + public OSVR_PositionReport(int sensor, OSVR_Vec3 xyz) { + super(); + this.sensor = sensor; + this.xyz = xyz; + } + public OSVR_PositionReport(Pointer peer) { + super(peer); + } + public static class ByReference extends OSVR_PositionReport implements Structure.ByReference { + + }; + public static class ByValue extends OSVR_PositionReport implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_Quaternion.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_Quaternion.java new file mode 100644 index 0000000000..72952297a1 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_Quaternion.java @@ -0,0 +1,37 @@ +package com.jme3.system.osvr.osvrclientreporttypes; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class OSVR_Quaternion extends Structure { + /** C type : double[4] */ + public double[] data = new double[4]; + public OSVR_Quaternion() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("data"); + } + /** @param data C type : double[4] */ + public OSVR_Quaternion(double data[]) { + super(); + if ((data.length != this.data.length)) + throw new IllegalArgumentException("Wrong array size !"); + this.data = data; + } + public OSVR_Quaternion(Pointer peer) { + super(peer); + } + public static class ByReference extends OSVR_Quaternion implements Structure.ByReference { + + }; + public static class ByValue extends OSVR_Quaternion implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_Vec2.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_Vec2.java new file mode 100644 index 0000000000..7427d14461 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_Vec2.java @@ -0,0 +1,37 @@ +package com.jme3.system.osvr.osvrclientreporttypes; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class OSVR_Vec2 extends Structure { + /** C type : double[2] */ + public double[] data = new double[2]; + public OSVR_Vec2() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("data"); + } + /** @param data C type : double[2] */ + public OSVR_Vec2(double data[]) { + super(); + if ((data.length != this.data.length)) + throw new IllegalArgumentException("Wrong array size !"); + this.data = data; + } + public OSVR_Vec2(Pointer peer) { + super(peer); + } + public static class ByReference extends OSVR_Vec2 implements Structure.ByReference { + + }; + public static class ByValue extends OSVR_Vec2 implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_Vec3.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_Vec3.java new file mode 100644 index 0000000000..b3b2ed8893 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_Vec3.java @@ -0,0 +1,37 @@ +package com.jme3.system.osvr.osvrclientreporttypes; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class OSVR_Vec3 extends Structure { + /** C type : double[3] */ + public double[] data = new double[3]; + public OSVR_Vec3() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("data"); + } + /** @param data C type : double[3] */ + public OSVR_Vec3(double data[]) { + super(); + if ((data.length != this.data.length)) + throw new IllegalArgumentException("Wrong array size !"); + this.data = data; + } + public OSVR_Vec3(Pointer peer) { + super(peer); + } + public static class ByReference extends OSVR_Vec3 implements Structure.ByReference { + + }; + public static class ByValue extends OSVR_Vec3 implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_VelocityReport.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_VelocityReport.java new file mode 100644 index 0000000000..da65aaf62c --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_VelocityReport.java @@ -0,0 +1,37 @@ +package com.jme3.system.osvr.osvrclientreporttypes; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class OSVR_VelocityReport extends Structure { + public int sensor; + /** C type : OSVR_VelocityState */ + public OSVR_VelocityState state; + public OSVR_VelocityReport() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("sensor", "state"); + } + /** @param state C type : OSVR_VelocityState */ + public OSVR_VelocityReport(int sensor, OSVR_VelocityState state) { + super(); + this.sensor = sensor; + this.state = state; + } + public OSVR_VelocityReport(Pointer peer) { + super(peer); + } + public static class ByReference extends OSVR_VelocityReport implements Structure.ByReference { + + }; + public static class ByValue extends OSVR_VelocityReport implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_VelocityState.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_VelocityState.java new file mode 100644 index 0000000000..4a4589a077 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_VelocityState.java @@ -0,0 +1,49 @@ +package com.jme3.system.osvr.osvrclientreporttypes; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class OSVR_VelocityState extends Structure { + /** C type : OSVR_LinearVelocityState */ + public OSVR_Vec3 linearVelocity; + /** C type : OSVR_CBool */ + public byte linearVelocityValid; + /** C type : OSVR_AngularVelocityState */ + public OSVR_IncrementalQuaternion angularVelocity; + /** C type : OSVR_CBool */ + public byte angularVelocityValid; + public OSVR_VelocityState() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("linearVelocity", "linearVelocityValid", "angularVelocity", "angularVelocityValid"); + } + /** + * @param linearVelocity C type : OSVR_LinearVelocityState
+ * @param linearVelocityValid C type : OSVR_CBool
+ * @param angularVelocity C type : OSVR_AngularVelocityState
+ * @param angularVelocityValid C type : OSVR_CBool + */ + public OSVR_VelocityState(OSVR_Vec3 linearVelocity, byte linearVelocityValid, OSVR_IncrementalQuaternion angularVelocity, byte angularVelocityValid) { + super(); + this.linearVelocity = linearVelocity; + this.linearVelocityValid = linearVelocityValid; + this.angularVelocity = angularVelocity; + this.angularVelocityValid = angularVelocityValid; + } + public OSVR_VelocityState(Pointer peer) { + super(peer); + } + public static class ByReference extends OSVR_VelocityState implements Structure.ByReference { + + }; + public static class ByValue extends OSVR_VelocityState implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OsvrClientReportTypesLibrary.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OsvrClientReportTypesLibrary.java new file mode 100644 index 0000000000..4289cb200f --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OsvrClientReportTypesLibrary.java @@ -0,0 +1,79 @@ +package com.jme3.system.osvr.osvrclientreporttypes; +import com.sun.jna.Library; +import com.sun.jna.Native; +import com.sun.jna.NativeLibrary; +/** + * JNA Wrapper for library osvrClientReportTypes
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class OsvrClientReportTypesLibrary implements Library { + public static final String JNA_LIBRARY_NAME = "osvrClientKit"; + public static final NativeLibrary JNA_NATIVE_LIB = NativeLibrary.getInstance(OsvrClientReportTypesLibrary.JNA_LIBRARY_NAME); + static { + Native.register(OsvrClientReportTypesLibrary.class, OsvrClientReportTypesLibrary.JNA_NATIVE_LIB); + } + public static final int OSVR_TRUE = 1; + public static final int OSVR_FALSE = 0; + public static final int OSVR_BUTTON_PRESSED = 1; + public static final int OSVR_BUTTON_NOT_PRESSED = 0; + public static final int OSVR_EYE_BLINK = 1; + public static final int OSVR_EYE_NO_BLINK = 0; + /** Original signature : double osvrVec3GetX(const OSVR_Vec3*) */ + public static native double osvrVec3GetX(OSVR_Vec3 v); + /** Original signature : void osvrVec3SetX(OSVR_Vec3*, double) */ + public static native void osvrVec3SetX(OSVR_Vec3 v, double val); + /** Original signature : double osvrVec3GetY(const OSVR_Vec3*) */ + public static native double osvrVec3GetY(OSVR_Vec3 v); + /** Original signature : void osvrVec3SetY(OSVR_Vec3*, double) */ + public static native void osvrVec3SetY(OSVR_Vec3 v, double val); + /** Original signature : double osvrVec3GetZ(const OSVR_Vec3*) */ + public static native double osvrVec3GetZ(OSVR_Vec3 v); + /** Original signature : void osvrVec3SetZ(OSVR_Vec3*, double) */ + public static native void osvrVec3SetZ(OSVR_Vec3 v, double val); + /** + * Set a Vec3 to the zero vector. + * Original signature : void osvrVec3Zero(OSVR_Vec3*) + */ + public static native void osvrVec3Zero(OSVR_Vec3 v); + /** Original signature : double osvrQuatGetW(const OSVR_Quaternion*) */ + public static native double osvrQuatGetW(OSVR_Quaternion q); + /** Original signature : void osvrQuatSetW(OSVR_Quaternion*, double) */ + public static native void osvrQuatSetW(OSVR_Quaternion q, double val); + /** Original signature : double osvrQuatGetX(const OSVR_Quaternion*) */ + public static native double osvrQuatGetX(OSVR_Quaternion q); + /** Original signature : void osvrQuatSetX(OSVR_Quaternion*, double) */ + public static native void osvrQuatSetX(OSVR_Quaternion q, double val); + /** Original signature : double osvrQuatGetY(const OSVR_Quaternion*) */ + public static native double osvrQuatGetY(OSVR_Quaternion q); + /** Original signature : void osvrQuatSetY(OSVR_Quaternion*, double) */ + public static native void osvrQuatSetY(OSVR_Quaternion q, double val); + /** Original signature : double osvrQuatGetZ(const OSVR_Quaternion*) */ + public static native double osvrQuatGetZ(OSVR_Quaternion q); + /** Original signature : void osvrQuatSetZ(OSVR_Quaternion*, double) */ + public static native void osvrQuatSetZ(OSVR_Quaternion q, double val); + /** + * Set a quaternion to the identity rotation. + * Original signature : void osvrQuatSetIdentity(OSVR_Quaternion*) + */ + public static native void osvrQuatSetIdentity(OSVR_Quaternion q); + /** + * Set a pose to identity. + * Original signature : void osvrPose3SetIdentity(OSVR_Pose3*) + */ + public static native void osvrPose3SetIdentity(OSVR_Pose3 pose); + /** Original signature : double osvrVec2GetX(const OSVR_Vec2*) */ + public static native double osvrVec2GetX(OSVR_Vec2 v); + /** Original signature : void osvrVec2SetX(OSVR_Vec2*, double) */ + public static native void osvrVec2SetX(OSVR_Vec2 v, double val); + /** Original signature : double osvrVec2GetY(const OSVR_Vec2*) */ + public static native double osvrVec2GetY(OSVR_Vec2 v); + /** Original signature : void osvrVec2SetY(OSVR_Vec2*, double) */ + public static native void osvrVec2SetY(OSVR_Vec2 v, double val); + /** + * Set a Vec2 to the zero vector. + * Original signature : void osvrVec2Zero(OSVR_Vec2*) + */ + public static native void osvrVec2Zero(OSVR_Vec2 v); +} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrdisplay/OsvrDisplayLibrary.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrdisplay/OsvrDisplayLibrary.java new file mode 100644 index 0000000000..de59467448 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrdisplay/OsvrDisplayLibrary.java @@ -0,0 +1,851 @@ +package com.jme3.system.osvr.osvrdisplay; +import com.jme3.system.osvr.osvrclientkit.OsvrClientKitLibrary; +import com.sun.jna.Library; +import com.sun.jna.Native; +import com.sun.jna.NativeLibrary; +import com.sun.jna.Pointer; +import com.sun.jna.PointerType; +import com.sun.jna.ptr.DoubleByReference; +import com.sun.jna.ptr.FloatByReference; +import com.sun.jna.ptr.IntByReference; +import com.sun.jna.ptr.PointerByReference; +import java.nio.ByteBuffer; +import java.nio.DoubleBuffer; +import java.nio.FloatBuffer; +import java.nio.IntBuffer; + +/** + * JNA Wrapper for library osvrDisplay
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class OsvrDisplayLibrary implements Library { + public static final String JNA_LIBRARY_NAME = "osvrClientKit"; + public static final NativeLibrary JNA_NATIVE_LIB = NativeLibrary.getInstance(OsvrDisplayLibrary.JNA_LIBRARY_NAME); + static { + Native.register(OsvrDisplayLibrary.class, OsvrDisplayLibrary.JNA_NATIVE_LIB); + } + /** + * Allocates a display configuration object populated with data from the
+ * OSVR system.
+ * Before this call will succeed, your application will need to be correctly
+ * and fully connected to an OSVR server. You may consider putting this call in
+ * a loop alternating with osvrClientUpdate() until this call succeeds.
+ * Data provided by a display configuration object:
+ * - The logical display topology (number and relationship of viewers, eyes,
+ * and surfaces), which remains constant throughout the life of the
+ * configuration object. (A method of notification of change here is TBD).
+ * - Pose data for viewers (not required for rendering) and pose/view data for
+ * eyes (used for rendering) which is based on tracker data: if used, these
+ * should be queried every frame.
+ * - Projection matrix data for surfaces, which while in current practice may
+ * be relatively unchanging, we are not guaranteeing them to be constant:
+ * these should be queried every frame.
+ * - Video-input-relative viewport size/location for a surface: would like this
+ * to be variable, but probably not feasible. If you have input, please
+ * comment on the dev mailing list.
+ * - Per-surface distortion strategy priorities/availabilities: constant. Note
+ * the following, though...
+ * - Per-surface distortion strategy parameters: variable, request each frame.
+ * (Could make constant with a notification if needed?)
+ * Important note: While most of this data is immediately available if you are
+ * successful in getting a display config object, the pose-based data (viewer
+ * pose, eye pose, eye view matrix) needs tracker state, so at least one (and in
+ * practice, typically more) osvrClientUpdate() must be performed before a new
+ * tracker report is available to populate that state. See
+ * osvrClientCheckDisplayStartup() to query if all startup data is available.
+ * todo Decide if relative viewport should be constant in a display config,
+ * and update docs accordingly.
+ * todo Decide if distortion params should be constant in a display config,
+ * and update docs accordingly.
+ * @return OSVR_RETURN_FAILURE if invalid parameters were passed or some other
+ * error occurred, in which case the output argument is unmodified.
+ * Original signature : OSVR_ReturnCode osvrClientGetDisplay(OSVR_ClientContext, OSVR_DisplayConfig*)
+ * @deprecated use the safer method + * {@link #osvrClientGetDisplay(com.jme3.system.osvr.osvrclientkit.OsvrClientKitLibrary.OSVR_ClientContext, com.sun.jna.ptr.PointerByReference)} + * instead + */ + @Deprecated + public static native byte osvrClientGetDisplay(Pointer ctx, Pointer disp); + /** + * Allocates a display configuration object populated with data from the
+ * OSVR system.
+ * Before this call will succeed, your application will need to be correctly
+ * and fully connected to an OSVR server. You may consider putting this call in
+ * a loop alternating with osvrClientUpdate() until this call succeeds.
+ * Data provided by a display configuration object:
+ * - The logical display topology (number and relationship of viewers, eyes,
+ * and surfaces), which remains constant throughout the life of the
+ * configuration object. (A method of notification of change here is TBD).
+ * - Pose data for viewers (not required for rendering) and pose/view data for
+ * eyes (used for rendering) which is based on tracker data: if used, these
+ * should be queried every frame.
+ * - Projection matrix data for surfaces, which while in current practice may
+ * be relatively unchanging, we are not guaranteeing them to be constant:
+ * these should be queried every frame.
+ * - Video-input-relative viewport size/location for a surface: would like this
+ * to be variable, but probably not feasible. If you have input, please
+ * comment on the dev mailing list.
+ * - Per-surface distortion strategy priorities/availabilities: constant. Note
+ * the following, though...
+ * - Per-surface distortion strategy parameters: variable, request each frame.
+ * (Could make constant with a notification if needed?)
+ * Important note: While most of this data is immediately available if you are
+ * successful in getting a display config object, the pose-based data (viewer
+ * pose, eye pose, eye view matrix) needs tracker state, so at least one (and in
+ * practice, typically more) osvrClientUpdate() must be performed before a new
+ * tracker report is available to populate that state. See
+ * osvrClientCheckDisplayStartup() to query if all startup data is available.
+ * todo Decide if relative viewport should be constant in a display config,
+ * and update docs accordingly.
+ * todo Decide if distortion params should be constant in a display config,
+ * and update docs accordingly.
+ * @return OSVR_RETURN_FAILURE if invalid parameters were passed or some other
+ * error occurred, in which case the output argument is unmodified.
+ * Original signature : OSVR_ReturnCode osvrClientGetDisplay(OSVR_ClientContext, OSVR_DisplayConfig*) + */ + public static native byte osvrClientGetDisplay(OsvrClientKitLibrary.OSVR_ClientContext ctx, PointerByReference disp); + /** + * Allocates a display configuration object populated with data from the
+ * OSVR system.
+ * Before this call will succeed, your application will need to be correctly
+ * and fully connected to an OSVR server. You may consider putting this call in
+ * a loop alternating with osvrClientUpdate() until this call succeeds.
+ * Data provided by a display configuration object:
+ * - The logical display topology (number and relationship of viewers, eyes,
+ * and surfaces), which remains constant throughout the life of the
+ * configuration object. (A method of notification of change here is TBD).
+ * - Pose data for viewers (not required for rendering) and pose/view data for
+ * eyes (used for rendering) which is based on tracker data: if used, these
+ * should be queried every frame.
+ * - Projection matrix data for surfaces, which while in current practice may
+ * be relatively unchanging, we are not guaranteeing them to be constant:
+ * these should be queried every frame.
+ * - Video-input-relative viewport size/location for a surface: would like this
+ * to be variable, but probably not feasible. If you have input, please
+ * comment on the dev mailing list.
+ * - Per-surface distortion strategy priorities/availabilities: constant. Note
+ * the following, though...
+ * - Per-surface distortion strategy parameters: variable, request each frame.
+ * (Could make constant with a notification if needed?)
+ * Important note: While most of this data is immediately available if you are
+ * successful in getting a display config object, the pose-based data (viewer
+ * pose, eye pose, eye view matrix) needs tracker state, so at least one (and in
+ * practice, typically more) osvrClientUpdate() must be performed before a new
+ * tracker report is available to populate that state. See
+ * osvrClientCheckDisplayStartup() to query if all startup data is available.
+ * todo Decide if relative viewport should be constant in a display config,
+ * and update docs accordingly.
+ * todo Decide if distortion params should be constant in a display config,
+ * and update docs accordingly.
+ * @return OSVR_RETURN_FAILURE if invalid parameters were passed or some other
+ * error occurred, in which case the output argument is unmodified.
+ * Original signature : OSVR_ReturnCode osvrClientGetDisplay(OSVR_ClientContext, OSVR_DisplayConfig*) + */ + public static native byte osvrClientGetDisplay(Pointer ctx, PointerByReference disp); + /** + * Frees a display configuration object. The corresponding context must
+ * still be open.
+ * If you fail to call this, it will be automatically called as part of
+ * clean-up when the corresponding context is closed.
+ * @return OSVR_RETURN_FAILURE if a null config was passed, or if the given
+ * display object was already freed.
+ * Original signature : OSVR_ReturnCode osvrClientFreeDisplay(OSVR_DisplayConfig)
+ * @deprecated use the safer method + * {@link #osvrClientFreeDisplay(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig)} + * instead + */ + @Deprecated + public static native byte osvrClientFreeDisplay(Pointer disp); + /** + * Frees a display configuration object. The corresponding context must
+ * still be open.
+ * If you fail to call this, it will be automatically called as part of
+ * clean-up when the corresponding context is closed.
+ * @return OSVR_RETURN_FAILURE if a null config was passed, or if the given
+ * display object was already freed.
+ * Original signature : OSVR_ReturnCode osvrClientFreeDisplay(OSVR_DisplayConfig) + */ + public static native byte osvrClientFreeDisplay(OsvrDisplayLibrary.OSVR_DisplayConfig disp); + /** + * Checks to see if a display is fully configured and ready, including
+ * having received its first pose update.
+ * Once this first succeeds, it will continue to succeed for the lifetime of
+ * the display config object, so it is not necessary to keep calling once you
+ * get a successful result.
+ * @return OSVR_RETURN_FAILURE if a null config was passed, or if the given
+ * display config object was otherwise not ready for full use.
+ * Original signature : OSVR_ReturnCode osvrClientCheckDisplayStartup(OSVR_DisplayConfig)
+ * @deprecated use the safer method + * {@link #osvrClientCheckDisplayStartup(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig)} + * instead + */ + @Deprecated + public static native byte osvrClientCheckDisplayStartup(Pointer disp); + /** + * Checks to see if a display is fully configured and ready, including
+ * having received its first pose update.
+ * Once this first succeeds, it will continue to succeed for the lifetime of
+ * the display config object, so it is not necessary to keep calling once you
+ * get a successful result.
+ * @return OSVR_RETURN_FAILURE if a null config was passed, or if the given
+ * display config object was otherwise not ready for full use.
+ * Original signature : OSVR_ReturnCode osvrClientCheckDisplayStartup(OSVR_DisplayConfig) + */ + public static native byte osvrClientCheckDisplayStartup(OsvrDisplayLibrary.OSVR_DisplayConfig disp); + /** + * A display config can have one or more display inputs to pass pixels
+ * over (HDMI/DVI connections, etcetera): retrieve the number of display inputs in
+ * the current configuration.
+ * @param disp Display config object.
+ * @param numDisplayInputs Number of display inputs in the logical display
+ * topology, **constant** throughout the active, valid lifetime of a display
+ * config object.
+ * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in
+ * which case the output argument is unmodified.
+ * Original signature : OSVR_ReturnCode osvrClientGetNumDisplayInputs(OSVR_DisplayConfig, OSVR_DisplayInputCount*)
+ * @deprecated use the safer method + * {@link #osvrClientGetNumDisplayInputs(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, java.nio.ByteBuffer)} + * instead + */ + @Deprecated + public static native byte osvrClientGetNumDisplayInputs(Pointer disp, Pointer numDisplayInputs); + /** + * A display config can have one or more display inputs to pass pixels
+ * over (HDMI/DVI connections, etcetera): retrieve the number of display inputs in
+ * the current configuration.
+ * @param disp Display config object.
+ * @param numDisplayInputs Number of display inputs in the logical display
+ * topology, **constant** throughout the active, valid lifetime of a display
+ * config object.
+ * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in
+ * which case the output argument is unmodified.
+ * Original signature : OSVR_ReturnCode osvrClientGetNumDisplayInputs(OSVR_DisplayConfig, OSVR_DisplayInputCount*) + */ + public static native byte osvrClientGetNumDisplayInputs(OsvrDisplayLibrary.OSVR_DisplayConfig disp, ByteBuffer numDisplayInputs); + /** + * Retrieve the pixel dimensions of a given display input for a display
+ * config
+ * @param disp Display config object.
+ * @param displayInputIndex The zero-based index of the display input.
+ * @param width Width (in pixels) of the display input.
+ * @param height Height (in pixels) of the display input.
+ * The out parameters are **constant** throughout the active, valid lifetime of
+ * a display config object.
+ * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in
+ * which case the output arguments are unmodified.
+ * Original signature : OSVR_ReturnCode osvrClientGetDisplayDimensions(OSVR_DisplayConfig, OSVR_DisplayInputCount, OSVR_DisplayDimension*, OSVR_DisplayDimension*)
+ * @deprecated use the safer method + * {@link #osvrClientGetDisplayDimensions(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, byte, java.nio.IntBuffer, java.nio.IntBuffer)} + * instead + */ + @Deprecated + public static native byte osvrClientGetDisplayDimensions(Pointer disp, byte displayInputIndex, IntByReference width, IntByReference height); + /** + * Retrieve the pixel dimensions of a given display input for a display
+ * config
+ * @param disp Display config object.
+ * @param displayInputIndex The zero-based index of the display input.
+ * @param width Width (in pixels) of the display input.
+ * @param height Height (in pixels) of the display input.
+ * The out parameters are **constant** throughout the active, valid lifetime of
+ * a display config object.
+ * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in
+ * which case the output arguments are unmodified.
+ * Original signature : OSVR_ReturnCode osvrClientGetDisplayDimensions(OSVR_DisplayConfig, OSVR_DisplayInputCount, OSVR_DisplayDimension*, OSVR_DisplayDimension*) + */ + public static native byte osvrClientGetDisplayDimensions(OsvrDisplayLibrary.OSVR_DisplayConfig disp, byte displayInputIndex, IntBuffer width, IntBuffer height); + /** + * A display config can have one (or theoretically more) viewers:
+ * retrieve the viewer count.
+ * @param disp Display config object.
+ * @param viewers Number of viewers in the logical display topology,
+ * *constant** throughout the active, valid lifetime of a display config
+ * object.
+ * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case
+ * the output argument is unmodified.
+ * Original signature : OSVR_ReturnCode osvrClientGetNumViewers(OSVR_DisplayConfig, OSVR_ViewerCount*)
+ * @deprecated use the safer method + * {@link #osvrClientGetNumViewers(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, java.nio.IntBuffer)} + * instead + */ + @Deprecated + public static native byte osvrClientGetNumViewers(Pointer disp, IntByReference viewers); + /** + * A display config can have one (or theoretically more) viewers:
+ * retrieve the viewer count.
+ * @param disp Display config object.
+ * @param viewers Number of viewers in the logical display topology,
+ * *constant** throughout the active, valid lifetime of a display config
+ * object.
+ * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case
+ * the output argument is unmodified.
+ * Original signature : OSVR_ReturnCode osvrClientGetNumViewers(OSVR_DisplayConfig, OSVR_ViewerCount*) + */ + public static native byte osvrClientGetNumViewers(OsvrDisplayLibrary.OSVR_DisplayConfig disp, IntBuffer viewers); + /** + * Get the pose of a viewer in a display config.
+ * Note that there may not necessarily be any surfaces rendered from this pose
+ * (it's the unused "center" eye in a stereo configuration, for instance) so
+ * only use this if it makes integration into your engine or existing
+ * applications (not originally designed for stereo) easier.
+ * Will only succeed if osvrClientCheckDisplayStartup() succeeds.
+ * @return OSVR_RETURN_FAILURE if invalid parameters were passed or no pose was
+ * yet available, in which case the pose argument is unmodified.
+ * Original signature : OSVR_ReturnCode osvrClientGetViewerPose(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_Pose3*)
+ * @deprecated use the safer method + * {@link #osvrClientGetViewerPose(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, com.sun.jna.Pointer)} + * instead + */ + @Deprecated + public static native byte osvrClientGetViewerPose(Pointer disp, int viewer, Pointer pose); + /** + * Get the pose of a viewer in a display config.
+ * Note that there may not necessarily be any surfaces rendered from this pose
+ * (it's the unused "center" eye in a stereo configuration, for instance) so
+ * only use this if it makes integration into your engine or existing
+ * applications (not originally designed for stereo) easier.
+ * Will only succeed if osvrClientCheckDisplayStartup() succeeds.
+ * @return OSVR_RETURN_FAILURE if invalid parameters were passed or no pose was
+ * yet available, in which case the pose argument is unmodified.
+ * Original signature : OSVR_ReturnCode osvrClientGetViewerPose(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_Pose3*) + */ + public static native byte osvrClientGetViewerPose(OsvrDisplayLibrary.OSVR_DisplayConfig disp, int viewer, Pointer pose); + /** + * Each viewer in a display config can have one or more "eyes" which
+ * have a substantially similar pose: get the count.
+ * @param disp Display config object.
+ * @param viewer Viewer ID
+ * @param eyes Number of eyes for this viewer in the logical display
+ * topology, **constant** throughout the active, valid lifetime of a display
+ * config object
+ * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case
+ * the output argument is unmodified.
+ * Original signature : OSVR_ReturnCode osvrClientGetNumEyesForViewer(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount*)
+ * @deprecated use the safer method + * {@link #osvrClientGetNumEyesForViewer(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, java.nio.ByteBuffer)} + * instead + */ + @Deprecated + public static native byte osvrClientGetNumEyesForViewer(Pointer disp, int viewer, Pointer eyes); + /** + * Each viewer in a display config can have one or more "eyes" which
+ * have a substantially similar pose: get the count.
+ * @param disp Display config object.
+ * @param viewer Viewer ID
+ * @param eyes Number of eyes for this viewer in the logical display
+ * topology, **constant** throughout the active, valid lifetime of a display
+ * config object
+ * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case
+ * the output argument is unmodified.
+ * Original signature : OSVR_ReturnCode osvrClientGetNumEyesForViewer(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount*) + */ + public static native byte osvrClientGetNumEyesForViewer(OsvrDisplayLibrary.OSVR_DisplayConfig disp, int viewer, ByteBuffer eyes); + /** + * Get the "viewpoint" for the given eye of a viewer in a display
+ * config.
+ * Will only succeed if osvrClientCheckDisplayStartup() succeeds.
+ * @param disp Display config object
+ * @param viewer Viewer ID
+ * @param eye Eye ID
+ * @param pose Room-space pose (not relative to pose of the viewer)
+ * @return OSVR_RETURN_FAILURE if invalid parameters were passed or no pose was
+ * yet available, in which case the pose argument is unmodified.
+ * Original signature : OSVR_ReturnCode osvrClientGetViewerEyePose(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_Pose3*)
+ * @deprecated use the safer method + * {@link #osvrClientGetViewerEyePose(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, byte, com.sun.jna.Pointer)} + * instead + */ + @Deprecated + public static native byte osvrClientGetViewerEyePose(Pointer disp, int viewer, byte eye, Pointer pose); + /** + * Get the "viewpoint" for the given eye of a viewer in a display
+ * config.
+ * Will only succeed if osvrClientCheckDisplayStartup() succeeds.
+ * @param disp Display config object
+ * @param viewer Viewer ID
+ * @param eye Eye ID
+ * @param pose Room-space pose (not relative to pose of the viewer)
+ * @return OSVR_RETURN_FAILURE if invalid parameters were passed or no pose was
+ * yet available, in which case the pose argument is unmodified.
+ * Original signature : OSVR_ReturnCode osvrClientGetViewerEyePose(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_Pose3*) + */ + public static native byte osvrClientGetViewerEyePose(OsvrDisplayLibrary.OSVR_DisplayConfig disp, int viewer, byte eye, Pointer pose); + /** + * Get the view matrix (inverse of pose) for the given eye of a
+ * viewer in a display config - matrix of **doubles**.
+ * Will only succeed if osvrClientCheckDisplayStartup() succeeds.
+ * @param disp Display config object
+ * @param viewer Viewer ID
+ * @param eye Eye ID
+ * @param flags Bitwise OR of matrix convention flags (see @ref MatrixFlags)
+ * @param mat Pass a double[::OSVR_MATRIX_SIZE] to get the transformation
+ * matrix from room space to eye space (not relative to pose of the viewer)
+ * @return OSVR_RETURN_FAILURE if invalid parameters were passed or no pose was
+ * yet available, in which case the output argument is unmodified.
+ * Original signature : OSVR_ReturnCode osvrClientGetViewerEyeViewMatrixd(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_MatrixConventions, double*)
+ * @deprecated use the safer method + * {@link #osvrClientGetViewerEyeViewMatrixd(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, byte, short, java.nio.DoubleBuffer)} + * instead + */ + @Deprecated + public static native byte osvrClientGetViewerEyeViewMatrixd(Pointer disp, int viewer, byte eye, short flags, DoubleByReference mat); + /** + * Get the view matrix (inverse of pose) for the given eye of a
+ * viewer in a display config - matrix of **doubles**.
+ * Will only succeed if osvrClientCheckDisplayStartup() succeeds.
+ * @param disp Display config object
+ * @param viewer Viewer ID
+ * @param eye Eye ID
+ * @param flags Bitwise OR of matrix convention flags (see @ref MatrixFlags)
+ * @param mat Pass a double[::OSVR_MATRIX_SIZE] to get the transformation
+ * matrix from room space to eye space (not relative to pose of the viewer)
+ * @return OSVR_RETURN_FAILURE if invalid parameters were passed or no pose was
+ * yet available, in which case the output argument is unmodified.
+ * Original signature : OSVR_ReturnCode osvrClientGetViewerEyeViewMatrixd(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_MatrixConventions, double*) + */ + public static native byte osvrClientGetViewerEyeViewMatrixd(OsvrDisplayLibrary.OSVR_DisplayConfig disp, int viewer, byte eye, short flags, DoubleBuffer mat); + /** + * Get the view matrix (inverse of pose) for the given eye of a
+ * viewer in a display config - matrix of **floats**.
+ * Will only succeed if osvrClientCheckDisplayStartup() succeeds.
+ * @param disp Display config object
+ * @param viewer Viewer ID
+ * @param eye Eye ID
+ * @param flags Bitwise OR of matrix convention flags (see @ref MatrixFlags)
+ * @param mat Pass a float[::OSVR_MATRIX_SIZE] to get the transformation
+ * matrix from room space to eye space (not relative to pose of the viewer)
+ * @return OSVR_RETURN_FAILURE if invalid parameters were passed or no pose was
+ * yet available, in which case the output argument is unmodified.
+ * Original signature : OSVR_ReturnCode osvrClientGetViewerEyeViewMatrixf(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_MatrixConventions, float*)
+ * @deprecated use the safer method + * {@link #osvrClientGetViewerEyeViewMatrixf(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, byte, short, java.nio.FloatBuffer)} + * instead + */ + @Deprecated + public static native byte osvrClientGetViewerEyeViewMatrixf(Pointer disp, int viewer, byte eye, short flags, FloatByReference mat); + /** + * Get the view matrix (inverse of pose) for the given eye of a
+ * viewer in a display config - matrix of **floats**.
+ * Will only succeed if osvrClientCheckDisplayStartup() succeeds.
+ * @param disp Display config object
+ * @param viewer Viewer ID
+ * @param eye Eye ID
+ * @param flags Bitwise OR of matrix convention flags (see @ref MatrixFlags)
+ * @param mat Pass a float[::OSVR_MATRIX_SIZE] to get the transformation
+ * matrix from room space to eye space (not relative to pose of the viewer)
+ * @return OSVR_RETURN_FAILURE if invalid parameters were passed or no pose was
+ * yet available, in which case the output argument is unmodified.
+ * Original signature : OSVR_ReturnCode osvrClientGetViewerEyeViewMatrixf(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_MatrixConventions, float*) + */ + public static native byte osvrClientGetViewerEyeViewMatrixf(OsvrDisplayLibrary.OSVR_DisplayConfig disp, int viewer, byte eye, short flags, FloatBuffer mat); + /** + * Each eye of each viewer in a display config has one or more surfaces
+ * (aka "screens") on which content should be rendered.
+ * @param disp Display config object
+ * @param viewer Viewer ID
+ * @param eye Eye ID
+ * @param surfaces Number of surfaces (numbered [0, surfaces - 1]) for the
+ * given viewer and eye. **Constant** throughout the active, valid lifetime of
+ * a display config object.
+ * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case
+ * the output argument is unmodified.
+ * Original signature : OSVR_ReturnCode osvrClientGetNumSurfacesForViewerEye(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_SurfaceCount*)
+ * @deprecated use the safer method + * {@link #osvrClientGetNumSurfacesForViewerEye(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, byte, java.nio.IntBuffer)} + * instead + */ + @Deprecated + public static native byte osvrClientGetNumSurfacesForViewerEye(Pointer disp, int viewer, byte eye, IntByReference surfaces); + /** + * Each eye of each viewer in a display config has one or more surfaces
+ * (aka "screens") on which content should be rendered.
+ * @param disp Display config object
+ * @param viewer Viewer ID
+ * @param eye Eye ID
+ * @param surfaces Number of surfaces (numbered [0, surfaces - 1]) for the
+ * given viewer and eye. **Constant** throughout the active, valid lifetime of
+ * a display config object.
+ * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case
+ * the output argument is unmodified.
+ * Original signature : OSVR_ReturnCode osvrClientGetNumSurfacesForViewerEye(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_SurfaceCount*) + */ + public static native byte osvrClientGetNumSurfacesForViewerEye(OsvrDisplayLibrary.OSVR_DisplayConfig disp, int viewer, byte eye, IntBuffer surfaces); + /** + * Get the dimensions/location of the viewport **within the display
+ * input** for a surface seen by an eye of a viewer in a display config. (This
+ * does not include other video inputs that may be on a single virtual desktop,
+ * etc. or explicitly account for display configurations that use multiple
+ * video inputs. It does not necessarily indicate that a viewport in the sense
+ * of glViewport must be created with these parameters, though the parameter
+ * order matches for convenience.)
+ * @param disp Display config object
+ * @param viewer Viewer ID
+ * @param eye Eye ID
+ * @param surface Surface ID
+ * @param left Output: Distance in pixels from the left of the video input
+ * to the left of the viewport.
+ * @param bottom Output: Distance in pixels from the bottom of the video
+ * input to the bottom of the viewport.
+ * @param width Output: Width of viewport in pixels.
+ * @param height Output: Height of viewport in pixels.
+ * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case
+ * the output arguments are unmodified.
+ * Original signature : OSVR_ReturnCode osvrClientGetRelativeViewportForViewerEyeSurface(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_SurfaceCount, OSVR_ViewportDimension*, OSVR_ViewportDimension*, OSVR_ViewportDimension*, OSVR_ViewportDimension*)
+ * @deprecated use the safer method + * {@link #osvrClientGetRelativeViewportForViewerEyeSurface(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, byte, int, java.nio.IntBuffer, java.nio.IntBuffer, java.nio.IntBuffer, java.nio.IntBuffer)} + * instead + */ + @Deprecated + public static native byte osvrClientGetRelativeViewportForViewerEyeSurface(Pointer disp, int viewer, byte eye, int surface, IntByReference left, IntByReference bottom, IntByReference width, IntByReference height); + /** + * Get the dimensions/location of the viewport **within the display
+ * input** for a surface seen by an eye of a viewer in a display config. (This
+ * does not include other video inputs that may be on a single virtual desktop,
+ * etc. or explicitly account for display configurations that use multiple
+ * video inputs. It does not necessarily indicate that a viewport in the sense
+ * of glViewport must be created with these parameters, though the parameter
+ * order matches for convenience.)
+ * @param disp Display config object
+ * @param viewer Viewer ID
+ * @param eye Eye ID
+ * @param surface Surface ID
+ * @param left Output: Distance in pixels from the left of the video input
+ * to the left of the viewport.
+ * @param bottom Output: Distance in pixels from the bottom of the video
+ * input to the bottom of the viewport.
+ * @param width Output: Width of viewport in pixels.
+ * @param height Output: Height of viewport in pixels.
+ * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case
+ * the output arguments are unmodified.
+ * Original signature : OSVR_ReturnCode osvrClientGetRelativeViewportForViewerEyeSurface(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_SurfaceCount, OSVR_ViewportDimension*, OSVR_ViewportDimension*, OSVR_ViewportDimension*, OSVR_ViewportDimension*) + */ + public static native byte osvrClientGetRelativeViewportForViewerEyeSurface(OsvrDisplayLibrary.OSVR_DisplayConfig disp, int viewer, byte eye, int surface, IntBuffer left, IntBuffer bottom, IntBuffer width, IntBuffer height); + /** + * Get the index of the display input for a surface seen by an eye of a
+ * viewer in a display config.
+ * This is the OSVR-assigned display input: it may not (and in practice,
+ * usually will not) match any platform-specific display indices. This function
+ * exists to associate surfaces with video inputs as enumerated by
+ * osvrClientGetNumDisplayInputs().
+ * @param disp Display config object
+ * @param viewer Viewer ID
+ * @param eye Eye ID
+ * @param surface Surface ID
+ * @param displayInput Zero-based index of the display input pixels for
+ * this surface are transmitted over.
+ * This association is **constant** throughout the active, valid lifetime of a
+ * display config object.
+ * @see #osvrClientGetNumDisplayInputs(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, java.nio.ByteBuffer) + * @see #osvrClientGetRelativeViewportForViewerEyeSurface(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, byte, int, java.nio.IntBuffer, java.nio.IntBuffer, java.nio.IntBuffer, java.nio.IntBuffer) + * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which
+ * case the output argument is unmodified.
+ * Original signature : OSVR_ReturnCode osvrClientGetViewerEyeSurfaceDisplayInputIndex(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_SurfaceCount, OSVR_DisplayInputCount*)
+ * @deprecated use the safer method + * {@link #osvrClientGetViewerEyeSurfaceDisplayInputIndex(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, byte, int, java.nio.ByteBuffer)} + * instead + */ + @Deprecated + public static native byte osvrClientGetViewerEyeSurfaceDisplayInputIndex(Pointer disp, int viewer, byte eye, int surface, Pointer displayInput); + /** + * Get the index of the display input for a surface seen by an eye of a
+ * viewer in a display config.
+ * This is the OSVR-assigned display input: it may not (and in practice,
+ * usually will not) match any platform-specific display indices. This function
+ * exists to associate surfaces with video inputs as enumerated by
+ * osvrClientGetNumDisplayInputs().
+ * @param disp Display config object
+ * @param viewer Viewer ID
+ * @param eye Eye ID
+ * @param surface Surface ID
+ * @param displayInput Zero-based index of the display input pixels for
+ * this surface are transmitted over.
+ * This association is **constant** throughout the active, valid lifetime of a
+ * display config object.
+ * @see #osvrClientGetNumDisplayInputs(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, java.nio.ByteBuffer) + * @see #osvrClientGetRelativeViewportForViewerEyeSurface(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, byte, int, java.nio.IntBuffer, java.nio.IntBuffer, java.nio.IntBuffer, java.nio.IntBuffer) + * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which
+ * case the output argument is unmodified.
+ * Original signature : OSVR_ReturnCode osvrClientGetViewerEyeSurfaceDisplayInputIndex(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_SurfaceCount, OSVR_DisplayInputCount*) + */ + public static native byte osvrClientGetViewerEyeSurfaceDisplayInputIndex(OsvrDisplayLibrary.OSVR_DisplayConfig disp, int viewer, byte eye, int surface, ByteBuffer displayInput); + /** + * Get the projection matrix for a surface seen by an eye of a viewer
+ * in a display config. (double version)
+ * @param disp Display config object
+ * @param viewer Viewer ID
+ * @param eye Eye ID
+ * @param surface Surface ID
+ * @param near Distance from viewpoint to near clipping plane - must be
+ * positive.
+ * @param far Distance from viewpoint to far clipping plane - must be positive
+ * and not equal to near, typically greater than near.
+ * @param flags Bitwise OR of matrix convention flags (see @ref MatrixFlags)
+ * @param matrix Output projection matrix: supply an array of 16
+ * (::OSVR_MATRIX_SIZE) doubles.
+ * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case
+ * the output argument is unmodified.
+ * Original signature : OSVR_ReturnCode osvrClientGetViewerEyeSurfaceProjectionMatrixd(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_SurfaceCount, double, double, OSVR_MatrixConventions, double*)
+ * @deprecated use the safer method + * {@link #osvrClientGetViewerEyeSurfaceProjectionMatrixd(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, byte, int, double, double, short, java.nio.DoubleBuffer)} + * instead + */ + @Deprecated + public static native byte osvrClientGetViewerEyeSurfaceProjectionMatrixd(Pointer disp, int viewer, byte eye, int surface, double near, double far, short flags, DoubleByReference matrix); + /** + * Get the projection matrix for a surface seen by an eye of a viewer
+ * in a display config. (double version)
+ * @param disp Display config object
+ * @param viewer Viewer ID
+ * @param eye Eye ID
+ * @param surface Surface ID
+ * @param near Distance from viewpoint to near clipping plane - must be
+ * positive.
+ * @param far Distance from viewpoint to far clipping plane - must be positive
+ * and not equal to near, typically greater than near.
+ * @param flags Bitwise OR of matrix convention flags (see @ref MatrixFlags)
+ * @param matrix Output projection matrix: supply an array of 16
+ * (::OSVR_MATRIX_SIZE) doubles.
+ * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case
+ * the output argument is unmodified.
+ * Original signature : OSVR_ReturnCode osvrClientGetViewerEyeSurfaceProjectionMatrixd(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_SurfaceCount, double, double, OSVR_MatrixConventions, double*) + */ + public static native byte osvrClientGetViewerEyeSurfaceProjectionMatrixd(OsvrDisplayLibrary.OSVR_DisplayConfig disp, int viewer, byte eye, int surface, double near, double far, short flags, DoubleBuffer matrix); + /** + * Get the projection matrix for a surface seen by an eye of a viewer
+ * in a display config. (float version)
+ * @param disp Display config object
+ * @param viewer Viewer ID
+ * @param eye Eye ID
+ * @param surface Surface ID
+ * @param near Distance to near clipping plane - must be nonzero, typically
+ * positive.
+ * @param far Distance to far clipping plane - must be nonzero, typically
+ * positive and greater than near.
+ * @param flags Bitwise OR of matrix convention flags (see @ref MatrixFlags)
+ * @param matrix Output projection matrix: supply an array of 16
+ * (::OSVR_MATRIX_SIZE) floats.
+ * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case
+ * the output argument is unmodified.
+ * Original signature : OSVR_ReturnCode osvrClientGetViewerEyeSurfaceProjectionMatrixf(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_SurfaceCount, float, float, OSVR_MatrixConventions, float*)
+ * @deprecated use the safer method + * {@link #osvrClientGetViewerEyeSurfaceProjectionMatrixf(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, byte, int, float, float, short, java.nio.FloatBuffer)} + * instead + */ + @Deprecated + public static native byte osvrClientGetViewerEyeSurfaceProjectionMatrixf(Pointer disp, int viewer, byte eye, int surface, float near, float far, short flags, FloatByReference matrix); + /** + * Get the projection matrix for a surface seen by an eye of a viewer
+ * in a display config. (float version)
+ * @param disp Display config object
+ * @param viewer Viewer ID
+ * @param eye Eye ID
+ * @param surface Surface ID
+ * @param near Distance to near clipping plane - must be nonzero, typically
+ * positive.
+ * @param far Distance to far clipping plane - must be nonzero, typically
+ * positive and greater than near.
+ * @param flags Bitwise OR of matrix convention flags (see @ref MatrixFlags)
+ * @param matrix Output projection matrix: supply an array of 16
+ * (::OSVR_MATRIX_SIZE) floats.
+ * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case
+ * the output argument is unmodified.
+ * Original signature : OSVR_ReturnCode osvrClientGetViewerEyeSurfaceProjectionMatrixf(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_SurfaceCount, float, float, OSVR_MatrixConventions, float*) + */ + public static native byte osvrClientGetViewerEyeSurfaceProjectionMatrixf(OsvrDisplayLibrary.OSVR_DisplayConfig disp, int viewer, byte eye, int surface, float near, float far, short flags, FloatBuffer matrix); + /** + * Get the clipping planes (positions at unit distance) for a surface
+ * seen by an eye of a viewer
+ * in a display config.
+ * This is only for use in integrations that cannot accept a fully-formulated
+ * projection matrix as returned by
+ * osvrClientGetViewerEyeSurfaceProjectionMatrixf() or
+ * osvrClientGetViewerEyeSurfaceProjectionMatrixd(), and may not necessarily
+ * provide the same optimizations.
+ * As all the planes are given at unit (1) distance, before passing these
+ * planes to a consuming function in your application/engine, you will typically
+ * divide them by your near clipping plane distance.
+ * @param disp Display config object
+ * @param viewer Viewer ID
+ * @param eye Eye ID
+ * @param surface Surface ID
+ * @param left Distance to left clipping plane
+ * @param right Distance to right clipping plane
+ * @param bottom Distance to bottom clipping plane
+ * @param top Distance to top clipping plane
+ * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case
+ * the output arguments are unmodified.
+ * Original signature : OSVR_ReturnCode osvrClientGetViewerEyeSurfaceProjectionClippingPlanes(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_SurfaceCount, double*, double*, double*, double*)
+ * @deprecated use the safer method + * {@link #osvrClientGetViewerEyeSurfaceProjectionClippingPlanes(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, byte, int, java.nio.DoubleBuffer, java.nio.DoubleBuffer, java.nio.DoubleBuffer, java.nio.DoubleBuffer)} + * instead + */ + @Deprecated + public static native byte osvrClientGetViewerEyeSurfaceProjectionClippingPlanes(Pointer disp, int viewer, byte eye, int surface, DoubleByReference left, DoubleByReference right, DoubleByReference bottom, DoubleByReference top); + /** + * Get the clipping planes (positions at unit distance) for a surface
+ * seen by an eye of a viewer
+ * in a display config.
+ * This is only for use in integrations that cannot accept a fully-formulated
+ * projection matrix as returned by
+ * osvrClientGetViewerEyeSurfaceProjectionMatrixf() or
+ * osvrClientGetViewerEyeSurfaceProjectionMatrixd(), and may not necessarily
+ * provide the same optimizations.
+ * As all the planes are given at unit (1) distance, before passing these
+ * planes to a consuming function in your application/engine, you will typically
+ * divide them by your near clipping plane distance.
+ * @param disp Display config object
+ * @param viewer Viewer ID
+ * @param eye Eye ID
+ * @param surface Surface ID
+ * @param left Distance to left clipping plane
+ * @param right Distance to right clipping plane
+ * @param bottom Distance to bottom clipping plane
+ * @param top Distance to top clipping plane
+ * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case
+ * the output arguments are unmodified.
+ * Original signature : OSVR_ReturnCode osvrClientGetViewerEyeSurfaceProjectionClippingPlanes(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_SurfaceCount, double*, double*, double*, double*) + */ + public static native byte osvrClientGetViewerEyeSurfaceProjectionClippingPlanes(OsvrDisplayLibrary.OSVR_DisplayConfig disp, int viewer, byte eye, int surface, DoubleBuffer left, DoubleBuffer right, DoubleBuffer bottom, DoubleBuffer top); + /** + * Determines if a surface seen by an eye of a viewer in a display
+ * config requests some distortion to be performed.
+ * This simply reports true or false, and does not specify which kind of
+ * distortion implementations have been parameterized for this display. For
+ * each distortion implementation your application supports, you'll want to
+ * call the corresponding priority function to find out if it is available.
+ * @param disp Display config object
+ * @param viewer Viewer ID
+ * @param eye Eye ID
+ * @param surface Surface ID
+ * @param distortionRequested Output parameter: whether distortion is
+ * requested. **Constant** throughout the active, valid lifetime of a display
+ * config object.
+ * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case
+ * the output argument is unmodified.
+ * Original signature : OSVR_ReturnCode osvrClientDoesViewerEyeSurfaceWantDistortion(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_SurfaceCount, OSVR_CBool*)
+ * @deprecated use the safer method + * {@link #osvrClientDoesViewerEyeSurfaceWantDistortion(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, byte, int, java.nio.ByteBuffer)} + * instead + */ + @Deprecated + public static native byte osvrClientDoesViewerEyeSurfaceWantDistortion(Pointer disp, int viewer, byte eye, int surface, Pointer distortionRequested); + /** + * Determines if a surface seen by an eye of a viewer in a display
+ * config requests some distortion to be performed.
+ * This simply reports true or false, and does not specify which kind of
+ * distortion implementations have been parameterized for this display. For
+ * each distortion implementation your application supports, you'll want to
+ * call the corresponding priority function to find out if it is available.
+ * @param disp Display config object
+ * @param viewer Viewer ID
+ * @param eye Eye ID
+ * @param surface Surface ID
+ * @param distortionRequested Output parameter: whether distortion is
+ * requested. **Constant** throughout the active, valid lifetime of a display
+ * config object.
+ * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case
+ * the output argument is unmodified.
+ * Original signature : OSVR_ReturnCode osvrClientDoesViewerEyeSurfaceWantDistortion(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_SurfaceCount, OSVR_CBool*) + */ + public static native byte osvrClientDoesViewerEyeSurfaceWantDistortion(OsvrDisplayLibrary.OSVR_DisplayConfig disp, int viewer, byte eye, int surface, ByteBuffer distortionRequested); + /** + * Returns the priority/availability of radial distortion parameters for
+ * a surface seen by an eye of a viewer in a display config.
+ * If osvrClientDoesViewerEyeSurfaceWantDistortion() reports false, then the
+ * display does not request distortion of any sort, and thus neither this nor
+ * any other distortion strategy priority function will report an "available"
+ * priority.
+ * @param disp Display config object
+ * @param viewer Viewer ID
+ * @param eye Eye ID
+ * @param surface Surface ID
+ * @param priority Output: the priority level. Negative values
+ * (canonically OSVR_DISTORTION_PRIORITY_UNAVAILABLE) indicate this technique
+ * not available, higher values indicate higher preference for the given
+ * technique based on the device's description. **Constant** throughout the
+ * active, valid lifetime of a display config object.
+ * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case
+ * the output argument is unmodified.
+ * Original signature : OSVR_ReturnCode osvrClientGetViewerEyeSurfaceRadialDistortionPriority(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_SurfaceCount, OSVR_DistortionPriority*)
+ * @deprecated use the safer method + * {@link #osvrClientGetViewerEyeSurfaceRadialDistortionPriority(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, byte, int, java.nio.IntBuffer)} + * instead + */ + @Deprecated + public static native byte osvrClientGetViewerEyeSurfaceRadialDistortionPriority(Pointer disp, int viewer, byte eye, int surface, IntByReference priority); + /** + * Returns the priority/availability of radial distortion parameters for
+ * a surface seen by an eye of a viewer in a display config.
+ * If osvrClientDoesViewerEyeSurfaceWantDistortion() reports false, then the
+ * display does not request distortion of any sort, and thus neither this nor
+ * any other distortion strategy priority function will report an "available"
+ * priority.
+ * @param disp Display config object
+ * @param viewer Viewer ID
+ * @param eye Eye ID
+ * @param surface Surface ID
+ * @param priority Output: the priority level. Negative values
+ * (canonically OSVR_DISTORTION_PRIORITY_UNAVAILABLE) indicate this technique
+ * not available, higher values indicate higher preference for the given
+ * technique based on the device's description. **Constant** throughout the
+ * active, valid lifetime of a display config object.
+ * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case
+ * the output argument is unmodified.
+ * Original signature : OSVR_ReturnCode osvrClientGetViewerEyeSurfaceRadialDistortionPriority(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_SurfaceCount, OSVR_DistortionPriority*) + */ + public static native byte osvrClientGetViewerEyeSurfaceRadialDistortionPriority(OsvrDisplayLibrary.OSVR_DisplayConfig disp, int viewer, byte eye, int surface, IntBuffer priority); + /** + * Returns the radial distortion parameters, if known/requested, for a
+ * surface seen by an eye of a viewer in a display config.
+ * Will only succeed if osvrClientGetViewerEyeSurfaceRadialDistortionPriority()
+ * reports a non-negative priority.
+ * @param disp Display config object
+ * @param viewer Viewer ID
+ * @param eye Eye ID
+ * @param surface Surface ID
+ * @param params Output: the parameters for radial distortion
+ * @return OSVR_RETURN_FAILURE if this surface does not have these parameters
+ * described, or if invalid parameters were passed, in which case the output
+ * argument is unmodified.
+ * Original signature : OSVR_ReturnCode osvrClientGetViewerEyeSurfaceRadialDistortion(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_SurfaceCount, OSVR_RadialDistortionParameters*)
+ * @deprecated use the safer method + * {@link #osvrClientGetViewerEyeSurfaceRadialDistortion(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, byte, int, com.sun.jna.Pointer)} + * instead + */ + @Deprecated + public static native byte osvrClientGetViewerEyeSurfaceRadialDistortion(Pointer disp, int viewer, byte eye, int surface, Pointer params); + /** + * Returns the radial distortion parameters, if known/requested, for a
+ * surface seen by an eye of a viewer in a display config.
+ * Will only succeed if osvrClientGetViewerEyeSurfaceRadialDistortionPriority()
+ * reports a non-negative priority.
+ * @param disp Display config object
+ * @param viewer Viewer ID
+ * @param eye Eye ID
+ * @param surface Surface ID
+ * @param params Output: the parameters for radial distortion
+ * @return OSVR_RETURN_FAILURE if this surface does not have these parameters
+ * described, or if invalid parameters were passed, in which case the output
+ * argument is unmodified.
+ * Original signature : OSVR_ReturnCode osvrClientGetViewerEyeSurfaceRadialDistortion(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_SurfaceCount, OSVR_RadialDistortionParameters*) + */ + public static native byte osvrClientGetViewerEyeSurfaceRadialDistortion(OsvrDisplayLibrary.OSVR_DisplayConfig disp, int viewer, byte eye, int surface, Pointer params); + public static class OSVR_ClientContext extends PointerType { + public OSVR_ClientContext(Pointer address) { + super(address); + } + public OSVR_ClientContext() { + super(); + } + }; + public static class OSVR_DisplayConfig extends PointerType { + public OSVR_DisplayConfig(Pointer address) { + super(address); + } + public OSVR_DisplayConfig() { + super(); + } + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrinterface/OsvrInterfaceLibrary.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrinterface/OsvrInterfaceLibrary.java new file mode 100644 index 0000000000..2a1c69476f --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrinterface/OsvrInterfaceLibrary.java @@ -0,0 +1,24 @@ +package com.jme3.system.osvr.osvrinterface; +import com.jme3.system.osvr.osvrclientkit.OsvrClientKitLibrary.OSVR_ClientInterface; +import com.jme3.system.osvr.osvrclientreporttypes.OSVR_Pose3; +import com.jme3.system.osvr.osvrtimevalue.OSVR_TimeValue; +import com.sun.jna.Library; +import com.sun.jna.Native; +import com.sun.jna.NativeLibrary; +/** + * JNA Wrapper for library osvrInterface
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class OsvrInterfaceLibrary implements Library { + public static final String JNA_LIBRARY_NAME = "osvrClientKit"; + public static final NativeLibrary JNA_NATIVE_LIB = NativeLibrary.getInstance(OsvrInterfaceLibrary.JNA_LIBRARY_NAME); + static { + Native.register(OsvrInterfaceLibrary.class, OsvrInterfaceLibrary.JNA_NATIVE_LIB); + } + + /** Manually added */ + public static native byte osvrGetPoseState(OSVR_ClientInterface iface, OSVR_TimeValue timestamp, OSVR_Pose3 state); + +} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrmatrixconventions/OSVR_Pose3.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrmatrixconventions/OSVR_Pose3.java new file mode 100644 index 0000000000..8ec8f7cfa4 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrmatrixconventions/OSVR_Pose3.java @@ -0,0 +1,41 @@ +package com.jme3.system.osvr.osvrmatrixconventions; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class OSVR_Pose3 extends Structure { + /** C type : OSVR_Vec3 */ + public OSVR_Vec3 translation; + /** C type : OSVR_Quaternion */ + public OSVR_Quaternion rotation; + public OSVR_Pose3() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("translation", "rotation"); + } + /** + * @param translation C type : OSVR_Vec3
+ * @param rotation C type : OSVR_Quaternion + */ + public OSVR_Pose3(OSVR_Vec3 translation, OSVR_Quaternion rotation) { + super(); + this.translation = translation; + this.rotation = rotation; + } + public OSVR_Pose3(Pointer peer) { + super(peer); + } + public static class ByReference extends OSVR_Pose3 implements Structure.ByReference { + + }; + public static class ByValue extends OSVR_Pose3 implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrmatrixconventions/OSVR_Quaternion.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrmatrixconventions/OSVR_Quaternion.java new file mode 100644 index 0000000000..4627040206 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrmatrixconventions/OSVR_Quaternion.java @@ -0,0 +1,37 @@ +package com.jme3.system.osvr.osvrmatrixconventions; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class OSVR_Quaternion extends Structure { + /** C type : double[4] */ + public double[] data = new double[4]; + public OSVR_Quaternion() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("data"); + } + /** @param data C type : double[4] */ + public OSVR_Quaternion(double data[]) { + super(); + if ((data.length != this.data.length)) + throw new IllegalArgumentException("Wrong array size !"); + this.data = data; + } + public OSVR_Quaternion(Pointer peer) { + super(peer); + } + public static class ByReference extends OSVR_Quaternion implements Structure.ByReference { + + }; + public static class ByValue extends OSVR_Quaternion implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrmatrixconventions/OSVR_Vec3.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrmatrixconventions/OSVR_Vec3.java new file mode 100644 index 0000000000..7aa44a9793 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrmatrixconventions/OSVR_Vec3.java @@ -0,0 +1,37 @@ +package com.jme3.system.osvr.osvrmatrixconventions; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class OSVR_Vec3 extends Structure { + /** C type : double[3] */ + public double[] data = new double[3]; + public OSVR_Vec3() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("data"); + } + /** @param data C type : double[3] */ + public OSVR_Vec3(double data[]) { + super(); + if ((data.length != this.data.length)) + throw new IllegalArgumentException("Wrong array size !"); + this.data = data; + } + public OSVR_Vec3(Pointer peer) { + super(peer); + } + public static class ByReference extends OSVR_Vec3 implements Structure.ByReference { + + }; + public static class ByValue extends OSVR_Vec3 implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrmatrixconventions/OsvrMatrixConventionsLibrary.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrmatrixconventions/OsvrMatrixConventionsLibrary.java new file mode 100644 index 0000000000..384dd827ce --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrmatrixconventions/OsvrMatrixConventionsLibrary.java @@ -0,0 +1,192 @@ +package com.jme3.system.osvr.osvrmatrixconventions; +import com.sun.jna.Library; +import com.sun.jna.Native; +import com.sun.jna.NativeLibrary; +import com.sun.jna.Pointer; +import com.sun.jna.PointerType; +import com.sun.jna.ptr.DoubleByReference; +import com.sun.jna.ptr.FloatByReference; +import java.nio.DoubleBuffer; +import java.nio.FloatBuffer; +/** + * JNA Wrapper for library osvrMatrixConventions
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class OsvrMatrixConventionsLibrary implements Library { + public static final String JNA_LIBRARY_NAME = "osvrUtil"; + public static final NativeLibrary JNA_NATIVE_LIB = NativeLibrary.getInstance(OsvrMatrixConventionsLibrary.JNA_LIBRARY_NAME); + static { + Native.register(OsvrMatrixConventionsLibrary.class, OsvrMatrixConventionsLibrary.JNA_NATIVE_LIB); + } + /** enum values */ + public static interface OSVR_MatrixMasks { + public static final int OSVR_MATRIX_MASK_ROWMAJOR = 0x1; + public static final int OSVR_MATRIX_MASK_ROWVECTORS = 0x2; + public static final int OSVR_MATRIX_MASK_LHINPUT = 0x4; + public static final int OSVR_MATRIX_MASK_UNSIGNEDZ = 0x8; + }; + /** enum values */ + public static interface OSVR_MatrixOrderingFlags { + public static final int OSVR_MATRIX_COLMAJOR = 0x0; + public static final int OSVR_MATRIX_ROWMAJOR = OsvrMatrixConventionsLibrary.OSVR_MatrixMasks.OSVR_MATRIX_MASK_ROWMAJOR; + }; + /** enum values */ + public static interface OSVR_MatrixVectorFlags { + public static final int OSVR_MATRIX_COLVECTORS = 0x0; + public static final int OSVR_MATRIX_ROWVECTORS = OsvrMatrixConventionsLibrary.OSVR_MatrixMasks.OSVR_MATRIX_MASK_ROWVECTORS; + }; + /** enum values */ + public static interface OSVR_ProjectionMatrixInputFlags { + public static final int OSVR_MATRIX_RHINPUT = 0x0; + public static final int OSVR_MATRIX_LHINPUT = OsvrMatrixConventionsLibrary.OSVR_MatrixMasks.OSVR_MATRIX_MASK_LHINPUT; + }; + /** enum values */ + public static interface OSVR_ProjectionMatrixZFlags { + public static final int OSVR_MATRIX_SIGNEDZ = 0x0; + public static final int OSVR_MATRIX_UNSIGNEDZ = OsvrMatrixConventionsLibrary.OSVR_MatrixMasks.OSVR_MATRIX_MASK_UNSIGNEDZ; + }; + public static final int OSVR_MATRIX_SIZE = 16; + public static final int OSVR_RETURN_SUCCESS = 0; + public static final int OSVR_RETURN_FAILURE = 1; + /** Original signature : double osvrVec3GetX(const OSVR_Vec3*) */ + public static native double osvrVec3GetX(OSVR_Vec3 v); + /** Original signature : void osvrVec3SetX(OSVR_Vec3*, double) */ + public static native void osvrVec3SetX(OSVR_Vec3 v, double val); + /** Original signature : double osvrVec3GetY(const OSVR_Vec3*) */ + public static native double osvrVec3GetY(OSVR_Vec3 v); + /** Original signature : void osvrVec3SetY(OSVR_Vec3*, double) */ + public static native void osvrVec3SetY(OSVR_Vec3 v, double val); + /** Original signature : double osvrVec3GetZ(const OSVR_Vec3*) */ + public static native double osvrVec3GetZ(OSVR_Vec3 v); + /** Original signature : void osvrVec3SetZ(OSVR_Vec3*, double) */ + public static native void osvrVec3SetZ(OSVR_Vec3 v, double val); + /** + * Set a Vec3 to the zero vector
+ * Original signature : void osvrVec3Zero(OSVR_Vec3*) + */ + public static native void osvrVec3Zero(OSVR_Vec3 v); + /** Original signature : double osvrQuatGetW(const OSVR_Quaternion*) */ + public static native double osvrQuatGetW(OSVR_Quaternion q); + /** Original signature : void osvrQuatSetW(OSVR_Quaternion*, double) */ + public static native void osvrQuatSetW(OSVR_Quaternion q, double val); + /** Original signature : double osvrQuatGetX(const OSVR_Quaternion*) */ + public static native double osvrQuatGetX(OSVR_Quaternion q); + /** Original signature : void osvrQuatSetX(OSVR_Quaternion*, double) */ + public static native void osvrQuatSetX(OSVR_Quaternion q, double val); + /** Original signature : double osvrQuatGetY(const OSVR_Quaternion*) */ + public static native double osvrQuatGetY(OSVR_Quaternion q); + /** Original signature : void osvrQuatSetY(OSVR_Quaternion*, double) */ + public static native void osvrQuatSetY(OSVR_Quaternion q, double val); + /** Original signature : double osvrQuatGetZ(const OSVR_Quaternion*) */ + public static native double osvrQuatGetZ(OSVR_Quaternion q); + /** Original signature : void osvrQuatSetZ(OSVR_Quaternion*, double) */ + public static native void osvrQuatSetZ(OSVR_Quaternion q, double val); + /** + * Set a quaternion to the identity rotation
+ * Original signature : void osvrQuatSetIdentity(OSVR_Quaternion*) + */ + public static native void osvrQuatSetIdentity(OSVR_Quaternion q); + /** + * Set a pose to identity
+ * Original signature : void osvrPose3SetIdentity(OSVR_Pose3*) + */ + public static native void osvrPose3SetIdentity(OSVR_Pose3 pose); + /** + * Set a matrix of doubles based on a Pose3.
+ * @param pose The Pose3 to convert
+ * @param flags Memory ordering flag - see @ref MatrixFlags
+ * @param mat an array of 16 doubles
+ * Original signature : OSVR_ReturnCode osvrPose3ToMatrixd(const OSVR_Pose3*, OSVR_MatrixConventions, double*)
+ * @deprecated use the safer method + * {@link #osvrPose3ToMatrixd(com.jme3.system.osvr.osvrmatrixconventions.OSVR_Pose3, short, java.nio.DoubleBuffer)} + * instead + */ + @Deprecated + public static native byte osvrPose3ToMatrixd(OSVR_Pose3 pose, short flags, DoubleByReference mat); + /** + * Set a matrix of doubles based on a Pose3.
+ * @param pose The Pose3 to convert
+ * @param flags Memory ordering flag - see @ref MatrixFlags
+ * @param mat an array of 16 doubles
+ * Original signature : OSVR_ReturnCode osvrPose3ToMatrixd(const OSVR_Pose3*, OSVR_MatrixConventions, double*) + */ + public static native byte osvrPose3ToMatrixd(OSVR_Pose3 pose, short flags, DoubleBuffer mat); + /** + * Set a matrix of floats based on a Pose3.
+ * @param pose The Pose3 to convert
+ * @param flags Memory ordering flag - see @ref MatrixFlags
+ * @param mat an array of 16 floats
+ * Original signature : OSVR_ReturnCode osvrPose3ToMatrixf(const OSVR_Pose3*, OSVR_MatrixConventions, float*)
+ * @deprecated use the safer method + * {@link #osvrPose3ToMatrixf(com.jme3.system.osvr.osvrmatrixconventions.OSVR_Pose3, short, java.nio.FloatBuffer)} + * instead + */ + @Deprecated + public static native byte osvrPose3ToMatrixf(OSVR_Pose3 pose, short flags, FloatByReference mat); + /** + * Set a matrix of floats based on a Pose3.
+ * @param pose The Pose3 to convert
+ * @param flags Memory ordering flag - see @ref MatrixFlags
+ * @param mat an array of 16 floats
+ * Original signature : OSVR_ReturnCode osvrPose3ToMatrixf(const OSVR_Pose3*, OSVR_MatrixConventions, float*) + */ + public static native byte osvrPose3ToMatrixf(OSVR_Pose3 pose, short flags, FloatBuffer mat); + /** + * Set a matrix based on a Pose3. (C++-only overload - detecting scalar
+ * type)
+ * Original signature : OSVR_ReturnCode osvrPose3ToMatrix(const OSVR_Pose3*, OSVR_MatrixConventions, double*)
+ * @deprecated use the safer method + * {@link #osvrPose3ToMatrix(com.jme3.system.osvr.osvrmatrixconventions.OSVR_Pose3, short, java.nio.DoubleBuffer)} + * instead + */ + @Deprecated + public static native byte osvrPose3ToMatrix(OSVR_Pose3 pose, short flags, DoubleByReference mat); + /** + * Set a matrix based on a Pose3. (C++-only overload - detecting scalar
+ * type)
+ * Original signature : OSVR_ReturnCode osvrPose3ToMatrix(const OSVR_Pose3*, OSVR_MatrixConventions, double*) + */ + public static native byte osvrPose3ToMatrix(OSVR_Pose3 pose, short flags, DoubleBuffer mat); + /** + * Set a matrix based on a Pose3. (C++-only overload - detecting scalar
+ * type)
+ * Original signature : OSVR_ReturnCode osvrPose3ToMatrix(const OSVR_Pose3*, OSVR_MatrixConventions, float*)
+ * @deprecated use the safer method + * {@link #osvrPose3ToMatrix(com.jme3.system.osvr.osvrmatrixconventions.OSVR_Pose3, short, java.nio.FloatBuffer)} + * instead + */ + @Deprecated + public static native byte osvrPose3ToMatrix(OSVR_Pose3 pose, short flags, FloatByReference mat); + /** + * Set a matrix based on a Pose3. (C++-only overload - detecting scalar
+ * type)
+ * Original signature : OSVR_ReturnCode osvrPose3ToMatrix(const OSVR_Pose3*, OSVR_MatrixConventions, float*) + */ + public static native byte osvrPose3ToMatrix(OSVR_Pose3 pose, short flags, FloatBuffer mat); + /** + * Set a matrix based on a Pose3. (C++-only overload - detects scalar
+ * and takes array rather than pointer)
+ * Original signature : OSVR_ReturnCode osvrPose3ToMatrix(const OSVR_Pose3*, OSVR_MatrixConventions, Scalar[OSVR_MATRIX_SIZE])
+ * @deprecated use the safer method + * {@link #osvrPose3ToMatrix(com.jme3.system.osvr.osvrmatrixconventions.OSVR_Pose3, short, java.nio.DoubleBuffer)} + * instead + */ + @Deprecated + public static native byte osvrPose3ToMatrix(OSVR_Pose3 pose, short flags, Pointer mat); + /** + * Set a matrix based on a Pose3. (C++-only overload - detects scalar
+ * and takes array rather than pointer)
+ * Original signature : OSVR_ReturnCode osvrPose3ToMatrix(const OSVR_Pose3*, OSVR_MatrixConventions, Scalar[OSVR_MATRIX_SIZE]) + */ + public static native byte osvrPose3ToMatrix(OSVR_Pose3 pose, short flags, OsvrMatrixConventionsLibrary.Scalar mat[]); + public static class Scalar extends PointerType { + public Scalar(Pointer address) { + super(address); + } + public Scalar() { + super(); + } + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanager/OSVR_ProjectionMatrix.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanager/OSVR_ProjectionMatrix.java new file mode 100644 index 0000000000..2ebeb8f2fe --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanager/OSVR_ProjectionMatrix.java @@ -0,0 +1,45 @@ +package com.jme3.system.osvr.osvrrendermanager; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class OSVR_ProjectionMatrix extends Structure { + public double left; + public double right; + public double top; + public double bottom; + /** Cannot name "near" because Visual Studio keyword */ + public double nearClip; + public double farClip; + public OSVR_ProjectionMatrix() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("left", "right", "top", "bottom", "nearClip", "farClip"); + } + /** @param nearClip Cannot name "near" because Visual Studio keyword */ + public OSVR_ProjectionMatrix(double left, double right, double top, double bottom, double nearClip, double farClip) { + super(); + this.left = left; + this.right = right; + this.top = top; + this.bottom = bottom; + this.nearClip = nearClip; + this.farClip = farClip; + } + public OSVR_ProjectionMatrix(Pointer peer) { + super(peer); + } + public static class ByReference extends OSVR_ProjectionMatrix implements Structure.ByReference { + + }; + public static class ByValue extends OSVR_ProjectionMatrix implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanager/OSVR_RGB.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanager/OSVR_RGB.java new file mode 100644 index 0000000000..4fca69fc4c --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanager/OSVR_RGB.java @@ -0,0 +1,37 @@ +package com.jme3.system.osvr.osvrrendermanager; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class OSVR_RGB extends Structure { + public float r; + public float g; + public float b; + public OSVR_RGB() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("r", "g", "b"); + } + public OSVR_RGB(float r, float g, float b) { + super(); + this.r = r; + this.g = g; + this.b = b; + } + public OSVR_RGB(Pointer peer) { + super(peer); + } + public static class ByReference extends OSVR_RGB implements Structure.ByReference { + + }; + public static class ByValue extends OSVR_RGB implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanager/OSVR_RenderParams.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanager/OSVR_RenderParams.java new file mode 100644 index 0000000000..ea094d4f3e --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanager/OSVR_RenderParams.java @@ -0,0 +1,53 @@ +package com.jme3.system.osvr.osvrrendermanager; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class OSVR_RenderParams extends Structure { + /** + * Room space to insert
+ * C type : OSVR_PoseState* + */ + public Pointer worldFromRoomAppend; + /** + * Overrides head space
+ * C type : OSVR_PoseState* + */ + public Pointer roomFromHeadReplace; + public double nearClipDistanceMeters; + public double farClipDistanceMeters; + public OSVR_RenderParams() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("worldFromRoomAppend", "roomFromHeadReplace", "nearClipDistanceMeters", "farClipDistanceMeters"); + } + /** + * @param worldFromRoomAppend Room space to insert
+ * C type : OSVR_PoseState*
+ * @param roomFromHeadReplace Overrides head space
+ * C type : OSVR_PoseState* + */ + public OSVR_RenderParams(Pointer worldFromRoomAppend, Pointer roomFromHeadReplace, double nearClipDistanceMeters, double farClipDistanceMeters) { + super(); + this.worldFromRoomAppend = worldFromRoomAppend; + this.roomFromHeadReplace = roomFromHeadReplace; + this.nearClipDistanceMeters = nearClipDistanceMeters; + this.farClipDistanceMeters = farClipDistanceMeters; + } + public OSVR_RenderParams(Pointer peer) { + super(peer); + } + public static class ByReference extends OSVR_RenderParams implements Structure.ByReference { + + }; + public static class ByValue extends OSVR_RenderParams implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanager/OSVR_ViewportDescription.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanager/OSVR_ViewportDescription.java new file mode 100644 index 0000000000..2e38658290 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanager/OSVR_ViewportDescription.java @@ -0,0 +1,49 @@ +package com.jme3.system.osvr.osvrrendermanager; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class OSVR_ViewportDescription extends Structure { + /** Left side of the viewport in pixels */ + public double left; + /** First pixel in the viewport at the bottom. */ + public double lower; + /** Last pixel in the viewport at the top */ + public double width; + /** Last pixel on the right of the viewport in pixels */ + public double height; + public OSVR_ViewportDescription() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("left", "lower", "width", "height"); + } + /** + * @param left Left side of the viewport in pixels
+ * @param lower First pixel in the viewport at the bottom.
+ * @param width Last pixel in the viewport at the top
+ * @param height Last pixel on the right of the viewport in pixels + */ + public OSVR_ViewportDescription(double left, double lower, double width, double height) { + super(); + this.left = left; + this.lower = lower; + this.width = width; + this.height = height; + } + public OSVR_ViewportDescription(Pointer peer) { + super(peer); + } + public static class ByReference extends OSVR_ViewportDescription implements Structure.ByReference { + + }; + public static class ByValue extends OSVR_ViewportDescription implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanager/OsvrRenderManagerLibrary.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanager/OsvrRenderManagerLibrary.java new file mode 100644 index 0000000000..649c222d26 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanager/OsvrRenderManagerLibrary.java @@ -0,0 +1,117 @@ +package com.jme3.system.osvr.osvrrendermanager; +import com.ochafik.lang.jnaerator.runtime.NativeSizeByReference; +import com.sun.jna.Library; +import com.sun.jna.Native; +import com.sun.jna.NativeLibrary; +import com.sun.jna.Pointer; +import com.sun.jna.ptr.DoubleByReference; +import com.sun.jna.ptr.FloatByReference; +import com.sun.jna.ptr.PointerByReference; +import java.nio.DoubleBuffer; +import java.nio.FloatBuffer; +/** + * JNA Wrapper for library osvrRenderManager
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class OsvrRenderManagerLibrary implements Library { + public static final String JNA_LIBRARY_NAME = "osvrRenderManager"; + public static final NativeLibrary JNA_NATIVE_LIB = NativeLibrary.getInstance(OsvrRenderManagerLibrary.JNA_LIBRARY_NAME); + static { + Native.register(OsvrRenderManagerLibrary.class, OsvrRenderManagerLibrary.JNA_NATIVE_LIB); + } + /** enum values */ + public static interface OSVR_OpenStatus { + public static final int OSVR_OPEN_STATUS_FAILURE = 0; + public static final int OSVR_OPEN_STATUS_PARTIAL = 1; + public static final int OSVR_OPEN_STATUS_COMPLETE = 2; + }; + /** + * todo OSVR_RenderTimingInfo. + * Original signature : OSVR_ReturnCode osvrDestroyRenderManager(OSVR_RenderManager) + */ + public static native byte osvrDestroyRenderManager(Pointer renderManager); + /** + * todo Make this actually cache, for now it does not.
+ * Original signature : OSVR_ReturnCode osvrRenderManagerGetNumRenderInfo(OSVR_RenderManager, OSVR_RenderParams, OSVR_RenderInfoCount*) + */ + public static native byte osvrRenderManagerGetNumRenderInfo(Pointer renderManager, OSVR_RenderParams.ByValue renderParams, NativeSizeByReference numRenderInfoOut); + /** Original signature : OSVR_ReturnCode osvrRenderManagerGetDoingOkay(OSVR_RenderManager) */ + public static native byte osvrRenderManagerGetDoingOkay(Pointer renderManager); + /** Original signature : OSVR_ReturnCode osvrRenderManagerGetDefaultRenderParams(OSVR_RenderParams*) */ + public static native byte osvrRenderManagerGetDefaultRenderParams(OSVR_RenderParams renderParamsOut); + /** + * must be registered before they are presented.
+ * Original signature : OSVR_ReturnCode osvrRenderManagerStartPresentRenderBuffers(OSVR_RenderManagerPresentState*) + */ + public static native byte osvrRenderManagerStartPresentRenderBuffers(PointerByReference presentStateOut); + /** + * buffers for a single frame. This sequence starts with the Start function.
+ * Original signature : OSVR_ReturnCode osvrRenderManagerFinishPresentRenderBuffers(OSVR_RenderManager, OSVR_RenderManagerPresentState, OSVR_RenderParams, OSVR_CBool) + */ + public static native byte osvrRenderManagerFinishPresentRenderBuffers(Pointer renderManager, Pointer presentState, OSVR_RenderParams.ByValue renderParams, byte shouldFlipY); + /** + * must be registered before they are presented.
+ * Original signature : OSVR_ReturnCode osvrRenderManagerStartRegisterRenderBuffers(OSVR_RenderManagerRegisterBufferState*) + */ + public static native byte osvrRenderManagerStartRegisterRenderBuffers(PointerByReference registerBufferStateOut); + /** + * buffers for a single frame. This sequence starts with the Start function.
+ * Original signature : OSVR_ReturnCode osvrRenderManagerFinishRegisterRenderBuffers(OSVR_RenderManager, OSVR_RenderManagerRegisterBufferState, OSVR_CBool) + */ + public static native byte osvrRenderManagerFinishRegisterRenderBuffers(Pointer renderManager, Pointer registerBufferState, byte appWillNotOverwriteBeforeNewPresent); + /** Original signature : OSVR_ReturnCode osvrRenderManagerPresentSolidColorf(OSVR_RenderManager, OSVR_RGB_FLOAT) */ + public static native byte osvrRenderManagerPresentSolidColorf(Pointer renderManager, com.jme3.system.osvr.osvrrendermanager.OSVR_RGB.ByValue rgb); + /** + * when you're done.
+ * Original signature : OSVR_ReturnCode osvrRenderManagerGetRenderInfoCollection(OSVR_RenderManager, OSVR_RenderParams, OSVR_RenderInfoCollection*) + */ + public static native byte osvrRenderManagerGetRenderInfoCollection(Pointer renderManager, OSVR_RenderParams.ByValue renderParams, PointerByReference renderInfoCollectionOut); + /** + * Releases the OSVR_RenderInfoCollection.
+ * Original signature : OSVR_ReturnCode osvrRenderManagerReleaseRenderInfoCollection(OSVR_RenderInfoCollection) + */ + public static native byte osvrRenderManagerReleaseRenderInfoCollection(Pointer renderInfoCollection); + /** + * Get the size of the OSVR_RenderInfoCollection.
+ * Original signature : OSVR_ReturnCode osvrRenderManagerGetNumRenderInfoInCollection(OSVR_RenderInfoCollection, OSVR_RenderInfoCount*) + */ + public static native byte osvrRenderManagerGetNumRenderInfoInCollection(Pointer renderInfoCollection, NativeSizeByReference countOut); + /** + * @return True on success, false on failure (null pointer).
+ * Original signature : OSVR_ReturnCode OSVR_Projection_to_OpenGL(double*, OSVR_ProjectionMatrix)
+ * @deprecated use the safer methods {@link #OSVR_Projection_to_OpenGL(java.nio.DoubleBuffer, com.jme3.system.osvr.osvrrendermanager.OSVR_ProjectionMatrix.ByValue)} and {@link #OSVR_Projection_to_OpenGL(com.sun.jna.ptr.DoubleByReference, com.jme3.system.osvr.osvrrendermanager.OSVR_ProjectionMatrix.ByValue)} instead + */ + @Deprecated + public static native byte OSVR_Projection_to_OpenGL(DoubleByReference OpenGL_out, com.jme3.system.osvr.osvrrendermanager.OSVR_ProjectionMatrix.ByValue projection_in); + /** + * @return True on success, false on failure (null pointer).
+ * Original signature : OSVR_ReturnCode OSVR_Projection_to_OpenGL(double*, OSVR_ProjectionMatrix) + */ + public static native byte OSVR_Projection_to_OpenGL(DoubleBuffer OpenGL_out, com.jme3.system.osvr.osvrrendermanager.OSVR_ProjectionMatrix.ByValue projection_in); + /** + * @return True on success, false on failure (null pointer).
+ * Original signature : OSVR_ReturnCode OSVR_Projection_to_D3D(float[16], OSVR_ProjectionMatrix)
+ * @deprecated use the safer methods {@link #OSVR_Projection_to_D3D(java.nio.FloatBuffer, com.jme3.system.osvr.osvrrendermanager.OSVR_ProjectionMatrix.ByValue)} and {@link #OSVR_Projection_to_D3D(com.sun.jna.ptr.FloatByReference, com.jme3.system.osvr.osvrrendermanager.OSVR_ProjectionMatrix.ByValue)} instead + */ + @Deprecated + public static native byte OSVR_Projection_to_D3D(FloatByReference D3D_out, com.jme3.system.osvr.osvrrendermanager.OSVR_ProjectionMatrix.ByValue projection_in); + /** + * @return True on success, false on failure (null pointer).
+ * Original signature : OSVR_ReturnCode OSVR_Projection_to_D3D(float[16], OSVR_ProjectionMatrix) + */ + public static native byte OSVR_Projection_to_D3D(FloatBuffer D3D_out, com.jme3.system.osvr.osvrrendermanager.OSVR_ProjectionMatrix.ByValue projection_in); + /** + * @return True on success, false on failure (null pointer).
+ * Original signature : OSVR_ReturnCode OSVR_Projection_to_Unreal(float[16], OSVR_ProjectionMatrix)
+ * @deprecated use the safer methods {@link #OSVR_Projection_to_Unreal(java.nio.FloatBuffer, com.jme3.system.osvr.osvrrendermanager.OSVR_ProjectionMatrix.ByValue)} and {@link #OSVR_Projection_to_Unreal(com.sun.jna.ptr.FloatByReference, com.jme3.system.osvr.osvrrendermanager.OSVR_ProjectionMatrix.ByValue)} instead + */ + @Deprecated + public static native byte OSVR_Projection_to_Unreal(FloatByReference Unreal_out, com.jme3.system.osvr.osvrrendermanager.OSVR_ProjectionMatrix.ByValue projection_in); + /** + * @return True on success, false on failure (null pointer).
+ * Original signature : OSVR_ReturnCode OSVR_Projection_to_Unreal(float[16], OSVR_ProjectionMatrix) + */ + public static native byte OSVR_Projection_to_Unreal(FloatBuffer Unreal_out, com.jme3.system.osvr.osvrrendermanager.OSVR_ProjectionMatrix.ByValue projection_in); +} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_GraphicsLibraryOpenGL.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_GraphicsLibraryOpenGL.java new file mode 100644 index 0000000000..f52a83387b --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_GraphicsLibraryOpenGL.java @@ -0,0 +1,35 @@ +package com.jme3.system.osvr.osvrrendermanageropengl; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class OSVR_GraphicsLibraryOpenGL extends Structure { + /** C type : const OSVR_OpenGLToolkitFunctions* */ + public com.jme3.system.osvr.osvrrendermanageropengl.OSVR_OpenGLToolkitFunctions.ByReference toolkit; + public OSVR_GraphicsLibraryOpenGL() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("toolkit"); + } + /** @param toolkit C type : const OSVR_OpenGLToolkitFunctions* */ + public OSVR_GraphicsLibraryOpenGL(com.jme3.system.osvr.osvrrendermanageropengl.OSVR_OpenGLToolkitFunctions.ByReference toolkit) { + super(); + this.toolkit = toolkit; + } + public OSVR_GraphicsLibraryOpenGL(Pointer peer) { + super(peer); + } + public static class ByReference extends OSVR_GraphicsLibraryOpenGL implements Structure.ByReference { + + }; + public static class ByValue extends OSVR_GraphicsLibraryOpenGL implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_OpenGLContextParams.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_OpenGLContextParams.java new file mode 100644 index 0000000000..185a2d5bb8 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_OpenGLContextParams.java @@ -0,0 +1,57 @@ +package com.jme3.system.osvr.osvrrendermanageropengl; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class OSVR_OpenGLContextParams extends Structure { + /** C type : const char* */ + public Pointer windowTitle; + /** C type : OSVR_CBool */ + public byte fullScreen; + public int width; + public int height; + public int xPos; + public int yPos; + public int bitsPerPixel; + public int numBuffers; + /** C type : OSVR_CBool */ + public byte visible; + public OSVR_OpenGLContextParams() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("windowTitle", "fullScreen", "width", "height", "xPos", "yPos", "bitsPerPixel", "numBuffers", "visible"); + } + /** + * @param windowTitle C type : const char*
+ * @param fullScreen C type : OSVR_CBool
+ * @param visible C type : OSVR_CBool + */ + public OSVR_OpenGLContextParams(Pointer windowTitle, byte fullScreen, int width, int height, int xPos, int yPos, int bitsPerPixel, int numBuffers, byte visible) { + super(); + this.windowTitle = windowTitle; + this.fullScreen = fullScreen; + this.width = width; + this.height = height; + this.xPos = xPos; + this.yPos = yPos; + this.bitsPerPixel = bitsPerPixel; + this.numBuffers = numBuffers; + this.visible = visible; + } + public OSVR_OpenGLContextParams(Pointer peer) { + super(peer); + } + public static class ByReference extends OSVR_OpenGLContextParams implements Structure.ByReference { + + }; + public static class ByValue extends OSVR_OpenGLContextParams implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_OpenGLToolkitFunctions.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_OpenGLToolkitFunctions.java new file mode 100644 index 0000000000..e32b3901f3 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_OpenGLToolkitFunctions.java @@ -0,0 +1,92 @@ +package com.jme3.system.osvr.osvrrendermanageropengl; +import com.ochafik.lang.jnaerator.runtime.NativeSize; +import com.sun.jna.Callback; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import com.sun.jna.ptr.IntByReference; +import java.util.Arrays; +import java.util.List; +/** + * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class OSVR_OpenGLToolkitFunctions extends Structure { + public NativeSize size; + /** C type : void* */ + public Pointer data; + /** C type : create_callback* */ + public OSVR_OpenGLToolkitFunctions.create_callback create; + /** C type : destroy_callback* */ + public OSVR_OpenGLToolkitFunctions.destroy_callback destroy; + /** C type : handleEvents_callback* */ + public OSVR_OpenGLToolkitFunctions.handleEvents_callback handleEvents; + /** C type : getDisplayFrameBuffer_callback* */ + public OSVR_OpenGLToolkitFunctions.getDisplayFrameBuffer_callback getDisplayFrameBuffer; + /** C type : getDisplaySizeOverride_callback* */ + public OSVR_OpenGLToolkitFunctions.getDisplaySizeOverride_callback getDisplaySizeOverride; + public interface create_callback extends Callback { + void apply(Pointer data); + }; + public interface destroy_callback extends Callback { + void apply(Pointer data); + }; + public interface OSVR_CBool_callback extends Callback { + int apply(Pointer data, OSVR_OpenGLContextParams p); + }; + public interface OSVR_CBool_callback2 extends Callback { + int apply(Pointer data); + }; + public interface OSVR_CBool_callback3 extends Callback { + int apply(Pointer data, NativeSize display); + }; + public interface OSVR_CBool_callback4 extends Callback { + int apply(Pointer data, NativeSize display); + }; + public interface OSVR_CBool_callback5 extends Callback { + int apply(Pointer data, byte verticalSync); + }; + public interface handleEvents_callback extends Callback { + byte apply(Pointer data); + }; + public interface getDisplayFrameBuffer_callback extends Callback { + byte apply(Pointer data, NativeSize display, IntByReference frameBufferOut); + }; + public interface getDisplaySizeOverride_callback extends Callback { + byte apply(Pointer data, NativeSize display, IntByReference width, IntByReference height); + }; + public OSVR_OpenGLToolkitFunctions() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("size", "data", "create", "destroy", "handleEvents", "getDisplayFrameBuffer", "getDisplaySizeOverride"); + } + /** + * @param data C type : void*
+ * @param create C type : create_callback*
+ * @param destroy C type : destroy_callback*
+ * @param handleEvents C type : handleEvents_callback*
+ * @param getDisplayFrameBuffer C type : getDisplayFrameBuffer_callback*
+ * @param getDisplaySizeOverride C type : getDisplaySizeOverride_callback* + */ + public OSVR_OpenGLToolkitFunctions(NativeSize size, Pointer data, OSVR_OpenGLToolkitFunctions.create_callback create, OSVR_OpenGLToolkitFunctions.destroy_callback destroy, OSVR_OpenGLToolkitFunctions.handleEvents_callback handleEvents, OSVR_OpenGLToolkitFunctions.getDisplayFrameBuffer_callback getDisplayFrameBuffer, OSVR_OpenGLToolkitFunctions.getDisplaySizeOverride_callback getDisplaySizeOverride) { + super(); + this.size = size; + this.data = data; + this.create = create; + this.destroy = destroy; + this.handleEvents = handleEvents; + this.getDisplayFrameBuffer = getDisplayFrameBuffer; + this.getDisplaySizeOverride = getDisplaySizeOverride; + } + public OSVR_OpenGLToolkitFunctions(Pointer peer) { + super(peer); + } + public static class ByReference extends OSVR_OpenGLToolkitFunctions implements Structure.ByReference { + + }; + public static class ByValue extends OSVR_OpenGLToolkitFunctions implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_OpenResultsOpenGL.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_OpenResultsOpenGL.java new file mode 100644 index 0000000000..85e020f6e7 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_OpenResultsOpenGL.java @@ -0,0 +1,48 @@ +package com.jme3.system.osvr.osvrrendermanageropengl; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class OSVR_OpenResultsOpenGL extends Structure { + /** + * C type : OSVR_OpenStatus + */ + public int status; + /** C type : OSVR_GraphicsLibraryOpenGL */ + public OSVR_GraphicsLibraryOpenGL library; + /** C type : OSVR_RenderBufferOpenGL */ + public OSVR_RenderBufferOpenGL buffers; + public OSVR_OpenResultsOpenGL() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("status", "library", "buffers"); + } + /** + * @param status @see OsvrRenderManagerOpenGLLibrary.OSVR_OpenStatus
+ * C type : OSVR_OpenStatus
+ * @param library C type : OSVR_GraphicsLibraryOpenGL
+ * @param buffers C type : OSVR_RenderBufferOpenGL + */ + public OSVR_OpenResultsOpenGL(int status, OSVR_GraphicsLibraryOpenGL library, OSVR_RenderBufferOpenGL buffers) { + super(); + this.status = status; + this.library = library; + this.buffers = buffers; + } + public OSVR_OpenResultsOpenGL(Pointer peer) { + super(peer); + } + public static class ByReference extends OSVR_OpenResultsOpenGL implements Structure.ByReference { + + }; + public static class ByValue extends OSVR_OpenResultsOpenGL implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_ProjectionMatrix.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_ProjectionMatrix.java new file mode 100644 index 0000000000..94d2248543 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_ProjectionMatrix.java @@ -0,0 +1,45 @@ +package com.jme3.system.osvr.osvrrendermanageropengl; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class OSVR_ProjectionMatrix extends Structure { + public double left; + public double right; + public double top; + public double bottom; + /** Cannot name "near" because Visual Studio keyword */ + public double nearClip; + public double farClip; + public OSVR_ProjectionMatrix() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("left", "right", "top", "bottom", "nearClip", "farClip"); + } + /** @param nearClip Cannot name "near" because Visual Studio keyword */ + public OSVR_ProjectionMatrix(double left, double right, double top, double bottom, double nearClip, double farClip) { + super(); + this.left = left; + this.right = right; + this.top = top; + this.bottom = bottom; + this.nearClip = nearClip; + this.farClip = farClip; + } + public OSVR_ProjectionMatrix(Pointer peer) { + super(peer); + } + public static class ByReference extends OSVR_ProjectionMatrix implements Structure.ByReference { + + }; + public static class ByValue extends OSVR_ProjectionMatrix implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_RGB.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_RGB.java new file mode 100644 index 0000000000..c74e15643b --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_RGB.java @@ -0,0 +1,37 @@ +package com.jme3.system.osvr.osvrrendermanageropengl; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class OSVR_RGB extends Structure { + public float r; + public float g; + public float b; + public OSVR_RGB() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("r", "g", "b"); + } + public OSVR_RGB(float r, float g, float b) { + super(); + this.r = r; + this.g = g; + this.b = b; + } + public OSVR_RGB(Pointer peer) { + super(peer); + } + public static class ByReference extends OSVR_RGB implements Structure.ByReference { + + }; + public static class ByValue extends OSVR_RGB implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_RenderBufferOpenGL.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_RenderBufferOpenGL.java new file mode 100644 index 0000000000..7f502dd053 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_RenderBufferOpenGL.java @@ -0,0 +1,35 @@ +package com.jme3.system.osvr.osvrrendermanageropengl; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class OSVR_RenderBufferOpenGL extends Structure { + public int colorBufferName; + public int depthStencilBufferName; + public OSVR_RenderBufferOpenGL() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("colorBufferName", "depthStencilBufferName"); + } + public OSVR_RenderBufferOpenGL(int colorBufferName, int depthStencilBufferName) { + super(); + this.colorBufferName = colorBufferName; + this.depthStencilBufferName = depthStencilBufferName; + } + public OSVR_RenderBufferOpenGL(Pointer peer) { + super(peer); + } + public static class ByReference extends OSVR_RenderBufferOpenGL implements Structure.ByReference { + + }; + public static class ByValue extends OSVR_RenderBufferOpenGL implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_RenderInfoOpenGL.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_RenderInfoOpenGL.java new file mode 100644 index 0000000000..997215f3cb --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_RenderInfoOpenGL.java @@ -0,0 +1,48 @@ +package com.jme3.system.osvr.osvrrendermanageropengl; +import com.jme3.system.osvr.osvrmatrixconventions.OSVR_Pose3; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public /*abstract*/ class OSVR_RenderInfoOpenGL extends Structure { + /** C type : OSVR_GraphicsLibraryOpenGL */ + public OSVR_GraphicsLibraryOpenGL library; + /** C type : OSVR_ViewportDescription */ + public OSVR_ViewportDescription viewport; + public OSVR_Pose3 pose; + /** C type : OSVR_ProjectionMatrix */ + public OSVR_ProjectionMatrix projection; + public OSVR_RenderInfoOpenGL() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("library", "viewport", "pose", "projection"); + } + /** + * @param library C type : OSVR_GraphicsLibraryOpenGL
+ * @param viewport C type : OSVR_ViewportDescription
+ * @param projection C type : OSVR_ProjectionMatrix + */ + public OSVR_RenderInfoOpenGL(OSVR_GraphicsLibraryOpenGL library, OSVR_ViewportDescription viewport, OSVR_Pose3 pose, OSVR_ProjectionMatrix projection) { + super(); + this.library = library; + this.viewport = viewport; + this.pose = pose; + this.projection = projection; + } + public OSVR_RenderInfoOpenGL(Pointer peer) { + super(peer); + } + public static /*abstract*/ class ByReference extends OSVR_RenderInfoOpenGL implements Structure.ByReference { + + }; + public static /*abstract*/ class ByValue extends OSVR_RenderInfoOpenGL implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_RenderParams.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_RenderParams.java new file mode 100644 index 0000000000..6df55bdc88 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_RenderParams.java @@ -0,0 +1,53 @@ +package com.jme3.system.osvr.osvrrendermanageropengl; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class OSVR_RenderParams extends Structure { + /** + * Room space to insert
+ * C type : OSVR_PoseState* + */ + public Pointer worldFromRoomAppend; + /** + * Overrides head space
+ * C type : OSVR_PoseState* + */ + public Pointer roomFromHeadReplace; + public double nearClipDistanceMeters; + public double farClipDistanceMeters; + public OSVR_RenderParams() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("worldFromRoomAppend", "roomFromHeadReplace", "nearClipDistanceMeters", "farClipDistanceMeters"); + } + /** + * @param worldFromRoomAppend Room space to insert
+ * C type : OSVR_PoseState*
+ * @param roomFromHeadReplace Overrides head space
+ * C type : OSVR_PoseState* + */ + public OSVR_RenderParams(Pointer worldFromRoomAppend, Pointer roomFromHeadReplace, double nearClipDistanceMeters, double farClipDistanceMeters) { + super(); + this.worldFromRoomAppend = worldFromRoomAppend; + this.roomFromHeadReplace = roomFromHeadReplace; + this.nearClipDistanceMeters = nearClipDistanceMeters; + this.farClipDistanceMeters = farClipDistanceMeters; + } + public OSVR_RenderParams(Pointer peer) { + super(peer); + } + public static class ByReference extends OSVR_RenderParams implements Structure.ByReference { + + }; + public static class ByValue extends OSVR_RenderParams implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_ViewportDescription.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_ViewportDescription.java new file mode 100644 index 0000000000..f504476e4c --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_ViewportDescription.java @@ -0,0 +1,49 @@ +package com.jme3.system.osvr.osvrrendermanageropengl; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class OSVR_ViewportDescription extends Structure { + /** Left side of the viewport in pixels */ + public double left; + /** First pixel in the viewport at the bottom. */ + public double lower; + /** Last pixel in the viewport at the top */ + public double width; + /** Last pixel on the right of the viewport in pixels */ + public double height; + public OSVR_ViewportDescription() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("left", "lower", "width", "height"); + } + /** + * @param left Left side of the viewport in pixels
+ * @param lower First pixel in the viewport at the bottom.
+ * @param width Last pixel in the viewport at the top
+ * @param height Last pixel on the right of the viewport in pixels + */ + public OSVR_ViewportDescription(double left, double lower, double width, double height) { + super(); + this.left = left; + this.lower = lower; + this.width = width; + this.height = height; + } + public OSVR_ViewportDescription(Pointer peer) { + super(peer); + } + public static class ByReference extends OSVR_ViewportDescription implements Structure.ByReference { + + }; + public static class ByValue extends OSVR_ViewportDescription implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OsvrRenderManagerOpenGLLibrary.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OsvrRenderManagerOpenGLLibrary.java new file mode 100644 index 0000000000..6b3a02f065 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OsvrRenderManagerOpenGLLibrary.java @@ -0,0 +1,169 @@ +package com.jme3.system.osvr.osvrrendermanageropengl; +import com.jme3.system.osvr.osvrclientkit.OsvrClientKitLibrary; +import com.ochafik.lang.jnaerator.runtime.NativeSize; +import com.ochafik.lang.jnaerator.runtime.NativeSizeByReference; +import com.sun.jna.Library; +import com.sun.jna.Native; +import com.sun.jna.NativeLibrary; +import com.sun.jna.Pointer; +import com.sun.jna.PointerType; +import com.sun.jna.ptr.DoubleByReference; +import com.sun.jna.ptr.FloatByReference; +import com.sun.jna.ptr.IntByReference; +import com.sun.jna.ptr.PointerByReference; +import java.nio.DoubleBuffer; +import java.nio.FloatBuffer; +import java.nio.IntBuffer; +/** + * JNA Wrapper for library osvrRenderManagerOpenGL
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class OsvrRenderManagerOpenGLLibrary implements Library { + public static final String JNA_LIBRARY_NAME = "osvrRenderManager"; + public static final NativeLibrary JNA_NATIVE_LIB = NativeLibrary.getInstance(OsvrRenderManagerOpenGLLibrary.JNA_LIBRARY_NAME); + static { + Native.register(OsvrRenderManagerOpenGLLibrary.class, OsvrRenderManagerOpenGLLibrary.JNA_NATIVE_LIB); + } + /** enum values */ + public static interface OSVR_OpenStatus { + public static final int OSVR_OPEN_STATUS_FAILURE = 0; + public static final int OSVR_OPEN_STATUS_PARTIAL = 1; + public static final int OSVR_OPEN_STATUS_COMPLETE = 2; + }; + /** + * todo OSVR_RenderTimingInfo
+ * Original signature : OSVR_ReturnCode osvrDestroyRenderManager(OSVR_RenderManager) + */ + public static native byte osvrDestroyRenderManager(Pointer renderManager); + /** + * todo Make this actually cache, for now it does not.
+ * Original signature : OSVR_ReturnCode osvrRenderManagerGetNumRenderInfo(OSVR_RenderManager, OSVR_RenderParams, OSVR_RenderInfoCount*) + */ + public static native byte osvrRenderManagerGetNumRenderInfo(Pointer renderManager, OSVR_RenderParams.ByValue renderParams, NativeSizeByReference numRenderInfoOut); + /** Original signature : OSVR_ReturnCode osvrRenderManagerGetDoingOkay(OSVR_RenderManager) */ + public static native byte osvrRenderManagerGetDoingOkay(Pointer renderManager); + /** Original signature : OSVR_ReturnCode osvrRenderManagerGetDefaultRenderParams(OSVR_RenderParams*) */ + public static native byte osvrRenderManagerGetDefaultRenderParams(OSVR_RenderParams renderParamsOut); + /** + * must be registered before they are presented.
+ * Original signature : OSVR_ReturnCode osvrRenderManagerStartPresentRenderBuffers(OSVR_RenderManagerPresentState*) + */ + public static native byte osvrRenderManagerStartPresentRenderBuffers(PointerByReference presentStateOut); + /** + * buffers for a single frame. This sequence starts with the Start function.
+ * Original signature : OSVR_ReturnCode osvrRenderManagerFinishPresentRenderBuffers(OSVR_RenderManager, OSVR_RenderManagerPresentState, OSVR_RenderParams, OSVR_CBool) + */ + public static native byte osvrRenderManagerFinishPresentRenderBuffers(Pointer renderManager, Pointer presentState, OSVR_RenderParams.ByValue renderParams, byte shouldFlipY); + /** + * must be registered before they are presented.
+ * Original signature : OSVR_ReturnCode osvrRenderManagerStartRegisterRenderBuffers(OSVR_RenderManagerRegisterBufferState*) + */ + public static native byte osvrRenderManagerStartRegisterRenderBuffers(PointerByReference registerBufferStateOut); + /** + * buffers for a single frame. This sequence starts with the Start function.
+ * Original signature : OSVR_ReturnCode osvrRenderManagerFinishRegisterRenderBuffers(OSVR_RenderManager, OSVR_RenderManagerRegisterBufferState, OSVR_CBool) + */ + public static native byte osvrRenderManagerFinishRegisterRenderBuffers(Pointer renderManager, Pointer registerBufferState, byte appWillNotOverwriteBeforeNewPresent); + /** Original signature : OSVR_ReturnCode osvrRenderManagerPresentSolidColorf(OSVR_RenderManager, OSVR_RGB_FLOAT) */ + public static native byte osvrRenderManagerPresentSolidColorf(Pointer renderManager, com.jme3.system.osvr.osvrrendermanageropengl.OSVR_RGB.ByValue rgb); + /** + * when you're done.
+ * Original signature : OSVR_ReturnCode osvrRenderManagerGetRenderInfoCollection(OSVR_RenderManager, OSVR_RenderParams, OSVR_RenderInfoCollection*) + */ + public static native byte osvrRenderManagerGetRenderInfoCollection(Pointer renderManager, OSVR_RenderParams.ByValue renderParams, PointerByReference renderInfoCollectionOut); + /** + * Releases the OSVR_RenderInfoCollection.
+ * Original signature : OSVR_ReturnCode osvrRenderManagerReleaseRenderInfoCollection(OSVR_RenderInfoCollection) + */ + public static native byte osvrRenderManagerReleaseRenderInfoCollection(Pointer renderInfoCollection); + /** + * Get the size of the OSVR_RenderInfoCollection.
+ * Original signature : OSVR_ReturnCode osvrRenderManagerGetNumRenderInfoInCollection(OSVR_RenderInfoCollection, OSVR_RenderInfoCount*) + */ + public static native byte osvrRenderManagerGetNumRenderInfoInCollection(Pointer renderInfoCollection, NativeSizeByReference countOut); + /** + * @return True on success, false on failure (null pointer).
+ * Original signature : OSVR_ReturnCode OSVR_Projection_to_OpenGL(double*, OSVR_ProjectionMatrix)
+ * @deprecated use the safer methods {@link #OSVR_Projection_to_OpenGL(java.nio.DoubleBuffer, com.jme3.system.osvr.osvrrendermanageropengl.OSVR_ProjectionMatrix.ByValue)} and {@link #OSVR_Projection_to_OpenGL(com.sun.jna.ptr.DoubleByReference, com.jme3.system.osvr.osvrrendermanageropengl.OSVR_ProjectionMatrix.ByValue)} instead + */ + @Deprecated + public static native byte OSVR_Projection_to_OpenGL(DoubleByReference OpenGL_out, com.jme3.system.osvr.osvrrendermanageropengl.OSVR_ProjectionMatrix.ByValue projection_in); + /** + * @return True on success, false on failure (null pointer).
+ * Original signature : OSVR_ReturnCode OSVR_Projection_to_OpenGL(double*, OSVR_ProjectionMatrix) + */ + public static native byte OSVR_Projection_to_OpenGL(DoubleBuffer OpenGL_out, com.jme3.system.osvr.osvrrendermanageropengl.OSVR_ProjectionMatrix.ByValue projection_in); + /** + * @return True on success, false on failure (null pointer).
+ * Original signature : OSVR_ReturnCode OSVR_Projection_to_D3D(float[16], OSVR_ProjectionMatrix)
+ * @deprecated use the safer methods {@link #OSVR_Projection_to_D3D(java.nio.FloatBuffer, com.jme3.system.osvr.osvrrendermanageropengl.OSVR_ProjectionMatrix.ByValue)} and {@link #OSVR_Projection_to_D3D(com.sun.jna.ptr.FloatByReference, com.jme3.system.osvr.osvrrendermanageropengl.OSVR_ProjectionMatrix.ByValue)} instead + */ + @Deprecated + public static native byte OSVR_Projection_to_D3D(FloatByReference D3D_out, com.jme3.system.osvr.osvrrendermanageropengl.OSVR_ProjectionMatrix.ByValue projection_in); + /** + * @return True on success, false on failure (null pointer).
+ * Original signature : OSVR_ReturnCode OSVR_Projection_to_D3D(float[16], OSVR_ProjectionMatrix) + */ + public static native byte OSVR_Projection_to_D3D(FloatBuffer D3D_out, com.jme3.system.osvr.osvrrendermanageropengl.OSVR_ProjectionMatrix.ByValue projection_in); + /** + * @return True on success, false on failure (null pointer).
+ * Original signature : OSVR_ReturnCode OSVR_Projection_to_Unreal(float[16], OSVR_ProjectionMatrix)
+ * @deprecated use the safer methods {@link #OSVR_Projection_to_Unreal(java.nio.FloatBuffer, com.jme3.system.osvr.osvrrendermanageropengl.OSVR_ProjectionMatrix.ByValue)} and {@link #OSVR_Projection_to_Unreal(com.sun.jna.ptr.FloatByReference, com.jme3.system.osvr.osvrrendermanageropengl.OSVR_ProjectionMatrix.ByValue)} instead + */ + @Deprecated + public static native byte OSVR_Projection_to_Unreal(FloatByReference Unreal_out, com.jme3.system.osvr.osvrrendermanageropengl.OSVR_ProjectionMatrix.ByValue projection_in); + /** + * @return True on success, false on failure (null pointer).
+ * Original signature : OSVR_ReturnCode OSVR_Projection_to_Unreal(float[16], OSVR_ProjectionMatrix) + */ + public static native byte OSVR_Projection_to_Unreal(FloatBuffer Unreal_out, com.jme3.system.osvr.osvrrendermanageropengl.OSVR_ProjectionMatrix.ByValue projection_in); + /** + * Original signature : OSVR_ReturnCode osvrCreateRenderManagerOpenGL(OSVR_ClientContext, const char[], OSVR_GraphicsLibraryOpenGL, OSVR_RenderManager*, OSVR_RenderManagerOpenGL*)
+ * @deprecated use the safer method + * {@link #osvrCreateRenderManagerOpenGL(com.jme3.system.osvr.osvrclientkit.OsvrClientKitLibrary.OSVR_ClientContext, byte[], com.jme3.system.osvr.osvrrendermanageropengl.OSVR_GraphicsLibraryOpenGL.ByValue, com.sun.jna.ptr.PointerByReference, com.sun.jna.ptr.PointerByReference)} + * instead + */ + @Deprecated + public static native byte osvrCreateRenderManagerOpenGL(Pointer clientContext, Pointer graphicsLibraryName, com.jme3.system.osvr.osvrrendermanageropengl.OSVR_GraphicsLibraryOpenGL.ByValue graphicsLibrary, PointerByReference renderManagerOut, PointerByReference renderManagerOpenGLOut); + /** Original signature : OSVR_ReturnCode osvrCreateRenderManagerOpenGL(OSVR_ClientContext, const char[], OSVR_GraphicsLibraryOpenGL, OSVR_RenderManager*, OSVR_RenderManagerOpenGL*) */ + public static native byte osvrCreateRenderManagerOpenGL(OsvrClientKitLibrary.OSVR_ClientContext clientContext, byte graphicsLibraryName[], com.jme3.system.osvr.osvrrendermanageropengl.OSVR_GraphicsLibraryOpenGL.ByValue graphicsLibrary, PointerByReference renderManagerOut, PointerByReference renderManagerOpenGLOut); + /** Original signature : OSVR_ReturnCode osvrRenderManagerGetRenderInfoOpenGL(OSVR_RenderManagerOpenGL, OSVR_RenderInfoCount, OSVR_RenderParams, OSVR_RenderInfoOpenGL*) */ + public static native byte osvrRenderManagerGetRenderInfoOpenGL(Pointer renderManager, NativeSize renderInfoIndex, OSVR_RenderParams.ByValue renderParams, OSVR_RenderInfoOpenGL renderInfoOut); + /** Original signature : OSVR_ReturnCode osvrRenderManagerOpenDisplayOpenGL(OSVR_RenderManagerOpenGL, OSVR_OpenResultsOpenGL*) */ + public static native byte osvrRenderManagerOpenDisplayOpenGL(Pointer renderManager, OSVR_OpenResultsOpenGL openResultsOut); + /** Original signature : OSVR_ReturnCode osvrRenderManagerPresentRenderBufferOpenGL(OSVR_RenderManagerPresentState, OSVR_RenderBufferOpenGL, OSVR_RenderInfoOpenGL, OSVR_ViewportDescription) */ + public static native byte osvrRenderManagerPresentRenderBufferOpenGL(Pointer presentState, com.jme3.system.osvr.osvrrendermanageropengl.OSVR_RenderBufferOpenGL.ByValue buffer, OSVR_RenderInfoOpenGL.ByValue renderInfoUsed, com.jme3.system.osvr.osvrrendermanageropengl.OSVR_ViewportDescription.ByValue normalizedCroppingViewport); + /** Original signature : OSVR_ReturnCode osvrRenderManagerRegisterRenderBufferOpenGL(OSVR_RenderManagerRegisterBufferState, OSVR_RenderBufferOpenGL) */ + public static native byte osvrRenderManagerRegisterRenderBufferOpenGL(Pointer registerBufferState, com.jme3.system.osvr.osvrrendermanageropengl.OSVR_RenderBufferOpenGL.ByValue renderBuffer); + /** + * Gets a given OSVR_RenderInfoOpenGL from an OSVR_RenderInfoCollection.
+ * Original signature : OSVR_ReturnCode osvrRenderManagerGetRenderInfoFromCollectionOpenGL(OSVR_RenderInfoCollection, OSVR_RenderInfoCount, OSVR_RenderInfoOpenGL*) + */ + public static native byte osvrRenderManagerGetRenderInfoFromCollectionOpenGL(Pointer renderInfoCollection, NativeSize index, OSVR_RenderInfoOpenGL renderInfoOut); + /** + * Original signature : OSVR_ReturnCode osvrRenderManagerCreateColorBufferOpenGL(GLsizei, GLsizei, GLenum, GLuint*)
+ * @deprecated use the safer methods {@link #osvrRenderManagerCreateColorBufferOpenGL(int, int, int, java.nio.IntBuffer)} and {@link #osvrRenderManagerCreateColorBufferOpenGL(int, int, int, com.sun.jna.ptr.IntByReference)} instead + */ + @Deprecated + public static native byte osvrRenderManagerCreateColorBufferOpenGL(int width, int height, int format, IntByReference colorBufferNameOut); + /** Original signature : OSVR_ReturnCode osvrRenderManagerCreateColorBufferOpenGL(GLsizei, GLsizei, GLenum, GLuint*) */ + public static native byte osvrRenderManagerCreateColorBufferOpenGL(int width, int height, int format, IntBuffer colorBufferNameOut); + /** + * Original signature : OSVR_ReturnCode osvrRenderManagerCreateDepthBufferOpenGL(GLsizei, GLsizei, GLuint*)
+ * @deprecated use the safer methods {@link #osvrRenderManagerCreateDepthBufferOpenGL(int, int, java.nio.IntBuffer)} and {@link #osvrRenderManagerCreateDepthBufferOpenGL(int, int, com.sun.jna.ptr.IntByReference)} instead + */ + @Deprecated + public static native byte osvrRenderManagerCreateDepthBufferOpenGL(int width, int height, IntByReference depthBufferNameOut); + /** Original signature : OSVR_ReturnCode osvrRenderManagerCreateDepthBufferOpenGL(GLsizei, GLsizei, GLuint*) */ + public static native byte osvrRenderManagerCreateDepthBufferOpenGL(int width, int height, IntBuffer depthBufferNameOut); + public static class OSVR_ClientContext extends PointerType { + public OSVR_ClientContext(Pointer address) { + super(address); + } + public OSVR_ClientContext() { + super(); + } + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrtimevalue/OSVR_TimeValue.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrtimevalue/OSVR_TimeValue.java new file mode 100644 index 0000000000..e500f89b17 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrtimevalue/OSVR_TimeValue.java @@ -0,0 +1,41 @@ +package com.jme3.system.osvr.osvrtimevalue; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; +/** + * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class OSVR_TimeValue extends Structure { + /** C type : OSVR_TimeValue_Seconds */ + public long seconds; + /** C type : OSVR_TimeValue_Microseconds */ + public int microseconds; + public OSVR_TimeValue() { + super(); + } + @Override + protected List getFieldOrder() { + return Arrays.asList("seconds", "microseconds"); + } + /** + * @param seconds C type : OSVR_TimeValue_Seconds
+ * @param microseconds C type : OSVR_TimeValue_Microseconds + */ + public OSVR_TimeValue(long seconds, int microseconds) { + super(); + this.seconds = seconds; + this.microseconds = microseconds; + } + public OSVR_TimeValue(Pointer peer) { + super(peer); + } + public static class ByReference extends OSVR_TimeValue implements Structure.ByReference { + + }; + public static class ByValue extends OSVR_TimeValue implements Structure.ByValue { + + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrtimevalue/OsvrTimeValueLibrary.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrtimevalue/OsvrTimeValueLibrary.java new file mode 100644 index 0000000000..eb2731b5c0 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrtimevalue/OsvrTimeValueLibrary.java @@ -0,0 +1,119 @@ +package com.jme3.system.osvr.osvrtimevalue; +import com.sun.jna.Library; +import com.sun.jna.Native; +import com.sun.jna.NativeLibrary; +import com.sun.jna.Pointer; +import com.sun.jna.PointerType; +/** + * JNA Wrapper for library osvrTimeValue
+ * This file was autogenerated by JNAerator,
+ * a tool written by Olivier Chafik that uses a few opensource projects..
+ * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class OsvrTimeValueLibrary implements Library { + public static final String JNA_LIBRARY_NAME = "osvrClientKit"; + public static final NativeLibrary JNA_NATIVE_LIB = NativeLibrary.getInstance(OsvrTimeValueLibrary.JNA_LIBRARY_NAME); + static { + Native.register(OsvrTimeValueLibrary.class, OsvrTimeValueLibrary.JNA_NATIVE_LIB); + } + public static final int OSVR_TRUE = 1; + public static final int OSVR_FALSE = 0; + /** + * Gets the current time in the TimeValue. Parallel to gettimeofday. + * Original signature : void osvrTimeValueGetNow(OSVR_TimeValue*) + */ + public static native void osvrTimeValueGetNow(OSVR_TimeValue dest); + /** + * Converts from a TimeValue struct to your system's struct timeval. + * @param dest Pointer to an empty struct timeval for your platform.
+ * @param src A pointer to an OSVR_TimeValue you'd like to convert from.
+ * If either parameter is NULL, the function will return without doing
+ * anything.
+ * Original signature : void osvrTimeValueToStructTimeval(timeval*, const OSVR_TimeValue*) + */ + public static native void osvrTimeValueToStructTimeval(OsvrTimeValueLibrary.timeval dest, OSVR_TimeValue src); + /** + * Converts from a TimeValue struct to your system's struct timeval. + * @param dest An OSVR_TimeValue destination pointer.
+ * @param src Pointer to a struct timeval you'd like to convert from.
+ * The result is normalized.
+ * If either parameter is NULL, the function will return without doing
+ * anything.
+ * Original signature : void osvrStructTimevalToTimeValue(OSVR_TimeValue*, timeval*) + */ + public static native void osvrStructTimevalToTimeValue(OSVR_TimeValue dest, OsvrTimeValueLibrary.timeval src); + /** + * "Normalizes" a time value so that the absolute number of microseconds + * is less than 1,000,000, and that the sign of both components is the same.
+ * @param tv Address of a struct TimeValue to normalize in place.
+ * If the given pointer is NULL, this function returns without doing anything.
+ * Original signature : void osvrTimeValueNormalize(OSVR_TimeValue*) + */ + public static native void osvrTimeValueNormalize(OSVR_TimeValue tv); + /** + * Sums two time values, replacing the first with the result. + * @param tvA Destination and first source.
+ * @param tvB second source
+ * If a given pointer is NULL, this function returns without doing anything.
+ * Both parameters are expected to be in normalized form.
+ * Original signature : void osvrTimeValueSum(OSVR_TimeValue*, const OSVR_TimeValue*) + */ + public static native void osvrTimeValueSum(OSVR_TimeValue tvA, OSVR_TimeValue tvB); + /** + * Computes the difference between two time values, replacing the first + * with the result.
+ * Effectively, `*tvA = *tvA - *tvB`
+ * @param tvA Destination and first source.
+ * @param tvB second source
+ * If a given pointer is NULL, this function returns without doing anything.
+ * Both parameters are expected to be in normalized form.
+ * Original signature : void osvrTimeValueDifference(OSVR_TimeValue*, const OSVR_TimeValue*) + */ + public static native void osvrTimeValueDifference(OSVR_TimeValue tvA, OSVR_TimeValue tvB); + /** + * Compares two time values (assumed to be normalized), returning + * the same values as strcmp
+ * @return <0 if A is earlier than B, 0 if they are the same, and >0 if A
+ * is later than B.
+ * Original signature : int osvrTimeValueCmp(const OSVR_TimeValue*, const OSVR_TimeValue*) + */ + public static native int osvrTimeValueCmp(OSVR_TimeValue tvA, OSVR_TimeValue tvB); + /** + * Compute the difference between the two time values, returning the + * duration as a double-precision floating-point number of seconds.
+ * Effectively, `ret = *tvA - *tvB`
+ * @param tvA first source.
+ * @param tvB second source
+ * @return Duration of timespan in seconds (floating-point)
+ * Original signature : double osvrTimeValueDurationSeconds(const OSVR_TimeValue*, const OSVR_TimeValue*) + */ + public static native double osvrTimeValueDurationSeconds(OSVR_TimeValue tvA, OSVR_TimeValue tvB); + /** + * True if A is later than B. + * Original signature : OSVR_CBool osvrTimeValueGreater(const OSVR_TimeValue*, const OSVR_TimeValue*) + */ + public static native byte osvrTimeValueGreater(OSVR_TimeValue tvA, OSVR_TimeValue tvB); + /** + * Returns true if the time value is normalized. Typically used in assertions.
+ * Original signature : bool osvrTimeValueIsNormalized(const OSVR_TimeValue&) + */ + public static native byte osvrTimeValueIsNormalized(OSVR_TimeValue tv); + /** + * Operator > overload for time values
+ * Original signature : bool operator>(const OSVR_TimeValue&, const OSVR_TimeValue&) + */ + public static native byte operatorGreater(OSVR_TimeValue tvA, OSVR_TimeValue tvB); + /** + * Operator == overload for time values
+ * Original signature : bool operator==(const OSVR_TimeValue&, const OSVR_TimeValue&) + */ + public static native byte operatorIsEqual(OSVR_TimeValue tvA, OSVR_TimeValue tvB); + public static class timeval extends PointerType { + public timeval(Pointer address) { + super(address); + } + public timeval() { + super(); + } + }; +} diff --git a/jme3-xr/src/main/java/com/jme3/util/VRGUIPositioningMode.java b/jme3-xr/src/main/java/com/jme3/util/VRGUIPositioningMode.java new file mode 100644 index 0000000000..d3e32ea972 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/util/VRGUIPositioningMode.java @@ -0,0 +1,15 @@ +package com.jme3.util; + +/** + * An enumeration that describes the GUI display positioning modes. + * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr + * + */ +public enum VRGUIPositioningMode { + MANUAL, + AUTO_CAM_ALL, + AUTO_CAM_ALL_SKIP_PITCH, + AUTO_OBSERVER_POS_CAM_ROTATION, + AUTO_OBSERVER_ALL, + AUTO_OBSERVER_ALL_CAMHEIGHT +} diff --git a/jme3-xr/src/main/java/com/jme3/util/VRGuiManager.java b/jme3-xr/src/main/java/com/jme3/util/VRGuiManager.java new file mode 100644 index 0000000000..6bbd603ff6 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/util/VRGuiManager.java @@ -0,0 +1,467 @@ +package com.jme3.util; + +import com.jme3.app.VREnvironment; +import com.jme3.material.Material; +import com.jme3.material.RenderState.BlendMode; +import com.jme3.math.ColorRGBA; +import com.jme3.math.Matrix3f; +import com.jme3.math.Quaternion; +import com.jme3.math.Vector2f; +import com.jme3.math.Vector3f; +import com.jme3.renderer.Camera; +import com.jme3.renderer.ViewPort; +import com.jme3.renderer.queue.RenderQueue.Bucket; +import com.jme3.scene.Spatial; +import com.jme3.scene.Geometry; +import com.jme3.scene.Node; +import com.jme3.scene.shape.CenterQuad; +import com.jme3.system.AppSettings; +import com.jme3.texture.FrameBuffer; +import com.jme3.texture.Image.Format; +import com.jme3.texture.Texture; +import com.jme3.texture.Texture2D; +import java.awt.GraphicsEnvironment; +import java.util.Iterator; + +/** + * A class dedicated to the management and the display of a Graphical User Interface (GUI) within a VR environment. + * @author reden - phr00t - https://github.com/phr00t + * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr + * + */ +public class VRGuiManager { + private Camera camLeft, camRight; + private float guiDistance = 1.5f; + private float guiScale = 1f; + private float guiPositioningElastic; + + private VRGUIPositioningMode posMode = VRGUIPositioningMode.AUTO_CAM_ALL; + + private final Matrix3f orient = new Matrix3f(); + private Vector2f screenSize; + protected boolean wantsReposition; + + private Vector2f ratio; + + private final Vector3f EoldPos = new Vector3f(); + + private final Quaternion EoldDir = new Quaternion(); + + private final Vector3f look = new Vector3f(); + private final Vector3f left = new Vector3f(); + private final Vector3f temppos = new Vector3f(); + private final Vector3f up = new Vector3f(); + + private boolean useCurvedSurface = false; + private boolean overdraw = false; + private Geometry guiQuad; + private Node guiQuadNode; + private ViewPort offView; + private Texture2D guiTexture; + + private final Quaternion tempq = new Quaternion(); + + private VREnvironment environment = null; + + /** + * Create a new GUI manager attached to the given app state. + * @param environment the VR environment to which this manager is attached to. + */ + public VRGuiManager(VREnvironment environment){ + this.environment = environment; + } + + public boolean isWantsReposition() { + return wantsReposition; + } + + public void setWantsReposition(boolean wantsReposition) { + this.wantsReposition = wantsReposition; + } + + /** + * + * Makes auto GUI positioning happen not immediately, but like an + * elastic connected to the headset. Setting to 0 disables (default) + * Higher settings make it track the headset quicker. + * + * @param elastic amount of elasticity + */ + public void setPositioningElasticity(float elastic) { + guiPositioningElastic = elastic; + } + + public float getPositioningElasticity() { + return guiPositioningElastic; + } + + /** + * Get the GUI {@link VRGUIPositioningMode positioning mode}. + * @return the GUI {@link VRGUIPositioningMode positioning mode}. + * @see #setPositioningMode(VRGUIPositioningMode) + */ + public VRGUIPositioningMode getPositioningMode() { + return posMode; + } + + /** + * Set the GUI {@link VRGUIPositioningMode positioning mode}. + * @param mode the GUI {@link VRGUIPositioningMode positioning mode}. + * @see #getPositioningMode() + */ + public void setPositioningMode(VRGUIPositioningMode mode) { + posMode = mode; + } + + /** + * Get the GUI canvas size. This method return the size in pixels of the GUI available area within the VR view. + * @return the GUI canvas size. This method return the size in pixels of the GUI available area within the VR view. + */ + public Vector2f getCanvasSize() { + if (environment != null){ + + if (environment.getApplication() != null){ + if( screenSize == null ) { + if( environment.isInVR() && environment.getVRHardware() != null ) { + screenSize = new Vector2f(); + environment.getVRHardware().getRenderSize(screenSize); + screenSize.multLocal(environment.getVRViewManager().getResolutionMuliplier()); + } else { + AppSettings as = environment.getApplication().getContext().getSettings(); + screenSize = new Vector2f(as.getWidth(), as.getHeight()); + } + } + return screenSize; + } else { + throw new IllegalStateException("VR GUI manager underlying environment is not attached to any application."); + } + } else { + throw new IllegalStateException("VR GUI manager is not attached to any environment."); + } + } + + /** + * Get the ratio between the {@link #getCanvasSize() GUI canvas size} and the application main windows (if available) or the screen size. + * @return the ratio between the {@link #getCanvasSize() GUI canvas size} and the application main windows (if available). + * @see #getCanvasSize() + */ + public Vector2f getCanvasToWindowRatio() { + if (environment != null){ + + if (environment.getApplication() != null){ + if( ratio == null ) { + ratio = new Vector2f(); + Vector2f canvas = getCanvasSize(); + int width = Integer.min(GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDisplayMode().getWidth(), + environment.getApplication().getContext().getSettings().getWidth()); + int height = Integer.min(GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDisplayMode().getHeight(), + environment.getApplication().getContext().getSettings().getHeight()); + ratio.x = Float.max(1f, canvas.x / width); + ratio.y = Float.max(1f, canvas.y / height); + } + return ratio; + + } else { + throw new IllegalStateException("VR GUI manager underlying environment is not attached to any application."); + } + } else { + throw new IllegalStateException("VR GUI manager is not attached to any environment."); + } + } + + /** + * Inform this manager that it has to position the GUI. + */ + public void positionGui() { + wantsReposition = true; + } + + /** + * Position the GUI to the given location. + * @param pos the position of the GUI. + * @param dir the rotation of the GUI. + * @param tpf the time per frame. + */ + private void positionTo(Vector3f pos, Quaternion dir, float tpf) { + if (environment != null){ + Vector3f guiPos = guiQuadNode.getLocalTranslation(); + guiPos.set(0f, 0f, guiDistance); + dir.mult(guiPos, guiPos); + guiPos.x += pos.x; + guiPos.y += pos.y + environment.getVRHeightAdjustment(); + guiPos.z += pos.z; + if( guiPositioningElastic > 0f && posMode != VRGUIPositioningMode.MANUAL ) { + // mix pos & dir with current pos & dir + guiPos.interpolateLocal(EoldPos, guiPos, Float.min(1f, tpf * guiPositioningElastic)); + EoldPos.set(guiPos); + } + } else { + throw new IllegalStateException("VR GUI manager is not attached to any environment."); + } + } + + /** + * Update the GUI geometric state. This method should be called after GUI modification. + */ + public void updateGuiQuadGeometricState() { + guiQuadNode.updateGeometricState(); + } + + /** + * Position the GUI without delay. + * @param tpf the time per frame. + */ + public void positionGuiNow(float tpf) { + if (environment != null){ + wantsReposition = false; + if( environment.isInVR() == false ){ + return; + } + + guiQuadNode.setLocalScale(guiDistance * guiScale * 4f, 4f * guiDistance * guiScale, 1f); + + switch( posMode ) { + case MANUAL: + case AUTO_CAM_ALL_SKIP_PITCH: + case AUTO_CAM_ALL: + if( camLeft != null && camRight != null ) { + // get middle point + temppos.set(camLeft.getLocation()).interpolateLocal(camRight.getLocation(), 0.5f); + positionTo(temppos, camLeft.getRotation(), tpf); + } + rotateScreenTo(camLeft.getRotation(), tpf); + + break; + case AUTO_OBSERVER_POS_CAM_ROTATION: + Object obs = environment.getObserver(); + if( obs != null ) { + if( obs instanceof Camera ) { + positionTo(((Camera)obs).getLocation(), camLeft.getRotation(), tpf); + } else { + positionTo(((Spatial)obs).getWorldTranslation(), camLeft.getRotation(), tpf); + } + } + rotateScreenTo(camLeft.getRotation(), tpf); + + break; + case AUTO_OBSERVER_ALL: + case AUTO_OBSERVER_ALL_CAMHEIGHT: + obs = environment.getObserver(); + if( obs != null ) { + Quaternion q; + if( obs instanceof Camera ) { + q = ((Camera)obs).getRotation(); + temppos.set(((Camera)obs).getLocation()); + } else { + q = ((Spatial)obs).getWorldRotation(); + temppos.set(((Spatial)obs).getWorldTranslation()); + } + if( posMode == VRGUIPositioningMode.AUTO_OBSERVER_ALL_CAMHEIGHT ) { + temppos.y = camLeft.getLocation().y; + } + positionTo(temppos, q, tpf); + rotateScreenTo(q, tpf); + + } + break; + } + } else { + throw new IllegalStateException("VR GUI manager is not attached to any environment."); + } + } + + /** + * Rotate the GUI to the given direction. + * @param dir the direction to rotate to. + * @param tpf the time per frame. + */ + private void rotateScreenTo(Quaternion dir, float tpf) { + dir.getRotationColumn(2, look).negateLocal(); + dir.getRotationColumn(0, left).negateLocal(); + orient.fromAxes(left, dir.getRotationColumn(1, up), look); + Quaternion rot = tempq.fromRotationMatrix(orient); + if( posMode == VRGUIPositioningMode.AUTO_CAM_ALL_SKIP_PITCH ){ + VRUtil.stripToYaw(rot); + } + + if( guiPositioningElastic > 0f && posMode != VRGUIPositioningMode.MANUAL ) { + // mix pos & dir with current pos & dir + EoldDir.nlerp(rot, tpf * guiPositioningElastic); + guiQuadNode.setLocalRotation(EoldDir); + } else { + guiQuadNode.setLocalRotation(rot); + } + } + + /** + * Get the GUI distance from the observer. + * @return the GUI distance from the observer. + * @see #setGuiDistance(float) + */ + public float getGuiDistance() { + return guiDistance; + } + + /** + * Set the GUI distance from the observer. + * @param newGuiDistance the GUI distance from the observer. + * @see #getGuiDistance() + */ + public void setGuiDistance(float newGuiDistance) { + guiDistance = newGuiDistance; + } + + /** + * Get the GUI scale. + * @return the GUI scale. + * @see #setGuiScale(float) + */ + public float getGUIScale(){ + return guiScale; + } + + /** + * Set the GUI scale. + * @param scale the GUI scale. + * @see #getGUIScale() + */ + public void setGuiScale(float scale) { + guiScale = scale; + } + + /** + * Adjust the GUI distance from the observer. + * This method increment / decrement the {@link #getGuiDistance() GUI distance} by the given value. + * @param adjustAmount the increment (if positive) / decrement (if negative) value of the GUI distance. + */ + public void adjustGuiDistance(float adjustAmount) { + guiDistance += adjustAmount; + } + + /** + * Set up the GUI. + * @param leftCam the left-eye camera. + * @param rightCam the right-eye camera. + * @param left the left-eye viewport. + * @param right the right-eye viewport. + */ + public void setupGui(Camera leftCam, Camera rightCam, ViewPort left, ViewPort right) { + + if (environment != null){ + if( environment.hasTraditionalGUIOverlay() ) { + camLeft = leftCam; + camRight = rightCam; + Spatial guiScene = getGuiQuad(camLeft); + left.attachScene(guiScene); + if( right != null ) right.attachScene(guiScene); + setPositioningMode(posMode); + } + } else { + throw new IllegalStateException("VR GUI manager is not attached to any environment."); + } + } + + /** + * Get if the GUI has to use curved surface. + * @return true if the GUI has to use curved surface and false otherwise. + * @see #setCurvedSurface(boolean) + */ + public boolean isCurverSurface(){ + return useCurvedSurface; + } + + /** + * Set if the GUI has to use curved surface. + * @param set true if the GUI has to use curved surface and false otherwise. + * @see #isCurverSurface() + */ + public void setCurvedSurface(boolean set) { + useCurvedSurface = set; + } + + /** + * Get if the GUI has to be displayed even if it is behind objects. + * @return true if the GUI has to use curved surface and false otherwise. + * @see #setGuiOverdraw(boolean) + */ + public boolean isGuiOverdraw(){ + return overdraw; + } + + /** + * Set if the GUI has to be displayed even if it is behind objects. + * @param set true if the GUI has to use curved surface and false otherwise. + * @see #isGuiOverdraw() + */ + public void setGuiOverdraw(boolean set) { + overdraw = set; + } + + /** + * Create a GUI quad for the given camera. + * @param sourceCam the camera + * @return a GUI quad for the given camera. + */ + private Spatial getGuiQuad(Camera sourceCam){ + if (environment != null){ + + if (environment.getApplication() != null){ + if( guiQuadNode == null ) { + Vector2f guiCanvasSize = getCanvasSize(); + Camera offCamera = sourceCam.clone(); + offCamera.setParallelProjection(true); + offCamera.setLocation(Vector3f.ZERO); + offCamera.lookAt(Vector3f.UNIT_Z, Vector3f.UNIT_Y); + + offView = environment.getApplication().getRenderManager().createPreView("GUI View", offCamera); + offView.setClearFlags(true, true, true); + offView.setBackgroundColor(ColorRGBA.BlackNoAlpha); + + // create offscreen framebuffer + FrameBuffer offBuffer = new FrameBuffer((int)guiCanvasSize.x, (int)guiCanvasSize.y, 1); + + //setup framebuffer's texture + guiTexture = new Texture2D((int)guiCanvasSize.x, (int)guiCanvasSize.y, Format.RGBA8); + guiTexture.setMinFilter(Texture.MinFilter.BilinearNoMipMaps); + guiTexture.setMagFilter(Texture.MagFilter.Bilinear); + + //setup framebuffer to use texture + offBuffer.setDepthBuffer(Format.Depth); + offBuffer.setColorTexture(guiTexture); + + //set viewport to render to offscreen framebuffer + offView.setOutputFrameBuffer(offBuffer); + + // setup framebuffer's scene + Iterator spatialIter = environment.getApplication().getGuiViewPort().getScenes().iterator(); + while(spatialIter.hasNext()){ + offView.attachScene(spatialIter.next()); + } + + if( useCurvedSurface ) { + guiQuad = (Geometry)environment.getApplication().getAssetManager().loadModel("Common/Util/gui_mesh.j3o"); + } else { + guiQuad = new Geometry("guiQuad", new CenterQuad(1f, 1f)); + } + + Material mat = new Material(environment.getApplication().getAssetManager(), "Common/MatDefs/VR/GuiOverlay.j3md"); + mat.getAdditionalRenderState().setDepthTest(!overdraw); + mat.getAdditionalRenderState().setBlendMode(BlendMode.Alpha); + mat.getAdditionalRenderState().setDepthWrite(false); + mat.setTexture("ColorMap", guiTexture); + guiQuad.setQueueBucket(Bucket.Translucent); + guiQuad.setMaterial(mat); + + guiQuadNode = new Node("gui-quad-node"); + guiQuadNode.setQueueBucket(Bucket.Translucent); + guiQuadNode.attachChild(guiQuad); + } + return guiQuadNode; + } else { + throw new IllegalStateException("VR GUI manager underlying environment is not attached to any application."); + } + } else { + throw new IllegalStateException("VR GUI manager is not attached to any environment."); + } + } +} diff --git a/jme3-xr/src/main/java/com/jme3/util/VRUtil.java b/jme3-xr/src/main/java/com/jme3/util/VRUtil.java new file mode 100644 index 0000000000..19a4c5c9be --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/util/VRUtil.java @@ -0,0 +1,101 @@ +package com.jme3.util; + +import com.jme3.math.FastMath; +import com.jme3.math.Matrix4f; +import com.jme3.math.Quaternion; + + +import java.util.concurrent.TimeUnit; + +/** + * + * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr + * + */ +public class VRUtil { + + private static final long SLEEP_PRECISION = TimeUnit.MILLISECONDS.toNanos(4); + private static final long SPIN_YIELD_PRECISION = TimeUnit.MILLISECONDS.toNanos(2); + + /** + * A private constructor to inhibit instantiation of this class. + */ + private VRUtil() { + } + + public static void sleepNanos(long nanoDuration) { + final long end = System.nanoTime() + nanoDuration; + long timeLeft = nanoDuration; + do { + try { + if (timeLeft > SLEEP_PRECISION) { + Thread.sleep(1); + } else if (timeLeft > SPIN_YIELD_PRECISION) { + Thread.sleep(0); + } + } catch(Exception e) { } + timeLeft = end - System.nanoTime(); + } while (timeLeft > 0); + } + + + + + public static void convertMatrix4toQuat(Matrix4f in, Quaternion out) { + // convert rotation matrix to quat + out.fromRotationMatrix(in.m00, in.m01, in.m02, in.m10, in.m11, in.m12, in.m20, in.m21, in.m22); + // flip the pitch + out.set(-out.getX(), out.getY(), -out.getZ(), out.getW()); + } + + public static Quaternion FastFullAngles(Quaternion use, float yaw, float pitch, float roll) { + float angle; + float sinRoll, sinPitch, sinYaw, cosRoll, cosPitch, cosYaw; + angle = roll * 0.5f; + sinPitch = (float)Math.sin(angle); + cosPitch = (float)Math.cos(angle); + angle = yaw * 0.5f; + sinRoll = (float)Math.sin(angle); + cosRoll = (float)Math.cos(angle); + angle = pitch * 0.5f; + sinYaw = (float)Math.sin(angle); + cosYaw = (float)Math.cos(angle); + + // variables used to reduce multiplication calls. + float cosRollXcosPitch = cosRoll * cosPitch; + float sinRollXsinPitch = sinRoll * sinPitch; + float cosRollXsinPitch = cosRoll * sinPitch; + float sinRollXcosPitch = sinRoll * cosPitch; + + use.set((cosRollXcosPitch * sinYaw + sinRollXsinPitch * cosYaw), + (sinRollXcosPitch * cosYaw + cosRollXsinPitch * sinYaw), + (cosRollXsinPitch * cosYaw - sinRollXcosPitch * sinYaw), + (cosRollXcosPitch * cosYaw - sinRollXsinPitch * sinYaw)); + + return use; + } + + public static Quaternion stripToYaw(Quaternion q) { + float yaw; + float w = q.getW(); + float x = q.getX(); + float y = q.getY(); + float z = q.getZ(); + float sqx = x*x; + float sqy = y*y; + float sqz = z*z; + float sqw = w*w; + float unit = sqx + sqy + sqz + sqw; // if normalized is one, otherwise + // is correction factor + float test = x * y + z * w; + if (test > 0.499 * unit) { // singularity at north pole + yaw = 2 * FastMath.atan2(x, w); + } else if (test < -0.499 * unit) { // singularity at south pole + yaw = -2 * FastMath.atan2(x, w); + } else { + yaw = FastMath.atan2(2 * y * w - 2 * x * z, sqx - sqy - sqz + sqw); // roll or heading + } + FastFullAngles(q, yaw, 0f, 0f); + return q; + } +} diff --git a/jme3-xr/src/main/java/test/TestInitHmd.java b/jme3-xr/src/main/java/test/TestInitHmd.java new file mode 100644 index 0000000000..a15ea732d1 --- /dev/null +++ b/jme3-xr/src/main/java/test/TestInitHmd.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2009-2018 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package test; + +import com.jme3.app.VREnvironment; +import com.jme3.input.vr.openvr.OpenVR; +import com.jme3.system.AppSettings; + +/** + * Testing OpenVR environment. + * @author Rickard (neph1 @ github) + */ +public class TestInitHmd { + + public static void main(String... args){ + testInitHmd(); + } + + public static void testInitHmd(){ + VREnvironment environment = new VREnvironment(new AppSettings(true)); + environment.initialize(); + OpenVR openVr = (OpenVR) environment.getVRHardware(); + System.out.println(openVr.getName()); + + openVr.updatePose(); + + openVr.destroy(); + + } +} \ No newline at end of file diff --git a/jme3-xr/src/main/resources/Common/MatDefs/VR/CartoonSSAO.frag b/jme3-xr/src/main/resources/Common/MatDefs/VR/CartoonSSAO.frag new file mode 100644 index 0000000000..5d121019fc --- /dev/null +++ b/jme3-xr/src/main/resources/Common/MatDefs/VR/CartoonSSAO.frag @@ -0,0 +1,109 @@ +//#define FRAGMENT_SHADER +#import "Common/ShaderLib/GLSLCompat.glsllib" + +uniform vec2 g_ResolutionInverse; +uniform vec2 m_FrustumNearFar; +uniform sampler2D m_Texture; +uniform sampler2D m_Normals; +uniform sampler2D m_DepthTexture; +uniform vec3 m_FrustumCorner; +uniform float m_Distance; + +varying vec2 texCoord; + +#define m_Scale 3.15 +#define m_Bias 0.025 +#define m_SampleRadius 200.0 + +vec4 fetchNormalDepth(vec2 tc){ + vec4 nd; + nd.xyz = texture2D(m_Normals, tc).rgb; + nd.w = 150.0 * texture2D(m_DepthTexture, tc).r; + return nd; +} + +vec3 getPosition(in vec2 uv){ + float depth= (2.0 * m_FrustumNearFar.x) / (m_FrustumNearFar.y + m_FrustumNearFar.x - texture2D(m_DepthTexture,uv).r * (m_FrustumNearFar.y-m_FrustumNearFar.x)); +#ifdef INSTANCING + float x = mix(-m_FrustumCorner.x, m_FrustumCorner.x, (uv.x - (uv.x > 0.5 ? 0.5 : 0.0)) * 2.0); +#else + float x = mix(-m_FrustumCorner.x, m_FrustumCorner.x, uv.x); +#endif + float y = mix(-m_FrustumCorner.y, m_FrustumCorner.y, uv.y); + return depth* vec3(x, y, m_FrustumCorner.z); +} + +vec3 getPosition(in vec2 uv, in float indepth){ + float depth= (2.0 * m_FrustumNearFar.x) / (m_FrustumNearFar.y + m_FrustumNearFar.x - indepth * (m_FrustumNearFar.y-m_FrustumNearFar.x)); +#ifdef INSTANCING + float x = mix(-m_FrustumCorner.x, m_FrustumCorner.x, (uv.x - (uv.x > 0.5 ? 0.5 : 0.0)) * 2.0); +#else + float x = mix(-m_FrustumCorner.x, m_FrustumCorner.x, uv.x); +#endif + float y = mix(-m_FrustumCorner.y, m_FrustumCorner.y, uv.y); + return depth* vec3(x, y, m_FrustumCorner.z); +} + +float doAmbientOcclusion(in vec2 tc, in vec3 pos, in vec3 norm){ + vec3 diff = getPosition(tc)- pos; + float d = length(diff) * m_Scale; + vec3 v = normalize(diff); + return step(0.00002,d)*max(0.0, dot(norm, v) - m_Bias) * ( 1.0/(1.0 + d) ) * smoothstep(0.00002,0.0027,d); +} + +void main(){ + float result; + + float firstdepth = texture2D(m_DepthTexture,texCoord).r; + vec4 color = texture2D(m_Texture, texCoord); + + if( firstdepth == 1.0 ) { + gl_FragColor = color; + return; + } + + vec3 position = getPosition(texCoord, firstdepth); + vec3 normal = texture2D(m_Normals, texCoord).xyz * 2.0 - 1.0; + + vec2 rad = m_SampleRadius * g_ResolutionInverse / max(16.0, position.z); + + float ao = doAmbientOcclusion(texCoord + vec2( rad.x, rad.y), position, normal); + ao += doAmbientOcclusion(texCoord + vec2(-rad.x, rad.y), position, normal); + ao += doAmbientOcclusion(texCoord + vec2( rad.x, -rad.y), position, normal); + ao += doAmbientOcclusion(texCoord + vec2(-rad.x, -rad.y), position, normal); + + ao += doAmbientOcclusion(texCoord + vec2(-rad.x, 0.0), position, normal); + ao += doAmbientOcclusion(texCoord + vec2( rad.x, 0.0), position, normal); + ao += doAmbientOcclusion(texCoord + vec2(0.0, -rad.y), position, normal); + ao += doAmbientOcclusion(texCoord + vec2(0.0, rad.y), position, normal); + + rad *= 0.7; + + ao += doAmbientOcclusion(texCoord + vec2(-rad.x, -rad.y), position, normal); + ao += doAmbientOcclusion(texCoord + vec2( rad.x, -rad.y), position, normal); + ao += doAmbientOcclusion(texCoord + vec2(-rad.x, rad.y), position, normal); + ao += doAmbientOcclusion(texCoord + vec2( rad.x, rad.y), position, normal); + + result = 1.0 - clamp(ao * 0.4 - position.z * m_Distance * 2.5, 0.0, 0.6); + +#ifndef NO_OUTLINE + // ok, done with ambient occlusion, do cartoon edge + + vec2 mv = 0.5 * g_ResolutionInverse; + + vec4 n1 = fetchNormalDepth(texCoord + vec2(-mv.x, -mv.y)); + vec4 n2 = fetchNormalDepth(texCoord + vec2( mv.x, mv.y)); + vec4 n3 = fetchNormalDepth(texCoord + vec2(-mv.x, mv.y)); + vec4 n4 = fetchNormalDepth(texCoord + vec2( mv.x, -mv.y)); + + // Work out how much the normal and depth values are changing. + vec4 diagonalDelta = abs(n1 - n2) + abs(n3 - n4); + + float normalDelta = dot(diagonalDelta.xyz, vec3(1.0)); + float totalDelta = (diagonalDelta.w + normalDelta * 0.4) - position.z * m_Distance; + + gl_FragColor = color * vec4(result, result, result, 1.0) * (1.0 - clamp(totalDelta, 0.0, 1.0)); +#else + gl_FragColor = color * vec4(result, result, result, 1.0); +#endif +} diff --git a/jme3-xr/src/main/resources/Common/MatDefs/VR/CartoonSSAO.j3md b/jme3-xr/src/main/resources/Common/MatDefs/VR/CartoonSSAO.j3md new file mode 100644 index 0000000000..5faaf9260b --- /dev/null +++ b/jme3-xr/src/main/resources/Common/MatDefs/VR/CartoonSSAO.j3md @@ -0,0 +1,47 @@ +MaterialDef CartoonSSAO { + + MaterialParameters { + Int NumSamples + Int NumSamplesDepth + Texture2D DepthTexture + Texture2D Texture + Texture2D Normals + Vector3 FrustumCorner + Float Distance + Boolean disableOutline + Boolean useInstancing + Vector2 FrustumNearFar + } + + Technique { + VertexShader GLSL150: Common/MatDefs/Post/Post15.vert + FragmentShader GLSL150: Common/MatDefs/VR/CartoonSSAO.frag + + WorldParameters { + WorldViewProjectionMatrix + WorldViewMatrix + ResolutionInverse + } + + Defines { + NO_OUTLINE : disableOutline + INSTANCING : useInstancing + } + } + + Technique { + VertexShader GLSL100: Common/MatDefs/Post/Post.vert + FragmentShader GLSL100: Common/MatDefs/VR/CartoonSSAO.frag + + WorldParameters { + WorldViewProjectionMatrix + WorldViewMatrix + ResolutionInverse + } + + Defines { + NO_OUTLINE : disableOutline + INSTANCING : useInstancing + } + } +} diff --git a/jme3-xr/src/main/resources/Common/MatDefs/VR/GuiOverlay.frag b/jme3-xr/src/main/resources/Common/MatDefs/VR/GuiOverlay.frag new file mode 100644 index 0000000000..555ef3eb49 --- /dev/null +++ b/jme3-xr/src/main/resources/Common/MatDefs/VR/GuiOverlay.frag @@ -0,0 +1,10 @@ +#import "Common/ShaderLib/GLSLCompat.glsllib" + +uniform sampler2D m_ColorMap; + +varying vec2 texCoord1; + +void main(){ + gl_FragColor = texture2D(m_ColorMap, texCoord1); + gl_FragColor.a *= 12.0 / (1.0 + gl_FragColor.a * 11.0 ); +} \ No newline at end of file diff --git a/jme3-xr/src/main/resources/Common/MatDefs/VR/GuiOverlay.j3md b/jme3-xr/src/main/resources/Common/MatDefs/VR/GuiOverlay.j3md new file mode 100644 index 0000000000..79b7759237 --- /dev/null +++ b/jme3-xr/src/main/resources/Common/MatDefs/VR/GuiOverlay.j3md @@ -0,0 +1,38 @@ +MaterialDef GuiOverlay { + + MaterialParameters { + Texture2D ColorMap + + // For VR instancing + Matrix4 RightEyeViewProjectionMatrix + } + + Technique { + VertexShader GLSL150: Common/MatDefs/VR/GuiOverlay15.vert + FragmentShader GLSL150: Common/MatDefs/VR/GuiOverlay15.frag + + WorldParameters { + WorldViewProjectionMatrix + ViewProjectionMatrix // needed for VR instancing + } + + Defines { + INSTANCING : RightEyeViewProjectionMatrix // For VR instancing + } + } + + Technique { + VertexShader GLSL100: Common/MatDefs/VR/GuiOverlay.vert + FragmentShader GLSL100: Common/MatDefs/VR/GuiOverlay.frag + + WorldParameters { + WorldViewProjectionMatrix + ViewProjectionMatrix // needed for VR instancing + } + + Defines { + INSTANCING : RightEyeViewProjectionMatrix // For VR instancing + } + } + +} \ No newline at end of file diff --git a/jme3-xr/src/main/resources/Common/MatDefs/VR/GuiOverlay.vert b/jme3-xr/src/main/resources/Common/MatDefs/VR/GuiOverlay.vert new file mode 100644 index 0000000000..8b05071961 --- /dev/null +++ b/jme3-xr/src/main/resources/Common/MatDefs/VR/GuiOverlay.vert @@ -0,0 +1,12 @@ +// import the following for VR instancing +#import "Common/ShaderLib/InstanceVR.glsllib" + +attribute vec3 inPosition; +attribute vec2 inTexCoord; +varying vec2 texCoord1; + +void main(){ + texCoord1 = inTexCoord; + vec4 modelSpacePos = vec4(inPosition, 1.0); + gl_Position = TransformWorldViewProjectionVR(modelSpacePos); +} \ No newline at end of file diff --git a/jme3-xr/src/main/resources/Common/MatDefs/VR/GuiOverlay15.frag b/jme3-xr/src/main/resources/Common/MatDefs/VR/GuiOverlay15.frag new file mode 100644 index 0000000000..efaca8436c --- /dev/null +++ b/jme3-xr/src/main/resources/Common/MatDefs/VR/GuiOverlay15.frag @@ -0,0 +1,13 @@ +//#define FRAGMENT_SHADER +#import "Common/ShaderLib/GLSLCompat.glsllib" + +uniform sampler2D m_ColorMap; + +in vec2 texCoord1; + +out vec4 outColor; + +void main(){ + outColor = texture2D(m_ColorMap, texCoord1); + outColor.a *= 12.0 / (1.0 + outColor.a * 11.0 ); +} \ No newline at end of file diff --git a/jme3-xr/src/main/resources/Common/MatDefs/VR/GuiOverlay15.vert b/jme3-xr/src/main/resources/Common/MatDefs/VR/GuiOverlay15.vert new file mode 100644 index 0000000000..cb505d5cfe --- /dev/null +++ b/jme3-xr/src/main/resources/Common/MatDefs/VR/GuiOverlay15.vert @@ -0,0 +1,14 @@ +// import the following for VR instancing +//#define VERTEX_SHADER +#import "Common/ShaderLib/GLSLCompat.glsllib" +#import "Common/ShaderLib/InstanceVR.glsllib" + +in vec3 inPosition; +in vec2 inTexCoord; +out vec2 texCoord1; + +void main(){ + texCoord1 = inTexCoord; + vec4 modelSpacePos = vec4(inPosition, 1.0); + gl_Position = TransformWorldViewProjectionVR(modelSpacePos); +} \ No newline at end of file diff --git a/jme3-xr/src/main/resources/Common/MatDefs/VR/OpenVR.frag b/jme3-xr/src/main/resources/Common/MatDefs/VR/OpenVR.frag new file mode 100644 index 0000000000..9d61ca057e --- /dev/null +++ b/jme3-xr/src/main/resources/Common/MatDefs/VR/OpenVR.frag @@ -0,0 +1,22 @@ +#import "Common/ShaderLib/GLSLCompat.glsllib" +uniform sampler2D m_Texture; + +varying vec2 UVred; +varying vec2 UVgreen; +varying vec2 UVblue; + +void main() { + // performance & FOV experiment by removing bounds check + //float fBoundsCheck = ( (dot( vec2( lessThan( UVgreen.xy, vec2(0.05, 0.05)) ), vec2(1.0, 1.0))+dot( vec2( greaterThan( UVgreen.xy, vec2( 0.95, 0.95)) ), vec2(1.0, 1.0))) ); + // + //if( fBoundsCheck > 1.0 ) { + // gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + //} else { + + float red = texture2D(m_Texture, UVred).x; + float green = texture2D(m_Texture, UVgreen).y; + float blue = texture2D(m_Texture, UVblue).z; + gl_FragColor = vec4( red, green, blue, 1.0 ); + + //} +} diff --git a/jme3-xr/src/main/resources/Common/MatDefs/VR/OpenVR.j3md b/jme3-xr/src/main/resources/Common/MatDefs/VR/OpenVR.j3md new file mode 100644 index 0000000000..7cadd0af08 --- /dev/null +++ b/jme3-xr/src/main/resources/Common/MatDefs/VR/OpenVR.j3md @@ -0,0 +1,33 @@ +MaterialDef OpenVR { + MaterialParameters { + Int NumSamples + Texture2D Texture + + Vector2 inUVred + Vector2 inUVblue + Vector2 inUVgreen + } + + Technique { + VertexShader GLSL150: Common/MatDefs/VR/OpenVR15.vert + FragmentShader GLSL150: Common/MatDefs/VR/OpenVR15.frag + + WorldParameters { + } + + Defines { + } + + } + + Technique { + VertexShader GLSL100: Common/MatDefs/VR/OpenVR.vert + FragmentShader GLSL100: Common/MatDefs/VR/OpenVR.frag + + WorldParameters { + } + + Defines { + } + } +} \ No newline at end of file diff --git a/jme3-xr/src/main/resources/Common/MatDefs/VR/OpenVR.vert b/jme3-xr/src/main/resources/Common/MatDefs/VR/OpenVR.vert new file mode 100644 index 0000000000..734a097e29 --- /dev/null +++ b/jme3-xr/src/main/resources/Common/MatDefs/VR/OpenVR.vert @@ -0,0 +1,17 @@ +#import "Common/ShaderLib/GLSLCompat.glsllib" +attribute vec4 inPosition; + +attribute vec2 inTexCoord; // m_inUVred +attribute vec2 inTexCoord2; // m_inUVgreen +attribute vec2 inTexCoord3; // m_inUVblue + +varying vec2 UVred; +varying vec2 UVgreen; +varying vec2 UVblue; + +void main() { + gl_Position = inPosition; + UVred = inTexCoord; + UVgreen = inTexCoord2; + UVblue = inTexCoord3; +} \ No newline at end of file diff --git a/jme3-xr/src/main/resources/Common/MatDefs/VR/OpenVR15.frag b/jme3-xr/src/main/resources/Common/MatDefs/VR/OpenVR15.frag new file mode 100644 index 0000000000..20d195c490 --- /dev/null +++ b/jme3-xr/src/main/resources/Common/MatDefs/VR/OpenVR15.frag @@ -0,0 +1,24 @@ +#import "Common/ShaderLib/GLSLCompat.glsllib" +uniform sampler2D m_Texture; + +in vec2 UVred; +in vec2 UVgreen; +in vec2 UVblue; + +out vec4 outColor; + +void main() { + // performance & FOV improvement by removing bounds check + //float fBoundsCheck = ( (dot( vec2( lessThan( UVgreen.xy, vec2(0.05, 0.05)) ), vec2(1.0, 1.0))+dot( vec2( greaterThan( UVgreen.xy, vec2( 0.95, 0.95)) ), vec2(1.0, 1.0))) ); + // + //if( fBoundsCheck > 1.0 ) { + // gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + //} else { + + float red = texture2D(m_Texture, UVred).x; + float green = texture2D(m_Texture, UVgreen).y; + float blue = texture2D(m_Texture, UVblue).z; + outColor = vec4( red, green, blue, 1.0 ); + + //} +} diff --git a/jme3-xr/src/main/resources/Common/MatDefs/VR/OpenVR15.vert b/jme3-xr/src/main/resources/Common/MatDefs/VR/OpenVR15.vert new file mode 100644 index 0000000000..e0c17a91b1 --- /dev/null +++ b/jme3-xr/src/main/resources/Common/MatDefs/VR/OpenVR15.vert @@ -0,0 +1,17 @@ +#import "Common/ShaderLib/GLSLCompat.glsllib" +in vec4 inPosition; + +in vec2 inTexCoord; // m_inUVred +in vec2 inTexCoord2; // m_inUVgreen +in vec2 inTexCoord3; // m_inUVblue + +out vec2 UVred; +out vec2 UVgreen; +out vec2 UVblue; + +void main() { + gl_Position = inPosition; + UVred = inTexCoord; + UVgreen = inTexCoord2; + UVblue = inTexCoord3; +} \ No newline at end of file diff --git a/jme3-xr/src/main/resources/Common/MatDefs/VR/PostShadowFilter.frag b/jme3-xr/src/main/resources/Common/MatDefs/VR/PostShadowFilter.frag new file mode 100644 index 0000000000..c940462d8a --- /dev/null +++ b/jme3-xr/src/main/resources/Common/MatDefs/VR/PostShadowFilter.frag @@ -0,0 +1,184 @@ +#import "Common/ShaderLib/GLSLCompat.glsllib" +#import "Common/ShaderLib/MultiSample.glsllib" +#import "Common/ShaderLib/Shadows.glsllib" + + +uniform COLORTEXTURE m_Texture; +uniform DEPTHTEXTURE m_DepthTexture; +uniform mat4 m_ViewProjectionMatrixInverse; +uniform vec4 m_ViewProjectionMatrixRow2; + +#ifdef INSTANCING + uniform mat4 m_ViewProjectionMatrixInverseRight; + uniform vec4 m_ViewProjectionMatrixRow2Right; +#endif + +in vec2 texCoord; +out vec4 outFragColor; + +const mat4 biasMat = mat4(0.5, 0.0, 0.0, 0.0, + 0.0, 0.5, 0.0, 0.0, + 0.0, 0.0, 0.5, 0.0, + 0.5, 0.5, 0.5, 1.0); + +uniform mat4 m_LightViewProjectionMatrix0; +uniform mat4 m_LightViewProjectionMatrix1; +uniform mat4 m_LightViewProjectionMatrix2; +uniform mat4 m_LightViewProjectionMatrix3; + +uniform vec2 g_ResolutionInverse; + +#ifdef POINTLIGHT + uniform vec3 m_LightPos; + uniform mat4 m_LightViewProjectionMatrix4; + uniform mat4 m_LightViewProjectionMatrix5; +#else + uniform vec3 m_LightDir; + #ifndef PSSM + uniform vec3 m_LightPos; + #endif +#endif + +#ifdef FADE +uniform vec2 m_FadeInfo; +#endif + +vec3 getPosition(in float depth, in vec2 uv){ + #ifdef INSTANCING + vec4 pos; + mat4 usemat; + uv.x *= 2.0; + if( uv.x > 1.0 ) { + // right eye + uv.x -= 1.0; + usemat = m_ViewProjectionMatrixInverseRight; + } else { + // left eye + usemat = m_ViewProjectionMatrixInverse; + } + pos = vec4(uv, depth, 1.0) * 2.0 - 1.0; + pos = usemat * pos; + #else + vec4 pos = vec4(uv, depth, 1.0) * 2.0 - 1.0; + pos = m_ViewProjectionMatrixInverse * pos; + #endif + return pos.xyz / pos.w; +} + +#ifndef BACKFACE_SHADOWS + vec3 approximateNormal(in float depth,in vec4 worldPos,in vec2 texCoord, in int numSample){ + float step = g_ResolutionInverse.x ; + float stepy = g_ResolutionInverse.y ; + float depth1 = fetchTextureSample(m_DepthTexture,texCoord + vec2(-step,stepy),numSample).r; + float depth2 = fetchTextureSample(m_DepthTexture,texCoord + vec2(step,stepy),numSample).r; + vec3 v1, v2; + vec4 worldPos1 = vec4(getPosition(depth1,texCoord + vec2(-step,stepy)),1.0); + vec4 worldPos2 = vec4(getPosition(depth2,texCoord + vec2(step,stepy)),1.0); + + v1 = normalize((worldPos1 - worldPos)).xyz; + v2 = normalize((worldPos2 - worldPos)).xyz; + return normalize(cross(v2, v1)); + + } +#endif + +vec4 main_multiSample(in int numSample){ + float depth = fetchTextureSample(m_DepthTexture,texCoord,numSample).r;//getDepth(m_DepthTexture,texCoord).r; + vec4 color = fetchTextureSample(m_Texture,texCoord,numSample); + + //Discard shadow computation on the sky + if(depth == 1.0){ + return color; + } + + // get the vertex in world space + vec4 worldPos = vec4(getPosition(depth,texCoord),1.0); + + + vec3 lightDir; + #ifdef PSSM + lightDir = m_LightDir; + #else + lightDir = worldPos.xyz - m_LightPos; + #endif + + #ifndef BACKFACE_SHADOWS + vec3 normal = approximateNormal(depth, worldPos, texCoord, numSample); + float ndotl = dot(normal, lightDir); + if(ndotl > 0.0){ + return color; + } + #endif + + #if (!defined(POINTLIGHT) && !defined(PSSM)) + if( dot(m_LightDir,lightDir)<0){ + return color; + } + #endif + + // populate the light view matrices array and convert vertex to light viewProj space + vec4 projCoord0 = biasMat * m_LightViewProjectionMatrix0 * worldPos; + vec4 projCoord1 = biasMat * m_LightViewProjectionMatrix1 * worldPos; + vec4 projCoord2 = biasMat * m_LightViewProjectionMatrix2 * worldPos; + vec4 projCoord3 = biasMat * m_LightViewProjectionMatrix3 * worldPos; + #ifdef POINTLIGHT + vec4 projCoord4 = biasMat * m_LightViewProjectionMatrix4 * worldPos; + vec4 projCoord5 = biasMat * m_LightViewProjectionMatrix5 * worldPos; + #endif + + float shadow = 1.0; + + #if defined(PSSM) || defined(FADE) + #ifdef INSTANCING + vec4 useMat = (texCoord.x > 0.5 ? m_ViewProjectionMatrixRow2Right : m_ViewProjectionMatrixRow2); + float shadowPosition = useMat.x * worldPos.x + useMat.y * worldPos.y + useMat.z * worldPos.z + useMat.w; + #else + float shadowPosition = m_ViewProjectionMatrixRow2.x * worldPos.x + m_ViewProjectionMatrixRow2.y * worldPos.y + m_ViewProjectionMatrixRow2.z * worldPos.z + m_ViewProjectionMatrixRow2.w; + #endif + #endif + + #ifdef POINTLIGHT + shadow = getPointLightShadows(worldPos, m_LightPos, + m_ShadowMap0,m_ShadowMap1,m_ShadowMap2,m_ShadowMap3,m_ShadowMap4,m_ShadowMap5, + projCoord0, projCoord1, projCoord2, projCoord3, projCoord4, projCoord5); + #else + #ifdef PSSM + shadow = getDirectionalLightShadows(m_Splits, shadowPosition, + m_ShadowMap0,m_ShadowMap1,m_ShadowMap2,m_ShadowMap3, + projCoord0, projCoord1, projCoord2, projCoord3); + #else + //spotlight + shadow = getSpotLightShadows(m_ShadowMap0,projCoord0); + #endif + #endif + + + #ifdef FADE + shadow = clamp(max(0.0,mix(shadow, 1.0 ,(shadowPosition - m_FadeInfo.x) * m_FadeInfo.y)),0.0,1.0); + #endif + + shadow= shadow * m_ShadowIntensity + (1.0 - m_ShadowIntensity); + return color * vec4(shadow, shadow, shadow, 1.0); +} + +void main(){ + + #if !defined( RENDER_SHADOWS ) + outFragColor = fetchTextureSample(m_Texture,texCoord,0); + return; + #endif + + #ifdef RESOLVE_MS + vec4 color = vec4(0.0); + for (int i = 0; i < m_NumSamples; i++){ + color += main_multiSample(i); + } + outFragColor = color / m_NumSamples; + #else + outFragColor = main_multiSample(0); + #endif + +} + + + diff --git a/jme3-xr/src/main/resources/Common/MatDefs/VR/PostShadowFilter.j3md b/jme3-xr/src/main/resources/Common/MatDefs/VR/PostShadowFilter.j3md new file mode 100644 index 0000000000..3bdd5b2ea1 --- /dev/null +++ b/jme3-xr/src/main/resources/Common/MatDefs/VR/PostShadowFilter.j3md @@ -0,0 +1,99 @@ +MaterialDef Post Shadow { + + MaterialParameters { + Int FilterMode + Boolean HardwareShadows + + Texture2D ShadowMap0 + Texture2D ShadowMap1 + Texture2D ShadowMap2 + Texture2D ShadowMap3 + //pointLights + Texture2D ShadowMap4 + Texture2D ShadowMap5 + + Float ShadowIntensity + Vector4 Splits + Vector2 FadeInfo + + Matrix4 LightViewProjectionMatrix0 + Matrix4 LightViewProjectionMatrix1 + Matrix4 LightViewProjectionMatrix2 + Matrix4 LightViewProjectionMatrix3 + //pointLight + Matrix4 LightViewProjectionMatrix4 + Matrix4 LightViewProjectionMatrix5 + Vector3 LightPos + Vector3 LightDir + + Float PCFEdge + + Float ShadowMapSize + + Matrix4 ViewProjectionMatrixInverse + Vector4 ViewProjectionMatrixRow2 + + Int NumSamples + Int NumSamplesDepth + Texture2D Texture + Texture2D DepthTexture + + // is VR instancing? + Matrix4 ViewProjectionMatrixInverseRight + Vector4 ViewProjectionMatrixRow2Right + + Boolean BackfaceShadows: true + } + + Technique { + VertexShader GLSL150: Common/MatDefs/VR/PostShadowFilter.vert + FragmentShader GLSL150: Common/MatDefs/VR/PostShadowFilter.frag + + WorldParameters { + ResolutionInverse + } + + Defines { + RESOLVE_MS : NumSamples + RESOLVE_DEPTH_MS : NumSamplesDepth + HARDWARE_SHADOWS : HardwareShadows + FILTER_MODE : FilterMode + PCFEDGE : PCFEdge + SHADOWMAP_SIZE : ShadowMapSize + FADE : FadeInfo + PSSM : Splits + POINTLIGHT : LightViewProjectionMatrix5 + //if no shadow map don't render shadows + RENDER_SHADOWS : ShadowMap0 + INSTANCING : ViewProjectionMatrixInverseRight + BACKFACE_SHADOWS : BackfaceShadows + } + + } + + Technique { + VertexShader GLSL100: Common/MatDefs/Shadow/PostShadowFilter.vert + FragmentShader GLSL100: Common/MatDefs/Shadow/PostShadowFilter.frag + + WorldParameters { + ResolutionInverse + } + + Defines { + HARDWARE_SHADOWS : HardwareShadows + FILTER_MODE : FilterMode + PCFEDGE : PCFEdge + SHADOWMAP_SIZE : ShadowMapSize + FADE : FadeInfo + PSSM : Splits + POINTLIGHT : LightViewProjectionMatrix5 + INSTANCING : ViewProjectionMatrixInverseRight + BACKFACE_SHADOWS : BackfaceShadows + } + + } + + + + +} \ No newline at end of file diff --git a/jme3-xr/src/main/resources/Common/MatDefs/VR/PostShadowFilter.vert b/jme3-xr/src/main/resources/Common/MatDefs/VR/PostShadowFilter.vert new file mode 100644 index 0000000000..d8ffbbfcb9 --- /dev/null +++ b/jme3-xr/src/main/resources/Common/MatDefs/VR/PostShadowFilter.vert @@ -0,0 +1,11 @@ +//#define VERTEX_SHADER +#import "Common/ShaderLib/GLSLCompat.glsllib" + +attribute vec4 inPosition; +attribute vec2 inTexCoord; +varying vec2 texCoord; + +void main() { + gl_Position = vec4(inPosition.xy * 2.0 - 1.0, 0.0, 1.0); + texCoord = inTexCoord; +} \ No newline at end of file diff --git a/jme3-xr/src/main/resources/Common/MatDefs/VR/Unshaded.frag b/jme3-xr/src/main/resources/Common/MatDefs/VR/Unshaded.frag new file mode 100644 index 0000000000..14217abc4a --- /dev/null +++ b/jme3-xr/src/main/resources/Common/MatDefs/VR/Unshaded.frag @@ -0,0 +1,21 @@ +//#define FRAGMENT_SHADER +#import "Common/ShaderLib/GLSLCompat.glsllib" + +uniform vec4 m_Color; +uniform sampler2D m_ColorMap; + +varying vec2 texCoord1; + +void main(){ + vec4 color = vec4(1.0); + + #ifdef HAS_COLORMAP + color *= texture2D(m_ColorMap, texCoord1); + #endif + + #ifdef HAS_COLOR + color *= m_Color; + #endif + + gl_FragColor = color; +} \ No newline at end of file diff --git a/jme3-xr/src/main/resources/Common/MatDefs/VR/Unshaded.j3md b/jme3-xr/src/main/resources/Common/MatDefs/VR/Unshaded.j3md new file mode 100644 index 0000000000..81e1ebecc4 --- /dev/null +++ b/jme3-xr/src/main/resources/Common/MatDefs/VR/Unshaded.j3md @@ -0,0 +1,45 @@ +MaterialDef Unshaded { + + MaterialParameters { + Texture2D ColorMap + Color Color (Color) + + // For VR instancing + Matrix4 RightEyeViewProjectionMatrix + } + + Technique { + VertexShader GLSL150: Common/MatDefs/VR/Unshaded.vert + FragmentShader GLSL150: Common/MatDefs/VR/Unshaded.frag + + WorldParameters { + WorldViewProjectionMatrix + ViewProjectionMatrix // needed for VR instancing + ViewMatrix + } + + Defines { + INSTANCING : RightEyeViewProjectionMatrix // For VR instancing + HAS_COLORMAP : ColorMap + HAS_COLOR : Color + } + } + + Technique { + VertexShader GLSL100: Common/MatDefs/VR/Unshaded.vert + FragmentShader GLSL100: Common/MatDefs/VR/Unshaded.frag + + WorldParameters { + WorldViewProjectionMatrix + ViewProjectionMatrix // needed for VR instancing + ViewMatrix + } + + Defines { + INSTANCING : RightEyeViewProjectionMatrix // For VR instancing + HAS_COLORMAP : ColorMap + HAS_COLOR : Color + } + } + +} \ No newline at end of file diff --git a/jme3-xr/src/main/resources/Common/MatDefs/VR/Unshaded.vert b/jme3-xr/src/main/resources/Common/MatDefs/VR/Unshaded.vert new file mode 100644 index 0000000000..6e72b10e7f --- /dev/null +++ b/jme3-xr/src/main/resources/Common/MatDefs/VR/Unshaded.vert @@ -0,0 +1,27 @@ +//#define VERTEX_SHADER +#import "Common/ShaderLib/GLSLCompat.glsllib" + +// import the following for VR instancing +#import "Common/ShaderLib/InstanceVR.glsllib" + +attribute vec3 inPosition; + +#if defined(HAS_COLORMAP) || (defined(HAS_LIGHTMAP) && !defined(SEPARATE_TEXCOORD)) + #define NEED_TEXCOORD1 +#endif + +attribute vec2 inTexCoord; +attribute vec4 inColor; + +varying vec2 texCoord1; + +void main(){ + #ifdef NEED_TEXCOORD1 + texCoord1 = inTexCoord; + #endif + + vec4 modelSpacePos = vec4(inPosition, 1.0); + + // use the following transform function for VR instancing + gl_Position = TransformWorldViewProjectionVR(modelSpacePos); +} \ No newline at end of file diff --git a/jme3-xr/src/main/resources/Common/MatDefs/VR/normal.frag b/jme3-xr/src/main/resources/Common/MatDefs/VR/normal.frag new file mode 100644 index 0000000000..16d32cedcd --- /dev/null +++ b/jme3-xr/src/main/resources/Common/MatDefs/VR/normal.frag @@ -0,0 +1,9 @@ +//#define FRAGMENT_SHADER +#import "Common/ShaderLib/GLSLCompat.glsllib" + +varying vec3 normal; + +void main(void) +{ + gl_FragColor = vec4(normal.xy* 0.5 + 0.5,-normal.z* 0.5 + 0.5, 1.0); +} diff --git a/jme3-xr/src/main/resources/Common/MatDefs/VR/normal.vert b/jme3-xr/src/main/resources/Common/MatDefs/VR/normal.vert new file mode 100644 index 0000000000..3f590101f5 --- /dev/null +++ b/jme3-xr/src/main/resources/Common/MatDefs/VR/normal.vert @@ -0,0 +1,19 @@ +//#define VERTEX_SHADER +#import "Common/ShaderLib/GLSLCompat.glsllib" + +// import the following for VR instancing +#import "Common/ShaderLib/InstanceVR.glsllib" + +attribute vec3 inPosition; +attribute vec3 inNormal; + +varying vec3 normal; + +void main(void) +{ + vec4 modelSpacePos = vec4(inPosition, 1.0); + normal = normalize(TransformNormal(inNormal)); + + // use the following transform function for VR instancing + gl_Position = TransformWorldViewProjectionVR(modelSpacePos); +} \ No newline at end of file diff --git a/jme3-xr/src/main/resources/Common/ShaderLib/InstanceVR.glsllib b/jme3-xr/src/main/resources/Common/ShaderLib/InstanceVR.glsllib new file mode 100644 index 0000000000..99629173f9 --- /dev/null +++ b/jme3-xr/src/main/resources/Common/ShaderLib/InstanceVR.glsllib @@ -0,0 +1,126 @@ +// Instancing GLSL library. Modified for VR use. +// +// When the INSTANCING define is set in the shader, +// all global matrices are replaced with "instanced" versions. +// One exception is g_NormalMatrix which becomes unusable, +// instead the function ApplyNormalTransform is used to transform +// the normal and tangent vectors into world view space. + +// The world matrix and normal transform quaternion need to be passed +// as vertex attributes "inWorldMatrix" and "inNormalRotationQuaternion" +// respectively. +// The VertexBuffers for those two attributes +// need to be configured into instanced mode (VertexBuffer.setInstanced(true)). +// - inWorldMatrix should have 12 * numInstances floats. +// - inNormalRotationQuaternion should have 4 * numInstances. +// Thus, instancing data occupies 4 vertex attributes (16 / 4 = 4). +// +// The GL_ARB_draw_instanced and GL_ARB_instanced_arrays extensions +// are required (OGL 3.3). + +#if defined INSTANCING + +uniform mat4 g_ViewProjectionMatrix; +uniform mat4 g_ViewMatrix; +uniform mat4 m_RightEyeViewProjectionMatrix; + +// World Matrix + Normal Rotation Quaternion. +// The World Matrix is the top 3 rows - +// since the bottom row is always 0,0,0,1 for this transform. +// The bottom row is the transpose of the inverse of WorldView Transform +// as a quaternion. i.e. g_NormalMatrix converted to a quaternion. +// +// Using a quaternion instead of a matrix here allows saving approximately +// 2 vertex attributes which now can be used for additional per-vertex data. +attribute mat4 inInstanceData; + +// Extract the world matrix out of the instance data, leaving out the +// quaternion at the end. +mat4 worldMatrix = mat4(vec4(inInstanceData[0].xyz, 0.0), + vec4(inInstanceData[1].xyz, 0.0), + vec4(inInstanceData[2].xyz, 0.0), + vec4(inInstanceData[3].xyz, 1.0)); + +vec4 TransformWorld(vec4 position) +{ + return (worldMatrix * position); +} + +vec4 TransformWorldView(vec4 position) +{ + return g_ViewMatrix * TransformWorld(position); +} + +vec4 TransformWorldViewProjection(vec4 position) +{ + return g_ViewProjectionMatrix * TransformWorld(position); +} + +// VR specific variables +const float EyeOffsetScale[2] = float[](-0.5, 0.5); +const vec4 EyeClipEdge[2] = vec4[](vec4(-1.0,0.0,0.0,1.0), vec4(1.0,0.0,0.0,1.0)); +out float gl_ClipDistance[1]; +in int gl_InstanceID; + +vec4 TransformWorldViewProjectionVR(vec4 position) +{ + vec4 clipPos = (gl_InstanceID == 0 ? g_ViewProjectionMatrix : m_RightEyeViewProjectionMatrix) * TransformWorld(position); + gl_ClipDistance[0] = dot(clipPos, EyeClipEdge[gl_InstanceID]); + clipPos.x *= 0.5; // shrink to half of the screen + clipPos.x += EyeOffsetScale[gl_InstanceID] * clipPos.w; // scoot left or right. + return clipPos; +} + +vec3 TransformNormal(vec3 vec) +{ + vec4 quat = vec4(inInstanceData[0].w, inInstanceData[1].w, + inInstanceData[2].w, inInstanceData[3].w); + + vec3 worldNormal = vec + vec3(2.0) * cross(cross(vec, quat.xyz) + vec3(quat.w) * vec, quat.xyz); + + return (g_ViewMatrix * vec4(worldNormal, 0.0)).xyz; +} + +// Prevent user from using g_** matrices which will have invalid data in this case. +#define g_WorldMatrix use_TransformWorld_not_gWorldMatrix +#define g_WorldViewMatrix use_TransformWorldView_not_gWorldMatrix +#define g_WorldViewProjectionMatrix use_TransformWorldViewProjectionVR_not_gWorldViewProjectionMatrix +#define g_NormalMatrix use_TransformNormal_not_gNormalMatrix + +#else + +uniform mat4 g_WorldMatrix; +uniform mat4 g_WorldViewMatrix; +uniform mat4 g_WorldViewProjectionMatrix; +uniform mat3 g_NormalMatrix; +uniform mat3 g_WorldNormalMatrix; + +vec4 TransformWorld(vec4 position) +{ + return g_WorldMatrix * position; +} + +vec4 TransformWorldView(vec4 position) +{ + return g_WorldViewMatrix * position; +} + +vec4 TransformWorldViewProjection(vec4 position) +{ + return g_WorldViewProjectionMatrix * position; +} + +vec4 TransformWorldViewProjectionVR(vec4 position) +{ + return g_WorldViewProjectionMatrix * position; +} + +vec3 TransformNormal(vec3 normal) { + return g_NormalMatrix * normal; +} + +vec3 TransformWorldNormal(vec3 normal) { + return normalize(g_WorldNormalMatrix * normal); +} + +#endif \ No newline at end of file diff --git a/jme3-xr/src/main/resources/Common/Util/gui_mesh.j3o b/jme3-xr/src/main/resources/Common/Util/gui_mesh.j3o new file mode 100644 index 0000000000000000000000000000000000000000..728a7060207cc28f5466abe45263f5e21caa3e5e GIT binary patch literal 4995 zcmZu#U2L0I89v8NQ!~wT+V{{Y_IJCu!2AP12;vhQv+cC0`O3$6v9X zl8z01bVHM-2_e|HVHeYcxBwyUKmyHQ#Rc2|nm~XMyWpZ5LhND^0tpa;=Q%#db~9YP zKj%H~dC&9ye2qWfT$mXXLIgk!Q3=jZ&xX63xV!6&B?=o(&PhD) z{6+9Xo9SZuxm+Q$opUx=E75`6$!F5p#DY<@2eWOoTWg!nmb?o~>|Q#b-gR)G5VF~I)JEDtCpL<1 zeryZgLBXr#zD6J)Xt?slI(zVN11_%0(5C~vd%8j*B+7y+gm#i+2tT1lb0%0a*0UfPx_I zg+MG^803N?pjSY3pw~h5pl^esp!Yy*<6}?*=-;45gyz{Mg!%-s8AtvA*#Z|2vK6N9 zLmqS9YmqzOXG7yxJ5QYz$Y`T4C?)u!~ zKVR4EF0}eMCmvuZXv^w3d+9;k@7)mdHze3AW!||?Qu%2ztkKuddk?fPwBU* zAHYsscx^|1XnchC)-$gg-79_b8?RDNf=VsvkBu(8AFcl#y6{N968|;2S1Q}-pHk)c z`m8F)p}(if@u{bjxtH;iHSyK`H-2N|t53f2M;kv`j-OKWH~66o_3~f7MIWs{?0wJZ zUa}mA{+0SbxAmdFr@rtoWBgMlj>hj-@e98Ok6*=;^2_*jeBaa`F@;})$FJf^89V(w zTYvhS`V)`vOnmKQ@cZmjwZAq#`z!o1e(EXT^u0vg;D=tpul)@k?O(>}!Kcz+`rH1} z-{OJpm8y6u^{0=mo7Ss%yrh{Q#<%@teA{2`U&UklMLd=H;aNLB#9;dcz0xoG_-4lF zV``%3%`eZJo_Sjz?PHz`1w6Kf&?_@fyLlFLzsy2IGw zeO6V^mTSdF{qd8JdSsE`U9x!4V>@jMW!P-{_34hb?l`>B>&^(F50-K z?H9h6R3H5Q%gJm1>Q#U4y-pxv{lmCw`qP5e8wR@6&pwz@@n5^iH~-P0z8ZPI1WJDQ z;j;QjJw{Q5n0?yOzSNPF*0GnQ9kENe!)JWNC?S^5IP}CFKI2oz-9GO%@k@+<@~7V^ zz5IT^-#j#`ectIF_Fs84ZsV62pRsud<7f9z`-3YVmVW-@E;au32A{MN?pKV#Sd7Ek z)YQkf^*I{)UFq$yQU9-nBZ@H?i*XEo#rOt~s==cy9@dWdO?<`r8$8JxJc@Wsd_}v# zZ|m=~7L3DOsWZO8pEUS+hmFrzIzF%~;IaMEwPwBszn!0? zogd~}(=X!J{omOnhAv&YgV*%~}0yntOGv@Sq3Y`%LHelsZF z1tPR(ovHEv5}jgITKglmkYx6)q&*IsmD)}pL)N~IHT^tex6<0VM@pG}D`{Iddz7@- zQrzrwkK~zsD`|^^h@H|iIaoiAem`y;bYNqa2` zv(G(}Fn3$2ZLr4;7JWC|tfZYjR?_ZaZKbuZ8$ZwNTWRf2V1|$W5Kqm=o}uKOlmfJF z{8L71JGQhm*cgUu`cSSLNu3l|{Cjlj$-hV8x!k6+ACgT^yrGBj4VT~9`OP{Yf&yR3 z@rDo<5%79^*N%b5@J`T(_kb2qGk7b$^B)Gafw$w!btk9;yh|JvJ)myzW1?5|f%l2y zA}*f7_vtvOUkr$+#US{gI4MqvXT%xMY4EdRNDPA#;3MK$F$Nk1KPS$M3*Z;TMR7@7 z7USUK;)<9MS49#$DHN;|nk($I0pA4p1gtGUdlmdDR?p(x74R#F8UyZ2;FqvI4ByM( zm$3@to{QiYk^Lw<&w-!A`U>Kn2S1P15YQz+W8i(L%MfTp^B80d5l2J{*-V0l!KaXa z3UpTUKFB_JpB2-{{u<~E_#`~1L8mlNKqgR?Q>fYis`M1-gqXqW@BsJ#*0bU|syGW8 z5I0cQe(-)VCvJ*cSltBOfHniqTcEg@M<0%Z9|xK_cpd{khIK#U_Ja3fbp+k(0QG<` zh()Xyu_C_>c^h5r!hP-NTRS>E2n0)5FJVQ#0J#9~c1%nws?dsx#^BY7bthKj9grQE z8ct6ms@{msw87GYbq`kL-H_dwvPNL4M`e3KeL#5$^Gg)loIOzLS= zYz*r$tjI?pN71WFU8GbZ8()Nlj2>E@cM*00*Z@L_t(o!@ZboNR(?D z$N$ef^P*$Eq%)3=FT-Ry8k&l_iDjlI%Tm+vrAae{2nouN{ZJ{aQ4qEn!hR@h&sKO~ zV^PW$IwE@#i)w*>|UG9Vz}zX05-s;Y$V1`Y@aAOIE@7Y|6k-MMq; z`+((gIRP*wCFMFvF90}m=FG~1{r&xU;J^WzOeU&SD(2+m{0RU^t~_|}-n}GArBcb& zt5>tKvU0mLzEXccCVjEn?RfFx1w>KA)vH(A%gW0B004p@teoP~(o#-MP0`_Su(h?7 zq9{_U)edxZb!}czS4&{YYHDf-fF2$mf4_P2rrV0RJRl%|rKP2uoSdY?;h^1aCrMUR zR1g5OvaFTNxR)no6W|&ygUM6Sy|c7()^*Jq2&SV^?H_+l+b3gxxggp zbUHaWI7oxRKv5JY&1UlflCouw>Y2>X&kybG?NF=L%DZ>(UZ|_9O9gFK zJ18iK7K?>8n~n3?{{8z2fEgJXw@At?7R$GTgM))oK7e0b~~r0rg;4LaROjkTH1q=krBm$6&MVLMS~@{!{Ok> z!~`=lGYNpXxw(HMsanvUhlYl-sHlh&6BGOvlY-ID&yOmVim|b=5lgPs3pKml4y)A) zwOY--zP=a9$;q(*aPi{Bxm~>!#h+VeXD1a31@(IU#O2GE^XIJTVPRn`EG%?^7m~+w z*{M^f2!KYT@z<)VDxX;uYcv{WWo2=Ee0<4JX}#1srKhLgAt|3xd2nzrw{PFhv9Ylw zgFm<3yLS@+lai9I&w4s-+qR8kV`Iw(l?3SZdb+#2(_*nSk`zDZ%2g^AL{WrHCUd!C zsb{UU{`vFg2n!2COG}HzZns|t@UNnxB5d5a5ilB!%*n}_H>#zA;cz(E+uO_G;o$`- zfAr`PeSCbV)9IY`_4P3T(A(SldphmfwQEkWbZSX1Y-wqskB<-4YBjyQyy)%iO@DuX z>U278-n^OT&Yk0{SFc>_o12@tYSk)wd3gnsIRY&$BrH2hYue} zlB1)e)Mzx6$z*ngLh%&9zqMNJZ?Unl^zrc_fUiD+AW#%V1_lQHoRgCylgnhXSubaT zAYgoa9NF2~c=F^4Dl01i0G^(nFq_S2YHAWvQ&a!a(b4hayLa#WIy*aa8X6j=A3l7D z(a}*MBqU_@$jFGG)9JJtjV7$Ox7RHxDXGBA%j*}cUAva~`S~-t+GexSU@%Y+1Onj6 zlP6tcV`F0kK$FSz&$hNU_u0FG(5oSd8_Np9V`l@SpUJb3V6=%PbEEG&#>v-vA=Ha50$(csS&Pft&iBuyq0l}aV!;^G>lc?k&#KgeXV zvADQ6SKti|4KX@8n(^`R1b}PTt}PyHv)MQ?F~Qv2T&mS-CMG7f{@;E@Xtmn+TCJ8= ztJRfWQU}u1)bz(i-7vz#!-Ch&<-;2`Y=~blI5IL)y8Y8=G`7vv)&hXpY<}&wBxK^OSarAq|BlfX&U#Ut|FQMny&ar?9Zlb3rbTii%=NN=iq6e}9nlR&VFd zoiom@uC7L9Wo2k$Vj@i@(-&n`3bGqFZsY;LvuDrd24`es{7TXn0IXK)ynpoN%a`u) z@$uII&}y~16b}px5C9`0BANi;%9Sga?@Hne0FNI(o)fBb zpFVwJc6PQ?r_+(7ZbAF};K74M6&;dlnM`I43JRjb;c&V8?Afyfz|73dKQH?$s@Jby z0|3&}(z;bD6;JCX{lgtfJ`?FPU@hYo$Ay0Ea23WZ{-prD|1 z#oh|8S+iy^A|k@oAduvV6DJ6O2?+^5ExT%I@2ab-F9P8G`}bK+kAnwq&~Kzqr Date: Fri, 24 Feb 2023 00:05:20 +0100 Subject: [PATCH 02/18] Cleanup oculus. Include openxr instead openvr. --- jme3-xr/build.gradle | 22 +- .../main/java/com/jme3/app/VREnvironment.java | 14 - .../java/com/jme3/input/vr/VRInputType.java | 100 +-- .../input/vr/lwjgl_openvr/LWJGLOpenVR.java | 36 +- .../lwjgl_openvr/LWJGLOpenVRViewManager.java | 4 +- .../input/vr/oculus/OculusMouseManager.java | 106 --- .../com/jme3/input/vr/oculus/OculusVR.java | 663 ------------------ .../jme3/input/vr/oculus/OculusVRInput.java | 370 ---------- .../input/vr/oculus/OculusViewManager.java | 340 --------- .../jme3/input/vr/oculus/package-info.java | 35 - 10 files changed, 16 insertions(+), 1674 deletions(-) delete mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/oculus/OculusMouseManager.java delete mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/oculus/OculusVR.java delete mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/oculus/OculusVRInput.java delete mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/oculus/OculusViewManager.java delete mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/oculus/package-info.java diff --git a/jme3-xr/build.gradle b/jme3-xr/build.gradle index 6fbc20d209..6ae71e8151 100644 --- a/jme3-xr/build.gradle +++ b/jme3-xr/build.gradle @@ -8,17 +8,17 @@ dependencies { implementation 'net.java.dev.jna:jna:5.10.0' implementation 'com.nativelibs4java:jnaerator-runtime:0.12' - // Native LibOVR/Oculus support - api "org.lwjgl:lwjgl-ovr:${lwjgl3Version}" - runtimeOnly "org.lwjgl:lwjgl-ovr:${lwjgl3Version}:natives-windows" - - // Native OpenVR/LWJGL support - api "org.lwjgl:lwjgl-openvr:${lwjgl3Version}" - implementation "org.lwjgl:lwjgl-openvr:${lwjgl3Version}:natives-linux" - implementation "org.lwjgl:lwjgl-openvr:${lwjgl3Version}:natives-macos" - runtimeOnly "org.lwjgl:lwjgl-openvr:${lwjgl3Version}:natives-windows" - runtimeOnly "org.lwjgl:lwjgl-openvr:${lwjgl3Version}:natives-linux" - runtimeOnly "org.lwjgl:lwjgl-openvr:${lwjgl3Version}:natives-macos" + // Native OpenXR/LWJGL support + api "org.lwjgl:lwjgl-openxr:${lwjgl3Version}" +// implementation "org.lwjgl:lwjgl-openxr:${lwjgl3Version}:natives-linux" +// implementation "org.lwjgl:lwjgl-openxr:${lwjgl3Version}:natives-macos" + runtimeOnly "org.lwjgl:lwjgl-openxr:${lwjgl3Version}:natives-windows" + runtimeOnly "org.lwjgl:lwjgl-openxr:${lwjgl3Version}:natives-linux" + runtimeOnly "org.lwjgl:lwjgl-openxr:${lwjgl3Version}:natives-macos" + + // Necessary by lwjgl-openxr + implementation "org.joml:joml:1.10.4" + implementation "org.lwjgl:lwjgl-vulkan:${lwjgl3Version}" } javadoc { diff --git a/jme3-xr/src/main/java/com/jme3/app/VREnvironment.java b/jme3-xr/src/main/java/com/jme3/app/VREnvironment.java index 6dd41d6cde..06d59f5cac 100644 --- a/jme3-xr/src/main/java/com/jme3/app/VREnvironment.java +++ b/jme3-xr/src/main/java/com/jme3/app/VREnvironment.java @@ -13,9 +13,6 @@ import com.jme3.input.vr.lwjgl_openvr.LWJGLOpenVR; import com.jme3.input.vr.lwjgl_openvr.LWJGLOpenVRMouseManager; import com.jme3.input.vr.lwjgl_openvr.LWJGLOpenVRViewManager; -import com.jme3.input.vr.oculus.OculusMouseManager; -import com.jme3.input.vr.oculus.OculusVR; -import com.jme3.input.vr.oculus.OculusViewManager; import com.jme3.input.vr.openvr.OpenVR; import com.jme3.input.vr.openvr.OpenVRMouseManager; import com.jme3.input.vr.openvr.OpenVRViewManager; @@ -402,8 +399,6 @@ public void atttach(AppState appState, Application application){ viewManager = new OpenVRViewManager(this); } else if (vrBinding == VRConstants.SETTING_VRAPI_OSVR_VALUE){ viewManager = new OSVRViewManager(this); - } else if (vrBinding == VRConstants.SETTING_VRAPI_OCULUSVR_VALUE) { - viewManager = new OculusViewManager(this); } else if (vrBinding == VRConstants.SETTING_VRAPI_OPENVR_LWJGL_VALUE) { viewManager = new LWJGLOpenVRViewManager(this); } else { @@ -421,8 +416,6 @@ public boolean initialize(){ initialized = false; - // we are going to use OpenVR now, not the Oculus Rift - // OpenVR does support the Rift String OS = System.getProperty("os.name", "generic").toLowerCase(Locale.ENGLISH); vrSupportedOS = System.getProperty("sun.arch.data.model").equalsIgnoreCase("64"); //64-bit only compositorOS = OS.contains("indows") || OS.contains("nux"); @@ -447,13 +440,6 @@ public boolean initialize(){ hardware = new OpenVR(this); initialized = true; logger.config("Creating OpenVR wrapper [SUCCESS]"); - } else if (vrBinding == VRConstants.SETTING_VRAPI_OCULUSVR_VALUE) { - guiManager = new VRGuiManager(this); - mouseManager = new OculusMouseManager(this); - - hardware = new OculusVR(this); - initialized = true; - logger.config("Creating Oculus Rift wrapper [SUCCESS]"); } else if (vrBinding == VRConstants.SETTING_VRAPI_OPENVR_LWJGL_VALUE) { guiManager = new VRGuiManager(this); mouseManager = new LWJGLOpenVRMouseManager(this); diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/VRInputType.java b/jme3-xr/src/main/java/com/jme3/input/vr/VRInputType.java index f4e145c708..0d090c349c 100644 --- a/jme3-xr/src/main/java/com/jme3/input/vr/VRInputType.java +++ b/jme3-xr/src/main/java/com/jme3/input/vr/VRInputType.java @@ -28,103 +28,7 @@ public enum VRInputType { /** * an HTC vive menu button (about Vive controller). */ - ViveMenuButton(3), - - /** - * The thumbstick on the Oculus Touch controllers. - * - * Unlike the Vive controllers where the touchpad is commonly used - * as a virtual DPad, you should avoid using the thumbstick for purposes - * that do not require analog input. - */ - OculusThumbstickAxis(0), - - /** - * The trigger button on the Oculus Touch controllers. - * - * This is the button under the user's index finger, and should not be used to - * pick up objects. See the - * Oculus Developer documentation. - */ - OculusTriggerAxis(0), - - /** - * The 'grab' button on the Oculus Touch controllers. - * - * This button should only (unless you have a compelling reason otherwise) be used to pick up objects. - */ - OculusGripAxis(0), - - /** - * The upper buttons on the Oculus Touch controllers - B on the right controller, and Y on the left. - */ - OculusTopButton(org.lwjgl.ovr.OVR.ovrButton_B | org.lwjgl.ovr.OVR.ovrButton_Y), - - /** - * The lower (not counting menu) buttons on the Oculus Touch - * controllers - A on the right controller, and X on the left. - */ - OculusBottomButton(org.lwjgl.ovr.OVR.ovrButton_A | org.lwjgl.ovr.OVR.ovrButton_X), - - /** - * The 'click' button on the Oculus Touch thumbsticks. - */ - OculusThumbstickButton(org.lwjgl.ovr.OVR.ovrButton_LThumb | org.lwjgl.ovr.OVR.ovrButton_RThumb), - - /** - * The game-usable menu button, under and to the left of the 'X' button on the left controller. - * - * Most games use this to pause - it preferably should be used for at least that purpose, and is - * uncomfortable to rest your thumb on (in games where you suddenly have to pause/open a menu). - */ - OculusMenuButton(org.lwjgl.ovr.OVR.ovrButton_Enter), - - /** - * The capacitive touch sensors on the top buttons (Y and B) of the Oculus Touch. - */ - OculusTopTouch(org.lwjgl.ovr.OVR.ovrTouch_B | org.lwjgl.ovr.OVR.ovrTouch_Y), - - /** - * The capacitive touch sensors on the lower buttons (X and A) of the Oculus Touch. - */ - OculusBottomTouch(org.lwjgl.ovr.OVR.ovrTouch_A | org.lwjgl.ovr.OVR.ovrTouch_X), - - /** - * The capacitive touch sensors on the thumbsticks of the Oculus Touch. - */ - OculusThumbstickTouch(org.lwjgl.ovr.OVR.ovrTouch_LThumb | org.lwjgl.ovr.OVR.ovrTouch_RThumb), - - /** - * The capacitive touch sensors on the thumbrests of the Oculus Touch - this is a textured pad - * on the Oculus Touch controller next to the ABXY buttons for users to reset their thumbs on. - * - * While it probably goes without saying, only use this for gesture support and do not bind game - * elements to it. - */ - OculusThumbrestTouch(org.lwjgl.ovr.OVR.ovrTouch_LThumbRest | org.lwjgl.ovr.OVR.ovrTouch_RThumbRest), - - /** - * The state of a software calculation based on the capacitive touch sensor values that determine if - * the user has lifted their thumb off the controller, and can be used for gesture support. - * - * This should be used instead of calculating this yourself based on the touch results of all the other - * parts of the controller. - */ - OculusThumbUp(org.lwjgl.ovr.OVR.ovrTouch_LThumbUp | org.lwjgl.ovr.OVR.ovrTouch_RThumbUp), - - /** - * Is the user resting their finger on the trigger of an Oculus Touch controller? - */ - OculusIndexTouch(org.lwjgl.ovr.OVR.ovrTouch_LIndexPointing | org.lwjgl.ovr.OVR.ovrTouch_RIndexPointing), - - /** - * Is the user pointing their finger forwards, as if to press a button? - * - * This is internally calculated from proximity and filtering is applied - it should be used rather - * than !OculusIndexTouch, as it will probably lead to better results. - */ - OculusIndexPointing(org.lwjgl.ovr.OVR.ovrTouch_LIndexPointing | org.lwjgl.ovr.OVR.ovrTouch_RIndexPointing); + ViveMenuButton(3); /** * The value that codes the input type. @@ -146,4 +50,4 @@ private VRInputType(int value) { public int getValue() { return value; } -} \ No newline at end of file +} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVR.java b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVR.java index 30c4ec2c99..3a973edc88 100644 --- a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVR.java +++ b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVR.java @@ -382,40 +382,6 @@ public Matrix4f getHMDMatrixPoseRightEye(){ @Override public HmdType getType() { - String completeName = ""; - String name = VRSystem.VRSystem_GetStringTrackedDeviceProperty(VR.k_unTrackedDeviceIndex_Hmd, - VR.ETrackedDeviceProperty_Prop_ManufacturerName_String, - 128, hmdErrorStore); - if( hmdErrorStore.get(0) == 0 ) completeName += name; - String number = VRSystem.VRSystem_GetStringTrackedDeviceProperty(VR.k_unTrackedDeviceIndex_Hmd, - VR.ETrackedDeviceProperty_Prop_ModelNumber_String, - 128, hmdErrorStore); - if( hmdErrorStore.get(0) == 0 ) completeName += " " + number; - if( completeName.length() > 0 ) { - completeName = completeName.toLowerCase(Locale.ENGLISH).trim(); - if( completeName.contains("htc") || completeName.contains("vive") ) { - return HmdType.HTC_VIVE; - } else if ( completeName.contains("index") ) { - return HmdType.VALVE_INDEX; - } else if( completeName.contains("osvr") ) { - return HmdType.OSVR; - } else if( completeName.contains("oculus") || completeName.contains("rift") || - completeName.contains("dk1") || completeName.contains("dk2") || completeName.contains("cv1") ) { - return HmdType.OCULUS_RIFT; - } else if( completeName.contains("fove") ) { - return HmdType.FOVE; - } else if( completeName.contains("game") && completeName.contains("face") ) { - return HmdType.GAMEFACE; - } else if( completeName.contains("morpheus") ) { - return HmdType.MORPHEUS; - } else if( completeName.contains("gear") ) { - return HmdType.GEARVR; - } else if( completeName.contains("star") ) { - return HmdType.STARVR; - } else if( completeName.contains("null") ) { - return HmdType.NULL; - } - } return HmdType.OTHER; } @@ -431,4 +397,4 @@ public void setTrackingSpace(boolean isSeated){ public Matrix4f[] getPoseMatrices() { return poseMatrices; } -} \ No newline at end of file +} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRViewManager.java b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRViewManager.java index 2b658e53f4..8e47a4438a 100644 --- a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRViewManager.java +++ b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRViewManager.java @@ -150,7 +150,7 @@ public void render() { finalRotation.set(objRot); finalRotation.mult(hmdPos, hmdPos); finalRotation.multLocal(hmdRot); - } + } finalizeCamera(dev.getHMDVectorPoseLeftEye(), objPos, getLeftCamera()); finalizeCamera(dev.getHMDVectorPoseRightEye(), objPos, getRightCamera()); @@ -566,4 +566,4 @@ private ViewPort setupViewBuffers(Camera cam, String viewName) { } } -} \ No newline at end of file +} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/oculus/OculusMouseManager.java b/jme3-xr/src/main/java/com/jme3/input/vr/oculus/OculusMouseManager.java deleted file mode 100644 index fc52ee467a..0000000000 --- a/jme3-xr/src/main/java/com/jme3/input/vr/oculus/OculusMouseManager.java +++ /dev/null @@ -1,106 +0,0 @@ -package com.jme3.input.vr.oculus; - -import com.jme3.app.VREnvironment; -import com.jme3.input.controls.AnalogListener; -import com.jme3.input.vr.AbstractVRMouseManager; -import com.jme3.input.vr.VRInputType; -import com.jme3.math.Vector2f; - -/** - * A class dedicated to the mouse handling within Oculus Rift based VR experience. - * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr - * - */ -public class OculusMouseManager extends AbstractVRMouseManager { - private final int AVERAGE_AMNT = 4; - - private int avgCounter; - - private final float[] lastXmv = new float[AVERAGE_AMNT]; - - private final float[] lastYmv = new float[AVERAGE_AMNT]; - - /** - * Create a new VR mouse manager within the given {@link VREnvironment VR environment}. - * @param environment the VR environment of the mouse manager. - */ - public OculusMouseManager(VREnvironment environment){ - super(environment); - } - - @Override - public void updateAnalogAsMouse(int inputIndex, AnalogListener mouseListener, String mouseXName, String mouseYName, float tpf) { - if (getVREnvironment() != null){ - if (getVREnvironment().getApplication() != null){ - // got a tracked controller to use as the "mouse" - if( getVREnvironment().isInVR() == false || - getVREnvironment().getVRinput() == null || - getVREnvironment().getVRinput().isInputDeviceTracking(inputIndex) == false ){ - return; - } - - Vector2f tpDelta; - // TODO option to use Touch joysticks - if( isThumbstickMode() ) { - tpDelta = getVREnvironment().getVRinput().getAxis(inputIndex, VRInputType.OculusThumbstickAxis); - } else { - tpDelta = getVREnvironment().getVRinput().getAxisDeltaSinceLastCall(inputIndex, VRInputType.OculusThumbstickAxis); - } - - float Xamount = (float)Math.pow(Math.abs(tpDelta.x) * getSpeedSensitivity(), getSpeedAcceleration()); - float Yamount = (float)Math.pow(Math.abs(tpDelta.y) * getSpeedSensitivity(), getSpeedAcceleration()); - - if( tpDelta.x < 0f ){ - Xamount = -Xamount; - } - - if( tpDelta.y < 0f ){ - Yamount = -Yamount; - } - - Xamount *= getMouseMoveScale(); - Yamount *= getMouseMoveScale(); - - if( mouseListener != null ) { - if( tpDelta.x != 0f && mouseXName != null ) mouseListener.onAnalog(mouseXName, Xamount * 0.2f, tpf); - if( tpDelta.y != 0f && mouseYName != null ) mouseListener.onAnalog(mouseYName, Yamount * 0.2f, tpf); - } - - if( getVREnvironment().getApplication().getInputManager().isCursorVisible() ) { - int index = (avgCounter+1) % AVERAGE_AMNT; - lastXmv[index] = Xamount * 133f; - lastYmv[index] = Yamount * 133f; - cursorPos.x -= avg(lastXmv); - cursorPos.y -= avg(lastYmv); - Vector2f maxsize = getVREnvironment().getVRGUIManager().getCanvasSize(); - - if( cursorPos.x > maxsize.x ){ - cursorPos.x = maxsize.x; - } - - if( cursorPos.x < 0f ){ - cursorPos.x = 0f; - } - - if( cursorPos.y > maxsize.y ){ - cursorPos.y = maxsize.y; - } - - if( cursorPos.y < 0f ){ - cursorPos.y = 0f; - } - } - } else { - throw new IllegalStateException("This VR environment is not attached to any application."); - } - } else { - throw new IllegalStateException("This VR view manager is not attached to any VR environment."); - } - } - - private float avg(float[] arr) { - float amt = 0f; - for(float f : arr) amt += f; - return amt / arr.length; - } -} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/oculus/OculusVR.java b/jme3-xr/src/main/java/com/jme3/input/vr/oculus/OculusVR.java deleted file mode 100644 index 75c14c1647..0000000000 --- a/jme3-xr/src/main/java/com/jme3/input/vr/oculus/OculusVR.java +++ /dev/null @@ -1,663 +0,0 @@ -package com.jme3.input.vr.oculus; - -import com.jme3.app.VREnvironment; -import com.jme3.input.vr.HmdType; -import com.jme3.input.vr.VRAPI; -import com.jme3.math.*; -import com.jme3.renderer.Camera; -import com.jme3.texture.*; -import org.lwjgl.*; -import org.lwjgl.ovr.*; - -import java.nio.IntBuffer; -import java.util.logging.Logger; - -import static org.lwjgl.BufferUtils.createPointerBuffer; -import static org.lwjgl.ovr.OVR.*; -import static org.lwjgl.ovr.OVRErrorCode.ovrSuccess; -import static org.lwjgl.ovr.OVRUtil.ovr_Detect; -import static org.lwjgl.system.MemoryUtil.*; - -/** - * Oculus VR (LibOVR 1.3.0) Native support. - *

- * A few notes about the Oculus coordinate system: - *

    - *
  • Matrices should be transposed
  • - *
  • Quaternions should be inverted
  • - *
  • Vectors should have their X and Z axes flipped, but apparently not Y.
  • - *
- * - * @author Campbell Suter (znix@znix.xyz) - */ -public class OculusVR implements VRAPI { - - private static final Logger LOGGER = Logger.getLogger(OculusVR.class.getName()); - - private final VREnvironment environment; - private boolean initialized; - - /** - * Pointer to the HMD object - */ - private long session; - - /** - * Information about the VR session (should the app quit, is - * it visible or is the universal menu open, etcetera) - */ - private OVRSessionStatus sessionStatus; - - /** - * HMD information, such as product name and manufacturer. - */ - private OVRHmdDesc hmdDesc; - - /** - * The horizontal resolution of the HMD - */ - private int resolutionW; - - /** - * The vertical resolution of the HMD - */ - private int resolutionH; - - /** - * Field-of-view data for each eye (how many degrees from the - * center can the user see). - */ - private final OVRFovPort fovPorts[] = new OVRFovPort[2]; - - /** - * Data about each eye to be rendered - in particular, the - * offset from the center of the HMD to the eye. - */ - private final OVREyeRenderDesc eyeRenderDesc[] = new OVREyeRenderDesc[2]; - - /** - * Store the projections for each eye, so we don't have to malloc - * and recalculate them each frame. - */ - private final OVRMatrix4f[] projections = new OVRMatrix4f[2]; - - /** - * Store the poses for each eye, relative to the HMD. - * - * @see #getHMDMatrixPoseLeftEye() - */ - private final Matrix4f[] hmdRelativeEyePoses = new Matrix4f[2]; - - /** - * Store the positions for each eye, relative to the HMD. - * - * @see #getHMDVectorPoseLeftEye() - */ - private final Vector3f[] hmdRelativeEyePositions = new Vector3f[2]; - - /** - * The current state of the tracked components (HMD, touch) - */ - private OVRTrackingState trackingState; - - /** - * The position and orientation of the user's head. - */ - private OVRPosef headPose; - - /** - * The state of the Touch controllers. - */ - private OculusVRInput input; - - // The size of the texture drawn onto the HMD - private int textureW; - private int textureH; - - // Layers to render into - private PointerBuffer layers; - private OVRLayerEyeFov layer0; - - /** - * Chain texture set thing. - */ - private long chains[]; - - /** - * Frame buffers we can draw into. - */ - private FrameBuffer framebuffers[][]; - - public OculusVR(VREnvironment environment) { - this.environment = environment; - } - - @Override - public OculusVRInput getVRinput() { - return input; - } - - @Override - public String getName() { - return "OVR"; - } - - @Override - public int getDisplayFrequency() { - // TODO find correct frequency. I'm not sure - // if LibOVR has a way to do that, though. - return 60; - } - - @Override - public boolean initialize() { - // Check to make sure the HMD is connected - OVRDetectResult detect = OVRDetectResult.calloc(); - ovr_Detect(0, detect); - boolean connected = detect.IsOculusHMDConnected(); - LOGGER.config("OVRDetectResult.IsOculusHMDConnected = " + connected); - LOGGER.config("OVRDetectResult.IsOculusServiceRunning = " + detect.IsOculusServiceRunning()); - detect.free(); - - if (!connected) { - LOGGER.info("Oculus Rift not connected"); - return false; - } - - initialized = true; - - // Set up the HMD - OVRLogCallback callback = new OVRLogCallback() { - @Override - public void invoke(long userData, int level, long message) { - LOGGER.fine("LibOVR [" + userData + "] [" + level + "] " + memASCII(message)); - } - }; - OVRInitParams initParams = OVRInitParams.calloc(); - initParams.LogCallback(callback); - if (ovr_Initialize(initParams) != ovrSuccess) { - LOGGER.severe("LibOVR Init Failed"); - return false; // TODO fix memory leak - destroy() is not called - } - LOGGER.config("LibOVR Version " + ovr_GetVersionString()); - initParams.free(); - - // Get access to the HMD - LOGGER.info("Initialize HMD Session"); - PointerBuffer pHmd = memAllocPointer(1); - OVRGraphicsLuid luid = OVRGraphicsLuid.calloc(); - if (ovr_Create(pHmd, luid) != ovrSuccess) { - LOGGER.severe("Failed to create HMD"); - return false; // TODO fix memory leak - destroy() is not called - } - session = pHmd.get(0); - memFree(pHmd); - luid.free(); - sessionStatus = OVRSessionStatus.calloc(); - - // Get the information about the HMD - LOGGER.fine("Get HMD properties"); - hmdDesc = OVRHmdDesc.malloc(); - ovr_GetHmdDesc(session, hmdDesc); - if (hmdDesc.Type() == ovrHmd_None) { - LOGGER.warning("No HMD connected"); - return false; // TODO fix memory leak - destroy() is not called - } - - resolutionW = hmdDesc.Resolution().w(); - resolutionH = hmdDesc.Resolution().h(); - - LOGGER.config("HMD Properties: " - + "\t Manufacturer: " + hmdDesc.ManufacturerString() - + "\t Product: " + hmdDesc.ProductNameString() - + "\t Serial: " // + hmdDesc.SerialNumberString() // Hidden for privacy reasons - + "\t Type: " + hmdDesc.Type() - + "\t Resolution (total): " + resolutionW + "," + resolutionH); - - if (resolutionW == 0) { - LOGGER.severe("HMD width=0 : aborting"); - return false; // TODO fix memory leak - destroy() is not called - } - - // Find the FOV for each eye - for (int eye = 0; eye < 2; eye++) { - fovPorts[eye] = hmdDesc.DefaultEyeFov(eye); - } - - // Get the pose for each eye, and cache it for later. - for (int eye = 0; eye < 2; eye++) { - // Create the projection objects - projections[eye] = OVRMatrix4f.malloc(); - hmdRelativeEyePoses[eye] = new Matrix4f(); - hmdRelativeEyePositions[eye] = new Vector3f(); - - // Find the eye render information - we use this in the - // view manager for giving LibOVR its timewarp information. - eyeRenderDesc[eye] = OVREyeRenderDesc.malloc(); - ovr_GetRenderDesc(session, eye, fovPorts[eye], eyeRenderDesc[eye]); - - // Get the pose of the eye - OVRPosef pose = eyeRenderDesc[eye].HmdToEyePose(); - - // Get the position and rotation of the eye - vecO2J(pose.Position(), hmdRelativeEyePositions[eye]); - Quaternion rotation = quatO2J(pose.Orientation(), new Quaternion()); - - // Put it into a matrix for the get eye pose functions - hmdRelativeEyePoses[eye].loadIdentity(); - hmdRelativeEyePoses[eye].setTranslation(hmdRelativeEyePositions[eye]); - hmdRelativeEyePoses[eye].setRotationQuaternion(rotation); - } - - // Recenter the HMD. The game itself should do this too, but just in case / before they do. - reset(); - - // Do this so others relying on our texture size (the GUI in particular) get it correct. - findHMDTextureSize(); - - // Allocate the memory for the tracking state - we actually - // set it up later, but Input uses it so calloc it now. - trackingState = OVRTrackingState.calloc(); - - // Set up the input - input = new OculusVRInput(this, session, sessionStatus, trackingState); - - // TODO find some way to get in ovrTrackingOrigin_FloorLevel - - // throw new UnsupportedOperationException("Not yet implemented!"); - return true; - } - - @Override - public void updatePose() { - double ftiming = ovr_GetPredictedDisplayTime(session, 0); - ovr_GetTrackingState(session, ftiming, true, trackingState); - ovr_GetSessionStatus(session, sessionStatus); - - input.updateControllerStates(); - - headPose = trackingState.HeadPose().ThePose(); - } - - @Override - public boolean isInitialized() { - return initialized; - } - - @Override - public void destroy() { - // fovPorts: contents are managed by LibOVR, no need to do anything. - - // Clean up the input - input.dispose(); - - // Check if we've set up rendering - if so, clean that up. - if (chains != null) { - // Destroy our set of huge buffer images. - for (long chain : chains) { - ovr_DestroyTextureSwapChain(session, chain); - } - - // Free up the layer - layer0.free(); - - // The layers array apparently takes care of itself (and crashes if we try to free it) - } - - for (OVREyeRenderDesc eye : eyeRenderDesc) { - eye.free(); - } - for (OVRMatrix4f projection : projections) { - projection.free(); - } - - hmdDesc.free(); - trackingState.free(); - sessionStatus.free(); - - // Wrap everything up - ovr_Destroy(session); - ovr_Shutdown(); - } - - @Override - public void reset() { - // Reset the coordinate system - where the user's head is now is facing forwards from [0,0,0] - ovr_RecenterTrackingOrigin(session); - } - - @Override - public void getRenderSize(Vector2f store) { - if (!isInitialized()) { - throw new IllegalStateException("Cannot call getRenderSize() before initialized!"); - } - store.x = textureW; - store.y = textureH; - } - - @Override - public float getInterpupillaryDistance() { - return 0.065f; // TODO - } - - @Override - public Quaternion getOrientation() { - return quatO2J(headPose.Orientation(), new Quaternion()); - } - - @Override - public Vector3f getPosition() { - return vecO2J(headPose.Position(), new Vector3f()); - } - - @Override - public void getPositionAndOrientation(Vector3f storePos, Quaternion storeRot) { - storePos.set(getPosition()); - storeRot.set(getOrientation()); - } - - private Matrix4f calculateProjection(int eye, Camera cam) { - Matrix4f mat = new Matrix4f(); - - // Get LibOVR to find the correct projection - OVRUtil.ovrMatrix4f_Projection(fovPorts[eye], cam.getFrustumNear(), cam.getFrustumFar(), OVRUtil.ovrProjection_None, projections[eye]); - - matrixO2J(projections[eye], mat); - - return mat; - } - - @Override - public Matrix4f getHMDMatrixProjectionLeftEye(Camera cam) { - return calculateProjection(ovrEye_Left, cam); - } - - @Override - public Matrix4f getHMDMatrixProjectionRightEye(Camera cam) { - return calculateProjection(ovrEye_Right, cam); - } - - @Override - public Vector3f getHMDVectorPoseLeftEye() { - return hmdRelativeEyePositions[ovrEye_Left]; - } - - @Override - public Vector3f getHMDVectorPoseRightEye() { - return hmdRelativeEyePositions[ovrEye_Right]; - } - - @Override - public Vector3f getSeatedToAbsolutePosition() { - throw new UnsupportedOperationException(); - } - - @Override - public Matrix4f getHMDMatrixPoseLeftEye() { - return hmdRelativeEyePoses[ovrEye_Left]; - } - - @Override - public Matrix4f getHMDMatrixPoseRightEye() { - return hmdRelativeEyePoses[ovrEye_Left]; - } - - @Override - public HmdType getType() { - return HmdType.OCULUS_RIFT; - } - - @Override - public boolean initVRCompositor(boolean set) { - if (!set) { - throw new UnsupportedOperationException("Cannot use LibOVR without compositor!"); - } - - setupLayers(); - - framebuffers = new FrameBuffer[2][]; - for (int eye = 0; eye < 2; eye++) - setupFramebuffers(eye); - - // TODO move initialization code here from VRViewManagerOculus - return true; - } - - @Override - public void printLatencyInfoToConsole(boolean set) { - throw new UnsupportedOperationException("Not yet implemented!"); - } - - @Override - public void setFlipEyes(boolean set) { - throw new UnsupportedOperationException("Not yet implemented!"); - } - - @Override - public Void getCompositor() { - throw new UnsupportedOperationException("Not yet implemented!"); - } - - @Override - public Void getVRSystem() { - throw new UnsupportedOperationException("Not yet implemented!"); - } - - // Rendering-type stuff - - public void findHMDTextureSize() { - // Texture sizes - float pixelScaling = 1.0f; // pixelsPerDisplayPixel - - OVRSizei leftTextureSize = OVRSizei.malloc(); - ovr_GetFovTextureSize(session, ovrEye_Left, fovPorts[ovrEye_Left], pixelScaling, leftTextureSize); - - OVRSizei rightTextureSize = OVRSizei.malloc(); - ovr_GetFovTextureSize(session, ovrEye_Right, fovPorts[ovrEye_Right], pixelScaling, rightTextureSize); - - if (leftTextureSize.w() != rightTextureSize.w()) { - throw new IllegalStateException("Texture sizes do not match [horizontal]"); - } - if (leftTextureSize.h() != rightTextureSize.h()) { - throw new IllegalStateException("Texture sizes do not match [vertical]"); - } - - textureW = leftTextureSize.w(); - textureH = leftTextureSize.h(); - - leftTextureSize.free(); - rightTextureSize.free(); - } - - private long setupTextureChain() { - // Set up the information for the texture buffer chain thing - OVRTextureSwapChainDesc swapChainDesc = OVRTextureSwapChainDesc.calloc() - .Type(ovrTexture_2D) - .ArraySize(1) - .Format(OVR_FORMAT_R8G8B8A8_UNORM_SRGB) - .Width(textureW) - .Height(textureH) - .MipLevels(1) - .SampleCount(1) - .StaticImage(false); // ovrFalse - - // Create the chain - PointerBuffer textureSetPB = createPointerBuffer(1); - if (OVRGL.ovr_CreateTextureSwapChainGL(session, swapChainDesc, textureSetPB) != ovrSuccess) { - throw new RuntimeException("Failed to create Swap Texture Set"); - } - swapChainDesc.free(); - - return textureSetPB.get(); // TODO is this a memory leak? - } - - public void setupLayers() { - //Layers - layer0 = OVRLayerEyeFov.calloc(); - layer0.Header().Type(ovrLayerType_EyeFov); - layer0.Header().Flags(ovrLayerFlag_TextureOriginAtBottomLeft); - - chains = new long[2]; - for (int eye = 0; eye < 2; eye++) { - long eyeChain = setupTextureChain(); - chains[eye] = eyeChain; - - OVRRecti viewport = OVRRecti.calloc(); - viewport.Pos().x(0); - viewport.Pos().y(0); - viewport.Size().w(textureW); - viewport.Size().h(textureH); - - layer0.ColorTexture(eye, eyeChain); - layer0.Viewport(eye, viewport); - layer0.Fov(eye, fovPorts[eye]); - - viewport.free(); - // we update pose only when we have it in the render loop - } - - layers = createPointerBuffer(1); - layers.put(0, layer0); - } - - /** - * Create a framebuffer for an eye. - */ - public void setupFramebuffers(int eye) { - // Find the chain length - IntBuffer length = BufferUtils.createIntBuffer(1); - ovr_GetTextureSwapChainLength(session, chains[eye], length); - int chainLength = length.get(); - - LOGGER.fine("HMD Eye #" + eye + " texture chain length: " + chainLength); - - // Create the frame buffers - framebuffers[eye] = new FrameBuffer[chainLength]; - for (int i = 0; i < chainLength; i++) { - // find the GL texture ID for this texture - IntBuffer textureIdB = BufferUtils.createIntBuffer(1); - OVRGL.ovr_GetTextureSwapChainBufferGL(session, chains[eye], i, textureIdB); - int textureId = textureIdB.get(); - - // TODO less hacky way of getting our texture into JMonkeyEngine - Image img = new Image(); - img.setId(textureId); - img.setFormat(Image.Format.RGBA8); - img.setWidth(textureW); - img.setHeight(textureH); - - Texture2D tex = new Texture2D(img); - - FrameBuffer buffer = new FrameBuffer(textureW, textureH, 1); - buffer.setDepthBuffer(Image.Format.Depth); - buffer.setColorTexture(tex); - - framebuffers[eye][i] = buffer; - } - } - - // UTILITIES - // TODO move to helper class - - /** - * Copy the values from a LibOVR matrix into a jMonkeyEngine matrix. - * - * @param from The matrix to copy from. - * @param to The matrix to copy to. - * @return The {@code to} argument. - */ - public static Matrix4f matrixO2J(OVRMatrix4f from, Matrix4f to) { - to.loadIdentity(); // For the additional columns (unless I'm badly misunderstanding matrices) - - for (int x = 0; x < 4; x++) { - for (int y = 0; y < 4; y++) { - float val = from.M(x + y * 4); // TODO verify this - to.set(x, y, val); - } - } - - to.transposeLocal(); // jME vs LibOVR coordinate spaces - Yay! - - return to; - } - - /** - * Copy the values from a LibOVR quaternion into a jMonkeyEngine quaternion. - * - * @param from The quaternion to copy from. - * @param to The quaternion to copy to. - * @return The {@code to} argument. - */ - public static Quaternion quatO2J(OVRQuatf from, Quaternion to) { - // jME and LibOVR do their coordinate spaces differently for rotations, so flip Y and W (thanks, jMonkeyVR). - to.set( - from.x(), - -from.y(), - from.z(), - -from.w() - ); - - to.normalizeLocal(); - - return to; - } - - /** - * Copy the values from a LibOVR vector into a jMonkeyEngine vector. - * - * @param from The vector to copy from. - * @param to The vector to copy to. - * @return The {@code to} argument. - */ - public static Vector3f vecO2J(OVRVector3f from, Vector3f to) { - // jME and LibOVR disagree on which way X and Z are, too. - to.set( - -from.x(), - from.y(), - -from.z() - ); - - return to; - } - - // Getters, intended for VRViewManager. - - public long getSessionPointer() { - return session; - } - - public long getChain(int eye) { - return chains[eye]; - } - - public FrameBuffer[] getFramebuffers(int eye) { - return framebuffers[eye]; - } - - public PointerBuffer getLayers() { - return layers; - } - - public OVRLayerEyeFov getLayer0() { - return layer0; - } - - public OVRFovPort getFovPort() { - return fovPorts[ovrEye_Left]; // TODO checking the left and right eyes match - } - - public OVRPosef getHeadPose() { - return headPose; - } - - public OVRPosef getEyePose(int eye) { - return eyeRenderDesc[eye].HmdToEyePose(); - } - - public VREnvironment getEnvironment() { - return environment; - } -} - -/* vim: set ts=4 softtabstop=0 sw=4 expandtab: */ - diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/oculus/OculusVRInput.java b/jme3-xr/src/main/java/com/jme3/input/vr/oculus/OculusVRInput.java deleted file mode 100644 index f2ce772fbb..0000000000 --- a/jme3-xr/src/main/java/com/jme3/input/vr/oculus/OculusVRInput.java +++ /dev/null @@ -1,370 +0,0 @@ -package com.jme3.input.vr.oculus; - -import com.jme3.app.VREnvironment; -import com.jme3.input.vr.VRInputAPI; -import com.jme3.input.vr.VRInputType; -import com.jme3.input.vr.VRTrackedController; -import com.jme3.math.*; -import com.jme3.renderer.Camera; -import com.jme3.scene.Spatial; - -import org.lwjgl.ovr.*; - -import static org.lwjgl.ovr.OVR.*; - -public class OculusVRInput implements VRInputAPI { - // State control - private final OVRInputState inputState; - private final OVRSessionStatus sessionStatus; - private final OVRTrackingState trackingState; - private final OculusVR hardware; - private long session; - - // Setup values - private float axisMultiplier = 1; - - // Cached stuff - private int buttons, touch; - - // Used to calculate sinceLastCall stuff - private int lastButtons, lastTouch; - private final Vector2f[][] lastAxes; - - /** - * The state data (linear and angular velocity and acceleration) for each hand - */ - private OVRPoseStatef[] handStates; - - /** - * The position and orientation of the Touch controllers. - */ - private OVRPosef[] handPoses; - - /** - * The object forms of the tracked controllers. - */ - private final OculusController[] controllers = { - new OculusController(0), - new OculusController(1) - }; - - public OculusVRInput(OculusVR hardware, long session, - OVRSessionStatus sessionStatus, OVRTrackingState trackingState) { - this.hardware = hardware; - this.session = session; - this.sessionStatus = sessionStatus; - this.trackingState = trackingState; - - inputState = OVRInputState.calloc(); - - handStates = new OVRPoseStatef[ovrHand_Count]; - handPoses = new OVRPosef[handStates.length]; - lastAxes = new Vector2f[handStates.length][3]; // trigger+grab+thumbstick for each hand. - } - - public void dispose() { - inputState.free(); - session = 0; // Crashing > undefined behaviour if this object is incorrectly accessed again. - } - - @Override - public void updateControllerStates() { - // Handle buttons, axes - ovr_GetInputState(session, ovrControllerType_Touch, inputState); - buttons = inputState.Buttons(); - touch = inputState.Touches(); - - // Get the touch controller poses - // TODO what if no touch controllers are available? - for (int hand = 0; hand < handPoses.length; hand++) { - handStates[hand] = trackingState.HandPoses(hand); - handPoses[hand] = handStates[hand].ThePose(); - } - } - - private Vector3f cv(OVRVector3f in) { - // TODO do we want to reuse vectors rather than making new ones? - // TODO OpenVRInput does this, but it will probably cause some bugs. - return OculusVR.vecO2J(in, new Vector3f()); // This also fixes the coordinate space transform issues. - } - - private Vector2f cv(OVRVector2f in) { - // TODO do we want to reuse vectors rather than making new ones? - // TODO OpenVRInput does this, but it will probably cause some bugs. - return new Vector2f(in.x(), in.y()); - } - - private Quaternion cq(OVRQuatf in) { - // TODO do we want to reuse quaternions rather than making new ones? - // TODO OpenVRInput does this, but it will probably cause some bugs. - return OculusVR.quatO2J(in, new Quaternion()); // This also fixes the coordinate space transform issues. - } - - private Vector2f axis(float input) { - // See above comments about reusing vectors - return new Vector2f(input, input); - } - - // Tracking (position, rotation, velocity, status) - - @Override - public Vector3f getPosition(int index) { - return cv(handPoses[index].Position()); - } - - @Override - public Vector3f getVelocity(int controllerIndex) { - return cv(handStates[controllerIndex].LinearVelocity()); - } - - @Override - public Quaternion getOrientation(int index) { - return cq(handPoses[index].Orientation()); - } - - @Override - public Vector3f getAngularVelocity(int controllerIndex) { - return cv(handStates[controllerIndex].AngularVelocity()); - } - - @Override - public Quaternion getFinalObserverRotation(int index) { - // Copied from OpenVRInput - - VREnvironment env = hardware.getEnvironment(); - OculusViewManager vrvm = (OculusViewManager) hardware.getEnvironment().getVRViewManager(); - - Object obs = env.getObserver(); - Quaternion tempQuaternion = new Quaternion(); // TODO move to class scope? - if (obs instanceof Camera) { - tempQuaternion.set(((Camera) obs).getRotation()); - } else { - tempQuaternion.set(((Spatial) obs).getWorldRotation()); - } - - return tempQuaternion.multLocal(getOrientation(index)); - } - - @Override - public Vector3f getFinalObserverPosition(int index) { - // Copied from OpenVRInput - - VREnvironment env = hardware.getEnvironment(); - OculusViewManager vrvm = (OculusViewManager) hardware.getEnvironment().getVRViewManager(); - - Object obs = env.getObserver(); - Vector3f pos = getPosition(index); - if (obs instanceof Camera) { - ((Camera) obs).getRotation().mult(pos, pos); - return pos.addLocal(((Camera) obs).getLocation()); - } else { - ((Spatial) obs).getWorldRotation().mult(pos, pos); - return pos.addLocal(((Spatial) obs).getWorldTranslation()); - } - } - - @Override - public boolean isInputDeviceTracking(int index) { - int flags = trackingState.HandStatusFlags(index); - return (flags & ovrStatus_PositionTracked) != 0; // TODO do we require orientation as well? - } - - // Input Getters - - @Override - public Vector2f getAxis(int controllerIndex, VRInputType forAxis) { - Vector2f result = getAxisRaw(controllerIndex, forAxis); - return result == null ? null : result.multLocal(axisMultiplier); - } - - @Override - public Vector2f getAxisRaw(int controllerIndex, VRInputType forAxis) { - switch (forAxis) { - case OculusThumbstickAxis: - return cv(inputState.Thumbstick(controllerIndex)); - case OculusTriggerAxis: - return axis(inputState.IndexTrigger(controllerIndex)); - case OculusGripAxis: - return axis(inputState.HandTrigger(controllerIndex)); - default: - return null; - } - } - - @Override - public boolean isButtonDown(int controllerIndex, VRInputType checkButton) { - return isButtonDownForStatus(controllerIndex, checkButton, buttons, touch); - } - - public boolean isButtonDownForStatus(int controllerIndex, VRInputType checkButton, int buttons, int touch) { - int buttonMask = (controllerIndex == ovrHand_Left) ? ovrButton_LMask : ovrButton_RMask; - int touchMask = (controllerIndex == ovrHand_Left) ? - (ovrTouch_LButtonMask + ovrTouch_LPoseMask) : - (ovrTouch_RButtonMask + ovrTouch_RPoseMask); - - switch (checkButton) { - default: - return false; - - case OculusTopButton: // Physical buttons - case OculusBottomButton: - case OculusThumbstickButton: - case OculusMenuButton: - return (buttons & buttonMask & checkButton.getValue()) != 0; - - case OculusTopTouch: // Standard capacitive buttons - case OculusBottomTouch: - case OculusThumbstickTouch: - case OculusThumbrestTouch: - case OculusIndexTouch: - case OculusThumbUp: // Calculated/virtual capacitive buttons - case OculusIndexPointing: - return (touch & touchMask & checkButton.getValue()) != 0; - } - } - - // Since-last-call stuff - - @Override - public void resetInputSinceLastCall() { - lastButtons = 0; - lastTouch = 0; - } - - @Override - public boolean wasButtonPressedSinceLastCall(int controllerIndex, VRInputType checkButton) { - boolean wasPressed = isButtonDownForStatus(controllerIndex, checkButton, lastButtons, lastTouch); - lastButtons = buttons; - lastTouch = touch; - return !wasPressed && isButtonDown(controllerIndex, checkButton); - } - - @Override - public Vector2f getAxisDeltaSinceLastCall(int controllerIndex, VRInputType forAxis) { - int index; - switch (forAxis) { - case OculusTriggerAxis: - index = 0; - break; - case OculusGripAxis: - index = 1; - break; - case OculusThumbstickAxis: - index = 2; - break; - default: - return null; - } - - Vector2f last = lastAxes[controllerIndex][index]; - if (last == null) { - last = lastAxes[controllerIndex][index] = new Vector2f(); - } - - Vector2f current = getAxis(controllerIndex, forAxis); - - // TODO could this lead to accuracy problems? - current.subtractLocal(last); - last.addLocal(current); - - return current; - } - - // Misc - - @Override - public boolean init() { - throw new UnsupportedOperationException("Input initialized at creation time"); - } - - @Override - public void updateConnectedControllers() { - throw new UnsupportedOperationException("Automatically done by LibOVR (I think?)"); - } - - @Override - public float getAxisMultiplier() { - return axisMultiplier; - } - - @Override - public void setAxisMultiplier(float axisMultiplier) { - this.axisMultiplier = axisMultiplier; - } - - @Override - public void triggerHapticPulse(int controllerIndex, float seconds) { - // TODO: How do we time so we can turn the feedback off? - } - - @Override - public boolean isInputFocused() { - return sessionStatus.IsVisible(); // TODO do we need HmdMounted, or is it counted in IsVisible - } - - @Override - public Object getRawControllerState(int index) { - throw new UnsupportedOperationException("Cannot get raw controller state!"); - } - - @Override - public void swapHands() { - // Do nothing. - // TODO although OSVR and OpenVR if it has more than two controllers both do nothing, shouldn't we be - // TODO throwing an exception or something? - } - - @Override - public int getTrackedControllerCount() { - // TODO: Shouldn't we be seeing if the user has the touch controllers first? - return 2; - } - - @Override - public VRTrackedController getTrackedController(int index) { - return controllers[index]; - } - - /** - * The object form representation of a controller. - */ - public class OculusController implements VRTrackedController { - - /** - * The ID of the hand to track - */ - private int hand; - - public OculusController(int hand) { - this.hand = hand; - } - - @Override - public String getControllerName() { - return "Touch"; // TODO - } - - @Override - public String getControllerManufacturer() { - return "Oculus"; // TODO - } - - @Override - public Vector3f getPosition() { - return OculusVRInput.this.getPosition(hand); - } - - @Override - public Quaternion getOrientation() { - return OculusVRInput.this.getOrientation(hand); - } - - @Override - public Matrix4f getPose() { - Matrix4f mat = new Matrix4f(); - mat.setRotationQuaternion(getOrientation()); - mat.setTranslation(getPosition()); - return mat; - } - } -} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/oculus/OculusViewManager.java b/jme3-xr/src/main/java/com/jme3/input/vr/oculus/OculusViewManager.java deleted file mode 100644 index 6ebbab1cf9..0000000000 --- a/jme3-xr/src/main/java/com/jme3/input/vr/oculus/OculusViewManager.java +++ /dev/null @@ -1,340 +0,0 @@ -/* - * Copyright (c) 2009-2018 jMonkeyEngine - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'jMonkeyEngine' nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package com.jme3.input.vr.oculus; - -import com.jme3.app.VREnvironment; -import com.jme3.input.vr.AbstractVRViewManager; -import com.jme3.input.vr.VRAPI; -import com.jme3.math.*; -import com.jme3.renderer.Camera; -import com.jme3.renderer.ViewPort; -import com.jme3.scene.Spatial; -import com.jme3.util.BufferUtils; -import com.jme3.util.VRGUIPositioningMode; - -import java.nio.IntBuffer; -import java.util.Iterator; -import java.util.Objects; - -import org.lwjgl.ovr.OVRFovPort; -import org.lwjgl.ovr.OVRPosef; -import org.lwjgl.ovr.OVRUtil; - -import static org.lwjgl.ovr.OVR.*; -import static org.lwjgl.ovr.OVRErrorCode.*; - -/** - * A rendering system for Oculus's LibOVR API. - * - * @author Campbell Suter (znix@znix.xyz) - */ -public class OculusViewManager extends AbstractVRViewManager { - - private final VREnvironment environment; - private final OculusVR hardware; - - // Copied from OSVR - //final & temp values for camera calculations - private final Vector3f finalPosition = new Vector3f(); - private final Quaternion finalRotation = new Quaternion(); - private final Vector3f hmdPos = new Vector3f(); - private final Quaternion hmdRot = new Quaternion(); - - public OculusViewManager(VREnvironment environment) { - this.environment = environment; - - VRAPI hardware = environment.getVRHardware(); - Objects.requireNonNull(hardware, "Attached VR Hardware cannot be null"); - if (!(hardware instanceof OculusVR)) { - throw new IllegalStateException("Cannot use Oculus VR view manager on non-Oculus hardware state!"); - } - - this.hardware = (OculusVR) hardware; - - if (!environment.compositorAllowed()) { - throw new UnsupportedOperationException("Cannot render without compositor on LibOVR"); - } - } - - @Override - public void initialize() { - setupCamerasAndViews(); - - if (environment.hasTraditionalGUIOverlay()) { - - environment.getVRMouseManager().initialize(); - - // update the pose to position the gui correctly on start - update(0f); - environment.getVRGUIManager().positionGui(); - } - } - - private long session() { - return hardware.getSessionPointer(); - } - - @Override - public void update(float tpf) { - // TODO - - hardware.updatePose(); - - // TODO deduplicate - if (environment == null) { - throw new IllegalStateException("This VR view manager is not attached to any VR environment."); - } - - // grab the observer - Object obs = environment.getObserver(); - Quaternion objRot; - Vector3f objPos; - if (obs instanceof Camera) { - objRot = ((Camera) obs).getRotation(); - objPos = ((Camera) obs).getLocation(); - } else { - objRot = ((Spatial) obs).getWorldRotation(); - objPos = ((Spatial) obs).getWorldTranslation(); - } - - // update the HMD's position & orientation - hardware.getPositionAndOrientation(hmdPos, hmdRot); - if (obs != null) { - // update hmdPos based on obs rotation - finalRotation.set(objRot); - finalRotation.mult(hmdPos, hmdPos); - finalRotation.multLocal(hmdRot); - } - - // Update both eye cameras - finalizeCamera(hardware.getHMDVectorPoseLeftEye(), objPos, leftCamera); - finalizeCamera(hardware.getHMDVectorPoseRightEye(), objPos, rightCamera); - - // Update the main camera, so it shows the same basic view the HMD is getting - // TODO: Do this in VRAppState, so it works on all HMDs. - // I only have a Rift, so I can't test it on anything else. - if(!environment.isInstanceRendering()) { // We use the app camera as the left camera here - // TODO: Double up on rendering and use one eye, to reduce GPU load rendering the scene again. - // TODO: Snip at the image to remove the distorted corners from a very high FOV. - finalizeCamera(Vector3f.ZERO, objPos, environment.getApplication().getCamera()); - } - - if (environment.hasTraditionalGUIOverlay()) { - // update the mouse? - environment.getVRMouseManager().update(tpf); - - // update GUI position? - if (environment.getVRGUIManager().isWantsReposition() || environment.getVRGUIManager().getPositioningMode() != VRGUIPositioningMode.MANUAL) { - environment.getVRGUIManager().positionGuiNow(tpf); - environment.getVRGUIManager().updateGuiQuadGeometricState(); - } - } - } - - /** - * Place the camera within the scene. - * - * @param eyePos the eye position. - * @param obsPosition the observer position. - * @param cam the camera to place. - */ - private void finalizeCamera(Vector3f eyePos, Vector3f obsPosition, Camera cam) { - finalRotation.mult(eyePos, finalPosition); - finalPosition.addLocal(hmdPos); - if (obsPosition != null) { - finalPosition.addLocal(obsPosition); - } - finalPosition.y += getHeightAdjustment(); - cam.setFrame(finalPosition, finalRotation); - } - - @Override - public void render() { - - // Calculate the render pose (translation/rotation) for each eye. - // LibOVR takes the difference between this and the real position of each eye at display time - // to apply AZW (timewarp). - - OVRPosef.Buffer hmdToEyeOffsets = OVRPosef.calloc(2); - hmdToEyeOffsets.put(0, hardware.getEyePose(ovrEye_Left)); - hmdToEyeOffsets.put(1, hardware.getEyePose(ovrEye_Right)); - - //calculate eye poses - OVRUtil.ovr_CalcEyePoses(hardware.getHeadPose(), hmdToEyeOffsets, hardware.getLayer0().RenderPose()); - hmdToEyeOffsets.free(); - - for (int eye = 0; eye < 2; eye++) { - IntBuffer currentIndexB = BufferUtils.createIntBuffer(1); - ovr_GetTextureSwapChainCurrentIndex(session(), hardware.getChain(eye), currentIndexB); - int index = currentIndexB.get(); - - // Constantly (each frame) rotating through a series of - // frame buffers, so make sure we write into the correct one. - (eye == ovrEye_Left ? leftViewPort : rightViewPort).setOutputFrameBuffer(hardware.getFramebuffers(eye)[index]); - } - - // Now the game will render into the buffers given to us by LibOVR - } - - @Override - public void postRender() { - // We're done with our textures now - the game is done drawing into them. - for (int eye = 0; eye < 2; eye++) { - ovr_CommitTextureSwapChain(session(), hardware.getChain(eye)); - } - - // Send the result to the HMD - int result = ovr_SubmitFrame(session(), 0, null, hardware.getLayers()); - if (result != ovrSuccess) { - throw new IllegalStateException("Failed to submit frame!"); - } - } - - /* - ********************************************************* - * Show's over, now it's just boring camera stuff etc. * - ********************************************************* - */ - - /** - * Set up the cameras and views for each eye and the mirror display. - */ - private void setupCamerasAndViews() { - // TODO: Use LobOVR IPD etc - if (environment != null) { - // get desired frustum from original camera - Camera origCam = environment.getCamera(); - float fFar = origCam.getFrustumFar(); - float fNear = origCam.getFrustumNear(); - - // restore frustum on distortion scene cam, if needed - if (environment.isInstanceRendering()) { - leftCamera = origCam; - } else { - leftCamera = origCam.clone(); - } - - OVRFovPort fp = hardware.getFovPort(); - float hFov = fp.LeftTan() + fp.RightTan(); - float vFov = fp.UpTan() + fp.DownTan(); - getLeftCamera().setFrustumPerspective(hFov / FastMath.TWO_PI * 360, vFov / hFov, fNear, fFar); - - prepareCameraSize(getLeftCamera(), 1f); - if (environment.getVRHardware() != null) { - getLeftCamera().setProjectionMatrix(environment.getVRHardware().getHMDMatrixProjectionLeftEye(getLeftCamera())); - } - //org.lwjgl.opengl.GL11.glEnable(org.lwjgl.opengl.GL30.GL_FRAMEBUFFER_SRGB); - - if (!environment.isInstanceRendering()) { - leftViewPort = setupViewBuffers(getLeftCamera(), LEFT_VIEW_NAME); - rightCamera = getLeftCamera().clone(); - if (environment.getVRHardware() != null) { - getRightCamera().setProjectionMatrix(environment.getVRHardware().getHMDMatrixProjectionRightEye(getRightCamera())); - } - rightViewPort = setupViewBuffers(getRightCamera(), RIGHT_VIEW_NAME); - } else if (environment.getApplication() != null) { - throw new UnsupportedOperationException("Not yet implemented!"); - } else { - throw new IllegalStateException("This VR environment is not attached to any application."); - } - - // setup gui - environment.getVRGUIManager().setupGui(getLeftCamera(), getRightCamera(), getLeftViewPort(), getRightViewPort()); - } else { - throw new IllegalStateException("This VR view manager is not attached to any VR environment."); - } - } - - private void prepareCameraSize(Camera cam, float xMult) { - // TODO this function is identical to that in VRViewManagerOpenVR; merge the two. - if (environment != null) { - if (environment.getApplication() != null) { - Vector2f size = new Vector2f(); - VRAPI vrhmd = environment.getVRHardware(); - - if (vrhmd == null) { - size.x = 1280f; - size.y = 720f; - } else { - vrhmd.getRenderSize(size); - } - - if (size.x < environment.getApplication().getContext().getSettings().getWidth()) { - size.x = environment.getApplication().getContext().getSettings().getWidth(); - } - if (size.y < environment.getApplication().getContext().getSettings().getHeight()) { - size.y = environment.getApplication().getContext().getSettings().getHeight(); - } - - if (environment.isInstanceRendering()) { - size.x *= 2f; - } - - // other adjustments - size.x *= xMult; - size.x *= getResolutionMuliplier(); - size.y *= getResolutionMuliplier(); - - if (cam.getWidth() != size.x || cam.getHeight() != size.y) { - cam.resize((int) size.x, (int) size.y, false); - } - } else { - throw new IllegalStateException("This VR environment is not attached to any application."); - } - } else { - throw new IllegalStateException("This VR view manager is not attached to any VR environment."); - } - } - - private ViewPort setupViewBuffers(Camera cam, String viewName) { - // TODO this function is identical to that in VRViewManagerOpenVR; merge the two. - if (environment != null) { - if (environment.getApplication() != null) { - ViewPort viewPort = environment.getApplication().getRenderManager().createPreView(viewName, cam); - viewPort.setClearFlags(true, true, true); - viewPort.setBackgroundColor(ColorRGBA.Black); - - Iterator spatialIter = environment.getApplication().getViewPort().getScenes().iterator(); - while (spatialIter.hasNext()) { - viewPort.attachScene(spatialIter.next()); - } - - // The target view buffer will be set during prerender. - return viewPort; - } else { - throw new IllegalStateException("This VR environment is not attached to any application."); - } - } else { - throw new IllegalStateException("This VR view manager is not attached to any VR environment."); - } - } -} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/oculus/package-info.java b/jme3-xr/src/main/java/com/jme3/input/vr/oculus/package-info.java deleted file mode 100644 index ab7b1bbb89..0000000000 --- a/jme3-xr/src/main/java/com/jme3/input/vr/oculus/package-info.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2021 jMonkeyEngine - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'jMonkeyEngine' nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -/** - * user-input classes for Oculus Rift headsets - */ -package com.jme3.input.vr.oculus; From 723f81106882c3bfe563223dfafa37e9b072c29b Mon Sep 17 00:00:00 2001 From: Starcommander Date: Fri, 24 Feb 2023 00:07:01 +0100 Subject: [PATCH 03/18] Add lwjgl openxr working sample data and source. --- .../jme3/input/vr/lwjgl_openxr/IOUtil.java | 75 + .../com/jme3/input/vr/lwjgl_openxr/Main.java | 2252 +++++++++++++++++ .../jme3/input/vr/lwjgl_openxr/XrHelper.java | 210 ++ .../demo/openxr/vulkan/hello.frag.spv | Bin 0 -> 1300 bytes .../demo/openxr/vulkan/hello.vert.spv | Bin 0 -> 1384 bytes 5 files changed, 2537 insertions(+) create mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/IOUtil.java create mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/Main.java create mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/XrHelper.java create mode 100644 jme3-xr/src/main/resources/demo/openxr/vulkan/hello.frag.spv create mode 100644 jme3-xr/src/main/resources/demo/openxr/vulkan/hello.vert.spv diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/IOUtil.java b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/IOUtil.java new file mode 100644 index 0000000000..1c70380e6f --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/IOUtil.java @@ -0,0 +1,75 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.jme3.input.vr.lwjgl_openxr; // JME3: Modified package path + +import org.lwjgl.*; + +import java.io.*; +import java.nio.*; +import java.nio.channels.*; +import java.nio.file.*; + +import static org.lwjgl.BufferUtils.*; +import static org.lwjgl.system.MemoryUtil.*; + +public final class IOUtil { + + private IOUtil() { + } + + private static ByteBuffer resizeBuffer(ByteBuffer buffer, int newCapacity) { + ByteBuffer newBuffer = BufferUtils.createByteBuffer(newCapacity); + buffer.flip(); + newBuffer.put(buffer); + return newBuffer; + } + + /** + * Reads the specified resource and returns the raw data as a ByteBuffer. + * + * @param resource the resource to read + * @param bufferSize the initial buffer size + * + * @return the resource data + * + * @throws IOException if an IO error occurs + */ + public static ByteBuffer ioResourceToByteBuffer(String resource, int bufferSize) throws IOException { + System.out.println("com.starcom.lwjglvr.IOUtil.ioResourceToByteBuffer(): " + resource); + ByteBuffer buffer; + + Path path = Paths.get(resource); + if (Files.isReadable(path)) { + try (SeekableByteChannel fc = Files.newByteChannel(path)) { + buffer = BufferUtils.createByteBuffer((int)fc.size() + 1); + while (fc.read(buffer) != -1) { + ; + } + } + } else { + try ( + InputStream source = IOUtil.class.getClassLoader().getResourceAsStream(resource); + ReadableByteChannel rbc = Channels.newChannel(source) + ) { + buffer = createByteBuffer(bufferSize); + + while (true) { + int bytes = rbc.read(buffer); + if (bytes == -1) { + break; + } + if (buffer.remaining() == 0) { + buffer = resizeBuffer(buffer, buffer.capacity() * 3 / 2); // 50% + } + } + } + } + + buffer.flip(); + return memSlice(buffer); + } + +} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/Main.java b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/Main.java new file mode 100644 index 0000000000..23cbb1d525 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/Main.java @@ -0,0 +1,2252 @@ +/* + * Source: https://github.com/LWJGL/lwjgl3/blob/master/modules/samples/src/test/java/org/lwjgl/demo/openxr/HelloOpenXRVK.java + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + */ +package com.jme3.input.vr.lwjgl_openxr; // JME3: Modified package path + +import org.joml.*; +import org.lwjgl.*; +import org.lwjgl.openxr.*; +import org.lwjgl.system.*; +import org.lwjgl.vulkan.*; + +import java.io.*; +import java.lang.reflect.*; +import java.nio.*; +import java.util.*; +import java.util.Random; +import java.util.function.*; + +import static org.joml.Math.*; +import static org.lwjgl.openxr.EXTDebugUtils.*; +import static org.lwjgl.openxr.KHRVulkanEnable.*; +import static org.lwjgl.openxr.XR10.*; +import static org.lwjgl.system.MemoryStack.*; +import static org.lwjgl.system.MemoryUtil.*; +import static org.lwjgl.vulkan.EXTDebugUtils.*; +import static org.lwjgl.vulkan.VK10.*; +import org.joml.*; +import org.lwjgl.*; +import org.lwjgl.openxr.*; +import org.lwjgl.system.*; +import org.lwjgl.vulkan.*; + +import java.io.*; +import java.lang.reflect.*; +import java.nio.*; +import java.util.Random; +import java.util.*; +import java.util.function.*; + +import static org.joml.Math.*; +import static com.jme3.input.vr.lwjgl_openxr.lwjgl.IOUtil.*; +import static org.lwjgl.openxr.EXTDebugUtils.*; +import static org.lwjgl.openxr.KHRVulkanEnable.*; +import static org.lwjgl.openxr.XR10.*; +import static org.lwjgl.system.MemoryStack.*; +import static org.lwjgl.system.MemoryUtil.*; +import static org.lwjgl.vulkan.EXTDebugUtils.*; +import static org.lwjgl.vulkan.VK10.*; + +public class Main { + + private static final String VK_LAYER_LUNARG_STANDARD_VALIDATION = "VK_LAYER_LUNARG_standard_validation"; + + private static final int VERTEX_SIZE = 2 * 3 * 4; + private static final int VERTEX_LOCATION_POSITION = 0; + private static final int VERTEX_LOCATION_COLOR = 1; + private static final int VERTEX_OFFSET_POSITION = 0; + private static final int VERTEX_OFFSET_COLOR = 1 * 3 * 4; + + private static final int INDEX_SIZE = 2; + private static final int INDEX_TYPE = VK_INDEX_TYPE_UINT16; + + private static class BigModel { + + static final int NUM_CUBES = 500; + + static final int NUM_VERTICES = NUM_CUBES * 6 * 4; + static final int NUM_INDICES = NUM_CUBES * 6 * 6; + } + + private static class SwapchainImage { + final long colorImage; + final long colorImageView; + final long framebuffer; + + SwapchainImage(long colorImage, long colorImageView, long framebuffer) { + this.colorImage = colorImage; + this.colorImageView = colorImageView; + this.framebuffer = framebuffer; + } + } + + private static class SwapchainWrapper { + + final XrSwapchain swapchain; + + final int width, height, numSamples; + + final long depthImage; + final long depthImageView; + final long depthImageMemory; + + final SwapchainImage[] images; + + final long fence; + + final VkCommandBuffer commandBuffer; + + SwapchainWrapper( + XrSwapchain swapchain, int width, int height, int numSamples, + long depthImage, long depthImageView, long depthImageMemory, SwapchainImage[] images, + long fence, VkCommandBuffer commandBuffer + ) { + if (swapchain == null) { + throw new NullPointerException("swapchain"); + } + this.swapchain = swapchain; + if (width <= 0) { + throw new IllegalArgumentException("width is " + width); + } + this.width = width; + if (height <= 0) { + throw new IllegalArgumentException("height is " + height); + } + this.height = height; + + if (numSamples <= 0) { + throw new IllegalArgumentException("numSamples is " + numSamples); + } + + if (images == null) { + throw new IllegalArgumentException("images are null"); + } + this.numSamples = numSamples; + for (SwapchainImage image : images) { + if (image == null) { + throw new IllegalArgumentException("An image is null"); + } + + if (image.colorImage == 0) { + throw new IllegalArgumentException("A color image is 0"); + } + if (image.colorImageView == 0) { + throw new IllegalArgumentException("A color image view is 0"); + } + if (image.framebuffer == 0) { + throw new IllegalArgumentException("A framebuffer is 0"); + } + } + this.images = images; + + if (depthImage == 0) { + throw new IllegalArgumentException("The depth image is 0"); + } + this.depthImage = depthImage; + if (depthImageView == 0) { + throw new IllegalArgumentException("The depth image view is 0"); + } + this.depthImageView = depthImageView; + if (depthImageMemory == 0) { + throw new IllegalArgumentException("The depth image memory is 0"); + } + this.depthImageMemory = depthImageMemory; + + if (fence == 0) { + throw new IllegalArgumentException("Fence is 0"); + } + this.fence = fence; + + if (commandBuffer == null) { + throw new NullPointerException("commandBuffer"); + } + this.commandBuffer = commandBuffer; + } + } + + private static ByteBuffer getShaderResource(String resource) { + try { + return ioResourceToByteBuffer(resource, 2048); + } catch (IOException e) { + throw new IllegalStateException("Needed resources should always be available", e); + } + } + +// JME3: No main, commented out +// public static void main(String[] args) { +// Main classInstance = new Main(); +// classInstance.start(); +// } + + private XrInstance xrInstance; + + private XrDebugUtilsMessengerEXT xrDebugMessenger; + + private long xrSystemId; + + private XrSession xrVkSession; + + private int xrSessionState; + + private XrActionSet xrActionSet; + private XrAction xrHandPoseAction; + private XrAction xrHandClickAction; + + private long xrPathLeftHand; + private long xrPathRightHand; + + private XrSpace xrLeftHandSpace; + private XrSpace xrRightHandSpace; + + private boolean missingXrDebug; + + private VkInstance vkInstance; + + private long vkDebugMessenger; + + private VkPhysicalDevice vkPhysicalDevice; + private VkDevice vkDevice; + + private VkQueue vkQueue; + + private int vkQueueFamilyIndex; + private int vkQueueIndex; + + private long vkCommandPoolCopying; + private long vkCommandPoolDrawing; + + private long vkRenderPass; + private long vkPipelineLayout; + + private long[] vkGraphicsPipelines; + + private long vkDeviceMemory; + private long vkBigBuffer; + + private SwapchainWrapper[] swapchains; + + private int viewConfiguration; + private int swapchainColorFormat; + private int swapchainDepthFormat; + + private XrSpace renderSpace; + + // The default value can be used in edge cases where the position tracking of the driver fails right at the start + // Let's hope it won't be used a lot + private Matrix4f lastCameraMatrix = new Matrix4f().perspective(toRadians(70f), 0.7f, 0.01f, 100f, true); + + private void start() { + try { + createXrInstance(); + initXrSystem(); + initVk(); + createXrVkSession(); + initXrActions(); + createRenderResources(); + loopXrSession(); + } catch (RuntimeException ex) { + System.err.println("OpenXR testing failed:"); + ex.printStackTrace(); + } + + // Always clean up + destroySwapchains(); + destroyXrVkSession(); + destroyVk(); + destroyXrInstance(); + } + + private void createXrInstance() { + try (MemoryStack stack = stackPush()) { + boolean hasCoreValidationLayer = false; + + IntBuffer pi = stack.callocInt(1); + xrCheck(xrEnumerateApiLayerProperties(pi, null), "EnumerateApiLayerProperties"); + int numLayers = pi.get(0); + + XrApiLayerProperties.Buffer pLayers = XrHelper.prepareApiLayerProperties(stack, numLayers); + xrCheck(xrEnumerateApiLayerProperties(pi, pLayers), "EnumerateApiLayerProperties"); + System.out.println(numLayers + " XR layers are available:"); + for (int index = 0; index < numLayers; index++) { + XrApiLayerProperties layer = pLayers.get(index); + + String layerName = layer.layerNameString(); + System.out.println(layerName); + if (layerName.equals("XR_APILAYER_LUNARG_core_validation")) { + hasCoreValidationLayer = true; + } + } + System.out.println("-----------"); + + xrCheck(xrEnumerateInstanceExtensionProperties((ByteBuffer)null, pi, null), "EnumerateInstanceExtensionProperties"); + int numExtensions = pi.get(0); + + XrExtensionProperties.Buffer properties = XrHelper.prepareExtensionProperties(stack, numExtensions); + xrCheck(xrEnumerateInstanceExtensionProperties((ByteBuffer)null, pi, properties), "EnumerateInstanceExtensionProperties"); + + System.out.printf("OpenXR loaded with %d extensions:%n", numExtensions); + System.out.println("~~~~~~~~~~~~~~~~~~"); + + missingXrDebug = true; + boolean missingVulkan = true; + + PointerBuffer extensions = stack.mallocPointer(numExtensions); + for (int i = 0; i < numExtensions; i++) { + XrExtensionProperties prop = properties.get(i); + extensions.put(i, prop.extensionName()); + + String extensionName = prop.extensionNameString(); + System.out.println(extensionName); + if (extensionName.equals(KHRVulkanEnable.XR_KHR_VULKAN_ENABLE_EXTENSION_NAME)) { + missingVulkan = false; + } + if (extensionName.equals("XR_EXT_debug_utils")) { + missingXrDebug = false; + } + } + System.out.println("~~~~~~~~~~~~~~~~~~"); + + if (missingVulkan) { + throw new IllegalStateException("OpenXR library does not provide required extension: " + KHRVulkanEnable.XR_KHR_VULKAN_ENABLE_EXTENSION_NAME); + } + + PointerBuffer wantedExtensions; + if (missingXrDebug) { + wantedExtensions = stack.callocPointer(1); + } else { + wantedExtensions = stack.callocPointer(2); + wantedExtensions.put(1, stack.UTF8("XR_EXT_debug_utils")); + System.out.println("Enabling XR debug utils"); + } + wantedExtensions.put(0, stack.UTF8(XR_KHR_VULKAN_ENABLE_EXTENSION_NAME)); + + PointerBuffer wantedLayers; + if (hasCoreValidationLayer) { + wantedLayers = stack.callocPointer(1); + wantedLayers.put(0, stack.UTF8("XR_APILAYER_LUNARG_core_validation")); + System.out.println("Enabling XR core validation"); + } else { + wantedLayers = null; + } + + XrInstanceCreateInfo createInfo = XrInstanceCreateInfo.malloc(stack) + .type$Default() + .next(NULL) + .createFlags(0) + .applicationInfo(XrApplicationInfo.malloc(stack) + .applicationName(stack.UTF8("DummyXRVK")) + .apiVersion(XR_CURRENT_API_VERSION)) + .enabledApiLayerNames(wantedLayers) + .enabledExtensionNames(wantedExtensions); + + System.out.println("Create instance..."); + PointerBuffer pp = stack.mallocPointer(1); + xrCheck(xrCreateInstance(createInfo, pp), "CreateInstance"); + xrInstance = new XrInstance(pp.get(0), createInfo); + System.out.println("Created instance"); + } + } + + private void initXrSystem() { + try (MemoryStack stack = stackPush()) { + XrSystemGetInfo giSystem = XrSystemGetInfo.calloc(stack) + .type$Default() + .formFactor(XR_FORM_FACTOR_HEAD_MOUNTED_DISPLAY); + + LongBuffer pl = stack.callocLong(1); + System.out.println("xrInstance is " + xrInstance + " and giSystem is " + giSystem); + xrCheck(xrGetSystem(xrInstance, giSystem, pl), "GetSystem"); + xrSystemId = pl.get(0); + + System.out.println("System ID is " + xrSystemId); + } + } + + private void initXrActions() { + try (MemoryStack stack = stackPush()) { + PointerBuffer pp = stack.mallocPointer(1); + LongBuffer lp = stack.mallocLong(1); + + xrCheck(xrCreateActionSet( + xrInstance, + XrActionSetCreateInfo.calloc(stack) + .type$Default() + .priority(1) + .actionSetName(stack.UTF8("handcontrols")) + .localizedActionSetName(stack.UTF8("Demo Hand Controls")), + pp + ), "CreateActionSet"); + this.xrActionSet = new XrActionSet(pp.get(0), xrInstance); + + xrCheck(xrStringToPath(xrInstance, stack.UTF8("/user/hand/left"), lp), "StringToPath"); + this.xrPathLeftHand = lp.get(0); + + xrCheck(xrStringToPath(xrInstance, stack.UTF8("/user/hand/right"), lp), "StringToPath"); + this.xrPathRightHand = lp.get(0); + + xrCheck(xrCreateAction( + xrActionSet, + XrActionCreateInfo.calloc(stack) + .type$Default() + .actionType(XR_ACTION_TYPE_POSE_INPUT) + .actionName(stack.UTF8("handpose")) + .localizedActionName(stack.UTF8("Hand pose")) + .subactionPaths(stack.longs(xrPathLeftHand, xrPathRightHand)), + pp), "CreateAction"); + this.xrHandPoseAction = new XrAction(pp.get(0), xrActionSet); + + xrCheck(xrCreateAction( + xrActionSet, + XrActionCreateInfo.calloc(stack) + .type$Default() + .actionType(XR_ACTION_TYPE_BOOLEAN_INPUT) + .actionName(stack.UTF8("invert_colors")) + .localizedActionName(stack.UTF8("Invert colors")) + .subactionPaths(stack.longs(xrPathLeftHand, xrPathRightHand)), + pp + ), "CreateAction"); + this.xrHandClickAction = new XrAction(pp.get(0), xrActionSet); + + xrCheck(xrStringToPath(xrInstance, stack.UTF8("/interaction_profiles/khr/simple_controller"), lp), "StringToPath"); + long interactionProfile = lp.get(0); + + XrActionSuggestedBinding.Buffer suggestedBindings = XrActionSuggestedBinding.calloc(4, stack); + + xrCheck(xrStringToPath(xrInstance, stack.UTF8("/user/hand/left/input/grip/pose"), lp), "StringToPath"); + suggestedBindings.get(0) + .action(xrHandPoseAction) + .binding(lp.get(0)); + + xrCheck(xrStringToPath(xrInstance, stack.UTF8("/user/hand/right/input/grip/pose"), lp), "StringToPath"); + suggestedBindings.get(1) + .action(xrHandPoseAction) + .binding(lp.get(0)); + + xrCheck(xrStringToPath(xrInstance, stack.UTF8("/user/hand/left/input/select/click"), lp), "StringToPath"); + suggestedBindings.get(2) + .action(xrHandClickAction) + .binding(lp.get(0)); + + xrCheck(xrStringToPath(xrInstance, stack.UTF8("/user/hand/right/input/select/click"), lp), "StringToPath"); + suggestedBindings.get(3) + .action(xrHandClickAction) + .binding(lp.get(0)); + + xrCheck(xrSuggestInteractionProfileBindings( + xrInstance, + XrInteractionProfileSuggestedBinding.calloc(stack) + .type$Default() + .interactionProfile(interactionProfile) + .suggestedBindings(suggestedBindings) + ), "SuggestInteractionProfileBindings"); + + xrCheck(xrCreateActionSpace( + xrVkSession, + XrActionSpaceCreateInfo.calloc(stack) + .type$Default() + .action(xrHandPoseAction) + .subactionPath(xrPathLeftHand) + .poseInActionSpace(identityPose(stack)), + pp + ), "CreateActionSpace"); + this.xrLeftHandSpace = new XrSpace(pp.get(0), xrVkSession); + + xrCheck(xrCreateActionSpace( + xrVkSession, + XrActionSpaceCreateInfo.calloc(stack) + .type$Default() + .action(xrHandPoseAction) + .subactionPath(xrPathRightHand) + .poseInActionSpace(identityPose(stack)), + pp + ), "CreateActionSpace"); + this.xrRightHandSpace = new XrSpace(pp.get(0), xrVkSession); + + xrCheck(xrAttachSessionActionSets( + xrVkSession, + XrSessionActionSetsAttachInfo.calloc(stack) + .type$Default() + .actionSets(stack.pointers(xrActionSet)) + ), "AttachSessionActionSets"); + } + } + + private void initVk() { + try (MemoryStack stack = stackPush()) { + PointerBuffer pp = stack.mallocPointer(1); + IntBuffer pi = stack.mallocInt(1); + LongBuffer pl = stack.mallocLong(1); + + XrGraphicsRequirementsVulkanKHR graphicsRequirements = XrGraphicsRequirementsVulkanKHR.calloc(stack) + .type$Default(); + + xrCheck(xrGetVulkanGraphicsRequirementsKHR(xrInstance, xrSystemId, graphicsRequirements), "GetVulkanGraphicsRequirements"); + + long minApiVersion = graphicsRequirements.minApiVersionSupported(); + long maxApiVersion = graphicsRequirements.maxApiVersionSupported(); + + long minVkMajor = XR_VERSION_MAJOR(minApiVersion); + long minVkMinor = XR_VERSION_MINOR(minApiVersion); + long minVkPatch = XR_VERSION_PATCH(minApiVersion); + + System.out.println("Minimum Vulkan API version: " + minVkMajor + "." + minVkMinor + "." + minVkPatch); + System.out.println("Maximum Vulkan API version: " + XR_VERSION_MAJOR(maxApiVersion) + "." + XR_VERSION_MINOR(maxApiVersion) + "." + XR_VERSION_PATCH(maxApiVersion)); + + VkInstanceCreateInfo ciInstance = VkInstanceCreateInfo.calloc(stack) + .sType$Default() + .pApplicationInfo(VkApplicationInfo.calloc(stack) + .sType$Default() + .pApplicationName(stack.UTF8("DummyXRVK")) + .applicationVersion(VK_MAKE_VERSION(0, 1, 0)) + .apiVersion(VK_MAKE_VERSION((int)minVkMajor, (int)minVkMinor, (int)minVkPatch))); + + xrCheck(xrGetVulkanInstanceExtensionsKHR(xrInstance, xrSystemId, pi, null), "GetVulkanInstanceExtensions"); + + ByteBuffer pXrVkInstanceExtensions = stack.calloc(pi.get(0)); + xrCheck(xrGetVulkanInstanceExtensionsKHR(xrInstance, xrSystemId, pi, pXrVkInstanceExtensions), "GetVulkanInstanceExtensions"); + + // NOTE: The call to memAddress is important because LWJGL doesn't expect byte buffers to end with the null char + String[] requiredInstanceExtensionsArray = memUTF8(memAddress(pXrVkInstanceExtensions)).split(" "); + Set requiredInstanceExtensions = new HashSet<>(requiredInstanceExtensionsArray.length); + Collections.addAll(requiredInstanceExtensions, requiredInstanceExtensionsArray); + + vkCheck(vkEnumerateInstanceExtensionProperties((ByteBuffer)null, pi, null), "EnumerateInstanceExtensionProperties"); + int numExtensions = pi.get(0); + + VkExtensionProperties.Buffer pExtensionProps = VkExtensionProperties.calloc(numExtensions, stack); + vkCheck(vkEnumerateInstanceExtensionProperties((ByteBuffer)null, pi, pExtensionProps), "EnumerateInstanceExtensionProperties"); + + Set availableInstanceExtensions = new HashSet<>(numExtensions); + for (int index = 0; index < numExtensions; index++) { + availableInstanceExtensions.add(pExtensionProps.get(index).extensionNameString()); + } + + boolean hasExtDebugUtils = availableInstanceExtensions.contains(VK_EXT_DEBUG_UTILS_EXTENSION_NAME); + System.out.println("Available Vulkan instance extensions:"); + for (String extension : availableInstanceExtensions) { + System.out.println(extension); + } + System.out.println("-----------"); + + Set chosenInstanceExtensions = new HashSet<>(requiredInstanceExtensions.size() + 1); + if (hasExtDebugUtils) { + chosenInstanceExtensions.add(VK_EXT_DEBUG_UTILS_EXTENSION_NAME); + } + System.out.println(requiredInstanceExtensions.size() + " Vulkan instance extensions are required for OpenXR:"); + for (String extension : requiredInstanceExtensions) { + if (availableInstanceExtensions.contains(extension)) { + System.out.println(extension); + chosenInstanceExtensions.add(extension); + } else { + // This can happen if the OpenXR runtime is being stupid + System.out.println(extension + " [NOT SUPPORTED]"); + } + } + System.out.println("--------------"); + + PointerBuffer ppExtensionNames = stack.callocPointer(chosenInstanceExtensions.size()); + + int instanceExtensionIndex = 0; + for (String extension : chosenInstanceExtensions) { + ppExtensionNames.put(instanceExtensionIndex, stack.UTF8(extension)); + instanceExtensionIndex++; + } + ciInstance.ppEnabledExtensionNames(ppExtensionNames); + + vkCheck(vkEnumerateInstanceLayerProperties(pi, null), "EnumerateInstanceLayerProperties"); + int propertyCount = pi.get(0); + + VkLayerProperties.Buffer layerProps = VkLayerProperties.calloc(propertyCount, stack); + vkCheck(vkEnumerateInstanceLayerProperties(pi, layerProps), "EnumerateInstanceLayerProperties"); + + boolean hasValidationLayer = false; + System.out.println("Available vulkan layers:"); + for (int index = 0; index < propertyCount; index++) { + VkLayerProperties layerProp = layerProps.get(index); + + String layerName = layerProp.layerNameString(); + System.out.println(layerName); + if (layerName.equals(VK_LAYER_LUNARG_STANDARD_VALIDATION)) { + hasValidationLayer = true; + } + } + System.out.println("-------------"); + + if (hasValidationLayer) { + System.out.println("Enabling vulkan validation layer"); + PointerBuffer ppLayers = stack.callocPointer(1); + ppLayers.put(0, stack.UTF8(VK_LAYER_LUNARG_STANDARD_VALIDATION)); + ciInstance.ppEnabledLayerNames(ppLayers); + } else { + System.out.println("Vulkan validation layer is not available"); + } + + vkCheck(vkCreateInstance(ciInstance, null, pp), "CreateInstance"); + vkInstance = new VkInstance(pp.get(0), ciInstance); + + if (hasExtDebugUtils) { + VkDebugUtilsMessengerCreateInfoEXT ciDebugUtils = VkDebugUtilsMessengerCreateInfoEXT.calloc(stack) + .sType$Default() + .messageSeverity( + VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT | + VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT + ) + .messageType( + VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT | + VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT | + VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT + ) + .pfnUserCallback((messageSeverity, messageTypes, pCallbackData, userData) -> { + VkDebugUtilsMessengerCallbackDataEXT callbackData = VkDebugUtilsMessengerCallbackDataEXT.create(pCallbackData); + System.out.println("DebugUtils: " + callbackData.pMessageString()); + return 0; + }); + + vkCheck(vkCreateDebugUtilsMessengerEXT(vkInstance, ciDebugUtils, null, pl), "CreateDebugUtilsMessenger"); + vkDebugMessenger = pl.get(0); + } + + xrCheck(xrGetVulkanGraphicsDeviceKHR(xrInstance, xrSystemId, vkInstance, pp), "GetVulkanGraphicsDevice"); + vkPhysicalDevice = new VkPhysicalDevice(pp.get(0), vkInstance); + + xrCheck(xrGetVulkanDeviceExtensionsKHR(xrInstance, xrSystemId, pi, null), "GetVulkanDeviceExtensions"); + ByteBuffer pXrDeviceExtensions = stack.calloc(pi.get(0)); + + xrCheck(xrGetVulkanDeviceExtensionsKHR(xrInstance, xrSystemId, pi, pXrDeviceExtensions), "GetVulkanDeviceExtensions"); + // NOTE: The memAddress call is important because LWJGL doesn't expect byte buffers to contain the 0 char + String[] requiredDeviceExtensions = memUTF8(memAddress(pXrDeviceExtensions)).split(" "); + + vkCheck(vkEnumerateDeviceExtensionProperties(vkPhysicalDevice, (ByteBuffer)null, pi, null), "EnumerateDeviceExtensionProperties"); + int numDeviceExtensions = pi.get(0); + + VkExtensionProperties.Buffer pAvailableDeviceExtensions = VkExtensionProperties.calloc(numDeviceExtensions, stack); + vkCheck(vkEnumerateDeviceExtensionProperties(vkPhysicalDevice, (ByteBuffer)null, pi, pAvailableDeviceExtensions), "enumerateDeviceExtensionProperties"); + + // Collect the available extensions in a set for easier lookup + Set availableDeviceExtensions = new HashSet<>(numDeviceExtensions); + for (int index = 0; index < numDeviceExtensions; index++) { + availableDeviceExtensions.add(pAvailableDeviceExtensions.get(index).extensionNameString()); + } + + Set chosenDeviceExtensions = new HashSet<>(requiredDeviceExtensions.length); + + // Enumerate available device extensions + System.out.println(requiredDeviceExtensions.length + " Vulkan device extensions are required for OpenXR:"); + for (String extension : requiredDeviceExtensions) { + if (availableDeviceExtensions.contains(extension)) { + System.out.println(extension); + chosenDeviceExtensions.add(extension); + } else { + // The SteamVR OpenXR runtime sometimes requires extensions that are not supported... + System.out.println(extension + " [NOT SUPPORTED]"); + } + } + System.out.println("-------------"); + + VkPhysicalDeviceProperties pPhysicalProperties = VkPhysicalDeviceProperties.calloc(stack); + vkGetPhysicalDeviceProperties(vkPhysicalDevice, pPhysicalProperties); + System.out.println("The OpenXR runtime chose physical device " + pPhysicalProperties.deviceNameString()); + + vkGetPhysicalDeviceQueueFamilyProperties(vkPhysicalDevice, pi, null); + int queueFamilyCount = pi.get(0); + + VkQueueFamilyProperties.Buffer pQueueFamilies = VkQueueFamilyProperties.calloc(queueFamilyCount, stack); + vkGetPhysicalDeviceQueueFamilyProperties(vkPhysicalDevice, pi, pQueueFamilies); + System.out.println("Found " + queueFamilyCount + " queue families"); + + int suitableQueueFamilyIndex = -1; + for (int index = 0; index < queueFamilyCount; index++) { + VkQueueFamilyProperties familyProps = pQueueFamilies.get(index); + + int flags = familyProps.queueFlags(); + if ((flags & VK_QUEUE_GRAPHICS_BIT) != 0) { + suitableQueueFamilyIndex = index; + } + } + + if (suitableQueueFamilyIndex == -1) { + throw new RuntimeException("No queue family with graphics support was found"); + } + + vkQueueFamilyIndex = suitableQueueFamilyIndex; + // We only use 1 queue + vkQueueIndex = 0; + + VkDeviceQueueCreateInfo.Buffer cipDeviceQueue = VkDeviceQueueCreateInfo.calloc(1, stack); + cipDeviceQueue.get(0) + .sType$Default() + .queueFamilyIndex(suitableQueueFamilyIndex) + .pQueuePriorities(stack.floats(1.0f)); + + VkDeviceCreateInfo ciDevice = VkDeviceCreateInfo.calloc(stack) + .sType$Default() + .pQueueCreateInfos(cipDeviceQueue); + + PointerBuffer ppDeviceExtensions = stack.callocPointer(chosenDeviceExtensions.size()); + + int deviceExtensionIndex = 0; + for (String extension : chosenDeviceExtensions) { + ppDeviceExtensions.put(deviceExtensionIndex, stack.UTF8(extension)); + deviceExtensionIndex++; + } + ciDevice.ppEnabledExtensionNames(ppDeviceExtensions); + + vkCheck(vkCreateDevice(vkPhysicalDevice, ciDevice, null, pp), "CreateDevice"); + this.vkDevice = new VkDevice(pp.get(0), vkPhysicalDevice, ciDevice); + + vkGetDeviceQueue(vkDevice, vkQueueFamilyIndex, vkQueueIndex, pp); + this.vkQueue = new VkQueue(pp.get(0), vkDevice); + } + } + + private void destroyVk() { + if (this.vkRenderPass != 0) { + vkDestroyRenderPass(vkDevice, vkRenderPass, null); + } + + if (vkPipelineLayout != 0) { + vkDestroyPipelineLayout(vkDevice, vkPipelineLayout, null); + } + + if (vkGraphicsPipelines != null) { + for (int pipelineIndex = 0; pipelineIndex < vkGraphicsPipelines.length; pipelineIndex++) { + long graphicsPipeline = vkGraphicsPipelines[pipelineIndex]; + if (graphicsPipeline != 0 && (pipelineIndex == 0 || graphicsPipeline != vkGraphicsPipelines[pipelineIndex - 1])) { + vkDestroyPipeline(vkDevice, graphicsPipeline, null); + } + } + } + + if (vkCommandPoolCopying != 0) { + vkDestroyCommandPool(vkDevice, vkCommandPoolCopying, null); + } + if (vkCommandPoolDrawing != 0) { + vkDestroyCommandPool(vkDevice, vkCommandPoolDrawing, null); + } + + if (vkBigBuffer != 0) { + vkDestroyBuffer(vkDevice, vkBigBuffer, null); + } + if (vkDeviceMemory != 0) { + vkFreeMemory(vkDevice, vkDeviceMemory, null); + } + + if (vkDevice != null) { + vkDestroyDevice(vkDevice, null); + } + + if (vkDebugMessenger != 0L) { + vkDestroyDebugUtilsMessengerEXT(vkInstance, vkDebugMessenger, null); + } + if (vkInstance != null) { + vkDestroyInstance(vkInstance, null); + } + } + + private void createXrVkSession() { + try (MemoryStack stack = stackPush()) { + PointerBuffer pp = stack.callocPointer(1); + + xrCheck(xrCreateSession( + xrInstance, + XrSessionCreateInfo.calloc(stack) + .type$Default() + .systemId(xrSystemId) + .next(XrGraphicsBindingVulkanKHR.calloc(stack) + .type$Default() + .instance(vkInstance) + .physicalDevice(vkPhysicalDevice) + .device(vkDevice) + .queueFamilyIndex(vkQueueFamilyIndex) + .queueIndex(vkQueueIndex)), + pp + ), "CreateSession"); + xrVkSession = new XrSession(pp.get(0), xrInstance); + xrSessionState = XR_SESSION_STATE_IDLE; + System.out.println("Session is " + xrVkSession); + + if (!missingXrDebug) { + XrDebugUtilsMessengerCreateInfoEXT ciDebugUtils = XrDebugUtilsMessengerCreateInfoEXT.calloc(stack) + .type$Default() + .messageSeverities( + XR_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT | + XR_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT | + XR_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT + ) + .messageTypes( + XR_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT | + XR_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT | + XR_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT | + XR_DEBUG_UTILS_MESSAGE_TYPE_CONFORMANCE_BIT_EXT + ) + .userCallback((messageSeverity, messageTypes, pCallbackData, userData) -> { + XrDebugUtilsMessengerCallbackDataEXT callbackData = XrDebugUtilsMessengerCallbackDataEXT.create(pCallbackData); + System.out.println("XR Debug Utils: " + callbackData.messageString()); + return 0; + }); + + System.out.println("Enabling OpenXR debug utils"); + xrCheck(xrCreateDebugUtilsMessengerEXT(xrInstance, ciDebugUtils, pp), "CreateDebugUtilsMessenger"); + xrDebugMessenger = new XrDebugUtilsMessengerEXT(pp.get(0), xrInstance); + } + } + } + + private static XrPosef identityPose(MemoryStack stack) { + return XrPosef.calloc(stack) + .orientation(XrQuaternionf.calloc(stack) + .w(1.0f)) + .position$(XrVector3f.calloc(stack)); + } + + private void createRenderResources() { + chooseSwapchainFormats(); + createRenderPass(); + createCommandPools(); + createSwapchains(); + createGraphicsPipelines(); + createRenderSpace(); + createBuffers(); + } + + private int chooseMemoryTypeIndex(VkMemoryRequirements requirements, int requiredPropertyBits, MemoryStack stack) { + VkPhysicalDeviceMemoryProperties memoryProps = VkPhysicalDeviceMemoryProperties.calloc(stack); + vkGetPhysicalDeviceMemoryProperties(vkPhysicalDevice, memoryProps); + + for (int memoryTypeIndex = 0; memoryTypeIndex < memoryProps.memoryTypeCount(); memoryTypeIndex++) { + boolean allowedByResource = (requirements.memoryTypeBits() & (1 << memoryTypeIndex)) != 0; + boolean hasNeededProperties = (memoryProps.memoryTypes(memoryTypeIndex).propertyFlags() & requiredPropertyBits) == requiredPropertyBits; + + if (allowedByResource && hasNeededProperties) { + return memoryTypeIndex; + } + } + + throw new IllegalArgumentException("Failed to find suitable memory type for resource"); + } + + private static final float[][] QUAD_OFFSETS = { + {-1, -1, 0}, {1, -1, 0}, {1, 1, 0}, {-1, 1, 0} + }; + + private static class CubePlane { + + final float constantX, constantY, constantZ; + final float factorX, factorY, factorZ; + final int offsetX, offsetY, offsetZ; + final int colorIndex; + + CubePlane( + float constantX, float constantY, float constantZ, + float factorX, float factorY, float factorZ, + int offsetX, int offsetY, int offsetZ, int colorIndex + ) { + this.constantX = constantX; + this.constantY = constantY; + this.constantZ = constantZ; + + this.factorX = factorX; + this.factorY = factorY; + this.factorZ = factorZ; + + this.offsetX = offsetX; + this.offsetY = offsetY; + this.offsetZ = offsetZ; + + this.colorIndex = colorIndex; + } + } + + private static final CubePlane[] CUBE_PLANES = { + // Bottom + new CubePlane( + 0, -1, 0, 1, 0, 1, + 0, 2, 1, 0 + ), + // Top + new CubePlane( + 0, 1, 0, 1, 0, -1, + 0, 2, 1, 1 + ), + // Left + new CubePlane( + -1, 0, 0, 0, 1, 1, + 2, 1, 0, 2 + ), + // Right + new CubePlane( + 1, 0, 0, 0, 1, -1, + 2, 1, 0, 3 + ), + // Front + new CubePlane( + 0, 0, -1, -1, 1, 0, + 0, 1, 2, 4 + ), + // Back + new CubePlane( + 0, 0, 1, 1, 1, 0, + 0, 1, 2, 5 + ) + }; + +// JME3: TODO, replace this function + private static void putVertexData(ByteBuffer dest) { + Random random = new Random(87234); + for (int cubeIndex = 0; cubeIndex < BigModel.NUM_CUBES; cubeIndex++) { + float midX = 60f * random.nextFloat() - 30f; + float midY = 60f * random.nextFloat() - 30f; + float midZ = 60f * random.nextFloat() - 30f; + + // Each side has its own color + float[] red = new float[6]; + float[] green = new float[6]; + float[] blue = new float[6]; + + for (int side = 0; side < 6; side++) { + red[side] = random.nextFloat(); + green[side] = random.nextFloat(); + blue[side] = random.nextFloat(); + } + + float size = 1.5f; + + for (CubePlane plane : CUBE_PLANES) { + for (float[] offsets : QUAD_OFFSETS) { + float cornerX = midX + size * (plane.constantX + offsets[plane.offsetX] * plane.factorX); + float cornerY = midY + size * (plane.constantY + offsets[plane.offsetY] * plane.factorY); + float cornerZ = midZ + size * (plane.constantZ + offsets[plane.offsetZ] * plane.factorZ); + dest.putFloat(cornerX); + dest.putFloat(cornerY); + dest.putFloat(cornerZ); + dest.putFloat(red[plane.colorIndex]); + dest.putFloat(green[plane.colorIndex]); + dest.putFloat(blue[plane.colorIndex]); + } + } + } + + // 1 more cube for the small model + float size = 0.15f; + for (CubePlane plane : CUBE_PLANES) { + for (float[] offsets : QUAD_OFFSETS) { + float cornerX = size * (plane.constantX + offsets[plane.offsetX] * plane.factorX); + float cornerY = size * (plane.constantY + offsets[plane.offsetY] * plane.factorY); + float cornerZ = size * (plane.constantZ + offsets[plane.offsetZ] * plane.factorZ); + dest.putFloat(cornerX); + dest.putFloat(cornerY); + dest.putFloat(cornerZ); + dest.putFloat(max(0f, abs(plane.constantX))); + dest.putFloat(max(0f, abs(plane.constantY))); + dest.putFloat(max(0f, abs(plane.constantZ))); + } + } + } + +// JME3: TODO, replace this function + private static void putIndexData(ByteBuffer dest) { + int vertexIndex = 0; + + for (int cubeCounter = 0; cubeCounter < BigModel.NUM_CUBES; cubeCounter++) { + for (int quadCounter = 0; quadCounter < 6; quadCounter++) { + + int[] indexOffsets = {0, 1, 2, 2, 3, 0}; + for (int indexOffset : indexOffsets) { + if (INDEX_SIZE == 4) { + dest.putInt(vertexIndex + indexOffset); + } else if (INDEX_SIZE == 2) { + dest.putShort((short)(vertexIndex + indexOffset)); + } else { + throw new Error("Unexpected index size: " + INDEX_SIZE); + } + } + + vertexIndex += 4; + } + } + } + + private void createBuffers() { + try (MemoryStack stack = stackPush()) { + PointerBuffer pp = stack.callocPointer(1); + LongBuffer pl = stack.callocLong(1); + + int bigVertexSize = BigModel.NUM_VERTICES * VERTEX_SIZE; + int bigIndexSize = BigModel.NUM_INDICES * INDEX_SIZE; + + // The small model only needs 1 cube + int smallVertexSize = 6 * 4 * VERTEX_SIZE; + // We can just reuse the indices of the big model because the ones for the small model should be a substring of it + + int totalVertexSize = bigVertexSize + smallVertexSize; + + long sharedBuffer = createBuffer(totalVertexSize + bigIndexSize, VK_BUFFER_USAGE_TRANSFER_SRC_BIT); + + VkMemoryRequirements sharedMemRequirements = VkMemoryRequirements.calloc(stack); + vkGetBufferMemoryRequirements(vkDevice, sharedBuffer, sharedMemRequirements); + + vkCheck(vkAllocateMemory( + vkDevice, + VkMemoryAllocateInfo.calloc(stack) + .sType$Default() + .allocationSize(sharedMemRequirements.size()) + .memoryTypeIndex(chooseMemoryTypeIndex(sharedMemRequirements, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, stack)), + null, + pl + ), "AllocateMemory"); + long sharedMemory = pl.get(0); + + vkCheck(vkMapMemory(vkDevice, sharedMemory, 0, VK_WHOLE_SIZE, 0, pp), "MapMemory"); + ByteBuffer sharedData = memByteBuffer(pp.get(0), totalVertexSize + bigIndexSize); + + sharedData.position(0); + sharedData.limit(totalVertexSize); + putVertexData(sharedData); + + sharedData.position(totalVertexSize); + sharedData.limit(totalVertexSize + bigIndexSize); + putIndexData(sharedData); + + sharedData.position(0); + sharedData.limit(sharedData.capacity()); + + vkCheck(vkFlushMappedMemoryRanges( + vkDevice, + VkMappedMemoryRange.calloc(stack) + .sType$Default() + .memory(sharedMemory) + .offset(0) + .size(VK_WHOLE_SIZE) + ), "FlushMappedMemoryRanges"); + vkUnmapMemory(vkDevice, sharedMemory); + vkCheck(vkBindBufferMemory(vkDevice, sharedBuffer, sharedMemory, 0), "BindBufferMemory"); + + this.vkBigBuffer = createBuffer( + totalVertexSize + bigIndexSize, + VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | VK_BUFFER_USAGE_INDEX_BUFFER_BIT + ); + + VkMemoryRequirements deviceMemRequirements = VkMemoryRequirements.calloc(stack); + vkGetBufferMemoryRequirements(vkDevice, vkBigBuffer, deviceMemRequirements); + + vkCheck(vkAllocateMemory( + vkDevice, + VkMemoryAllocateInfo.calloc(stack) + .sType$Default() + .allocationSize(deviceMemRequirements.size()) + .memoryTypeIndex(chooseMemoryTypeIndex(deviceMemRequirements, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, stack)), + null, + pl + ), "AllocateMemory"); + this.vkDeviceMemory = pl.get(0); + + vkCheck(vkBindBufferMemory(vkDevice, vkBigBuffer, vkDeviceMemory, 0), "BindBufferMemory"); + + vkCheck(vkAllocateCommandBuffers( + vkDevice, + VkCommandBufferAllocateInfo.calloc(stack) + .sType$Default() + .commandPool(vkCommandPoolCopying) + .level(VK_COMMAND_BUFFER_LEVEL_PRIMARY) + .commandBufferCount(1), + pp + ), "AllocateCommandBuffers"); + VkCommandBuffer copyCommandBuffer = new VkCommandBuffer(pp.get(0), vkDevice); + + vkCheck(vkBeginCommandBuffer( + copyCommandBuffer, + VkCommandBufferBeginInfo.calloc(stack) + .sType$Default() + .flags(VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT) + ), "BeginCommandBuffer"); + + VkBufferCopy.Buffer copyRegions = VkBufferCopy.calloc(1, stack); + copyRegions.get(0) + .srcOffset(0) + .dstOffset(0) + .size(totalVertexSize + bigIndexSize); + + vkCmdCopyBuffer(copyCommandBuffer, sharedBuffer, vkBigBuffer, copyRegions); + vkEndCommandBuffer(copyCommandBuffer); + + vkCheck(vkCreateFence( + vkDevice, + VkFenceCreateInfo.calloc(stack) + .sType$Default() + .flags(0), + null, + pl + ), "CreateFence"); + long fence = pl.get(0); + + vkCheck(vkQueueSubmit( + vkQueue, + VkSubmitInfo.calloc(stack) + .sType$Default() + .waitSemaphoreCount(0) // I'm not sure why I need to set this explicitly + .pWaitSemaphores(null) + .pSignalSemaphores(null) + .pWaitDstStageMask(null) + .pCommandBuffers(stack.pointers(copyCommandBuffer)), + fence + ), "QueueSubmit"); + vkCheck(vkWaitForFences(vkDevice, pl, true, 1_000_000_000L), "WaitForFences"); + vkCheck(vkQueueWaitIdle(vkQueue), "QueueWaitIdle"); + + vkFreeMemory(vkDevice, sharedMemory, null); + vkDestroyBuffer(vkDevice, sharedBuffer, null); + vkFreeCommandBuffers(vkDevice, vkCommandPoolCopying, copyCommandBuffer); + vkDestroyFence(vkDevice, fence, null); + } + } + + private long createBuffer(long size, int usage) { + try (MemoryStack stack = stackPush()) { + LongBuffer pl = stack.callocLong(1); + vkCreateBuffer( + vkDevice, + VkBufferCreateInfo.calloc(stack) + .sType$Default() + .flags(0) + .size(size) + .usage(usage) + .sharingMode(VK_SHARING_MODE_EXCLUSIVE), + null, + pl); + return pl.get(0); + } + } + + private void createRenderSpace() { + try (MemoryStack stack = stackPush()) { + PointerBuffer pp = stack.callocPointer(1); + xrCheck(xrCreateReferenceSpace( + xrVkSession, + XrReferenceSpaceCreateInfo.calloc(stack) + .type$Default() + .referenceSpaceType(XR_REFERENCE_SPACE_TYPE_LOCAL) + .poseInReferenceSpace(identityPose(stack)), + pp + ), "CreateReferenceSpace"); + renderSpace = new XrSpace(pp.get(0), xrVkSession); + } + } + + private void createRenderPass() { + try (MemoryStack stack = stackPush()) { + VkAttachmentDescription.Buffer attachments = VkAttachmentDescription.calloc(2, stack); + + attachments.get(0) + .flags(0) + .format(swapchainColorFormat) + // TODO SAMPLES + .samples(VK_SAMPLE_COUNT_1_BIT) + .loadOp(VK_ATTACHMENT_LOAD_OP_CLEAR) + .storeOp(VK_ATTACHMENT_STORE_OP_STORE) + .stencilLoadOp(VK_ATTACHMENT_LOAD_OP_DONT_CARE) + .stencilStoreOp(VK_ATTACHMENT_STORE_OP_DONT_CARE) + .initialLayout(VK_IMAGE_LAYOUT_UNDEFINED) + .finalLayout(VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); + + attachments.get(1) + .flags(0) + .format(swapchainDepthFormat) + // TODO SAMPLES + .samples(VK_SAMPLE_COUNT_1_BIT) + .loadOp(VK_ATTACHMENT_LOAD_OP_CLEAR) + .storeOp(VK_ATTACHMENT_STORE_OP_DONT_CARE) + .stencilLoadOp(VK_ATTACHMENT_LOAD_OP_DONT_CARE) + .stencilStoreOp(VK_ATTACHMENT_STORE_OP_DONT_CARE) + .initialLayout(VK_IMAGE_LAYOUT_UNDEFINED) + .finalLayout(VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL); + + VkAttachmentReference.Buffer colorAttachmentRefs = VkAttachmentReference.calloc(1, stack); + colorAttachmentRefs.get(0) + .attachment(0) + .layout(VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); + + // Ensure that the render pass doesn't begin too early + VkSubpassDependency.Buffer dependencies = VkSubpassDependency.calloc(1, stack); + dependencies.get(0) + .srcSubpass(VK_SUBPASS_EXTERNAL) + .dstSubpass(0) + .srcStageMask(VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT) + .srcAccessMask(0) + .dstStageMask(VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT) + .dstAccessMask(VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT); + + VkSubpassDescription.Buffer subpasses = VkSubpassDescription.calloc(1, stack); + subpasses.get(0) + .flags(0) + .pipelineBindPoint(VK_PIPELINE_BIND_POINT_GRAPHICS) + // For some reason, I have to specify the colorAttachmentCount explicitly + .colorAttachmentCount(1) + .pColorAttachments(colorAttachmentRefs) + .pDepthStencilAttachment(VkAttachmentReference.calloc(stack) + .attachment(1) + .layout(VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL)); + + LongBuffer pl = stack.callocLong(1); + vkCheck(vkCreateRenderPass( + vkDevice, + VkRenderPassCreateInfo.calloc(stack) + .sType$Default() + .flags(0) + .pAttachments(attachments) + .pSubpasses(subpasses) + .pDependencies(dependencies), + null, + pl + ), "CreateRenderPass"); + this.vkRenderPass = pl.get(0); + } + } + + private void createGraphicsPipelines() { + try (MemoryStack stack = stackPush()) { + VkPushConstantRange.Buffer pushConstants = VkPushConstantRange.calloc(1, stack); + pushConstants.get(0) + .stageFlags(VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT) + .offset(0) + // 1 matrix of 4x4 floats (4 bytes per float) + // and 1 boolean that needs 4 bytes + .size(4 * 4 * 4 + 4); + + LongBuffer pl = stack.callocLong(1); + vkCheck(vkCreatePipelineLayout( + vkDevice, + VkPipelineLayoutCreateInfo.calloc(stack) + .sType$Default() + .flags(0) + // I will add uniform variables or push constants later + .pSetLayouts(null) + .pPushConstantRanges(pushConstants), + null, + pl + ), "CreatePipelineLayout"); + this.vkPipelineLayout = pl.get(0); + } + + long vertexModule, fragmentModule; + try (MemoryStack stack = stackPush()) { + LongBuffer pl = stack.callocLong(1); + + ByteBuffer vertexBytes = getShaderResource("demo/openxr/vulkan/hello.vert.spv"); + vkCheck(vkCreateShaderModule( + vkDevice, + VkShaderModuleCreateInfo.calloc(stack) + .sType$Default() + .pCode(vertexBytes), + null, + pl + ), "CreateShaderModule (vertex)"); + vertexModule = pl.get(0); + + ByteBuffer fragmentBytes = getShaderResource("demo/openxr/vulkan/hello.frag.spv"); + vkCheck(vkCreateShaderModule( + vkDevice, + VkShaderModuleCreateInfo.calloc(stack) + .sType$Default() + .pCode(fragmentBytes), + null, + pl + ), "CreateShaderModule (fragment)"); + fragmentModule = pl.get(0); + } + + this.vkGraphicsPipelines = new long[this.swapchains.length]; + + for (int swapchainIndex = 0; swapchainIndex < this.swapchains.length; swapchainIndex++) { + if ( + swapchainIndex == 0 || this.swapchains[swapchainIndex - 1].width != this.swapchains[swapchainIndex].width + || this.swapchains[swapchainIndex - 1].height != this.swapchains[swapchainIndex].height + ) { + createGraphicsPipeline(swapchainIndex, vertexModule, fragmentModule); + } else { + // If the swapchain has the same size as the previous swapchain (expected case), share the graphics pipeline + this.vkGraphicsPipelines[swapchainIndex] = this.vkGraphicsPipelines[swapchainIndex - 1]; + } + } + + vkDestroyShaderModule(vkDevice, vertexModule, null); + vkDestroyShaderModule(vkDevice, fragmentModule, null); + } + + private void createGraphicsPipeline(int swapchainIndex, long vertexModule, long fragmentModule) { + try (MemoryStack stack = stackPush()) { + VkPipelineShaderStageCreateInfo.Buffer ciPipelineShaderStages = VkPipelineShaderStageCreateInfo.calloc(2, stack); + ciPipelineShaderStages.get(0) + .sType$Default() + .flags(0) + .stage(VK_SHADER_STAGE_VERTEX_BIT) + .module(vertexModule) + .pName(stack.UTF8("main")); + + ciPipelineShaderStages.get(1) + .sType$Default() + .flags(0) + .stage(VK_SHADER_STAGE_FRAGMENT_BIT) + .module(fragmentModule) + .pName(stack.UTF8("main")); + + VkVertexInputBindingDescription.Buffer vertexBindingDescriptions = VkVertexInputBindingDescription.calloc(1, stack); + vertexBindingDescriptions.get(0) + .binding(0) + .stride(VERTEX_SIZE) + .inputRate(VK_VERTEX_INPUT_RATE_VERTEX); + + VkVertexInputAttributeDescription.Buffer vertexAttributeDescriptions = VkVertexInputAttributeDescription.calloc(2, stack); + vertexAttributeDescriptions.get(0) + .location(VERTEX_LOCATION_POSITION) + .binding(0) + .format(VK_FORMAT_R32G32B32_SFLOAT) + .offset(VERTEX_OFFSET_POSITION); + + vertexAttributeDescriptions.get(1) + .location(VERTEX_LOCATION_COLOR) + .binding(0) + .format(VK_FORMAT_R32G32B32_SFLOAT) + .offset(VERTEX_OFFSET_COLOR); + + VkViewport.Buffer viewports = VkViewport.calloc(1, stack); + viewports.get(0) + .x(0f) + .y(0f) + .width(this.swapchains[swapchainIndex].width) + .height(this.swapchains[swapchainIndex].height) + .minDepth(0f) + .maxDepth(1f); + + VkRect2D.Buffer scissors = VkRect2D.calloc(1, stack); + scissors.get(0) + .offset(VkOffset2D.calloc(stack)) // By using calloc, the offset will have a default value of 0, which is desired + .extent(VkExtent2D.calloc(stack).set( + this.swapchains[swapchainIndex].width, + this.swapchains[swapchainIndex].height + )); + + VkPipelineColorBlendAttachmentState.Buffer atsColorBlend = VkPipelineColorBlendAttachmentState.calloc(1, stack); + // We only have 1 color attachment, so we only use 1 color blend attachment state + atsColorBlend.get(0) + .blendEnable(false) // We won't be doing any fancy blending + .colorWriteMask(VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT); + + VkGraphicsPipelineCreateInfo.Buffer ciGraphicsPipelines = VkGraphicsPipelineCreateInfo.calloc(1, stack); + + // In this example, I will use only 1 graphics pipeline + ciGraphicsPipelines.get(0) + .sType$Default() + .flags(0) + .renderPass(this.vkRenderPass) + .subpass(0) + .layout(this.vkPipelineLayout) + .basePipelineHandle(VK_NULL_HANDLE) // No pipeline derivatives in this example + .basePipelineIndex(-1) + .pStages(ciPipelineShaderStages) + .pVertexInputState(VkPipelineVertexInputStateCreateInfo.calloc(stack) + .sType$Default() + .flags(0) + .pVertexBindingDescriptions(vertexBindingDescriptions) + .pVertexAttributeDescriptions(vertexAttributeDescriptions)) + .pInputAssemblyState(VkPipelineInputAssemblyStateCreateInfo.calloc(stack) + .sType$Default() + .flags(0) + .topology(VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST) + .primitiveRestartEnable(false)) + // This example won't use a tessellation shader + .pTessellationState(null) + .pViewportState(VkPipelineViewportStateCreateInfo.calloc(stack) + .sType$Default() + .flags(0) + .pViewports(viewports) + .pScissors(scissors)) + .pRasterizationState(VkPipelineRasterizationStateCreateInfo.calloc(stack) + .sType$Default() + .flags(0) + .depthClampEnable(false) + .rasterizerDiscardEnable(false) + .polygonMode(VK_POLYGON_MODE_FILL) + .lineWidth(1f) + .cullMode(VK_CULL_MODE_BACK_BIT) + .frontFace(VK_FRONT_FACE_COUNTER_CLOCKWISE) + .depthBiasEnable(false)) + .pMultisampleState(VkPipelineMultisampleStateCreateInfo.calloc(stack) + .sType$Default() + .flags(0) + // TODO SAMPLES + .rasterizationSamples(VK_SAMPLE_COUNT_1_BIT) + .sampleShadingEnable(false) + // I won't ignore a part of the samples + .pSampleMask(null) + // I won't use transparency in this example + .alphaToCoverageEnable(false) + .alphaToOneEnable(false)) + .pDepthStencilState(VkPipelineDepthStencilStateCreateInfo.calloc(stack) + .sType$Default() + .flags(0) + .depthTestEnable(true) + .depthWriteEnable(true) + .depthCompareOp(VK_COMPARE_OP_LESS) + .depthBoundsTestEnable(false) + .stencilTestEnable(false)) + .pColorBlendState(VkPipelineColorBlendStateCreateInfo.calloc(stack) + .sType$Default() + .flags(0) + .logicOpEnable(false) + .pAttachments(atsColorBlend)) + .pDynamicState(null); // No dynamic state will be needed + + LongBuffer pl = stack.callocLong(1); + vkCheck(vkCreateGraphicsPipelines(vkDevice, VK_NULL_HANDLE, ciGraphicsPipelines, null, pl), "CreateGraphicsPipelines"); + this.vkGraphicsPipelines[swapchainIndex] = pl.get(0); + } + } + + private void createCommandPools() { + try (MemoryStack stack = stackPush()) { + LongBuffer pl = stack.callocLong(1); + + // The copy command pool is for 1-time-use copy commands + vkCheck(vkCreateCommandPool( + vkDevice, + VkCommandPoolCreateInfo.calloc(stack) + .sType$Default() + .flags(VK_COMMAND_POOL_CREATE_TRANSIENT_BIT) + .queueFamilyIndex(vkQueueFamilyIndex), + null, + pl + ), "CreateCommandPool"); + this.vkCommandPoolCopying = pl.get(0); + + // The drawing command buffers will be allocated once and recorded many times + vkCheck(vkCreateCommandPool( + vkDevice, + VkCommandPoolCreateInfo.calloc(stack) + .sType$Default() + .flags(VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT) + .queueFamilyIndex(vkQueueFamilyIndex), + null, + pl + ), "CreateCommandPool"); + this.vkCommandPoolDrawing = pl.get(0); + } + } + + private void chooseSwapchainFormats() { + try (MemoryStack stack = stackPush()) { + IntBuffer pi = stack.callocInt(1); + xrCheck(xrEnumerateSwapchainFormats(xrVkSession, pi, null), "EnumerateSwapchainFormats"); + int numFormats = pi.get(0); + + LongBuffer formats = stack.callocLong(numFormats); + xrCheck(xrEnumerateSwapchainFormats(xrVkSession, pi, formats), "EnumerateSwapchainFormats"); + + // SRGB formats are preferred due to the human perception of colors + // Non-alpha formats are preferred because I don't intend to use it and it would spare memory + int[] preferredColorFormats = { + VK_FORMAT_R8G8B8_SRGB, VK_FORMAT_B8G8R8_SRGB, + VK_FORMAT_R8G8B8A8_SRGB, VK_FORMAT_B8G8R8A8_SRGB, + VK_FORMAT_R8G8B8_UNORM, VK_FORMAT_B8G8R8_UNORM, + VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_B8G8R8A8_UNORM + }; + boolean[] hasPreferredColorFormats = new boolean[preferredColorFormats.length]; + + // NVidia recommends avoiding 32 bits for the depth component because it slows down depth testing. + // (For graphics cards, comparisons with 24 bit floating point numbers is easier than with 32.) + // We don't use the stencil test, so we prefer a format without one. + int[] preferredDepthFormats = { + VK_FORMAT_X8_D24_UNORM_PACK32, + VK_FORMAT_D24_UNORM_S8_UINT, + VK_FORMAT_D32_SFLOAT, + VK_FORMAT_D32_SFLOAT_S8_UINT + }; + boolean[] hasPrefferedDepthFormats = new boolean[preferredDepthFormats.length]; + + System.out.println("There are " + numFormats + " swapchain formats:"); + for (int index = 0; index < numFormats; index++) { + long format = formats.get(index); + + String formatName = findConstantMeaning(VK10.class, name -> name.startsWith("VK_FORMAT_"), format); + if (formatName == null) { + formatName = "unknown"; + } + System.out.println(formatName + " (" + format + ")"); + + for (int prefIndex = 0; prefIndex < preferredColorFormats.length; prefIndex++) { + if (format == preferredColorFormats[prefIndex]) { + hasPreferredColorFormats[prefIndex] = true; + } + } + + for (int prefIndex = 0; prefIndex < preferredDepthFormats.length; prefIndex++) { + if (format == preferredDepthFormats[prefIndex]) { + hasPrefferedDepthFormats[prefIndex] = true; + } + } + } + System.out.println("--------------"); + + swapchainColorFormat = -1; + swapchainDepthFormat = -1; + + // Pick the best formats available + for (int prefIndex = 0; prefIndex < preferredColorFormats.length; prefIndex++) { + if (hasPreferredColorFormats[prefIndex]) { + swapchainColorFormat = preferredColorFormats[prefIndex]; + break; + } + } + + for (int prefIndex = 0; prefIndex < preferredDepthFormats.length; prefIndex++) { + if (hasPrefferedDepthFormats[prefIndex]) { + swapchainDepthFormat = preferredDepthFormats[prefIndex]; + break; + } + } + + if (swapchainColorFormat == -1) { + // Damn... what kind of graphics card/xr runtime is this? + // Well... if we can't find any format we like, we will just pick the first one + swapchainColorFormat = (int)formats.get(0); + } + if (swapchainDepthFormat == -1) { + // Let's hope it will never come to this... + swapchainDepthFormat = (int)formats.get(0); + } + + System.out.println("Chose swapchain formats " + swapchainColorFormat + " and " + swapchainDepthFormat); + } + } + + private void createSwapchains() { + try (MemoryStack stack = stackPush()) { + IntBuffer pi = stack.callocInt(1); + LongBuffer pl = stack.callocLong(1); + + xrCheck(xrEnumerateViewConfigurations(xrInstance, xrSystemId, pi, null), "EnumerateViewConfigurations"); + int numViewConfigurations = pi.get(0); + + System.out.println("There are " + numViewConfigurations + " view configurations:"); + IntBuffer viewConfigurations = stack.callocInt(numViewConfigurations); + xrCheck(xrEnumerateViewConfigurations(xrInstance, xrSystemId, pi, viewConfigurations), "EnumerateViewConfigurations"); + + boolean hasPrimarySterio = false; + for (int viewIndex = 0; viewIndex < numViewConfigurations; viewIndex++) { + int viewConfiguration = viewConfigurations.get(viewIndex); + System.out.println(findConstantMeaning(XR10.class, constantName -> constantName.startsWith("XR_VIEW_CONFIGURATION_TYPE_"), viewConfiguration) + " (" + viewConfiguration + ")"); + if (viewConfiguration == XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO) { + hasPrimarySterio = true; + } + } + System.out.println("~~~~~~~~~~"); + + // I prefer primary stereo. If that is not available, I will go for the first best alternative. + viewConfiguration = hasPrimarySterio + ? XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO + : viewConfigurations.get(0); + System.out.println("Chose " + viewConfiguration); + + xrCheck(xrEnumerateViewConfigurationViews(xrInstance, xrSystemId, viewConfiguration, pi, null), "EnumerateViewConfigurationViews"); + int numViews = pi.get(0); + + System.out.println("There are " + numViews + " views"); + XrViewConfigurationView.Buffer viewConfigurationViews = XrHelper.fill( + XrViewConfigurationView.calloc(numViews, stack), + XrViewConfigurationView.TYPE, + XR_TYPE_VIEW_CONFIGURATION_VIEW + ); + xrCheck(xrEnumerateViewConfigurationViews(xrInstance, xrSystemId, viewConfiguration, pi, viewConfigurationViews), "EnumerateViewConfigurationViews"); + + PointerBuffer pCommandBuffers = stack.callocPointer(2); + vkCheck(vkAllocateCommandBuffers( + vkDevice, + VkCommandBufferAllocateInfo.calloc(stack) + .sType$Default() + .commandPool(vkCommandPoolDrawing) + .level(VK_COMMAND_BUFFER_LEVEL_PRIMARY) + .commandBufferCount(numViews), + pCommandBuffers + ), "AllocateCommandBuffers"); + + this.swapchains = new SwapchainWrapper[numViews]; + for (int swapchainIndex = 0; swapchainIndex < numViews; swapchainIndex++) { + XrViewConfigurationView viewConfig = viewConfigurationViews.get(swapchainIndex); + + XrSwapchainCreateInfo ciSwapchain = XrSwapchainCreateInfo.calloc(stack) + .type$Default() + .createFlags(0) + .usageFlags(XR_SWAPCHAIN_USAGE_COLOR_ATTACHMENT_BIT | XR_SWAPCHAIN_USAGE_SAMPLED_BIT) + .format(swapchainColorFormat) + .width(viewConfig.recommendedImageRectWidth()) + .height(viewConfig.recommendedImageRectHeight()) + .sampleCount(viewConfig.recommendedSwapchainSampleCount()) + .mipCount(1) + .arraySize(1) + .faceCount(1); + + System.out.println("Creating a swapchain of " + + ciSwapchain.width() + " x " + + ciSwapchain.height() + " with " + + ciSwapchain.sampleCount() + " samples"); + + PointerBuffer pp = stack.callocPointer(1); + xrCheck(xrCreateSwapchain(xrVkSession, ciSwapchain, pp), "CreateSwapchain"); + XrSwapchain swapchain = new XrSwapchain(pp.get(0), xrVkSession); + + xrCheck(xrEnumerateSwapchainImages(swapchain, pi, null), "EnumerateSwapchainImages"); + int numImages = pi.get(0); + + System.out.println("Swapchain " + swapchainIndex + " has " + numImages + " images"); + XrSwapchainImageVulkanKHR.Buffer swapchainColorImages = XrHelper.fill( + XrSwapchainImageVulkanKHR.calloc(numImages, stack), + XrSwapchainImageVulkanKHR.TYPE, + XR_TYPE_SWAPCHAIN_IMAGE_VULKAN_KHR + ); + + xrCheck(xrEnumerateSwapchainImages( + swapchain, pi, + XrSwapchainImageBaseHeader.create(swapchainColorImages) + ), "EnumerateSwapchainImages"); + + vkCheck(vkCreateImage( + vkDevice, + VkImageCreateInfo.calloc(stack) + .sType$Default() + .flags(0) + .imageType(VK_IMAGE_TYPE_2D) + .format(swapchainDepthFormat) + .extent(it -> it + .width(ciSwapchain.width()) + .height(ciSwapchain.height()) + .depth(1)) + .mipLevels(1) + .arrayLayers(1) + // TODO SAMPLES + .samples(VK_SAMPLE_COUNT_1_BIT) + .tiling(VK_IMAGE_TILING_OPTIMAL) + .usage(VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) + .sharingMode(VK_SHARING_MODE_EXCLUSIVE) + .initialLayout(VK_IMAGE_LAYOUT_UNDEFINED), + null, + pl + ), "CreateImage"); + long depthImage = pl.get(0); + + SwapchainImage[] swapchainImages = new SwapchainImage[numImages]; + + VkComponentMapping componentMapping = VkComponentMapping.calloc(stack) + .r(VK_COMPONENT_SWIZZLE_IDENTITY) + .g(VK_COMPONENT_SWIZZLE_IDENTITY) + .b(VK_COMPONENT_SWIZZLE_IDENTITY) + .a(VK_COMPONENT_SWIZZLE_IDENTITY); + + VkImageViewCreateInfo ciDepthImageView = VkImageViewCreateInfo.calloc(stack) + .sType$Default() + .flags(0) + .image(depthImage) + .viewType(VK_IMAGE_VIEW_TYPE_2D) + .format(swapchainDepthFormat) + .components(componentMapping) + .subresourceRange(VkImageSubresourceRange.calloc(stack) + .aspectMask(VK_IMAGE_ASPECT_DEPTH_BIT) + .baseMipLevel(0) + .levelCount(1) + .baseArrayLayer(0) + .layerCount(1)); + + VkMemoryRequirements pMemoryRequirements = VkMemoryRequirements.calloc(stack); + vkGetImageMemoryRequirements(vkDevice, depthImage, pMemoryRequirements); + + int memoryTypeIndex = chooseMemoryTypeIndex(pMemoryRequirements, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, stack); + + vkCheck(vkAllocateMemory( + vkDevice, + VkMemoryAllocateInfo.calloc(stack) + .sType$Default() + .allocationSize(pMemoryRequirements.size()) + .memoryTypeIndex(memoryTypeIndex), + null, + pl + ), "AllocateMemory"); + long depthImageMemory = pl.get(0); + + vkCheck(vkBindImageMemory(vkDevice, depthImage, depthImageMemory, 0), "BindImageMemory"); + vkCheck(vkCreateImageView(vkDevice, ciDepthImageView, null, pl), "CreateImageView"); + long depthImageView = pl.get(0); + + for (int imageIndex = 0; imageIndex < numImages; imageIndex++) { + long colorImage = swapchainColorImages.get(imageIndex).image(); + + vkCheck(vkCreateImageView( + vkDevice, + VkImageViewCreateInfo.calloc(stack) + .sType$Default() + .flags(0) + .image(colorImage) + .viewType(VK_IMAGE_VIEW_TYPE_2D) + .format(swapchainColorFormat) + .components(componentMapping) + .subresourceRange(VkImageSubresourceRange.calloc(stack) + .aspectMask(VK_IMAGE_ASPECT_COLOR_BIT) + .baseMipLevel(0) + .levelCount(1) + .baseArrayLayer(0) + .layerCount(1)), + null, + pl + ), "CreateImageView"); + long colorImageView = pl.get(0); + + vkCheck(vkCreateFramebuffer( + vkDevice, + VkFramebufferCreateInfo.calloc(stack) + .sType$Default() + .flags(0) + .renderPass(vkRenderPass) + .pAttachments(stack.longs(colorImageView, depthImageView)) + .width(ciSwapchain.width()) + .height(ciSwapchain.height()) + .layers(1), + null, + pl + ), "CreateFramebuffer"); + long framebuffer = pl.get(0); + + swapchainImages[imageIndex] = new SwapchainImage(colorImage, colorImageView, framebuffer); + } + + vkCheck(vkCreateFence( + vkDevice, + VkFenceCreateInfo.calloc(stack) + .sType$Default() + .flags(0), + null, + pl + ), "CreateFence"); + + this.swapchains[swapchainIndex] = new SwapchainWrapper( + new XrSwapchain(pp.get(0), xrVkSession), + ciSwapchain.width(), ciSwapchain.height(), ciSwapchain.sampleCount(), + depthImage, depthImageView, depthImageMemory, swapchainImages, + pl.get(0), new VkCommandBuffer(pCommandBuffers.get(swapchainIndex), vkDevice) + ); + } + } + } + + private XrCompositionLayerProjectionView.Buffer createProjectionViews(MemoryStack stack, long displayTime) { + IntBuffer pi = stack.ints(swapchains.length); + + XrViewState viewState = XrViewState.calloc(stack) + .type$Default(); + + XrView.Buffer views = XrHelper.fill( + XrView.calloc(swapchains.length, stack), + XrView.TYPE, + XR_TYPE_VIEW + ); + + xrCheck(xrLocateViews( + xrVkSession, + XrViewLocateInfo.calloc(stack) + .type$Default() + .viewConfigurationType(viewConfiguration) + .displayTime(displayTime) + .space(renderSpace), + viewState, + pi, + views + ), "LocateViews"); + + long viewFlags = viewState.viewStateFlags(); + if ((viewFlags & XR_VIEW_STATE_POSITION_VALID_BIT) == 0) { + System.out.println("View position invalid; abort rendering this frame"); + return null; + } + if ((viewFlags & XR_VIEW_STATE_ORIENTATION_VALID_BIT) == 0) { + System.out.println("View orientation invalid; abort rendering this frame"); + return null; + } + + XrCompositionLayerProjectionView.Buffer projectionViews = XrCompositionLayerProjectionView.calloc(swapchains.length, stack); + for (int viewIndex = 0; viewIndex < swapchains.length; viewIndex++) { + SwapchainWrapper swapchain = swapchains[viewIndex]; + + XrView currentView = views.get(viewIndex); + + projectionViews.get(viewIndex) + .type$Default() + .pose(currentView.pose()) + .fov(currentView.fov()) + .subImage(XrSwapchainSubImage.calloc(stack) + .swapchain(swapchain.swapchain) + .imageRect(XrRect2Di.calloc(stack) + .offset(it -> it + .x(0) + .y(0)) + .extent(it -> it + .width(swapchain.width) + .height(swapchain.height))) + .imageArrayIndex(0)); + } + + return projectionViews; + } + + private void updateSessionState(MemoryStack stack) { + // Use malloc instead of calloc because this will be called frequently + XrEventDataBuffer pollEventData = XrEventDataBuffer.malloc(stack); + + while (true) { + pollEventData + .type$Default() + .next(NULL); + + int pollResult = xrPollEvent(xrInstance, pollEventData); + xrCheck(pollResult, "PollEvent"); + if (pollResult != XR_EVENT_UNAVAILABLE) { + if (pollEventData.type() == XR_TYPE_EVENT_DATA_SESSION_STATE_CHANGED) { + XrEventDataSessionStateChanged sessionEvent = XrEventDataSessionStateChanged.create(pollEventData.address()); + xrSessionState = sessionEvent.state(); + System.out.println("Changed session state to " + xrSessionState); + } else { + System.out.println("Received another event"); + } + } else { + break; + } + } + } + + private static class HandStates { + final Vector3f leftPosition, rightPosition; + final Quaternionf leftRotation, rightRotation; + + HandStates(Vector3f leftPosition, Vector3f rightPosition, Quaternionf leftRotation, Quaternionf rightRotation) { + this.leftPosition = leftPosition; + this.rightPosition = rightPosition; + this.leftRotation = leftRotation; + this.rightRotation = rightRotation; + } + } + + private HandStates getHandStates(MemoryStack stack, long time) { + XrActiveActionSet.Buffer activeActionSets = XrActiveActionSet.calloc(1, stack); + activeActionSets.get(0) + .actionSet(xrActionSet) + .subactionPath(XR_NULL_PATH); + + xrCheck(xrSyncActions( + xrVkSession, + XrActionsSyncInfo.calloc(stack) + .type$Default() + .activeActionSets(activeActionSets) + ), "SyncActions"); + + XrSpaceLocation leftHandLocation = XrSpaceLocation.calloc(stack) + .type$Default(); + + XrSpaceLocation rightHandLocation = XrSpaceLocation.calloc(stack) + .type$Default(); + + xrCheck(xrLocateSpace(xrLeftHandSpace, renderSpace, time, leftHandLocation), "LocateSpace"); + xrCheck(xrLocateSpace(xrRightHandSpace, renderSpace, time, rightHandLocation), "LocateSpace"); + + Vector3f leftHandPosition = null; + Vector3f rightHandPosition = null; + + if ((leftHandLocation.locationFlags() & XR_SPACE_LOCATION_POSITION_VALID_BIT) != 0) { + XrVector3f pos = leftHandLocation.pose().position$(); + leftHandPosition = new Vector3f(pos.x(), pos.y(), pos.z()); + } +// else +// { +// XrVector3f pos = leftHandLocation.pose().position$(); +// if (pos == null) +// { +// System.out.println("com.starcom.lwjglvr.Main.getHandStates() errPos-L: null"); +// } +// else +// { +// System.out.println("com.starcom.lwjglvr.Main.getHandStates() errPos-L: BIT=" + leftHandLocation.locationFlags()); +// System.out.println("com.starcom.lwjglvr.Main.getHandStates() errPos-L: x=" + pos.x() + " y=" + pos.y() + " z=" + pos.z()); +// } +// } + if ((rightHandLocation.locationFlags() & XR_SPACE_LOCATION_POSITION_VALID_BIT) != 0) { + XrVector3f pos = rightHandLocation.pose().position$(); + rightHandPosition = new Vector3f(pos.x(), pos.y(), pos.z()); + } + + Quaternionf leftHandRotation = null; + Quaternionf rightHandRotation = null; + + if ((leftHandLocation.locationFlags() & XR_SPACE_LOCATION_ORIENTATION_VALID_BIT) != 0) { + XrQuaternionf rot = leftHandLocation.pose().orientation(); + leftHandRotation = new Quaternionf(rot.x(), rot.y(), rot.z(), rot.w()); + } + + if ((rightHandLocation.locationFlags() & XR_SPACE_LOCATION_ORIENTATION_VALID_BIT) != 0) { + XrQuaternionf rot = rightHandLocation.pose().orientation(); + rightHandRotation = new Quaternionf(rot.x(), rot.y(), rot.z(), rot.w()); + } + + //System.out.println("com.starcom.lwjglvr.Main.getHandStates() L: " + leftHandPosition.toString()); + return new HandStates(leftHandPosition, rightHandPosition, leftHandRotation, rightHandRotation); + } + + private void loopXrSession() { + // This is a safety check for debugging. Set to 0 to disable this. + long endTime = System.currentTimeMillis() + (10_000 * 10); + + boolean startedSession = false; + + while (true) { + try (MemoryStack stack = stackPush()) { + updateSessionState(stack); + + if (xrSessionState == XR_SESSION_STATE_IDLE) { + try { + System.out.println("Session is idle"); + Thread.sleep(500); + } catch (InterruptedException e) { + throw new RuntimeException("Shouldn't happen", e); + } + continue; + } + + boolean timeoutStop = endTime != 0 && System.currentTimeMillis() > endTime; + if (timeoutStop && startedSession) { + xrCheck(xrRequestExitSession(xrVkSession), "RequestExitSession"); + startedSession = false; + } + + if (xrSessionState == XR_SESSION_STATE_STOPPING) { + xrEndSession(xrVkSession); + } + if ( + xrSessionState == XR_SESSION_STATE_LOSS_PENDING || xrSessionState == XR_SESSION_STATE_EXITING || + xrSessionState == XR_SESSION_STATE_STOPPING + ) { + break; + } + + if (timeoutStop) { + continue; + } + + if (xrSessionState == XR_SESSION_STATE_READY && !startedSession) { + System.out.println("Begin session"); + xrCheck(xrBeginSession( + xrVkSession, + XrSessionBeginInfo.calloc(stack) + .type$Default() + .primaryViewConfigurationType(viewConfiguration) + ), "BeginSession"); + startedSession = true; + } + + updateSessionState(stack); + + if ( + xrSessionState == XR_SESSION_STATE_SYNCHRONIZED || xrSessionState == XR_SESSION_STATE_VISIBLE || + xrSessionState == XR_SESSION_STATE_FOCUSED || xrSessionState == XR_SESSION_STATE_READY + ) { + XrFrameState frameState = XrFrameState.calloc(stack) + .type$Default(); + + xrCheck(xrWaitFrame(xrVkSession, null, frameState), "WaitFrame"); + xrCheck(xrBeginFrame(xrVkSession, null), "BeginFrame"); + + PointerBuffer layers = null; + if (frameState.shouldRender()) { + XrCompositionLayerProjection layer = XrCompositionLayerProjection.calloc(stack) + .type$Default() + .layerFlags(0) // If we were to use alpha, we should set the alpha layer flag + .space(renderSpace); + + XrCompositionLayerProjectionView.Buffer projectionViews = createProjectionViews(stack, frameState.predictedDisplayTime()); + if (projectionViews != null) { + layer.views(projectionViews); + layers = stack.pointers(layer); + } + + HandStates handStates = getHandStates(stack, frameState.predictedDisplayTime()); + + Matrix4f leftHandMatrix = null; + if (handStates.leftPosition != null) { + leftHandMatrix = new Matrix4f().translate(handStates.leftPosition); + + if (handStates.leftRotation != null) { + leftHandMatrix.rotate(handStates.leftRotation); + } + } + + Matrix4f rightHandMatrix = null; + if (handStates.rightPosition != null) { + rightHandMatrix = new Matrix4f().translate(handStates.rightPosition); + + if (handStates.rightRotation != null) { + rightHandMatrix.rotate(handStates.rightRotation); + } + } + + for (int swapchainIndex = 0; swapchainIndex < swapchains.length; swapchainIndex++) { + SwapchainWrapper swapchain = this.swapchains[swapchainIndex]; + + IntBuffer pi = stack.callocInt(1); + xrCheck(xrAcquireSwapchainImage(swapchain.swapchain, null, pi), "AcquireSwapchainImage"); + int imageIndex = pi.get(0); + + Matrix4f cameraMatrix; + if (projectionViews != null) { + // If the position tracker is working, we should use it to create the camera matrix + XrCompositionLayerProjectionView projectionView = projectionViews.get(swapchainIndex); + + Matrix4f projectionMatrix = new Matrix4f().scale(1f, -1f, 1f); + XrHelper.applyProjectionToMatrix(projectionMatrix, projectionView.fov(), 0.01f, 100f, true); + + Matrix4f viewMatrix = new Matrix4f(); + + XrVector3f position = projectionView.pose().position$(); + XrQuaternionf orientation = projectionView.pose().orientation(); + + viewMatrix.translationRotateScaleInvert( + position.x(), position.y(), position.z(), + orientation.x(), orientation.y(), orientation.z(), orientation.w(), + 1, 1, 1 + ); + + cameraMatrix = projectionMatrix.mul(viewMatrix); + } else { + // When the position tracking is having issues, we will fall back to the previous one + cameraMatrix = lastCameraMatrix; + } + + lastCameraMatrix = cameraMatrix; + + xrCheck(xrWaitSwapchainImage( + swapchain.swapchain, + XrSwapchainImageWaitInfo.calloc(stack) + .type$Default() + .timeout(1_000_000_000) // Time out after 1 second. If we would have to wait so long, something is seriously wrong + ), "WaitSwapchainImage"); + + vkCheck(vkBeginCommandBuffer( + swapchain.commandBuffer, + VkCommandBufferBeginInfo.calloc(stack) + .sType$Default() + .flags(VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT) + ), "BeginCommandBuffer"); + + VkClearValue.Buffer clearValues = VkClearValue.calloc(2, stack); + clearValues.get(0) + .color(VkClearColorValue.calloc(stack) + .float32(0, 0.1f) + .float32(1, 0.2f) + .float32(2, 0.92f) + .float32(3, 1f)); + clearValues.get(1) + .depthStencil(VkClearDepthStencilValue.calloc(stack) + .depth(1f)); + + VkRenderPassBeginInfo biRenderPass = VkRenderPassBeginInfo.calloc(stack) + .sType$Default() + .pNext(VK_NULL_HANDLE) + .renderPass(vkRenderPass) + .framebuffer(swapchain.images[imageIndex].framebuffer) + .renderArea(it -> it + .offset(offset -> offset + .x(0) + .y(0)) + .extent(extent -> extent + .width(swapchain.width) + .height(swapchain.height))) + .pClearValues(clearValues); + + int pushIndexInvertColor = 4 * 4 * 4; + + ByteBuffer pushConstants = stack.calloc(pushIndexInvertColor + 4); + cameraMatrix.get(pushConstants); + + int stageFlags = VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT; + vkCmdBeginRenderPass(swapchain.commandBuffer, biRenderPass, VK_SUBPASS_CONTENTS_INLINE); + vkCmdBindPipeline(swapchain.commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vkGraphicsPipelines[swapchainIndex]); + vkCmdPushConstants(swapchain.commandBuffer, vkPipelineLayout, stageFlags, 0, pushConstants); + vkCmdBindVertexBuffers(swapchain.commandBuffer, 0, stack.longs(vkBigBuffer), stack.longs(0)); + vkCmdBindIndexBuffer(swapchain.commandBuffer, vkBigBuffer, VERTEX_SIZE * (BigModel.NUM_VERTICES + 4 * 6), INDEX_TYPE); + + // Draw big model + vkCmdDrawIndexed(swapchain.commandBuffer, BigModel.NUM_INDICES, 1, 0, 0, 0); + + // Draw (small) hand models if hand locations are known + if (leftHandMatrix != null) { + XrActionStateBoolean actionState = XrActionStateBoolean.calloc(stack) + .type$Default(); + + xrCheck(xrGetActionStateBoolean( + xrVkSession, + XrActionStateGetInfo.calloc(stack) + .type$Default() + .action(xrHandClickAction) + .subactionPath(xrPathLeftHand), + actionState + ), "GetActionStateBoolean"); + + pushConstants.putInt(pushIndexInvertColor, actionState.currentState() ? 1 : 0); + cameraMatrix.mul(leftHandMatrix, new Matrix4f()).get(pushConstants); + vkCmdPushConstants(swapchain.commandBuffer, vkPipelineLayout, stageFlags, 0, pushConstants); + vkCmdDrawIndexed(swapchain.commandBuffer, 6 * 6, 1, 0, BigModel.NUM_VERTICES, 0); + } + + if (rightHandMatrix != null) { + XrActionStateBoolean actionState = XrActionStateBoolean.calloc(stack) + .type$Default(); + + xrCheck(xrGetActionStateBoolean( + xrVkSession, + XrActionStateGetInfo.calloc(stack) + .type$Default() + .action(xrHandClickAction) + .subactionPath(xrPathRightHand), + actionState + ), "GetActionStateBoolean"); + + pushConstants.putInt(pushIndexInvertColor, actionState.currentState() ? 1 : 0); + cameraMatrix.mul(rightHandMatrix, new Matrix4f()).get(pushConstants); + vkCmdPushConstants(swapchain.commandBuffer, vkPipelineLayout, VK_SHADER_STAGE_VERTEX_BIT, 0, pushConstants); + vkCmdDrawIndexed(swapchain.commandBuffer, 6 * 6, 1, 0, BigModel.NUM_VERTICES, 0); + } + + vkCmdEndRenderPass(swapchain.commandBuffer); + + vkCheck(vkEndCommandBuffer(swapchain.commandBuffer), "EndCommandBuffer"); + + vkCheck(vkQueueSubmit( + vkQueue, + VkSubmitInfo.calloc(stack) + .sType$Default() + .pCommandBuffers(stack.pointers(swapchain.commandBuffer)), + swapchain.fence + ), "QueueSubmit"); + } + + // Submit command buffers for both eyes before waiting for them to complete + for (SwapchainWrapper swapchain : swapchains) { + vkCheck(vkWaitForFences(vkDevice, swapchain.fence, true, 1_000_000_000), "WaitForFences"); + vkCheck(vkResetFences(vkDevice, swapchain.fence), "ResetFences"); + xrCheck(xrReleaseSwapchainImage(swapchain.swapchain, null), "ReleaseSwapchainImage"); + } + } else { + System.out.println("Skip frame"); + } + + xrCheck(xrEndFrame( + xrVkSession, + XrFrameEndInfo.calloc(stack) + .type$Default() + .displayTime(frameState.predictedDisplayTime()) + .environmentBlendMode(XR_ENVIRONMENT_BLEND_MODE_OPAQUE) + .layers(layers) + ), "EndFrame"); + } + } + } + } + + private void destroySwapchains() { + if (swapchains != null) { + for (SwapchainWrapper swapchain : swapchains) { + if (swapchain != null) { + // In case we crashed during rendering, let's at least make sure that it is finished + vkWaitForFences(vkDevice, swapchain.fence, true, 100_000_000); + xrDestroySwapchain(swapchain.swapchain); + + for (SwapchainImage swapchainImage : swapchain.images) { + vkDestroyFramebuffer(vkDevice, swapchainImage.framebuffer, null); + vkDestroyImageView(vkDevice, swapchainImage.colorImageView, null); + // No need to destroy the colorImage because that happens implicitly upon destroying swapchain + } + + vkDestroyImageView(vkDevice, swapchain.depthImageView, null); + vkDestroyImage(vkDevice, swapchain.depthImage, null); + vkFreeMemory(vkDevice, swapchain.depthImageMemory, null); + vkDestroyFence(vkDevice, swapchain.fence, null); + vkFreeCommandBuffers(vkDevice, vkCommandPoolDrawing, swapchain.commandBuffer); + } + } + } + } + + private void destroyXrVkSession() { + if (xrHandPoseAction != null) { + xrDestroyAction(xrHandPoseAction); + } + if (xrHandClickAction != null) { + xrDestroyAction(xrHandClickAction); + } + if (xrActionSet != null) { + xrDestroyActionSet(xrActionSet); + } + if (xrLeftHandSpace != null) { + xrDestroySpace(xrLeftHandSpace); + } + if (xrRightHandSpace != null) { + xrDestroySpace(xrRightHandSpace); + } + if (renderSpace != null) { + xrDestroySpace(renderSpace); + } + if (xrVkSession != null) { + xrDestroySession(xrVkSession); + } + } + + private void destroyXrInstance() { + if (xrDebugMessenger != null) { + xrDestroyDebugUtilsMessengerEXT(xrDebugMessenger); + } + if (xrInstance != null) { + xrDestroyInstance(xrInstance); + } + } + + private static void xrCheck(int result, String functionName) { + if (result < XR_SUCCESS) { + String constantName = findConstantMeaning(XR10.class, candidateConstant -> candidateConstant.startsWith("XR_ERROR_"), result); + throw new RuntimeException("OpenXR function " + functionName + " returned " + result + " (" + constantName + ")"); + } + } + + private static void vkCheck(int result, String functionName) { + if (result < VK_SUCCESS) { + String constantName = findConstantMeaning(VK10.class, candidateConstant -> candidateConstant.startsWith("VK_ERROR_"), result); + throw new RuntimeException("Vulkan function " + functionName + " returned " + result + " (" + constantName + ")"); + } + } + + private static String findConstantMeaning(Class containingClass, Predicate constantFilter, Object constant) { + Field[] fields = containingClass.getFields(); + for (Field field : fields) { + if (Modifier.isStatic(field.getModifiers()) && constantFilter.test(field.getName())) { + try { + Object value = field.get(null); + if (value instanceof Number && constant instanceof Number) { + if (((Number)value).longValue() == ((Number)constant).longValue()) { + return field.getName(); + } + } + if (constant.equals(value)) { + return field.getName(); + } + } catch (IllegalAccessException ex) { + // Ignore private fields + } + } + } + + return null; + } + +} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/XrHelper.java b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/XrHelper.java new file mode 100644 index 0000000000..e4d7d800fe --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/XrHelper.java @@ -0,0 +1,210 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.jme3.input.vr.lwjgl_openxr; // JME3: Modified package path + +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + */ + +import org.joml.Math; +import org.joml.*; +//import org.lwjgl.egl.*; +import org.lwjgl.openxr.*; +import org.lwjgl.system.*; +import org.lwjgl.system.linux.*; + +import static org.lwjgl.glfw.GLFW.*; +import static org.lwjgl.glfw.GLFWNativeEGL.*; +import static org.lwjgl.glfw.GLFWNativeGLX.*; +import static org.lwjgl.glfw.GLFWNativeWGL.*; +import static org.lwjgl.glfw.GLFWNativeWayland.*; +import static org.lwjgl.glfw.GLFWNativeWin32.*; +import static org.lwjgl.glfw.GLFWNativeX11.*; +import static org.lwjgl.opengl.GLX.*; +import static org.lwjgl.opengl.GLX13.*; +import static org.lwjgl.openxr.XR10.*; +import static org.lwjgl.system.MemoryUtil.*; +import static org.lwjgl.system.windows.User32.*; + +/** + * A helper class with some static methods to help applications with OpenXR related tasks that are cumbersome in + * some way. + */ +final class XrHelper { + + private XrHelper() { + } + + static > T fill(T buffer, int offset, int value) { + long ptr = buffer.address() + offset; + int stride = buffer.sizeof(); + for (int i = 0; i < buffer.limit(); i++) { + memPutInt(ptr + i * stride, value); + } + return buffer; + } + + /** + * Allocates an {@link XrApiLayerProperties.Buffer} onto the given stack with the given number of layers and + * sets the type of each element in the buffer to {@link XR10#XR_TYPE_API_LAYER_PROPERTIES XR_TYPE_API_LAYER_PROPERTIES}. + * + *

Note: you can't use the buffer after the stack is gone!

+ * + * @param stack the stack to allocate the buffer on + * @param numLayers the number of elements the buffer should get + * + * @return the created buffer + */ + static XrApiLayerProperties.Buffer prepareApiLayerProperties(MemoryStack stack, int numLayers) { + return fill( + XrApiLayerProperties.calloc(numLayers, stack), + XrApiLayerProperties.TYPE, + XR_TYPE_API_LAYER_PROPERTIES + ); + } + + /** + * Allocates an {@link XrExtensionProperties.Buffer} onto the given stack with the given number of extensions + * and sets the type of each element in the buffer to {@link XR10#XR_TYPE_EXTENSION_PROPERTIES XR_TYPE_EXTENSION_PROPERTIES}. + * + *

Note: you can't use the buffer after the stack is gone!

+ * + * @param stack the stack onto which to allocate the buffer + * @param numExtensions the number of elements the buffer should get + * + * @return the created buffer + */ + static XrExtensionProperties.Buffer prepareExtensionProperties(MemoryStack stack, int numExtensions) { + return fill( + XrExtensionProperties.calloc(numExtensions, stack), + XrExtensionProperties.TYPE, + XR_TYPE_EXTENSION_PROPERTIES + ); + } + + /** + * Applies an off-center asymmetric perspective projection transformation to the given {@link Matrix4f}, + * such that it represents a projection matrix with the given fov, nearZ (a.k.a. near plane), + * farZ (a.k.a. far plane). + * + * @param m The matrix to apply the perspective projection transformation to + * @param fov The desired Field of View for the projection matrix. You should normally use the value of + * {@link XrCompositionLayerProjectionView#fov}. + * @param nearZ The nearest Z value that the user should see (also known as the near plane) + * @param farZ The furthest Z value that the user should see (also known as far plane) + * @param zZeroToOne True if the z-axis of the coordinate system goes from 0 to 1 (Vulkan). + * False if the z-axis of the coordinate system goes from -1 to 1 (OpenGL). + * + * @return the provided matrix + */ + static Matrix4f applyProjectionToMatrix(Matrix4f m, XrFovf fov, float nearZ, float farZ, boolean zZeroToOne) { + float distToLeftPlane = Math.tan(fov.angleLeft()); + float distToRightPlane = Math.tan(fov.angleRight()); + float distToBottomPlane = Math.tan(fov.angleDown()); + float distToTopPlane = Math.tan(fov.angleUp()); + return m.frustum(distToLeftPlane * nearZ, distToRightPlane * nearZ, distToBottomPlane * nearZ, distToTopPlane * nearZ, nearZ, farZ, zZeroToOne); + } + + /** + * Appends the right XrGraphicsBinding** struct to the next chain of sessionCreateInfo. OpenGL + * session creation is poorly standardized in OpenXR, so the right graphics binding struct depends on the OS and + * the windowing system, among others. There are basically 4 graphics binding structs for this: + *
    + *
  • XrGraphicsBindingOpenGLWin32KHR, which can only be used on Windows computers.
  • + *
  • XrGraphicsBindingOpenGLXlibKHR, which can only be used on Linux computers with the X11 windowing system.
  • + *
  • + * XrGraphicsBindingOpenGLWaylandKHR, which can only be used on Linux computers with the + * Wayland windowing system. But, no OpenXR runtime has implemented the specification for this struct and + * the Wayland developers have claimed that the specification doesn't make sense and can't be implemented + * as such. For this reason, this method won't use this struct. + *
  • + *
  • + * XrGraphicsBindingEGLMNDX, which is cross-platform, but can only be used if the experimental + * OpenXR extension XR_MNDX_egl_enable is enabled. But, since the extension is experimental, it + * is not widely supported (at the time of writing this only by the Monado OpenXR runtime). Nevertheless, + * this is the only way to create an OpenXR session on the Wayland windowing system (or on systems + * without well-known windowing system). + *
  • + *
+ * + * The parameter useEGL determines which graphics binding struct this method will choose: + *
    + *
  • + * If useEGL is true, this method will use XrGraphicsBindingEGLMNDX. + * The caller must ensure that the extension XR_MNDX_egl_enable has been enabled. + *
  • + *
  • + * If useEGL is false, this method will try to use a platform-specific struct. + * If no such struct exists, it will throw an IllegalStateException. + *
  • + *
+ * + * @param sessionCreateInfo The XrSessionCreateInfo whose next chain should be populated + * @param stack The MemoryStack onto which this method should allocate the graphics binding struct + * @param window The GLFW window + * @param useEGL Whether this method should use XrGraphicsBindingEGLMNDX + * @return sessionCreateInfo (after appending a graphics binding to it) + * @throws IllegalStateException If the current OS and/or windowing system needs EGL, but useEGL is false + */ + static XrSessionCreateInfo createGraphicsBindingOpenGL( + XrSessionCreateInfo sessionCreateInfo, MemoryStack stack, long window, boolean useEGL + ) throws IllegalStateException { + /*if (useEGL) { + System.out.println("Using XrGraphicsBindingEGLMNDX to create the session..."); + return sessionCreateInfo.next( + XrGraphicsBindingEGLMNDX.malloc(stack) + .type$Default() + .next(NULL) + .getProcAddress(EGL.getCapabilities().eglGetProcAddress) + .display(glfwGetEGLDisplay()) + .config(glfwGetEGLConfig(window)) + .context(glfwGetEGLContext(window)) + ); + }*/ + switch (Platform.get()) { + case LINUX: + int platform = glfwGetPlatform(); + if (platform == GLFW_PLATFORM_X11) { + long display = glfwGetX11Display(); + long glxConfig = glfwGetGLXFBConfig(window); + + XVisualInfo visualInfo = glXGetVisualFromFBConfig(display, glxConfig); + if (visualInfo == null) { + throw new IllegalStateException("Failed to get visual info"); + } + long visualid = visualInfo.visualid(); + + System.out.println("Using XrGraphicsBindingOpenGLXlibKHR to create the session"); + return sessionCreateInfo.next( + XrGraphicsBindingOpenGLXlibKHR.malloc(stack) + .type$Default() + .xDisplay(display) + .visualid((int)visualid) + .glxFBConfig(glxConfig) + .glxDrawable(glXGetCurrentDrawable()) + .glxContext(glfwGetGLXContext(window)) + ); + } else { + throw new IllegalStateException( + "X11 is the only Linux windowing system with explicit OpenXR support. All other Linux systems must use EGL." + ); + } + case WINDOWS: + System.out.println("Using XrGraphicsBindingOpenGLWin32KHR to create the session"); + return sessionCreateInfo.next( + XrGraphicsBindingOpenGLWin32KHR.malloc(stack) + .type$Default() + .hDC(GetDC(glfwGetWin32Window(window))) + .hGLRC(glfwGetWGLContext(window)) + ); + default: + throw new IllegalStateException( + "Windows and Linux are the only platforms with explicit OpenXR support. All other platforms must use EGL." + ); + } + } +} diff --git a/jme3-xr/src/main/resources/demo/openxr/vulkan/hello.frag.spv b/jme3-xr/src/main/resources/demo/openxr/vulkan/hello.frag.spv new file mode 100644 index 0000000000000000000000000000000000000000..562d499b68a847454f2a68f972885e86eafb468c GIT binary patch literal 1300 zcmYk4*>2QO42Ip#(kal5u52akuong{03jhZRVZ8xY7q|*MKh_0G)+cHrh+>p9*4K! zrC1~+{x8WvIg(@h_irEDC$0JZg4vw)Y{?#3b=GWNh}n7Tmf9bF91ikgJb3)1q%2#j zB*Iy-1#3$qr(v8B*pXb7tcnM&3uLua)$E6o+IG(TVc;Jf`NOxtXgUq@;>#ooCUFu4 z<2Z{(MSK>)>os_BGMdcBO+rVE=Di*3sIu88P4Xg4id=Tr7E4T~67+bXDxy1?l5i{^_t$m%ErVomJ$D+bQRshIw9A5csZ~ zmMFFGs~++Dd~})^yIO5v^aSs<#Mch#lRf&X%l*3&4n8|~{<>K3_R7syIa{*3!aT{g z_}qoh4tMnJNrT~U>bofINjSUmxf@P}xAlKiHu!VJ@!1t|@|UDN2{Rnj{&MYm@>gWT zMK;v!MQM2W>k^-nd41X7F7JkH^1xl*E!pHT zzstKV8{FmHkxd@>v0jOHx-0P{)O7Kenv-`U_FHo?GxISgwRxWd3HN=dXSrWvQvb0B iH8$741~tapxE>zLCLca=dUQPyYxY1dfAvQ^ll%j|lVOGc literal 0 HcmV?d00001 diff --git a/jme3-xr/src/main/resources/demo/openxr/vulkan/hello.vert.spv b/jme3-xr/src/main/resources/demo/openxr/vulkan/hello.vert.spv new file mode 100644 index 0000000000000000000000000000000000000000..5157154da788c619e20a1fbaaa177490eb8da9c9 GIT binary patch literal 1384 zcmYk4%Wl&^6o!Y~X=zI-y#OVogv$b{VgU#VaZ^C)BB()?y0xstz(}qg*-izlcm-aG zr(%P||BXG7$2vZ9{`t>!rr8*Fjk#iaX2U!-<=Qq4A;zqmj??4G+2lAc=Eu*TKZUVr znvMu(%UpH)mi`x^O)xejwottL@ZL#?3y-*C#iiH2goRC?b(=SbO^h9R;di7M)XIKOyN>igvM+yfW7ET~ z{yph|g!QDddF8}Al)WYmAFQt(J^L7(Ap`NQN&ES{s%+i|7@5lFKsNIr zE_LW|XQ*}TO_aykk=bT=DD{k3enHvuE(ffS~_eXti)B*ND T;%j@PJ^gaV9I*eX` Date: Fri, 24 Feb 2023 01:05:28 +0100 Subject: [PATCH 04/18] Add openxr to settings.gradle --- jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/Main.java | 2 +- settings.gradle | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/Main.java b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/Main.java index 23cbb1d525..c6751ff524 100644 --- a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/Main.java +++ b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/Main.java @@ -40,7 +40,7 @@ import java.util.function.*; import static org.joml.Math.*; -import static com.jme3.input.vr.lwjgl_openxr.lwjgl.IOUtil.*; +import static com.jme3.input.vr.lwjgl_openxr.IOUtil.*; import static org.lwjgl.openxr.EXTDebugUtils.*; import static org.lwjgl.openxr.KHRVulkanEnable.*; import static org.lwjgl.openxr.XR10.*; diff --git a/settings.gradle b/settings.gradle index 3f6acceb8e..f12c54f4fc 100644 --- a/settings.gradle +++ b/settings.gradle @@ -16,6 +16,7 @@ include 'jme3-lwjgl' if (JavaVersion.current().isJava8Compatible()) { include 'jme3-lwjgl3' include 'jme3-vr' + include 'jme3-xr' } // Other external dependencies From 355646ca292bf15849c4ea0c96597c5112fc2d42 Mon Sep 17 00:00:00 2001 From: Starcommander Date: Sat, 4 Mar 2023 07:26:03 +0100 Subject: [PATCH 05/18] Get xr object from environment. Clean vr-code for replacing. Code cleanup. --- .../input/vr/lwjgl_openvr/LWJGLOpenVR.java | 12 +- jme3-xr/build.gradle | 6 +- .../main/java/com/jme3/app/VREnvironment.java | 14 +- .../input/vr/lwjgl_openvr/LWJGLOpenVR.java | 189 ++----- .../LWJGLOpenVRAnalogActionData.java | 14 +- .../vr/lwjgl_openvr/LWJGLOpenVRBounds.java | 2 +- .../LWJGLOpenVRDigitalActionData.java | 14 +- .../vr/lwjgl_openvr/LWJGLOpenVRInput.java | 494 +++++++++--------- .../lwjgl_openvr/LWJGLOpenVRViewManager.java | 180 +++---- .../com/jme3/input/vr/lwjgl_openxr/Main.java | 52 +- 10 files changed, 462 insertions(+), 515 deletions(-) diff --git a/jme3-vr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVR.java b/jme3-vr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVR.java index 30c4ec2c99..c0574bc46d 100644 --- a/jme3-vr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVR.java +++ b/jme3-vr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVR.java @@ -48,7 +48,7 @@ public class LWJGLOpenVR implements VRAPI { private Vector3f hmdPoseLeftEyeVec, hmdPoseRightEyeVec, hmdSeatToStand; - private LWJGLOpenVRInput VRinput; + private LWJGLOpenVRInput vrInput; private VREnvironment environment = null; @@ -91,7 +91,7 @@ public LWJGLOpenVR(VREnvironment environment){ @Override public LWJGLOpenVRInput getVRinput() { - return VRinput; + return vrInput; } @Override @@ -158,9 +158,9 @@ public boolean initialize() { hmdDisplayFrequency.get(0); TrackedDevicePose.create(VR.k_unMaxTrackedDeviceCount); // init controllers for the first time - VRinput = new LWJGLOpenVRInput(environment); - VRinput.init(); - VRinput.updateConnectedControllers(); + vrInput = new LWJGLOpenVRInput(environment); + vrInput.init(); + vrInput.updateConnectedControllers(); // init bounds & chaperone info LWJGLOpenVRBounds bounds = new LWJGLOpenVRBounds(); @@ -431,4 +431,4 @@ public void setTrackingSpace(boolean isSeated){ public Matrix4f[] getPoseMatrices() { return poseMatrices; } -} \ No newline at end of file +} diff --git a/jme3-xr/build.gradle b/jme3-xr/build.gradle index 6ae71e8151..c44b52c2fb 100644 --- a/jme3-xr/build.gradle +++ b/jme3-xr/build.gradle @@ -14,11 +14,11 @@ dependencies { // implementation "org.lwjgl:lwjgl-openxr:${lwjgl3Version}:natives-macos" runtimeOnly "org.lwjgl:lwjgl-openxr:${lwjgl3Version}:natives-windows" runtimeOnly "org.lwjgl:lwjgl-openxr:${lwjgl3Version}:natives-linux" - runtimeOnly "org.lwjgl:lwjgl-openxr:${lwjgl3Version}:natives-macos" +// runtimeOnly "org.lwjgl:lwjgl-openxr:${lwjgl3Version}:natives-macos" // Necessary by lwjgl-openxr - implementation "org.joml:joml:1.10.4" - implementation "org.lwjgl:lwjgl-vulkan:${lwjgl3Version}" + api "org.joml:joml:1.10.4" + api "org.lwjgl:lwjgl-vulkan:${lwjgl3Version}" } javadoc { diff --git a/jme3-xr/src/main/java/com/jme3/app/VREnvironment.java b/jme3-xr/src/main/java/com/jme3/app/VREnvironment.java index 06d59f5cac..6bf234f910 100644 --- a/jme3-xr/src/main/java/com/jme3/app/VREnvironment.java +++ b/jme3-xr/src/main/java/com/jme3/app/VREnvironment.java @@ -73,6 +73,8 @@ public class VREnvironment { private Camera dummyCam = null; private AppState app = null; + + private com.jme3.input.vr.lwjgl_openxr.Main mainXr; private boolean initialized = false; @@ -91,6 +93,16 @@ public VREnvironment(AppSettings settings){ public VRAPI getVRHardware() { return hardware; } + + /** Will be set in LWJGLOpenVR, when ready. */ + public void setXR(com.jme3.input.vr.lwjgl_openxr.Main mainXr) { + this.mainXr = mainXr; + } + + public com.jme3.input.vr.lwjgl_openxr.Main getXr() + { + return mainXr; + } /** * Set the VR bounds. @@ -425,7 +437,7 @@ public boolean initialize(){ vrSupportedOS = false; } - if( vrSupportedOS) { + if(vrSupportedOS) { if( vrBinding == VRConstants.SETTING_VRAPI_OSVR_VALUE ) { guiManager = new VRGuiManager(this); mouseManager = new OpenVRMouseManager(this); diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVR.java b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVR.java index 3a973edc88..d51f79017b 100644 --- a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVR.java +++ b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVR.java @@ -11,11 +11,8 @@ import com.jme3.util.VRUtil; import java.nio.IntBuffer; -import java.util.Locale; -import java.util.logging.Level; import java.util.logging.Logger; import org.lwjgl.BufferUtils; -import org.lwjgl.openvr.*; /** * A class that wraps an OpenVR system. @@ -30,8 +27,8 @@ public class LWJGLOpenVR implements VRAPI { private static boolean flipEyes = false; private IntBuffer hmdDisplayFrequency; - private TrackedDevicePose.Buffer trackedDevicePose; - protected TrackedDevicePose[] hmdTrackedDevicePoses; +// private TrackedDevicePose.Buffer trackedDevicePose; +// protected TrackedDevicePose[] hmdTrackedDevicePoses; protected IntBuffer hmdErrorStore = BufferUtils.createIntBuffer(1); @@ -48,38 +45,10 @@ public class LWJGLOpenVR implements VRAPI { private Vector3f hmdPoseLeftEyeVec, hmdPoseRightEyeVec, hmdSeatToStand; - private LWJGLOpenVRInput VRinput; + private LWJGLOpenVRInput vrInput; private VREnvironment environment = null; - /** - * Convert specific OpenVR {@link org.lwjgl.openvr.HmdMatrix34 HmdMatrix34} into JME {@link Matrix4f Matrix4f} - * @param hmdMatrix the input matrix - * @param mat the converted matrix - * @return the converted matrix - */ - public static Matrix4f convertSteamVRMatrix3ToMatrix4f(org.lwjgl.openvr.HmdMatrix34 hmdMatrix, Matrix4f mat){ - mat.set(hmdMatrix.m(0), hmdMatrix.m(1), hmdMatrix.m(2), hmdMatrix.m(3), - hmdMatrix.m(4), hmdMatrix.m(5), hmdMatrix.m(6), hmdMatrix.m(7), - hmdMatrix.m(8), hmdMatrix.m(9), hmdMatrix.m(10), hmdMatrix.m(11), - 0f, 0f, 0f, 1f); - return mat; - } - - /** - * Convert specific OpenVR {@link org.lwjgl.openvr.HmdMatrix34 HmdMatrix34_t} into JME {@link Matrix4f Matrix4f} - * @param hmdMatrix the input matrix - * @param mat the converted matrix - * @return the converted matrix - */ - public static Matrix4f convertSteamVRMatrix4ToMatrix4f(org.lwjgl.openvr.HmdMatrix44 hmdMatrix, Matrix4f mat){ - mat.set(hmdMatrix.m(0), hmdMatrix.m(1), hmdMatrix.m(2), hmdMatrix.m(3), - hmdMatrix.m(4), hmdMatrix.m(5), hmdMatrix.m(6), hmdMatrix.m(7), - hmdMatrix.m(8), hmdMatrix.m(9), hmdMatrix.m(10), hmdMatrix.m(11), - hmdMatrix.m(12), hmdMatrix.m(13), hmdMatrix.m(14), hmdMatrix.m(15)); - return mat; - } - /** * Create a new OpenVR system * attached to the given {@link VREnvironment VR environment}. @@ -91,7 +60,7 @@ public LWJGLOpenVR(VREnvironment environment){ @Override public LWJGLOpenVRInput getVRinput() { - return VRinput; + return vrInput; } @Override @@ -106,7 +75,7 @@ public Object getCompositor() { @Override public String getName() { - return "OpenVR/LWJGL"; + return "OpenXR/LWJGL"; } @Override @@ -129,66 +98,18 @@ public int getDisplayFrequency() { public boolean initialize() { logger.config("Initializing OpenVR system..."); - // Init the native linking to the OpenVR library. - - int result = VR.VR_InitInternal(hmdErrorStore, VR.EVRApplicationType_VRApplication_Scene); - - if(hmdErrorStore.get(0) != VR.EVRInitError_VRInitError_None) { - logger.severe("OpenVR Initialize Result: " + VR.VR_GetVRInitErrorAsEnglishDescription(hmdErrorStore.get(0))); - logger.severe("Initializing OpenVR system [FAILED]"); - return false; - } else { - logger.config("OpenVR initialized & VR connected."); - org.lwjgl.openvr.OpenVR.create(result); - logger.info("Model Number : " + VRSystem.VRSystem_GetStringTrackedDeviceProperty( - VR.k_unTrackedDeviceIndex_Hmd, VR.ETrackedDeviceProperty_Prop_ModelNumber_String, hmdErrorStore)); - logger.info("Serial Number: " + VRSystem.VRSystem_GetStringTrackedDeviceProperty( - VR.k_unTrackedDeviceIndex_Hmd, VR.ETrackedDeviceProperty_Prop_SerialNumber_String, hmdErrorStore)); - - hmdDisplayFrequency = BufferUtils.createIntBuffer(1); - hmdDisplayFrequency.put(VR.ETrackedDeviceProperty_Prop_DisplayFrequency_Float); - - trackedDevicePose = TrackedDevicePose.create(VR.k_unMaxTrackedDeviceCount); - hmdTrackedDevicePoses = new TrackedDevicePose[VR.k_unMaxTrackedDeviceCount]; - poseMatrices = new Matrix4f[VR.k_unMaxTrackedDeviceCount]; - for(int i=0;i 0){ - if(hmdErrorStore.get(0) == VR.EVRInitError_VRInitError_None){ - setTrackingSpace(environment.isSeatedExperience() ); - logger.config("OpenVR Compositor initialized"); - } else { - logger.severe("OpenVR Compositor error: " + hmdErrorStore.get(0)); - } - } else { - logger.log(Level.SEVERE, "Cannot get generic interface for \""+VR.IVRCompositor_Version+"\", "+VR.VR_GetVRInitErrorAsEnglishDescription(hmdErrorStore.get(0))+" ("+hmdErrorStore.get(0)+")"); - } - } return true; } @@ -198,24 +119,11 @@ public boolean initVRCompositor(boolean allowed) { * @return token for camera */ public long initCamera(boolean allowed) { - hmdErrorStore.put(0, VR.EVRInitError_VRInitError_None); // clear the error store - if( allowed) { - long result = VR.VR_GetGenericInterface(VR.IVRTrackedCamera_Version, hmdErrorStore); - if (result > 0){ - if(hmdErrorStore.get(0) == VR.EVRInitError_VRInitError_None ){ - logger.config("OpenVR Camera initialized"); - } - return result; - } else { - logger.severe("Failed to initialize camera"); - } - } return 0; } @Override public void destroy() { - VR.VR_ShutdownInternal(); } @Override @@ -225,19 +133,15 @@ public boolean isInitialized() { @Override public void reset() { - VRChaperone.VRChaperone_ResetZeroPose(VR.ETrackingUniverseOrigin_TrackingUniverseSeated); +// VRChaperone.VRChaperone_ResetZeroPose(VR.ETrackingUniverseOrigin_TrackingUniverseSeated); hmdSeatToStand = null; } @Override public void getRenderSize(Vector2f store) { - IntBuffer w = BufferUtils.createIntBuffer(1); - IntBuffer h = BufferUtils.createIntBuffer(1); - VRSystem.VRSystem_GetRecommendedRenderTargetSize(w, h); - logger.config("Recommended render width : " + w.get(0)); - logger.config("Recommended render height: " + h.get(0)); - store.x = w.get(0); - store.y = h.get(0); + //TODO + store.x = 800; + store.y = 600; } @Override @@ -270,23 +174,7 @@ public void getPositionAndOrientation(Vector3f storePos, Quaternion storeRot) { @Override public void updatePose(){ - int result = VRCompositor.nVRCompositor_WaitGetPoses(trackedDevicePose.address(), trackedDevicePose.remaining(), 0, 0); - // NPE when calling without a gamePoseArray. Issue filed with lwjgl #418 -// int result = VRCompositor.VRCompositor_WaitGetPoses(trackedDevicePose, null); - environment.getVRinput().updateControllerStates(); - - // read pose data from native - for (int nDevice = 0; nDevice < VR.k_unMaxTrackedDeviceCount; ++nDevice ){ - if( hmdTrackedDevicePoses[nDevice].bPoseIsValid() ){ - convertSteamVRMatrix3ToMatrix4f(hmdTrackedDevicePoses[nDevice].mDeviceToAbsoluteTracking(), poseMatrices[nDevice]); - } - } - - if ( hmdTrackedDevicePoses[VR.k_unTrackedDeviceIndex_Hmd].bPoseIsValid()){ - hmdPose.set(poseMatrices[VR.k_unTrackedDeviceIndex_Hmd]); - } else { - hmdPose.set(Matrix4f.IDENTITY); - } + environment.getXr().loopXrSession(); } @Override @@ -294,10 +182,11 @@ public Matrix4f getHMDMatrixProjectionLeftEye(Camera cam){ if( hmdProjectionLeftEye != null ) { return hmdProjectionLeftEye; } else { - HmdMatrix44 mat = HmdMatrix44.create(); - mat = VRSystem.VRSystem_GetProjectionMatrix(VR.EVREye_Eye_Left, cam.getFrustumNear(), cam.getFrustumFar(), mat); +// HmdMatrix44 mat = HmdMatrix44.create(); +// mat = VRSystem.VRSystem_GetProjectionMatrix(VR.EVREye_Eye_Left, cam.getFrustumNear(), cam.getFrustumFar(), mat); hmdProjectionLeftEye = new Matrix4f(); - convertSteamVRMatrix4ToMatrix4f(mat, hmdProjectionLeftEye); + //TODO +// convertSteamVRMatrix4ToMatrix4f(mat, hmdProjectionLeftEye); return hmdProjectionLeftEye; } } @@ -307,10 +196,11 @@ public Matrix4f getHMDMatrixProjectionRightEye(Camera cam){ if( hmdProjectionRightEye != null ) { return hmdProjectionRightEye; } else { - HmdMatrix44 mat = HmdMatrix44.create(); - mat = VRSystem.VRSystem_GetProjectionMatrix(VR.EVREye_Eye_Right, cam.getFrustumNear(), cam.getFrustumFar(), mat); +// HmdMatrix44 mat = HmdMatrix44.create(); +// mat = VRSystem.VRSystem_GetProjectionMatrix(VR.EVREye_Eye_Right, cam.getFrustumNear(), cam.getFrustumFar(), mat); hmdProjectionRightEye = new Matrix4f(); - convertSteamVRMatrix4ToMatrix4f(mat, hmdProjectionRightEye); + //TODO +// convertSteamVRMatrix4ToMatrix4f(mat, hmdProjectionRightEye); return hmdProjectionRightEye; } } @@ -347,11 +237,7 @@ public Vector3f getSeatedToAbsolutePosition() { if( hmdSeatToStand == null ) { hmdSeatToStand = new Vector3f(); - HmdMatrix34 mat = HmdMatrix34.create(); - VRSystem.VRSystem_GetSeatedZeroPoseToStandingAbsoluteTrackingPose(mat); - Matrix4f tempMatrix = new Matrix4f(); - convertSteamVRMatrix3ToMatrix4f(mat, tempMatrix); - tempMatrix.toTranslationVector(hmdSeatToStand); + //TODO } return hmdSeatToStand; } @@ -361,10 +247,12 @@ public Matrix4f getHMDMatrixPoseLeftEye(){ if( hmdPoseLeftEye != null ) { return hmdPoseLeftEye; } else { - HmdMatrix34 mat = HmdMatrix34.create(); - VRSystem.VRSystem_GetEyeToHeadTransform(VR.EVREye_Eye_Left, mat); + //HmdMatrix34 mat = HmdMatrix34.create(); + //VRSystem.VRSystem_GetEyeToHeadTransform(VR.EVREye_Eye_Left, mat); + //TODO hmdPoseLeftEye = new Matrix4f(); - return convertSteamVRMatrix3ToMatrix4f(mat, hmdPoseLeftEye); + //return convertSteamVRMatrix3ToMatrix4f(mat, hmdPoseLeftEye); + return hmdPoseLeftEye; } } @@ -373,10 +261,12 @@ public Matrix4f getHMDMatrixPoseRightEye(){ if( hmdPoseRightEye != null ) { return hmdPoseRightEye; } else { - HmdMatrix34 mat = HmdMatrix34.create(); - VRSystem.VRSystem_GetEyeToHeadTransform(VR.EVREye_Eye_Right, mat); + //HmdMatrix34 mat = HmdMatrix34.create(); + //VRSystem.VRSystem_GetEyeToHeadTransform(VR.EVREye_Eye_Right, mat); + //TODO hmdPoseRightEye = new Matrix4f(); - return convertSteamVRMatrix3ToMatrix4f(mat, hmdPoseRightEye); + //return convertSteamVRMatrix3ToMatrix4f(mat, hmdPoseRightEye); + return hmdPoseRightEye; } } @@ -386,11 +276,6 @@ public HmdType getType() { } public void setTrackingSpace(boolean isSeated){ - if( isSeated) { - VRCompositor.VRCompositor_SetTrackingSpace(VR.ETrackingUniverseOrigin_TrackingUniverseSeated); - } else { - VRCompositor.VRCompositor_SetTrackingSpace(VR.ETrackingUniverseOrigin_TrackingUniverseStanding); - } } diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRAnalogActionData.java b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRAnalogActionData.java index aa702fc13a..2c5652dd89 100644 --- a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRAnalogActionData.java +++ b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRAnalogActionData.java @@ -1,6 +1,6 @@ package com.jme3.input.vr.lwjgl_openvr; -import org.lwjgl.openvr.InputAnalogActionData; +//import org.lwjgl.openvr.InputAnalogActionData; /** * This is a set of reusable parts that are used when accessing an analogue action @@ -24,11 +24,11 @@ public class LWJGLOpenVRAnalogActionData{ * This is a LWJGL object that will have the actions state passed into it. It is mapped to native memory so we * don't want to keep creating new ones. */ - InputAnalogActionData actionData; +// InputAnalogActionData actionData; - public LWJGLOpenVRAnalogActionData(String actionName, long actionHandle, InputAnalogActionData actionData){ - this.actionName = actionName; - this.actionHandle = actionHandle; - this.actionData = actionData; - } +// public LWJGLOpenVRAnalogActionData(String actionName, long actionHandle, InputAnalogActionData actionData){ +// this.actionName = actionName; +// this.actionHandle = actionHandle; +// this.actionData = actionData; +// } } diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRBounds.java b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRBounds.java index cce7aec17b..07834860d7 100644 --- a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRBounds.java +++ b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRBounds.java @@ -31,7 +31,7 @@ public boolean init(VRAPI api) { // vrChaperone = new VR_IVRChaperone_FnTable(JOpenVRLibrary.VR_GetGenericInterface(JOpenVRLibrary.IVRChaperone_Version, api.hmdErrorStore).getPointer()); FloatBuffer fbX = BufferUtils.createFloatBuffer(1); FloatBuffer fbZ = BufferUtils.createFloatBuffer(1); - org.lwjgl.openvr.VRChaperone.VRChaperone_GetPlayAreaSize(fbX, fbZ); +// org.lwjgl.openvr.VRChaperone.VRChaperone_GetPlayAreaSize(fbX, fbZ); playSize = new Vector2f(fbX.get(0), fbZ.get(0)); setup = true; diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRDigitalActionData.java b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRDigitalActionData.java index 75b1a100ed..00390d6a0d 100644 --- a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRDigitalActionData.java +++ b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRDigitalActionData.java @@ -1,6 +1,6 @@ package com.jme3.input.vr.lwjgl_openvr; -import org.lwjgl.openvr.InputDigitalActionData; +//import org.lwjgl.openvr.InputDigitalActionData; /** * This is a set of reusable parts that are used when accessing a digital action @@ -24,11 +24,11 @@ public class LWJGLOpenVRDigitalActionData{ * This is a LWJGL object that will have the actions state passed into it. It is mapped to native memory so we * don't want to keep creating new ones. */ - InputDigitalActionData actionData; +// InputDigitalActionData actionData; - public LWJGLOpenVRDigitalActionData(String actionName, long actionHandle, InputDigitalActionData actionData){ - this.actionName = actionName; - this.actionHandle = actionHandle; - this.actionData = actionData; - } +// public LWJGLOpenVRDigitalActionData(String actionName, long actionHandle, InputDigitalActionData actionData){ +// this.actionName = actionName; +// this.actionHandle = actionHandle; +// this.actionData = actionData; +// } } diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRInput.java b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRInput.java index 04d5e9dd38..1d2ee5ece8 100644 --- a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRInput.java +++ b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRInput.java @@ -22,14 +22,15 @@ import com.jme3.util.VRUtil; import java.nio.IntBuffer; import org.lwjgl.BufferUtils; -import org.lwjgl.openvr.HmdVector3; -import org.lwjgl.openvr.InputAnalogActionData; -import org.lwjgl.openvr.InputDigitalActionData; -import org.lwjgl.openvr.VR; -import org.lwjgl.openvr.VRActiveActionSet; -import org.lwjgl.openvr.VRControllerState; -import org.lwjgl.openvr.VRInput; -import org.lwjgl.openvr.VRSystem; +import org.lwjgl.openxr.XrControllerModelStateMSFT; +//import org.lwjgl.openvr.HmdVector3; +//import org.lwjgl.openvr.InputAnalogActionData; +//import org.lwjgl.openvr.InputDigitalActionData; +//import org.lwjgl.openvr.VR; +//import org.lwjgl.openvr.VRActiveActionSet; +//import org.lwjgl.openvr.VRControllerState; +//import org.lwjgl.openvr.VRInput; +//import org.lwjgl.openvr.VRSystem; /* make helper functions to pull the following easily from raw data (DONE) @@ -77,30 +78,31 @@ make helper functions to pull the following easily from raw data (DONE) public class LWJGLOpenVRInput implements VRInputAPI { private static final Logger logger = Logger.getLogger(LWJGLOpenVRInput.class.getName()); - + private static final int MAX_CNT=30; /** * Deprecated as used controller specific values. Should use Actions manifest instead */ - @Deprecated - private final VRControllerState[] cStates = new VRControllerState[VR.k_unMaxTrackedDeviceCount]; +// @Deprecated +// private final VRControllerState[] cStates = new VRControllerState[VR.k_unMaxTrackedDeviceCount]; + private final XrControllerModelStateMSFT[] cStates = new XrControllerModelStateMSFT[MAX_CNT]; - private final Quaternion[] rotStore = new Quaternion[VR.k_unMaxTrackedDeviceCount]; + private final Quaternion[] rotStore = new Quaternion[MAX_CNT]; - private final Vector3f[] posStore = new Vector3f[VR.k_unMaxTrackedDeviceCount]; + private final Vector3f[] posStore = new Vector3f[MAX_CNT]; - private static final int[] controllerIndex = new int[VR.k_unMaxTrackedDeviceCount]; + private static final int[] controllerIndex = new int[MAX_CNT]; private int controllerCount = 0; private final Vector2f tempAxis = new Vector2f(), temp2Axis = new Vector2f(); - - private final Vector2f[] lastCallAxis = new Vector2f[VR.k_unMaxTrackedDeviceCount]; - - /** - * Deprecated as used controller specific values. Should use Actions manifest instead - */ - @Deprecated - private final boolean[][] buttonDown = new boolean[VR.k_unMaxTrackedDeviceCount][16]; +// +// private final Vector2f[] lastCallAxis = new Vector2f[VR.k_unMaxTrackedDeviceCount]; +// +// /** +// * Deprecated as used controller specific values. Should use Actions manifest instead +// */ +// @Deprecated +// private final boolean[][] buttonDown = new boolean[VR.k_unMaxTrackedDeviceCount][16]; /** * A map of the action name to the objects/data required to read states from lwjgl @@ -132,6 +134,7 @@ public class LWJGLOpenVRInput implements VRInputAPI { private float axisMultiplier = 1f; private final Vector3f tempVel = new Vector3f(); +// private final Vector3f observerPosition = new Vector3f(); private final Quaternion tempq = new Quaternion(); @@ -143,7 +146,7 @@ public class LWJGLOpenVRInput implements VRInputAPI { * A lwjgl object that contains handles to the active action sets (is used each frame to tell lwjgl which actions to * fetch states back for) */ - private VRActiveActionSet.Buffer activeActionSets; +// private VRActiveActionSet.Buffer activeActionSets; InputMode inputMode = InputMode.LEGACY; @@ -168,18 +171,18 @@ private enum InputMode{ public LWJGLOpenVRInput(VREnvironment environment) { this.environment = environment; - inputHandles.put(null, VR.k_ulInvalidInputValueHandle); +// inputHandles.put(null, VR.k_ulInvalidInputValueHandle); } @Override public void registerActionManifest(String actionManifestAbsolutePath, String startingActiveActionSets){ inputMode = InputMode.ACTION_BASED; - int errorCode = VRInput.VRInput_SetActionManifestPath(actionManifestAbsolutePath); - - if ( errorCode != 0 ) - { - logger.warning( "An error code of " + errorCode + " was reported while registering an action manifest" ); - } +// int errorCode = VRInput.VRInput_SetActionManifestPath(actionManifestAbsolutePath); +// +// if ( errorCode != 0 ) +// { +// logger.warning( "An error code of " + errorCode + " was reported while registering an action manifest" ); +// } setActiveActionSet(startingActiveActionSets); } @@ -193,19 +196,19 @@ public void setActiveActionSet(String actionSet){ actionSetHandle = actionSetHandles.get(actionSet); }else{ LongBuffer longBuffer = BufferUtils.createLongBuffer(1); - int errorCode = VRInput.VRInput_GetActionHandle(actionSet, longBuffer); - if ( errorCode != 0 ) - { - logger.warning( "An error code of " + errorCode + " was reported while fetching an action set handle for " + actionSet ); - } +// int errorCode = VRInput.VRInput_GetActionHandle(actionSet, longBuffer); +// if ( errorCode != 0 ) +// { +// logger.warning( "An error code of " + errorCode + " was reported while fetching an action set handle for " + actionSet ); +// } actionSetHandle = longBuffer.get(0); actionSetHandles.put(actionSet,actionSetHandle); } //Todo: this seems to imply that you could have multiple active action sets at once (Although I was not able to get that to work), allow multiple action sets - activeActionSets = VRActiveActionSet.create(1); - activeActionSets.ulActionSet(actionSetHandle); - activeActionSets.ulRestrictedToDevice(VR.k_ulInvalidInputValueHandle); // both hands +// activeActionSets = VRActiveActionSet.create(1); +// activeActionSets.ulActionSet(actionSetHandle); +// activeActionSets.ulRestrictedToDevice(VR.k_ulInvalidInputValueHandle); // both hands } @Override @@ -216,40 +219,42 @@ public DigitalActionState getDigitalActionState(String actionName, String restri if (actionDataObjects == null){ //this is the first time the action has been used. We must obtain a handle to it to efficiently fetch it in future long handle = fetchActionHandle(actionName); - actionDataObjects = new LWJGLOpenVRDigitalActionData(actionName, handle, InputDigitalActionData.create()); - digitalActions.put(actionName, actionDataObjects); - } - int errorCode = VRInput.VRInput_GetDigitalActionData(actionDataObjects.actionHandle, actionDataObjects.actionData, getOrFetchInputHandle(restrictToInput)); - - if (errorCode == VR.EVRInputError_VRInputError_WrongType){ - throw new RuntimeException("Attempted to fetch a non-digital state as if it is digital"); - }else if (errorCode!=0){ - logger.warning( "An error code of " + errorCode + " was reported while fetching an action state for " + actionName ); +// actionDataObjects = new LWJGLOpenVRDigitalActionData(actionName, handle, InputDigitalActionData.create()); +// digitalActions.put(actionName, actionDataObjects); } - - return new DigitalActionState(actionDataObjects.actionData.bState(), actionDataObjects.actionData.bChanged()); +// int errorCode = VRInput.VRInput_GetDigitalActionData(actionDataObjects.actionHandle, actionDataObjects.actionData, getOrFetchInputHandle(restrictToInput)); +// +// if (errorCode == VR.EVRInputError_VRInputError_WrongType){ +// throw new RuntimeException("Attempted to fetch a non-digital state as if it is digital"); +// }else if (errorCode!=0){ +// logger.warning( "An error code of " + errorCode + " was reported while fetching an action state for " + actionName ); +// } +// +// return new DigitalActionState(actionDataObjects.actionData.bState(), actionDataObjects.actionData.bChanged()); + return new DigitalActionState(false, false); } @Override public AnalogActionState getAnalogActionState(String actionName, String restrictToInput ){ assert inputMode == InputMode.ACTION_BASED : "registerActionManifest must be called before attempting to fetch action states"; - LWJGLOpenVRAnalogActionData actionDataObjects = analogActions.get(actionName); - if (actionDataObjects == null){ - //this is the first time the action has been used. We must obtain a handle to it to efficiently fetch it in future - long handle = fetchActionHandle(actionName); - actionDataObjects = new LWJGLOpenVRAnalogActionData(actionName, handle, InputAnalogActionData.create()); - analogActions.put(actionName, actionDataObjects); - } - int errorCode = VRInput.VRInput_GetAnalogActionData(actionDataObjects.actionHandle, actionDataObjects.actionData, getOrFetchInputHandle(restrictToInput)); - - if (errorCode == VR.EVRInputError_VRInputError_WrongType){ - throw new RuntimeException("Attempted to fetch a non-analog state as if it is analog"); - }else if (errorCode!=0){ - logger.warning( "An error code of " + errorCode + " was reported while fetching an action state for " + actionName ); - } - - return new AnalogActionState(actionDataObjects.actionData.x(), actionDataObjects.actionData.y(), actionDataObjects.actionData.z(), actionDataObjects.actionData.deltaX(), actionDataObjects.actionData.deltaY(), actionDataObjects.actionData.deltaZ()); +// LWJGLOpenVRAnalogActionData actionDataObjects = analogActions.get(actionName); +// if (actionDataObjects == null){ +// //this is the first time the action has been used. We must obtain a handle to it to efficiently fetch it in future +// long handle = fetchActionHandle(actionName); +// actionDataObjects = new LWJGLOpenVRAnalogActionData(actionName, handle, InputAnalogActionData.create()); +// analogActions.put(actionName, actionDataObjects); +// } +// int errorCode = VRInput.VRInput_GetAnalogActionData(actionDataObjects.actionHandle, actionDataObjects.actionData, getOrFetchInputHandle(restrictToInput)); +// +// if (errorCode == VR.EVRInputError_VRInputError_WrongType){ +// throw new RuntimeException("Attempted to fetch a non-analog state as if it is analog"); +// }else if (errorCode!=0){ +// logger.warning( "An error code of " + errorCode + " was reported while fetching an action state for " + actionName ); +// } +// +// return new AnalogActionState(actionDataObjects.actionData.x(), actionDataObjects.actionData.y(), actionDataObjects.actionData.z(), actionDataObjects.actionData.deltaX(), actionDataObjects.actionData.deltaY(), actionDataObjects.actionData.deltaZ()); + return new AnalogActionState(0,0,0,0,0,0); } @Override @@ -264,141 +269,147 @@ public void setAxisMultiplier(float set) { @Override public void swapHands() { - if (controllerCount != 2) { - return; - } - int temp = controllerIndex[0]; - controllerIndex[0] = controllerIndex[1]; - controllerIndex[1] = temp; +// if (controllerCount != 2) { +// return; +// } +// int temp = controllerIndex[0]; +// controllerIndex[0] = controllerIndex[1]; +// controllerIndex[1] = temp; } @Override public boolean isButtonDown(int controllerIndex, VRInputType checkButton) { - assert inputMode != InputMode.ACTION_BASED : "registerActionManifest has been called, legacy button access disabled"; - VRControllerState cs = cStates[LWJGLOpenVRInput.controllerIndex[controllerIndex]]; - switch (checkButton) { - default: - return false; - case ViveGripButton: - return (cs.ulButtonPressed() & 4) != 0; - case ViveMenuButton: - return (cs.ulButtonPressed() & 2) != 0; - case ViveTrackpadAxis: - return (cs.ulButtonPressed() & 4294967296l) != 0; - case ViveTriggerAxis: - return (cs.ulButtonPressed() & 8589934592l) != 0; - } +// assert inputMode != InputMode.ACTION_BASED : "registerActionManifest has been called, legacy button access disabled"; +// VRControllerState cs = cStates[LWJGLOpenVRInput.controllerIndex[controllerIndex]]; +// switch (checkButton) { +// default: +// return false; +// case ViveGripButton: +// return (cs.ulButtonPressed() & 4) != 0; +// case ViveMenuButton: +// return (cs.ulButtonPressed() & 2) != 0; +// case ViveTrackpadAxis: +// return (cs.ulButtonPressed() & 4294967296l) != 0; +// case ViveTriggerAxis: +// return (cs.ulButtonPressed() & 8589934592l) != 0; +// } +return false; } @Override public boolean wasButtonPressedSinceLastCall(int controllerIndex, VRInputType checkButton) { - boolean buttonDownNow = isButtonDown(controllerIndex, checkButton); - int checkButtonValue = checkButton.getValue(); - int cIndex = LWJGLOpenVRInput.controllerIndex[controllerIndex]; - boolean retval = buttonDownNow == true && buttonDown[cIndex][checkButtonValue] == false; - buttonDown[cIndex][checkButtonValue] = buttonDownNow; - return retval; +// boolean buttonDownNow = isButtonDown(controllerIndex, checkButton); +// int checkButtonValue = checkButton.getValue(); +// int cIndex = LWJGLOpenVRInput.controllerIndex[controllerIndex]; +// boolean retval = buttonDownNow == true && buttonDown[cIndex][checkButtonValue] == false; +// buttonDown[cIndex][checkButtonValue] = buttonDownNow; +// return retval; +return false; } @Override public void resetInputSinceLastCall() { - for (int i = 0; i < lastCallAxis.length; i++) { - lastCallAxis[i].x = 0f; - lastCallAxis[i].y = 0f; - } - for (int i = 0; i < VR.k_unMaxTrackedDeviceCount; i++) { - for (int j = 0; j < 16; j++) { - buttonDown[i][j] = false; - } - } +// for (int i = 0; i < lastCallAxis.length; i++) { +// lastCallAxis[i].x = 0f; +// lastCallAxis[i].y = 0f; +// } +// for (int i = 0; i < VR.k_unMaxTrackedDeviceCount; i++) { +// for (int j = 0; j < 16; j++) { +// buttonDown[i][j] = false; +// } +// } } @Override public Vector2f getAxisDeltaSinceLastCall(int controllerIndex, VRInputType forAxis) { - int axisIndex = forAxis.getValue(); - temp2Axis.set(lastCallAxis[axisIndex]); - lastCallAxis[axisIndex].set(getAxis(controllerIndex, forAxis)); - if ((temp2Axis.x != 0f || temp2Axis.y != 0f) && (lastCallAxis[axisIndex].x != 0f || lastCallAxis[axisIndex].y != 0f)) { - temp2Axis.subtractLocal(lastCallAxis[axisIndex]); - } else { - // move made from rest, don't count as a delta move - temp2Axis.x = 0f; - temp2Axis.y = 0f; - } - return temp2Axis; +// int axisIndex = forAxis.getValue(); +// temp2Axis.set(lastCallAxis[axisIndex]); +// lastCallAxis[axisIndex].set(getAxis(controllerIndex, forAxis)); +// if ((temp2Axis.x != 0f || temp2Axis.y != 0f) && (lastCallAxis[axisIndex].x != 0f || lastCallAxis[axisIndex].y != 0f)) { +// temp2Axis.subtractLocal(lastCallAxis[axisIndex]); +// } else { +// // move made from rest, don't count as a delta move +// temp2Axis.x = 0f; +// temp2Axis.y = 0f; +// } +// return temp2Axis; +return new Vector2f(); } @Override public Vector3f getVelocity(int controllerIndex) { - if (environment != null) { - - if (environment.getVRHardware() instanceof LWJGLOpenVR) { - int index = LWJGLOpenVRInput.controllerIndex[controllerIndex]; -// if( needsNewVelocity[index] ) { - HmdVector3 tempVec = ((LWJGLOpenVR) environment.getVRHardware()).hmdTrackedDevicePoses[index].vVelocity(); -// needsNewVelocity[index] = false; -// } - tempVel.x = tempVec.v(0); - tempVel.y = tempVec.v(1); - tempVel.z = tempVec.v(2); - return tempVel; - } else { - throw new IllegalStateException("VR hardware " + environment.getVRHardware().getClass().getSimpleName() + " is not a subclass of " + LWJGLOpenVR.class.getSimpleName()); - } - } else { - throw new IllegalStateException("VR input is not attached to a VR environment."); - } +// if (environment != null) { +// +// if (environment.getVRHardware() instanceof LWJGLOpenVR) { +// int index = LWJGLOpenVRInput.controllerIndex[controllerIndex]; +//// if( needsNewVelocity[index] ) { +// HmdVector3 tempVec = ((LWJGLOpenVR) environment.getVRHardware()).hmdTrackedDevicePoses[index].vVelocity(); +//// needsNewVelocity[index] = false; +//// } +// tempVel.x = tempVec.v(0); +// tempVel.y = tempVec.v(1); +// tempVel.z = tempVec.v(2); +// return tempVel; +// } else { +// throw new IllegalStateException("VR hardware " + environment.getVRHardware().getClass().getSimpleName() + " is not a subclass of " + LWJGLOpenVR.class.getSimpleName()); +// } +// } else { +// throw new IllegalStateException("VR input is not attached to a VR environment."); +// } +return new Vector3f(); } @Override public Vector3f getAngularVelocity(int controllerIndex) { - if (environment != null) { - - if (environment.getVRHardware() instanceof LWJGLOpenVR) { - - int index = LWJGLOpenVRInput.controllerIndex[controllerIndex]; - HmdVector3 tempVec = ((LWJGLOpenVR) environment.getVRHardware()).hmdTrackedDevicePoses[index].vAngularVelocity(); -// needsNewVelocity[index] = false; -// } - tempVel.x = tempVec.v(0); - tempVel.y = tempVec.v(1); - tempVel.z = tempVec.v(2); - return tempVel; - } else { - throw new IllegalStateException("VR hardware " + environment.getVRHardware().getClass().getSimpleName() + " is not a subclass of " + LWJGLOpenVR.class.getSimpleName()); - } - } else { - throw new IllegalStateException("VR input is not attached to a VR environment."); - } - +// if (environment != null) { +// +// if (environment.getVRHardware() instanceof LWJGLOpenVR) { +// +// int index = LWJGLOpenVRInput.controllerIndex[controllerIndex]; +// HmdVector3 tempVec = ((LWJGLOpenVR) environment.getVRHardware()).hmdTrackedDevicePoses[index].vAngularVelocity(); +//// needsNewVelocity[index] = false; +//// } +// tempVel.x = tempVec.v(0); +// tempVel.y = tempVec.v(1); +// tempVel.z = tempVec.v(2); +// return tempVel; +// } else { +// throw new IllegalStateException("VR hardware " + environment.getVRHardware().getClass().getSimpleName() + " is not a subclass of " + LWJGLOpenVR.class.getSimpleName()); +// } +// } else { +// throw new IllegalStateException("VR input is not attached to a VR environment."); +// } +return new Vector3f(); } @Override public Vector2f getAxisRaw(int controllerIndex, VRInputType forAxis) { - VRControllerState cs = cStates[LWJGLOpenVRInput.controllerIndex[controllerIndex]]; - switch (forAxis) { - default: - return null; - case ViveTriggerAxis: - tempAxis.x = cs.rAxis(1).x(); - tempAxis.y = tempAxis.x; - break; - case ViveTrackpadAxis: - tempAxis.x = cs.rAxis(0).x(); - tempAxis.y = cs.rAxis(0).y(); - break; - } - return tempAxis; +// VRControllerState cs = cStates[LWJGLOpenVRInput.controllerIndex[controllerIndex]]; +// switch (forAxis) { +// default: +// return null; +// case ViveTriggerAxis: +// tempAxis.x = cs.rAxis(1).x(); +// tempAxis.y = tempAxis.x; +// break; +// case ViveTrackpadAxis: +// tempAxis.x = cs.rAxis(0).x(); +// tempAxis.y = cs.rAxis(0).y(); +// break; +// } +// return tempAxis; +return new Vector2f(); } @Override public Vector2f getAxis(int controllerIndex, VRInputType forAxis) { - getAxisRaw(controllerIndex, forAxis); - tempAxis.x *= axisMultiplier; - tempAxis.y *= axisMultiplier; - return tempAxis; +// getAxisRaw(controllerIndex, forAxis); +// tempAxis.x *= axisMultiplier; +// tempAxis.y *= axisMultiplier; +// return tempAxis; +return new Vector2f(); } @Override @@ -406,13 +417,13 @@ public boolean init() { logger.config("Initialize OpenVR input."); - for (int i = 0; i < VR.k_unMaxTrackedDeviceCount; i++) { - rotStore[i] = new Quaternion(); - posStore[i] = new Vector3f(); - cStates[i] = VRControllerState.create(); - lastCallAxis[i] = new Vector2f(); - logger.config(" Input " + (i + 1) + "/" + VR.k_unMaxTrackedDeviceCount + " bound."); - } +// for (int i = 0; i < VR.k_unMaxTrackedDeviceCount; i++) { +// rotStore[i] = new Quaternion(); +// posStore[i] = new Vector3f(); +// cStates[i] = VRControllerState.create(); +// lastCallAxis[i] = new Vector2f(); +// logger.config(" Input " + (i + 1) + "/" + VR.k_unMaxTrackedDeviceCount + " bound."); +// } return true; } @@ -430,11 +441,13 @@ public VRTrackedController getTrackedController(int index) { @Override public int getTrackedControllerCount() { - return controllerCount; +// return controllerCount; +return 0; } @Override - public VRControllerState getRawControllerState(int index) { +// public VRControllerState getRawControllerState(int index) { + public XrControllerModelStateMSFT getRawControllerState(int index) { if (isInputDeviceTracking(index) == false) { return null; } @@ -445,8 +458,9 @@ public VRControllerState getRawControllerState(int index) { public boolean isInputFocused() { if (environment != null){ // not a 100% match, but the closest I can find in LWJGL. Doc seems to confirm this too. - return VRSystem.VRSystem_IsInputAvailable(); +// return VRSystem.VRSystem_IsInputAvailable(); //return ((VR_IVRSystem_FnTable)environment.getVRHardware().getVRSystem()).IsInputFocusCapturedByAnotherProcess.apply() == 0; + return true; } else { throw new IllegalStateException("VR input is not attached to a VR environment."); } @@ -461,7 +475,8 @@ public boolean isInputDeviceTracking(int index) { if (environment != null) { if (environment.getVRHardware() instanceof LWJGLOpenVR) { - return ((LWJGLOpenVR) environment.getVRHardware()).hmdTrackedDevicePoses[controllerIndex[index]].bPoseIsValid(); +// return ((LWJGLOpenVR) environment.getVRHardware()).hmdTrackedDevicePoses[controllerIndex[index]].bPoseIsValid(); +return true; } else { throw new IllegalStateException("VR hardware " + environment.getVRHardware().getClass().getSimpleName() + " is not a subclass of " + LWJGLOpenVR.class.getSimpleName()); } @@ -564,7 +579,6 @@ public Vector3f getFinalObserverPosition(int index) { } else { throw new IllegalStateException("VR environment has no valid view manager."); } - } else { throw new IllegalStateException("VR input is not attached to a VR environment."); } @@ -577,8 +591,8 @@ public void triggerHapticPulse(int controllerIndex, float seconds) { } // apparently only axis ID of 0 works - VRSystem.VRSystem_TriggerHapticPulse(LWJGLOpenVRInput.controllerIndex[controllerIndex], - 0, (short) Math.round(3f * seconds / 1e-3f)); +// VRSystem.VRSystem_TriggerHapticPulse(LWJGLOpenVRInput.controllerIndex[controllerIndex], +// 0, (short) Math.round(3f * seconds / 1e-3f)); } @Override @@ -592,69 +606,69 @@ public void triggerHapticAction(String actionName, float duration, float frequen hapticActionHandle = hapticActionHandles.get(actionName); } - VRInput.VRInput_TriggerHapticVibrationAction(hapticActionHandle, 0, duration, frequency, amplitude, getOrFetchInputHandle(restrictToInput)); +// VRInput.VRInput_TriggerHapticVibrationAction(hapticActionHandle, 0, duration, frequency, amplitude, getOrFetchInputHandle(restrictToInput)); } @Override public void updateConnectedControllers() { logger.config("Updating connected controllers."); - if (environment != null) { - controllerCount = 0; - for (int i = 0; i < VR.k_unMaxTrackedDeviceCount; i++) { - int classCallback = VRSystem.VRSystem_GetTrackedDeviceClass(i); - if (classCallback == VR.ETrackedDeviceClass_TrackedDeviceClass_Controller || classCallback == VR.ETrackedDeviceClass_TrackedDeviceClass_GenericTracker) { - IntBuffer error = BufferUtils.createIntBuffer(1); - String controllerName = "Unknown"; - String manufacturerName = "Unknown"; - controllerName = VRSystem.VRSystem_GetStringTrackedDeviceProperty(i, VR.ETrackedDeviceProperty_Prop_TrackingSystemName_String, error); - manufacturerName = VRSystem.VRSystem_GetStringTrackedDeviceProperty(i, VR.ETrackedDeviceProperty_Prop_ManufacturerName_String, error); - - if (error.get(0) != 0) { - logger.warning("Error getting controller information " + controllerName + " " + manufacturerName + "Code (" + error.get(0) + ")"); - } - controllerIndex[controllerCount] = i; - - // Adding tracked controller to control. - if (trackedControllers == null) { - trackedControllers = new ArrayList(VR.k_unMaxTrackedDeviceCount); - } - trackedControllers.add(new LWJGLOpenVRTrackedController(i, this, controllerName, manufacturerName, environment)); - - // Send a Haptic pulse to the controller - triggerHapticPulse(controllerCount, 1.0f); - - controllerCount++; - logger.config(" Tracked controller " + (i + 1) + "/" + VR.k_unMaxTrackedDeviceCount + " " + controllerName + " (" + manufacturerName + ") attached."); - } else { - logger.config(" Controller " + (i + 1) + "/" + VR.k_unMaxTrackedDeviceCount + " ignored."); - } - } - } else { - throw new IllegalStateException("VR input is not attached to a VR environment."); - } +// if (environment != null) { +// controllerCount = 0; +// for (int i = 0; i < VR.k_unMaxTrackedDeviceCount; i++) { +// int classCallback = VRSystem.VRSystem_GetTrackedDeviceClass(i); +// if (classCallback == VR.ETrackedDeviceClass_TrackedDeviceClass_Controller || classCallback == VR.ETrackedDeviceClass_TrackedDeviceClass_GenericTracker) { +// IntBuffer error = BufferUtils.createIntBuffer(1); +// String controllerName = "Unknown"; +// String manufacturerName = "Unknown"; +// controllerName = VRSystem.VRSystem_GetStringTrackedDeviceProperty(i, VR.ETrackedDeviceProperty_Prop_TrackingSystemName_String, error); +// manufacturerName = VRSystem.VRSystem_GetStringTrackedDeviceProperty(i, VR.ETrackedDeviceProperty_Prop_ManufacturerName_String, error); +// +// if (error.get(0) != 0) { +// logger.warning("Error getting controller information " + controllerName + " " + manufacturerName + "Code (" + error.get(0) + ")"); +// } +// controllerIndex[controllerCount] = i; +// +// // Adding tracked controller to control. +// if (trackedControllers == null) { +// trackedControllers = new ArrayList(VR.k_unMaxTrackedDeviceCount); +// } +// trackedControllers.add(new LWJGLOpenVRTrackedController(i, this, controllerName, manufacturerName, environment)); +// +// // Send a Haptic pulse to the controller +// triggerHapticPulse(controllerCount, 1.0f); +// +// controllerCount++; +// logger.config(" Tracked controller " + (i + 1) + "/" + VR.k_unMaxTrackedDeviceCount + " " + controllerName + " (" + manufacturerName + ") attached."); +// } else { +// logger.config(" Controller " + (i + 1) + "/" + VR.k_unMaxTrackedDeviceCount + " ignored."); +// } +// } +// } else { +// throw new IllegalStateException("VR input is not attached to a VR environment."); +// } } @Override public void updateControllerStates() { if (environment != null) { - switch(inputMode){ - case ACTION_BASED: - int errorCode = VRInput.VRInput_UpdateActionState(activeActionSets, VRActiveActionSet.SIZEOF); - if(errorCode!=0){ - logger.warning("An error code of " + errorCode + " was returned while upding the action states"); - } - break; - case LEGACY: - for (int i = 0; i < controllerCount; i++) { - int index = controllerIndex[i]; - VRSystem.VRSystem_GetControllerState(index, cStates[index], 64); - cStates[index].ulButtonPressed(); - cStates[index].rAxis(); - } - break; - } +// switch(inputMode){ +// case ACTION_BASED: +// int errorCode = VRInput.VRInput_UpdateActionState(activeActionSets, VRActiveActionSet.SIZEOF); +// if(errorCode!=0){ +// logger.warning("An error code of " + errorCode + " was returned while upding the action states"); +// } +// break; +// case LEGACY: +// for (int i = 0; i < controllerCount; i++) { +// int index = controllerIndex[i]; +// VRSystem.VRSystem_GetControllerState(index, cStates[index], 64); +// cStates[index].ulButtonPressed(); +// cStates[index].rAxis(); +// } +// break; +// } } else { throw new IllegalStateException("VR input is not attached to a VR environment."); @@ -670,10 +684,10 @@ public void updateControllerStates() { */ private long fetchActionHandle( String actionName ){ LongBuffer longBuffer = BufferUtils.createLongBuffer(1); - int errorCode = VRInput.VRInput_GetActionHandle(actionName, longBuffer); - if (errorCode !=0 ){ - logger.warning( "An error code of " + errorCode + " was reported while registering an action manifest" ); - } +// int errorCode = VRInput.VRInput_GetActionHandle(actionName, longBuffer); +// if (errorCode !=0 ){ +// logger.warning( "An error code of " + errorCode + " was reported while registering an action manifest" ); +// } return longBuffer.get(0); } @@ -689,10 +703,10 @@ public long getOrFetchInputHandle( String inputName ){ if(!inputHandles.containsKey(inputName)){ LongBuffer longBuffer = BufferUtils.createLongBuffer(1); - int errorCode = VRInput.VRInput_GetInputSourceHandle(inputName, longBuffer); - if (errorCode !=0 ){ - logger.warning( "An error code of " + errorCode + " was reported while fetching an input manifest" ); - } +// int errorCode = VRInput.VRInput_GetInputSourceHandle(inputName, longBuffer); +// if (errorCode !=0 ){ +// logger.warning( "An error code of " + errorCode + " was reported while fetching an input manifest" ); +// } long handle = longBuffer.get(0); inputHandles.put(inputName, handle); } @@ -700,4 +714,4 @@ public long getOrFetchInputHandle( String inputName ){ return inputHandles.get(inputName); } -} \ No newline at end of file +} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRViewManager.java b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRViewManager.java index 8e47a4438a..ea93af654e 100644 --- a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRViewManager.java +++ b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRViewManager.java @@ -19,10 +19,10 @@ import java.util.Iterator; import java.util.logging.Logger; -import org.lwjgl.openvr.VRTextureBounds; -import org.lwjgl.openvr.Texture; -import org.lwjgl.openvr.VR; -import org.lwjgl.openvr.VRCompositor; +//import org.lwjgl.openvr.VRTextureBounds; +//import org.lwjgl.openvr.Texture; +//import org.lwjgl.openvr.VR; +//import org.lwjgl.openvr.VRCompositor; /** * A VR view manager based on OpenVR. This class enable to submit 3D views to @@ -37,11 +37,11 @@ public class LWJGLOpenVRViewManager extends AbstractVRViewManager { private static final Logger logger = Logger.getLogger(LWJGLOpenVRViewManager.class.getName()); // OpenVR values - private VRTextureBounds leftTextureBounds; - private Texture leftTextureType; - - private VRTextureBounds rightTextureBounds; - private Texture rightTextureType; +// private VRTextureBounds leftTextureBounds; +// private Texture leftTextureType; +// +// private VRTextureBounds rightTextureBounds; +// private Texture rightTextureType; private Texture2D dualEyeTex; @@ -99,25 +99,25 @@ private int getFullTexId() { * Initialize the system binds of the textures. */ private void initTextureSubmitStructs() { - leftTextureType = Texture.create(); - rightTextureType = Texture.create(); - - if (environment != null) { - if (environment.getVRHardware() instanceof LWJGLOpenVR) { - leftTextureBounds = VRTextureBounds.create(); - rightTextureBounds = VRTextureBounds.create(); - // left eye - leftTextureBounds.set(0f, 0f, 0.5f, 1f); - // right eye - rightTextureBounds.set(0.5f, 0f, 1f, 1f); - // texture type - leftTextureType.set(-1, VR.ETextureType_TextureType_OpenGL, VR.EColorSpace_ColorSpace_Gamma); - rightTextureType.set(-1, VR.ETextureType_TextureType_OpenGL, VR.EColorSpace_ColorSpace_Gamma); - - } - } else { - throw new IllegalStateException("This VR view manager is not attached to any VR environment."); - } +// leftTextureType = Texture.create(); +// rightTextureType = Texture.create(); +// +// if (environment != null) { +// if (environment.getVRHardware() instanceof LWJGLOpenVR) { +// leftTextureBounds = VRTextureBounds.create(); +// rightTextureBounds = VRTextureBounds.create(); +// // left eye +// leftTextureBounds.set(0f, 0f, 0.5f, 1f); +// // right eye +// rightTextureBounds.set(0.5f, 0f, 1f, 1f); +// // texture type +// leftTextureType.set(-1, VR.ETextureType_TextureType_OpenGL, VR.EColorSpace_ColorSpace_Gamma); +// rightTextureType.set(-1, VR.ETextureType_TextureType_OpenGL, VR.EColorSpace_ColorSpace_Gamma); +// +// } +// } else { +// throw new IllegalStateException("This VR view manager is not attached to any VR environment."); +// } } /** @@ -163,68 +163,68 @@ public void render() { @Override public void postRender() { - - if (environment != null) { - if (environment.isInVR()) { - VRAPI api = environment.getVRHardware(); - // using the compositor... - int errl = 0, errr = 0; - if (environment.isInstanceRendering()) { - if (leftTextureType.handle() == -1 || leftTextureType.handle() != getFullTexId()) { - leftTextureType.set(getFullTexId(), leftTextureType.eType(), leftTextureType.eColorSpace()); - } else { - if (api instanceof LWJGLOpenVR) { - int submitFlag = VR.EVRSubmitFlags_Submit_Default; - errr = VRCompositor.VRCompositor_Submit(VR.EVREye_Eye_Right, rightTextureType, rightTextureBounds, submitFlag); - errl = VRCompositor.VRCompositor_Submit(VR.EVREye_Eye_Left, leftTextureType, leftTextureBounds, submitFlag); - } - } - } else if (leftTextureType.handle() == -1 || rightTextureType.handle() == -1 - || leftTextureType.handle() != getLeftTexId() || rightTextureType.handle() != getRightTexId()) { - leftTextureType.set(getLeftTexId(), leftTextureType.eType(), leftTextureType.eColorSpace()); - rightTextureType.set(getRightTexId(), leftTextureType.eType(), leftTextureType.eColorSpace()); - } else { - if (api instanceof LWJGLOpenVR) { - int submitFlag = VR.EVRSubmitFlags_Submit_Default; - errr = VRCompositor.VRCompositor_Submit(VR.EVREye_Eye_Right, rightTextureType, null, submitFlag); - errl = VRCompositor.VRCompositor_Submit(VR.EVREye_Eye_Left, leftTextureType, null, submitFlag); - } else { - - } - } - - if (errl != 0) { - logger.severe("Submit to left compositor error: " + " (" + Integer.toString(errl) + ")"); - logger.severe(" Texture handle: " + leftTextureType.handle()); - - logger.severe(" Left eye texture " + leftEyeTexture.getName() + " (" + leftEyeTexture.getImage().getId() + ")"); - logger.severe(" Type: " + leftEyeTexture.getType()); - logger.severe(" Size: " + leftEyeTexture.getImage().getWidth() + "x" + leftEyeTexture.getImage().getHeight()); - logger.severe(" Image depth: " + leftEyeTexture.getImage().getDepth()); - logger.severe(" Image format: " + leftEyeTexture.getImage().getFormat()); - logger.severe(" Image color space: " + leftEyeTexture.getImage().getColorSpace()); - - } - - if (errr != 0) { - logger.severe("Submit to right compositor error: " + " (" + Integer.toString(errl) + ")"); -// logger.severe(" Texture color space: "+OpenVRUtil.getEColorSpaceString(rightTextureType.eColorSpace)); -// logger.severe(" Texture type: "+OpenVRUtil.getETextureTypeString(rightTextureType.eType)); - logger.severe(" Texture handle: " + rightTextureType.handle()); - - logger.severe(" Right eye texture " + rightEyeTexture.getName() + " (" + rightEyeTexture.getImage().getId() + ")"); - logger.severe(" Type: " + rightEyeTexture.getType()); - logger.severe(" Size: " + rightEyeTexture.getImage().getWidth() + "x" + rightEyeTexture.getImage().getHeight()); - logger.severe(" Image depth: " + rightEyeTexture.getImage().getDepth()); - logger.severe(" Image format: " + rightEyeTexture.getImage().getFormat()); - logger.severe(" Image color space: " + rightEyeTexture.getImage().getColorSpace()); - } - } - } else { - throw new IllegalStateException("This VR view manager is not attached to any VR environment."); - } - - VRCompositor.VRCompositor_PostPresentHandoff(); +// +// if (environment != null) { +// if (environment.isInVR()) { +// VRAPI api = environment.getVRHardware(); +// // using the compositor... +// int errl = 0, errr = 0; +// if (environment.isInstanceRendering()) { +// if (leftTextureType.handle() == -1 || leftTextureType.handle() != getFullTexId()) { +// leftTextureType.set(getFullTexId(), leftTextureType.eType(), leftTextureType.eColorSpace()); +// } else { +// if (api instanceof LWJGLOpenVR) { +// int submitFlag = VR.EVRSubmitFlags_Submit_Default; +// errr = VRCompositor.VRCompositor_Submit(VR.EVREye_Eye_Right, rightTextureType, rightTextureBounds, submitFlag); +// errl = VRCompositor.VRCompositor_Submit(VR.EVREye_Eye_Left, leftTextureType, leftTextureBounds, submitFlag); +// } +// } +// } else if (leftTextureType.handle() == -1 || rightTextureType.handle() == -1 +// || leftTextureType.handle() != getLeftTexId() || rightTextureType.handle() != getRightTexId()) { +// leftTextureType.set(getLeftTexId(), leftTextureType.eType(), leftTextureType.eColorSpace()); +// rightTextureType.set(getRightTexId(), leftTextureType.eType(), leftTextureType.eColorSpace()); +// } else { +// if (api instanceof LWJGLOpenVR) { +// int submitFlag = VR.EVRSubmitFlags_Submit_Default; +// errr = VRCompositor.VRCompositor_Submit(VR.EVREye_Eye_Right, rightTextureType, null, submitFlag); +// errl = VRCompositor.VRCompositor_Submit(VR.EVREye_Eye_Left, leftTextureType, null, submitFlag); +// } else { +// +// } +// } +// +// if (errl != 0) { +// logger.severe("Submit to left compositor error: " + " (" + Integer.toString(errl) + ")"); +// logger.severe(" Texture handle: " + leftTextureType.handle()); +// +// logger.severe(" Left eye texture " + leftEyeTexture.getName() + " (" + leftEyeTexture.getImage().getId() + ")"); +// logger.severe(" Type: " + leftEyeTexture.getType()); +// logger.severe(" Size: " + leftEyeTexture.getImage().getWidth() + "x" + leftEyeTexture.getImage().getHeight()); +// logger.severe(" Image depth: " + leftEyeTexture.getImage().getDepth()); +// logger.severe(" Image format: " + leftEyeTexture.getImage().getFormat()); +// logger.severe(" Image color space: " + leftEyeTexture.getImage().getColorSpace()); +// +// } +// +// if (errr != 0) { +// logger.severe("Submit to right compositor error: " + " (" + Integer.toString(errl) + ")"); +//// logger.severe(" Texture color space: "+OpenVRUtil.getEColorSpaceString(rightTextureType.eColorSpace)); +//// logger.severe(" Texture type: "+OpenVRUtil.getETextureTypeString(rightTextureType.eType)); +// logger.severe(" Texture handle: " + rightTextureType.handle()); +// +// logger.severe(" Right eye texture " + rightEyeTexture.getName() + " (" + rightEyeTexture.getImage().getId() + ")"); +// logger.severe(" Type: " + rightEyeTexture.getType()); +// logger.severe(" Size: " + rightEyeTexture.getImage().getWidth() + "x" + rightEyeTexture.getImage().getHeight()); +// logger.severe(" Image depth: " + rightEyeTexture.getImage().getDepth()); +// logger.severe(" Image format: " + rightEyeTexture.getImage().getFormat()); +// logger.severe(" Image color space: " + rightEyeTexture.getImage().getColorSpace()); +// } +// } +// } else { +// throw new IllegalStateException("This VR view manager is not attached to any VR environment."); +// } +// +// VRCompositor.VRCompositor_PostPresentHandoff(); } diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/Main.java b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/Main.java index c6751ff524..31f0a92a05 100644 --- a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/Main.java +++ b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/Main.java @@ -232,11 +232,46 @@ private static ByteBuffer getShaderResource(String resource) { private int swapchainDepthFormat; private XrSpace renderSpace; + + boolean startedSession = false; // JME3: Use as member var // The default value can be used in edge cases where the position tracking of the driver fails right at the start // Let's hope it won't be used a lot private Matrix4f lastCameraMatrix = new Matrix4f().perspective(toRadians(70f), 0.7f, 0.01f, 100f, true); - + +// JME3: New Variables + private Vector3f internalCameraPos = new Vector3f(); + private Quaternionf internalCameraRot = new Quaternionf(); + +// JME3: New function + public void getCameraLocation(com.jme3.math.Vector3f dst) + { + lastCameraMatrix.getTranslation(internalCameraPos); + dst.set(internalCameraPos.x, internalCameraPos.y, internalCameraPos.z); + } + +// JME3: New function + public void getCameraRotation(com.jme3.math.Quaternion dst) + { + lastCameraMatrix.getNormalizedRotation(internalCameraRot); + dst.set(internalCameraRot.x, internalCameraRot.y, internalCameraRot.z, internalCameraRot.w); + } + +// JME3: New function to init xr system + public void initXr() { + try { + createXrInstance(); + initXrSystem(); + initVk(); + createXrVkSession(); + initXrActions(); + createRenderResources(); //TODO: Render rootNode instead creating default resources + } catch (RuntimeException ex) { + System.err.println("OpenXR testing failed:"); + ex.printStackTrace(); + } + } + private void start() { try { createXrInstance(); @@ -1896,13 +1931,13 @@ private HandStates getHandStates(MemoryStack stack, long time) { return new HandStates(leftHandPosition, rightHandPosition, leftHandRotation, rightHandRotation); } - private void loopXrSession() { + public boolean loopXrSession() { // JME3: As public function and returns bool for continue next loop // This is a safety check for debugging. Set to 0 to disable this. long endTime = System.currentTimeMillis() + (10_000 * 10); - boolean startedSession = false; +// boolean startedSession = false; // JME3: Commented out, use as member var - while (true) { +// while (true) { // JME3: Commented out try (MemoryStack stack = stackPush()) { updateSessionState(stack); @@ -1913,7 +1948,7 @@ private void loopXrSession() { } catch (InterruptedException e) { throw new RuntimeException("Shouldn't happen", e); } - continue; + return true; // JME3: Return instead continue loop } boolean timeoutStop = endTime != 0 && System.currentTimeMillis() > endTime; @@ -1929,11 +1964,11 @@ private void loopXrSession() { xrSessionState == XR_SESSION_STATE_LOSS_PENDING || xrSessionState == XR_SESSION_STATE_EXITING || xrSessionState == XR_SESSION_STATE_STOPPING ) { - break; + return false; // JME3: Return instead continue loop } if (timeoutStop) { - continue; + return true; // JME3: Return instead continue loop } if (xrSessionState == XR_SESSION_STATE_READY && !startedSession) { @@ -2152,7 +2187,8 @@ private void loopXrSession() { ), "EndFrame"); } } - } +// } // JME3: Commented out + return true; } private void destroySwapchains() { From bf7399c2a7276404075beaff05045fe70ec0b798 Mon Sep 17 00:00:00 2001 From: Starcommander Date: Tue, 14 Mar 2023 22:08:45 +0100 Subject: [PATCH 06/18] Comment out vulkan code --- .../com/jme3/input/vr/lwjgl_openxr/Main.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/Main.java b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/Main.java index 31f0a92a05..ae0e52a4e6 100644 --- a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/Main.java +++ b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/Main.java @@ -1594,6 +1594,8 @@ private void createSwapchains() { ); xrCheck(xrEnumerateViewConfigurationViews(xrInstance, xrSystemId, viewConfiguration, pi, viewConfigurationViews), "EnumerateViewConfigurationViews"); +// JME3: Comment out vulkan code +/* PointerBuffer pCommandBuffers = stack.callocPointer(2); vkCheck(vkAllocateCommandBuffers( vkDevice, @@ -1604,7 +1606,7 @@ private void createSwapchains() { .commandBufferCount(numViews), pCommandBuffers ), "AllocateCommandBuffers"); - +*/ this.swapchains = new SwapchainWrapper[numViews]; for (int swapchainIndex = 0; swapchainIndex < numViews; swapchainIndex++) { XrViewConfigurationView viewConfig = viewConfigurationViews.get(swapchainIndex); @@ -1645,6 +1647,8 @@ private void createSwapchains() { XrSwapchainImageBaseHeader.create(swapchainColorImages) ), "EnumerateSwapchainImages"); +// JME3: Comment out vulkan code +/* vkCheck(vkCreateImage( vkDevice, VkImageCreateInfo.calloc(stack) @@ -1767,6 +1771,7 @@ private void createSwapchains() { depthImage, depthImageView, depthImageMemory, swapchainImages, pl.get(0), new VkCommandBuffer(pCommandBuffers.get(swapchainIndex), vkDevice) ); +*/ } } } @@ -2066,8 +2071,10 @@ public boolean loopXrSession() { // JME3: As public function and returns bool fo XrSwapchainImageWaitInfo.calloc(stack) .type$Default() .timeout(1_000_000_000) // Time out after 1 second. If we would have to wait so long, something is seriously wrong - ), "WaitSwapchainImage"); + ), "WaitSwapchainImage"); //TODO: DrawBegin +// JME3: Comment out vulkan code +/* vkCheck(vkBeginCommandBuffer( swapchain.commandBuffer, VkCommandBufferBeginInfo.calloc(stack) @@ -2090,7 +2097,7 @@ public boolean loopXrSession() { // JME3: As public function and returns bool fo .sType$Default() .pNext(VK_NULL_HANDLE) .renderPass(vkRenderPass) - .framebuffer(swapchain.images[imageIndex].framebuffer) + .framebuffer(swapchain.images[imageIndex].framebuffer) // TODO: Does it happen here? .renderArea(it -> it .offset(offset -> offset .x(0) @@ -2165,13 +2172,14 @@ public boolean loopXrSession() { // JME3: As public function and returns bool fo .pCommandBuffers(stack.pointers(swapchain.commandBuffer)), swapchain.fence ), "QueueSubmit"); +*/ } // Submit command buffers for both eyes before waiting for them to complete for (SwapchainWrapper swapchain : swapchains) { vkCheck(vkWaitForFences(vkDevice, swapchain.fence, true, 1_000_000_000), "WaitForFences"); vkCheck(vkResetFences(vkDevice, swapchain.fence), "ResetFences"); - xrCheck(xrReleaseSwapchainImage(swapchain.swapchain, null), "ReleaseSwapchainImage"); + xrCheck(xrReleaseSwapchainImage(swapchain.swapchain, null), "ReleaseSwapchainImage"); //TODO: DrawEnd } } else { System.out.println("Skip frame"); From 49f7bbb927a8a1d0db0d97576e390132fb463382 Mon Sep 17 00:00:00 2001 From: Starcommander Date: Thu, 23 Mar 2023 02:27:15 +0100 Subject: [PATCH 07/18] For XR use GL example instead Vulkan. --- jme3-xr/build.gradle | 3 +- .../main/java/com/jme3/app/VREnvironment.java | 6 +- .../input/vr/lwjgl_openvr/LWJGLOpenVR.java | 2 +- .../input/vr/lwjgl_openxr/HelloOpenXRGL.java | 936 +++++++ .../jme3/input/vr/lwjgl_openxr/IOUtil.java | 75 - .../com/jme3/input/vr/lwjgl_openxr/Main.java | 2296 ----------------- .../jme3/input/vr/lwjgl_openxr/ShadersGL.java | 132 + .../{XrHelper.java => XRHelper.java} | 19 +- 8 files changed, 1081 insertions(+), 2388 deletions(-) create mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/HelloOpenXRGL.java delete mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/IOUtil.java delete mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/Main.java create mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/ShadersGL.java rename jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/{XrHelper.java => XRHelper.java} (96%) diff --git a/jme3-xr/build.gradle b/jme3-xr/build.gradle index c44b52c2fb..b56dd97778 100644 --- a/jme3-xr/build.gradle +++ b/jme3-xr/build.gradle @@ -18,7 +18,8 @@ dependencies { // Necessary by lwjgl-openxr api "org.joml:joml:1.10.4" - api "org.lwjgl:lwjgl-vulkan:${lwjgl3Version}" + api "org.lwjgl:lwjgl-egl:${lwjgl3Version}" +// api "org.lwjgl:lwjgl-vulkan:${lwjgl3Version}" } javadoc { diff --git a/jme3-xr/src/main/java/com/jme3/app/VREnvironment.java b/jme3-xr/src/main/java/com/jme3/app/VREnvironment.java index 6bf234f910..3f15d1fde9 100644 --- a/jme3-xr/src/main/java/com/jme3/app/VREnvironment.java +++ b/jme3-xr/src/main/java/com/jme3/app/VREnvironment.java @@ -74,7 +74,7 @@ public class VREnvironment { private AppState app = null; - private com.jme3.input.vr.lwjgl_openxr.Main mainXr; + private com.jme3.input.vr.lwjgl_openxr.HelloOpenXRGL mainXr; private boolean initialized = false; @@ -95,11 +95,11 @@ public VRAPI getVRHardware() { } /** Will be set in LWJGLOpenVR, when ready. */ - public void setXR(com.jme3.input.vr.lwjgl_openxr.Main mainXr) { + public void setXR(com.jme3.input.vr.lwjgl_openxr.HelloOpenXRGL mainXr) { this.mainXr = mainXr; } - public com.jme3.input.vr.lwjgl_openxr.Main getXr() + public com.jme3.input.vr.lwjgl_openxr.HelloOpenXRGL getXr() { return mainXr; } diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVR.java b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVR.java index d51f79017b..8f85ad326b 100644 --- a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVR.java +++ b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVR.java @@ -98,7 +98,7 @@ public int getDisplayFrequency() { public boolean initialize() { logger.config("Initializing OpenVR system..."); - com.jme3.input.vr.lwjgl_openxr.Main mainXr = new com.jme3.input.vr.lwjgl_openxr.Main(); + com.jme3.input.vr.lwjgl_openxr.HelloOpenXRGL mainXr = new com.jme3.input.vr.lwjgl_openxr.HelloOpenXRGL(); mainXr.initXr(); vrInput = new LWJGLOpenVRInput(environment); vrInput.init(); diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/HelloOpenXRGL.java b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/HelloOpenXRGL.java new file mode 100644 index 0000000000..2211230ce3 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/HelloOpenXRGL.java @@ -0,0 +1,936 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * Source: https://github.com/LWJGL/lwjgl3/tree/master/modules/samples/src/test/java/org/lwjgl/demo/openxr + */ +package com.jme3.input.vr.lwjgl_openxr; + +import org.joml.*; +import org.lwjgl.*; +import org.lwjgl.opengl.*; +import org.lwjgl.openxr.*; +import org.lwjgl.system.*; + +import java.nio.*; +import java.util.*; + +import static org.lwjgl.glfw.GLFW.*; +import static org.lwjgl.opengl.GL11.*; +import static org.lwjgl.opengl.GL20.*; +import static org.lwjgl.opengl.GL30.*; +import static org.lwjgl.openxr.EXTDebugUtils.*; +import static org.lwjgl.openxr.KHROpenGLEnable.*; +import static org.lwjgl.openxr.MNDXEGLEnable.*; +import static org.lwjgl.openxr.XR10.*; +import static org.lwjgl.system.MemoryStack.*; +import static org.lwjgl.system.MemoryUtil.*; + +public class HelloOpenXRGL { + + long window; + + //XR globals + //Init + XrInstance xrInstance; + long systemID; + XrSession xrSession; + boolean missingXrDebug; + boolean useEglGraphicsBinding; + XrDebugUtilsMessengerEXT xrDebugMessenger; + XrSpace xrAppSpace; //The real world space in which the program runs + long glColorFormat; + XrView.Buffer views; //Each view reperesents an eye in the headset with views[0] being left and views[1] being right + Swapchain[] swapchains; //One swapchain per view + XrViewConfigurationView.Buffer viewConfigs; + int viewConfigType = XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO; + + //Runtime + XrEventDataBuffer eventDataBuffer; + int sessionState; + boolean sessionRunning; + + //GL globals + Map depthTextures; //Swapchain images only provide a color texture so we have to create depth textures seperatley + + int swapchainFramebuffer; + int cubeVertexBuffer; + int cubeIndexBuffer; + int quadVertexBuffer; + int cubeVAO; + int quadVAO; + int screenShader; + int textureShader; + int colorShader; + + static class Swapchain { + XrSwapchain handle; + int width; + int height; + XrSwapchainImageOpenGLKHR.Buffer images; + } + + public static void main(String[] args) throws InterruptedException { + HelloOpenXRGL helloOpenXR = new HelloOpenXRGL(); + + helloOpenXR.createOpenXRInstance(); + helloOpenXR.initializeOpenXRSystem(); + helloOpenXR.initializeAndBindOpenGL(); + helloOpenXR.createXRReferenceSpace(); + helloOpenXR.createXRSwapchains(); + helloOpenXR.createOpenGLResourses(); + + helloOpenXR.eventDataBuffer = XrEventDataBuffer.calloc() + .type$Default(); + + while (!helloOpenXR.pollEvents() && !glfwWindowShouldClose(helloOpenXR.window)) { + if (helloOpenXR.sessionRunning) { + helloOpenXR.renderFrameOpenXR(); + } else { + // Throttle loop since xrWaitFrame won't be called. + Thread.sleep(250); + } + } + + // Wait until idle + glFinish(); + + // Destroy OpenXR + helloOpenXR.eventDataBuffer.free(); + helloOpenXR.views.free(); + helloOpenXR.viewConfigs.free(); + for (Swapchain swapchain : helloOpenXR.swapchains) { + xrDestroySwapchain(swapchain.handle); + swapchain.images.free(); + } + + xrDestroySpace(helloOpenXR.xrAppSpace); + if (helloOpenXR.xrDebugMessenger != null) { + xrDestroyDebugUtilsMessengerEXT(helloOpenXR.xrDebugMessenger); + } + xrDestroySession(helloOpenXR.xrSession); + xrDestroyInstance(helloOpenXR.xrInstance); + + //Destroy OpenGL + for (int texture : helloOpenXR.depthTextures.values()) { + glDeleteTextures(texture); + } + glDeleteFramebuffers(helloOpenXR.swapchainFramebuffer); + glDeleteBuffers(helloOpenXR.cubeVertexBuffer); + glDeleteBuffers(helloOpenXR.cubeIndexBuffer); + glDeleteBuffers(helloOpenXR.quadVertexBuffer); + glDeleteVertexArrays(helloOpenXR.cubeVAO); + glDeleteVertexArrays(helloOpenXR.quadVAO); + glDeleteProgram(helloOpenXR.screenShader); + glDeleteProgram(helloOpenXR.textureShader); + glDeleteProgram(helloOpenXR.colorShader); + + glfwTerminate(); + } + + public void createOpenXRInstance() { + try (MemoryStack stack = stackPush()) { + IntBuffer pi = stack.mallocInt(1); + + check(xrEnumerateInstanceExtensionProperties((ByteBuffer)null, pi, null)); + int numExtensions = pi.get(0); + + XrExtensionProperties.Buffer properties = XRHelper.prepareExtensionProperties(stack, numExtensions); + + check(xrEnumerateInstanceExtensionProperties((ByteBuffer)null, pi, properties)); + + System.out.printf("OpenXR loaded with %d extensions:%n", numExtensions); + System.out.println("~~~~~~~~~~~~~~~~~~"); + + boolean missingOpenGL = true; + missingXrDebug = true; + + useEglGraphicsBinding = false; + for (int i = 0; i < numExtensions; i++) { + XrExtensionProperties prop = properties.get(i); + + String extensionName = prop.extensionNameString(); + System.out.println(extensionName); + + if (extensionName.equals(XR_KHR_OPENGL_ENABLE_EXTENSION_NAME)) { + missingOpenGL = false; + } + if (extensionName.equals(XR_EXT_DEBUG_UTILS_EXTENSION_NAME)) { + missingXrDebug = false; + } + if (extensionName.equals(XR_MNDX_EGL_ENABLE_EXTENSION_NAME)) { + useEglGraphicsBinding = true; + } + } + + if (missingOpenGL) { + throw new IllegalStateException("OpenXR library does not provide required extension: " + XR_KHR_OPENGL_ENABLE_EXTENSION_NAME); + } + + if (useEglGraphicsBinding) { + System.out.println("Going to use cross-platform experimental EGL for session creation"); + } else { + System.out.println("Going to use platform-specific session creation"); + } + + PointerBuffer extensions = stack.mallocPointer(2); + extensions.put(stack.UTF8(XR_KHR_OPENGL_ENABLE_EXTENSION_NAME)); + if (useEglGraphicsBinding) { + extensions.put(stack.UTF8(XR_MNDX_EGL_ENABLE_EXTENSION_NAME)); + } else if (!missingXrDebug) { + // At the time of writing this, the OpenXR validation layers don't like EGL + extensions.put(stack.UTF8(XR_EXT_DEBUG_UTILS_EXTENSION_NAME)); + } + extensions.flip(); + System.out.println("~~~~~~~~~~~~~~~~~~"); + + boolean useValidationLayer = false; + + check(xrEnumerateApiLayerProperties(pi, null)); + int numLayers = pi.get(0); + + XrApiLayerProperties.Buffer pLayers = XRHelper.prepareApiLayerProperties(stack, numLayers); + check(xrEnumerateApiLayerProperties(pi, pLayers)); + System.out.println(numLayers + " XR layers are available:"); + for (int index = 0; index < numLayers; index++) { + XrApiLayerProperties layer = pLayers.get(index); + + String layerName = layer.layerNameString(); + System.out.println(layerName); + + // At the time of wring this, the OpenXR validation layers don't like EGL + if (!useEglGraphicsBinding && layerName.equals("XR_APILAYER_LUNARG_core_validation")) { + useValidationLayer = true; + } + } + System.out.println("-----------"); + + PointerBuffer wantedLayers; + if (useValidationLayer) { + wantedLayers = stack.callocPointer(1); + wantedLayers.put(0, stack.UTF8("XR_APILAYER_LUNARG_core_validation")); + System.out.println("Enabling XR core validation"); + } else { + System.out.println("Running without validation layers"); + wantedLayers = null; + } + + XrInstanceCreateInfo createInfo = XrInstanceCreateInfo.malloc(stack) + .type$Default() + .next(NULL) + .createFlags(0) + .applicationInfo(XrApplicationInfo.calloc(stack) + .applicationName(stack.UTF8("HelloOpenXR")) + .apiVersion(XR_CURRENT_API_VERSION)) + .enabledApiLayerNames(wantedLayers) + .enabledExtensionNames(extensions); + + PointerBuffer pp = stack.mallocPointer(1); + System.out.println("Creating OpenXR instance..."); + check(xrCreateInstance(createInfo, pp)); + xrInstance = new XrInstance(pp.get(0), createInfo); + System.out.println("Created OpenXR instance"); + } + } + + public void initializeOpenXRSystem() { + try (MemoryStack stack = stackPush()) { + //Get headset + LongBuffer pl = stack.longs(0); + + check(xrGetSystem( + xrInstance, + XrSystemGetInfo.malloc(stack) + .type$Default() + .next(NULL) + .formFactor(XR_FORM_FACTOR_HEAD_MOUNTED_DISPLAY), + pl + )); + + systemID = pl.get(0); + if (systemID == 0) { + throw new IllegalStateException("No compatible headset detected"); + } + System.out.printf("Headset found with System ID: %d\n", systemID); + } + } + + public void initializeAndBindOpenGL() { + try (MemoryStack stack = stackPush()) { + //Initialize OpenXR's OpenGL compatability + XrGraphicsRequirementsOpenGLKHR graphicsRequirements = XrGraphicsRequirementsOpenGLKHR.malloc(stack) + .type$Default() + .next(NULL) + .minApiVersionSupported(0) + .maxApiVersionSupported(0); + + xrGetOpenGLGraphicsRequirementsKHR(xrInstance, systemID, graphicsRequirements); + + int minMajorVersion = XR_VERSION_MAJOR(graphicsRequirements.minApiVersionSupported()); + int minMinorVersion = XR_VERSION_MINOR(graphicsRequirements.minApiVersionSupported()); + + int maxMajorVersion = XR_VERSION_MAJOR(graphicsRequirements.maxApiVersionSupported()); + int maxMinorVersion = XR_VERSION_MINOR(graphicsRequirements.maxApiVersionSupported()); + + System.out.println("The OpenXR runtime supports OpenGL " + minMajorVersion + "." + minMinorVersion + + " to OpenGL " + maxMajorVersion + "." + maxMinorVersion); + + // This example needs at least OpenGL 4.0 + if (maxMajorVersion < 4) { + throw new UnsupportedOperationException("This example requires at least OpenGL 4.0"); + } + int majorVersionToRequest = 4; + int minorVersionToRequest = 0; + + // But when the OpenXR runtime requires a later version, we should respect that. + // As a matter of fact, the runtime on my current laptop does, so this code is actually needed. + if (minMajorVersion == 4) { + minorVersionToRequest = 5; + } + + //Init glfw + if (!glfwInit()) { + throw new IllegalStateException("Failed to initialize GLFW."); + } + + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, majorVersionToRequest); + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, minorVersionToRequest); + glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); + glfwWindowHint(GLFW_DOUBLEBUFFER, GL_FALSE); + if (useEglGraphicsBinding) { + glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_EGL_CONTEXT_API); + } + window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL); + glfwMakeContextCurrent(window); + GL.createCapabilities(); + + // Check if OpenGL version is supported by OpenXR runtime + int actualMajorVersion = glGetInteger(GL_MAJOR_VERSION); + int actualMinorVersion = glGetInteger(GL_MINOR_VERSION); + + if (minMajorVersion > actualMajorVersion || (minMajorVersion == actualMajorVersion && minMinorVersion > actualMinorVersion)) { + throw new IllegalStateException( + "The OpenXR runtime supports only OpenGL " + minMajorVersion + "." + minMinorVersion + + " and later, but we got OpenGL " + actualMajorVersion + "." + actualMinorVersion + ); + } + + if (actualMajorVersion > maxMajorVersion || (actualMajorVersion == maxMajorVersion && actualMinorVersion > maxMinorVersion)) { + throw new IllegalStateException( + "The OpenXR runtime supports only OpenGL " + maxMajorVersion + "." + minMajorVersion + + " and earlier, but we got OpenGL " + actualMajorVersion + "." + actualMinorVersion + ); + } + + //Bind the OpenGL context to the OpenXR instance and create the session + PointerBuffer pp = stack.mallocPointer(1); + check(xrCreateSession( + xrInstance, + XRHelper.createGraphicsBindingOpenGL( + XrSessionCreateInfo.malloc(stack) + .type$Default() + .next(NULL) + .createFlags(0) + .systemId(systemID), + stack, + window, + useEglGraphicsBinding + ), + pp + )); + + xrSession = new XrSession(pp.get(0), xrInstance); + + if (!missingXrDebug && !useEglGraphicsBinding) { + XrDebugUtilsMessengerCreateInfoEXT ciDebugUtils = XrDebugUtilsMessengerCreateInfoEXT.calloc(stack) + .type$Default() + .messageSeverities( + XR_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT | + XR_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT | + XR_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT + ) + .messageTypes( + XR_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT | + XR_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT | + XR_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT | + XR_DEBUG_UTILS_MESSAGE_TYPE_CONFORMANCE_BIT_EXT + ) + .userCallback((messageSeverity, messageTypes, pCallbackData, userData) -> { + XrDebugUtilsMessengerCallbackDataEXT callbackData = XrDebugUtilsMessengerCallbackDataEXT.create(pCallbackData); + System.out.println("XR Debug Utils: " + callbackData.messageString()); + return 0; + }); + + System.out.println("Enabling OpenXR debug utils"); + check(xrCreateDebugUtilsMessengerEXT(xrInstance, ciDebugUtils, pp)); + xrDebugMessenger = new XrDebugUtilsMessengerEXT(pp.get(0), xrInstance); + } + } + } + + public void createXRReferenceSpace() { + try (MemoryStack stack = stackPush()) { + PointerBuffer pp = stack.mallocPointer(1); + + check(xrCreateReferenceSpace( + xrSession, + XrReferenceSpaceCreateInfo.malloc(stack) + .type$Default() + .next(NULL) + .referenceSpaceType(XR_REFERENCE_SPACE_TYPE_LOCAL) + .poseInReferenceSpace(XrPosef.malloc(stack) + .orientation(XrQuaternionf.malloc(stack) + .x(0) + .y(0) + .z(0) + .w(1)) + .position$(XrVector3f.calloc(stack))), + pp + )); + + xrAppSpace = new XrSpace(pp.get(0), xrSession); + } + } + + public void createXRSwapchains() { + try (MemoryStack stack = stackPush()) { + XrSystemProperties systemProperties = XrSystemProperties.calloc(stack) + .type$Default(); + check(xrGetSystemProperties(xrInstance, systemID, systemProperties)); + + System.out.printf("Headset name:%s vendor:%d \n", + memUTF8(memAddress(systemProperties.systemName())), + systemProperties.vendorId()); + + XrSystemTrackingProperties trackingProperties = systemProperties.trackingProperties(); + System.out.printf("Headset orientationTracking:%b positionTracking:%b \n", + trackingProperties.orientationTracking(), + trackingProperties.positionTracking()); + + XrSystemGraphicsProperties graphicsProperties = systemProperties.graphicsProperties(); + System.out.printf("Headset MaxWidth:%d MaxHeight:%d MaxLayerCount:%d \n", + graphicsProperties.maxSwapchainImageWidth(), + graphicsProperties.maxSwapchainImageHeight(), + graphicsProperties.maxLayerCount()); + + IntBuffer pi = stack.mallocInt(1); + + check(xrEnumerateViewConfigurationViews(xrInstance, systemID, viewConfigType, pi, null)); + viewConfigs = XRHelper.fill( + XrViewConfigurationView.calloc(pi.get(0)), + XrViewConfigurationView.TYPE, + XR_TYPE_VIEW_CONFIGURATION_VIEW + ); + + check(xrEnumerateViewConfigurationViews(xrInstance, systemID, viewConfigType, pi, viewConfigs)); + int viewCountNumber = pi.get(0); + + views = XRHelper.fill( + XrView.calloc(viewCountNumber), + XrView.TYPE, + XR_TYPE_VIEW + ); + + if (viewCountNumber > 0) { + check(xrEnumerateSwapchainFormats(xrSession, pi, null)); + LongBuffer swapchainFormats = stack.mallocLong(pi.get(0)); + check(xrEnumerateSwapchainFormats(xrSession, pi, swapchainFormats)); + + long[] desiredSwapchainFormats = { + GL_RGB10_A2, + GL_RGBA16F, + // The two below should only be used as a fallback, as they are linear color formats without enough bits for color + // depth, thus leading to banding. + GL_RGBA8, + GL31.GL_RGBA8_SNORM + }; + + out: + for (long glFormatIter : desiredSwapchainFormats) { + for (int i = 0; i < swapchainFormats.limit(); i++) { + if (glFormatIter == swapchainFormats.get(i)) { + glColorFormat = glFormatIter; + break out; + } + } + } + + if (glColorFormat == 0) { + throw new IllegalStateException("No compatable swapchain / framebuffer format availible"); + } + + swapchains = new Swapchain[viewCountNumber]; + for (int i = 0; i < viewCountNumber; i++) { + XrViewConfigurationView viewConfig = viewConfigs.get(i); + + Swapchain swapchainWrapper = new Swapchain(); + + XrSwapchainCreateInfo swapchainCreateInfo = XrSwapchainCreateInfo.malloc(stack) + .type$Default() + .next(NULL) + .createFlags(0) + .usageFlags(XR_SWAPCHAIN_USAGE_SAMPLED_BIT | XR_SWAPCHAIN_USAGE_COLOR_ATTACHMENT_BIT) + .format(glColorFormat) + .sampleCount(viewConfig.recommendedSwapchainSampleCount()) + .width(viewConfig.recommendedImageRectWidth()) + .height(viewConfig.recommendedImageRectHeight()) + .faceCount(1) + .arraySize(1) + .mipCount(1); + + PointerBuffer pp = stack.mallocPointer(1); + check(xrCreateSwapchain(xrSession, swapchainCreateInfo, pp)); + + swapchainWrapper.handle = new XrSwapchain(pp.get(0), xrSession); + swapchainWrapper.width = swapchainCreateInfo.width(); + swapchainWrapper.height = swapchainCreateInfo.height(); + + check(xrEnumerateSwapchainImages(swapchainWrapper.handle, pi, null)); + int imageCount = pi.get(0); + + XrSwapchainImageOpenGLKHR.Buffer swapchainImageBuffer = XRHelper.fill( + XrSwapchainImageOpenGLKHR.calloc(imageCount), + XrSwapchainImageOpenGLKHR.TYPE, + XR_TYPE_SWAPCHAIN_IMAGE_OPENGL_KHR + ); + + check(xrEnumerateSwapchainImages(swapchainWrapper.handle, pi, XrSwapchainImageBaseHeader.create(swapchainImageBuffer))); + swapchainWrapper.images = swapchainImageBuffer; + swapchains[i] = swapchainWrapper; + } + } + } + } + + private void createOpenGLResourses() { + swapchainFramebuffer = glGenFramebuffers(); + depthTextures = new HashMap<>(0); + for (Swapchain swapchain : swapchains) { + for (XrSwapchainImageOpenGLKHR swapchainImage : swapchain.images) { + int texture = glGenTextures(); + glBindTexture(GL_TEXTURE_2D, texture); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32, swapchain.width, swapchain.height, 0, GL_DEPTH_COMPONENT, GL_FLOAT, (ByteBuffer)null); + depthTextures.put(swapchainImage, texture); + } + } + glBindTexture(GL_TEXTURE_2D, 0); + + textureShader = ShadersGL.createShaderProgram(ShadersGL.texVertShader, ShadersGL.texFragShader); + colorShader = ShadersGL.createShaderProgram(ShadersGL.colVertShader, ShadersGL.colFragShader); + screenShader = ShadersGL.createShaderProgram(ShadersGL.screenVertShader, ShadersGL.texFragShader); + + { + cubeVertexBuffer = glGenBuffers(); + glBindBuffer(GL_ARRAY_BUFFER, cubeVertexBuffer); + glBufferData(GL_ARRAY_BUFFER, Geometry.cubeVertices, GL_STATIC_DRAW); + + cubeIndexBuffer = glGenBuffers(); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, cubeIndexBuffer); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, Geometry.cubeIndices, GL_STATIC_DRAW); + + cubeVAO = glGenVertexArrays(); + glBindVertexArray(cubeVAO); + glEnableVertexAttribArray(0); + glEnableVertexAttribArray(1); + glVertexAttribPointer(0, 3, GL_FLOAT, false, 4 * 3 * 2, 0); + glVertexAttribPointer(1, 3, GL_FLOAT, false, 24, 12); + } + { + quadVAO = glGenVertexArrays(); + quadVertexBuffer = glGenBuffers(); + glBindVertexArray(quadVAO); + glBindBuffer(GL_ARRAY_BUFFER, quadVertexBuffer); + glBufferData(GL_ARRAY_BUFFER, Geometry.quadVertices, GL_STATIC_DRAW); + glEnableVertexAttribArray(0); + glVertexAttribPointer(0, 2, GL_FLOAT, false, 4 * 4, 0); + glEnableVertexAttribArray(1); + glVertexAttribPointer(1, 2, GL_FLOAT, false, 4 * 4, 2 * 4); + } + + glBindBuffer(GL_ARRAY_BUFFER, 0); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + glBindVertexArray(0); + } + + private boolean pollEvents() { + glfwPollEvents(); + XrEventDataBaseHeader event = readNextOpenXREvent(); + if (event == null) { + return false; + } + + do { + switch (event.type()) { + case XR_TYPE_EVENT_DATA_INSTANCE_LOSS_PENDING: { + XrEventDataInstanceLossPending instanceLossPending = XrEventDataInstanceLossPending.create(event); + System.err.printf("XrEventDataInstanceLossPending by %d\n", instanceLossPending.lossTime()); + //*requestRestart = true; + return true; + } + case XR_TYPE_EVENT_DATA_SESSION_STATE_CHANGED: { + XrEventDataSessionStateChanged sessionStateChangedEvent = XrEventDataSessionStateChanged.create(event); + return OpenXRHandleSessionStateChangedEvent(sessionStateChangedEvent/*, requestRestart*/); + } + case XR_TYPE_EVENT_DATA_INTERACTION_PROFILE_CHANGED: + break; + case XR_TYPE_EVENT_DATA_REFERENCE_SPACE_CHANGE_PENDING: + default: { + System.out.printf("Ignoring event type %d\n", event.type()); + break; + } + } + event = readNextOpenXREvent(); + } + while (event != null); + + return false; + } + + private XrEventDataBaseHeader readNextOpenXREvent() { + // It is sufficient to just clear the XrEventDataBuffer header to + // XR_TYPE_EVENT_DATA_BUFFER rather than recreate it every time + eventDataBuffer.clear(); + eventDataBuffer.type$Default(); + int result = xrPollEvent(xrInstance, eventDataBuffer); + if (result == XR_SUCCESS) { + XrEventDataBaseHeader header = XrEventDataBaseHeader.create(eventDataBuffer.address()); + if (header.type() == XR_TYPE_EVENT_DATA_EVENTS_LOST) { + XrEventDataEventsLost dataEventsLost = XrEventDataEventsLost.create(header); + System.out.printf("%d events lost\n", dataEventsLost.lostEventCount()); + } + return header; + } + if (result == XR_EVENT_UNAVAILABLE) { + return null; + } + throw new IllegalStateException(String.format("[XrResult failure %d in xrPollEvent]", result)); + } + + boolean OpenXRHandleSessionStateChangedEvent(XrEventDataSessionStateChanged stateChangedEvent) { + int oldState = sessionState; + sessionState = stateChangedEvent.state(); + + System.out.printf("XrEventDataSessionStateChanged: state %s->%s session=%d time=%d\n", oldState, sessionState, stateChangedEvent.session(), stateChangedEvent.time()); + + if ((stateChangedEvent.session() != NULL) && (stateChangedEvent.session() != xrSession.address())) { + System.err.println("XrEventDataSessionStateChanged for unknown session"); + return false; + } + + switch (sessionState) { + case XR_SESSION_STATE_READY: { + assert (xrSession != null); + try (MemoryStack stack = stackPush()) { + check(xrBeginSession( + xrSession, + XrSessionBeginInfo.malloc(stack) + .type$Default() + .next(NULL) + .primaryViewConfigurationType(viewConfigType) + )); + sessionRunning = true; + return false; + } + } + case XR_SESSION_STATE_STOPPING: { + assert (xrSession != null); + sessionRunning = false; + check(xrEndSession(xrSession)); + return false; + } + case XR_SESSION_STATE_EXITING: { + // Do not attempt to restart because user closed this session. + //*requestRestart = false; + return true; + } + case XR_SESSION_STATE_LOSS_PENDING: { + // Poll for a new instance. + //*requestRestart = true; + return true; + } + default: + return false; + } + } + + private void renderFrameOpenXR() { + try (MemoryStack stack = stackPush()) { + XrFrameState frameState = XrFrameState.calloc(stack) + .type$Default(); + + check(xrWaitFrame( + xrSession, + XrFrameWaitInfo.calloc(stack) + .type$Default(), + frameState + )); + + check(xrBeginFrame( + xrSession, + XrFrameBeginInfo.calloc(stack) + .type$Default() + )); + + XrCompositionLayerProjection layerProjection = XrCompositionLayerProjection.calloc(stack) + .type$Default(); + + PointerBuffer layers = stack.callocPointer(1); + + boolean didRender = false; + if (frameState.shouldRender()) { + if (renderLayerOpenXR(stack, frameState.predictedDisplayTime(), layerProjection)) { + layers.put(0, layerProjection); + didRender = true; + } else { + System.out.println("Didn't render"); + } + } else { + System.out.println("Shouldn't render"); + } + + check(xrEndFrame( + xrSession, + XrFrameEndInfo.malloc(stack) + .type$Default() + .next(NULL) + .displayTime(frameState.predictedDisplayTime()) + .environmentBlendMode(XR_ENVIRONMENT_BLEND_MODE_OPAQUE) + .layers(didRender ? layers : null) + .layerCount(didRender ? layers.remaining() : 0) + )); + } + } + + private boolean renderLayerOpenXR(MemoryStack stack, long predictedDisplayTime, XrCompositionLayerProjection layer) { + XrViewState viewState = XrViewState.calloc(stack) + .type$Default(); + + IntBuffer pi = stack.mallocInt(1); + check(xrLocateViews( + xrSession, + XrViewLocateInfo.malloc(stack) + .type$Default() + .next(NULL) + .viewConfigurationType(viewConfigType) + .displayTime(predictedDisplayTime) + .space(xrAppSpace), + viewState, + pi, + views + )); + + if ((viewState.viewStateFlags() & XR_VIEW_STATE_POSITION_VALID_BIT) == 0 || + (viewState.viewStateFlags() & XR_VIEW_STATE_ORIENTATION_VALID_BIT) == 0) { + return false; // There is no valid tracking poses for the views. + } + + int viewCountOutput = pi.get(0); + assert (viewCountOutput == views.capacity()); + assert (viewCountOutput == viewConfigs.capacity()); + assert (viewCountOutput == swapchains.length); + + XrCompositionLayerProjectionView.Buffer projectionLayerViews = XRHelper.fill( + XrCompositionLayerProjectionView.calloc(viewCountOutput, stack), + XrCompositionLayerProjectionView.TYPE, + XR_TYPE_COMPOSITION_LAYER_PROJECTION_VIEW + ); + + // Render view to the appropriate part of the swapchain image. + for (int viewIndex = 0; viewIndex < viewCountOutput; viewIndex++) { + // Each view has a separate swapchain which is acquired, rendered to, and released. + Swapchain viewSwapchain = swapchains[viewIndex]; + + check(xrAcquireSwapchainImage( + viewSwapchain.handle, + XrSwapchainImageAcquireInfo.calloc(stack) + .type$Default(), + pi + )); + int swapchainImageIndex = pi.get(0); + + check(xrWaitSwapchainImage( + viewSwapchain.handle, + XrSwapchainImageWaitInfo.malloc(stack) + .type$Default() + .next(NULL) + .timeout(XR_INFINITE_DURATION) + )); + + XrCompositionLayerProjectionView projectionLayerView = projectionLayerViews.get(viewIndex) + .pose(views.get(viewIndex).pose()) + .fov(views.get(viewIndex).fov()) + .subImage(si -> si + .swapchain(viewSwapchain.handle) + .imageRect(rect -> rect + .offset(offset -> offset + .x(0) + .y(0)) + .extent(extent -> extent + .width(viewSwapchain.width) + .height(viewSwapchain.height) + ))); + + OpenGLRenderView(projectionLayerView, viewSwapchain.images.get(swapchainImageIndex), viewIndex); + + check(xrReleaseSwapchainImage( + viewSwapchain.handle, + XrSwapchainImageReleaseInfo.calloc(stack) + .type$Default() + )); + } + + layer.space(xrAppSpace); + layer.views(projectionLayerViews); + return true; + } + + private static Matrix4f modelviewMatrix = new Matrix4f(); + private static Matrix4f projectionMatrix = new Matrix4f(); + private static Matrix4f viewMatrix = new Matrix4f(); + + private static FloatBuffer mvpMatrix = BufferUtils.createFloatBuffer(16); + + private void OpenGLRenderView(XrCompositionLayerProjectionView layerView, XrSwapchainImageOpenGLKHR swapchainImage, int viewIndex) { + glBindFramebuffer(GL_FRAMEBUFFER, swapchainFramebuffer); + + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, swapchainImage.image(), 0); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthTextures.get(swapchainImage), 0); + + XrRect2Di imageRect = layerView.subImage().imageRect(); + glViewport( + imageRect.offset().x(), + imageRect.offset().y(), + imageRect.extent().width(), + imageRect.extent().height() + ); + + float[] DarkSlateGray = {0.184313729f, 0.309803933f, 0.309803933f}; + glClearColor(DarkSlateGray[0], DarkSlateGray[1], DarkSlateGray[2], 1.0f); + glClearDepth(1.0f); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + + glFrontFace(GL_CW); + glCullFace(GL_BACK); + glEnable(GL_DEPTH_TEST); + + XrPosef pose = layerView.pose(); + XrVector3f pos = pose.position$(); + XrQuaternionf orientation = pose.orientation(); + XRHelper.applyProjectionToMatrix(projectionMatrix.identity(), layerView.fov(), 0.1f, 100f, false); + viewMatrix.translationRotateScaleInvert( + pos.x(), pos.y(), pos.z(), + orientation.x(), orientation.y(), orientation.z(), orientation.w(), + 1, 1, 1 + ); + + glDisable(GL_CULL_FACE); // Disable back-face culling so we can see the inside of the world-space cube and backside of the plane + + { // Rotating plane + modelviewMatrix.translation(0, 0, -3).rotate((float)-glfwGetTime(), 1, 0, 0); + glUseProgram(colorShader); + glUniformMatrix4fv(glGetUniformLocation(colorShader, "projection"), false, projectionMatrix.get(mvpMatrix)); + glUniformMatrix4fv(glGetUniformLocation(colorShader, "view"), false, viewMatrix.get(mvpMatrix)); + glUniformMatrix4fv(glGetUniformLocation(colorShader, "model"), false, modelviewMatrix.get(mvpMatrix)); + glBindVertexArray(quadVAO); + glDrawArrays(GL_TRIANGLES, 0, 6); + } + + { // World-space cube + modelviewMatrix.identity().scale(10); + glUniformMatrix4fv(glGetUniformLocation(colorShader, "model"), false, modelviewMatrix.get(mvpMatrix)); + glBindVertexArray(cubeVAO); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, cubeIndexBuffer); + glDrawElements(GL_TRIANGLES, 36, GL_UNSIGNED_SHORT, 0); + } + + glEnable(GL_CULL_FACE); + + glBindFramebuffer(GL_FRAMEBUFFER, 0); + + if (viewIndex == 0 || true) { // The view to the GLFW window + try (MemoryStack stack = stackPush()) { + Swapchain swapchain = swapchains[viewIndex]; + + IntBuffer ww = stack.mallocInt(1); + IntBuffer wh = stack.mallocInt(1); + glfwGetWindowSize(window, ww, wh); + + int wh2 = (int)(((float)swapchain.height / swapchain.width) * ww.get(0)); + if (wh2 > wh.get(0)) { + int ww2 = (int)(((float)swapchain.width / swapchain.height) * wh.get(0)); + glViewport(ww2 * viewIndex, 0, ww2, wh.get(0)); + } else { + glViewport(ww.get(0) * viewIndex, 0, ww.get(0), wh2); + } + } + glFrontFace(GL_CCW); + glUseProgram(screenShader); + glBindVertexArray(quadVAO); + glDisable(GL_DEPTH_TEST); + glBindTexture(GL_TEXTURE_2D, swapchainImage.image()); + glDrawArrays(GL_TRIANGLES, 0, 6); + if (viewIndex == swapchains.length - 1) { + glFlush(); + } + } + } + + public void check(int result) throws IllegalStateException { + if (XR_SUCCEEDED(result)) { + return; + } + + if (xrInstance != null) { + ByteBuffer str = stackMalloc(XR_MAX_RESULT_STRING_SIZE); + if (xrResultToString(xrInstance, result, str) >= 0) { + throw new XrResultException(memUTF8(str, memLengthNT1(str))); + } + } + + throw new XrResultException("XR method returned " + result); + } + + @SuppressWarnings("serial") + public static class XrResultException extends RuntimeException { + public XrResultException(String s) { + super(s); + } + } + + private static class Geometry { + + static float[] cubeVertices = { + -0.5f, 0.5f, -0.5f, 0.25f, 0f, 0f, -0.5f, -0.5f, 0.5f, 0.25f, 0f, 0f, -0.5f, -0.5f, -0.5f, 0.25f, 0f, 0f, -0.5f, 0.5f, -0.5f, 0.25f, 0f, 0f, -0.5f, 0.5f, 0.5f, 0.25f, 0f, 0f, -0.5f, -0.5f, 0.5f, 0.25f, 0f, 0f, + 0.5f, 0.5f, -0.5f, 1f, 0f, 0f, 0.5f, -0.5f, -0.5f, 1f, 0f, 0f, 0.5f, -0.5f, 0.5f, 1f, 0f, 0f, 0.5f, 0.5f, -0.5f, 1f, 0f, 0f, 0.5f, -0.5f, 0.5f, 1f, 0f, 0f, 0.5f, 0.5f, 0.5f, 1f, 0f, 0f, + -0.5f, -0.5f, -0.5f, 0f, 0.25f, 0f, -0.5f, -0.5f, 0.5f, 0f, 0.25f, 0f, 0.5f, -0.5f, 0.5f, 0f, 0.25f, 0f, -0.5f, -0.5f, -0.5f, 0f, 0.25f, 0f, 0.5f, -0.5f, 0.5f, 0f, 0.25f, 0f, 0.5f, -0.5f, -0.5f, 0f, 0.25f, 0f, + -0.5f, 0.5f, -0.5f, 0f, 1f, 0f, 0.5f, 0.5f, -0.5f, 0f, 1f, 0f, 0.5f, 0.5f, 0.5f, 0f, 1f, 0f, -0.5f, 0.5f, -0.5f, 0f, 1f, 0f, 0.5f, 0.5f, 0.5f, 0f, 1f, 0f, -0.5f, 0.5f, 0.5f, 0f, 1f, 0f, + -0.5f, -0.5f, -0.5f, 0f, 0f, 0.25f, 0.5f, -0.5f, -0.5f, 0f, 0f, 0.25f, 0.5f, 0.5f, -0.5f, 0f, 0f, 0.25f, -0.5f, -0.5f, -0.5f, 0f, 0f, 0.25f, 0.5f, 0.5f, -0.5f, 0f, 0f, 0.25f, -0.5f, 0.5f, -0.5f, 0f, 0f, 0.25f, + -0.5f, -0.5f, 0.5f, 0f, 0f, 1f, -0.5f, 0.5f, 0.5f, 0f, 0f, 1f, 0.5f, 0.5f, 0.5f, 0f, 0f, 1f, -0.5f, -0.5f, 0.5f, 0f, 0f, 1f, 0.5f, 0.5f, 0.5f, 0f, 0f, 1f, 0.5f, -0.5f, 0.5f, 0f, 0f, 1f + }; + + // Winding order is clockwise. Each side uses a different color. + static short[] cubeIndices = { + 0, 1, 2, 3, 4, 5, + 6, 7, 8, 9, 10, 11, + 12, 13, 14, 15, 16, 17, + 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 34, 35, + }; + + static float[] quadVertices = { // vertex attributes for a quad that fills the entire screen in Normalized Device Coordinates. + // positions // texCoords + -1.0f, 1.0f, 0.0f, 1.0f, + -1.0f, -1.0f, 0.0f, 0.0f, + 1.0f, -1.0f, 1.0f, 0.0f, + + -1.0f, 1.0f, 0.0f, 1.0f, + 1.0f, -1.0f, 1.0f, 0.0f, + 1.0f, 1.0f, 1.0f, 1.0f + }; + } + +} \ No newline at end of file diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/IOUtil.java b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/IOUtil.java deleted file mode 100644 index 1c70380e6f..0000000000 --- a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/IOUtil.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package com.jme3.input.vr.lwjgl_openxr; // JME3: Modified package path - -import org.lwjgl.*; - -import java.io.*; -import java.nio.*; -import java.nio.channels.*; -import java.nio.file.*; - -import static org.lwjgl.BufferUtils.*; -import static org.lwjgl.system.MemoryUtil.*; - -public final class IOUtil { - - private IOUtil() { - } - - private static ByteBuffer resizeBuffer(ByteBuffer buffer, int newCapacity) { - ByteBuffer newBuffer = BufferUtils.createByteBuffer(newCapacity); - buffer.flip(); - newBuffer.put(buffer); - return newBuffer; - } - - /** - * Reads the specified resource and returns the raw data as a ByteBuffer. - * - * @param resource the resource to read - * @param bufferSize the initial buffer size - * - * @return the resource data - * - * @throws IOException if an IO error occurs - */ - public static ByteBuffer ioResourceToByteBuffer(String resource, int bufferSize) throws IOException { - System.out.println("com.starcom.lwjglvr.IOUtil.ioResourceToByteBuffer(): " + resource); - ByteBuffer buffer; - - Path path = Paths.get(resource); - if (Files.isReadable(path)) { - try (SeekableByteChannel fc = Files.newByteChannel(path)) { - buffer = BufferUtils.createByteBuffer((int)fc.size() + 1); - while (fc.read(buffer) != -1) { - ; - } - } - } else { - try ( - InputStream source = IOUtil.class.getClassLoader().getResourceAsStream(resource); - ReadableByteChannel rbc = Channels.newChannel(source) - ) { - buffer = createByteBuffer(bufferSize); - - while (true) { - int bytes = rbc.read(buffer); - if (bytes == -1) { - break; - } - if (buffer.remaining() == 0) { - buffer = resizeBuffer(buffer, buffer.capacity() * 3 / 2); // 50% - } - } - } - } - - buffer.flip(); - return memSlice(buffer); - } - -} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/Main.java b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/Main.java deleted file mode 100644 index ae0e52a4e6..0000000000 --- a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/Main.java +++ /dev/null @@ -1,2296 +0,0 @@ -/* - * Source: https://github.com/LWJGL/lwjgl3/blob/master/modules/samples/src/test/java/org/lwjgl/demo/openxr/HelloOpenXRVK.java - * Copyright LWJGL. All rights reserved. - * License terms: https://www.lwjgl.org/license - */ -package com.jme3.input.vr.lwjgl_openxr; // JME3: Modified package path - -import org.joml.*; -import org.lwjgl.*; -import org.lwjgl.openxr.*; -import org.lwjgl.system.*; -import org.lwjgl.vulkan.*; - -import java.io.*; -import java.lang.reflect.*; -import java.nio.*; -import java.util.*; -import java.util.Random; -import java.util.function.*; - -import static org.joml.Math.*; -import static org.lwjgl.openxr.EXTDebugUtils.*; -import static org.lwjgl.openxr.KHRVulkanEnable.*; -import static org.lwjgl.openxr.XR10.*; -import static org.lwjgl.system.MemoryStack.*; -import static org.lwjgl.system.MemoryUtil.*; -import static org.lwjgl.vulkan.EXTDebugUtils.*; -import static org.lwjgl.vulkan.VK10.*; -import org.joml.*; -import org.lwjgl.*; -import org.lwjgl.openxr.*; -import org.lwjgl.system.*; -import org.lwjgl.vulkan.*; - -import java.io.*; -import java.lang.reflect.*; -import java.nio.*; -import java.util.Random; -import java.util.*; -import java.util.function.*; - -import static org.joml.Math.*; -import static com.jme3.input.vr.lwjgl_openxr.IOUtil.*; -import static org.lwjgl.openxr.EXTDebugUtils.*; -import static org.lwjgl.openxr.KHRVulkanEnable.*; -import static org.lwjgl.openxr.XR10.*; -import static org.lwjgl.system.MemoryStack.*; -import static org.lwjgl.system.MemoryUtil.*; -import static org.lwjgl.vulkan.EXTDebugUtils.*; -import static org.lwjgl.vulkan.VK10.*; - -public class Main { - - private static final String VK_LAYER_LUNARG_STANDARD_VALIDATION = "VK_LAYER_LUNARG_standard_validation"; - - private static final int VERTEX_SIZE = 2 * 3 * 4; - private static final int VERTEX_LOCATION_POSITION = 0; - private static final int VERTEX_LOCATION_COLOR = 1; - private static final int VERTEX_OFFSET_POSITION = 0; - private static final int VERTEX_OFFSET_COLOR = 1 * 3 * 4; - - private static final int INDEX_SIZE = 2; - private static final int INDEX_TYPE = VK_INDEX_TYPE_UINT16; - - private static class BigModel { - - static final int NUM_CUBES = 500; - - static final int NUM_VERTICES = NUM_CUBES * 6 * 4; - static final int NUM_INDICES = NUM_CUBES * 6 * 6; - } - - private static class SwapchainImage { - final long colorImage; - final long colorImageView; - final long framebuffer; - - SwapchainImage(long colorImage, long colorImageView, long framebuffer) { - this.colorImage = colorImage; - this.colorImageView = colorImageView; - this.framebuffer = framebuffer; - } - } - - private static class SwapchainWrapper { - - final XrSwapchain swapchain; - - final int width, height, numSamples; - - final long depthImage; - final long depthImageView; - final long depthImageMemory; - - final SwapchainImage[] images; - - final long fence; - - final VkCommandBuffer commandBuffer; - - SwapchainWrapper( - XrSwapchain swapchain, int width, int height, int numSamples, - long depthImage, long depthImageView, long depthImageMemory, SwapchainImage[] images, - long fence, VkCommandBuffer commandBuffer - ) { - if (swapchain == null) { - throw new NullPointerException("swapchain"); - } - this.swapchain = swapchain; - if (width <= 0) { - throw new IllegalArgumentException("width is " + width); - } - this.width = width; - if (height <= 0) { - throw new IllegalArgumentException("height is " + height); - } - this.height = height; - - if (numSamples <= 0) { - throw new IllegalArgumentException("numSamples is " + numSamples); - } - - if (images == null) { - throw new IllegalArgumentException("images are null"); - } - this.numSamples = numSamples; - for (SwapchainImage image : images) { - if (image == null) { - throw new IllegalArgumentException("An image is null"); - } - - if (image.colorImage == 0) { - throw new IllegalArgumentException("A color image is 0"); - } - if (image.colorImageView == 0) { - throw new IllegalArgumentException("A color image view is 0"); - } - if (image.framebuffer == 0) { - throw new IllegalArgumentException("A framebuffer is 0"); - } - } - this.images = images; - - if (depthImage == 0) { - throw new IllegalArgumentException("The depth image is 0"); - } - this.depthImage = depthImage; - if (depthImageView == 0) { - throw new IllegalArgumentException("The depth image view is 0"); - } - this.depthImageView = depthImageView; - if (depthImageMemory == 0) { - throw new IllegalArgumentException("The depth image memory is 0"); - } - this.depthImageMemory = depthImageMemory; - - if (fence == 0) { - throw new IllegalArgumentException("Fence is 0"); - } - this.fence = fence; - - if (commandBuffer == null) { - throw new NullPointerException("commandBuffer"); - } - this.commandBuffer = commandBuffer; - } - } - - private static ByteBuffer getShaderResource(String resource) { - try { - return ioResourceToByteBuffer(resource, 2048); - } catch (IOException e) { - throw new IllegalStateException("Needed resources should always be available", e); - } - } - -// JME3: No main, commented out -// public static void main(String[] args) { -// Main classInstance = new Main(); -// classInstance.start(); -// } - - private XrInstance xrInstance; - - private XrDebugUtilsMessengerEXT xrDebugMessenger; - - private long xrSystemId; - - private XrSession xrVkSession; - - private int xrSessionState; - - private XrActionSet xrActionSet; - private XrAction xrHandPoseAction; - private XrAction xrHandClickAction; - - private long xrPathLeftHand; - private long xrPathRightHand; - - private XrSpace xrLeftHandSpace; - private XrSpace xrRightHandSpace; - - private boolean missingXrDebug; - - private VkInstance vkInstance; - - private long vkDebugMessenger; - - private VkPhysicalDevice vkPhysicalDevice; - private VkDevice vkDevice; - - private VkQueue vkQueue; - - private int vkQueueFamilyIndex; - private int vkQueueIndex; - - private long vkCommandPoolCopying; - private long vkCommandPoolDrawing; - - private long vkRenderPass; - private long vkPipelineLayout; - - private long[] vkGraphicsPipelines; - - private long vkDeviceMemory; - private long vkBigBuffer; - - private SwapchainWrapper[] swapchains; - - private int viewConfiguration; - private int swapchainColorFormat; - private int swapchainDepthFormat; - - private XrSpace renderSpace; - - boolean startedSession = false; // JME3: Use as member var - - // The default value can be used in edge cases where the position tracking of the driver fails right at the start - // Let's hope it won't be used a lot - private Matrix4f lastCameraMatrix = new Matrix4f().perspective(toRadians(70f), 0.7f, 0.01f, 100f, true); - -// JME3: New Variables - private Vector3f internalCameraPos = new Vector3f(); - private Quaternionf internalCameraRot = new Quaternionf(); - -// JME3: New function - public void getCameraLocation(com.jme3.math.Vector3f dst) - { - lastCameraMatrix.getTranslation(internalCameraPos); - dst.set(internalCameraPos.x, internalCameraPos.y, internalCameraPos.z); - } - -// JME3: New function - public void getCameraRotation(com.jme3.math.Quaternion dst) - { - lastCameraMatrix.getNormalizedRotation(internalCameraRot); - dst.set(internalCameraRot.x, internalCameraRot.y, internalCameraRot.z, internalCameraRot.w); - } - -// JME3: New function to init xr system - public void initXr() { - try { - createXrInstance(); - initXrSystem(); - initVk(); - createXrVkSession(); - initXrActions(); - createRenderResources(); //TODO: Render rootNode instead creating default resources - } catch (RuntimeException ex) { - System.err.println("OpenXR testing failed:"); - ex.printStackTrace(); - } - } - - private void start() { - try { - createXrInstance(); - initXrSystem(); - initVk(); - createXrVkSession(); - initXrActions(); - createRenderResources(); - loopXrSession(); - } catch (RuntimeException ex) { - System.err.println("OpenXR testing failed:"); - ex.printStackTrace(); - } - - // Always clean up - destroySwapchains(); - destroyXrVkSession(); - destroyVk(); - destroyXrInstance(); - } - - private void createXrInstance() { - try (MemoryStack stack = stackPush()) { - boolean hasCoreValidationLayer = false; - - IntBuffer pi = stack.callocInt(1); - xrCheck(xrEnumerateApiLayerProperties(pi, null), "EnumerateApiLayerProperties"); - int numLayers = pi.get(0); - - XrApiLayerProperties.Buffer pLayers = XrHelper.prepareApiLayerProperties(stack, numLayers); - xrCheck(xrEnumerateApiLayerProperties(pi, pLayers), "EnumerateApiLayerProperties"); - System.out.println(numLayers + " XR layers are available:"); - for (int index = 0; index < numLayers; index++) { - XrApiLayerProperties layer = pLayers.get(index); - - String layerName = layer.layerNameString(); - System.out.println(layerName); - if (layerName.equals("XR_APILAYER_LUNARG_core_validation")) { - hasCoreValidationLayer = true; - } - } - System.out.println("-----------"); - - xrCheck(xrEnumerateInstanceExtensionProperties((ByteBuffer)null, pi, null), "EnumerateInstanceExtensionProperties"); - int numExtensions = pi.get(0); - - XrExtensionProperties.Buffer properties = XrHelper.prepareExtensionProperties(stack, numExtensions); - xrCheck(xrEnumerateInstanceExtensionProperties((ByteBuffer)null, pi, properties), "EnumerateInstanceExtensionProperties"); - - System.out.printf("OpenXR loaded with %d extensions:%n", numExtensions); - System.out.println("~~~~~~~~~~~~~~~~~~"); - - missingXrDebug = true; - boolean missingVulkan = true; - - PointerBuffer extensions = stack.mallocPointer(numExtensions); - for (int i = 0; i < numExtensions; i++) { - XrExtensionProperties prop = properties.get(i); - extensions.put(i, prop.extensionName()); - - String extensionName = prop.extensionNameString(); - System.out.println(extensionName); - if (extensionName.equals(KHRVulkanEnable.XR_KHR_VULKAN_ENABLE_EXTENSION_NAME)) { - missingVulkan = false; - } - if (extensionName.equals("XR_EXT_debug_utils")) { - missingXrDebug = false; - } - } - System.out.println("~~~~~~~~~~~~~~~~~~"); - - if (missingVulkan) { - throw new IllegalStateException("OpenXR library does not provide required extension: " + KHRVulkanEnable.XR_KHR_VULKAN_ENABLE_EXTENSION_NAME); - } - - PointerBuffer wantedExtensions; - if (missingXrDebug) { - wantedExtensions = stack.callocPointer(1); - } else { - wantedExtensions = stack.callocPointer(2); - wantedExtensions.put(1, stack.UTF8("XR_EXT_debug_utils")); - System.out.println("Enabling XR debug utils"); - } - wantedExtensions.put(0, stack.UTF8(XR_KHR_VULKAN_ENABLE_EXTENSION_NAME)); - - PointerBuffer wantedLayers; - if (hasCoreValidationLayer) { - wantedLayers = stack.callocPointer(1); - wantedLayers.put(0, stack.UTF8("XR_APILAYER_LUNARG_core_validation")); - System.out.println("Enabling XR core validation"); - } else { - wantedLayers = null; - } - - XrInstanceCreateInfo createInfo = XrInstanceCreateInfo.malloc(stack) - .type$Default() - .next(NULL) - .createFlags(0) - .applicationInfo(XrApplicationInfo.malloc(stack) - .applicationName(stack.UTF8("DummyXRVK")) - .apiVersion(XR_CURRENT_API_VERSION)) - .enabledApiLayerNames(wantedLayers) - .enabledExtensionNames(wantedExtensions); - - System.out.println("Create instance..."); - PointerBuffer pp = stack.mallocPointer(1); - xrCheck(xrCreateInstance(createInfo, pp), "CreateInstance"); - xrInstance = new XrInstance(pp.get(0), createInfo); - System.out.println("Created instance"); - } - } - - private void initXrSystem() { - try (MemoryStack stack = stackPush()) { - XrSystemGetInfo giSystem = XrSystemGetInfo.calloc(stack) - .type$Default() - .formFactor(XR_FORM_FACTOR_HEAD_MOUNTED_DISPLAY); - - LongBuffer pl = stack.callocLong(1); - System.out.println("xrInstance is " + xrInstance + " and giSystem is " + giSystem); - xrCheck(xrGetSystem(xrInstance, giSystem, pl), "GetSystem"); - xrSystemId = pl.get(0); - - System.out.println("System ID is " + xrSystemId); - } - } - - private void initXrActions() { - try (MemoryStack stack = stackPush()) { - PointerBuffer pp = stack.mallocPointer(1); - LongBuffer lp = stack.mallocLong(1); - - xrCheck(xrCreateActionSet( - xrInstance, - XrActionSetCreateInfo.calloc(stack) - .type$Default() - .priority(1) - .actionSetName(stack.UTF8("handcontrols")) - .localizedActionSetName(stack.UTF8("Demo Hand Controls")), - pp - ), "CreateActionSet"); - this.xrActionSet = new XrActionSet(pp.get(0), xrInstance); - - xrCheck(xrStringToPath(xrInstance, stack.UTF8("/user/hand/left"), lp), "StringToPath"); - this.xrPathLeftHand = lp.get(0); - - xrCheck(xrStringToPath(xrInstance, stack.UTF8("/user/hand/right"), lp), "StringToPath"); - this.xrPathRightHand = lp.get(0); - - xrCheck(xrCreateAction( - xrActionSet, - XrActionCreateInfo.calloc(stack) - .type$Default() - .actionType(XR_ACTION_TYPE_POSE_INPUT) - .actionName(stack.UTF8("handpose")) - .localizedActionName(stack.UTF8("Hand pose")) - .subactionPaths(stack.longs(xrPathLeftHand, xrPathRightHand)), - pp), "CreateAction"); - this.xrHandPoseAction = new XrAction(pp.get(0), xrActionSet); - - xrCheck(xrCreateAction( - xrActionSet, - XrActionCreateInfo.calloc(stack) - .type$Default() - .actionType(XR_ACTION_TYPE_BOOLEAN_INPUT) - .actionName(stack.UTF8("invert_colors")) - .localizedActionName(stack.UTF8("Invert colors")) - .subactionPaths(stack.longs(xrPathLeftHand, xrPathRightHand)), - pp - ), "CreateAction"); - this.xrHandClickAction = new XrAction(pp.get(0), xrActionSet); - - xrCheck(xrStringToPath(xrInstance, stack.UTF8("/interaction_profiles/khr/simple_controller"), lp), "StringToPath"); - long interactionProfile = lp.get(0); - - XrActionSuggestedBinding.Buffer suggestedBindings = XrActionSuggestedBinding.calloc(4, stack); - - xrCheck(xrStringToPath(xrInstance, stack.UTF8("/user/hand/left/input/grip/pose"), lp), "StringToPath"); - suggestedBindings.get(0) - .action(xrHandPoseAction) - .binding(lp.get(0)); - - xrCheck(xrStringToPath(xrInstance, stack.UTF8("/user/hand/right/input/grip/pose"), lp), "StringToPath"); - suggestedBindings.get(1) - .action(xrHandPoseAction) - .binding(lp.get(0)); - - xrCheck(xrStringToPath(xrInstance, stack.UTF8("/user/hand/left/input/select/click"), lp), "StringToPath"); - suggestedBindings.get(2) - .action(xrHandClickAction) - .binding(lp.get(0)); - - xrCheck(xrStringToPath(xrInstance, stack.UTF8("/user/hand/right/input/select/click"), lp), "StringToPath"); - suggestedBindings.get(3) - .action(xrHandClickAction) - .binding(lp.get(0)); - - xrCheck(xrSuggestInteractionProfileBindings( - xrInstance, - XrInteractionProfileSuggestedBinding.calloc(stack) - .type$Default() - .interactionProfile(interactionProfile) - .suggestedBindings(suggestedBindings) - ), "SuggestInteractionProfileBindings"); - - xrCheck(xrCreateActionSpace( - xrVkSession, - XrActionSpaceCreateInfo.calloc(stack) - .type$Default() - .action(xrHandPoseAction) - .subactionPath(xrPathLeftHand) - .poseInActionSpace(identityPose(stack)), - pp - ), "CreateActionSpace"); - this.xrLeftHandSpace = new XrSpace(pp.get(0), xrVkSession); - - xrCheck(xrCreateActionSpace( - xrVkSession, - XrActionSpaceCreateInfo.calloc(stack) - .type$Default() - .action(xrHandPoseAction) - .subactionPath(xrPathRightHand) - .poseInActionSpace(identityPose(stack)), - pp - ), "CreateActionSpace"); - this.xrRightHandSpace = new XrSpace(pp.get(0), xrVkSession); - - xrCheck(xrAttachSessionActionSets( - xrVkSession, - XrSessionActionSetsAttachInfo.calloc(stack) - .type$Default() - .actionSets(stack.pointers(xrActionSet)) - ), "AttachSessionActionSets"); - } - } - - private void initVk() { - try (MemoryStack stack = stackPush()) { - PointerBuffer pp = stack.mallocPointer(1); - IntBuffer pi = stack.mallocInt(1); - LongBuffer pl = stack.mallocLong(1); - - XrGraphicsRequirementsVulkanKHR graphicsRequirements = XrGraphicsRequirementsVulkanKHR.calloc(stack) - .type$Default(); - - xrCheck(xrGetVulkanGraphicsRequirementsKHR(xrInstance, xrSystemId, graphicsRequirements), "GetVulkanGraphicsRequirements"); - - long minApiVersion = graphicsRequirements.minApiVersionSupported(); - long maxApiVersion = graphicsRequirements.maxApiVersionSupported(); - - long minVkMajor = XR_VERSION_MAJOR(minApiVersion); - long minVkMinor = XR_VERSION_MINOR(minApiVersion); - long minVkPatch = XR_VERSION_PATCH(minApiVersion); - - System.out.println("Minimum Vulkan API version: " + minVkMajor + "." + minVkMinor + "." + minVkPatch); - System.out.println("Maximum Vulkan API version: " + XR_VERSION_MAJOR(maxApiVersion) + "." + XR_VERSION_MINOR(maxApiVersion) + "." + XR_VERSION_PATCH(maxApiVersion)); - - VkInstanceCreateInfo ciInstance = VkInstanceCreateInfo.calloc(stack) - .sType$Default() - .pApplicationInfo(VkApplicationInfo.calloc(stack) - .sType$Default() - .pApplicationName(stack.UTF8("DummyXRVK")) - .applicationVersion(VK_MAKE_VERSION(0, 1, 0)) - .apiVersion(VK_MAKE_VERSION((int)minVkMajor, (int)minVkMinor, (int)minVkPatch))); - - xrCheck(xrGetVulkanInstanceExtensionsKHR(xrInstance, xrSystemId, pi, null), "GetVulkanInstanceExtensions"); - - ByteBuffer pXrVkInstanceExtensions = stack.calloc(pi.get(0)); - xrCheck(xrGetVulkanInstanceExtensionsKHR(xrInstance, xrSystemId, pi, pXrVkInstanceExtensions), "GetVulkanInstanceExtensions"); - - // NOTE: The call to memAddress is important because LWJGL doesn't expect byte buffers to end with the null char - String[] requiredInstanceExtensionsArray = memUTF8(memAddress(pXrVkInstanceExtensions)).split(" "); - Set requiredInstanceExtensions = new HashSet<>(requiredInstanceExtensionsArray.length); - Collections.addAll(requiredInstanceExtensions, requiredInstanceExtensionsArray); - - vkCheck(vkEnumerateInstanceExtensionProperties((ByteBuffer)null, pi, null), "EnumerateInstanceExtensionProperties"); - int numExtensions = pi.get(0); - - VkExtensionProperties.Buffer pExtensionProps = VkExtensionProperties.calloc(numExtensions, stack); - vkCheck(vkEnumerateInstanceExtensionProperties((ByteBuffer)null, pi, pExtensionProps), "EnumerateInstanceExtensionProperties"); - - Set availableInstanceExtensions = new HashSet<>(numExtensions); - for (int index = 0; index < numExtensions; index++) { - availableInstanceExtensions.add(pExtensionProps.get(index).extensionNameString()); - } - - boolean hasExtDebugUtils = availableInstanceExtensions.contains(VK_EXT_DEBUG_UTILS_EXTENSION_NAME); - System.out.println("Available Vulkan instance extensions:"); - for (String extension : availableInstanceExtensions) { - System.out.println(extension); - } - System.out.println("-----------"); - - Set chosenInstanceExtensions = new HashSet<>(requiredInstanceExtensions.size() + 1); - if (hasExtDebugUtils) { - chosenInstanceExtensions.add(VK_EXT_DEBUG_UTILS_EXTENSION_NAME); - } - System.out.println(requiredInstanceExtensions.size() + " Vulkan instance extensions are required for OpenXR:"); - for (String extension : requiredInstanceExtensions) { - if (availableInstanceExtensions.contains(extension)) { - System.out.println(extension); - chosenInstanceExtensions.add(extension); - } else { - // This can happen if the OpenXR runtime is being stupid - System.out.println(extension + " [NOT SUPPORTED]"); - } - } - System.out.println("--------------"); - - PointerBuffer ppExtensionNames = stack.callocPointer(chosenInstanceExtensions.size()); - - int instanceExtensionIndex = 0; - for (String extension : chosenInstanceExtensions) { - ppExtensionNames.put(instanceExtensionIndex, stack.UTF8(extension)); - instanceExtensionIndex++; - } - ciInstance.ppEnabledExtensionNames(ppExtensionNames); - - vkCheck(vkEnumerateInstanceLayerProperties(pi, null), "EnumerateInstanceLayerProperties"); - int propertyCount = pi.get(0); - - VkLayerProperties.Buffer layerProps = VkLayerProperties.calloc(propertyCount, stack); - vkCheck(vkEnumerateInstanceLayerProperties(pi, layerProps), "EnumerateInstanceLayerProperties"); - - boolean hasValidationLayer = false; - System.out.println("Available vulkan layers:"); - for (int index = 0; index < propertyCount; index++) { - VkLayerProperties layerProp = layerProps.get(index); - - String layerName = layerProp.layerNameString(); - System.out.println(layerName); - if (layerName.equals(VK_LAYER_LUNARG_STANDARD_VALIDATION)) { - hasValidationLayer = true; - } - } - System.out.println("-------------"); - - if (hasValidationLayer) { - System.out.println("Enabling vulkan validation layer"); - PointerBuffer ppLayers = stack.callocPointer(1); - ppLayers.put(0, stack.UTF8(VK_LAYER_LUNARG_STANDARD_VALIDATION)); - ciInstance.ppEnabledLayerNames(ppLayers); - } else { - System.out.println("Vulkan validation layer is not available"); - } - - vkCheck(vkCreateInstance(ciInstance, null, pp), "CreateInstance"); - vkInstance = new VkInstance(pp.get(0), ciInstance); - - if (hasExtDebugUtils) { - VkDebugUtilsMessengerCreateInfoEXT ciDebugUtils = VkDebugUtilsMessengerCreateInfoEXT.calloc(stack) - .sType$Default() - .messageSeverity( - VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT | - VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT - ) - .messageType( - VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT | - VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT | - VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT - ) - .pfnUserCallback((messageSeverity, messageTypes, pCallbackData, userData) -> { - VkDebugUtilsMessengerCallbackDataEXT callbackData = VkDebugUtilsMessengerCallbackDataEXT.create(pCallbackData); - System.out.println("DebugUtils: " + callbackData.pMessageString()); - return 0; - }); - - vkCheck(vkCreateDebugUtilsMessengerEXT(vkInstance, ciDebugUtils, null, pl), "CreateDebugUtilsMessenger"); - vkDebugMessenger = pl.get(0); - } - - xrCheck(xrGetVulkanGraphicsDeviceKHR(xrInstance, xrSystemId, vkInstance, pp), "GetVulkanGraphicsDevice"); - vkPhysicalDevice = new VkPhysicalDevice(pp.get(0), vkInstance); - - xrCheck(xrGetVulkanDeviceExtensionsKHR(xrInstance, xrSystemId, pi, null), "GetVulkanDeviceExtensions"); - ByteBuffer pXrDeviceExtensions = stack.calloc(pi.get(0)); - - xrCheck(xrGetVulkanDeviceExtensionsKHR(xrInstance, xrSystemId, pi, pXrDeviceExtensions), "GetVulkanDeviceExtensions"); - // NOTE: The memAddress call is important because LWJGL doesn't expect byte buffers to contain the 0 char - String[] requiredDeviceExtensions = memUTF8(memAddress(pXrDeviceExtensions)).split(" "); - - vkCheck(vkEnumerateDeviceExtensionProperties(vkPhysicalDevice, (ByteBuffer)null, pi, null), "EnumerateDeviceExtensionProperties"); - int numDeviceExtensions = pi.get(0); - - VkExtensionProperties.Buffer pAvailableDeviceExtensions = VkExtensionProperties.calloc(numDeviceExtensions, stack); - vkCheck(vkEnumerateDeviceExtensionProperties(vkPhysicalDevice, (ByteBuffer)null, pi, pAvailableDeviceExtensions), "enumerateDeviceExtensionProperties"); - - // Collect the available extensions in a set for easier lookup - Set availableDeviceExtensions = new HashSet<>(numDeviceExtensions); - for (int index = 0; index < numDeviceExtensions; index++) { - availableDeviceExtensions.add(pAvailableDeviceExtensions.get(index).extensionNameString()); - } - - Set chosenDeviceExtensions = new HashSet<>(requiredDeviceExtensions.length); - - // Enumerate available device extensions - System.out.println(requiredDeviceExtensions.length + " Vulkan device extensions are required for OpenXR:"); - for (String extension : requiredDeviceExtensions) { - if (availableDeviceExtensions.contains(extension)) { - System.out.println(extension); - chosenDeviceExtensions.add(extension); - } else { - // The SteamVR OpenXR runtime sometimes requires extensions that are not supported... - System.out.println(extension + " [NOT SUPPORTED]"); - } - } - System.out.println("-------------"); - - VkPhysicalDeviceProperties pPhysicalProperties = VkPhysicalDeviceProperties.calloc(stack); - vkGetPhysicalDeviceProperties(vkPhysicalDevice, pPhysicalProperties); - System.out.println("The OpenXR runtime chose physical device " + pPhysicalProperties.deviceNameString()); - - vkGetPhysicalDeviceQueueFamilyProperties(vkPhysicalDevice, pi, null); - int queueFamilyCount = pi.get(0); - - VkQueueFamilyProperties.Buffer pQueueFamilies = VkQueueFamilyProperties.calloc(queueFamilyCount, stack); - vkGetPhysicalDeviceQueueFamilyProperties(vkPhysicalDevice, pi, pQueueFamilies); - System.out.println("Found " + queueFamilyCount + " queue families"); - - int suitableQueueFamilyIndex = -1; - for (int index = 0; index < queueFamilyCount; index++) { - VkQueueFamilyProperties familyProps = pQueueFamilies.get(index); - - int flags = familyProps.queueFlags(); - if ((flags & VK_QUEUE_GRAPHICS_BIT) != 0) { - suitableQueueFamilyIndex = index; - } - } - - if (suitableQueueFamilyIndex == -1) { - throw new RuntimeException("No queue family with graphics support was found"); - } - - vkQueueFamilyIndex = suitableQueueFamilyIndex; - // We only use 1 queue - vkQueueIndex = 0; - - VkDeviceQueueCreateInfo.Buffer cipDeviceQueue = VkDeviceQueueCreateInfo.calloc(1, stack); - cipDeviceQueue.get(0) - .sType$Default() - .queueFamilyIndex(suitableQueueFamilyIndex) - .pQueuePriorities(stack.floats(1.0f)); - - VkDeviceCreateInfo ciDevice = VkDeviceCreateInfo.calloc(stack) - .sType$Default() - .pQueueCreateInfos(cipDeviceQueue); - - PointerBuffer ppDeviceExtensions = stack.callocPointer(chosenDeviceExtensions.size()); - - int deviceExtensionIndex = 0; - for (String extension : chosenDeviceExtensions) { - ppDeviceExtensions.put(deviceExtensionIndex, stack.UTF8(extension)); - deviceExtensionIndex++; - } - ciDevice.ppEnabledExtensionNames(ppDeviceExtensions); - - vkCheck(vkCreateDevice(vkPhysicalDevice, ciDevice, null, pp), "CreateDevice"); - this.vkDevice = new VkDevice(pp.get(0), vkPhysicalDevice, ciDevice); - - vkGetDeviceQueue(vkDevice, vkQueueFamilyIndex, vkQueueIndex, pp); - this.vkQueue = new VkQueue(pp.get(0), vkDevice); - } - } - - private void destroyVk() { - if (this.vkRenderPass != 0) { - vkDestroyRenderPass(vkDevice, vkRenderPass, null); - } - - if (vkPipelineLayout != 0) { - vkDestroyPipelineLayout(vkDevice, vkPipelineLayout, null); - } - - if (vkGraphicsPipelines != null) { - for (int pipelineIndex = 0; pipelineIndex < vkGraphicsPipelines.length; pipelineIndex++) { - long graphicsPipeline = vkGraphicsPipelines[pipelineIndex]; - if (graphicsPipeline != 0 && (pipelineIndex == 0 || graphicsPipeline != vkGraphicsPipelines[pipelineIndex - 1])) { - vkDestroyPipeline(vkDevice, graphicsPipeline, null); - } - } - } - - if (vkCommandPoolCopying != 0) { - vkDestroyCommandPool(vkDevice, vkCommandPoolCopying, null); - } - if (vkCommandPoolDrawing != 0) { - vkDestroyCommandPool(vkDevice, vkCommandPoolDrawing, null); - } - - if (vkBigBuffer != 0) { - vkDestroyBuffer(vkDevice, vkBigBuffer, null); - } - if (vkDeviceMemory != 0) { - vkFreeMemory(vkDevice, vkDeviceMemory, null); - } - - if (vkDevice != null) { - vkDestroyDevice(vkDevice, null); - } - - if (vkDebugMessenger != 0L) { - vkDestroyDebugUtilsMessengerEXT(vkInstance, vkDebugMessenger, null); - } - if (vkInstance != null) { - vkDestroyInstance(vkInstance, null); - } - } - - private void createXrVkSession() { - try (MemoryStack stack = stackPush()) { - PointerBuffer pp = stack.callocPointer(1); - - xrCheck(xrCreateSession( - xrInstance, - XrSessionCreateInfo.calloc(stack) - .type$Default() - .systemId(xrSystemId) - .next(XrGraphicsBindingVulkanKHR.calloc(stack) - .type$Default() - .instance(vkInstance) - .physicalDevice(vkPhysicalDevice) - .device(vkDevice) - .queueFamilyIndex(vkQueueFamilyIndex) - .queueIndex(vkQueueIndex)), - pp - ), "CreateSession"); - xrVkSession = new XrSession(pp.get(0), xrInstance); - xrSessionState = XR_SESSION_STATE_IDLE; - System.out.println("Session is " + xrVkSession); - - if (!missingXrDebug) { - XrDebugUtilsMessengerCreateInfoEXT ciDebugUtils = XrDebugUtilsMessengerCreateInfoEXT.calloc(stack) - .type$Default() - .messageSeverities( - XR_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT | - XR_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT | - XR_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT - ) - .messageTypes( - XR_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT | - XR_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT | - XR_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT | - XR_DEBUG_UTILS_MESSAGE_TYPE_CONFORMANCE_BIT_EXT - ) - .userCallback((messageSeverity, messageTypes, pCallbackData, userData) -> { - XrDebugUtilsMessengerCallbackDataEXT callbackData = XrDebugUtilsMessengerCallbackDataEXT.create(pCallbackData); - System.out.println("XR Debug Utils: " + callbackData.messageString()); - return 0; - }); - - System.out.println("Enabling OpenXR debug utils"); - xrCheck(xrCreateDebugUtilsMessengerEXT(xrInstance, ciDebugUtils, pp), "CreateDebugUtilsMessenger"); - xrDebugMessenger = new XrDebugUtilsMessengerEXT(pp.get(0), xrInstance); - } - } - } - - private static XrPosef identityPose(MemoryStack stack) { - return XrPosef.calloc(stack) - .orientation(XrQuaternionf.calloc(stack) - .w(1.0f)) - .position$(XrVector3f.calloc(stack)); - } - - private void createRenderResources() { - chooseSwapchainFormats(); - createRenderPass(); - createCommandPools(); - createSwapchains(); - createGraphicsPipelines(); - createRenderSpace(); - createBuffers(); - } - - private int chooseMemoryTypeIndex(VkMemoryRequirements requirements, int requiredPropertyBits, MemoryStack stack) { - VkPhysicalDeviceMemoryProperties memoryProps = VkPhysicalDeviceMemoryProperties.calloc(stack); - vkGetPhysicalDeviceMemoryProperties(vkPhysicalDevice, memoryProps); - - for (int memoryTypeIndex = 0; memoryTypeIndex < memoryProps.memoryTypeCount(); memoryTypeIndex++) { - boolean allowedByResource = (requirements.memoryTypeBits() & (1 << memoryTypeIndex)) != 0; - boolean hasNeededProperties = (memoryProps.memoryTypes(memoryTypeIndex).propertyFlags() & requiredPropertyBits) == requiredPropertyBits; - - if (allowedByResource && hasNeededProperties) { - return memoryTypeIndex; - } - } - - throw new IllegalArgumentException("Failed to find suitable memory type for resource"); - } - - private static final float[][] QUAD_OFFSETS = { - {-1, -1, 0}, {1, -1, 0}, {1, 1, 0}, {-1, 1, 0} - }; - - private static class CubePlane { - - final float constantX, constantY, constantZ; - final float factorX, factorY, factorZ; - final int offsetX, offsetY, offsetZ; - final int colorIndex; - - CubePlane( - float constantX, float constantY, float constantZ, - float factorX, float factorY, float factorZ, - int offsetX, int offsetY, int offsetZ, int colorIndex - ) { - this.constantX = constantX; - this.constantY = constantY; - this.constantZ = constantZ; - - this.factorX = factorX; - this.factorY = factorY; - this.factorZ = factorZ; - - this.offsetX = offsetX; - this.offsetY = offsetY; - this.offsetZ = offsetZ; - - this.colorIndex = colorIndex; - } - } - - private static final CubePlane[] CUBE_PLANES = { - // Bottom - new CubePlane( - 0, -1, 0, 1, 0, 1, - 0, 2, 1, 0 - ), - // Top - new CubePlane( - 0, 1, 0, 1, 0, -1, - 0, 2, 1, 1 - ), - // Left - new CubePlane( - -1, 0, 0, 0, 1, 1, - 2, 1, 0, 2 - ), - // Right - new CubePlane( - 1, 0, 0, 0, 1, -1, - 2, 1, 0, 3 - ), - // Front - new CubePlane( - 0, 0, -1, -1, 1, 0, - 0, 1, 2, 4 - ), - // Back - new CubePlane( - 0, 0, 1, 1, 1, 0, - 0, 1, 2, 5 - ) - }; - -// JME3: TODO, replace this function - private static void putVertexData(ByteBuffer dest) { - Random random = new Random(87234); - for (int cubeIndex = 0; cubeIndex < BigModel.NUM_CUBES; cubeIndex++) { - float midX = 60f * random.nextFloat() - 30f; - float midY = 60f * random.nextFloat() - 30f; - float midZ = 60f * random.nextFloat() - 30f; - - // Each side has its own color - float[] red = new float[6]; - float[] green = new float[6]; - float[] blue = new float[6]; - - for (int side = 0; side < 6; side++) { - red[side] = random.nextFloat(); - green[side] = random.nextFloat(); - blue[side] = random.nextFloat(); - } - - float size = 1.5f; - - for (CubePlane plane : CUBE_PLANES) { - for (float[] offsets : QUAD_OFFSETS) { - float cornerX = midX + size * (plane.constantX + offsets[plane.offsetX] * plane.factorX); - float cornerY = midY + size * (plane.constantY + offsets[plane.offsetY] * plane.factorY); - float cornerZ = midZ + size * (plane.constantZ + offsets[plane.offsetZ] * plane.factorZ); - dest.putFloat(cornerX); - dest.putFloat(cornerY); - dest.putFloat(cornerZ); - dest.putFloat(red[plane.colorIndex]); - dest.putFloat(green[plane.colorIndex]); - dest.putFloat(blue[plane.colorIndex]); - } - } - } - - // 1 more cube for the small model - float size = 0.15f; - for (CubePlane plane : CUBE_PLANES) { - for (float[] offsets : QUAD_OFFSETS) { - float cornerX = size * (plane.constantX + offsets[plane.offsetX] * plane.factorX); - float cornerY = size * (plane.constantY + offsets[plane.offsetY] * plane.factorY); - float cornerZ = size * (plane.constantZ + offsets[plane.offsetZ] * plane.factorZ); - dest.putFloat(cornerX); - dest.putFloat(cornerY); - dest.putFloat(cornerZ); - dest.putFloat(max(0f, abs(plane.constantX))); - dest.putFloat(max(0f, abs(plane.constantY))); - dest.putFloat(max(0f, abs(plane.constantZ))); - } - } - } - -// JME3: TODO, replace this function - private static void putIndexData(ByteBuffer dest) { - int vertexIndex = 0; - - for (int cubeCounter = 0; cubeCounter < BigModel.NUM_CUBES; cubeCounter++) { - for (int quadCounter = 0; quadCounter < 6; quadCounter++) { - - int[] indexOffsets = {0, 1, 2, 2, 3, 0}; - for (int indexOffset : indexOffsets) { - if (INDEX_SIZE == 4) { - dest.putInt(vertexIndex + indexOffset); - } else if (INDEX_SIZE == 2) { - dest.putShort((short)(vertexIndex + indexOffset)); - } else { - throw new Error("Unexpected index size: " + INDEX_SIZE); - } - } - - vertexIndex += 4; - } - } - } - - private void createBuffers() { - try (MemoryStack stack = stackPush()) { - PointerBuffer pp = stack.callocPointer(1); - LongBuffer pl = stack.callocLong(1); - - int bigVertexSize = BigModel.NUM_VERTICES * VERTEX_SIZE; - int bigIndexSize = BigModel.NUM_INDICES * INDEX_SIZE; - - // The small model only needs 1 cube - int smallVertexSize = 6 * 4 * VERTEX_SIZE; - // We can just reuse the indices of the big model because the ones for the small model should be a substring of it - - int totalVertexSize = bigVertexSize + smallVertexSize; - - long sharedBuffer = createBuffer(totalVertexSize + bigIndexSize, VK_BUFFER_USAGE_TRANSFER_SRC_BIT); - - VkMemoryRequirements sharedMemRequirements = VkMemoryRequirements.calloc(stack); - vkGetBufferMemoryRequirements(vkDevice, sharedBuffer, sharedMemRequirements); - - vkCheck(vkAllocateMemory( - vkDevice, - VkMemoryAllocateInfo.calloc(stack) - .sType$Default() - .allocationSize(sharedMemRequirements.size()) - .memoryTypeIndex(chooseMemoryTypeIndex(sharedMemRequirements, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, stack)), - null, - pl - ), "AllocateMemory"); - long sharedMemory = pl.get(0); - - vkCheck(vkMapMemory(vkDevice, sharedMemory, 0, VK_WHOLE_SIZE, 0, pp), "MapMemory"); - ByteBuffer sharedData = memByteBuffer(pp.get(0), totalVertexSize + bigIndexSize); - - sharedData.position(0); - sharedData.limit(totalVertexSize); - putVertexData(sharedData); - - sharedData.position(totalVertexSize); - sharedData.limit(totalVertexSize + bigIndexSize); - putIndexData(sharedData); - - sharedData.position(0); - sharedData.limit(sharedData.capacity()); - - vkCheck(vkFlushMappedMemoryRanges( - vkDevice, - VkMappedMemoryRange.calloc(stack) - .sType$Default() - .memory(sharedMemory) - .offset(0) - .size(VK_WHOLE_SIZE) - ), "FlushMappedMemoryRanges"); - vkUnmapMemory(vkDevice, sharedMemory); - vkCheck(vkBindBufferMemory(vkDevice, sharedBuffer, sharedMemory, 0), "BindBufferMemory"); - - this.vkBigBuffer = createBuffer( - totalVertexSize + bigIndexSize, - VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | VK_BUFFER_USAGE_INDEX_BUFFER_BIT - ); - - VkMemoryRequirements deviceMemRequirements = VkMemoryRequirements.calloc(stack); - vkGetBufferMemoryRequirements(vkDevice, vkBigBuffer, deviceMemRequirements); - - vkCheck(vkAllocateMemory( - vkDevice, - VkMemoryAllocateInfo.calloc(stack) - .sType$Default() - .allocationSize(deviceMemRequirements.size()) - .memoryTypeIndex(chooseMemoryTypeIndex(deviceMemRequirements, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, stack)), - null, - pl - ), "AllocateMemory"); - this.vkDeviceMemory = pl.get(0); - - vkCheck(vkBindBufferMemory(vkDevice, vkBigBuffer, vkDeviceMemory, 0), "BindBufferMemory"); - - vkCheck(vkAllocateCommandBuffers( - vkDevice, - VkCommandBufferAllocateInfo.calloc(stack) - .sType$Default() - .commandPool(vkCommandPoolCopying) - .level(VK_COMMAND_BUFFER_LEVEL_PRIMARY) - .commandBufferCount(1), - pp - ), "AllocateCommandBuffers"); - VkCommandBuffer copyCommandBuffer = new VkCommandBuffer(pp.get(0), vkDevice); - - vkCheck(vkBeginCommandBuffer( - copyCommandBuffer, - VkCommandBufferBeginInfo.calloc(stack) - .sType$Default() - .flags(VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT) - ), "BeginCommandBuffer"); - - VkBufferCopy.Buffer copyRegions = VkBufferCopy.calloc(1, stack); - copyRegions.get(0) - .srcOffset(0) - .dstOffset(0) - .size(totalVertexSize + bigIndexSize); - - vkCmdCopyBuffer(copyCommandBuffer, sharedBuffer, vkBigBuffer, copyRegions); - vkEndCommandBuffer(copyCommandBuffer); - - vkCheck(vkCreateFence( - vkDevice, - VkFenceCreateInfo.calloc(stack) - .sType$Default() - .flags(0), - null, - pl - ), "CreateFence"); - long fence = pl.get(0); - - vkCheck(vkQueueSubmit( - vkQueue, - VkSubmitInfo.calloc(stack) - .sType$Default() - .waitSemaphoreCount(0) // I'm not sure why I need to set this explicitly - .pWaitSemaphores(null) - .pSignalSemaphores(null) - .pWaitDstStageMask(null) - .pCommandBuffers(stack.pointers(copyCommandBuffer)), - fence - ), "QueueSubmit"); - vkCheck(vkWaitForFences(vkDevice, pl, true, 1_000_000_000L), "WaitForFences"); - vkCheck(vkQueueWaitIdle(vkQueue), "QueueWaitIdle"); - - vkFreeMemory(vkDevice, sharedMemory, null); - vkDestroyBuffer(vkDevice, sharedBuffer, null); - vkFreeCommandBuffers(vkDevice, vkCommandPoolCopying, copyCommandBuffer); - vkDestroyFence(vkDevice, fence, null); - } - } - - private long createBuffer(long size, int usage) { - try (MemoryStack stack = stackPush()) { - LongBuffer pl = stack.callocLong(1); - vkCreateBuffer( - vkDevice, - VkBufferCreateInfo.calloc(stack) - .sType$Default() - .flags(0) - .size(size) - .usage(usage) - .sharingMode(VK_SHARING_MODE_EXCLUSIVE), - null, - pl); - return pl.get(0); - } - } - - private void createRenderSpace() { - try (MemoryStack stack = stackPush()) { - PointerBuffer pp = stack.callocPointer(1); - xrCheck(xrCreateReferenceSpace( - xrVkSession, - XrReferenceSpaceCreateInfo.calloc(stack) - .type$Default() - .referenceSpaceType(XR_REFERENCE_SPACE_TYPE_LOCAL) - .poseInReferenceSpace(identityPose(stack)), - pp - ), "CreateReferenceSpace"); - renderSpace = new XrSpace(pp.get(0), xrVkSession); - } - } - - private void createRenderPass() { - try (MemoryStack stack = stackPush()) { - VkAttachmentDescription.Buffer attachments = VkAttachmentDescription.calloc(2, stack); - - attachments.get(0) - .flags(0) - .format(swapchainColorFormat) - // TODO SAMPLES - .samples(VK_SAMPLE_COUNT_1_BIT) - .loadOp(VK_ATTACHMENT_LOAD_OP_CLEAR) - .storeOp(VK_ATTACHMENT_STORE_OP_STORE) - .stencilLoadOp(VK_ATTACHMENT_LOAD_OP_DONT_CARE) - .stencilStoreOp(VK_ATTACHMENT_STORE_OP_DONT_CARE) - .initialLayout(VK_IMAGE_LAYOUT_UNDEFINED) - .finalLayout(VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); - - attachments.get(1) - .flags(0) - .format(swapchainDepthFormat) - // TODO SAMPLES - .samples(VK_SAMPLE_COUNT_1_BIT) - .loadOp(VK_ATTACHMENT_LOAD_OP_CLEAR) - .storeOp(VK_ATTACHMENT_STORE_OP_DONT_CARE) - .stencilLoadOp(VK_ATTACHMENT_LOAD_OP_DONT_CARE) - .stencilStoreOp(VK_ATTACHMENT_STORE_OP_DONT_CARE) - .initialLayout(VK_IMAGE_LAYOUT_UNDEFINED) - .finalLayout(VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL); - - VkAttachmentReference.Buffer colorAttachmentRefs = VkAttachmentReference.calloc(1, stack); - colorAttachmentRefs.get(0) - .attachment(0) - .layout(VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); - - // Ensure that the render pass doesn't begin too early - VkSubpassDependency.Buffer dependencies = VkSubpassDependency.calloc(1, stack); - dependencies.get(0) - .srcSubpass(VK_SUBPASS_EXTERNAL) - .dstSubpass(0) - .srcStageMask(VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT) - .srcAccessMask(0) - .dstStageMask(VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT) - .dstAccessMask(VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT); - - VkSubpassDescription.Buffer subpasses = VkSubpassDescription.calloc(1, stack); - subpasses.get(0) - .flags(0) - .pipelineBindPoint(VK_PIPELINE_BIND_POINT_GRAPHICS) - // For some reason, I have to specify the colorAttachmentCount explicitly - .colorAttachmentCount(1) - .pColorAttachments(colorAttachmentRefs) - .pDepthStencilAttachment(VkAttachmentReference.calloc(stack) - .attachment(1) - .layout(VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL)); - - LongBuffer pl = stack.callocLong(1); - vkCheck(vkCreateRenderPass( - vkDevice, - VkRenderPassCreateInfo.calloc(stack) - .sType$Default() - .flags(0) - .pAttachments(attachments) - .pSubpasses(subpasses) - .pDependencies(dependencies), - null, - pl - ), "CreateRenderPass"); - this.vkRenderPass = pl.get(0); - } - } - - private void createGraphicsPipelines() { - try (MemoryStack stack = stackPush()) { - VkPushConstantRange.Buffer pushConstants = VkPushConstantRange.calloc(1, stack); - pushConstants.get(0) - .stageFlags(VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT) - .offset(0) - // 1 matrix of 4x4 floats (4 bytes per float) - // and 1 boolean that needs 4 bytes - .size(4 * 4 * 4 + 4); - - LongBuffer pl = stack.callocLong(1); - vkCheck(vkCreatePipelineLayout( - vkDevice, - VkPipelineLayoutCreateInfo.calloc(stack) - .sType$Default() - .flags(0) - // I will add uniform variables or push constants later - .pSetLayouts(null) - .pPushConstantRanges(pushConstants), - null, - pl - ), "CreatePipelineLayout"); - this.vkPipelineLayout = pl.get(0); - } - - long vertexModule, fragmentModule; - try (MemoryStack stack = stackPush()) { - LongBuffer pl = stack.callocLong(1); - - ByteBuffer vertexBytes = getShaderResource("demo/openxr/vulkan/hello.vert.spv"); - vkCheck(vkCreateShaderModule( - vkDevice, - VkShaderModuleCreateInfo.calloc(stack) - .sType$Default() - .pCode(vertexBytes), - null, - pl - ), "CreateShaderModule (vertex)"); - vertexModule = pl.get(0); - - ByteBuffer fragmentBytes = getShaderResource("demo/openxr/vulkan/hello.frag.spv"); - vkCheck(vkCreateShaderModule( - vkDevice, - VkShaderModuleCreateInfo.calloc(stack) - .sType$Default() - .pCode(fragmentBytes), - null, - pl - ), "CreateShaderModule (fragment)"); - fragmentModule = pl.get(0); - } - - this.vkGraphicsPipelines = new long[this.swapchains.length]; - - for (int swapchainIndex = 0; swapchainIndex < this.swapchains.length; swapchainIndex++) { - if ( - swapchainIndex == 0 || this.swapchains[swapchainIndex - 1].width != this.swapchains[swapchainIndex].width - || this.swapchains[swapchainIndex - 1].height != this.swapchains[swapchainIndex].height - ) { - createGraphicsPipeline(swapchainIndex, vertexModule, fragmentModule); - } else { - // If the swapchain has the same size as the previous swapchain (expected case), share the graphics pipeline - this.vkGraphicsPipelines[swapchainIndex] = this.vkGraphicsPipelines[swapchainIndex - 1]; - } - } - - vkDestroyShaderModule(vkDevice, vertexModule, null); - vkDestroyShaderModule(vkDevice, fragmentModule, null); - } - - private void createGraphicsPipeline(int swapchainIndex, long vertexModule, long fragmentModule) { - try (MemoryStack stack = stackPush()) { - VkPipelineShaderStageCreateInfo.Buffer ciPipelineShaderStages = VkPipelineShaderStageCreateInfo.calloc(2, stack); - ciPipelineShaderStages.get(0) - .sType$Default() - .flags(0) - .stage(VK_SHADER_STAGE_VERTEX_BIT) - .module(vertexModule) - .pName(stack.UTF8("main")); - - ciPipelineShaderStages.get(1) - .sType$Default() - .flags(0) - .stage(VK_SHADER_STAGE_FRAGMENT_BIT) - .module(fragmentModule) - .pName(stack.UTF8("main")); - - VkVertexInputBindingDescription.Buffer vertexBindingDescriptions = VkVertexInputBindingDescription.calloc(1, stack); - vertexBindingDescriptions.get(0) - .binding(0) - .stride(VERTEX_SIZE) - .inputRate(VK_VERTEX_INPUT_RATE_VERTEX); - - VkVertexInputAttributeDescription.Buffer vertexAttributeDescriptions = VkVertexInputAttributeDescription.calloc(2, stack); - vertexAttributeDescriptions.get(0) - .location(VERTEX_LOCATION_POSITION) - .binding(0) - .format(VK_FORMAT_R32G32B32_SFLOAT) - .offset(VERTEX_OFFSET_POSITION); - - vertexAttributeDescriptions.get(1) - .location(VERTEX_LOCATION_COLOR) - .binding(0) - .format(VK_FORMAT_R32G32B32_SFLOAT) - .offset(VERTEX_OFFSET_COLOR); - - VkViewport.Buffer viewports = VkViewport.calloc(1, stack); - viewports.get(0) - .x(0f) - .y(0f) - .width(this.swapchains[swapchainIndex].width) - .height(this.swapchains[swapchainIndex].height) - .minDepth(0f) - .maxDepth(1f); - - VkRect2D.Buffer scissors = VkRect2D.calloc(1, stack); - scissors.get(0) - .offset(VkOffset2D.calloc(stack)) // By using calloc, the offset will have a default value of 0, which is desired - .extent(VkExtent2D.calloc(stack).set( - this.swapchains[swapchainIndex].width, - this.swapchains[swapchainIndex].height - )); - - VkPipelineColorBlendAttachmentState.Buffer atsColorBlend = VkPipelineColorBlendAttachmentState.calloc(1, stack); - // We only have 1 color attachment, so we only use 1 color blend attachment state - atsColorBlend.get(0) - .blendEnable(false) // We won't be doing any fancy blending - .colorWriteMask(VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT); - - VkGraphicsPipelineCreateInfo.Buffer ciGraphicsPipelines = VkGraphicsPipelineCreateInfo.calloc(1, stack); - - // In this example, I will use only 1 graphics pipeline - ciGraphicsPipelines.get(0) - .sType$Default() - .flags(0) - .renderPass(this.vkRenderPass) - .subpass(0) - .layout(this.vkPipelineLayout) - .basePipelineHandle(VK_NULL_HANDLE) // No pipeline derivatives in this example - .basePipelineIndex(-1) - .pStages(ciPipelineShaderStages) - .pVertexInputState(VkPipelineVertexInputStateCreateInfo.calloc(stack) - .sType$Default() - .flags(0) - .pVertexBindingDescriptions(vertexBindingDescriptions) - .pVertexAttributeDescriptions(vertexAttributeDescriptions)) - .pInputAssemblyState(VkPipelineInputAssemblyStateCreateInfo.calloc(stack) - .sType$Default() - .flags(0) - .topology(VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST) - .primitiveRestartEnable(false)) - // This example won't use a tessellation shader - .pTessellationState(null) - .pViewportState(VkPipelineViewportStateCreateInfo.calloc(stack) - .sType$Default() - .flags(0) - .pViewports(viewports) - .pScissors(scissors)) - .pRasterizationState(VkPipelineRasterizationStateCreateInfo.calloc(stack) - .sType$Default() - .flags(0) - .depthClampEnable(false) - .rasterizerDiscardEnable(false) - .polygonMode(VK_POLYGON_MODE_FILL) - .lineWidth(1f) - .cullMode(VK_CULL_MODE_BACK_BIT) - .frontFace(VK_FRONT_FACE_COUNTER_CLOCKWISE) - .depthBiasEnable(false)) - .pMultisampleState(VkPipelineMultisampleStateCreateInfo.calloc(stack) - .sType$Default() - .flags(0) - // TODO SAMPLES - .rasterizationSamples(VK_SAMPLE_COUNT_1_BIT) - .sampleShadingEnable(false) - // I won't ignore a part of the samples - .pSampleMask(null) - // I won't use transparency in this example - .alphaToCoverageEnable(false) - .alphaToOneEnable(false)) - .pDepthStencilState(VkPipelineDepthStencilStateCreateInfo.calloc(stack) - .sType$Default() - .flags(0) - .depthTestEnable(true) - .depthWriteEnable(true) - .depthCompareOp(VK_COMPARE_OP_LESS) - .depthBoundsTestEnable(false) - .stencilTestEnable(false)) - .pColorBlendState(VkPipelineColorBlendStateCreateInfo.calloc(stack) - .sType$Default() - .flags(0) - .logicOpEnable(false) - .pAttachments(atsColorBlend)) - .pDynamicState(null); // No dynamic state will be needed - - LongBuffer pl = stack.callocLong(1); - vkCheck(vkCreateGraphicsPipelines(vkDevice, VK_NULL_HANDLE, ciGraphicsPipelines, null, pl), "CreateGraphicsPipelines"); - this.vkGraphicsPipelines[swapchainIndex] = pl.get(0); - } - } - - private void createCommandPools() { - try (MemoryStack stack = stackPush()) { - LongBuffer pl = stack.callocLong(1); - - // The copy command pool is for 1-time-use copy commands - vkCheck(vkCreateCommandPool( - vkDevice, - VkCommandPoolCreateInfo.calloc(stack) - .sType$Default() - .flags(VK_COMMAND_POOL_CREATE_TRANSIENT_BIT) - .queueFamilyIndex(vkQueueFamilyIndex), - null, - pl - ), "CreateCommandPool"); - this.vkCommandPoolCopying = pl.get(0); - - // The drawing command buffers will be allocated once and recorded many times - vkCheck(vkCreateCommandPool( - vkDevice, - VkCommandPoolCreateInfo.calloc(stack) - .sType$Default() - .flags(VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT) - .queueFamilyIndex(vkQueueFamilyIndex), - null, - pl - ), "CreateCommandPool"); - this.vkCommandPoolDrawing = pl.get(0); - } - } - - private void chooseSwapchainFormats() { - try (MemoryStack stack = stackPush()) { - IntBuffer pi = stack.callocInt(1); - xrCheck(xrEnumerateSwapchainFormats(xrVkSession, pi, null), "EnumerateSwapchainFormats"); - int numFormats = pi.get(0); - - LongBuffer formats = stack.callocLong(numFormats); - xrCheck(xrEnumerateSwapchainFormats(xrVkSession, pi, formats), "EnumerateSwapchainFormats"); - - // SRGB formats are preferred due to the human perception of colors - // Non-alpha formats are preferred because I don't intend to use it and it would spare memory - int[] preferredColorFormats = { - VK_FORMAT_R8G8B8_SRGB, VK_FORMAT_B8G8R8_SRGB, - VK_FORMAT_R8G8B8A8_SRGB, VK_FORMAT_B8G8R8A8_SRGB, - VK_FORMAT_R8G8B8_UNORM, VK_FORMAT_B8G8R8_UNORM, - VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_B8G8R8A8_UNORM - }; - boolean[] hasPreferredColorFormats = new boolean[preferredColorFormats.length]; - - // NVidia recommends avoiding 32 bits for the depth component because it slows down depth testing. - // (For graphics cards, comparisons with 24 bit floating point numbers is easier than with 32.) - // We don't use the stencil test, so we prefer a format without one. - int[] preferredDepthFormats = { - VK_FORMAT_X8_D24_UNORM_PACK32, - VK_FORMAT_D24_UNORM_S8_UINT, - VK_FORMAT_D32_SFLOAT, - VK_FORMAT_D32_SFLOAT_S8_UINT - }; - boolean[] hasPrefferedDepthFormats = new boolean[preferredDepthFormats.length]; - - System.out.println("There are " + numFormats + " swapchain formats:"); - for (int index = 0; index < numFormats; index++) { - long format = formats.get(index); - - String formatName = findConstantMeaning(VK10.class, name -> name.startsWith("VK_FORMAT_"), format); - if (formatName == null) { - formatName = "unknown"; - } - System.out.println(formatName + " (" + format + ")"); - - for (int prefIndex = 0; prefIndex < preferredColorFormats.length; prefIndex++) { - if (format == preferredColorFormats[prefIndex]) { - hasPreferredColorFormats[prefIndex] = true; - } - } - - for (int prefIndex = 0; prefIndex < preferredDepthFormats.length; prefIndex++) { - if (format == preferredDepthFormats[prefIndex]) { - hasPrefferedDepthFormats[prefIndex] = true; - } - } - } - System.out.println("--------------"); - - swapchainColorFormat = -1; - swapchainDepthFormat = -1; - - // Pick the best formats available - for (int prefIndex = 0; prefIndex < preferredColorFormats.length; prefIndex++) { - if (hasPreferredColorFormats[prefIndex]) { - swapchainColorFormat = preferredColorFormats[prefIndex]; - break; - } - } - - for (int prefIndex = 0; prefIndex < preferredDepthFormats.length; prefIndex++) { - if (hasPrefferedDepthFormats[prefIndex]) { - swapchainDepthFormat = preferredDepthFormats[prefIndex]; - break; - } - } - - if (swapchainColorFormat == -1) { - // Damn... what kind of graphics card/xr runtime is this? - // Well... if we can't find any format we like, we will just pick the first one - swapchainColorFormat = (int)formats.get(0); - } - if (swapchainDepthFormat == -1) { - // Let's hope it will never come to this... - swapchainDepthFormat = (int)formats.get(0); - } - - System.out.println("Chose swapchain formats " + swapchainColorFormat + " and " + swapchainDepthFormat); - } - } - - private void createSwapchains() { - try (MemoryStack stack = stackPush()) { - IntBuffer pi = stack.callocInt(1); - LongBuffer pl = stack.callocLong(1); - - xrCheck(xrEnumerateViewConfigurations(xrInstance, xrSystemId, pi, null), "EnumerateViewConfigurations"); - int numViewConfigurations = pi.get(0); - - System.out.println("There are " + numViewConfigurations + " view configurations:"); - IntBuffer viewConfigurations = stack.callocInt(numViewConfigurations); - xrCheck(xrEnumerateViewConfigurations(xrInstance, xrSystemId, pi, viewConfigurations), "EnumerateViewConfigurations"); - - boolean hasPrimarySterio = false; - for (int viewIndex = 0; viewIndex < numViewConfigurations; viewIndex++) { - int viewConfiguration = viewConfigurations.get(viewIndex); - System.out.println(findConstantMeaning(XR10.class, constantName -> constantName.startsWith("XR_VIEW_CONFIGURATION_TYPE_"), viewConfiguration) + " (" + viewConfiguration + ")"); - if (viewConfiguration == XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO) { - hasPrimarySterio = true; - } - } - System.out.println("~~~~~~~~~~"); - - // I prefer primary stereo. If that is not available, I will go for the first best alternative. - viewConfiguration = hasPrimarySterio - ? XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO - : viewConfigurations.get(0); - System.out.println("Chose " + viewConfiguration); - - xrCheck(xrEnumerateViewConfigurationViews(xrInstance, xrSystemId, viewConfiguration, pi, null), "EnumerateViewConfigurationViews"); - int numViews = pi.get(0); - - System.out.println("There are " + numViews + " views"); - XrViewConfigurationView.Buffer viewConfigurationViews = XrHelper.fill( - XrViewConfigurationView.calloc(numViews, stack), - XrViewConfigurationView.TYPE, - XR_TYPE_VIEW_CONFIGURATION_VIEW - ); - xrCheck(xrEnumerateViewConfigurationViews(xrInstance, xrSystemId, viewConfiguration, pi, viewConfigurationViews), "EnumerateViewConfigurationViews"); - -// JME3: Comment out vulkan code -/* - PointerBuffer pCommandBuffers = stack.callocPointer(2); - vkCheck(vkAllocateCommandBuffers( - vkDevice, - VkCommandBufferAllocateInfo.calloc(stack) - .sType$Default() - .commandPool(vkCommandPoolDrawing) - .level(VK_COMMAND_BUFFER_LEVEL_PRIMARY) - .commandBufferCount(numViews), - pCommandBuffers - ), "AllocateCommandBuffers"); -*/ - this.swapchains = new SwapchainWrapper[numViews]; - for (int swapchainIndex = 0; swapchainIndex < numViews; swapchainIndex++) { - XrViewConfigurationView viewConfig = viewConfigurationViews.get(swapchainIndex); - - XrSwapchainCreateInfo ciSwapchain = XrSwapchainCreateInfo.calloc(stack) - .type$Default() - .createFlags(0) - .usageFlags(XR_SWAPCHAIN_USAGE_COLOR_ATTACHMENT_BIT | XR_SWAPCHAIN_USAGE_SAMPLED_BIT) - .format(swapchainColorFormat) - .width(viewConfig.recommendedImageRectWidth()) - .height(viewConfig.recommendedImageRectHeight()) - .sampleCount(viewConfig.recommendedSwapchainSampleCount()) - .mipCount(1) - .arraySize(1) - .faceCount(1); - - System.out.println("Creating a swapchain of " + - ciSwapchain.width() + " x " + - ciSwapchain.height() + " with " + - ciSwapchain.sampleCount() + " samples"); - - PointerBuffer pp = stack.callocPointer(1); - xrCheck(xrCreateSwapchain(xrVkSession, ciSwapchain, pp), "CreateSwapchain"); - XrSwapchain swapchain = new XrSwapchain(pp.get(0), xrVkSession); - - xrCheck(xrEnumerateSwapchainImages(swapchain, pi, null), "EnumerateSwapchainImages"); - int numImages = pi.get(0); - - System.out.println("Swapchain " + swapchainIndex + " has " + numImages + " images"); - XrSwapchainImageVulkanKHR.Buffer swapchainColorImages = XrHelper.fill( - XrSwapchainImageVulkanKHR.calloc(numImages, stack), - XrSwapchainImageVulkanKHR.TYPE, - XR_TYPE_SWAPCHAIN_IMAGE_VULKAN_KHR - ); - - xrCheck(xrEnumerateSwapchainImages( - swapchain, pi, - XrSwapchainImageBaseHeader.create(swapchainColorImages) - ), "EnumerateSwapchainImages"); - -// JME3: Comment out vulkan code -/* - vkCheck(vkCreateImage( - vkDevice, - VkImageCreateInfo.calloc(stack) - .sType$Default() - .flags(0) - .imageType(VK_IMAGE_TYPE_2D) - .format(swapchainDepthFormat) - .extent(it -> it - .width(ciSwapchain.width()) - .height(ciSwapchain.height()) - .depth(1)) - .mipLevels(1) - .arrayLayers(1) - // TODO SAMPLES - .samples(VK_SAMPLE_COUNT_1_BIT) - .tiling(VK_IMAGE_TILING_OPTIMAL) - .usage(VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) - .sharingMode(VK_SHARING_MODE_EXCLUSIVE) - .initialLayout(VK_IMAGE_LAYOUT_UNDEFINED), - null, - pl - ), "CreateImage"); - long depthImage = pl.get(0); - - SwapchainImage[] swapchainImages = new SwapchainImage[numImages]; - - VkComponentMapping componentMapping = VkComponentMapping.calloc(stack) - .r(VK_COMPONENT_SWIZZLE_IDENTITY) - .g(VK_COMPONENT_SWIZZLE_IDENTITY) - .b(VK_COMPONENT_SWIZZLE_IDENTITY) - .a(VK_COMPONENT_SWIZZLE_IDENTITY); - - VkImageViewCreateInfo ciDepthImageView = VkImageViewCreateInfo.calloc(stack) - .sType$Default() - .flags(0) - .image(depthImage) - .viewType(VK_IMAGE_VIEW_TYPE_2D) - .format(swapchainDepthFormat) - .components(componentMapping) - .subresourceRange(VkImageSubresourceRange.calloc(stack) - .aspectMask(VK_IMAGE_ASPECT_DEPTH_BIT) - .baseMipLevel(0) - .levelCount(1) - .baseArrayLayer(0) - .layerCount(1)); - - VkMemoryRequirements pMemoryRequirements = VkMemoryRequirements.calloc(stack); - vkGetImageMemoryRequirements(vkDevice, depthImage, pMemoryRequirements); - - int memoryTypeIndex = chooseMemoryTypeIndex(pMemoryRequirements, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, stack); - - vkCheck(vkAllocateMemory( - vkDevice, - VkMemoryAllocateInfo.calloc(stack) - .sType$Default() - .allocationSize(pMemoryRequirements.size()) - .memoryTypeIndex(memoryTypeIndex), - null, - pl - ), "AllocateMemory"); - long depthImageMemory = pl.get(0); - - vkCheck(vkBindImageMemory(vkDevice, depthImage, depthImageMemory, 0), "BindImageMemory"); - vkCheck(vkCreateImageView(vkDevice, ciDepthImageView, null, pl), "CreateImageView"); - long depthImageView = pl.get(0); - - for (int imageIndex = 0; imageIndex < numImages; imageIndex++) { - long colorImage = swapchainColorImages.get(imageIndex).image(); - - vkCheck(vkCreateImageView( - vkDevice, - VkImageViewCreateInfo.calloc(stack) - .sType$Default() - .flags(0) - .image(colorImage) - .viewType(VK_IMAGE_VIEW_TYPE_2D) - .format(swapchainColorFormat) - .components(componentMapping) - .subresourceRange(VkImageSubresourceRange.calloc(stack) - .aspectMask(VK_IMAGE_ASPECT_COLOR_BIT) - .baseMipLevel(0) - .levelCount(1) - .baseArrayLayer(0) - .layerCount(1)), - null, - pl - ), "CreateImageView"); - long colorImageView = pl.get(0); - - vkCheck(vkCreateFramebuffer( - vkDevice, - VkFramebufferCreateInfo.calloc(stack) - .sType$Default() - .flags(0) - .renderPass(vkRenderPass) - .pAttachments(stack.longs(colorImageView, depthImageView)) - .width(ciSwapchain.width()) - .height(ciSwapchain.height()) - .layers(1), - null, - pl - ), "CreateFramebuffer"); - long framebuffer = pl.get(0); - - swapchainImages[imageIndex] = new SwapchainImage(colorImage, colorImageView, framebuffer); - } - - vkCheck(vkCreateFence( - vkDevice, - VkFenceCreateInfo.calloc(stack) - .sType$Default() - .flags(0), - null, - pl - ), "CreateFence"); - - this.swapchains[swapchainIndex] = new SwapchainWrapper( - new XrSwapchain(pp.get(0), xrVkSession), - ciSwapchain.width(), ciSwapchain.height(), ciSwapchain.sampleCount(), - depthImage, depthImageView, depthImageMemory, swapchainImages, - pl.get(0), new VkCommandBuffer(pCommandBuffers.get(swapchainIndex), vkDevice) - ); -*/ - } - } - } - - private XrCompositionLayerProjectionView.Buffer createProjectionViews(MemoryStack stack, long displayTime) { - IntBuffer pi = stack.ints(swapchains.length); - - XrViewState viewState = XrViewState.calloc(stack) - .type$Default(); - - XrView.Buffer views = XrHelper.fill( - XrView.calloc(swapchains.length, stack), - XrView.TYPE, - XR_TYPE_VIEW - ); - - xrCheck(xrLocateViews( - xrVkSession, - XrViewLocateInfo.calloc(stack) - .type$Default() - .viewConfigurationType(viewConfiguration) - .displayTime(displayTime) - .space(renderSpace), - viewState, - pi, - views - ), "LocateViews"); - - long viewFlags = viewState.viewStateFlags(); - if ((viewFlags & XR_VIEW_STATE_POSITION_VALID_BIT) == 0) { - System.out.println("View position invalid; abort rendering this frame"); - return null; - } - if ((viewFlags & XR_VIEW_STATE_ORIENTATION_VALID_BIT) == 0) { - System.out.println("View orientation invalid; abort rendering this frame"); - return null; - } - - XrCompositionLayerProjectionView.Buffer projectionViews = XrCompositionLayerProjectionView.calloc(swapchains.length, stack); - for (int viewIndex = 0; viewIndex < swapchains.length; viewIndex++) { - SwapchainWrapper swapchain = swapchains[viewIndex]; - - XrView currentView = views.get(viewIndex); - - projectionViews.get(viewIndex) - .type$Default() - .pose(currentView.pose()) - .fov(currentView.fov()) - .subImage(XrSwapchainSubImage.calloc(stack) - .swapchain(swapchain.swapchain) - .imageRect(XrRect2Di.calloc(stack) - .offset(it -> it - .x(0) - .y(0)) - .extent(it -> it - .width(swapchain.width) - .height(swapchain.height))) - .imageArrayIndex(0)); - } - - return projectionViews; - } - - private void updateSessionState(MemoryStack stack) { - // Use malloc instead of calloc because this will be called frequently - XrEventDataBuffer pollEventData = XrEventDataBuffer.malloc(stack); - - while (true) { - pollEventData - .type$Default() - .next(NULL); - - int pollResult = xrPollEvent(xrInstance, pollEventData); - xrCheck(pollResult, "PollEvent"); - if (pollResult != XR_EVENT_UNAVAILABLE) { - if (pollEventData.type() == XR_TYPE_EVENT_DATA_SESSION_STATE_CHANGED) { - XrEventDataSessionStateChanged sessionEvent = XrEventDataSessionStateChanged.create(pollEventData.address()); - xrSessionState = sessionEvent.state(); - System.out.println("Changed session state to " + xrSessionState); - } else { - System.out.println("Received another event"); - } - } else { - break; - } - } - } - - private static class HandStates { - final Vector3f leftPosition, rightPosition; - final Quaternionf leftRotation, rightRotation; - - HandStates(Vector3f leftPosition, Vector3f rightPosition, Quaternionf leftRotation, Quaternionf rightRotation) { - this.leftPosition = leftPosition; - this.rightPosition = rightPosition; - this.leftRotation = leftRotation; - this.rightRotation = rightRotation; - } - } - - private HandStates getHandStates(MemoryStack stack, long time) { - XrActiveActionSet.Buffer activeActionSets = XrActiveActionSet.calloc(1, stack); - activeActionSets.get(0) - .actionSet(xrActionSet) - .subactionPath(XR_NULL_PATH); - - xrCheck(xrSyncActions( - xrVkSession, - XrActionsSyncInfo.calloc(stack) - .type$Default() - .activeActionSets(activeActionSets) - ), "SyncActions"); - - XrSpaceLocation leftHandLocation = XrSpaceLocation.calloc(stack) - .type$Default(); - - XrSpaceLocation rightHandLocation = XrSpaceLocation.calloc(stack) - .type$Default(); - - xrCheck(xrLocateSpace(xrLeftHandSpace, renderSpace, time, leftHandLocation), "LocateSpace"); - xrCheck(xrLocateSpace(xrRightHandSpace, renderSpace, time, rightHandLocation), "LocateSpace"); - - Vector3f leftHandPosition = null; - Vector3f rightHandPosition = null; - - if ((leftHandLocation.locationFlags() & XR_SPACE_LOCATION_POSITION_VALID_BIT) != 0) { - XrVector3f pos = leftHandLocation.pose().position$(); - leftHandPosition = new Vector3f(pos.x(), pos.y(), pos.z()); - } -// else -// { -// XrVector3f pos = leftHandLocation.pose().position$(); -// if (pos == null) -// { -// System.out.println("com.starcom.lwjglvr.Main.getHandStates() errPos-L: null"); -// } -// else -// { -// System.out.println("com.starcom.lwjglvr.Main.getHandStates() errPos-L: BIT=" + leftHandLocation.locationFlags()); -// System.out.println("com.starcom.lwjglvr.Main.getHandStates() errPos-L: x=" + pos.x() + " y=" + pos.y() + " z=" + pos.z()); -// } -// } - if ((rightHandLocation.locationFlags() & XR_SPACE_LOCATION_POSITION_VALID_BIT) != 0) { - XrVector3f pos = rightHandLocation.pose().position$(); - rightHandPosition = new Vector3f(pos.x(), pos.y(), pos.z()); - } - - Quaternionf leftHandRotation = null; - Quaternionf rightHandRotation = null; - - if ((leftHandLocation.locationFlags() & XR_SPACE_LOCATION_ORIENTATION_VALID_BIT) != 0) { - XrQuaternionf rot = leftHandLocation.pose().orientation(); - leftHandRotation = new Quaternionf(rot.x(), rot.y(), rot.z(), rot.w()); - } - - if ((rightHandLocation.locationFlags() & XR_SPACE_LOCATION_ORIENTATION_VALID_BIT) != 0) { - XrQuaternionf rot = rightHandLocation.pose().orientation(); - rightHandRotation = new Quaternionf(rot.x(), rot.y(), rot.z(), rot.w()); - } - - //System.out.println("com.starcom.lwjglvr.Main.getHandStates() L: " + leftHandPosition.toString()); - return new HandStates(leftHandPosition, rightHandPosition, leftHandRotation, rightHandRotation); - } - - public boolean loopXrSession() { // JME3: As public function and returns bool for continue next loop - // This is a safety check for debugging. Set to 0 to disable this. - long endTime = System.currentTimeMillis() + (10_000 * 10); - -// boolean startedSession = false; // JME3: Commented out, use as member var - -// while (true) { // JME3: Commented out - try (MemoryStack stack = stackPush()) { - updateSessionState(stack); - - if (xrSessionState == XR_SESSION_STATE_IDLE) { - try { - System.out.println("Session is idle"); - Thread.sleep(500); - } catch (InterruptedException e) { - throw new RuntimeException("Shouldn't happen", e); - } - return true; // JME3: Return instead continue loop - } - - boolean timeoutStop = endTime != 0 && System.currentTimeMillis() > endTime; - if (timeoutStop && startedSession) { - xrCheck(xrRequestExitSession(xrVkSession), "RequestExitSession"); - startedSession = false; - } - - if (xrSessionState == XR_SESSION_STATE_STOPPING) { - xrEndSession(xrVkSession); - } - if ( - xrSessionState == XR_SESSION_STATE_LOSS_PENDING || xrSessionState == XR_SESSION_STATE_EXITING || - xrSessionState == XR_SESSION_STATE_STOPPING - ) { - return false; // JME3: Return instead continue loop - } - - if (timeoutStop) { - return true; // JME3: Return instead continue loop - } - - if (xrSessionState == XR_SESSION_STATE_READY && !startedSession) { - System.out.println("Begin session"); - xrCheck(xrBeginSession( - xrVkSession, - XrSessionBeginInfo.calloc(stack) - .type$Default() - .primaryViewConfigurationType(viewConfiguration) - ), "BeginSession"); - startedSession = true; - } - - updateSessionState(stack); - - if ( - xrSessionState == XR_SESSION_STATE_SYNCHRONIZED || xrSessionState == XR_SESSION_STATE_VISIBLE || - xrSessionState == XR_SESSION_STATE_FOCUSED || xrSessionState == XR_SESSION_STATE_READY - ) { - XrFrameState frameState = XrFrameState.calloc(stack) - .type$Default(); - - xrCheck(xrWaitFrame(xrVkSession, null, frameState), "WaitFrame"); - xrCheck(xrBeginFrame(xrVkSession, null), "BeginFrame"); - - PointerBuffer layers = null; - if (frameState.shouldRender()) { - XrCompositionLayerProjection layer = XrCompositionLayerProjection.calloc(stack) - .type$Default() - .layerFlags(0) // If we were to use alpha, we should set the alpha layer flag - .space(renderSpace); - - XrCompositionLayerProjectionView.Buffer projectionViews = createProjectionViews(stack, frameState.predictedDisplayTime()); - if (projectionViews != null) { - layer.views(projectionViews); - layers = stack.pointers(layer); - } - - HandStates handStates = getHandStates(stack, frameState.predictedDisplayTime()); - - Matrix4f leftHandMatrix = null; - if (handStates.leftPosition != null) { - leftHandMatrix = new Matrix4f().translate(handStates.leftPosition); - - if (handStates.leftRotation != null) { - leftHandMatrix.rotate(handStates.leftRotation); - } - } - - Matrix4f rightHandMatrix = null; - if (handStates.rightPosition != null) { - rightHandMatrix = new Matrix4f().translate(handStates.rightPosition); - - if (handStates.rightRotation != null) { - rightHandMatrix.rotate(handStates.rightRotation); - } - } - - for (int swapchainIndex = 0; swapchainIndex < swapchains.length; swapchainIndex++) { - SwapchainWrapper swapchain = this.swapchains[swapchainIndex]; - - IntBuffer pi = stack.callocInt(1); - xrCheck(xrAcquireSwapchainImage(swapchain.swapchain, null, pi), "AcquireSwapchainImage"); - int imageIndex = pi.get(0); - - Matrix4f cameraMatrix; - if (projectionViews != null) { - // If the position tracker is working, we should use it to create the camera matrix - XrCompositionLayerProjectionView projectionView = projectionViews.get(swapchainIndex); - - Matrix4f projectionMatrix = new Matrix4f().scale(1f, -1f, 1f); - XrHelper.applyProjectionToMatrix(projectionMatrix, projectionView.fov(), 0.01f, 100f, true); - - Matrix4f viewMatrix = new Matrix4f(); - - XrVector3f position = projectionView.pose().position$(); - XrQuaternionf orientation = projectionView.pose().orientation(); - - viewMatrix.translationRotateScaleInvert( - position.x(), position.y(), position.z(), - orientation.x(), orientation.y(), orientation.z(), orientation.w(), - 1, 1, 1 - ); - - cameraMatrix = projectionMatrix.mul(viewMatrix); - } else { - // When the position tracking is having issues, we will fall back to the previous one - cameraMatrix = lastCameraMatrix; - } - - lastCameraMatrix = cameraMatrix; - - xrCheck(xrWaitSwapchainImage( - swapchain.swapchain, - XrSwapchainImageWaitInfo.calloc(stack) - .type$Default() - .timeout(1_000_000_000) // Time out after 1 second. If we would have to wait so long, something is seriously wrong - ), "WaitSwapchainImage"); //TODO: DrawBegin - -// JME3: Comment out vulkan code -/* - vkCheck(vkBeginCommandBuffer( - swapchain.commandBuffer, - VkCommandBufferBeginInfo.calloc(stack) - .sType$Default() - .flags(VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT) - ), "BeginCommandBuffer"); - - VkClearValue.Buffer clearValues = VkClearValue.calloc(2, stack); - clearValues.get(0) - .color(VkClearColorValue.calloc(stack) - .float32(0, 0.1f) - .float32(1, 0.2f) - .float32(2, 0.92f) - .float32(3, 1f)); - clearValues.get(1) - .depthStencil(VkClearDepthStencilValue.calloc(stack) - .depth(1f)); - - VkRenderPassBeginInfo biRenderPass = VkRenderPassBeginInfo.calloc(stack) - .sType$Default() - .pNext(VK_NULL_HANDLE) - .renderPass(vkRenderPass) - .framebuffer(swapchain.images[imageIndex].framebuffer) // TODO: Does it happen here? - .renderArea(it -> it - .offset(offset -> offset - .x(0) - .y(0)) - .extent(extent -> extent - .width(swapchain.width) - .height(swapchain.height))) - .pClearValues(clearValues); - - int pushIndexInvertColor = 4 * 4 * 4; - - ByteBuffer pushConstants = stack.calloc(pushIndexInvertColor + 4); - cameraMatrix.get(pushConstants); - - int stageFlags = VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT; - vkCmdBeginRenderPass(swapchain.commandBuffer, biRenderPass, VK_SUBPASS_CONTENTS_INLINE); - vkCmdBindPipeline(swapchain.commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vkGraphicsPipelines[swapchainIndex]); - vkCmdPushConstants(swapchain.commandBuffer, vkPipelineLayout, stageFlags, 0, pushConstants); - vkCmdBindVertexBuffers(swapchain.commandBuffer, 0, stack.longs(vkBigBuffer), stack.longs(0)); - vkCmdBindIndexBuffer(swapchain.commandBuffer, vkBigBuffer, VERTEX_SIZE * (BigModel.NUM_VERTICES + 4 * 6), INDEX_TYPE); - - // Draw big model - vkCmdDrawIndexed(swapchain.commandBuffer, BigModel.NUM_INDICES, 1, 0, 0, 0); - - // Draw (small) hand models if hand locations are known - if (leftHandMatrix != null) { - XrActionStateBoolean actionState = XrActionStateBoolean.calloc(stack) - .type$Default(); - - xrCheck(xrGetActionStateBoolean( - xrVkSession, - XrActionStateGetInfo.calloc(stack) - .type$Default() - .action(xrHandClickAction) - .subactionPath(xrPathLeftHand), - actionState - ), "GetActionStateBoolean"); - - pushConstants.putInt(pushIndexInvertColor, actionState.currentState() ? 1 : 0); - cameraMatrix.mul(leftHandMatrix, new Matrix4f()).get(pushConstants); - vkCmdPushConstants(swapchain.commandBuffer, vkPipelineLayout, stageFlags, 0, pushConstants); - vkCmdDrawIndexed(swapchain.commandBuffer, 6 * 6, 1, 0, BigModel.NUM_VERTICES, 0); - } - - if (rightHandMatrix != null) { - XrActionStateBoolean actionState = XrActionStateBoolean.calloc(stack) - .type$Default(); - - xrCheck(xrGetActionStateBoolean( - xrVkSession, - XrActionStateGetInfo.calloc(stack) - .type$Default() - .action(xrHandClickAction) - .subactionPath(xrPathRightHand), - actionState - ), "GetActionStateBoolean"); - - pushConstants.putInt(pushIndexInvertColor, actionState.currentState() ? 1 : 0); - cameraMatrix.mul(rightHandMatrix, new Matrix4f()).get(pushConstants); - vkCmdPushConstants(swapchain.commandBuffer, vkPipelineLayout, VK_SHADER_STAGE_VERTEX_BIT, 0, pushConstants); - vkCmdDrawIndexed(swapchain.commandBuffer, 6 * 6, 1, 0, BigModel.NUM_VERTICES, 0); - } - - vkCmdEndRenderPass(swapchain.commandBuffer); - - vkCheck(vkEndCommandBuffer(swapchain.commandBuffer), "EndCommandBuffer"); - - vkCheck(vkQueueSubmit( - vkQueue, - VkSubmitInfo.calloc(stack) - .sType$Default() - .pCommandBuffers(stack.pointers(swapchain.commandBuffer)), - swapchain.fence - ), "QueueSubmit"); -*/ - } - - // Submit command buffers for both eyes before waiting for them to complete - for (SwapchainWrapper swapchain : swapchains) { - vkCheck(vkWaitForFences(vkDevice, swapchain.fence, true, 1_000_000_000), "WaitForFences"); - vkCheck(vkResetFences(vkDevice, swapchain.fence), "ResetFences"); - xrCheck(xrReleaseSwapchainImage(swapchain.swapchain, null), "ReleaseSwapchainImage"); //TODO: DrawEnd - } - } else { - System.out.println("Skip frame"); - } - - xrCheck(xrEndFrame( - xrVkSession, - XrFrameEndInfo.calloc(stack) - .type$Default() - .displayTime(frameState.predictedDisplayTime()) - .environmentBlendMode(XR_ENVIRONMENT_BLEND_MODE_OPAQUE) - .layers(layers) - ), "EndFrame"); - } - } -// } // JME3: Commented out - return true; - } - - private void destroySwapchains() { - if (swapchains != null) { - for (SwapchainWrapper swapchain : swapchains) { - if (swapchain != null) { - // In case we crashed during rendering, let's at least make sure that it is finished - vkWaitForFences(vkDevice, swapchain.fence, true, 100_000_000); - xrDestroySwapchain(swapchain.swapchain); - - for (SwapchainImage swapchainImage : swapchain.images) { - vkDestroyFramebuffer(vkDevice, swapchainImage.framebuffer, null); - vkDestroyImageView(vkDevice, swapchainImage.colorImageView, null); - // No need to destroy the colorImage because that happens implicitly upon destroying swapchain - } - - vkDestroyImageView(vkDevice, swapchain.depthImageView, null); - vkDestroyImage(vkDevice, swapchain.depthImage, null); - vkFreeMemory(vkDevice, swapchain.depthImageMemory, null); - vkDestroyFence(vkDevice, swapchain.fence, null); - vkFreeCommandBuffers(vkDevice, vkCommandPoolDrawing, swapchain.commandBuffer); - } - } - } - } - - private void destroyXrVkSession() { - if (xrHandPoseAction != null) { - xrDestroyAction(xrHandPoseAction); - } - if (xrHandClickAction != null) { - xrDestroyAction(xrHandClickAction); - } - if (xrActionSet != null) { - xrDestroyActionSet(xrActionSet); - } - if (xrLeftHandSpace != null) { - xrDestroySpace(xrLeftHandSpace); - } - if (xrRightHandSpace != null) { - xrDestroySpace(xrRightHandSpace); - } - if (renderSpace != null) { - xrDestroySpace(renderSpace); - } - if (xrVkSession != null) { - xrDestroySession(xrVkSession); - } - } - - private void destroyXrInstance() { - if (xrDebugMessenger != null) { - xrDestroyDebugUtilsMessengerEXT(xrDebugMessenger); - } - if (xrInstance != null) { - xrDestroyInstance(xrInstance); - } - } - - private static void xrCheck(int result, String functionName) { - if (result < XR_SUCCESS) { - String constantName = findConstantMeaning(XR10.class, candidateConstant -> candidateConstant.startsWith("XR_ERROR_"), result); - throw new RuntimeException("OpenXR function " + functionName + " returned " + result + " (" + constantName + ")"); - } - } - - private static void vkCheck(int result, String functionName) { - if (result < VK_SUCCESS) { - String constantName = findConstantMeaning(VK10.class, candidateConstant -> candidateConstant.startsWith("VK_ERROR_"), result); - throw new RuntimeException("Vulkan function " + functionName + " returned " + result + " (" + constantName + ")"); - } - } - - private static String findConstantMeaning(Class containingClass, Predicate constantFilter, Object constant) { - Field[] fields = containingClass.getFields(); - for (Field field : fields) { - if (Modifier.isStatic(field.getModifiers()) && constantFilter.test(field.getName())) { - try { - Object value = field.get(null); - if (value instanceof Number && constant instanceof Number) { - if (((Number)value).longValue() == ((Number)constant).longValue()) { - return field.getName(); - } - } - if (constant.equals(value)) { - return field.getName(); - } - } catch (IllegalAccessException ex) { - // Ignore private fields - } - } - } - - return null; - } - -} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/ShadersGL.java b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/ShadersGL.java new file mode 100644 index 0000000000..8bff141327 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/ShadersGL.java @@ -0,0 +1,132 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * Source: https://github.com/LWJGL/lwjgl3/tree/master/modules/samples/src/test/java/org/lwjgl/demo/openxr + */ +package com.jme3.input.vr.lwjgl_openxr; + +import org.lwjgl.system.*; + +import java.nio.*; + +import static org.lwjgl.opengl.GL11.*; +import static org.lwjgl.opengl.GL20.*; +import static org.lwjgl.system.MemoryStack.*; + +final class ShadersGL { + + static final String texVertShader = "#version 330 core\n" + + "layout (location = 0) in vec3 aPos;\n" + + "layout (location = 1) in vec2 aTexCoord;\n" + + "\n" + + "out vec2 TexCoord;\n" + + "\n" + + "uniform mat4 model;\n" + + "uniform mat4 view;\n" + + "uniform mat4 projection;\n" + + "\n" + + "void main()\n" + + "{\n" + + " gl_Position = projection * view * model * vec4(aPos, 1.0);\n" + + " TexCoord = vec2(aTexCoord.x, aTexCoord.y);\n" + + "}"; + + static final String screenVertShader = "#version 330 core\n" + + "layout (location = 0) in vec2 aPos;\n" + + "layout (location = 1) in vec2 aTexCoords;\n" + + "\n" + + "out vec2 TexCoords;\n" + + "\n" + + "void main()\n" + + "{\n" + + " TexCoords = aTexCoords;\n" + + " gl_Position = vec4(aPos.x, aPos.y, 0.0, 1.0); \n" + + "}"; + + static final String texFragShader = "#version 330 core\n" + + "out vec4 FragColor;\n" + + "\n" + + "in vec2 TexCoords;\n" + + "\n" + + "uniform sampler2D textureSampler;\n" + + "\n" + + "void main()\n" + + "{\n" + + " vec3 col = texture(textureSampler, TexCoords).rgb;\n" + + " FragColor = vec4(col, 1.0);\n" + + "}"; + + static final String colVertShader = "#version 330 core\n" + + "layout (location = 0) in vec3 aPos;\n" + + "layout (location = 1) in vec3 aColorIn;\n" + + "\n" + + "out vec3 Color;\n" + + "\n" + + "uniform mat4 model;\n" + + "uniform mat4 view;\n" + + "uniform mat4 projection;\n" + + "\n" + + "void main()\n" + + "{\n" + + " //gl_Position = transform * vec4(aPos, 1.0f);\n" + + " gl_Position = projection * view * model * vec4(aPos, 1.0);\n" + + " Color = aColorIn;\n" + + "}"; + + static final String colFragShader = "#version 330 core\n" + + "in vec3 Color;" + + "out vec4 FragColor;\n" + + "void main()\n" + + "{\n" + + " FragColor = vec4(Color, 1.0f);\n" + + "}"; + + + private ShadersGL() { + } + + static int createShaderProgram(String vertexShaderGlsl, String fragmentShaderGlsl) { + int vertexShader = glCreateShader(GL_VERTEX_SHADER); + glShaderSource(vertexShader, vertexShaderGlsl); + glCompileShader(vertexShader); + checkShader(vertexShader); + + int fragmentShader = glCreateShader(GL_FRAGMENT_SHADER); + glShaderSource(fragmentShader, fragmentShaderGlsl); + glCompileShader(fragmentShader); + checkShader(fragmentShader); + + int program = glCreateProgram(); + + glAttachShader(program, vertexShader); + glAttachShader(program, fragmentShader); + glLinkProgram(program); + checkProgram(program); + + glDeleteShader(vertexShader); + glDeleteShader(fragmentShader); + + return program; + } + + static void checkShader(int shader) { + try (MemoryStack stack = stackPush()) { + IntBuffer pi = stack.mallocInt(1); + glGetShaderiv(shader, GL_COMPILE_STATUS, pi); + if (pi.get(0) == GL_FALSE) { + throw new IllegalStateException("Compile shader failed: " + glGetShaderInfoLog(shader, 4096)); + } + } + } + + static void checkProgram(int program) { + try (MemoryStack stack = stackPush()) { + IntBuffer pi = stack.mallocInt(1); + glGetProgramiv(program, GL_LINK_STATUS, pi); + if (pi.get(0) == GL_FALSE) { + throw new IllegalStateException("Link program failed: " + glGetProgramInfoLog(program, 4096)); + } + } + } + +} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/XrHelper.java b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/XRHelper.java similarity index 96% rename from jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/XrHelper.java rename to jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/XRHelper.java index e4d7d800fe..dbcbeed37d 100644 --- a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/XrHelper.java +++ b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/XRHelper.java @@ -1,18 +1,13 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package com.jme3.input.vr.lwjgl_openxr; // JME3: Modified package path - /* * Copyright LWJGL. All rights reserved. * License terms: https://www.lwjgl.org/license + * Source: https://github.com/LWJGL/lwjgl3/tree/master/modules/samples/src/test/java/org/lwjgl/demo/openxr */ +package com.jme3.input.vr.lwjgl_openxr; import org.joml.Math; import org.joml.*; -//import org.lwjgl.egl.*; +import org.lwjgl.egl.*; import org.lwjgl.openxr.*; import org.lwjgl.system.*; import org.lwjgl.system.linux.*; @@ -34,9 +29,9 @@ * A helper class with some static methods to help applications with OpenXR related tasks that are cumbersome in * some way. */ -final class XrHelper { +final class XRHelper { - private XrHelper() { + private XRHelper() { } static > T fill(T buffer, int offset, int value) { @@ -153,7 +148,7 @@ static Matrix4f applyProjectionToMatrix(Matrix4f m, XrFovf fov, float nearZ, flo static XrSessionCreateInfo createGraphicsBindingOpenGL( XrSessionCreateInfo sessionCreateInfo, MemoryStack stack, long window, boolean useEGL ) throws IllegalStateException { - /*if (useEGL) { + if (useEGL) { System.out.println("Using XrGraphicsBindingEGLMNDX to create the session..."); return sessionCreateInfo.next( XrGraphicsBindingEGLMNDX.malloc(stack) @@ -164,7 +159,7 @@ static XrSessionCreateInfo createGraphicsBindingOpenGL( .config(glfwGetEGLConfig(window)) .context(glfwGetEGLContext(window)) ); - }*/ + } switch (Platform.get()) { case LINUX: int platform = glfwGetPlatform(); From 27d21bfd834df9f377c7346968f38d4c00749586 Mon Sep 17 00:00:00 2001 From: Starcommander Date: Thu, 23 Mar 2023 22:18:38 +0100 Subject: [PATCH 08/18] Update xr and code cleanup --- .../main/java/com/jme3/app/VREnvironment.java | 16 +-- .../input/vr/lwjgl_openvr/LWJGLOpenVR.java | 14 +- .../lwjgl_openvr/LWJGLOpenVRViewManager.java | 6 + .../input/vr/lwjgl_openxr/HelloOpenXRGL.java | 122 ++++++++++++------ 4 files changed, 94 insertions(+), 64 deletions(-) diff --git a/jme3-xr/src/main/java/com/jme3/app/VREnvironment.java b/jme3-xr/src/main/java/com/jme3/app/VREnvironment.java index 3f15d1fde9..16ea59b5bb 100644 --- a/jme3-xr/src/main/java/com/jme3/app/VREnvironment.java +++ b/jme3-xr/src/main/java/com/jme3/app/VREnvironment.java @@ -438,21 +438,7 @@ public boolean initialize(){ } if(vrSupportedOS) { - if( vrBinding == VRConstants.SETTING_VRAPI_OSVR_VALUE ) { - guiManager = new VRGuiManager(this); - mouseManager = new OpenVRMouseManager(this); - - hardware = new OSVR(this); - initialized = true; - logger.config("Creating OSVR wrapper [SUCCESS]"); - } else if( vrBinding == VRConstants.SETTING_VRAPI_OPENVR_VALUE ) { - guiManager = new VRGuiManager(this); - mouseManager = new OpenVRMouseManager(this); - - hardware = new OpenVR(this); - initialized = true; - logger.config("Creating OpenVR wrapper [SUCCESS]"); - } else if (vrBinding == VRConstants.SETTING_VRAPI_OPENVR_LWJGL_VALUE) { + if (vrBinding == VRConstants.SETTING_VRAPI_OPENVR_LWJGL_VALUE) { guiManager = new VRGuiManager(this); mouseManager = new LWJGLOpenVRMouseManager(this); diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVR.java b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVR.java index 8f85ad326b..c7703686ae 100644 --- a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVR.java +++ b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVR.java @@ -99,12 +99,13 @@ public boolean initialize() { logger.config("Initializing OpenVR system..."); com.jme3.input.vr.lwjgl_openxr.HelloOpenXRGL mainXr = new com.jme3.input.vr.lwjgl_openxr.HelloOpenXRGL(); - mainXr.initXr(); - vrInput = new LWJGLOpenVRInput(environment); - vrInput.init(); - vrInput.updateConnectedControllers(); - environment.setXR(mainXr); - initSuccess = mainXr.loopXrSession(); + vrInput = new LWJGLOpenVRInput(environment); + initSuccess = vrInput.init(); + if (initSuccess) + { + vrInput.updateConnectedControllers(); + environment.setXR(mainXr); + } return initSuccess; } @@ -174,7 +175,6 @@ public void getPositionAndOrientation(Vector3f storePos, Quaternion storeRot) { @Override public void updatePose(){ - environment.getXr().loopXrSession(); } @Override diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRViewManager.java b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRViewManager.java index ea93af654e..0e70669809 100644 --- a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRViewManager.java +++ b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRViewManager.java @@ -163,6 +163,12 @@ public void render() { @Override public void postRender() { + boolean cont = environment.getXr().renderFrame(); + if (!cont) + { + environment.getApplication().stop(); + environment.getXr().destroy(); + } // // if (environment != null) { // if (environment.isInVR()) { diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/HelloOpenXRGL.java b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/HelloOpenXRGL.java index 2211230ce3..cfd712d44a 100644 --- a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/HelloOpenXRGL.java +++ b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/HelloOpenXRGL.java @@ -69,65 +69,99 @@ static class Swapchain { XrSwapchainImageOpenGLKHR.Buffer images; } - public static void main(String[] args) throws InterruptedException { - HelloOpenXRGL helloOpenXR = new HelloOpenXRGL(); - - helloOpenXR.createOpenXRInstance(); - helloOpenXR.initializeOpenXRSystem(); - helloOpenXR.initializeAndBindOpenGL(); - helloOpenXR.createXRReferenceSpace(); - helloOpenXR.createXRSwapchains(); - helloOpenXR.createOpenGLResourses(); - - helloOpenXR.eventDataBuffer = XrEventDataBuffer.calloc() + //JME3: Split function main(args) to public functions init+render+destroy + public HelloOpenXRGL() + { + createOpenXRInstance(); + initializeOpenXRSystem(); + initializeAndBindOpenGL(); + createXRReferenceSpace(); + createXRSwapchains(); + createOpenGLResourses(); + + eventDataBuffer = XrEventDataBuffer.calloc() .type$Default(); - - while (!helloOpenXR.pollEvents() && !glfwWindowShouldClose(helloOpenXR.window)) { - if (helloOpenXR.sessionRunning) { - helloOpenXR.renderFrameOpenXR(); - } else { - // Throttle loop since xrWaitFrame won't be called. + } + + /** Returns true for continue */ + public boolean renderFrame() + { + if (pollEvents()) return false; + if (glfwWindowShouldClose(window)) return false; + if (sessionRunning) + { + try { + renderFrameOpenXR(); + } + catch (IllegalStateException e) + { + return false; + } + } + else + { + // Throttle loop since xrWaitFrame won't be called. + try + { Thread.sleep(250); } + catch (InterruptedException e) + { + e.printStackTrace(); + return false; + } } - - // Wait until idle - glFinish(); + return true; + } + + public void destroy() + { + glFinish(); // Destroy OpenXR - helloOpenXR.eventDataBuffer.free(); - helloOpenXR.views.free(); - helloOpenXR.viewConfigs.free(); - for (Swapchain swapchain : helloOpenXR.swapchains) { + eventDataBuffer.free(); + views.free(); + viewConfigs.free(); + for (Swapchain swapchain : swapchains) { xrDestroySwapchain(swapchain.handle); swapchain.images.free(); } - xrDestroySpace(helloOpenXR.xrAppSpace); - if (helloOpenXR.xrDebugMessenger != null) { - xrDestroyDebugUtilsMessengerEXT(helloOpenXR.xrDebugMessenger); + xrDestroySpace(xrAppSpace); + if (xrDebugMessenger != null) { + xrDestroyDebugUtilsMessengerEXT(xrDebugMessenger); } - xrDestroySession(helloOpenXR.xrSession); - xrDestroyInstance(helloOpenXR.xrInstance); + xrDestroySession(xrSession); + xrDestroyInstance(xrInstance); //Destroy OpenGL - for (int texture : helloOpenXR.depthTextures.values()) { + for (int texture : depthTextures.values()) { glDeleteTextures(texture); } - glDeleteFramebuffers(helloOpenXR.swapchainFramebuffer); - glDeleteBuffers(helloOpenXR.cubeVertexBuffer); - glDeleteBuffers(helloOpenXR.cubeIndexBuffer); - glDeleteBuffers(helloOpenXR.quadVertexBuffer); - glDeleteVertexArrays(helloOpenXR.cubeVAO); - glDeleteVertexArrays(helloOpenXR.quadVAO); - glDeleteProgram(helloOpenXR.screenShader); - glDeleteProgram(helloOpenXR.textureShader); - glDeleteProgram(helloOpenXR.colorShader); + glDeleteFramebuffers(swapchainFramebuffer); + glDeleteBuffers(cubeVertexBuffer); + glDeleteBuffers(cubeIndexBuffer); + glDeleteBuffers(quadVertexBuffer); + glDeleteVertexArrays(cubeVAO); + glDeleteVertexArrays(quadVAO); + glDeleteProgram(screenShader); + glDeleteProgram(textureShader); + glDeleteProgram(colorShader); glfwTerminate(); } + + //JME3: New public functions for positions/orientations + public void getViewPosition(com.jme3.math.Vector3f store) + { + store.set(viewPos); + } + public void getViewRotation(com.jme3.math.Quaternion store) + { + store.set(viewRot); + } - public void createOpenXRInstance() { + private void createOpenXRInstance() { try (MemoryStack stack = stackPush()) { IntBuffer pi = stack.mallocInt(1); @@ -158,7 +192,7 @@ public void createOpenXRInstance() { missingXrDebug = false; } if (extensionName.equals(XR_MNDX_EGL_ENABLE_EXTENSION_NAME)) { - useEglGraphicsBinding = true; + //useEglGraphicsBinding = true; //JME3: Do not use EGL } } @@ -790,6 +824,8 @@ private boolean renderLayerOpenXR(MemoryStack stack, long predictedDisplayTime, private static Matrix4f modelviewMatrix = new Matrix4f(); private static Matrix4f projectionMatrix = new Matrix4f(); private static Matrix4f viewMatrix = new Matrix4f(); + private static com.jme3.math.Vector3f viewPos = new com.jme3.math.Vector3f(); + private static com.jme3.math.Quaternion viewRot = new com.jme3.math.Quaternion(); private static FloatBuffer mvpMatrix = BufferUtils.createFloatBuffer(16); @@ -825,6 +861,8 @@ private void OpenGLRenderView(XrCompositionLayerProjectionView layerView, XrSwap orientation.x(), orientation.y(), orientation.z(), orientation.w(), 1, 1, 1 ); + viewPos.set(pos.x(), pos.y(), pos.z()); + viewRot.set(orientation.x(), orientation.y(), orientation.z(), orientation.w()); glDisable(GL_CULL_FACE); // Disable back-face culling so we can see the inside of the world-space cube and backside of the plane @@ -933,4 +971,4 @@ private static class Geometry { }; } -} \ No newline at end of file +} From 58edcd4f0aacd8373f9fa50a2310b7a42048c61d Mon Sep 17 00:00:00 2001 From: Starcommander Date: Fri, 24 Mar 2023 18:47:36 +0100 Subject: [PATCH 09/18] Cleanup example data like VertexBuffer IndexBuffer and Geometry --- .../input/vr/lwjgl_openxr/HelloOpenXRGL.java | 53 +++---------------- 1 file changed, 7 insertions(+), 46 deletions(-) diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/HelloOpenXRGL.java b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/HelloOpenXRGL.java index cfd712d44a..a85ffd633a 100644 --- a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/HelloOpenXRGL.java +++ b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/HelloOpenXRGL.java @@ -53,11 +53,6 @@ public class HelloOpenXRGL { Map depthTextures; //Swapchain images only provide a color texture so we have to create depth textures seperatley int swapchainFramebuffer; - int cubeVertexBuffer; - int cubeIndexBuffer; - int quadVertexBuffer; - int cubeVAO; - int quadVAO; int screenShader; int textureShader; int colorShader; @@ -139,11 +134,6 @@ public void destroy() glDeleteTextures(texture); } glDeleteFramebuffers(swapchainFramebuffer); - glDeleteBuffers(cubeVertexBuffer); - glDeleteBuffers(cubeIndexBuffer); - glDeleteBuffers(quadVertexBuffer); - glDeleteVertexArrays(cubeVAO); - glDeleteVertexArrays(quadVAO); glDeleteProgram(screenShader); glDeleteProgram(textureShader); glDeleteProgram(colorShader); @@ -556,6 +546,7 @@ private void createOpenGLResourses() { colorShader = ShadersGL.createShaderProgram(ShadersGL.colVertShader, ShadersGL.colFragShader); screenShader = ShadersGL.createShaderProgram(ShadersGL.screenVertShader, ShadersGL.texFragShader); + /* { cubeVertexBuffer = glGenBuffers(); glBindBuffer(GL_ARRAY_BUFFER, cubeVertexBuffer); @@ -583,6 +574,7 @@ private void createOpenGLResourses() { glEnableVertexAttribArray(1); glVertexAttribPointer(1, 2, GL_FLOAT, false, 4 * 4, 2 * 4); } + */ glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); @@ -821,13 +813,13 @@ private boolean renderLayerOpenXR(MemoryStack stack, long predictedDisplayTime, return true; } - private static Matrix4f modelviewMatrix = new Matrix4f(); +// private static Matrix4f modelviewMatrix = new Matrix4f(); private static Matrix4f projectionMatrix = new Matrix4f(); private static Matrix4f viewMatrix = new Matrix4f(); private static com.jme3.math.Vector3f viewPos = new com.jme3.math.Vector3f(); private static com.jme3.math.Quaternion viewRot = new com.jme3.math.Quaternion(); - private static FloatBuffer mvpMatrix = BufferUtils.createFloatBuffer(16); +// private static FloatBuffer mvpMatrix = BufferUtils.createFloatBuffer(16); private void OpenGLRenderView(XrCompositionLayerProjectionView layerView, XrSwapchainImageOpenGLKHR swapchainImage, int viewIndex) { glBindFramebuffer(GL_FRAMEBUFFER, swapchainFramebuffer); @@ -864,6 +856,7 @@ private void OpenGLRenderView(XrCompositionLayerProjectionView layerView, XrSwap viewPos.set(pos.x(), pos.y(), pos.z()); viewRot.set(orientation.x(), orientation.y(), orientation.z(), orientation.w()); + /* glDisable(GL_CULL_FACE); // Disable back-face culling so we can see the inside of the world-space cube and backside of the plane { // Rotating plane @@ -885,6 +878,7 @@ private void OpenGLRenderView(XrCompositionLayerProjectionView layerView, XrSwap } glEnable(GL_CULL_FACE); + */ glBindFramebuffer(GL_FRAMEBUFFER, 0); @@ -906,7 +900,7 @@ private void OpenGLRenderView(XrCompositionLayerProjectionView layerView, XrSwap } glFrontFace(GL_CCW); glUseProgram(screenShader); - glBindVertexArray(quadVAO); +// glBindVertexArray(quadVAO); glDisable(GL_DEPTH_TEST); glBindTexture(GL_TEXTURE_2D, swapchainImage.image()); glDrawArrays(GL_TRIANGLES, 0, 6); @@ -938,37 +932,4 @@ public XrResultException(String s) { } } - private static class Geometry { - - static float[] cubeVertices = { - -0.5f, 0.5f, -0.5f, 0.25f, 0f, 0f, -0.5f, -0.5f, 0.5f, 0.25f, 0f, 0f, -0.5f, -0.5f, -0.5f, 0.25f, 0f, 0f, -0.5f, 0.5f, -0.5f, 0.25f, 0f, 0f, -0.5f, 0.5f, 0.5f, 0.25f, 0f, 0f, -0.5f, -0.5f, 0.5f, 0.25f, 0f, 0f, - 0.5f, 0.5f, -0.5f, 1f, 0f, 0f, 0.5f, -0.5f, -0.5f, 1f, 0f, 0f, 0.5f, -0.5f, 0.5f, 1f, 0f, 0f, 0.5f, 0.5f, -0.5f, 1f, 0f, 0f, 0.5f, -0.5f, 0.5f, 1f, 0f, 0f, 0.5f, 0.5f, 0.5f, 1f, 0f, 0f, - -0.5f, -0.5f, -0.5f, 0f, 0.25f, 0f, -0.5f, -0.5f, 0.5f, 0f, 0.25f, 0f, 0.5f, -0.5f, 0.5f, 0f, 0.25f, 0f, -0.5f, -0.5f, -0.5f, 0f, 0.25f, 0f, 0.5f, -0.5f, 0.5f, 0f, 0.25f, 0f, 0.5f, -0.5f, -0.5f, 0f, 0.25f, 0f, - -0.5f, 0.5f, -0.5f, 0f, 1f, 0f, 0.5f, 0.5f, -0.5f, 0f, 1f, 0f, 0.5f, 0.5f, 0.5f, 0f, 1f, 0f, -0.5f, 0.5f, -0.5f, 0f, 1f, 0f, 0.5f, 0.5f, 0.5f, 0f, 1f, 0f, -0.5f, 0.5f, 0.5f, 0f, 1f, 0f, - -0.5f, -0.5f, -0.5f, 0f, 0f, 0.25f, 0.5f, -0.5f, -0.5f, 0f, 0f, 0.25f, 0.5f, 0.5f, -0.5f, 0f, 0f, 0.25f, -0.5f, -0.5f, -0.5f, 0f, 0f, 0.25f, 0.5f, 0.5f, -0.5f, 0f, 0f, 0.25f, -0.5f, 0.5f, -0.5f, 0f, 0f, 0.25f, - -0.5f, -0.5f, 0.5f, 0f, 0f, 1f, -0.5f, 0.5f, 0.5f, 0f, 0f, 1f, 0.5f, 0.5f, 0.5f, 0f, 0f, 1f, -0.5f, -0.5f, 0.5f, 0f, 0f, 1f, 0.5f, 0.5f, 0.5f, 0f, 0f, 1f, 0.5f, -0.5f, 0.5f, 0f, 0f, 1f - }; - - // Winding order is clockwise. Each side uses a different color. - static short[] cubeIndices = { - 0, 1, 2, 3, 4, 5, - 6, 7, 8, 9, 10, 11, - 12, 13, 14, 15, 16, 17, - 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, - 30, 31, 32, 33, 34, 35, - }; - - static float[] quadVertices = { // vertex attributes for a quad that fills the entire screen in Normalized Device Coordinates. - // positions // texCoords - -1.0f, 1.0f, 0.0f, 1.0f, - -1.0f, -1.0f, 0.0f, 0.0f, - 1.0f, -1.0f, 1.0f, 0.0f, - - -1.0f, 1.0f, 0.0f, 1.0f, - 1.0f, -1.0f, 1.0f, 0.0f, - 1.0f, 1.0f, 1.0f, 1.0f - }; - } - } From 1db9534307f77a5a16a3b63ff7d7b2b13d593db6 Mon Sep 17 00:00:00 2001 From: Starcommander Date: Mon, 10 Apr 2023 11:13:50 +0200 Subject: [PATCH 10/18] Cleanup and extend xr. --- .../input/vr/lwjgl_openvr/LWJGLOpenVR.java | 18 +++------ .../input/vr/lwjgl_openxr/HelloOpenXRGL.java | 40 ++++++++++++++----- 2 files changed, 36 insertions(+), 22 deletions(-) diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVR.java b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVR.java index c7703686ae..fecca2eeea 100644 --- a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVR.java +++ b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVR.java @@ -37,7 +37,6 @@ public class LWJGLOpenVR implements VRAPI { protected Matrix4f[] poseMatrices; - private final Matrix4f hmdPose = Matrix4f.IDENTITY.clone(); private Matrix4f hmdProjectionLeftEye; private Matrix4f hmdProjectionRightEye; private Matrix4f hmdPoseLeftEye; @@ -98,7 +97,7 @@ public int getDisplayFrequency() { public boolean initialize() { logger.config("Initializing OpenVR system..."); - com.jme3.input.vr.lwjgl_openxr.HelloOpenXRGL mainXr = new com.jme3.input.vr.lwjgl_openxr.HelloOpenXRGL(); + com.jme3.input.vr.lwjgl_openxr.HelloOpenXRGL mainXr = new com.jme3.input.vr.lwjgl_openxr.HelloOpenXRGL(environment); vrInput = new LWJGLOpenVRInput(environment); initSuccess = vrInput.init(); if (initSuccess) @@ -140,9 +139,7 @@ public void reset() { @Override public void getRenderSize(Vector2f store) { - //TODO - store.x = 800; - store.y = 600; + environment.getXr().getRenderSize(store); } @Override @@ -152,24 +149,19 @@ public float getInterpupillaryDistance() { @Override public Quaternion getOrientation() { - VRUtil.convertMatrix4toQuat(hmdPose, rotStore); + environment.getXr().getViewRotation(rotStore); return rotStore; } @Override public Vector3f getPosition() { - // the hmdPose comes in rotated funny, fix that here - hmdPose.toTranslationVector(posStore); - posStore.x = -posStore.x; - posStore.z = -posStore.z; + environment.getXr().getViewPosition(posStore); return posStore; } @Override public void getPositionAndOrientation(Vector3f storePos, Quaternion storeRot) { - hmdPose.toTranslationVector(storePos); - storePos.x = -storePos.x; - storePos.z = -storePos.z; + storePos.set(getPosition()); storeRot.set(getOrientation()); } diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/HelloOpenXRGL.java b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/HelloOpenXRGL.java index a85ffd633a..0a87ecb52e 100644 --- a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/HelloOpenXRGL.java +++ b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/HelloOpenXRGL.java @@ -11,8 +11,12 @@ import org.lwjgl.openxr.*; import org.lwjgl.system.*; +import com.jme3.app.VREnvironment; +import com.jme3.util.NativeObject; + import java.nio.*; import java.util.*; +import java.util.logging.Logger; import static org.lwjgl.glfw.GLFW.*; import static org.lwjgl.opengl.GL11.*; @@ -26,7 +30,10 @@ import static org.lwjgl.system.MemoryUtil.*; public class HelloOpenXRGL { - + + private static final Logger logger = Logger.getLogger(HelloOpenXRGL.class.getName()); + VREnvironment environment; + long window; //XR globals @@ -64,15 +71,20 @@ static class Swapchain { XrSwapchainImageOpenGLKHR.Buffer images; } - //JME3: Split function main(args) to public functions init+render+destroy - public HelloOpenXRGL() + //JME3: Split function main(args) to public functions constr+init+render+destroy + public HelloOpenXRGL(VREnvironment environment) { + this.environment = environment; createOpenXRInstance(); initializeOpenXRSystem(); initializeAndBindOpenGL(); createXRReferenceSpace(); createXRSwapchains(); - createOpenGLResourses(); + } + + private void initialize() + { + createOpenGLResources(); eventDataBuffer = XrEventDataBuffer.calloc() .type$Default(); @@ -81,6 +93,7 @@ public HelloOpenXRGL() /** Returns true for continue */ public boolean renderFrame() { + if (eventDataBuffer == null) { initialize(); } if (pollEvents()) return false; if (glfwWindowShouldClose(window)) return false; if (sessionRunning) @@ -149,7 +162,16 @@ public void getViewPosition(com.jme3.math.Vector3f store) public void getViewRotation(com.jme3.math.Quaternion store) { store.set(viewRot); - } + } + public void getRenderSize(com.jme3.math.Vector2f store) + { + if (swapchains == null || swapchains.length == 0 || swapchains[0] == null) + { + logger.warning("XR is not ready. Returning default renderSize of 1512x1680"); + store.set(1512, 1680); + } + store.set(swapchains[0].width,swapchains[0].height); + } private void createOpenXRInstance() { try (MemoryStack stack = stackPush()) { @@ -525,7 +547,7 @@ public void createXRSwapchains() { } } - private void createOpenGLResourses() { + private void createOpenGLResources() { swapchainFramebuffer = glGenFramebuffers(); depthTextures = new HashMap<>(0); for (Swapchain swapchain : swapchains) { @@ -576,9 +598,9 @@ private void createOpenGLResourses() { } */ - glBindBuffer(GL_ARRAY_BUFFER, 0); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - glBindVertexArray(0); +// glBindBuffer(GL_ARRAY_BUFFER, 0); +// glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); +// glBindVertexArray(0); } private boolean pollEvents() { From a3af4d7672c6532c8afad55c21b71f6200b65b78 Mon Sep 17 00:00:00 2001 From: Starcommander Date: Mon, 15 May 2023 21:00:33 +0200 Subject: [PATCH 11/18] Refactor, try and cleanup. After a long period of try and error a working solution was found. --- .../main/java/com/jme3/app/VRAppState.java | 626 ----- .../main/java/com/jme3/app/VRApplication.java | 1504 ----------- .../main/java/com/jme3/app/VRConstants.java | 174 -- .../main/java/com/jme3/app/VREnvironment.java | 527 ---- .../com/jme3/input/lwjgl/GlfwKeyInputVR.java | 153 -- .../jme3/input/lwjgl/GlfwMouseInputVR.java | 332 --- .../jme3/input/vr/AbstractVRMouseManager.java | 226 -- .../jme3/input/vr/AbstractVRViewManager.java | 226 -- .../com/jme3/input/vr/AnalogActionState.java | 48 - .../com/jme3/input/vr/DigitalActionState.java | 19 - .../main/java/com/jme3/input/vr/HmdType.java | 68 - .../main/java/com/jme3/input/vr/VRAPI.java | 183 -- .../main/java/com/jme3/input/vr/VRBounds.java | 17 - .../java/com/jme3/input/vr/VRInputAPI.java | 377 --- .../java/com/jme3/input/vr/VRInputType.java | 53 - .../com/jme3/input/vr/VRMouseManager.java | 111 - .../jme3/input/vr/VRTrackedController.java | 48 - .../java/com/jme3/input/vr/VRViewManager.java | 172 -- .../input/vr/lwjgl_openvr/LWJGLOpenVR.java | 277 -- .../LWJGLOpenVRAnalogActionData.java | 34 - .../vr/lwjgl_openvr/LWJGLOpenVRBounds.java | 50 - .../LWJGLOpenVRDigitalActionData.java | 34 - .../vr/lwjgl_openvr/LWJGLOpenVRInput.java | 717 ----- .../lwjgl_openvr/LWJGLOpenVRMouseManager.java | 107 - .../LWJGLOpenVRTrackedController.java | 96 - .../lwjgl_openvr/LWJGLOpenVRViewManager.java | 575 ---- .../jme3/input/vr/lwjgl_openxr/ShadersGL.java | 132 - .../java/com/jme3/input/vr/openvr/OpenVR.java | 584 ----- .../jme3/input/vr/openvr/OpenVRBounds.java | 56 - .../com/jme3/input/vr/openvr/OpenVRInput.java | 498 ---- .../input/vr/openvr/OpenVRMouseManager.java | 106 - .../vr/openvr/OpenVRTrackedController.java | 95 - .../input/vr/openvr/OpenVRViewManager.java | 733 ------ .../jme3/input/vr/openvr/package-info.java | 35 - .../java/com/jme3/input/vr/osvr/OSVR.java | 459 ---- .../com/jme3/input/vr/osvr/OSVRInput.java | 347 --- .../jme3/input/vr/osvr/OSVRMouseManager.java | 106 - .../jme3/input/vr/osvr/OSVRViewManager.java | 867 ------ .../com/jme3/input/vr/osvr/package-info.java | 36 - .../java/com/jme3/input/vr/package-info.java | 35 - .../src/main/java/com/jme3/input/xr/Eye.java | 92 + .../main/java/com/jme3/input/xr/XrHmd.java | 61 + .../java/com/jme3/input/xr/XrListener.java | 16 + .../main/java/com/jme3/post/CartoonSSAO.java | 155 -- .../main/java/com/jme3/post/FilterUtil.java | 48 - .../java/com/jme3/post/PreNormalCaching.java | 72 - .../main/java/com/jme3/scene/CenterQuad.java | 173 -- .../jme3/shadow/AbstractShadowFilterVR.java | 320 --- .../jme3/shadow/AbstractShadowRendererVR.java | 839 ------ .../DirectionalLightShadowFilterVR.java | 172 -- .../DirectionalLightShadowRendererVR.java | 308 --- .../InstancedDirectionalShadowFilter.java | 66 - .../VRDirectionalLightShadowRenderer.java | 78 - .../system/jopenvr/AppOverrideKeys_t.java | 50 - .../jme3/system/jopenvr/COpenVRContext.java | 110 - .../jme3/system/jopenvr/CVRSettingHelper.java | 43 - .../CameraVideoStreamFrameHeader_t.java | 53 - .../jopenvr/Compositor_CumulativeStats.java | 44 - .../jopenvr/Compositor_FrameTiming.java | 54 - .../jopenvr/Compositor_OverlaySettings.java | 44 - .../system/jopenvr/D3D12TextureData_t.java | 54 - .../jopenvr/DistortionCoordinates_t.java | 64 - .../jopenvr/DriverDirectMode_FrameTiming.java | 42 - .../jme3/system/jopenvr/HiddenAreaMesh_t.java | 44 - .../com/jme3/system/jopenvr/HmdColor_t.java | 40 - .../jme3/system/jopenvr/HmdMatrix33_t.java | 44 - .../jme3/system/jopenvr/HmdMatrix34_t.java | 44 - .../jme3/system/jopenvr/HmdMatrix44_t.java | 44 - .../com/jme3/system/jopenvr/HmdQuad_t.java | 44 - .../jme3/system/jopenvr/HmdQuaternion_t.java | 40 - .../jme3/system/jopenvr/HmdQuaternionf_t.java | 40 - .../com/jme3/system/jopenvr/HmdRect2_t.java | 42 - .../com/jme3/system/jopenvr/HmdVector2_t.java | 44 - .../com/jme3/system/jopenvr/HmdVector3_t.java | 44 - .../jme3/system/jopenvr/HmdVector3d_t.java | 44 - .../com/jme3/system/jopenvr/HmdVector4_t.java | 44 - .../com/jme3/system/jopenvr/ImuSample_t.java | 46 - .../jopenvr/InputAnalogActionData_t.java | 52 - .../jopenvr/InputDigitalActionData_t.java | 44 - .../system/jopenvr/InputOriginInfo_t.java | 52 - .../system/jopenvr/InputPoseActionData_t.java | 44 - .../jopenvr/InputSkeletalActionData_t.java | 40 - .../jopenvr/IntersectionMaskCircle_t.java | 38 - .../jopenvr/IntersectionMaskRectangle_t.java | 40 - .../jme3/system/jopenvr/JOpenVRLibrary.java | 2332 ----------------- .../system/jopenvr/NotificationBitmap_t.java | 48 - .../com/jme3/system/jopenvr/OpenVRUtil.java | 779 ------ .../jopenvr/RenderModel_ComponentState_t.java | 46 - .../RenderModel_ControllerMode_State_t.java | 34 - .../jopenvr/RenderModel_TextureMap_t.java | 46 - .../system/jopenvr/RenderModel_Vertex_t.java | 52 - .../jme3/system/jopenvr/RenderModel_t.java | 59 - .../system/jopenvr/SpatialAnchorPose_t.java | 36 - .../com/jme3/system/jopenvr/Texture_t.java | 56 - .../system/jopenvr/TrackedDevicePose_t.java | 57 - .../system/jopenvr/VRActiveActionSet_t.java | 50 - .../system/jopenvr/VRBoneTransform_t.java | 42 - .../system/jopenvr/VRControllerAxis_t.java | 36 - .../system/jopenvr/VRControllerState_t.java | 50 - .../jopenvr/VREvent_ApplicationLaunch_t.java | 36 - .../system/jopenvr/VREvent_Chaperone_t.java | 36 - .../system/jopenvr/VREvent_Controller_t.java | 34 - .../jme3/system/jopenvr/VREvent_Data_t.java | 135 - .../system/jopenvr/VREvent_DualAnalog_t.java | 49 - .../VREvent_EditingCameraSurface_t.java | 36 - .../jopenvr/VREvent_HapticVibration_t.java | 42 - .../VREvent_InputActionManifestLoad_t.java | 40 - .../jopenvr/VREvent_InputBindingLoad_t.java | 42 - .../jme3/system/jopenvr/VREvent_Ipd_t.java | 34 - .../system/jopenvr/VREvent_Keyboard_t.java | 46 - .../jopenvr/VREvent_MessageOverlay_t.java | 34 - .../jme3/system/jopenvr/VREvent_Mouse_t.java | 38 - .../jopenvr/VREvent_Notification_t.java | 36 - .../system/jopenvr/VREvent_Overlay_t.java | 36 - .../jopenvr/VREvent_PerformanceTest_t.java | 34 - .../system/jopenvr/VREvent_Process_t.java | 38 - .../system/jopenvr/VREvent_Property_t.java | 45 - .../system/jopenvr/VREvent_Reserved_t.java | 40 - .../jopenvr/VREvent_ScreenshotProgress_t.java | 34 - .../system/jopenvr/VREvent_Screenshot_t.java | 36 - .../jme3/system/jopenvr/VREvent_Scroll_t.java | 38 - .../VREvent_SeatedZeroPoseReset_t.java | 34 - .../jopenvr/VREvent_SpatialAnchor_t.java | 36 - .../jme3/system/jopenvr/VREvent_Status_t.java | 34 - .../jopenvr/VREvent_TouchPadMove_t.java | 44 - .../system/jopenvr/VREvent_WebConsole_t.java | 36 - .../com/jme3/system/jopenvr/VREvent_t.java | 49 - ...erlayIntersectionMaskPrimitive_Data_t.java | 39 - .../VROverlayIntersectionMaskPrimitive_t.java | 45 - .../VROverlayIntersectionParams_t.java | 49 - .../VROverlayIntersectionResults_t.java | 48 - .../system/jopenvr/VRTextureBounds_t.java | 40 - .../system/jopenvr/VRTextureDepthInfo_t.java | 50 - .../system/jopenvr/VRTextureWithDepth_t.java | 36 - .../jopenvr/VRTextureWithPoseAndDepth_t.java | 36 - .../system/jopenvr/VRTextureWithPose_t.java | 36 - .../system/jopenvr/VRVulkanTextureData_t.java | 59 - .../jopenvr/VR_IVRApplications_FnTable.java | 217 -- .../jopenvr/VR_IVRChaperoneSetup_FnTable.java | 152 -- .../jopenvr/VR_IVRChaperone_FnTable.java | 100 - .../jopenvr/VR_IVRCompositor_FnTable.java | 291 -- .../jopenvr/VR_IVRDriverManager_FnTable.java | 59 - .../VR_IVRExtendedDisplay_FnTable.java | 60 - .../jopenvr/VR_IVRIOBuffer_FnTable.java | 77 - .../system/jopenvr/VR_IVRInput_FnTable.java | 140 - .../jopenvr/VR_IVRNotifications_FnTable.java | 52 - .../system/jopenvr/VR_IVROverlay_FnTable.java | 526 ---- .../jopenvr/VR_IVRRenderModels_FnTable.java | 146 -- .../jopenvr/VR_IVRResources_FnTable.java | 51 - .../jopenvr/VR_IVRScreenshots_FnTable.java | 92 - .../jopenvr/VR_IVRSettings_FnTable.java | 103 - .../jopenvr/VR_IVRSpatialAnchors_FnTable.java | 68 - .../system/jopenvr/VR_IVRSystem_FnTable.java | 317 --- .../jopenvr/VR_IVRTrackedCamera_FnTable.java | 105 - .../com/jme3/system/lwjgl/EmptyKeyInput.java | 40 + .../jme3/system/lwjgl/EmptyMouseInput.java | 52 + ...wjglContextVR.java => LwjglContextXr.java} | 662 ++--- .../com/jme3/system/lwjgl/LwjglDisplayVR.java | 54 - .../system/lwjgl/LwjglOffscreenBufferVR.java | 50 - ...{LwjglWindowVR.java => LwjglWindowXr.java} | 1288 ++++----- .../lwjgl/openxr}/HelloOpenXRGL.java | 145 +- .../lwjgl/openxr}/XRHelper.java | 2 +- .../osvrclientkit/OsvrClientKitLibrary.java | 380 --- .../OSVR_AccelerationReport.java | 37 - .../OSVR_AccelerationState.java | 49 - .../OSVR_AnalogReport.java | 37 - .../OSVR_AngularAccelerationReport.java | 37 - .../OSVR_AngularVelocityReport.java | 37 - .../OSVR_ButtonReport.java | 37 - .../OSVR_DirectionReport.java | 41 - .../OSVR_EyeTracker2DReport.java | 41 - .../OSVR_EyeTracker3DReport.java | 41 - .../OSVR_EyeTracker3DState.java | 49 - .../OSVR_EyeTrackerBlinkReport.java | 41 - .../OSVR_IncrementalQuaternion.java | 37 - .../OSVR_LinearAccelerationReport.java | 37 - .../OSVR_LinearVelocityReport.java | 37 - .../OSVR_Location2DReport.java | 41 - .../OSVR_NaviPositionReport.java | 41 - .../OSVR_NaviVelocityReport.java | 41 - .../OSVR_OrientationReport.java | 37 - .../osvrclientreporttypes/OSVR_Pose3.java | 41 - .../OSVR_PoseReport.java | 37 - .../OSVR_PositionReport.java | 37 - .../OSVR_Quaternion.java | 37 - .../osvr/osvrclientreporttypes/OSVR_Vec2.java | 37 - .../osvr/osvrclientreporttypes/OSVR_Vec3.java | 37 - .../OSVR_VelocityReport.java | 37 - .../OSVR_VelocityState.java | 49 - .../OsvrClientReportTypesLibrary.java | 79 - .../osvr/osvrdisplay/OsvrDisplayLibrary.java | 851 ------ .../osvrinterface/OsvrInterfaceLibrary.java | 24 - .../osvrmatrixconventions/OSVR_Pose3.java | 41 - .../OSVR_Quaternion.java | 37 - .../osvr/osvrmatrixconventions/OSVR_Vec3.java | 37 - .../OsvrMatrixConventionsLibrary.java | 192 -- .../OSVR_ProjectionMatrix.java | 45 - .../osvr/osvrrendermanager/OSVR_RGB.java | 37 - .../osvrrendermanager/OSVR_RenderParams.java | 53 - .../OSVR_ViewportDescription.java | 49 - .../OsvrRenderManagerLibrary.java | 117 - .../OSVR_GraphicsLibraryOpenGL.java | 35 - .../OSVR_OpenGLContextParams.java | 57 - .../OSVR_OpenGLToolkitFunctions.java | 92 - .../OSVR_OpenResultsOpenGL.java | 48 - .../OSVR_ProjectionMatrix.java | 45 - .../osvrrendermanageropengl/OSVR_RGB.java | 37 - .../OSVR_RenderBufferOpenGL.java | 35 - .../OSVR_RenderInfoOpenGL.java | 48 - .../OSVR_RenderParams.java | 53 - .../OSVR_ViewportDescription.java | 49 - .../OsvrRenderManagerOpenGLLibrary.java | 169 -- .../osvr/osvrtimevalue/OSVR_TimeValue.java | 41 - .../osvrtimevalue/OsvrTimeValueLibrary.java | 119 - .../com/jme3/util/VRGUIPositioningMode.java | 15 - .../main/java/com/jme3/util/VRGuiManager.java | 467 ---- .../src/main/java/com/jme3/util/VRUtil.java | 101 - jme3-xr/src/main/java/test/TestInitHmd.java | 59 - 218 files changed, 1318 insertions(+), 28021 deletions(-) delete mode 100644 jme3-xr/src/main/java/com/jme3/app/VRAppState.java delete mode 100644 jme3-xr/src/main/java/com/jme3/app/VRApplication.java delete mode 100644 jme3-xr/src/main/java/com/jme3/app/VRConstants.java delete mode 100644 jme3-xr/src/main/java/com/jme3/app/VREnvironment.java delete mode 100644 jme3-xr/src/main/java/com/jme3/input/lwjgl/GlfwKeyInputVR.java delete mode 100644 jme3-xr/src/main/java/com/jme3/input/lwjgl/GlfwMouseInputVR.java delete mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/AbstractVRMouseManager.java delete mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/AbstractVRViewManager.java delete mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/AnalogActionState.java delete mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/DigitalActionState.java delete mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/HmdType.java delete mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/VRAPI.java delete mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/VRBounds.java delete mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/VRInputAPI.java delete mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/VRInputType.java delete mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/VRMouseManager.java delete mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/VRTrackedController.java delete mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/VRViewManager.java delete mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVR.java delete mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRAnalogActionData.java delete mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRBounds.java delete mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRDigitalActionData.java delete mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRInput.java delete mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRMouseManager.java delete mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRTrackedController.java delete mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRViewManager.java delete mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/ShadersGL.java delete mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/openvr/OpenVR.java delete mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/openvr/OpenVRBounds.java delete mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/openvr/OpenVRInput.java delete mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/openvr/OpenVRMouseManager.java delete mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/openvr/OpenVRTrackedController.java delete mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/openvr/OpenVRViewManager.java delete mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/openvr/package-info.java delete mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/osvr/OSVR.java delete mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/osvr/OSVRInput.java delete mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/osvr/OSVRMouseManager.java delete mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/osvr/OSVRViewManager.java delete mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/osvr/package-info.java delete mode 100644 jme3-xr/src/main/java/com/jme3/input/vr/package-info.java create mode 100644 jme3-xr/src/main/java/com/jme3/input/xr/Eye.java create mode 100644 jme3-xr/src/main/java/com/jme3/input/xr/XrHmd.java create mode 100644 jme3-xr/src/main/java/com/jme3/input/xr/XrListener.java delete mode 100644 jme3-xr/src/main/java/com/jme3/post/CartoonSSAO.java delete mode 100644 jme3-xr/src/main/java/com/jme3/post/FilterUtil.java delete mode 100644 jme3-xr/src/main/java/com/jme3/post/PreNormalCaching.java delete mode 100644 jme3-xr/src/main/java/com/jme3/scene/CenterQuad.java delete mode 100644 jme3-xr/src/main/java/com/jme3/shadow/AbstractShadowFilterVR.java delete mode 100644 jme3-xr/src/main/java/com/jme3/shadow/AbstractShadowRendererVR.java delete mode 100644 jme3-xr/src/main/java/com/jme3/shadow/DirectionalLightShadowFilterVR.java delete mode 100644 jme3-xr/src/main/java/com/jme3/shadow/DirectionalLightShadowRendererVR.java delete mode 100644 jme3-xr/src/main/java/com/jme3/shadow/InstancedDirectionalShadowFilter.java delete mode 100644 jme3-xr/src/main/java/com/jme3/shadow/VRDirectionalLightShadowRenderer.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/AppOverrideKeys_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/COpenVRContext.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/CVRSettingHelper.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/CameraVideoStreamFrameHeader_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/Compositor_CumulativeStats.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/Compositor_FrameTiming.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/Compositor_OverlaySettings.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/D3D12TextureData_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/DistortionCoordinates_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/DriverDirectMode_FrameTiming.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/HiddenAreaMesh_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdColor_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdMatrix33_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdMatrix34_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdMatrix44_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdQuad_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdQuaternion_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdQuaternionf_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdRect2_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdVector2_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdVector3_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdVector3d_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdVector4_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/ImuSample_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/InputAnalogActionData_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/InputDigitalActionData_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/InputOriginInfo_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/InputPoseActionData_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/InputSkeletalActionData_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/IntersectionMaskCircle_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/IntersectionMaskRectangle_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/JOpenVRLibrary.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/NotificationBitmap_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/OpenVRUtil.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/RenderModel_ComponentState_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/RenderModel_ControllerMode_State_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/RenderModel_TextureMap_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/RenderModel_Vertex_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/RenderModel_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/SpatialAnchorPose_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/Texture_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/TrackedDevicePose_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VRActiveActionSet_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VRBoneTransform_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VRControllerAxis_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VRControllerState_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_ApplicationLaunch_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Chaperone_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Controller_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Data_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_DualAnalog_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_EditingCameraSurface_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_HapticVibration_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_InputActionManifestLoad_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_InputBindingLoad_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Ipd_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Keyboard_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_MessageOverlay_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Mouse_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Notification_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Overlay_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_PerformanceTest_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Process_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Property_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Reserved_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_ScreenshotProgress_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Screenshot_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Scroll_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_SeatedZeroPoseReset_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_SpatialAnchor_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Status_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_TouchPadMove_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_WebConsole_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VROverlayIntersectionMaskPrimitive_Data_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VROverlayIntersectionMaskPrimitive_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VROverlayIntersectionParams_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VROverlayIntersectionResults_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VRTextureBounds_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VRTextureDepthInfo_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VRTextureWithDepth_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VRTextureWithPoseAndDepth_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VRTextureWithPose_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VRVulkanTextureData_t.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRApplications_FnTable.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRChaperoneSetup_FnTable.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRChaperone_FnTable.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRCompositor_FnTable.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRDriverManager_FnTable.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRExtendedDisplay_FnTable.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRIOBuffer_FnTable.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRInput_FnTable.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRNotifications_FnTable.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVROverlay_FnTable.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRRenderModels_FnTable.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRResources_FnTable.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRScreenshots_FnTable.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRSettings_FnTable.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRSpatialAnchors_FnTable.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRSystem_FnTable.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRTrackedCamera_FnTable.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/lwjgl/EmptyKeyInput.java create mode 100644 jme3-xr/src/main/java/com/jme3/system/lwjgl/EmptyMouseInput.java rename jme3-xr/src/main/java/com/jme3/system/lwjgl/{LwjglContextVR.java => LwjglContextXr.java} (58%) delete mode 100644 jme3-xr/src/main/java/com/jme3/system/lwjgl/LwjglDisplayVR.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/lwjgl/LwjglOffscreenBufferVR.java rename jme3-xr/src/main/java/com/jme3/system/lwjgl/{LwjglWindowVR.java => LwjglWindowXr.java} (54%) rename jme3-xr/src/main/java/com/jme3/{input/vr/lwjgl_openxr => system/lwjgl/openxr}/HelloOpenXRGL.java (87%) rename jme3-xr/src/main/java/com/jme3/{input/vr/lwjgl_openxr => system/lwjgl/openxr}/XRHelper.java (99%) delete mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientkit/OsvrClientKitLibrary.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_AccelerationReport.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_AccelerationState.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_AnalogReport.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_AngularAccelerationReport.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_AngularVelocityReport.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_ButtonReport.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_DirectionReport.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_EyeTracker2DReport.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_EyeTracker3DReport.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_EyeTracker3DState.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_EyeTrackerBlinkReport.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_IncrementalQuaternion.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_LinearAccelerationReport.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_LinearVelocityReport.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_Location2DReport.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_NaviPositionReport.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_NaviVelocityReport.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_OrientationReport.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_Pose3.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_PoseReport.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_PositionReport.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_Quaternion.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_Vec2.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_Vec3.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_VelocityReport.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_VelocityState.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OsvrClientReportTypesLibrary.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrdisplay/OsvrDisplayLibrary.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrinterface/OsvrInterfaceLibrary.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrmatrixconventions/OSVR_Pose3.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrmatrixconventions/OSVR_Quaternion.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrmatrixconventions/OSVR_Vec3.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrmatrixconventions/OsvrMatrixConventionsLibrary.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanager/OSVR_ProjectionMatrix.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanager/OSVR_RGB.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanager/OSVR_RenderParams.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanager/OSVR_ViewportDescription.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanager/OsvrRenderManagerLibrary.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_GraphicsLibraryOpenGL.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_OpenGLContextParams.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_OpenGLToolkitFunctions.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_OpenResultsOpenGL.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_ProjectionMatrix.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_RGB.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_RenderBufferOpenGL.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_RenderInfoOpenGL.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_RenderParams.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_ViewportDescription.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OsvrRenderManagerOpenGLLibrary.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrtimevalue/OSVR_TimeValue.java delete mode 100644 jme3-xr/src/main/java/com/jme3/system/osvr/osvrtimevalue/OsvrTimeValueLibrary.java delete mode 100644 jme3-xr/src/main/java/com/jme3/util/VRGUIPositioningMode.java delete mode 100644 jme3-xr/src/main/java/com/jme3/util/VRGuiManager.java delete mode 100644 jme3-xr/src/main/java/com/jme3/util/VRUtil.java delete mode 100644 jme3-xr/src/main/java/test/TestInitHmd.java diff --git a/jme3-xr/src/main/java/com/jme3/app/VRAppState.java b/jme3-xr/src/main/java/com/jme3/app/VRAppState.java deleted file mode 100644 index fa0956b2b2..0000000000 --- a/jme3-xr/src/main/java/com/jme3/app/VRAppState.java +++ /dev/null @@ -1,626 +0,0 @@ -package com.jme3.app; - -/* - * Copyright (c) 2009-2021 jMonkeyEngine - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'jMonkeyEngine' nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -import com.jme3.app.Application; -import com.jme3.app.state.AbstractAppState; -import com.jme3.app.state.AppStateManager; -import com.jme3.input.vr.VRAPI; -import com.jme3.input.vr.VRInputAPI; -import com.jme3.input.vr.VRMouseManager; -import com.jme3.input.vr.VRViewManager; -import com.jme3.math.ColorRGBA; -import com.jme3.math.Quaternion; -import com.jme3.math.Vector3f; -import com.jme3.post.PreNormalCaching; -import com.jme3.renderer.RenderManager; -import com.jme3.renderer.ViewPort; -import com.jme3.scene.Spatial; -import com.jme3.system.AppSettings; -import com.jme3.util.VRGUIPositioningMode; -import com.jme3.util.VRGuiManager; - -import java.awt.GraphicsDevice; -import java.awt.GraphicsEnvironment; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.util.Locale; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * A JMonkey app state dedicated to Virtual Reality. - * An application that want to use VR devices (HTC vive, ...) has to use this app state.
- * As this app state and the main {@link Application application} have to share {@link AppSettings application settings}, - * the common way to use this app state is:
- *
    - *
  • To create {@link AppSettings application settings} and set the VR related settings (see {@link VRConstants}). - *
  • To instantiate this app state with the created settings. - *
  • To instantiate the main {@link Application application} and to attach it to the created settings (with {@link Application#setSettings(AppSettings) setSettings(AppSettings)}). - *
  • To start the main {@link Application application}. - *
- * Attaching an instance of this app state to an already started application may cause crashes. - * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr - */ -public class VRAppState extends AbstractAppState { - public static final String ID = "VRAppState"; - private static final Logger logger = Logger.getLogger(VRAppState.class.getName()); - - /** - * Is the application has not to start within VR mode (default is false). - */ - public boolean DISABLE_VR = false; - - private float fFar = 1000f; - private float fNear = 0.1f; - private int xWin = 1920; - private int yWin = 1080; - - private float resMult = 1f; - - /* - where is the headset pointing, after all rotations are combined? - depends on observer rotation, if any - */ - private Quaternion tempq = new Quaternion(); - - private Application application = null; - private AppStateManager stateManager = null; - private AppSettings settings = null; - - private VREnvironment environment = null; - - /** - * Create a new default VR app state that relies on the given {@link VREnvironment VR environment}. - * @param environment the {@link VREnvironment VR environment} that this app state is using. - */ - public VRAppState(VREnvironment environment) { - super(ID); - - this.environment = environment; - - this.setSettings(environment.getSettings()); - } - - /** - * Create a new VR app state with given settings. The app state relies on the given {@link VREnvironment VR environment}. - * @param settings the settings to use. - * @param environment the {@link VREnvironment VR environment} that this app state is using. - */ - public VRAppState(AppSettings settings, VREnvironment environment){ - this(environment); - this.settings = settings; - processSettings(settings); - } - - /** - * Simple update of the app state, this method should contain any spatial updates. - * This method is called by the {@link #update(float) update()} method and should not be called manually. - * @param tpf the application time. - */ - public void simpleUpdate(float tpf) { - return; - } - - /** - * Rendering callback of the app state. This method is called by the {@link #update(float) update()} method and should not be called manually. - * @param renderManager the {@link RenderManager render manager}. - */ - public void simpleRender(RenderManager renderManager) { - PreNormalCaching.resetCache(environment.isInVR()); - } - - /** - * Set the frustum values for the application. - * @param near the frustum near value. - * @param far the frustum far value. - */ - public void setFrustrumNearFar(float near, float far) { - fNear = near; - fFar = far; - } - - /** - * Set the mirror window size in pixel. - * @param width the width of the mirror window in pixel. - * @param height the height of the mirror window in pixel. - */ - public void setMirrorWindowSize(int width, int height) { - xWin = width; - yWin = height; - } - - /** - * Set the resolution multiplier. - * @param val the resolution multiplier. - */ - public void setResolutionMultiplier(float val) { - resMult = val; - if( environment.getVRViewManager() != null ){ - environment.getVRViewManager().setResolutionMultiplier(resMult); - } - } - - /** - * Move filters from the main scene into the eye's. - * This removes filters from the main scene. - */ - public void moveScreenProcessingToVR() { - environment.getVRViewManager().moveScreenProcessingToEyes(); - } - - /** - * Get the observer final rotation within the scene. - * @return the observer final rotation within the scene. - * @see #getFinalObserverPosition() - */ - public Quaternion getFinalObserverRotation() { - if( environment.getVRViewManager() == null ) { - if( environment.getObserver() == null ) { - return environment.getCamera().getRotation(); - } else { - return ((Spatial)environment.getObserver()).getWorldRotation(); - } - } - - if( environment.getObserver() == null ) { - tempq.set(environment.getDummyCamera().getRotation()); - } else { - tempq.set(((Spatial)environment.getObserver()).getWorldRotation()); - } - return tempq.multLocal(environment.getVRHardware().getOrientation()); - } - - /** - * Get the observer final position within the scene. - * @return the observer position. - * @see #getFinalObserverRotation() - */ - public Vector3f getFinalObserverPosition() { - if( environment.getVRViewManager() == null ) { - if( environment.getObserver() == null ) { - return environment.getCamera().getLocation(); - } else{ - return ((Spatial)environment.getObserver()).getWorldTranslation(); - } - } - - Vector3f pos = environment.getVRHardware().getPosition(); - if( environment.getObserver() == null ) { - environment.getDummyCamera().getRotation().mult(pos, pos); - return pos.addLocal(environment.getDummyCamera().getLocation()); - } else { - ((Spatial)environment.getObserver()).getWorldRotation().mult(pos, pos); - return pos.addLocal(((Spatial)environment.getObserver()).getWorldTranslation()); - } - } - - /** - * Get the VR headset left viewport. - * @return the VR headset left viewport. - * @see #getRightViewPort() - */ - public ViewPort getLeftViewPort() { - if( environment.getVRViewManager() == null ){ - return application.getViewPort(); - } - - return environment.getVRViewManager().getLeftViewPort(); - } - - /** - * Get the VR headset right viewport. - * @return the VR headset right viewport. - * @see #getLeftViewPort() - */ - public ViewPort getRightViewPort() { - if( environment.getVRViewManager() == null ){ - return application.getViewPort(); - } - return environment.getVRViewManager().getRightViewPort(); - } - - /** - * Set the background color for both left and right view ports. - * @param clr the background color. - */ - public void setBackgroundColors(ColorRGBA clr) { - if( environment.getVRViewManager() == null ) { - application.getViewPort().setBackgroundColor(clr); - } else if( environment.getVRViewManager().getLeftViewPort() != null ) { - environment.getVRViewManager().getLeftViewPort().setBackgroundColor(clr); - - if( environment.getVRViewManager().getRightViewPort() != null ){ - environment.getVRViewManager().getRightViewPort().setBackgroundColor(clr); - } - } - } - - /** - * Get the {@link Application} to which this app state is attached. - * @return the {@link Application} to which this app state is attached. - * @see #getStateManager() - */ - public Application getApplication(){ - return application; - } - - /** - * Get the {@link AppStateManager state manager} to which this app state is attached. - * @return the {@link AppStateManager state manager} to which this app state is attached. - * @see #getApplication() - */ - public AppStateManager getStateManager(){ - return stateManager; - } - - /** - * Get the scene observer. If no observer has been set, this method returns the application camera. - * @return the scene observer. - * @see #setObserver(Spatial) - */ - public Object getObserver() { - return environment.getObserver(); - } - - /** - * Set the scene observer. The VR headset will be linked to it. If no observer is set, the VR headset is linked to the application camera. - * @param observer the scene observer. - */ - public void setObserver(Spatial observer) { - environment.setObserver(observer); - } - - /** - * Check if the rendering is instanced (see Geometry instancing). - * @return true if the rendering is instanced and false otherwise. - */ - public boolean isInstanceRendering() { - return environment.isInstanceRendering(); - } - - /** - * Return the {@link VREnvironment VR environment} on which this app state relies. - * @return the {@link VREnvironment VR environment} on which this app state relies. - */ - public VREnvironment getVREnvironment(){ - return environment; - } - - /** - * Get the VR underlying hardware. - * @return the VR underlying hardware. - */ - public VRAPI getVRHardware() { - return getVREnvironment().getVRHardware(); - } - - /** - * Get the VR dedicated input. - * @return the VR dedicated input. - */ - public VRInputAPI getVRinput() { - if( getVREnvironment().getVRHardware() == null ){ - return null; - } - - return getVREnvironment().getVRHardware().getVRinput(); - } - - /** - * Get the VR view manager. - * @return the VR view manager. - */ - public VRViewManager getVRViewManager() { - return getVREnvironment().getVRViewManager(); - } - - /** - * Get the GUI manager attached to this app state. - * @return the GUI manager attached to this app state. - */ - public VRGuiManager getVRGUIManager(){ - return getVREnvironment().getVRGUIManager(); - } - - /** - * Get the VR mouse manager attached to this app state. - * @return the VR mouse manager attached to this application. - */ - public VRMouseManager getVRMouseManager(){ - return getVREnvironment().getVRMouseManager(); - } - - /** - * Get the {@link AppSettings settings} attached to this app state. - * @return the {@link AppSettings settings} attached to this app state. - * @see #setSettings(AppSettings) - */ - public AppSettings getSettings(){ - return settings; - } - - /** - * Set the {@link AppSettings settings} attached to this app state. - * @param settings the {@link AppSettings settings} attached to this app state. - * @see #getSettings() - */ - public void setSettings(AppSettings settings){ - this.settings = settings; - processSettings(settings); - } - - @Override - public void update(float tpf) { - - // update VR pose & cameras - if( environment.getVRViewManager() != null ) { - environment.getVRViewManager().update(tpf); - } else if( environment.getObserver() != null ) { - environment.getCamera().setFrame(((Spatial)environment.getObserver()).getWorldTranslation(), ((Spatial)environment.getObserver()).getWorldRotation()); - } - - if( environment.isInVR() == false || environment.getVRGUIManager().getPositioningMode() == VRGUIPositioningMode.MANUAL ) { - // only update geometric state here if GUI is in manual mode, or not in VR - // it will get updated automatically in the view manager update otherwise - // TODO isn't this done by SimpleApplication? - for (Spatial spatial : application.getGuiViewPort().getScenes()) { - //spatial.updateLogicalState(tpf); - spatial.updateGeometricState(); - } - } - - // use the analog control on the first tracked controller to push around the mouse - environment.getVRMouseManager().updateAnalogAsMouse(0, null, null, null, tpf); - } - - @Override - public void render(RenderManager rm) { - super.render(rm); - - // update compositor - if( environment.getVRViewManager() != null ) { - environment.getVRViewManager().render(); - } - } - - @Override - public void postRender() { - super.postRender(); - - // update compositor - if( environment.getVRViewManager() != null ) { - environment.getVRViewManager().postRender(); - } - } - - @Override - public void initialize(AppStateManager stateManager, Application app) { - super.initialize(stateManager, app); - - this.application = app; - this.stateManager = stateManager; - - // disable annoying warnings about GUI stuff being updated, which is normal behavior - // for late GUI placement for VR purposes - Logger.getLogger("com.jme3").setLevel(Level.SEVERE); - - app.getCamera().setFrustumFar(fFar); - app.getCamera().setFrustumNear(fNear); - - if( environment.isInVR() ) { - logger.config("VR mode enabled."); - - if( environment.getVRHardware() != null ) { - environment.getVRHardware().initVRCompositor(environment.compositorAllowed()); - } else { - logger.warning("No VR system found."); - } - - environment.getVRViewManager().setResolutionMultiplier(resMult); - //inputManager.addMapping(RESET_HMD, new KeyTrigger(KeyInput.KEY_F9)); - //setLostFocusBehavior(LostFocusBehavior.Disabled); - } else { - logger.config("VR mode disabled."); - //viewPort.attachScene(rootNode); - //guiViewPort.attachScene(guiNode); - } - - if( environment.getVRViewManager() != null ) { - environment.getVRViewManager().initialize(); - } - } - - @Override - public void stateAttached(AppStateManager stateManager) { - super.stateAttached(stateManager); //To change body of generated methods, choose Tools | Templates. - - if (settings == null) { - settings = new AppSettings(true); - logger.config("Using default settings."); - } else { - logger.config("Using given settings."); - } - - // Attach VR environment to the application - if (!environment.isInitialized()){ - environment.initialize(); - } - - if (environment.isInitialized()){ - environment.atttach(this, stateManager.getApplication()); - } else { - logger.severe("Cannot attach VR environment to the VR app state as its not initialized."); - } - - GraphicsDevice defDev = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); - - if( environment.isInVR() && !environment.compositorAllowed() ) { - // "easy extended" mode - // setup experimental JFrame on external device - // first, find the VR device - GraphicsDevice VRdev = null; - GraphicsDevice[] devs = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices(); - // pick the display that isn't the default one - for(GraphicsDevice gd : devs) { - if( gd != defDev ) { - VRdev = gd; - break; - } - } - - // did we get the VR device? - if( VRdev != null ) { - // set properties for VR acceleration - try { - java.awt.DisplayMode useDM = null; - int max = 0; - for(java.awt.DisplayMode dm : VRdev.getDisplayModes()) { - int check = dm.getHeight() + dm.getWidth() + dm.getRefreshRate() + dm.getBitDepth(); - if( check > max ) { - max = check; - useDM = dm; - } - } - - // create a window for the VR device - settings.setWidth(useDM.getWidth()); - settings.setHeight(useDM.getHeight()); - settings.setBitsPerPixel(useDM.getBitDepth()); - settings.setFrequency(useDM.getRefreshRate()); - settings.setSwapBuffers(true); - settings.setVSync(true); // allow vsync on this display - stateManager.getApplication().setSettings(settings); - logger.config("Updated underlying application settings."); - - //VRdev.setFullScreenWindow(VRwindow); - // make sure we are in the right display mode - if( VRdev.getDisplayMode().equals(useDM) == false ) { - VRdev.setDisplayMode(useDM); - } - - return; - } catch(Exception e) { - logger.log(Level.SEVERE, e.getMessage(), e); - } - } else { - logger.config("Cannot access to external screen."); - } - } else { - if (!environment.isInVR()){ - logger.config("Cannot switch to VR mode (VR disabled by user)."); - } else if (!environment.compositorAllowed()){ - logger.warning("Cannot switch to VR mode (VR not supported)."); - } - } - - if( !environment.isInVR() ) { - //FIXME: Handling GLFW workaround on MacOS - boolean macOs = false; - if (macOs) { - // GLFW workaround on macs - settings.setFrequency(defDev.getDisplayMode().getRefreshRate()); - settings.setDepthBits(24); - settings.setVSync(true); - // try and read resolution from file in local dir - File resfile = new File("resolution.txt"); - if( resfile.exists() ) { - try { - BufferedReader br = new BufferedReader(new FileReader(resfile)); - settings.setWidth(Integer.parseInt(br.readLine())); - settings.setHeight(Integer.parseInt(br.readLine())); - try { - settings.setFullscreen(br.readLine().toLowerCase(Locale.ENGLISH).contains("full")); - } catch(Exception e) { - settings.setFullscreen(false); - } - br.close(); - } catch(Exception e) { - settings.setWidth(1280); - settings.setHeight(720); - } - } else { - settings.setWidth(1280); - settings.setHeight(720); - settings.setFullscreen(false); - } - settings.setResizable(false); - } - settings.setSwapBuffers(true); - } else { - // use basic mirroring window, skip settings window - settings.setSamples(1); - settings.setWidth(xWin); - settings.setHeight(yWin); - settings.setBitsPerPixel(32); - settings.setFrameRate(0); - settings.setFrequency(environment.getVRHardware().getDisplayFrequency()); - settings.setFullscreen(false); - settings.setVSync(false); // stop vsyncing on primary monitor! - settings.setSwapBuffers(environment.isSwapBuffers()); - } - - // Updating application settings - stateManager.getApplication().setSettings(settings); - logger.config("Updated underlying application settings."); - } - - @Override - public void cleanup() { - if( environment.getVRHardware() != null ) { - environment.getVRHardware().destroy(); - } - - this.application = null; - this.stateManager = null; - } - - @Override - public void stateDetached(AppStateManager stateManager) { - super.stateDetached(stateManager); - } - - /** - * Process the attached settings and apply changes to this app state. - * @param settings the app settings to process. - */ - protected void processSettings(AppSettings settings){ - if (settings != null){ - - if (settings.get(VRConstants.SETTING_DISABLE_VR) != null){ - DISABLE_VR = settings.getBoolean(VRConstants.SETTING_DISABLE_VR); - } - } - } -} \ No newline at end of file diff --git a/jme3-xr/src/main/java/com/jme3/app/VRApplication.java b/jme3-xr/src/main/java/com/jme3/app/VRApplication.java deleted file mode 100644 index 02ab733230..0000000000 --- a/jme3-xr/src/main/java/com/jme3/app/VRApplication.java +++ /dev/null @@ -1,1504 +0,0 @@ -package com.jme3.app; - -import com.jme3.app.AppTask; -import com.jme3.app.Application; -import com.jme3.app.LegacyApplication; -import com.jme3.app.LostFocusBehavior; -import com.jme3.app.ResetStatsState; -import com.jme3.app.SimpleApplication; -import com.jme3.app.state.AppState; -import com.jme3.app.state.AppStateManager; -import com.jme3.asset.AssetManager; -import com.jme3.audio.AudioContext; -import com.jme3.audio.AudioRenderer; -import com.jme3.audio.Listener; -import com.jme3.input.InputManager; -import com.jme3.input.JoyInput; -import com.jme3.input.KeyInput; -import com.jme3.input.MouseInput; -import com.jme3.input.TouchInput; -import com.jme3.input.controls.KeyTrigger; -import com.jme3.input.vr.VRAPI; -import com.jme3.input.vr.VRInputAPI; -import com.jme3.input.vr.openvr.OpenVR; -import com.jme3.input.vr.openvr.OpenVRMouseManager; -import com.jme3.input.vr.openvr.OpenVRViewManager; -import com.jme3.input.vr.osvr.OSVR; -import com.jme3.math.ColorRGBA; -import com.jme3.math.Quaternion; -import com.jme3.math.Vector3f; -import com.jme3.post.PreNormalCaching; -import com.jme3.profile.AppProfiler; -import com.jme3.renderer.Camera; -import com.jme3.renderer.RenderManager; -import com.jme3.renderer.Renderer; -import com.jme3.renderer.ViewPort; -import com.jme3.renderer.queue.RenderQueue.Bucket; -import com.jme3.scene.Node; -import com.jme3.scene.Spatial; -import com.jme3.scene.Spatial.CullHint; -import com.jme3.system.AppSettings; -import com.jme3.system.JmeContext; -import com.jme3.system.JmeContext.Type; -import com.jme3.system.jopenvr.JOpenVRLibrary; -import com.jme3.system.JmeSystem; -import com.jme3.system.NanoTimer; -import com.jme3.system.SystemListener; -import com.jme3.system.Timer; -import com.jme3.system.lwjgl.LwjglDisplayVR; -import com.jme3.system.lwjgl.LwjglOffscreenBufferVR; -import com.jme3.util.VRGUIPositioningMode; -import com.jme3.util.VRGuiManager; - -import java.awt.GraphicsDevice; -import java.awt.GraphicsEnvironment; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.Locale; -import java.util.concurrent.Callable; -import java.util.concurrent.ConcurrentLinkedQueue; -import java.util.concurrent.Future; -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.lwjgl.system.Platform; - -/** - * A JMonkey application dedicated to Virtual Reality. An application that use VR devices (HTC vive, ...) has to extend this one.
- *

- * This class is no more functional and is deprecated. Please use {@link VRAppState VRAppState} instead. - * @author reden - phr00t - https://github.com/phr00t - * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr - * @deprecated use {@link VRAppState VRAppState} instead. - */ -public abstract class VRApplication implements Application, SystemListener { - private static final Logger logger = Logger.getLogger(LegacyApplication.class.getName()); - - /** - * The default FOV. - */ - public float DEFAULT_FOV = 108f; - - /** - * The default aspect ratio. - */ - public float DEFAULT_ASPECT = 1f; - - /** - * Is the application is based on OSVR (default is false). - */ - public boolean CONSTRUCT_WITH_OSVR = false; - - /** - * Is the application has not to start within VR mode (default is false). - */ - public boolean DISABLE_VR = false; - - /** - * VR application configuration parameters. - * @author reden - phr00t - https://github.com/phr00t - * @author Julien Seinturier - (c) 2016 - JOrigin project - http:/www.jorigin.org - * - */ - public static enum PreconfigParameter { - /** - * Is the SteamVR compositor is used (kinda needed at the moment) - */ - USE_VR_COMPOSITOR, - - /** - * Render two eyes, regardless of VR API detection. - */ - FORCE_VR_MODE, - - /** - * Invert the eyes. - */ - FLIP_EYES, - - /** - * Show GUI even if it is behind objects. - */ - SET_GUI_OVERDRAW, - - /** - * - */ - SET_GUI_CURVED_SURFACE, - - /** - * Display a mirror rendering on the screen. Runs faster when set to false. - */ - ENABLE_MIRROR_WINDOW, - - /** - * - */ - PREFER_OPENGL3, - - /** - * Disable VR rendering, regardless VR API and devices are presents. - */ - DISABLE_VR, - - /** - * - */ - SEATED_EXPERIENCE, - - /** - * Remove GUI node from the application. - */ - NO_GUI, - - /** - * Faster VR rendering, requires some vertex shader changes (see Common/MatDefs/VR/Unshaded.j3md) - */ - INSTANCE_VR_RENDERING, - - /** - * - */ - FORCE_DISABLE_MSAA - } - - private VRAPI vrHardware = null; - private VRGuiManager guiManager = null; - private OpenVRMouseManager mouseManager = null; - private OpenVRViewManager viewManager = null; - - private String OS; - - private Camera dummyCam; - private Spatial observer; - private boolean VRSupportedOS; - private boolean forceVR; - private boolean disableSwapBuffers = true; - private boolean tryOpenGL3 = true; - private boolean seated; - private boolean nogui; - private boolean instanceVR; - private boolean forceDisableMSAA; - - // things taken from LegacyApplication - private AppStateManager stateManager; - private Camera cam; - private AppSettings settings; - private JmeContext context; - private float speed = 1f; - private AudioRenderer audioRenderer; - private LostFocusBehavior lostFocusBehavior = LostFocusBehavior.ThrottleOnLostFocus; - private final ConcurrentLinkedQueue> taskQueue = new ConcurrentLinkedQueue<>(); - private Timer timer = new NanoTimer(); - private boolean paused = false, inputEnabled = true; - private InputManager inputManager; - private RenderManager renderManager; - private ViewPort viewPort; - private ViewPort guiViewPort; - private AssetManager assetManager; - private Renderer renderer; - private Listener listener; - private MouseInput mouseInput; - private KeyInput keyInput; - private JoyInput joyInput; - private TouchInput touchInput; - - protected Node guiNode, rootNode; - - private float fFar = 1000f, fNear = 1f; - private int xWin = 1280, yWin = 720; - - private float resMult = 1f; - - private boolean useCompositor = true, compositorOS; - private final String RESET_HMD = "ResetHMD"; - - /** - * Create a new VR application and attach the given {@link AppState app states}.
- * The application scene is made of a {@link #getRootNode() root node} that holds the scene spatials - * and a {@link #getGuiNode() GUI node} that is the root of the Graphical user interface. - * @param initialStates the {@link AppState app states} to attach to the application. - */ - public VRApplication(AppState... initialStates) { - this(); - - if (initialStates != null) { - for (AppState a : initialStates) { - if (a != null) { - stateManager.attach(a); - } - } - } - } - - /** - * Create a new VR application.
- * The application scene is made of a {@link #getRootNode() root node} that holds the scene spatials - * and a {@link #getGuiNode() GUI node} that is the root of the Graphical user interface. - */ - public VRApplication() { - super(); - - rootNode = new Node("root"); - guiNode = new Node("guiNode"); - - guiNode.setQueueBucket(Bucket.Gui); - guiNode.setCullHint(CullHint.Never); - dummyCam = new Camera(0, 0); - - initStateManager(); - - // Create the GUI manager. - guiManager = new VRGuiManager(null); - - // Create a new view manager. - viewManager = new OpenVRViewManager(null); - - // Create a new mouse manager. - mouseManager = new OpenVRMouseManager(null); - - // we are going to use OpenVR now, not the Oculus Rift - // OpenVR does support the Rift - OS = System.getProperty("os.name", "generic").toLowerCase(Locale.ENGLISH); - VRSupportedOS = !OS.contains("nux") && System.getProperty("sun.arch.data.model").equalsIgnoreCase("64"); //for the moment, linux/unix causes crashes, 64-bit only - compositorOS = OS.contains("indows"); - - if( !VRSupportedOS ) { - logger.warning("Non-supported OS: " + OS + ", architecture: " + System.getProperty("sun.arch.data.model")); - } else if( DISABLE_VR ) { - logger.warning("VR disabled via code."); - } else if( VRSupportedOS && DISABLE_VR == false ) { - if( CONSTRUCT_WITH_OSVR ) { - //FIXME: WARNING !! - vrHardware = new OSVR(null); - logger.config("Creating OSVR wrapper [SUCCESS]"); - } else { - //FIXME: WARNING !! - vrHardware = new OpenVR(null); - logger.config("Creating OpenVR wrapper [SUCCESS]"); - } - if( vrHardware.initialize() ) { - setPauseOnLostFocus(false); - } - } - } - - /** - * Get the VR underlying hardware. - * @return the VR underlying hardware. - */ - public VRAPI getVRHardware() { - return vrHardware; - } - - /** - * Get the VR dedicated input. - * @return the VR dedicated input. - */ - public VRInputAPI getVRinput() { - if( vrHardware == null ) return null; - return vrHardware.getVRinput(); - } - - /** - * Get the VR view manager. - * @return the VR view manager. - */ - public OpenVRViewManager getVRViewManager() { - return viewManager; - } - - /** - * Get the GUI manager attached to this application. - * @return the GUI manager attached to this application. - */ - public VRGuiManager getVRGUIManager(){ - return guiManager; - } - - /** - * Get the VR mouse manager attached to this application. - * @return the VR mouse manager attached to this application. - */ - public OpenVRMouseManager getVRMouseManager(){ - return mouseManager; - } - - /** - * Set the frustum values for the application. - * @param near the frustum near value. - * @param far the frustum far value. - */ - public void setFrustrumNearFar(float near, float far) { - fNear = near; - fFar = far; - } - - /** - * Set the mirror window size in pixel. - * @param width the width of the mirror window in pixel. - * @param height the height of the mirror window in pixel. - */ - public void setMirrorWindowSize(int width, int height) { - xWin = width; - yWin = height; - } - - /** - * Set the resolution multiplier. - * @param val the resolution multiplier. - */ - public void setResolutionMultiplier(float val) { - resMult = val; - if( viewManager != null ) viewManager.setResolutionMultiplier(resMult); - } - - - /** - * Is the SteamVR compositor is active. - * @return true if the SteamVR compositor is active and false otherwise. - */ - public boolean compositorAllowed() { - return useCompositor && compositorOS; - } - - /** - * Get if the system currently support VR. - * @return true if the system currently support VR and false otherwise. - */ - public boolean isOSVRSupported() { - return VRSupportedOS; - } - - /** - * Simple update of the application, this method should contain {@link #getRootNode() root node} updates. - * This method is called by the {@link #update() update()} method and should not be called manually. - * @param tpf the application time. - */ - public void simpleUpdate(float tpf) { } - - /** - * Rendering callback of the application. This method is called by the {@link #update() update()} method and should not be called manually. - * @param renderManager the {@link RenderManager render manager}. - */ - public void simpleRender(RenderManager renderManager) { - PreNormalCaching.resetCache(isInVR()); - } - - - /** - we do NOT want to get and modify the distortion scene camera, so - return the left viewport camera instead if we are in VR mode - */ - @Override - public Camera getCamera() { - if( isInVR() && viewManager != null && viewManager.getLeftCamera() != null ) { - return dummyCam; - } - return cam; - } - - /** - * Get the application internal camera. - * @return the application internal camera. - * @see #getCamera() - */ - public Camera getBaseCamera() { - return cam; - } - - @Override - public JmeContext getContext(){ - return context; - } - - @Override - public AssetManager getAssetManager(){ - return assetManager; - } - - @Override - public InputManager getInputManager(){ - return inputManager; - } - - @Override - public AppStateManager getStateManager() { - return stateManager; - } - - @Override - public RenderManager getRenderManager() { - return renderManager; - } - - @Override - public Renderer getRenderer(){ - return renderer; - } - - @Override - public AudioRenderer getAudioRenderer() { - return audioRenderer; - } - - @Override - public Listener getListener() { - return listener; - } - - @Override - public Timer getTimer(){ - return timer; - } - - /** - * Handle the error given in parameters by creating a log entry and a dialog window. Internal use only. - */ - @Override - public void handleError(String errMsg, Throwable t){ - // Print error to log. - logger.log(Level.SEVERE, errMsg, t); - // Display error message on screen if not in headless mode - if (context.getType() != JmeContext.Type.Headless) { - if (t != null) { - JmeSystem.handleErrorMessage(errMsg + "\n" + t.getClass().getSimpleName() + - (t.getMessage() != null ? ": " + t.getMessage() : "")); - } else { - JmeSystem.handleErrorMessage(errMsg); - } - } - - stop(); // stop the application - } - - - /** - * Force the focus gain for the application. Internal use only. - */ - @Override - public void gainFocus(){ - if (lostFocusBehavior != LostFocusBehavior.Disabled) { - if (lostFocusBehavior == LostFocusBehavior.PauseOnLostFocus) { - paused = false; - } - context.setAutoFlushFrames(true); - if (inputManager != null) { - inputManager.reset(); - } - } - } - - /** - * Force the focus lost for the application. Internal use only. - */ - @Override - public void loseFocus(){ - if (lostFocusBehavior != LostFocusBehavior.Disabled){ - if (lostFocusBehavior == LostFocusBehavior.PauseOnLostFocus) { - paused = true; - } - context.setAutoFlushFrames(false); - } - } - - /** - * Reshape the display window. Internal use only. - */ - @Override - public void reshape(int w, int h){ - if (renderManager != null) { - renderManager.notifyReshape(w, h); - } - } - - /** - * Request the application to close. Internal use only. - */ - @Override - public void requestClose(boolean esc){ - context.destroy(false); - } - - /** - * Set the {@link AppSettings display settings} to define the display created. - *

- * Examples of display parameters include display frame {@link AppSettings#getWidth() width} and {@link AppSettings#getHeight() height}, - * pixel {@link AppSettings#getBitsPerPixel() color bit depth}, {@link AppSettings#getDepthBits() z-buffer bits}, {@link AppSettings#getSamples() anti-aliasing samples}, {@link AppSettings#getFrequency() update frequency}, ... - *

If this method is called while the application is already running, then - * {@link #restart() } must be called to apply the settings to the display. - * - * @param settings The settings to set. - */ - @Override - public void setSettings(AppSettings settings){ - this.settings = settings; - if (context != null && settings.useInput() != inputEnabled){ - // may need to create or destroy input based - // on settings change - inputEnabled = !inputEnabled; - if (inputEnabled){ - initInput(); - }else{ - destroyInput(); - } - }else{ - inputEnabled = settings.useInput(); - } - } - - /** - * Sets the {@link Timer} implementation that will be used for calculating - * frame times.

- * By default, Application will use the Timer as returned by the current {@link JmeContext} implementation. - * @param timer the timer to use. - */ - @Override - public void setTimer(Timer timer){ - this.timer = timer; - - if (timer != null) { - timer.reset(); - } - - if (renderManager != null) { - renderManager.setTimer(timer); - } - } - - /** - * Determine the application's behavior when unfocused. - * @return The lost focus behavior of the application. - */ - @Override - public LostFocusBehavior getLostFocusBehavior() { - return lostFocusBehavior; - } - - /** - * Change the application's behavior when unfocused. By default, the application will - * {@link LostFocusBehavior#ThrottleOnLostFocus throttle the update loop} - * so as to not take 100% CPU usage when it is not in focus, e.g. - * alt-tabbed, minimized, or obstructed by another window. - * - * @param lostFocusBehavior The new {@link LostFocusBehavior lost focus behavior} to use. - */ - @Override - public void setLostFocusBehavior(LostFocusBehavior lostFocusBehavior) { - this.lostFocusBehavior = lostFocusBehavior; - } - - /** - * Get if the application has to pause then it lost the focus. - * @return true if pause on lost focus is enabled, false otherwise. - * @see #getLostFocusBehavior() - */ - @Override - public boolean isPauseOnLostFocus() { - return getLostFocusBehavior() == LostFocusBehavior.PauseOnLostFocus; - } - - /** - * Enable or disable pause on lost focus. - *

- * By default, pause on lost focus is enabled. - * If enabled, the application will stop updating - * when it loses focus or becomes inactive (e.g. alt-tab). - * For online or real-time applications, this might not be preferable, - * so this feature should be set to disabled. For other applications, - * it is best to keep it on so that CPU usage is not used when - * not necessary. - * - * @param pauseOnLostFocus true to enable pause on lost focus, false - * otherwise. - * - * @see #setLostFocusBehavior(com.jme3.app.LostFocusBehavior) - */ - @Override - public void setPauseOnLostFocus(boolean pauseOnLostFocus) { - if (pauseOnLostFocus) { - setLostFocusBehavior(LostFocusBehavior.PauseOnLostFocus); - } else { - setLostFocusBehavior(LostFocusBehavior.Disabled); - } - } - - @Override - public void start() { - logger.config("Starting application..."); - - // set some default settings in-case - // settings dialog is not shown - boolean loadSettings = false; - if (settings == null) { - setSettings(new AppSettings(true)); - loadSettings = true; - } - - GraphicsDevice defDev = null; - try { - GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); - defDev = ge.getDefaultScreenDevice(); - } catch (Throwable e1) { - logger.log(Level.SEVERE, "Cannot access default screen device: "+e1.getMessage(), e1); - } - - if( isInVR() && !compositorAllowed() ) { - logger.warning("VR Composition is not allowed."); - // "easy extended" mode - // TO-DO: JFrame was removed in LWJGL 3, need to use new GLFW library to pick "monitor" display of VR device - // first, find the VR device - GraphicsDevice VRdev = null; - GraphicsDevice[] devs = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices(); - // pick the display that isn't the default one - for(GraphicsDevice gd : devs) { - if( gd != defDev ) { - VRdev = gd; - break; - } - } - // did we get the VR device? - if( VRdev != null ) { - // set properties for VR acceleration - try { - java.awt.DisplayMode useDM = null; - int max = 0; - for(java.awt.DisplayMode dm : VRdev.getDisplayModes()) { - int check = dm.getHeight() + dm.getWidth() + dm.getRefreshRate() + dm.getBitDepth(); - if( check > max ) { - max = check; - useDM = dm; - } - } - // create a window for the VR device - settings.setWidth(useDM.getWidth()); - settings.setHeight(useDM.getHeight()); - settings.setBitsPerPixel(useDM.getBitDepth()); - settings.setFrequency(useDM.getRefreshRate()); - settings.setSwapBuffers(true); - settings.setVSync(true); // allow vsync on this display - setSettings(settings); - //VRdev.setFullScreenWindow(VRwindow); - // make sure we are in the right display mode - if( VRdev.getDisplayMode().equals(useDM) == false ) { - VRdev.setDisplayMode(useDM); - } - // make a blank cursor to hide it - //BufferedImage cursorImg = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB); - //Cursor blankCursor = Toolkit.getDefaultToolkit().createCustomCursor(cursorImg, new Point(0, 0), "blank cursor"); - //VRwindow.setCursor(blankCursor); - //jmeCanvas.getCanvas().setCursor(blankCursor); - //VRwindow.pack(); - //VRwindow.setVisible(true); - //startCanvas(); - logger.config("Starting application [SUCCESS]"); - return; - } catch(Exception e) { - logger.log(Level.SEVERE, "Error during application start: "+e.getMessage(), e); - } - } - } - - if( !isInVR() ) { - logger.config("VR mode disabled."); - - // not in VR, show settings dialog - if (!JmeSystem.showSettingsDialog(settings, loadSettings)) { - logger.config("Starting application [SUCCESS]"); - return; - } - - - settings.setSwapBuffers(true); - } else { - logger.config("VR mode enabled."); - - // use basic mirroring window, skip settings window - settings.setWidth(xWin); - settings.setHeight(yWin); - settings.setBitsPerPixel(24); - settings.setFrameRate(0); // never sleep in main loop - settings.setFrequency(vrHardware.getDisplayFrequency()); - settings.setFullscreen(false); - settings.setVSync(false); // stop vsyncing on primary monitor! - settings.setSwapBuffers(!disableSwapBuffers || vrHardware instanceof OSVR); - settings.setTitle("Put Headset On Now: " + settings.getTitle()); - settings.setResizable(true); - } - - if( forceDisableMSAA ) { - logger.config("Disabling multisampling."); - // disable multisampling, which is more likely to break things than be useful - settings.setSamples(1); - } - - // set opengl mode - if( tryOpenGL3 ) { - logger.config("Using LWJGL OpenGL 3.2 renderer."); - settings.setRenderer(AppSettings.LWJGL_OPENGL32); - } else { - logger.config("Using LWJGL OpenGL 2 renderer."); - settings.setRenderer(AppSettings.LWJGL_OPENGL2); - } - - - setSettings(settings); - start(JmeContext.Type.Display, false); - - // disable annoying warnings about GUI stuff being updated, which is normal behavior - // for late GUI placement for VR purposes - Logger.getLogger("com.jme3").setLevel(Level.SEVERE); - } - - /** - * Starts the application in {@link com.jme3.system.JmeContext.Type#Display display} mode. - * @param waitFor if true, the method will wait until the application is started. - * @see #start(com.jme3.system.JmeContext.Type, boolean) - */ - @Override - public void start(boolean waitFor){ - start(JmeContext.Type.Display, waitFor); - } - - /** - * Starts the application. - * Creating a rendering context and executing the main loop in a separate thread. - * @param contextType the {@link com.jme3.system.JmeContext.Type type} of the context to create. - * @param waitFor if true, the method will wait until the application is started. - * @throws IllegalArgumentException if the context type is not supported. - */ - public void start(JmeContext.Type contextType, boolean waitFor){ - if (context != null && context.isCreated()){ - logger.warning("start() called when application already created!"); - return; - } - - if (settings == null){ - settings = new AppSettings(true); - } - - logger.log(Level.FINE, "Starting application: {0}", getClass().getName()); - - // Create VR dedicated context - if (contextType == Type.Display){ - context = new LwjglDisplayVR(); - context.setSettings(settings); - } else if (contextType == Type.OffscreenSurface){ - context = new LwjglOffscreenBufferVR(); - context.setSettings(settings); - } else { - logger.severe("Unsupported context type \""+contextType+"\". Supported are \"Display\" and \"OffscreenSurface\""); - throw new IllegalArgumentException("Unsupported context type \""+contextType+"\". Supported are \"Display\" and \"OffscreenSurface\""); - } - - context.setSystemListener(this); - context.create(waitFor); - } - - /** - * Move filters from the main scene into the eye's. - * This removes filters from the main scene. - */ - public void moveScreenProcessingToVR() { - if( isInVR() ) { - viewManager.moveScreenProcessingToEyes(); - } - } - - /** - * Set VR application {@link PreconfigParameter specific parameter}. - * If making changes to default values, this must be called before the VRApplication starts - * @param parm the parameter to set. - * @param value the value of the parameter. - */ - public void preconfigureVRApp(PreconfigParameter parm, boolean value) { - switch( parm ) { - case SET_GUI_OVERDRAW: - guiManager.setGuiOverdraw(value); - break; - case SET_GUI_CURVED_SURFACE: - guiManager.setCurvedSurface(value); - break; - case FORCE_VR_MODE: - forceVR = value; - break; - //case USE_CUSTOM_DISTORTION: //deprecated, always using a render manager - // VRViewManager._setCustomDistortion(value); - // break; - case USE_VR_COMPOSITOR: - useCompositor = value; - if( value == false ) disableSwapBuffers = false; - break; - case FLIP_EYES: - if( vrHardware == null ) return; - vrHardware.setFlipEyes(value); - break; - case INSTANCE_VR_RENDERING: - instanceVR = value; - break; - case ENABLE_MIRROR_WINDOW: - if( useCompositor == false ) { - disableSwapBuffers = false; - } else disableSwapBuffers = !value; - break; - case PREFER_OPENGL3: - tryOpenGL3 = value; - break; - case DISABLE_VR: - DISABLE_VR = value; - break; - case NO_GUI: - nogui = value; - break; - case SEATED_EXPERIENCE: - seated = value; - break; - case FORCE_DISABLE_MSAA: - forceDisableMSAA = value; - break; - } - } - - /** - * Can be used to change seated experience during runtime. - * @param isSeated true if designed for sitting, false for standing/roomscale - * @see #isSeatedExperience() - */ - public void setSeatedExperience(boolean isSeated) { - seated = isSeated; - if( vrHardware instanceof OpenVR ) { - if( vrHardware.getCompositor() == null ) return; - if( seated ) { - ((OpenVR) vrHardware).getCompositor().SetTrackingSpace.apply(JOpenVRLibrary.ETrackingUniverseOrigin.ETrackingUniverseOrigin_TrackingUniverseSeated); - } else { - ((OpenVR) vrHardware).getCompositor().SetTrackingSpace.apply(JOpenVRLibrary.ETrackingUniverseOrigin.ETrackingUniverseOrigin_TrackingUniverseStanding); - } - } - } - - /** - * Check if the application is configured as a seated experience. - * @return true if the application is configured as a seated experience and false otherwise. - * @see #setSeatedExperience(boolean) - */ - public boolean isSeatedExperience() { - return seated; - } - - /** - * Reset headset pose if seating experience. - */ - public void resetSeatedPose(){ - if( VRSupportedOS == false || isSeatedExperience() == false ) return; - vrHardware.reset(); - } - - /** - * Check if the rendering is instanced (see Geometry instancing). - * @return true if the rendering is instanced and false otherwise. - */ - public boolean isInstanceVRRendering() { - return instanceVR && isInVR(); - } - - /** - * Check if the VR mode is enabled. - * @return true if the VR mode is enabled and false otherwise. - */ - public boolean isInVR() { - return DISABLE_VR == false && (forceVR || VRSupportedOS && vrHardware != null && vrHardware.isInitialized()); - } - - - /** - * Get the GUI node from the application. - * @return the GUI node from the application. - * @see #setGuiNode(Node) - */ - public Node getGuiNode(){ - return guiNode; - } - - /** - * Set the GUI node that is displayed within the GUI viewport. - * Calling this method involve clearing all the scenes previously attached to the gui viewport. - * @param node the GUI node to attach. - * @see #getGuiNode() - */ - public void setGuiNode(Node node){ - if (node != null){ - if (guiViewPort != null){ - enqueue(new Callable(){ - - @Override - public Object call() throws Exception { - guiViewPort.clearScenes(); - guiViewPort.attachScene(node); - guiNode = node; - return null; - } - - }); - - } else { - throw new IllegalArgumentException("GUI view port is not initialized."); - } - } - } - - /** - * Get the root node of the application. - * @return the root node of the application. - */ - public Node getRootNode() { - return rootNode; - } - - /** - * Check if the application has a GUI overlay attached. - * @return true if the application has a GUI overlay attached and false otherwise. - */ - public boolean hasTraditionalGUIOverlay() { - return !nogui; - } - - /** - * Get the scene observer. If no observer has been set, this method return the application {@link #getCamera() camera}. - * @return the scene observer. - * @see #setObserver(Spatial) - */ - public Object getObserver() { - if( observer == null ) { - return getCamera(); - } - return observer; - } - - /** - * Set the scene observer. The VR headset will be linked to it. If no observer is set, the VR headset is linked to the application {@link #getCamera() camera}. - * @param observer the scene observer. - */ - public void setObserver(Spatial observer) { - this.observer = observer; - } - - /* - where is the headset pointing, after all rotations are combined? - depends on observer rotation, if any - */ - private static Quaternion tempq = new Quaternion(); - - /** - * Get the observer final rotation within the scene. - * @return the observer final rotation within the scene. - * @see #getFinalObserverPosition() - */ - public Quaternion getFinalObserverRotation() { - if( viewManager == null ) { - if( observer == null ) { - return getCamera().getRotation(); - } else return observer.getWorldRotation(); - } - if( observer == null ) { - tempq.set(dummyCam.getRotation()); - } else { - tempq.set(observer.getWorldRotation()); - } - return tempq.multLocal(vrHardware.getOrientation()); - } - - /** - * Get the observer final position within the scene. - * @return the observer position. - * @see #getFinalObserverRotation() - */ - public Vector3f getFinalObserverPosition() { - if( viewManager == null ) { - if( observer == null ) { - return getCamera().getLocation(); - } else return observer.getWorldTranslation(); - } - Vector3f pos = vrHardware.getPosition(); - if( observer == null ) { - dummyCam.getRotation().mult(pos, pos); - return pos.addLocal(dummyCam.getLocation()); - } else { - observer.getWorldRotation().mult(pos, pos); - return pos.addLocal(observer.getWorldTranslation()); - } - } - - /** - * Set the VR headset height from the ground. - * @param amount the VR headset height from the ground. - * @see #getVRHeightAdjustment() - */ - public void setVRHeightAdjustment(float amount) { - if( viewManager != null ) viewManager.setHeightAdjustment(amount); - } - - /** - * Get the VR headset height from the ground. - * @return the VR headset height from the ground. - * @see #setVRHeightAdjustment(float) - */ - public float getVRHeightAdjustment() { - if( viewManager != null ) return viewManager.getHeightAdjustment(); - return 0f; - } - - /** - * Get the VR headset left viewport. - * @return the VR headset left viewport. - * @see #getRightViewPort() - */ - public ViewPort getLeftViewPort() { - if( viewManager == null ) return getViewPort(); - return viewManager.getLeftViewPort(); - } - - /** - * Get the VR headset right viewport. - * @return the VR headset right viewport. - * @see #getLeftViewPort() - */ - public ViewPort getRightViewPort() { - if( viewManager == null ) return getViewPort(); - return viewManager.getRightViewPort(); - } - - /** - * Set the background color for both left and right view ports. - * @param clr the background color. - */ - public void setBackgroundColors(ColorRGBA clr) { - if( viewManager == null ) { - getViewPort().setBackgroundColor(clr); - } else if( viewManager.getLeftViewPort() != null ) { - viewManager.getLeftViewPort().setBackgroundColor(clr); - if( viewManager.getRightViewPort() != null ) viewManager.getRightViewPort().setBackgroundColor(clr); - } - } - - /** - * Runs tasks enqueued via {@link #enqueue(Callable)} - */ - protected void runQueuedTasks() { - AppTask task; - while( (task = taskQueue.poll()) != null ) { - if (!task.isCancelled()) { - task.invoke(); - } - } - } - - @Override - public void update() { - // Make sure the audio renderer is available to callables - AudioContext.setAudioRenderer(audioRenderer); - - runQueuedTasks(); - - if (speed != 0 && !paused) { - - timer.update(); - - if (inputEnabled){ - inputManager.update(timer.getTimePerFrame()); - } - - if (audioRenderer != null){ - audioRenderer.update(timer.getTimePerFrame()); - } - } - - if (speed == 0 || paused) { - try { - Thread.sleep(50); // throttle the CPU when paused - } catch (InterruptedException ex) { - Logger.getLogger(SimpleApplication.class.getName()).log(Level.SEVERE, null, ex); - } - return; - } - - float tpf = timer.getTimePerFrame() * speed; - - // update states - stateManager.update(tpf); - - // simple update and root node - simpleUpdate(tpf); - - - // render states - stateManager.render(renderManager); - - // update VR pose & cameras - if( viewManager != null ) { - viewManager.update(tpf); - } else if( observer != null ) { - getCamera().setFrame(observer.getWorldTranslation(), observer.getWorldRotation()); - } - - //FIXME: check if this code is necessary. - // Updates scene and gui states. - rootNode.updateLogicalState(tpf); - guiNode.updateLogicalState(tpf); - - rootNode.updateGeometricState(); - - if( isInVR() == false || guiManager.getPositioningMode() == VRGUIPositioningMode.MANUAL ) { - // Update geometric state here only if GUI is in manual mode, or not in VR. - // Otherwise it will get updated automatically in the view-manager update. - guiNode.updateGeometricState(); - } - - renderManager.render(tpf, context.isRenderable()); - simpleRender(renderManager); - stateManager.postRender(); - - // update compositor? - if( viewManager != null ) { - viewManager.postRender(); - } - } - - private void initAssetManager(){ - URL assetCfgUrl = null; - - if (settings != null){ - String assetCfg = settings.getString("AssetConfigURL"); - if (assetCfg != null){ - try { - assetCfgUrl = new URL(assetCfg); - } catch (MalformedURLException ex) { - } - if (assetCfgUrl == null) { - assetCfgUrl = LegacyApplication.class.getClassLoader().getResource(assetCfg); - if (assetCfgUrl == null) { - logger.log(Level.SEVERE, "Unable to access AssetConfigURL in asset config:{0}", assetCfg); - return; - } - } - } - } - if (assetCfgUrl == null) { - assetCfgUrl = JmeSystem.getPlatformAssetConfigURL(); - } - if (assetManager == null){ - assetManager = JmeSystem.newAssetManager(assetCfgUrl); - logger.config("Created asset manager from "+assetCfgUrl); - } - } - - private void initDisplay(){ - // acquire important objects - // from the context - settings = context.getSettings(); - - // Only reset the timer if a user has not already provided one - if (timer == null) { - timer = context.getTimer(); - } - - renderer = context.getRenderer(); - } - - private void initAudio(){ - if (settings.getAudioRenderer() != null && context.getType() != JmeContext.Type.Headless){ - audioRenderer = JmeSystem.newAudioRenderer(settings); - audioRenderer.initialize(); - AudioContext.setAudioRenderer(audioRenderer); - - listener = new Listener(); - audioRenderer.setListener(listener); - } - } - - /** - * Creates the camera to use for rendering. Default values are perspective - * projection with 45° field of view, with near and far values 1 and 1000 - * units respectively. - */ - private void initCamera(){ - cam = new Camera(settings.getWidth(), settings.getHeight()); - - cam.setFrustumPerspective(45f, (float)cam.getWidth() / cam.getHeight(), 1f, 1000f); - cam.setLocation(new Vector3f(0f, 0f, 10f)); - cam.lookAt(new Vector3f(0f, 0f, 0f), Vector3f.UNIT_Y); - - renderManager = new RenderManager(renderer); - //Remy - 09/14/2010 set the timer in the renderManager - renderManager.setTimer(timer); - - viewPort = renderManager.createMainView("Default", cam); - viewPort.setClearFlags(true, true, true); - - // Create a new cam for the gui - Camera guiCam = new Camera(settings.getWidth(), settings.getHeight()); - guiViewPort = renderManager.createPostView("Gui Default", guiCam); - guiViewPort.setClearFlags(false, false, false); - } - - /** - * Initializes mouse and keyboard input. Also - * initializes joystick input if joysticks are enabled in the - * AppSettings. - */ - private void initInput(){ - mouseInput = context.getMouseInput(); - if (mouseInput != null) - mouseInput.initialize(); - - keyInput = context.getKeyInput(); - if (keyInput != null) - keyInput.initialize(); - - touchInput = context.getTouchInput(); - if (touchInput != null) - touchInput.initialize(); - - if (settings.useJoysticks()){ - joyInput = context.getJoyInput(); - if (joyInput != null) - joyInput.initialize(); - } - - inputManager = new InputManager(mouseInput, keyInput, joyInput, touchInput); - } - - private void initStateManager(){ - stateManager = new AppStateManager(this); - - // Always register a ResetStatsState to make sure - // that the stats are cleared every frame - stateManager.attach(new ResetStatsState()); - } - - /** - * Do not call manually. - * Callback from ContextListener. - *

- * Initializes the Application, by creating a display and - * default camera. If display settings are not specified, a default - * 640x480 display is created. Default values are used for the camera; - * perspective projection with 45° field of view, with near - * and far values 1 and 1000 units respectively. - */ - private void initialize_internal(){ - if (assetManager == null){ - initAssetManager(); - } - - initDisplay(); - initCamera(); - - if (inputEnabled){ - initInput(); - } - initAudio(); - - // update timer so that the next delta is not too large -// timer.update(); - timer.reset(); - - // user code here - } - - @Override - public void initialize() { - logger.config("Initialize VR application..."); - - initialize_internal(); - cam.setFrustumFar(fFar); - cam.setFrustumNear(fNear); - dummyCam = cam.clone(); - if( isInVR() ) { - logger.config("VR mode enabled."); - - if( vrHardware != null ) { - vrHardware.initVRCompositor(compositorAllowed()); - } else { - logger.warning("No VR system found."); - } - - //FIXME: WARNING !! - viewManager = new OpenVRViewManager(null); - viewManager.setResolutionMultiplier(resMult); - inputManager.addMapping(RESET_HMD, new KeyTrigger(KeyInput.KEY_F9)); - setLostFocusBehavior(LostFocusBehavior.Disabled); - } else { - logger.config("VR mode disabled."); - viewPort.attachScene(rootNode); - guiViewPort.attachScene(guiNode); - } - - if( viewManager != null ) { - viewManager.initialize(); - } - - simpleInitApp(); - - // any filters created, move them now - if( viewManager != null ) { - viewManager.moveScreenProcessingToEyes(); - - // print out camera information - if( isInVR() ) { - logger.info("VR Initialization Information"); - if( viewManager.getLeftCamera() != null ){ - logger.info("camLeft: " + viewManager.getLeftCamera().toString()); - } - - if( viewManager.getRightCamera() != null ){ - logger.info("camRight: " + viewManager.getRightCamera().toString()); - } - } - } - } - - /** - * Initialize the application. This method has to be overridden by implementations. - */ - public abstract void simpleInitApp(); - - /** - * Destroy the application (release all resources). - */ - @Override - public void destroy() { - if( vrHardware != null ) { - vrHardware.destroy(); - vrHardware = null; - } - DISABLE_VR = true; - stateManager.cleanup(); - - destroyInput(); - if (audioRenderer != null) - audioRenderer.cleanup(); - - timer.reset(); - Runtime.getRuntime().exit(0); - } - - protected void destroyInput(){ - if (mouseInput != null) - mouseInput.destroy(); - - if (keyInput != null) - keyInput.destroy(); - - if (joyInput != null) - joyInput.destroy(); - - if (touchInput != null) - touchInput.destroy(); - - inputManager = null; - } - - @Override - public ViewPort getGuiViewPort() { - return guiViewPort; - } - - @Override - public ViewPort getViewPort() { - return viewPort; - } - - @Override - public Future enqueue(Callable callable) { - AppTask task = new AppTask<>(callable); - taskQueue.add(task); - return task; - } - - /** - * Enqueues a runnable object to execute in the jME3 - * rendering thread. - *

- * Runnables are executed right at the beginning of the main loop. - * They are executed even if the application is currently paused - * or out of focus. - * - * @param runnable The runnable to run in the main jME3 thread - */ - @Override - public void enqueue(Runnable runnable){ - enqueue(new RunnableWrapper(runnable)); - } - - private class RunnableWrapper implements Callable{ - private final Runnable runnable; - - public RunnableWrapper(Runnable runnable){ - this.runnable = runnable; - } - - @Override - public Object call(){ - runnable.run(); - return null; - } - } - - /** - * Requests the context to close, shutting down the main loop - * and making necessary cleanup operations. - * - * Same as calling stop(false) - * - * @see #stop(boolean) - */ - @Override - public void stop(){ - stop(false); - } - - /** - * Requests the context to close, shutting down the main loop - * and making necessary cleanup operations. - * After the application has stopped, it cannot be used anymore. - */ - @Override - public void stop(boolean waitFor){ - logger.log(Level.FINE, "Closing application: {0}", getClass().getName()); - context.destroy(waitFor); - } - - /** - * Restarts the context, applying any changed settings. - *

- * Changes to the {@link AppSettings} of this Application are not - * applied immediately; calling this method forces the context - * to restart, applying the new settings. - */ - @Override - public void restart(){ - context.setSettings(settings); - context.restart(); - } - - /** - * Sets an AppProfiler hook that will be called back for - * specific steps within a single update frame. Value defaults - * to null. - */ - @Override - public void setAppProfiler(AppProfiler prof) { - return; - } - - /** - * Returns the current AppProfiler hook, or null if none is set. - */ - @Override - public AppProfiler getAppProfiler() { - return null; - } -} diff --git a/jme3-xr/src/main/java/com/jme3/app/VRConstants.java b/jme3-xr/src/main/java/com/jme3/app/VRConstants.java deleted file mode 100644 index d6ed724766..0000000000 --- a/jme3-xr/src/main/java/com/jme3/app/VRConstants.java +++ /dev/null @@ -1,174 +0,0 @@ -package com.jme3.app; - -import java.util.HashMap; -import com.jme3.system.AppSettings; - -/** - * Some constants dedicated to the VR module. - * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr - * @since 3.1.0 - */ -public class VRConstants { - /** - * An AppSettings parameter that set if the VR compositor has to be used. - *

- * Type: boolean
- * Usage: {@link AppSettings appSettings}.{@link HashMap#put(Object, Object) put}(VRConstants.SETTING_USE_COMPOSITOR, value) - */ - public static final String SETTING_USE_COMPOSITOR = "VRUseCompositor"; - - /** - * An AppSettings parameter that set if the rendering has to use two eyes, - * regardless of VR API detection (turning this setting on without a VR system should lead to errors). - *

- * Type: boolean
- * Usage: {@link AppSettings appSettings}.{@link HashMap#put(Object, Object) put}(VRConstants.SETTING_VR_FORCE, value) - */ - public static final String SETTING_VR_FORCE = "VRForce"; - - /** - * An AppSettings parameter that set to invert the eyes of the HMD. - * Type: boolean
- * Usage: {@link AppSettings appSettings}.{@link HashMap#put(Object, Object) put}(VRConstants.SETTING_FLIP_EYES, value) - */ - public static final String SETTING_FLIP_EYES = "VRFlipEyes"; - - /** - * An AppSettings parameter that set if the GUI has to be displayed even if it is behind objects. - * Type: boolean
- * Usage: {@link AppSettings appSettings}.{@link HashMap#put(Object, Object) put}(VRConstants.SETTING_GUI_OVERDRAW, value) - * - */ - public static final String SETTING_GUI_OVERDRAW = "VRGUIOverdraw"; - - /** - * An AppSettings parameter that set if the GUI surface has to be curved. - * Type: boolean
- * Usage: {@link AppSettings appSettings}.{@link HashMap#put(Object, Object) put}(VRConstants.SETTING_GUI_CURVED_SURFACE, value) - */ - public static final String SETTING_GUI_CURVED_SURFACE = "VRGUICurvedSurface"; - - /** - * An AppSettings parameter that set if a mirror rendering has to be displayed on the screen. - * Runs faster when set to false. - * Type: boolean
- * Usage: {@link AppSettings appSettings}.{@link HashMap#put(Object, Object) put}(VRConstants.SETTING_ENABLE_MIRROR_WINDOW, value) - */ - public static final String SETTING_ENABLE_MIRROR_WINDOW = "VREnableMirrorWindow"; - - /** - * An AppSettings parameter that set if the VR rendering has to be disabled, - * regardless VR API and devices are presents. - * Type: boolean
- * Usage: {@link AppSettings appSettings}.{@link HashMap#put(Object, Object) put}(VRConstants.SETTING_DISABLE_VR, value) - */ - public static final String SETTING_DISABLE_VR = "VRDisable"; - - - /** - * An AppSettings parameter that set if the VR user is seated. - * Type: boolean
- * Usage: {@link AppSettings appSettings}.{@link HashMap#put(Object, Object) put}(VRConstants.SETTING_SEATED_EXPERIENCE, value) - */ - public static final String SETTING_SEATED_EXPERIENCE = "VRSeatedExperience"; - - /** - * An AppSettings parameter that set if the GUI has to be ignored. - * Type: boolean
- * Usage: {@link AppSettings appSettings}.{@link HashMap#put(Object, Object) put}(VRConstants.SETTING_NO_GUI, value) - */ - public static final String SETTING_NO_GUI = "VRNoGUI"; - - /** - * An AppSettings parameter that set if instance rendering has to be used. - * This setting requires some vertex shader changes (see Common/MatDefs/VR/Unshaded.j3md). - * Type: boolean
- * Usage: {@link AppSettings appSettings}.{@link HashMap#put(Object, Object) put}(VRConstants.SETTING_INSTANCE_RENDERING, value) - */ - public static final String SETTING_INSTANCE_RENDERING = "VRInstanceRendering"; - - /** - * An AppSettings parameter that set if Multi Sample Anti Aliasing has to be enabled. - * Type: boolean
- * Usage: {@link AppSettings appSettings}.{@link HashMap#put(Object, Object) put}(VRConstants.SETTING_DISABLE_MSAA, value) - */ - public static final String SETTING_DISABLE_MSAA = "VRDisableMSAA"; - - /** - * An AppSettings parameter that set the default field of view (FOV) value. - * Type: float
- * Usage: {@link AppSettings appSettings}.{@link HashMap#put(Object, Object) put}(VRConstants.SETTING_DEFAULT_FOV, value) - */ - public static final String SETTING_DEFAULT_FOV = "VRDefaultFOV"; - - /** - * An AppSettings parameter that set the default aspect ratio. - * Type: float
- * Usage: {@link AppSettings appSettings}.{@link HashMap#put(Object, Object) put}(VRConstants.SETTING_DEFAULT_ASPECT_RATIO, value) - */ - public static final String SETTING_DEFAULT_ASPECT_RATIO = "VRDefaultAspectRatio"; - - /** - * An AppSettings parameter that specifies the underlying VR API. Possible values are:
- *

    - *
  • {@link VRConstants#SETTING_VRAPI_OPENVR_VALUE SETTING_VRAPI_OPENVR_VALUE}: Use OpenVR binding. - *
  • {@link VRConstants#SETTING_VRAPI_OSVR_VALUE SETTING_VRAPI_OSVR_VALUE}: Use OSVR binding. - *
  • {@link VRConstants#SETTING_VRAPI_OPENVR_LWJGL_VALUE SETTING_VRAPI_OPENVR_LWJGL_VALUE}: Use OpenVR binding from LWJGL. - *
  • {@link VRConstants#SETTING_VRAPI_OCULUSVR_VALUE SETTING_VRAPI_OCULUSVR_VALUE}: Use Oculus Rift binding binding. - *
- * Type: int
- * Usage: {@link AppSettings appSettings}.{@link HashMap#put(Object, Object) put}(VRConstants.SETTING_VRAPI, value) - */ - public static final String SETTING_VRAPI = "VRAPI"; - - /** - * The identifier of the OpenVR system. - * - * Deprecated as only the lwjgl OpenVr version has been upgraded to modern action based inputs - * - * @see #SETTING_VRAPI_OSVR_VALUE - * @see #SETTING_VRAPI_OPENVR_LWJGL_VALUE - * @see #SETTING_VRAPI_OCULUSVR_VALUE - */ - @Deprecated - public static final int SETTING_VRAPI_OPENVR_VALUE = 1; - - /** - * The identifier of the OSVR system. - * - * Deprecated as an OpenVr system should be used instead for a non vender specific api - * - * @see #SETTING_VRAPI_OPENVR_VALUE - * @see #SETTING_VRAPI_OPENVR_LWJGL_VALUE - * @see #SETTING_VRAPI_OCULUSVR_VALUE - */ - @Deprecated - public static final int SETTING_VRAPI_OSVR_VALUE = 2; - - /** - * The identifier of the OpenVR from LWJGL system. - * - * @see #SETTING_VRAPI_OPENVR_VALUE - * @see #SETTING_VRAPI_OSVR_VALUE - * @see #SETTING_VRAPI_OCULUSVR_VALUE - */ - public static final int SETTING_VRAPI_OPENVR_LWJGL_VALUE = 3; - - /** - * The identifier of the Oculus Rift system. - * - * Deprecated as an OpenVr system should be used instead (and the rift itself is discontinued) - * - * @see #SETTING_VRAPI_OPENVR_VALUE - * @see #SETTING_VRAPI_OSVR_VALUE - * @see #SETTING_VRAPI_OPENVR_LWJGL_VALUE - */ - @Deprecated - public static final int SETTING_VRAPI_OCULUSVR_VALUE = 4; - - /** - * A private constructor to inhibit instantiation of this class. - */ - private VRConstants() { - } -} diff --git a/jme3-xr/src/main/java/com/jme3/app/VREnvironment.java b/jme3-xr/src/main/java/com/jme3/app/VREnvironment.java deleted file mode 100644 index 16ea59b5bb..0000000000 --- a/jme3-xr/src/main/java/com/jme3/app/VREnvironment.java +++ /dev/null @@ -1,527 +0,0 @@ -package com.jme3.app; - -import java.util.Locale; -import java.util.logging.Level; -import java.util.logging.Logger; - -import com.jme3.app.state.AppState; -import com.jme3.input.vr.VRAPI; -import com.jme3.input.vr.VRBounds; -import com.jme3.input.vr.VRInputAPI; -import com.jme3.input.vr.VRMouseManager; -import com.jme3.input.vr.VRViewManager; -import com.jme3.input.vr.lwjgl_openvr.LWJGLOpenVR; -import com.jme3.input.vr.lwjgl_openvr.LWJGLOpenVRMouseManager; -import com.jme3.input.vr.lwjgl_openvr.LWJGLOpenVRViewManager; -import com.jme3.input.vr.openvr.OpenVR; -import com.jme3.input.vr.openvr.OpenVRMouseManager; -import com.jme3.input.vr.openvr.OpenVRViewManager; -import com.jme3.input.vr.osvr.OSVR; -import com.jme3.input.vr.osvr.OSVRViewManager; -import com.jme3.renderer.Camera; -import com.jme3.scene.Spatial; -import com.jme3.system.AppSettings; -import com.jme3.system.jopenvr.JOpenVRLibrary; -import com.jme3.util.VRGuiManager; - -/** - * - * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr - * - */ -public class VREnvironment { - private static final Logger logger = Logger.getLogger(VREnvironment.class.getName()); - - private VRAPI hardware = null; - private VRGuiManager guiManager = null; - private VRMouseManager mouseManager = null; - private VRViewManager viewManager = null; - - private VRBounds bounds = null; - - /** - * The underlying system VR API. By default, set to {@link VRConstants#SETTING_VRAPI_OPENVR_VALUE}. - */ - public int vrBinding = VRConstants.SETTING_VRAPI_OPENVR_VALUE; - - private boolean seated = false; - - private Spatial observer = null; - - private boolean forceVR = false; - - private boolean vrSupportedOS = false; - - private boolean nogui = false; - - private boolean compositorOS; - - private boolean useCompositor = true; - - private boolean instanceRendering = false; - - private boolean disableSwapBuffers = true; - - private float defaultFOV = 108f; - - private float defaultAspect = 1f; - - private AppSettings settings = null; - - private Application application = null; - - private Camera dummyCam = null; - - private AppState app = null; - - private com.jme3.input.vr.lwjgl_openxr.HelloOpenXRGL mainXr; - - private boolean initialized = false; - - public VREnvironment(AppSettings settings){ - this.settings = settings; - - bounds = null; - - processSettings(); - } - - /** - * Get the VR underlying hardware. - * @return the VR underlying hardware. - */ - public VRAPI getVRHardware() { - return hardware; - } - - /** Will be set in LWJGLOpenVR, when ready. */ - public void setXR(com.jme3.input.vr.lwjgl_openxr.HelloOpenXRGL mainXr) { - this.mainXr = mainXr; - } - - public com.jme3.input.vr.lwjgl_openxr.HelloOpenXRGL getXr() - { - return mainXr; - } - - /** - * Set the VR bounds. - * @see #getVRBounds() - */ - public void setVRBounds(VRBounds bounds){ - this.bounds = bounds; - } - - /** - * Get the VR bounds. - * @return the VR bounds. - * @see #setVRBounds(VRBounds) - */ - public VRBounds getVRBounds(){ - return bounds; - } - - /** - * Get the VR dedicated input. - * @return the VR dedicated input. - */ - public VRInputAPI getVRinput() { - if( hardware == null ){ - return null; - } - - return hardware.getVRinput(); - } - - /** - * Get the VR view manager. - * @return the VR view manager. - */ - public VRViewManager getVRViewManager() { - return viewManager; - } - - /** - * Get the GUI manager attached to this environment. - * @return the GUI manager attached to this environment. - */ - public VRGuiManager getVRGUIManager(){ - return guiManager; - } - - /** - * Get the VR mouse manager attached to this environment. - * @return the VR mouse manager attached to this environment. - */ - public VRMouseManager getVRMouseManager(){ - return mouseManager; - } - - /** - * Can be used to change seated experience during runtime. - * @param isSeated true if designed for sitting, false for standing/roomscale - * @see #isSeatedExperience() - */ - public void setSeatedExperience(boolean isSeated) { - seated = isSeated; - if( hardware instanceof OpenVR ) { - if( hardware.getCompositor() == null ) { - return; - } - - if( seated ) { - ((OpenVR)hardware).getCompositor().SetTrackingSpace.apply(JOpenVRLibrary.ETrackingUniverseOrigin.ETrackingUniverseOrigin_TrackingUniverseSeated); - } else { - ((OpenVR)hardware).getCompositor().SetTrackingSpace.apply(JOpenVRLibrary.ETrackingUniverseOrigin.ETrackingUniverseOrigin_TrackingUniverseStanding); - } - } else if (hardware instanceof LWJGLOpenVR) { - if( hardware.isInitialized() ) { - ((LWJGLOpenVR)hardware).setTrackingSpace(seated); - } - } - } - - /** - * Check if the application is configured as a seated experience. - * @return true if the application is configured as a seated experience and false otherwise. - * @see #setSeatedExperience(boolean) - */ - public boolean isSeatedExperience() { - return seated; - } - - /** - * Set the VR headset height from the ground. - * @param amount the VR headset height from the ground. - * @see #getVRHeightAdjustment() - */ - public void setVRHeightAdjustment(float amount) { - if( viewManager != null ){ - viewManager.setHeightAdjustment(amount); - } - } - - /** - * Get the VR headset height from the ground. - * @return the VR headset height from the ground. - * @see #setVRHeightAdjustment(float) - */ - public float getVRHeightAdjustment() { - if( viewManager != null ){ - return viewManager.getHeightAdjustment(); - } - return 0f; - } - - /** - * Get the scene observer. If no observer has been set, this method return the application {@link #getCamera() camera}. - * @return the scene observer. - * @see #setObserver(Spatial) - */ - public Object getObserver() { - if( observer == null ) { - if (application != null){ - return application.getCamera(); - } else { - throw new IllegalStateException("VR environment is not attached to any application."); - } - } - return observer; - } - - /** - * Set the scene observer. The VR headset will be linked to it. If no observer is set, the VR headset is linked to the application {@link #getCamera() camera}. - * @param observer the scene observer. - */ - public void setObserver(Spatial observer) { - this.observer = observer; - } - - /** - * Get the default Field Of View (FOV) value. - * @return the default Field Of View (FOV) value. - * @see #setDefaultFOV(float) - */ - public float getDefaultFOV() { - return defaultFOV; - } - - /** - * Set the default Field Of View (FOV) value. - * @param defaultFOV the default Field Of View (FOV) value. - * @see #getDefaultFOV() - */ - public void setDefaultFOV(float defaultFOV) { - this.defaultFOV = defaultFOV; - } - - /** - * Get the default aspect ratio. - * @return the default aspect ratio. - * @see #setDefaultAspect(float) - */ - public float getDefaultAspect() { - return defaultAspect; - } - - /** - * Set the default aspect ratio. - * @param defaultAspect the default aspect ratio. - * @see #getDefaultAspect() - */ - public void setDefaultAspect(float defaultAspect) { - this.defaultAspect = defaultAspect; - } - - /** - * Get the {@link AppSettings settings} attached to this environment. - * @return the {@link AppSettings settings} attached to this environment. - * @see #setSettings(AppSettings) - */ - public AppSettings getSettings(){ - return settings; - } - - /** - * Set the {@link AppSettings settings} attached to this environment. - * @param settings the {@link AppSettings settings} attached to this environment. - * @see #getSettings() - */ - public void setSettings(AppSettings settings){ - this.settings = settings; - processSettings(); - } - - /** - * Get if the system currently support VR. - * @return true if the system currently support VR and false otherwise. - */ - public boolean isVRSupported() { - return vrSupportedOS; - } - - /** - * Check if the VR mode is enabled. - * @return true if the VR mode is enabled and false otherwise. - */ - public boolean isInVR() { - return (forceVR || vrSupportedOS && hardware != null && hardware.isInitialized() && isInitialized()); - } - - /** - * Check if the rendering is instanced (see Geometry instancing). - * @return true if the rendering is instanced and false otherwise. - */ - public boolean isInstanceRendering() { - return instanceRendering; - } - - public boolean isSwapBuffers(){ - return disableSwapBuffers; - } - - /** - * Check if the application has a GUI overlay attached. - * @return true if the application has a GUI overlay attached and false otherwise. - */ - public boolean hasTraditionalGUIOverlay() { - return !nogui; - } - - /** - * Check if the VR environment is initialized. A call to the {@link #initialize() initialize()} method should set this value to true - * @return true if the VR environment is initialized and false otherwise. - */ - public boolean isInitialized(){ - return initialized; - } - - /** - * Is the VR compositor is active. - * @return true if the VR compositor is active and false otherwise. - */ - public boolean compositorAllowed() { - return useCompositor && compositorOS; - } - - /** - * Reset headset pose if seating experience. - */ - public void resetSeatedPose(){ - if( vrSupportedOS == false || isSeatedExperience() == false ){ - return; - } - getVRHardware().reset(); - } - - public AppState getAppState(){ - return app; - } - - public Application getApplication(){ - return application; - } - - /** - * Get the {@link Camera camera} used for rendering. - * If the VR mode is {@link #isInVR() active}, this method return a dummy camera, otherwise, - * this method return the camera of the attached application. - * @return the camera attached used for rendering. - */ - public Camera getCamera() { - if( isInVR() && getVRViewManager() != null && getVRViewManager().getLeftCamera() != null ) { - return getDummyCamera(); - } - - return application.getCamera(); - } - - public Camera getDummyCamera(){ - if (dummyCam == null){ - if (application != null){ - if (application.getCamera() != null){ - dummyCam = application.getCamera().clone(); - } else { - if ((settings != null) && (settings.getWidth() != 0) && (settings.getHeight() != 0)){ - dummyCam = new Camera(settings.getWidth(), settings.getHeight()); - } else { - dummyCam = new Camera(0, 0); - } - } - } else { - throw new IllegalStateException("VR environment is not attached to any application."); - } - } - return dummyCam; - } - - /** - * Attach the VR environment to the given app state and application. - * This method should be called within the {@link AppState#stateAttached(com.jme3.app.state.AppStateManager) stateAttached(com.jme3.app.state.AppStateManager)} method - * from the app state. - * @param appState the app state to attach. - * @param application the application to attach. - */ - public void atttach(AppState appState, Application application){ - this.application = application; - this.app = appState; - - // Instantiate view manager - if (vrBinding == VRConstants.SETTING_VRAPI_OPENVR_VALUE){ - viewManager = new OpenVRViewManager(this); - } else if (vrBinding == VRConstants.SETTING_VRAPI_OSVR_VALUE){ - viewManager = new OSVRViewManager(this); - } else if (vrBinding == VRConstants.SETTING_VRAPI_OPENVR_LWJGL_VALUE) { - viewManager = new LWJGLOpenVRViewManager(this); - } else { - logger.severe("Cannot instantiate view manager, unknown VRAPI type: "+vrBinding); - } - } - - /** - * Initialize this VR environment. This method enable the system bindings and configure all the VR system modules. - * A call to this method has to be made before any use of VR capabilities. - * @return true if the VR environment is successfully initialized and false otherwise. - */ - public boolean initialize(){ - logger.config("Initializing VR environment."); - - initialized = false; - - String OS = System.getProperty("os.name", "generic").toLowerCase(Locale.ENGLISH); - vrSupportedOS = System.getProperty("sun.arch.data.model").equalsIgnoreCase("64"); //64-bit only - compositorOS = OS.contains("indows") || OS.contains("nux"); - - if (OS.contains("nux") && vrBinding != VRConstants.SETTING_VRAPI_OPENVR_LWJGL_VALUE){ - logger.severe("Only LWJGL VR backend is currently (partially) supported on Linux."); - vrSupportedOS = false; - } - - if(vrSupportedOS) { - if (vrBinding == VRConstants.SETTING_VRAPI_OPENVR_LWJGL_VALUE) { - guiManager = new VRGuiManager(this); - mouseManager = new LWJGLOpenVRMouseManager(this); - - hardware = new LWJGLOpenVR(this); - initialized = true; - logger.config("Creating OpenVR/LWJGL wrapper [SUCCESS]"); - } else { - logger.config("Cannot create VR binding: "+vrBinding+" [FAILED]"); - logger.log(Level.SEVERE, "Cannot initialize VR environment [FAILED]"); - } - - if( hardware.initialize() ) { - initialized &= true; - logger.config("VR native wrapper initialized [SUCCESS]"); - } else { - initialized &= false; - logger.warning("VR native wrapper initialized [FAILED]"); - logger.log(Level.SEVERE, "Cannot initialize VR environment [FAILED]"); - } - } else { - logger.log(Level.SEVERE, "System does not support VR capabilities."); - logger.log(Level.SEVERE, "Cannot initialize VR environment [FAILED]"); - } - - return initialized; - } - - private void processSettings(){ - if (settings != null){ - if (settings.get(VRConstants.SETTING_USE_COMPOSITOR) != null){ - useCompositor = settings.getBoolean(VRConstants.SETTING_USE_COMPOSITOR); - if( useCompositor == false ){ - disableSwapBuffers = false; - } - } - - if (settings.get(VRConstants.SETTING_ENABLE_MIRROR_WINDOW) != null){ - if( useCompositor == false ) { - disableSwapBuffers = false; - } else { - disableSwapBuffers = !settings.getBoolean(VRConstants.SETTING_ENABLE_MIRROR_WINDOW); - } - } - - if (settings.get(VRConstants.SETTING_GUI_OVERDRAW) != null){ - getVRGUIManager().setGuiOverdraw(settings.getBoolean(VRConstants.SETTING_GUI_OVERDRAW)); - } - - if (settings.get(VRConstants.SETTING_GUI_CURVED_SURFACE) != null){ - getVRGUIManager().setCurvedSurface(settings.getBoolean(VRConstants.SETTING_GUI_CURVED_SURFACE)); - } - - if (settings.get(VRConstants.SETTING_NO_GUI) != null){ - nogui = settings.getBoolean(VRConstants.SETTING_NO_GUI); - } - - if (settings.get(VRConstants.SETTING_VRAPI) != null){ - vrBinding = settings.getInteger(VRConstants.SETTING_VRAPI); - }else{ - vrBinding = VRConstants.SETTING_VRAPI_OPENVR_LWJGL_VALUE; //this is the binding that is best supported so makes sense to be the default - } - - if (settings.get(VRConstants.SETTING_SEATED_EXPERIENCE) != null){ - seated = settings.getBoolean(VRConstants.SETTING_SEATED_EXPERIENCE); - } - - if (settings.get(VRConstants.SETTING_INSTANCE_RENDERING) != null){ - instanceRendering = settings.getBoolean(VRConstants.SETTING_INSTANCE_RENDERING); - } - - if (settings.get(VRConstants.SETTING_DEFAULT_FOV) != null){ - defaultFOV = settings.getFloat(VRConstants.SETTING_DEFAULT_FOV); - } - - if (settings.get(VRConstants.SETTING_DEFAULT_ASPECT_RATIO) != null){ - defaultAspect = settings.getFloat(VRConstants.SETTING_DEFAULT_ASPECT_RATIO); - } - - if (settings.get(VRConstants.SETTING_FLIP_EYES) != null){ - if( getVRHardware() != null ){ - getVRHardware().setFlipEyes(settings.getBoolean(VRConstants.SETTING_FLIP_EYES)); - } - } - } - } -} diff --git a/jme3-xr/src/main/java/com/jme3/input/lwjgl/GlfwKeyInputVR.java b/jme3-xr/src/main/java/com/jme3/input/lwjgl/GlfwKeyInputVR.java deleted file mode 100644 index 6d4f5d6691..0000000000 --- a/jme3-xr/src/main/java/com/jme3/input/lwjgl/GlfwKeyInputVR.java +++ /dev/null @@ -1,153 +0,0 @@ -package com.jme3.input.lwjgl; - -/* - * Copyright (c) 2009-2021 jMonkeyEngine - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'jMonkeyEngine' nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import com.jme3.input.KeyInput; -import com.jme3.input.RawInputListener; -import com.jme3.input.event.KeyInputEvent; -import com.jme3.system.lwjgl.LwjglWindowVR; - -import org.lwjgl.glfw.GLFWKeyCallback; - -import java.util.LinkedList; -import java.util.Queue; -import java.util.logging.Logger; - -import static org.lwjgl.glfw.GLFW.*; - -/** - * A key input that wraps GLFW underlying components. - * @author reden - phr00t - https://github.com/phr00t - * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr - * - */ -public class GlfwKeyInputVR implements KeyInput { - - private static final Logger logger = Logger.getLogger(GlfwKeyInput.class.getName()); - - private LwjglWindowVR context; - private RawInputListener listener; - private boolean initialized, shift_pressed; - private GLFWKeyCallback keyCallback; - private Queue keyInputEvents = new LinkedList<>(); - - /** - * Create a new input attached to the given {@link LwjglWindowVR context}. - * @param context the context to attach to this input. - */ - public GlfwKeyInputVR(LwjglWindowVR context) { - this.context = context; - } - - @Override - public void initialize() { - if (!context.isRenderable()) { - return; - } - - glfwSetKeyCallback(context.getWindowHandle(), keyCallback = new GLFWKeyCallback() { - @Override - public void invoke(long window, int key, int scancode, int action, int mods) { - scancode = GlfwKeyMap.toJmeKeyCode(key); - if( key == GLFW_KEY_LEFT_SHIFT || key == GLFW_KEY_RIGHT_SHIFT ) { - shift_pressed = (action == GLFW_PRESS); - } else if( key >= 'A' && key <= 'Z' && !shift_pressed ) { - key += 32; // make lowercase - } else if( key >= 'a' && key <= 'z' && shift_pressed ) { - key -= 32; // make uppercase - } - final KeyInputEvent evt = new KeyInputEvent(scancode, (char) key, GLFW_PRESS == action, GLFW_REPEAT == action); - evt.setTime(getInputTimeNanos()); - keyInputEvents.add(evt); - } - }); - - glfwSetInputMode(context.getWindowHandle(), GLFW_STICKY_KEYS, 1); - - initialized = true; - logger.fine("Keyboard created."); - } - - /** - * Get the key count. - * @return the key count. - */ - public int getKeyCount() { - // This might not be correct - return GLFW_KEY_LAST - GLFW_KEY_SPACE; - } - - @Override - public void update() { - if (!context.isRenderable()) { - return; - } - - while (!keyInputEvents.isEmpty()) { - listener.onKeyEvent(keyInputEvents.poll()); - } - } - - @Override - public void destroy() { - if (!context.isRenderable()) { - return; - } - - keyCallback.free(); - - logger.fine("Keyboard destroyed."); - } - - @Override - public boolean isInitialized() { - return initialized; - } - - @Override - public void setInputListener(RawInputListener listener) { - this.listener = listener; - } - - @Override - public long getInputTimeNanos() { - return (long) (glfwGetTime() * 1000000000); - } - - @Override - public String getKeyName(int jmeKey) { - int glfwKey = GlfwKeyMap.fromJmeKeyCode(jmeKey); - return glfwGetKeyName(glfwKey, 0); - } - -} diff --git a/jme3-xr/src/main/java/com/jme3/input/lwjgl/GlfwMouseInputVR.java b/jme3-xr/src/main/java/com/jme3/input/lwjgl/GlfwMouseInputVR.java deleted file mode 100644 index 8566ca3a04..0000000000 --- a/jme3-xr/src/main/java/com/jme3/input/lwjgl/GlfwMouseInputVR.java +++ /dev/null @@ -1,332 +0,0 @@ -package com.jme3.input.lwjgl; - -/* - * Copyright (c) 2009-2021 jMonkeyEngine - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'jMonkeyEngine' nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import com.jme3.cursors.plugins.JmeCursor; -import com.jme3.input.MouseInput; -import com.jme3.input.RawInputListener; -import com.jme3.input.event.MouseButtonEvent; -import com.jme3.input.event.MouseMotionEvent; -import com.jme3.system.lwjgl.LwjglWindowVR; -import com.jme3.util.BufferUtils; - -import org.lwjgl.glfw.GLFWCursorPosCallback; -import org.lwjgl.glfw.GLFWMouseButtonCallback; -import org.lwjgl.glfw.GLFWScrollCallback; - -import java.nio.ByteBuffer; -import java.nio.IntBuffer; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.Map; -import java.util.Queue; -import java.util.logging.Logger; - -import static org.lwjgl.glfw.GLFW.*; -import org.lwjgl.glfw.GLFWImage; -import org.lwjgl.system.MemoryUtil; - -/** - * Captures mouse input using GLFW callbacks. It then temporarily stores these in event queues which are processed in the - * {@link #update()} method. Due to some of the GLFW button IDs, there is a conversion method in this class which will - * convert the GLFW left, middle and right mouse button to JME3 left, middle and right button codes.

- * This class support modifications dedicated to VR rendering. - * @author Daniel Johansson (dannyjo) - * @author reden - phr00t - https://github.com/phr00t - * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr * @author Julien Seinturier - (c) 2016 - JOrigin project - http:/www.jorigin.org - */ -public class GlfwMouseInputVR implements MouseInput { - - private static final Logger logger = Logger.getLogger(GlfwMouseInputVR.class.getName()); - - private static final int WHEEL_SCALE = 120; - - private LwjglWindowVR context; - private RawInputListener listener; - private boolean cursorVisible = true; - private int mouseX, xDelta; - private int mouseY, yDelta; - private int mouseWheel; - private boolean initialized; - private GLFWCursorPosCallback cursorPosCallback; - private GLFWScrollCallback scrollCallback; - private GLFWMouseButtonCallback mouseButtonCallback; - private Queue mouseMotionEvents = new LinkedList<>(); - private Queue mouseButtonEvents = new LinkedList<>(); - - private Map jmeToGlfwCursorMap = new HashMap<>(); - - /** - * Create a new mouse input attached to the given {@link LwjglWindowVR context}. - * @param context the context to which to attach the input. - */ - public GlfwMouseInputVR(LwjglWindowVR context) { - this.context = context; - } - - private void onCursorPos(long window, double xpos, double ypos) { - int x = (int) Math.round(xpos); - int y = context.getSettings().getHeight() - (int) Math.round(ypos); - - if (mouseX == 0) { - mouseX = x; - } - - if (mouseY == 0) { - mouseY = y; - } - - xDelta = x - mouseX; - yDelta = y - mouseY; - mouseX = x; - mouseY = y; - - if (xDelta != 0 || yDelta != 0) { - final MouseMotionEvent mouseMotionEvent = new MouseMotionEvent(x, y, xDelta, yDelta, mouseWheel, 0); - mouseMotionEvent.setTime(getInputTimeNanos()); - mouseMotionEvents.add(mouseMotionEvent); - } - } - - private void onWheelScroll(long window, double xOffset, double yOffset) { - mouseWheel += yOffset; - - final MouseMotionEvent mouseMotionEvent = new MouseMotionEvent(mouseX, mouseY, 0, 0, mouseWheel, (int) Math.round(yOffset)); - mouseMotionEvent.setTime(getInputTimeNanos()); - mouseMotionEvents.add(mouseMotionEvent); - } - private void onMouseButton(final long window, final int button, final int action, final int mods) { - final MouseButtonEvent mouseButtonEvent = new MouseButtonEvent(convertButton(button), action == GLFW_PRESS, mouseX, mouseY); - mouseButtonEvent.setTime(getInputTimeNanos()); - mouseButtonEvents.add(mouseButtonEvent); - } - - @Override - public void initialize() { - glfwSetCursorPosCallback(context.getWindowHandle(), cursorPosCallback = new GLFWCursorPosCallback() { - @Override - public void invoke(long window, double xpos, double ypos) { - onCursorPos(window, xpos, ypos); - } - }); - - glfwSetScrollCallback(context.getWindowHandle(), scrollCallback = new GLFWScrollCallback() { - @Override - public void invoke(final long window, final double xOffset, final double yOffset) { - onWheelScroll(window, xOffset, yOffset * WHEEL_SCALE); - } - }); - - glfwSetMouseButtonCallback(context.getWindowHandle(), mouseButtonCallback = new GLFWMouseButtonCallback() { - @Override - public void invoke(final long window, final int button, final int action, final int mods) { - onMouseButton(window, button, action, mods); - } - }); - - setCursorVisible(cursorVisible); - logger.fine("Mouse created."); - initialized = true; - } - - /** - * Set the position of the cursor on the display. - * @param x the x position of the cursor (pixel). - * @param y the y position of the cursor (pixel). - */ - public void setCursorPosition(int x, int y) { - if (!context.isRenderable()) { - return; - } - - glfwSetCursorPos(context.getWindowHandle(), x, y); - } - - /** - * Hide the active cursor within the display. - */ - public void hideActiveCursor() { - if (!context.isRenderable()) { - return; - } - - if (cursorVisible) { - glfwSetInputMode(context.getWindowHandle(), GLFW_CURSOR, GLFW_CURSOR_HIDDEN); - } - } - - /** - * Get the last delta in x (pixel). - * @return the last delta in x (pixel). - * @see #getLastDeltaY() - */ - public int getLastDeltaX() { - return xDelta; - } - - /** - * Get the last delta in y (pixel). - * @return the last delta in y (pixel). - * @see #getLastDeltaX() - */ - public int getLastDeltaY() { - return yDelta; - } - - /** - * Clear the last x and y deltas. - * @see #getLastDeltaX() - * @see #getLastDeltaY() - */ - public void clearDeltas() { - xDelta = 0; - yDelta = 0; - } - - /** - * Check if the input is initialized. - * @return true if the input is initialized and false otherwise. - */ - @Override - public boolean isInitialized() { - return initialized; - } - - @Override - public int getButtonCount() { - return GLFW_MOUSE_BUTTON_LAST + 1; - } - - @Override - public void update() { - while (!mouseMotionEvents.isEmpty()) { - listener.onMouseMotionEvent(mouseMotionEvents.poll()); - } - - while (!mouseButtonEvents.isEmpty()) { - listener.onMouseButtonEvent(mouseButtonEvents.poll()); - } - } - - @Override - public void destroy() { - if (!context.isRenderable()) { - return; - } - - cursorPosCallback.free(); - scrollCallback.free(); - mouseButtonCallback.free(); - - for (long glfwCursor : jmeToGlfwCursorMap.values()) { - glfwDestroyCursor(glfwCursor); - } - - logger.fine("Mouse destroyed."); - } - - @Override - public void setCursorVisible(boolean visible) { - cursorVisible = visible; - - if (!context.isRenderable()) { - return; - } - - if (cursorVisible) { - glfwSetInputMode(context.getWindowHandle(), GLFW_CURSOR, GLFW_CURSOR_NORMAL); - } else { - glfwSetInputMode(context.getWindowHandle(), GLFW_CURSOR, GLFW_CURSOR_DISABLED); - } - } - - @Override - public void setInputListener(RawInputListener listener) { - this.listener = listener; - } - - @Override - public long getInputTimeNanos() { - return (long) (glfwGetTime() * 1000000000); - } - - private long createGlfwCursor(JmeCursor jmeCursor) { - GLFWImage glfwImage = new GLFWImage(BufferUtils.createByteBuffer(GLFWImage.SIZEOF)); - - // TODO: currently animated cursors are not supported - IntBuffer imageData = jmeCursor.getImagesData(); - ByteBuffer buf = BufferUtils.createByteBuffer(imageData.capacity() * 4); - buf.asIntBuffer().put(imageData); - - glfwImage.set(jmeCursor.getWidth(), jmeCursor.getHeight(), buf); - - return glfwCreateCursor(glfwImage, jmeCursor.getXHotSpot(), jmeCursor.getYHotSpot()); - } - - @Override - public void setNativeCursor(JmeCursor jmeCursor) { - if (jmeCursor != null) { - Long glfwCursor = jmeToGlfwCursorMap.get(jmeCursor); - - if (glfwCursor == null) { - glfwCursor = createGlfwCursor(jmeCursor); - jmeToGlfwCursorMap.put(jmeCursor, glfwCursor); - } - - glfwSetCursor(context.getWindowHandle(), glfwCursor); - } else { - glfwSetCursor(context.getWindowHandle(), MemoryUtil.NULL); - } - } - - /** - * Simply converts the GLFW button code to a JME button code. If there is no - * match it just returns the GLFW button code. Bear in mind GLFW supports 8 - * different mouse buttons. - * - * @param glfwButton the raw GLFW button index. - * @return the mapped {@link MouseInput} button id. - */ - private int convertButton(final int glfwButton) { - switch (glfwButton) { - case GLFW_MOUSE_BUTTON_LEFT: - return MouseInput.BUTTON_LEFT; - case GLFW_MOUSE_BUTTON_MIDDLE: - return MouseInput.BUTTON_MIDDLE; - case GLFW_MOUSE_BUTTON_RIGHT: - return MouseInput.BUTTON_RIGHT; - default: - return glfwButton; - } - } -} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/AbstractVRMouseManager.java b/jme3-xr/src/main/java/com/jme3/input/vr/AbstractVRMouseManager.java deleted file mode 100644 index 6be4cae9fb..0000000000 --- a/jme3-xr/src/main/java/com/jme3/input/vr/AbstractVRMouseManager.java +++ /dev/null @@ -1,226 +0,0 @@ -package com.jme3.input.vr; - -import java.util.logging.Logger; - -import org.lwjgl.glfw.GLFW; - -import com.jme3.app.VREnvironment; -import com.jme3.input.MouseInput; -import com.jme3.input.lwjgl.GlfwMouseInputVR; -import com.jme3.material.RenderState.BlendMode; -import com.jme3.math.Vector2f; -import com.jme3.system.AppSettings; -import com.jme3.system.lwjgl.LwjglWindow; -import com.jme3.texture.Texture; -import com.jme3.texture.Texture2D; -import com.jme3.ui.Picture; - -/** - * An abstract implementation of a {@link VRMouseManager}. This class should be overridden by specific hardware implementation of VR devices. - * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr - * - */ -public abstract class AbstractVRMouseManager implements VRMouseManager { - private static final Logger logger = Logger.getLogger(AbstractVRMouseManager.class.getName()); - - private VREnvironment environment = null; - - private boolean vrMouseEnabled = true; - private boolean mouseAttached = false; - private Picture mouseImage; - private int recentCenterCount = 0; - - protected final Vector2f cursorPos = new Vector2f(); - - private float ySize, sensitivity = 8f, acceleration = 2f; - - private boolean thumbstickMode; - private float moveScale = 1f; - - /** - * Create a new AbstractVRMouseManager attached to the given {@link VREnvironment VR environment}. - * @param environment the {@link VREnvironment VR environment} that this manager is attached to. - */ - public AbstractVRMouseManager(VREnvironment environment) { - this.environment = environment; - } - - @Override - public void initialize() { - logger.config("Initializing VR mouse manager."); - - // load default mouse image - mouseImage = new Picture("mouse"); - setImage("Common/Util/mouse.png"); - // hide default cursor by making it invisible - - MouseInput mi = environment.getApplication().getContext().getMouseInput(); - if( mi instanceof GlfwMouseInputVR ){ - ((GlfwMouseInputVR)mi).hideActiveCursor(); - } - centerMouse(); - - logger.config("Initialized VR mouse manager [SUCCESS]"); - } - - @Override - public VREnvironment getVREnvironment() { - return environment; - } - - @Override - public void setVRMouseEnabled(boolean enabled) { - vrMouseEnabled = enabled; - } - - @Override - public void setThumbstickMode(boolean set) { - thumbstickMode = set; - } - - @Override - public boolean isThumbstickMode() { - return thumbstickMode; - } - - @Override - public void setSpeed(float sensitivity, float acceleration) { - this.sensitivity = sensitivity; - this.acceleration = acceleration; - } - - @Override - public float getSpeedSensitivity() { - return sensitivity; - } - - @Override - public float getSpeedAcceleration() { - return acceleration; - } - - @Override - public float getMouseMoveScale() { - return moveScale; - } - - @Override - public void setMouseMoveScale(float set) { - moveScale = set; - } - - @Override - public void setImage(String texture) { - if (environment != null){ - - if (environment.getApplication() != null){ - if( environment.isInVR() == false ){ - Texture tex = environment.getApplication().getAssetManager().loadTexture(texture); - mouseImage.setTexture(environment.getApplication().getAssetManager(), (Texture2D)tex, true); - ySize = tex.getImage().getHeight(); - mouseImage.setHeight(ySize); - mouseImage.setWidth(tex.getImage().getWidth()); - mouseImage.getMaterial().getAdditionalRenderState().setBlendMode(BlendMode.Alpha); - mouseImage.getMaterial().getAdditionalRenderState().setDepthWrite(false); - } else { - Texture tex = environment.getApplication().getAssetManager().loadTexture(texture); - mouseImage.setTexture(environment.getApplication().getAssetManager(), (Texture2D)tex, true); - ySize = tex.getImage().getHeight(); - mouseImage.setHeight(ySize); - mouseImage.setWidth(tex.getImage().getWidth()); - mouseImage.getMaterial().getAdditionalRenderState().setBlendMode(BlendMode.Alpha); - mouseImage.getMaterial().getAdditionalRenderState().setDepthWrite(false); - } - } else { - throw new IllegalStateException("This VR environment is not attached to any application."); - } - - } else { - throw new IllegalStateException("This VR view manager is not attached to any VR environment."); - } - } - - - @Override - public Vector2f getCursorPosition() { - - if (environment != null){ - if (environment.getApplication() != null){ - if( environment.isInVR() ) { - return cursorPos; - } - - return environment.getApplication().getInputManager().getCursorPosition(); - } else { - throw new IllegalStateException("This VR environment is not attached to any application."); - } - } else { - throw new IllegalStateException("This VR view manager is not attached to any VR environment."); - } - } - - @Override - public void centerMouse() { - if (environment != null){ - if (environment.getApplication() != null){ - // set mouse in center of the screen if newly added - Vector2f size = environment.getVRGUIManager().getCanvasSize(); - MouseInput mi = environment.getApplication().getContext().getMouseInput(); - AppSettings as = environment.getApplication().getContext().getSettings(); - if( mi instanceof GlfwMouseInputVR ) ((GlfwMouseInputVR)mi).setCursorPosition((int)(as.getWidth() / 2f), (int)(as.getHeight() / 2f)); - if( environment.isInVR() ) { - cursorPos.x = size.x / 2f; - cursorPos.y = size.y / 2f; - recentCenterCount = 2; - } - } else { - throw new IllegalStateException("This VR environment is not attached to any application."); - } - } else { - throw new IllegalStateException("This VR view manager is not attached to any VR environment."); - } - } - - @Override - public void update(float tpf) { - // if we are showing the cursor, add our picture as it - if( vrMouseEnabled && environment.getApplication().getInputManager().isCursorVisible() ) { - if(!mouseAttached) { - mouseAttached = true; - environment.getApplication().getGuiViewPort().attachScene(mouseImage); - centerMouse(); - // the "real" mouse pointer should stay hidden - if (environment.getApplication().getContext() instanceof LwjglWindow){ - GLFW.glfwSetInputMode(((LwjglWindow)environment.getApplication().getContext()).getWindowHandle(), GLFW.GLFW_CURSOR, GLFW.GLFW_CURSOR_DISABLED); - } - } - // handle mouse movements, which may be in addition to (or exclusive from) tracked movement - MouseInput mi = environment.getApplication().getContext().getMouseInput(); - if( mi instanceof GlfwMouseInputVR ) { - if( recentCenterCount <= 0 ) { - //Vector2f winratio = VRGuiManager.getCanvasToWindowRatio(); - cursorPos.x += ((GlfwMouseInputVR)mi).getLastDeltaX();// * winratio.x; - cursorPos.y += ((GlfwMouseInputVR)mi).getLastDeltaY();// * winratio.y; - if( cursorPos.x < 0f ) cursorPos.x = 0f; - if( cursorPos.y < 0f ) cursorPos.y = 0f; - if( cursorPos.x > environment.getVRGUIManager().getCanvasSize().x ) cursorPos.x = environment.getVRGUIManager().getCanvasSize().x; - if( cursorPos.y > environment.getVRGUIManager().getCanvasSize().y ) cursorPos.y = environment.getVRGUIManager().getCanvasSize().y; - } else recentCenterCount--; - ((GlfwMouseInputVR)mi).clearDeltas(); - } - // ok, update the cursor graphic position - Vector2f currentPos = getCursorPosition(); - mouseImage.setLocalTranslation(currentPos.x, currentPos.y - ySize, environment.getVRGUIManager().getGuiDistance() + 1f); - - mouseImage.updateGeometricState(); - - } else if(mouseAttached) { - mouseAttached = false; - environment.getApplication().getGuiViewPort().detachScene(mouseImage); - - // Use the setCursorVisible implementation to show the cursor again, depending on the state of cursorVisible - boolean cursorVisible = environment.getApplication().getInputManager().isCursorVisible(); - environment.getApplication().getContext().getMouseInput().setCursorVisible(cursorVisible); - } - } -} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/AbstractVRViewManager.java b/jme3-xr/src/main/java/com/jme3/input/vr/AbstractVRViewManager.java deleted file mode 100644 index 03868cedf7..0000000000 --- a/jme3-xr/src/main/java/com/jme3/input/vr/AbstractVRViewManager.java +++ /dev/null @@ -1,226 +0,0 @@ -package com.jme3.input.vr; - -import com.jme3.app.VREnvironment; -import com.jme3.post.CartoonSSAO; -import com.jme3.post.Filter; -import com.jme3.post.FilterPostProcessor; -import com.jme3.post.FilterUtil; -import com.jme3.post.SceneProcessor; -import com.jme3.post.filters.FogFilter; -import com.jme3.post.filters.TranslucentBucketFilter; -import com.jme3.post.ssao.SSAOFilter; -import com.jme3.renderer.Camera; -import com.jme3.renderer.ViewPort; -import com.jme3.shadow.DirectionalLightShadowFilter; -import com.jme3.shadow.VRDirectionalLightShadowRenderer; -import com.jme3.texture.Texture2D; - -/** - * A VR view manager. This class holds methods that enable to submit 3D views to the VR compositor. - * System-dependent classes should extend this one. - * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr - */ -public abstract class AbstractVRViewManager implements VRViewManager { - //private static final Logger logger = Logger.getLogger(AbstractVRViewManager.class.getName()); - - protected VREnvironment environment = null; - - protected Camera leftCamera; - protected ViewPort leftViewPort; - protected FilterPostProcessor leftPostProcessor; - protected Texture2D leftEyeTexture; - protected Texture2D leftEyeDepth; - - protected Camera rightCamera; - protected ViewPort rightViewPort; - protected FilterPostProcessor rightPostProcessor; - protected Texture2D rightEyeTexture; - protected Texture2D rightEyeDepth; - - protected ViewPort mirrorViewPort; - - private float resMult = 1f; - - private float heightAdjustment; - - @Override - public Camera getLeftCamera() { - return leftCamera; - } - - @Override - public Camera getRightCamera() { - return rightCamera; - } - - @Override - public ViewPort getLeftViewPort() { - return leftViewPort; - } - - @Override - public ViewPort getRightViewPort() { - return rightViewPort; - } - - /** - * Get the {@link ViewPort view port} attached to the mirror display. - * @return the view port attached to the mirror display. - */ - @Override - public ViewPort getMirrorViewPort() { - return mirrorViewPort; - } - - - @Override - public Texture2D getLeftTexture(){ - return leftEyeTexture; - } - - @Override - public Texture2D getRightTexture(){ - return rightEyeTexture; - } - - @Override - public Texture2D getLeftDepth(){ - return leftEyeDepth; - } - - @Override - public Texture2D getRightDepth(){ - return rightEyeDepth; - } - - @Override - public FilterPostProcessor getLeftPostProcessor(){ - return leftPostProcessor; - } - - @Override - public FilterPostProcessor getRightPostProcessor(){ - return rightPostProcessor; - } - - @Override - public float getResolutionMuliplier() { - return resMult; - } - - @Override - public void setResolutionMultiplier(float resMult) { - this.resMult = resMult; - } - - @Override - public float getHeightAdjustment() { - return heightAdjustment; - } - - @Override - public void setHeightAdjustment(float amount) { - heightAdjustment = amount; - } - - @Override - public VREnvironment getVREnvironment(){ - return environment; - } - - /** - * Handles moving filters from the main view to each eye - */ - @Override - public void moveScreenProcessingToEyes() { - if (environment != null){ - if( getRightViewPort() == null ){ - return; - } - - if (environment.getApplication() != null){ - syncScreenProcessing(environment.getApplication().getViewPort()); - environment.getApplication().getViewPort().clearProcessors(); - } else { - throw new IllegalStateException("The VR environment is not attached to any application."); - } - - } else { - throw new IllegalStateException("This VR view manager is not attached to any VR environment."); - } - } - - /** - * Sets the two views to use the list of {@link SceneProcessor processors}. - * @param sourceViewport the {@link ViewPort viewport} that contains the processors to use. - */ - public void syncScreenProcessing(ViewPort sourceViewport) { - if (environment != null){ - if( getRightViewPort() == null ){ - return; - } - - if (environment.getApplication() != null){ - // set up post-processing filters - if( getRightPostProcessor() == null ) { - rightPostProcessor = new FilterPostProcessor(environment.getApplication().getAssetManager()); - leftPostProcessor = new FilterPostProcessor(environment.getApplication().getAssetManager()); - } - // clear out all filters & processors, to start from scratch - getRightPostProcessor().removeAllFilters(); - getLeftPostProcessor().removeAllFilters(); - getLeftViewPort().clearProcessors(); - getRightViewPort().clearProcessors(); - // if we have no processors to sync, don't add the FilterPostProcessor - if( sourceViewport.getProcessors().isEmpty() ) return; - // add post processors we just made, which are empty - getLeftViewPort().addProcessor(getLeftPostProcessor()); - getRightViewPort().addProcessor(getRightPostProcessor()); - // Go through all of the filters in the processors list, - // add them to the left viewport processor, and clone them to the right. - for(SceneProcessor sceneProcessor : sourceViewport.getProcessors()) { - if (sceneProcessor instanceof FilterPostProcessor) { - for(Filter f : ((FilterPostProcessor)sceneProcessor).getFilterList() ) { - if( f instanceof TranslucentBucketFilter ) { - // just remove this filter, we will add it at the end manually - ((FilterPostProcessor)sceneProcessor).removeFilter(f); - } else { - getLeftPostProcessor().addFilter(f); - // clone to the right - Filter f2; - if(f instanceof FogFilter){ - f2 = FilterUtil.cloneFogFilter((FogFilter)f); - } else if (f instanceof CartoonSSAO ) { - f2 = new CartoonSSAO((CartoonSSAO)f); - } else if (f instanceof SSAOFilter){ - f2 = FilterUtil.cloneSSAOFilter((SSAOFilter)f); - } else if (f instanceof DirectionalLightShadowFilter){ - f2 = FilterUtil.cloneDirectionalLightShadowFilter(environment.getApplication().getAssetManager(), (DirectionalLightShadowFilter)f); - } else { - f2 = f; // dof, bloom, light scattering etc. - } - getRightPostProcessor().addFilter(f2); - } - } - } else if (sceneProcessor instanceof VRDirectionalLightShadowRenderer) { - // shadow processing - // TODO: make right shadow processor use same left shadow maps for performance - VRDirectionalLightShadowRenderer dlsr = (VRDirectionalLightShadowRenderer) sceneProcessor; - VRDirectionalLightShadowRenderer dlsrRight = dlsr.clone(); - dlsrRight.setLight(dlsr.getLight()); - getRightViewPort().getProcessors().add(0, dlsrRight); - getLeftViewPort().getProcessors().add(0, sceneProcessor); - } - } - // make sure each has a translucent filter renderer - getLeftPostProcessor().addFilter(new TranslucentBucketFilter()); - getRightPostProcessor().addFilter(new TranslucentBucketFilter()); - } else { - throw new IllegalStateException("The VR environment is not attached to any application."); - } - - } else { - throw new IllegalStateException("This VR view manager is not attached to any VR environment."); - } - } -} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/AnalogActionState.java b/jme3-xr/src/main/java/com/jme3/input/vr/AnalogActionState.java deleted file mode 100644 index 8cf519ff0b..0000000000 --- a/jme3-xr/src/main/java/com/jme3/input/vr/AnalogActionState.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.jme3.input.vr; - -public class AnalogActionState{ - - /** - * The X coordinate of the analog data (typically between -1 and 1 for joystick coordinates or 0 and 1 for - * trigger pulls) - */ - public final float x; - - /** - * The Y coordinate of the analog data (typically between -1 and 1) - * - * Will be zero if the analog action doesn't have at least 2 dimensions - */ - public final float y; - - /** - * The Z coordinate of the analog data (typically between -1 and 1) - * - * Will be zero if the analog action doesn't have at least 3 dimensions - */ - public final float z; - - /** - * The change in the X coordinate since the last frame - */ - public final float deltaX; - - /** - * The change in the Y coordinate since the last frame - */ - public final float deltaY; - - /** - * The change in the Z coordinate since the last frame - */ - public final float deltaZ; - - public AnalogActionState(float x, float y, float z, float deltaX, float deltaY, float deltaZ){ - this.x = x; - this.y = y; - this.z = z; - this.deltaX = deltaX; - this.deltaY = deltaY; - this.deltaZ = deltaZ; - } -} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/DigitalActionState.java b/jme3-xr/src/main/java/com/jme3/input/vr/DigitalActionState.java deleted file mode 100644 index 1da865eecf..0000000000 --- a/jme3-xr/src/main/java/com/jme3/input/vr/DigitalActionState.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.jme3.input.vr; - -public class DigitalActionState{ - - /** - * The current value of this action - */ - public final boolean state; - - /** - * If since the last loop the value of this action has changed - */ - public final boolean changed; - - public DigitalActionState(boolean state, boolean changed){ - this.state = state; - this.changed = changed; - } -} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/HmdType.java b/jme3-xr/src/main/java/com/jme3/input/vr/HmdType.java deleted file mode 100644 index 8dfe9b9365..0000000000 --- a/jme3-xr/src/main/java/com/jme3/input/vr/HmdType.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.jme3.input.vr; - -/** - * The type of VR Head Mounted Device (HMD) - * @author reden - phr00t - https://github.com/phr00t - * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr - */ -public enum HmdType { - /** - * HTC vive Head Mounted Device (HMD). - */ - HTC_VIVE, - - /** - * Valve Index Head Mounted Device (HMD). - */ - VALVE_INDEX, - - /** - * Oculus Rift Head Mounted Device (HMD). - */ - OCULUS_RIFT, - - /** - * OSVR generic Head Mounted Device (HMD). - */ - OSVR, - - /** - * FOVE Head Mounted Device (HMD). - */ - FOVE, - - /** - * STARVR Head Mounted Device (HMD). - */ - STARVR, - - /** - * GameFace Head Mounted Device (HMD). - */ - GAMEFACE, - - /** - * PlayStation VR (formerly Morpheus) Head Mounted Device (HMD). - */ - MORPHEUS, - - /** - * Samsung GearVR Head Mounted Device (HMD). - */ - GEARVR, - - /** - * a null Head Mounted Device (HMD). - */ - NULL, - - /** - * a none Head Mounted Device (HMD). - */ - NONE, - - /** - * a not referenced Head Mounted Device (HMD). - */ - OTHER -} \ No newline at end of file diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/VRAPI.java b/jme3-xr/src/main/java/com/jme3/input/vr/VRAPI.java deleted file mode 100644 index e2afa0e789..0000000000 --- a/jme3-xr/src/main/java/com/jme3/input/vr/VRAPI.java +++ /dev/null @@ -1,183 +0,0 @@ -package com.jme3.input.vr; - -import com.jme3.math.Matrix4f; -import com.jme3.math.Quaternion; -import com.jme3.math.Vector2f; -import com.jme3.math.Vector3f; -import com.jme3.renderer.Camera; - -/** - * An interface that represents a VR system. This interface has to be implemented in order to wrap underlying VR system (OpenVR, OSVR, ...) - * @author reden - phr00t - https://github.com/phr00t - * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr - */ -public interface VRAPI { - /** - * Initialize this object from a VR system. All the native bindings to underlying VR system should be done within this method. - * @return true if the initialization is a success and false otherwise. - */ - public boolean initialize(); - - /** - * Initialize the VR compositor that will be used for rendering. - * @param allowed true if the use of VR compositor is allowed and false otherwise. - * @return true if the initialization is a success and false otherwise. - */ - public boolean initVRCompositor(boolean allowed); - - /** - * Get the object that wraps natively the VR system. - * @return the object that wraps natively the VR system. - */ - public Object getVRSystem(); - - /** - * Get the object that wraps natively the VR compositor. - * @return the object that wraps natively the VR system. - */ - public Object getCompositor(); - - /** - * Get the name of the underlying VR system. - * @return the name of the underlying VR system. - */ - public String getName(); - - /** - * Get the input provided by the underlying VR system. - * @return the input provided by the underlying VR system. - */ - public VRInputAPI getVRinput(); - - /** - * Flip the left and right eye. - * @param set true if the eyes has to be flipped and false otherwise. - */ - public void setFlipEyes(boolean set); - - /** - * Set if latency information has to be logged. - * @param set true if latency information has to be logged and false otherwise. - */ - public void printLatencyInfoToConsole(boolean set); - - /** - * Get the Head Mounted Device (HMD) display frequency. - * @return the Head Mounted Device (HMD) display frequency. - */ - public int getDisplayFrequency(); - - /** - * Close the link with underlying VR system and free all attached resources. - */ - public void destroy(); - - /** - * Check if the VR API is initialized. - * @return true if the VR API is initialized and false otherwise. - * @see #initialize() - */ - public boolean isInitialized(); - - /** - * Reset the VR system. After a call to this method, the current position of the HMD should be - * the origin (i-e the observer without any combined transformation). - */ - public void reset(); - - /** - * Get the size of a Head Mounted Device (HMD) rendering area in pixels. - * @param store the size of a Head Mounted Device (HMD) rendering area in pixels (modified). - */ - public void getRenderSize(Vector2f store); - - //public float getFOV(int dir); - - /** - * Get the Head Mounted Device (HMD) interpupilar distance in meters. - * @return the Head Mounted Device (HMD) interpupilar distance in meters. - */ - public float getInterpupillaryDistance(); - - /** - * Get the Head Mounted Device (HMD) orientation. - * @return the Head Mounted Device (HMD) orientation. - */ - public Quaternion getOrientation(); - - /** - * Get the Head Mounted Device (HMD) position. - * @return the Head Mounted Device (HMD) orientation. - */ - public Vector3f getPosition(); - - /** - * Get the Head Mounted Device (HMD) position and orientation. - * @param storePos the Head Mounted Device (HMD) position (modified). - * @param storeRot the Head Mounted Device (HMD) rotation (modified). - */ - public void getPositionAndOrientation(Vector3f storePos, Quaternion storeRot); - - /** - * Update Head Mounted Device (HMD) pose internal storage. This method should be called before other calls to HMD position/orientation access. - */ - public void updatePose(); - - /** - * Get the Head Mounted Device (HMD) left eye projection matrix. - * @param cam the camera attached to the left eye. - * @return the Head Mounted Device (HMD) left eye projection matrix. - */ - public Matrix4f getHMDMatrixProjectionLeftEye(Camera cam); - - /** - * Get the Head Mounted Device (HMD) right eye projection matrix. - * @param cam the camera attached to the right eye. - * @return the Head Mounted Device (HMD) right eye projection matrix. - */ - public Matrix4f getHMDMatrixProjectionRightEye(Camera cam); - - /** - * Get the Head Mounted Device (HMD) left eye pose (position of the eye from the head) as a {@link Vector3f vector}. - * @return the Head Mounted Device (HMD) left eye pose as a {@link Vector3f vector}. - */ - public Vector3f getHMDVectorPoseLeftEye(); - - /** - * Get the Head Mounted Device (HMD) right eye pose (position of the eye from the head) as a {@link Vector3f vector}. - * @return the Head Mounted Device (HMD) right eye pose as a {@link Vector3f vector}. - */ - public Vector3f getHMDVectorPoseRightEye(); - - /** - * Returns the transform between the view space and left eye space. - * Eye space is the per-eye flavor of view space that provides stereo disparity. - * Instead of Model * View * Projection the model is Model * View * Eye * Projection. - * Normally View and Eye will be multiplied together and treated as View. - * This matrix incorporates the user's interpupillary distance (IPD). - * @return the transform between the view space and eye space. - */ - public Matrix4f getHMDMatrixPoseLeftEye(); - - /** - * Returns the transform between the view space and right eye space. - * Eye space is the per-eye flavor of view space that provides stereo disparity. - * Instead of Model * View * Projection the model is Model * View * Eye * Projection. - * Normally View and Eye will be multiplied together and treated as View. - * This matrix incorporates the user's interpupillary distance (IPD). - * @return the transform between the view space and eye space. - */ - public Matrix4f getHMDMatrixPoseRightEye(); - - /** - * Get the Head Mounted Device (HMD) type. - * @return the Head Mounted Device (HMD) type. - */ - public HmdType getType(); - - /** - * Get the seated to absolute position. - * @return the seated to absolute position. - */ - public Vector3f getSeatedToAbsolutePosition(); -} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/VRBounds.java b/jme3-xr/src/main/java/com/jme3/input/vr/VRBounds.java deleted file mode 100644 index 179dbb1b08..0000000000 --- a/jme3-xr/src/main/java/com/jme3/input/vr/VRBounds.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.jme3.input.vr; - -import com.jme3.math.Vector2f; - -/** - * This interface describes the VR playground bounds. - * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr - * - */ -public interface VRBounds { - - /** - * Get the size of the VR playground. - * @return the size of the VR playground. - */ - public Vector2f getPlaySize(); -} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/VRInputAPI.java b/jme3-xr/src/main/java/com/jme3/input/vr/VRInputAPI.java deleted file mode 100644 index 53d99a8014..0000000000 --- a/jme3-xr/src/main/java/com/jme3/input/vr/VRInputAPI.java +++ /dev/null @@ -1,377 +0,0 @@ -package com.jme3.input.vr; - -import com.jme3.math.Quaternion; -import com.jme3.math.Vector2f; -import com.jme3.math.Vector3f; - -/** - * An interface that represents a VR input (typically a VR device such as a controller). - * @author reden - phr00t - https://github.com/phr00t - * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr - */ -public interface VRInputAPI { - - /** - * Registers an action manifest. An actions manifest is a file that defines "actions" a player can make. - * (An action is an abstract version of a button press). The action manifest may then also include references to - * further files that define default mappings between those actions and physical buttons on the VR controllers. - * - * Note that registering an actions manifest will deactivate legacy inputs (i.e. methods such as {@link #isButtonDown} - * will no longer work - * - * See https://github.com/ValveSoftware/openvr/wiki/Action-manifest for documentation on how to create an - * action manifest - * - * This option is only relevant to OpenVR - * - * @param actionManifestAbsolutePath - * the absolute file path to an actions manifest - * @param startingActiveActionSet - * the actions in the manifest are divided into action sets (groups) by their prefix (e.g. "/actions/main"). - * These action sets can be turned off and on per frame. This argument sets the action set that will be - * active now. The active action sets can be later be changed by calling {@link #setActiveActionSet}. - * Note that at present only a single set at a time is supported - * - */ - default void registerActionManifest( String actionManifestAbsolutePath, String startingActiveActionSet ){ - throw new UnsupportedOperationException("Action manifests are not supported for the currently used VR API"); - } - - /** - * Updates the active action set (the action group that will have their states available to be polled). - * - * Note that this update will not take effect until the next loop - * Note that at present only a single set at a time is supported - * - * @param activeActionSet - * the actions in the manifest are divided into action sets (groups) by their prefix (e.g. "/actions/main"). - * These action sets can be turned off and on per frame. This argument sets the action set that will be - * active now. - */ - default void setActiveActionSet( String activeActionSet ){ - throw new UnsupportedOperationException("Action manifests are not supported for the currently used VR API"); - } - - /** - * Gets the current state of the action (abstract version of a button press). - * - * This is called for digital style actions (a button is pressed, or not) - * - * This method is commonly called when it's not important which hand the action is bound to (e.g. if a button press - * is opening your inventory that could be bound to either left or right hand and that would not matter). - * - * If the handedness matters use {@link #getDigitalActionState(String, String)} - * - * {@link #registerActionManifest} must have been called before using this method. - * - * @param actionName The name of the action. Will be something like /actions/main/in/openInventory - * @return the DigitalActionState that has details on if the state has changed, what the state is etc. - */ - default DigitalActionState getDigitalActionState( String actionName ){ - return getDigitalActionState(actionName, null); - } - - /** - * Gets the current state of the action (abstract version of a button press). - * - * This is called for digital style actions (a button is pressed, or not) - * - * This method is commonly called when it is important which hand the action is found on. For example while - * holding a weapon a button may be bound to "eject magazine" to allow you to load a new one, but that would only - * want to take effect on the hand that is holding the weapon - * - * Note that restrictToInput only restricts, it must still be bound to the input you want to receive the input from in - * the action manifest default bindings. - * - * {@link #registerActionManifest} must have been called before using this method. - * - * @param actionName The name of the action. E.g. /actions/main/in/openInventory - * @param restrictToInput the input to restrict the action to. E.g. /user/hand/right. Or null, which means "any input" - * @return the DigitalActionState that has details on if the state has changed, what the state is etc. - */ - default DigitalActionState getDigitalActionState( String actionName, String restrictToInput ){ - throw new UnsupportedOperationException("Action manifests are not supported for the currently used VR API"); - } - - /** - * Gets the current state of the action (abstract version of a button press). - * - * This is called for analog style actions (most commonly joysticks, but button pressure can also be mapped in analog). - * - * This method is commonly called when it's not important which hand the action is bound to (e.g. if the thumb stick - * is controlling a third-person character in-game that could be bound to either left or right hand and that would - * not matter). - * - * If the handedness matters use {@link #getAnalogActionState(String, String)} - * - * {@link #registerActionManifest} must have been called before using this method. - * - * @param actionName The name of the action. E.g. /actions/main/in/openInventory - * @return the DigitalActionState that has details on if the state has changed, what the state is etc. - */ - default AnalogActionState getAnalogActionState( String actionName ){ - return getAnalogActionState(actionName, null); - } - - /** - * Gets the current state of the action (abstract version of a button press). - * - * This is called for analog style actions (most commonly joysticks, but button pressure can also be mapped in analog). - * - * This method is commonly called when it is important which hand the action is found on. For example an "in universe" - * joystick that has a hat control might (while you are holding it) bind to the on-controller hat, but only on the hand - * holding it - * - * Note that restrictToInput only restricts, it must still be bound to the input you want to receive the input from in - * the action manifest default bindings. - * - * {@link #registerActionManifest} must have been called before using this method. - * - * @param actionName The name of the action. E.g. /actions/main/in/openInventory - * @param restrictToInput the input to restrict the action to. E.g. /user/hand/right. Or null, which means "any input" - * @return the DigitalActionState that has details on if the state has changed, what the state is etc. - */ - default AnalogActionState getAnalogActionState( String actionName, String restrictToInput ){ - throw new UnsupportedOperationException("Action manifests are not supported for the currently used VR API"); - } - - /** - * Check if the given button is down (more generally if the given input type is activated). - * - * Deprecated as should use an actions manifest approach. See {@link #registerActionManifest}. Note; action based will only work with the OpenVR api - * - * @param controllerIndex the index of the controller to check. - * @param checkButton the button / input to check. - * @return true if the button / input is down / activated and false otherwise. - */ - @Deprecated - public boolean isButtonDown(int controllerIndex, VRInputType checkButton); - - /** - * Check if the given button / input from the given controller has been just pressed / activated. - * - * Deprecated as should use an actions manifest approach. See {@link #registerActionManifest}. Note; action based will only work with the OpenVR api - * - * @param controllerIndex the index of the controller. - * @param checkButton the button / input to check. - * @return true if the given button / input from the given controller has been just pressed / activated and false otherwise. - */ - @Deprecated - public boolean wasButtonPressedSinceLastCall(int controllerIndex, VRInputType checkButton); - - /** - * Reset the current activation of the inputs. After a call to this method, all input activation is considered as new activation. - * @see #wasButtonPressedSinceLastCall(int, VRInputType) - * - * Deprecated as should use an actions manifest approach. See {@link #registerActionManifest}. Note; action based will only work with the OpenVR api - */ - @Deprecated - public void resetInputSinceLastCall(); - - /** - * Get the controller axis delta from the last value. - * - * Deprecated as should use an actions manifest approach. See {@link #registerActionManifest}. Note; action based will only work with the OpenVR api - * - * @param controllerIndex the index of the controller. - * @param forAxis the axis. - * @return the controller axis delta from the last call. - */ - @Deprecated - public Vector2f getAxisDeltaSinceLastCall(int controllerIndex, VRInputType forAxis); - - /** - * Get the controller velocity on all axes. - * @param controllerIndex the index of the controller. - * @return the controller velocity on all axes. - * @see #getAngularVelocity(int) - */ - public Vector3f getVelocity(int controllerIndex); - - /** - * Get the controller angular velocity on all axes. - * @param controllerIndex the index of the controller. - * @return the controller angular velocity on all axes. - * @see #getVelocity(int) - */ - public Vector3f getAngularVelocity(int controllerIndex); - - /** - * Get the axis value for the given input on the given controller. - * This value is the {@link #getAxisRaw(int, VRInputType) raw value} multiplied by the {@link #getAxisMultiplier() axis multiplier}. - * - * Deprecated as should use an actions manifest approach. See {@link #registerActionManifest}. Note; action based will only work with the OpenVR api - * - * @param controllerIndex the index of the controller. - * @param forAxis the axis. - * @return the axis value for the given input on the given controller. - * @see #getAxisRaw(int, VRInputType) - * @see #getAxisMultiplier() - */ - @Deprecated - public Vector2f getAxis(int controllerIndex, VRInputType forAxis); - - /** - * Get the axis value for the given input on the given controller. - * - * Deprecated as should use an actions manifest approach. See {@link #registerActionManifest} Note; action based will only work with the OpenVR api - * - * @param controllerIndex the index of the controller. - * @param forAxis the axis. - * @return the axis value for the given input on the given controller. - * @see #getAxis(int, VRInputType) - */ - @Deprecated - public Vector2f getAxisRaw(int controllerIndex, VRInputType forAxis); - - /** - * Initialize the input. - * @return true if the initialization is successful and false otherwise. - */ - public boolean init(); - - /** - * Get the number of tracked controllers (for example, hand controllers) attached to the VR system. - * @return the number of controllers attached to the VR system. - * @see #getTrackedController(int) - */ - public int getTrackedControllerCount(); - - /** - * Get a tracked controller (for example, a hand controller) that is attached to the VR system. - * @param index the index of the controller. - * @return the tracked controller (for example, a hand controller) that is attached to the VR system. - * @see #getTrackedControllerCount() - */ - public VRTrackedController getTrackedController(int index); - - /** - * Update the connected controllers. - * This method should be used just after the initialization of the input. - */ - public void updateConnectedControllers(); - - /** - * Update the controller states. - * This method should be called before accessing any controller data. - */ - public void updateControllerStates(); - - /** - * Get the native wrapping of a controller state. - * @param index the index of the controller. - * @return the native wrapping of a controller state. - */ - public Object getRawControllerState(int index); - - /** - * Swap the two hands (exchange the hands' controller 1 and 2 indices). - */ - public void swapHands(); - - /** - * Get the controller axis multiplier. - * The controller axis raw data (trackpad, trigger, ...) value is multiplied by the one given in parameter. - * @return the controller axis multiplier. - * @see #setAxisMultiplier(float) - */ - public float getAxisMultiplier(); - - /** - * Set the controller axis multiplier. - * The controller axis raw data (trackpad, trigger, ...) value is multiplied by the one given in parameter. - * @param set the controller axis multiplier. - * @see #getAxisMultiplier() - */ - public void setAxisMultiplier(float set); - - //public Matrix4f getPoseForInputDevice(int index); - - /** - * Check if the VR system has the focus and if it's not used by other process. - * @return true if the VR system has the focus and false otherwise. - */ - public boolean isInputFocused(); - - /** - * Check if the input device is actually tracked (i-e if we can obtain a pose from the input). - * @param index the index of the controller. - * @return true if the input device is actually tracked and false otherwise. - */ - public boolean isInputDeviceTracking(int index); - - /** - * Get the orientation of the input. - * @param index the index of the controller. - * @return the orientation of the input. - */ - public Quaternion getOrientation(int index); - - /** - * Get the position of the input. - * @param index the index of the controller. - * @return the position of the input. - */ - public Vector3f getPosition(int index); - - /** - * Get where is the controller pointing, after all rotations are combined. - * This position should include observer rotation from the VR application. - * @param index the index of the controller. - * @return the rotation of the input after all positional tracking is complete. - */ - public Quaternion getFinalObserverRotation(int index); - - /** - * Get the position of the input after all positional tracking is complete. - * This position should include observer position from the VR application. - * @param index the index of the controller. - * @return the position of the input after all positional tracking is complete. - */ - public Vector3f getFinalObserverPosition(int index); - - /** - * Trigger a haptic pulse on the selected controller for the duration given in parameters (in seconds). - * - * Deprecated, use triggerHapticAction instead (as it has more options and doesn't use deprecated methods) - * - * @param controllerIndex the index of the controller. - * @param seconds the duration of the pulse in seconds. - */ - @Deprecated - public void triggerHapticPulse(int controllerIndex, float seconds); - - /** - * Triggers a haptic action (aka a vibration). - * - * Note if you want a haptic action in only one hand that is done either by only binding the action to one hand in - * the action manifest's standard bindings or by binding to both and using {@link #triggerHapticAction(String, float, float, float, String)} - * to control which input it gets set to at run time - * - * @param actionName The name of the action. Will be something like /actions/main/out/vibrate - * @param duration how long in seconds the - * @param frequency in cycles per second - * @param amplitude between 0 and 1 - */ - default void triggerHapticAction( String actionName, float duration, float frequency, float amplitude){ - triggerHapticAction( actionName, duration, frequency, amplitude, null ); - } - - /** - * Triggers a haptic action (aka a vibration) restricted to just one input (e.g. left or right hand). - * - * Note that restrictToInput only restricts, it must still be bound to the input you want to send the haptic to in - * the action manifest default bindings. - * - * This method is typically used to bind the haptic to both hands then decide at run time which hand to sent to * - * - * @param actionName The name of the action. Will be something like /actions/main/out/vibrate - * @param duration how long in seconds the - * @param frequency in cycles per second - * @param amplitude between 0 and 1 - * @param restrictToInput the input to restrict the action to. E.g. /user/hand/right, /user/hand/left. Or null, which means "any input" - */ - default void triggerHapticAction( String actionName, float duration, float frequency, float amplitude, String restrictToInput){ - throw new UnsupportedOperationException("Action manifests are not supported for the currently used VR API"); - } -} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/VRInputType.java b/jme3-xr/src/main/java/com/jme3/input/vr/VRInputType.java deleted file mode 100644 index 0d090c349c..0000000000 --- a/jme3-xr/src/main/java/com/jme3/input/vr/VRInputType.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.jme3.input.vr; - -/** - * The type of a VR input. This enumeration enables to determine which part of the VR device is involved within input callback. - * @author reden - phr00t - https://github.com/phr00t - * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr - * - * Deprecated, use the LWJGL openVR bindings and use actions instead - * - */ -@Deprecated -public enum VRInputType { - /** - * an HTC vive trigger axis (about Vive controller). - */ - ViveTriggerAxis(0), - - /** - * an HTC vive trackpad axis (about Vive controller). - */ - ViveTrackpadAxis(1), - - /** - * an HTC vive grip button (about Vive controller). - */ - ViveGripButton(2), - - /** - * an HTC vive menu button (about Vive controller). - */ - ViveMenuButton(3); - - /** - * The value that codes the input type. - */ - private final int value; - - /** - * Construct a new input type with the given code. - * @param value the code of the input type. - */ - private VRInputType(int value) { - this.value = value; - } - - /** - * Get the value (code) of the input type. - * @return the value (code) of the input type. - */ - public int getValue() { - return value; - } -} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/VRMouseManager.java b/jme3-xr/src/main/java/com/jme3/input/vr/VRMouseManager.java deleted file mode 100644 index b6923388f2..0000000000 --- a/jme3-xr/src/main/java/com/jme3/input/vr/VRMouseManager.java +++ /dev/null @@ -1,111 +0,0 @@ -package com.jme3.input.vr; - -import com.jme3.app.VREnvironment; -import com.jme3.input.controls.AnalogListener; -import com.jme3.math.Vector2f; - -/** - * A class dedicated to the handling of the mouse within VR environment. - * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr - */ -public interface VRMouseManager { - /** - * Initialize the VR mouse manager. - */ - public void initialize(); - - /** - * Get the {@link VREnvironment VR Environment} to which this manager is attached. - * @return the {@link VREnvironment VR Environment} to which this manager is attached. - */ - public VREnvironment getVREnvironment(); - - /** - * Set if the mouse cursor should be used in the VR view. - * @param enabled true if the mouse cursor should be displayed in VR and false otherwise. - */ - public void setVRMouseEnabled(boolean enabled); - - /** - * Set if the VR device controller is used within thumb stick mode. - * @param set true if the VR device controller is used within thumb stick mode and false otherwise. - */ - public void setThumbstickMode(boolean set); - - /** - * Get if the VR device controller is used within thumb stick mode. - * @return true if the VR device controller is used within thumb stick mode and false otherwise. - */ - public boolean isThumbstickMode(); - - /** - * Set the speed of the mouse. - * @param sensitivity the sensitivity of the mouse. - * @param acceleration the acceleration of the mouse. - * @see #getSpeedAcceleration() - * @see #getSpeedSensitivity() - */ - public void setSpeed(float sensitivity, float acceleration); - - /** - * Get the sensitivity of the mouse. - * @return the sensitivity of the mouse. - * @see #setSpeed(float, float) - */ - public float getSpeedSensitivity(); - - /** - * Get the acceleration of the mouse. - * @return the acceleration of the mouse. - * @see #setSpeed(float, float) - */ - public float getSpeedAcceleration(); - - /** - * Get the move scale. - * return the move scale. - * @see #setMouseMoveScale(float) - */ - public float getMouseMoveScale(); - - /** - * Set the mouse move scale. - * @param set the mouse move scale. - * @see #getMouseMoveScale() - */ - public void setMouseMoveScale(float set); - - /** - * Set the image to use as mouse cursor. The given string describe an asset that the underlying application asset manager has to load. - * @param texture the image to use as mouse cursor. - */ - public void setImage(String texture); - - /** - * Update analog controller as it was a mouse controller. - * @param inputIndex the index of the controller attached to the VR system. - * @param mouseListener the JMonkey mouse listener to trigger. - * @param mouseXName the mouseX identifier. - * @param mouseYName the mouseY identifier - * @param tpf the time per frame. - */ - public void updateAnalogAsMouse(int inputIndex, AnalogListener mouseListener, String mouseXName, String mouseYName, float tpf); - - /** - * Get the actual cursor position. - * @return the actual cursor position. - */ - public Vector2f getCursorPosition(); - - /** - * Center the mouse on the display. - */ - public void centerMouse(); - - /** - * Update the mouse manager. This method should not be called manually. - * The standard behavior for this method is to be called from the {@link VRViewManager#update(float) update method} of the attached {@link VRViewManager VR view manager}. - * @param tpf the time per frame. - */ - public void update(float tpf); -} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/VRTrackedController.java b/jme3-xr/src/main/java/com/jme3/input/vr/VRTrackedController.java deleted file mode 100644 index e5133d2e38..0000000000 --- a/jme3-xr/src/main/java/com/jme3/input/vr/VRTrackedController.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.jme3.input.vr; - -import com.jme3.math.Matrix4f; -import com.jme3.math.Quaternion; -import com.jme3.math.Vector3f; - -/** - * TODO - * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr - */ -public interface VRTrackedController { - /** - * Get the controller name. - * @return the controller name. - */ - public String getControllerName(); - - /** - * Get the controller manufacturer. - * @return the controller manufacturer. - */ - public String getControllerManufacturer(); - - /** - * Get the position of the tracked device. This value is the translation component of the device {@link #getPose() pose}. - * @return the position of the tracked device. - * @see #getOrientation() - * @see #getPose() - */ - public Vector3f getPosition(); - - /** - * Get the orientation of the tracked device. This value is the rotation component of the device {@link #getPose() pose}. - * @return the orientation of the tracked device. - * @see #getPosition() - * @see #getPose() - */ - public Quaternion getOrientation(); - - /** - * Get the pose of the tracked device. - * The pose is a 4x4 matrix than combine the {@link #getPosition() position} and the {@link #getOrientation() orientation} of the device. - * @return the pose of the tracked device. - * @see #getPosition() - * @see #getOrientation() - */ - public Matrix4f getPose(); -} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/VRViewManager.java b/jme3-xr/src/main/java/com/jme3/input/vr/VRViewManager.java deleted file mode 100644 index 87aaadff90..0000000000 --- a/jme3-xr/src/main/java/com/jme3/input/vr/VRViewManager.java +++ /dev/null @@ -1,172 +0,0 @@ -package com.jme3.input.vr; - -import com.jme3.app.VRAppState; -import com.jme3.app.VREnvironment; -import com.jme3.app.state.AppState; -import com.jme3.post.FilterPostProcessor; -import com.jme3.renderer.Camera; -import com.jme3.renderer.ViewPort; -import com.jme3.texture.Texture2D; - -/** - * A VR view manager. This interface describes methods that enable to submit 3D views to the VR compositor. - * @author reden - phr00t - https://github.com/phr00t - * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr - */ -public interface VRViewManager { - - /** - * The name of the left view. - */ - public final static String LEFT_VIEW_NAME = "Left View"; - - /** - * The name of the right view. - */ - public final static String RIGHT_VIEW_NAME = "Right View"; - - /** - * Get the {@link Camera camera} attached to the left eye. - * @return the {@link Camera camera} attached to the left eye. - * @see #getRightCamera() - */ - public Camera getLeftCamera(); - - /** - * Get the {@link Camera camera} attached to the right eye. - * @return the {@link Camera camera} attached to the right eye. - * @see #getLeftCamera() - */ - public Camera getRightCamera(); - - /** - * Get the {@link ViewPort viewport} attached to the left eye. - * @return the {@link ViewPort viewport} attached to the left eye. - * @see #getRightViewPort() - */ - public ViewPort getLeftViewPort(); - - - /** - * Get the {@link ViewPort viewport} attached to the right eye. - * @return the {@link ViewPort viewport} attached to the right eye. - * @see #getLeftViewPort() - */ - public ViewPort getRightViewPort(); - - /** - * Get the {@link ViewPort view port} attached to the mirror display. - * @return the view port attached to the mirror display. - * @see #getLeftViewPort() - * @see #getRightViewPort() - */ - public ViewPort getMirrorViewPort(); - - /** - * Get the texture attached to the left eye. - * @return the texture attached to the left eye. - * @see #getRightTexture() - */ - public Texture2D getLeftTexture(); - - /** - * Get the texture attached to the right eye. - * @return the texture attached to the right eye. - * @see #getLeftTexture() - */ - public Texture2D getRightTexture(); - - /** - * Get the depth texture attached to the left eye. - * @return the texture attached to the left eye. - * @see #getRightTexture() - */ - public Texture2D getLeftDepth(); - - /** - * Get the depth texture attached to the right eye. - * @return the texture attached to the right eye. - * @see #getLeftTexture() - */ - public Texture2D getRightDepth(); - - /** - * Get the {@link FilterPostProcessor filter post processor} attached to the left eye. - * @return the {@link FilterPostProcessor filter post processor} attached to the left eye. - * @see #getRightPostProcessor() - */ - public FilterPostProcessor getLeftPostProcessor(); - - /** - * Get the {@link FilterPostProcessor filter post processor} attached to the right eye. - * @return the {@link FilterPostProcessor filter post processor} attached to the right eye. - * @see #getLeftPostProcessor() - */ - public FilterPostProcessor getRightPostProcessor(); - - /** - * Get the resolution multiplier. - * @return the resolution multiplier. - * @see #setResolutionMultiplier(float) - */ - public float getResolutionMuliplier(); - - /** - * Set the resolution multiplier. - * @param resMult the resolution multiplier. - * @see #getResolutionMuliplier() - */ - public void setResolutionMultiplier(float resMult); - - /** - * Get the height adjustment to apply to the cameras before rendering. - * @return the height adjustment to apply to the cameras before rendering. - * @see #setHeightAdjustment(float) - */ - public float getHeightAdjustment(); - - /** - * Set the height adjustment to apply to the cameras before rendering. - * @param amount the height adjustment to apply to the cameras before rendering. - * @see #getHeightAdjustment() - */ - public void setHeightAdjustment(float amount); - - /** - * Get the {@link VREnvironment VR environment} to which the view manager is attached. - * @return the {@link VREnvironment VR environment} to which the view manager is attached. - */ - public VREnvironment getVREnvironment(); - - /** - * Initialize the VR view manager. This method should be called after the attachment of a {@link VREnvironment VR environment} to an application. - */ - public void initialize(); - - /** - * Update the VR view manager. - * This method is called by the attached {@link VRAppState app state} and should not be called manually. - * @param tpf the time per frame. - */ - public void update(float tpf); - - /** - * This method contains action to be done during the rendering phase. - * This method should be called for example from the {@link com.jme3.app.state.AppState#render(com.jme3.renderer.RenderManager) render} method of an {@link com.jme3.app.state.AppState app state}. - * @see #postRender() - */ - public void render(); - - /** - * Send the rendering result as textures to the two eyes. - * This method should be called after all the rendering operations - * (for example at the end of the {@link AppState#postRender() postRender()} method of the attached app state.) - * @see #render() - */ - public void postRender(); - - /** - * Handles moving filters from the main view to each eye. - */ - public void moveScreenProcessingToEyes(); -} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVR.java b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVR.java deleted file mode 100644 index fecca2eeea..0000000000 --- a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVR.java +++ /dev/null @@ -1,277 +0,0 @@ -package com.jme3.input.vr.lwjgl_openvr; - -import com.jme3.app.VREnvironment; -import com.jme3.input.vr.HmdType; -import com.jme3.input.vr.VRAPI; -import com.jme3.math.Matrix4f; -import com.jme3.math.Quaternion; -import com.jme3.math.Vector2f; -import com.jme3.math.Vector3f; -import com.jme3.renderer.Camera; -import com.jme3.util.VRUtil; - -import java.nio.IntBuffer; -import java.util.logging.Logger; -import org.lwjgl.BufferUtils; - -/** - * A class that wraps an OpenVR system. - * @author reden - phr00t - * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr - * @author Rickard Edén - */ -public class LWJGLOpenVR implements VRAPI { - private static final Logger logger = Logger.getLogger(LWJGLOpenVR.class.getName()); - - private static boolean initSuccess = false; - private static boolean flipEyes = false; - - private IntBuffer hmdDisplayFrequency; -// private TrackedDevicePose.Buffer trackedDevicePose; -// protected TrackedDevicePose[] hmdTrackedDevicePoses; - - protected IntBuffer hmdErrorStore = BufferUtils.createIntBuffer(1); - - private final Quaternion rotStore = new Quaternion(); - private final Vector3f posStore = new Vector3f(); - - protected Matrix4f[] poseMatrices; - - private Matrix4f hmdProjectionLeftEye; - private Matrix4f hmdProjectionRightEye; - private Matrix4f hmdPoseLeftEye; - private Matrix4f hmdPoseRightEye; - - private Vector3f hmdPoseLeftEyeVec, hmdPoseRightEyeVec, hmdSeatToStand; - - private LWJGLOpenVRInput vrInput; - - private VREnvironment environment = null; - - /** - * Create a new OpenVR system - * attached to the given {@link VREnvironment VR environment}. - * @param environment the VR environment to which this API is attached. - */ - public LWJGLOpenVR(VREnvironment environment){ - this.environment = environment; - } - - @Override - public LWJGLOpenVRInput getVRinput() { - return vrInput; - } - - @Override - public Object getVRSystem() { - throw new UnsupportedOperationException("Not yet implemented!"); - } - - @Override - public Object getCompositor() { - throw new UnsupportedOperationException("Not yet implemented!"); - } - - @Override - public String getName() { - return "OpenXR/LWJGL"; - } - - @Override - public void setFlipEyes(boolean set) { - flipEyes = set; - } - - @Override - public void printLatencyInfoToConsole(boolean set) { - // not implemented - } - - @Override - public int getDisplayFrequency() { - if( hmdDisplayFrequency == null ) return 0; - return hmdDisplayFrequency.get(0); - } - - @Override - public boolean initialize() { - logger.config("Initializing OpenVR system..."); - - com.jme3.input.vr.lwjgl_openxr.HelloOpenXRGL mainXr = new com.jme3.input.vr.lwjgl_openxr.HelloOpenXRGL(environment); - vrInput = new LWJGLOpenVRInput(environment); - initSuccess = vrInput.init(); - if (initSuccess) - { - vrInput.updateConnectedControllers(); - environment.setXR(mainXr); - } - return initSuccess; - } - - @Override - public boolean initVRCompositor(boolean allowed) { - return true; - } - - /** - * Initialize the headset camera. - * @param allowed true is the use of the headset camera is allowed and false otherwise. - * @return token for camera - */ - public long initCamera(boolean allowed) { - return 0; - } - - @Override - public void destroy() { - } - - @Override - public boolean isInitialized() { - return initSuccess; - } - - @Override - public void reset() { -// VRChaperone.VRChaperone_ResetZeroPose(VR.ETrackingUniverseOrigin_TrackingUniverseSeated); - hmdSeatToStand = null; - } - - @Override - public void getRenderSize(Vector2f store) { - environment.getXr().getRenderSize(store); - } - - @Override - public float getInterpupillaryDistance() { - throw new UnsupportedOperationException("Not yet implemented!"); - } - - @Override - public Quaternion getOrientation() { - environment.getXr().getViewRotation(rotStore); - return rotStore; - } - - @Override - public Vector3f getPosition() { - environment.getXr().getViewPosition(posStore); - return posStore; - } - - @Override - public void getPositionAndOrientation(Vector3f storePos, Quaternion storeRot) { - storePos.set(getPosition()); - storeRot.set(getOrientation()); - } - - @Override - public void updatePose(){ - } - - @Override - public Matrix4f getHMDMatrixProjectionLeftEye(Camera cam){ - if( hmdProjectionLeftEye != null ) { - return hmdProjectionLeftEye; - } else { -// HmdMatrix44 mat = HmdMatrix44.create(); -// mat = VRSystem.VRSystem_GetProjectionMatrix(VR.EVREye_Eye_Left, cam.getFrustumNear(), cam.getFrustumFar(), mat); - hmdProjectionLeftEye = new Matrix4f(); - //TODO -// convertSteamVRMatrix4ToMatrix4f(mat, hmdProjectionLeftEye); - return hmdProjectionLeftEye; - } - } - - @Override - public Matrix4f getHMDMatrixProjectionRightEye(Camera cam){ - if( hmdProjectionRightEye != null ) { - return hmdProjectionRightEye; - } else { -// HmdMatrix44 mat = HmdMatrix44.create(); -// mat = VRSystem.VRSystem_GetProjectionMatrix(VR.EVREye_Eye_Right, cam.getFrustumNear(), cam.getFrustumFar(), mat); - hmdProjectionRightEye = new Matrix4f(); - //TODO -// convertSteamVRMatrix4ToMatrix4f(mat, hmdProjectionRightEye); - return hmdProjectionRightEye; - } - } - - @Override - public Vector3f getHMDVectorPoseLeftEye() { - if( hmdPoseLeftEyeVec == null ) { - hmdPoseLeftEyeVec = getHMDMatrixPoseLeftEye().toTranslationVector(); - // set default IPD if none or broken - if( hmdPoseLeftEyeVec.x <= 0.080f * -0.5f || hmdPoseLeftEyeVec.x >= 0.040f * -0.5f ) { - hmdPoseLeftEyeVec.x = 0.065f * -0.5f; - } - if( flipEyes == false ) hmdPoseLeftEyeVec.x *= -1f; // it seems these need flipping - } - return hmdPoseLeftEyeVec; - } - - @Override - public Vector3f getHMDVectorPoseRightEye() { - if( hmdPoseRightEyeVec == null ) { - hmdPoseRightEyeVec = getHMDMatrixPoseRightEye().toTranslationVector(); - // set default IPD if none or broken - if( hmdPoseRightEyeVec.x >= 0.080f * 0.5f || hmdPoseRightEyeVec.x <= 0.040f * 0.5f ) { - hmdPoseRightEyeVec.x = 0.065f * 0.5f; - } - if( flipEyes == false ) hmdPoseRightEyeVec.x *= -1f; // it seems these need flipping - } - return hmdPoseRightEyeVec; - } - - @Override - public Vector3f getSeatedToAbsolutePosition() { - if( environment.isSeatedExperience() == false ) return Vector3f.ZERO; - if( hmdSeatToStand == null ) { - hmdSeatToStand = new Vector3f(); - - //TODO - } - return hmdSeatToStand; - } - - @Override - public Matrix4f getHMDMatrixPoseLeftEye(){ - if( hmdPoseLeftEye != null ) { - return hmdPoseLeftEye; - } else { - //HmdMatrix34 mat = HmdMatrix34.create(); - //VRSystem.VRSystem_GetEyeToHeadTransform(VR.EVREye_Eye_Left, mat); - //TODO - hmdPoseLeftEye = new Matrix4f(); - //return convertSteamVRMatrix3ToMatrix4f(mat, hmdPoseLeftEye); - return hmdPoseLeftEye; - } - } - - @Override - public Matrix4f getHMDMatrixPoseRightEye(){ - if( hmdPoseRightEye != null ) { - return hmdPoseRightEye; - } else { - //HmdMatrix34 mat = HmdMatrix34.create(); - //VRSystem.VRSystem_GetEyeToHeadTransform(VR.EVREye_Eye_Right, mat); - //TODO - hmdPoseRightEye = new Matrix4f(); - //return convertSteamVRMatrix3ToMatrix4f(mat, hmdPoseRightEye); - return hmdPoseRightEye; - } - } - - @Override - public HmdType getType() { - return HmdType.OTHER; - } - - public void setTrackingSpace(boolean isSeated){ - } - - - public Matrix4f[] getPoseMatrices() { - return poseMatrices; - } -} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRAnalogActionData.java b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRAnalogActionData.java deleted file mode 100644 index 2c5652dd89..0000000000 --- a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRAnalogActionData.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.jme3.input.vr.lwjgl_openvr; - -//import org.lwjgl.openvr.InputAnalogActionData; - -/** - * This is a set of reusable parts that are used when accessing an analogue action - * (Analogue meaning something like a trigger pull or joystick coordinate) - */ -public class LWJGLOpenVRAnalogActionData{ - - /** - * This is the address string for the action. It will be something like /actions/main/in/openInventory - */ - String actionName; - - /** - * The handle used to request the action's state from LWJGL. - * - * It is how the action is addressed efficiently - */ - long actionHandle; - - /** - * This is a LWJGL object that will have the actions state passed into it. It is mapped to native memory so we - * don't want to keep creating new ones. - */ -// InputAnalogActionData actionData; - -// public LWJGLOpenVRAnalogActionData(String actionName, long actionHandle, InputAnalogActionData actionData){ -// this.actionName = actionName; -// this.actionHandle = actionHandle; -// this.actionData = actionData; -// } -} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRBounds.java b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRBounds.java deleted file mode 100644 index 07834860d7..0000000000 --- a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRBounds.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.jme3.input.vr.lwjgl_openvr; - -import com.jme3.input.vr.VRAPI; -import com.jme3.input.vr.VRBounds; -import com.jme3.math.Vector2f; -import com.jme3.util.BufferUtils; -import java.nio.FloatBuffer; - -import java.util.logging.Logger; - -/** - * A class that represents VR world bounds. - * @author reden - phr00t - https://github.com/phr00t - * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr - * @author Rickard Edén - */ -public class LWJGLOpenVRBounds implements VRBounds { - private static Logger logger = Logger.getLogger(LWJGLOpenVRBounds.class.getName()); - - private Vector2f playSize; - private boolean setup = false; - - /** - * Initialize the VR bounds. - * @return true if the initialization is a success and false otherwise. - */ - public boolean init(VRAPI api) { - logger.config("Initialize VR bounds..."); - - if( !setup ) { -// vrChaperone = new VR_IVRChaperone_FnTable(JOpenVRLibrary.VR_GetGenericInterface(JOpenVRLibrary.IVRChaperone_Version, api.hmdErrorStore).getPointer()); - FloatBuffer fbX = BufferUtils.createFloatBuffer(1); - FloatBuffer fbZ = BufferUtils.createFloatBuffer(1); -// org.lwjgl.openvr.VRChaperone.VRChaperone_GetPlayAreaSize(fbX, fbZ); - - playSize = new Vector2f(fbX.get(0), fbZ.get(0)); - setup = true; - logger.config("Initialize VR bounds [SUCCESS]"); - return true; // init success - } - - logger.config("Initialize VR bounds already done."); - return true; // already initialized - } - - @Override - public Vector2f getPlaySize() { - return playSize; - } -} \ No newline at end of file diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRDigitalActionData.java b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRDigitalActionData.java deleted file mode 100644 index 00390d6a0d..0000000000 --- a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRDigitalActionData.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.jme3.input.vr.lwjgl_openvr; - -//import org.lwjgl.openvr.InputDigitalActionData; - -/** - * This is a set of reusable parts that are used when accessing a digital action - * (Digital meaning something like a button press, that is either on or off) - */ -public class LWJGLOpenVRDigitalActionData{ - - /** - * This is the address string for the action. It will be something like /actions/main/in/openInventory - */ - String actionName; - - /** - * The handle used to request the action's state from LWJGL. - * - * It is how the action is addressed efficiently - */ - long actionHandle; - - /** - * This is a LWJGL object that will have the actions state passed into it. It is mapped to native memory so we - * don't want to keep creating new ones. - */ -// InputDigitalActionData actionData; - -// public LWJGLOpenVRDigitalActionData(String actionName, long actionHandle, InputDigitalActionData actionData){ -// this.actionName = actionName; -// this.actionHandle = actionHandle; -// this.actionData = actionData; -// } -} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRInput.java b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRInput.java deleted file mode 100644 index 1d2ee5ece8..0000000000 --- a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRInput.java +++ /dev/null @@ -1,717 +0,0 @@ -package com.jme3.input.vr.lwjgl_openvr; - -import java.nio.LongBuffer; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.logging.Logger; - -import com.jme3.app.VREnvironment; -import com.jme3.input.vr.AnalogActionState; -import com.jme3.input.vr.DigitalActionState; -import com.jme3.input.vr.VRInputAPI; -import com.jme3.input.vr.VRInputType; -import com.jme3.input.vr.VRTrackedController; -import com.jme3.input.vr.VRViewManager; -import com.jme3.math.Quaternion; -import com.jme3.math.Vector2f; -import com.jme3.math.Vector3f; -import com.jme3.renderer.Camera; -import com.jme3.scene.Spatial; -import com.jme3.util.VRUtil; -import java.nio.IntBuffer; -import org.lwjgl.BufferUtils; -import org.lwjgl.openxr.XrControllerModelStateMSFT; -//import org.lwjgl.openvr.HmdVector3; -//import org.lwjgl.openvr.InputAnalogActionData; -//import org.lwjgl.openvr.InputDigitalActionData; -//import org.lwjgl.openvr.VR; -//import org.lwjgl.openvr.VRActiveActionSet; -//import org.lwjgl.openvr.VRControllerState; -//import org.lwjgl.openvr.VRInput; -//import org.lwjgl.openvr.VRSystem; - -/* -make helper functions to pull the following easily from raw data (DONE) -trigger: -Controller#1, Axis#0 X: 0.0, Y: 0.0 -Controller#1, Axis#1 X: 1.0, Y: 0.0 -Controller#1, Axis#2 X: 0.0, Y: 0.0 -Controller#1, Axis#3 X: 0.0, Y: 0.0 -Controller#1, Axis#4 X: 0.0, Y: 0.0 -Button press: 8589934592 (when full), touch: 8589934592 -touchpad (upper left): -Controller#1, Axis#0 X: -0.6059755, Y: 0.2301706 -Controller#1, Axis#1 X: 0.0, Y: 0.0 -Controller#1, Axis#2 X: 0.0, Y: 0.0 -Controller#1, Axis#3 X: 0.0, Y: 0.0 -Controller#1, Axis#4 X: 0.0, Y: 0.0 -Button press: 4294967296 (when pressed in), touch: 4294967296 -grip: -Controller#1, Axis#0 X: 0.0, Y: 0.0 -Controller#1, Axis#1 X: 0.0, Y: 0.0 -Controller#1, Axis#2 X: 0.0, Y: 0.0 -Controller#1, Axis#3 X: 0.0, Y: 0.0 -Controller#1, Axis#4 X: 0.0, Y: 0.0 -Button press: 4, touch: 4 -thumb: -Controller#1, Axis#0 X: 0.0, Y: 0.0 -Controller#1, Axis#1 X: 0.0, Y: 0.0 -Controller#1, Axis#2 X: 0.0, Y: 0.0 -Controller#1, Axis#3 X: 0.0, Y: 0.0 -Controller#1, Axis#4 X: 0.0, Y: 0.0 -Button press: 2, touch: 2 - */ -/** - * A class that wraps an - * OpenVR - * input.
- * null values will be returned if no valid pose exists, or that - * input device isn't available user code should check for null - * values. - * - * @author reden - phr00t - * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr - * @author Rickard Edén - */ -public class LWJGLOpenVRInput implements VRInputAPI { - - private static final Logger logger = Logger.getLogger(LWJGLOpenVRInput.class.getName()); - private static final int MAX_CNT=30; - /** - * Deprecated as used controller specific values. Should use Actions manifest instead - */ -// @Deprecated -// private final VRControllerState[] cStates = new VRControllerState[VR.k_unMaxTrackedDeviceCount]; - private final XrControllerModelStateMSFT[] cStates = new XrControllerModelStateMSFT[MAX_CNT]; - - private final Quaternion[] rotStore = new Quaternion[MAX_CNT]; - - private final Vector3f[] posStore = new Vector3f[MAX_CNT]; - - private static final int[] controllerIndex = new int[MAX_CNT]; - - private int controllerCount = 0; - - private final Vector2f tempAxis = new Vector2f(), temp2Axis = new Vector2f(); -// -// private final Vector2f[] lastCallAxis = new Vector2f[VR.k_unMaxTrackedDeviceCount]; -// -// /** -// * Deprecated as used controller specific values. Should use Actions manifest instead -// */ -// @Deprecated -// private final boolean[][] buttonDown = new boolean[VR.k_unMaxTrackedDeviceCount][16]; - - /** - * A map of the action name to the objects/data required to read states from lwjgl - */ - private final Map digitalActions = new HashMap<>(); - - /** - * A map of the action name to the objects/data required to read states from lwjgl - */ - private final Map analogActions = new HashMap<>(); - - /** - * A map of the action name to the handle of a haptic action - */ - private final Map hapticActionHandles = new HashMap<>(); - - /** - * A map of the action set name to the handle that is used to refer to it when talking to LWJGL - */ - private final Map actionSetHandles = new HashMap<>(); - - /** - * A map of input names (e.g. /user/hand/right) to the handle used to address it. - * - * Note that null is a special case that maps to VR.k_ulInvalidInputValueHandle and means "any input" - */ - private final Map inputHandles = new HashMap<>(); - - private float axisMultiplier = 1f; - - private final Vector3f tempVel = new Vector3f(); -// private final Vector3f observerPosition = new Vector3f(); - - private final Quaternion tempq = new Quaternion(); - - private final VREnvironment environment; - - private List trackedControllers = null; - - /** - * A lwjgl object that contains handles to the active action sets (is used each frame to tell lwjgl which actions to - * fetch states back for) - */ -// private VRActiveActionSet.Buffer activeActionSets; - - InputMode inputMode = InputMode.LEGACY; - - private enum InputMode{ - /** - * Simple bitfield, no way to map new controllers - */ - LEGACY, - /** - * Actions manifest based. - */ - ACTION_BASED; - } - - /** - * Create a new - * OpenVR - * input attached to the given VR environment. - * - * @param environment the VR environment to which the input is attached. - */ - public LWJGLOpenVRInput(VREnvironment environment) { - this.environment = environment; - -// inputHandles.put(null, VR.k_ulInvalidInputValueHandle); - } - - @Override - public void registerActionManifest(String actionManifestAbsolutePath, String startingActiveActionSets){ - inputMode = InputMode.ACTION_BASED; -// int errorCode = VRInput.VRInput_SetActionManifestPath(actionManifestAbsolutePath); -// -// if ( errorCode != 0 ) -// { -// logger.warning( "An error code of " + errorCode + " was reported while registering an action manifest" ); -// } - setActiveActionSet(startingActiveActionSets); - } - - @Override - public void setActiveActionSet(String actionSet){ - assert inputMode == InputMode.ACTION_BASED : "registerActionManifest must be called before attempting to fetch action states"; - - - long actionSetHandle; - if (actionSetHandles.containsKey(actionSet)){ - actionSetHandle = actionSetHandles.get(actionSet); - }else{ - LongBuffer longBuffer = BufferUtils.createLongBuffer(1); -// int errorCode = VRInput.VRInput_GetActionHandle(actionSet, longBuffer); -// if ( errorCode != 0 ) -// { -// logger.warning( "An error code of " + errorCode + " was reported while fetching an action set handle for " + actionSet ); -// } - actionSetHandle = longBuffer.get(0); - actionSetHandles.put(actionSet,actionSetHandle); - } - - //Todo: this seems to imply that you could have multiple active action sets at once (Although I was not able to get that to work), allow multiple action sets -// activeActionSets = VRActiveActionSet.create(1); -// activeActionSets.ulActionSet(actionSetHandle); -// activeActionSets.ulRestrictedToDevice(VR.k_ulInvalidInputValueHandle); // both hands - } - - @Override - public DigitalActionState getDigitalActionState(String actionName, String restrictToInput){ - assert inputMode == InputMode.ACTION_BASED : "registerActionManifest must be called before attempting to fetch action states"; - - LWJGLOpenVRDigitalActionData actionDataObjects = digitalActions.get(actionName); - if (actionDataObjects == null){ - //this is the first time the action has been used. We must obtain a handle to it to efficiently fetch it in future - long handle = fetchActionHandle(actionName); -// actionDataObjects = new LWJGLOpenVRDigitalActionData(actionName, handle, InputDigitalActionData.create()); -// digitalActions.put(actionName, actionDataObjects); - } -// int errorCode = VRInput.VRInput_GetDigitalActionData(actionDataObjects.actionHandle, actionDataObjects.actionData, getOrFetchInputHandle(restrictToInput)); -// -// if (errorCode == VR.EVRInputError_VRInputError_WrongType){ -// throw new RuntimeException("Attempted to fetch a non-digital state as if it is digital"); -// }else if (errorCode!=0){ -// logger.warning( "An error code of " + errorCode + " was reported while fetching an action state for " + actionName ); -// } -// -// return new DigitalActionState(actionDataObjects.actionData.bState(), actionDataObjects.actionData.bChanged()); - return new DigitalActionState(false, false); - } - - @Override - public AnalogActionState getAnalogActionState(String actionName, String restrictToInput ){ - assert inputMode == InputMode.ACTION_BASED : "registerActionManifest must be called before attempting to fetch action states"; - -// LWJGLOpenVRAnalogActionData actionDataObjects = analogActions.get(actionName); -// if (actionDataObjects == null){ -// //this is the first time the action has been used. We must obtain a handle to it to efficiently fetch it in future -// long handle = fetchActionHandle(actionName); -// actionDataObjects = new LWJGLOpenVRAnalogActionData(actionName, handle, InputAnalogActionData.create()); -// analogActions.put(actionName, actionDataObjects); -// } -// int errorCode = VRInput.VRInput_GetAnalogActionData(actionDataObjects.actionHandle, actionDataObjects.actionData, getOrFetchInputHandle(restrictToInput)); -// -// if (errorCode == VR.EVRInputError_VRInputError_WrongType){ -// throw new RuntimeException("Attempted to fetch a non-analog state as if it is analog"); -// }else if (errorCode!=0){ -// logger.warning( "An error code of " + errorCode + " was reported while fetching an action state for " + actionName ); -// } -// -// return new AnalogActionState(actionDataObjects.actionData.x(), actionDataObjects.actionData.y(), actionDataObjects.actionData.z(), actionDataObjects.actionData.deltaX(), actionDataObjects.actionData.deltaY(), actionDataObjects.actionData.deltaZ()); - return new AnalogActionState(0,0,0,0,0,0); - } - - @Override - public float getAxisMultiplier() { - return axisMultiplier; - } - - @Override - public void setAxisMultiplier(float set) { - axisMultiplier = set; - } - - @Override - public void swapHands() { -// if (controllerCount != 2) { -// return; -// } -// int temp = controllerIndex[0]; -// controllerIndex[0] = controllerIndex[1]; -// controllerIndex[1] = temp; - } - - @Override - public boolean isButtonDown(int controllerIndex, VRInputType checkButton) { -// assert inputMode != InputMode.ACTION_BASED : "registerActionManifest has been called, legacy button access disabled"; -// VRControllerState cs = cStates[LWJGLOpenVRInput.controllerIndex[controllerIndex]]; -// switch (checkButton) { -// default: -// return false; -// case ViveGripButton: -// return (cs.ulButtonPressed() & 4) != 0; -// case ViveMenuButton: -// return (cs.ulButtonPressed() & 2) != 0; -// case ViveTrackpadAxis: -// return (cs.ulButtonPressed() & 4294967296l) != 0; -// case ViveTriggerAxis: -// return (cs.ulButtonPressed() & 8589934592l) != 0; -// } -return false; - } - - @Override - public boolean wasButtonPressedSinceLastCall(int controllerIndex, VRInputType checkButton) { -// boolean buttonDownNow = isButtonDown(controllerIndex, checkButton); -// int checkButtonValue = checkButton.getValue(); -// int cIndex = LWJGLOpenVRInput.controllerIndex[controllerIndex]; -// boolean retval = buttonDownNow == true && buttonDown[cIndex][checkButtonValue] == false; -// buttonDown[cIndex][checkButtonValue] = buttonDownNow; -// return retval; -return false; - } - - @Override - public void resetInputSinceLastCall() { -// for (int i = 0; i < lastCallAxis.length; i++) { -// lastCallAxis[i].x = 0f; -// lastCallAxis[i].y = 0f; -// } -// for (int i = 0; i < VR.k_unMaxTrackedDeviceCount; i++) { -// for (int j = 0; j < 16; j++) { -// buttonDown[i][j] = false; -// } -// } - } - - @Override - public Vector2f getAxisDeltaSinceLastCall(int controllerIndex, VRInputType forAxis) { -// int axisIndex = forAxis.getValue(); -// temp2Axis.set(lastCallAxis[axisIndex]); -// lastCallAxis[axisIndex].set(getAxis(controllerIndex, forAxis)); -// if ((temp2Axis.x != 0f || temp2Axis.y != 0f) && (lastCallAxis[axisIndex].x != 0f || lastCallAxis[axisIndex].y != 0f)) { -// temp2Axis.subtractLocal(lastCallAxis[axisIndex]); -// } else { -// // move made from rest, don't count as a delta move -// temp2Axis.x = 0f; -// temp2Axis.y = 0f; -// } -// return temp2Axis; -return new Vector2f(); - } - - @Override - public Vector3f getVelocity(int controllerIndex) { - -// if (environment != null) { -// -// if (environment.getVRHardware() instanceof LWJGLOpenVR) { -// int index = LWJGLOpenVRInput.controllerIndex[controllerIndex]; -//// if( needsNewVelocity[index] ) { -// HmdVector3 tempVec = ((LWJGLOpenVR) environment.getVRHardware()).hmdTrackedDevicePoses[index].vVelocity(); -//// needsNewVelocity[index] = false; -//// } -// tempVel.x = tempVec.v(0); -// tempVel.y = tempVec.v(1); -// tempVel.z = tempVec.v(2); -// return tempVel; -// } else { -// throw new IllegalStateException("VR hardware " + environment.getVRHardware().getClass().getSimpleName() + " is not a subclass of " + LWJGLOpenVR.class.getSimpleName()); -// } -// } else { -// throw new IllegalStateException("VR input is not attached to a VR environment."); -// } -return new Vector3f(); - } - - @Override - public Vector3f getAngularVelocity(int controllerIndex) { - -// if (environment != null) { -// -// if (environment.getVRHardware() instanceof LWJGLOpenVR) { -// -// int index = LWJGLOpenVRInput.controllerIndex[controllerIndex]; -// HmdVector3 tempVec = ((LWJGLOpenVR) environment.getVRHardware()).hmdTrackedDevicePoses[index].vAngularVelocity(); -//// needsNewVelocity[index] = false; -//// } -// tempVel.x = tempVec.v(0); -// tempVel.y = tempVec.v(1); -// tempVel.z = tempVec.v(2); -// return tempVel; -// } else { -// throw new IllegalStateException("VR hardware " + environment.getVRHardware().getClass().getSimpleName() + " is not a subclass of " + LWJGLOpenVR.class.getSimpleName()); -// } -// } else { -// throw new IllegalStateException("VR input is not attached to a VR environment."); -// } -return new Vector3f(); - } - - @Override - public Vector2f getAxisRaw(int controllerIndex, VRInputType forAxis) { -// VRControllerState cs = cStates[LWJGLOpenVRInput.controllerIndex[controllerIndex]]; -// switch (forAxis) { -// default: -// return null; -// case ViveTriggerAxis: -// tempAxis.x = cs.rAxis(1).x(); -// tempAxis.y = tempAxis.x; -// break; -// case ViveTrackpadAxis: -// tempAxis.x = cs.rAxis(0).x(); -// tempAxis.y = cs.rAxis(0).y(); -// break; -// } -// return tempAxis; -return new Vector2f(); - } - - @Override - public Vector2f getAxis(int controllerIndex, VRInputType forAxis) { -// getAxisRaw(controllerIndex, forAxis); -// tempAxis.x *= axisMultiplier; -// tempAxis.y *= axisMultiplier; -// return tempAxis; -return new Vector2f(); - } - - @Override - public boolean init() { - - logger.config("Initialize OpenVR input."); - -// for (int i = 0; i < VR.k_unMaxTrackedDeviceCount; i++) { -// rotStore[i] = new Quaternion(); -// posStore[i] = new Vector3f(); -// cStates[i] = VRControllerState.create(); -// lastCallAxis[i] = new Vector2f(); -// logger.config(" Input " + (i + 1) + "/" + VR.k_unMaxTrackedDeviceCount + " bound."); -// } - - return true; - } - - @Override - public VRTrackedController getTrackedController(int index) { - if (trackedControllers != null) { - if ((trackedControllers.size() > 0) && (index < trackedControllers.size())) { - return trackedControllers.get(index); - } - } - - return null; - } - - @Override - public int getTrackedControllerCount() { -// return controllerCount; -return 0; - } - - @Override -// public VRControllerState getRawControllerState(int index) { - public XrControllerModelStateMSFT getRawControllerState(int index) { - if (isInputDeviceTracking(index) == false) { - return null; - } - return cStates[controllerIndex[index]]; - } - - @Override - public boolean isInputFocused() { - if (environment != null){ - // not a 100% match, but the closest I can find in LWJGL. Doc seems to confirm this too. -// return VRSystem.VRSystem_IsInputAvailable(); - //return ((VR_IVRSystem_FnTable)environment.getVRHardware().getVRSystem()).IsInputFocusCapturedByAnotherProcess.apply() == 0; - return true; - } else { - throw new IllegalStateException("VR input is not attached to a VR environment."); - } - } - - @Override - public boolean isInputDeviceTracking(int index) { - if (index < 0 || index >= controllerCount) { - return false; - } - - if (environment != null) { - - if (environment.getVRHardware() instanceof LWJGLOpenVR) { -// return ((LWJGLOpenVR) environment.getVRHardware()).hmdTrackedDevicePoses[controllerIndex[index]].bPoseIsValid(); -return true; - } else { - throw new IllegalStateException("VR hardware " + environment.getVRHardware().getClass().getSimpleName() + " is not a subclass of " + LWJGLOpenVR.class.getSimpleName()); - } - } else { - throw new IllegalStateException("VR input is not attached to a VR environment."); - } - } - - @Override - public Quaternion getOrientation(int index) { - if (isInputDeviceTracking(index) == false) { - return null; - } - - if (environment != null) { - - if (environment.getVRHardware() instanceof LWJGLOpenVR) { - index = controllerIndex[index]; - VRUtil.convertMatrix4toQuat(((LWJGLOpenVR) environment.getVRHardware()).poseMatrices[index], rotStore[index]); - return rotStore[index]; - } else { - throw new IllegalStateException("VR hardware " + environment.getVRHardware().getClass().getSimpleName() + " is not a subclass of " + LWJGLOpenVR.class.getSimpleName()); - } - } else { - throw new IllegalStateException("VR input is not attached to a VR environment."); - } - } - - @Override - public Vector3f getPosition(int index) { - if (isInputDeviceTracking(index) == false) { - return null; - } - - if (environment != null) { - - if (environment.getVRHardware() instanceof LWJGLOpenVR) { - // the hmdPose comes in rotated funny, fix that here - index = controllerIndex[index]; - ((LWJGLOpenVR) environment.getVRHardware()).poseMatrices[index].toTranslationVector(posStore[index]); - posStore[index].x = -posStore[index].x; - posStore[index].z = -posStore[index].z; - return posStore[index]; - } else { - throw new IllegalStateException("VR hardware " + environment.getVRHardware().getClass().getSimpleName() + " is not a subclass of " + LWJGLOpenVR.class.getSimpleName()); - } - } else { - throw new IllegalStateException("VR input is not attached to a VR environment."); - } - - } - - @Override - public Quaternion getFinalObserverRotation(int index) { - - if (environment != null) { - VRViewManager vrvm = environment.getVRViewManager(); - - if (vrvm != null) { - if (isInputDeviceTracking(index) == false) { - return null; - } - - Object obs = environment.getObserver(); - if (obs instanceof Camera) { - tempq.set(((Camera) obs).getRotation()); - } else { - tempq.set(((Spatial) obs).getWorldRotation()); - } - - return tempq.multLocal(getOrientation(index)); - } else { - throw new IllegalStateException("VR environment has no valid view manager."); - } - - } else { - throw new IllegalStateException("VR input is not attached to a VR environment."); - } - } - - @Override - public Vector3f getFinalObserverPosition(int index) { - - if (environment != null) { - VRViewManager vrvm = environment.getVRViewManager(); - - if (vrvm != null) { - if (isInputDeviceTracking(index) == false) { - return null; - } - Object obs = environment.getObserver(); - Vector3f pos = getPosition(index); - if (obs instanceof Camera) { - ((Camera) obs).getRotation().mult(pos, pos); - return pos.addLocal(((Camera) obs).getLocation()); - } else { - ((Spatial) obs).getWorldRotation().mult(pos, pos); - return pos.addLocal(((Spatial) obs).getWorldTranslation()); - } - } else { - throw new IllegalStateException("VR environment has no valid view manager."); - } - } else { - throw new IllegalStateException("VR input is not attached to a VR environment."); - } - } - - @Override - public void triggerHapticPulse(int controllerIndex, float seconds) { - if (environment.isInVR() == false || isInputDeviceTracking(controllerIndex) == false) { - return; - } - - // apparently only axis ID of 0 works -// VRSystem.VRSystem_TriggerHapticPulse(LWJGLOpenVRInput.controllerIndex[controllerIndex], -// 0, (short) Math.round(3f * seconds / 1e-3f)); - } - - @Override - public void triggerHapticAction(String actionName, float duration, float frequency, float amplitude, String restrictToInput ){ - long hapticActionHandle; - if (!hapticActionHandles.containsKey(actionName)){ - //this is the first time the action has been used. We must obtain a handle to it to efficiently fetch it in future - hapticActionHandle = fetchActionHandle(actionName); - hapticActionHandles.put(actionName, hapticActionHandle); - }else{ - hapticActionHandle = hapticActionHandles.get(actionName); - } - -// VRInput.VRInput_TriggerHapticVibrationAction(hapticActionHandle, 0, duration, frequency, amplitude, getOrFetchInputHandle(restrictToInput)); - } - - @Override - public void updateConnectedControllers() { - logger.config("Updating connected controllers."); - -// if (environment != null) { -// controllerCount = 0; -// for (int i = 0; i < VR.k_unMaxTrackedDeviceCount; i++) { -// int classCallback = VRSystem.VRSystem_GetTrackedDeviceClass(i); -// if (classCallback == VR.ETrackedDeviceClass_TrackedDeviceClass_Controller || classCallback == VR.ETrackedDeviceClass_TrackedDeviceClass_GenericTracker) { -// IntBuffer error = BufferUtils.createIntBuffer(1); -// String controllerName = "Unknown"; -// String manufacturerName = "Unknown"; -// controllerName = VRSystem.VRSystem_GetStringTrackedDeviceProperty(i, VR.ETrackedDeviceProperty_Prop_TrackingSystemName_String, error); -// manufacturerName = VRSystem.VRSystem_GetStringTrackedDeviceProperty(i, VR.ETrackedDeviceProperty_Prop_ManufacturerName_String, error); -// -// if (error.get(0) != 0) { -// logger.warning("Error getting controller information " + controllerName + " " + manufacturerName + "Code (" + error.get(0) + ")"); -// } -// controllerIndex[controllerCount] = i; -// -// // Adding tracked controller to control. -// if (trackedControllers == null) { -// trackedControllers = new ArrayList(VR.k_unMaxTrackedDeviceCount); -// } -// trackedControllers.add(new LWJGLOpenVRTrackedController(i, this, controllerName, manufacturerName, environment)); -// -// // Send a Haptic pulse to the controller -// triggerHapticPulse(controllerCount, 1.0f); -// -// controllerCount++; -// logger.config(" Tracked controller " + (i + 1) + "/" + VR.k_unMaxTrackedDeviceCount + " " + controllerName + " (" + manufacturerName + ") attached."); -// } else { -// logger.config(" Controller " + (i + 1) + "/" + VR.k_unMaxTrackedDeviceCount + " ignored."); -// } -// } -// } else { -// throw new IllegalStateException("VR input is not attached to a VR environment."); -// } - } - - @Override - public void updateControllerStates() { - - if (environment != null) { -// switch(inputMode){ -// case ACTION_BASED: -// int errorCode = VRInput.VRInput_UpdateActionState(activeActionSets, VRActiveActionSet.SIZEOF); -// if(errorCode!=0){ -// logger.warning("An error code of " + errorCode + " was returned while upding the action states"); -// } -// break; -// case LEGACY: -// for (int i = 0; i < controllerCount; i++) { -// int index = controllerIndex[i]; -// VRSystem.VRSystem_GetControllerState(index, cStates[index], 64); -// cStates[index].ulButtonPressed(); -// cStates[index].rAxis(); -// } -// break; -// } - - } else { - throw new IllegalStateException("VR input is not attached to a VR environment."); - } - - } - - /** - * Converts an action name (as it appears in the action manifest) to a handle (long) that the rest of the - * lwjgl (and openVR) wants to talk in - * @param actionName The name of the action. Will be something like /actions/main/in/openInventory - * @return a long that is the handle that can be used to refer to the action - */ - private long fetchActionHandle( String actionName ){ - LongBuffer longBuffer = BufferUtils.createLongBuffer(1); -// int errorCode = VRInput.VRInput_GetActionHandle(actionName, longBuffer); -// if (errorCode !=0 ){ -// logger.warning( "An error code of " + errorCode + " was reported while registering an action manifest" ); -// } - return longBuffer.get(0); - } - - /** - * Given an input name returns the handle to address it. - * - * If a cached handle is available it is returned, if not it is fetched from openVr - * - * @param inputName the input name, e.g. /user/hand/right. Or null, which means "any input" - * @return the input handle - */ - public long getOrFetchInputHandle( String inputName ){ - if(!inputHandles.containsKey(inputName)){ - LongBuffer longBuffer = BufferUtils.createLongBuffer(1); - -// int errorCode = VRInput.VRInput_GetInputSourceHandle(inputName, longBuffer); -// if (errorCode !=0 ){ -// logger.warning( "An error code of " + errorCode + " was reported while fetching an input manifest" ); -// } - long handle = longBuffer.get(0); - inputHandles.put(inputName, handle); - } - - return inputHandles.get(inputName); - } - -} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRMouseManager.java b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRMouseManager.java deleted file mode 100644 index a21b2e3052..0000000000 --- a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRMouseManager.java +++ /dev/null @@ -1,107 +0,0 @@ -package com.jme3.input.vr.lwjgl_openvr; - -import com.jme3.app.VREnvironment; -import com.jme3.input.controls.AnalogListener; -import com.jme3.input.vr.AbstractVRMouseManager; -import com.jme3.input.vr.VRInputType; -import com.jme3.math.Vector2f; - - -/** - * A class dedicated to the handling of the mouse within VR environment. - * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr - */ -public class LWJGLOpenVRMouseManager extends AbstractVRMouseManager { - private final int AVERAGE_AMNT = 4; - - private int avgCounter; - - private final float[] lastXmv = new float[AVERAGE_AMNT]; - - private final float[] lastYmv = new float[AVERAGE_AMNT]; - - /** - * Create a new VR mouse manager within the given {@link VREnvironment VR environment}. - * @param environment the VR environment of the mouse manager. - */ - public LWJGLOpenVRMouseManager(VREnvironment environment){ - super(environment); - } - - - @Override - public void updateAnalogAsMouse(int inputIndex, AnalogListener mouseListener, String mouseXName, String mouseYName, float tpf) { - if (getVREnvironment() != null){ - if (getVREnvironment().getApplication() != null){ - // got a tracked controller to use as the "mouse" - if( getVREnvironment().isInVR() == false || - getVREnvironment().getVRinput() == null || - getVREnvironment().getVRinput().isInputDeviceTracking(inputIndex) == false ){ - return; - } - - Vector2f tpDelta; - // TODO option to use Touch joysticks - if( isThumbstickMode() ) { - tpDelta = getVREnvironment().getVRinput().getAxis(inputIndex, VRInputType.ViveTrackpadAxis); - } else { - tpDelta = getVREnvironment().getVRinput().getAxisDeltaSinceLastCall(inputIndex, VRInputType.ViveTrackpadAxis); - } - - float xAmount = (float)Math.pow(Math.abs(tpDelta.x) * getSpeedSensitivity(), getSpeedAcceleration()); - float yAmount = (float)Math.pow(Math.abs(tpDelta.y) * getSpeedSensitivity(), getSpeedAcceleration()); - - if( tpDelta.x < 0f ){ - xAmount = -xAmount; - } - - if( tpDelta.y < 0f ){ - yAmount = -yAmount; - } - - xAmount *= getMouseMoveScale(); - yAmount *= getMouseMoveScale(); - - if( mouseListener != null ) { - if( tpDelta.x != 0f && mouseXName != null ) mouseListener.onAnalog(mouseXName, xAmount * 0.2f, tpf); - if( tpDelta.y != 0f && mouseYName != null ) mouseListener.onAnalog(mouseYName, yAmount * 0.2f, tpf); - } - - if( getVREnvironment().getApplication().getInputManager().isCursorVisible() ) { - int index = (avgCounter+1) % AVERAGE_AMNT; - lastXmv[index] = xAmount * 133f; - lastYmv[index] = yAmount * 133f; - cursorPos.x -= avg(lastXmv); - cursorPos.y -= avg(lastYmv); - Vector2f maxsize = getVREnvironment().getVRGUIManager().getCanvasSize(); - - if( cursorPos.x > maxsize.x ){ - cursorPos.x = maxsize.x; - } - - if( cursorPos.x < 0f ){ - cursorPos.x = 0f; - } - - if( cursorPos.y > maxsize.y ){ - cursorPos.y = maxsize.y; - } - - if( cursorPos.y < 0f ){ - cursorPos.y = 0f; - } - } - } else { - throw new IllegalStateException("This VR environment is not attached to any application."); - } - } else { - throw new IllegalStateException("This VR view manager is not attached to any VR environment."); - } - } - - private float avg(float[] arr) { - float amt = 0f; - for(float f : arr) amt += f; - return amt / arr.length; - } -} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRTrackedController.java b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRTrackedController.java deleted file mode 100644 index c0705f0864..0000000000 --- a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRTrackedController.java +++ /dev/null @@ -1,96 +0,0 @@ -package com.jme3.input.vr.lwjgl_openvr; - -import com.jme3.app.VREnvironment; -import com.jme3.input.vr.VRInputAPI; -import com.jme3.input.vr.VRTrackedController; -import com.jme3.math.Matrix4f; -import com.jme3.math.Quaternion; -import com.jme3.math.Vector3f; - -/** - * A controller that is tracked within the VR environment. Such a controller can provide its position within the VR space. - * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr - * @author Rickard Edén - */ -public class LWJGLOpenVRTrackedController implements VRTrackedController{ - /** - * The index of the controller within the underlying VR API. - */ - private int controllerIndex = -1; - - /** - * The underlying VRAPI. - */ - private VRInputAPI hardware = null; - - /** - * The name of the controller. - */ - private String name; - - private VREnvironment environment; - - /** - * Wrap a new VR tracked controller on an OpenVR system. - * @param controllerIndex the index of the controller within the underlying VR system. - * @param hardware the underlying VR system. - * @param name the name of the controller. - * @param manufacturer the manufacturer of the controller. - * @param environment the VR environment. - */ - public LWJGLOpenVRTrackedController(int controllerIndex, VRInputAPI hardware, String name, String manufacturer, VREnvironment environment){ - this.controllerIndex = controllerIndex; - this.hardware = hardware; - - this.name = name; - this.manufacturer = manufacturer; - - this.environment = environment; - } - - /** - * The manufacturer of the controller. - */ - private String manufacturer; - - @Override - public Vector3f getPosition() { - if (hardware != null){ - return hardware.getPosition(controllerIndex); - } else { - throw new IllegalStateException("No underlying VR API."); - } - } - - @Override - public Quaternion getOrientation() { - if (hardware != null){ - return hardware.getOrientation(controllerIndex); - } else { - throw new IllegalStateException("No underlying VR API."); - } - } - - @Override - public Matrix4f getPose(){ - if (environment != null){ - if (hardware != null){ - return ((LWJGLOpenVR)environment.getVRHardware()).getPoseMatrices()[controllerIndex]; - } else { - throw new IllegalStateException("No underlying VR API."); - } - } else { - throw new IllegalStateException("VR tracked device is not attached to any environment."); - } - } - - @Override - public String getControllerName() { - return name; - } - - @Override - public String getControllerManufacturer() { - return manufacturer; - } -} \ No newline at end of file diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRViewManager.java b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRViewManager.java deleted file mode 100644 index 0e70669809..0000000000 --- a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVRViewManager.java +++ /dev/null @@ -1,575 +0,0 @@ -package com.jme3.input.vr.lwjgl_openvr; - -import com.jme3.app.VREnvironment; -import com.jme3.input.vr.AbstractVRViewManager; -import com.jme3.input.vr.VRAPI; -import com.jme3.math.ColorRGBA; -import com.jme3.math.Quaternion; -import com.jme3.math.Vector2f; -import com.jme3.math.Vector3f; -import com.jme3.renderer.Camera; -import com.jme3.renderer.ViewPort; -import com.jme3.renderer.queue.RenderQueue.Bucket; -import com.jme3.scene.Spatial; -import com.jme3.texture.FrameBuffer; -import com.jme3.texture.Image; -import com.jme3.texture.Texture2D; -import com.jme3.ui.Picture; -import com.jme3.util.VRGUIPositioningMode; - -import java.util.Iterator; -import java.util.logging.Logger; -//import org.lwjgl.openvr.VRTextureBounds; -//import org.lwjgl.openvr.Texture; -//import org.lwjgl.openvr.VR; -//import org.lwjgl.openvr.VRCompositor; - -/** - * A VR view manager based on OpenVR. This class enable to submit 3D views to - * the VR compositor. - * - * @author reden - phr00t - * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr - * @author Rickard Edén - */ -public class LWJGLOpenVRViewManager extends AbstractVRViewManager { - - private static final Logger logger = Logger.getLogger(LWJGLOpenVRViewManager.class.getName()); - - // OpenVR values -// private VRTextureBounds leftTextureBounds; -// private Texture leftTextureType; -// -// private VRTextureBounds rightTextureBounds; -// private Texture rightTextureType; - - private Texture2D dualEyeTex; - - //final & temp values for camera calculations - private final Vector3f finalPosition = new Vector3f(); - private final Quaternion finalRotation = new Quaternion(); - private final Vector3f hmdPos = new Vector3f(); - private final Quaternion hmdRot = new Quaternion(); - - /** - * Create a new VR view manager attached to the given - * {@link VREnvironment VR environment}. - * - * @param environment the {@link VREnvironment VR environment} to which this - * view manager is attached. - */ - public LWJGLOpenVRViewManager(VREnvironment environment) { - this.environment = environment; - } - - /** - * Get the identifier of the left eye texture. - * - * @return the identifier of the left eye texture. - * @see #getRightTexId() - * @see #getFullTexId() - */ - protected int getLeftTexId() { - return getLeftTexture().getImage().getId(); - } - - /** - * Get the identifier of the right eye texture. - * - * @return the identifier of the right eye texture. - * @see #getLeftTexId() - * @see #getFullTexId() - */ - protected int getRightTexId() { - return getRightTexture().getImage().getId(); - } - - /** - * Get the identifier of the full (dual eye) texture. - * - * @return the identifier of the full (dual eye) texture. - * @see #getLeftTexId() - * @see #getRightTexId() - */ - private int getFullTexId() { - return dualEyeTex.getImage().getId(); - } - - /** - * Initialize the system binds of the textures. - */ - private void initTextureSubmitStructs() { -// leftTextureType = Texture.create(); -// rightTextureType = Texture.create(); -// -// if (environment != null) { -// if (environment.getVRHardware() instanceof LWJGLOpenVR) { -// leftTextureBounds = VRTextureBounds.create(); -// rightTextureBounds = VRTextureBounds.create(); -// // left eye -// leftTextureBounds.set(0f, 0f, 0.5f, 1f); -// // right eye -// rightTextureBounds.set(0.5f, 0f, 1f, 1f); -// // texture type -// leftTextureType.set(-1, VR.ETextureType_TextureType_OpenGL, VR.EColorSpace_ColorSpace_Gamma); -// rightTextureType.set(-1, VR.ETextureType_TextureType_OpenGL, VR.EColorSpace_ColorSpace_Gamma); -// -// } -// } else { -// throw new IllegalStateException("This VR view manager is not attached to any VR environment."); -// } - } - - /** - * updatePose can be called here because appstates are always called before the main renderer. This way we get the latest pose close to when it's supposed to render - */ - @Override - public void render() { - if (environment != null) { - // grab the observer - Object obs = environment.getObserver(); - Quaternion objRot; - Vector3f objPos; - if (obs instanceof Camera) { - objRot = ((Camera) obs).getRotation(); - objPos = ((Camera) obs).getLocation(); - } else { - objRot = ((Spatial) obs).getWorldRotation(); - objPos = ((Spatial) obs).getWorldTranslation(); - } - // grab the hardware handle - VRAPI dev = environment.getVRHardware(); - if (dev != null) { - - // update the HMD's position & orientation - dev.updatePose(); - dev.getPositionAndOrientation(hmdPos, hmdRot); - - if (obs != null) { - // update hmdPos based on obs rotation - finalRotation.set(objRot); - finalRotation.mult(hmdPos, hmdPos); - finalRotation.multLocal(hmdRot); - } - - finalizeCamera(dev.getHMDVectorPoseLeftEye(), objPos, getLeftCamera()); - finalizeCamera(dev.getHMDVectorPoseRightEye(), objPos, getRightCamera()); - } else { - getLeftCamera().setFrame(objPos, objRot); - getRightCamera().setFrame(objPos, objRot); - } - } - } - - @Override - public void postRender() { - boolean cont = environment.getXr().renderFrame(); - if (!cont) - { - environment.getApplication().stop(); - environment.getXr().destroy(); - } -// -// if (environment != null) { -// if (environment.isInVR()) { -// VRAPI api = environment.getVRHardware(); -// // using the compositor... -// int errl = 0, errr = 0; -// if (environment.isInstanceRendering()) { -// if (leftTextureType.handle() == -1 || leftTextureType.handle() != getFullTexId()) { -// leftTextureType.set(getFullTexId(), leftTextureType.eType(), leftTextureType.eColorSpace()); -// } else { -// if (api instanceof LWJGLOpenVR) { -// int submitFlag = VR.EVRSubmitFlags_Submit_Default; -// errr = VRCompositor.VRCompositor_Submit(VR.EVREye_Eye_Right, rightTextureType, rightTextureBounds, submitFlag); -// errl = VRCompositor.VRCompositor_Submit(VR.EVREye_Eye_Left, leftTextureType, leftTextureBounds, submitFlag); -// } -// } -// } else if (leftTextureType.handle() == -1 || rightTextureType.handle() == -1 -// || leftTextureType.handle() != getLeftTexId() || rightTextureType.handle() != getRightTexId()) { -// leftTextureType.set(getLeftTexId(), leftTextureType.eType(), leftTextureType.eColorSpace()); -// rightTextureType.set(getRightTexId(), leftTextureType.eType(), leftTextureType.eColorSpace()); -// } else { -// if (api instanceof LWJGLOpenVR) { -// int submitFlag = VR.EVRSubmitFlags_Submit_Default; -// errr = VRCompositor.VRCompositor_Submit(VR.EVREye_Eye_Right, rightTextureType, null, submitFlag); -// errl = VRCompositor.VRCompositor_Submit(VR.EVREye_Eye_Left, leftTextureType, null, submitFlag); -// } else { -// -// } -// } -// -// if (errl != 0) { -// logger.severe("Submit to left compositor error: " + " (" + Integer.toString(errl) + ")"); -// logger.severe(" Texture handle: " + leftTextureType.handle()); -// -// logger.severe(" Left eye texture " + leftEyeTexture.getName() + " (" + leftEyeTexture.getImage().getId() + ")"); -// logger.severe(" Type: " + leftEyeTexture.getType()); -// logger.severe(" Size: " + leftEyeTexture.getImage().getWidth() + "x" + leftEyeTexture.getImage().getHeight()); -// logger.severe(" Image depth: " + leftEyeTexture.getImage().getDepth()); -// logger.severe(" Image format: " + leftEyeTexture.getImage().getFormat()); -// logger.severe(" Image color space: " + leftEyeTexture.getImage().getColorSpace()); -// -// } -// -// if (errr != 0) { -// logger.severe("Submit to right compositor error: " + " (" + Integer.toString(errl) + ")"); -//// logger.severe(" Texture color space: "+OpenVRUtil.getEColorSpaceString(rightTextureType.eColorSpace)); -//// logger.severe(" Texture type: "+OpenVRUtil.getETextureTypeString(rightTextureType.eType)); -// logger.severe(" Texture handle: " + rightTextureType.handle()); -// -// logger.severe(" Right eye texture " + rightEyeTexture.getName() + " (" + rightEyeTexture.getImage().getId() + ")"); -// logger.severe(" Type: " + rightEyeTexture.getType()); -// logger.severe(" Size: " + rightEyeTexture.getImage().getWidth() + "x" + rightEyeTexture.getImage().getHeight()); -// logger.severe(" Image depth: " + rightEyeTexture.getImage().getDepth()); -// logger.severe(" Image format: " + rightEyeTexture.getImage().getFormat()); -// logger.severe(" Image color space: " + rightEyeTexture.getImage().getColorSpace()); -// } -// } -// } else { -// throw new IllegalStateException("This VR view manager is not attached to any VR environment."); -// } -// -// VRCompositor.VRCompositor_PostPresentHandoff(); - - } - - @Override - public void initialize() { - - logger.config("Initializing VR view manager."); - - if (environment != null) { - - initTextureSubmitStructs(); - setupCamerasAndViews(); - setupVRScene(); - moveScreenProcessingToEyes(); - - if (environment.hasTraditionalGUIOverlay()) { - - environment.getVRMouseManager().initialize(); - - // update the pose to position the gui correctly on start - update(0f); - environment.getVRGUIManager().positionGui(); - } - - logger.config("Initialized VR view manager [SUCCESS]"); - - } else { - throw new IllegalStateException("This VR view manager is not attached to any VR environment."); - } - } - - /** - * Prepare the size of the given {@link Camera camera} to adapt it to the - * underlying rendering context. - * - * @param cam the {@link Camera camera} to prepare. - * @param xMult the camera width multiplier. - */ - private void prepareCameraSize(Camera cam, float xMult) { - - if (environment != null) { - - if (environment.getApplication() != null) { - Vector2f size = new Vector2f(); - VRAPI vrhmd = environment.getVRHardware(); - - if (vrhmd == null) { - size.x = 1280f; - size.y = 720f; - } else { - vrhmd.getRenderSize(size); - } - - if (size.x < environment.getApplication().getContext().getSettings().getWidth()) { - size.x = environment.getApplication().getContext().getSettings().getWidth(); - } - if (size.y < environment.getApplication().getContext().getSettings().getHeight()) { - size.y = environment.getApplication().getContext().getSettings().getHeight(); - } - - if (environment.isInstanceRendering()) { - size.x *= 2f; - } - - // other adjustments - size.x *= xMult; - size.x *= getResolutionMuliplier(); - size.y *= getResolutionMuliplier(); - - if (cam.getWidth() != size.x || cam.getHeight() != size.y) { - cam.resize((int) size.x, (int) size.y, false); - } - } else { - throw new IllegalStateException("This VR environment is not attached to any application."); - } - - } else { - throw new IllegalStateException("This VR view manager is not attached to any VR environment."); - } - - } - - /** - * Replaces rootNode with the distortion mesh as the main camera's scene. - */ - private void setupVRScene() { - - if (environment != null) { - if (environment.getApplication() != null) { - // no special scene to set up if we are doing instancing - if (environment.isInstanceRendering()) { - // distortion has to be done with compositor here... we want only one pass on our end! - if (environment.getApplication().getContext().getSettings().isSwapBuffers()) { - setupMirrorBuffers(environment.getCamera(), dualEyeTex, true); - } - return; - } - - leftEyeTexture = (Texture2D) getLeftViewPort().getOutputFrameBuffer().getColorBuffer().getTexture(); - rightEyeTexture = (Texture2D) getRightViewPort().getOutputFrameBuffer().getColorBuffer().getTexture(); - leftEyeDepth = (Texture2D) getLeftViewPort().getOutputFrameBuffer().getDepthBuffer().getTexture(); - rightEyeDepth = (Texture2D) getRightViewPort().getOutputFrameBuffer().getDepthBuffer().getTexture(); - - // main viewport is either going to be a distortion scene or nothing - // mirroring is handled by copying framebuffers - Iterator spatialIter = environment.getApplication().getViewPort().getScenes().iterator(); - while (spatialIter.hasNext()) { - environment.getApplication().getViewPort().detachScene(spatialIter.next()); - } - - spatialIter = environment.getApplication().getGuiViewPort().getScenes().iterator(); - while (spatialIter.hasNext()) { - environment.getApplication().getGuiViewPort().detachScene(spatialIter.next()); - } - - // only setup distortion scene if compositor isn't running (or using custom mesh distortion option) - if (environment.getApplication().getContext().getSettings().isSwapBuffers()) { - setupMirrorBuffers(environment.getCamera(), leftEyeTexture, false); - - } - } else { - throw new IllegalStateException("This VR environment is not attached to any application."); - } - } else { - throw new IllegalStateException("This VR view manager is not attached to any VR environment."); - } - } - - @Override - public void update(float tpf) { - - if (environment != null) { - - if (environment.hasTraditionalGUIOverlay()) { - // update the mouse? - environment.getVRMouseManager().update(tpf); - - // update GUI position? - if (environment.getVRGUIManager().isWantsReposition() || environment.getVRGUIManager().getPositioningMode() != VRGUIPositioningMode.MANUAL) { - environment.getVRGUIManager().positionGuiNow(tpf); - environment.getVRGUIManager().updateGuiQuadGeometricState(); - } - } - } else { - throw new IllegalStateException("This VR view manager is not attached to any VR environment."); - } - } - - /** - * Place the camera within the scene. - * - * @param eyePos the eye position. - * @param obsPosition the observer position. - * @param cam the camera to place. - */ - private void finalizeCamera(Vector3f eyePos, Vector3f obsPosition, Camera cam) { - finalRotation.mult(eyePos, finalPosition); - finalPosition.addLocal(hmdPos); - if (obsPosition != null) { - finalPosition.addLocal(obsPosition); - } - finalPosition.y += getHeightAdjustment(); - cam.setFrame(finalPosition, finalRotation); - } - - private void setupCamerasAndViews() { - - if (environment != null) { - // get desired frustum from original camera - Camera origCam = environment.getCamera(); - float fFar = origCam.getFrustumFar(); - float fNear = origCam.getFrustumNear(); - - // restore frustum on distortion scene cam, if needed - if (environment.isInstanceRendering()) { - leftCamera = origCam; - } else if (environment.compositorAllowed() == false) { - origCam.setFrustumFar(100f); - origCam.setFrustumNear(1f); - leftCamera = origCam.clone(); - prepareCameraSize(origCam, 2f); - } else { - leftCamera = origCam.clone(); - } - - getLeftCamera().setFrustumPerspective(environment.getDefaultFOV(), environment.getDefaultAspect(), fNear, fFar); - - prepareCameraSize(getLeftCamera(), 1f); - if (environment.getVRHardware() != null) { - getLeftCamera().setProjectionMatrix(environment.getVRHardware().getHMDMatrixProjectionLeftEye(getLeftCamera())); - } - //org.lwjgl.opengl.GL11.glEnable(org.lwjgl.opengl.GL30.GL_FRAMEBUFFER_SRGB); - - if (!environment.isInstanceRendering()) { - leftViewPort = setupViewBuffers(getLeftCamera(), LEFT_VIEW_NAME); - rightCamera = getLeftCamera().clone(); - if (environment.getVRHardware() != null) { - getRightCamera().setProjectionMatrix(environment.getVRHardware().getHMDMatrixProjectionRightEye(getRightCamera())); - } - rightViewPort = setupViewBuffers(getRightCamera(), RIGHT_VIEW_NAME); - } else { - - if (environment.getApplication() != null) { - - logger.severe("THIS CODE NEED CHANGES !!!"); - leftViewPort = environment.getApplication().getViewPort(); - //leftViewport.attachScene(app.getRootNode()); - rightCamera = getLeftCamera().clone(); - if (environment.getVRHardware() != null) { - getRightCamera().setProjectionMatrix(environment.getVRHardware().getHMDMatrixProjectionRightEye(getRightCamera())); - } - - org.lwjgl.opengl.GL11.glEnable(org.lwjgl.opengl.GL30.GL_CLIP_DISTANCE0); - - //FIXME: [jme-vr] Fix with JMonkey next release - //RenderManager._VRInstancing_RightCamProjection = camRight.getViewProjectionMatrix(); - setupFinalFullTexture(environment.getApplication().getViewPort().getCamera()); - } else { - throw new IllegalStateException("This VR environment is not attached to any application."); - } - - } - - // setup gui - environment.getVRGUIManager().setupGui(getLeftCamera(), getRightCamera(), getLeftViewPort(), getRightViewPort()); - - if (environment.getVRHardware() != null) { - // call these to cache the results internally - environment.getVRHardware().getHMDMatrixPoseLeftEye(); - environment.getVRHardware().getHMDMatrixPoseRightEye(); - } - } else { - throw new IllegalStateException("This VR view manager is not attached to any VR environment."); - } - } - - private ViewPort setupMirrorBuffers(Camera cam, Texture2D tex, boolean expand) { - - if (environment != null) { - if (environment.getApplication() != null) { - Camera clonecam = cam.clone(); - ViewPort viewPort = environment.getApplication().getRenderManager().createPostView("MirrorView", clonecam); - clonecam.setParallelProjection(true); - viewPort.setClearFlags(true, true, true); - viewPort.setBackgroundColor(ColorRGBA.Black); - Picture pic = new Picture("fullscene"); - pic.setLocalTranslation(-0.75f, -0.5f, 0f); - if (expand) { - pic.setLocalScale(3f, 1f, 1f); - } else { - pic.setLocalScale(1.5f, 1f, 1f); - } - pic.setQueueBucket(Bucket.Opaque); - pic.setTexture(environment.getApplication().getAssetManager(), tex, false); - viewPort.attachScene(pic); - viewPort.setOutputFrameBuffer(null); - - pic.updateGeometricState(); - - return viewPort; - } else { - throw new IllegalStateException("This VR environment is not attached to any application."); - } - } else { - throw new IllegalStateException("This VR view manager is not attached to any VR environment."); - } - } - - private void setupFinalFullTexture(Camera cam) { - - if (environment != null) { - if (environment.getApplication() != null) { - // create offscreen framebuffer - FrameBuffer out = new FrameBuffer(cam.getWidth(), cam.getHeight(), 1); - //offBuffer.setSrgb(true); - - //setup framebuffer's texture - dualEyeTex = new Texture2D(cam.getWidth(), cam.getHeight(), Image.Format.RGBA8); - dualEyeTex.setMinFilter(Texture2D.MinFilter.BilinearNoMipMaps); - dualEyeTex.setMagFilter(Texture2D.MagFilter.Bilinear); - - logger.config("Dual eye texture " + dualEyeTex.getName() + " (" + dualEyeTex.getImage().getId() + ")"); - logger.config(" Type: " + dualEyeTex.getType()); - logger.config(" Size: " + dualEyeTex.getImage().getWidth() + "x" + dualEyeTex.getImage().getHeight()); - logger.config(" Image depth: " + dualEyeTex.getImage().getDepth()); - logger.config(" Image format: " + dualEyeTex.getImage().getFormat()); - logger.config(" Image color space: " + dualEyeTex.getImage().getColorSpace()); - - //setup framebuffer to use texture - out.setDepthBuffer(Image.Format.Depth); - out.setColorTexture(dualEyeTex); - - ViewPort viewPort = environment.getApplication().getViewPort(); - viewPort.setClearFlags(true, true, true); - viewPort.setBackgroundColor(ColorRGBA.Black); - viewPort.setOutputFrameBuffer(out); - } else { - throw new IllegalStateException("This VR environment is not attached to any application."); - } - } else { - throw new IllegalStateException("This VR view manager is not attached to any VR environment."); - } - } - - private ViewPort setupViewBuffers(Camera cam, String viewName) { - - if (environment != null) { - if (environment.getApplication() != null) { - // create offscreen framebuffer - FrameBuffer offBufferLeft = new FrameBuffer(cam.getWidth(), cam.getHeight(), 1); - //offBufferLeft.setSrgb(true); - - //setup framebuffer's texture - Texture2D offTex = new Texture2D(cam.getWidth(), cam.getHeight(), Image.Format.RGBA8); - offTex.setMinFilter(Texture2D.MinFilter.BilinearNoMipMaps); - offTex.setMagFilter(Texture2D.MagFilter.Bilinear); - - //setup framebuffer to use texture - offBufferLeft.setDepthBuffer(Image.Format.Depth); - offBufferLeft.setColorTexture(offTex); - - ViewPort viewPort = environment.getApplication().getRenderManager().createPreView(viewName, cam); - viewPort.setClearFlags(true, true, true); - viewPort.setBackgroundColor(ColorRGBA.Black); - - Iterator spatialIter = environment.getApplication().getViewPort().getScenes().iterator(); - while (spatialIter.hasNext()) { - viewPort.attachScene(spatialIter.next()); - } - - //set viewport to render to offscreen framebuffer - viewPort.setOutputFrameBuffer(offBufferLeft); - return viewPort; - } else { - throw new IllegalStateException("This VR environment is not attached to any application."); - } - } else { - throw new IllegalStateException("This VR view manager is not attached to any VR environment."); - } - } - -} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/ShadersGL.java b/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/ShadersGL.java deleted file mode 100644 index 8bff141327..0000000000 --- a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/ShadersGL.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright LWJGL. All rights reserved. - * License terms: https://www.lwjgl.org/license - * Source: https://github.com/LWJGL/lwjgl3/tree/master/modules/samples/src/test/java/org/lwjgl/demo/openxr - */ -package com.jme3.input.vr.lwjgl_openxr; - -import org.lwjgl.system.*; - -import java.nio.*; - -import static org.lwjgl.opengl.GL11.*; -import static org.lwjgl.opengl.GL20.*; -import static org.lwjgl.system.MemoryStack.*; - -final class ShadersGL { - - static final String texVertShader = "#version 330 core\n" + - "layout (location = 0) in vec3 aPos;\n" + - "layout (location = 1) in vec2 aTexCoord;\n" + - "\n" + - "out vec2 TexCoord;\n" + - "\n" + - "uniform mat4 model;\n" + - "uniform mat4 view;\n" + - "uniform mat4 projection;\n" + - "\n" + - "void main()\n" + - "{\n" + - " gl_Position = projection * view * model * vec4(aPos, 1.0);\n" + - " TexCoord = vec2(aTexCoord.x, aTexCoord.y);\n" + - "}"; - - static final String screenVertShader = "#version 330 core\n" + - "layout (location = 0) in vec2 aPos;\n" + - "layout (location = 1) in vec2 aTexCoords;\n" + - "\n" + - "out vec2 TexCoords;\n" + - "\n" + - "void main()\n" + - "{\n" + - " TexCoords = aTexCoords;\n" + - " gl_Position = vec4(aPos.x, aPos.y, 0.0, 1.0); \n" + - "}"; - - static final String texFragShader = "#version 330 core\n" + - "out vec4 FragColor;\n" + - "\n" + - "in vec2 TexCoords;\n" + - "\n" + - "uniform sampler2D textureSampler;\n" + - "\n" + - "void main()\n" + - "{\n" + - " vec3 col = texture(textureSampler, TexCoords).rgb;\n" + - " FragColor = vec4(col, 1.0);\n" + - "}"; - - static final String colVertShader = "#version 330 core\n" + - "layout (location = 0) in vec3 aPos;\n" + - "layout (location = 1) in vec3 aColorIn;\n" + - "\n" + - "out vec3 Color;\n" + - "\n" + - "uniform mat4 model;\n" + - "uniform mat4 view;\n" + - "uniform mat4 projection;\n" + - "\n" + - "void main()\n" + - "{\n" + - " //gl_Position = transform * vec4(aPos, 1.0f);\n" + - " gl_Position = projection * view * model * vec4(aPos, 1.0);\n" + - " Color = aColorIn;\n" + - "}"; - - static final String colFragShader = "#version 330 core\n" + - "in vec3 Color;" + - "out vec4 FragColor;\n" + - "void main()\n" + - "{\n" + - " FragColor = vec4(Color, 1.0f);\n" + - "}"; - - - private ShadersGL() { - } - - static int createShaderProgram(String vertexShaderGlsl, String fragmentShaderGlsl) { - int vertexShader = glCreateShader(GL_VERTEX_SHADER); - glShaderSource(vertexShader, vertexShaderGlsl); - glCompileShader(vertexShader); - checkShader(vertexShader); - - int fragmentShader = glCreateShader(GL_FRAGMENT_SHADER); - glShaderSource(fragmentShader, fragmentShaderGlsl); - glCompileShader(fragmentShader); - checkShader(fragmentShader); - - int program = glCreateProgram(); - - glAttachShader(program, vertexShader); - glAttachShader(program, fragmentShader); - glLinkProgram(program); - checkProgram(program); - - glDeleteShader(vertexShader); - glDeleteShader(fragmentShader); - - return program; - } - - static void checkShader(int shader) { - try (MemoryStack stack = stackPush()) { - IntBuffer pi = stack.mallocInt(1); - glGetShaderiv(shader, GL_COMPILE_STATUS, pi); - if (pi.get(0) == GL_FALSE) { - throw new IllegalStateException("Compile shader failed: " + glGetShaderInfoLog(shader, 4096)); - } - } - } - - static void checkProgram(int program) { - try (MemoryStack stack = stackPush()) { - IntBuffer pi = stack.mallocInt(1); - glGetProgramiv(program, GL_LINK_STATUS, pi); - if (pi.get(0) == GL_FALSE) { - throw new IllegalStateException("Link program failed: " + glGetProgramInfoLog(program, 4096)); - } - } - } - -} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/openvr/OpenVR.java b/jme3-xr/src/main/java/com/jme3/input/vr/openvr/OpenVR.java deleted file mode 100644 index 4489bd9f99..0000000000 --- a/jme3-xr/src/main/java/com/jme3/input/vr/openvr/OpenVR.java +++ /dev/null @@ -1,584 +0,0 @@ -package com.jme3.input.vr.openvr; - -import com.jme3.app.VREnvironment; -import com.jme3.input.vr.HmdType; -import com.jme3.input.vr.VRAPI; -import com.jme3.math.Matrix4f; -import com.jme3.math.Quaternion; -import com.jme3.math.Vector2f; -import com.jme3.math.Vector3f; -import com.jme3.renderer.Camera; -import com.jme3.system.jopenvr.HmdMatrix34_t; -import com.jme3.system.jopenvr.HmdMatrix44_t; -import com.jme3.system.jopenvr.JOpenVRLibrary; -import com.jme3.system.jopenvr.OpenVRUtil; -import com.jme3.system.jopenvr.TrackedDevicePose_t; -import com.jme3.system.jopenvr.VR_IVRCompositor_FnTable; -import com.jme3.system.jopenvr.VR_IVRSystem_FnTable; -import com.jme3.system.jopenvr.VR_IVRTrackedCamera_FnTable; -import com.jme3.util.VRUtil; -import com.sun.jna.Memory; -import com.sun.jna.Pointer; -import com.sun.jna.ptr.FloatByReference; -import com.sun.jna.ptr.IntByReference; -import com.sun.jna.ptr.LongByReference; - -import java.nio.IntBuffer; -import java.util.Locale; -import java.util.concurrent.TimeUnit; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * A class that wraps an OpenVR system. - * @author reden - phr00t - https://github.com/phr00t - * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr - */ -public class OpenVR implements VRAPI { - private static final Logger logger = Logger.getLogger(OpenVR.class.getName()); - - private static VR_IVRCompositor_FnTable compositorFunctions; - private static VR_IVRSystem_FnTable vrSystemFunctions; - private static VR_IVRTrackedCamera_FnTable cameraFunctions; - - private static boolean initSuccess = false; - private static boolean flipEyes = false; - - private IntBuffer hmdDisplayFrequency; - private TrackedDevicePose_t.ByReference hmdTrackedDevicePoseReference; - protected TrackedDevicePose_t[] hmdTrackedDevicePoses; - - protected IntByReference hmdErrorStore; - - private final Quaternion rotStore = new Quaternion(); - private final Vector3f posStore = new Vector3f(); - - private static FloatByReference tlastVsync; - - /** - * The actual frame count. - */ - public static LongByReference _tframeCount; - - // for debugging latency - private int frames = 0; - - protected Matrix4f[] poseMatrices; - - private final Matrix4f hmdPose = Matrix4f.IDENTITY.clone(); - private Matrix4f hmdProjectionLeftEye; - private Matrix4f hmdProjectionRightEye; - private Matrix4f hmdPoseLeftEye; - private Matrix4f hmdPoseRightEye; - - private Vector3f hmdPoseLeftEyeVec, hmdPoseRightEyeVec, hmdSeatToStand; - - private float vsyncToPhotons; - private double timePerFrame, frameCountRun; - private long frameCount; - private OpenVRInput vrInput; - - private VREnvironment environment = null; - - /** - * Convert specific OpenVR {@link com.jme3.system.jopenvr.HmdMatrix34_t HmdMatrix34_t} into JME {@link Matrix4f Matrix4f} - * @param hmdMatrix the input matrix - * @param mat the converted matrix - * @return the converted matrix - */ - public static Matrix4f convertSteamVRMatrix3ToMatrix4f(com.jme3.system.jopenvr.HmdMatrix34_t hmdMatrix, Matrix4f mat){ - mat.set(hmdMatrix.m[0], hmdMatrix.m[1], hmdMatrix.m[2], hmdMatrix.m[3], - hmdMatrix.m[4], hmdMatrix.m[5], hmdMatrix.m[6], hmdMatrix.m[7], - hmdMatrix.m[8], hmdMatrix.m[9], hmdMatrix.m[10], hmdMatrix.m[11], - 0f, 0f, 0f, 1f); - return mat; - } - - /** - * Convert specific OpenVR {@link com.jme3.system.jopenvr.HmdMatrix44_t HmdMatrix34_t} into JME {@link Matrix4f Matrix4f} - * @param hmdMatrix the input matrix - * @param mat the converted matrix - * @return the converted matrix - */ - public static Matrix4f convertSteamVRMatrix4ToMatrix4f(com.jme3.system.jopenvr.HmdMatrix44_t hmdMatrix, Matrix4f mat){ - mat.set(hmdMatrix.m[0], hmdMatrix.m[1], hmdMatrix.m[2], hmdMatrix.m[3], - hmdMatrix.m[4], hmdMatrix.m[5], hmdMatrix.m[6], hmdMatrix.m[7], - hmdMatrix.m[8], hmdMatrix.m[9], hmdMatrix.m[10], hmdMatrix.m[11], - hmdMatrix.m[12], hmdMatrix.m[13], hmdMatrix.m[14], hmdMatrix.m[15]); - return mat; - } - - /** - * Create a new OpenVR system - * attached to the given {@link VREnvironment VR environment}. - * @param environment the VR environment to which this API is attached. - */ - public OpenVR(VREnvironment environment){ - this.environment = environment; - } - - @Override - public OpenVRInput getVRinput() { - return vrInput; - } - - @Override - public VR_IVRSystem_FnTable getVRSystem() { - return vrSystemFunctions; - } - - @Override - public VR_IVRCompositor_FnTable getCompositor() { - return compositorFunctions; - } - - public VR_IVRTrackedCamera_FnTable getTrackedCamera(){ - return cameraFunctions; - } - - @Override - public String getName() { - return "OpenVR"; - } - - private static long latencyWaitTime = 0; - - @Override - public void setFlipEyes(boolean set) { - flipEyes = set; - } - - private boolean enableDebugLatency = false; - - @Override - public void printLatencyInfoToConsole(boolean set) { - enableDebugLatency = set; - } - - @Override - public int getDisplayFrequency() { - if( hmdDisplayFrequency == null ) return 0; - return hmdDisplayFrequency.get(0); - } - - @Override - public boolean initialize() { - logger.config("Initializing OpenVR system..."); - - hmdErrorStore = new IntByReference(); - vrSystemFunctions = null; - - // Init the native linking to the OpenVR library. - try{ - JOpenVRLibrary.init(); - } catch(Throwable t){ - logger.log(Level.SEVERE, "Cannot link to OpenVR system library: "+t.getMessage(), t); - return false; - } - - JOpenVRLibrary.VR_InitInternal(hmdErrorStore, JOpenVRLibrary.EVRApplicationType.EVRApplicationType_VRApplication_Scene); - - if( hmdErrorStore.getValue() == 0 ) { - vrSystemFunctions = new VR_IVRSystem_FnTable(JOpenVRLibrary.VR_GetGenericInterface(JOpenVRLibrary.IVRSystem_Version, hmdErrorStore).getPointer()); - } - - if( vrSystemFunctions == null || hmdErrorStore.getValue() != 0 ) { - logger.severe("OpenVR Initialize Result: " + JOpenVRLibrary.VR_GetVRInitErrorAsEnglishDescription(hmdErrorStore.getValue()).getString(0)); - logger.severe("Initializing OpenVR system [FAILED]"); - return false; - } else { - logger.config("OpenVR initialized & VR connected."); - - vrSystemFunctions.setAutoSynch(false); - vrSystemFunctions.read(); - - tlastVsync = new FloatByReference(); - _tframeCount = new LongByReference(); - - hmdDisplayFrequency = IntBuffer.allocate(1); - hmdDisplayFrequency.put(JOpenVRLibrary.ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DisplayFrequency_Float); - hmdTrackedDevicePoseReference = new TrackedDevicePose_t.ByReference(); - hmdTrackedDevicePoses = (TrackedDevicePose_t[])hmdTrackedDevicePoseReference.toArray(JOpenVRLibrary.k_unMaxTrackedDeviceCount); - poseMatrices = new Matrix4f[JOpenVRLibrary.k_unMaxTrackedDeviceCount]; - for(int i=0;itrue is the use of the headset camera is allowed and false otherwise. - */ - public void initCamera(boolean allowed) { - hmdErrorStore.setValue(0); // clear the error store - - if( allowed && vrSystemFunctions != null ) { - IntByReference intptr = JOpenVRLibrary.VR_GetGenericInterface(JOpenVRLibrary.IVRTrackedCamera_Version, hmdErrorStore); - if (intptr != null){ - cameraFunctions = new VR_IVRTrackedCamera_FnTable(intptr.getPointer()); - if(cameraFunctions != null && hmdErrorStore.getValue() == 0 ){ - cameraFunctions.setAutoSynch(false); - cameraFunctions.read(); - logger.config("OpenVR Camera initialized"); - } - } - } - } - - @Override - public void destroy() { - JOpenVRLibrary.VR_ShutdownInternal(); - } - - @Override - public boolean isInitialized() { - return initSuccess; - } - - @Override - public void reset() { - if( vrSystemFunctions == null ) return; - vrSystemFunctions.ResetSeatedZeroPose.apply(); - hmdSeatToStand = null; - } - - @Override - public void getRenderSize(Vector2f store) { - if( vrSystemFunctions == null ) { - // 1344x1512 - store.x = 1344f; - store.y = 1512f; - } else { - IntByReference x = new IntByReference(); - IntByReference y = new IntByReference(); - vrSystemFunctions.GetRecommendedRenderTargetSize.apply(x, y); - store.x = x.getValue(); - store.y = y.getValue(); - } - } - /* - @Override - public float getFOV(int dir) { - float val = 0f; - if( vrsystemFunctions != null ) { - val = vrsystemFunctions.GetFloatTrackedDeviceProperty.apply(JOpenVRLibrary.k_unTrackedDeviceIndex_Hmd, dir, hmdErrorStore); - } - // verification of number - if( val == 0f ) { - return 55f; - } else if( val <= 10f ) { - // most likely a radian number - return val * 57.2957795f; - } - return val; - } - */ - - @Override - public float getInterpupillaryDistance() { - if( vrSystemFunctions == null ) return 0.065f; - return vrSystemFunctions.GetFloatTrackedDeviceProperty.apply(JOpenVRLibrary.k_unTrackedDeviceIndex_Hmd, JOpenVRLibrary.ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_UserIpdMeters_Float, hmdErrorStore); - } - - @Override - public Quaternion getOrientation() { - VRUtil.convertMatrix4toQuat(hmdPose, rotStore); - return rotStore; - } - - @Override - public Vector3f getPosition() { - // the hmdPose comes in rotated funny, fix that here - hmdPose.toTranslationVector(posStore); - posStore.x = -posStore.x; - posStore.z = -posStore.z; - return posStore; - } - - @Override - public void getPositionAndOrientation(Vector3f storePos, Quaternion storeRot) { - hmdPose.toTranslationVector(storePos); - storePos.x = -storePos.x; - storePos.z = -storePos.z; - storeRot.set(getOrientation()); - } - - @Override - public void updatePose(){ - if(vrSystemFunctions == null) return; - if(compositorFunctions != null) { - compositorFunctions.WaitGetPoses.apply(hmdTrackedDevicePoseReference, JOpenVRLibrary.k_unMaxTrackedDeviceCount, null, 0); - } else { - // wait - if( latencyWaitTime > 0 ) VRUtil.sleepNanos(latencyWaitTime); - - vrSystemFunctions.GetTimeSinceLastVsync.apply(tlastVsync, _tframeCount); - float fSecondsUntilPhotons = (float)timePerFrame - tlastVsync.getValue() + vsyncToPhotons; - - if( enableDebugLatency ) { - if( frames == 10 ) { - System.out.println("Waited (nanos): " + Long.toString(latencyWaitTime)); - System.out.println("Predict ahead time: " + Float.toString(fSecondsUntilPhotons)); - } - frames = (frames + 1) % 60; - } - - // handle skipping frame stuff - long nowCount = _tframeCount.getValue(); - if( nowCount - frameCount > 1 ) { - // skipped a frame! - if( enableDebugLatency ) System.out.println("Frame skipped!"); - frameCountRun = 0; - if( latencyWaitTime > 0 ) { - latencyWaitTime -= TimeUnit.MILLISECONDS.toNanos(1); - if( latencyWaitTime < 0 ) latencyWaitTime = 0; - } - } else if( latencyWaitTime < timePerFrame * 1000000000.0 ) { - // didn't skip a frame, lets try waiting longer to improve latency - frameCountRun++; - latencyWaitTime += Math.round(Math.pow(frameCountRun / 10.0, 2.0)); - } - - frameCount = nowCount; - - vrSystemFunctions.GetDeviceToAbsoluteTrackingPose.apply( - environment.isSeatedExperience()?JOpenVRLibrary.ETrackingUniverseOrigin.ETrackingUniverseOrigin_TrackingUniverseSeated: - JOpenVRLibrary.ETrackingUniverseOrigin.ETrackingUniverseOrigin_TrackingUniverseStanding, - fSecondsUntilPhotons, hmdTrackedDevicePoseReference, JOpenVRLibrary.k_unMaxTrackedDeviceCount); - } - - // deal with controllers being plugged in and out - // causing an invalid memory crash... skipping for now - /*boolean hasEvent = false; - while( JOpenVRLibrary.VR_IVRSystem_PollNextEvent(OpenVR.getVRSystemInstance(), tempEvent) != 0 ) { - // Wait until the events are clear. - hasEvent = true; - } - if( hasEvent ) { - // an event probably changed controller state - VRInput._updateConnectedControllers(); - }*/ - //update controllers pose information - environment.getVRinput().updateControllerStates(); - - // read pose data from native - for (int nDevice = 0; nDevice < JOpenVRLibrary.k_unMaxTrackedDeviceCount; ++nDevice ){ - hmdTrackedDevicePoses[nDevice].readField("bPoseIsValid"); - if( hmdTrackedDevicePoses[nDevice].bPoseIsValid != 0 ){ - hmdTrackedDevicePoses[nDevice].readField("mDeviceToAbsoluteTracking"); - convertSteamVRMatrix3ToMatrix4f(hmdTrackedDevicePoses[nDevice].mDeviceToAbsoluteTracking, poseMatrices[nDevice]); - } - } - - if ( hmdTrackedDevicePoses[JOpenVRLibrary.k_unTrackedDeviceIndex_Hmd].bPoseIsValid != 0 ){ - hmdPose.set(poseMatrices[JOpenVRLibrary.k_unTrackedDeviceIndex_Hmd]); - } else { - hmdPose.set(Matrix4f.IDENTITY); - } - } - - @Override - public Matrix4f getHMDMatrixProjectionLeftEye(Camera cam){ - if( hmdProjectionLeftEye != null ) { - return hmdProjectionLeftEye; - } else if(vrSystemFunctions == null){ - return cam.getProjectionMatrix(); - } else { - HmdMatrix44_t mat = vrSystemFunctions.GetProjectionMatrix.apply(JOpenVRLibrary.EVREye.EVREye_Eye_Left, cam.getFrustumNear(), cam.getFrustumFar()); - hmdProjectionLeftEye = new Matrix4f(); - convertSteamVRMatrix4ToMatrix4f(mat, hmdProjectionLeftEye); - return hmdProjectionLeftEye; - } - } - - @Override - public Matrix4f getHMDMatrixProjectionRightEye(Camera cam){ - if( hmdProjectionRightEye != null ) { - return hmdProjectionRightEye; - } else if(vrSystemFunctions == null){ - return cam.getProjectionMatrix(); - } else { - HmdMatrix44_t mat = vrSystemFunctions.GetProjectionMatrix.apply(JOpenVRLibrary.EVREye.EVREye_Eye_Right, cam.getFrustumNear(), cam.getFrustumFar()); - hmdProjectionRightEye = new Matrix4f(); - convertSteamVRMatrix4ToMatrix4f(mat, hmdProjectionRightEye); - return hmdProjectionRightEye; - } - } - - @Override - public Vector3f getHMDVectorPoseLeftEye() { - if( hmdPoseLeftEyeVec == null ) { - hmdPoseLeftEyeVec = getHMDMatrixPoseLeftEye().toTranslationVector(); - // set default IPD if none or broken - if( hmdPoseLeftEyeVec.x <= 0.080f * -0.5f || hmdPoseLeftEyeVec.x >= 0.040f * -0.5f ) { - hmdPoseLeftEyeVec.x = 0.065f * -0.5f; - } - if( flipEyes == false ) hmdPoseLeftEyeVec.x *= -1f; // it seems these need flipping - } - return hmdPoseLeftEyeVec; - } - - @Override - public Vector3f getHMDVectorPoseRightEye() { - if( hmdPoseRightEyeVec == null ) { - hmdPoseRightEyeVec = getHMDMatrixPoseRightEye().toTranslationVector(); - // set default IPD if none or broken - if( hmdPoseRightEyeVec.x >= 0.080f * 0.5f || hmdPoseRightEyeVec.x <= 0.040f * 0.5f ) { - hmdPoseRightEyeVec.x = 0.065f * 0.5f; - } - if( flipEyes == false ) hmdPoseRightEyeVec.x *= -1f; // it seems these need flipping - } - return hmdPoseRightEyeVec; - } - - @Override - public Vector3f getSeatedToAbsolutePosition() { - if( environment.isSeatedExperience() == false ) return Vector3f.ZERO; - if( hmdSeatToStand == null ) { - hmdSeatToStand = new Vector3f(); - HmdMatrix34_t mat = vrSystemFunctions.GetSeatedZeroPoseToStandingAbsoluteTrackingPose.apply(); - Matrix4f tempMatrix = new Matrix4f(); - convertSteamVRMatrix3ToMatrix4f(mat, tempMatrix); - tempMatrix.toTranslationVector(hmdSeatToStand); - } - return hmdSeatToStand; - } - - @Override - public Matrix4f getHMDMatrixPoseLeftEye(){ - if( hmdPoseLeftEye != null ) { - return hmdPoseLeftEye; - } else if(vrSystemFunctions == null) { - return Matrix4f.IDENTITY; - } else { - HmdMatrix34_t mat = vrSystemFunctions.GetEyeToHeadTransform.apply(JOpenVRLibrary.EVREye.EVREye_Eye_Left); - hmdPoseLeftEye = new Matrix4f(); - return convertSteamVRMatrix3ToMatrix4f(mat, hmdPoseLeftEye); - } - } - - @Override - public HmdType getType() { - if( vrSystemFunctions != null ) { - Pointer str1 = new Memory(128); - Pointer str2 = new Memory(128); - String completeName = ""; - vrSystemFunctions.GetStringTrackedDeviceProperty.apply(JOpenVRLibrary.k_unTrackedDeviceIndex_Hmd, - JOpenVRLibrary.ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_ManufacturerName_String, - str1, 128, hmdErrorStore); - if( hmdErrorStore.getValue() == 0 ) completeName += str1.getString(0); - vrSystemFunctions.GetStringTrackedDeviceProperty.apply(JOpenVRLibrary.k_unTrackedDeviceIndex_Hmd, - JOpenVRLibrary.ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_ModelNumber_String, - str2, 128, hmdErrorStore); - if( hmdErrorStore.getValue() == 0 ) completeName += " " + str2.getString(0); - if( completeName.length() > 0 ) { - completeName = completeName.toLowerCase(Locale.ENGLISH).trim(); - if( completeName.contains("htc") || completeName.contains("vive") ) { - return HmdType.HTC_VIVE; - } else if ( completeName.contains("index") ) { - return HmdType.VALVE_INDEX; - } else if( completeName.contains("osvr") ) { - return HmdType.OSVR; - } else if( completeName.contains("oculus") || completeName.contains("rift") || - completeName.contains("dk1") || completeName.contains("dk2") || completeName.contains("cv1") ) { - return HmdType.OCULUS_RIFT; - } else if( completeName.contains("fove") ) { - return HmdType.FOVE; - } else if( completeName.contains("game") && completeName.contains("face") ) { - return HmdType.GAMEFACE; - } else if( completeName.contains("morpheus") ) { - return HmdType.MORPHEUS; - } else if( completeName.contains("gear") ) { - return HmdType.GEARVR; - } else if( completeName.contains("star") ) { - return HmdType.STARVR; - } else if( completeName.contains("null") ) { - return HmdType.NULL; - } - } - } else return HmdType.NONE; - return HmdType.OTHER; - } - - @Override - public Matrix4f getHMDMatrixPoseRightEye(){ - if( hmdPoseRightEye != null ) { - return hmdPoseRightEye; - } else if(vrSystemFunctions == null) { - return Matrix4f.IDENTITY; - } else { - HmdMatrix34_t mat = vrSystemFunctions.GetEyeToHeadTransform.apply(JOpenVRLibrary.EVREye.EVREye_Eye_Right); - hmdPoseRightEye = new Matrix4f(); - return convertSteamVRMatrix3ToMatrix4f(mat, hmdPoseRightEye); - } - } -} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/openvr/OpenVRBounds.java b/jme3-xr/src/main/java/com/jme3/input/vr/openvr/OpenVRBounds.java deleted file mode 100644 index ed53274888..0000000000 --- a/jme3-xr/src/main/java/com/jme3/input/vr/openvr/OpenVRBounds.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.jme3.input.vr.openvr; - -import com.jme3.input.vr.VRBounds; -import com.jme3.math.Vector2f; -import com.jme3.system.jopenvr.JOpenVRLibrary; -import com.jme3.system.jopenvr.VR_IVRChaperone_FnTable; -import com.sun.jna.ptr.FloatByReference; - -import java.util.logging.Logger; - -/** - * A class that represents VR world bounds. - * @author reden - phr00t - https://github.com/phr00t - * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr - */ -public class OpenVRBounds implements VRBounds { - private static Logger logger = Logger.getLogger(OpenVRBounds.class.getName()); - - private VR_IVRChaperone_FnTable vrChaperone; - private Vector2f playSize; - - /** - * Initialize the VR bounds. - * @return true if the initialization is a success and false otherwise. - */ - public boolean init(OpenVR api) { - logger.config("Initialize VR bounds..."); - - if( vrChaperone == null ) { - vrChaperone = new VR_IVRChaperone_FnTable(JOpenVRLibrary.VR_GetGenericInterface(JOpenVRLibrary.IVRChaperone_Version, api.hmdErrorStore).getPointer()); - if( vrChaperone != null ) { - vrChaperone.setAutoSynch(false); - vrChaperone.read(); - FloatByReference fbX = new FloatByReference(); - FloatByReference fbZ = new FloatByReference(); - vrChaperone.GetPlayAreaSize.apply(fbX, fbZ); - playSize = new Vector2f(fbX.getValue(), fbZ.getValue()); - - logger.config("Initialize VR bounds [SUCCESS]"); - return true; // init success - } - - logger.warning("Initialize VR bounds [FAILED]."); - return false; // failed to init - } - - logger.config("Initialize VR bounds already done."); - return true; // already initialized - } - - @Override - public Vector2f getPlaySize() { - return playSize; - } -} - diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/openvr/OpenVRInput.java b/jme3-xr/src/main/java/com/jme3/input/vr/openvr/OpenVRInput.java deleted file mode 100644 index 6e4e536aec..0000000000 --- a/jme3-xr/src/main/java/com/jme3/input/vr/openvr/OpenVRInput.java +++ /dev/null @@ -1,498 +0,0 @@ -package com.jme3.input.vr.openvr; - -import java.util.ArrayList; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; - -import com.jme3.app.VREnvironment; -import com.jme3.input.vr.VRInputAPI; -import com.jme3.input.vr.VRInputType; -import com.jme3.input.vr.VRTrackedController; -import com.jme3.math.Quaternion; -import com.jme3.math.Vector2f; -import com.jme3.math.Vector3f; -import com.jme3.renderer.Camera; -import com.jme3.scene.Spatial; -import com.jme3.system.jopenvr.JOpenVRLibrary; -import com.jme3.system.jopenvr.OpenVRUtil; -import com.jme3.system.jopenvr.VRControllerState_t; -import com.jme3.system.jopenvr.VR_IVRSystem_FnTable; -import com.jme3.util.VRUtil; - -/* -make helper functions to pull the following easily from raw data (DONE) - -trigger: -Controller#1, Axis#0 X: 0.0, Y: 0.0 -Controller#1, Axis#1 X: 1.0, Y: 0.0 -Controller#1, Axis#2 X: 0.0, Y: 0.0 -Controller#1, Axis#3 X: 0.0, Y: 0.0 -Controller#1, Axis#4 X: 0.0, Y: 0.0 -Button press: 8589934592 (when full), touch: 8589934592 - -touchpad (upper left): -Controller#1, Axis#0 X: -0.6059755, Y: 0.2301706 -Controller#1, Axis#1 X: 0.0, Y: 0.0 -Controller#1, Axis#2 X: 0.0, Y: 0.0 -Controller#1, Axis#3 X: 0.0, Y: 0.0 -Controller#1, Axis#4 X: 0.0, Y: 0.0 -Button press: 4294967296 (when pressed in), touch: 4294967296 - -grip: -Controller#1, Axis#0 X: 0.0, Y: 0.0 -Controller#1, Axis#1 X: 0.0, Y: 0.0 -Controller#1, Axis#2 X: 0.0, Y: 0.0 -Controller#1, Axis#3 X: 0.0, Y: 0.0 -Controller#1, Axis#4 X: 0.0, Y: 0.0 -Button press: 4, touch: 4 - -thumb: -Controller#1, Axis#0 X: 0.0, Y: 0.0 -Controller#1, Axis#1 X: 0.0, Y: 0.0 -Controller#1, Axis#2 X: 0.0, Y: 0.0 -Controller#1, Axis#3 X: 0.0, Y: 0.0 -Controller#1, Axis#4 X: 0.0, Y: 0.0 -Button press: 2, touch: 2 - -*/ - -/** - * A class that wraps an OpenVR input.
- * null values will be returned if no valid pose exists, or that input device isn't available - * user code should check for null values. - * @author reden - phr00t - https://github.com/phr00t - * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr - */ -public class OpenVRInput implements VRInputAPI { - private static final Logger logger = Logger.getLogger(OpenVRInput.class.getName()); - - private final VRControllerState_t[] cStates = new VRControllerState_t[JOpenVRLibrary.k_unMaxTrackedDeviceCount]; - - private final Quaternion[] rotStore = new Quaternion[JOpenVRLibrary.k_unMaxTrackedDeviceCount]; - - private final Vector3f[] posStore = new Vector3f[JOpenVRLibrary.k_unMaxTrackedDeviceCount]; - - private static final int[] controllerIndex = new int[JOpenVRLibrary.k_unMaxTrackedDeviceCount]; - - private int controllerCount = 0; - - private final Vector2f tempAxis = new Vector2f(), temp2Axis = new Vector2f(); - - private final Vector2f lastCallAxis[] = new Vector2f[JOpenVRLibrary.k_unMaxTrackedDeviceCount]; - - private final boolean needsNewVelocity[] = new boolean[JOpenVRLibrary.k_unMaxTrackedDeviceCount]; - - private final boolean needsNewAngVelocity[] = new boolean[JOpenVRLibrary.k_unMaxTrackedDeviceCount]; - - private final boolean buttonDown[][] = new boolean[JOpenVRLibrary.k_unMaxTrackedDeviceCount][16]; - - private float axisMultiplier = 1f; - - private final Vector3f tempVel = new Vector3f(); - - private final Quaternion tempQuaternion = new Quaternion(); - - private VREnvironment environment; - - private List trackedControllers = null; - - /** - * Create a new OpenVR input attached to the given VR environment. - * @param environment the VR environment to which the input is attached. - */ - public OpenVRInput(VREnvironment environment){ - this.environment = environment; - } - - @Override - public float getAxisMultiplier() { - return axisMultiplier; - } - - @Override - public void setAxisMultiplier(float set) { - axisMultiplier = set; - } - - @Override - public void swapHands() { - if( controllerCount != 2 ) return; - int temp = controllerIndex[0]; - controllerIndex[0] = controllerIndex[1]; - controllerIndex[1] = temp; - } - - @Override - public boolean isButtonDown(int controllerIndex, VRInputType checkButton) { - VRControllerState_t cs = cStates[OpenVRInput.controllerIndex[controllerIndex]]; - switch( checkButton ) { - default: - return false; - case ViveGripButton: - return (cs.ulButtonPressed & 4) != 0; - case ViveMenuButton: - return (cs.ulButtonPressed & 2) != 0; - case ViveTrackpadAxis: - return (cs.ulButtonPressed & 4294967296l) != 0; - case ViveTriggerAxis: - return (cs.ulButtonPressed & 8589934592l) != 0; - } - } - - @Override - public boolean wasButtonPressedSinceLastCall(int controllerIndex, VRInputType checkButton) { - boolean buttonDownNow = isButtonDown(controllerIndex, checkButton); - int checkButtonValue = checkButton.getValue(); - int cIndex = OpenVRInput.controllerIndex[controllerIndex]; - boolean retval = buttonDownNow == true && buttonDown[cIndex][checkButtonValue] == false; - buttonDown[cIndex][checkButtonValue] = buttonDownNow; - return retval; - } - - @Override - public void resetInputSinceLastCall() { - for(int i=0;i 0) && (index < trackedControllers.size())){ - return trackedControllers.get(index); - } - } - - return null; - } - - @Override - public int getTrackedControllerCount() { - return controllerCount; - } - - @Override - public VRControllerState_t getRawControllerState(int index) { - if( isInputDeviceTracking(index) == false ) return null; - return cStates[controllerIndex[index]]; - } - - //public Matrix4f getPoseForInputDevice(int index) { - // if( isInputDeviceTracking(index) == false ) return null; - // return OpenVR.poseMatrices[controllerIndex[index]]; - //} - - @Override - public boolean isInputFocused() { - if (environment != null){ - return ((VR_IVRSystem_FnTable)environment.getVRHardware().getVRSystem()).IsInputAvailable.apply() == 0; - } else { - throw new IllegalStateException("VR input is not attached to a VR environment."); - } - } - - @Override - public boolean isInputDeviceTracking(int index) { - if( index < 0 || index >= controllerCount ){ - return false; - } - - if (environment != null){ - if (environment.getVRHardware() instanceof OpenVR){ - return ((OpenVR)environment.getVRHardware()).hmdTrackedDevicePoses[controllerIndex[index]].bPoseIsValid != 0; - } else { - throw new IllegalStateException("VR hardware "+environment.getVRHardware().getClass().getSimpleName()+" is not a subclass of "+OpenVR.class.getSimpleName()); - } - } else { - throw new IllegalStateException("VR input is not attached to a VR environment."); - } - } - - @Override - public Quaternion getOrientation(int index) { - if( isInputDeviceTracking(index) == false ){ - return null; - } - - if (environment != null){ - - if (environment.getVRHardware() instanceof OpenVR){ - index = controllerIndex[index]; - VRUtil.convertMatrix4toQuat(((OpenVR)environment.getVRHardware()).poseMatrices[index], rotStore[index]); - return rotStore[index]; - } else { - throw new IllegalStateException("VR hardware "+environment.getVRHardware().getClass().getSimpleName()+" is not a subclass of "+OpenVR.class.getSimpleName()); - } - } else { - throw new IllegalStateException("VR input is not attached to a VR environment."); - } - } - - @Override - public Vector3f getPosition(int index) { - if( isInputDeviceTracking(index) == false ){ - return null; - } - - if (environment != null){ - if (environment.getVRHardware() instanceof OpenVR){ - // the hmdPose comes in rotated funny, fix that here - index = controllerIndex[index]; - ((OpenVR)environment.getVRHardware()).poseMatrices[index].toTranslationVector(posStore[index]); - posStore[index].x = -posStore[index].x; - posStore[index].z = -posStore[index].z; - return posStore[index]; - } else { - throw new IllegalStateException("VR hardware "+environment.getVRHardware().getClass().getSimpleName()+" is not a subclass of "+OpenVR.class.getSimpleName()); - } - } else { - throw new IllegalStateException("VR input is not attached to a VR environment."); - } - } - - @Override - public Quaternion getFinalObserverRotation(int index) { - if (environment != null){ - OpenVRViewManager vrvm = (OpenVRViewManager)environment.getVRViewManager(); - - if (vrvm != null){ - if(isInputDeviceTracking(index) == false ){ - return null; - } - - Object obs = environment.getObserver(); - if( obs instanceof Camera ) { - tempQuaternion.set(((Camera)obs).getRotation()); - } else { - tempQuaternion.set(((Spatial)obs).getWorldRotation()); - } - - return tempQuaternion.multLocal(getOrientation(index)); - } else { - throw new IllegalStateException("VR environment has no valid view manager."); - } - - } else { - throw new IllegalStateException("VR input is not attached to a VR environment."); - } - } - - @Override - public Vector3f getFinalObserverPosition(int index) { - if (environment != null){ - OpenVRViewManager vrvm = (OpenVRViewManager)environment.getVRViewManager(); - - if (vrvm != null){ - if(isInputDeviceTracking(index) == false ){ - return null; - } - Object obs = environment.getObserver(); - Vector3f pos = getPosition(index); - if( obs instanceof Camera ) { - ((Camera)obs).getRotation().mult(pos, pos); - return pos.addLocal(((Camera)obs).getLocation()); - } else { - ((Spatial)obs).getWorldRotation().mult(pos, pos); - return pos.addLocal(((Spatial)obs).getWorldTranslation()); - } - } else { - throw new IllegalStateException("VR environment has no valid view manager."); - } - - } else { - throw new IllegalStateException("VR input is not attached to a VR environment."); - } - } - - @Override - public void triggerHapticPulse(int controllerIndex, float seconds) { - if( environment.isInVR() == false || isInputDeviceTracking(controllerIndex) == false ){ - return; - } - - // apparently only axis ID of 0 works - ((VR_IVRSystem_FnTable)environment.getVRHardware().getVRSystem()).TriggerHapticPulse.apply(OpenVRInput.controllerIndex[controllerIndex], - 0, (short)Math.round(3f * seconds / 1e-3f)); - } - - @Override - public void updateConnectedControllers() { - logger.config("Updating connected controllers."); - - if (environment != null){ - controllerCount = 0; - for(int i=0;i(JOpenVRLibrary.k_unMaxTrackedDeviceCount); - } - trackedControllers.add(new OpenVRTrackedController(i, this, controllerName, manufacturerName, environment)); - - // Send a Haptic pulse to the controller - triggerHapticPulse(controllerCount, 1.0f); - - controllerCount++; - logger.config(" Tracked controller "+(i+1)+"/"+JOpenVRLibrary.k_unMaxTrackedDeviceCount+" "+controllerName+" ("+manufacturerName+") attached."); - } else { - logger.config(" Controller "+(i+1)+"/"+JOpenVRLibrary.k_unMaxTrackedDeviceCount+" ignored."); - } - } - } else { - throw new IllegalStateException("VR input is not attached to a VR environment."); - } - } - - @Override - public void updateControllerStates() { - if (environment != null){ - for(int i=0;ihttp://www.seinturier.fr - */ -public class OpenVRMouseManager extends AbstractVRMouseManager { - private final int AVERAGE_AMNT = 4; - - private int avgCounter; - - private final float[] lastXmv = new float[AVERAGE_AMNT]; - - private final float[] lastYmv = new float[AVERAGE_AMNT]; - - /** - * Create a new VR mouse manager within the given {@link VREnvironment VR environment}. - * @param environment the VR environment of the mouse manager. - */ - public OpenVRMouseManager(VREnvironment environment){ - super(environment); - } - - @Override - public void updateAnalogAsMouse(int inputIndex, AnalogListener mouseListener, String mouseXName, String mouseYName, float tpf) { - if (getVREnvironment() != null){ - if (getVREnvironment().getApplication() != null){ - // got a tracked controller to use as the "mouse" - if( getVREnvironment().isInVR() == false || - getVREnvironment().getVRinput() == null || - getVREnvironment().getVRinput().isInputDeviceTracking(inputIndex) == false ){ - return; - } - - Vector2f tpDelta; - // TODO option to use Touch joysticks - if( isThumbstickMode() ) { - tpDelta = getVREnvironment().getVRinput().getAxis(inputIndex, VRInputType.ViveTrackpadAxis); - } else { - tpDelta = getVREnvironment().getVRinput().getAxisDeltaSinceLastCall(inputIndex, VRInputType.ViveTrackpadAxis); - } - - float xAmount = (float)Math.pow(Math.abs(tpDelta.x) * getSpeedSensitivity(), getSpeedAcceleration()); - float yAmount = (float)Math.pow(Math.abs(tpDelta.y) * getSpeedSensitivity(), getSpeedAcceleration()); - - if( tpDelta.x < 0f ){ - xAmount = -xAmount; - } - - if( tpDelta.y < 0f ){ - yAmount = -yAmount; - } - - xAmount *= getMouseMoveScale(); - yAmount *= getMouseMoveScale(); - - if( mouseListener != null ) { - if( tpDelta.x != 0f && mouseXName != null ) mouseListener.onAnalog(mouseXName, xAmount * 0.2f, tpf); - if( tpDelta.y != 0f && mouseYName != null ) mouseListener.onAnalog(mouseYName, yAmount * 0.2f, tpf); - } - - if( getVREnvironment().getApplication().getInputManager().isCursorVisible() ) { - int index = (avgCounter+1) % AVERAGE_AMNT; - lastXmv[index] = xAmount * 133f; - lastYmv[index] = yAmount * 133f; - cursorPos.x -= avg(lastXmv); - cursorPos.y -= avg(lastYmv); - Vector2f maxsize = getVREnvironment().getVRGUIManager().getCanvasSize(); - - if( cursorPos.x > maxsize.x ){ - cursorPos.x = maxsize.x; - } - - if( cursorPos.x < 0f ){ - cursorPos.x = 0f; - } - - if( cursorPos.y > maxsize.y ){ - cursorPos.y = maxsize.y; - } - - if( cursorPos.y < 0f ){ - cursorPos.y = 0f; - } - } - } else { - throw new IllegalStateException("This VR environment is not attached to any application."); - } - } else { - throw new IllegalStateException("This VR view manager is not attached to any VR environment."); - } - } - - private float avg(float[] arr) { - float amt = 0f; - for(float f : arr) amt += f; - return amt / arr.length; - } -} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/openvr/OpenVRTrackedController.java b/jme3-xr/src/main/java/com/jme3/input/vr/openvr/OpenVRTrackedController.java deleted file mode 100644 index bcd521e891..0000000000 --- a/jme3-xr/src/main/java/com/jme3/input/vr/openvr/OpenVRTrackedController.java +++ /dev/null @@ -1,95 +0,0 @@ -package com.jme3.input.vr.openvr; - -import com.jme3.app.VREnvironment; -import com.jme3.input.vr.VRTrackedController; -import com.jme3.math.Matrix4f; -import com.jme3.math.Quaternion; -import com.jme3.math.Vector3f; - -/** - * A controller that is tracked within the VR environment. Such a controller can provide its position within the VR space. - * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr - * - */ -public class OpenVRTrackedController implements VRTrackedController{ - /** - * The index of the controller within the underlying VR API. - */ - private int controllerIndex = -1; - - /** - * The underlying VRAPI. - */ - private OpenVRInput hardware = null; - - /** - * The name of the controller. - */ - private String name; - - private VREnvironment environment; - - /** - * Wrap a new VR tracked controller on an OpenVR system. - * @param controllerIndex the index of the controller within the underlying VR system. - * @param hardware the underlying VR system. - * @param name the name of the controller. - * @param manufacturer the manufacturer of the controller. - * @param environment the VR environment. - */ - public OpenVRTrackedController(int controllerIndex, OpenVRInput hardware, String name, String manufacturer, VREnvironment environment){ - this.controllerIndex = controllerIndex; - this.hardware = hardware; - - this.name = name; - this.manufacturer = manufacturer; - - this.environment = environment; - } - - /** - * The manufacturer of the controller. - */ - private String manufacturer; - - @Override - public Vector3f getPosition() { - if (hardware != null){ - return hardware.getPosition(controllerIndex); - } else { - throw new IllegalStateException("No underlying VR API."); - } - } - - @Override - public Quaternion getOrientation() { - if (hardware != null){ - return hardware.getOrientation(controllerIndex); - } else { - throw new IllegalStateException("No underlying VR API."); - } - } - - @Override - public Matrix4f getPose(){ - if (environment != null){ - if (hardware != null){ - return ((OpenVR)environment.getVRHardware()).poseMatrices[controllerIndex]; - } else { - throw new IllegalStateException("No underlying VR API."); - } - } else { - throw new IllegalStateException("VR tracked device is not attached to any environment."); - } - } - - @Override - public String getControllerName() { - return name; - } - - @Override - public String getControllerManufacturer() { - return manufacturer; - } -} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/openvr/OpenVRViewManager.java b/jme3-xr/src/main/java/com/jme3/input/vr/openvr/OpenVRViewManager.java deleted file mode 100644 index c6d0237321..0000000000 --- a/jme3-xr/src/main/java/com/jme3/input/vr/openvr/OpenVRViewManager.java +++ /dev/null @@ -1,733 +0,0 @@ -package com.jme3.input.vr.openvr; - -import com.jme3.app.VREnvironment; -import com.jme3.input.vr.AbstractVRViewManager; -import com.jme3.input.vr.VRAPI; -import com.jme3.material.Material; -import com.jme3.math.ColorRGBA; -import com.jme3.math.Quaternion; -import com.jme3.math.Vector2f; -import com.jme3.math.Vector3f; -import com.jme3.renderer.Camera; -import com.jme3.renderer.ViewPort; -import com.jme3.renderer.queue.RenderQueue.Bucket; -import com.jme3.scene.Geometry; -import com.jme3.scene.Mesh; -import com.jme3.scene.Node; -import com.jme3.scene.Spatial; -import com.jme3.scene.VertexBuffer; -import com.jme3.system.jopenvr.DistortionCoordinates_t; -import com.jme3.system.jopenvr.JOpenVRLibrary; -import com.jme3.system.jopenvr.OpenVRUtil; -import com.jme3.system.jopenvr.Texture_t; -import com.jme3.system.jopenvr.VRTextureBounds_t; -import com.jme3.system.jopenvr.VR_IVRSystem_FnTable; -import com.jme3.texture.FrameBuffer; -import com.jme3.texture.Image; -import com.jme3.texture.Texture; -import com.jme3.texture.Texture2D; -import com.jme3.ui.Picture; -import com.jme3.util.VRGUIPositioningMode; - -import java.util.Iterator; -import java.util.logging.Logger; - -/** - * A VR view manager based on OpenVR. This class enable to submit 3D views to the VR compositor. - * @author reden - phr00t - https://github.com/phr00t - * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr - */ -public class OpenVRViewManager extends AbstractVRViewManager { - private static final Logger logger = Logger.getLogger(OpenVRViewManager.class.getName()); - - // OpenVR values - private VRTextureBounds_t leftTextureBounds; - private Texture_t leftTextureType; - - private VRTextureBounds_t rightTextureBounds; - private Texture_t rightTextureType; - - private Texture2D dualEyeTex; - - //final & temp values for camera calculations - private final Vector3f finalPosition = new Vector3f(); - private final Quaternion finalRotation = new Quaternion(); - private final Vector3f hmdPos = new Vector3f(); - private final Quaternion hmdRot = new Quaternion(); - - /** - * Create a new VR view manager attached to the given {@link VREnvironment VR environment}. - * @param environment the {@link VREnvironment VR environment} to which this view manager is attached. - */ - public OpenVRViewManager(VREnvironment environment){ - this.environment = environment; - } - - /** - * Get the identifier of the left eye texture. - * @return the identifier of the left eye texture. - * @see #getRightTexId() - * @see #getFullTexId() - */ - protected int getLeftTexId() { - return getLeftTexture().getImage().getId(); - } - - /** - * Get the identifier of the right eye texture. - * @return the identifier of the right eye texture. - * @see #getLeftTexId() - * @see #getFullTexId() - */ - protected int getRightTexId() { - return getRightTexture().getImage().getId(); - } - - /** - * Get the identifier of the full (dual eye) texture. - * @return the identifier of the full (dual eye) texture. - * @see #getLeftTexId() - * @see #getRightTexId() - */ - private int getFullTexId() { - return dualEyeTex.getImage().getId(); - } - - /** - * Initialize the system binds of the textures. - */ - private void initTextureSubmitStructs() { - leftTextureType = new Texture_t(); - rightTextureType = new Texture_t(); - - if (environment != null){ - if( environment.getVRHardware() instanceof OpenVR ) { - leftTextureBounds = new VRTextureBounds_t(); - rightTextureBounds = new VRTextureBounds_t(); - // left eye - leftTextureBounds.uMax = 0.5f; - leftTextureBounds.uMin = 0f; - leftTextureBounds.vMax = 1f; - leftTextureBounds.vMin = 0f; - leftTextureBounds.setAutoSynch(false); - leftTextureBounds.setAutoRead(false); - leftTextureBounds.setAutoWrite(false); - leftTextureBounds.write(); - // right eye - rightTextureBounds.uMax = 1f; - rightTextureBounds.uMin = 0.5f; - rightTextureBounds.vMax = 1f; - rightTextureBounds.vMin = 0f; - rightTextureBounds.setAutoSynch(false); - rightTextureBounds.setAutoRead(false); - rightTextureBounds.setAutoWrite(false); - rightTextureBounds.write(); - // texture type - leftTextureType.eColorSpace = JOpenVRLibrary.EColorSpace.EColorSpace_ColorSpace_Gamma; - leftTextureType.eType = JOpenVRLibrary.ETextureType.ETextureType_TextureType_OpenGL; - leftTextureType.setAutoSynch(false); - leftTextureType.setAutoRead(false); - leftTextureType.setAutoWrite(false); - leftTextureType.handle = -1; - rightTextureType.eColorSpace = JOpenVRLibrary.EColorSpace.EColorSpace_ColorSpace_Gamma; - rightTextureType.eType = JOpenVRLibrary.ETextureType.ETextureType_TextureType_OpenGL; - rightTextureType.setAutoSynch(false); - rightTextureType.setAutoRead(false); - rightTextureType.setAutoWrite(false); - rightTextureType.handle = -1; - - logger.config("Init eyes native texture binds"); - logger.config(" Left eye texture"); - logger.config(" address: "+leftTextureType.getPointer()); - logger.config(" size: "+leftTextureType.size()+" bytes"); - logger.config(" color space: "+OpenVRUtil.getEColorSpaceString(leftTextureType.eColorSpace)); - logger.config(" type: "+OpenVRUtil.getETextureTypeString(leftTextureType.eType)); - logger.config(" auto read: "+leftTextureType.getAutoRead()); - logger.config(" auto write: "+leftTextureType.getAutoWrite()); - logger.config(" handle address: "+leftTextureType.handle); - logger.config(" handle value: "+leftTextureType.handle); - logger.config(""); - logger.config(" Right eye texture"); - logger.config(" address: "+rightTextureType.getPointer()); - logger.config(" size: "+rightTextureType.size()+" bytes"); - logger.config(" color space: "+OpenVRUtil.getEColorSpaceString(rightTextureType.eColorSpace)); - logger.config(" type: "+OpenVRUtil.getETextureTypeString(rightTextureType.eType)); - logger.config(" auto read: "+rightTextureType.getAutoRead()); - logger.config(" auto write: "+rightTextureType.getAutoWrite()); - logger.config(" handle address: "+rightTextureType.handle); - logger.config(" handle value: "+rightTextureType.handle); - } - } else { - throw new IllegalStateException("This VR view manager is not attached to any VR environment."); - } - } - - @Override - public void render() { - } - - @Override - public void postRender() { - if (environment != null){ - if( environment.isInVR() ) { - VRAPI api = environment.getVRHardware(); - if( api.getCompositor() != null ) { - // using the compositor... - int errl = 0, errr = 0; - if( environment.isInstanceRendering() ) { - if( leftTextureType.handle == -1 || leftTextureType.handle != getFullTexId() ) { - leftTextureType.handle = getFullTexId(); - if( leftTextureType.handle != -1 ) { - leftTextureType.write(); - } - } else { - if( api instanceof OpenVR ) { - int submitFlag = JOpenVRLibrary.EVRSubmitFlags.EVRSubmitFlags_Submit_Default; - errr = ((OpenVR)api).getCompositor().Submit.apply(JOpenVRLibrary.EVREye.EVREye_Eye_Right, leftTextureType, rightTextureBounds, submitFlag); - errl = ((OpenVR)api).getCompositor().Submit.apply(JOpenVRLibrary.EVREye.EVREye_Eye_Left, leftTextureType, leftTextureBounds, submitFlag); - } - } - } else if( leftTextureType.handle == -1 || rightTextureType.handle == -1 || - leftTextureType.handle != getLeftTexId() || rightTextureType.handle != getRightTexId() ) { - leftTextureType.handle = getLeftTexId(); - if( leftTextureType.handle != -1 ) { - logger.fine("Writing Left texture to native memory at " + leftTextureType.getPointer()); - leftTextureType.write(); - } - rightTextureType.handle = getRightTexId(); - if( rightTextureType.handle != -1 ) { - logger.fine("Writing Right texture to native memory at " + leftTextureType.getPointer()); - rightTextureType.write(); - } - } else { - if( api instanceof OpenVR ) { - errl = ((OpenVR)api).getCompositor().Submit.apply(JOpenVRLibrary.EVREye.EVREye_Eye_Left, leftTextureType, null, - JOpenVRLibrary.EVRSubmitFlags.EVRSubmitFlags_Submit_Default); - errr = ((OpenVR)api).getCompositor().Submit.apply(JOpenVRLibrary.EVREye.EVREye_Eye_Right, rightTextureType, null, - JOpenVRLibrary.EVRSubmitFlags.EVRSubmitFlags_Submit_Default); - } else { - - } - } - - if( errl != 0 ){ - logger.severe("Submit to left compositor error: " + OpenVRUtil.getEVRCompositorErrorString(errl)+" ("+Integer.toString(errl)+")"); - logger.severe(" Texture color space: "+OpenVRUtil.getEColorSpaceString(leftTextureType.eColorSpace)); - logger.severe(" Texture type: "+OpenVRUtil.getETextureTypeString(leftTextureType.eType)); - logger.severe(" Texture handle: "+leftTextureType.handle); - - logger.severe(" Left eye texture "+leftEyeTexture.getName()+" ("+leftEyeTexture.getImage().getId()+")"); - logger.severe(" Type: "+leftEyeTexture.getType()); - logger.severe(" Size: "+leftEyeTexture.getImage().getWidth()+"x"+leftEyeTexture.getImage().getHeight()); - logger.severe(" Image depth: "+leftEyeTexture.getImage().getDepth()); - logger.severe(" Image format: "+leftEyeTexture.getImage().getFormat()); - logger.severe(" Image color space: "+leftEyeTexture.getImage().getColorSpace()); - } - - if( errr != 0 ){ - logger.severe("Submit to right compositor error: " + OpenVRUtil.getEVRCompositorErrorString(errl)+" ("+Integer.toString(errl)+")"); - logger.severe(" Texture color space: "+OpenVRUtil.getEColorSpaceString(rightTextureType.eColorSpace)); - logger.severe(" Texture type: "+OpenVRUtil.getETextureTypeString(rightTextureType.eType)); - logger.severe(" Texture handle: "+rightTextureType.handle); - - logger.severe(" Right eye texture "+rightEyeTexture.getName()+" ("+rightEyeTexture.getImage().getId()+")"); - logger.severe(" Type: "+rightEyeTexture.getType()); - logger.severe(" Size: "+rightEyeTexture.getImage().getWidth()+"x"+rightEyeTexture.getImage().getHeight()); - logger.severe(" Image depth: "+rightEyeTexture.getImage().getDepth()); - logger.severe(" Image format: "+rightEyeTexture.getImage().getFormat()); - logger.severe(" Image color space: "+rightEyeTexture.getImage().getColorSpace()); - } - } - } - } else { - throw new IllegalStateException("This VR view manager is not attached to any VR environment."); - } - } - - @Override - public void initialize() { - logger.config("Initializing VR view manager."); - - if (environment != null){ - initTextureSubmitStructs(); - setupCamerasAndViews(); - setupVRScene(); - moveScreenProcessingToEyes(); - - if( environment.hasTraditionalGUIOverlay() ) { - environment.getVRMouseManager().initialize(); - - // update the pose to position the gui correctly on start - update(0f); - environment.getVRGUIManager().positionGui(); - } - - logger.config("Initialized VR view manager [SUCCESS]"); - - } else { - throw new IllegalStateException("This VR view manager is not attached to any VR environment."); - } - } - - /** - * Prepare the size of the given {@link Camera camera} to adapt it to the underlying rendering context. - * @param cam the {@link Camera camera} to prepare. - * @param xMult the camera width multiplier. - */ - private void prepareCameraSize(Camera cam, float xMult) { - if (environment != null){ - - if (environment.getApplication() != null){ - Vector2f size = new Vector2f(); - VRAPI vrhmd = environment.getVRHardware(); - - if( vrhmd == null ) { - size.x = 1280f; - size.y = 720f; - } else { - vrhmd.getRenderSize(size); - } - - if( size.x < environment.getApplication().getContext().getSettings().getWidth() ) { - size.x = environment.getApplication().getContext().getSettings().getWidth(); - } - if( size.y < environment.getApplication().getContext().getSettings().getHeight() ) { - size.y = environment.getApplication().getContext().getSettings().getHeight(); - } - - if( environment.isInstanceRendering() ){ - size.x *= 2f; - } - - // other adjustments - size.x *= xMult; - size.x *= getResolutionMuliplier(); - size.y *= getResolutionMuliplier(); - - if( cam.getWidth() != size.x || cam.getHeight() != size.y ){ - cam.resize((int)size.x, (int)size.y, false); - } - } else { - throw new IllegalStateException("This VR environment is not attached to any application."); - } - - } else { - throw new IllegalStateException("This VR view manager is not attached to any VR environment."); - } - } - - /** - * Replaces rootNode with the distortion mesh as the main camera's scene. - */ - private void setupVRScene(){ - if (environment != null){ - if (environment.getApplication() != null){ - // no special scene to set up if we are doing instancing - if( environment.isInstanceRendering() ) { - // distortion has to be done with compositor here... we want only one pass on our end! - if( environment.getApplication().getContext().getSettings().isSwapBuffers() ) { - setupMirrorBuffers(environment.getCamera(), dualEyeTex, true); - } - return; - } - - leftEyeTexture = (Texture2D) getLeftViewPort().getOutputFrameBuffer().getColorBuffer().getTexture(); - rightEyeTexture = (Texture2D)getRightViewPort().getOutputFrameBuffer().getColorBuffer().getTexture(); - leftEyeDepth = (Texture2D) getLeftViewPort().getOutputFrameBuffer().getDepthBuffer().getTexture(); - rightEyeDepth = (Texture2D)getRightViewPort().getOutputFrameBuffer().getDepthBuffer().getTexture(); - - // main viewport is either going to be a distortion scene or nothing - // mirroring is handled by copying framebuffers - Iterator spatialIter = environment.getApplication().getViewPort().getScenes().iterator(); - while(spatialIter.hasNext()){ - environment.getApplication().getViewPort().detachScene(spatialIter.next()); - } - - spatialIter = environment.getApplication().getGuiViewPort().getScenes().iterator(); - while(spatialIter.hasNext()){ - environment.getApplication().getGuiViewPort().detachScene(spatialIter.next()); - } - - // only setup distortion scene if compositor isn't running (or using custom mesh distortion option) - if( environment.getVRHardware().getCompositor() == null ) { - Node distortionScene = new Node(); - Material leftMat = new Material(environment.getApplication().getAssetManager(), "Common/MatDefs/VR/OpenVR.j3md"); - leftMat.setTexture("Texture", leftEyeTexture); - Geometry leftEye = new Geometry("box", setupDistortionMesh(JOpenVRLibrary.EVREye.EVREye_Eye_Left, environment.getVRHardware())); - leftEye.setMaterial(leftMat); - distortionScene.attachChild(leftEye); - - Material rightMat = new Material(environment.getApplication().getAssetManager(), "Common/MatDefs/VR/OpenVR.j3md"); - rightMat.setTexture("Texture", rightEyeTexture); - Geometry rightEye = new Geometry("box", setupDistortionMesh(JOpenVRLibrary.EVREye.EVREye_Eye_Right, environment.getVRHardware())); - rightEye.setMaterial(rightMat); - distortionScene.attachChild(rightEye); - - distortionScene.updateGeometricState(); - - environment.getApplication().getViewPort().attachScene(distortionScene); - - //if( useCustomDistortion ) setupFinalFullTexture(app.getViewPort().getCamera()); - } - - if( environment.getApplication().getContext().getSettings().isSwapBuffers() ) { - setupMirrorBuffers(environment.getCamera(), leftEyeTexture, false); - } - } else { - throw new IllegalStateException("This VR environment is not attached to any application."); - } - } else { - throw new IllegalStateException("This VR view manager is not attached to any VR environment."); - } - } - - @Override - public void update(float tpf) { - if (environment != null){ - // grab the observer - Object obs = environment.getObserver(); - Quaternion objRot; - Vector3f objPos; - if( obs instanceof Camera ) { - objRot = ((Camera)obs).getRotation(); - objPos = ((Camera)obs).getLocation(); - } else { - objRot = ((Spatial)obs).getWorldRotation(); - objPos = ((Spatial)obs).getWorldTranslation(); - } - // grab the hardware handle - VRAPI dev = environment.getVRHardware(); - if( dev != null ) { - // update the HMD's position & orientation - dev.updatePose(); - dev.getPositionAndOrientation(hmdPos, hmdRot); -/* - // TOREMOVE - Vector3f v = dev.getVRinput().getTrackedController(0).getPosition(); - Quaternion q = dev.getVRinput().getTrackedController(0).getOrientation(); - if ((v != null)&&(q != null)){ - hmdPos.set(v); - hmdRot.set(q); - } - - logger.severe("HMD controller "); - logger.severe(" Position "+hmdPos); - logger.severe(" Orientation "+hmdRot); - - VRTrackedController tc = null; - for(int i = 0; i < dev.getVRinput().getTrackedControllerCount(); i++){ - tc = dev.getVRinput().getTrackedController(i); - logger.severe("Tracked controller "+i+": "+tc.getControllerName()); - logger.severe(" Position "+tc.getPosition()); - logger.severe(" Orientation "+tc.getOrientation()); - logger.severe(""); - } -*/ - // TOREMOVE - - if( obs != null ) { - // update hmdPos based on obs rotation - finalRotation.set(objRot); - finalRotation.mult(hmdPos, hmdPos); - finalRotation.multLocal(hmdRot); - } - - finalizeCamera(dev.getHMDVectorPoseLeftEye(), objPos, getLeftCamera()); - finalizeCamera(dev.getHMDVectorPoseRightEye(), objPos, getRightCamera()); - } else { - getLeftCamera().setFrame(objPos, objRot); - getRightCamera().setFrame(objPos, objRot); - } - - if( environment.hasTraditionalGUIOverlay() ) { - // update the mouse? - environment.getVRMouseManager().update(tpf); - - // update GUI position? - if( environment.getVRGUIManager().isWantsReposition() || environment.getVRGUIManager().getPositioningMode() != VRGUIPositioningMode.MANUAL ) { - environment.getVRGUIManager().positionGuiNow(tpf); - environment.getVRGUIManager().updateGuiQuadGeometricState(); - } - } - } else { - throw new IllegalStateException("This VR view manager is not attached to any VR environment."); - } - } - - /** - * Place the camera within the scene. - * @param eyePos the eye position. - * @param obsPosition the observer position. - * @param cam the camera to place. - */ - private void finalizeCamera(Vector3f eyePos, Vector3f obsPosition, Camera cam) { - finalRotation.mult(eyePos, finalPosition); - finalPosition.addLocal(hmdPos); - if( obsPosition != null ) finalPosition.addLocal(obsPosition); - finalPosition.y += getHeightAdjustment(); - cam.setFrame(finalPosition, finalRotation); - } - - private void setupCamerasAndViews() { - if (environment != null){ - // get desired frustum from original camera - Camera origCam = environment.getCamera(); - float fFar = origCam.getFrustumFar(); - float fNear = origCam.getFrustumNear(); - - // restore frustum on distortion scene cam, if needed - if( environment.isInstanceRendering() ) { - leftCamera = origCam; - } else if( environment.compositorAllowed() == false ) { - origCam.setFrustumFar(100f); - origCam.setFrustumNear(1f); - leftCamera = origCam.clone(); - prepareCameraSize(origCam, 2f); - } else { - leftCamera = origCam.clone(); - } - - getLeftCamera().setFrustumPerspective(environment.getDefaultFOV(), environment.getDefaultAspect(), fNear, fFar); - - prepareCameraSize(getLeftCamera(), 1f); - if( environment.getVRHardware() != null ) { - getLeftCamera().setProjectionMatrix(environment.getVRHardware().getHMDMatrixProjectionLeftEye(getLeftCamera())); - } - //org.lwjgl.opengl.GL11.glEnable(org.lwjgl.opengl.GL30.GL_FRAMEBUFFER_SRGB); - - if( !environment.isInstanceRendering()) { - leftViewPort = setupViewBuffers(getLeftCamera(), LEFT_VIEW_NAME); - rightCamera = getLeftCamera().clone(); - if( environment.getVRHardware() != null ){ - getRightCamera().setProjectionMatrix(environment.getVRHardware().getHMDMatrixProjectionRightEye(getRightCamera())); - } - rightViewPort = setupViewBuffers(getRightCamera(), RIGHT_VIEW_NAME); - } else { - if (environment.getApplication() != null){ - - logger.severe("THIS CODE NEED CHANGES !!!"); - leftViewPort = environment.getApplication().getViewPort(); - //leftViewport.attachScene(app.getRootNode()); - rightCamera = getLeftCamera().clone(); - if( environment.getVRHardware() != null ){ - getRightCamera().setProjectionMatrix(environment.getVRHardware().getHMDMatrixProjectionRightEye(getRightCamera())); - } - - org.lwjgl.opengl.GL11.glEnable(org.lwjgl.opengl.GL30.GL_CLIP_DISTANCE0); - - //FIXME: [jme-vr] Fix with JMonkey next release - //RenderManager._VRInstancing_RightCamProjection = camRight.getViewProjectionMatrix(); - setupFinalFullTexture(environment.getApplication().getViewPort().getCamera()); - } else { - throw new IllegalStateException("This VR environment is not attached to any application."); - } - } - - // setup gui - environment.getVRGUIManager().setupGui(getLeftCamera(), getRightCamera(), getLeftViewPort(), getRightViewPort()); - - if( environment.getVRHardware() != null ) { - // call these to cache the results internally - environment.getVRHardware().getHMDMatrixPoseLeftEye(); - environment.getVRHardware().getHMDMatrixPoseRightEye(); - } - } else { - throw new IllegalStateException("This VR view manager is not attached to any VR environment."); - } - } - - private ViewPort setupMirrorBuffers(Camera cam, Texture tex, boolean expand) { - if (environment != null){ - if (environment.getApplication() != null){ - Camera cloneCam = cam.clone(); - ViewPort viewPort = environment.getApplication().getRenderManager().createPostView("MirrorView", cloneCam); - cloneCam.setParallelProjection(true); - viewPort.setClearFlags(true, true, true); - viewPort.setBackgroundColor(ColorRGBA.Black); - Picture pic = new Picture("fullscene"); - pic.setLocalTranslation(-0.75f, -0.5f, 0f); - if( expand ) { - pic.setLocalScale(3f, 1f, 1f); - } else { - pic.setLocalScale(1.5f, 1f, 1f); - } - pic.setQueueBucket(Bucket.Opaque); - pic.setTexture(environment.getApplication().getAssetManager(), (Texture2D)tex, false); - viewPort.attachScene(pic); - viewPort.setOutputFrameBuffer(null); - - pic.updateGeometricState(); - - return viewPort; - } else { - throw new IllegalStateException("This VR environment is not attached to any application."); - } - } else { - throw new IllegalStateException("This VR view manager is not attached to any VR environment."); - } - } - - private void setupFinalFullTexture(Camera cam) { - if (environment != null){ - if (environment.getApplication() != null){ - // create offscreen framebuffer - FrameBuffer out = new FrameBuffer(cam.getWidth(), cam.getHeight(), 1); - //offBuffer.setSrgb(true); - - //setup framebuffer's texture - dualEyeTex = new Texture2D(cam.getWidth(), cam.getHeight(), Image.Format.RGBA8); - dualEyeTex.setMinFilter(Texture.MinFilter.BilinearNoMipMaps); - dualEyeTex.setMagFilter(Texture.MagFilter.Bilinear); - - logger.config("Dual eye texture "+dualEyeTex.getName()+" ("+dualEyeTex.getImage().getId()+")"); - logger.config(" Type: "+dualEyeTex.getType()); - logger.config(" Size: "+dualEyeTex.getImage().getWidth()+"x"+dualEyeTex.getImage().getHeight()); - logger.config(" Image depth: "+dualEyeTex.getImage().getDepth()); - logger.config(" Image format: "+dualEyeTex.getImage().getFormat()); - logger.config(" Image color space: "+dualEyeTex.getImage().getColorSpace()); - - //setup framebuffer to use texture - out.setDepthBuffer(Image.Format.Depth); - out.setColorTexture(dualEyeTex); - - ViewPort viewPort = environment.getApplication().getViewPort(); - viewPort.setClearFlags(true, true, true); - viewPort.setBackgroundColor(ColorRGBA.Black); - viewPort.setOutputFrameBuffer(out); - } else { - throw new IllegalStateException("This VR environment is not attached to any application."); - } - } else { - throw new IllegalStateException("This VR view manager is not attached to any VR environment."); - } - } - - private ViewPort setupViewBuffers(Camera cam, String viewName){ - if (environment != null){ - if (environment.getApplication() != null){ - // create offscreen framebuffer - FrameBuffer offBufferLeft = new FrameBuffer(cam.getWidth(), cam.getHeight(), 1); - //offBufferLeft.setSrgb(true); - - //setup framebuffer's texture - Texture2D offTex = new Texture2D(cam.getWidth(), cam.getHeight(), Image.Format.RGBA8); - offTex.setMinFilter(Texture.MinFilter.BilinearNoMipMaps); - offTex.setMagFilter(Texture.MagFilter.Bilinear); - - //setup framebuffer to use texture - offBufferLeft.setDepthBuffer(Image.Format.Depth); - offBufferLeft.setColorTexture(offTex); - - ViewPort viewPort = environment.getApplication().getRenderManager().createPreView(viewName, cam); - viewPort.setClearFlags(true, true, true); - viewPort.setBackgroundColor(ColorRGBA.Black); - - Iterator spatialIter = environment.getApplication().getViewPort().getScenes().iterator(); - while(spatialIter.hasNext()){ - viewPort.attachScene(spatialIter.next()); - } - - //set viewport to render to offscreen framebuffer - viewPort.setOutputFrameBuffer(offBufferLeft); - return viewPort; - } else { - throw new IllegalStateException("This VR environment is not attached to any application."); - } - } else { - throw new IllegalStateException("This VR view manager is not attached to any VR environment."); - } - } - - /** - * Set up a distortion mesh for the stereo view. - * @param eye the eye to apply. - * @param api the underlying VR api - * @return the distorted mesh. - */ - public static Mesh setupDistortionMesh(int eye, VRAPI api) { - Mesh distortionMesh = new Mesh(); - float m_iLensGridSegmentCountH = 43, m_iLensGridSegmentCountV = 43; - - float w = 1f / (m_iLensGridSegmentCountH - 1f); - float h = 1f / (m_iLensGridSegmentCountV - 1f); - - float u, v; - - float verts[] = new float[(int) (m_iLensGridSegmentCountV * m_iLensGridSegmentCountH) * 3]; - - float texcoordR[] = new float[(int) (m_iLensGridSegmentCountV * m_iLensGridSegmentCountH) * 2]; - float texcoordG[] = new float[(int) (m_iLensGridSegmentCountV * m_iLensGridSegmentCountH) * 2]; - float texcoordB[] = new float[(int) (m_iLensGridSegmentCountV * m_iLensGridSegmentCountH) * 2]; - - int vertPos = 0, coordPos = 0; - - float Xoffset = eye == JOpenVRLibrary.EVREye.EVREye_Eye_Left ? -1f : 0; - for (int y = 0; y < m_iLensGridSegmentCountV; y++) { - for (int x = 0; x < m_iLensGridSegmentCountH; x++) { - u = x * w; - v = 1 - y * h; - verts[vertPos] = Xoffset + u; // x - verts[vertPos + 1] = -1 + 2 * y * h; // y - verts[vertPos + 2] = 0f; // z - vertPos += 3; - - DistortionCoordinates_t dc0 = new DistortionCoordinates_t(); - if( api.getVRSystem() == null ) { - // default to no distortion - texcoordR[coordPos] = u; - texcoordR[coordPos + 1] = 1 - v; - texcoordG[coordPos] = u; - texcoordG[coordPos + 1] = 1 - v; - texcoordB[coordPos] = u; - texcoordB[coordPos + 1] = 1 - v; - } else { - ((VR_IVRSystem_FnTable)api.getVRSystem()).ComputeDistortion.apply(eye, u, v, dc0); - - texcoordR[coordPos] = dc0.rfRed[0]; - texcoordR[coordPos + 1] = 1 - dc0.rfRed[1]; - texcoordG[coordPos] = dc0.rfGreen[0]; - texcoordG[coordPos + 1] = 1 - dc0.rfGreen[1]; - texcoordB[coordPos] = dc0.rfBlue[0]; - texcoordB[coordPos + 1] = 1 - dc0.rfBlue[1]; - } - - coordPos += 2; - } - } - - // have UV coordinates & positions, now set up indices - - int[] indices = new int[(int) ((m_iLensGridSegmentCountV - 1) * (m_iLensGridSegmentCountH - 1)) * 6]; - int indexPos = 0; - int a, b, c, d; - - int offset = 0; - for (int y = 0; y < m_iLensGridSegmentCountV - 1; y++) { - for (int x = 0; x < m_iLensGridSegmentCountH - 1; x++) { - a = (int) (m_iLensGridSegmentCountH * y + x + offset); - b = (int) (m_iLensGridSegmentCountH * y + x + 1 + offset); - c = (int) ((y + 1) * m_iLensGridSegmentCountH + x + 1 + offset); - d = (int) ((y + 1) * m_iLensGridSegmentCountH + x + offset); - - indices[indexPos] = a; - indices[indexPos + 1] = b; - indices[indexPos + 2] = c; - - indices[indexPos + 3] = a; - indices[indexPos + 4] = c; - indices[indexPos + 5] = d; - - indexPos += 6; - } - } - - // OK, create the mesh - distortionMesh.setBuffer(VertexBuffer.Type.Position, 3, verts); - distortionMesh.setBuffer(VertexBuffer.Type.Index, 1, indices); - distortionMesh.setBuffer(VertexBuffer.Type.TexCoord, 2, texcoordR); - distortionMesh.setBuffer(VertexBuffer.Type.TexCoord2, 2, texcoordG); - distortionMesh.setBuffer(VertexBuffer.Type.TexCoord3, 2, texcoordB); - distortionMesh.setStatic(); - return distortionMesh; - } -} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/openvr/package-info.java b/jme3-xr/src/main/java/com/jme3/input/vr/openvr/package-info.java deleted file mode 100644 index e74abe7d49..0000000000 --- a/jme3-xr/src/main/java/com/jme3/input/vr/openvr/package-info.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2021 jMonkeyEngine - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'jMonkeyEngine' nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -/** - * user-input classes for devices that use the OpenVR API - */ -package com.jme3.input.vr.openvr; diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/osvr/OSVR.java b/jme3-xr/src/main/java/com/jme3/input/vr/osvr/OSVR.java deleted file mode 100644 index c8da65a4f1..0000000000 --- a/jme3-xr/src/main/java/com/jme3/input/vr/osvr/OSVR.java +++ /dev/null @@ -1,459 +0,0 @@ -/* - -https://github.com/sensics/OSVR-RenderManager/blob/master/examples/RenderManagerOpenGLCAPIExample.cpp - -- JVM crashes often. Placing breakpoints during initialization clears it up most of the time (WHY!?) - - OSVR is just unstable. Any way to improve things? -- Render manager looks good, but left eye seems stretched. - - */ -package com.jme3.input.vr.osvr; - -import com.jme3.app.VREnvironment; -import com.jme3.input.vr.HmdType; -import com.jme3.input.vr.VRAPI; -import com.jme3.input.vr.VRInputAPI; -import com.jme3.math.Matrix4f; -import com.jme3.math.Quaternion; -import com.jme3.math.Vector2f; -import com.jme3.math.Vector3f; -import com.jme3.renderer.Camera; -import com.jme3.system.osvr.osvrclientkit.OsvrClientKitLibrary; -import com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary; -import com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig; -import com.jme3.system.osvr.osvrmatrixconventions.OSVR_Pose3; -import com.jme3.system.osvr.osvrrendermanageropengl.OSVR_OpenResultsOpenGL; -import com.jme3.system.osvr.osvrrendermanageropengl.OSVR_RenderBufferOpenGL; -import com.jme3.system.osvr.osvrrendermanageropengl.OSVR_RenderInfoOpenGL; -import com.jme3.system.osvr.osvrrendermanageropengl.OSVR_RenderParams; -import com.jme3.system.osvr.osvrrendermanageropengl.OSVR_ViewportDescription; -import com.jme3.system.osvr.osvrrendermanageropengl.OsvrRenderManagerOpenGLLibrary; -import com.ochafik.lang.jnaerator.runtime.NativeSize; -import com.ochafik.lang.jnaerator.runtime.NativeSizeByReference; -import com.sun.jna.Pointer; -import com.sun.jna.ptr.PointerByReference; -import java.nio.FloatBuffer; -import java.util.logging.Logger; - -/** - * A class that wraps an OSVR system. - * @author reden - phr00t - https://github.com/phr00t - * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr - */ -public class OSVR implements VRAPI { - private static final Logger logger = Logger.getLogger(OSVR.class.getName()); - - /** - * The first viewer index. - */ - public static final int FIRST_VIEWER = 0; - - /** - * The left eye index. - */ - public static final int EYE_LEFT = 0; - - /** - * The right eye index. - */ - public static final int EYE_RIGHT = 1; - - /** - * The size of the left eye. - */ - public static final NativeSize EYE_LEFT_SIZE = new NativeSize(EYE_LEFT); - - /** - * The size of the right eye. - */ - public static final NativeSize EYE_RIGHT_SIZE = new NativeSize(EYE_RIGHT); - - /** - * The default J String. - */ - public static byte[] defaultJString = { 'j', (byte)0 }; - - /** - * The default OpenGL String. - */ - public static byte[] OpenGLString = { 'O', 'p', 'e', 'n', 'G', 'L', (byte)0 }; - - private final Matrix4f[] eyeMatrix = new Matrix4f[2]; - - private PointerByReference grabRM; - private PointerByReference grabRMOGL; - private PointerByReference grabRIC; - - OSVR_RenderParams.ByValue renderParams; - OsvrClientKitLibrary.OSVR_ClientContext context; - com.jme3.system.osvr.osvrrendermanageropengl.OSVR_GraphicsLibraryOpenGL.ByValue graphicsLibrary; - Pointer renderManager, renderManagerOpenGL, renderInfoCollection, registerBufferState; - OSVRInput VRinput; - NativeSize numRenderInfo; - NativeSizeByReference grabNumInfo = new NativeSizeByReference(); - OSVR_RenderInfoOpenGL.ByValue eyeLeftInfo, eyeRightInfo; - Matrix4f hmdPoseLeftEye; - Matrix4f hmdPoseRightEye; - Vector3f hmdPoseLeftEyeVec, hmdPoseRightEyeVec, hmdSeatToStand; - OSVR_DisplayConfig displayConfig; - OSVR_Pose3 hmdPose = new OSVR_Pose3(); - Vector3f storePos = new Vector3f(); - Quaternion storeRot = new Quaternion(); - PointerByReference presentState = new PointerByReference(); - OSVR_OpenResultsOpenGL openResults = new OSVR_OpenResultsOpenGL(); - - long glfwContext; - long renderManagerContext; - long wglGLFW; - long wglRM; - - boolean initSuccess = false; - boolean flipEyes = false; - - private VREnvironment environment = null; - - /** - * Create a new OSVR system attached to the given {@link VREnvironment VR environment}. - * @param environment the {@link VREnvironment VR environment} to which the input is attached. - */ - public OSVR(VREnvironment environment){ - this.environment = environment; - } - - /** - * Access to the underlying OSVR structures. - * @param leftView the left viewport. - * @param rightView the right viewport. - * @param leftBuffer the left buffer. - * @param rightBuffer the right buffer. - * @return true if the structure are accessible and false otherwise. - */ - public boolean handleRenderBufferPresent(OSVR_ViewportDescription.ByValue leftView, OSVR_ViewportDescription.ByValue rightView, - OSVR_RenderBufferOpenGL.ByValue leftBuffer, OSVR_RenderBufferOpenGL.ByValue rightBuffer) { - if( eyeLeftInfo == null || eyeRightInfo == null ) return false; - byte retval; - OsvrRenderManagerOpenGLLibrary.osvrRenderManagerStartPresentRenderBuffers(presentState); - getEyeInfo(); - OsvrRenderManagerOpenGLLibrary.osvrRenderManagerPresentRenderBufferOpenGL(presentState.getValue(), leftBuffer, eyeLeftInfo, leftView); - OsvrRenderManagerOpenGLLibrary.osvrRenderManagerPresentRenderBufferOpenGL(presentState.getValue(), rightBuffer, eyeRightInfo, rightView); - retval = OsvrRenderManagerOpenGLLibrary.osvrRenderManagerFinishPresentRenderBuffers(renderManager, presentState.getValue(), renderParams, (byte)0); - return retval == 0; // only check the last error, since if something errored above, the last call won't work & all calls will log to syserr - } - - @Override - public boolean initialize() { - logger.config("Initialize OSVR system."); - - hmdPose.setAutoSynch(false); - context = OsvrClientKitLibrary.osvrClientInit(defaultJString, 0); - VRinput = new OSVRInput(environment); - initSuccess = context != null && VRinput.init(); - if( initSuccess ) { - PointerByReference grabDisplay = new PointerByReference(); - byte retval = OsvrDisplayLibrary.osvrClientGetDisplay(context, grabDisplay); - if( retval != 0 ) { - System.out.println("OSVR Get Display Error: " + retval); - initSuccess = false; - return false; - } - displayConfig = new OSVR_DisplayConfig(grabDisplay.getValue()); - System.out.println("Waiting for the display to fully start up, including receiving initial pose update..."); - int i = 400; - while (OsvrDisplayLibrary.osvrClientCheckDisplayStartup(displayConfig) != 0) { - if( i-- < 0 ) { - System.out.println("Couldn't get display startup update in time, continuing anyway..."); - break; - } - OsvrClientKitLibrary.osvrClientUpdate(context); - try { - Thread.sleep(5); - } catch(Exception e) { } - } - System.out.println("OK, display startup status is good!"); - } - return initSuccess; - } - - - /** - * Grab the current GLFW context. - */ - public void grabGLFWContext() { - // get current context - wglGLFW = org.lwjgl.opengl.WGL.wglGetCurrentContext(); - glfwContext = org.lwjgl.glfw.GLFW.glfwGetCurrentContext(); - } - - /** - * Enable context sharing. - * @return true if the context is successfully shared and false otherwise. - */ - public boolean shareContext() { - if( org.lwjgl.opengl.WGL.wglShareLists(wglRM, wglGLFW)) { - System.out.println("Context sharing success!"); - return true; - } else { - System.out.println("Context sharing problem..."); - return false; - } - } - - @Override - public boolean initVRCompositor(boolean allowed) { - if( !allowed || renderManager != null ) return false; - grabGLFWContext(); - graphicsLibrary = new com.jme3.system.osvr.osvrrendermanageropengl.OSVR_GraphicsLibraryOpenGL.ByValue(); - graphicsLibrary.toolkit = null; - graphicsLibrary.setAutoSynch(false); - grabRM = new PointerByReference(); grabRMOGL = new PointerByReference(); - byte retval = OsvrRenderManagerOpenGLLibrary.osvrCreateRenderManagerOpenGL(context, OpenGLString, graphicsLibrary, grabRM, grabRMOGL); - if( retval == 0 ) { - renderManager = grabRM.getValue(); renderManagerOpenGL = grabRMOGL.getValue(); - if( renderManager == null || renderManagerOpenGL == null ) { - System.out.println("Render Manager Created NULL, error!"); - return false; - } - openResults.setAutoSynch(false); - retval = OsvrRenderManagerOpenGLLibrary.osvrRenderManagerOpenDisplayOpenGL(renderManager, openResults); - if( retval == 0 ) { - wglRM = org.lwjgl.opengl.WGL.wglGetCurrentContext(); - renderManagerContext = org.lwjgl.glfw.GLFW.glfwGetCurrentContext(); - shareContext(); - OsvrClientKitLibrary.osvrClientUpdate(context); - renderParams = new OSVR_RenderParams.ByValue(); - renderParams.setAutoSynch(false); - OsvrRenderManagerOpenGLLibrary.osvrRenderManagerGetDefaultRenderParams(renderParams); - grabRIC = new PointerByReference(); - retval = OsvrRenderManagerOpenGLLibrary.osvrRenderManagerGetRenderInfoCollection(renderManager, renderParams, grabRIC); - if( retval == 0 ) { - renderInfoCollection = grabRIC.getValue(); - OsvrRenderManagerOpenGLLibrary.osvrRenderManagerGetNumRenderInfoInCollection(renderInfoCollection, grabNumInfo); - numRenderInfo = grabNumInfo.getValue(); - eyeLeftInfo = new OSVR_RenderInfoOpenGL.ByValue(); - eyeRightInfo = new OSVR_RenderInfoOpenGL.ByValue(); - eyeLeftInfo.setAutoSynch(false); - eyeRightInfo.setAutoSynch(false); - return true; - } - OsvrRenderManagerOpenGLLibrary.osvrDestroyRenderManager(renderManager); - System.out.println("OSVR Render Manager Info Collection Error: " + retval); - return false; - } - OsvrRenderManagerOpenGLLibrary.osvrDestroyRenderManager(renderManager); - System.out.println("OSVR Open Render Manager Display Error: " + retval); - return false; - } - System.out.println("OSVR Create Render Manager Error: " + retval); - return false; - } - - @Override - public OsvrClientKitLibrary.OSVR_ClientContext getVRSystem() { - return context; - } - - @Override - public Pointer getCompositor() { - return renderManager; - } - - @Override - public String getName() { - return "OSVR"; - } - - @Override - public VRInputAPI getVRinput() { - return VRinput; - } - - @Override - public void setFlipEyes(boolean set) { - flipEyes = set; - } - - @Override - public void printLatencyInfoToConsole(boolean set) { - } - - @Override - public int getDisplayFrequency() { - return 60; //debug display frequency - } - - @Override - public void destroy() { - if( renderManager != null ) OsvrRenderManagerOpenGLLibrary.osvrDestroyRenderManager(renderManager); - if( displayConfig != null ) OsvrDisplayLibrary.osvrClientFreeDisplay(displayConfig); - } - - @Override - public boolean isInitialized() { - return initSuccess; - } - - @Override - public void reset() { - // TODO: no native OSVR reset function - // may need to take current position and negate it from future values - } - - @Override - public void getRenderSize(Vector2f store) { - if( eyeLeftInfo == null || eyeLeftInfo.viewport.width == 0.0 ) { - store.x = 1280f; store.y = 720f; - } else { - store.x = (float)eyeLeftInfo.viewport.width; - store.y = (float)eyeLeftInfo.viewport.height; - } - } - - /** - * Read and update the eye info from the underlying OSVR system. - */ - public void getEyeInfo() { - OsvrRenderManagerOpenGLLibrary.osvrRenderManagerGetRenderInfoFromCollectionOpenGL(renderInfoCollection, EYE_LEFT_SIZE, eyeLeftInfo); - OsvrRenderManagerOpenGLLibrary.osvrRenderManagerGetRenderInfoFromCollectionOpenGL(renderInfoCollection, EYE_RIGHT_SIZE, eyeRightInfo); - eyeLeftInfo.read(); eyeRightInfo.read(); - } -/* - @Override - public float getFOV(int dir) { - return 105f; //default FOV - } -*/ - @Override - public float getInterpupillaryDistance() { - return 0.065f; //default IPD - } - - @Override - public Quaternion getOrientation() { - storeRot.set((float)-hmdPose.rotation.data[1], - (float)hmdPose.rotation.data[2], - (float)-hmdPose.rotation.data[3], - (float)hmdPose.rotation.data[0]); - if( storeRot.equals(Quaternion.ZERO) ) storeRot.set(Quaternion.DIRECTION_Z); - return storeRot; - } - - @Override - public Vector3f getPosition() { - storePos.x = (float)-hmdPose.translation.data[0]; - storePos.y = (float)hmdPose.translation.data[1]; - storePos.z = (float)-hmdPose.translation.data[2]; - return storePos; - } - - @Override - public void getPositionAndOrientation(Vector3f storePos, Quaternion storeRot) { - storePos.x = (float)-hmdPose.translation.data[0]; - storePos.y = (float)hmdPose.translation.data[1]; - storePos.z = (float)-hmdPose.translation.data[2]; - storeRot.set((float)-hmdPose.rotation.data[1], - (float)hmdPose.rotation.data[2], - (float)-hmdPose.rotation.data[3], - (float)hmdPose.rotation.data[0]); - if( storeRot.equals(Quaternion.ZERO) ) storeRot.set(Quaternion.DIRECTION_Z); - } - - @Override - public void updatePose() { - if( context == null || displayConfig == null ) return; - OsvrClientKitLibrary.osvrClientUpdate(context); - OsvrDisplayLibrary.osvrClientGetViewerPose(displayConfig, FIRST_VIEWER, hmdPose.getPointer()); - VRinput.updateControllerStates(); - hmdPose.read(); - } - - @Override - public Matrix4f getHMDMatrixProjectionLeftEye(Camera cam) { - if( eyeLeftInfo == null ) return cam.getProjectionMatrix(); - if( eyeMatrix[EYE_LEFT] == null ) { - FloatBuffer tfb = FloatBuffer.allocate(16); - com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.osvrClientGetViewerEyeSurfaceProjectionMatrixf(displayConfig, 0, (byte)EYE_LEFT, 0, cam.getFrustumNear(), cam.getFrustumFar(), (short)0, tfb); - eyeMatrix[EYE_LEFT] = new Matrix4f(); - eyeMatrix[EYE_LEFT].set(tfb.get(0), tfb.get(4), tfb.get(8), tfb.get(12), - tfb.get(1), tfb.get(5), tfb.get(9), tfb.get(13), - tfb.get(2), tfb.get(6), tfb.get(10), tfb.get(14), - tfb.get(3), tfb.get(7), tfb.get(11), tfb.get(15)); - } - return eyeMatrix[EYE_LEFT]; - } - - @Override - public Matrix4f getHMDMatrixProjectionRightEye(Camera cam) { - if( eyeRightInfo == null ) return cam.getProjectionMatrix(); - if( eyeMatrix[EYE_RIGHT] == null ) { - FloatBuffer tfb = FloatBuffer.allocate(16); - com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.osvrClientGetViewerEyeSurfaceProjectionMatrixf(displayConfig, 0, (byte)EYE_RIGHT, 0, cam.getFrustumNear(), cam.getFrustumFar(), (short)0, tfb); - eyeMatrix[EYE_RIGHT] = new Matrix4f(); - eyeMatrix[EYE_RIGHT].set(tfb.get(0), tfb.get(4), tfb.get(8), tfb.get(12), - tfb.get(1), tfb.get(5), tfb.get(9), tfb.get(13), - tfb.get(2), tfb.get(6), tfb.get(10), tfb.get(14), - tfb.get(3), tfb.get(7), tfb.get(11), tfb.get(15)); - } - return eyeMatrix[EYE_RIGHT]; - } - - @Override - public Vector3f getHMDVectorPoseLeftEye() { - if( hmdPoseLeftEyeVec == null ) { - hmdPoseLeftEyeVec = new Vector3f(); - hmdPoseLeftEyeVec.x = 0.065f * -0.5f; - if( flipEyes == false ) hmdPoseLeftEyeVec.x *= -1f; // it seems these need flipping - } - return hmdPoseLeftEyeVec; - } - - @Override - public Vector3f getHMDVectorPoseRightEye() { - if( hmdPoseRightEyeVec == null ) { - hmdPoseRightEyeVec = new Vector3f(); - hmdPoseRightEyeVec.x = 0.065f * 0.5f; - if( flipEyes == false ) hmdPoseRightEyeVec.x *= -1f; // it seems these need flipping - } - return hmdPoseRightEyeVec; - } - - @Override - public Vector3f getSeatedToAbsolutePosition() { - return Vector3f.ZERO; - } - - @Override - public Matrix4f getHMDMatrixPoseLeftEye() { - // not actually used internally... - /*if( hmdPoseLeftEye != null ) { - return hmdPoseLeftEye; - } else { - FloatBuffer mat = FloatBuffer.allocate(16); - OsvrDisplayLibrary.osvrClientGetViewerEyeViewMatrixf(displayConfig, FIRST_VIEWER, (byte)EYE_LEFT, - (short)(OsvrMatrixConventionsLibrary.OSVR_MatrixVectorFlags.OSVR_MATRIX_COLVECTORS | - OsvrMatrixConventionsLibrary.OSVR_MatrixOrderingFlags.OSVR_MATRIX_COLMAJOR), tempfb); - hmdPoseLeftEye = new Matrix4f(tempfb.array()); - return hmdPoseLeftEye; - }*/ - return null; - } - - @Override - public Matrix4f getHMDMatrixPoseRightEye() { - // not actually used internally... - /*if( hmdPoseRightEye != null ) { - return hmdPoseRightEye; - } else { - OsvrDisplayLibrary.osvrClientGetViewerEyeViewMatrixf(displayConfig, FIRST_VIEWER, (byte)EYE_RIGHT, - (short)(OsvrMatrixConventionsLibrary.OSVR_MatrixVectorFlags.OSVR_MATRIX_COLVECTORS | - OsvrMatrixConventionsLibrary.OSVR_MatrixOrderingFlags.OSVR_MATRIX_COLMAJOR), tempfb); - hmdPoseRightEye = new Matrix4f(tempfb.array()); - return hmdPoseRightEye; - }*/ - return null; - } - - @Override - public HmdType getType() { - return HmdType.OSVR; - } -} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/osvr/OSVRInput.java b/jme3-xr/src/main/java/com/jme3/input/vr/osvr/OSVRInput.java deleted file mode 100644 index 44bdf97e10..0000000000 --- a/jme3-xr/src/main/java/com/jme3/input/vr/osvr/OSVRInput.java +++ /dev/null @@ -1,347 +0,0 @@ -package com.jme3.input.vr.osvr; - -import java.util.logging.Logger; - -import com.jme3.app.VREnvironment; -import com.jme3.input.vr.VRInputAPI; -import com.jme3.input.vr.VRInputType; -import com.jme3.input.vr.VRTrackedController; -import com.jme3.math.Quaternion; -import com.jme3.math.Vector2f; -import com.jme3.math.Vector3f; -import com.jme3.renderer.Camera; -import com.jme3.scene.Spatial; -import com.jme3.system.osvr.osvrclientkit.OsvrClientKitLibrary; -import com.jme3.system.osvr.osvrclientkit.OsvrClientKitLibrary.OSVR_ClientInterface; -import com.jme3.system.osvr.osvrclientreporttypes.OSVR_AnalogReport; -import com.jme3.system.osvr.osvrclientreporttypes.OSVR_ButtonReport; -import com.jme3.system.osvr.osvrclientreporttypes.OSVR_Pose3; -import com.jme3.system.osvr.osvrinterface.OsvrInterfaceLibrary; -import com.jme3.system.osvr.osvrtimevalue.OSVR_TimeValue; -import com.sun.jna.Callback; -import com.sun.jna.Pointer; -import com.sun.jna.ptr.PointerByReference; - - -/** - * A class that wraps an OSVR input. - * @author reden - phr00t - https://github.com/phr00t - * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr - */ -public class OSVRInput implements VRInputAPI { - private static final Logger logger = Logger.getLogger(OSVRInput.class.getName()); - - // position example: https://github.com/OSVR/OSVR-Core/blob/master/examples/clients/TrackerState.c - // button example: https://github.com/OSVR/OSVR-Core/blob/master/examples/clients/ButtonCallback.c - // analog example: https://github.com/OSVR/OSVR-Core/blob/master/examples/clients/AnalogCallback.c - - private static final int ANALOG_COUNT = 3, BUTTON_COUNT = 7, CHANNEL_COUNT = 3; - - OSVR_ClientInterface[][] buttons; - OSVR_ClientInterface[][][] analogs; - OSVR_ClientInterface[] hands; - - OSVR_Pose3[] handState; - Callback buttonHandler, analogHandler; - OSVR_TimeValue tv = new OSVR_TimeValue(); - boolean[] isHandTracked = new boolean[2]; - - private float[][][] analogState; - private float[][] buttonState; - - private final Quaternion tempq = new Quaternion(); - private final Vector3f tempv = new Vector3f(); - private final Vector2f temp2 = new Vector2f(); - private final boolean[][] buttonDown = new boolean[16][16]; - - private static final Vector2f temp2Axis = new Vector2f(); - private static final Vector2f lastCallAxis[] = new Vector2f[16]; - private static float axisMultiplier = 1f; - - private VREnvironment environment = null; - - /** - * Get the system String that identifies a controller. - * @param left is the controller is the left one (false if the right controller is needed). - * @param index the index of the controller. - * @return the system String that identifies the controller. - */ - public static byte[] getButtonString(boolean left, byte index) { - if( left ) { - return new byte[] { '/', 'c', 'o', 'n', 't', 'r', 'o', 'l', 'l', 'e', 'r', '/', 'l', 'e', 'f', 't', '/', index, (byte)0 }; - } - return new byte[] { '/', 'c', 'o', 'n', 't', 'r', 'o', 'l', 'l', 'e', 'r', '/', 'r', 'i', 'g', 'h', 't', '/', index, (byte)0 }; - } - - /** - * The left-hand system String. - */ - public static byte[] leftHand = { '/', 'm', 'e', '/', 'h', 'a', 'n', 'd', 's', '/', 'l', 'e', 'f', 't', (byte)0 }; - - /** - * The right-hand system String. - */ - public static byte[] rightHand = { '/', 'm', 'e', '/', 'h', 'a', 'n', 'd', 's', '/', 'r', 'i', 'g', 'h', 't', (byte)0 }; - - - /** - * Create a new OSVR input attached to the given {@link VREnvironment VR environment}. - * @param environment the {@link VREnvironment VR environment} to which the input is attached. - */ - public OSVRInput(VREnvironment environment){ - this.environment = environment; - } - - @Override - public boolean isButtonDown(int controllerIndex, VRInputType checkButton) { - return buttonState[controllerIndex][checkButton.getValue()] != 0f; - } - - @Override - public boolean wasButtonPressedSinceLastCall(int controllerIndex, VRInputType checkButton) { - boolean buttonDownNow = isButtonDown(controllerIndex, checkButton); - int checkButtonValue = checkButton.getValue(); - boolean retval = buttonDownNow == true && buttonDown[controllerIndex][checkButtonValue] == false; - buttonDown[controllerIndex][checkButtonValue] = buttonDownNow; - return retval; - } - - @Override - public void resetInputSinceLastCall() { - for(int i=0;ihttp://www.seinturier.fr - */ -public class OSVRMouseManager extends AbstractVRMouseManager { - private final int AVERAGE_AMNT = 4; - - private int avgCounter; - - private final float[] lastXmv = new float[AVERAGE_AMNT]; - - private final float[] lastYmv = new float[AVERAGE_AMNT]; - - /** - * Create a new VR mouse manager within the given {@link VREnvironment VR environment}. - * @param environment the VR environment of the mouse manager. - */ - public OSVRMouseManager(VREnvironment environment){ - super(environment); - } - - @Override - public void updateAnalogAsMouse(int inputIndex, AnalogListener mouseListener, String mouseXName, String mouseYName, float tpf) { - - if (getVREnvironment() != null){ - if (getVREnvironment().getApplication() != null){ - // got a tracked controller to use as the "mouse" - if( getVREnvironment().isInVR() == false || - getVREnvironment().getVRinput() == null || - getVREnvironment().getVRinput().isInputDeviceTracking(inputIndex) == false ){ - return; - } - - Vector2f tpDelta; - // TODO option to use Touch joysticks - if( isThumbstickMode() ) { - tpDelta = getVREnvironment().getVRinput().getAxis(inputIndex, VRInputType.ViveTrackpadAxis); - } else { - tpDelta = getVREnvironment().getVRinput().getAxisDeltaSinceLastCall(inputIndex, VRInputType.ViveTrackpadAxis); - } - - float Xamount = (float)Math.pow(Math.abs(tpDelta.x) * getSpeedSensitivity(), getSpeedAcceleration()); - float Yamount = (float)Math.pow(Math.abs(tpDelta.y) * getSpeedSensitivity(), getSpeedAcceleration()); - - if( tpDelta.x < 0f ){ - Xamount = -Xamount; - } - - if( tpDelta.y < 0f ){ - Yamount = -Yamount; - } - - Xamount *= getMouseMoveScale(); - Yamount *= getMouseMoveScale(); - - if( mouseListener != null ) { - if( tpDelta.x != 0f && mouseXName != null ) mouseListener.onAnalog(mouseXName, Xamount * 0.2f, tpf); - if( tpDelta.y != 0f && mouseYName != null ) mouseListener.onAnalog(mouseYName, Yamount * 0.2f, tpf); - } - - if( getVREnvironment().getApplication().getInputManager().isCursorVisible() ) { - int index = (avgCounter+1) % AVERAGE_AMNT; - lastXmv[index] = Xamount * 133f; - lastYmv[index] = Yamount * 133f; - cursorPos.x -= avg(lastXmv); - cursorPos.y -= avg(lastYmv); - Vector2f maxsize = getVREnvironment().getVRGUIManager().getCanvasSize(); - - if( cursorPos.x > maxsize.x ){ - cursorPos.x = maxsize.x; - } - - if( cursorPos.x < 0f ){ - cursorPos.x = 0f; - } - - if( cursorPos.y > maxsize.y ){ - cursorPos.y = maxsize.y; - } - - if( cursorPos.y < 0f ){ - cursorPos.y = 0f; - } - } - } else { - throw new IllegalStateException("This VR environment is not attached to any application."); - } - } else { - throw new IllegalStateException("This VR view manager is not attached to any VR environment."); - } - } - - private float avg(float[] arr) { - float amt = 0f; - for(float f : arr) amt += f; - return amt / arr.length; - } -} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/osvr/OSVRViewManager.java b/jme3-xr/src/main/java/com/jme3/input/vr/osvr/OSVRViewManager.java deleted file mode 100644 index a3310c67e2..0000000000 --- a/jme3-xr/src/main/java/com/jme3/input/vr/osvr/OSVRViewManager.java +++ /dev/null @@ -1,867 +0,0 @@ -package com.jme3.input.vr.osvr; - -import java.awt.GraphicsEnvironment; -import java.util.Iterator; -import java.util.logging.Logger; - -import com.jme3.app.VREnvironment; -import com.jme3.input.vr.AbstractVRViewManager; -import com.jme3.input.vr.VRAPI; -import com.jme3.input.vr.openvr.OpenVRViewManager; -import com.jme3.material.Material; -import com.jme3.math.ColorRGBA; -import com.jme3.math.Quaternion; -import com.jme3.math.Vector2f; -import com.jme3.math.Vector3f; -import com.jme3.post.CartoonSSAO; -import com.jme3.post.Filter; -import com.jme3.post.FilterPostProcessor; -import com.jme3.post.FilterUtil; -import com.jme3.post.SceneProcessor; -import com.jme3.post.filters.FogFilter; -import com.jme3.post.filters.TranslucentBucketFilter; -import com.jme3.post.ssao.SSAOFilter; -import com.jme3.renderer.Camera; -import com.jme3.renderer.ViewPort; -import com.jme3.renderer.queue.RenderQueue.Bucket; -import com.jme3.scene.Geometry; -import com.jme3.scene.Mesh; -import com.jme3.scene.Node; -import com.jme3.scene.Spatial; -import com.jme3.scene.VertexBuffer; -import com.jme3.shadow.DirectionalLightShadowFilter; -import com.jme3.shadow.VRDirectionalLightShadowRenderer; -import com.jme3.system.jopenvr.DistortionCoordinates_t; -import com.jme3.system.jopenvr.JOpenVRLibrary; -import com.jme3.system.jopenvr.OpenVRUtil; -import com.jme3.system.jopenvr.Texture_t; -import com.jme3.system.jopenvr.VR_IVRSystem_FnTable; -import com.jme3.system.lwjgl.LwjglWindow; -import com.jme3.system.osvr.osvrrendermanageropengl.OSVR_RenderBufferOpenGL; -import com.jme3.system.osvr.osvrrendermanageropengl.OSVR_ViewportDescription; -import com.jme3.system.osvr.osvrrendermanageropengl.OsvrRenderManagerOpenGLLibrary; -import com.jme3.texture.FrameBuffer; -import com.jme3.texture.Image; -import com.jme3.texture.Texture; -import com.jme3.texture.Texture2D; -import com.jme3.ui.Picture; -import com.jme3.util.VRGUIPositioningMode; -import com.sun.jna.Pointer; -import com.sun.jna.ptr.PointerByReference; - -/** - * - * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr - * - */ -public class OSVRViewManager extends AbstractVRViewManager{ - private static final Logger logger = Logger.getLogger(OpenVRViewManager.class.getName()); - - // OpenVR values - private Texture_t leftTextureType; - private Texture_t rightTextureType; - - // OSVR values - OSVR_RenderBufferOpenGL.ByValue[] osvr_renderBuffer; - OSVR_ViewportDescription.ByValue osvr_viewDescFull; - OSVR_ViewportDescription.ByValue osvr_viewDescLeft; - OSVR_ViewportDescription.ByValue osvr_viewDescRight; - Pointer osvr_rmBufferState; - - private Texture2D dualEyeTex; - - private final PointerByReference grabRBS = new PointerByReference(); - - //final & temp values for camera calculations - private final Vector3f finalPosition = new Vector3f(); - private final Quaternion finalRotation = new Quaternion(); - private final Vector3f hmdPos = new Vector3f(); - private final Quaternion hmdRot = new Quaternion(); - - /** - * Create a new VR view manager attached to the given {@link VREnvironment VR environment}. - * @param environment the {@link VREnvironment VR environment} to which this view manager is attached. - */ - public OSVRViewManager(VREnvironment environment){ - this.environment = environment; - } - - /** - * Get the identifier of the left eye texture. - * @return the identifier of the left eye texture. - * @see #getRightTexId() - * @see #getFullTexId() - */ - protected int getLeftTexId() { - return leftEyeTexture.getImage().getId(); - } - - /** - * Get the identifier of the right eye texture. - * @return the identifier of the right eye texture. - * @see #getLeftTexId() - * @see #getFullTexId() - */ - protected int getRightTexId() { - return rightEyeTexture.getImage().getId(); - } - - /** - * Get the identifier of the full (dual eye) texture. - * @return the identifier of the full (dual eye) texture. - * @see #getLeftTexId() - * @see #getRightTexId() - */ - private int getFullTexId() { - return dualEyeTex.getImage().getId(); - } - - /** - * Initialize the system binds of the textures. - */ - private void initTextureSubmitStructs() { - leftTextureType = new Texture_t(); - rightTextureType = new Texture_t(); - - // must be OSVR - osvr_renderBuffer = new OSVR_RenderBufferOpenGL.ByValue[2]; - osvr_renderBuffer[OSVR.EYE_LEFT] = new OSVR_RenderBufferOpenGL.ByValue(); - osvr_renderBuffer[OSVR.EYE_RIGHT] = new OSVR_RenderBufferOpenGL.ByValue(); - osvr_renderBuffer[OSVR.EYE_LEFT].setAutoSynch(false); - osvr_renderBuffer[OSVR.EYE_RIGHT].setAutoSynch(false); - osvr_viewDescFull = new OSVR_ViewportDescription.ByValue(); - osvr_viewDescFull.setAutoSynch(false); - osvr_viewDescFull.left = osvr_viewDescFull.lower = 0.0; - osvr_viewDescFull.width = osvr_viewDescFull.height = 1.0; - osvr_viewDescLeft = new OSVR_ViewportDescription.ByValue(); - osvr_viewDescLeft.setAutoSynch(false); - osvr_viewDescLeft.left = osvr_viewDescLeft.lower = 0.0; - osvr_viewDescLeft.width = 0.5; - osvr_viewDescLeft.height = 1.0; - osvr_viewDescRight = new OSVR_ViewportDescription.ByValue(); - osvr_viewDescRight.setAutoSynch(false); - osvr_viewDescRight.left = 0.5; - osvr_viewDescRight.lower = 0.0; - osvr_viewDescRight.width = 0.5; - osvr_viewDescRight.height = 1.0; - osvr_viewDescRight.write(); - osvr_viewDescLeft.write(); - osvr_viewDescFull.write(); - osvr_renderBuffer[OSVR.EYE_LEFT].depthStencilBufferName = -1; - osvr_renderBuffer[OSVR.EYE_LEFT].colorBufferName = -1; - osvr_renderBuffer[OSVR.EYE_RIGHT].depthStencilBufferName = -1; - osvr_renderBuffer[OSVR.EYE_RIGHT].colorBufferName = -1; - } - - /** - * Register the OSVR OpenGL buffer. - * @param buf the OSVR OpenGL buffer. - */ - private void registerOSVRBuffer(OSVR_RenderBufferOpenGL.ByValue buf) { - if (environment != null){ - OsvrRenderManagerOpenGLLibrary.osvrRenderManagerStartRegisterRenderBuffers(grabRBS); - OsvrRenderManagerOpenGLLibrary.osvrRenderManagerRegisterRenderBufferOpenGL(grabRBS.getValue(), buf); - OsvrRenderManagerOpenGLLibrary.osvrRenderManagerFinishRegisterRenderBuffers(((OSVR)environment.getVRHardware()).getCompositor(), grabRBS.getValue(), (byte)0); - - } else { - throw new IllegalStateException("This VR view manager is not attached to any VR environment."); - } - } - - /** - * Send the textures to the two eyes. - */ - @Override - public void postRender() { - if (environment != null){ - if( environment.isInVR() ) { - VRAPI api = environment.getVRHardware(); - if( api.getCompositor() != null ) { - // using the compositor... - int errl = 0, errr = 0; - if( environment.isInstanceRendering() ) { - if( leftTextureType.handle == -1 || leftTextureType.handle != getFullTexId() ) { - leftTextureType.handle = getFullTexId(); - if( leftTextureType.handle != -1 ) { - leftTextureType.write(); - if( api instanceof OSVR ) { - osvr_renderBuffer[OSVR.EYE_LEFT].colorBufferName = leftTextureType.handle; - osvr_renderBuffer[OSVR.EYE_LEFT].depthStencilBufferName = dualEyeTex.getImage().getId(); - osvr_renderBuffer[OSVR.EYE_LEFT].write(); - registerOSVRBuffer(osvr_renderBuffer[OSVR.EYE_LEFT]); - } - } - } else { - if( api instanceof OSVR ) { - ((OSVR)api).handleRenderBufferPresent(osvr_viewDescLeft, osvr_viewDescRight, - osvr_renderBuffer[OSVR.EYE_LEFT], osvr_renderBuffer[OSVR.EYE_LEFT]); - } - } - } else if( leftTextureType.handle == -1 || rightTextureType.handle == -1 || - leftTextureType.handle != getLeftTexId() || rightTextureType.handle != getRightTexId() ) { - leftTextureType.handle = getLeftTexId(); - if( leftTextureType.handle != -1 ) { - logger.fine("Writing Left texture to native memory at " + leftTextureType.getPointer()); - leftTextureType.write(); - if( api instanceof OSVR ) { - osvr_renderBuffer[OSVR.EYE_LEFT].colorBufferName = leftTextureType.handle; - if( leftEyeDepth != null ) osvr_renderBuffer[OSVR.EYE_LEFT].depthStencilBufferName = leftEyeDepth.getImage().getId(); - osvr_renderBuffer[OSVR.EYE_LEFT].write(); - registerOSVRBuffer(osvr_renderBuffer[OSVR.EYE_LEFT]); - } - } - rightTextureType.handle = getRightTexId(); - if( rightTextureType.handle != -1 ) { - logger.fine("Writing Right texture to native memory at " + leftTextureType.getPointer()); - rightTextureType.write(); - if( api instanceof OSVR ) { - osvr_renderBuffer[OSVR.EYE_RIGHT].colorBufferName = rightTextureType.handle; - if( rightEyeDepth != null ) osvr_renderBuffer[OSVR.EYE_RIGHT].depthStencilBufferName = rightEyeDepth.getImage().getId(); - osvr_renderBuffer[OSVR.EYE_RIGHT].write(); - registerOSVRBuffer(osvr_renderBuffer[OSVR.EYE_RIGHT]); - } - } - } else { - if( api instanceof OSVR ) { - ((OSVR)api).handleRenderBufferPresent(osvr_viewDescFull, osvr_viewDescFull, - osvr_renderBuffer[OSVR.EYE_LEFT], osvr_renderBuffer[OSVR.EYE_RIGHT]); - } - } - - if( errl != 0 ){ - logger.severe("Submit to left compositor error: " + OpenVRUtil.getEVRCompositorErrorString(errl)+" ("+Integer.toString(errl)+")"); - logger.severe(" Texture color space: "+OpenVRUtil.getEColorSpaceString(leftTextureType.eColorSpace)); - logger.severe(" Texture type: "+OpenVRUtil.getETextureTypeString(leftTextureType.eType)); - logger.severe(" Texture handle: "+leftTextureType.handle); - - logger.severe(" Left eye texture "+leftEyeTexture.getName()+" ("+leftEyeTexture.getImage().getId()+")"); - logger.severe(" Type: "+leftEyeTexture.getType()); - logger.severe(" Size: "+leftEyeTexture.getImage().getWidth()+"x"+leftEyeTexture.getImage().getHeight()); - logger.severe(" Image depth: "+leftEyeTexture.getImage().getDepth()); - logger.severe(" Image format: "+leftEyeTexture.getImage().getFormat()); - logger.severe(" Image color space: "+leftEyeTexture.getImage().getColorSpace()); - } - - if( errr != 0 ){ - logger.severe("Submit to right compositor error: " + OpenVRUtil.getEVRCompositorErrorString(errl)+" ("+Integer.toString(errl)+")"); - logger.severe(" Texture color space: "+OpenVRUtil.getEColorSpaceString(rightTextureType.eColorSpace)); - logger.severe(" Texture type: "+OpenVRUtil.getETextureTypeString(rightTextureType.eType)); - logger.severe(" Texture handle: "+rightTextureType.handle); - - logger.severe(" Right eye texture "+rightEyeTexture.getName()+" ("+rightEyeTexture.getImage().getId()+")"); - logger.severe(" Type: "+rightEyeTexture.getType()); - logger.severe(" Size: "+rightEyeTexture.getImage().getWidth()+"x"+rightEyeTexture.getImage().getHeight()); - logger.severe(" Image depth: "+rightEyeTexture.getImage().getDepth()); - logger.severe(" Image format: "+rightEyeTexture.getImage().getFormat()); - logger.severe(" Image color space: "+rightEyeTexture.getImage().getColorSpace()); - } - } - } - } else { - throw new IllegalStateException("This VR view manager is not attached to any VR environment."); - } - } - - /** - * Initialize the VR view manager. - */ - @Override - public void initialize() { - logger.config("Initializing VR view manager."); - - if (environment != null){ - initTextureSubmitStructs(); - setupCamerasAndViews(); - setupVRScene(); - moveScreenProcessingToEyes(); - if( environment.hasTraditionalGUIOverlay() ) { - - environment.getVRMouseManager().initialize(); - - // update the pose to position the gui correctly on start - update(0f); - environment.getVRGUIManager().positionGui(); - } - - if (environment.getApplication() != null){ - // if we are OSVR, our primary mirror window needs to be the same size as the render manager's output... - if( environment.getVRHardware() instanceof OSVR ) { - int origWidth = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDisplayMode().getWidth(); - int origHeight = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDisplayMode().getHeight(); - long window = ((LwjglWindow)environment.getApplication().getContext()).getWindowHandle(); - Vector2f windowSize = new Vector2f(); - environment.getVRHardware().getRenderSize(windowSize); - windowSize.x = Math.max(windowSize.x * 2f, leftCamera.getWidth()); - org.lwjgl.glfw.GLFW.glfwSetWindowSize(window, (int)windowSize.x, (int)windowSize.y); - environment.getApplication().getContext().getSettings().setResolution((int)windowSize.x, (int)windowSize.y); - - if (environment.getApplication().getRenderManager() != null) { - environment.getApplication().getRenderManager().notifyReshape((int)windowSize.x, (int)windowSize.y); - } - - org.lwjgl.glfw.GLFW.glfwSetWindowPos(window, origWidth - (int)windowSize.x, 32); - - org.lwjgl.glfw.GLFW.glfwFocusWindow(window); - - org.lwjgl.glfw.GLFW.glfwSetCursorPos(window, origWidth / 2.0, origHeight / 2.0); - - logger.config("Initialized VR view manager [SUCCESS]"); - } else { - throw new IllegalStateException("Underlying VR hardware should be "+OSVR.class.getSimpleName()); - } - } else { - throw new IllegalStateException("This VR environment is not attached to any application."); - } - } else { - throw new IllegalStateException("This VR view manager is not attached to any VR environment."); - } - } - - /** - * Prepare the size of the given {@link Camera camera} to adapt it to the underlying rendering context. - * @param cam the {@link Camera camera} to prepare. - * @param xMult the camera width multiplier. - */ - private void prepareCameraSize(Camera cam, float xMult) { - if (environment != null){ - if (environment.getApplication() != null){ - - } else { - throw new IllegalStateException("This VR environment is not attached to any application."); - } - - Vector2f size = new Vector2f(); - VRAPI vrhmd = environment.getVRHardware(); - - if( vrhmd == null ) { - size.x = 1280f; - size.y = 720f; - } else { - vrhmd.getRenderSize(size); - } - - if( size.x < environment.getApplication().getContext().getSettings().getWidth() ) { - size.x = environment.getApplication().getContext().getSettings().getWidth(); - } - if( size.y < environment.getApplication().getContext().getSettings().getHeight() ) { - size.y = environment.getApplication().getContext().getSettings().getHeight(); - } - - if( environment.isInstanceRendering() ){ - size.x *= 2f; - } - - // other adjustments - size.x *= xMult; - size.x *= getResolutionMuliplier(); - size.y *= getResolutionMuliplier(); - - if( cam.getWidth() != size.x || cam.getHeight() != size.y ){ - cam.resize((int)size.x, (int)size.y, false); - } - } else { - throw new IllegalStateException("This VR view manager is not attached to any VR environment."); - } - } - - /** - * Replaces rootNode with the distortion mesh as the main camera's scene. - */ - private void setupVRScene(){ - if (environment != null){ - if (environment.getApplication() != null){ - // no special scene to set up if we are doing instancing - if( environment.isInstanceRendering() ) { - // distortion has to be done with compositor here... we want only one pass on our end! - if( environment.getApplication().getContext().getSettings().isSwapBuffers() ) { - setupMirrorBuffers(environment.getCamera(), dualEyeTex, true); - } - return; - } - - leftEyeTexture = (Texture2D) getLeftViewPort().getOutputFrameBuffer().getColorBuffer().getTexture(); - rightEyeTexture = (Texture2D)getRightViewPort().getOutputFrameBuffer().getColorBuffer().getTexture(); - leftEyeDepth = (Texture2D) getLeftViewPort().getOutputFrameBuffer().getDepthBuffer().getTexture(); - rightEyeDepth = (Texture2D)getRightViewPort().getOutputFrameBuffer().getDepthBuffer().getTexture(); - - // main viewport is either going to be a distortion scene or nothing - // mirroring is handled by copying framebuffers - Iterator spatialIter = environment.getApplication().getViewPort().getScenes().iterator(); - while(spatialIter.hasNext()){ - environment.getApplication().getViewPort().detachScene(spatialIter.next()); - } - - spatialIter = environment.getApplication().getGuiViewPort().getScenes().iterator(); - while(spatialIter.hasNext()){ - environment.getApplication().getGuiViewPort().detachScene(spatialIter.next()); - } - - // only setup distortion scene if compositor isn't running (or using custom mesh distortion option) - if( environment.getVRHardware().getCompositor() == null ) { - Node distortionScene = new Node(); - Material leftMat = new Material(environment.getApplication().getAssetManager(), "Common/MatDefs/VR/OpenVR.j3md"); - leftMat.setTexture("Texture", leftEyeTexture); - Geometry leftEye = new Geometry("box", setupDistortionMesh(JOpenVRLibrary.EVREye.EVREye_Eye_Left, environment.getVRHardware())); - leftEye.setMaterial(leftMat); - distortionScene.attachChild(leftEye); - - Material rightMat = new Material(environment.getApplication().getAssetManager(), "Common/MatDefs/VR/OpenVR.j3md"); - rightMat.setTexture("Texture", rightEyeTexture); - Geometry rightEye = new Geometry("box", setupDistortionMesh(JOpenVRLibrary.EVREye.EVREye_Eye_Right, environment.getVRHardware())); - rightEye.setMaterial(rightMat); - distortionScene.attachChild(rightEye); - - distortionScene.updateGeometricState(); - - environment.getApplication().getViewPort().attachScene(distortionScene); - - //if( useCustomDistortion ) setupFinalFullTexture(app.getViewPort().getCamera()); - } - - if( environment.getApplication().getContext().getSettings().isSwapBuffers() ) { - setupMirrorBuffers(environment.getCamera(), leftEyeTexture, false); - } - } else { - throw new IllegalStateException("This VR environment is not attached to any application."); - } - } else { - throw new IllegalStateException("This VR view manager is not attached to any VR environment."); - } - } - - /** - * Update the VR view manager. - * This method is called by the attached VR application and should not be called manually. - * @param tpf the time per frame. - */ - @Override - public void update(float tpf) { - if (environment != null){ - // grab the observer - Object obs = environment.getObserver(); - Quaternion objRot; - Vector3f objPos; - if( obs instanceof Camera ) { - objRot = ((Camera)obs).getRotation(); - objPos = ((Camera)obs).getLocation(); - } else { - objRot = ((Spatial)obs).getWorldRotation(); - objPos = ((Spatial)obs).getWorldTranslation(); - } - // grab the hardware handle - VRAPI dev = environment.getVRHardware(); - if( dev != null ) { - // update the HMD's position & orientation - dev.updatePose(); - dev.getPositionAndOrientation(hmdPos, hmdRot); - if( obs != null ) { - // update hmdPos based on obs rotation - finalRotation.set(objRot); - finalRotation.mult(hmdPos, hmdPos); - finalRotation.multLocal(hmdRot); - } - - finalizeCamera(dev.getHMDVectorPoseLeftEye(), objPos, leftCamera); - finalizeCamera(dev.getHMDVectorPoseRightEye(), objPos, rightCamera); - } else { - leftCamera.setFrame(objPos, objRot); - rightCamera.setFrame(objPos, objRot); - } - - if( environment.hasTraditionalGUIOverlay() ) { - // update the mouse? - environment.getVRMouseManager().update(tpf); - - // update GUI position? - if( environment.getVRGUIManager().isWantsReposition() || environment.getVRGUIManager().getPositioningMode() != VRGUIPositioningMode.MANUAL ) { - environment.getVRGUIManager().positionGuiNow(tpf); - environment.getVRGUIManager().updateGuiQuadGeometricState(); - } - } - } else { - throw new IllegalStateException("This VR view manager is not attached to any VR environment."); - } - } - - /** - * Place the camera within the scene. - * @param eyePos the eye position. - * @param obsPosition the observer position. - * @param cam the camera to place. - */ - private void finalizeCamera(Vector3f eyePos, Vector3f obsPosition, Camera cam) { - finalRotation.mult(eyePos, finalPosition); - finalPosition.addLocal(hmdPos); - if( obsPosition != null ){ - finalPosition.addLocal(obsPosition); - } - finalPosition.y += getHeightAdjustment(); - cam.setFrame(finalPosition, finalRotation); - } - - /** - * Handles moving filters from the main view to each eye - */ - @Override - public void moveScreenProcessingToEyes() { - if( getRightViewPort() == null ){ - return; - } - - if (environment != null){ - if (environment.getApplication() != null){ - - syncScreenProcessing(environment.getApplication().getViewPort()); - environment.getApplication().getViewPort().clearProcessors(); - } else { - throw new IllegalStateException("This VR environment is not attached to any application."); - } - } else { - throw new IllegalStateException("This VR view manager is not attached to any VR environment."); - } - } - - /** - * Sets the two views to use the list of {@link SceneProcessor processors}. - * @param sourceViewport the {@link ViewPort viewport} that contains the processors to use. - */ - @Override - public void syncScreenProcessing(ViewPort sourceViewport) { - if( getRightViewPort() == null ){ - return; - } - - if (environment != null){ - if (environment.getApplication() != null){ - // set up post-processing filters - if( rightPostProcessor == null ) { - rightPostProcessor = new FilterPostProcessor(environment.getApplication().getAssetManager()); - leftPostProcessor = new FilterPostProcessor(environment.getApplication().getAssetManager()); - } - // clear out all filters & processors, to start from scratch - rightPostProcessor.removeAllFilters(); - leftPostProcessor.removeAllFilters(); - getLeftViewPort().clearProcessors(); - getRightViewPort().clearProcessors(); - // if we have no processors to sync, don't add the FilterPostProcessor - if( sourceViewport.getProcessors().isEmpty() ) return; - // add post processors we just made, which are empty - getLeftViewPort().addProcessor(leftPostProcessor); - getRightViewPort().addProcessor(rightPostProcessor); - // go through all of the filters in the processors list - // add them to the left viewport processor & clone them to the right - for(SceneProcessor sceneProcessor : sourceViewport.getProcessors()) { - if (sceneProcessor instanceof FilterPostProcessor) { - for(Filter f : ((FilterPostProcessor)sceneProcessor).getFilterList() ) { - if( f instanceof TranslucentBucketFilter ) { - // just remove this filter, we will add it at the end manually - ((FilterPostProcessor)sceneProcessor).removeFilter(f); - } else { - leftPostProcessor.addFilter(f); - // clone to the right - Filter f2; - if(f instanceof FogFilter){ - f2 = FilterUtil.cloneFogFilter((FogFilter)f); - } else if (f instanceof CartoonSSAO ) { - f2 = new CartoonSSAO((CartoonSSAO)f); - } else if (f instanceof SSAOFilter){ - f2 = FilterUtil.cloneSSAOFilter((SSAOFilter)f); - } else if (f instanceof DirectionalLightShadowFilter){ - f2 = FilterUtil.cloneDirectionalLightShadowFilter(environment.getApplication().getAssetManager(), (DirectionalLightShadowFilter)f); - } else { - f2 = f; // DoF, bloom, light scattering etc. - } - rightPostProcessor.addFilter(f2); - } - } - } else if (sceneProcessor instanceof VRDirectionalLightShadowRenderer) { - // shadow processing - // TODO: make right shadow processor use same left shadow maps for performance - VRDirectionalLightShadowRenderer dlsr = (VRDirectionalLightShadowRenderer) sceneProcessor; - VRDirectionalLightShadowRenderer dlsrRight = dlsr.clone(); - dlsrRight.setLight(dlsr.getLight()); - getRightViewPort().getProcessors().add(0, dlsrRight); - getLeftViewPort().getProcessors().add(0, sceneProcessor); - } - } - // make sure each has a translucent filter renderer - leftPostProcessor.addFilter(new TranslucentBucketFilter()); - rightPostProcessor.addFilter(new TranslucentBucketFilter()); - } else { - throw new IllegalStateException("This VR environment is not attached to any application."); - } - } else { - throw new IllegalStateException("This VR view manager is not attached to any VR environment."); - } - } - - private void setupCamerasAndViews() { - if (environment != null){ - if (environment.getApplication() != null){ - // get desired frustum from original camera - Camera origCam = environment.getCamera(); - float fFar = origCam.getFrustumFar(); - float fNear = origCam.getFrustumNear(); - - // if we are using OSVR get the eye info here - if( environment.getVRHardware() instanceof OSVR ) { - ((OSVR)environment.getVRHardware()).getEyeInfo(); - } - - // restore frustum on distortion scene cam, if needed - if( environment.isInstanceRendering() ) { - leftCamera = origCam; - } else if( environment.compositorAllowed() == false ) { - origCam.setFrustumFar(100f); - origCam.setFrustumNear(1f); - leftCamera = origCam.clone(); - prepareCameraSize(origCam, 2f); - } else { - leftCamera = origCam.clone(); - } - - leftCamera.setFrustumPerspective(environment.getDefaultFOV(), environment.getDefaultAspect(), fNear, fFar); - - prepareCameraSize(leftCamera, 1f); - if( environment.getVRHardware() != null ) leftCamera.setProjectionMatrix(environment.getVRHardware().getHMDMatrixProjectionLeftEye(leftCamera)); - //org.lwjgl.opengl.GL11.glEnable(org.lwjgl.opengl.GL30.GL_FRAMEBUFFER_SRGB); - - if( !environment.isInstanceRendering()) { - leftViewPort = setupViewBuffers(leftCamera, LEFT_VIEW_NAME); - rightCamera = leftCamera.clone(); - if( environment.getVRHardware() != null ){ - rightCamera.setProjectionMatrix(environment.getVRHardware().getHMDMatrixProjectionRightEye(rightCamera)); - } - rightViewPort = setupViewBuffers(rightCamera, RIGHT_VIEW_NAME); - } else { - System.err.println("[VRViewManager] THIS CODE NEED CHANGES !!!"); - leftViewPort = environment.getApplication().getViewPort(); - //leftViewport.attachScene(app.getRootNode()); - rightCamera = leftCamera.clone(); - if( environment.getVRHardware() != null ){ - rightCamera.setProjectionMatrix(environment.getVRHardware().getHMDMatrixProjectionRightEye(rightCamera)); - } - - org.lwjgl.opengl.GL11.glEnable(org.lwjgl.opengl.GL30.GL_CLIP_DISTANCE0); - - //FIXME: [jme-vr] Fix with JMonkey next release - //RenderManager._VRInstancing_RightCamProjection = camRight.getViewProjectionMatrix(); - setupFinalFullTexture(environment.getApplication().getViewPort().getCamera()); - } - - // setup gui - environment.getVRGUIManager().setupGui(leftCamera, rightCamera, getLeftViewPort(), getRightViewPort()); - - if( environment.getVRHardware() != null ) { - // call these to cache the results internally - environment.getVRHardware().getHMDMatrixPoseLeftEye(); - environment.getVRHardware().getHMDMatrixPoseRightEye(); - } - } else { - throw new IllegalStateException("This VR environment is not attached to any application."); - } - } else { - throw new IllegalStateException("This VR view manager is not attached to any VR environment."); - } - } - - private ViewPort setupMirrorBuffers(Camera cam, Texture tex, boolean expand) { - if (environment != null){ - if (environment.getApplication() != null){ - Camera cloneCam = cam.clone(); - ViewPort viewPort = environment.getApplication().getRenderManager().createPostView("MirrorView", cloneCam); - cloneCam.setParallelProjection(true); - viewPort.setClearFlags(true, true, true); - viewPort.setBackgroundColor(ColorRGBA.Black); - Picture pic = new Picture("fullscene"); - pic.setLocalTranslation(-0.75f, -0.5f, 0f); - if( expand ) { - pic.setLocalScale(3f, 1f, 1f); - } else { - pic.setLocalScale(1.5f, 1f, 1f); - } - pic.setQueueBucket(Bucket.Opaque); - pic.setTexture(environment.getApplication().getAssetManager(), (Texture2D)tex, false); - viewPort.attachScene(pic); - viewPort.setOutputFrameBuffer(null); - - pic.updateGeometricState(); - - return viewPort; - } else { - throw new IllegalStateException("This VR environment is not attached to any application."); - } - } else { - throw new IllegalStateException("This VR view manager is not attached to any VR environment."); - } - } - - private void setupFinalFullTexture(Camera cam) { - if (environment != null){ - if (environment.getApplication() != null){ - // create offscreen framebuffer - FrameBuffer out = new FrameBuffer(cam.getWidth(), cam.getHeight(), 1); - //offBuffer.setSrgb(true); - - //setup framebuffer's texture - dualEyeTex = new Texture2D(cam.getWidth(), cam.getHeight(), Image.Format.RGBA8); - dualEyeTex.setMinFilter(Texture.MinFilter.BilinearNoMipMaps); - dualEyeTex.setMagFilter(Texture.MagFilter.Bilinear); - - logger.config("Dual eye texture "+dualEyeTex.getName()+" ("+dualEyeTex.getImage().getId()+")"); - logger.config(" Type: "+dualEyeTex.getType()); - logger.config(" Size: "+dualEyeTex.getImage().getWidth()+"x"+dualEyeTex.getImage().getHeight()); - logger.config(" Image depth: "+dualEyeTex.getImage().getDepth()); - logger.config(" Image format: "+dualEyeTex.getImage().getFormat()); - logger.config(" Image color space: "+dualEyeTex.getImage().getColorSpace()); - - //setup framebuffer to use texture - out.setDepthBuffer(Image.Format.Depth); - out.setColorTexture(dualEyeTex); - - ViewPort viewPort = environment.getApplication().getViewPort(); - viewPort.setClearFlags(true, true, true); - viewPort.setBackgroundColor(ColorRGBA.Black); - viewPort.setOutputFrameBuffer(out); - } else { - throw new IllegalStateException("This VR environment is not attached to any application."); - } - } else { - throw new IllegalStateException("This VR view manager is not attached to any VR environment."); - } - } - - private ViewPort setupViewBuffers(Camera cam, String viewName){ - if (environment != null){ - if (environment.getApplication() != null){ - // create offscreen framebuffer - FrameBuffer offBufferLeft = new FrameBuffer(cam.getWidth(), cam.getHeight(), 1); - //offBufferLeft.setSrgb(true); - - //setup framebuffer's texture - Texture2D offTex = new Texture2D(cam.getWidth(), cam.getHeight(), Image.Format.RGBA8); - offTex.setMinFilter(Texture.MinFilter.BilinearNoMipMaps); - offTex.setMagFilter(Texture.MagFilter.Bilinear); - - //setup framebuffer to use texture - offBufferLeft.setDepthBuffer(Image.Format.Depth); - offBufferLeft.setColorTexture(offTex); - - ViewPort viewPort = environment.getApplication().getRenderManager().createPreView(viewName, cam); - viewPort.setClearFlags(true, true, true); - viewPort.setBackgroundColor(ColorRGBA.Black); - - Iterator spatialIter = environment.getApplication().getViewPort().getScenes().iterator(); - while(spatialIter.hasNext()){ - viewPort.attachScene(spatialIter.next()); - } - - //set viewport to render to offscreen framebuffer - viewPort.setOutputFrameBuffer(offBufferLeft); - return viewPort; - } else { - throw new IllegalStateException("This VR environment is not attached to any application."); - } - } else { - throw new IllegalStateException("This VR view manager is not attached to any VR environment."); - } - } - - /** - * Set up a distortion mesh for the stereo view. - * @param eye the eye to apply. - * @param api the underlying VR api - * @return the distorted mesh. - */ - public static Mesh setupDistortionMesh(int eye, VRAPI api) { - Mesh distortionMesh = new Mesh(); - float m_iLensGridSegmentCountH = 43, m_iLensGridSegmentCountV = 43; - - float w = 1f / (m_iLensGridSegmentCountH - 1f); - float h = 1f / (m_iLensGridSegmentCountV - 1f); - - float u, v; - - float verts[] = new float[(int) (m_iLensGridSegmentCountV * m_iLensGridSegmentCountH) * 3]; - - float texcoordR[] = new float[(int) (m_iLensGridSegmentCountV * m_iLensGridSegmentCountH) * 2]; - float texcoordG[] = new float[(int) (m_iLensGridSegmentCountV * m_iLensGridSegmentCountH) * 2]; - float texcoordB[] = new float[(int) (m_iLensGridSegmentCountV * m_iLensGridSegmentCountH) * 2]; - - int vertPos = 0, coordPos = 0; - - float Xoffset = eye == JOpenVRLibrary.EVREye.EVREye_Eye_Left ? -1f : 0; - for (int y = 0; y < m_iLensGridSegmentCountV; y++) { - for (int x = 0; x < m_iLensGridSegmentCountH; x++) { - u = x * w; - v = 1 - y * h; - verts[vertPos] = Xoffset + u; // x - verts[vertPos + 1] = -1 + 2 * y * h; // y - verts[vertPos + 2] = 0f; // z - vertPos += 3; - - DistortionCoordinates_t dc0 = new DistortionCoordinates_t(); - if( api.getVRSystem() == null ) { - // default to no distortion - texcoordR[coordPos] = u; - texcoordR[coordPos + 1] = 1 - v; - texcoordG[coordPos] = u; - texcoordG[coordPos + 1] = 1 - v; - texcoordB[coordPos] = u; - texcoordB[coordPos + 1] = 1 - v; - } else { - ((VR_IVRSystem_FnTable)api.getVRSystem()).ComputeDistortion.apply(eye, u, v, dc0); - - texcoordR[coordPos] = dc0.rfRed[0]; - texcoordR[coordPos + 1] = 1 - dc0.rfRed[1]; - texcoordG[coordPos] = dc0.rfGreen[0]; - texcoordG[coordPos + 1] = 1 - dc0.rfGreen[1]; - texcoordB[coordPos] = dc0.rfBlue[0]; - texcoordB[coordPos + 1] = 1 - dc0.rfBlue[1]; - } - - coordPos += 2; - } - } - - // have UV coordinates & positions, now set up indices - - int[] indices = new int[(int) ((m_iLensGridSegmentCountV - 1) * (m_iLensGridSegmentCountH - 1)) * 6]; - int indexPos = 0; - int a, b, c, d; - - int offset = 0; - for (int y = 0; y < m_iLensGridSegmentCountV - 1; y++) { - for (int x = 0; x < m_iLensGridSegmentCountH - 1; x++) { - a = (int) (m_iLensGridSegmentCountH * y + x + offset); - b = (int) (m_iLensGridSegmentCountH * y + x + 1 + offset); - c = (int) ((y + 1) * m_iLensGridSegmentCountH + x + 1 + offset); - d = (int) ((y + 1) * m_iLensGridSegmentCountH + x + offset); - - indices[indexPos] = a; - indices[indexPos + 1] = b; - indices[indexPos + 2] = c; - - indices[indexPos + 3] = a; - indices[indexPos + 4] = c; - indices[indexPos + 5] = d; - - indexPos += 6; - } - } - - // OK, create the mesh - distortionMesh.setBuffer(VertexBuffer.Type.Position, 3, verts); - distortionMesh.setBuffer(VertexBuffer.Type.Index, 1, indices); - distortionMesh.setBuffer(VertexBuffer.Type.TexCoord, 2, texcoordR); - distortionMesh.setBuffer(VertexBuffer.Type.TexCoord2, 2, texcoordG); - distortionMesh.setBuffer(VertexBuffer.Type.TexCoord3, 2, texcoordB); - distortionMesh.setStatic(); - return distortionMesh; - } - - @Override - public void render() { - // TODO Auto-generated method stub - } -} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/osvr/package-info.java b/jme3-xr/src/main/java/com/jme3/input/vr/osvr/package-info.java deleted file mode 100644 index fb1c9ca58d..0000000000 --- a/jme3-xr/src/main/java/com/jme3/input/vr/osvr/package-info.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2021 jMonkeyEngine - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'jMonkeyEngine' nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -/** - * user-input classes for devices that use the Open Source Virtual Reality - * (OSVR) API - */ -package com.jme3.input.vr.osvr; diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/package-info.java b/jme3-xr/src/main/java/com/jme3/input/vr/package-info.java deleted file mode 100644 index b260858f81..0000000000 --- a/jme3-xr/src/main/java/com/jme3/input/vr/package-info.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2021 jMonkeyEngine - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'jMonkeyEngine' nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -/** - * user-input classes for Virtual Reality (VR) applications - */ -package com.jme3.input.vr; diff --git a/jme3-xr/src/main/java/com/jme3/input/xr/Eye.java b/jme3-xr/src/main/java/com/jme3/input/xr/Eye.java new file mode 100644 index 0000000000..f5dd474023 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/input/xr/Eye.java @@ -0,0 +1,92 @@ +package com.jme3.input.xr; + +import com.jme3.app.SimpleApplication; +import com.jme3.material.Material; +import com.jme3.math.ColorRGBA; +import com.jme3.math.Quaternion; +import com.jme3.math.Vector3f; +import com.jme3.renderer.Camera; +import com.jme3.renderer.ViewPort; +import com.jme3.scene.Geometry; +import com.jme3.scene.shape.Box; +import com.jme3.texture.FrameBuffer; +import com.jme3.texture.Texture; +import com.jme3.texture.Texture2D; +import com.jme3.texture.FrameBuffer.FrameBufferTarget; +import com.jme3.texture.Image.Format; + +public class Eye { + SimpleApplication app; + float posX; + Vector3f tmpVec = new Vector3f(); + Texture2D offTex; + Geometry offGeo; + Camera offCamera; + Vector3f centerPos = new Vector3f(0f, 0f, -5f); + Quaternion centerRot = new Quaternion(); + + public Eye(SimpleApplication app, float posX) + { + this.app = app; + this.posX = posX; + setupOffscreenView(app); + Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); + mat.setTexture("ColorMap", offTex); + + offGeo = new Geometry("box", new Box(1, 1, 1)); + offGeo.setMaterial(mat); + } + + /** Moves the camera. + * @param The new absolute center position. */ + public void moveAbs(Vector3f newPos) + { + centerPos.set(newPos); + rotateAbs(offCamera.getRotation()); + } + + /** Rotates the camera, and moves left/right. + * @param The new rotation. */ + public void rotateAbs(Quaternion newRot) + { + tmpVec.set(posX, 0.0f, 0.0f); + newRot.multLocal(tmpVec); + offCamera.setLocation(tmpVec.addLocal(centerPos)); + offCamera.setRotation(newRot); + } + + private void setupOffscreenView(SimpleApplication app) + { + int w = app.getContext().getSettings().getWidth(); + int h = app.getContext().getSettings().getHeight(); + offCamera = new Camera(w, h); + + ViewPort offView = app.getRenderManager().createPreView("OffscreenViewX" + posX, offCamera); + offView.setClearFlags(true, true, true); + offView.setBackgroundColor(ColorRGBA.DarkGray); + FrameBuffer offBuffer = new FrameBuffer(w, h, 1); + + //setup framebuffer's cam + offCamera.setFrustumPerspective(45f, 1f, 1f, 1000f); + offCamera.setLocation(new Vector3f(-posX, 0f, -5f)); + offCamera.lookAt(new Vector3f(0f, 0f, 0f), Vector3f.UNIT_Y); + + //setup framebuffer's texture + offTex = new Texture2D(w, h, Format.RGBA8); + offTex.setMinFilter(Texture.MinFilter.Trilinear); + offTex.setMagFilter(Texture.MagFilter.Bilinear); + + //setup framebuffer to use texture + offBuffer.setDepthTarget(FrameBufferTarget.newTarget(Format.Depth)); + offBuffer.addColorTarget(FrameBufferTarget.newTarget(offTex)); + + //set viewport to render to offscreen framebuffer + offView.setOutputFrameBuffer(offBuffer); + offView.attachScene(app.getRootNode()); + } + + public void render() + { + app.getRenderManager().renderGeometry(offGeo); + } +} diff --git a/jme3-xr/src/main/java/com/jme3/input/xr/XrHmd.java b/jme3-xr/src/main/java/com/jme3/input/xr/XrHmd.java new file mode 100644 index 0000000000..592e381a0a --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/input/xr/XrHmd.java @@ -0,0 +1,61 @@ +package com.jme3.input.xr; + +import java.util.ArrayList; + +import com.jme3.app.SimpleApplication; +import com.jme3.math.Quaternion; +import com.jme3.math.Vector3f; +import com.jme3.system.AppSettings; +import com.jme3.system.lwjgl.LwjglWindowXr; + +public class XrHmd +{ + Quaternion tmpQ = new Quaternion(); + SimpleApplication app; + Eye leftEye; + Eye rightEye; + ArrayList hmdListeners = new ArrayList(); + ArrayList contr1Listeners = new ArrayList(); + ArrayList contr2Listeners = new ArrayList(); + + public XrHmd(SimpleApplication app, float distX) + { + this.app = app; + leftEye = new Eye(app, -distX/2.0f); + rightEye = new Eye(app, distX/2.0f); + hmdListeners.add((p,r) -> doMoveRotate(p,r)); + } + + private void doMoveRotate(Vector3f p, Quaternion r) + { + tmpQ.set(r); + tmpQ.inverseLocal(); + leftEye.rotateAbs(tmpQ); + rightEye.rotateAbs(tmpQ); + } + + public Eye getLeftEye() { return leftEye; } + public Eye getRightEye() { return rightEye; } + + public ArrayList getHmdOrientationListeners() { return hmdListeners; } + public ArrayList getContr1ButtonPressedListeners() { return contr1Listeners; } + public ArrayList getContr2ButtonPressedListeners() { return contr2Listeners; } + + public void onUpdateHmdOrientation(Vector3f viewPos, Quaternion viewRot) + { + for (XrListener.OrientationListener l : hmdListeners) { l.onUpdateOrientation(viewPos, viewRot); } + } + + /** Must be called in main function before init. + * @param s The appSettings that must be used with app.setSettings(s). */ + public static void setRendererForSettings(AppSettings s) + { + s.setRenderer("CUSTOM" + com.jme3.system.lwjgl.LwjglWindowXr.class.getName()); //see JmeDesktopSystem.newContext(...) + } + + public static XrHmd initHmd(SimpleApplication app) { + XrHmd xrHmd = new XrHmd(app, 0.8f); + ((LwjglWindowXr)app.getContext()).getXr().setHmd(xrHmd); + return xrHmd; + } +} diff --git a/jme3-xr/src/main/java/com/jme3/input/xr/XrListener.java b/jme3-xr/src/main/java/com/jme3/input/xr/XrListener.java new file mode 100644 index 0000000000..aa57f52fa2 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/input/xr/XrListener.java @@ -0,0 +1,16 @@ +package com.jme3.input.xr; + +import com.jme3.math.Quaternion; +import com.jme3.math.Vector3f; + +public interface XrListener { + public interface OrientationListener + { + public void onUpdateOrientation(Vector3f pos, Quaternion rot); + } + + public interface ButtonPressedListener + { + public void onButtonPressed(int num); + } +} diff --git a/jme3-xr/src/main/java/com/jme3/post/CartoonSSAO.java b/jme3-xr/src/main/java/com/jme3/post/CartoonSSAO.java deleted file mode 100644 index 82c45001dd..0000000000 --- a/jme3-xr/src/main/java/com/jme3/post/CartoonSSAO.java +++ /dev/null @@ -1,155 +0,0 @@ -package com.jme3.post; - -import com.jme3.asset.AssetManager; -import com.jme3.material.Material; -import com.jme3.math.Vector2f; -import com.jme3.math.Vector3f; -import com.jme3.post.Filter; -import com.jme3.renderer.RenderManager; -import com.jme3.renderer.ViewPort; -import com.jme3.renderer.queue.RenderQueue; -import com.jme3.texture.Image.Format; - -/** - * A Cartoon Screen Space Ambient Occlusion filter with instance rendering capabilities. - * @author reden - phr00t - https://github.com/phr00t - * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr - * - */ -public class CartoonSSAO extends Filter{ - private Pass normalPass; - private Vector3f frustumCorner; - private Vector2f frustumNearFar; - private boolean useOutline = true; - private float downsample = 1f, applyDistance = 0.0005f; - - private boolean instancedRendering = false; - - RenderManager renderManager; - ViewPort viewPort; - - /** - * Create a Screen Space Ambient Occlusion Filter. - * @param instancedRendering true if this filter has to use instance rendering and false (default) otherwise. - */ - public CartoonSSAO(boolean instancedRendering) { - super("CartoonSSAO"); - this.instancedRendering = instancedRendering; - } - - /** - * Create a Screen Space Ambient Occlusion Filter. - * @param downsample factor to divide resolution by for filter, >1 increases speed but degrades quality. - * @param instancedRendering true if this filter has to use instance rendering and false (default) otherwise. - */ - public CartoonSSAO(float downsample, boolean instancedRendering) { - this(instancedRendering); - this.downsample = downsample; - } - - /** - * Create a Screen Space Ambient Occlusion Filter from the given one (by copy). - * @param cloneFrom the original filter. - */ - public CartoonSSAO(CartoonSSAO cloneFrom) { - this(cloneFrom.downsample, cloneFrom.instancedRendering); - } - - @Override - protected boolean isRequiresDepthTexture() { - return true; - } - - @Override - protected void postQueue(RenderQueue renderQueue) { - PreNormalCaching.getPreNormals(renderManager, normalPass, viewPort); - } - - /** - * Set if outline has to be enabled. - * @param set true if the outline has to be enabled and false otherwise. - * @see #isOutlineEnabled() - */ - public void setOutlineEnabled(boolean set) { - useOutline = set; - if( material != null ) { - if( useOutline ) { - material.clearParam("disableOutline"); - } else { - material.setBoolean("disableOutline", true); - } - } - } - - /** - * Is outline rendering is enabled. - * @return true if the outline is enabled and false otherwise. - * @see #setOutlineEnabled(boolean) - */ - public boolean isOutlineEnabled() { - return useOutline; - } - - /** - * Set the down sampling value. - * @param downsample the down sampling value. - * @see #getDownsampling() - */ - public void setDownsampling(float downsample) { - this.downsample = downsample; - } - - /** - * Get the down sampling value. - * @return the down sampling value. - * @see #setDownsampling(float) - */ - public float getDownsampling() { - return this.downsample; - } - - @Override - protected Material getMaterial() { - return material; - } - - /** - * Set the distance of the material. - * @param dist the distance of the material. - */ - public void setDistance(float dist) { - applyDistance = dist; - if( material != null ) material.setFloat("Distance", dist); - } - - @Override - protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) { - this.renderManager = renderManager; - this.viewPort = vp; - - int screenWidth = Math.round(w / downsample); - int screenHeight = Math.round(h / downsample); - - normalPass = new Pass(); - normalPass.init(renderManager.getRenderer(), screenWidth, screenHeight, Format.RGBA8, Format.Depth); - - frustumNearFar = new Vector2f(); - - float farY = (vp.getCamera().getFrustumTop() / vp.getCamera().getFrustumNear()) * vp.getCamera().getFrustumFar(); - float farX = farY * (screenWidth / (float) screenHeight); - frustumCorner = new Vector3f(farX, farY, vp.getCamera().getFrustumFar()); - frustumNearFar.x = vp.getCamera().getFrustumNear(); - frustumNearFar.y = vp.getCamera().getFrustumFar(); - - //ssao Pass - material = new Material(manager, "Common/MatDefs/VR/CartoonSSAO.j3md"); - material.setTexture("Normals", normalPass.getRenderedTexture()); - - material.setVector3("FrustumCorner", frustumCorner); - material.setVector2("FrustumNearFar", frustumNearFar); - material.setFloat("Distance", applyDistance); - if( useOutline == false ) material.setBoolean("disableOutline", true); - if( instancedRendering ) material.setBoolean("useInstancing", true); - } - -} \ No newline at end of file diff --git a/jme3-xr/src/main/java/com/jme3/post/FilterUtil.java b/jme3-xr/src/main/java/com/jme3/post/FilterUtil.java deleted file mode 100644 index d8d2778742..0000000000 --- a/jme3-xr/src/main/java/com/jme3/post/FilterUtil.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.jme3.post; - -import com.jme3.asset.AssetManager; -import com.jme3.post.filters.FogFilter; -import com.jme3.post.ssao.SSAOFilter; -import com.jme3.shadow.DirectionalLightShadowFilter; - -/** - * - * @author Rickard - */ -public class FilterUtil { - /** - * A private constructor to inhibit instantiation of this class. - */ - private FilterUtil() { - } - - public static FogFilter cloneFogFilter(FogFilter fogFilter){ - FogFilter filterClone = new FogFilter(); - filterClone.setFogColor(fogFilter.getFogColor()); - filterClone.setFogDensity(fogFilter.getFogDensity()); - filterClone.setFogDistance(fogFilter.getFogDistance()); - filterClone.setName(fogFilter.getName() + " Clone"); - - return filterClone; - } - - public static SSAOFilter cloneSSAOFilter(SSAOFilter filter){ - SSAOFilter clone = new SSAOFilter(); - clone.setSampleRadius(filter.getSampleRadius()); - clone.setIntensity(filter.getIntensity()); - clone.setScale(filter.getScale()); - clone.setBias(filter.getBias()); - return clone; - } - - public static DirectionalLightShadowFilter cloneDirectionalLightShadowFilter(AssetManager assetManager, DirectionalLightShadowFilter filter){ - DirectionalLightShadowFilter clone = new DirectionalLightShadowFilter(assetManager, 512, 3); - clone.setLight(filter.getLight()); - clone.setLambda(filter.getLambda()); - clone.setShadowIntensity(filter.getShadowIntensity()); - clone.setEdgeFilteringMode(filter.getEdgeFilteringMode()); -// clone.setEnabled(filter.isEnabled()); - return clone; - } - -} diff --git a/jme3-xr/src/main/java/com/jme3/post/PreNormalCaching.java b/jme3-xr/src/main/java/com/jme3/post/PreNormalCaching.java deleted file mode 100644 index b2250e8d76..0000000000 --- a/jme3-xr/src/main/java/com/jme3/post/PreNormalCaching.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.jme3.post; - -import com.jme3.post.Filter.Pass; -import com.jme3.renderer.Caps; -import com.jme3.renderer.RenderManager; -import com.jme3.renderer.Renderer; -import com.jme3.renderer.ViewPort; -import com.jme3.texture.FrameBuffer; - -/** - * Pre normal caching class. - * @author reden - phr00t - https://github.com/phr00t - * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr - */ -public class PreNormalCaching { - - private static FrameBuffer cachedPreNormals; - private static int lastNormalPassesCount, curCount; - - /** - * A private constructor to inhibit instantiation of this class. - */ - private PreNormalCaching() { - } - - /** - * Get pre-normals from the given rendering. - * @param renderManager the render manager. - * @param normalPass the normal pass. - * @param viewPort the viewport. - */ - public static void getPreNormals(RenderManager renderManager, Pass normalPass, ViewPort viewPort) { - curCount++; - // do we already have a valid cache to set the framebuffer to? - Renderer r = renderManager.getRenderer(); - if( cachedPreNormals != null ) { - r.copyFrameBuffer(cachedPreNormals, normalPass.getRenderFrameBuffer(),true, false); - } else { - // let's make the prenormals - r.setFrameBuffer(normalPass.getRenderFrameBuffer()); - renderManager.getRenderer().clearBuffers(true, true, true); - if( renderManager.getRenderer().getCaps().contains(Caps.GLSL150) ) { - renderManager.setForcedTechnique("PreNormalPass15"); - } else { - renderManager.setForcedTechnique("PreNormalPass"); - } - renderManager.renderViewPortQueues(viewPort, false); - renderManager.setForcedTechnique(null); - // if we should cache this, do it now - if( lastNormalPassesCount > 1 ) { - cachedPreNormals = normalPass.getRenderFrameBuffer(); - } - } - renderManager.getRenderer().setFrameBuffer(viewPort.getOutputFrameBuffer()); - } - - /** - * Reset the cache - * @param stereo true if the rendering is stereo based and false otherwise. - */ - public static void resetCache(boolean stereo) { - if( stereo == false ) { - // only use this feature if we are NOT in VR - // we can't use the same normal information for another eye, - // because it will be different! - lastNormalPassesCount = curCount; - } - cachedPreNormals = null; - curCount = 0; - } - -} diff --git a/jme3-xr/src/main/java/com/jme3/scene/CenterQuad.java b/jme3-xr/src/main/java/com/jme3/scene/CenterQuad.java deleted file mode 100644 index e2911eba6f..0000000000 --- a/jme3-xr/src/main/java/com/jme3/scene/CenterQuad.java +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Copyright (c) 2009-2021 jMonkeyEngine - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'jMonkeyEngine' nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package com.jme3.scene; - -import com.jme3.export.InputCapsule; -import com.jme3.export.JmeExporter; -import com.jme3.export.JmeImporter; -import com.jme3.export.OutputCapsule; -import com.jme3.scene.VertexBuffer.Type; -import java.io.IOException; - -/** - * A static, indexed, Triangles-mode mesh for an axis-aligned rectangle in the - * X-Y plane. - * - *

The rectangle extends from (-width/2, -height/2, 0) to - * (width/2, height/2, 0) with normals set to (0,0,1). - * - *

This differs from com.jme3.scene.shape.Quad because it puts - * (0,0,0) at the rectangle's center instead of in a corner. - * - * @author Kirill Vainer - * @deprecated use com.jme3.scene.shape.CenterQuad - */ -@Deprecated -public class CenterQuad extends Mesh { - - public static CenterQuad UnitQuad = new CenterQuad(0.5f, 0.5f); - public static Mesh CenterSplitQuad; - - private float width; - private float height; - - /** - * Create a quad with the given width and height. The quad - * is always created in the XY plane. - * - * @param width The X extent or width - * @param height The Y extent or width - */ - public CenterQuad(float width, float height){ - updateGeometry(width, height); - } - - /** - * Create a quad with the given width and height. The quad - * is always created in the XY plane. - * - * @param width The X extent or width - * @param height The Y extent or width - * @param flipCoords If true, the texture coordinates will be flipped - * along the Y axis. - */ - public CenterQuad(float width, float height, boolean flipCoords){ - updateGeometry(width, height, flipCoords); - this.setStatic(); - } - - /** - * For serialization only. Do not use. - */ - protected CenterQuad() { - } - - public float getHeight() { - return height; - } - - public float getWidth() { - return width; - } - - public void updateGeometry(float width, float height){ - updateGeometry(width, height, false); - } - - public void updateGeometry(float width, float height, boolean flipCoords) { - this.width = width; - this.height = height; - setBuffer(Type.Position, 3, new float[]{-width/2, -height/2, 0, - width/2, -height/2, 0, - width/2, height/2, 0, - -width/2, height/2, 0 - }); - - - if (flipCoords){ - setBuffer(Type.TexCoord, 2, new float[]{0, 1, - 1, 1, - 1, 0, - 0, 0}); - }else{ - setBuffer(Type.TexCoord, 2, new float[]{0, 0, - 1, 0, - 1, 1, - 0, 1}); - } - setBuffer(Type.Normal, 3, new float[]{0, 0, 1, - 0, 0, 1, - 0, 0, 1, - 0, 0, 1}); - if (height < 0){ - setBuffer(Type.Index, 3, new short[]{0, 2, 1, - 0, 3, 2}); - }else{ - setBuffer(Type.Index, 3, new short[]{0, 1, 2, - 0, 2, 3}); - } - - updateBound(); - } - - /** - * De-serializes from the specified importer, for example when loading from - * a J3O file. - * - * @param importer the importer to use (not null) - * @throws IOException from the importer - */ - @Override - public void read(JmeImporter importer) throws IOException { - super.read(importer); - InputCapsule capsule = importer.getCapsule(this); - - width = capsule.readFloat("width", 0f); - height = capsule.readFloat("height", 0f); - } - - /** - * Serializes to the specified exporter, for example when saving to a J3O - * file. The current instance is unaffected. - * - * @param exporter the exporter to use (not null) - * @throws IOException from the exporter - */ - @Override - public void write(JmeExporter exporter) throws IOException { - super.write(exporter); - OutputCapsule capsule = exporter.getCapsule(this); - - capsule.write(width, "width", 0f); - capsule.write(height, "height", 0f); - } -} diff --git a/jme3-xr/src/main/java/com/jme3/shadow/AbstractShadowFilterVR.java b/jme3-xr/src/main/java/com/jme3/shadow/AbstractShadowFilterVR.java deleted file mode 100644 index 3144a417e0..0000000000 --- a/jme3-xr/src/main/java/com/jme3/shadow/AbstractShadowFilterVR.java +++ /dev/null @@ -1,320 +0,0 @@ -package com.jme3.shadow; - -/* - * Copyright (c) 2009-2021 jMonkeyEngine - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'jMonkeyEngine' nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import com.jme3.asset.AssetManager; -import com.jme3.export.JmeExporter; -import com.jme3.export.JmeImporter; -import com.jme3.material.Material; -import com.jme3.material.RenderState; -import com.jme3.math.Matrix4f; -import com.jme3.math.Vector4f; -import com.jme3.post.Filter; -import com.jme3.renderer.RenderManager; -import com.jme3.renderer.ViewPort; -import com.jme3.renderer.queue.RenderQueue; -import com.jme3.texture.FrameBuffer; - -import java.io.IOException; - -/** - * Generic abstract filter that holds common implementations for the different - * shadow filters. - * - * @author Rémy Bouquet aka Nehon - * @author reden - phr00t - https://github.com/phr00t - * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr - * @param the type of the underlying renderer (subclass of {@link AbstractShadowRendererVR}). - */ -public abstract class AbstractShadowFilterVR extends Filter { - - protected T shadowRenderer; - protected ViewPort viewPort; - - /** - * Abstract class constructor - * - * @param manager the application asset manager - * @param shadowMapSize the size of the rendered shadowmaps (512,1024,2048, - * etc...) - * @param shadowRenderer the shadowRenderer to use for this Filter - */ - @SuppressWarnings("all") - protected AbstractShadowFilterVR(AssetManager manager, int shadowMapSize, T shadowRenderer) { - super("Post Shadow"); - material = new Material(manager, "Common/MatDefs/Shadow/PostShadowFilter.j3md"); - this.shadowRenderer = shadowRenderer; - this.shadowRenderer.setPostShadowMaterial(material); - - //this is legacy setting for shadows with backface shadows - this.shadowRenderer.setRenderBackFacesShadows(true); - } - - @SuppressWarnings("all") - protected AbstractShadowFilterVR(AssetManager manager, int shadowMapSize, T shadowRenderer, String useMatDef) { - super("Post Shadow"); - material = new Material(manager, useMatDef); - this.shadowRenderer = shadowRenderer; - this.shadowRenderer.setPostShadowMaterial(material); - } - - @Override - protected Material getMaterial() { - return material; - } - - @Override - protected boolean isRequiresDepthTexture() { - return true; - } - - /** - * Get the {@link Material material} used by this filter. - * @return the {@link Material material} used by this filter. - */ - public Material getShadowMaterial() { - return material; - } - - Vector4f tmpv = new Vector4f(); - - @Override - protected void preFrame(float tpf) { - shadowRenderer.preFrame(tpf); - material.setMatrix4("ViewProjectionMatrixInverse", viewPort.getCamera().getViewProjectionMatrix().invert()); - Matrix4f m = viewPort.getCamera().getViewProjectionMatrix(); - material.setVector4("ViewProjectionMatrixRow2", tmpv.set(m.m20, m.m21, m.m22, m.m23)); - - } - - @Override - protected void postQueue(RenderQueue queue) { - shadowRenderer.postQueue(queue); - if(shadowRenderer.skipPostPass){ - //removing the shadow map so that the post pass is skipped - material.setTexture("ShadowMap0", null); - } - } - - @Override - protected void postFrame(RenderManager renderManager, ViewPort viewPort, FrameBuffer prevFilterBuffer, FrameBuffer sceneBuffer) { - if(!shadowRenderer.skipPostPass){ - shadowRenderer.setPostShadowParams(); - } - } - - @Override - protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) { - shadowRenderer.needsfallBackMaterial = true; - shadowRenderer.initialize(renderManager, vp); - this.viewPort = vp; - } - - /** - * How far the shadows are rendered in the view - * - * @see #setShadowZExtend(float zFar) - * @return shadowZExtend - */ - public float getShadowZExtend() { - return shadowRenderer.getShadowZExtend(); - } - - /** - * Set the distance from the eye where the shadows will be rendered default - * value is dynamically computed to the shadow casters/receivers union bound - * zFar, capped to view frustum far value. - * - * @param zFar the zFar values that override the computed one - */ - public void setShadowZExtend(float zFar) { - shadowRenderer.setShadowZExtend(zFar); - } - - /** - * Define the length over which the shadow will fade out when using a - * shadowZextend - * - * @param length the fade length in world units - */ - public void setShadowZFadeLength(float length) { - shadowRenderer.setShadowZFadeLength(length); - } - - /** - * get the length over which the shadow will fade out when using a - * shadowZextend - * - * @return the fade length in world units - */ - public float getShadowZFadeLength() { - return shadowRenderer.getShadowZFadeLength(); - } - - /** - * returns the shadow intensity - * - * @see #setShadowIntensity(float shadowIntensity) - * @return shadowIntensity - */ - public float getShadowIntensity() { - return shadowRenderer.getShadowIntensity(); - } - - /** - * Set the shadowIntensity, the value should be between 0 and 1, a 0 value - * gives a bright and invisible shadow, a 1 value gives a pitch black - * shadow, default is 0.7 - * - * @param shadowIntensity the darkness of the shadow - */ - final public void setShadowIntensity(float shadowIntensity) { - shadowRenderer.setShadowIntensity(shadowIntensity); - } - - /** - * returns the edges thickness
- * - * @see #setEdgesThickness(int edgesThickness) - * @return edgesThickness - */ - public int getEdgesThickness() { - return shadowRenderer.getEdgesThickness(); - } - - /** - * Sets the shadow edge thickness. Default is 1. Setting it to lower values - * can help to reduce the jagged effect of the shadow edges. - * @param edgesThickness the edge thickness. - */ - public void setEdgesThickness(int edgesThickness) { - shadowRenderer.setEdgesThickness(edgesThickness); - } - - /** - * isFlushQueues does nothing and is kept only for backward compatibility. - * @return false - * @deprecated does nothing and is kept only for backward compatibility. - */ - @Deprecated - public boolean isFlushQueues() { - return shadowRenderer.isFlushQueues(); - } - - /** - * Sets the shadow compare mode (see {@link CompareMode} for more info). - * @param compareMode the compare mode. - */ - final public void setShadowCompareMode(CompareMode compareMode) { - shadowRenderer.setShadowCompareMode(compareMode); - } - - /** - * Get the shadow compare mode. - * - * @return the shadow compare mode. - * @see CompareMode - */ - public CompareMode getShadowCompareMode() { - return shadowRenderer.getShadowCompareMode(); - } - - /** - * Sets the filtering mode for shadow edges see {@link EdgeFilteringMode} for more info - * @param filterMode the filtering mode for shadow edges. - */ - final public void setEdgeFilteringMode(EdgeFilteringMode filterMode) { - shadowRenderer.setEdgeFilteringMode(filterMode); - } - - /** - * - * WARNING this parameter is defaulted to true for the shadow filter. Setting it to true, may produce edges artifacts on shadows.
- *
- * Set to true if you want back faces shadows on geometries. - * Note that back faces shadows will be blended over dark lighten areas and may produce overly dark lighting.
- *
- * Setting this parameter will override this parameter for ALL materials in the scene. - * This also will automatically adjust the face cull mode and the PolyOffset of the pre shadow pass. - * You can modify them by using {@link #getPreShadowForcedRenderState()}.
- *
- * If you want to set it differently for each material in the scene you have to use the ShadowRenderer instead - * of the shadow filter. - * - * @param renderBackFacesShadows true if back faces shadows on geometries have to be rendered and false otherwise. - */ - public void setRenderBackFacesShadows(Boolean renderBackFacesShadows) { - shadowRenderer.setRenderBackFacesShadows(renderBackFacesShadows); - } - - /** - * Is this filter renders back faces shadows. - * @return true if this filter renders back faces shadows and false otherwise. - */ - public boolean isRenderBackFacesShadows() { - return shadowRenderer.isRenderBackFacesShadows(); - } - - /** - * Get the pre-shadows pass render state. - * use it to adjust the RenderState parameters of the pre shadow pass. - * Note that this will be overridden if the preShadow technique in the material has a ForcedRenderState - * @return the pre shadow render state. - */ - public RenderState getPreShadowForcedRenderState() { - return shadowRenderer.getPreShadowForcedRenderState(); - } - - - /** - * Get the edge filtering mode. - * @return the edge filtering mode. - */ - public EdgeFilteringMode getEdgeFilteringMode() { - return shadowRenderer.getEdgeFilteringMode(); - } - - @Override - public void write(JmeExporter ex) throws IOException { - super.write(ex); - //OutputCapsule oc = ex.getCapsule(this); - - } - - @Override - public void read(JmeImporter im) throws IOException { - super.read(im); - //InputCapsule ic = im.getCapsule(this); - - } -} diff --git a/jme3-xr/src/main/java/com/jme3/shadow/AbstractShadowRendererVR.java b/jme3-xr/src/main/java/com/jme3/shadow/AbstractShadowRendererVR.java deleted file mode 100644 index 7338864dd8..0000000000 --- a/jme3-xr/src/main/java/com/jme3/shadow/AbstractShadowRendererVR.java +++ /dev/null @@ -1,839 +0,0 @@ -package com.jme3.shadow; - -/* - * Copyright (c) 2009-2021 jMonkeyEngine - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'jMonkeyEngine' nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import com.jme3.asset.AssetManager; -import com.jme3.export.*; -import com.jme3.light.LightFilter; -import com.jme3.light.NullLightFilter; -import com.jme3.material.Material; -import com.jme3.material.RenderState; -import com.jme3.math.ColorRGBA; -import com.jme3.math.Matrix4f; -import com.jme3.math.Vector2f; -import com.jme3.math.Vector3f; -import com.jme3.post.SceneProcessor; -import com.jme3.profile.AppProfiler; -import com.jme3.renderer.Camera; -import com.jme3.renderer.RenderManager; -import com.jme3.renderer.Renderer; -import com.jme3.renderer.ViewPort; -import com.jme3.renderer.queue.GeometryList; -import com.jme3.renderer.queue.OpaqueComparator; -import com.jme3.renderer.queue.RenderQueue; -import com.jme3.renderer.queue.RenderQueue.ShadowMode; -import com.jme3.scene.Geometry; -import com.jme3.scene.Spatial; -import com.jme3.scene.debug.WireFrustum; -import com.jme3.texture.FrameBuffer; -import com.jme3.texture.Image.Format; -import com.jme3.texture.Texture.MagFilter; -import com.jme3.texture.Texture.MinFilter; -import com.jme3.texture.Texture.ShadowCompareMode; -import com.jme3.texture.Texture2D; -import com.jme3.texture.FrameBuffer.FrameBufferTarget; -import com.jme3.ui.Picture; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -/** - * Abstract shadow renderer that holds commons feature to have for a shadow - * renderer. - * - * @author Rémy Bouquet aka Nehon - * @author reden - phr00t - https://github.com/phr00t - * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr - */ -public abstract class AbstractShadowRendererVR implements SceneProcessor, Savable { - private static final LightFilter NULL_LIGHT_FILTER = new NullLightFilter(); - protected int nbShadowMaps = 1; - protected float shadowMapSize; - protected float shadowIntensity = 0.7f; - protected RenderManager renderManager; - protected ViewPort viewPort; - protected FrameBuffer[] shadowFB; - protected Texture2D[] shadowMaps; - protected Texture2D dummyTex; - protected Material preshadowMat; - protected Material postshadowMat; - protected Matrix4f[] lightViewProjectionsMatrices; - protected AssetManager assetManager; - protected boolean debug = false; - protected float edgesThickness = 1.0f; - protected EdgeFilteringMode edgeFilteringMode = EdgeFilteringMode.Bilinear; - protected CompareMode shadowCompareMode = CompareMode.Hardware; - protected Picture[] dispPic; - protected RenderState forcedRenderState = new RenderState(); - protected boolean renderBackFacesShadows; - - protected AppProfiler profiler = null; - - /** - * true if the fallback material should be used, otherwise false - */ - protected boolean needsfallBackMaterial = false; - /** - * name of the post material technique - */ - protected String postTechniqueName = "PostShadow"; - /** - * list of materials for post shadow queue geometries - */ - protected List matCache = new ArrayList<>(); - protected GeometryList lightReceivers = new GeometryList(new OpaqueComparator()); - protected GeometryList shadowMapOccluders = new GeometryList(new OpaqueComparator()); - private String[] shadowMapStringCache; - private String[] lightViewStringCache; - /** - * fade shadows at distance - */ - protected float zFarOverride = 0; - protected Vector2f fadeInfo; - protected float fadeLength; - protected Camera frustumCam; - /** - * true to skip the post pass when there are no shadow casters - */ - protected boolean skipPostPass; - - /** - * used for serialization - */ - protected AbstractShadowRendererVR(){ - } - - /** - * Create an abstract shadow renderer. Subclasses invoke this constructor. - * - * @param assetManager the application asset manager - * @param shadowMapSize the size of the rendered shadow maps (512,1024,2048, - * etc...) - * @param nbShadowMaps the number of shadow maps rendered (the more shadow - * maps the more quality, the fewer fps). - */ - protected AbstractShadowRendererVR(AssetManager assetManager, int shadowMapSize, int nbShadowMaps) { - - this.assetManager = assetManager; - this.nbShadowMaps = nbShadowMaps; - this.shadowMapSize = shadowMapSize; - init(assetManager, nbShadowMaps, shadowMapSize); - - } - - private void init(AssetManager assetManager, int nbShadowMaps, int shadowMapSize) { - this.postshadowMat = new Material(assetManager, "Common/MatDefs/Shadow/PostShadow.j3md"); - shadowFB = new FrameBuffer[nbShadowMaps]; - shadowMaps = new Texture2D[nbShadowMaps]; - dispPic = new Picture[nbShadowMaps]; - lightViewProjectionsMatrices = new Matrix4f[nbShadowMaps]; - shadowMapStringCache = new String[nbShadowMaps]; - lightViewStringCache = new String[nbShadowMaps]; - - //DO NOT COMMENT THIS (It prevents the OSX incomplete read buffer crash.) - dummyTex = new Texture2D(shadowMapSize, shadowMapSize, Format.RGBA8); - - preshadowMat = new Material(assetManager, "Common/MatDefs/Shadow/PreShadow.j3md"); - postshadowMat.setFloat("ShadowMapSize", shadowMapSize); - - for (int i = 0; i < nbShadowMaps; i++) { - lightViewProjectionsMatrices[i] = new Matrix4f(); - shadowFB[i] = new FrameBuffer(shadowMapSize, shadowMapSize, 1); - shadowMaps[i] = new Texture2D(shadowMapSize, shadowMapSize, Format.Depth); - - shadowFB[i].setDepthTarget(FrameBufferTarget.newTarget(shadowMaps[i])); - - //DO NOT COMMENT THIS (It prevents the OSX incomplete read buffer crash.) - shadowFB[i].addColorTarget(FrameBufferTarget.newTarget(dummyTex)); - shadowMapStringCache[i] = "ShadowMap" + i; - lightViewStringCache[i] = "LightViewProjectionMatrix" + i; - - postshadowMat.setTexture(shadowMapStringCache[i], shadowMaps[i]); - - //quads for debugging purposes - dispPic[i] = new Picture("Picture" + i); - dispPic[i].setTexture(assetManager, shadowMaps[i], false); - } - - setShadowCompareMode(shadowCompareMode); - setEdgeFilteringMode(edgeFilteringMode); - setShadowIntensity(shadowIntensity); - initForcedRenderState(); - setRenderBackFacesShadows(isRenderBackFacesShadows()); - } - - protected void initForcedRenderState() { - forcedRenderState.setFaceCullMode(RenderState.FaceCullMode.Front); - forcedRenderState.setColorWrite(false); - forcedRenderState.setDepthWrite(true); - forcedRenderState.setDepthTest(true); - } - - /** - * set the post shadow material for this renderer - * - * @param postShadowMat - */ - protected final void setPostShadowMaterial(Material postShadowMat) { - this.postshadowMat = postShadowMat; - postshadowMat.setFloat("ShadowMapSize", shadowMapSize); - for (int i = 0; i < nbShadowMaps; i++) { - postshadowMat.setTexture(shadowMapStringCache[i], shadowMaps[i]); - } - setShadowCompareMode(shadowCompareMode); - setEdgeFilteringMode(edgeFilteringMode); - setShadowIntensity(shadowIntensity); - } - - /** - * Sets the filtering mode for shadow edges. See {@link EdgeFilteringMode} - * for more info. - * - * @param filterMode the desired filter mode (not null) - */ - final public void setEdgeFilteringMode(EdgeFilteringMode filterMode) { - if (filterMode == null) { - throw new IllegalArgumentException("filterMode cannot be null"); - } - - this.edgeFilteringMode = filterMode; - postshadowMat.setInt("FilterMode", filterMode.getMaterialParamValue()); - postshadowMat.setFloat("PCFEdge", edgesThickness); - if (shadowCompareMode == CompareMode.Hardware) { - for (Texture2D shadowMap : shadowMaps) { - if (filterMode == EdgeFilteringMode.Bilinear) { - shadowMap.setMagFilter(MagFilter.Bilinear); - shadowMap.setMinFilter(MinFilter.BilinearNoMipMaps); - } else { - shadowMap.setMagFilter(MagFilter.Nearest); - shadowMap.setMinFilter(MinFilter.NearestNoMipMaps); - } - } - } - } - - /** - * Get the edge filtering mode. - * @return the edge filtering mode. - */ - public EdgeFilteringMode getEdgeFilteringMode() { - return edgeFilteringMode; - } - - /** - * Sets the shadow compare mode. See {@link CompareMode} for more info. - * - * @param compareMode the desired compare mode (not null) - */ - final public void setShadowCompareMode(CompareMode compareMode) { - if (compareMode == null) { - throw new IllegalArgumentException("Shadow compare mode cannot be null"); - } - - this.shadowCompareMode = compareMode; - for (Texture2D shadowMap : shadowMaps) { - if (compareMode == CompareMode.Hardware) { - shadowMap.setShadowCompareMode(ShadowCompareMode.LessOrEqual); - if (edgeFilteringMode == EdgeFilteringMode.Bilinear) { - shadowMap.setMagFilter(MagFilter.Bilinear); - shadowMap.setMinFilter(MinFilter.BilinearNoMipMaps); - } else { - shadowMap.setMagFilter(MagFilter.Nearest); - shadowMap.setMinFilter(MinFilter.NearestNoMipMaps); - } - } else { - shadowMap.setShadowCompareMode(ShadowCompareMode.Off); - shadowMap.setMagFilter(MagFilter.Nearest); - shadowMap.setMinFilter(MinFilter.NearestNoMipMaps); - } - } - postshadowMat.setBoolean("HardwareShadows", compareMode == CompareMode.Hardware); - } - - /** - * returns the shadow compare mode - * - * @see CompareMode - * @return the shadowCompareMode - */ - public CompareMode getShadowCompareMode() { - return shadowCompareMode; - } - - /** - * debug function to create a visible frustum - */ - protected Geometry createFrustum(Vector3f[] pts, int i) { - WireFrustum frustum = new WireFrustum(pts); - Geometry frustumMdl = new Geometry("f", frustum); - frustumMdl.setCullHint(Spatial.CullHint.Never); - frustumMdl.setShadowMode(ShadowMode.Off); - Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); - mat.getAdditionalRenderState().setWireframe(true); - frustumMdl.setMaterial(mat); - switch (i) { - case 0: - frustumMdl.getMaterial().setColor("Color", ColorRGBA.Pink); - break; - case 1: - frustumMdl.getMaterial().setColor("Color", ColorRGBA.Red); - break; - case 2: - frustumMdl.getMaterial().setColor("Color", ColorRGBA.Green); - break; - case 3: - frustumMdl.getMaterial().setColor("Color", ColorRGBA.Blue); - break; - default: - frustumMdl.getMaterial().setColor("Color", ColorRGBA.White); - break; - } - - frustumMdl.updateGeometricState(); - return frustumMdl; - } - - /** - * Initialize this shadow renderer prior to its first update. - * - * @param rm the render manager - * @param vp the viewport - */ - @Override - public void initialize(RenderManager rm, ViewPort vp) { - renderManager = rm; - viewPort = vp; - postTechniqueName = "PostShadow"; - if(zFarOverride>0 && frustumCam == null){ - initFrustumCam(); - } - } - - /** - * delegates the initialization of the frustum cam to child renderers - */ - protected abstract void initFrustumCam(); - - /** - * Test whether this shadow renderer has been initialized. - * - * @return true if initialized, otherwise false - */ - @Override - public boolean isInitialized() { - return viewPort != null; - } - - /** - * Invoked once per frame to update the shadow cams according to the light - * view. - * - * @param viewCam the scene cam - */ - protected abstract void updateShadowCams(Camera viewCam); - - /** - * Returns a subclass-specific geometryList containing the occluders to be - * rendered in the shadow map - * - * @param shadowMapIndex the index of the shadow map being rendered - * @param shadowMapOccluders the list of occluders - * @return a list of occluders - */ - protected abstract GeometryList getOccludersToRender(int shadowMapIndex, GeometryList shadowMapOccluders); - - /** - * return the shadow camera to use for rendering the shadow map according - * the given index - * - * @param shadowMapIndex the index of the shadow map being rendered - * @return the shadowCam - */ - protected abstract Camera getShadowCam(int shadowMapIndex); - - @Override - public void setProfiler(AppProfiler profiler) { - this.profiler = profiler; - } - - /** - * responsible for displaying the frustum of the shadow cam for debug - * purpose - * - * @param shadowMapIndex - */ - protected void doDisplayFrustumDebug(int shadowMapIndex) { - } - - @SuppressWarnings("fallthrough") - @Override - public void postQueue(RenderQueue rq) { - lightReceivers.clear(); - skipPostPass = false; - if ( !checkCulling(viewPort.getCamera()) ) { - skipPostPass = true; - return; - } - - updateShadowCams(viewPort.getCamera()); - - Renderer r = renderManager.getRenderer(); - renderManager.setForcedMaterial(preshadowMat); - renderManager.setForcedTechnique("PreShadow"); - - for (int shadowMapIndex = 0; shadowMapIndex < nbShadowMaps; shadowMapIndex++) { - - if (debugfrustums) { - doDisplayFrustumDebug(shadowMapIndex); - } - renderShadowMap(shadowMapIndex); - - } - - debugfrustums = false; - - //restore setting for future rendering - r.setFrameBuffer(viewPort.getOutputFrameBuffer()); - renderManager.setForcedMaterial(null); - renderManager.setForcedTechnique(null); - renderManager.setCamera(viewPort.getCamera(), false); - } - - protected void renderShadowMap(int shadowMapIndex) { - shadowMapOccluders = getOccludersToRender(shadowMapIndex, shadowMapOccluders); - Camera shadowCam = getShadowCam(shadowMapIndex); - - //saving light view projection matrix for this split - lightViewProjectionsMatrices[shadowMapIndex].set(shadowCam.getViewProjectionMatrix()); - renderManager.setCamera(shadowCam, false); - - renderManager.getRenderer().setFrameBuffer(shadowFB[shadowMapIndex]); - renderManager.getRenderer().clearBuffers(true, true, true); - renderManager.setForcedRenderState(forcedRenderState); - - // render shadow casters to shadow map and disables the lightfilter - LightFilter tmpLightFilter = renderManager.getLightFilter(); - renderManager.setLightFilter(NULL_LIGHT_FILTER); - viewPort.getQueue().renderShadowQueue(shadowMapOccluders, renderManager, shadowCam, true); - renderManager.setLightFilter(tmpLightFilter); - renderManager.setForcedRenderState(null); - } - boolean debugfrustums = false; - - /** - * Force the frustum to be displayed. - */ - public void displayFrustum() { - debugfrustums = true; - } - - /** - * For debugging purposes, display depth shadow maps. - */ - protected void displayShadowMap(Renderer r) { - Camera cam = viewPort.getCamera(); - renderManager.setCamera(cam, true); - int h = cam.getHeight(); - for (int i = 0; i < dispPic.length; i++) { - dispPic[i].setPosition((128 * i) + (150 + 64 * (i + 1)), h / 20f); - dispPic[i].setWidth(128); - dispPic[i].setHeight(128); - dispPic[i].updateGeometricState(); - renderManager.renderGeometry(dispPic[i]); - } - renderManager.setCamera(cam, false); - } - - /** - * For debugging purposes, "snapshot" the current frustum to the scene. - */ - public void displayDebug() { - debug = true; - } - - protected abstract void getReceivers(GeometryList lightReceivers); - - @Override - public void postFrame(FrameBuffer out) { - if (skipPostPass) { - return; - } - if (debug) { - displayShadowMap(renderManager.getRenderer()); - } - - getReceivers(lightReceivers); - - if (lightReceivers.size() != 0) { - //setting params to receiving geometry list - setMatParams(lightReceivers); - - Camera cam = viewPort.getCamera(); - //If some materials in the scene do not have a post shadow technique, use the fallback material. - if (needsfallBackMaterial) { - renderManager.setForcedMaterial(postshadowMat); - } - - //forcing the post shadow technique and render state - renderManager.setForcedTechnique(postTechniqueName); - - //rendering the post shadow pass - viewPort.getQueue().renderShadowQueue(lightReceivers, renderManager, cam, false); - - //resetting renderManager settings - renderManager.setForcedTechnique(null); - renderManager.setForcedMaterial(null); - renderManager.setCamera(cam, false); - - //clearing the params in case there are some other shadow renderers - clearMatParams(); - } - } - - /** - * This method is called once per frame and is responsible for clearing any - * material parameters that subclasses may need to clear on the post material. - * - * @param material the material that was used for the post shadow pass - */ - protected abstract void clearMaterialParameters(Material material); - - private void clearMatParams(){ - for (Material mat : matCache) { - //clearing only necessary params, the others may be set by other - //renderers - //Note that j start at 1 because other shadow renderers will have - //at least 1 shadow map and will set it on each frame anyway. - for (int j = 1; j < nbShadowMaps; j++) { - mat.clearParam(lightViewStringCache[j]); - } - for (int j = 1; j < nbShadowMaps; j++) { - mat.clearParam(shadowMapStringCache[j]); - } - mat.clearParam("FadeInfo"); - clearMaterialParameters(mat); - } - //No need to clear the postShadowMat params as the instance is locale to each renderer - } - - /** - * This method is called once per frame and is responsible for setting any - * material parameters that subclasses may need to set on the post material. - * - * @param material the material to use for the post shadow pass - */ - protected abstract void setMaterialParameters(Material material); - - private void setMatParams(GeometryList l) { - //iterate through all the geometries of the list to gather the materials - - buildMatCache(l); - - //iterating through the mat cache and setting the parameters - for (Material mat : matCache) { - - mat.setFloat("ShadowMapSize", shadowMapSize); - - for (int j = 0; j < nbShadowMaps; j++) { - mat.setMatrix4(lightViewStringCache[j], lightViewProjectionsMatrices[j]); - } - for (int j = 0; j < nbShadowMaps; j++) { - mat.setTexture(shadowMapStringCache[j], shadowMaps[j]); - } - mat.setBoolean("HardwareShadows", shadowCompareMode == CompareMode.Hardware); - mat.setInt("FilterMode", edgeFilteringMode.getMaterialParamValue()); - mat.setFloat("PCFEdge", edgesThickness); - mat.setFloat("ShadowIntensity", shadowIntensity); - mat.setBoolean("BackfaceShadows", renderBackFacesShadows); - - if (fadeInfo != null) { - mat.setVector2("FadeInfo", fadeInfo); - } - - setMaterialParameters(mat); - } - - //At least one material of the receiving geoms does not support the post shadow technique, - //so we fall back to the forced material solution. (Transparent shadows won't be supported for these objects.) - if (needsfallBackMaterial) { - setPostShadowParams(); - } - - } - - private void buildMatCache(GeometryList l) { - matCache.clear(); - for (int i = 0; i < l.size(); i++) { - Material mat = l.get(i).getMaterial(); - //checking if the material has the post technique and adding it to the material cache - if (mat.getMaterialDef().getTechniqueDefs(postTechniqueName) != null) { - if (!matCache.contains(mat)) { - matCache.add(mat); - } - } else { - needsfallBackMaterial = true; - } - } - } - - /** - * for internal use only - */ - protected void setPostShadowParams() { - setMaterialParameters(postshadowMat); - for (int j = 0; j < nbShadowMaps; j++) { - postshadowMat.setMatrix4(lightViewStringCache[j], lightViewProjectionsMatrices[j]); - postshadowMat.setTexture(shadowMapStringCache[j], shadowMaps[j]); - } - if (fadeInfo != null) { - postshadowMat.setVector2("FadeInfo", fadeInfo); - } - postshadowMat.setBoolean("BackfaceShadows", renderBackFacesShadows); - } - - /** - * How far the shadows are rendered in the view - * - * @see #setShadowZExtend(float zFar) - * @return shadowZExtend - */ - public float getShadowZExtend() { - return zFarOverride; - } - - /** - * Set the distance from the eye where the shadows will be rendered default - * value is dynamically computed to the shadow casters/receivers union bound - * zFar, capped to view frustum far value. - * - * @param zFar the zFar values that override the computed one - */ - public void setShadowZExtend(float zFar) { - this.zFarOverride = zFar; - if(zFarOverride == 0){ - fadeInfo = null; - frustumCam = null; - }else{ - if (fadeInfo != null) { - fadeInfo.set(zFarOverride - fadeLength, 1f / fadeLength); - } - if(frustumCam == null && viewPort != null){ - initFrustumCam(); - } - } - } - - /** - * Define the length over which the shadow will fade out when using a - * shadowZextend This is useful to make dynamic shadows fade into baked - * shadows in the distance. - * - * @param length the fade length in world units - */ - public void setShadowZFadeLength(float length) { - if (length == 0) { - fadeInfo = null; - fadeLength = 0; - postshadowMat.clearParam("FadeInfo"); - } else { - if (zFarOverride == 0) { - fadeInfo = new Vector2f(0, 0); - } else { - fadeInfo = new Vector2f(zFarOverride - length, 1.0f / length); - } - fadeLength = length; - postshadowMat.setVector2("FadeInfo", fadeInfo); - } - } - - /** - * get the length over which the shadow will fade out when using a - * shadowZextend - * - * @return the fade length in world units - */ - public float getShadowZFadeLength() { - if (fadeInfo != null) { - return zFarOverride - fadeInfo.x; - } - return 0f; - } - - /** - * returns true if the light source bounding box is in the view frustum - * @return true if box in frustum - */ - protected abstract boolean checkCulling(Camera viewCam); - - @Override - public void preFrame(float tpf) { - } - - @Override - public void cleanup() { - } - - @Override - public void reshape(ViewPort vp, int w, int h) { - } - - /** - * Returns the shadow intensity. - * - * @see #setShadowIntensity(float shadowIntensity) - * @return shadowIntensity - */ - public float getShadowIntensity() { - return shadowIntensity; - } - - /** - * Set the shadowIntensity. The value should be between 0 and 1. A 0 value - * gives a bright and invisible shadow, a 1 value gives a pitch black - * shadow. The default is 0.7 - * - * @param shadowIntensity the darkness of the shadow - */ - final public void setShadowIntensity(float shadowIntensity) { - this.shadowIntensity = shadowIntensity; - postshadowMat.setFloat("ShadowIntensity", shadowIntensity); - } - - /** - * returns the edges thickness - * - * @see #setEdgesThickness(int edgesThickness) - * @return edgesThickness - */ - public int getEdgesThickness() { - return (int) (edgesThickness * 10); - } - - /** - * Sets the shadow edge thickness. Default is 1. Setting it to lower values - * can help to reduce the jagged effect of the shadow edges. - * @param edgesThickness the shadow edge thickness. - */ - public void setEdgesThickness(int edgesThickness) { - this.edgesThickness = Math.max(1, Math.min(edgesThickness, 10)); - this.edgesThickness *= 0.1f; - postshadowMat.setFloat("PCFEdge", edgesThickness); - } - - /** - * This method does nothing now and is kept only for backward compatibility. - * @return false - * @deprecated This method does nothing now and is kept only for backward compatibility. - */ - @Deprecated - public boolean isFlushQueues() { return false; } - - /** - * Returns the pre shadows pass render state. - * use it to adjust the RenderState parameters of the pre shadow pass. - * Note that this will be overridden if the preShadow technique in the material has a ForcedRenderState - * @return the pre shadow render state. - */ - public RenderState getPreShadowForcedRenderState() { - return forcedRenderState; - } - - /** - * Set to true if you want back faces shadows on geometries. - * Note that back faces shadows will be blended over dark lighten areas and may produce overly dark lighting. - * - * Also note that setting this parameter will override this parameter for ALL materials in the scene. - * You can alternatively change this parameter on a single material using {@link Material#setBoolean(String, boolean)} - * - * This also will automatically adjust the faceCullMode and the PolyOffset of the pre shadow pass. - * You can modify them by using {@link #getPreShadowForcedRenderState()} - * - * @param renderBackFacesShadows true or false. - */ - public void setRenderBackFacesShadows(Boolean renderBackFacesShadows) { - this.renderBackFacesShadows = renderBackFacesShadows; - if(renderBackFacesShadows) { - getPreShadowForcedRenderState().setPolyOffset(5, 3); - getPreShadowForcedRenderState().setFaceCullMode(RenderState.FaceCullMode.Back); - }else{ - getPreShadowForcedRenderState().setPolyOffset(0, 0); - getPreShadowForcedRenderState().setFaceCullMode(RenderState.FaceCullMode.Front); - } - } - - /** - * if this processor renders back faces shadows - * - * @return true if this processor renders back faces shadows - */ - public boolean isRenderBackFacesShadows() { - return renderBackFacesShadows; - } - - /** - * De-serialize this instance, for example when loading from a J3O file. - * - * @param im importer (not null) - */ - @Override - public void read(JmeImporter im) throws IOException { - InputCapsule ic = im.getCapsule(this); - assetManager = im.getAssetManager(); - nbShadowMaps = ic.readInt("nbShadowMaps", 1); - shadowMapSize = ic.readFloat("shadowMapSize", 0f); - shadowIntensity = ic.readFloat("shadowIntensity", 0.7f); - edgeFilteringMode = ic.readEnum("edgeFilteringMode", EdgeFilteringMode.class, EdgeFilteringMode.Bilinear); - shadowCompareMode = ic.readEnum("shadowCompareMode", CompareMode.class, CompareMode.Hardware); - init(assetManager, nbShadowMaps, (int) shadowMapSize); - edgesThickness = ic.readFloat("edgesThickness", 1.0f); - postshadowMat.setFloat("PCFEdge", edgesThickness); - - } - - /** - * Serialize this instance, for example when saving to a J3O file. - * - * @param ex exporter (not null) - */ - @Override - public void write(JmeExporter ex) throws IOException { - OutputCapsule oc = ex.getCapsule(this); - oc.write(nbShadowMaps, "nbShadowMaps", 1); - oc.write(shadowMapSize, "shadowMapSize", 0); - oc.write(shadowIntensity, "shadowIntensity", 0.7f); - oc.write(edgeFilteringMode, "edgeFilteringMode", EdgeFilteringMode.Bilinear); - oc.write(shadowCompareMode, "shadowCompareMode", CompareMode.Hardware); - oc.write(edgesThickness, "edgesThickness", 1.0f); - } -} diff --git a/jme3-xr/src/main/java/com/jme3/shadow/DirectionalLightShadowFilterVR.java b/jme3-xr/src/main/java/com/jme3/shadow/DirectionalLightShadowFilterVR.java deleted file mode 100644 index 7d9adc02f6..0000000000 --- a/jme3-xr/src/main/java/com/jme3/shadow/DirectionalLightShadowFilterVR.java +++ /dev/null @@ -1,172 +0,0 @@ -package com.jme3.shadow; - -/* - * Copyright (c) 2009-2018 jMonkeyEngine - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'jMonkeyEngine' nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import com.jme3.asset.AssetManager; -import com.jme3.export.InputCapsule; -import com.jme3.export.JmeExporter; -import com.jme3.export.JmeImporter; -import com.jme3.export.OutputCapsule; -import com.jme3.light.DirectionalLight; -import java.io.IOException; - -/** - * - * This Filter does basically the same as a DirectionalLightShadowRenderer - * except it renders the post shadow pass as a fullscreen quad pass instead of a - * geometry pass. It's mostly faster than PssmShadowRenderer as long as you have - * more than about ten shadow receiving objects. The expense is the drawback - * that the shadow Receive mode set on spatial is ignored. So basically all and - * only objects that render depth in the scene receive shadows. See this post - * for more details - * http://jmonkeyengine.org/groups/general-2/forum/topic/silly-question-about-shadow-rendering/#post-191599 - * - * API is basically the same as the PssmShadowRenderer; - * - * @author Rémy Bouquet aka Nehon - * @author reden - phr00t - https://github.com/phr00t - * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr - */ -public class DirectionalLightShadowFilterVR extends AbstractShadowFilterVR { - - /** - * Creates a DirectionalLightShadowFilter Shadow Filter More info on the - * technique at http://http.developer.nvidia.com/GPUGems3/gpugems3_ch10.html - * - * @param assetManager the application asset manager - * @param shadowMapSize the size of the rendered shadowmaps (512, 1024, 2048, - * etcetera) - * @param nbSplits the number of shadow maps rendered (More shadow maps yield - * better quality, fewer fps.) - */ - public DirectionalLightShadowFilterVR(AssetManager assetManager, int shadowMapSize, int nbSplits) { - super(assetManager, shadowMapSize, new DirectionalLightShadowRendererVR(assetManager, shadowMapSize, nbSplits)); - } - - /** - * Creates a DirectionalLight shadow filter. More info on the - * technique at http://http.developer.nvidia.com/GPUGems3/gpugems3_ch10.html. - * - * @param assetManager the application's asset manager - * @param shadowMapSize the size of the rendered shadowmaps (512, 1024, 2048, etc...) - * @param nbSplits the number of shadow maps rendered (More shadow maps yield - * better quality, fewer fps.) - * @param useMatDef the material to attach to this filter. - */ - public DirectionalLightShadowFilterVR(AssetManager assetManager, int shadowMapSize, int nbSplits, String useMatDef) { - super(assetManager, shadowMapSize, new DirectionalLightShadowRendererVR(assetManager, shadowMapSize, nbSplits), useMatDef); - } - - /** - * return the light used to cast shadows - * - * @return the DirectionalLight - */ - public DirectionalLight getLight() { - return shadowRenderer.getLight(); - } - - /** - * Sets the light to use to cast shadows - * - * @param light a DirectionalLight - */ - public void setLight(DirectionalLight light) { - shadowRenderer.setLight(light); - } - - /** - * returns the lambda parameter - * - * @see #setLambda(float lambda) - * @return lambda - */ - public float getLambda() { - return shadowRenderer.getLambda(); - } - - /** - * Adjusts the partition of the shadow extend into shadow maps. - * Lambda is usually between 0 and 1. - * A low value gives a more linear partition, - * resulting in consistent shadow quality over the extend, - * but near shadows could look very jagged. - * A high value gives a more logarithmic partition, - * resulting in high quality for near shadows, - * but quality decreases rapidly with distance. - * The default value is 0.65 (the theoretical optimum). - * - * @param lambda the lambda value. - */ - public void setLambda(float lambda) { - shadowRenderer.setLambda(lambda); - } - - /** - * Check if stabilization is enabled. - * @return true if the stabilization is enabled and false otherwise. - * @see #setEnabledStabilization(boolean) - */ - public boolean isEnabledStabilization() { - return shadowRenderer.isEnabledStabilization(); - } - - /** - * Enables the stabilization of the shadow's edges. (default is true) - * This prevents shadow edges from flickering when the camera moves. - * However, it can lead to some loss of shadow quality in particular scenes. - * - * @param stabilize true if the stabilization has to be enabled and false otherwise. - * @see #isEnabledStabilization() - */ - public void setEnabledStabilization(boolean stabilize) { - shadowRenderer.setEnabledStabilization(stabilize); - } - - @Override - public void write(JmeExporter ex) throws IOException { - super.write(ex); - OutputCapsule oc = ex.getCapsule(this); - oc.write(shadowRenderer, "shadowRenderer", null); - - } - - @Override - public void read(JmeImporter im) throws IOException { - super.read(im); - InputCapsule ic = im.getCapsule(this); - shadowRenderer = (DirectionalLightShadowRendererVR) ic.readSavable("shadowRenderer", null); - } -} diff --git a/jme3-xr/src/main/java/com/jme3/shadow/DirectionalLightShadowRendererVR.java b/jme3-xr/src/main/java/com/jme3/shadow/DirectionalLightShadowRendererVR.java deleted file mode 100644 index d0676eebb8..0000000000 --- a/jme3-xr/src/main/java/com/jme3/shadow/DirectionalLightShadowRendererVR.java +++ /dev/null @@ -1,308 +0,0 @@ -package com.jme3.shadow; - -/* - * Copyright (c) 2009-2021 jMonkeyEngine - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'jMonkeyEngine' nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import com.jme3.asset.AssetManager; -import com.jme3.export.InputCapsule; -import com.jme3.export.JmeExporter; -import com.jme3.export.JmeImporter; -import com.jme3.export.OutputCapsule; -import com.jme3.light.DirectionalLight; -import com.jme3.material.Material; -import com.jme3.math.ColorRGBA; -import com.jme3.math.Vector2f; -import com.jme3.math.Vector3f; -import com.jme3.renderer.Camera; -import com.jme3.renderer.queue.GeometryList; -import com.jme3.renderer.queue.RenderQueue; -import com.jme3.scene.Node; -import com.jme3.scene.Spatial; - -import java.io.IOException; - -/** - * DirectionalLightShadowRenderer renderer use Parallel Split Shadow Mapping - * technique (pssm)
It splits the view frustum in several parts and compute - * a shadow map for each one.
splits are distributed so that the closer they - * are from the camera, the smaller they are to maximize the resolution used of - * the shadow map.
This results in a better quality shadow than standard - * shadow mapping.
for more information on this read http://http.developer.nvidia.com/GPUGems3/gpugems3_ch10.html
- * - * @author Rémy Bouquet aka Nehon - * @author reden - phr00t - https://github.com/phr00t - * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr - */ -public class DirectionalLightShadowRendererVR extends AbstractShadowRendererVR { - - protected float lambda = 0.65f; - protected Camera shadowCam; - protected ColorRGBA splits; - protected float[] splitsArray; - protected DirectionalLight light; - protected Vector3f[] points = new Vector3f[8]; - //Holding the info for fading shadows in the far distance - private boolean stabilize = true; - - /** - * Used for serialization use - * DirectionalLightShadowRenderer#DirectionalLightShadowRenderer(AssetManager - * assetManager, int shadowMapSize, int nbSplits) - */ - public DirectionalLightShadowRendererVR() { - super(); - } - - /** - * Creates a DirectionalLight shadow renderer. More info on the technique at http://http.developer.nvidia.com/GPUGems3/gpugems3_ch10.html - * - * @param assetManager the application's asset manager - * @param shadowMapSize the size of the rendered shadowmaps (512, 1024, 2048, - * etcetera) - * @param nbSplits the number of shadow maps rendered (More shadow maps yield - * better quality, fewer fps.) - */ - public DirectionalLightShadowRendererVR(AssetManager assetManager, int shadowMapSize, int nbSplits) { - super(assetManager, shadowMapSize, nbSplits); - init(nbSplits, shadowMapSize); - } - - private void init(int nbSplits, int shadowMapSize) { - nbShadowMaps = Math.max(Math.min(nbSplits, 4), 1); - if (nbShadowMaps != nbSplits) { - throw new IllegalArgumentException("Number of splits must be between 1 and 4. Given value : " + nbSplits); - } - splits = new ColorRGBA(); - splitsArray = new float[nbSplits + 1]; - shadowCam = new Camera(shadowMapSize, shadowMapSize); - shadowCam.setParallelProjection(true); - for (int i = 0; i < points.length; i++) { - points[i] = new Vector3f(); - } - } - - @Override - protected void initFrustumCam() { - //nothing to do - } - - /** - * return the light used to cast shadows - * @return the DirectionalLight - */ - public DirectionalLight getLight() { - return light; - } - - /** - * Sets the light to use to cast shadows - * @param light a DirectionalLight - */ - public void setLight(DirectionalLight light) { - this.light = light; - } - - @Override - protected void updateShadowCams(Camera viewCam) { - - float zFar = zFarOverride; - if (zFar == 0) { - zFar = viewCam.getFrustumFar(); - } - - //We prevent computing the frustum points and splits with zeroed or negative near clip value - float frustumNear = Math.max(viewCam.getFrustumNear(), 0.001f); - ShadowUtil.updateFrustumPoints(viewCam, frustumNear, zFar, 1.0f, points); - - //shadowCam.setDirection(direction); - shadowCam.getRotation().lookAt(light.getDirection(), shadowCam.getUp()); - shadowCam.update(); - shadowCam.updateViewProjection(); - - PssmShadowUtil.updateFrustumSplits(splitsArray, frustumNear, zFar, lambda); - - // in parallel projection shadow position goe from 0 to 1 - if(viewCam.isParallelProjection()){ - for (int i = 0; i < nbShadowMaps; i++) { - splitsArray[i] = splitsArray[i]/(zFar- frustumNear); - } - } - - switch (splitsArray.length) { - case 5: - splits.a = splitsArray[4]; - case 4: - splits.b = splitsArray[3]; - case 3: - splits.g = splitsArray[2]; - case 2: - case 1: - splits.r = splitsArray[1]; - break; - } - - } - - @Override - protected GeometryList getOccludersToRender(int shadowMapIndex, GeometryList shadowMapOccluders) { - - // update frustum points based on current camera and split - ShadowUtil.updateFrustumPoints(viewPort.getCamera(), splitsArray[shadowMapIndex], splitsArray[shadowMapIndex + 1], 1.0f, points); - - //Updating shadow cam with current split frusta - if (lightReceivers.size()==0) { - for (Spatial scene : viewPort.getScenes()) { - ShadowUtil.getGeometriesInCamFrustum(scene, viewPort.getCamera(), RenderQueue.ShadowMode.Receive, lightReceivers); - } - } - ShadowUtil.updateShadowCamera(viewPort, lightReceivers, shadowCam, points, shadowMapOccluders, stabilize?shadowMapSize:0); - - return shadowMapOccluders; - } - - @Override - protected void getReceivers(GeometryList lightReceivers) { - if (lightReceivers.size()==0) { - for (Spatial scene : viewPort.getScenes()) { - ShadowUtil.getGeometriesInCamFrustum(scene, viewPort.getCamera(), RenderQueue.ShadowMode.Receive, lightReceivers); - } - } - } - - @Override - protected Camera getShadowCam(int shadowMapIndex) { - return shadowCam; - } - - @Override - protected void doDisplayFrustumDebug(int shadowMapIndex) { - ((Node) viewPort.getScenes().get(0)).attachChild(createFrustum(points, shadowMapIndex)); - ShadowUtil.updateFrustumPoints2(shadowCam, points); - ((Node) viewPort.getScenes().get(0)).attachChild(createFrustum(points, shadowMapIndex)); - } - - @Override - protected void setMaterialParameters(Material material) { - material.setColor("Splits", splits); - material.setVector3("LightDir", light.getDirection()); - if (fadeInfo != null) { - material.setVector2("FadeInfo", fadeInfo); - } - } - - @Override - protected void clearMaterialParameters(Material material) { - material.clearParam("Splits"); - material.clearParam("FadeInfo"); - material.clearParam("LightDir"); - } - - /** - * returns the lambda parameter see #setLambda(float lambda) - * - * @return lambda - */ - public float getLambda() { - return lambda; - } - - /** - * Adjusts the partition of the shadow extend into shadow maps. - * Lambda is usually between 0 and 1. - * A low value gives a more linear partition, - * resulting in consistent shadow quality over the extend, - * but near shadows could look very jagged. - * A high value gives a more logarithmic partition, - * resulting in high quality for near shadows, - * but quality decreases rapidly with distance. - * The default value is 0.65 (the theoretical optimum). - * - * @param lambda the lambda value. - */ - public void setLambda(float lambda) { - this.lambda = lambda; - } - - /** - * Check if the stabilization is enabled. - * @return true if stabilization is enabled and false otherwise. - */ - public boolean isEnabledStabilization() { - return stabilize; - } - - /** - * Enables the stabilization of the shadow's edges. (default is true) - * This prevents shadow edges from flickering when the camera moves. - * However, it can lead to some loss of shadow quality in particular scenes. - * - * @param stabilize true if stabilization has to be enabled and false otherwise. - */ - public void setEnabledStabilization(boolean stabilize) { - this.stabilize = stabilize; - } - - @Override - public void read(JmeImporter im) throws IOException { - super.read(im); - InputCapsule ic = im.getCapsule(this); - lambda = ic.readFloat("lambda", 0.65f); - zFarOverride = ic.readInt("zFarOverride", 0); - light = (DirectionalLight) ic.readSavable("light", null); - fadeInfo = (Vector2f) ic.readSavable("fadeInfo", null); - fadeLength = ic.readFloat("fadeLength", 0f); - init(nbShadowMaps, (int) shadowMapSize); - } - - @Override - public void write(JmeExporter ex) throws IOException { - super.write(ex); - OutputCapsule oc = ex.getCapsule(this); - oc.write(lambda, "lambda", 0.65f); - oc.write(zFarOverride, "zFarOverride", 0); - oc.write(light, "light", null); - oc.write(fadeInfo, "fadeInfo", null); - oc.write(fadeLength, "fadeLength", 0f); - } - - /** - * Directional light is always in the view frustum - * @param viewCam - * @return true - */ - @Override - protected boolean checkCulling(Camera viewCam) { - return true; - } -} diff --git a/jme3-xr/src/main/java/com/jme3/shadow/InstancedDirectionalShadowFilter.java b/jme3-xr/src/main/java/com/jme3/shadow/InstancedDirectionalShadowFilter.java deleted file mode 100644 index a848409f70..0000000000 --- a/jme3-xr/src/main/java/com/jme3/shadow/InstancedDirectionalShadowFilter.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.jme3.shadow; - -import com.jme3.app.Application; -import com.jme3.math.Matrix4f; -import com.jme3.math.Vector4f; -import com.jme3.renderer.Camera; - -/** - * An instanced version of the {@link DirectionalLightShadowFilterVR directional light shadow filter}. - * @author reden - phr00t - https://github.com/phr00t - * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr - */ -public class InstancedDirectionalShadowFilter extends DirectionalLightShadowFilterVR { - private final Vector4f temp4f = new Vector4f(), temp4f2 = new Vector4f(); - - private boolean instanceRendering = false; - - private Camera rightCamera = null; - - /** - * Create a new instanced version of the {@link DirectionalLightShadowFilterVR directional light shadow filter}. - * @param application the application that this filter is attached to. - * @param camera - * @param shadowMapSize the size of the rendered shadowmaps (512, 1024, 2048, etcetera) - * @param nbSplits the number of shadow maps rendered (More shadow maps yield - * better quality, fewer frames per second.) - * @param instancedRendering true if this filter has to use instance rendering and false otherwise. - * @param rightCamera the camera used as right eye in stereo rendering mode. - */ - public InstancedDirectionalShadowFilter(Application application, Camera camera, int shadowMapSize, int nbSplits, boolean instancedRendering, Camera rightCamera) { - super(application.getAssetManager(), shadowMapSize, nbSplits, "Common/MatDefs/VR/PostShadowFilter.j3md"); - this.instanceRendering = instancedRendering; - this.rightCamera = rightCamera; - } - - @Override - protected void preFrame(float tpf) { - shadowRenderer.preFrame(tpf); - if( instanceRendering ) { - material.setMatrix4("ViewProjectionMatrixInverseRight", rightCamera.getViewProjectionMatrix().invert()); - Matrix4f m = rightCamera.getViewProjectionMatrix(); - material.setVector4("ViewProjectionMatrixRow2Right", temp4f2.set(m.m20, m.m21, m.m22, m.m23)); - } - material.setMatrix4("ViewProjectionMatrixInverse", viewPort.getCamera().getViewProjectionMatrix().invert()); - Matrix4f m = viewPort.getCamera().getViewProjectionMatrix(); - material.setVector4("ViewProjectionMatrixRow2", temp4f.set(m.m20, m.m21, m.m22, m.m23)); - } - - /** - * Get if this filter is using instance rendering. - * @return true if this filter is using instance rendering and false otherwise. - * @see #setInstanceRendering(boolean) - */ - public boolean isInstanceRendering() { - return instanceRendering; - } - - /** - * Set if this filter has to use instance rendering. - * @param instanceRendering true if this filter has to use instance rendering and false otherwise. - * @see #isInstanceRendering() - */ - public void setInstanceRendering(boolean instanceRendering) { - this.instanceRendering = instanceRendering; - } -} diff --git a/jme3-xr/src/main/java/com/jme3/shadow/VRDirectionalLightShadowRenderer.java b/jme3-xr/src/main/java/com/jme3/shadow/VRDirectionalLightShadowRenderer.java deleted file mode 100644 index 39ecdaed96..0000000000 --- a/jme3-xr/src/main/java/com/jme3/shadow/VRDirectionalLightShadowRenderer.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2009-2021 jMonkeyEngine - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'jMonkeyEngine' nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package com.jme3.shadow; - -import com.jme3.asset.AssetManager; -import com.jme3.shadow.DirectionalLightShadowRenderer; - -/** - * DirectionalLightShadowRenderer renderer use Parallel Split Shadow Mapping - * technique (pssm)
It splits the view frustum in several parts and compute - * a shadow map for each one.
splits are distributed so that the closer they - * are from the camera, the smaller they are to maximize the resolution used of - * the shadow map.
This results in a better quality shadow than standard - * shadow mapping.
for more information on this read http://http.developer.nvidia.com/GPUGems3/gpugems3_ch10.html
- * - * @author Rémy Bouquet aka Nehon - */ -public class VRDirectionalLightShadowRenderer extends DirectionalLightShadowRenderer { - - /** - * Create an OculusDirectionalLightShadowRenderer More info on the technique at http://http.developer.nvidia.com/GPUGems3/gpugems3_ch10.html - * - * @param assetManager the application asset manager - * @param shadowMapSize the size of the rendered shadowmaps (512,1024,2048, - * etc...) - * @param nbSplits the number of shadow maps rendered (More shadow maps - * result in higher quality, fewer fps.) - */ - public VRDirectionalLightShadowRenderer(AssetManager assetManager, int shadowMapSize, int nbSplits) { - super(assetManager, shadowMapSize, nbSplits); - } - - @Override - public VRDirectionalLightShadowRenderer clone() { - VRDirectionalLightShadowRenderer clone = new VRDirectionalLightShadowRenderer(assetManager, (int)shadowMapSize, nbShadowMaps); - clone.setEdgeFilteringMode(getEdgeFilteringMode()); - clone.setEdgesThickness(getEdgesThickness()); - clone.setEnabledStabilization(isEnabledStabilization()); - clone.setLambda(getLambda()); - clone.setLight(getLight()); - clone.setShadowCompareMode(getShadowCompareMode()); - clone.setShadowIntensity(getShadowIntensity()); - clone.setShadowZExtend(getShadowZExtend()); - clone.setShadowZFadeLength(getShadowZFadeLength()); - return clone; - } -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/AppOverrideKeys_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/AppOverrideKeys_t.java deleted file mode 100644 index f88400e2bd..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/AppOverrideKeys_t.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1485
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class AppOverrideKeys_t extends Structure { - /** - * const char *
- * C type : char* - */ - public Pointer pchKey; - /** - * const char *
- * C type : char* - */ - public Pointer pchValue; - public AppOverrideKeys_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("pchKey", "pchValue"); - } - /** - * @param pchKey const char *
- * C type : char*
- * @param pchValue const char *
- * C type : char* - */ - public AppOverrideKeys_t(Pointer pchKey, Pointer pchValue) { - super(); - this.pchKey = pchKey; - this.pchValue = pchValue; - } - public AppOverrideKeys_t(Pointer peer) { - super(peer); - } - public static class ByReference extends AppOverrideKeys_t implements Structure.ByReference { - - }; - public static class ByValue extends AppOverrideKeys_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/COpenVRContext.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/COpenVRContext.java deleted file mode 100644 index 5c3d4fc08e..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/COpenVRContext.java +++ /dev/null @@ -1,110 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import com.sun.jna.ptr.IntByReference; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1670
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class COpenVRContext extends Structure { - /** - * class vr::IVRSystem *
- * C type : intptr_t - */ - public IntByReference m_pVRSystem; - /** - * class vr::IVRChaperone *
- * C type : intptr_t - */ - public IntByReference m_pVRChaperone; - /** - * class vr::IVRChaperoneSetup *
- * C type : intptr_t - */ - public IntByReference m_pVRChaperoneSetup; - /** - * class vr::IVRCompositor *
- * C type : intptr_t - */ - public IntByReference m_pVRCompositor; - /** - * class vr::IVROverlay *
- * C type : intptr_t - */ - public IntByReference m_pVROverlay; - /** - * class vr::IVRResources *
- * C type : intptr_t - */ - public IntByReference m_pVRResources; - /** - * class vr::IVRRenderModels *
- * C type : intptr_t - */ - public IntByReference m_pVRRenderModels; - /** - * class vr::IVRExtendedDisplay *
- * C type : intptr_t - */ - public IntByReference m_pVRExtendedDisplay; - /** - * class vr::IVRSettings *
- * C type : intptr_t - */ - public IntByReference m_pVRSettings; - /** - * class vr::IVRApplications *
- * C type : intptr_t - */ - public IntByReference m_pVRApplications; - /** - * class vr::IVRTrackedCamera *
- * C type : intptr_t - */ - public IntByReference m_pVRTrackedCamera; - /** - * class vr::IVRScreenshots *
- * C type : intptr_t - */ - public IntByReference m_pVRScreenshots; - /** - * class vr::IVRDriverManager *
- * C type : intptr_t - */ - public IntByReference m_pVRDriverManager; - /** - * class vr::IVRInput *
- * C type : intptr_t - */ - public IntByReference m_pVRInput; - /** - * class vr::IVRIOBuffer *
- * C type : intptr_t - */ - public IntByReference m_pVRIOBuffer; - /** - * class vr::IVRSpatialAnchors *
- * C type : intptr_t - */ - public IntByReference m_pVRSpatialAnchors; - public COpenVRContext() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("m_pVRSystem", "m_pVRChaperone", "m_pVRChaperoneSetup", "m_pVRCompositor", "m_pVROverlay", "m_pVRResources", "m_pVRRenderModels", "m_pVRExtendedDisplay", "m_pVRSettings", "m_pVRApplications", "m_pVRTrackedCamera", "m_pVRScreenshots", "m_pVRDriverManager", "m_pVRInput", "m_pVRIOBuffer", "m_pVRSpatialAnchors"); - } - public COpenVRContext(Pointer peer) { - super(peer); - } - public static class ByReference extends COpenVRContext implements Structure.ByReference { - - }; - public static class ByValue extends COpenVRContext implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/CVRSettingHelper.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/CVRSettingHelper.java deleted file mode 100644 index 5be90516cb..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/CVRSettingHelper.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import com.sun.jna.ptr.IntByReference; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1592
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class CVRSettingHelper extends Structure { - /** - * class vr::IVRSettings *
- * C type : intptr_t - */ - public IntByReference m_pSettings; - public CVRSettingHelper() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("m_pSettings"); - } - /** - * @param m_pSettings class vr::IVRSettings *
- * C type : intptr_t - */ - public CVRSettingHelper(IntByReference m_pSettings) { - super(); - this.m_pSettings = m_pSettings; - } - public CVRSettingHelper(Pointer peer) { - super(peer); - } - public static class ByReference extends CVRSettingHelper implements Structure.ByReference { - - }; - public static class ByValue extends CVRSettingHelper implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/CameraVideoStreamFrameHeader_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/CameraVideoStreamFrameHeader_t.java deleted file mode 100644 index ebbc398bd6..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/CameraVideoStreamFrameHeader_t.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1466
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class CameraVideoStreamFrameHeader_t extends Structure { - /** - * C type : EVRTrackedCameraFrameType - */ - public int eFrameType; - public int nWidth; - public int nHeight; - public int nBytesPerPixel; - public int nFrameSequence; - /** C type : TrackedDevicePose_t */ - public TrackedDevicePose_t standingTrackedDevicePose; - public CameraVideoStreamFrameHeader_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("eFrameType", "nWidth", "nHeight", "nBytesPerPixel", "nFrameSequence", "standingTrackedDevicePose"); - } - /** - * @param eFrameType @see JOpenVRLibrary.EVRTrackedCameraFrameType
- * C type : EVRTrackedCameraFrameType
- * @param standingTrackedDevicePose C type : TrackedDevicePose_t - */ - public CameraVideoStreamFrameHeader_t(int eFrameType, int nWidth, int nHeight, int nBytesPerPixel, int nFrameSequence, TrackedDevicePose_t standingTrackedDevicePose) { - super(); - this.eFrameType = eFrameType; - this.nWidth = nWidth; - this.nHeight = nHeight; - this.nBytesPerPixel = nBytesPerPixel; - this.nFrameSequence = nFrameSequence; - this.standingTrackedDevicePose = standingTrackedDevicePose; - } - public CameraVideoStreamFrameHeader_t(Pointer peer) { - super(peer); - } - public static class ByReference extends CameraVideoStreamFrameHeader_t implements Structure.ByReference { - - }; - public static class ByValue extends CameraVideoStreamFrameHeader_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/Compositor_CumulativeStats.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/Compositor_CumulativeStats.java deleted file mode 100644 index 3b426b7b8f..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/Compositor_CumulativeStats.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1528
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class Compositor_CumulativeStats extends Structure { - public int m_nPid; - public int m_nNumFramePresents; - public int m_nNumDroppedFrames; - public int m_nNumReprojectedFrames; - public int m_nNumFramePresentsOnStartup; - public int m_nNumDroppedFramesOnStartup; - public int m_nNumReprojectedFramesOnStartup; - public int m_nNumLoading; - public int m_nNumFramePresentsLoading; - public int m_nNumDroppedFramesLoading; - public int m_nNumReprojectedFramesLoading; - public int m_nNumTimedOut; - public int m_nNumFramePresentsTimedOut; - public int m_nNumDroppedFramesTimedOut; - public int m_nNumReprojectedFramesTimedOut; - public Compositor_CumulativeStats() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("m_nPid", "m_nNumFramePresents", "m_nNumDroppedFrames", "m_nNumReprojectedFrames", "m_nNumFramePresentsOnStartup", "m_nNumDroppedFramesOnStartup", "m_nNumReprojectedFramesOnStartup", "m_nNumLoading", "m_nNumFramePresentsLoading", "m_nNumDroppedFramesLoading", "m_nNumReprojectedFramesLoading", "m_nNumTimedOut", "m_nNumFramePresentsTimedOut", "m_nNumDroppedFramesTimedOut", "m_nNumReprojectedFramesTimedOut"); - } - public Compositor_CumulativeStats(Pointer peer) { - super(peer); - } - public static class ByReference extends Compositor_CumulativeStats implements Structure.ByReference { - - }; - public static class ByValue extends Compositor_CumulativeStats implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/Compositor_FrameTiming.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/Compositor_FrameTiming.java deleted file mode 100644 index ede38a055b..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/Compositor_FrameTiming.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1511
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class Compositor_FrameTiming extends Structure { - public int m_nSize; - public int m_nFrameIndex; - public int m_nNumFramePresents; - public int m_nNumMisPresented; - public int m_nNumDroppedFrames; - public int m_nReprojectionFlags; - public double m_flSystemTimeInSeconds; - public float m_flPreSubmitGpuMs; - public float m_flPostSubmitGpuMs; - public float m_flTotalRenderGpuMs; - public float m_flCompositorRenderGpuMs; - public float m_flCompositorRenderCpuMs; - public float m_flCompositorIdleCpuMs; - public float m_flClientFrameIntervalMs; - public float m_flPresentCallCpuMs; - public float m_flWaitForPresentCpuMs; - public float m_flSubmitFrameMs; - public float m_flWaitGetPosesCalledMs; - public float m_flNewPosesReadyMs; - public float m_flNewFrameReadyMs; - public float m_flCompositorUpdateStartMs; - public float m_flCompositorUpdateEndMs; - public float m_flCompositorRenderStartMs; - /** C type : TrackedDevicePose_t */ - public TrackedDevicePose_t m_HmdPose; - public Compositor_FrameTiming() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("m_nSize", "m_nFrameIndex", "m_nNumFramePresents", "m_nNumMisPresented", "m_nNumDroppedFrames", "m_nReprojectionFlags", "m_flSystemTimeInSeconds", "m_flPreSubmitGpuMs", "m_flPostSubmitGpuMs", "m_flTotalRenderGpuMs", "m_flCompositorRenderGpuMs", "m_flCompositorRenderCpuMs", "m_flCompositorIdleCpuMs", "m_flClientFrameIntervalMs", "m_flPresentCallCpuMs", "m_flWaitForPresentCpuMs", "m_flSubmitFrameMs", "m_flWaitGetPosesCalledMs", "m_flNewPosesReadyMs", "m_flNewFrameReadyMs", "m_flCompositorUpdateStartMs", "m_flCompositorUpdateEndMs", "m_flCompositorRenderStartMs", "m_HmdPose"); - } - public Compositor_FrameTiming(Pointer peer) { - super(peer); - } - public static class ByReference extends Compositor_FrameTiming implements Structure.ByReference { - - }; - public static class ByValue extends Compositor_FrameTiming implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/Compositor_OverlaySettings.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/Compositor_OverlaySettings.java deleted file mode 100644 index 3afba14f1d..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/Compositor_OverlaySettings.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1452
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class Compositor_OverlaySettings extends Structure { - public int size; - public byte curved; - public byte antialias; - public float scale; - public float distance; - public float alpha; - public float uOffset; - public float vOffset; - public float uScale; - public float vScale; - public float gridDivs; - public float gridWidth; - public float gridScale; - /** C type : HmdMatrix44_t */ - public HmdMatrix44_t transform; - public Compositor_OverlaySettings() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("size", "curved", "antialias", "scale", "distance", "alpha", "uOffset", "vOffset", "uScale", "vScale", "gridDivs", "gridWidth", "gridScale", "transform"); - } - public Compositor_OverlaySettings(Pointer peer) { - super(peer); - } - public static class ByReference extends Compositor_OverlaySettings implements Structure.ByReference { - - }; - public static class ByValue extends Compositor_OverlaySettings implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/D3D12TextureData_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/D3D12TextureData_t.java deleted file mode 100644 index c902ad237a..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/D3D12TextureData_t.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.jme3.system.jopenvr; -import com.jme3.system.jopenvr.JOpenVRLibrary.ID3D12CommandQueue; -import com.jme3.system.jopenvr.JOpenVRLibrary.ID3D12Resource; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1301
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class D3D12TextureData_t extends Structure { - /** - * struct ID3D12Resource *
- * C type : ID3D12Resource* - */ - public ID3D12Resource m_pResource; - /** - * struct ID3D12CommandQueue *
- * C type : ID3D12CommandQueue* - */ - public ID3D12CommandQueue m_pCommandQueue; - public int m_nNodeMask; - public D3D12TextureData_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("m_pResource", "m_pCommandQueue", "m_nNodeMask"); - } - /** - * @param m_pResource struct ID3D12Resource *
- * C type : ID3D12Resource*
- * @param m_pCommandQueue struct ID3D12CommandQueue *
- * C type : ID3D12CommandQueue* - */ - public D3D12TextureData_t(ID3D12Resource m_pResource, ID3D12CommandQueue m_pCommandQueue, int m_nNodeMask) { - super(); - this.m_pResource = m_pResource; - this.m_pCommandQueue = m_pCommandQueue; - this.m_nNodeMask = m_nNodeMask; - } - public D3D12TextureData_t(Pointer peer) { - super(peer); - } - public static class ByReference extends D3D12TextureData_t implements Structure.ByReference { - - }; - public static class ByValue extends D3D12TextureData_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/DistortionCoordinates_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/DistortionCoordinates_t.java deleted file mode 100644 index 59e0ab3dd1..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/DistortionCoordinates_t.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1237
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class DistortionCoordinates_t extends Structure { - /** - * float[2]
- * C type : float[2] - */ - public float[] rfRed = new float[2]; - /** - * float[2]
- * C type : float[2] - */ - public float[] rfGreen = new float[2]; - /** - * float[2]
- * C type : float[2] - */ - public float[] rfBlue = new float[2]; - public DistortionCoordinates_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("rfRed", "rfGreen", "rfBlue"); - } - /** - * @param rfRed float[2]
- * C type : float[2]
- * @param rfGreen float[2]
- * C type : float[2]
- * @param rfBlue float[2]
- * C type : float[2] - */ - public DistortionCoordinates_t(float rfRed[], float rfGreen[], float rfBlue[]) { - super(); - if ((rfRed.length != this.rfRed.length)) - throw new IllegalArgumentException("Wrong array size !"); - this.rfRed = rfRed; - if ((rfGreen.length != this.rfGreen.length)) - throw new IllegalArgumentException("Wrong array size !"); - this.rfGreen = rfGreen; - if ((rfBlue.length != this.rfBlue.length)) - throw new IllegalArgumentException("Wrong array size !"); - this.rfBlue = rfBlue; - } - public DistortionCoordinates_t(Pointer peer) { - super(peer); - } - public static class ByReference extends DistortionCoordinates_t implements Structure.ByReference { - - }; - public static class ByValue extends DistortionCoordinates_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/DriverDirectMode_FrameTiming.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/DriverDirectMode_FrameTiming.java deleted file mode 100644 index 4b89bc4746..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/DriverDirectMode_FrameTiming.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1473
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class DriverDirectMode_FrameTiming extends Structure { - public int m_nSize; - public int m_nNumFramePresents; - public int m_nNumMisPresented; - public int m_nNumDroppedFrames; - public int m_nReprojectionFlags; - public DriverDirectMode_FrameTiming() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("m_nSize", "m_nNumFramePresents", "m_nNumMisPresented", "m_nNumDroppedFrames", "m_nReprojectionFlags"); - } - public DriverDirectMode_FrameTiming(int m_nSize, int m_nNumFramePresents, int m_nNumMisPresented, int m_nNumDroppedFrames, int m_nReprojectionFlags) { - super(); - this.m_nSize = m_nSize; - this.m_nNumFramePresents = m_nNumFramePresents; - this.m_nNumMisPresented = m_nNumMisPresented; - this.m_nNumDroppedFrames = m_nNumDroppedFrames; - this.m_nReprojectionFlags = m_nReprojectionFlags; - } - public DriverDirectMode_FrameTiming(Pointer peer) { - super(peer); - } - public static class ByReference extends DriverDirectMode_FrameTiming implements Structure.ByReference { - - }; - public static class ByValue extends DriverDirectMode_FrameTiming implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/HiddenAreaMesh_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/HiddenAreaMesh_t.java deleted file mode 100644 index 2844685d11..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/HiddenAreaMesh_t.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1425
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class HiddenAreaMesh_t extends Structure { - /** - * const struct vr::HmdVector2_t *
- * C type : HmdVector2_t* - */ - public com.jme3.system.jopenvr.HmdVector2_t.ByReference pVertexData; - public int unTriangleCount; - public HiddenAreaMesh_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("pVertexData", "unTriangleCount"); - } - /** - * @param pVertexData const struct vr::HmdVector2_t *
- * C type : HmdVector2_t* - */ - public HiddenAreaMesh_t(com.jme3.system.jopenvr.HmdVector2_t.ByReference pVertexData, int unTriangleCount) { - super(); - this.pVertexData = pVertexData; - this.unTriangleCount = unTriangleCount; - } - public HiddenAreaMesh_t(Pointer peer) { - super(peer); - } - public static class ByReference extends HiddenAreaMesh_t implements Structure.ByReference { - - }; - public static class ByValue extends HiddenAreaMesh_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdColor_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdColor_t.java deleted file mode 100644 index 6387f1f0f7..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdColor_t.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1221
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class HmdColor_t extends Structure { - public float r; - public float g; - public float b; - public float a; - public HmdColor_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("r", "g", "b", "a"); - } - public HmdColor_t(float r, float g, float b, float a) { - super(); - this.r = r; - this.g = g; - this.b = b; - this.a = a; - } - public HmdColor_t(Pointer peer) { - super(peer); - } - public static class ByReference extends HmdColor_t implements Structure.ByReference { - - }; - public static class ByValue extends HmdColor_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdMatrix33_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdMatrix33_t.java deleted file mode 100644 index 25e7f8d670..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdMatrix33_t.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1183
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class HmdMatrix33_t extends Structure { - /** - * float[3][3]
- * C type : float[3][3] - */ - public float[] m = new float[((3) * (3))]; - public HmdMatrix33_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("m"); - } - /** - * @param m float[3][3]
- * C type : float[3][3] - */ - public HmdMatrix33_t(float m[]) { - super(); - if ((m.length != this.m.length)) - throw new IllegalArgumentException("Wrong array size !"); - this.m = m; - } - public HmdMatrix33_t(Pointer peer) { - super(peer); - } - public static class ByReference extends HmdMatrix33_t implements Structure.ByReference { - - }; - public static class ByValue extends HmdMatrix33_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdMatrix34_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdMatrix34_t.java deleted file mode 100644 index 175bc07f75..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdMatrix34_t.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1179
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class HmdMatrix34_t extends Structure { - /** - * float[3][4]
- * C type : float[3][4] - */ - public float[] m = new float[((3) * (4))]; - public HmdMatrix34_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("m"); - } - /** - * @param m float[3][4]
- * C type : float[3][4] - */ - public HmdMatrix34_t(float m[]) { - super(); - if ((m.length != this.m.length)) - throw new IllegalArgumentException("Wrong array size !"); - this.m = m; - } - public HmdMatrix34_t(Pointer peer) { - super(peer); - } - public static class ByReference extends HmdMatrix34_t implements Structure.ByReference { - - }; - public static class ByValue extends HmdMatrix34_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdMatrix44_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdMatrix44_t.java deleted file mode 100644 index 2243e8f5fa..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdMatrix44_t.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1187
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class HmdMatrix44_t extends Structure { - /** - * float[4][4]
- * C type : float[4][4] - */ - public float[] m = new float[((4) * (4))]; - public HmdMatrix44_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("m"); - } - /** - * @param m float[4][4]
- * C type : float[4][4] - */ - public HmdMatrix44_t(float m[]) { - super(); - if ((m.length != this.m.length)) - throw new IllegalArgumentException("Wrong array size !"); - this.m = m; - } - public HmdMatrix44_t(Pointer peer) { - super(peer); - } - public static class ByReference extends HmdMatrix44_t implements Structure.ByReference { - - }; - public static class ByValue extends HmdMatrix44_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdQuad_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdQuad_t.java deleted file mode 100644 index 28abf8f754..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdQuad_t.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1225
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class HmdQuad_t extends Structure { - /** - * struct vr::HmdVector3_t[4]
- * C type : HmdVector3_t[4] - */ - public HmdVector3_t[] vCorners = new HmdVector3_t[4]; - public HmdQuad_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("vCorners"); - } - /** - * @param vCorners struct vr::HmdVector3_t[4]
- * C type : HmdVector3_t[4] - */ - public HmdQuad_t(HmdVector3_t vCorners[]) { - super(); - if ((vCorners.length != this.vCorners.length)) - throw new IllegalArgumentException("Wrong array size !"); - this.vCorners = vCorners; - } - public HmdQuad_t(Pointer peer) { - super(peer); - } - public static class ByReference extends HmdQuad_t implements Structure.ByReference { - - }; - public static class ByValue extends HmdQuad_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdQuaternion_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdQuaternion_t.java deleted file mode 100644 index d26c2acfef..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdQuaternion_t.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1209
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class HmdQuaternion_t extends Structure { - public double w; - public double x; - public double y; - public double z; - public HmdQuaternion_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("w", "x", "y", "z"); - } - public HmdQuaternion_t(double w, double x, double y, double z) { - super(); - this.w = w; - this.x = x; - this.y = y; - this.z = z; - } - public HmdQuaternion_t(Pointer peer) { - super(peer); - } - public static class ByReference extends HmdQuaternion_t implements Structure.ByReference { - - }; - public static class ByValue extends HmdQuaternion_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdQuaternionf_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdQuaternionf_t.java deleted file mode 100644 index b24d5c071d..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdQuaternionf_t.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1215
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class HmdQuaternionf_t extends Structure { - public float w; - public float x; - public float y; - public float z; - public HmdQuaternionf_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("w", "x", "y", "z"); - } - public HmdQuaternionf_t(float w, float x, float y, float z) { - super(); - this.w = w; - this.x = x; - this.y = y; - this.z = z; - } - public HmdQuaternionf_t(Pointer peer) { - super(peer); - } - public static class ByReference extends HmdQuaternionf_t implements Structure.ByReference { - - }; - public static class ByValue extends HmdQuaternionf_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdRect2_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdRect2_t.java deleted file mode 100644 index a8c25431db..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdRect2_t.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1229
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class HmdRect2_t extends Structure { - /** C type : HmdVector2_t */ - public HmdVector2_t vTopLeft; - /** C type : HmdVector2_t */ - public HmdVector2_t vBottomRight; - public HmdRect2_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("vTopLeft", "vBottomRight"); - } - /** - * @param vTopLeft C type : HmdVector2_t
- * @param vBottomRight C type : HmdVector2_t - */ - public HmdRect2_t(HmdVector2_t vTopLeft, HmdVector2_t vBottomRight) { - super(); - this.vTopLeft = vTopLeft; - this.vBottomRight = vBottomRight; - } - public HmdRect2_t(Pointer peer) { - super(peer); - } - public static class ByReference extends HmdRect2_t implements Structure.ByReference { - - }; - public static class ByValue extends HmdRect2_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdVector2_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdVector2_t.java deleted file mode 100644 index f66240574d..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdVector2_t.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1203
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class HmdVector2_t extends Structure { - /** - * float[2]
- * C type : float[2] - */ - public float[] v = new float[2]; - public HmdVector2_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("v"); - } - /** - * @param v float[2]
- * C type : float[2] - */ - public HmdVector2_t(float v[]) { - super(); - if ((v.length != this.v.length)) - throw new IllegalArgumentException("Wrong array size !"); - this.v = v; - } - public HmdVector2_t(Pointer peer) { - super(peer); - } - public static class ByReference extends HmdVector2_t implements Structure.ByReference { - - }; - public static class ByValue extends HmdVector2_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdVector3_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdVector3_t.java deleted file mode 100644 index 92ad299605..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdVector3_t.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1191
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class HmdVector3_t extends Structure { - /** - * float[3]
- * C type : float[3] - */ - public float[] v = new float[3]; - public HmdVector3_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("v"); - } - /** - * @param v float[3]
- * C type : float[3] - */ - public HmdVector3_t(float v[]) { - super(); - if ((v.length != this.v.length)) - throw new IllegalArgumentException("Wrong array size !"); - this.v = v; - } - public HmdVector3_t(Pointer peer) { - super(peer); - } - public static class ByReference extends HmdVector3_t implements Structure.ByReference { - - }; - public static class ByValue extends HmdVector3_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdVector3d_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdVector3d_t.java deleted file mode 100644 index 7bde50647c..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdVector3d_t.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1199
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class HmdVector3d_t extends Structure { - /** - * double[3]
- * C type : double[3] - */ - public double[] v = new double[3]; - public HmdVector3d_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("v"); - } - /** - * @param v double[3]
- * C type : double[3] - */ - public HmdVector3d_t(double v[]) { - super(); - if ((v.length != this.v.length)) - throw new IllegalArgumentException("Wrong array size !"); - this.v = v; - } - public HmdVector3d_t(Pointer peer) { - super(peer); - } - public static class ByReference extends HmdVector3d_t implements Structure.ByReference { - - }; - public static class ByValue extends HmdVector3d_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdVector4_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdVector4_t.java deleted file mode 100644 index 1db01177cf..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/HmdVector4_t.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1195
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class HmdVector4_t extends Structure { - /** - * float[4]
- * C type : float[4] - */ - public float[] v = new float[4]; - public HmdVector4_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("v"); - } - /** - * @param v float[4]
- * C type : float[4] - */ - public HmdVector4_t(float v[]) { - super(); - if ((v.length != this.v.length)) - throw new IllegalArgumentException("Wrong array size !"); - this.v = v; - } - public HmdVector4_t(Pointer peer) { - super(peer); - } - public static class ByReference extends HmdVector4_t implements Structure.ByReference { - - }; - public static class ByValue extends HmdVector4_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/ImuSample_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/ImuSample_t.java deleted file mode 100644 index 1cadc4b7f2..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/ImuSample_t.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1479
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class ImuSample_t extends Structure { - public double fSampleTime; - /** C type : HmdVector3d_t */ - public HmdVector3d_t vAccel; - /** C type : HmdVector3d_t */ - public HmdVector3d_t vGyro; - public int unOffScaleFlags; - public ImuSample_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("fSampleTime", "vAccel", "vGyro", "unOffScaleFlags"); - } - /** - * @param vAccel C type : HmdVector3d_t
- * @param vGyro C type : HmdVector3d_t - */ - public ImuSample_t(double fSampleTime, HmdVector3d_t vAccel, HmdVector3d_t vGyro, int unOffScaleFlags) { - super(); - this.fSampleTime = fSampleTime; - this.vAccel = vAccel; - this.vGyro = vGyro; - this.unOffScaleFlags = unOffScaleFlags; - } - public ImuSample_t(Pointer peer) { - super(peer); - } - public static class ByReference extends ImuSample_t implements Structure.ByReference { - - }; - public static class ByValue extends ImuSample_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/InputAnalogActionData_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/InputAnalogActionData_t.java deleted file mode 100644 index 7f7a2a6922..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/InputAnalogActionData_t.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1603
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class InputAnalogActionData_t extends Structure { - public byte bActive; - /** C type : VRInputValueHandle_t */ - public long activeOrigin; - public float x; - public float y; - public float z; - public float deltaX; - public float deltaY; - public float deltaZ; - public float fUpdateTime; - public InputAnalogActionData_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("bActive", "activeOrigin", "x", "y", "z", "deltaX", "deltaY", "deltaZ", "fUpdateTime"); - } - /** @param activeOrigin C type : VRInputValueHandle_t */ - public InputAnalogActionData_t(byte bActive, long activeOrigin, float x, float y, float z, float deltaX, float deltaY, float deltaZ, float fUpdateTime) { - super(); - this.bActive = bActive; - this.activeOrigin = activeOrigin; - this.x = x; - this.y = y; - this.z = z; - this.deltaX = deltaX; - this.deltaY = deltaY; - this.deltaZ = deltaZ; - this.fUpdateTime = fUpdateTime; - } - public InputAnalogActionData_t(Pointer peer) { - super(peer); - } - public static class ByReference extends InputAnalogActionData_t implements Structure.ByReference { - - }; - public static class ByValue extends InputAnalogActionData_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/InputDigitalActionData_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/InputDigitalActionData_t.java deleted file mode 100644 index 3b212e44af..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/InputDigitalActionData_t.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1610
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class InputDigitalActionData_t extends Structure { - public byte bActive; - /** C type : VRInputValueHandle_t */ - public long activeOrigin; - public byte bState; - public byte bChanged; - public float fUpdateTime; - public InputDigitalActionData_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("bActive", "activeOrigin", "bState", "bChanged", "fUpdateTime"); - } - /** @param activeOrigin C type : VRInputValueHandle_t */ - public InputDigitalActionData_t(byte bActive, long activeOrigin, byte bState, byte bChanged, float fUpdateTime) { - super(); - this.bActive = bActive; - this.activeOrigin = activeOrigin; - this.bState = bState; - this.bChanged = bChanged; - this.fUpdateTime = fUpdateTime; - } - public InputDigitalActionData_t(Pointer peer) { - super(peer); - } - public static class ByReference extends InputDigitalActionData_t implements Structure.ByReference { - - }; - public static class ByValue extends InputDigitalActionData_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/InputOriginInfo_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/InputOriginInfo_t.java deleted file mode 100644 index eff72867ae..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/InputOriginInfo_t.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1626
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class InputOriginInfo_t extends Structure { - /** C type : VRInputValueHandle_t */ - public long devicePath; - /** C type : TrackedDeviceIndex_t */ - public int trackedDeviceIndex; - /** - * char[128]
- * C type : char*[128] - */ - public Pointer[] rchRenderModelComponentName = new Pointer[128]; - public InputOriginInfo_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("devicePath", "trackedDeviceIndex", "rchRenderModelComponentName"); - } - /** - * @param devicePath C type : VRInputValueHandle_t
- * @param trackedDeviceIndex C type : TrackedDeviceIndex_t
- * @param rchRenderModelComponentName char[128]
- * C type : char*[128] - */ - public InputOriginInfo_t(long devicePath, int trackedDeviceIndex, Pointer rchRenderModelComponentName[]) { - super(); - this.devicePath = devicePath; - this.trackedDeviceIndex = trackedDeviceIndex; - if ((rchRenderModelComponentName.length != this.rchRenderModelComponentName.length)) - throw new IllegalArgumentException("Wrong array size !"); - this.rchRenderModelComponentName = rchRenderModelComponentName; - } - public InputOriginInfo_t(Pointer peer) { - super(peer); - } - public static class ByReference extends InputOriginInfo_t implements Structure.ByReference { - - }; - public static class ByValue extends InputOriginInfo_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/InputPoseActionData_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/InputPoseActionData_t.java deleted file mode 100644 index bc375f1a57..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/InputPoseActionData_t.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1615
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class InputPoseActionData_t extends Structure { - public byte bActive; - /** C type : VRInputValueHandle_t */ - public long activeOrigin; - /** C type : TrackedDevicePose_t */ - public TrackedDevicePose_t pose; - public InputPoseActionData_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("bActive", "activeOrigin", "pose"); - } - /** - * @param activeOrigin C type : VRInputValueHandle_t
- * @param pose C type : TrackedDevicePose_t - */ - public InputPoseActionData_t(byte bActive, long activeOrigin, TrackedDevicePose_t pose) { - super(); - this.bActive = bActive; - this.activeOrigin = activeOrigin; - this.pose = pose; - } - public InputPoseActionData_t(Pointer peer) { - super(peer); - } - public static class ByReference extends InputPoseActionData_t implements Structure.ByReference { - - }; - public static class ByValue extends InputPoseActionData_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/InputSkeletalActionData_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/InputSkeletalActionData_t.java deleted file mode 100644 index 8d1f26514b..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/InputSkeletalActionData_t.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1620
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class InputSkeletalActionData_t extends Structure { - public byte bActive; - /** C type : VRInputValueHandle_t */ - public long activeOrigin; - public int boneCount; - public InputSkeletalActionData_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("bActive", "activeOrigin", "boneCount"); - } - /** @param activeOrigin C type : VRInputValueHandle_t */ - public InputSkeletalActionData_t(byte bActive, long activeOrigin, int boneCount) { - super(); - this.bActive = bActive; - this.activeOrigin = activeOrigin; - this.boneCount = boneCount; - } - public InputSkeletalActionData_t(Pointer peer) { - super(peer); - } - public static class ByReference extends InputSkeletalActionData_t implements Structure.ByReference { - - }; - public static class ByValue extends InputSkeletalActionData_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/IntersectionMaskCircle_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/IntersectionMaskCircle_t.java deleted file mode 100644 index 8c994f84ba..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/IntersectionMaskCircle_t.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1552
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class IntersectionMaskCircle_t extends Structure { - public float m_flCenterX; - public float m_flCenterY; - public float m_flRadius; - public IntersectionMaskCircle_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("m_flCenterX", "m_flCenterY", "m_flRadius"); - } - public IntersectionMaskCircle_t(float m_flCenterX, float m_flCenterY, float m_flRadius) { - super(); - this.m_flCenterX = m_flCenterX; - this.m_flCenterY = m_flCenterY; - this.m_flRadius = m_flRadius; - } - public IntersectionMaskCircle_t(Pointer peer) { - super(peer); - } - public static class ByReference extends IntersectionMaskCircle_t implements Structure.ByReference { - - }; - public static class ByValue extends IntersectionMaskCircle_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/IntersectionMaskRectangle_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/IntersectionMaskRectangle_t.java deleted file mode 100644 index e33a836db9..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/IntersectionMaskRectangle_t.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1547
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class IntersectionMaskRectangle_t extends Structure { - public float m_flTopLeftX; - public float m_flTopLeftY; - public float m_flWidth; - public float m_flHeight; - public IntersectionMaskRectangle_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("m_flTopLeftX", "m_flTopLeftY", "m_flWidth", "m_flHeight"); - } - public IntersectionMaskRectangle_t(float m_flTopLeftX, float m_flTopLeftY, float m_flWidth, float m_flHeight) { - super(); - this.m_flTopLeftX = m_flTopLeftX; - this.m_flTopLeftY = m_flTopLeftY; - this.m_flWidth = m_flWidth; - this.m_flHeight = m_flHeight; - } - public IntersectionMaskRectangle_t(Pointer peer) { - super(peer); - } - public static class ByReference extends IntersectionMaskRectangle_t implements Structure.ByReference { - - }; - public static class ByValue extends IntersectionMaskRectangle_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/JOpenVRLibrary.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/JOpenVRLibrary.java deleted file mode 100644 index 4a00707fed..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/JOpenVRLibrary.java +++ /dev/null @@ -1,2332 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Library; -import com.sun.jna.Native; -import com.sun.jna.NativeLibrary; -import com.sun.jna.Pointer; -import com.sun.jna.PointerType; -import com.sun.jna.ptr.IntByReference; - -import java.nio.IntBuffer; -import java.util.logging.Logger; -/** - * JNA Wrapper for library JOpenVR
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class JOpenVRLibrary implements Library { - private static final Logger logger = Logger.getLogger(JOpenVRLibrary.class.getName()); - - private static String JNA_LIBRARY_NAME; - private static NativeLibrary JNA_NATIVE_LIB; - - /** - * The system property that specifies an implementation of OpenVR (openvr_api file) to use. - * This property has to be set at the program launch using -D connector. - * If this property is not set, the embedded library is loaded. - */ - public static final String JNA_OPENVR_LIBRARY_PATH = "openvr.library.path"; - - /** - * Init the native binding to the underlying system library. - */ - public static void init() throws UnsatisfiedLinkError { - Native.unregister(JOpenVRLibrary.class); - - String path = System.getProperty(JNA_OPENVR_LIBRARY_PATH); - if (path != null){ - - JNA_LIBRARY_NAME = path; - - logger.config("Using OpenVR implementation located at "+JNA_LIBRARY_NAME); - - JNA_NATIVE_LIB = NativeLibrary.getInstance(JOpenVRLibrary.JNA_LIBRARY_NAME); - Native.register(JOpenVRLibrary.class, JOpenVRLibrary.JNA_NATIVE_LIB); - } else { - - JNA_LIBRARY_NAME = "openvr_api"; - - logger.config("Using embedded OpenVR implementation "+JOpenVRLibrary.JNA_LIBRARY_NAME); - - JNA_NATIVE_LIB = NativeLibrary.getInstance(JOpenVRLibrary.JNA_LIBRARY_NAME); - Native.register(JOpenVRLibrary.class, JOpenVRLibrary.JNA_NATIVE_LIB); - } - } - - /** - * Get the name of the underlying system library. - * @return the name of the underlying system library. - */ - public static String getSystemLibraryName(){ - return ""+JNA_LIBRARY_NAME; - } - - - /** - * native declaration : headers\openvr_capi.h:229
- * enum values - */ - public static interface EVREye { - /** native declaration : headers\openvr_capi.h:227 */ - public static final int EVREye_Eye_Left = 0; - /** native declaration : headers\openvr_capi.h:228 */ - public static final int EVREye_Eye_Right = 1; - }; - /** - * native declaration : headers\openvr_capi.h:239
- * enum values - */ - public static interface ETextureType { - /** native declaration : headers\openvr_capi.h:231 */ - public static final int ETextureType_TextureType_Invalid = -1; - /** native declaration : headers\openvr_capi.h:232 */ - public static final int ETextureType_TextureType_DirectX = 0; - /** native declaration : headers\openvr_capi.h:233 */ - public static final int ETextureType_TextureType_OpenGL = 1; - /** native declaration : headers\openvr_capi.h:234 */ - public static final int ETextureType_TextureType_Vulkan = 2; - /** native declaration : headers\openvr_capi.h:235 */ - public static final int ETextureType_TextureType_IOSurface = 3; - /** native declaration : headers\openvr_capi.h:236 */ - public static final int ETextureType_TextureType_DirectX12 = 4; - /** native declaration : headers\openvr_capi.h:237 */ - public static final int ETextureType_TextureType_DXGISharedHandle = 5; - /** native declaration : headers\openvr_capi.h:238 */ - public static final int ETextureType_TextureType_Metal = 6; - }; - /** - * native declaration : headers\openvr_capi.h:244
- * enum values - */ - public static interface EColorSpace { - /** native declaration : headers\openvr_capi.h:241 */ - public static final int EColorSpace_ColorSpace_Auto = 0; - /** native declaration : headers\openvr_capi.h:242 */ - public static final int EColorSpace_ColorSpace_Gamma = 1; - /** native declaration : headers\openvr_capi.h:243 */ - public static final int EColorSpace_ColorSpace_Linear = 2; - }; - /** - * native declaration : headers\openvr_capi.h:251
- * enum values - */ - public static interface ETrackingResult { - /** native declaration : headers\openvr_capi.h:246 */ - public static final int ETrackingResult_TrackingResult_Uninitialized = 1; - /** native declaration : headers\openvr_capi.h:247 */ - public static final int ETrackingResult_TrackingResult_Calibrating_InProgress = 100; - /** native declaration : headers\openvr_capi.h:248 */ - public static final int ETrackingResult_TrackingResult_Calibrating_OutOfRange = 101; - /** native declaration : headers\openvr_capi.h:249 */ - public static final int ETrackingResult_TrackingResult_Running_OK = 200; - /** native declaration : headers\openvr_capi.h:250 */ - public static final int ETrackingResult_TrackingResult_Running_OutOfRange = 201; - }; - /** - * native declaration : headers\openvr_capi.h:260
- * enum values - */ - public static interface ETrackedDeviceClass { - /** native declaration : headers\openvr_capi.h:253 */ - public static final int ETrackedDeviceClass_TrackedDeviceClass_Invalid = 0; - /** native declaration : headers\openvr_capi.h:254 */ - public static final int ETrackedDeviceClass_TrackedDeviceClass_HMD = 1; - /** native declaration : headers\openvr_capi.h:255 */ - public static final int ETrackedDeviceClass_TrackedDeviceClass_Controller = 2; - /** native declaration : headers\openvr_capi.h:256 */ - public static final int ETrackedDeviceClass_TrackedDeviceClass_GenericTracker = 3; - /** native declaration : headers\openvr_capi.h:257 */ - public static final int ETrackedDeviceClass_TrackedDeviceClass_TrackingReference = 4; - /** native declaration : headers\openvr_capi.h:258 */ - public static final int ETrackedDeviceClass_TrackedDeviceClass_DisplayRedirect = 5; - /** native declaration : headers\openvr_capi.h:259 */ - public static final int ETrackedDeviceClass_TrackedDeviceClass_Max = 6; - }; - /** - * native declaration : headers\openvr_capi.h:267
- * enum values - */ - public static interface ETrackedControllerRole { - /** native declaration : headers\openvr_capi.h:262 */ - public static final int ETrackedControllerRole_TrackedControllerRole_Invalid = 0; - /** native declaration : headers\openvr_capi.h:263 */ - public static final int ETrackedControllerRole_TrackedControllerRole_LeftHand = 1; - /** native declaration : headers\openvr_capi.h:264 */ - public static final int ETrackedControllerRole_TrackedControllerRole_RightHand = 2; - /** native declaration : headers\openvr_capi.h:265 */ - public static final int ETrackedControllerRole_TrackedControllerRole_OptOut = 3; - /** native declaration : headers\openvr_capi.h:266 */ - public static final int ETrackedControllerRole_TrackedControllerRole_Max = 4; - }; - /** - * native declaration : headers\openvr_capi.h:272
- * enum values - */ - public static interface ETrackingUniverseOrigin { - /** native declaration : headers\openvr_capi.h:269 */ - public static final int ETrackingUniverseOrigin_TrackingUniverseSeated = 0; - /** native declaration : headers\openvr_capi.h:270 */ - public static final int ETrackingUniverseOrigin_TrackingUniverseStanding = 1; - /** native declaration : headers\openvr_capi.h:271 */ - public static final int ETrackingUniverseOrigin_TrackingUniverseRawAndUncalibrated = 2; - }; - /** - * native declaration : headers\openvr_capi.h:432
- * enum values - */ - public static interface ETrackedDeviceProperty { - /** native declaration : headers\openvr_capi.h:274 */ - public static final int ETrackedDeviceProperty_Prop_Invalid = 0; - /** native declaration : headers\openvr_capi.h:275 */ - public static final int ETrackedDeviceProperty_Prop_TrackingSystemName_String = 1000; - /** native declaration : headers\openvr_capi.h:276 */ - public static final int ETrackedDeviceProperty_Prop_ModelNumber_String = 1001; - /** native declaration : headers\openvr_capi.h:277 */ - public static final int ETrackedDeviceProperty_Prop_SerialNumber_String = 1002; - /** native declaration : headers\openvr_capi.h:278 */ - public static final int ETrackedDeviceProperty_Prop_RenderModelName_String = 1003; - /** native declaration : headers\openvr_capi.h:279 */ - public static final int ETrackedDeviceProperty_Prop_WillDriftInYaw_Bool = 1004; - /** native declaration : headers\openvr_capi.h:280 */ - public static final int ETrackedDeviceProperty_Prop_ManufacturerName_String = 1005; - /** native declaration : headers\openvr_capi.h:281 */ - public static final int ETrackedDeviceProperty_Prop_TrackingFirmwareVersion_String = 1006; - /** native declaration : headers\openvr_capi.h:282 */ - public static final int ETrackedDeviceProperty_Prop_HardwareRevision_String = 1007; - /** native declaration : headers\openvr_capi.h:283 */ - public static final int ETrackedDeviceProperty_Prop_AllWirelessDongleDescriptions_String = 1008; - /** native declaration : headers\openvr_capi.h:284 */ - public static final int ETrackedDeviceProperty_Prop_ConnectedWirelessDongle_String = 1009; - /** native declaration : headers\openvr_capi.h:285 */ - public static final int ETrackedDeviceProperty_Prop_DeviceIsWireless_Bool = 1010; - /** native declaration : headers\openvr_capi.h:286 */ - public static final int ETrackedDeviceProperty_Prop_DeviceIsCharging_Bool = 1011; - /** native declaration : headers\openvr_capi.h:287 */ - public static final int ETrackedDeviceProperty_Prop_DeviceBatteryPercentage_Float = 1012; - /** native declaration : headers\openvr_capi.h:288 */ - public static final int ETrackedDeviceProperty_Prop_StatusDisplayTransform_Matrix34 = 1013; - /** native declaration : headers\openvr_capi.h:289 */ - public static final int ETrackedDeviceProperty_Prop_Firmware_UpdateAvailable_Bool = 1014; - /** native declaration : headers\openvr_capi.h:290 */ - public static final int ETrackedDeviceProperty_Prop_Firmware_ManualUpdate_Bool = 1015; - /** native declaration : headers\openvr_capi.h:291 */ - public static final int ETrackedDeviceProperty_Prop_Firmware_ManualUpdateURL_String = 1016; - /** native declaration : headers\openvr_capi.h:292 */ - public static final int ETrackedDeviceProperty_Prop_HardwareRevision_Uint64 = 1017; - /** native declaration : headers\openvr_capi.h:293 */ - public static final int ETrackedDeviceProperty_Prop_FirmwareVersion_Uint64 = 1018; - /** native declaration : headers\openvr_capi.h:294 */ - public static final int ETrackedDeviceProperty_Prop_FPGAVersion_Uint64 = 1019; - /** native declaration : headers\openvr_capi.h:295 */ - public static final int ETrackedDeviceProperty_Prop_VRCVersion_Uint64 = 1020; - /** native declaration : headers\openvr_capi.h:296 */ - public static final int ETrackedDeviceProperty_Prop_RadioVersion_Uint64 = 1021; - /** native declaration : headers\openvr_capi.h:297 */ - public static final int ETrackedDeviceProperty_Prop_DongleVersion_Uint64 = 1022; - /** native declaration : headers\openvr_capi.h:298 */ - public static final int ETrackedDeviceProperty_Prop_BlockServerShutdown_Bool = 1023; - /** native declaration : headers\openvr_capi.h:299 */ - public static final int ETrackedDeviceProperty_Prop_CanUnifyCoordinateSystemWithHmd_Bool = 1024; - /** native declaration : headers\openvr_capi.h:300 */ - public static final int ETrackedDeviceProperty_Prop_ContainsProximitySensor_Bool = 1025; - /** native declaration : headers\openvr_capi.h:301 */ - public static final int ETrackedDeviceProperty_Prop_DeviceProvidesBatteryStatus_Bool = 1026; - /** native declaration : headers\openvr_capi.h:302 */ - public static final int ETrackedDeviceProperty_Prop_DeviceCanPowerOff_Bool = 1027; - /** native declaration : headers\openvr_capi.h:303 */ - public static final int ETrackedDeviceProperty_Prop_Firmware_ProgrammingTarget_String = 1028; - /** native declaration : headers\openvr_capi.h:304 */ - public static final int ETrackedDeviceProperty_Prop_DeviceClass_Int32 = 1029; - /** native declaration : headers\openvr_capi.h:305 */ - public static final int ETrackedDeviceProperty_Prop_HasCamera_Bool = 1030; - /** native declaration : headers\openvr_capi.h:306 */ - public static final int ETrackedDeviceProperty_Prop_DriverVersion_String = 1031; - /** native declaration : headers\openvr_capi.h:307 */ - public static final int ETrackedDeviceProperty_Prop_Firmware_ForceUpdateRequired_Bool = 1032; - /** native declaration : headers\openvr_capi.h:308 */ - public static final int ETrackedDeviceProperty_Prop_ViveSystemButtonFixRequired_Bool = 1033; - /** native declaration : headers\openvr_capi.h:309 */ - public static final int ETrackedDeviceProperty_Prop_ParentDriver_Uint64 = 1034; - /** native declaration : headers\openvr_capi.h:310 */ - public static final int ETrackedDeviceProperty_Prop_ResourceRoot_String = 1035; - /** native declaration : headers\openvr_capi.h:311 */ - public static final int ETrackedDeviceProperty_Prop_RegisteredDeviceType_String = 1036; - /** native declaration : headers\openvr_capi.h:312 */ - public static final int ETrackedDeviceProperty_Prop_InputProfilePath_String = 1037; - /** native declaration : headers\openvr_capi.h:313 */ - public static final int ETrackedDeviceProperty_Prop_NeverTracked_Bool = 1038; - /** native declaration : headers\openvr_capi.h:314 */ - public static final int ETrackedDeviceProperty_Prop_NumCameras_Int32 = 1039; - /** native declaration : headers\openvr_capi.h:315 */ - public static final int ETrackedDeviceProperty_Prop_CameraFrameLayout_Int32 = 1040; - /** native declaration : headers\openvr_capi.h:316 */ - public static final int ETrackedDeviceProperty_Prop_ReportsTimeSinceVSync_Bool = 2000; - /** native declaration : headers\openvr_capi.h:317 */ - public static final int ETrackedDeviceProperty_Prop_SecondsFromVsyncToPhotons_Float = 2001; - /** native declaration : headers\openvr_capi.h:318 */ - public static final int ETrackedDeviceProperty_Prop_DisplayFrequency_Float = 2002; - /** native declaration : headers\openvr_capi.h:319 */ - public static final int ETrackedDeviceProperty_Prop_UserIpdMeters_Float = 2003; - /** native declaration : headers\openvr_capi.h:320 */ - public static final int ETrackedDeviceProperty_Prop_CurrentUniverseId_Uint64 = 2004; - /** native declaration : headers\openvr_capi.h:321 */ - public static final int ETrackedDeviceProperty_Prop_PreviousUniverseId_Uint64 = 2005; - /** native declaration : headers\openvr_capi.h:322 */ - public static final int ETrackedDeviceProperty_Prop_DisplayFirmwareVersion_Uint64 = 2006; - /** native declaration : headers\openvr_capi.h:323 */ - public static final int ETrackedDeviceProperty_Prop_IsOnDesktop_Bool = 2007; - /** native declaration : headers\openvr_capi.h:324 */ - public static final int ETrackedDeviceProperty_Prop_DisplayMCType_Int32 = 2008; - /** native declaration : headers\openvr_capi.h:325 */ - public static final int ETrackedDeviceProperty_Prop_DisplayMCOffset_Float = 2009; - /** native declaration : headers\openvr_capi.h:326 */ - public static final int ETrackedDeviceProperty_Prop_DisplayMCScale_Float = 2010; - /** native declaration : headers\openvr_capi.h:327 */ - public static final int ETrackedDeviceProperty_Prop_EdidVendorID_Int32 = 2011; - /** native declaration : headers\openvr_capi.h:328 */ - public static final int ETrackedDeviceProperty_Prop_DisplayMCImageLeft_String = 2012; - /** native declaration : headers\openvr_capi.h:329 */ - public static final int ETrackedDeviceProperty_Prop_DisplayMCImageRight_String = 2013; - /** native declaration : headers\openvr_capi.h:330 */ - public static final int ETrackedDeviceProperty_Prop_DisplayGCBlackClamp_Float = 2014; - /** native declaration : headers\openvr_capi.h:331 */ - public static final int ETrackedDeviceProperty_Prop_EdidProductID_Int32 = 2015; - /** native declaration : headers\openvr_capi.h:332 */ - public static final int ETrackedDeviceProperty_Prop_CameraToHeadTransform_Matrix34 = 2016; - /** native declaration : headers\openvr_capi.h:333 */ - public static final int ETrackedDeviceProperty_Prop_DisplayGCType_Int32 = 2017; - /** native declaration : headers\openvr_capi.h:334 */ - public static final int ETrackedDeviceProperty_Prop_DisplayGCOffset_Float = 2018; - /** native declaration : headers\openvr_capi.h:335 */ - public static final int ETrackedDeviceProperty_Prop_DisplayGCScale_Float = 2019; - /** native declaration : headers\openvr_capi.h:336 */ - public static final int ETrackedDeviceProperty_Prop_DisplayGCPrescale_Float = 2020; - /** native declaration : headers\openvr_capi.h:337 */ - public static final int ETrackedDeviceProperty_Prop_DisplayGCImage_String = 2021; - /** native declaration : headers\openvr_capi.h:338 */ - public static final int ETrackedDeviceProperty_Prop_LensCenterLeftU_Float = 2022; - /** native declaration : headers\openvr_capi.h:339 */ - public static final int ETrackedDeviceProperty_Prop_LensCenterLeftV_Float = 2023; - /** native declaration : headers\openvr_capi.h:340 */ - public static final int ETrackedDeviceProperty_Prop_LensCenterRightU_Float = 2024; - /** native declaration : headers\openvr_capi.h:341 */ - public static final int ETrackedDeviceProperty_Prop_LensCenterRightV_Float = 2025; - /** native declaration : headers\openvr_capi.h:342 */ - public static final int ETrackedDeviceProperty_Prop_UserHeadToEyeDepthMeters_Float = 2026; - /** native declaration : headers\openvr_capi.h:343 */ - public static final int ETrackedDeviceProperty_Prop_CameraFirmwareVersion_Uint64 = 2027; - /** native declaration : headers\openvr_capi.h:344 */ - public static final int ETrackedDeviceProperty_Prop_CameraFirmwareDescription_String = 2028; - /** native declaration : headers\openvr_capi.h:345 */ - public static final int ETrackedDeviceProperty_Prop_DisplayFPGAVersion_Uint64 = 2029; - /** native declaration : headers\openvr_capi.h:346 */ - public static final int ETrackedDeviceProperty_Prop_DisplayBootloaderVersion_Uint64 = 2030; - /** native declaration : headers\openvr_capi.h:347 */ - public static final int ETrackedDeviceProperty_Prop_DisplayHardwareVersion_Uint64 = 2031; - /** native declaration : headers\openvr_capi.h:348 */ - public static final int ETrackedDeviceProperty_Prop_AudioFirmwareVersion_Uint64 = 2032; - /** native declaration : headers\openvr_capi.h:349 */ - public static final int ETrackedDeviceProperty_Prop_CameraCompatibilityMode_Int32 = 2033; - /** native declaration : headers\openvr_capi.h:350 */ - public static final int ETrackedDeviceProperty_Prop_ScreenshotHorizontalFieldOfViewDegrees_Float = 2034; - /** native declaration : headers\openvr_capi.h:351 */ - public static final int ETrackedDeviceProperty_Prop_ScreenshotVerticalFieldOfViewDegrees_Float = 2035; - /** native declaration : headers\openvr_capi.h:352 */ - public static final int ETrackedDeviceProperty_Prop_DisplaySuppressed_Bool = 2036; - /** native declaration : headers\openvr_capi.h:353 */ - public static final int ETrackedDeviceProperty_Prop_DisplayAllowNightMode_Bool = 2037; - /** native declaration : headers\openvr_capi.h:354 */ - public static final int ETrackedDeviceProperty_Prop_DisplayMCImageWidth_Int32 = 2038; - /** native declaration : headers\openvr_capi.h:355 */ - public static final int ETrackedDeviceProperty_Prop_DisplayMCImageHeight_Int32 = 2039; - /** native declaration : headers\openvr_capi.h:356 */ - public static final int ETrackedDeviceProperty_Prop_DisplayMCImageNumChannels_Int32 = 2040; - /** native declaration : headers\openvr_capi.h:357 */ - public static final int ETrackedDeviceProperty_Prop_DisplayMCImageData_Binary = 2041; - /** native declaration : headers\openvr_capi.h:358 */ - public static final int ETrackedDeviceProperty_Prop_SecondsFromPhotonsToVblank_Float = 2042; - /** native declaration : headers\openvr_capi.h:359 */ - public static final int ETrackedDeviceProperty_Prop_DriverDirectModeSendsVsyncEvents_Bool = 2043; - /** native declaration : headers\openvr_capi.h:360 */ - public static final int ETrackedDeviceProperty_Prop_DisplayDebugMode_Bool = 2044; - /** native declaration : headers\openvr_capi.h:361 */ - public static final int ETrackedDeviceProperty_Prop_GraphicsAdapterLuid_Uint64 = 2045; - /** native declaration : headers\openvr_capi.h:362 */ - public static final int ETrackedDeviceProperty_Prop_DriverProvidedChaperonePath_String = 2048; - /** native declaration : headers\openvr_capi.h:363 */ - public static final int ETrackedDeviceProperty_Prop_ExpectedTrackingReferenceCount_Int32 = 2049; - /** native declaration : headers\openvr_capi.h:364 */ - public static final int ETrackedDeviceProperty_Prop_ExpectedControllerCount_Int32 = 2050; - /** native declaration : headers\openvr_capi.h:365 */ - public static final int ETrackedDeviceProperty_Prop_NamedIconPathControllerLeftDeviceOff_String = 2051; - /** native declaration : headers\openvr_capi.h:366 */ - public static final int ETrackedDeviceProperty_Prop_NamedIconPathControllerRightDeviceOff_String = 2052; - /** native declaration : headers\openvr_capi.h:367 */ - public static final int ETrackedDeviceProperty_Prop_NamedIconPathTrackingReferenceDeviceOff_String = 2053; - /** native declaration : headers\openvr_capi.h:368 */ - public static final int ETrackedDeviceProperty_Prop_DoNotApplyPrediction_Bool = 2054; - /** native declaration : headers\openvr_capi.h:369 */ - public static final int ETrackedDeviceProperty_Prop_CameraToHeadTransforms_Matrix34_Array = 2055; - /** native declaration : headers\openvr_capi.h:370 */ - public static final int ETrackedDeviceProperty_Prop_DistortionMeshResolution_Int32 = 2056; - /** native declaration : headers\openvr_capi.h:371 */ - public static final int ETrackedDeviceProperty_Prop_DriverIsDrawingControllers_Bool = 2057; - /** native declaration : headers\openvr_capi.h:372 */ - public static final int ETrackedDeviceProperty_Prop_DriverRequestsApplicationPause_Bool = 2058; - /** native declaration : headers\openvr_capi.h:373 */ - public static final int ETrackedDeviceProperty_Prop_DriverRequestsReducedRendering_Bool = 2059; - /** native declaration : headers\openvr_capi.h:374 */ - public static final int ETrackedDeviceProperty_Prop_MinimumIpdStepMeters_Float = 2060; - /** native declaration : headers\openvr_capi.h:375 */ - public static final int ETrackedDeviceProperty_Prop_AudioBridgeFirmwareVersion_Uint64 = 2061; - /** native declaration : headers\openvr_capi.h:376 */ - public static final int ETrackedDeviceProperty_Prop_ImageBridgeFirmwareVersion_Uint64 = 2062; - /** native declaration : headers\openvr_capi.h:377 */ - public static final int ETrackedDeviceProperty_Prop_ImuToHeadTransform_Matrix34 = 2063; - /** native declaration : headers\openvr_capi.h:378 */ - public static final int ETrackedDeviceProperty_Prop_ImuFactoryGyroBias_Vector3 = 2064; - /** native declaration : headers\openvr_capi.h:379 */ - public static final int ETrackedDeviceProperty_Prop_ImuFactoryGyroScale_Vector3 = 2065; - /** native declaration : headers\openvr_capi.h:380 */ - public static final int ETrackedDeviceProperty_Prop_ImuFactoryAccelerometerBias_Vector3 = 2066; - /** native declaration : headers\openvr_capi.h:381 */ - public static final int ETrackedDeviceProperty_Prop_ImuFactoryAccelerometerScale_Vector3 = 2067; - /** native declaration : headers\openvr_capi.h:382 */ - public static final int ETrackedDeviceProperty_Prop_ConfigurationIncludesLighthouse20Features_Bool = 2069; - /** native declaration : headers\openvr_capi.h:383 */ - public static final int ETrackedDeviceProperty_Prop_DriverRequestedMuraCorrectionMode_Int32 = 2200; - /** native declaration : headers\openvr_capi.h:384 */ - public static final int ETrackedDeviceProperty_Prop_DriverRequestedMuraFeather_InnerLeft_Int32 = 2201; - /** native declaration : headers\openvr_capi.h:385 */ - public static final int ETrackedDeviceProperty_Prop_DriverRequestedMuraFeather_InnerRight_Int32 = 2202; - /** native declaration : headers\openvr_capi.h:386 */ - public static final int ETrackedDeviceProperty_Prop_DriverRequestedMuraFeather_InnerTop_Int32 = 2203; - /** native declaration : headers\openvr_capi.h:387 */ - public static final int ETrackedDeviceProperty_Prop_DriverRequestedMuraFeather_InnerBottom_Int32 = 2204; - /** native declaration : headers\openvr_capi.h:388 */ - public static final int ETrackedDeviceProperty_Prop_DriverRequestedMuraFeather_OuterLeft_Int32 = 2205; - /** native declaration : headers\openvr_capi.h:389 */ - public static final int ETrackedDeviceProperty_Prop_DriverRequestedMuraFeather_OuterRight_Int32 = 2206; - /** native declaration : headers\openvr_capi.h:390 */ - public static final int ETrackedDeviceProperty_Prop_DriverRequestedMuraFeather_OuterTop_Int32 = 2207; - /** native declaration : headers\openvr_capi.h:391 */ - public static final int ETrackedDeviceProperty_Prop_DriverRequestedMuraFeather_OuterBottom_Int32 = 2208; - /** native declaration : headers\openvr_capi.h:392 */ - public static final int ETrackedDeviceProperty_Prop_AttachedDeviceId_String = 3000; - /** native declaration : headers\openvr_capi.h:393 */ - public static final int ETrackedDeviceProperty_Prop_SupportedButtons_Uint64 = 3001; - /** native declaration : headers\openvr_capi.h:394 */ - public static final int ETrackedDeviceProperty_Prop_Axis0Type_Int32 = 3002; - /** native declaration : headers\openvr_capi.h:395 */ - public static final int ETrackedDeviceProperty_Prop_Axis1Type_Int32 = 3003; - /** native declaration : headers\openvr_capi.h:396 */ - public static final int ETrackedDeviceProperty_Prop_Axis2Type_Int32 = 3004; - /** native declaration : headers\openvr_capi.h:397 */ - public static final int ETrackedDeviceProperty_Prop_Axis3Type_Int32 = 3005; - /** native declaration : headers\openvr_capi.h:398 */ - public static final int ETrackedDeviceProperty_Prop_Axis4Type_Int32 = 3006; - /** native declaration : headers\openvr_capi.h:399 */ - public static final int ETrackedDeviceProperty_Prop_ControllerRoleHint_Int32 = 3007; - /** native declaration : headers\openvr_capi.h:400 */ - public static final int ETrackedDeviceProperty_Prop_FieldOfViewLeftDegrees_Float = 4000; - /** native declaration : headers\openvr_capi.h:401 */ - public static final int ETrackedDeviceProperty_Prop_FieldOfViewRightDegrees_Float = 4001; - /** native declaration : headers\openvr_capi.h:402 */ - public static final int ETrackedDeviceProperty_Prop_FieldOfViewTopDegrees_Float = 4002; - /** native declaration : headers\openvr_capi.h:403 */ - public static final int ETrackedDeviceProperty_Prop_FieldOfViewBottomDegrees_Float = 4003; - /** native declaration : headers\openvr_capi.h:404 */ - public static final int ETrackedDeviceProperty_Prop_TrackingRangeMinimumMeters_Float = 4004; - /** native declaration : headers\openvr_capi.h:405 */ - public static final int ETrackedDeviceProperty_Prop_TrackingRangeMaximumMeters_Float = 4005; - /** native declaration : headers\openvr_capi.h:406 */ - public static final int ETrackedDeviceProperty_Prop_ModeLabel_String = 4006; - /** native declaration : headers\openvr_capi.h:407 */ - public static final int ETrackedDeviceProperty_Prop_IconPathName_String = 5000; - /** native declaration : headers\openvr_capi.h:408 */ - public static final int ETrackedDeviceProperty_Prop_NamedIconPathDeviceOff_String = 5001; - /** native declaration : headers\openvr_capi.h:409 */ - public static final int ETrackedDeviceProperty_Prop_NamedIconPathDeviceSearching_String = 5002; - /** native declaration : headers\openvr_capi.h:410 */ - public static final int ETrackedDeviceProperty_Prop_NamedIconPathDeviceSearchingAlert_String = 5003; - /** native declaration : headers\openvr_capi.h:411 */ - public static final int ETrackedDeviceProperty_Prop_NamedIconPathDeviceReady_String = 5004; - /** native declaration : headers\openvr_capi.h:412 */ - public static final int ETrackedDeviceProperty_Prop_NamedIconPathDeviceReadyAlert_String = 5005; - /** native declaration : headers\openvr_capi.h:413 */ - public static final int ETrackedDeviceProperty_Prop_NamedIconPathDeviceNotReady_String = 5006; - /** native declaration : headers\openvr_capi.h:414 */ - public static final int ETrackedDeviceProperty_Prop_NamedIconPathDeviceStandby_String = 5007; - /** native declaration : headers\openvr_capi.h:415 */ - public static final int ETrackedDeviceProperty_Prop_NamedIconPathDeviceAlertLow_String = 5008; - /** native declaration : headers\openvr_capi.h:416 */ - public static final int ETrackedDeviceProperty_Prop_DisplayHiddenArea_Binary_Start = 5100; - /** native declaration : headers\openvr_capi.h:417 */ - public static final int ETrackedDeviceProperty_Prop_DisplayHiddenArea_Binary_End = 5150; - /** native declaration : headers\openvr_capi.h:418 */ - public static final int ETrackedDeviceProperty_Prop_ParentContainer = 5151; - /** native declaration : headers\openvr_capi.h:419 */ - public static final int ETrackedDeviceProperty_Prop_UserConfigPath_String = 6000; - /** native declaration : headers\openvr_capi.h:420 */ - public static final int ETrackedDeviceProperty_Prop_InstallPath_String = 6001; - /** native declaration : headers\openvr_capi.h:421 */ - public static final int ETrackedDeviceProperty_Prop_HasDisplayComponent_Bool = 6002; - /** native declaration : headers\openvr_capi.h:422 */ - public static final int ETrackedDeviceProperty_Prop_HasControllerComponent_Bool = 6003; - /** native declaration : headers\openvr_capi.h:423 */ - public static final int ETrackedDeviceProperty_Prop_HasCameraComponent_Bool = 6004; - /** native declaration : headers\openvr_capi.h:424 */ - public static final int ETrackedDeviceProperty_Prop_HasDriverDirectModeComponent_Bool = 6005; - /** native declaration : headers\openvr_capi.h:425 */ - public static final int ETrackedDeviceProperty_Prop_HasVirtualDisplayComponent_Bool = 6006; - /** native declaration : headers\openvr_capi.h:426 */ - public static final int ETrackedDeviceProperty_Prop_HasSpatialAnchorsSupport_Bool = 6007; - /** native declaration : headers\openvr_capi.h:427 */ - public static final int ETrackedDeviceProperty_Prop_ControllerType_String = 7000; - /** native declaration : headers\openvr_capi.h:428 */ - public static final int ETrackedDeviceProperty_Prop_LegacyInputProfile_String = 7001; - /** native declaration : headers\openvr_capi.h:429 */ - public static final int ETrackedDeviceProperty_Prop_VendorSpecific_Reserved_Start = 10000; - /** native declaration : headers\openvr_capi.h:430 */ - public static final int ETrackedDeviceProperty_Prop_VendorSpecific_Reserved_End = 10999; - /** native declaration : headers\openvr_capi.h:431 */ - public static final int ETrackedDeviceProperty_Prop_TrackedDeviceProperty_Max = 1000000; - }; - /** - * native declaration : headers\openvr_capi.h:447
- * enum values - */ - public static interface ETrackedPropertyError { - /** native declaration : headers\openvr_capi.h:434 */ - public static final int ETrackedPropertyError_TrackedProp_Success = 0; - /** native declaration : headers\openvr_capi.h:435 */ - public static final int ETrackedPropertyError_TrackedProp_WrongDataType = 1; - /** native declaration : headers\openvr_capi.h:436 */ - public static final int ETrackedPropertyError_TrackedProp_WrongDeviceClass = 2; - /** native declaration : headers\openvr_capi.h:437 */ - public static final int ETrackedPropertyError_TrackedProp_BufferTooSmall = 3; - /** native declaration : headers\openvr_capi.h:438 */ - public static final int ETrackedPropertyError_TrackedProp_UnknownProperty = 4; - /** native declaration : headers\openvr_capi.h:439 */ - public static final int ETrackedPropertyError_TrackedProp_InvalidDevice = 5; - /** native declaration : headers\openvr_capi.h:440 */ - public static final int ETrackedPropertyError_TrackedProp_CouldNotContactServer = 6; - /** native declaration : headers\openvr_capi.h:441 */ - public static final int ETrackedPropertyError_TrackedProp_ValueNotProvidedByDevice = 7; - /** native declaration : headers\openvr_capi.h:442 */ - public static final int ETrackedPropertyError_TrackedProp_StringExceedsMaximumLength = 8; - /** native declaration : headers\openvr_capi.h:443 */ - public static final int ETrackedPropertyError_TrackedProp_NotYetAvailable = 9; - /** native declaration : headers\openvr_capi.h:444 */ - public static final int ETrackedPropertyError_TrackedProp_PermissionDenied = 10; - /** native declaration : headers\openvr_capi.h:445 */ - public static final int ETrackedPropertyError_TrackedProp_InvalidOperation = 11; - /** native declaration : headers\openvr_capi.h:446 */ - public static final int ETrackedPropertyError_TrackedProp_CannotWriteToWildcards = 12; - }; - /** - * native declaration : headers\openvr_capi.h:455
- * enum values - */ - public static interface EVRSubmitFlags { - /** native declaration : headers\openvr_capi.h:449 */ - public static final int EVRSubmitFlags_Submit_Default = 0; - /** native declaration : headers\openvr_capi.h:450 */ - public static final int EVRSubmitFlags_Submit_LensDistortionAlreadyApplied = 1; - /** native declaration : headers\openvr_capi.h:451 */ - public static final int EVRSubmitFlags_Submit_GlRenderBuffer = 2; - /** native declaration : headers\openvr_capi.h:452 */ - public static final int EVRSubmitFlags_Submit_Reserved = 4; - /** native declaration : headers\openvr_capi.h:453 */ - public static final int EVRSubmitFlags_Submit_TextureWithPose = 8; - /** native declaration : headers\openvr_capi.h:454 */ - public static final int EVRSubmitFlags_Submit_TextureWithDepth = 16; - }; - /** - * native declaration : headers\openvr_capi.h:466
- * enum values - */ - public static interface EVRState { - /** native declaration : headers\openvr_capi.h:457 */ - public static final int EVRState_VRState_Undefined = -1; - /** native declaration : headers\openvr_capi.h:458 */ - public static final int EVRState_VRState_Off = 0; - /** native declaration : headers\openvr_capi.h:459 */ - public static final int EVRState_VRState_Searching = 1; - /** native declaration : headers\openvr_capi.h:460 */ - public static final int EVRState_VRState_Searching_Alert = 2; - /** native declaration : headers\openvr_capi.h:461 */ - public static final int EVRState_VRState_Ready = 3; - /** native declaration : headers\openvr_capi.h:462 */ - public static final int EVRState_VRState_Ready_Alert = 4; - /** native declaration : headers\openvr_capi.h:463 */ - public static final int EVRState_VRState_NotReady = 5; - /** native declaration : headers\openvr_capi.h:464 */ - public static final int EVRState_VRState_Standby = 6; - /** native declaration : headers\openvr_capi.h:465 */ - public static final int EVRState_VRState_Ready_Alert_Low = 7; - }; - /** - * native declaration : headers\openvr_capi.h:616
- * enum values - */ - public static interface EVREventType { - /** native declaration : headers\openvr_capi.h:468 */ - public static final int EVREventType_VREvent_None = 0; - /** native declaration : headers\openvr_capi.h:469 */ - public static final int EVREventType_VREvent_TrackedDeviceActivated = 100; - /** native declaration : headers\openvr_capi.h:470 */ - public static final int EVREventType_VREvent_TrackedDeviceDeactivated = 101; - /** native declaration : headers\openvr_capi.h:471 */ - public static final int EVREventType_VREvent_TrackedDeviceUpdated = 102; - /** native declaration : headers\openvr_capi.h:472 */ - public static final int EVREventType_VREvent_TrackedDeviceUserInteractionStarted = 103; - /** native declaration : headers\openvr_capi.h:473 */ - public static final int EVREventType_VREvent_TrackedDeviceUserInteractionEnded = 104; - /** native declaration : headers\openvr_capi.h:474 */ - public static final int EVREventType_VREvent_IpdChanged = 105; - /** native declaration : headers\openvr_capi.h:475 */ - public static final int EVREventType_VREvent_EnterStandbyMode = 106; - /** native declaration : headers\openvr_capi.h:476 */ - public static final int EVREventType_VREvent_LeaveStandbyMode = 107; - /** native declaration : headers\openvr_capi.h:477 */ - public static final int EVREventType_VREvent_TrackedDeviceRoleChanged = 108; - /** native declaration : headers\openvr_capi.h:478 */ - public static final int EVREventType_VREvent_WatchdogWakeUpRequested = 109; - /** native declaration : headers\openvr_capi.h:479 */ - public static final int EVREventType_VREvent_LensDistortionChanged = 110; - /** native declaration : headers\openvr_capi.h:480 */ - public static final int EVREventType_VREvent_PropertyChanged = 111; - /** native declaration : headers\openvr_capi.h:481 */ - public static final int EVREventType_VREvent_WirelessDisconnect = 112; - /** native declaration : headers\openvr_capi.h:482 */ - public static final int EVREventType_VREvent_WirelessReconnect = 113; - /** native declaration : headers\openvr_capi.h:483 */ - public static final int EVREventType_VREvent_ButtonPress = 200; - /** native declaration : headers\openvr_capi.h:484 */ - public static final int EVREventType_VREvent_ButtonUnpress = 201; - /** native declaration : headers\openvr_capi.h:485 */ - public static final int EVREventType_VREvent_ButtonTouch = 202; - /** native declaration : headers\openvr_capi.h:486 */ - public static final int EVREventType_VREvent_ButtonUntouch = 203; - /** native declaration : headers\openvr_capi.h:487 */ - public static final int EVREventType_VREvent_DualAnalog_Press = 250; - /** native declaration : headers\openvr_capi.h:488 */ - public static final int EVREventType_VREvent_DualAnalog_Unpress = 251; - /** native declaration : headers\openvr_capi.h:489 */ - public static final int EVREventType_VREvent_DualAnalog_Touch = 252; - /** native declaration : headers\openvr_capi.h:490 */ - public static final int EVREventType_VREvent_DualAnalog_Untouch = 253; - /** native declaration : headers\openvr_capi.h:491 */ - public static final int EVREventType_VREvent_DualAnalog_Move = 254; - /** native declaration : headers\openvr_capi.h:492 */ - public static final int EVREventType_VREvent_DualAnalog_ModeSwitch1 = 255; - /** native declaration : headers\openvr_capi.h:493 */ - public static final int EVREventType_VREvent_DualAnalog_ModeSwitch2 = 256; - /** native declaration : headers\openvr_capi.h:494 */ - public static final int EVREventType_VREvent_DualAnalog_Cancel = 257; - /** native declaration : headers\openvr_capi.h:495 */ - public static final int EVREventType_VREvent_MouseMove = 300; - /** native declaration : headers\openvr_capi.h:496 */ - public static final int EVREventType_VREvent_MouseButtonDown = 301; - /** native declaration : headers\openvr_capi.h:497 */ - public static final int EVREventType_VREvent_MouseButtonUp = 302; - /** native declaration : headers\openvr_capi.h:498 */ - public static final int EVREventType_VREvent_FocusEnter = 303; - /** native declaration : headers\openvr_capi.h:499 */ - public static final int EVREventType_VREvent_FocusLeave = 304; - /** native declaration : headers\openvr_capi.h:500 */ - public static final int EVREventType_VREvent_Scroll = 305; - /** native declaration : headers\openvr_capi.h:501 */ - public static final int EVREventType_VREvent_TouchPadMove = 306; - /** native declaration : headers\openvr_capi.h:502 */ - public static final int EVREventType_VREvent_OverlayFocusChanged = 307; - /** native declaration : headers\openvr_capi.h:503 */ - public static final int EVREventType_VREvent_InputFocusCaptured = 400; - /** native declaration : headers\openvr_capi.h:504 */ - public static final int EVREventType_VREvent_InputFocusReleased = 401; - /** native declaration : headers\openvr_capi.h:505 */ - public static final int EVREventType_VREvent_SceneFocusLost = 402; - /** native declaration : headers\openvr_capi.h:506 */ - public static final int EVREventType_VREvent_SceneFocusGained = 403; - /** native declaration : headers\openvr_capi.h:507 */ - public static final int EVREventType_VREvent_SceneApplicationChanged = 404; - /** native declaration : headers\openvr_capi.h:508 */ - public static final int EVREventType_VREvent_SceneFocusChanged = 405; - /** native declaration : headers\openvr_capi.h:509 */ - public static final int EVREventType_VREvent_InputFocusChanged = 406; - /** native declaration : headers\openvr_capi.h:510 */ - public static final int EVREventType_VREvent_SceneApplicationSecondaryRenderingStarted = 407; - /** native declaration : headers\openvr_capi.h:511 */ - public static final int EVREventType_VREvent_SceneApplicationUsingWrongGraphicsAdapter = 408; - /** native declaration : headers\openvr_capi.h:512 */ - public static final int EVREventType_VREvent_ActionBindingReloaded = 409; - /** native declaration : headers\openvr_capi.h:513 */ - public static final int EVREventType_VREvent_HideRenderModels = 410; - /** native declaration : headers\openvr_capi.h:514 */ - public static final int EVREventType_VREvent_ShowRenderModels = 411; - /** native declaration : headers\openvr_capi.h:515 */ - public static final int EVREventType_VREvent_ConsoleOpened = 420; - /** native declaration : headers\openvr_capi.h:516 */ - public static final int EVREventType_VREvent_ConsoleClosed = 421; - /** native declaration : headers\openvr_capi.h:517 */ - public static final int EVREventType_VREvent_OverlayShown = 500; - /** native declaration : headers\openvr_capi.h:518 */ - public static final int EVREventType_VREvent_OverlayHidden = 501; - /** native declaration : headers\openvr_capi.h:519 */ - public static final int EVREventType_VREvent_DashboardActivated = 502; - /** native declaration : headers\openvr_capi.h:520 */ - public static final int EVREventType_VREvent_DashboardDeactivated = 503; - /** native declaration : headers\openvr_capi.h:521 */ - public static final int EVREventType_VREvent_DashboardThumbSelected = 504; - /** native declaration : headers\openvr_capi.h:522 */ - public static final int EVREventType_VREvent_DashboardRequested = 505; - /** native declaration : headers\openvr_capi.h:523 */ - public static final int EVREventType_VREvent_ResetDashboard = 506; - /** native declaration : headers\openvr_capi.h:524 */ - public static final int EVREventType_VREvent_RenderToast = 507; - /** native declaration : headers\openvr_capi.h:525 */ - public static final int EVREventType_VREvent_ImageLoaded = 508; - /** native declaration : headers\openvr_capi.h:526 */ - public static final int EVREventType_VREvent_ShowKeyboard = 509; - /** native declaration : headers\openvr_capi.h:527 */ - public static final int EVREventType_VREvent_HideKeyboard = 510; - /** native declaration : headers\openvr_capi.h:528 */ - public static final int EVREventType_VREvent_OverlayGamepadFocusGained = 511; - /** native declaration : headers\openvr_capi.h:529 */ - public static final int EVREventType_VREvent_OverlayGamepadFocusLost = 512; - /** native declaration : headers\openvr_capi.h:530 */ - public static final int EVREventType_VREvent_OverlaySharedTextureChanged = 513; - /** native declaration : headers\openvr_capi.h:531 */ - public static final int EVREventType_VREvent_ScreenshotTriggered = 516; - /** native declaration : headers\openvr_capi.h:532 */ - public static final int EVREventType_VREvent_ImageFailed = 517; - /** native declaration : headers\openvr_capi.h:533 */ - public static final int EVREventType_VREvent_DashboardOverlayCreated = 518; - /** native declaration : headers\openvr_capi.h:534 */ - public static final int EVREventType_VREvent_SwitchGamepadFocus = 519; - /** native declaration : headers\openvr_capi.h:535 */ - public static final int EVREventType_VREvent_RequestScreenshot = 520; - /** native declaration : headers\openvr_capi.h:536 */ - public static final int EVREventType_VREvent_ScreenshotTaken = 521; - /** native declaration : headers\openvr_capi.h:537 */ - public static final int EVREventType_VREvent_ScreenshotFailed = 522; - /** native declaration : headers\openvr_capi.h:538 */ - public static final int EVREventType_VREvent_SubmitScreenshotToDashboard = 523; - /** native declaration : headers\openvr_capi.h:539 */ - public static final int EVREventType_VREvent_ScreenshotProgressToDashboard = 524; - /** native declaration : headers\openvr_capi.h:540 */ - public static final int EVREventType_VREvent_PrimaryDashboardDeviceChanged = 525; - /** native declaration : headers\openvr_capi.h:541 */ - public static final int EVREventType_VREvent_RoomViewShown = 526; - /** native declaration : headers\openvr_capi.h:542 */ - public static final int EVREventType_VREvent_RoomViewHidden = 527; - /** native declaration : headers\openvr_capi.h:543 */ - public static final int EVREventType_VREvent_Notification_Shown = 600; - /** native declaration : headers\openvr_capi.h:544 */ - public static final int EVREventType_VREvent_Notification_Hidden = 601; - /** native declaration : headers\openvr_capi.h:545 */ - public static final int EVREventType_VREvent_Notification_BeginInteraction = 602; - /** native declaration : headers\openvr_capi.h:546 */ - public static final int EVREventType_VREvent_Notification_Destroyed = 603; - /** native declaration : headers\openvr_capi.h:547 */ - public static final int EVREventType_VREvent_Quit = 700; - /** native declaration : headers\openvr_capi.h:548 */ - public static final int EVREventType_VREvent_ProcessQuit = 701; - /** native declaration : headers\openvr_capi.h:549 */ - public static final int EVREventType_VREvent_QuitAborted_UserPrompt = 702; - /** native declaration : headers\openvr_capi.h:550 */ - public static final int EVREventType_VREvent_QuitAcknowledged = 703; - /** native declaration : headers\openvr_capi.h:551 */ - public static final int EVREventType_VREvent_DriverRequestedQuit = 704; - /** native declaration : headers\openvr_capi.h:552 */ - public static final int EVREventType_VREvent_ChaperoneDataHasChanged = 800; - /** native declaration : headers\openvr_capi.h:553 */ - public static final int EVREventType_VREvent_ChaperoneUniverseHasChanged = 801; - /** native declaration : headers\openvr_capi.h:554 */ - public static final int EVREventType_VREvent_ChaperoneTempDataHasChanged = 802; - /** native declaration : headers\openvr_capi.h:555 */ - public static final int EVREventType_VREvent_ChaperoneSettingsHaveChanged = 803; - /** native declaration : headers\openvr_capi.h:556 */ - public static final int EVREventType_VREvent_SeatedZeroPoseReset = 804; - /** native declaration : headers\openvr_capi.h:557 */ - public static final int EVREventType_VREvent_AudioSettingsHaveChanged = 820; - /** native declaration : headers\openvr_capi.h:558 */ - public static final int EVREventType_VREvent_BackgroundSettingHasChanged = 850; - /** native declaration : headers\openvr_capi.h:559 */ - public static final int EVREventType_VREvent_CameraSettingsHaveChanged = 851; - /** native declaration : headers\openvr_capi.h:560 */ - public static final int EVREventType_VREvent_ReprojectionSettingHasChanged = 852; - /** native declaration : headers\openvr_capi.h:561 */ - public static final int EVREventType_VREvent_ModelSkinSettingsHaveChanged = 853; - /** native declaration : headers\openvr_capi.h:562 */ - public static final int EVREventType_VREvent_EnvironmentSettingsHaveChanged = 854; - /** native declaration : headers\openvr_capi.h:563 */ - public static final int EVREventType_VREvent_PowerSettingsHaveChanged = 855; - /** native declaration : headers\openvr_capi.h:564 */ - public static final int EVREventType_VREvent_EnableHomeAppSettingsHaveChanged = 856; - /** native declaration : headers\openvr_capi.h:565 */ - public static final int EVREventType_VREvent_SteamVRSectionSettingChanged = 857; - /** native declaration : headers\openvr_capi.h:566 */ - public static final int EVREventType_VREvent_LighthouseSectionSettingChanged = 858; - /** native declaration : headers\openvr_capi.h:567 */ - public static final int EVREventType_VREvent_NullSectionSettingChanged = 859; - /** native declaration : headers\openvr_capi.h:568 */ - public static final int EVREventType_VREvent_UserInterfaceSectionSettingChanged = 860; - /** native declaration : headers\openvr_capi.h:569 */ - public static final int EVREventType_VREvent_NotificationsSectionSettingChanged = 861; - /** native declaration : headers\openvr_capi.h:570 */ - public static final int EVREventType_VREvent_KeyboardSectionSettingChanged = 862; - /** native declaration : headers\openvr_capi.h:571 */ - public static final int EVREventType_VREvent_PerfSectionSettingChanged = 863; - /** native declaration : headers\openvr_capi.h:572 */ - public static final int EVREventType_VREvent_DashboardSectionSettingChanged = 864; - /** native declaration : headers\openvr_capi.h:573 */ - public static final int EVREventType_VREvent_WebInterfaceSectionSettingChanged = 865; - /** native declaration : headers\openvr_capi.h:574 */ - public static final int EVREventType_VREvent_TrackersSectionSettingChanged = 866; - /** native declaration : headers\openvr_capi.h:575 */ - public static final int EVREventType_VREvent_StatusUpdate = 900; - /** native declaration : headers\openvr_capi.h:576 */ - public static final int EVREventType_VREvent_WebInterface_InstallDriverCompleted = 950; - /** native declaration : headers\openvr_capi.h:577 */ - public static final int EVREventType_VREvent_MCImageUpdated = 1000; - /** native declaration : headers\openvr_capi.h:578 */ - public static final int EVREventType_VREvent_FirmwareUpdateStarted = 1100; - /** native declaration : headers\openvr_capi.h:579 */ - public static final int EVREventType_VREvent_FirmwareUpdateFinished = 1101; - /** native declaration : headers\openvr_capi.h:580 */ - public static final int EVREventType_VREvent_KeyboardClosed = 1200; - /** native declaration : headers\openvr_capi.h:581 */ - public static final int EVREventType_VREvent_KeyboardCharInput = 1201; - /** native declaration : headers\openvr_capi.h:582 */ - public static final int EVREventType_VREvent_KeyboardDone = 1202; - /** native declaration : headers\openvr_capi.h:583 */ - public static final int EVREventType_VREvent_ApplicationTransitionStarted = 1300; - /** native declaration : headers\openvr_capi.h:584 */ - public static final int EVREventType_VREvent_ApplicationTransitionAborted = 1301; - /** native declaration : headers\openvr_capi.h:585 */ - public static final int EVREventType_VREvent_ApplicationTransitionNewAppStarted = 1302; - /** native declaration : headers\openvr_capi.h:586 */ - public static final int EVREventType_VREvent_ApplicationListUpdated = 1303; - /** native declaration : headers\openvr_capi.h:587 */ - public static final int EVREventType_VREvent_ApplicationMimeTypeLoad = 1304; - /** native declaration : headers\openvr_capi.h:588 */ - public static final int EVREventType_VREvent_ApplicationTransitionNewAppLaunchComplete = 1305; - /** native declaration : headers\openvr_capi.h:589 */ - public static final int EVREventType_VREvent_ProcessConnected = 1306; - /** native declaration : headers\openvr_capi.h:590 */ - public static final int EVREventType_VREvent_ProcessDisconnected = 1307; - /** native declaration : headers\openvr_capi.h:591 */ - public static final int EVREventType_VREvent_Compositor_MirrorWindowShown = 1400; - /** native declaration : headers\openvr_capi.h:592 */ - public static final int EVREventType_VREvent_Compositor_MirrorWindowHidden = 1401; - /** native declaration : headers\openvr_capi.h:593 */ - public static final int EVREventType_VREvent_Compositor_ChaperoneBoundsShown = 1410; - /** native declaration : headers\openvr_capi.h:594 */ - public static final int EVREventType_VREvent_Compositor_ChaperoneBoundsHidden = 1411; - /** native declaration : headers\openvr_capi.h:595 */ - public static final int EVREventType_VREvent_TrackedCamera_StartVideoStream = 1500; - /** native declaration : headers\openvr_capi.h:596 */ - public static final int EVREventType_VREvent_TrackedCamera_StopVideoStream = 1501; - /** native declaration : headers\openvr_capi.h:597 */ - public static final int EVREventType_VREvent_TrackedCamera_PauseVideoStream = 1502; - /** native declaration : headers\openvr_capi.h:598 */ - public static final int EVREventType_VREvent_TrackedCamera_ResumeVideoStream = 1503; - /** native declaration : headers\openvr_capi.h:599 */ - public static final int EVREventType_VREvent_TrackedCamera_EditingSurface = 1550; - /** native declaration : headers\openvr_capi.h:600 */ - public static final int EVREventType_VREvent_PerformanceTest_EnableCapture = 1600; - /** native declaration : headers\openvr_capi.h:601 */ - public static final int EVREventType_VREvent_PerformanceTest_DisableCapture = 1601; - /** native declaration : headers\openvr_capi.h:602 */ - public static final int EVREventType_VREvent_PerformanceTest_FidelityLevel = 1602; - /** native declaration : headers\openvr_capi.h:603 */ - public static final int EVREventType_VREvent_MessageOverlay_Closed = 1650; - /** native declaration : headers\openvr_capi.h:604 */ - public static final int EVREventType_VREvent_MessageOverlayCloseRequested = 1651; - /** native declaration : headers\openvr_capi.h:605 */ - public static final int EVREventType_VREvent_Input_HapticVibration = 1700; - /** native declaration : headers\openvr_capi.h:606 */ - public static final int EVREventType_VREvent_Input_BindingLoadFailed = 1701; - /** native declaration : headers\openvr_capi.h:607 */ - public static final int EVREventType_VREvent_Input_BindingLoadSuccessful = 1702; - /** native declaration : headers\openvr_capi.h:608 */ - public static final int EVREventType_VREvent_Input_ActionManifestReloaded = 1703; - /** native declaration : headers\openvr_capi.h:609 */ - public static final int EVREventType_VREvent_Input_ActionManifestLoadFailed = 1704; - /** native declaration : headers\openvr_capi.h:610 */ - public static final int EVREventType_VREvent_SpatialAnchors_PoseUpdated = 1800; - /** native declaration : headers\openvr_capi.h:611 */ - public static final int EVREventType_VREvent_SpatialAnchors_DescriptorUpdated = 1801; - /** native declaration : headers\openvr_capi.h:612 */ - public static final int EVREventType_VREvent_SpatialAnchors_RequestPoseUpdate = 1802; - /** native declaration : headers\openvr_capi.h:613 */ - public static final int EVREventType_VREvent_SpatialAnchors_RequestDescriptorUpdate = 1803; - /** native declaration : headers\openvr_capi.h:614 */ - public static final int EVREventType_VREvent_VendorSpecific_Reserved_Start = 10000; - /** native declaration : headers\openvr_capi.h:615 */ - public static final int EVREventType_VREvent_VendorSpecific_Reserved_End = 19999; - }; - /** - * native declaration : headers\openvr_capi.h:623
- * enum values - */ - public static interface EDeviceActivityLevel { - /** native declaration : headers\openvr_capi.h:618 */ - public static final int EDeviceActivityLevel_k_EDeviceActivityLevel_Unknown = -1; - /** native declaration : headers\openvr_capi.h:619 */ - public static final int EDeviceActivityLevel_k_EDeviceActivityLevel_Idle = 0; - /** native declaration : headers\openvr_capi.h:620 */ - public static final int EDeviceActivityLevel_k_EDeviceActivityLevel_UserInteraction = 1; - /** native declaration : headers\openvr_capi.h:621 */ - public static final int EDeviceActivityLevel_k_EDeviceActivityLevel_UserInteraction_Timeout = 2; - /** native declaration : headers\openvr_capi.h:622 */ - public static final int EDeviceActivityLevel_k_EDeviceActivityLevel_Standby = 3; - }; - /** - * native declaration : headers\openvr_capi.h:646
- * enum values - */ - public static interface EVRButtonId { - /** native declaration : headers\openvr_capi.h:625 */ - public static final int EVRButtonId_k_EButton_System = 0; - /** native declaration : headers\openvr_capi.h:626 */ - public static final int EVRButtonId_k_EButton_ApplicationMenu = 1; - /** native declaration : headers\openvr_capi.h:627 */ - public static final int EVRButtonId_k_EButton_Grip = 2; - /** native declaration : headers\openvr_capi.h:628 */ - public static final int EVRButtonId_k_EButton_DPad_Left = 3; - /** native declaration : headers\openvr_capi.h:629 */ - public static final int EVRButtonId_k_EButton_DPad_Up = 4; - /** native declaration : headers\openvr_capi.h:630 */ - public static final int EVRButtonId_k_EButton_DPad_Right = 5; - /** native declaration : headers\openvr_capi.h:631 */ - public static final int EVRButtonId_k_EButton_DPad_Down = 6; - /** native declaration : headers\openvr_capi.h:632 */ - public static final int EVRButtonId_k_EButton_A = 7; - /** native declaration : headers\openvr_capi.h:633 */ - public static final int EVRButtonId_k_EButton_ProximitySensor = 31; - /** native declaration : headers\openvr_capi.h:634 */ - public static final int EVRButtonId_k_EButton_Axis0 = 32; - /** native declaration : headers\openvr_capi.h:635 */ - public static final int EVRButtonId_k_EButton_Axis1 = 33; - /** native declaration : headers\openvr_capi.h:636 */ - public static final int EVRButtonId_k_EButton_Axis2 = 34; - /** native declaration : headers\openvr_capi.h:637 */ - public static final int EVRButtonId_k_EButton_Axis3 = 35; - /** native declaration : headers\openvr_capi.h:638 */ - public static final int EVRButtonId_k_EButton_Axis4 = 36; - /** native declaration : headers\openvr_capi.h:639 */ - public static final int EVRButtonId_k_EButton_SteamVR_Touchpad = 32; - /** native declaration : headers\openvr_capi.h:640 */ - public static final int EVRButtonId_k_EButton_SteamVR_Trigger = 33; - /** native declaration : headers\openvr_capi.h:641 */ - public static final int EVRButtonId_k_EButton_Dashboard_Back = 2; - /** native declaration : headers\openvr_capi.h:642 */ - public static final int EVRButtonId_k_EButton_Knuckles_A = 2; - /** native declaration : headers\openvr_capi.h:643 */ - public static final int EVRButtonId_k_EButton_Knuckles_B = 1; - /** native declaration : headers\openvr_capi.h:644 */ - public static final int EVRButtonId_k_EButton_Knuckles_JoyStick = 35; - /** native declaration : headers\openvr_capi.h:645 */ - public static final int EVRButtonId_k_EButton_Max = 64; - }; - /** - * native declaration : headers\openvr_capi.h:651
- * enum values - */ - public static interface EVRMouseButton { - /** native declaration : headers\openvr_capi.h:648 */ - public static final int EVRMouseButton_VRMouseButton_Left = 1; - /** native declaration : headers\openvr_capi.h:649 */ - public static final int EVRMouseButton_VRMouseButton_Right = 2; - /** native declaration : headers\openvr_capi.h:650 */ - public static final int EVRMouseButton_VRMouseButton_Middle = 4; - }; - /** - * native declaration : headers\openvr_capi.h:655
- * enum values - */ - public static interface EDualAnalogWhich { - /** native declaration : headers\openvr_capi.h:653 */ - public static final int EDualAnalogWhich_k_EDualAnalog_Left = 0; - /** native declaration : headers\openvr_capi.h:654 */ - public static final int EDualAnalogWhich_k_EDualAnalog_Right = 1; - }; - /** - * native declaration : headers\openvr_capi.h:674
- * enum values - */ - public static interface EVRInputError { - /** native declaration : headers\openvr_capi.h:657 */ - public static final int EVRInputError_VRInputError_None = 0; - /** native declaration : headers\openvr_capi.h:658 */ - public static final int EVRInputError_VRInputError_NameNotFound = 1; - /** native declaration : headers\openvr_capi.h:659 */ - public static final int EVRInputError_VRInputError_WrongType = 2; - /** native declaration : headers\openvr_capi.h:660 */ - public static final int EVRInputError_VRInputError_InvalidHandle = 3; - /** native declaration : headers\openvr_capi.h:661 */ - public static final int EVRInputError_VRInputError_InvalidParam = 4; - /** native declaration : headers\openvr_capi.h:662 */ - public static final int EVRInputError_VRInputError_NoSteam = 5; - /** native declaration : headers\openvr_capi.h:663 */ - public static final int EVRInputError_VRInputError_MaxCapacityReached = 6; - /** native declaration : headers\openvr_capi.h:664 */ - public static final int EVRInputError_VRInputError_IPCError = 7; - /** native declaration : headers\openvr_capi.h:665 */ - public static final int EVRInputError_VRInputError_NoActiveActionSet = 8; - /** native declaration : headers\openvr_capi.h:666 */ - public static final int EVRInputError_VRInputError_InvalidDevice = 9; - /** native declaration : headers\openvr_capi.h:667 */ - public static final int EVRInputError_VRInputError_InvalidSkeleton = 10; - /** native declaration : headers\openvr_capi.h:668 */ - public static final int EVRInputError_VRInputError_InvalidBoneCount = 11; - /** native declaration : headers\openvr_capi.h:669 */ - public static final int EVRInputError_VRInputError_InvalidCompressedData = 12; - /** native declaration : headers\openvr_capi.h:670 */ - public static final int EVRInputError_VRInputError_NoData = 13; - /** native declaration : headers\openvr_capi.h:671 */ - public static final int EVRInputError_VRInputError_BufferTooSmall = 14; - /** native declaration : headers\openvr_capi.h:672 */ - public static final int EVRInputError_VRInputError_MismatchedActionManifest = 15; - /** native declaration : headers\openvr_capi.h:673 */ - public static final int EVRInputError_VRInputError_MissingSkeletonData = 16; - }; - /** - * native declaration : headers\openvr_capi.h:690
- * enum values - */ - public static interface EVRSpatialAnchorError { - /** native declaration : headers\openvr_capi.h:676 */ - public static final int EVRSpatialAnchorError_VRSpatialAnchorError_Success = 0; - /** native declaration : headers\openvr_capi.h:677 */ - public static final int EVRSpatialAnchorError_VRSpatialAnchorError_Internal = 1; - /** native declaration : headers\openvr_capi.h:678 */ - public static final int EVRSpatialAnchorError_VRSpatialAnchorError_UnknownHandle = 2; - /** native declaration : headers\openvr_capi.h:679 */ - public static final int EVRSpatialAnchorError_VRSpatialAnchorError_ArrayTooSmall = 3; - /** native declaration : headers\openvr_capi.h:680 */ - public static final int EVRSpatialAnchorError_VRSpatialAnchorError_InvalidDescriptorChar = 4; - /** native declaration : headers\openvr_capi.h:681 */ - public static final int EVRSpatialAnchorError_VRSpatialAnchorError_NotYetAvailable = 5; - /** native declaration : headers\openvr_capi.h:682 */ - public static final int EVRSpatialAnchorError_VRSpatialAnchorError_NotAvailableInThisUniverse = 6; - /** native declaration : headers\openvr_capi.h:683 */ - public static final int EVRSpatialAnchorError_VRSpatialAnchorError_PermanentlyUnavailable = 7; - /** native declaration : headers\openvr_capi.h:684 */ - public static final int EVRSpatialAnchorError_VRSpatialAnchorError_WrongDriver = 8; - /** native declaration : headers\openvr_capi.h:685 */ - public static final int EVRSpatialAnchorError_VRSpatialAnchorError_DescriptorTooLong = 9; - /** native declaration : headers\openvr_capi.h:686 */ - public static final int EVRSpatialAnchorError_VRSpatialAnchorError_Unknown = 10; - /** native declaration : headers\openvr_capi.h:687 */ - public static final int EVRSpatialAnchorError_VRSpatialAnchorError_NoRoomCalibration = 11; - /** native declaration : headers\openvr_capi.h:688 */ - public static final int EVRSpatialAnchorError_VRSpatialAnchorError_InvalidArgument = 12; - /** native declaration : headers\openvr_capi.h:689 */ - public static final int EVRSpatialAnchorError_VRSpatialAnchorError_UnknownDriver = 13; - }; - /** - * native declaration : headers\openvr_capi.h:696
- * enum values - */ - public static interface EHiddenAreaMeshType { - /** native declaration : headers\openvr_capi.h:692 */ - public static final int EHiddenAreaMeshType_k_eHiddenAreaMesh_Standard = 0; - /** native declaration : headers\openvr_capi.h:693 */ - public static final int EHiddenAreaMeshType_k_eHiddenAreaMesh_Inverse = 1; - /** native declaration : headers\openvr_capi.h:694 */ - public static final int EHiddenAreaMeshType_k_eHiddenAreaMesh_LineLoop = 2; - /** native declaration : headers\openvr_capi.h:695 */ - public static final int EHiddenAreaMeshType_k_eHiddenAreaMesh_Max = 3; - }; - /** - * native declaration : headers\openvr_capi.h:702
- * enum values - */ - public static interface EVRControllerAxisType { - /** native declaration : headers\openvr_capi.h:698 */ - public static final int EVRControllerAxisType_k_eControllerAxis_None = 0; - /** native declaration : headers\openvr_capi.h:699 */ - public static final int EVRControllerAxisType_k_eControllerAxis_TrackPad = 1; - /** native declaration : headers\openvr_capi.h:700 */ - public static final int EVRControllerAxisType_k_eControllerAxis_Joystick = 2; - /** native declaration : headers\openvr_capi.h:701 */ - public static final int EVRControllerAxisType_k_eControllerAxis_Trigger = 3; - }; - /** - * native declaration : headers\openvr_capi.h:706
- * enum values - */ - public static interface EVRControllerEventOutputType { - /** native declaration : headers\openvr_capi.h:704 */ - public static final int EVRControllerEventOutputType_ControllerEventOutput_OSEvents = 0; - /** native declaration : headers\openvr_capi.h:705 */ - public static final int EVRControllerEventOutputType_ControllerEventOutput_VREvents = 1; - }; - /** - * native declaration : headers\openvr_capi.h:714
- * enum values - */ - public static interface ECollisionBoundsStyle { - /** native declaration : headers\openvr_capi.h:708 */ - public static final int ECollisionBoundsStyle_COLLISION_BOUNDS_STYLE_BEGINNER = 0; - /** native declaration : headers\openvr_capi.h:709 */ - public static final int ECollisionBoundsStyle_COLLISION_BOUNDS_STYLE_INTERMEDIATE = 1; - /** native declaration : headers\openvr_capi.h:710 */ - public static final int ECollisionBoundsStyle_COLLISION_BOUNDS_STYLE_SQUARES = 2; - /** native declaration : headers\openvr_capi.h:711 */ - public static final int ECollisionBoundsStyle_COLLISION_BOUNDS_STYLE_ADVANCED = 3; - /** native declaration : headers\openvr_capi.h:712 */ - public static final int ECollisionBoundsStyle_COLLISION_BOUNDS_STYLE_NONE = 4; - /** native declaration : headers\openvr_capi.h:713 */ - public static final int ECollisionBoundsStyle_COLLISION_BOUNDS_STYLE_COUNT = 5; - }; - /** - * native declaration : headers\openvr_capi.h:740
- * enum values - */ - public static interface EVROverlayError { - /** native declaration : headers\openvr_capi.h:716 */ - public static final int EVROverlayError_VROverlayError_None = 0; - /** native declaration : headers\openvr_capi.h:717 */ - public static final int EVROverlayError_VROverlayError_UnknownOverlay = 10; - /** native declaration : headers\openvr_capi.h:718 */ - public static final int EVROverlayError_VROverlayError_InvalidHandle = 11; - /** native declaration : headers\openvr_capi.h:719 */ - public static final int EVROverlayError_VROverlayError_PermissionDenied = 12; - /** native declaration : headers\openvr_capi.h:720 */ - public static final int EVROverlayError_VROverlayError_OverlayLimitExceeded = 13; - /** native declaration : headers\openvr_capi.h:721 */ - public static final int EVROverlayError_VROverlayError_WrongVisibilityType = 14; - /** native declaration : headers\openvr_capi.h:722 */ - public static final int EVROverlayError_VROverlayError_KeyTooLong = 15; - /** native declaration : headers\openvr_capi.h:723 */ - public static final int EVROverlayError_VROverlayError_NameTooLong = 16; - /** native declaration : headers\openvr_capi.h:724 */ - public static final int EVROverlayError_VROverlayError_KeyInUse = 17; - /** native declaration : headers\openvr_capi.h:725 */ - public static final int EVROverlayError_VROverlayError_WrongTransformType = 18; - /** native declaration : headers\openvr_capi.h:726 */ - public static final int EVROverlayError_VROverlayError_InvalidTrackedDevice = 19; - /** native declaration : headers\openvr_capi.h:727 */ - public static final int EVROverlayError_VROverlayError_InvalidParameter = 20; - /** native declaration : headers\openvr_capi.h:728 */ - public static final int EVROverlayError_VROverlayError_ThumbnailCantBeDestroyed = 21; - /** native declaration : headers\openvr_capi.h:729 */ - public static final int EVROverlayError_VROverlayError_ArrayTooSmall = 22; - /** native declaration : headers\openvr_capi.h:730 */ - public static final int EVROverlayError_VROverlayError_RequestFailed = 23; - /** native declaration : headers\openvr_capi.h:731 */ - public static final int EVROverlayError_VROverlayError_InvalidTexture = 24; - /** native declaration : headers\openvr_capi.h:732 */ - public static final int EVROverlayError_VROverlayError_UnableToLoadFile = 25; - /** native declaration : headers\openvr_capi.h:733 */ - public static final int EVROverlayError_VROverlayError_KeyboardAlreadyInUse = 26; - /** native declaration : headers\openvr_capi.h:734 */ - public static final int EVROverlayError_VROverlayError_NoNeighbor = 27; - /** native declaration : headers\openvr_capi.h:735 */ - public static final int EVROverlayError_VROverlayError_TooManyMaskPrimitives = 29; - /** native declaration : headers\openvr_capi.h:736 */ - public static final int EVROverlayError_VROverlayError_BadMaskPrimitive = 30; - /** native declaration : headers\openvr_capi.h:737 */ - public static final int EVROverlayError_VROverlayError_TextureAlreadyLocked = 31; - /** native declaration : headers\openvr_capi.h:738 */ - public static final int EVROverlayError_VROverlayError_TextureLockCapacityReached = 32; - /** native declaration : headers\openvr_capi.h:739 */ - public static final int EVROverlayError_VROverlayError_TextureNotLocked = 33; - }; - /** - * native declaration : headers\openvr_capi.h:751
- * enum values - */ - public static interface EVRApplicationType { - /** native declaration : headers\openvr_capi.h:742 */ - public static final int EVRApplicationType_VRApplication_Other = 0; - /** native declaration : headers\openvr_capi.h:743 */ - public static final int EVRApplicationType_VRApplication_Scene = 1; - /** native declaration : headers\openvr_capi.h:744 */ - public static final int EVRApplicationType_VRApplication_Overlay = 2; - /** native declaration : headers\openvr_capi.h:745 */ - public static final int EVRApplicationType_VRApplication_Background = 3; - /** native declaration : headers\openvr_capi.h:746 */ - public static final int EVRApplicationType_VRApplication_Utility = 4; - /** native declaration : headers\openvr_capi.h:747 */ - public static final int EVRApplicationType_VRApplication_VRMonitor = 5; - /** native declaration : headers\openvr_capi.h:748 */ - public static final int EVRApplicationType_VRApplication_SteamWatchdog = 6; - /** native declaration : headers\openvr_capi.h:749 */ - public static final int EVRApplicationType_VRApplication_Bootstrapper = 7; - /** native declaration : headers\openvr_capi.h:750 */ - public static final int EVRApplicationType_VRApplication_Max = 8; - }; - /** - * native declaration : headers\openvr_capi.h:756
- * enum values - */ - public static interface EVRFirmwareError { - /** native declaration : headers\openvr_capi.h:753 */ - public static final int EVRFirmwareError_VRFirmwareError_None = 0; - /** native declaration : headers\openvr_capi.h:754 */ - public static final int EVRFirmwareError_VRFirmwareError_Success = 1; - /** native declaration : headers\openvr_capi.h:755 */ - public static final int EVRFirmwareError_VRFirmwareError_Fail = 2; - }; - /** - * native declaration : headers\openvr_capi.h:763
- * enum values - */ - public static interface EVRNotificationError { - /** native declaration : headers\openvr_capi.h:758 */ - public static final int EVRNotificationError_VRNotificationError_OK = 0; - /** native declaration : headers\openvr_capi.h:759 */ - public static final int EVRNotificationError_VRNotificationError_InvalidNotificationId = 100; - /** native declaration : headers\openvr_capi.h:760 */ - public static final int EVRNotificationError_VRNotificationError_NotificationQueueFull = 101; - /** native declaration : headers\openvr_capi.h:761 */ - public static final int EVRNotificationError_VRNotificationError_InvalidOverlayHandle = 102; - /** native declaration : headers\openvr_capi.h:762 */ - public static final int EVRNotificationError_VRNotificationError_SystemWithUserValueAlreadyExists = 103; - }; - /** - * native declaration : headers\openvr_capi.h:767
- * enum values - */ - public static interface EVRSkeletalMotionRange { - /** native declaration : headers\openvr_capi.h:765 */ - public static final int EVRSkeletalMotionRange_VRSkeletalMotionRange_WithController = 0; - /** native declaration : headers\openvr_capi.h:766 */ - public static final int EVRSkeletalMotionRange_VRSkeletalMotionRange_WithoutController = 1; - }; - /** - * native declaration : headers\openvr_capi.h:857
- * enum values - */ - public static interface EVRInitError { - /** native declaration : headers\openvr_capi.h:769 */ - public static final int EVRInitError_VRInitError_None = 0; - /** native declaration : headers\openvr_capi.h:770 */ - public static final int EVRInitError_VRInitError_Unknown = 1; - /** native declaration : headers\openvr_capi.h:771 */ - public static final int EVRInitError_VRInitError_Init_InstallationNotFound = 100; - /** native declaration : headers\openvr_capi.h:772 */ - public static final int EVRInitError_VRInitError_Init_InstallationCorrupt = 101; - /** native declaration : headers\openvr_capi.h:773 */ - public static final int EVRInitError_VRInitError_Init_VRClientDLLNotFound = 102; - /** native declaration : headers\openvr_capi.h:774 */ - public static final int EVRInitError_VRInitError_Init_FileNotFound = 103; - /** native declaration : headers\openvr_capi.h:775 */ - public static final int EVRInitError_VRInitError_Init_FactoryNotFound = 104; - /** native declaration : headers\openvr_capi.h:776 */ - public static final int EVRInitError_VRInitError_Init_InterfaceNotFound = 105; - /** native declaration : headers\openvr_capi.h:777 */ - public static final int EVRInitError_VRInitError_Init_InvalidInterface = 106; - /** native declaration : headers\openvr_capi.h:778 */ - public static final int EVRInitError_VRInitError_Init_UserConfigDirectoryInvalid = 107; - /** native declaration : headers\openvr_capi.h:779 */ - public static final int EVRInitError_VRInitError_Init_HmdNotFound = 108; - /** native declaration : headers\openvr_capi.h:780 */ - public static final int EVRInitError_VRInitError_Init_NotInitialized = 109; - /** native declaration : headers\openvr_capi.h:781 */ - public static final int EVRInitError_VRInitError_Init_PathRegistryNotFound = 110; - /** native declaration : headers\openvr_capi.h:782 */ - public static final int EVRInitError_VRInitError_Init_NoConfigPath = 111; - /** native declaration : headers\openvr_capi.h:783 */ - public static final int EVRInitError_VRInitError_Init_NoLogPath = 112; - /** native declaration : headers\openvr_capi.h:784 */ - public static final int EVRInitError_VRInitError_Init_PathRegistryNotWritable = 113; - /** native declaration : headers\openvr_capi.h:785 */ - public static final int EVRInitError_VRInitError_Init_AppInfoInitFailed = 114; - /** native declaration : headers\openvr_capi.h:786 */ - public static final int EVRInitError_VRInitError_Init_Retry = 115; - /** native declaration : headers\openvr_capi.h:787 */ - public static final int EVRInitError_VRInitError_Init_InitCanceledByUser = 116; - /** native declaration : headers\openvr_capi.h:788 */ - public static final int EVRInitError_VRInitError_Init_AnotherAppLaunching = 117; - /** native declaration : headers\openvr_capi.h:789 */ - public static final int EVRInitError_VRInitError_Init_SettingsInitFailed = 118; - /** native declaration : headers\openvr_capi.h:790 */ - public static final int EVRInitError_VRInitError_Init_ShuttingDown = 119; - /** native declaration : headers\openvr_capi.h:791 */ - public static final int EVRInitError_VRInitError_Init_TooManyObjects = 120; - /** native declaration : headers\openvr_capi.h:792 */ - public static final int EVRInitError_VRInitError_Init_NoServerForBackgroundApp = 121; - /** native declaration : headers\openvr_capi.h:793 */ - public static final int EVRInitError_VRInitError_Init_NotSupportedWithCompositor = 122; - /** native declaration : headers\openvr_capi.h:794 */ - public static final int EVRInitError_VRInitError_Init_NotAvailableToUtilityApps = 123; - /** native declaration : headers\openvr_capi.h:795 */ - public static final int EVRInitError_VRInitError_Init_Internal = 124; - /** native declaration : headers\openvr_capi.h:796 */ - public static final int EVRInitError_VRInitError_Init_HmdDriverIdIsNone = 125; - /** native declaration : headers\openvr_capi.h:797 */ - public static final int EVRInitError_VRInitError_Init_HmdNotFoundPresenceFailed = 126; - /** native declaration : headers\openvr_capi.h:798 */ - public static final int EVRInitError_VRInitError_Init_VRMonitorNotFound = 127; - /** native declaration : headers\openvr_capi.h:799 */ - public static final int EVRInitError_VRInitError_Init_VRMonitorStartupFailed = 128; - /** native declaration : headers\openvr_capi.h:800 */ - public static final int EVRInitError_VRInitError_Init_LowPowerWatchdogNotSupported = 129; - /** native declaration : headers\openvr_capi.h:801 */ - public static final int EVRInitError_VRInitError_Init_InvalidApplicationType = 130; - /** native declaration : headers\openvr_capi.h:802 */ - public static final int EVRInitError_VRInitError_Init_NotAvailableToWatchdogApps = 131; - /** native declaration : headers\openvr_capi.h:803 */ - public static final int EVRInitError_VRInitError_Init_WatchdogDisabledInSettings = 132; - /** native declaration : headers\openvr_capi.h:804 */ - public static final int EVRInitError_VRInitError_Init_VRDashboardNotFound = 133; - /** native declaration : headers\openvr_capi.h:805 */ - public static final int EVRInitError_VRInitError_Init_VRDashboardStartupFailed = 134; - /** native declaration : headers\openvr_capi.h:806 */ - public static final int EVRInitError_VRInitError_Init_VRHomeNotFound = 135; - /** native declaration : headers\openvr_capi.h:807 */ - public static final int EVRInitError_VRInitError_Init_VRHomeStartupFailed = 136; - /** native declaration : headers\openvr_capi.h:808 */ - public static final int EVRInitError_VRInitError_Init_RebootingBusy = 137; - /** native declaration : headers\openvr_capi.h:809 */ - public static final int EVRInitError_VRInitError_Init_FirmwareUpdateBusy = 138; - /** native declaration : headers\openvr_capi.h:810 */ - public static final int EVRInitError_VRInitError_Init_FirmwareRecoveryBusy = 139; - /** native declaration : headers\openvr_capi.h:811 */ - public static final int EVRInitError_VRInitError_Init_USBServiceBusy = 140; - /** native declaration : headers\openvr_capi.h:812 */ - public static final int EVRInitError_VRInitError_Init_VRWebHelperStartupFailed = 141; - /** native declaration : headers\openvr_capi.h:813 */ - public static final int EVRInitError_VRInitError_Init_TrackerManagerInitFailed = 142; - /** native declaration : headers\openvr_capi.h:814 */ - public static final int EVRInitError_VRInitError_Driver_Failed = 200; - /** native declaration : headers\openvr_capi.h:815 */ - public static final int EVRInitError_VRInitError_Driver_Unknown = 201; - /** native declaration : headers\openvr_capi.h:816 */ - public static final int EVRInitError_VRInitError_Driver_HmdUnknown = 202; - /** native declaration : headers\openvr_capi.h:817 */ - public static final int EVRInitError_VRInitError_Driver_NotLoaded = 203; - /** native declaration : headers\openvr_capi.h:818 */ - public static final int EVRInitError_VRInitError_Driver_RuntimeOutOfDate = 204; - /** native declaration : headers\openvr_capi.h:819 */ - public static final int EVRInitError_VRInitError_Driver_HmdInUse = 205; - /** native declaration : headers\openvr_capi.h:820 */ - public static final int EVRInitError_VRInitError_Driver_NotCalibrated = 206; - /** native declaration : headers\openvr_capi.h:821 */ - public static final int EVRInitError_VRInitError_Driver_CalibrationInvalid = 207; - /** native declaration : headers\openvr_capi.h:822 */ - public static final int EVRInitError_VRInitError_Driver_HmdDisplayNotFound = 208; - /** native declaration : headers\openvr_capi.h:823 */ - public static final int EVRInitError_VRInitError_Driver_TrackedDeviceInterfaceUnknown = 209; - /** native declaration : headers\openvr_capi.h:824 */ - public static final int EVRInitError_VRInitError_Driver_HmdDriverIdOutOfBounds = 211; - /** native declaration : headers\openvr_capi.h:825 */ - public static final int EVRInitError_VRInitError_Driver_HmdDisplayMirrored = 212; - /** native declaration : headers\openvr_capi.h:826 */ - public static final int EVRInitError_VRInitError_IPC_ServerInitFailed = 300; - /** native declaration : headers\openvr_capi.h:827 */ - public static final int EVRInitError_VRInitError_IPC_ConnectFailed = 301; - /** native declaration : headers\openvr_capi.h:828 */ - public static final int EVRInitError_VRInitError_IPC_SharedStateInitFailed = 302; - /** native declaration : headers\openvr_capi.h:829 */ - public static final int EVRInitError_VRInitError_IPC_CompositorInitFailed = 303; - /** native declaration : headers\openvr_capi.h:830 */ - public static final int EVRInitError_VRInitError_IPC_MutexInitFailed = 304; - /** native declaration : headers\openvr_capi.h:831 */ - public static final int EVRInitError_VRInitError_IPC_Failed = 305; - /** native declaration : headers\openvr_capi.h:832 */ - public static final int EVRInitError_VRInitError_IPC_CompositorConnectFailed = 306; - /** native declaration : headers\openvr_capi.h:833 */ - public static final int EVRInitError_VRInitError_IPC_CompositorInvalidConnectResponse = 307; - /** native declaration : headers\openvr_capi.h:834 */ - public static final int EVRInitError_VRInitError_IPC_ConnectFailedAfterMultipleAttempts = 308; - /** native declaration : headers\openvr_capi.h:835 */ - public static final int EVRInitError_VRInitError_Compositor_Failed = 400; - /** native declaration : headers\openvr_capi.h:836 */ - public static final int EVRInitError_VRInitError_Compositor_D3D11HardwareRequired = 401; - /** native declaration : headers\openvr_capi.h:837 */ - public static final int EVRInitError_VRInitError_Compositor_FirmwareRequiresUpdate = 402; - /** native declaration : headers\openvr_capi.h:838 */ - public static final int EVRInitError_VRInitError_Compositor_OverlayInitFailed = 403; - /** native declaration : headers\openvr_capi.h:839 */ - public static final int EVRInitError_VRInitError_Compositor_ScreenshotsInitFailed = 404; - /** native declaration : headers\openvr_capi.h:840 */ - public static final int EVRInitError_VRInitError_Compositor_UnableToCreateDevice = 405; - /** native declaration : headers\openvr_capi.h:841 */ - public static final int EVRInitError_VRInitError_VendorSpecific_UnableToConnectToOculusRuntime = 1000; - /** native declaration : headers\openvr_capi.h:842 */ - public static final int EVRInitError_VRInitError_VendorSpecific_WindowsNotInDevMode = 1001; - /** native declaration : headers\openvr_capi.h:843 */ - public static final int EVRInitError_VRInitError_VendorSpecific_HmdFound_CantOpenDevice = 1101; - /** native declaration : headers\openvr_capi.h:844 */ - public static final int EVRInitError_VRInitError_VendorSpecific_HmdFound_UnableToRequestConfigStart = 1102; - /** native declaration : headers\openvr_capi.h:845 */ - public static final int EVRInitError_VRInitError_VendorSpecific_HmdFound_NoStoredConfig = 1103; - /** native declaration : headers\openvr_capi.h:846 */ - public static final int EVRInitError_VRInitError_VendorSpecific_HmdFound_ConfigTooBig = 1104; - /** native declaration : headers\openvr_capi.h:847 */ - public static final int EVRInitError_VRInitError_VendorSpecific_HmdFound_ConfigTooSmall = 1105; - /** native declaration : headers\openvr_capi.h:848 */ - public static final int EVRInitError_VRInitError_VendorSpecific_HmdFound_UnableToInitZLib = 1106; - /** native declaration : headers\openvr_capi.h:849 */ - public static final int EVRInitError_VRInitError_VendorSpecific_HmdFound_CantReadFirmwareVersion = 1107; - /** native declaration : headers\openvr_capi.h:850 */ - public static final int EVRInitError_VRInitError_VendorSpecific_HmdFound_UnableToSendUserDataStart = 1108; - /** native declaration : headers\openvr_capi.h:851 */ - public static final int EVRInitError_VRInitError_VendorSpecific_HmdFound_UnableToGetUserDataStart = 1109; - /** native declaration : headers\openvr_capi.h:852 */ - public static final int EVRInitError_VRInitError_VendorSpecific_HmdFound_UnableToGetUserDataNext = 1110; - /** native declaration : headers\openvr_capi.h:853 */ - public static final int EVRInitError_VRInitError_VendorSpecific_HmdFound_UserDataAddressRange = 1111; - /** native declaration : headers\openvr_capi.h:854 */ - public static final int EVRInitError_VRInitError_VendorSpecific_HmdFound_UserDataError = 1112; - /** native declaration : headers\openvr_capi.h:855 */ - public static final int EVRInitError_VRInitError_VendorSpecific_HmdFound_ConfigFailedSanityCheck = 1113; - /** native declaration : headers\openvr_capi.h:856 */ - public static final int EVRInitError_VRInitError_Steam_SteamInstallationNotFound = 2000; - }; - /** - * native declaration : headers\openvr_capi.h:865
- * enum values - */ - public static interface EVRScreenshotType { - /** native declaration : headers\openvr_capi.h:859 */ - public static final int EVRScreenshotType_VRScreenshotType_None = 0; - /** native declaration : headers\openvr_capi.h:860 */ - public static final int EVRScreenshotType_VRScreenshotType_Mono = 1; - /** native declaration : headers\openvr_capi.h:861 */ - public static final int EVRScreenshotType_VRScreenshotType_Stereo = 2; - /** native declaration : headers\openvr_capi.h:862 */ - public static final int EVRScreenshotType_VRScreenshotType_Cubemap = 3; - /** native declaration : headers\openvr_capi.h:863 */ - public static final int EVRScreenshotType_VRScreenshotType_MonoPanorama = 4; - /** native declaration : headers\openvr_capi.h:864 */ - public static final int EVRScreenshotType_VRScreenshotType_StereoPanorama = 5; - }; - /** - * native declaration : headers\openvr_capi.h:869
- * enum values - */ - public static interface EVRScreenshotPropertyFilenames { - /** native declaration : headers\openvr_capi.h:867 */ - public static final int EVRScreenshotPropertyFilenames_VRScreenshotPropertyFilenames_Preview = 0; - /** native declaration : headers\openvr_capi.h:868 */ - public static final int EVRScreenshotPropertyFilenames_VRScreenshotPropertyFilenames_VR = 1; - }; - /** - * native declaration : headers\openvr_capi.h:888
- * enum values - */ - public static interface EVRTrackedCameraError { - /** native declaration : headers\openvr_capi.h:871 */ - public static final int EVRTrackedCameraError_VRTrackedCameraError_None = 0; - /** native declaration : headers\openvr_capi.h:872 */ - public static final int EVRTrackedCameraError_VRTrackedCameraError_OperationFailed = 100; - /** native declaration : headers\openvr_capi.h:873 */ - public static final int EVRTrackedCameraError_VRTrackedCameraError_InvalidHandle = 101; - /** native declaration : headers\openvr_capi.h:874 */ - public static final int EVRTrackedCameraError_VRTrackedCameraError_InvalidFrameHeaderVersion = 102; - /** native declaration : headers\openvr_capi.h:875 */ - public static final int EVRTrackedCameraError_VRTrackedCameraError_OutOfHandles = 103; - /** native declaration : headers\openvr_capi.h:876 */ - public static final int EVRTrackedCameraError_VRTrackedCameraError_IPCFailure = 104; - /** native declaration : headers\openvr_capi.h:877 */ - public static final int EVRTrackedCameraError_VRTrackedCameraError_NotSupportedForThisDevice = 105; - /** native declaration : headers\openvr_capi.h:878 */ - public static final int EVRTrackedCameraError_VRTrackedCameraError_SharedMemoryFailure = 106; - /** native declaration : headers\openvr_capi.h:879 */ - public static final int EVRTrackedCameraError_VRTrackedCameraError_FrameBufferingFailure = 107; - /** native declaration : headers\openvr_capi.h:880 */ - public static final int EVRTrackedCameraError_VRTrackedCameraError_StreamSetupFailure = 108; - /** native declaration : headers\openvr_capi.h:881 */ - public static final int EVRTrackedCameraError_VRTrackedCameraError_InvalidGLTextureId = 109; - /** native declaration : headers\openvr_capi.h:882 */ - public static final int EVRTrackedCameraError_VRTrackedCameraError_InvalidSharedTextureHandle = 110; - /** native declaration : headers\openvr_capi.h:883 */ - public static final int EVRTrackedCameraError_VRTrackedCameraError_FailedToGetGLTextureId = 111; - /** native declaration : headers\openvr_capi.h:884 */ - public static final int EVRTrackedCameraError_VRTrackedCameraError_SharedTextureFailure = 112; - /** native declaration : headers\openvr_capi.h:885 */ - public static final int EVRTrackedCameraError_VRTrackedCameraError_NoFrameAvailable = 113; - /** native declaration : headers\openvr_capi.h:886 */ - public static final int EVRTrackedCameraError_VRTrackedCameraError_InvalidArgument = 114; - /** native declaration : headers\openvr_capi.h:887 */ - public static final int EVRTrackedCameraError_VRTrackedCameraError_InvalidFrameBufferSize = 115; - }; - /** - * native declaration : headers\openvr_capi.h:894
- * enum values - */ - public static interface EVRTrackedCameraFrameLayout { - /** native declaration : headers\openvr_capi.h:890 */ - public static final int EVRTrackedCameraFrameLayout_Mono = 1; - /** native declaration : headers\openvr_capi.h:891 */ - public static final int EVRTrackedCameraFrameLayout_Stereo = 2; - /** native declaration : headers\openvr_capi.h:892 */ - public static final int EVRTrackedCameraFrameLayout_VerticalLayout = 16; - /** native declaration : headers\openvr_capi.h:893 */ - public static final int EVRTrackedCameraFrameLayout_HorizontalLayout = 32; - }; - /** - * native declaration : headers\openvr_capi.h:900
- * enum values - */ - public static interface EVRTrackedCameraFrameType { - /** native declaration : headers\openvr_capi.h:896 */ - public static final int EVRTrackedCameraFrameType_VRTrackedCameraFrameType_Distorted = 0; - /** native declaration : headers\openvr_capi.h:897 */ - public static final int EVRTrackedCameraFrameType_VRTrackedCameraFrameType_Undistorted = 1; - /** native declaration : headers\openvr_capi.h:898 */ - public static final int EVRTrackedCameraFrameType_VRTrackedCameraFrameType_MaximumUndistorted = 2; - /** native declaration : headers\openvr_capi.h:899 */ - public static final int EVRTrackedCameraFrameType_MAX_CAMERA_FRAME_TYPES = 3; - }; - /** - * native declaration : headers\openvr_capi.h:905
- * enum values - */ - public static interface EVSync { - /** native declaration : headers\openvr_capi.h:902 */ - public static final int EVSync_VSync_None = 0; - /** native declaration : headers\openvr_capi.h:903 */ - public static final int EVSync_VSync_WaitRender = 1; - /** native declaration : headers\openvr_capi.h:904 */ - public static final int EVSync_VSync_NoWaitRender = 2; - }; - /** - * native declaration : headers\openvr_capi.h:909
- * enum values - */ - public static interface EVRMuraCorrectionMode { - /** native declaration : headers\openvr_capi.h:907 */ - public static final int EVRMuraCorrectionMode_Default = 0; - /** native declaration : headers\openvr_capi.h:908 */ - public static final int EVRMuraCorrectionMode_NoCorrection = 1; - }; - /** - * native declaration : headers\openvr_capi.h:917
- * enum values - */ - public static interface Imu_OffScaleFlags { - /** native declaration : headers\openvr_capi.h:911 */ - public static final int Imu_OffScaleFlags_OffScale_AccelX = 1; - /** native declaration : headers\openvr_capi.h:912 */ - public static final int Imu_OffScaleFlags_OffScale_AccelY = 2; - /** native declaration : headers\openvr_capi.h:913 */ - public static final int Imu_OffScaleFlags_OffScale_AccelZ = 4; - /** native declaration : headers\openvr_capi.h:914 */ - public static final int Imu_OffScaleFlags_OffScale_GyroX = 8; - /** native declaration : headers\openvr_capi.h:915 */ - public static final int Imu_OffScaleFlags_OffScale_GyroY = 16; - /** native declaration : headers\openvr_capi.h:916 */ - public static final int Imu_OffScaleFlags_OffScale_GyroZ = 32; - }; - /** - * native declaration : headers\openvr_capi.h:940
- * enum values - */ - public static interface EVRApplicationError { - /** native declaration : headers\openvr_capi.h:919 */ - public static final int EVRApplicationError_VRApplicationError_None = 0; - /** native declaration : headers\openvr_capi.h:920 */ - public static final int EVRApplicationError_VRApplicationError_AppKeyAlreadyExists = 100; - /** native declaration : headers\openvr_capi.h:921 */ - public static final int EVRApplicationError_VRApplicationError_NoManifest = 101; - /** native declaration : headers\openvr_capi.h:922 */ - public static final int EVRApplicationError_VRApplicationError_NoApplication = 102; - /** native declaration : headers\openvr_capi.h:923 */ - public static final int EVRApplicationError_VRApplicationError_InvalidIndex = 103; - /** native declaration : headers\openvr_capi.h:924 */ - public static final int EVRApplicationError_VRApplicationError_UnknownApplication = 104; - /** native declaration : headers\openvr_capi.h:925 */ - public static final int EVRApplicationError_VRApplicationError_IPCFailed = 105; - /** native declaration : headers\openvr_capi.h:926 */ - public static final int EVRApplicationError_VRApplicationError_ApplicationAlreadyRunning = 106; - /** native declaration : headers\openvr_capi.h:927 */ - public static final int EVRApplicationError_VRApplicationError_InvalidManifest = 107; - /** native declaration : headers\openvr_capi.h:928 */ - public static final int EVRApplicationError_VRApplicationError_InvalidApplication = 108; - /** native declaration : headers\openvr_capi.h:929 */ - public static final int EVRApplicationError_VRApplicationError_LaunchFailed = 109; - /** native declaration : headers\openvr_capi.h:930 */ - public static final int EVRApplicationError_VRApplicationError_ApplicationAlreadyStarting = 110; - /** native declaration : headers\openvr_capi.h:931 */ - public static final int EVRApplicationError_VRApplicationError_LaunchInProgress = 111; - /** native declaration : headers\openvr_capi.h:932 */ - public static final int EVRApplicationError_VRApplicationError_OldApplicationQuitting = 112; - /** native declaration : headers\openvr_capi.h:933 */ - public static final int EVRApplicationError_VRApplicationError_TransitionAborted = 113; - /** native declaration : headers\openvr_capi.h:934 */ - public static final int EVRApplicationError_VRApplicationError_IsTemplate = 114; - /** native declaration : headers\openvr_capi.h:935 */ - public static final int EVRApplicationError_VRApplicationError_SteamVRIsExiting = 115; - /** native declaration : headers\openvr_capi.h:936 */ - public static final int EVRApplicationError_VRApplicationError_BufferTooSmall = 200; - /** native declaration : headers\openvr_capi.h:937 */ - public static final int EVRApplicationError_VRApplicationError_PropertyNotSet = 201; - /** native declaration : headers\openvr_capi.h:938 */ - public static final int EVRApplicationError_VRApplicationError_UnknownProperty = 202; - /** native declaration : headers\openvr_capi.h:939 */ - public static final int EVRApplicationError_VRApplicationError_InvalidParameter = 203; - }; - /** - * native declaration : headers\openvr_capi.h:959
- * enum values - */ - public static interface EVRApplicationProperty { - /** native declaration : headers\openvr_capi.h:942 */ - public static final int EVRApplicationProperty_VRApplicationProperty_Name_String = 0; - /** native declaration : headers\openvr_capi.h:943 */ - public static final int EVRApplicationProperty_VRApplicationProperty_LaunchType_String = 11; - /** native declaration : headers\openvr_capi.h:944 */ - public static final int EVRApplicationProperty_VRApplicationProperty_WorkingDirectory_String = 12; - /** native declaration : headers\openvr_capi.h:945 */ - public static final int EVRApplicationProperty_VRApplicationProperty_BinaryPath_String = 13; - /** native declaration : headers\openvr_capi.h:946 */ - public static final int EVRApplicationProperty_VRApplicationProperty_Arguments_String = 14; - /** native declaration : headers\openvr_capi.h:947 */ - public static final int EVRApplicationProperty_VRApplicationProperty_URL_String = 15; - /** native declaration : headers\openvr_capi.h:948 */ - public static final int EVRApplicationProperty_VRApplicationProperty_Description_String = 50; - /** native declaration : headers\openvr_capi.h:949 */ - public static final int EVRApplicationProperty_VRApplicationProperty_NewsURL_String = 51; - /** native declaration : headers\openvr_capi.h:950 */ - public static final int EVRApplicationProperty_VRApplicationProperty_ImagePath_String = 52; - /** native declaration : headers\openvr_capi.h:951 */ - public static final int EVRApplicationProperty_VRApplicationProperty_Source_String = 53; - /** native declaration : headers\openvr_capi.h:952 */ - public static final int EVRApplicationProperty_VRApplicationProperty_ActionManifestURL_String = 54; - /** native declaration : headers\openvr_capi.h:953 */ - public static final int EVRApplicationProperty_VRApplicationProperty_IsDashboardOverlay_Bool = 60; - /** native declaration : headers\openvr_capi.h:954 */ - public static final int EVRApplicationProperty_VRApplicationProperty_IsTemplate_Bool = 61; - /** native declaration : headers\openvr_capi.h:955 */ - public static final int EVRApplicationProperty_VRApplicationProperty_IsInstanced_Bool = 62; - /** native declaration : headers\openvr_capi.h:956 */ - public static final int EVRApplicationProperty_VRApplicationProperty_IsInternal_Bool = 63; - /** native declaration : headers\openvr_capi.h:957 */ - public static final int EVRApplicationProperty_VRApplicationProperty_WantsCompositorPauseInStandby_Bool = 64; - /** native declaration : headers\openvr_capi.h:958 */ - public static final int EVRApplicationProperty_VRApplicationProperty_LastLaunchTime_Uint64 = 70; - }; - /** - * native declaration : headers\openvr_capi.h:965
- * enum values - */ - public static interface EVRApplicationTransitionState { - /** native declaration : headers\openvr_capi.h:961 */ - public static final int EVRApplicationTransitionState_VRApplicationTransition_None = 0; - /** native declaration : headers\openvr_capi.h:962 */ - public static final int EVRApplicationTransitionState_VRApplicationTransition_OldAppQuitSent = 10; - /** native declaration : headers\openvr_capi.h:963 */ - public static final int EVRApplicationTransitionState_VRApplicationTransition_WaitingForExternalLaunch = 11; - /** native declaration : headers\openvr_capi.h:964 */ - public static final int EVRApplicationTransitionState_VRApplicationTransition_NewAppLaunched = 20; - }; - /** - * native declaration : headers\openvr_capi.h:977
- * enum values - */ - public static interface ChaperoneCalibrationState { - /** native declaration : headers\openvr_capi.h:967 */ - public static final int ChaperoneCalibrationState_OK = 1; - /** native declaration : headers\openvr_capi.h:968 */ - public static final int ChaperoneCalibrationState_Warning = 100; - /** native declaration : headers\openvr_capi.h:969 */ - public static final int ChaperoneCalibrationState_Warning_BaseStationMayHaveMoved = 101; - /** native declaration : headers\openvr_capi.h:970 */ - public static final int ChaperoneCalibrationState_Warning_BaseStationRemoved = 102; - /** native declaration : headers\openvr_capi.h:971 */ - public static final int ChaperoneCalibrationState_Warning_SeatedBoundsInvalid = 103; - /** native declaration : headers\openvr_capi.h:972 */ - public static final int ChaperoneCalibrationState_Error = 200; - /** native declaration : headers\openvr_capi.h:973 */ - public static final int ChaperoneCalibrationState_Error_BaseStationUninitialized = 201; - /** native declaration : headers\openvr_capi.h:974 */ - public static final int ChaperoneCalibrationState_Error_BaseStationConflict = 202; - /** native declaration : headers\openvr_capi.h:975 */ - public static final int ChaperoneCalibrationState_Error_PlayAreaInvalid = 203; - /** native declaration : headers\openvr_capi.h:976 */ - public static final int ChaperoneCalibrationState_Error_CollisionBoundsInvalid = 204; - }; - /** - * native declaration : headers\openvr_capi.h:981
- * enum values - */ - public static interface EChaperoneConfigFile { - /** native declaration : headers\openvr_capi.h:979 */ - public static final int EChaperoneConfigFile_Live = 1; - /** native declaration : headers\openvr_capi.h:980 */ - public static final int EChaperoneConfigFile_Temp = 2; - }; - /** - * native declaration : headers\openvr_capi.h:984
- * enum values - */ - public static interface EChaperoneImportFlags { - /** native declaration : headers\openvr_capi.h:983 */ - public static final int EChaperoneImportFlags_EChaperoneImport_BoundsOnly = 1; - }; - /** - * native declaration : headers\openvr_capi.h:998
- * enum values - */ - public static interface EVRCompositorError { - /** native declaration : headers\openvr_capi.h:986 */ - public static final int EVRCompositorError_VRCompositorError_None = 0; - /** native declaration : headers\openvr_capi.h:987 */ - public static final int EVRCompositorError_VRCompositorError_RequestFailed = 1; - /** native declaration : headers\openvr_capi.h:988 */ - public static final int EVRCompositorError_VRCompositorError_IncompatibleVersion = 100; - /** native declaration : headers\openvr_capi.h:989 */ - public static final int EVRCompositorError_VRCompositorError_DoNotHaveFocus = 101; - /** native declaration : headers\openvr_capi.h:990 */ - public static final int EVRCompositorError_VRCompositorError_InvalidTexture = 102; - /** native declaration : headers\openvr_capi.h:991 */ - public static final int EVRCompositorError_VRCompositorError_IsNotSceneApplication = 103; - /** native declaration : headers\openvr_capi.h:992 */ - public static final int EVRCompositorError_VRCompositorError_TextureIsOnWrongDevice = 104; - /** native declaration : headers\openvr_capi.h:993 */ - public static final int EVRCompositorError_VRCompositorError_TextureUsesUnsupportedFormat = 105; - /** native declaration : headers\openvr_capi.h:994 */ - public static final int EVRCompositorError_VRCompositorError_SharedTexturesNotSupported = 106; - /** native declaration : headers\openvr_capi.h:995 */ - public static final int EVRCompositorError_VRCompositorError_IndexOutOfRange = 107; - /** native declaration : headers\openvr_capi.h:996 */ - public static final int EVRCompositorError_VRCompositorError_AlreadySubmitted = 108; - /** native declaration : headers\openvr_capi.h:997 */ - public static final int EVRCompositorError_VRCompositorError_InvalidBounds = 109; - }; - /** - * native declaration : headers\openvr_capi.h:1003
- * enum values - */ - public static interface EVRCompositorTimingMode { - /** native declaration : headers\openvr_capi.h:1000 */ - public static final int EVRCompositorTimingMode_VRCompositorTimingMode_Implicit = 0; - /** native declaration : headers\openvr_capi.h:1001 */ - public static final int EVRCompositorTimingMode_VRCompositorTimingMode_Explicit_RuntimePerformsPostPresentHandoff = 1; - /** native declaration : headers\openvr_capi.h:1002 */ - public static final int EVRCompositorTimingMode_VRCompositorTimingMode_Explicit_ApplicationPerformsPostPresentHandoff = 2; - }; - /** - * native declaration : headers\openvr_capi.h:1008
- * enum values - */ - public static interface VROverlayInputMethod { - /** native declaration : headers\openvr_capi.h:1005 */ - public static final int VROverlayInputMethod_None = 0; - /** native declaration : headers\openvr_capi.h:1006 */ - public static final int VROverlayInputMethod_Mouse = 1; - /** native declaration : headers\openvr_capi.h:1007 */ - public static final int VROverlayInputMethod_DualAnalog = 2; - }; - /** - * native declaration : headers\openvr_capi.h:1014
- * enum values - */ - public static interface VROverlayTransformType { - /** native declaration : headers\openvr_capi.h:1010 */ - public static final int VROverlayTransformType_VROverlayTransform_Absolute = 0; - /** native declaration : headers\openvr_capi.h:1011 */ - public static final int VROverlayTransformType_VROverlayTransform_TrackedDeviceRelative = 1; - /** native declaration : headers\openvr_capi.h:1012 */ - public static final int VROverlayTransformType_VROverlayTransform_SystemOverlay = 2; - /** native declaration : headers\openvr_capi.h:1013 */ - public static final int VROverlayTransformType_VROverlayTransform_TrackedComponent = 3; - }; - /** - * native declaration : headers\openvr_capi.h:1032
- * enum values - */ - public static interface VROverlayFlags { - /** native declaration : headers\openvr_capi.h:1016 */ - public static final int VROverlayFlags_None = 0; - /** native declaration : headers\openvr_capi.h:1017 */ - public static final int VROverlayFlags_Curved = 1; - /** native declaration : headers\openvr_capi.h:1018 */ - public static final int VROverlayFlags_RGSS4X = 2; - /** native declaration : headers\openvr_capi.h:1019 */ - public static final int VROverlayFlags_NoDashboardTab = 3; - /** native declaration : headers\openvr_capi.h:1020 */ - public static final int VROverlayFlags_AcceptsGamepadEvents = 4; - /** native declaration : headers\openvr_capi.h:1021 */ - public static final int VROverlayFlags_ShowGamepadFocus = 5; - /** native declaration : headers\openvr_capi.h:1022 */ - public static final int VROverlayFlags_SendVRScrollEvents = 6; - /** native declaration : headers\openvr_capi.h:1023 */ - public static final int VROverlayFlags_SendVRTouchpadEvents = 7; - /** native declaration : headers\openvr_capi.h:1024 */ - public static final int VROverlayFlags_ShowTouchPadScrollWheel = 8; - /** native declaration : headers\openvr_capi.h:1025 */ - public static final int VROverlayFlags_TransferOwnershipToInternalProcess = 9; - /** native declaration : headers\openvr_capi.h:1026 */ - public static final int VROverlayFlags_SideBySide_Parallel = 10; - /** native declaration : headers\openvr_capi.h:1027 */ - public static final int VROverlayFlags_SideBySide_Crossed = 11; - /** native declaration : headers\openvr_capi.h:1028 */ - public static final int VROverlayFlags_Panorama = 12; - /** native declaration : headers\openvr_capi.h:1029 */ - public static final int VROverlayFlags_StereoPanorama = 13; - /** native declaration : headers\openvr_capi.h:1030 */ - public static final int VROverlayFlags_SortWithNonSceneOverlays = 14; - /** native declaration : headers\openvr_capi.h:1031 */ - public static final int VROverlayFlags_VisibleInDashboard = 15; - }; - /** - * native declaration : headers\openvr_capi.h:1041
- * enum values - */ - public static interface VRMessageOverlayResponse { - /** native declaration : headers\openvr_capi.h:1034 */ - public static final int VRMessageOverlayResponse_ButtonPress_0 = 0; - /** native declaration : headers\openvr_capi.h:1035 */ - public static final int VRMessageOverlayResponse_ButtonPress_1 = 1; - /** native declaration : headers\openvr_capi.h:1036 */ - public static final int VRMessageOverlayResponse_ButtonPress_2 = 2; - /** native declaration : headers\openvr_capi.h:1037 */ - public static final int VRMessageOverlayResponse_ButtonPress_3 = 3; - /** native declaration : headers\openvr_capi.h:1038 */ - public static final int VRMessageOverlayResponse_CouldntFindSystemOverlay = 4; - /** native declaration : headers\openvr_capi.h:1039 */ - public static final int VRMessageOverlayResponse_CouldntFindOrCreateClientOverlay = 5; - /** native declaration : headers\openvr_capi.h:1040 */ - public static final int VRMessageOverlayResponse_ApplicationQuit = 6; - }; - /** - * native declaration : headers\openvr_capi.h:1046
- * enum values - */ - public static interface EGamepadTextInputMode { - /** native declaration : headers\openvr_capi.h:1043 */ - public static final int EGamepadTextInputMode_k_EGamepadTextInputModeNormal = 0; - /** native declaration : headers\openvr_capi.h:1044 */ - public static final int EGamepadTextInputMode_k_EGamepadTextInputModePassword = 1; - /** native declaration : headers\openvr_capi.h:1045 */ - public static final int EGamepadTextInputMode_k_EGamepadTextInputModeSubmit = 2; - }; - /** - * native declaration : headers\openvr_capi.h:1050
- * enum values - */ - public static interface EGamepadTextInputLineMode { - /** native declaration : headers\openvr_capi.h:1048 */ - public static final int EGamepadTextInputLineMode_k_EGamepadTextInputLineModeSingleLine = 0; - /** native declaration : headers\openvr_capi.h:1049 */ - public static final int EGamepadTextInputLineMode_k_EGamepadTextInputLineModeMultipleLines = 1; - }; - /** - * native declaration : headers\openvr_capi.h:1057
- * enum values - */ - public static interface EOverlayDirection { - /** native declaration : headers\openvr_capi.h:1052 */ - public static final int EOverlayDirection_OverlayDirection_Up = 0; - /** native declaration : headers\openvr_capi.h:1053 */ - public static final int EOverlayDirection_OverlayDirection_Down = 1; - /** native declaration : headers\openvr_capi.h:1054 */ - public static final int EOverlayDirection_OverlayDirection_Left = 2; - /** native declaration : headers\openvr_capi.h:1055 */ - public static final int EOverlayDirection_OverlayDirection_Right = 3; - /** native declaration : headers\openvr_capi.h:1056 */ - public static final int EOverlayDirection_OverlayDirection_Count = 4; - }; - /** - * native declaration : headers\openvr_capi.h:1061
- * enum values - */ - public static interface EVROverlayIntersectionMaskPrimitiveType { - /** native declaration : headers\openvr_capi.h:1059 */ - public static final int EVROverlayIntersectionMaskPrimitiveType_OverlayIntersectionPrimitiveType_Rectangle = 0; - /** native declaration : headers\openvr_capi.h:1060 */ - public static final int EVROverlayIntersectionMaskPrimitiveType_OverlayIntersectionPrimitiveType_Circle = 1; - }; - /** - * native declaration : headers\openvr_capi.h:1076
- * enum values - */ - public static interface EVRRenderModelError { - /** native declaration : headers\openvr_capi.h:1063 */ - public static final int EVRRenderModelError_VRRenderModelError_None = 0; - /** native declaration : headers\openvr_capi.h:1064 */ - public static final int EVRRenderModelError_VRRenderModelError_Loading = 100; - /** native declaration : headers\openvr_capi.h:1065 */ - public static final int EVRRenderModelError_VRRenderModelError_NotSupported = 200; - /** native declaration : headers\openvr_capi.h:1066 */ - public static final int EVRRenderModelError_VRRenderModelError_InvalidArg = 300; - /** native declaration : headers\openvr_capi.h:1067 */ - public static final int EVRRenderModelError_VRRenderModelError_InvalidModel = 301; - /** native declaration : headers\openvr_capi.h:1068 */ - public static final int EVRRenderModelError_VRRenderModelError_NoShapes = 302; - /** native declaration : headers\openvr_capi.h:1069 */ - public static final int EVRRenderModelError_VRRenderModelError_MultipleShapes = 303; - /** native declaration : headers\openvr_capi.h:1070 */ - public static final int EVRRenderModelError_VRRenderModelError_TooManyVertices = 304; - /** native declaration : headers\openvr_capi.h:1071 */ - public static final int EVRRenderModelError_VRRenderModelError_MultipleTextures = 305; - /** native declaration : headers\openvr_capi.h:1072 */ - public static final int EVRRenderModelError_VRRenderModelError_BufferTooSmall = 306; - /** native declaration : headers\openvr_capi.h:1073 */ - public static final int EVRRenderModelError_VRRenderModelError_NotEnoughNormals = 307; - /** native declaration : headers\openvr_capi.h:1074 */ - public static final int EVRRenderModelError_VRRenderModelError_NotEnoughTexCoords = 308; - /** native declaration : headers\openvr_capi.h:1075 */ - public static final int EVRRenderModelError_VRRenderModelError_InvalidTexture = 400; - }; - /** - * native declaration : headers\openvr_capi.h:1083
- * enum values - */ - public static interface EVRComponentProperty { - /** native declaration : headers\openvr_capi.h:1078 */ - public static final int EVRComponentProperty_VRComponentProperty_IsStatic = 1; - /** native declaration : headers\openvr_capi.h:1079 */ - public static final int EVRComponentProperty_VRComponentProperty_IsVisible = 2; - /** native declaration : headers\openvr_capi.h:1080 */ - public static final int EVRComponentProperty_VRComponentProperty_IsTouched = 4; - /** native declaration : headers\openvr_capi.h:1081 */ - public static final int EVRComponentProperty_VRComponentProperty_IsPressed = 8; - /** native declaration : headers\openvr_capi.h:1082 */ - public static final int EVRComponentProperty_VRComponentProperty_IsScrolled = 16; - }; - /** - * native declaration : headers\openvr_capi.h:1088
- * enum values - */ - public static interface EVRNotificationType { - /** native declaration : headers\openvr_capi.h:1085 */ - public static final int EVRNotificationType_Transient = 0; - /** native declaration : headers\openvr_capi.h:1086 */ - public static final int EVRNotificationType_Persistent = 1; - /** native declaration : headers\openvr_capi.h:1087 */ - public static final int EVRNotificationType_Transient_SystemWithUserValue = 2; - }; - /** - * native declaration : headers\openvr_capi.h:1095
- * enum values - */ - public static interface EVRNotificationStyle { - /** native declaration : headers\openvr_capi.h:1090 */ - public static final int EVRNotificationStyle_None = 0; - /** native declaration : headers\openvr_capi.h:1091 */ - public static final int EVRNotificationStyle_Application = 100; - /** native declaration : headers\openvr_capi.h:1092 */ - public static final int EVRNotificationStyle_Contact_Disabled = 200; - /** native declaration : headers\openvr_capi.h:1093 */ - public static final int EVRNotificationStyle_Contact_Enabled = 201; - /** native declaration : headers\openvr_capi.h:1094 */ - public static final int EVRNotificationStyle_Contact_Active = 202; - }; - /** - * native declaration : headers\openvr_capi.h:1103
- * enum values - */ - public static interface EVRSettingsError { - /** native declaration : headers\openvr_capi.h:1097 */ - public static final int EVRSettingsError_VRSettingsError_None = 0; - /** native declaration : headers\openvr_capi.h:1098 */ - public static final int EVRSettingsError_VRSettingsError_IPCFailed = 1; - /** native declaration : headers\openvr_capi.h:1099 */ - public static final int EVRSettingsError_VRSettingsError_WriteFailed = 2; - /** native declaration : headers\openvr_capi.h:1100 */ - public static final int EVRSettingsError_VRSettingsError_ReadFailed = 3; - /** native declaration : headers\openvr_capi.h:1101 */ - public static final int EVRSettingsError_VRSettingsError_JsonParseFailed = 4; - /** native declaration : headers\openvr_capi.h:1102 */ - public static final int EVRSettingsError_VRSettingsError_UnsetSettingHasNoDefault = 5; - }; - /** - * native declaration : headers\openvr_capi.h:1111
- * enum values - */ - public static interface EVRScreenshotError { - /** native declaration : headers\openvr_capi.h:1105 */ - public static final int EVRScreenshotError_VRScreenshotError_None = 0; - /** native declaration : headers\openvr_capi.h:1106 */ - public static final int EVRScreenshotError_VRScreenshotError_RequestFailed = 1; - /** native declaration : headers\openvr_capi.h:1107 */ - public static final int EVRScreenshotError_VRScreenshotError_IncompatibleVersion = 100; - /** native declaration : headers\openvr_capi.h:1108 */ - public static final int EVRScreenshotError_VRScreenshotError_NotFound = 101; - /** native declaration : headers\openvr_capi.h:1109 */ - public static final int EVRScreenshotError_VRScreenshotError_BufferTooSmall = 102; - /** native declaration : headers\openvr_capi.h:1110 */ - public static final int EVRScreenshotError_VRScreenshotError_ScreenshotAlreadyInProgress = 108; - }; - /** - * native declaration : headers\openvr_capi.h:1116
- * enum values - */ - public static interface EVRSkeletalTransformSpace { - /** native declaration : headers\openvr_capi.h:1113 */ - public static final int EVRSkeletalTransformSpace_VRSkeletalTransformSpace_Model = 0; - /** native declaration : headers\openvr_capi.h:1114 */ - public static final int EVRSkeletalTransformSpace_VRSkeletalTransformSpace_Parent = 1; - /** native declaration : headers\openvr_capi.h:1115 */ - public static final int EVRSkeletalTransformSpace_VRSkeletalTransformSpace_Additive = 2; - }; - /** - * native declaration : headers\openvr_capi.h:1120
- * enum values - */ - public static interface EVRInputFilterCancelType { - /** native declaration : headers\openvr_capi.h:1118 */ - public static final int EVRInputFilterCancelType_VRInputFilterCancel_Timers = 0; - /** native declaration : headers\openvr_capi.h:1119 */ - public static final int EVRInputFilterCancelType_VRInputFilterCancel_Momentum = 1; - }; - /** - * native declaration : headers\openvr_capi.h:1129
- * enum values - */ - public static interface EIOBufferError { - /** native declaration : headers\openvr_capi.h:1122 */ - public static final int EIOBufferError_IOBuffer_Success = 0; - /** native declaration : headers\openvr_capi.h:1123 */ - public static final int EIOBufferError_IOBuffer_OperationFailed = 100; - /** native declaration : headers\openvr_capi.h:1124 */ - public static final int EIOBufferError_IOBuffer_InvalidHandle = 101; - /** native declaration : headers\openvr_capi.h:1125 */ - public static final int EIOBufferError_IOBuffer_InvalidArgument = 102; - /** native declaration : headers\openvr_capi.h:1126 */ - public static final int EIOBufferError_IOBuffer_PathExists = 103; - /** native declaration : headers\openvr_capi.h:1127 */ - public static final int EIOBufferError_IOBuffer_PathDoesNotExist = 104; - /** native declaration : headers\openvr_capi.h:1128 */ - public static final int EIOBufferError_IOBuffer_Permission = 105; - }; - /** - * native declaration : headers\openvr_capi.h:1134
- * enum values - */ - public static interface EIOBufferMode { - /** native declaration : headers\openvr_capi.h:1131 */ - public static final int EIOBufferMode_IOBufferMode_Read = 1; - /** native declaration : headers\openvr_capi.h:1132 */ - public static final int EIOBufferMode_IOBufferMode_Write = 2; - /** native declaration : headers\openvr_capi.h:1133 */ - public static final int EIOBufferMode_IOBufferMode_Create = 512; - }; - /** OpenVR Constants */ - public static final long k_nDriverNone = 4294967295L; - public static final int k_unMaxDriverDebugResponseSize = 32768; - public static final int k_unTrackedDeviceIndex_Hmd = 0; - public static final int k_unMaxTrackedDeviceCount = 64; - public static final int k_unTrackedDeviceIndexOther = -2; - public static final long k_unTrackedDeviceIndexInvalid = 4294967295L; - public static final long k_ulInvalidPropertyContainer = 0; - public static final int k_unInvalidPropertyTag = 0; - public static final long k_ulInvalidDriverHandle = 0; - public static final int k_unFloatPropertyTag = 1; - public static final int k_unInt32PropertyTag = 2; - public static final int k_unUint64PropertyTag = 3; - public static final int k_unBoolPropertyTag = 4; - public static final int k_unStringPropertyTag = 5; - public static final int k_unHmdMatrix34PropertyTag = 20; - public static final int k_unHmdMatrix44PropertyTag = 21; - public static final int k_unHmdVector3PropertyTag = 22; - public static final int k_unHmdVector4PropertyTag = 23; - public static final int k_unHiddenAreaPropertyTag = 30; - public static final int k_unPathHandleInfoTag = 31; - public static final int k_unActionPropertyTag = 32; - public static final int k_unInputValuePropertyTag = 33; - public static final int k_unWildcardPropertyTag = 34; - public static final int k_unHapticVibrationPropertyTag = 35; - public static final int k_unSkeletonPropertyTag = 36; - public static final int k_unSpatialAnchorPosePropertyTag = 40; - public static final int k_unOpenVRInternalReserved_Start = 1000; - public static final int k_unOpenVRInternalReserved_End = 10000; - public static final int k_unMaxPropertyStringSize = 32768; - public static final long k_ulInvalidActionHandle = 0; - public static final long k_ulInvalidActionSetHandle = 0; - public static final long k_ulInvalidInputValueHandle = 0; - public static final int k_unControllerStateAxisCount = 5; - public static final long k_ulOverlayHandleInvalid = 0; - public static final int k_unScreenshotHandleInvalid = 0; - public static final int k_unMaxApplicationKeyLength = 128; - public static final int k_unVROverlayMaxKeyLength = 128; - public static final int k_unVROverlayMaxNameLength = 128; - public static final int k_unMaxOverlayCount = 64; - public static final int k_unMaxOverlayIntersectionMaskPrimitivesCount = 32; - public static final int k_unNotificationTextMaxSize = 256; - public static final int k_unMaxSettingsKeyLength = 128; - public static final int k_unMaxActionNameLength = 64; - public static final int k_unMaxActionSetNameLength = 64; - public static final int k_unMaxActionOriginCount = 16; - public static final long k_ulInvalidIOBufferHandle = 0; - public static final int k_ulInvalidSpatialAnchorHandle = 0; - - - public static final String IVRSystem_Version = "IVRSystem_019"; - public static final String IVRExtendedDisplay_Version = "IVRExtendedDisplay_001"; - public static final String IVRTrackedCamera_Version = "IVRTrackedCamera_003"; - public static final String k_pch_MimeType_HomeApp = "vr/home"; - public static final String k_pch_MimeType_GameTheater = "vr/game_theater"; - public static final String IVRApplications_Version = "IVRApplications_006"; - public static final String IVRChaperone_Version = "IVRChaperone_003"; - public static final String IVRChaperoneSetup_Version = "IVRChaperoneSetup_005"; - public static final String IVRCompositor_Version = "IVRCompositor_022"; - public static final String IVROverlay_Version = "IVROverlay_018"; - public static final String k_pch_Controller_Component_GDC2015 = "gdc2015"; - public static final String k_pch_Controller_Component_Base = "base"; - public static final String k_pch_Controller_Component_Tip = "tip"; - public static final String k_pch_Controller_Component_HandGrip = "handgrip"; - public static final String k_pch_Controller_Component_Status = "status"; - public static final String IVRRenderModels_Version = "IVRRenderModels_006"; - public static final String IVRNotifications_Version = "IVRNotifications_002"; - public static final String IVRSettings_Version = "IVRSettings_002"; - public static final String k_pch_SteamVR_Section = "steamvr"; - public static final String k_pch_SteamVR_RequireHmd_String = "requireHmd"; - public static final String k_pch_SteamVR_ForcedDriverKey_String = "forcedDriver"; - public static final String k_pch_SteamVR_ForcedHmdKey_String = "forcedHmd"; - public static final String k_pch_SteamVR_DisplayDebug_Bool = "displayDebug"; - public static final String k_pch_SteamVR_DebugProcessPipe_String = "debugProcessPipe"; - public static final String k_pch_SteamVR_DisplayDebugX_Int32 = "displayDebugX"; - public static final String k_pch_SteamVR_DisplayDebugY_Int32 = "displayDebugY"; - public static final String k_pch_SteamVR_SendSystemButtonToAllApps_Bool = "sendSystemButtonToAllApps"; - public static final String k_pch_SteamVR_LogLevel_Int32 = "loglevel"; - public static final String k_pch_SteamVR_IPD_Float = "ipd"; - public static final String k_pch_SteamVR_Background_String = "background"; - public static final String k_pch_SteamVR_BackgroundUseDomeProjection_Bool = "backgroundUseDomeProjection"; - public static final String k_pch_SteamVR_BackgroundCameraHeight_Float = "backgroundCameraHeight"; - public static final String k_pch_SteamVR_BackgroundDomeRadius_Float = "backgroundDomeRadius"; - public static final String k_pch_SteamVR_GridColor_String = "gridColor"; - public static final String k_pch_SteamVR_PlayAreaColor_String = "playAreaColor"; - public static final String k_pch_SteamVR_ShowStage_Bool = "showStage"; - public static final String k_pch_SteamVR_ActivateMultipleDrivers_Bool = "activateMultipleDrivers"; - public static final String k_pch_SteamVR_DirectMode_Bool = "directMode"; - public static final String k_pch_SteamVR_DirectModeEdidVid_Int32 = "directModeEdidVid"; - public static final String k_pch_SteamVR_DirectModeEdidPid_Int32 = "directModeEdidPid"; - public static final String k_pch_SteamVR_UsingSpeakers_Bool = "usingSpeakers"; - public static final String k_pch_SteamVR_SpeakersForwardYawOffsetDegrees_Float = "speakersForwardYawOffsetDegrees"; - public static final String k_pch_SteamVR_BaseStationPowerManagement_Bool = "basestationPowerManagement"; - public static final String k_pch_SteamVR_NeverKillProcesses_Bool = "neverKillProcesses"; - public static final String k_pch_SteamVR_SupersampleScale_Float = "supersampleScale"; - public static final String k_pch_SteamVR_AllowAsyncReprojection_Bool = "allowAsyncReprojection"; - public static final String k_pch_SteamVR_AllowReprojection_Bool = "allowInterleavedReprojection"; - public static final String k_pch_SteamVR_ForceReprojection_Bool = "forceReprojection"; - public static final String k_pch_SteamVR_ForceFadeOnBadTracking_Bool = "forceFadeOnBadTracking"; - public static final String k_pch_SteamVR_DefaultMirrorView_Int32 = "defaultMirrorView"; - public static final String k_pch_SteamVR_ShowMirrorView_Bool = "showMirrorView"; - public static final String k_pch_SteamVR_MirrorViewGeometry_String = "mirrorViewGeometry"; - public static final String k_pch_SteamVR_StartMonitorFromAppLaunch = "startMonitorFromAppLaunch"; - public static final String k_pch_SteamVR_StartCompositorFromAppLaunch_Bool = "startCompositorFromAppLaunch"; - public static final String k_pch_SteamVR_StartDashboardFromAppLaunch_Bool = "startDashboardFromAppLaunch"; - public static final String k_pch_SteamVR_StartOverlayAppsFromDashboard_Bool = "startOverlayAppsFromDashboard"; - public static final String k_pch_SteamVR_EnableHomeApp = "enableHomeApp"; - public static final String k_pch_SteamVR_CycleBackgroundImageTimeSec_Int32 = "CycleBackgroundImageTimeSec"; - public static final String k_pch_SteamVR_RetailDemo_Bool = "retailDemo"; - public static final String k_pch_SteamVR_IpdOffset_Float = "ipdOffset"; - public static final String k_pch_SteamVR_AllowSupersampleFiltering_Bool = "allowSupersampleFiltering"; - public static final String k_pch_SteamVR_SupersampleManualOverride_Bool = "supersampleManualOverride"; - public static final String k_pch_SteamVR_EnableLinuxVulkanAsync_Bool = "enableLinuxVulkanAsync"; - public static final String k_pch_SteamVR_AllowDisplayLockedMode_Bool = "allowDisplayLockedMode"; - public static final String k_pch_SteamVR_HaveStartedTutorialForNativeChaperoneDriver_Bool = "haveStartedTutorialForNativeChaperoneDriver"; - public static final String k_pch_SteamVR_ForceWindows32bitVRMonitor = "forceWindows32BitVRMonitor"; - public static final String k_pch_SteamVR_DebugInput = "debugInput"; - public static final String k_pch_SteamVR_LegacyInputRebinding = "legacyInputRebinding"; - public static final String k_pch_SteamVR_DebugInputBinding = "debugInputBinding"; - public static final String k_pch_SteamVR_InputBindingUIBlock = "inputBindingUI"; - public static final String k_pch_SteamVR_RenderCameraMode = "renderCameraMode"; - public static final String k_pch_Lighthouse_Section = "driver_lighthouse"; - public static final String k_pch_Lighthouse_DisableIMU_Bool = "disableimu"; - public static final String k_pch_Lighthouse_DisableIMUExceptHMD_Bool = "disableimuexcepthmd"; - public static final String k_pch_Lighthouse_UseDisambiguation_String = "usedisambiguation"; - public static final String k_pch_Lighthouse_DisambiguationDebug_Int32 = "disambiguationdebug"; - public static final String k_pch_Lighthouse_PrimaryBasestation_Int32 = "primarybasestation"; - public static final String k_pch_Lighthouse_DBHistory_Bool = "dbhistory"; - public static final String k_pch_Lighthouse_EnableBluetooth_Bool = "enableBluetooth"; - public static final String k_pch_Lighthouse_PowerManagedBaseStations_String = "PowerManagedBaseStations"; - public static final String k_pch_Null_Section = "driver_null"; - public static final String k_pch_Null_SerialNumber_String = "serialNumber"; - public static final String k_pch_Null_ModelNumber_String = "modelNumber"; - public static final String k_pch_Null_WindowX_Int32 = "windowX"; - public static final String k_pch_Null_WindowY_Int32 = "windowY"; - public static final String k_pch_Null_WindowWidth_Int32 = "windowWidth"; - public static final String k_pch_Null_WindowHeight_Int32 = "windowHeight"; - public static final String k_pch_Null_RenderWidth_Int32 = "renderWidth"; - public static final String k_pch_Null_RenderHeight_Int32 = "renderHeight"; - public static final String k_pch_Null_SecondsFromVsyncToPhotons_Float = "secondsFromVsyncToPhotons"; - public static final String k_pch_Null_DisplayFrequency_Float = "displayFrequency"; - public static final String k_pch_UserInterface_Section = "userinterface"; - public static final String k_pch_UserInterface_StatusAlwaysOnTop_Bool = "StatusAlwaysOnTop"; - public static final String k_pch_UserInterface_MinimizeToTray_Bool = "MinimizeToTray"; - public static final String k_pch_UserInterface_Screenshots_Bool = "screenshots"; - public static final String k_pch_UserInterface_ScreenshotType_Int = "screenshotType"; - public static final String k_pch_Notifications_Section = "notifications"; - public static final String k_pch_Notifications_DoNotDisturb_Bool = "DoNotDisturb"; - public static final String k_pch_Keyboard_Section = "keyboard"; - public static final String k_pch_Keyboard_TutorialCompletions = "TutorialCompletions"; - public static final String k_pch_Keyboard_ScaleX = "ScaleX"; - public static final String k_pch_Keyboard_ScaleY = "ScaleY"; - public static final String k_pch_Keyboard_OffsetLeftX = "OffsetLeftX"; - public static final String k_pch_Keyboard_OffsetRightX = "OffsetRightX"; - public static final String k_pch_Keyboard_OffsetY = "OffsetY"; - public static final String k_pch_Keyboard_Smoothing = "Smoothing"; - public static final String k_pch_Perf_Section = "perfcheck"; - public static final String k_pch_Perf_HeuristicActive_Bool = "heuristicActive"; - public static final String k_pch_Perf_NotifyInHMD_Bool = "warnInHMD"; - public static final String k_pch_Perf_NotifyOnlyOnce_Bool = "warnOnlyOnce"; - public static final String k_pch_Perf_AllowTimingStore_Bool = "allowTimingStore"; - public static final String k_pch_Perf_SaveTimingsOnExit_Bool = "saveTimingsOnExit"; - public static final String k_pch_Perf_TestData_Float = "perfTestData"; - public static final String k_pch_Perf_LinuxGPUProfiling_Bool = "linuxGPUProfiling"; - public static final String k_pch_CollisionBounds_Section = "collisionBounds"; - public static final String k_pch_CollisionBounds_Style_Int32 = "CollisionBoundsStyle"; - public static final String k_pch_CollisionBounds_GroundPerimeterOn_Bool = "CollisionBoundsGroundPerimeterOn"; - public static final String k_pch_CollisionBounds_CenterMarkerOn_Bool = "CollisionBoundsCenterMarkerOn"; - public static final String k_pch_CollisionBounds_PlaySpaceOn_Bool = "CollisionBoundsPlaySpaceOn"; - public static final String k_pch_CollisionBounds_FadeDistance_Float = "CollisionBoundsFadeDistance"; - public static final String k_pch_CollisionBounds_ColorGammaR_Int32 = "CollisionBoundsColorGammaR"; - public static final String k_pch_CollisionBounds_ColorGammaG_Int32 = "CollisionBoundsColorGammaG"; - public static final String k_pch_CollisionBounds_ColorGammaB_Int32 = "CollisionBoundsColorGammaB"; - public static final String k_pch_CollisionBounds_ColorGammaA_Int32 = "CollisionBoundsColorGammaA"; - public static final String k_pch_Camera_Section = "camera"; - public static final String k_pch_Camera_EnableCamera_Bool = "enableCamera"; - public static final String k_pch_Camera_EnableCameraInDashboard_Bool = "enableCameraInDashboard"; - public static final String k_pch_Camera_EnableCameraForCollisionBounds_Bool = "enableCameraForCollisionBounds"; - public static final String k_pch_Camera_EnableCameraForRoomView_Bool = "enableCameraForRoomView"; - public static final String k_pch_Camera_BoundsColorGammaR_Int32 = "cameraBoundsColorGammaR"; - public static final String k_pch_Camera_BoundsColorGammaG_Int32 = "cameraBoundsColorGammaG"; - public static final String k_pch_Camera_BoundsColorGammaB_Int32 = "cameraBoundsColorGammaB"; - public static final String k_pch_Camera_BoundsColorGammaA_Int32 = "cameraBoundsColorGammaA"; - public static final String k_pch_Camera_BoundsStrength_Int32 = "cameraBoundsStrength"; - public static final String k_pch_Camera_RoomViewMode_Int32 = "cameraRoomViewMode"; - public static final String k_pch_audio_Section = "audio"; - public static final String k_pch_audio_OnPlaybackDevice_String = "onPlaybackDevice"; - public static final String k_pch_audio_OnRecordDevice_String = "onRecordDevice"; - public static final String k_pch_audio_OnPlaybackMirrorDevice_String = "onPlaybackMirrorDevice"; - public static final String k_pch_audio_OffPlaybackDevice_String = "offPlaybackDevice"; - public static final String k_pch_audio_OffRecordDevice_String = "offRecordDevice"; - public static final String k_pch_audio_VIVEHDMIGain = "viveHDMIGain"; - public static final String k_pch_Power_Section = "power"; - public static final String k_pch_Power_PowerOffOnExit_Bool = "powerOffOnExit"; - public static final String k_pch_Power_TurnOffScreensTimeout_Float = "turnOffScreensTimeout"; - public static final String k_pch_Power_TurnOffControllersTimeout_Float = "turnOffControllersTimeout"; - public static final String k_pch_Power_ReturnToWatchdogTimeout_Float = "returnToWatchdogTimeout"; - public static final String k_pch_Power_AutoLaunchSteamVROnButtonPress = "autoLaunchSteamVROnButtonPress"; - public static final String k_pch_Power_PauseCompositorOnStandby_Bool = "pauseCompositorOnStandby"; - public static final String k_pch_Dashboard_Section = "dashboard"; - public static final String k_pch_Dashboard_EnableDashboard_Bool = "enableDashboard"; - public static final String k_pch_Dashboard_ArcadeMode_Bool = "arcadeMode"; - public static final String k_pch_Dashboard_EnableWebUI = "webUI"; - public static final String k_pch_Dashboard_EnableWebUIDevTools = "webUIDevTools"; - public static final String k_pch_Dashboard_EnableWebUIDashboardReplacement = "webUIDashboard"; - public static final String k_pch_modelskin_Section = "modelskins"; - public static final String k_pch_Driver_Enable_Bool = "enable"; - public static final String k_pch_WebInterface_Section = "WebInterface"; - public static final String k_pch_WebInterface_WebEnable_Bool = "WebEnable"; - public static final String k_pch_WebInterface_WebPort_String = "WebPort"; - public static final String k_pch_TrackingOverride_Section = "TrackingOverrides"; - public static final String k_pch_App_BindingAutosaveURLSuffix_String = "AutosaveURL"; - public static final String k_pch_App_BindingCurrentURLSuffix_String = "CurrentURL"; - public static final String k_pch_App_NeedToUpdateAutosaveSuffix_Bool = "NeedToUpdateAutosave"; - public static final String k_pch_App_ActionManifestURL_String = "ActionManifestURL"; - public static final String k_pch_Trackers_Section = "trackers"; - public static final String IVRScreenshots_Version = "IVRScreenshots_001"; - public static final String IVRResources_Version = "IVRResources_001"; - public static final String IVRDriverManager_Version = "IVRDriverManager_001"; - public static final String IVRInput_Version = "IVRInput_004"; - public static final String IVRIOBuffer_Version = "IVRIOBuffer_001"; - public static final String IVRSpatialAnchors_Version = "IVRSpatialAnchors_001"; - - - /** - * Global entry points
- * Original signature : intptr_t VR_InitInternal(EVRInitError*, EVRApplicationType)
- * native declaration : headers\openvr_capi.h:2378
- * @deprecated use the safer methods {@link #VR_InitInternal(java.nio.IntBuffer, int)} and {@link #VR_InitInternal(com.sun.jna.ptr.IntByReference, int)} instead - */ - @Deprecated - public static native IntByReference VR_InitInternal(IntByReference peError, int eType); - /** - * Global entry points
- * Original signature : intptr_t VR_InitInternal(EVRInitError*, EVRApplicationType)
- * native declaration : headers\openvr_capi.h:2378 - */ - public static native IntByReference VR_InitInternal(IntBuffer peError, int eType); - /** - * Original signature : void VR_ShutdownInternal()
- * native declaration : headers\openvr_capi.h:2380 - */ - public static native void VR_ShutdownInternal(); - /** - * Original signature : bool VR_IsHmdPresent()
- * native declaration : headers\openvr_capi.h:2382 - */ - public static native byte VR_IsHmdPresent(); - /** - * Original signature : intptr_t VR_GetGenericInterface(const char*, EVRInitError*)
- * native declaration : headers\openvr_capi.h:2384
- * @deprecated use the safer method - * {@link #VR_GetGenericInterface(java.lang.String, com.sun.jna.ptr.IntByReference)} - * instead - */ - @Deprecated - public static native IntByReference VR_GetGenericInterface(Pointer pchInterfaceVersion, IntByReference peError); - /** - * Original signature : intptr_t VR_GetGenericInterface(const char*, EVRInitError*)
- * native declaration : headers\openvr_capi.h:2384 - */ - public static native IntByReference VR_GetGenericInterface(String pchInterfaceVersion, IntByReference peError); - /** - * Original signature : bool VR_IsRuntimeInstalled()
- * native declaration : headers\openvr_capi.h:2386 - */ - public static native byte VR_IsRuntimeInstalled(); - /** - * Original signature : char* VR_GetVRInitErrorAsSymbol(EVRInitError)
- * native declaration : headers\openvr_capi.h:2388 - */ - public static native Pointer VR_GetVRInitErrorAsSymbol(int error); - /** - * Original signature : char* VR_GetVRInitErrorAsEnglishDescription(EVRInitError)
- * native declaration : headers\openvr_capi.h:2390 - */ - public static native Pointer VR_GetVRInitErrorAsEnglishDescription(int error); - public static class VkQueue_T extends PointerType { - public VkQueue_T(Pointer address) { - super(address); - } - public VkQueue_T() { - super(); - } - }; - public static class VkPhysicalDevice_T extends PointerType { - public VkPhysicalDevice_T(Pointer address) { - super(address); - } - public VkPhysicalDevice_T() { - super(); - } - }; - public static class VkInstance_T extends PointerType { - public VkInstance_T(Pointer address) { - super(address); - } - public VkInstance_T() { - super(); - } - }; - public static class ID3D12CommandQueue extends PointerType { - public ID3D12CommandQueue(Pointer address) { - super(address); - } - public ID3D12CommandQueue() { - super(); - } - }; - public static class ID3D12Resource extends PointerType { - public ID3D12Resource(Pointer address) { - super(address); - } - public ID3D12Resource() { - super(); - } - }; - public static class VkDevice_T extends PointerType { - public VkDevice_T(Pointer address) { - super(address); - } - public VkDevice_T() { - super(); - } - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/NotificationBitmap_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/NotificationBitmap_t.java deleted file mode 100644 index b9aaffe311..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/NotificationBitmap_t.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1588
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class NotificationBitmap_t extends Structure { - /** - * void *
- * C type : void* - */ - public Pointer m_pImageData; - public int m_nWidth; - public int m_nHeight; - public int m_nBytesPerPixel; - public NotificationBitmap_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("m_pImageData", "m_nWidth", "m_nHeight", "m_nBytesPerPixel"); - } - /** - * @param m_pImageData void *
- * C type : void* - */ - public NotificationBitmap_t(Pointer m_pImageData, int m_nWidth, int m_nHeight, int m_nBytesPerPixel) { - super(); - this.m_pImageData = m_pImageData; - this.m_nWidth = m_nWidth; - this.m_nHeight = m_nHeight; - this.m_nBytesPerPixel = m_nBytesPerPixel; - } - public NotificationBitmap_t(Pointer peer) { - super(peer); - } - public static class ByReference extends NotificationBitmap_t implements Structure.ByReference { - - }; - public static class ByValue extends NotificationBitmap_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/OpenVRUtil.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/OpenVRUtil.java deleted file mode 100644 index 2d075cf80a..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/OpenVRUtil.java +++ /dev/null @@ -1,779 +0,0 @@ -package com.jme3.system.jopenvr; - -import com.jme3.input.vr.openvr.OpenVRInput; -import com.jme3.system.jopenvr.JOpenVRLibrary.EColorSpace; -import com.jme3.system.jopenvr.JOpenVRLibrary.ETextureType; -import com.jme3.system.jopenvr.JOpenVRLibrary.ETrackedDeviceProperty; -import com.jme3.system.jopenvr.JOpenVRLibrary.ETrackedPropertyError; -import com.jme3.system.jopenvr.JOpenVRLibrary.EVRCompositorError; -import com.jme3.system.jopenvr.JOpenVRLibrary.EVRInitError; -import com.sun.jna.Memory; -import com.sun.jna.Pointer; -import com.sun.jna.ptr.IntByReference; - -/** - * A utility class that provide helper methods for OpenVR system. - * @author Julien Seinturier - 2017 - http://www.seinturier.fr - */ -public class OpenVRUtil { - /** - * A private constructor to inhibit instantiation of this class. - */ - private OpenVRUtil() { - } - - /** - * Get the value of the given string {@link JOpenVRLibrary.ETrackedDeviceProperty property} attached to the given device. - * @param system the underlying OpenVR system. - * @param deviceIndex the index of the device to query. - * @param property the property to query. - * @param bufferSize the size of the buffer to use for storing native string. - * @return the value of the given string property attached to the given device. - * @see OpenVRInput#getTrackedControllerCount() - * @see JOpenVRLibrary.ETrackedDeviceProperty - * @see #getTrackedDeviceStringProperty(VR_IVRSystem_FnTable, int, int) - */ - public static String getTrackedDeviceStringProperty(VR_IVRSystem_FnTable system, int deviceIndex, int property, int bufferSize){ - String str =""; - - int unBufferSize = 256; - Pointer pchValue = new Memory(unBufferSize); - IntByReference pError = new IntByReference(); - - system.GetStringTrackedDeviceProperty.apply(deviceIndex, property, pchValue, unBufferSize, pError); - - if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_Success){ - str = pchValue.getString(0); - } else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_BufferTooSmall){ - throw new IllegalArgumentException("Cannot access property \""+getETrackedDevicePropertyString(property)+"\" ("+property+") for device "+deviceIndex+": "+getETrackedPropertyErrorString(pError.getValue())+" ("+pError.getValue()+")"); - } else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_CouldNotContactServer){ - throw new IllegalArgumentException("Cannot access property \""+getETrackedDevicePropertyString(property)+"\" ("+property+") for device "+deviceIndex+": "+getETrackedPropertyErrorString(pError.getValue())+" ("+pError.getValue()+")"); - } else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_InvalidDevice){ - throw new IllegalArgumentException("Cannot access property \""+getETrackedDevicePropertyString(property)+"\" ("+property+") for device "+deviceIndex+": "+getETrackedPropertyErrorString(pError.getValue())+" ("+pError.getValue()+")"); - } else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_InvalidOperation){ - throw new IllegalArgumentException("Cannot access property \""+getETrackedDevicePropertyString(property)+"\" ("+property+") for device "+deviceIndex+": "+getETrackedPropertyErrorString(pError.getValue())+" ("+pError.getValue()+")"); - } else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_NotYetAvailable){ - throw new IllegalArgumentException("Cannot access property \""+getETrackedDevicePropertyString(property)+"\" ("+property+") for device "+deviceIndex+": "+getETrackedPropertyErrorString(pError.getValue())+" ("+pError.getValue()+")"); - } else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_PermissionDenied){ - throw new IllegalArgumentException("Cannot access property \""+getETrackedDevicePropertyString(property)+"\" ("+property+") for device "+deviceIndex+": "+getETrackedPropertyErrorString(pError.getValue())+" ("+pError.getValue()+")"); - } else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_StringExceedsMaximumLength){ - throw new IllegalArgumentException("Cannot access property \""+getETrackedDevicePropertyString(property)+"\" ("+property+") for device "+deviceIndex+": "+getETrackedPropertyErrorString(pError.getValue())+" ("+pError.getValue()+")"); - } else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_UnknownProperty){ - throw new IllegalArgumentException("Cannot access property \""+getETrackedDevicePropertyString(property)+"\" ("+property+") for device "+deviceIndex+": "+getETrackedPropertyErrorString(pError.getValue())+" ("+pError.getValue()+")"); - } else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_ValueNotProvidedByDevice){ - throw new IllegalArgumentException("Cannot access property \""+getETrackedDevicePropertyString(property)+"\" ("+property+") for device "+deviceIndex+": "+getETrackedPropertyErrorString(pError.getValue())+" ("+pError.getValue()+")"); - } else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_WrongDataType){ - throw new IllegalArgumentException("Cannot access property \""+getETrackedDevicePropertyString(property)+"\" ("+property+") for device "+deviceIndex+": "+getETrackedPropertyErrorString(pError.getValue())+" ("+pError.getValue()+")"); - } else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_WrongDeviceClass){ - throw new IllegalArgumentException("Cannot access property \""+getETrackedDevicePropertyString(property)+"\" ("+property+") for device "+deviceIndex+": "+getETrackedPropertyErrorString(pError.getValue())+" ("+pError.getValue()+")"); - } else { - throw new IllegalArgumentException("Cannot access property \""+getETrackedDevicePropertyString(property)+"\" ("+property+") for device "+deviceIndex+": "+getETrackedPropertyErrorString(pError.getValue())+" ("+pError.getValue()+")"); - } - - return str; - } - - /** - * Get the value of the given string {@link JOpenVRLibrary.ETrackedDeviceProperty property} attached to the given device. - * @param system the underlying OpenVR system. - * @param deviceIndex the index of the device to query. - * @param property the property to query. - * @return the value of the given string property attached to the given device. - * @see OpenVRInput#getTrackedControllerCount() - * @see JOpenVRLibrary.ETrackedDeviceProperty - * @see #getTrackedDeviceStringProperty(VR_IVRSystem_FnTable, int, int, int) - */ - public static String getTrackedDeviceStringProperty(VR_IVRSystem_FnTable system, int deviceIndex, int property){ - return getTrackedDeviceStringProperty(system, deviceIndex, property, 256); - } - - /** - * Get the String description of the given {@link ETrackedPropertyError string tracked property error}. - * @param error the string tracked property error. - * @return the String description of the given string tracked property error. - */ - public static String getETrackedPropertyErrorString(int error){ - String str =""; - - switch(error){ - case ETrackedPropertyError.ETrackedPropertyError_TrackedProp_Success: - str = "Success"; - break; - case ETrackedPropertyError.ETrackedPropertyError_TrackedProp_WrongDataType: - str = "Wrong data type"; - break; - case ETrackedPropertyError.ETrackedPropertyError_TrackedProp_WrongDeviceClass: - str = "Wrong device class"; - break; - case ETrackedPropertyError.ETrackedPropertyError_TrackedProp_BufferTooSmall: - str = "Buffer too small"; - break; - case ETrackedPropertyError.ETrackedPropertyError_TrackedProp_UnknownProperty: - str = "Unknown property"; - break; - case ETrackedPropertyError.ETrackedPropertyError_TrackedProp_InvalidDevice: - str = "Invalid device"; - break; - case ETrackedPropertyError.ETrackedPropertyError_TrackedProp_CouldNotContactServer: - str = "Could not contact server"; - break; - case ETrackedPropertyError.ETrackedPropertyError_TrackedProp_ValueNotProvidedByDevice: - str = "Value not provided by device"; - break; - case ETrackedPropertyError.ETrackedPropertyError_TrackedProp_StringExceedsMaximumLength: - str = "String exceed maximum length"; - break; - case ETrackedPropertyError.ETrackedPropertyError_TrackedProp_NotYetAvailable: - str = "Not yet available"; - break; - case ETrackedPropertyError.ETrackedPropertyError_TrackedProp_PermissionDenied: - str = "Permission denied"; - break; - case ETrackedPropertyError.ETrackedPropertyError_TrackedProp_InvalidOperation: - str = "Invalid operation"; - break; - default: - str = "Not handled error"; - } - - return str; - } - - /** - * Get the description of the given {@link EColorSpace color space}. - * @param eColorSpace the color space. - * @return the description of the given color space. - */ - public static String getEColorSpaceString(int eColorSpace){ - String str = ""; - - switch(eColorSpace){ - case EColorSpace.EColorSpace_ColorSpace_Auto: - str = "Auto"; - break; - case EColorSpace.EColorSpace_ColorSpace_Gamma: - str = "Gamma"; - break; - case EColorSpace.EColorSpace_ColorSpace_Linear: - str = "Linear"; - break; - default: - str = "Unknown ("+eColorSpace+")"; - } - - return str; - } - - /** - * Get the description of the given {@link ETextureType texture type}. - * @param type the texture type - * @return the description of the given texture type. - */ - public static String getETextureTypeString(int type){ - - String str = ""; - - switch(type){ - case ETextureType.ETextureType_TextureType_DirectX: - str = "DirectX"; - break; - case ETextureType.ETextureType_TextureType_OpenGL: - str = "OpenGL"; - break; - case ETextureType.ETextureType_TextureType_Vulkan: - str = "Vulkan"; - break; - case ETextureType.ETextureType_TextureType_IOSurface: - str = "IOSurface"; - break; - case ETextureType.ETextureType_TextureType_DirectX12: - str = "DirectX12"; - break; - default: - str = "Unknown ("+type+")"; - } - - return str; - } - - /** - * Get the description of the given {@link EVRCompositorError EVR compositor error}. - * @param error the EVR compositor error. - * @return the description of the given EVR compositor error. - */ - public static String getEVRCompositorErrorString(int error){ - String str =""; - - switch(error){ - case EVRCompositorError.EVRCompositorError_VRCompositorError_None: - str = "None"; - break; - case EVRCompositorError.EVRCompositorError_VRCompositorError_RequestFailed: - str = "Request failed"; - break; - case EVRCompositorError.EVRCompositorError_VRCompositorError_IncompatibleVersion: - str = "Incompatible version"; - break; - case EVRCompositorError.EVRCompositorError_VRCompositorError_DoNotHaveFocus: - str = "Do not have focus"; - break; - case EVRCompositorError.EVRCompositorError_VRCompositorError_InvalidTexture: - str = "Invalid texture"; - break; - case EVRCompositorError.EVRCompositorError_VRCompositorError_IsNotSceneApplication: - str = "Is not scene application"; - break; - case EVRCompositorError.EVRCompositorError_VRCompositorError_TextureIsOnWrongDevice: - str = "Texture is on wrong device"; - break; - case EVRCompositorError.EVRCompositorError_VRCompositorError_TextureUsesUnsupportedFormat: - str = "Texture uses unsupported format"; - break; - case EVRCompositorError.EVRCompositorError_VRCompositorError_SharedTexturesNotSupported: - str = "Shared textures not supported"; - break; - case EVRCompositorError.EVRCompositorError_VRCompositorError_IndexOutOfRange: - str = "Index out of range"; - break; - case EVRCompositorError.EVRCompositorError_VRCompositorError_AlreadySubmitted: - str = "Already submitted"; - break; - } - return str; - } - - /** - * Get the description of the given {@link EVRInitError EVR init error}. - * @param error the EVR init error. - * @return the description of the given EVR init error. - */ - public static String getEVRInitErrorString(int error){ - String str = ""; - - switch(error){ - - - case EVRInitError.EVRInitError_VRInitError_None: - str="None"; - break; - case EVRInitError.EVRInitError_VRInitError_Unknown: - str="Unknown"; - break; - case EVRInitError.EVRInitError_VRInitError_Init_InstallationNotFound: - str="Installation not found"; - break; - case EVRInitError.EVRInitError_VRInitError_Init_InstallationCorrupt: - str="Installation corrupt"; - break; - case EVRInitError.EVRInitError_VRInitError_Init_VRClientDLLNotFound: - str="VR Client DLL not found"; - break; - case EVRInitError.EVRInitError_VRInitError_Init_FileNotFound: - str="File not found"; - break; - case EVRInitError.EVRInitError_VRInitError_Init_FactoryNotFound: - str="Factory not found"; - break; - case EVRInitError.EVRInitError_VRInitError_Init_InterfaceNotFound: - str="Interface not found"; - break; - case EVRInitError.EVRInitError_VRInitError_Init_InvalidInterface: - str="Invalid interface"; - break; - case EVRInitError.EVRInitError_VRInitError_Init_UserConfigDirectoryInvalid: - str="User config directory invalid"; - break; - case EVRInitError.EVRInitError_VRInitError_Init_HmdNotFound: - str="HMD not found"; - break; - case EVRInitError.EVRInitError_VRInitError_Init_NotInitialized: - str="Not initialized"; - break; - case EVRInitError.EVRInitError_VRInitError_Init_PathRegistryNotFound: - str="Path registry not found"; - break; - case EVRInitError.EVRInitError_VRInitError_Init_NoConfigPath: - str="No config path"; - break; - case EVRInitError.EVRInitError_VRInitError_Init_NoLogPath: - str="No log path"; - break; - case EVRInitError.EVRInitError_VRInitError_Init_PathRegistryNotWritable: - str="Path registry not writable"; - break; - case EVRInitError.EVRInitError_VRInitError_Init_AppInfoInitFailed: - str="AppInfo init failed"; - break; - case EVRInitError.EVRInitError_VRInitError_Init_Retry: - str="Init retry"; - break; - case EVRInitError.EVRInitError_VRInitError_Init_InitCanceledByUser: - str="Init canceled by user"; - break; - case EVRInitError.EVRInitError_VRInitError_Init_AnotherAppLaunching: - str="Another app launching"; - break; - case EVRInitError.EVRInitError_VRInitError_Init_SettingsInitFailed: - str="Setting init failed"; - break; - case EVRInitError.EVRInitError_VRInitError_Init_ShuttingDown: - str="Shutting down"; - break; - case EVRInitError.EVRInitError_VRInitError_Init_TooManyObjects: - str="Too many objects"; - break; - case EVRInitError.EVRInitError_VRInitError_Init_NoServerForBackgroundApp: - str="No server background app"; - break; - case EVRInitError.EVRInitError_VRInitError_Init_NotSupportedWithCompositor: - str="Not supported with compositor"; - break; - case EVRInitError.EVRInitError_VRInitError_Init_NotAvailableToUtilityApps: - str="Not available to utility apps"; - break; - case EVRInitError.EVRInitError_VRInitError_Init_Internal: - str="Internal"; - break; - case EVRInitError.EVRInitError_VRInitError_Init_HmdDriverIdIsNone: - str="Driver Id is None"; - break; - case EVRInitError.EVRInitError_VRInitError_Init_HmdNotFoundPresenceFailed: - str="HMD not found presence failed"; - break; - case EVRInitError.EVRInitError_VRInitError_Init_VRMonitorNotFound: - str="VR monitor not found"; - break; - case EVRInitError.EVRInitError_VRInitError_Init_VRMonitorStartupFailed: - str="VR monitor startup failed"; - break; - case EVRInitError.EVRInitError_VRInitError_Init_LowPowerWatchdogNotSupported: - str="Low power watchdog not supported"; - break; - case EVRInitError.EVRInitError_VRInitError_Init_InvalidApplicationType: - str="Invalid application type"; - break; - case EVRInitError.EVRInitError_VRInitError_Init_NotAvailableToWatchdogApps: - str="Not available to watchdog apps"; - break; - case EVRInitError.EVRInitError_VRInitError_Init_WatchdogDisabledInSettings: - str="Watchdog disabled in settings"; - break; - case EVRInitError.EVRInitError_VRInitError_Init_VRDashboardNotFound: - str="VR dashboard not found"; - break; - case EVRInitError.EVRInitError_VRInitError_Init_VRDashboardStartupFailed: - str="VR dashboard setup failed"; - break; - case EVRInitError.EVRInitError_VRInitError_Driver_Failed: - str="Driver failed"; - break; - case EVRInitError.EVRInitError_VRInitError_Driver_Unknown: - str="Driver unknown"; - break; - case EVRInitError.EVRInitError_VRInitError_Driver_HmdUnknown: - str="HMD unknown"; - break; - case EVRInitError.EVRInitError_VRInitError_Driver_NotLoaded: - str="Driver not loaded"; - break; - case EVRInitError.EVRInitError_VRInitError_Driver_RuntimeOutOfDate: - str="Driver runtime out of date"; - break; - case EVRInitError.EVRInitError_VRInitError_Driver_HmdInUse: - str="HMD in use"; - break; - case EVRInitError.EVRInitError_VRInitError_Driver_NotCalibrated: - str="Not calibrated"; - break; - case EVRInitError.EVRInitError_VRInitError_Driver_CalibrationInvalid: - str="Calibration invalid"; - break; - case EVRInitError.EVRInitError_VRInitError_Driver_HmdDisplayNotFound: - str="HMD display not found"; - break; - case EVRInitError.EVRInitError_VRInitError_Driver_TrackedDeviceInterfaceUnknown: - str="Tracked device interface unknown"; - break; - case EVRInitError.EVRInitError_VRInitError_Driver_HmdDriverIdOutOfBounds: - str="HMD driver Id out of bounds"; - break; - case EVRInitError.EVRInitError_VRInitError_Driver_HmdDisplayMirrored: - str="HMD display mirrored"; - break; - case EVRInitError.EVRInitError_VRInitError_IPC_ServerInitFailed: - str=""; - break; - case EVRInitError.EVRInitError_VRInitError_IPC_ConnectFailed: str=""; break; - case EVRInitError.EVRInitError_VRInitError_IPC_SharedStateInitFailed: str=""; break; - case EVRInitError.EVRInitError_VRInitError_IPC_CompositorInitFailed: str=""; break; - case EVRInitError.EVRInitError_VRInitError_IPC_MutexInitFailed: str=""; break; - case EVRInitError.EVRInitError_VRInitError_IPC_Failed: str=""; break; - case EVRInitError.EVRInitError_VRInitError_IPC_CompositorConnectFailed: str=""; break; - case EVRInitError.EVRInitError_VRInitError_IPC_CompositorInvalidConnectResponse: str=""; break; - case EVRInitError.EVRInitError_VRInitError_IPC_ConnectFailedAfterMultipleAttempts: str=""; break; - case EVRInitError.EVRInitError_VRInitError_Compositor_Failed: str=""; break; - case EVRInitError.EVRInitError_VRInitError_Compositor_D3D11HardwareRequired: str=""; break; - case EVRInitError.EVRInitError_VRInitError_Compositor_FirmwareRequiresUpdate: str=""; break; - case EVRInitError.EVRInitError_VRInitError_Compositor_OverlayInitFailed: str=""; break; - case EVRInitError.EVRInitError_VRInitError_Compositor_ScreenshotsInitFailed: str=""; break; - case EVRInitError.EVRInitError_VRInitError_VendorSpecific_UnableToConnectToOculusRuntime: str=""; break; - case EVRInitError.EVRInitError_VRInitError_VendorSpecific_HmdFound_CantOpenDevice: str=""; break; - case EVRInitError.EVRInitError_VRInitError_VendorSpecific_HmdFound_UnableToRequestConfigStart: str=""; break; - case EVRInitError.EVRInitError_VRInitError_VendorSpecific_HmdFound_NoStoredConfig: str=""; break; - case EVRInitError.EVRInitError_VRInitError_VendorSpecific_HmdFound_ConfigTooBig: str=""; break; - case EVRInitError.EVRInitError_VRInitError_VendorSpecific_HmdFound_ConfigTooSmall: str=""; break; - case EVRInitError.EVRInitError_VRInitError_VendorSpecific_HmdFound_UnableToInitZLib: str=""; break; - case EVRInitError.EVRInitError_VRInitError_VendorSpecific_HmdFound_CantReadFirmwareVersion: str=""; break; - case EVRInitError.EVRInitError_VRInitError_VendorSpecific_HmdFound_UnableToSendUserDataStart: str=""; break; - case EVRInitError.EVRInitError_VRInitError_VendorSpecific_HmdFound_UnableToGetUserDataStart: str=""; break; - case EVRInitError.EVRInitError_VRInitError_VendorSpecific_HmdFound_UnableToGetUserDataNext: str=""; break; - case EVRInitError.EVRInitError_VRInitError_VendorSpecific_HmdFound_UserDataAddressRange: str=""; break; - case EVRInitError.EVRInitError_VRInitError_VendorSpecific_HmdFound_UserDataError: str=""; break; - case EVRInitError.EVRInitError_VRInitError_VendorSpecific_HmdFound_ConfigFailedSanityCheck: str=""; break; - case EVRInitError.EVRInitError_VRInitError_Steam_SteamInstallationNotFound: str=""; break; - default: - } - - return str; - } - - /** - * Get the description of the given tracked device property. - * @param property the tracked device property. - * @return the description of the given tracked device property. - */ - public static String getETrackedDevicePropertyString(int property){ - String str = ""; - - switch(property){ - - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_Invalid: - str = "Invalid"; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_TrackingSystemName_String: - str = "Tracking system name"; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_ModelNumber_String: - str = "Model number"; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_SerialNumber_String: - str = "Serial number"; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_RenderModelName_String: - str = "Render model name"; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_WillDriftInYaw_Bool: - str = "Will drift in yaw"; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_ManufacturerName_String: - str = "Manufacturer name"; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_TrackingFirmwareVersion_String: - str = "Tracking firmware version"; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_HardwareRevision_String: - str = "Hardware revision"; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_AllWirelessDongleDescriptions_String: - str = "All wireless dongle descriptions"; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_ConnectedWirelessDongle_String: - str = "Connect wireless dongle"; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DeviceIsWireless_Bool: - str = "Device is wireless"; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DeviceIsCharging_Bool: - str = "Device is charging"; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DeviceBatteryPercentage_Float: - str = "Device battery percentage"; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_StatusDisplayTransform_Matrix34: - str = "Status display transform"; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_Firmware_UpdateAvailable_Bool: - str = "Update available"; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_Firmware_ManualUpdate_Bool: - str = "Firmware manual update"; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_Firmware_ManualUpdateURL_String: - str = "Firmware manual update URL"; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_HardwareRevision_Uint64: - str = "Hardware revision"; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_FirmwareVersion_Uint64: - str = "Firmware version"; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_FPGAVersion_Uint64: - str = "FPGA version"; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_VRCVersion_Uint64: - str = "VRC version"; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_RadioVersion_Uint64: - str = "Radio version"; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DongleVersion_Uint64: - str = "Dongle version"; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_BlockServerShutdown_Bool: - str = "Block server shutdown"; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_CanUnifyCoordinateSystemWithHmd_Bool: - str = "Can unify coordinate system with HMD"; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_ContainsProximitySensor_Bool: - str = "Contains proximity sensor"; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DeviceProvidesBatteryStatus_Bool: - str = "Device provides battery status"; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DeviceCanPowerOff_Bool: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_Firmware_ProgrammingTarget_String: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DeviceClass_Int32: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_HasCamera_Bool: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DriverVersion_String: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_Firmware_ForceUpdateRequired_Bool: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_ViveSystemButtonFixRequired_Bool: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_ParentDriver_Uint64: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_ReportsTimeSinceVSync_Bool: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_SecondsFromVsyncToPhotons_Float: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DisplayFrequency_Float: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_UserIpdMeters_Float: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_CurrentUniverseId_Uint64: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_PreviousUniverseId_Uint64: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DisplayFirmwareVersion_Uint64: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_IsOnDesktop_Bool: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DisplayMCType_Int32: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DisplayMCOffset_Float: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DisplayMCScale_Float: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_EdidVendorID_Int32: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DisplayMCImageLeft_String: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DisplayMCImageRight_String: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DisplayGCBlackClamp_Float: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_EdidProductID_Int32: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_CameraToHeadTransform_Matrix34: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DisplayGCType_Int32: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DisplayGCOffset_Float: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DisplayGCScale_Float: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DisplayGCPrescale_Float: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DisplayGCImage_String: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_LensCenterLeftU_Float: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_LensCenterLeftV_Float: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_LensCenterRightU_Float: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_LensCenterRightV_Float: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_UserHeadToEyeDepthMeters_Float: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_CameraFirmwareVersion_Uint64: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_CameraFirmwareDescription_String: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DisplayFPGAVersion_Uint64: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DisplayBootloaderVersion_Uint64: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DisplayHardwareVersion_Uint64: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_AudioFirmwareVersion_Uint64: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_CameraCompatibilityMode_Int32: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_ScreenshotHorizontalFieldOfViewDegrees_Float: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_ScreenshotVerticalFieldOfViewDegrees_Float: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DisplaySuppressed_Bool: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DisplayAllowNightMode_Bool: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DisplayMCImageWidth_Int32: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DisplayMCImageHeight_Int32: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DisplayMCImageNumChannels_Int32: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DisplayMCImageData_Binary: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_AttachedDeviceId_String: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_SupportedButtons_Uint64: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_Axis0Type_Int32: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_Axis1Type_Int32: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_Axis2Type_Int32: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_Axis3Type_Int32: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_Axis4Type_Int32: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_ControllerRoleHint_Int32: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_FieldOfViewLeftDegrees_Float: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_FieldOfViewRightDegrees_Float: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_FieldOfViewTopDegrees_Float: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_FieldOfViewBottomDegrees_Float: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_TrackingRangeMinimumMeters_Float: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_TrackingRangeMaximumMeters_Float: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_ModeLabel_String: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_IconPathName_String: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_NamedIconPathDeviceOff_String: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_NamedIconPathDeviceSearching_String: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_NamedIconPathDeviceSearchingAlert_String: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_NamedIconPathDeviceReady_String: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_NamedIconPathDeviceReadyAlert_String: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_NamedIconPathDeviceNotReady_String: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_NamedIconPathDeviceStandby_String: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_NamedIconPathDeviceAlertLow_String: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DisplayHiddenArea_Binary_Start: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DisplayHiddenArea_Binary_End: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_UserConfigPath_String: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_InstallPath_String: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_VendorSpecific_Reserved_Start: - str = ""; - break; - case ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_VendorSpecific_Reserved_End: - str = ""; - break; - } - - - return str; - } -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/RenderModel_ComponentState_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/RenderModel_ComponentState_t.java deleted file mode 100644 index 7e72d93c88..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/RenderModel_ComponentState_t.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1557
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class RenderModel_ComponentState_t extends Structure { - /** C type : HmdMatrix34_t */ - public HmdMatrix34_t mTrackingToComponentRenderModel; - /** C type : HmdMatrix34_t */ - public HmdMatrix34_t mTrackingToComponentLocal; - /** C type : VRComponentProperties */ - public int uProperties; - public RenderModel_ComponentState_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("mTrackingToComponentRenderModel", "mTrackingToComponentLocal", "uProperties"); - } - /** - * @param mTrackingToComponentRenderModel C type : HmdMatrix34_t
- * @param mTrackingToComponentLocal C type : HmdMatrix34_t
- * @param uProperties C type : VRComponentProperties - */ - public RenderModel_ComponentState_t(HmdMatrix34_t mTrackingToComponentRenderModel, HmdMatrix34_t mTrackingToComponentLocal, int uProperties) { - super(); - this.mTrackingToComponentRenderModel = mTrackingToComponentRenderModel; - this.mTrackingToComponentLocal = mTrackingToComponentLocal; - this.uProperties = uProperties; - } - public RenderModel_ComponentState_t(Pointer peer) { - super(peer); - } - public static class ByReference extends RenderModel_ComponentState_t implements Structure.ByReference { - - }; - public static class ByValue extends RenderModel_ComponentState_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/RenderModel_ControllerMode_State_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/RenderModel_ControllerMode_State_t.java deleted file mode 100644 index cf1eac008f..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/RenderModel_ControllerMode_State_t.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1581
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class RenderModel_ControllerMode_State_t extends Structure { - public byte bScrollWheelVisible; - public RenderModel_ControllerMode_State_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("bScrollWheelVisible"); - } - public RenderModel_ControllerMode_State_t(byte bScrollWheelVisible) { - super(); - this.bScrollWheelVisible = bScrollWheelVisible; - } - public RenderModel_ControllerMode_State_t(Pointer peer) { - super(peer); - } - public static class ByReference extends RenderModel_ControllerMode_State_t implements Structure.ByReference { - - }; - public static class ByValue extends RenderModel_ControllerMode_State_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/RenderModel_TextureMap_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/RenderModel_TextureMap_t.java deleted file mode 100644 index 41670df53b..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/RenderModel_TextureMap_t.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1569
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class RenderModel_TextureMap_t extends Structure { - public short unWidth; - public short unHeight; - /** - * const uint8_t *
- * C type : uint8_t* - */ - public Pointer rubTextureMapData; - public RenderModel_TextureMap_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("unWidth", "unHeight", "rubTextureMapData"); - } - /** - * @param rubTextureMapData const uint8_t *
- * C type : uint8_t* - */ - public RenderModel_TextureMap_t(short unWidth, short unHeight, Pointer rubTextureMapData) { - super(); - this.unWidth = unWidth; - this.unHeight = unHeight; - this.rubTextureMapData = rubTextureMapData; - } - public RenderModel_TextureMap_t(Pointer peer) { - super(peer); - } - public static class ByReference extends RenderModel_TextureMap_t implements Structure.ByReference { - - }; - public static class ByValue extends RenderModel_TextureMap_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/RenderModel_Vertex_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/RenderModel_Vertex_t.java deleted file mode 100644 index 17fac6dd53..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/RenderModel_Vertex_t.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1563
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class RenderModel_Vertex_t extends Structure { - /** C type : HmdVector3_t */ - public HmdVector3_t vPosition; - /** C type : HmdVector3_t */ - public HmdVector3_t vNormal; - /** - * float[2]
- * C type : float[2] - */ - public float[] rfTextureCoord = new float[2]; - public RenderModel_Vertex_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("vPosition", "vNormal", "rfTextureCoord"); - } - /** - * @param vPosition C type : HmdVector3_t
- * @param vNormal C type : HmdVector3_t
- * @param rfTextureCoord float[2]
- * C type : float[2] - */ - public RenderModel_Vertex_t(HmdVector3_t vPosition, HmdVector3_t vNormal, float rfTextureCoord[]) { - super(); - this.vPosition = vPosition; - this.vNormal = vNormal; - if ((rfTextureCoord.length != this.rfTextureCoord.length)) - throw new IllegalArgumentException("Wrong array size !"); - this.rfTextureCoord = rfTextureCoord; - } - public RenderModel_Vertex_t(Pointer peer) { - super(peer); - } - public static class ByReference extends RenderModel_Vertex_t implements Structure.ByReference { - - }; - public static class ByValue extends RenderModel_Vertex_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/RenderModel_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/RenderModel_t.java deleted file mode 100644 index 9828f148fe..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/RenderModel_t.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import com.sun.jna.ptr.ShortByReference; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1578
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class RenderModel_t extends Structure { - /** - * const struct vr::RenderModel_Vertex_t *
- * C type : RenderModel_Vertex_t* - */ - public com.jme3.system.jopenvr.RenderModel_Vertex_t.ByReference rVertexData; - public int unVertexCount; - /** - * const uint16_t *
- * C type : uint16_t* - */ - public ShortByReference rIndexData; - public int unTriangleCount; - /** C type : TextureID_t */ - public int diffuseTextureId; - public RenderModel_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("rVertexData", "unVertexCount", "rIndexData", "unTriangleCount", "diffuseTextureId"); - } - /** - * @param rVertexData const struct vr::RenderModel_Vertex_t *
- * C type : RenderModel_Vertex_t*
- * @param rIndexData const uint16_t *
- * C type : uint16_t*
- * @param diffuseTextureId C type : TextureID_t - */ - public RenderModel_t(com.jme3.system.jopenvr.RenderModel_Vertex_t.ByReference rVertexData, int unVertexCount, ShortByReference rIndexData, int unTriangleCount, int diffuseTextureId) { - super(); - this.rVertexData = rVertexData; - this.unVertexCount = unVertexCount; - this.rIndexData = rIndexData; - this.unTriangleCount = unTriangleCount; - this.diffuseTextureId = diffuseTextureId; - } - public RenderModel_t(Pointer peer) { - super(peer); - } - public static class ByReference extends RenderModel_t implements Structure.ByReference { - - }; - public static class ByValue extends RenderModel_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/SpatialAnchorPose_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/SpatialAnchorPose_t.java deleted file mode 100644 index 2d3fc2cfdb..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/SpatialAnchorPose_t.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1636
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class SpatialAnchorPose_t extends Structure { - /** C type : HmdMatrix34_t */ - public HmdMatrix34_t mAnchorToAbsoluteTracking; - public SpatialAnchorPose_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("mAnchorToAbsoluteTracking"); - } - /** @param mAnchorToAbsoluteTracking C type : HmdMatrix34_t */ - public SpatialAnchorPose_t(HmdMatrix34_t mAnchorToAbsoluteTracking) { - super(); - this.mAnchorToAbsoluteTracking = mAnchorToAbsoluteTracking; - } - public SpatialAnchorPose_t(Pointer peer) { - super(peer); - } - public static class ByReference extends SpatialAnchorPose_t implements Structure.ByReference { - - }; - public static class ByValue extends SpatialAnchorPose_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/Texture_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/Texture_t.java deleted file mode 100644 index fc6cfeb95e..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/Texture_t.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1247
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class Texture_t extends Structure { - /** - * void *
- * C type : void* - */ - public int handle; - /** - * C type : ETextureType - */ - public int eType; - /** - * C type : EColorSpace - */ - public int eColorSpace; - public Texture_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("handle", "eType", "eColorSpace"); - } - /** - * @param handle void *
- * C type : void*
- * @param eType @see JOpenVRLibrary.ETextureType
- * C type : ETextureType
- * @param eColorSpace @see JOpenVRLibrary.EColorSpace
- * C type : EColorSpace - */ - public Texture_t(int handle, int eType, int eColorSpace) { - super(); - this.handle = handle; - this.eType = eType; - this.eColorSpace = eColorSpace; - } - public Texture_t(Pointer peer) { - super(peer); - } - public static class ByReference extends Texture_t implements Structure.ByReference { - - }; - public static class ByValue extends Texture_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/TrackedDevicePose_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/TrackedDevicePose_t.java deleted file mode 100644 index d2a39b1184..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/TrackedDevicePose_t.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1257
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class TrackedDevicePose_t extends Structure { - /** C type : HmdMatrix34_t */ - public HmdMatrix34_t mDeviceToAbsoluteTracking; - /** C type : HmdVector3_t */ - public HmdVector3_t vVelocity; - /** C type : HmdVector3_t */ - public HmdVector3_t vAngularVelocity; - /** - * C type : ETrackingResult - */ - public int eTrackingResult; - public byte bPoseIsValid; - public byte bDeviceIsConnected; - public TrackedDevicePose_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("mDeviceToAbsoluteTracking", "vVelocity", "vAngularVelocity", "eTrackingResult", "bPoseIsValid", "bDeviceIsConnected"); - } - /** - * @param mDeviceToAbsoluteTracking C type : HmdMatrix34_t
- * @param vVelocity C type : HmdVector3_t
- * @param vAngularVelocity C type : HmdVector3_t
- * @param eTrackingResult @see JOpenVRLibrary.ETrackingResult
- * C type : ETrackingResult - */ - public TrackedDevicePose_t(HmdMatrix34_t mDeviceToAbsoluteTracking, HmdVector3_t vVelocity, HmdVector3_t vAngularVelocity, int eTrackingResult, byte bPoseIsValid, byte bDeviceIsConnected) { - super(); - this.mDeviceToAbsoluteTracking = mDeviceToAbsoluteTracking; - this.vVelocity = vVelocity; - this.vAngularVelocity = vAngularVelocity; - this.eTrackingResult = eTrackingResult; - this.bPoseIsValid = bPoseIsValid; - this.bDeviceIsConnected = bDeviceIsConnected; - } - public TrackedDevicePose_t(Pointer peer) { - super(peer); - } - public static class ByReference extends TrackedDevicePose_t implements Structure.ByReference { - - }; - public static class ByValue extends TrackedDevicePose_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRActiveActionSet_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRActiveActionSet_t.java deleted file mode 100644 index 49720d038e..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRActiveActionSet_t.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1633
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VRActiveActionSet_t extends Structure { - /** C type : VRActionSetHandle_t */ - public long ulActionSet; - /** C type : VRInputValueHandle_t */ - public long ulRestrictedToDevice; - /** C type : VRActionSetHandle_t */ - public long ulSecondaryActionSet; - public int unPadding; - public int nPriority; - public VRActiveActionSet_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("ulActionSet", "ulRestrictedToDevice", "ulSecondaryActionSet", "unPadding", "nPriority"); - } - /** - * @param ulActionSet C type : VRActionSetHandle_t
- * @param ulRestrictedToDevice C type : VRInputValueHandle_t
- * @param ulSecondaryActionSet C type : VRActionSetHandle_t - */ - public VRActiveActionSet_t(long ulActionSet, long ulRestrictedToDevice, long ulSecondaryActionSet, int unPadding, int nPriority) { - super(); - this.ulActionSet = ulActionSet; - this.ulRestrictedToDevice = ulRestrictedToDevice; - this.ulSecondaryActionSet = ulSecondaryActionSet; - this.unPadding = unPadding; - this.nPriority = nPriority; - } - public VRActiveActionSet_t(Pointer peer) { - super(peer); - } - public static class ByReference extends VRActiveActionSet_t implements Structure.ByReference { - - }; - public static class ByValue extends VRActiveActionSet_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRBoneTransform_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRBoneTransform_t.java deleted file mode 100644 index e6e7626d24..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRBoneTransform_t.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1456
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VRBoneTransform_t extends Structure { - /** C type : HmdVector4_t */ - public HmdVector4_t position; - /** C type : HmdQuaternionf_t */ - public HmdQuaternionf_t orientation; - public VRBoneTransform_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("position", "orientation"); - } - /** - * @param position C type : HmdVector4_t
- * @param orientation C type : HmdQuaternionf_t - */ - public VRBoneTransform_t(HmdVector4_t position, HmdQuaternionf_t orientation) { - super(); - this.position = position; - this.orientation = orientation; - } - public VRBoneTransform_t(Pointer peer) { - super(peer); - } - public static class ByReference extends VRBoneTransform_t implements Structure.ByReference { - - }; - public static class ByValue extends VRBoneTransform_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRControllerAxis_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRControllerAxis_t.java deleted file mode 100644 index 41f0e13665..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRControllerAxis_t.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1429
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VRControllerAxis_t extends Structure { - public float x; - public float y; - public VRControllerAxis_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("x", "y"); - } - public VRControllerAxis_t(float x, float y) { - super(); - this.x = x; - this.y = y; - } - public VRControllerAxis_t(Pointer peer) { - super(peer); - } - public static class ByReference extends VRControllerAxis_t implements Structure.ByReference { - - }; - public static class ByValue extends VRControllerAxis_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRControllerState_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRControllerState_t.java deleted file mode 100644 index 9adc41c7d2..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRControllerState_t.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1436
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VRControllerState_t extends Structure { - public int unPacketNum; - public long ulButtonPressed; - public long ulButtonTouched; - /** - * struct vr::VRControllerAxis_t[5]
- * C type : VRControllerAxis_t[5] - */ - public VRControllerAxis_t[] rAxis = new VRControllerAxis_t[5]; - public VRControllerState_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("unPacketNum", "ulButtonPressed", "ulButtonTouched", "rAxis"); - } - /** - * @param rAxis struct vr::VRControllerAxis_t[5]
- * C type : VRControllerAxis_t[5] - */ - public VRControllerState_t(int unPacketNum, long ulButtonPressed, long ulButtonTouched, VRControllerAxis_t rAxis[]) { - super(); - this.unPacketNum = unPacketNum; - this.ulButtonPressed = ulButtonPressed; - this.ulButtonTouched = ulButtonTouched; - if ((rAxis.length != this.rAxis.length)) - throw new IllegalArgumentException("Wrong array size !"); - this.rAxis = rAxis; - } - public VRControllerState_t(Pointer peer) { - super(peer); - } - public static class ByReference extends VRControllerState_t implements Structure.ByReference { - - }; - public static class ByValue extends VRControllerState_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_ApplicationLaunch_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_ApplicationLaunch_t.java deleted file mode 100644 index 845ca8799c..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_ApplicationLaunch_t.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1373
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VREvent_ApplicationLaunch_t extends Structure { - public int pid; - public int unArgsHandle; - public VREvent_ApplicationLaunch_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("pid", "unArgsHandle"); - } - public VREvent_ApplicationLaunch_t(int pid, int unArgsHandle) { - super(); - this.pid = pid; - this.unArgsHandle = unArgsHandle; - } - public VREvent_ApplicationLaunch_t(Pointer peer) { - super(peer); - } - public static class ByReference extends VREvent_ApplicationLaunch_t implements Structure.ByReference { - - }; - public static class ByValue extends VREvent_ApplicationLaunch_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Chaperone_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Chaperone_t.java deleted file mode 100644 index 92e97a4580..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Chaperone_t.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1350
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VREvent_Chaperone_t extends Structure { - public long m_nPreviousUniverse; - public long m_nCurrentUniverse; - public VREvent_Chaperone_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("m_nPreviousUniverse", "m_nCurrentUniverse"); - } - public VREvent_Chaperone_t(long m_nPreviousUniverse, long m_nCurrentUniverse) { - super(); - this.m_nPreviousUniverse = m_nPreviousUniverse; - this.m_nCurrentUniverse = m_nCurrentUniverse; - } - public VREvent_Chaperone_t(Pointer peer) { - super(peer); - } - public static class ByReference extends VREvent_Chaperone_t implements Structure.ByReference { - - }; - public static class ByValue extends VREvent_Chaperone_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Controller_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Controller_t.java deleted file mode 100644 index e7959582cc..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Controller_t.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1304
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VREvent_Controller_t extends Structure { - public int button; - public VREvent_Controller_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("button"); - } - public VREvent_Controller_t(int button) { - super(); - this.button = button; - } - public VREvent_Controller_t(Pointer peer) { - super(peer); - } - public static class ByReference extends VREvent_Controller_t implements Structure.ByReference { - - }; - public static class ByValue extends VREvent_Controller_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Data_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Data_t.java deleted file mode 100644 index 983a7da823..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Data_t.java +++ /dev/null @@ -1,135 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Union; -/** - * native declaration : headers\openvr_capi.h:1686
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VREvent_Data_t extends Union { - /** C type : VREvent_Reserved_t */ - public VREvent_Reserved_t reserved; - /** C type : VREvent_Controller_t */ - public VREvent_Controller_t controller; - /** C type : VREvent_Mouse_t */ - public VREvent_Mouse_t mouse; - /** C type : VREvent_Scroll_t */ - public VREvent_Scroll_t scroll; - /** C type : VREvent_Process_t */ - public VREvent_Process_t process; - /** C type : VREvent_Notification_t */ - public VREvent_Notification_t notification; - /** C type : VREvent_Overlay_t */ - public VREvent_Overlay_t overlay; - /** C type : VREvent_Status_t */ - public VREvent_Status_t status; - /** C type : VREvent_Keyboard_t */ - public VREvent_Keyboard_t keyboard; - /** C type : VREvent_Ipd_t */ - public VREvent_Ipd_t ipd; - /** C type : VREvent_Chaperone_t */ - public VREvent_Chaperone_t chaperone; - /** C type : VREvent_PerformanceTest_t */ - public VREvent_PerformanceTest_t performanceTest; - /** C type : VREvent_TouchPadMove_t */ - public VREvent_TouchPadMove_t touchPadMove; - /** C type : VREvent_SeatedZeroPoseReset_t */ - public VREvent_SeatedZeroPoseReset_t seatedZeroPoseReset; - public VREvent_Data_t() { - super(); - } - /** @param reserved C type : VREvent_Reserved_t */ - public VREvent_Data_t(VREvent_Reserved_t reserved) { - super(); - this.reserved = reserved; - setType(VREvent_Reserved_t.class); - } - /** @param controller C type : VREvent_Controller_t */ - public VREvent_Data_t(VREvent_Controller_t controller) { - super(); - this.controller = controller; - setType(VREvent_Controller_t.class); - } - /** @param mouse C type : VREvent_Mouse_t */ - public VREvent_Data_t(VREvent_Mouse_t mouse) { - super(); - this.mouse = mouse; - setType(VREvent_Mouse_t.class); - } - /** @param scroll C type : VREvent_Scroll_t */ - public VREvent_Data_t(VREvent_Scroll_t scroll) { - super(); - this.scroll = scroll; - setType(VREvent_Scroll_t.class); - } - /** @param process C type : VREvent_Process_t */ - public VREvent_Data_t(VREvent_Process_t process) { - super(); - this.process = process; - setType(VREvent_Process_t.class); - } - /** @param notification C type : VREvent_Notification_t */ - public VREvent_Data_t(VREvent_Notification_t notification) { - super(); - this.notification = notification; - setType(VREvent_Notification_t.class); - } - /** @param overlay C type : VREvent_Overlay_t */ - public VREvent_Data_t(VREvent_Overlay_t overlay) { - super(); - this.overlay = overlay; - setType(VREvent_Overlay_t.class); - } - /** @param status C type : VREvent_Status_t */ - public VREvent_Data_t(VREvent_Status_t status) { - super(); - this.status = status; - setType(VREvent_Status_t.class); - } - /** @param keyboard C type : VREvent_Keyboard_t */ - public VREvent_Data_t(VREvent_Keyboard_t keyboard) { - super(); - this.keyboard = keyboard; - setType(VREvent_Keyboard_t.class); - } - /** @param ipd C type : VREvent_Ipd_t */ - public VREvent_Data_t(VREvent_Ipd_t ipd) { - super(); - this.ipd = ipd; - setType(VREvent_Ipd_t.class); - } - /** @param chaperone C type : VREvent_Chaperone_t */ - public VREvent_Data_t(VREvent_Chaperone_t chaperone) { - super(); - this.chaperone = chaperone; - setType(VREvent_Chaperone_t.class); - } - /** @param performanceTest C type : VREvent_PerformanceTest_t */ - public VREvent_Data_t(VREvent_PerformanceTest_t performanceTest) { - super(); - this.performanceTest = performanceTest; - setType(VREvent_PerformanceTest_t.class); - } - /** @param touchPadMove C type : VREvent_TouchPadMove_t */ - public VREvent_Data_t(VREvent_TouchPadMove_t touchPadMove) { - super(); - this.touchPadMove = touchPadMove; - setType(VREvent_TouchPadMove_t.class); - } - /** @param seatedZeroPoseReset C type : VREvent_SeatedZeroPoseReset_t */ - public VREvent_Data_t(VREvent_SeatedZeroPoseReset_t seatedZeroPoseReset) { - super(); - this.seatedZeroPoseReset = seatedZeroPoseReset; - setType(VREvent_SeatedZeroPoseReset_t.class); - } - public VREvent_Data_t(Pointer peer) { - super(peer); - } - public static class ByReference extends VREvent_Data_t implements com.sun.jna.Structure.ByReference { - - }; - public static class ByValue extends VREvent_Data_t implements com.sun.jna.Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_DualAnalog_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_DualAnalog_t.java deleted file mode 100644 index f5e45f5b24..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_DualAnalog_t.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1395
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VREvent_DualAnalog_t extends Structure { - public float x; - public float y; - public float transformedX; - public float transformedY; - /** - * C type : EDualAnalogWhich - */ - public int which; - public VREvent_DualAnalog_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("x", "y", "transformedX", "transformedY", "which"); - } - /** - * @param which @see JOpenVRLibrary.EDualAnalogWhich
- * C type : EDualAnalogWhich - */ - public VREvent_DualAnalog_t(float x, float y, float transformedX, float transformedY, int which) { - super(); - this.x = x; - this.y = y; - this.transformedX = transformedX; - this.transformedY = transformedY; - this.which = which; - } - public VREvent_DualAnalog_t(Pointer peer) { - super(peer); - } - public static class ByReference extends VREvent_DualAnalog_t implements Structure.ByReference { - - }; - public static class ByValue extends VREvent_DualAnalog_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_EditingCameraSurface_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_EditingCameraSurface_t.java deleted file mode 100644 index 5a54cdd582..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_EditingCameraSurface_t.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1377
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VREvent_EditingCameraSurface_t extends Structure { - public long overlayHandle; - public int nVisualMode; - public VREvent_EditingCameraSurface_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("overlayHandle", "nVisualMode"); - } - public VREvent_EditingCameraSurface_t(long overlayHandle, int nVisualMode) { - super(); - this.overlayHandle = overlayHandle; - this.nVisualMode = nVisualMode; - } - public VREvent_EditingCameraSurface_t(Pointer peer) { - super(peer); - } - public static class ByReference extends VREvent_EditingCameraSurface_t implements Structure.ByReference { - - }; - public static class ByValue extends VREvent_EditingCameraSurface_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_HapticVibration_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_HapticVibration_t.java deleted file mode 100644 index 7175e4c862..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_HapticVibration_t.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1402
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VREvent_HapticVibration_t extends Structure { - public long containerHandle; - public long componentHandle; - public float fDurationSeconds; - public float fFrequency; - public float fAmplitude; - public VREvent_HapticVibration_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("containerHandle", "componentHandle", "fDurationSeconds", "fFrequency", "fAmplitude"); - } - public VREvent_HapticVibration_t(long containerHandle, long componentHandle, float fDurationSeconds, float fFrequency, float fAmplitude) { - super(); - this.containerHandle = containerHandle; - this.componentHandle = componentHandle; - this.fDurationSeconds = fDurationSeconds; - this.fFrequency = fFrequency; - this.fAmplitude = fAmplitude; - } - public VREvent_HapticVibration_t(Pointer peer) { - super(peer); - } - public static class ByReference extends VREvent_HapticVibration_t implements Structure.ByReference { - - }; - public static class ByValue extends VREvent_HapticVibration_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_InputActionManifestLoad_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_InputActionManifestLoad_t.java deleted file mode 100644 index 427eddfbc2..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_InputActionManifestLoad_t.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1417
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VREvent_InputActionManifestLoad_t extends Structure { - public long pathAppKey; - public long pathMessage; - public long pathMessageParam; - public long pathManifestPath; - public VREvent_InputActionManifestLoad_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("pathAppKey", "pathMessage", "pathMessageParam", "pathManifestPath"); - } - public VREvent_InputActionManifestLoad_t(long pathAppKey, long pathMessage, long pathMessageParam, long pathManifestPath) { - super(); - this.pathAppKey = pathAppKey; - this.pathMessage = pathMessage; - this.pathMessageParam = pathMessageParam; - this.pathManifestPath = pathManifestPath; - } - public VREvent_InputActionManifestLoad_t(Pointer peer) { - super(peer); - } - public static class ByReference extends VREvent_InputActionManifestLoad_t implements Structure.ByReference { - - }; - public static class ByValue extends VREvent_InputActionManifestLoad_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_InputBindingLoad_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_InputBindingLoad_t.java deleted file mode 100644 index 9b88905847..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_InputBindingLoad_t.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1411
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VREvent_InputBindingLoad_t extends Structure { - /** C type : PropertyContainerHandle_t */ - public long ulAppContainer; - public long pathMessage; - public long pathUrl; - public long pathControllerType; - public VREvent_InputBindingLoad_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("ulAppContainer", "pathMessage", "pathUrl", "pathControllerType"); - } - /** @param ulAppContainer C type : PropertyContainerHandle_t */ - public VREvent_InputBindingLoad_t(long ulAppContainer, long pathMessage, long pathUrl, long pathControllerType) { - super(); - this.ulAppContainer = ulAppContainer; - this.pathMessage = pathMessage; - this.pathUrl = pathUrl; - this.pathControllerType = pathControllerType; - } - public VREvent_InputBindingLoad_t(Pointer peer) { - super(peer); - } - public static class ByReference extends VREvent_InputBindingLoad_t implements Structure.ByReference { - - }; - public static class ByValue extends VREvent_InputBindingLoad_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Ipd_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Ipd_t.java deleted file mode 100644 index afc05f74ea..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Ipd_t.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1346
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VREvent_Ipd_t extends Structure { - public float ipdMeters; - public VREvent_Ipd_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("ipdMeters"); - } - public VREvent_Ipd_t(float ipdMeters) { - super(); - this.ipdMeters = ipdMeters; - } - public VREvent_Ipd_t(Pointer peer) { - super(peer); - } - public static class ByReference extends VREvent_Ipd_t implements Structure.ByReference { - - }; - public static class ByValue extends VREvent_Ipd_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Keyboard_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Keyboard_t.java deleted file mode 100644 index 9cf8c64ed3..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Keyboard_t.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1343
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VREvent_Keyboard_t extends Structure { - /** - * char[8]
- * C type : char*[8] - */ - public Pointer[] cNewInput = new Pointer[8]; - public long uUserValue; - public VREvent_Keyboard_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("cNewInput", "uUserValue"); - } - /** - * @param cNewInput char[8]
- * C type : char*[8] - */ - public VREvent_Keyboard_t(Pointer cNewInput[], long uUserValue) { - super(); - if ((cNewInput.length != this.cNewInput.length)) - throw new IllegalArgumentException("Wrong array size !"); - this.cNewInput = cNewInput; - this.uUserValue = uUserValue; - } - public VREvent_Keyboard_t(Pointer peer) { - super(peer); - } - public static class ByReference extends VREvent_Keyboard_t implements Structure.ByReference { - - }; - public static class ByValue extends VREvent_Keyboard_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_MessageOverlay_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_MessageOverlay_t.java deleted file mode 100644 index b0fe1b8c2e..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_MessageOverlay_t.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1380
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VREvent_MessageOverlay_t extends Structure { - public int unVRMessageOverlayResponse; - public VREvent_MessageOverlay_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("unVRMessageOverlayResponse"); - } - public VREvent_MessageOverlay_t(int unVRMessageOverlayResponse) { - super(); - this.unVRMessageOverlayResponse = unVRMessageOverlayResponse; - } - public VREvent_MessageOverlay_t(Pointer peer) { - super(peer); - } - public static class ByReference extends VREvent_MessageOverlay_t implements Structure.ByReference { - - }; - public static class ByValue extends VREvent_MessageOverlay_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Mouse_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Mouse_t.java deleted file mode 100644 index d20db8c841..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Mouse_t.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1309
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VREvent_Mouse_t extends Structure { - public float x; - public float y; - public int button; - public VREvent_Mouse_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("x", "y", "button"); - } - public VREvent_Mouse_t(float x, float y, int button) { - super(); - this.x = x; - this.y = y; - this.button = button; - } - public VREvent_Mouse_t(Pointer peer) { - super(peer); - } - public static class ByReference extends VREvent_Mouse_t implements Structure.ByReference { - - }; - public static class ByValue extends VREvent_Mouse_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Notification_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Notification_t.java deleted file mode 100644 index fa67bd5e7c..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Notification_t.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1326
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VREvent_Notification_t extends Structure { - public long ulUserValue; - public int notificationId; - public VREvent_Notification_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("ulUserValue", "notificationId"); - } - public VREvent_Notification_t(long ulUserValue, int notificationId) { - super(); - this.ulUserValue = ulUserValue; - this.notificationId = notificationId; - } - public VREvent_Notification_t(Pointer peer) { - super(peer); - } - public static class ByReference extends VREvent_Notification_t implements Structure.ByReference { - - }; - public static class ByValue extends VREvent_Notification_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Overlay_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Overlay_t.java deleted file mode 100644 index 683c485ab7..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Overlay_t.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1335
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VREvent_Overlay_t extends Structure { - public long overlayHandle; - public long devicePath; - public VREvent_Overlay_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("overlayHandle", "devicePath"); - } - public VREvent_Overlay_t(long overlayHandle, long devicePath) { - super(); - this.overlayHandle = overlayHandle; - this.devicePath = devicePath; - } - public VREvent_Overlay_t(Pointer peer) { - super(peer); - } - public static class ByReference extends VREvent_Overlay_t implements Structure.ByReference { - - }; - public static class ByValue extends VREvent_Overlay_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_PerformanceTest_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_PerformanceTest_t.java deleted file mode 100644 index 13f14852cc..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_PerformanceTest_t.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1359
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VREvent_PerformanceTest_t extends Structure { - public int m_nFidelityLevel; - public VREvent_PerformanceTest_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("m_nFidelityLevel"); - } - public VREvent_PerformanceTest_t(int m_nFidelityLevel) { - super(); - this.m_nFidelityLevel = m_nFidelityLevel; - } - public VREvent_PerformanceTest_t(Pointer peer) { - super(peer); - } - public static class ByReference extends VREvent_PerformanceTest_t implements Structure.ByReference { - - }; - public static class ByValue extends VREvent_PerformanceTest_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Process_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Process_t.java deleted file mode 100644 index 0e7f9ae2fb..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Process_t.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1331
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VREvent_Process_t extends Structure { - public int pid; - public int oldPid; - public byte bForced; - public VREvent_Process_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("pid", "oldPid", "bForced"); - } - public VREvent_Process_t(int pid, int oldPid, byte bForced) { - super(); - this.pid = pid; - this.oldPid = oldPid; - this.bForced = bForced; - } - public VREvent_Process_t(Pointer peer) { - super(peer); - } - public static class ByReference extends VREvent_Process_t implements Structure.ByReference { - - }; - public static class ByValue extends VREvent_Process_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Property_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Property_t.java deleted file mode 100644 index be84aa3129..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Property_t.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1386
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VREvent_Property_t extends Structure { - /** C type : PropertyContainerHandle_t */ - public long container; - /** - * C type : ETrackedDeviceProperty - */ - public int prop; - public VREvent_Property_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("container", "prop"); - } - /** - * @param container C type : PropertyContainerHandle_t
- * @param prop @see JOpenVRLibrary.ETrackedDeviceProperty
- * C type : ETrackedDeviceProperty - */ - public VREvent_Property_t(long container, int prop) { - super(); - this.container = container; - this.prop = prop; - } - public VREvent_Property_t(Pointer peer) { - super(peer); - } - public static class ByReference extends VREvent_Property_t implements Structure.ByReference { - - }; - public static class ByValue extends VREvent_Property_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Reserved_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Reserved_t.java deleted file mode 100644 index 13f0c8d822..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Reserved_t.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1356
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VREvent_Reserved_t extends Structure { - public long reserved0; - public long reserved1; - public long reserved2; - public long reserved3; - public VREvent_Reserved_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("reserved0", "reserved1", "reserved2", "reserved3"); - } - public VREvent_Reserved_t(long reserved0, long reserved1, long reserved2, long reserved3) { - super(); - this.reserved0 = reserved0; - this.reserved1 = reserved1; - this.reserved2 = reserved2; - this.reserved3 = reserved3; - } - public VREvent_Reserved_t(Pointer peer) { - super(peer); - } - public static class ByReference extends VREvent_Reserved_t implements Structure.ByReference { - - }; - public static class ByValue extends VREvent_Reserved_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_ScreenshotProgress_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_ScreenshotProgress_t.java deleted file mode 100644 index b0511dbc24..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_ScreenshotProgress_t.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1369
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VREvent_ScreenshotProgress_t extends Structure { - public float progress; - public VREvent_ScreenshotProgress_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("progress"); - } - public VREvent_ScreenshotProgress_t(float progress) { - super(); - this.progress = progress; - } - public VREvent_ScreenshotProgress_t(Pointer peer) { - super(peer); - } - public static class ByReference extends VREvent_ScreenshotProgress_t implements Structure.ByReference { - - }; - public static class ByValue extends VREvent_ScreenshotProgress_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Screenshot_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Screenshot_t.java deleted file mode 100644 index c35acd1390..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Screenshot_t.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1366
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VREvent_Screenshot_t extends Structure { - public int handle; - public int type; - public VREvent_Screenshot_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("handle", "type"); - } - public VREvent_Screenshot_t(int handle, int type) { - super(); - this.handle = handle; - this.type = type; - } - public VREvent_Screenshot_t(Pointer peer) { - super(peer); - } - public static class ByReference extends VREvent_Screenshot_t implements Structure.ByReference { - - }; - public static class ByValue extends VREvent_Screenshot_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Scroll_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Scroll_t.java deleted file mode 100644 index 1d29ea839b..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Scroll_t.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1314
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VREvent_Scroll_t extends Structure { - public float xdelta; - public float ydelta; - public int repeatCount; - public VREvent_Scroll_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("xdelta", "ydelta", "repeatCount"); - } - public VREvent_Scroll_t(float xdelta, float ydelta, int repeatCount) { - super(); - this.xdelta = xdelta; - this.ydelta = ydelta; - this.repeatCount = repeatCount; - } - public VREvent_Scroll_t(Pointer peer) { - super(peer); - } - public static class ByReference extends VREvent_Scroll_t implements Structure.ByReference { - - }; - public static class ByValue extends VREvent_Scroll_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_SeatedZeroPoseReset_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_SeatedZeroPoseReset_t.java deleted file mode 100644 index cb7c9f62c5..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_SeatedZeroPoseReset_t.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1362
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VREvent_SeatedZeroPoseReset_t extends Structure { - public byte bResetBySystemMenu; - public VREvent_SeatedZeroPoseReset_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("bResetBySystemMenu"); - } - public VREvent_SeatedZeroPoseReset_t(byte bResetBySystemMenu) { - super(); - this.bResetBySystemMenu = bResetBySystemMenu; - } - public VREvent_SeatedZeroPoseReset_t(Pointer peer) { - super(peer); - } - public static class ByReference extends VREvent_SeatedZeroPoseReset_t implements Structure.ByReference { - - }; - public static class ByValue extends VREvent_SeatedZeroPoseReset_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_SpatialAnchor_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_SpatialAnchor_t.java deleted file mode 100644 index eeb51f2e26..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_SpatialAnchor_t.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1420
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VREvent_SpatialAnchor_t extends Structure { - /** C type : SpatialAnchorHandle_t */ - public int unHandle; - public VREvent_SpatialAnchor_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("unHandle"); - } - /** @param unHandle C type : SpatialAnchorHandle_t */ - public VREvent_SpatialAnchor_t(int unHandle) { - super(); - this.unHandle = unHandle; - } - public VREvent_SpatialAnchor_t(Pointer peer) { - super(peer); - } - public static class ByReference extends VREvent_SpatialAnchor_t implements Structure.ByReference { - - }; - public static class ByValue extends VREvent_SpatialAnchor_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Status_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Status_t.java deleted file mode 100644 index d16d2c0727..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_Status_t.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1338
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VREvent_Status_t extends Structure { - public int statusState; - public VREvent_Status_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("statusState"); - } - public VREvent_Status_t(int statusState) { - super(); - this.statusState = statusState; - } - public VREvent_Status_t(Pointer peer) { - super(peer); - } - public static class ByReference extends VREvent_Status_t implements Structure.ByReference { - - }; - public static class ByValue extends VREvent_Status_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_TouchPadMove_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_TouchPadMove_t.java deleted file mode 100644 index dd123e0d3b..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_TouchPadMove_t.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1322
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VREvent_TouchPadMove_t extends Structure { - public byte bFingerDown; - public float flSecondsFingerDown; - public float fValueXFirst; - public float fValueYFirst; - public float fValueXRaw; - public float fValueYRaw; - public VREvent_TouchPadMove_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("bFingerDown", "flSecondsFingerDown", "fValueXFirst", "fValueYFirst", "fValueXRaw", "fValueYRaw"); - } - public VREvent_TouchPadMove_t(byte bFingerDown, float flSecondsFingerDown, float fValueXFirst, float fValueYFirst, float fValueXRaw, float fValueYRaw) { - super(); - this.bFingerDown = bFingerDown; - this.flSecondsFingerDown = flSecondsFingerDown; - this.fValueXFirst = fValueXFirst; - this.fValueYFirst = fValueYFirst; - this.fValueXRaw = fValueXRaw; - this.fValueYRaw = fValueYRaw; - } - public VREvent_TouchPadMove_t(Pointer peer) { - super(peer); - } - public static class ByReference extends VREvent_TouchPadMove_t implements Structure.ByReference { - - }; - public static class ByValue extends VREvent_TouchPadMove_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_WebConsole_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_WebConsole_t.java deleted file mode 100644 index 21d9bdf390..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_WebConsole_t.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1405
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VREvent_WebConsole_t extends Structure { - /** C type : WebConsoleHandle_t */ - public long webConsoleHandle; - public VREvent_WebConsole_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("webConsoleHandle"); - } - /** @param webConsoleHandle C type : WebConsoleHandle_t */ - public VREvent_WebConsole_t(long webConsoleHandle) { - super(); - this.webConsoleHandle = webConsoleHandle; - } - public VREvent_WebConsole_t(Pointer peer) { - super(peer); - } - public static class ByReference extends VREvent_WebConsole_t implements Structure.ByReference { - - }; - public static class ByValue extends VREvent_WebConsole_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_t.java deleted file mode 100644 index 843f9da821..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VREvent_t.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * An event posted by the server to all running applications
- * native declaration : headers\openvr_capi.h:1694
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VREvent_t extends Structure { - /** EVREventType enum */ - public int eventType; - /** C type : TrackedDeviceIndex_t */ - public int trackedDeviceIndex; - public float eventAgeSeconds; - /** C type : VREvent_Data_t */ - public VREvent_Data_t data; - public VREvent_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("eventType", "trackedDeviceIndex", "eventAgeSeconds", "data"); - } - /** - * @param eventType EVREventType enum
- * @param trackedDeviceIndex C type : TrackedDeviceIndex_t
- * @param data C type : VREvent_Data_t - */ - public VREvent_t(int eventType, int trackedDeviceIndex, float eventAgeSeconds, VREvent_Data_t data) { - super(); - this.eventType = eventType; - this.trackedDeviceIndex = trackedDeviceIndex; - this.eventAgeSeconds = eventAgeSeconds; - this.data = data; - } - public VREvent_t(Pointer peer) { - super(peer); - } - public static class ByReference extends VREvent_t implements Structure.ByReference { - - }; - public static class ByValue extends VREvent_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VROverlayIntersectionMaskPrimitive_Data_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VROverlayIntersectionMaskPrimitive_Data_t.java deleted file mode 100644 index 9020bf2852..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VROverlayIntersectionMaskPrimitive_Data_t.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Union; -/** - * native declaration : headers\openvr_capi.h:1698
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VROverlayIntersectionMaskPrimitive_Data_t extends Union { - /** C type : IntersectionMaskRectangle_t */ - public IntersectionMaskRectangle_t m_Rectangle; - /** C type : IntersectionMaskCircle_t */ - public IntersectionMaskCircle_t m_Circle; - public VROverlayIntersectionMaskPrimitive_Data_t() { - super(); - } - /** @param m_Rectangle C type : IntersectionMaskRectangle_t */ - public VROverlayIntersectionMaskPrimitive_Data_t(IntersectionMaskRectangle_t m_Rectangle) { - super(); - this.m_Rectangle = m_Rectangle; - setType(IntersectionMaskRectangle_t.class); - } - /** @param m_Circle C type : IntersectionMaskCircle_t */ - public VROverlayIntersectionMaskPrimitive_Data_t(IntersectionMaskCircle_t m_Circle) { - super(); - this.m_Circle = m_Circle; - setType(IntersectionMaskCircle_t.class); - } - public VROverlayIntersectionMaskPrimitive_Data_t(Pointer peer) { - super(peer); - } - public static class ByReference extends VROverlayIntersectionMaskPrimitive_Data_t implements com.sun.jna.Structure.ByReference { - - }; - public static class ByValue extends VROverlayIntersectionMaskPrimitive_Data_t implements com.sun.jna.Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VROverlayIntersectionMaskPrimitive_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VROverlayIntersectionMaskPrimitive_t.java deleted file mode 100644 index e0396fda97..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VROverlayIntersectionMaskPrimitive_t.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1702
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VROverlayIntersectionMaskPrimitive_t extends Structure { - /** - * C type : EVROverlayIntersectionMaskPrimitiveType - */ - public int m_nPrimitiveType; - /** C type : VROverlayIntersectionMaskPrimitive_Data_t */ - public VROverlayIntersectionMaskPrimitive_Data_t m_Primitive; - public VROverlayIntersectionMaskPrimitive_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("m_nPrimitiveType", "m_Primitive"); - } - /** - * @param m_nPrimitiveType @see JOpenVRLibrary.EVROverlayIntersectionMaskPrimitiveType
- * C type : EVROverlayIntersectionMaskPrimitiveType
- * @param m_Primitive C type : VROverlayIntersectionMaskPrimitive_Data_t - */ - public VROverlayIntersectionMaskPrimitive_t(int m_nPrimitiveType, VROverlayIntersectionMaskPrimitive_Data_t m_Primitive) { - super(); - this.m_nPrimitiveType = m_nPrimitiveType; - this.m_Primitive = m_Primitive; - } - public VROverlayIntersectionMaskPrimitive_t(Pointer peer) { - super(peer); - } - public static class ByReference extends VROverlayIntersectionMaskPrimitive_t implements Structure.ByReference { - - }; - public static class ByValue extends VROverlayIntersectionMaskPrimitive_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VROverlayIntersectionParams_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VROverlayIntersectionParams_t.java deleted file mode 100644 index 053942a0e3..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VROverlayIntersectionParams_t.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1535
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VROverlayIntersectionParams_t extends Structure { - /** C type : HmdVector3_t */ - public HmdVector3_t vSource; - /** C type : HmdVector3_t */ - public HmdVector3_t vDirection; - /** - * C type : ETrackingUniverseOrigin - */ - public int eOrigin; - public VROverlayIntersectionParams_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("vSource", "vDirection", "eOrigin"); - } - /** - * @param vSource C type : HmdVector3_t
- * @param vDirection C type : HmdVector3_t
- * @param eOrigin @see JOpenVRLibrary.ETrackingUniverseOrigin
- * C type : ETrackingUniverseOrigin - */ - public VROverlayIntersectionParams_t(HmdVector3_t vSource, HmdVector3_t vDirection, int eOrigin) { - super(); - this.vSource = vSource; - this.vDirection = vDirection; - this.eOrigin = eOrigin; - } - public VROverlayIntersectionParams_t(Pointer peer) { - super(peer); - } - public static class ByReference extends VROverlayIntersectionParams_t implements Structure.ByReference { - - }; - public static class ByValue extends VROverlayIntersectionParams_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VROverlayIntersectionResults_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VROverlayIntersectionResults_t.java deleted file mode 100644 index 7fa5b020f2..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VROverlayIntersectionResults_t.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1541
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VROverlayIntersectionResults_t extends Structure { - /** C type : HmdVector3_t */ - public HmdVector3_t vPoint; - /** C type : HmdVector3_t */ - public HmdVector3_t vNormal; - /** C type : HmdVector2_t */ - public HmdVector2_t vUVs; - public float fDistance; - public VROverlayIntersectionResults_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("vPoint", "vNormal", "vUVs", "fDistance"); - } - /** - * @param vPoint C type : HmdVector3_t
- * @param vNormal C type : HmdVector3_t
- * @param vUVs C type : HmdVector2_t - */ - public VROverlayIntersectionResults_t(HmdVector3_t vPoint, HmdVector3_t vNormal, HmdVector2_t vUVs, float fDistance) { - super(); - this.vPoint = vPoint; - this.vNormal = vNormal; - this.vUVs = vUVs; - this.fDistance = fDistance; - } - public VROverlayIntersectionResults_t(Pointer peer) { - super(peer); - } - public static class ByReference extends VROverlayIntersectionResults_t implements Structure.ByReference { - - }; - public static class ByValue extends VROverlayIntersectionResults_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRTextureBounds_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRTextureBounds_t.java deleted file mode 100644 index 88c779846c..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRTextureBounds_t.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1263
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VRTextureBounds_t extends Structure { - public float uMin; - public float vMin; - public float uMax; - public float vMax; - public VRTextureBounds_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("uMin", "vMin", "uMax", "vMax"); - } - public VRTextureBounds_t(float uMin, float vMin, float uMax, float vMax) { - super(); - this.uMin = uMin; - this.vMin = vMin; - this.uMax = uMax; - this.vMax = vMax; - } - public VRTextureBounds_t(Pointer peer) { - super(peer); - } - public static class ByReference extends VRTextureBounds_t implements Structure.ByReference { - - }; - public static class ByValue extends VRTextureBounds_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRTextureDepthInfo_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRTextureDepthInfo_t.java deleted file mode 100644 index 89f42f80be..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRTextureDepthInfo_t.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1272
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VRTextureDepthInfo_t extends Structure { - /** - * void *
- * C type : void* - */ - public Pointer handle; - /** C type : HmdMatrix44_t */ - public HmdMatrix44_t mProjection; - /** C type : HmdVector2_t */ - public HmdVector2_t vRange; - public VRTextureDepthInfo_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("handle", "mProjection", "vRange"); - } - /** - * @param handle void *
- * C type : void*
- * @param mProjection C type : HmdMatrix44_t
- * @param vRange C type : HmdVector2_t - */ - public VRTextureDepthInfo_t(Pointer handle, HmdMatrix44_t mProjection, HmdVector2_t vRange) { - super(); - this.handle = handle; - this.mProjection = mProjection; - this.vRange = vRange; - } - public VRTextureDepthInfo_t(Pointer peer) { - super(peer); - } - public static class ByReference extends VRTextureDepthInfo_t implements Structure.ByReference { - - }; - public static class ByValue extends VRTextureDepthInfo_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRTextureWithDepth_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRTextureWithDepth_t.java deleted file mode 100644 index 0601b2b7a3..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRTextureWithDepth_t.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1275
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VRTextureWithDepth_t extends Structure { - /** C type : VRTextureDepthInfo_t */ - public VRTextureDepthInfo_t depth; - public VRTextureWithDepth_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("depth"); - } - /** @param depth C type : VRTextureDepthInfo_t */ - public VRTextureWithDepth_t(VRTextureDepthInfo_t depth) { - super(); - this.depth = depth; - } - public VRTextureWithDepth_t(Pointer peer) { - super(peer); - } - public static class ByReference extends VRTextureWithDepth_t implements Structure.ByReference { - - }; - public static class ByValue extends VRTextureWithDepth_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRTextureWithPoseAndDepth_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRTextureWithPoseAndDepth_t.java deleted file mode 100644 index bbe447ba2c..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRTextureWithPoseAndDepth_t.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1278
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VRTextureWithPoseAndDepth_t extends Structure { - /** C type : VRTextureDepthInfo_t */ - public VRTextureDepthInfo_t depth; - public VRTextureWithPoseAndDepth_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("depth"); - } - /** @param depth C type : VRTextureDepthInfo_t */ - public VRTextureWithPoseAndDepth_t(VRTextureDepthInfo_t depth) { - super(); - this.depth = depth; - } - public VRTextureWithPoseAndDepth_t(Pointer peer) { - super(peer); - } - public static class ByReference extends VRTextureWithPoseAndDepth_t implements Structure.ByReference { - - }; - public static class ByValue extends VRTextureWithPoseAndDepth_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRTextureWithPose_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRTextureWithPose_t.java deleted file mode 100644 index 8eff35c066..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRTextureWithPose_t.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1266
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VRTextureWithPose_t extends Structure { - /** C type : HmdMatrix34_t */ - public HmdMatrix34_t mDeviceToAbsoluteTracking; - public VRTextureWithPose_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("mDeviceToAbsoluteTracking"); - } - /** @param mDeviceToAbsoluteTracking C type : HmdMatrix34_t */ - public VRTextureWithPose_t(HmdMatrix34_t mDeviceToAbsoluteTracking) { - super(); - this.mDeviceToAbsoluteTracking = mDeviceToAbsoluteTracking; - } - public VRTextureWithPose_t(Pointer peer) { - super(peer); - } - public static class ByReference extends VRTextureWithPose_t implements Structure.ByReference { - - }; - public static class ByValue extends VRTextureWithPose_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRVulkanTextureData_t.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRVulkanTextureData_t.java deleted file mode 100644 index 9ac3eb08bf..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VRVulkanTextureData_t.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.jme3.system.jopenvr; -import com.jme3.system.jopenvr.JOpenVRLibrary.VkDevice_T; -import com.jme3.system.jopenvr.JOpenVRLibrary.VkInstance_T; -import com.jme3.system.jopenvr.JOpenVRLibrary.VkPhysicalDevice_T; -import com.jme3.system.jopenvr.JOpenVRLibrary.VkQueue_T; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1294
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VRVulkanTextureData_t extends Structure { - public long m_nImage; - /** - * struct VkDevice_T *
- * C type : VkDevice_T* - */ - public VkDevice_T m_pDevice; - /** - * struct VkPhysicalDevice_T *
- * C type : VkPhysicalDevice_T* - */ - public VkPhysicalDevice_T m_pPhysicalDevice; - /** - * struct VkInstance_T *
- * C type : VkInstance_T* - */ - public VkInstance_T m_pInstance; - /** - * struct VkQueue_T *
- * C type : VkQueue_T* - */ - public VkQueue_T m_pQueue; - public int m_nQueueFamilyIndex; - public int m_nWidth; - public int m_nHeight; - public int m_nFormat; - public int m_nSampleCount; - public VRVulkanTextureData_t() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("m_nImage", "m_pDevice", "m_pPhysicalDevice", "m_pInstance", "m_pQueue", "m_nQueueFamilyIndex", "m_nWidth", "m_nHeight", "m_nFormat", "m_nSampleCount"); - } - public VRVulkanTextureData_t(Pointer peer) { - super(peer); - } - public static class ByReference extends VRVulkanTextureData_t implements Structure.ByReference { - - }; - public static class ByValue extends VRVulkanTextureData_t implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRApplications_FnTable.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRApplications_FnTable.java deleted file mode 100644 index eed61b3e02..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRApplications_FnTable.java +++ /dev/null @@ -1,217 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Callback; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import com.sun.jna.ptr.IntByReference; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1897
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VR_IVRApplications_FnTable extends Structure { - /** C type : AddApplicationManifest_callback* */ - public VR_IVRApplications_FnTable.AddApplicationManifest_callback AddApplicationManifest; - /** C type : RemoveApplicationManifest_callback* */ - public VR_IVRApplications_FnTable.RemoveApplicationManifest_callback RemoveApplicationManifest; - /** C type : IsApplicationInstalled_callback* */ - public VR_IVRApplications_FnTable.IsApplicationInstalled_callback IsApplicationInstalled; - /** C type : GetApplicationCount_callback* */ - public VR_IVRApplications_FnTable.GetApplicationCount_callback GetApplicationCount; - /** C type : GetApplicationKeyByIndex_callback* */ - public VR_IVRApplications_FnTable.GetApplicationKeyByIndex_callback GetApplicationKeyByIndex; - /** C type : GetApplicationKeyByProcessId_callback* */ - public VR_IVRApplications_FnTable.GetApplicationKeyByProcessId_callback GetApplicationKeyByProcessId; - /** C type : LaunchApplication_callback* */ - public VR_IVRApplications_FnTable.LaunchApplication_callback LaunchApplication; - /** C type : LaunchTemplateApplication_callback* */ - public VR_IVRApplications_FnTable.LaunchTemplateApplication_callback LaunchTemplateApplication; - /** C type : LaunchApplicationFromMimeType_callback* */ - public VR_IVRApplications_FnTable.LaunchApplicationFromMimeType_callback LaunchApplicationFromMimeType; - /** C type : LaunchDashboardOverlay_callback* */ - public VR_IVRApplications_FnTable.LaunchDashboardOverlay_callback LaunchDashboardOverlay; - /** C type : CancelApplicationLaunch_callback* */ - public VR_IVRApplications_FnTable.CancelApplicationLaunch_callback CancelApplicationLaunch; - /** C type : IdentifyApplication_callback* */ - public VR_IVRApplications_FnTable.IdentifyApplication_callback IdentifyApplication; - /** C type : GetApplicationProcessId_callback* */ - public VR_IVRApplications_FnTable.GetApplicationProcessId_callback GetApplicationProcessId; - /** C type : GetApplicationsErrorNameFromEnum_callback* */ - public VR_IVRApplications_FnTable.GetApplicationsErrorNameFromEnum_callback GetApplicationsErrorNameFromEnum; - /** C type : GetApplicationPropertyString_callback* */ - public VR_IVRApplications_FnTable.GetApplicationPropertyString_callback GetApplicationPropertyString; - /** C type : GetApplicationPropertyBool_callback* */ - public VR_IVRApplications_FnTable.GetApplicationPropertyBool_callback GetApplicationPropertyBool; - /** C type : GetApplicationPropertyUint64_callback* */ - public VR_IVRApplications_FnTable.GetApplicationPropertyUint64_callback GetApplicationPropertyUint64; - /** C type : SetApplicationAutoLaunch_callback* */ - public VR_IVRApplications_FnTable.SetApplicationAutoLaunch_callback SetApplicationAutoLaunch; - /** C type : GetApplicationAutoLaunch_callback* */ - public VR_IVRApplications_FnTable.GetApplicationAutoLaunch_callback GetApplicationAutoLaunch; - /** C type : SetDefaultApplicationForMimeType_callback* */ - public VR_IVRApplications_FnTable.SetDefaultApplicationForMimeType_callback SetDefaultApplicationForMimeType; - /** C type : GetDefaultApplicationForMimeType_callback* */ - public VR_IVRApplications_FnTable.GetDefaultApplicationForMimeType_callback GetDefaultApplicationForMimeType; - /** C type : GetApplicationSupportedMimeTypes_callback* */ - public VR_IVRApplications_FnTable.GetApplicationSupportedMimeTypes_callback GetApplicationSupportedMimeTypes; - /** C type : GetApplicationsThatSupportMimeType_callback* */ - public VR_IVRApplications_FnTable.GetApplicationsThatSupportMimeType_callback GetApplicationsThatSupportMimeType; - /** C type : GetApplicationLaunchArguments_callback* */ - public VR_IVRApplications_FnTable.GetApplicationLaunchArguments_callback GetApplicationLaunchArguments; - /** C type : GetStartingApplication_callback* */ - public VR_IVRApplications_FnTable.GetStartingApplication_callback GetStartingApplication; - /** C type : GetTransitionState_callback* */ - public VR_IVRApplications_FnTable.GetTransitionState_callback GetTransitionState; - /** C type : PerformApplicationPrelaunchCheck_callback* */ - public VR_IVRApplications_FnTable.PerformApplicationPrelaunchCheck_callback PerformApplicationPrelaunchCheck; - /** C type : GetApplicationsTransitionStateNameFromEnum_callback* */ - public VR_IVRApplications_FnTable.GetApplicationsTransitionStateNameFromEnum_callback GetApplicationsTransitionStateNameFromEnum; - /** C type : IsQuitUserPromptRequested_callback* */ - public VR_IVRApplications_FnTable.IsQuitUserPromptRequested_callback IsQuitUserPromptRequested; - /** C type : LaunchInternalProcess_callback* */ - public VR_IVRApplications_FnTable.LaunchInternalProcess_callback LaunchInternalProcess; - /** C type : GetCurrentSceneProcessId_callback* */ - public VR_IVRApplications_FnTable.GetCurrentSceneProcessId_callback GetCurrentSceneProcessId; - /** native declaration : headers\openvr_capi.h:1866 */ - public interface AddApplicationManifest_callback extends Callback { - int apply(Pointer pchApplicationManifestFullPath, byte bTemporary); - }; - /** native declaration : headers\openvr_capi.h:1867 */ - public interface RemoveApplicationManifest_callback extends Callback { - int apply(Pointer pchApplicationManifestFullPath); - }; - /** native declaration : headers\openvr_capi.h:1868 */ - public interface IsApplicationInstalled_callback extends Callback { - byte apply(Pointer pchAppKey); - }; - /** native declaration : headers\openvr_capi.h:1869 */ - public interface GetApplicationCount_callback extends Callback { - int apply(); - }; - /** native declaration : headers\openvr_capi.h:1870 */ - public interface GetApplicationKeyByIndex_callback extends Callback { - int apply(int unApplicationIndex, Pointer pchAppKeyBuffer, int unAppKeyBufferLen); - }; - /** native declaration : headers\openvr_capi.h:1871 */ - public interface GetApplicationKeyByProcessId_callback extends Callback { - int apply(int unProcessId, Pointer pchAppKeyBuffer, int unAppKeyBufferLen); - }; - /** native declaration : headers\openvr_capi.h:1872 */ - public interface LaunchApplication_callback extends Callback { - int apply(Pointer pchAppKey); - }; - /** native declaration : headers\openvr_capi.h:1873 */ - public interface LaunchTemplateApplication_callback extends Callback { - int apply(Pointer pchTemplateAppKey, Pointer pchNewAppKey, AppOverrideKeys_t pKeys, int unKeys); - }; - /** native declaration : headers\openvr_capi.h:1874 */ - public interface LaunchApplicationFromMimeType_callback extends Callback { - int apply(Pointer pchMimeType, Pointer pchArgs); - }; - /** native declaration : headers\openvr_capi.h:1875 */ - public interface LaunchDashboardOverlay_callback extends Callback { - int apply(Pointer pchAppKey); - }; - /** native declaration : headers\openvr_capi.h:1876 */ - public interface CancelApplicationLaunch_callback extends Callback { - byte apply(Pointer pchAppKey); - }; - /** native declaration : headers\openvr_capi.h:1877 */ - public interface IdentifyApplication_callback extends Callback { - int apply(int unProcessId, Pointer pchAppKey); - }; - /** native declaration : headers\openvr_capi.h:1878 */ - public interface GetApplicationProcessId_callback extends Callback { - int apply(Pointer pchAppKey); - }; - /** native declaration : headers\openvr_capi.h:1879 */ - public interface GetApplicationsErrorNameFromEnum_callback extends Callback { - Pointer apply(int error); - }; - /** native declaration : headers\openvr_capi.h:1880 */ - public interface GetApplicationPropertyString_callback extends Callback { - int apply(Pointer pchAppKey, int eProperty, Pointer pchPropertyValueBuffer, int unPropertyValueBufferLen, IntByReference peError); - }; - /** native declaration : headers\openvr_capi.h:1881 */ - public interface GetApplicationPropertyBool_callback extends Callback { - byte apply(Pointer pchAppKey, int eProperty, IntByReference peError); - }; - /** native declaration : headers\openvr_capi.h:1882 */ - public interface GetApplicationPropertyUint64_callback extends Callback { - long apply(Pointer pchAppKey, int eProperty, IntByReference peError); - }; - /** native declaration : headers\openvr_capi.h:1883 */ - public interface SetApplicationAutoLaunch_callback extends Callback { - int apply(Pointer pchAppKey, byte bAutoLaunch); - }; - /** native declaration : headers\openvr_capi.h:1884 */ - public interface GetApplicationAutoLaunch_callback extends Callback { - byte apply(Pointer pchAppKey); - }; - /** native declaration : headers\openvr_capi.h:1885 */ - public interface SetDefaultApplicationForMimeType_callback extends Callback { - int apply(Pointer pchAppKey, Pointer pchMimeType); - }; - /** native declaration : headers\openvr_capi.h:1886 */ - public interface GetDefaultApplicationForMimeType_callback extends Callback { - byte apply(Pointer pchMimeType, Pointer pchAppKeyBuffer, int unAppKeyBufferLen); - }; - /** native declaration : headers\openvr_capi.h:1887 */ - public interface GetApplicationSupportedMimeTypes_callback extends Callback { - byte apply(Pointer pchAppKey, Pointer pchMimeTypesBuffer, int unMimeTypesBuffer); - }; - /** native declaration : headers\openvr_capi.h:1888 */ - public interface GetApplicationsThatSupportMimeType_callback extends Callback { - int apply(Pointer pchMimeType, Pointer pchAppKeysThatSupportBuffer, int unAppKeysThatSupportBuffer); - }; - /** native declaration : headers\openvr_capi.h:1889 */ - public interface GetApplicationLaunchArguments_callback extends Callback { - int apply(int unHandle, Pointer pchArgs, int unArgs); - }; - /** native declaration : headers\openvr_capi.h:1890 */ - public interface GetStartingApplication_callback extends Callback { - int apply(Pointer pchAppKeyBuffer, int unAppKeyBufferLen); - }; - /** native declaration : headers\openvr_capi.h:1891 */ - public interface GetTransitionState_callback extends Callback { - int apply(); - }; - /** native declaration : headers\openvr_capi.h:1892 */ - public interface PerformApplicationPrelaunchCheck_callback extends Callback { - int apply(Pointer pchAppKey); - }; - /** native declaration : headers\openvr_capi.h:1893 */ - public interface GetApplicationsTransitionStateNameFromEnum_callback extends Callback { - Pointer apply(int state); - }; - /** native declaration : headers\openvr_capi.h:1894 */ - public interface IsQuitUserPromptRequested_callback extends Callback { - byte apply(); - }; - /** native declaration : headers\openvr_capi.h:1895 */ - public interface LaunchInternalProcess_callback extends Callback { - int apply(Pointer pchBinaryPath, Pointer pchArguments, Pointer pchWorkingDirectory); - }; - /** native declaration : headers\openvr_capi.h:1896 */ - public interface GetCurrentSceneProcessId_callback extends Callback { - int apply(); - }; - public VR_IVRApplications_FnTable() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("AddApplicationManifest", "RemoveApplicationManifest", "IsApplicationInstalled", "GetApplicationCount", "GetApplicationKeyByIndex", "GetApplicationKeyByProcessId", "LaunchApplication", "LaunchTemplateApplication", "LaunchApplicationFromMimeType", "LaunchDashboardOverlay", "CancelApplicationLaunch", "IdentifyApplication", "GetApplicationProcessId", "GetApplicationsErrorNameFromEnum", "GetApplicationPropertyString", "GetApplicationPropertyBool", "GetApplicationPropertyUint64", "SetApplicationAutoLaunch", "GetApplicationAutoLaunch", "SetDefaultApplicationForMimeType", "GetDefaultApplicationForMimeType", "GetApplicationSupportedMimeTypes", "GetApplicationsThatSupportMimeType", "GetApplicationLaunchArguments", "GetStartingApplication", "GetTransitionState", "PerformApplicationPrelaunchCheck", "GetApplicationsTransitionStateNameFromEnum", "IsQuitUserPromptRequested", "LaunchInternalProcess", "GetCurrentSceneProcessId"); - } - public VR_IVRApplications_FnTable(Pointer peer) { - super(peer); - } - public static class ByReference extends VR_IVRApplications_FnTable implements Structure.ByReference { - - }; - public static class ByValue extends VR_IVRApplications_FnTable implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRChaperoneSetup_FnTable.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRChaperoneSetup_FnTable.java deleted file mode 100644 index 5795f54df7..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRChaperoneSetup_FnTable.java +++ /dev/null @@ -1,152 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Callback; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import com.sun.jna.ptr.FloatByReference; -import com.sun.jna.ptr.IntByReference; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1957
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VR_IVRChaperoneSetup_FnTable extends Structure { - /** C type : CommitWorkingCopy_callback* */ - public VR_IVRChaperoneSetup_FnTable.CommitWorkingCopy_callback CommitWorkingCopy; - /** C type : RevertWorkingCopy_callback* */ - public VR_IVRChaperoneSetup_FnTable.RevertWorkingCopy_callback RevertWorkingCopy; - /** C type : GetWorkingPlayAreaSize_callback* */ - public VR_IVRChaperoneSetup_FnTable.GetWorkingPlayAreaSize_callback GetWorkingPlayAreaSize; - /** C type : GetWorkingPlayAreaRect_callback* */ - public VR_IVRChaperoneSetup_FnTable.GetWorkingPlayAreaRect_callback GetWorkingPlayAreaRect; - /** C type : GetWorkingCollisionBoundsInfo_callback* */ - public VR_IVRChaperoneSetup_FnTable.GetWorkingCollisionBoundsInfo_callback GetWorkingCollisionBoundsInfo; - /** C type : GetLiveCollisionBoundsInfo_callback* */ - public VR_IVRChaperoneSetup_FnTable.GetLiveCollisionBoundsInfo_callback GetLiveCollisionBoundsInfo; - /** C type : GetWorkingSeatedZeroPoseToRawTrackingPose_callback* */ - public VR_IVRChaperoneSetup_FnTable.GetWorkingSeatedZeroPoseToRawTrackingPose_callback GetWorkingSeatedZeroPoseToRawTrackingPose; - /** C type : GetWorkingStandingZeroPoseToRawTrackingPose_callback* */ - public VR_IVRChaperoneSetup_FnTable.GetWorkingStandingZeroPoseToRawTrackingPose_callback GetWorkingStandingZeroPoseToRawTrackingPose; - /** C type : SetWorkingPlayAreaSize_callback* */ - public VR_IVRChaperoneSetup_FnTable.SetWorkingPlayAreaSize_callback SetWorkingPlayAreaSize; - /** C type : SetWorkingCollisionBoundsInfo_callback* */ - public VR_IVRChaperoneSetup_FnTable.SetWorkingCollisionBoundsInfo_callback SetWorkingCollisionBoundsInfo; - /** C type : SetWorkingSeatedZeroPoseToRawTrackingPose_callback* */ - public VR_IVRChaperoneSetup_FnTable.SetWorkingSeatedZeroPoseToRawTrackingPose_callback SetWorkingSeatedZeroPoseToRawTrackingPose; - /** C type : SetWorkingStandingZeroPoseToRawTrackingPose_callback* */ - public VR_IVRChaperoneSetup_FnTable.SetWorkingStandingZeroPoseToRawTrackingPose_callback SetWorkingStandingZeroPoseToRawTrackingPose; - /** C type : ReloadFromDisk_callback* */ - public VR_IVRChaperoneSetup_FnTable.ReloadFromDisk_callback ReloadFromDisk; - /** C type : GetLiveSeatedZeroPoseToRawTrackingPose_callback* */ - public VR_IVRChaperoneSetup_FnTable.GetLiveSeatedZeroPoseToRawTrackingPose_callback GetLiveSeatedZeroPoseToRawTrackingPose; - /** C type : SetWorkingCollisionBoundsTagsInfo_callback* */ - public VR_IVRChaperoneSetup_FnTable.SetWorkingCollisionBoundsTagsInfo_callback SetWorkingCollisionBoundsTagsInfo; - /** C type : GetLiveCollisionBoundsTagsInfo_callback* */ - public VR_IVRChaperoneSetup_FnTable.GetLiveCollisionBoundsTagsInfo_callback GetLiveCollisionBoundsTagsInfo; - /** C type : SetWorkingPhysicalBoundsInfo_callback* */ - public VR_IVRChaperoneSetup_FnTable.SetWorkingPhysicalBoundsInfo_callback SetWorkingPhysicalBoundsInfo; - /** C type : GetLivePhysicalBoundsInfo_callback* */ - public VR_IVRChaperoneSetup_FnTable.GetLivePhysicalBoundsInfo_callback GetLivePhysicalBoundsInfo; - /** C type : ExportLiveToBuffer_callback* */ - public VR_IVRChaperoneSetup_FnTable.ExportLiveToBuffer_callback ExportLiveToBuffer; - /** C type : ImportFromBufferToWorking_callback* */ - public VR_IVRChaperoneSetup_FnTable.ImportFromBufferToWorking_callback ImportFromBufferToWorking; - /** native declaration : headers\openvr_capi.h:1937 */ - public interface CommitWorkingCopy_callback extends Callback { - byte apply(int configFile); - }; - /** native declaration : headers\openvr_capi.h:1938 */ - public interface RevertWorkingCopy_callback extends Callback { - void apply(); - }; - /** native declaration : headers\openvr_capi.h:1939 */ - public interface GetWorkingPlayAreaSize_callback extends Callback { - byte apply(FloatByReference pSizeX, FloatByReference pSizeZ); - }; - /** native declaration : headers\openvr_capi.h:1940 */ - public interface GetWorkingPlayAreaRect_callback extends Callback { - byte apply(HmdQuad_t rect); - }; - /** native declaration : headers\openvr_capi.h:1941 */ - public interface GetWorkingCollisionBoundsInfo_callback extends Callback { - byte apply(HmdQuad_t pQuadsBuffer, IntByReference punQuadsCount); - }; - /** native declaration : headers\openvr_capi.h:1942 */ - public interface GetLiveCollisionBoundsInfo_callback extends Callback { - byte apply(HmdQuad_t pQuadsBuffer, IntByReference punQuadsCount); - }; - /** native declaration : headers\openvr_capi.h:1943 */ - public interface GetWorkingSeatedZeroPoseToRawTrackingPose_callback extends Callback { - byte apply(HmdMatrix34_t pmatSeatedZeroPoseToRawTrackingPose); - }; - /** native declaration : headers\openvr_capi.h:1944 */ - public interface GetWorkingStandingZeroPoseToRawTrackingPose_callback extends Callback { - byte apply(HmdMatrix34_t pmatStandingZeroPoseToRawTrackingPose); - }; - /** native declaration : headers\openvr_capi.h:1945 */ - public interface SetWorkingPlayAreaSize_callback extends Callback { - void apply(float sizeX, float sizeZ); - }; - /** native declaration : headers\openvr_capi.h:1946 */ - public interface SetWorkingCollisionBoundsInfo_callback extends Callback { - void apply(HmdQuad_t pQuadsBuffer, int unQuadsCount); - }; - /** native declaration : headers\openvr_capi.h:1947 */ - public interface SetWorkingSeatedZeroPoseToRawTrackingPose_callback extends Callback { - void apply(HmdMatrix34_t pMatSeatedZeroPoseToRawTrackingPose); - }; - /** native declaration : headers\openvr_capi.h:1948 */ - public interface SetWorkingStandingZeroPoseToRawTrackingPose_callback extends Callback { - void apply(HmdMatrix34_t pMatStandingZeroPoseToRawTrackingPose); - }; - /** native declaration : headers\openvr_capi.h:1949 */ - public interface ReloadFromDisk_callback extends Callback { - void apply(int configFile); - }; - /** native declaration : headers\openvr_capi.h:1950 */ - public interface GetLiveSeatedZeroPoseToRawTrackingPose_callback extends Callback { - byte apply(HmdMatrix34_t pmatSeatedZeroPoseToRawTrackingPose); - }; - /** native declaration : headers\openvr_capi.h:1951 */ - public interface SetWorkingCollisionBoundsTagsInfo_callback extends Callback { - void apply(Pointer pTagsBuffer, int unTagCount); - }; - /** native declaration : headers\openvr_capi.h:1952 */ - public interface GetLiveCollisionBoundsTagsInfo_callback extends Callback { - byte apply(Pointer pTagsBuffer, IntByReference punTagCount); - }; - /** native declaration : headers\openvr_capi.h:1953 */ - public interface SetWorkingPhysicalBoundsInfo_callback extends Callback { - byte apply(HmdQuad_t pQuadsBuffer, int unQuadsCount); - }; - /** native declaration : headers\openvr_capi.h:1954 */ - public interface GetLivePhysicalBoundsInfo_callback extends Callback { - byte apply(HmdQuad_t pQuadsBuffer, IntByReference punQuadsCount); - }; - /** native declaration : headers\openvr_capi.h:1955 */ - public interface ExportLiveToBuffer_callback extends Callback { - byte apply(Pointer pBuffer, IntByReference pnBufferLength); - }; - /** native declaration : headers\openvr_capi.h:1956 */ - public interface ImportFromBufferToWorking_callback extends Callback { - byte apply(Pointer pBuffer, int nImportFlags); - }; - public VR_IVRChaperoneSetup_FnTable() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("CommitWorkingCopy", "RevertWorkingCopy", "GetWorkingPlayAreaSize", "GetWorkingPlayAreaRect", "GetWorkingCollisionBoundsInfo", "GetLiveCollisionBoundsInfo", "GetWorkingSeatedZeroPoseToRawTrackingPose", "GetWorkingStandingZeroPoseToRawTrackingPose", "SetWorkingPlayAreaSize", "SetWorkingCollisionBoundsInfo", "SetWorkingSeatedZeroPoseToRawTrackingPose", "SetWorkingStandingZeroPoseToRawTrackingPose", "ReloadFromDisk", "GetLiveSeatedZeroPoseToRawTrackingPose", "SetWorkingCollisionBoundsTagsInfo", "GetLiveCollisionBoundsTagsInfo", "SetWorkingPhysicalBoundsInfo", "GetLivePhysicalBoundsInfo", "ExportLiveToBuffer", "ImportFromBufferToWorking"); - } - public VR_IVRChaperoneSetup_FnTable(Pointer peer) { - super(peer); - } - public static class ByReference extends VR_IVRChaperoneSetup_FnTable implements Structure.ByReference { - - }; - public static class ByValue extends VR_IVRChaperoneSetup_FnTable implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRChaperone_FnTable.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRChaperone_FnTable.java deleted file mode 100644 index 1a575c6c09..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRChaperone_FnTable.java +++ /dev/null @@ -1,100 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Callback; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import com.sun.jna.ptr.FloatByReference; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1915
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VR_IVRChaperone_FnTable extends Structure { - /** C type : GetCalibrationState_callback* */ - public VR_IVRChaperone_FnTable.GetCalibrationState_callback GetCalibrationState; - /** C type : GetPlayAreaSize_callback* */ - public VR_IVRChaperone_FnTable.GetPlayAreaSize_callback GetPlayAreaSize; - /** C type : GetPlayAreaRect_callback* */ - public VR_IVRChaperone_FnTable.GetPlayAreaRect_callback GetPlayAreaRect; - /** C type : ReloadInfo_callback* */ - public VR_IVRChaperone_FnTable.ReloadInfo_callback ReloadInfo; - /** C type : SetSceneColor_callback* */ - public VR_IVRChaperone_FnTable.SetSceneColor_callback SetSceneColor; - /** C type : GetBoundsColor_callback* */ - public VR_IVRChaperone_FnTable.GetBoundsColor_callback GetBoundsColor; - /** C type : AreBoundsVisible_callback* */ - public VR_IVRChaperone_FnTable.AreBoundsVisible_callback AreBoundsVisible; - /** C type : ForceBoundsVisible_callback* */ - public VR_IVRChaperone_FnTable.ForceBoundsVisible_callback ForceBoundsVisible; - /** native declaration : headers\openvr_capi.h:1907 */ - public interface GetCalibrationState_callback extends Callback { - int apply(); - }; - /** native declaration : headers\openvr_capi.h:1908 */ - public interface GetPlayAreaSize_callback extends Callback { - byte apply(FloatByReference pSizeX, FloatByReference pSizeZ); - }; - /** native declaration : headers\openvr_capi.h:1909 */ - public interface GetPlayAreaRect_callback extends Callback { - byte apply(HmdQuad_t rect); - }; - /** native declaration : headers\openvr_capi.h:1910 */ - public interface ReloadInfo_callback extends Callback { - void apply(); - }; - /** native declaration : headers\openvr_capi.h:1911 */ - public interface SetSceneColor_callback extends Callback { - void apply(HmdColor_t.ByValue color); - }; - /** native declaration : headers\openvr_capi.h:1912 */ - public interface GetBoundsColor_callback extends Callback { - void apply(HmdColor_t pOutputColorArray, int nNumOutputColors, float flCollisionBoundsFadeDistance, HmdColor_t pOutputCameraColor); - }; - /** native declaration : headers\openvr_capi.h:1913 */ - public interface AreBoundsVisible_callback extends Callback { - byte apply(); - }; - /** native declaration : headers\openvr_capi.h:1914 */ - public interface ForceBoundsVisible_callback extends Callback { - void apply(byte bForce); - }; - public VR_IVRChaperone_FnTable() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("GetCalibrationState", "GetPlayAreaSize", "GetPlayAreaRect", "ReloadInfo", "SetSceneColor", "GetBoundsColor", "AreBoundsVisible", "ForceBoundsVisible"); - } - /** - * @param GetCalibrationState C type : GetCalibrationState_callback*
- * @param GetPlayAreaSize C type : GetPlayAreaSize_callback*
- * @param GetPlayAreaRect C type : GetPlayAreaRect_callback*
- * @param ReloadInfo C type : ReloadInfo_callback*
- * @param SetSceneColor C type : SetSceneColor_callback*
- * @param GetBoundsColor C type : GetBoundsColor_callback*
- * @param AreBoundsVisible C type : AreBoundsVisible_callback*
- * @param ForceBoundsVisible C type : ForceBoundsVisible_callback* - */ - public VR_IVRChaperone_FnTable(VR_IVRChaperone_FnTable.GetCalibrationState_callback GetCalibrationState, VR_IVRChaperone_FnTable.GetPlayAreaSize_callback GetPlayAreaSize, VR_IVRChaperone_FnTable.GetPlayAreaRect_callback GetPlayAreaRect, VR_IVRChaperone_FnTable.ReloadInfo_callback ReloadInfo, VR_IVRChaperone_FnTable.SetSceneColor_callback SetSceneColor, VR_IVRChaperone_FnTable.GetBoundsColor_callback GetBoundsColor, VR_IVRChaperone_FnTable.AreBoundsVisible_callback AreBoundsVisible, VR_IVRChaperone_FnTable.ForceBoundsVisible_callback ForceBoundsVisible) { - super(); - this.GetCalibrationState = GetCalibrationState; - this.GetPlayAreaSize = GetPlayAreaSize; - this.GetPlayAreaRect = GetPlayAreaRect; - this.ReloadInfo = ReloadInfo; - this.SetSceneColor = SetSceneColor; - this.GetBoundsColor = GetBoundsColor; - this.AreBoundsVisible = AreBoundsVisible; - this.ForceBoundsVisible = ForceBoundsVisible; - } - public VR_IVRChaperone_FnTable(Pointer peer) { - super(peer); - } - public static class ByReference extends VR_IVRChaperone_FnTable implements Structure.ByReference { - - }; - public static class ByValue extends VR_IVRChaperone_FnTable implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRCompositor_FnTable.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRCompositor_FnTable.java deleted file mode 100644 index 53a3039437..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRCompositor_FnTable.java +++ /dev/null @@ -1,291 +0,0 @@ -package com.jme3.system.jopenvr; -import com.jme3.system.jopenvr.JOpenVRLibrary.VkPhysicalDevice_T; -import com.sun.jna.Callback; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import com.sun.jna.ptr.IntByReference; -import com.sun.jna.ptr.PointerByReference; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:2045
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VR_IVRCompositor_FnTable extends Structure { - /** C type : SetTrackingSpace_callback* */ - public VR_IVRCompositor_FnTable.SetTrackingSpace_callback SetTrackingSpace; - /** C type : GetTrackingSpace_callback* */ - public VR_IVRCompositor_FnTable.GetTrackingSpace_callback GetTrackingSpace; - /** C type : WaitGetPoses_callback* */ - public VR_IVRCompositor_FnTable.WaitGetPoses_callback WaitGetPoses; - /** C type : GetLastPoses_callback* */ - public VR_IVRCompositor_FnTable.GetLastPoses_callback GetLastPoses; - /** C type : GetLastPoseForTrackedDeviceIndex_callback* */ - public VR_IVRCompositor_FnTable.GetLastPoseForTrackedDeviceIndex_callback GetLastPoseForTrackedDeviceIndex; - /** C type : Submit_callback* */ - public VR_IVRCompositor_FnTable.Submit_callback Submit; - /** C type : ClearLastSubmittedFrame_callback* */ - public VR_IVRCompositor_FnTable.ClearLastSubmittedFrame_callback ClearLastSubmittedFrame; - /** C type : PostPresentHandoff_callback* */ - public VR_IVRCompositor_FnTable.PostPresentHandoff_callback PostPresentHandoff; - /** C type : GetFrameTiming_callback* */ - public VR_IVRCompositor_FnTable.GetFrameTiming_callback GetFrameTiming; - /** C type : GetFrameTimings_callback* */ - public VR_IVRCompositor_FnTable.GetFrameTimings_callback GetFrameTimings; - /** C type : GetFrameTimeRemaining_callback* */ - public VR_IVRCompositor_FnTable.GetFrameTimeRemaining_callback GetFrameTimeRemaining; - /** C type : GetCumulativeStats_callback* */ - public VR_IVRCompositor_FnTable.GetCumulativeStats_callback GetCumulativeStats; - /** C type : FadeToColor_callback* */ - public VR_IVRCompositor_FnTable.FadeToColor_callback FadeToColor; - /** C type : GetCurrentFadeColor_callback* */ - public VR_IVRCompositor_FnTable.GetCurrentFadeColor_callback GetCurrentFadeColor; - /** C type : FadeGrid_callback* */ - public VR_IVRCompositor_FnTable.FadeGrid_callback FadeGrid; - /** C type : GetCurrentGridAlpha_callback* */ - public VR_IVRCompositor_FnTable.GetCurrentGridAlpha_callback GetCurrentGridAlpha; - /** C type : SetSkyboxOverride_callback* */ - public VR_IVRCompositor_FnTable.SetSkyboxOverride_callback SetSkyboxOverride; - /** C type : ClearSkyboxOverride_callback* */ - public VR_IVRCompositor_FnTable.ClearSkyboxOverride_callback ClearSkyboxOverride; - /** C type : CompositorBringToFront_callback* */ - public VR_IVRCompositor_FnTable.CompositorBringToFront_callback CompositorBringToFront; - /** C type : CompositorGoToBack_callback* */ - public VR_IVRCompositor_FnTable.CompositorGoToBack_callback CompositorGoToBack; - /** C type : CompositorQuit_callback* */ - public VR_IVRCompositor_FnTable.CompositorQuit_callback CompositorQuit; - /** C type : IsFullscreen_callback* */ - public VR_IVRCompositor_FnTable.IsFullscreen_callback IsFullscreen; - /** C type : GetCurrentSceneFocusProcess_callback* */ - public VR_IVRCompositor_FnTable.GetCurrentSceneFocusProcess_callback GetCurrentSceneFocusProcess; - /** C type : GetLastFrameRenderer_callback* */ - public VR_IVRCompositor_FnTable.GetLastFrameRenderer_callback GetLastFrameRenderer; - /** C type : CanRenderScene_callback* */ - public VR_IVRCompositor_FnTable.CanRenderScene_callback CanRenderScene; - /** C type : ShowMirrorWindow_callback* */ - public VR_IVRCompositor_FnTable.ShowMirrorWindow_callback ShowMirrorWindow; - /** C type : HideMirrorWindow_callback* */ - public VR_IVRCompositor_FnTable.HideMirrorWindow_callback HideMirrorWindow; - /** C type : IsMirrorWindowVisible_callback* */ - public VR_IVRCompositor_FnTable.IsMirrorWindowVisible_callback IsMirrorWindowVisible; - /** C type : CompositorDumpImages_callback* */ - public VR_IVRCompositor_FnTable.CompositorDumpImages_callback CompositorDumpImages; - /** C type : ShouldAppRenderWithLowResources_callback* */ - public VR_IVRCompositor_FnTable.ShouldAppRenderWithLowResources_callback ShouldAppRenderWithLowResources; - /** C type : ForceInterleavedReprojectionOn_callback* */ - public VR_IVRCompositor_FnTable.ForceInterleavedReprojectionOn_callback ForceInterleavedReprojectionOn; - /** C type : ForceReconnectProcess_callback* */ - public VR_IVRCompositor_FnTable.ForceReconnectProcess_callback ForceReconnectProcess; - /** C type : SuspendRendering_callback* */ - public VR_IVRCompositor_FnTable.SuspendRendering_callback SuspendRendering; - /** C type : GetMirrorTextureD3D11_callback* */ - public VR_IVRCompositor_FnTable.GetMirrorTextureD3D11_callback GetMirrorTextureD3D11; - /** C type : ReleaseMirrorTextureD3D11_callback* */ - public VR_IVRCompositor_FnTable.ReleaseMirrorTextureD3D11_callback ReleaseMirrorTextureD3D11; - /** C type : GetMirrorTextureGL_callback* */ - public VR_IVRCompositor_FnTable.GetMirrorTextureGL_callback GetMirrorTextureGL; - /** C type : ReleaseSharedGLTexture_callback* */ - public VR_IVRCompositor_FnTable.ReleaseSharedGLTexture_callback ReleaseSharedGLTexture; - /** C type : LockGLSharedTextureForAccess_callback* */ - public VR_IVRCompositor_FnTable.LockGLSharedTextureForAccess_callback LockGLSharedTextureForAccess; - /** C type : UnlockGLSharedTextureForAccess_callback* */ - public VR_IVRCompositor_FnTable.UnlockGLSharedTextureForAccess_callback UnlockGLSharedTextureForAccess; - /** C type : GetVulkanInstanceExtensionsRequired_callback* */ - public VR_IVRCompositor_FnTable.GetVulkanInstanceExtensionsRequired_callback GetVulkanInstanceExtensionsRequired; - /** C type : GetVulkanDeviceExtensionsRequired_callback* */ - public VR_IVRCompositor_FnTable.GetVulkanDeviceExtensionsRequired_callback GetVulkanDeviceExtensionsRequired; - /** C type : SetExplicitTimingMode_callback* */ - public VR_IVRCompositor_FnTable.SetExplicitTimingMode_callback SetExplicitTimingMode; - /** C type : SubmitExplicitTimingData_callback* */ - public VR_IVRCompositor_FnTable.SubmitExplicitTimingData_callback SubmitExplicitTimingData; - /** native declaration : headers\openvr_capi.h:2002 */ - public interface SetTrackingSpace_callback extends Callback { - void apply(int eOrigin); - }; - /** native declaration : headers\openvr_capi.h:2003 */ - public interface GetTrackingSpace_callback extends Callback { - int apply(); - }; - /** native declaration : headers\openvr_capi.h:2004 */ - public interface WaitGetPoses_callback extends Callback { - int apply(TrackedDevicePose_t pRenderPoseArray, int unRenderPoseArrayCount, TrackedDevicePose_t pGamePoseArray, int unGamePoseArrayCount); - }; - /** native declaration : headers\openvr_capi.h:2005 */ - public interface GetLastPoses_callback extends Callback { - int apply(TrackedDevicePose_t pRenderPoseArray, int unRenderPoseArrayCount, TrackedDevicePose_t pGamePoseArray, int unGamePoseArrayCount); - }; - /** native declaration : headers\openvr_capi.h:2006 */ - public interface GetLastPoseForTrackedDeviceIndex_callback extends Callback { - int apply(int unDeviceIndex, TrackedDevicePose_t pOutputPose, TrackedDevicePose_t pOutputGamePose); - }; - /** native declaration : headers\openvr_capi.h:2007 */ - public interface Submit_callback extends Callback { - int apply(int eEye, Texture_t pTexture, VRTextureBounds_t pBounds, int nSubmitFlags); - }; - /** native declaration : headers\openvr_capi.h:2008 */ - public interface ClearLastSubmittedFrame_callback extends Callback { - void apply(); - }; - /** native declaration : headers\openvr_capi.h:2009 */ - public interface PostPresentHandoff_callback extends Callback { - void apply(); - }; - /** native declaration : headers\openvr_capi.h:2010 */ - public interface GetFrameTiming_callback extends Callback { - byte apply(Compositor_FrameTiming pTiming, int unFramesAgo); - }; - /** native declaration : headers\openvr_capi.h:2011 */ - public interface GetFrameTimings_callback extends Callback { - int apply(Compositor_FrameTiming pTiming, int nFrames); - }; - /** native declaration : headers\openvr_capi.h:2012 */ - public interface GetFrameTimeRemaining_callback extends Callback { - float apply(); - }; - /** native declaration : headers\openvr_capi.h:2013 */ - public interface GetCumulativeStats_callback extends Callback { - void apply(Compositor_CumulativeStats pStats, int nStatsSizeInBytes); - }; - /** native declaration : headers\openvr_capi.h:2014 */ - public interface FadeToColor_callback extends Callback { - void apply(float fSeconds, float fRed, float fGreen, float fBlue, float fAlpha, byte bBackground); - }; - /** native declaration : headers\openvr_capi.h:2015 */ - public interface GetCurrentFadeColor_callback extends Callback { - com.jme3.system.jopenvr.HmdColor_t.ByValue apply(byte bBackground); - }; - /** native declaration : headers\openvr_capi.h:2016 */ - public interface FadeGrid_callback extends Callback { - void apply(float fSeconds, byte bFadeIn); - }; - /** native declaration : headers\openvr_capi.h:2017 */ - public interface GetCurrentGridAlpha_callback extends Callback { - float apply(); - }; - /** native declaration : headers\openvr_capi.h:2018 */ - public interface SetSkyboxOverride_callback extends Callback { - int apply(Texture_t pTextures, int unTextureCount); - }; - /** native declaration : headers\openvr_capi.h:2019 */ - public interface ClearSkyboxOverride_callback extends Callback { - void apply(); - }; - /** native declaration : headers\openvr_capi.h:2020 */ - public interface CompositorBringToFront_callback extends Callback { - void apply(); - }; - /** native declaration : headers\openvr_capi.h:2021 */ - public interface CompositorGoToBack_callback extends Callback { - void apply(); - }; - /** native declaration : headers\openvr_capi.h:2022 */ - public interface CompositorQuit_callback extends Callback { - void apply(); - }; - /** native declaration : headers\openvr_capi.h:2023 */ - public interface IsFullscreen_callback extends Callback { - byte apply(); - }; - /** native declaration : headers\openvr_capi.h:2024 */ - public interface GetCurrentSceneFocusProcess_callback extends Callback { - int apply(); - }; - /** native declaration : headers\openvr_capi.h:2025 */ - public interface GetLastFrameRenderer_callback extends Callback { - int apply(); - }; - /** native declaration : headers\openvr_capi.h:2026 */ - public interface CanRenderScene_callback extends Callback { - byte apply(); - }; - /** native declaration : headers\openvr_capi.h:2027 */ - public interface ShowMirrorWindow_callback extends Callback { - void apply(); - }; - /** native declaration : headers\openvr_capi.h:2028 */ - public interface HideMirrorWindow_callback extends Callback { - void apply(); - }; - /** native declaration : headers\openvr_capi.h:2029 */ - public interface IsMirrorWindowVisible_callback extends Callback { - byte apply(); - }; - /** native declaration : headers\openvr_capi.h:2030 */ - public interface CompositorDumpImages_callback extends Callback { - void apply(); - }; - /** native declaration : headers\openvr_capi.h:2031 */ - public interface ShouldAppRenderWithLowResources_callback extends Callback { - byte apply(); - }; - /** native declaration : headers\openvr_capi.h:2032 */ - public interface ForceInterleavedReprojectionOn_callback extends Callback { - void apply(byte bOverride); - }; - /** native declaration : headers\openvr_capi.h:2033 */ - public interface ForceReconnectProcess_callback extends Callback { - void apply(); - }; - /** native declaration : headers\openvr_capi.h:2034 */ - public interface SuspendRendering_callback extends Callback { - void apply(byte bSuspend); - }; - /** native declaration : headers\openvr_capi.h:2035 */ - public interface GetMirrorTextureD3D11_callback extends Callback { - int apply(int eEye, Pointer pD3D11DeviceOrResource, PointerByReference ppD3D11ShaderResourceView); - }; - /** native declaration : headers\openvr_capi.h:2036 */ - public interface ReleaseMirrorTextureD3D11_callback extends Callback { - void apply(Pointer pD3D11ShaderResourceView); - }; - /** native declaration : headers\openvr_capi.h:2037 */ - public interface GetMirrorTextureGL_callback extends Callback { - int apply(int eEye, IntByReference pglTextureId, PointerByReference pglSharedTextureHandle); - }; - /** native declaration : headers\openvr_capi.h:2038 */ - public interface ReleaseSharedGLTexture_callback extends Callback { - byte apply(int glTextureId, Pointer glSharedTextureHandle); - }; - /** native declaration : headers\openvr_capi.h:2039 */ - public interface LockGLSharedTextureForAccess_callback extends Callback { - void apply(Pointer glSharedTextureHandle); - }; - /** native declaration : headers\openvr_capi.h:2040 */ - public interface UnlockGLSharedTextureForAccess_callback extends Callback { - void apply(Pointer glSharedTextureHandle); - }; - /** native declaration : headers\openvr_capi.h:2041 */ - public interface GetVulkanInstanceExtensionsRequired_callback extends Callback { - int apply(Pointer pchValue, int unBufferSize); - }; - /** native declaration : headers\openvr_capi.h:2042 */ - public interface GetVulkanDeviceExtensionsRequired_callback extends Callback { - int apply(VkPhysicalDevice_T pPhysicalDevice, Pointer pchValue, int unBufferSize); - }; - /** native declaration : headers\openvr_capi.h:2043 */ - public interface SetExplicitTimingMode_callback extends Callback { - void apply(int eTimingMode); - }; - /** native declaration : headers\openvr_capi.h:2044 */ - public interface SubmitExplicitTimingData_callback extends Callback { - int apply(); - }; - public VR_IVRCompositor_FnTable() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("SetTrackingSpace", "GetTrackingSpace", "WaitGetPoses", "GetLastPoses", "GetLastPoseForTrackedDeviceIndex", "Submit", "ClearLastSubmittedFrame", "PostPresentHandoff", "GetFrameTiming", "GetFrameTimings", "GetFrameTimeRemaining", "GetCumulativeStats", "FadeToColor", "GetCurrentFadeColor", "FadeGrid", "GetCurrentGridAlpha", "SetSkyboxOverride", "ClearSkyboxOverride", "CompositorBringToFront", "CompositorGoToBack", "CompositorQuit", "IsFullscreen", "GetCurrentSceneFocusProcess", "GetLastFrameRenderer", "CanRenderScene", "ShowMirrorWindow", "HideMirrorWindow", "IsMirrorWindowVisible", "CompositorDumpImages", "ShouldAppRenderWithLowResources", "ForceInterleavedReprojectionOn", "ForceReconnectProcess", "SuspendRendering", "GetMirrorTextureD3D11", "ReleaseMirrorTextureD3D11", "GetMirrorTextureGL", "ReleaseSharedGLTexture", "LockGLSharedTextureForAccess", "UnlockGLSharedTextureForAccess", "GetVulkanInstanceExtensionsRequired", "GetVulkanDeviceExtensionsRequired", "SetExplicitTimingMode", "SubmitExplicitTimingData"); - } - public VR_IVRCompositor_FnTable(Pointer peer) { - super(peer); - } - public static class ByReference extends VR_IVRCompositor_FnTable implements Structure.ByReference { - - }; - public static class ByValue extends VR_IVRCompositor_FnTable implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRDriverManager_FnTable.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRDriverManager_FnTable.java deleted file mode 100644 index 13e444730b..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRDriverManager_FnTable.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Callback; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:2313
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VR_IVRDriverManager_FnTable extends Structure { - /** C type : GetDriverCount_callback* */ - public VR_IVRDriverManager_FnTable.GetDriverCount_callback GetDriverCount; - /** C type : GetDriverName_callback* */ - public VR_IVRDriverManager_FnTable.GetDriverName_callback GetDriverName; - /** C type : GetDriverHandle_callback* */ - public VR_IVRDriverManager_FnTable.GetDriverHandle_callback GetDriverHandle; - /** native declaration : headers\openvr_capi.h:2310 */ - public interface GetDriverCount_callback extends Callback { - int apply(); - }; - /** native declaration : headers\openvr_capi.h:2311 */ - public interface GetDriverName_callback extends Callback { - int apply(int nDriver, Pointer pchValue, int unBufferSize); - }; - /** native declaration : headers\openvr_capi.h:2312 */ - public interface GetDriverHandle_callback extends Callback { - long apply(Pointer pchDriverName); - }; - public VR_IVRDriverManager_FnTable() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("GetDriverCount", "GetDriverName", "GetDriverHandle"); - } - /** - * @param GetDriverCount C type : GetDriverCount_callback*
- * @param GetDriverName C type : GetDriverName_callback*
- * @param GetDriverHandle C type : GetDriverHandle_callback* - */ - public VR_IVRDriverManager_FnTable(VR_IVRDriverManager_FnTable.GetDriverCount_callback GetDriverCount, VR_IVRDriverManager_FnTable.GetDriverName_callback GetDriverName, VR_IVRDriverManager_FnTable.GetDriverHandle_callback GetDriverHandle) { - super(); - this.GetDriverCount = GetDriverCount; - this.GetDriverName = GetDriverName; - this.GetDriverHandle = GetDriverHandle; - } - public VR_IVRDriverManager_FnTable(Pointer peer) { - super(peer); - } - public static class ByReference extends VR_IVRDriverManager_FnTable implements Structure.ByReference { - - }; - public static class ByValue extends VR_IVRDriverManager_FnTable implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRExtendedDisplay_FnTable.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRExtendedDisplay_FnTable.java deleted file mode 100644 index 2b04732a73..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRExtendedDisplay_FnTable.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Callback; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import com.sun.jna.ptr.IntByReference; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1807
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VR_IVRExtendedDisplay_FnTable extends Structure { - /** C type : GetWindowBounds_callback* */ - public VR_IVRExtendedDisplay_FnTable.GetWindowBounds_callback GetWindowBounds; - /** C type : GetEyeOutputViewport_callback* */ - public VR_IVRExtendedDisplay_FnTable.GetEyeOutputViewport_callback GetEyeOutputViewport; - /** C type : GetDXGIOutputInfo_callback* */ - public VR_IVRExtendedDisplay_FnTable.GetDXGIOutputInfo_callback GetDXGIOutputInfo; - /** native declaration : headers\openvr_capi.h:1804 */ - public interface GetWindowBounds_callback extends Callback { - void apply(IntByReference pnX, IntByReference pnY, IntByReference pnWidth, IntByReference pnHeight); - }; - /** native declaration : headers\openvr_capi.h:1805 */ - public interface GetEyeOutputViewport_callback extends Callback { - void apply(int eEye, IntByReference pnX, IntByReference pnY, IntByReference pnWidth, IntByReference pnHeight); - }; - /** native declaration : headers\openvr_capi.h:1806 */ - public interface GetDXGIOutputInfo_callback extends Callback { - void apply(IntByReference pnAdapterIndex, IntByReference pnAdapterOutputIndex); - }; - public VR_IVRExtendedDisplay_FnTable() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("GetWindowBounds", "GetEyeOutputViewport", "GetDXGIOutputInfo"); - } - /** - * @param GetWindowBounds C type : GetWindowBounds_callback*
- * @param GetEyeOutputViewport C type : GetEyeOutputViewport_callback*
- * @param GetDXGIOutputInfo C type : GetDXGIOutputInfo_callback* - */ - public VR_IVRExtendedDisplay_FnTable(VR_IVRExtendedDisplay_FnTable.GetWindowBounds_callback GetWindowBounds, VR_IVRExtendedDisplay_FnTable.GetEyeOutputViewport_callback GetEyeOutputViewport, VR_IVRExtendedDisplay_FnTable.GetDXGIOutputInfo_callback GetDXGIOutputInfo) { - super(); - this.GetWindowBounds = GetWindowBounds; - this.GetEyeOutputViewport = GetEyeOutputViewport; - this.GetDXGIOutputInfo = GetDXGIOutputInfo; - } - public VR_IVRExtendedDisplay_FnTable(Pointer peer) { - super(peer); - } - public static class ByReference extends VR_IVRExtendedDisplay_FnTable implements Structure.ByReference { - - }; - public static class ByValue extends VR_IVRExtendedDisplay_FnTable implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRIOBuffer_FnTable.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRIOBuffer_FnTable.java deleted file mode 100644 index 5a6b9291d0..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRIOBuffer_FnTable.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Callback; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import com.sun.jna.ptr.IntByReference; -import com.sun.jna.ptr.LongByReference; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:2363
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VR_IVRIOBuffer_FnTable extends Structure { - /** C type : Open_callback* */ - public VR_IVRIOBuffer_FnTable.Open_callback Open; - /** C type : Close_callback* */ - public VR_IVRIOBuffer_FnTable.Close_callback Close; - /** C type : Read_callback* */ - public VR_IVRIOBuffer_FnTable.Read_callback Read; - /** C type : Write_callback* */ - public VR_IVRIOBuffer_FnTable.Write_callback Write; - /** C type : PropertyContainer_callback* */ - public VR_IVRIOBuffer_FnTable.PropertyContainer_callback PropertyContainer; - /** native declaration : headers\openvr_capi.h:2358 */ - public interface Open_callback extends Callback { - int apply(Pointer pchPath, int mode, int unElementSize, int unElements, LongByReference pulBuffer); - }; - /** native declaration : headers\openvr_capi.h:2359 */ - public interface Close_callback extends Callback { - int apply(long ulBuffer); - }; - /** native declaration : headers\openvr_capi.h:2360 */ - public interface Read_callback extends Callback { - int apply(long ulBuffer, Pointer pDst, int unBytes, IntByReference punRead); - }; - /** native declaration : headers\openvr_capi.h:2361 */ - public interface Write_callback extends Callback { - int apply(long ulBuffer, Pointer pSrc, int unBytes); - }; - /** native declaration : headers\openvr_capi.h:2362 */ - public interface PropertyContainer_callback extends Callback { - long apply(long ulBuffer); - }; - public VR_IVRIOBuffer_FnTable() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("Open", "Close", "Read", "Write", "PropertyContainer"); - } - /** - * @param Open C type : Open_callback*
- * @param Close C type : Close_callback*
- * @param Read C type : Read_callback*
- * @param Write C type : Write_callback*
- * @param PropertyContainer C type : PropertyContainer_callback* - */ - public VR_IVRIOBuffer_FnTable(VR_IVRIOBuffer_FnTable.Open_callback Open, VR_IVRIOBuffer_FnTable.Close_callback Close, VR_IVRIOBuffer_FnTable.Read_callback Read, VR_IVRIOBuffer_FnTable.Write_callback Write, VR_IVRIOBuffer_FnTable.PropertyContainer_callback PropertyContainer) { - super(); - this.Open = Open; - this.Close = Close; - this.Read = Read; - this.Write = Write; - this.PropertyContainer = PropertyContainer; - } - public VR_IVRIOBuffer_FnTable(Pointer peer) { - super(peer); - } - public static class ByReference extends VR_IVRIOBuffer_FnTable implements Structure.ByReference { - - }; - public static class ByValue extends VR_IVRIOBuffer_FnTable implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRInput_FnTable.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRInput_FnTable.java deleted file mode 100644 index 44987cc991..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRInput_FnTable.java +++ /dev/null @@ -1,140 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Callback; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import com.sun.jna.ptr.IntByReference; -import com.sun.jna.ptr.LongByReference; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:2351
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VR_IVRInput_FnTable extends Structure { - /** C type : SetActionManifestPath_callback* */ - public VR_IVRInput_FnTable.SetActionManifestPath_callback SetActionManifestPath; - /** C type : GetActionSetHandle_callback* */ - public VR_IVRInput_FnTable.GetActionSetHandle_callback GetActionSetHandle; - /** C type : GetActionHandle_callback* */ - public VR_IVRInput_FnTable.GetActionHandle_callback GetActionHandle; - /** C type : GetInputSourceHandle_callback* */ - public VR_IVRInput_FnTable.GetInputSourceHandle_callback GetInputSourceHandle; - /** C type : UpdateActionState_callback* */ - public VR_IVRInput_FnTable.UpdateActionState_callback UpdateActionState; - /** C type : GetDigitalActionData_callback* */ - public VR_IVRInput_FnTable.GetDigitalActionData_callback GetDigitalActionData; - /** C type : GetAnalogActionData_callback* */ - public VR_IVRInput_FnTable.GetAnalogActionData_callback GetAnalogActionData; - /** C type : GetPoseActionData_callback* */ - public VR_IVRInput_FnTable.GetPoseActionData_callback GetPoseActionData; - /** C type : GetSkeletalActionData_callback* */ - public VR_IVRInput_FnTable.GetSkeletalActionData_callback GetSkeletalActionData; - /** C type : GetSkeletalBoneData_callback* */ - public VR_IVRInput_FnTable.GetSkeletalBoneData_callback GetSkeletalBoneData; - /** C type : GetSkeletalBoneDataCompressed_callback* */ - public VR_IVRInput_FnTable.GetSkeletalBoneDataCompressed_callback GetSkeletalBoneDataCompressed; - /** C type : DecompressSkeletalBoneData_callback* */ - public VR_IVRInput_FnTable.DecompressSkeletalBoneData_callback DecompressSkeletalBoneData; - /** C type : TriggerHapticVibrationAction_callback* */ - public VR_IVRInput_FnTable.TriggerHapticVibrationAction_callback TriggerHapticVibrationAction; - /** C type : GetActionOrigins_callback* */ - public VR_IVRInput_FnTable.GetActionOrigins_callback GetActionOrigins; - /** C type : GetOriginLocalizedName_callback* */ - public VR_IVRInput_FnTable.GetOriginLocalizedName_callback GetOriginLocalizedName; - /** C type : GetOriginTrackedDeviceInfo_callback* */ - public VR_IVRInput_FnTable.GetOriginTrackedDeviceInfo_callback GetOriginTrackedDeviceInfo; - /** C type : ShowActionOrigins_callback* */ - public VR_IVRInput_FnTable.ShowActionOrigins_callback ShowActionOrigins; - /** C type : ShowBindingsForActionSet_callback* */ - public VR_IVRInput_FnTable.ShowBindingsForActionSet_callback ShowBindingsForActionSet; - /** native declaration : headers\openvr_capi.h:2333 */ - public interface SetActionManifestPath_callback extends Callback { - int apply(Pointer pchActionManifestPath); - }; - /** native declaration : headers\openvr_capi.h:2334 */ - public interface GetActionSetHandle_callback extends Callback { - int apply(Pointer pchActionSetName, LongByReference pHandle); - }; - /** native declaration : headers\openvr_capi.h:2335 */ - public interface GetActionHandle_callback extends Callback { - int apply(Pointer pchActionName, LongByReference pHandle); - }; - /** native declaration : headers\openvr_capi.h:2336 */ - public interface GetInputSourceHandle_callback extends Callback { - int apply(Pointer pchInputSourcePath, LongByReference pHandle); - }; - /** native declaration : headers\openvr_capi.h:2337 */ - public interface UpdateActionState_callback extends Callback { - int apply(VRActiveActionSet_t pSets, int unSizeOfVRSelectedActionSet_t, int unSetCount); - }; - /** native declaration : headers\openvr_capi.h:2338 */ - public interface GetDigitalActionData_callback extends Callback { - int apply(long action, InputDigitalActionData_t pActionData, int unActionDataSize, long ulRestrictToDevice); - }; - /** native declaration : headers\openvr_capi.h:2339 */ - public interface GetAnalogActionData_callback extends Callback { - int apply(long action, InputAnalogActionData_t pActionData, int unActionDataSize, long ulRestrictToDevice); - }; - /** native declaration : headers\openvr_capi.h:2340 */ - public interface GetPoseActionData_callback extends Callback { - int apply(long action, int eOrigin, float fPredictedSecondsFromNow, InputPoseActionData_t pActionData, int unActionDataSize, long ulRestrictToDevice); - }; - /** native declaration : headers\openvr_capi.h:2341 */ - public interface GetSkeletalActionData_callback extends Callback { - int apply(long action, InputSkeletalActionData_t pActionData, int unActionDataSize, long ulRestrictToDevice); - }; - /** native declaration : headers\openvr_capi.h:2342 */ - public interface GetSkeletalBoneData_callback extends Callback { - int apply(long action, int eTransformSpace, int eMotionRange, VRBoneTransform_t pTransformArray, int unTransformArrayCount, long ulRestrictToDevice); - }; - /** native declaration : headers\openvr_capi.h:2343 */ - public interface GetSkeletalBoneDataCompressed_callback extends Callback { - int apply(long action, int eTransformSpace, int eMotionRange, Pointer pvCompressedData, int unCompressedSize, IntByReference punRequiredCompressedSize, long ulRestrictToDevice); - }; - /** native declaration : headers\openvr_capi.h:2344 */ - public interface DecompressSkeletalBoneData_callback extends Callback { - int apply(Pointer pvCompressedBuffer, int unCompressedBufferSize, IntByReference peTransformSpace, VRBoneTransform_t pTransformArray, int unTransformArrayCount); - }; - /** native declaration : headers\openvr_capi.h:2345 */ - public interface TriggerHapticVibrationAction_callback extends Callback { - int apply(long action, float fStartSecondsFromNow, float fDurationSeconds, float fFrequency, float fAmplitude, long ulRestrictToDevice); - }; - /** native declaration : headers\openvr_capi.h:2346 */ - public interface GetActionOrigins_callback extends Callback { - int apply(long actionSetHandle, long digitalActionHandle, LongByReference originsOut, int originOutCount); - }; - /** native declaration : headers\openvr_capi.h:2347 */ - public interface GetOriginLocalizedName_callback extends Callback { - int apply(long origin, Pointer pchNameArray, int unNameArraySize); - }; - /** native declaration : headers\openvr_capi.h:2348 */ - public interface GetOriginTrackedDeviceInfo_callback extends Callback { - int apply(long origin, InputOriginInfo_t pOriginInfo, int unOriginInfoSize); - }; - /** native declaration : headers\openvr_capi.h:2349 */ - public interface ShowActionOrigins_callback extends Callback { - int apply(long actionSetHandle, long ulActionHandle); - }; - /** native declaration : headers\openvr_capi.h:2350 */ - public interface ShowBindingsForActionSet_callback extends Callback { - int apply(VRActiveActionSet_t pSets, int unSizeOfVRSelectedActionSet_t, int unSetCount, long originToHighlight); - }; - public VR_IVRInput_FnTable() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("SetActionManifestPath", "GetActionSetHandle", "GetActionHandle", "GetInputSourceHandle", "UpdateActionState", "GetDigitalActionData", "GetAnalogActionData", "GetPoseActionData", "GetSkeletalActionData", "GetSkeletalBoneData", "GetSkeletalBoneDataCompressed", "DecompressSkeletalBoneData", "TriggerHapticVibrationAction", "GetActionOrigins", "GetOriginLocalizedName", "GetOriginTrackedDeviceInfo", "ShowActionOrigins", "ShowBindingsForActionSet"); - } - public VR_IVRInput_FnTable(Pointer peer) { - super(peer); - } - public static class ByReference extends VR_IVRInput_FnTable implements Structure.ByReference { - - }; - public static class ByValue extends VR_IVRInput_FnTable implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRNotifications_FnTable.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRNotifications_FnTable.java deleted file mode 100644 index 7e15f3591d..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRNotifications_FnTable.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Callback; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import com.sun.jna.ptr.IntByReference; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:2257
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VR_IVRNotifications_FnTable extends Structure { - /** C type : CreateNotification_callback* */ - public VR_IVRNotifications_FnTable.CreateNotification_callback CreateNotification; - /** C type : RemoveNotification_callback* */ - public VR_IVRNotifications_FnTable.RemoveNotification_callback RemoveNotification; - /** native declaration : headers\openvr_capi.h:2255 */ - public interface CreateNotification_callback extends Callback { - int apply(long ulOverlayHandle, long ulUserValue, int type, Pointer pchText, int style, NotificationBitmap_t pImage, IntByReference pNotificationId); - }; - /** native declaration : headers\openvr_capi.h:2256 */ - public interface RemoveNotification_callback extends Callback { - int apply(int notificationId); - }; - public VR_IVRNotifications_FnTable() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("CreateNotification", "RemoveNotification"); - } - /** - * @param CreateNotification C type : CreateNotification_callback*
- * @param RemoveNotification C type : RemoveNotification_callback* - */ - public VR_IVRNotifications_FnTable(VR_IVRNotifications_FnTable.CreateNotification_callback CreateNotification, VR_IVRNotifications_FnTable.RemoveNotification_callback RemoveNotification) { - super(); - this.CreateNotification = CreateNotification; - this.RemoveNotification = RemoveNotification; - } - public VR_IVRNotifications_FnTable(Pointer peer) { - super(peer); - } - public static class ByReference extends VR_IVRNotifications_FnTable implements Structure.ByReference { - - }; - public static class ByValue extends VR_IVRNotifications_FnTable implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVROverlay_FnTable.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVROverlay_FnTable.java deleted file mode 100644 index f9405bb07d..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVROverlay_FnTable.java +++ /dev/null @@ -1,526 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Callback; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import com.sun.jna.ptr.FloatByReference; -import com.sun.jna.ptr.IntByReference; -import com.sun.jna.ptr.LongByReference; -import com.sun.jna.ptr.PointerByReference; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:2211
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VR_IVROverlay_FnTable extends Structure { - /** C type : FindOverlay_callback* */ - public VR_IVROverlay_FnTable.FindOverlay_callback FindOverlay; - /** C type : CreateOverlay_callback* */ - public VR_IVROverlay_FnTable.CreateOverlay_callback CreateOverlay; - /** C type : DestroyOverlay_callback* */ - public VR_IVROverlay_FnTable.DestroyOverlay_callback DestroyOverlay; - /** C type : SetHighQualityOverlay_callback* */ - public VR_IVROverlay_FnTable.SetHighQualityOverlay_callback SetHighQualityOverlay; - /** C type : GetHighQualityOverlay_callback* */ - public VR_IVROverlay_FnTable.GetHighQualityOverlay_callback GetHighQualityOverlay; - /** C type : GetOverlayKey_callback* */ - public VR_IVROverlay_FnTable.GetOverlayKey_callback GetOverlayKey; - /** C type : GetOverlayName_callback* */ - public VR_IVROverlay_FnTable.GetOverlayName_callback GetOverlayName; - /** C type : SetOverlayName_callback* */ - public VR_IVROverlay_FnTable.SetOverlayName_callback SetOverlayName; - /** C type : GetOverlayImageData_callback* */ - public VR_IVROverlay_FnTable.GetOverlayImageData_callback GetOverlayImageData; - /** C type : GetOverlayErrorNameFromEnum_callback* */ - public VR_IVROverlay_FnTable.GetOverlayErrorNameFromEnum_callback GetOverlayErrorNameFromEnum; - /** C type : SetOverlayRenderingPid_callback* */ - public VR_IVROverlay_FnTable.SetOverlayRenderingPid_callback SetOverlayRenderingPid; - /** C type : GetOverlayRenderingPid_callback* */ - public VR_IVROverlay_FnTable.GetOverlayRenderingPid_callback GetOverlayRenderingPid; - /** C type : SetOverlayFlag_callback* */ - public VR_IVROverlay_FnTable.SetOverlayFlag_callback SetOverlayFlag; - /** C type : GetOverlayFlag_callback* */ - public VR_IVROverlay_FnTable.GetOverlayFlag_callback GetOverlayFlag; - /** C type : SetOverlayColor_callback* */ - public VR_IVROverlay_FnTable.SetOverlayColor_callback SetOverlayColor; - /** C type : GetOverlayColor_callback* */ - public VR_IVROverlay_FnTable.GetOverlayColor_callback GetOverlayColor; - /** C type : SetOverlayAlpha_callback* */ - public VR_IVROverlay_FnTable.SetOverlayAlpha_callback SetOverlayAlpha; - /** C type : GetOverlayAlpha_callback* */ - public VR_IVROverlay_FnTable.GetOverlayAlpha_callback GetOverlayAlpha; - /** C type : SetOverlayTexelAspect_callback* */ - public VR_IVROverlay_FnTable.SetOverlayTexelAspect_callback SetOverlayTexelAspect; - /** C type : GetOverlayTexelAspect_callback* */ - public VR_IVROverlay_FnTable.GetOverlayTexelAspect_callback GetOverlayTexelAspect; - /** C type : SetOverlaySortOrder_callback* */ - public VR_IVROverlay_FnTable.SetOverlaySortOrder_callback SetOverlaySortOrder; - /** C type : GetOverlaySortOrder_callback* */ - public VR_IVROverlay_FnTable.GetOverlaySortOrder_callback GetOverlaySortOrder; - /** C type : SetOverlayWidthInMeters_callback* */ - public VR_IVROverlay_FnTable.SetOverlayWidthInMeters_callback SetOverlayWidthInMeters; - /** C type : GetOverlayWidthInMeters_callback* */ - public VR_IVROverlay_FnTable.GetOverlayWidthInMeters_callback GetOverlayWidthInMeters; - /** C type : SetOverlayAutoCurveDistanceRangeInMeters_callback* */ - public VR_IVROverlay_FnTable.SetOverlayAutoCurveDistanceRangeInMeters_callback SetOverlayAutoCurveDistanceRangeInMeters; - /** C type : GetOverlayAutoCurveDistanceRangeInMeters_callback* */ - public VR_IVROverlay_FnTable.GetOverlayAutoCurveDistanceRangeInMeters_callback GetOverlayAutoCurveDistanceRangeInMeters; - /** C type : SetOverlayTextureColorSpace_callback* */ - public VR_IVROverlay_FnTable.SetOverlayTextureColorSpace_callback SetOverlayTextureColorSpace; - /** C type : GetOverlayTextureColorSpace_callback* */ - public VR_IVROverlay_FnTable.GetOverlayTextureColorSpace_callback GetOverlayTextureColorSpace; - /** C type : SetOverlayTextureBounds_callback* */ - public VR_IVROverlay_FnTable.SetOverlayTextureBounds_callback SetOverlayTextureBounds; - /** C type : GetOverlayTextureBounds_callback* */ - public VR_IVROverlay_FnTable.GetOverlayTextureBounds_callback GetOverlayTextureBounds; - /** C type : GetOverlayRenderModel_callback* */ - public VR_IVROverlay_FnTable.GetOverlayRenderModel_callback GetOverlayRenderModel; - /** C type : SetOverlayRenderModel_callback* */ - public VR_IVROverlay_FnTable.SetOverlayRenderModel_callback SetOverlayRenderModel; - /** C type : GetOverlayTransformType_callback* */ - public VR_IVROverlay_FnTable.GetOverlayTransformType_callback GetOverlayTransformType; - /** C type : SetOverlayTransformAbsolute_callback* */ - public VR_IVROverlay_FnTable.SetOverlayTransformAbsolute_callback SetOverlayTransformAbsolute; - /** C type : GetOverlayTransformAbsolute_callback* */ - public VR_IVROverlay_FnTable.GetOverlayTransformAbsolute_callback GetOverlayTransformAbsolute; - /** C type : SetOverlayTransformTrackedDeviceRelative_callback* */ - public VR_IVROverlay_FnTable.SetOverlayTransformTrackedDeviceRelative_callback SetOverlayTransformTrackedDeviceRelative; - /** C type : GetOverlayTransformTrackedDeviceRelative_callback* */ - public VR_IVROverlay_FnTable.GetOverlayTransformTrackedDeviceRelative_callback GetOverlayTransformTrackedDeviceRelative; - /** C type : SetOverlayTransformTrackedDeviceComponent_callback* */ - public VR_IVROverlay_FnTable.SetOverlayTransformTrackedDeviceComponent_callback SetOverlayTransformTrackedDeviceComponent; - /** C type : GetOverlayTransformTrackedDeviceComponent_callback* */ - public VR_IVROverlay_FnTable.GetOverlayTransformTrackedDeviceComponent_callback GetOverlayTransformTrackedDeviceComponent; - /** C type : GetOverlayTransformOverlayRelative_callback* */ - public VR_IVROverlay_FnTable.GetOverlayTransformOverlayRelative_callback GetOverlayTransformOverlayRelative; - /** C type : SetOverlayTransformOverlayRelative_callback* */ - public VR_IVROverlay_FnTable.SetOverlayTransformOverlayRelative_callback SetOverlayTransformOverlayRelative; - /** C type : ShowOverlay_callback* */ - public VR_IVROverlay_FnTable.ShowOverlay_callback ShowOverlay; - /** C type : HideOverlay_callback* */ - public VR_IVROverlay_FnTable.HideOverlay_callback HideOverlay; - /** C type : IsOverlayVisible_callback* */ - public VR_IVROverlay_FnTable.IsOverlayVisible_callback IsOverlayVisible; - /** C type : GetTransformForOverlayCoordinates_callback* */ - public VR_IVROverlay_FnTable.GetTransformForOverlayCoordinates_callback GetTransformForOverlayCoordinates; - /** C type : PollNextOverlayEvent_callback* */ - public VR_IVROverlay_FnTable.PollNextOverlayEvent_callback PollNextOverlayEvent; - /** C type : GetOverlayInputMethod_callback* */ - public VR_IVROverlay_FnTable.GetOverlayInputMethod_callback GetOverlayInputMethod; - /** C type : SetOverlayInputMethod_callback* */ - public VR_IVROverlay_FnTable.SetOverlayInputMethod_callback SetOverlayInputMethod; - /** C type : GetOverlayMouseScale_callback* */ - public VR_IVROverlay_FnTable.GetOverlayMouseScale_callback GetOverlayMouseScale; - /** C type : SetOverlayMouseScale_callback* */ - public VR_IVROverlay_FnTable.SetOverlayMouseScale_callback SetOverlayMouseScale; - /** C type : ComputeOverlayIntersection_callback* */ - public VR_IVROverlay_FnTable.ComputeOverlayIntersection_callback ComputeOverlayIntersection; - /** C type : IsHoverTargetOverlay_callback* */ - public VR_IVROverlay_FnTable.IsHoverTargetOverlay_callback IsHoverTargetOverlay; - /** C type : GetGamepadFocusOverlay_callback* */ - public VR_IVROverlay_FnTable.GetGamepadFocusOverlay_callback GetGamepadFocusOverlay; - /** C type : SetGamepadFocusOverlay_callback* */ - public VR_IVROverlay_FnTable.SetGamepadFocusOverlay_callback SetGamepadFocusOverlay; - /** C type : SetOverlayNeighbor_callback* */ - public VR_IVROverlay_FnTable.SetOverlayNeighbor_callback SetOverlayNeighbor; - /** C type : MoveGamepadFocusToNeighbor_callback* */ - public VR_IVROverlay_FnTable.MoveGamepadFocusToNeighbor_callback MoveGamepadFocusToNeighbor; - /** C type : SetOverlayDualAnalogTransform_callback* */ - public VR_IVROverlay_FnTable.SetOverlayDualAnalogTransform_callback SetOverlayDualAnalogTransform; - /** C type : GetOverlayDualAnalogTransform_callback* */ - public VR_IVROverlay_FnTable.GetOverlayDualAnalogTransform_callback GetOverlayDualAnalogTransform; - /** C type : SetOverlayTexture_callback* */ - public VR_IVROverlay_FnTable.SetOverlayTexture_callback SetOverlayTexture; - /** C type : ClearOverlayTexture_callback* */ - public VR_IVROverlay_FnTable.ClearOverlayTexture_callback ClearOverlayTexture; - /** C type : SetOverlayRaw_callback* */ - public VR_IVROverlay_FnTable.SetOverlayRaw_callback SetOverlayRaw; - /** C type : SetOverlayFromFile_callback* */ - public VR_IVROverlay_FnTable.SetOverlayFromFile_callback SetOverlayFromFile; - /** C type : GetOverlayTexture_callback* */ - public VR_IVROverlay_FnTable.GetOverlayTexture_callback GetOverlayTexture; - /** C type : ReleaseNativeOverlayHandle_callback* */ - public VR_IVROverlay_FnTable.ReleaseNativeOverlayHandle_callback ReleaseNativeOverlayHandle; - /** C type : GetOverlayTextureSize_callback* */ - public VR_IVROverlay_FnTable.GetOverlayTextureSize_callback GetOverlayTextureSize; - /** C type : CreateDashboardOverlay_callback* */ - public VR_IVROverlay_FnTable.CreateDashboardOverlay_callback CreateDashboardOverlay; - /** C type : IsDashboardVisible_callback* */ - public VR_IVROverlay_FnTable.IsDashboardVisible_callback IsDashboardVisible; - /** C type : IsActiveDashboardOverlay_callback* */ - public VR_IVROverlay_FnTable.IsActiveDashboardOverlay_callback IsActiveDashboardOverlay; - /** C type : SetDashboardOverlaySceneProcess_callback* */ - public VR_IVROverlay_FnTable.SetDashboardOverlaySceneProcess_callback SetDashboardOverlaySceneProcess; - /** C type : GetDashboardOverlaySceneProcess_callback* */ - public VR_IVROverlay_FnTable.GetDashboardOverlaySceneProcess_callback GetDashboardOverlaySceneProcess; - /** C type : ShowDashboard_callback* */ - public VR_IVROverlay_FnTable.ShowDashboard_callback ShowDashboard; - /** C type : GetPrimaryDashboardDevice_callback* */ - public VR_IVROverlay_FnTable.GetPrimaryDashboardDevice_callback GetPrimaryDashboardDevice; - /** C type : ShowKeyboard_callback* */ - public VR_IVROverlay_FnTable.ShowKeyboard_callback ShowKeyboard; - /** C type : ShowKeyboardForOverlay_callback* */ - public VR_IVROverlay_FnTable.ShowKeyboardForOverlay_callback ShowKeyboardForOverlay; - /** C type : GetKeyboardText_callback* */ - public VR_IVROverlay_FnTable.GetKeyboardText_callback GetKeyboardText; - /** C type : HideKeyboard_callback* */ - public VR_IVROverlay_FnTable.HideKeyboard_callback HideKeyboard; - /** C type : SetKeyboardTransformAbsolute_callback* */ - public VR_IVROverlay_FnTable.SetKeyboardTransformAbsolute_callback SetKeyboardTransformAbsolute; - /** C type : SetKeyboardPositionForOverlay_callback* */ - public VR_IVROverlay_FnTable.SetKeyboardPositionForOverlay_callback SetKeyboardPositionForOverlay; - /** C type : SetOverlayIntersectionMask_callback* */ - public VR_IVROverlay_FnTable.SetOverlayIntersectionMask_callback SetOverlayIntersectionMask; - /** C type : GetOverlayFlags_callback* */ - public VR_IVROverlay_FnTable.GetOverlayFlags_callback GetOverlayFlags; - /** C type : ShowMessageOverlay_callback* */ - public VR_IVROverlay_FnTable.ShowMessageOverlay_callback ShowMessageOverlay; - /** C type : CloseMessageOverlay_callback* */ - public VR_IVROverlay_FnTable.CloseMessageOverlay_callback CloseMessageOverlay; - /** native declaration : headers\openvr_capi.h:2129 */ - public interface FindOverlay_callback extends Callback { - int apply(Pointer pchOverlayKey, LongByReference pOverlayHandle); - }; - /** native declaration : headers\openvr_capi.h:2130 */ - public interface CreateOverlay_callback extends Callback { - int apply(Pointer pchOverlayKey, Pointer pchOverlayName, LongByReference pOverlayHandle); - }; - /** native declaration : headers\openvr_capi.h:2131 */ - public interface DestroyOverlay_callback extends Callback { - int apply(long ulOverlayHandle); - }; - /** native declaration : headers\openvr_capi.h:2132 */ - public interface SetHighQualityOverlay_callback extends Callback { - int apply(long ulOverlayHandle); - }; - /** native declaration : headers\openvr_capi.h:2133 */ - public interface GetHighQualityOverlay_callback extends Callback { - long apply(); - }; - /** native declaration : headers\openvr_capi.h:2134 */ - public interface GetOverlayKey_callback extends Callback { - int apply(long ulOverlayHandle, Pointer pchValue, int unBufferSize, IntByReference pError); - }; - /** native declaration : headers\openvr_capi.h:2135 */ - public interface GetOverlayName_callback extends Callback { - int apply(long ulOverlayHandle, Pointer pchValue, int unBufferSize, IntByReference pError); - }; - /** native declaration : headers\openvr_capi.h:2136 */ - public interface SetOverlayName_callback extends Callback { - int apply(long ulOverlayHandle, Pointer pchName); - }; - /** native declaration : headers\openvr_capi.h:2137 */ - public interface GetOverlayImageData_callback extends Callback { - int apply(long ulOverlayHandle, Pointer pvBuffer, int unBufferSize, IntByReference punWidth, IntByReference punHeight); - }; - /** native declaration : headers\openvr_capi.h:2138 */ - public interface GetOverlayErrorNameFromEnum_callback extends Callback { - Pointer apply(int error); - }; - /** native declaration : headers\openvr_capi.h:2139 */ - public interface SetOverlayRenderingPid_callback extends Callback { - int apply(long ulOverlayHandle, int unPID); - }; - /** native declaration : headers\openvr_capi.h:2140 */ - public interface GetOverlayRenderingPid_callback extends Callback { - int apply(long ulOverlayHandle); - }; - /** native declaration : headers\openvr_capi.h:2141 */ - public interface SetOverlayFlag_callback extends Callback { - int apply(long ulOverlayHandle, int eOverlayFlag, byte bEnabled); - }; - /** native declaration : headers\openvr_capi.h:2142 */ - public interface GetOverlayFlag_callback extends Callback { - int apply(long ulOverlayHandle, int eOverlayFlag, Pointer pbEnabled); - }; - /** native declaration : headers\openvr_capi.h:2143 */ - public interface SetOverlayColor_callback extends Callback { - int apply(long ulOverlayHandle, float fRed, float fGreen, float fBlue); - }; - /** native declaration : headers\openvr_capi.h:2144 */ - public interface GetOverlayColor_callback extends Callback { - int apply(long ulOverlayHandle, FloatByReference pfRed, FloatByReference pfGreen, FloatByReference pfBlue); - }; - /** native declaration : headers\openvr_capi.h:2145 */ - public interface SetOverlayAlpha_callback extends Callback { - int apply(long ulOverlayHandle, float fAlpha); - }; - /** native declaration : headers\openvr_capi.h:2146 */ - public interface GetOverlayAlpha_callback extends Callback { - int apply(long ulOverlayHandle, FloatByReference pfAlpha); - }; - /** native declaration : headers\openvr_capi.h:2147 */ - public interface SetOverlayTexelAspect_callback extends Callback { - int apply(long ulOverlayHandle, float fTexelAspect); - }; - /** native declaration : headers\openvr_capi.h:2148 */ - public interface GetOverlayTexelAspect_callback extends Callback { - int apply(long ulOverlayHandle, FloatByReference pfTexelAspect); - }; - /** native declaration : headers\openvr_capi.h:2149 */ - public interface SetOverlaySortOrder_callback extends Callback { - int apply(long ulOverlayHandle, int unSortOrder); - }; - /** native declaration : headers\openvr_capi.h:2150 */ - public interface GetOverlaySortOrder_callback extends Callback { - int apply(long ulOverlayHandle, IntByReference punSortOrder); - }; - /** native declaration : headers\openvr_capi.h:2151 */ - public interface SetOverlayWidthInMeters_callback extends Callback { - int apply(long ulOverlayHandle, float fWidthInMeters); - }; - /** native declaration : headers\openvr_capi.h:2152 */ - public interface GetOverlayWidthInMeters_callback extends Callback { - int apply(long ulOverlayHandle, FloatByReference pfWidthInMeters); - }; - /** native declaration : headers\openvr_capi.h:2153 */ - public interface SetOverlayAutoCurveDistanceRangeInMeters_callback extends Callback { - int apply(long ulOverlayHandle, float fMinDistanceInMeters, float fMaxDistanceInMeters); - }; - /** native declaration : headers\openvr_capi.h:2154 */ - public interface GetOverlayAutoCurveDistanceRangeInMeters_callback extends Callback { - int apply(long ulOverlayHandle, FloatByReference pfMinDistanceInMeters, FloatByReference pfMaxDistanceInMeters); - }; - /** native declaration : headers\openvr_capi.h:2155 */ - public interface SetOverlayTextureColorSpace_callback extends Callback { - int apply(long ulOverlayHandle, int eTextureColorSpace); - }; - /** native declaration : headers\openvr_capi.h:2156 */ - public interface GetOverlayTextureColorSpace_callback extends Callback { - int apply(long ulOverlayHandle, IntByReference peTextureColorSpace); - }; - /** native declaration : headers\openvr_capi.h:2157 */ - public interface SetOverlayTextureBounds_callback extends Callback { - int apply(long ulOverlayHandle, VRTextureBounds_t pOverlayTextureBounds); - }; - /** native declaration : headers\openvr_capi.h:2158 */ - public interface GetOverlayTextureBounds_callback extends Callback { - int apply(long ulOverlayHandle, VRTextureBounds_t pOverlayTextureBounds); - }; - /** native declaration : headers\openvr_capi.h:2159 */ - public interface GetOverlayRenderModel_callback extends Callback { - int apply(long ulOverlayHandle, Pointer pchValue, int unBufferSize, HmdColor_t pColor, IntByReference pError); - }; - /** native declaration : headers\openvr_capi.h:2160 */ - public interface SetOverlayRenderModel_callback extends Callback { - int apply(long ulOverlayHandle, Pointer pchRenderModel, HmdColor_t pColor); - }; - /** native declaration : headers\openvr_capi.h:2161 */ - public interface GetOverlayTransformType_callback extends Callback { - int apply(long ulOverlayHandle, IntByReference peTransformType); - }; - /** native declaration : headers\openvr_capi.h:2162 */ - public interface SetOverlayTransformAbsolute_callback extends Callback { - int apply(long ulOverlayHandle, int eTrackingOrigin, HmdMatrix34_t pmatTrackingOriginToOverlayTransform); - }; - /** native declaration : headers\openvr_capi.h:2163 */ - public interface GetOverlayTransformAbsolute_callback extends Callback { - int apply(long ulOverlayHandle, IntByReference peTrackingOrigin, HmdMatrix34_t pmatTrackingOriginToOverlayTransform); - }; - /** native declaration : headers\openvr_capi.h:2164 */ - public interface SetOverlayTransformTrackedDeviceRelative_callback extends Callback { - int apply(long ulOverlayHandle, int unTrackedDevice, HmdMatrix34_t pmatTrackedDeviceToOverlayTransform); - }; - /** native declaration : headers\openvr_capi.h:2165 */ - public interface GetOverlayTransformTrackedDeviceRelative_callback extends Callback { - int apply(long ulOverlayHandle, IntByReference punTrackedDevice, HmdMatrix34_t pmatTrackedDeviceToOverlayTransform); - }; - /** native declaration : headers\openvr_capi.h:2166 */ - public interface SetOverlayTransformTrackedDeviceComponent_callback extends Callback { - int apply(long ulOverlayHandle, int unDeviceIndex, Pointer pchComponentName); - }; - /** native declaration : headers\openvr_capi.h:2167 */ - public interface GetOverlayTransformTrackedDeviceComponent_callback extends Callback { - int apply(long ulOverlayHandle, IntByReference punDeviceIndex, Pointer pchComponentName, int unComponentNameSize); - }; - /** native declaration : headers\openvr_capi.h:2168 */ - public interface GetOverlayTransformOverlayRelative_callback extends Callback { - int apply(long ulOverlayHandle, LongByReference ulOverlayHandleParent, HmdMatrix34_t pmatParentOverlayToOverlayTransform); - }; - /** native declaration : headers\openvr_capi.h:2169 */ - public interface SetOverlayTransformOverlayRelative_callback extends Callback { - int apply(long ulOverlayHandle, long ulOverlayHandleParent, HmdMatrix34_t pmatParentOverlayToOverlayTransform); - }; - /** native declaration : headers\openvr_capi.h:2170 */ - public interface ShowOverlay_callback extends Callback { - int apply(long ulOverlayHandle); - }; - /** native declaration : headers\openvr_capi.h:2171 */ - public interface HideOverlay_callback extends Callback { - int apply(long ulOverlayHandle); - }; - /** native declaration : headers\openvr_capi.h:2172 */ - public interface IsOverlayVisible_callback extends Callback { - byte apply(long ulOverlayHandle); - }; - /** native declaration : headers\openvr_capi.h:2173 */ - public interface GetTransformForOverlayCoordinates_callback extends Callback { - int apply(long ulOverlayHandle, int eTrackingOrigin, HmdVector2_t.ByValue coordinatesInOverlay, HmdMatrix34_t pmatTransform); - }; - /** native declaration : headers\openvr_capi.h:2174 */ - public interface PollNextOverlayEvent_callback extends Callback { - byte apply(long ulOverlayHandle, VREvent_t pEvent, int uncbVREvent); - }; - /** native declaration : headers\openvr_capi.h:2175 */ - public interface GetOverlayInputMethod_callback extends Callback { - int apply(long ulOverlayHandle, IntByReference peInputMethod); - }; - /** native declaration : headers\openvr_capi.h:2176 */ - public interface SetOverlayInputMethod_callback extends Callback { - int apply(long ulOverlayHandle, int eInputMethod); - }; - /** native declaration : headers\openvr_capi.h:2177 */ - public interface GetOverlayMouseScale_callback extends Callback { - int apply(long ulOverlayHandle, HmdVector2_t pvecMouseScale); - }; - /** native declaration : headers\openvr_capi.h:2178 */ - public interface SetOverlayMouseScale_callback extends Callback { - int apply(long ulOverlayHandle, HmdVector2_t pvecMouseScale); - }; - /** native declaration : headers\openvr_capi.h:2179 */ - public interface ComputeOverlayIntersection_callback extends Callback { - byte apply(long ulOverlayHandle, VROverlayIntersectionParams_t pParams, VROverlayIntersectionResults_t pResults); - }; - /** native declaration : headers\openvr_capi.h:2180 */ - public interface IsHoverTargetOverlay_callback extends Callback { - byte apply(long ulOverlayHandle); - }; - /** native declaration : headers\openvr_capi.h:2181 */ - public interface GetGamepadFocusOverlay_callback extends Callback { - long apply(); - }; - /** native declaration : headers\openvr_capi.h:2182 */ - public interface SetGamepadFocusOverlay_callback extends Callback { - int apply(long ulNewFocusOverlay); - }; - /** native declaration : headers\openvr_capi.h:2183 */ - public interface SetOverlayNeighbor_callback extends Callback { - int apply(int eDirection, long ulFrom, long ulTo); - }; - /** native declaration : headers\openvr_capi.h:2184 */ - public interface MoveGamepadFocusToNeighbor_callback extends Callback { - int apply(int eDirection, long ulFrom); - }; - /** native declaration : headers\openvr_capi.h:2185 */ - public interface SetOverlayDualAnalogTransform_callback extends Callback { - int apply(long ulOverlay, int eWhich, HmdVector2_t vCenter, float fRadius); - }; - /** native declaration : headers\openvr_capi.h:2186 */ - public interface GetOverlayDualAnalogTransform_callback extends Callback { - int apply(long ulOverlay, int eWhich, HmdVector2_t pvCenter, FloatByReference pfRadius); - }; - /** native declaration : headers\openvr_capi.h:2187 */ - public interface SetOverlayTexture_callback extends Callback { - int apply(long ulOverlayHandle, Texture_t pTexture); - }; - /** native declaration : headers\openvr_capi.h:2188 */ - public interface ClearOverlayTexture_callback extends Callback { - int apply(long ulOverlayHandle); - }; - /** native declaration : headers\openvr_capi.h:2189 */ - public interface SetOverlayRaw_callback extends Callback { - int apply(long ulOverlayHandle, Pointer pvBuffer, int unWidth, int unHeight, int unDepth); - }; - /** native declaration : headers\openvr_capi.h:2190 */ - public interface SetOverlayFromFile_callback extends Callback { - int apply(long ulOverlayHandle, Pointer pchFilePath); - }; - /** native declaration : headers\openvr_capi.h:2191 */ - public interface GetOverlayTexture_callback extends Callback { - int apply(long ulOverlayHandle, PointerByReference pNativeTextureHandle, Pointer pNativeTextureRef, IntByReference pWidth, IntByReference pHeight, IntByReference pNativeFormat, IntByReference pAPIType, IntByReference pColorSpace, VRTextureBounds_t pTextureBounds); - }; - /** native declaration : headers\openvr_capi.h:2192 */ - public interface ReleaseNativeOverlayHandle_callback extends Callback { - int apply(long ulOverlayHandle, Pointer pNativeTextureHandle); - }; - /** native declaration : headers\openvr_capi.h:2193 */ - public interface GetOverlayTextureSize_callback extends Callback { - int apply(long ulOverlayHandle, IntByReference pWidth, IntByReference pHeight); - }; - /** native declaration : headers\openvr_capi.h:2194 */ - public interface CreateDashboardOverlay_callback extends Callback { - int apply(Pointer pchOverlayKey, Pointer pchOverlayFriendlyName, LongByReference pMainHandle, LongByReference pThumbnailHandle); - }; - /** native declaration : headers\openvr_capi.h:2195 */ - public interface IsDashboardVisible_callback extends Callback { - byte apply(); - }; - /** native declaration : headers\openvr_capi.h:2196 */ - public interface IsActiveDashboardOverlay_callback extends Callback { - byte apply(long ulOverlayHandle); - }; - /** native declaration : headers\openvr_capi.h:2197 */ - public interface SetDashboardOverlaySceneProcess_callback extends Callback { - int apply(long ulOverlayHandle, int unProcessId); - }; - /** native declaration : headers\openvr_capi.h:2198 */ - public interface GetDashboardOverlaySceneProcess_callback extends Callback { - int apply(long ulOverlayHandle, IntByReference punProcessId); - }; - /** native declaration : headers\openvr_capi.h:2199 */ - public interface ShowDashboard_callback extends Callback { - void apply(Pointer pchOverlayToShow); - }; - /** native declaration : headers\openvr_capi.h:2200 */ - public interface GetPrimaryDashboardDevice_callback extends Callback { - int apply(); - }; - /** native declaration : headers\openvr_capi.h:2201 */ - public interface ShowKeyboard_callback extends Callback { - int apply(int eInputMode, int eLineInputMode, Pointer pchDescription, int unCharMax, Pointer pchExistingText, byte bUseMinimalMode, long uUserValue); - }; - /** native declaration : headers\openvr_capi.h:2202 */ - public interface ShowKeyboardForOverlay_callback extends Callback { - int apply(long ulOverlayHandle, int eInputMode, int eLineInputMode, Pointer pchDescription, int unCharMax, Pointer pchExistingText, byte bUseMinimalMode, long uUserValue); - }; - /** native declaration : headers\openvr_capi.h:2203 */ - public interface GetKeyboardText_callback extends Callback { - int apply(Pointer pchText, int cchText); - }; - /** native declaration : headers\openvr_capi.h:2204 */ - public interface HideKeyboard_callback extends Callback { - void apply(); - }; - /** native declaration : headers\openvr_capi.h:2205 */ - public interface SetKeyboardTransformAbsolute_callback extends Callback { - void apply(int eTrackingOrigin, HmdMatrix34_t pmatTrackingOriginToKeyboardTransform); - }; - /** native declaration : headers\openvr_capi.h:2206 */ - public interface SetKeyboardPositionForOverlay_callback extends Callback { - void apply(long ulOverlayHandle, com.jme3.system.jopenvr.HmdRect2_t.ByValue avoidRect); - }; - /** native declaration : headers\openvr_capi.h:2207 */ - public interface SetOverlayIntersectionMask_callback extends Callback { - int apply(long ulOverlayHandle, VROverlayIntersectionMaskPrimitive_t pMaskPrimitives, int unNumMaskPrimitives, int unPrimitiveSize); - }; - /** native declaration : headers\openvr_capi.h:2208 */ - public interface GetOverlayFlags_callback extends Callback { - int apply(long ulOverlayHandle, IntByReference pFlags); - }; - /** native declaration : headers\openvr_capi.h:2209 */ - public interface ShowMessageOverlay_callback extends Callback { - int apply(Pointer pchText, Pointer pchCaption, Pointer pchButton0Text, Pointer pchButton1Text, Pointer pchButton2Text, Pointer pchButton3Text); - }; - /** native declaration : headers\openvr_capi.h:2210 */ - public interface CloseMessageOverlay_callback extends Callback { - void apply(); - }; - public VR_IVROverlay_FnTable() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("FindOverlay", "CreateOverlay", "DestroyOverlay", "SetHighQualityOverlay", "GetHighQualityOverlay", "GetOverlayKey", "GetOverlayName", "SetOverlayName", "GetOverlayImageData", "GetOverlayErrorNameFromEnum", "SetOverlayRenderingPid", "GetOverlayRenderingPid", "SetOverlayFlag", "GetOverlayFlag", "SetOverlayColor", "GetOverlayColor", "SetOverlayAlpha", "GetOverlayAlpha", "SetOverlayTexelAspect", "GetOverlayTexelAspect", "SetOverlaySortOrder", "GetOverlaySortOrder", "SetOverlayWidthInMeters", "GetOverlayWidthInMeters", "SetOverlayAutoCurveDistanceRangeInMeters", "GetOverlayAutoCurveDistanceRangeInMeters", "SetOverlayTextureColorSpace", "GetOverlayTextureColorSpace", "SetOverlayTextureBounds", "GetOverlayTextureBounds", "GetOverlayRenderModel", "SetOverlayRenderModel", "GetOverlayTransformType", "SetOverlayTransformAbsolute", "GetOverlayTransformAbsolute", "SetOverlayTransformTrackedDeviceRelative", "GetOverlayTransformTrackedDeviceRelative", "SetOverlayTransformTrackedDeviceComponent", "GetOverlayTransformTrackedDeviceComponent", "GetOverlayTransformOverlayRelative", "SetOverlayTransformOverlayRelative", "ShowOverlay", "HideOverlay", "IsOverlayVisible", "GetTransformForOverlayCoordinates", "PollNextOverlayEvent", "GetOverlayInputMethod", "SetOverlayInputMethod", "GetOverlayMouseScale", "SetOverlayMouseScale", "ComputeOverlayIntersection", "IsHoverTargetOverlay", "GetGamepadFocusOverlay", "SetGamepadFocusOverlay", "SetOverlayNeighbor", "MoveGamepadFocusToNeighbor", "SetOverlayDualAnalogTransform", "GetOverlayDualAnalogTransform", "SetOverlayTexture", "ClearOverlayTexture", "SetOverlayRaw", "SetOverlayFromFile", "GetOverlayTexture", "ReleaseNativeOverlayHandle", "GetOverlayTextureSize", "CreateDashboardOverlay", "IsDashboardVisible", "IsActiveDashboardOverlay", "SetDashboardOverlaySceneProcess", "GetDashboardOverlaySceneProcess", "ShowDashboard", "GetPrimaryDashboardDevice", "ShowKeyboard", "ShowKeyboardForOverlay", "GetKeyboardText", "HideKeyboard", "SetKeyboardTransformAbsolute", "SetKeyboardPositionForOverlay", "SetOverlayIntersectionMask", "GetOverlayFlags", "ShowMessageOverlay", "CloseMessageOverlay"); - } - public VR_IVROverlay_FnTable(Pointer peer) { - super(peer); - } - public static class ByReference extends VR_IVROverlay_FnTable implements Structure.ByReference { - - }; - public static class ByValue extends VR_IVROverlay_FnTable implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRRenderModels_FnTable.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRRenderModels_FnTable.java deleted file mode 100644 index 3d448c307e..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRRenderModels_FnTable.java +++ /dev/null @@ -1,146 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Callback; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import com.sun.jna.ptr.IntByReference; -import com.sun.jna.ptr.PointerByReference; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:2251
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VR_IVRRenderModels_FnTable extends Structure { - /** C type : LoadRenderModel_Async_callback* */ - public VR_IVRRenderModels_FnTable.LoadRenderModel_Async_callback LoadRenderModel_Async; - /** C type : FreeRenderModel_callback* */ - public VR_IVRRenderModels_FnTable.FreeRenderModel_callback FreeRenderModel; - /** C type : LoadTexture_Async_callback* */ - public VR_IVRRenderModels_FnTable.LoadTexture_Async_callback LoadTexture_Async; - /** C type : FreeTexture_callback* */ - public VR_IVRRenderModels_FnTable.FreeTexture_callback FreeTexture; - /** C type : LoadTextureD3D11_Async_callback* */ - public VR_IVRRenderModels_FnTable.LoadTextureD3D11_Async_callback LoadTextureD3D11_Async; - /** C type : LoadIntoTextureD3D11_Async_callback* */ - public VR_IVRRenderModels_FnTable.LoadIntoTextureD3D11_Async_callback LoadIntoTextureD3D11_Async; - /** C type : FreeTextureD3D11_callback* */ - public VR_IVRRenderModels_FnTable.FreeTextureD3D11_callback FreeTextureD3D11; - /** C type : GetRenderModelName_callback* */ - public VR_IVRRenderModels_FnTable.GetRenderModelName_callback GetRenderModelName; - /** C type : GetRenderModelCount_callback* */ - public VR_IVRRenderModels_FnTable.GetRenderModelCount_callback GetRenderModelCount; - /** C type : GetComponentCount_callback* */ - public VR_IVRRenderModels_FnTable.GetComponentCount_callback GetComponentCount; - /** C type : GetComponentName_callback* */ - public VR_IVRRenderModels_FnTable.GetComponentName_callback GetComponentName; - /** C type : GetComponentButtonMask_callback* */ - public VR_IVRRenderModels_FnTable.GetComponentButtonMask_callback GetComponentButtonMask; - /** C type : GetComponentRenderModelName_callback* */ - public VR_IVRRenderModels_FnTable.GetComponentRenderModelName_callback GetComponentRenderModelName; - /** C type : GetComponentStateForDevicePath_callback* */ - public VR_IVRRenderModels_FnTable.GetComponentStateForDevicePath_callback GetComponentStateForDevicePath; - /** C type : GetComponentState_callback* */ - public VR_IVRRenderModels_FnTable.GetComponentState_callback GetComponentState; - /** C type : RenderModelHasComponent_callback* */ - public VR_IVRRenderModels_FnTable.RenderModelHasComponent_callback RenderModelHasComponent; - /** C type : GetRenderModelThumbnailURL_callback* */ - public VR_IVRRenderModels_FnTable.GetRenderModelThumbnailURL_callback GetRenderModelThumbnailURL; - /** C type : GetRenderModelOriginalPath_callback* */ - public VR_IVRRenderModels_FnTable.GetRenderModelOriginalPath_callback GetRenderModelOriginalPath; - /** C type : GetRenderModelErrorNameFromEnum_callback* */ - public VR_IVRRenderModels_FnTable.GetRenderModelErrorNameFromEnum_callback GetRenderModelErrorNameFromEnum; - /** native declaration : headers\openvr_capi.h:2232 */ - public interface LoadRenderModel_Async_callback extends Callback { - int apply(Pointer pchRenderModelName, PointerByReference ppRenderModel); - }; - /** native declaration : headers\openvr_capi.h:2233 */ - public interface FreeRenderModel_callback extends Callback { - void apply(RenderModel_t pRenderModel); - }; - /** native declaration : headers\openvr_capi.h:2234 */ - public interface LoadTexture_Async_callback extends Callback { - int apply(int textureId, PointerByReference ppTexture); - }; - /** native declaration : headers\openvr_capi.h:2235 */ - public interface FreeTexture_callback extends Callback { - void apply(RenderModel_TextureMap_t pTexture); - }; - /** native declaration : headers\openvr_capi.h:2236 */ - public interface LoadTextureD3D11_Async_callback extends Callback { - int apply(int textureId, Pointer pD3D11Device, PointerByReference ppD3D11Texture2D); - }; - /** native declaration : headers\openvr_capi.h:2237 */ - public interface LoadIntoTextureD3D11_Async_callback extends Callback { - int apply(int textureId, Pointer pDstTexture); - }; - /** native declaration : headers\openvr_capi.h:2238 */ - public interface FreeTextureD3D11_callback extends Callback { - void apply(Pointer pD3D11Texture2D); - }; - /** native declaration : headers\openvr_capi.h:2239 */ - public interface GetRenderModelName_callback extends Callback { - int apply(int unRenderModelIndex, Pointer pchRenderModelName, int unRenderModelNameLen); - }; - /** native declaration : headers\openvr_capi.h:2240 */ - public interface GetRenderModelCount_callback extends Callback { - int apply(); - }; - /** native declaration : headers\openvr_capi.h:2241 */ - public interface GetComponentCount_callback extends Callback { - int apply(Pointer pchRenderModelName); - }; - /** native declaration : headers\openvr_capi.h:2242 */ - public interface GetComponentName_callback extends Callback { - int apply(Pointer pchRenderModelName, int unComponentIndex, Pointer pchComponentName, int unComponentNameLen); - }; - /** native declaration : headers\openvr_capi.h:2243 */ - public interface GetComponentButtonMask_callback extends Callback { - long apply(Pointer pchRenderModelName, Pointer pchComponentName); - }; - /** native declaration : headers\openvr_capi.h:2244 */ - public interface GetComponentRenderModelName_callback extends Callback { - int apply(Pointer pchRenderModelName, Pointer pchComponentName, Pointer pchComponentRenderModelName, int unComponentRenderModelNameLen); - }; - /** native declaration : headers\openvr_capi.h:2245 */ - public interface GetComponentStateForDevicePath_callback extends Callback { - byte apply(Pointer pchRenderModelName, Pointer pchComponentName, long devicePath, RenderModel_ControllerMode_State_t pState, RenderModel_ComponentState_t pComponentState); - }; - /** native declaration : headers\openvr_capi.h:2246 */ - public interface GetComponentState_callback extends Callback { - byte apply(Pointer pchRenderModelName, Pointer pchComponentName, VRControllerState_t pControllerState, RenderModel_ControllerMode_State_t pState, RenderModel_ComponentState_t pComponentState); - }; - /** native declaration : headers\openvr_capi.h:2247 */ - public interface RenderModelHasComponent_callback extends Callback { - byte apply(Pointer pchRenderModelName, Pointer pchComponentName); - }; - /** native declaration : headers\openvr_capi.h:2248 */ - public interface GetRenderModelThumbnailURL_callback extends Callback { - int apply(Pointer pchRenderModelName, Pointer pchThumbnailURL, int unThumbnailURLLen, IntByReference peError); - }; - /** native declaration : headers\openvr_capi.h:2249 */ - public interface GetRenderModelOriginalPath_callback extends Callback { - int apply(Pointer pchRenderModelName, Pointer pchOriginalPath, int unOriginalPathLen, IntByReference peError); - }; - /** native declaration : headers\openvr_capi.h:2250 */ - public interface GetRenderModelErrorNameFromEnum_callback extends Callback { - Pointer apply(int error); - }; - public VR_IVRRenderModels_FnTable() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("LoadRenderModel_Async", "FreeRenderModel", "LoadTexture_Async", "FreeTexture", "LoadTextureD3D11_Async", "LoadIntoTextureD3D11_Async", "FreeTextureD3D11", "GetRenderModelName", "GetRenderModelCount", "GetComponentCount", "GetComponentName", "GetComponentButtonMask", "GetComponentRenderModelName", "GetComponentStateForDevicePath", "GetComponentState", "RenderModelHasComponent", "GetRenderModelThumbnailURL", "GetRenderModelOriginalPath", "GetRenderModelErrorNameFromEnum"); - } - public VR_IVRRenderModels_FnTable(Pointer peer) { - super(peer); - } - public static class ByReference extends VR_IVRRenderModels_FnTable implements Structure.ByReference { - - }; - public static class ByValue extends VR_IVRRenderModels_FnTable implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRResources_FnTable.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRResources_FnTable.java deleted file mode 100644 index 1533e094c8..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRResources_FnTable.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Callback; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:2305
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VR_IVRResources_FnTable extends Structure { - /** C type : LoadSharedResource_callback* */ - public VR_IVRResources_FnTable.LoadSharedResource_callback LoadSharedResource; - /** C type : GetResourceFullPath_callback* */ - public VR_IVRResources_FnTable.GetResourceFullPath_callback GetResourceFullPath; - /** native declaration : headers\openvr_capi.h:2303 */ - public interface LoadSharedResource_callback extends Callback { - int apply(Pointer pchResourceName, Pointer pchBuffer, int unBufferLen); - }; - /** native declaration : headers\openvr_capi.h:2304 */ - public interface GetResourceFullPath_callback extends Callback { - int apply(Pointer pchResourceName, Pointer pchResourceTypeDirectory, Pointer pchPathBuffer, int unBufferLen); - }; - public VR_IVRResources_FnTable() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("LoadSharedResource", "GetResourceFullPath"); - } - /** - * @param LoadSharedResource C type : LoadSharedResource_callback*
- * @param GetResourceFullPath C type : GetResourceFullPath_callback* - */ - public VR_IVRResources_FnTable(VR_IVRResources_FnTable.LoadSharedResource_callback LoadSharedResource, VR_IVRResources_FnTable.GetResourceFullPath_callback GetResourceFullPath) { - super(); - this.LoadSharedResource = LoadSharedResource; - this.GetResourceFullPath = GetResourceFullPath; - } - public VR_IVRResources_FnTable(Pointer peer) { - super(peer); - } - public static class ByReference extends VR_IVRResources_FnTable implements Structure.ByReference { - - }; - public static class ByValue extends VR_IVRResources_FnTable implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRScreenshots_FnTable.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRScreenshots_FnTable.java deleted file mode 100644 index 058637d0d4..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRScreenshots_FnTable.java +++ /dev/null @@ -1,92 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Callback; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import com.sun.jna.ptr.IntByReference; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:2299
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VR_IVRScreenshots_FnTable extends Structure { - /** C type : RequestScreenshot_callback* */ - public VR_IVRScreenshots_FnTable.RequestScreenshot_callback RequestScreenshot; - /** C type : HookScreenshot_callback* */ - public VR_IVRScreenshots_FnTable.HookScreenshot_callback HookScreenshot; - /** C type : GetScreenshotPropertyType_callback* */ - public VR_IVRScreenshots_FnTable.GetScreenshotPropertyType_callback GetScreenshotPropertyType; - /** C type : GetScreenshotPropertyFilename_callback* */ - public VR_IVRScreenshots_FnTable.GetScreenshotPropertyFilename_callback GetScreenshotPropertyFilename; - /** C type : UpdateScreenshotProgress_callback* */ - public VR_IVRScreenshots_FnTable.UpdateScreenshotProgress_callback UpdateScreenshotProgress; - /** C type : TakeStereoScreenshot_callback* */ - public VR_IVRScreenshots_FnTable.TakeStereoScreenshot_callback TakeStereoScreenshot; - /** C type : SubmitScreenshot_callback* */ - public VR_IVRScreenshots_FnTable.SubmitScreenshot_callback SubmitScreenshot; - /** native declaration : headers\openvr_capi.h:2292 */ - public interface RequestScreenshot_callback extends Callback { - int apply(IntByReference pOutScreenshotHandle, int type, Pointer pchPreviewFilename, Pointer pchVRFilename); - }; - /** native declaration : headers\openvr_capi.h:2293 */ - public interface HookScreenshot_callback extends Callback { - int apply(IntByReference pSupportedTypes, int numTypes); - }; - /** native declaration : headers\openvr_capi.h:2294 */ - public interface GetScreenshotPropertyType_callback extends Callback { - int apply(int screenshotHandle, IntByReference pError); - }; - /** native declaration : headers\openvr_capi.h:2295 */ - public interface GetScreenshotPropertyFilename_callback extends Callback { - int apply(int screenshotHandle, int filenameType, Pointer pchFilename, int cchFilename, IntByReference pError); - }; - /** native declaration : headers\openvr_capi.h:2296 */ - public interface UpdateScreenshotProgress_callback extends Callback { - int apply(int screenshotHandle, float flProgress); - }; - /** native declaration : headers\openvr_capi.h:2297 */ - public interface TakeStereoScreenshot_callback extends Callback { - int apply(IntByReference pOutScreenshotHandle, Pointer pchPreviewFilename, Pointer pchVRFilename); - }; - /** native declaration : headers\openvr_capi.h:2298 */ - public interface SubmitScreenshot_callback extends Callback { - int apply(int screenshotHandle, int type, Pointer pchSourcePreviewFilename, Pointer pchSourceVRFilename); - }; - public VR_IVRScreenshots_FnTable() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("RequestScreenshot", "HookScreenshot", "GetScreenshotPropertyType", "GetScreenshotPropertyFilename", "UpdateScreenshotProgress", "TakeStereoScreenshot", "SubmitScreenshot"); - } - /** - * @param RequestScreenshot C type : RequestScreenshot_callback*
- * @param HookScreenshot C type : HookScreenshot_callback*
- * @param GetScreenshotPropertyType C type : GetScreenshotPropertyType_callback*
- * @param GetScreenshotPropertyFilename C type : GetScreenshotPropertyFilename_callback*
- * @param UpdateScreenshotProgress C type : UpdateScreenshotProgress_callback*
- * @param TakeStereoScreenshot C type : TakeStereoScreenshot_callback*
- * @param SubmitScreenshot C type : SubmitScreenshot_callback* - */ - public VR_IVRScreenshots_FnTable(VR_IVRScreenshots_FnTable.RequestScreenshot_callback RequestScreenshot, VR_IVRScreenshots_FnTable.HookScreenshot_callback HookScreenshot, VR_IVRScreenshots_FnTable.GetScreenshotPropertyType_callback GetScreenshotPropertyType, VR_IVRScreenshots_FnTable.GetScreenshotPropertyFilename_callback GetScreenshotPropertyFilename, VR_IVRScreenshots_FnTable.UpdateScreenshotProgress_callback UpdateScreenshotProgress, VR_IVRScreenshots_FnTable.TakeStereoScreenshot_callback TakeStereoScreenshot, VR_IVRScreenshots_FnTable.SubmitScreenshot_callback SubmitScreenshot) { - super(); - this.RequestScreenshot = RequestScreenshot; - this.HookScreenshot = HookScreenshot; - this.GetScreenshotPropertyType = GetScreenshotPropertyType; - this.GetScreenshotPropertyFilename = GetScreenshotPropertyFilename; - this.UpdateScreenshotProgress = UpdateScreenshotProgress; - this.TakeStereoScreenshot = TakeStereoScreenshot; - this.SubmitScreenshot = SubmitScreenshot; - } - public VR_IVRScreenshots_FnTable(Pointer peer) { - super(peer); - } - public static class ByReference extends VR_IVRScreenshots_FnTable implements Structure.ByReference { - - }; - public static class ByValue extends VR_IVRScreenshots_FnTable implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRSettings_FnTable.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRSettings_FnTable.java deleted file mode 100644 index ebbe247fb9..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRSettings_FnTable.java +++ /dev/null @@ -1,103 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Callback; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import com.sun.jna.ptr.IntByReference; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:2283
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VR_IVRSettings_FnTable extends Structure { - /** C type : GetSettingsErrorNameFromEnum_callback* */ - public VR_IVRSettings_FnTable.GetSettingsErrorNameFromEnum_callback GetSettingsErrorNameFromEnum; - /** C type : Sync_callback* */ - public VR_IVRSettings_FnTable.Sync_callback Sync; - /** C type : SetBool_callback* */ - public VR_IVRSettings_FnTable.SetBool_callback SetBool; - /** C type : SetInt32_callback* */ - public VR_IVRSettings_FnTable.SetInt32_callback SetInt32; - /** C type : SetFloat_callback* */ - public VR_IVRSettings_FnTable.SetFloat_callback SetFloat; - /** C type : SetString_callback* */ - public VR_IVRSettings_FnTable.SetString_callback SetString; - /** C type : GetBool_callback* */ - public VR_IVRSettings_FnTable.GetBool_callback GetBool; - /** C type : GetInt32_callback* */ - public VR_IVRSettings_FnTable.GetInt32_callback GetInt32; - /** C type : GetFloat_callback* */ - public VR_IVRSettings_FnTable.GetFloat_callback GetFloat; - /** C type : GetString_callback* */ - public VR_IVRSettings_FnTable.GetString_callback GetString; - /** C type : RemoveSection_callback* */ - public VR_IVRSettings_FnTable.RemoveSection_callback RemoveSection; - /** C type : RemoveKeyInSection_callback* */ - public VR_IVRSettings_FnTable.RemoveKeyInSection_callback RemoveKeyInSection; - /** native declaration : headers\openvr_capi.h:2271 */ - public interface GetSettingsErrorNameFromEnum_callback extends Callback { - Pointer apply(int eError); - }; - /** native declaration : headers\openvr_capi.h:2272 */ - public interface Sync_callback extends Callback { - byte apply(byte bForce, IntByReference peError); - }; - /** native declaration : headers\openvr_capi.h:2273 */ - public interface SetBool_callback extends Callback { - void apply(Pointer pchSection, Pointer pchSettingsKey, byte bValue, IntByReference peError); - }; - /** native declaration : headers\openvr_capi.h:2274 */ - public interface SetInt32_callback extends Callback { - void apply(Pointer pchSection, Pointer pchSettingsKey, int nValue, IntByReference peError); - }; - /** native declaration : headers\openvr_capi.h:2275 */ - public interface SetFloat_callback extends Callback { - void apply(Pointer pchSection, Pointer pchSettingsKey, float flValue, IntByReference peError); - }; - /** native declaration : headers\openvr_capi.h:2276 */ - public interface SetString_callback extends Callback { - void apply(Pointer pchSection, Pointer pchSettingsKey, Pointer pchValue, IntByReference peError); - }; - /** native declaration : headers\openvr_capi.h:2277 */ - public interface GetBool_callback extends Callback { - byte apply(Pointer pchSection, Pointer pchSettingsKey, IntByReference peError); - }; - /** native declaration : headers\openvr_capi.h:2278 */ - public interface GetInt32_callback extends Callback { - int apply(Pointer pchSection, Pointer pchSettingsKey, IntByReference peError); - }; - /** native declaration : headers\openvr_capi.h:2279 */ - public interface GetFloat_callback extends Callback { - float apply(Pointer pchSection, Pointer pchSettingsKey, IntByReference peError); - }; - /** native declaration : headers\openvr_capi.h:2280 */ - public interface GetString_callback extends Callback { - void apply(Pointer pchSection, Pointer pchSettingsKey, Pointer pchValue, int unValueLen, IntByReference peError); - }; - /** native declaration : headers\openvr_capi.h:2281 */ - public interface RemoveSection_callback extends Callback { - void apply(Pointer pchSection, IntByReference peError); - }; - /** native declaration : headers\openvr_capi.h:2282 */ - public interface RemoveKeyInSection_callback extends Callback { - void apply(Pointer pchSection, Pointer pchSettingsKey, IntByReference peError); - }; - public VR_IVRSettings_FnTable() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("GetSettingsErrorNameFromEnum", "Sync", "SetBool", "SetInt32", "SetFloat", "SetString", "GetBool", "GetInt32", "GetFloat", "GetString", "RemoveSection", "RemoveKeyInSection"); - } - public VR_IVRSettings_FnTable(Pointer peer) { - super(peer); - } - public static class ByReference extends VR_IVRSettings_FnTable implements Structure.ByReference { - - }; - public static class ByValue extends VR_IVRSettings_FnTable implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRSpatialAnchors_FnTable.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRSpatialAnchors_FnTable.java deleted file mode 100644 index 3b28c8da19..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRSpatialAnchors_FnTable.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Callback; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import com.sun.jna.ptr.IntByReference; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:2373
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VR_IVRSpatialAnchors_FnTable extends Structure { - /** C type : CreateSpatialAnchorFromDescriptor_callback* */ - public VR_IVRSpatialAnchors_FnTable.CreateSpatialAnchorFromDescriptor_callback CreateSpatialAnchorFromDescriptor; - /** C type : CreateSpatialAnchorFromPose_callback* */ - public VR_IVRSpatialAnchors_FnTable.CreateSpatialAnchorFromPose_callback CreateSpatialAnchorFromPose; - /** C type : GetSpatialAnchorPose_callback* */ - public VR_IVRSpatialAnchors_FnTable.GetSpatialAnchorPose_callback GetSpatialAnchorPose; - /** C type : GetSpatialAnchorDescriptor_callback* */ - public VR_IVRSpatialAnchors_FnTable.GetSpatialAnchorDescriptor_callback GetSpatialAnchorDescriptor; - /** native declaration : headers\openvr_capi.h:2369 */ - public interface CreateSpatialAnchorFromDescriptor_callback extends Callback { - int apply(Pointer pchDescriptor, IntByReference pHandleOut); - }; - /** native declaration : headers\openvr_capi.h:2370 */ - public interface CreateSpatialAnchorFromPose_callback extends Callback { - int apply(int unDeviceIndex, int eOrigin, SpatialAnchorPose_t pPose, IntByReference pHandleOut); - }; - /** native declaration : headers\openvr_capi.h:2371 */ - public interface GetSpatialAnchorPose_callback extends Callback { - int apply(int unHandle, int eOrigin, SpatialAnchorPose_t pPoseOut); - }; - /** native declaration : headers\openvr_capi.h:2372 */ - public interface GetSpatialAnchorDescriptor_callback extends Callback { - int apply(int unHandle, Pointer pchDescriptorOut, IntByReference punDescriptorBufferLenInOut); - }; - public VR_IVRSpatialAnchors_FnTable() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("CreateSpatialAnchorFromDescriptor", "CreateSpatialAnchorFromPose", "GetSpatialAnchorPose", "GetSpatialAnchorDescriptor"); - } - /** - * @param CreateSpatialAnchorFromDescriptor C type : CreateSpatialAnchorFromDescriptor_callback*
- * @param CreateSpatialAnchorFromPose C type : CreateSpatialAnchorFromPose_callback*
- * @param GetSpatialAnchorPose C type : GetSpatialAnchorPose_callback*
- * @param GetSpatialAnchorDescriptor C type : GetSpatialAnchorDescriptor_callback* - */ - public VR_IVRSpatialAnchors_FnTable(VR_IVRSpatialAnchors_FnTable.CreateSpatialAnchorFromDescriptor_callback CreateSpatialAnchorFromDescriptor, VR_IVRSpatialAnchors_FnTable.CreateSpatialAnchorFromPose_callback CreateSpatialAnchorFromPose, VR_IVRSpatialAnchors_FnTable.GetSpatialAnchorPose_callback GetSpatialAnchorPose, VR_IVRSpatialAnchors_FnTable.GetSpatialAnchorDescriptor_callback GetSpatialAnchorDescriptor) { - super(); - this.CreateSpatialAnchorFromDescriptor = CreateSpatialAnchorFromDescriptor; - this.CreateSpatialAnchorFromPose = CreateSpatialAnchorFromPose; - this.GetSpatialAnchorPose = GetSpatialAnchorPose; - this.GetSpatialAnchorDescriptor = GetSpatialAnchorDescriptor; - } - public VR_IVRSpatialAnchors_FnTable(Pointer peer) { - super(peer); - } - public static class ByReference extends VR_IVRSpatialAnchors_FnTable implements Structure.ByReference { - - }; - public static class ByValue extends VR_IVRSpatialAnchors_FnTable implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRSystem_FnTable.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRSystem_FnTable.java deleted file mode 100644 index 8257d23a4f..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRSystem_FnTable.java +++ /dev/null @@ -1,317 +0,0 @@ -package com.jme3.system.jopenvr; -import com.jme3.system.jopenvr.JOpenVRLibrary.VkInstance_T; -import com.sun.jna.Callback; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import com.sun.jna.ptr.FloatByReference; -import com.sun.jna.ptr.IntByReference; -import com.sun.jna.ptr.LongByReference; -import java.util.Arrays; -import java.util.List; -/** - * OpenVR Function Pointer Tables
- * native declaration : headers\openvr_capi.h:1799
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VR_IVRSystem_FnTable extends Structure { - /** C type : GetRecommendedRenderTargetSize_callback* */ - public VR_IVRSystem_FnTable.GetRecommendedRenderTargetSize_callback GetRecommendedRenderTargetSize; - /** C type : GetProjectionMatrix_callback* */ - public VR_IVRSystem_FnTable.GetProjectionMatrix_callback GetProjectionMatrix; - /** C type : GetProjectionRaw_callback* */ - public VR_IVRSystem_FnTable.GetProjectionRaw_callback GetProjectionRaw; - /** C type : ComputeDistortion_callback* */ - public VR_IVRSystem_FnTable.ComputeDistortion_callback ComputeDistortion; - /** C type : GetEyeToHeadTransform_callback* */ - public VR_IVRSystem_FnTable.GetEyeToHeadTransform_callback GetEyeToHeadTransform; - /** C type : GetTimeSinceLastVsync_callback* */ - public VR_IVRSystem_FnTable.GetTimeSinceLastVsync_callback GetTimeSinceLastVsync; - /** C type : GetD3D9AdapterIndex_callback* */ - public VR_IVRSystem_FnTable.GetD3D9AdapterIndex_callback GetD3D9AdapterIndex; - /** C type : GetDXGIOutputInfo_callback* */ - public com.jme3.system.jopenvr.VR_IVRExtendedDisplay_FnTable.GetDXGIOutputInfo_callback GetDXGIOutputInfo; - /** C type : GetOutputDevice_callback* */ - public VR_IVRSystem_FnTable.GetOutputDevice_callback GetOutputDevice; - /** C type : IsDisplayOnDesktop_callback* */ - public VR_IVRSystem_FnTable.IsDisplayOnDesktop_callback IsDisplayOnDesktop; - /** C type : SetDisplayVisibility_callback* */ - public VR_IVRSystem_FnTable.SetDisplayVisibility_callback SetDisplayVisibility; - /** C type : GetDeviceToAbsoluteTrackingPose_callback* */ - public VR_IVRSystem_FnTable.GetDeviceToAbsoluteTrackingPose_callback GetDeviceToAbsoluteTrackingPose; - /** C type : ResetSeatedZeroPose_callback* */ - public VR_IVRSystem_FnTable.ResetSeatedZeroPose_callback ResetSeatedZeroPose; - /** C type : GetSeatedZeroPoseToStandingAbsoluteTrackingPose_callback* */ - public VR_IVRSystem_FnTable.GetSeatedZeroPoseToStandingAbsoluteTrackingPose_callback GetSeatedZeroPoseToStandingAbsoluteTrackingPose; - /** C type : GetRawZeroPoseToStandingAbsoluteTrackingPose_callback* */ - public VR_IVRSystem_FnTable.GetRawZeroPoseToStandingAbsoluteTrackingPose_callback GetRawZeroPoseToStandingAbsoluteTrackingPose; - /** C type : GetSortedTrackedDeviceIndicesOfClass_callback* */ - public VR_IVRSystem_FnTable.GetSortedTrackedDeviceIndicesOfClass_callback GetSortedTrackedDeviceIndicesOfClass; - /** C type : GetTrackedDeviceActivityLevel_callback* */ - public VR_IVRSystem_FnTable.GetTrackedDeviceActivityLevel_callback GetTrackedDeviceActivityLevel; - /** C type : ApplyTransform_callback* */ - public VR_IVRSystem_FnTable.ApplyTransform_callback ApplyTransform; - /** C type : GetTrackedDeviceIndexForControllerRole_callback* */ - public VR_IVRSystem_FnTable.GetTrackedDeviceIndexForControllerRole_callback GetTrackedDeviceIndexForControllerRole; - /** C type : GetControllerRoleForTrackedDeviceIndex_callback* */ - public VR_IVRSystem_FnTable.GetControllerRoleForTrackedDeviceIndex_callback GetControllerRoleForTrackedDeviceIndex; - /** C type : GetTrackedDeviceClass_callback* */ - public VR_IVRSystem_FnTable.GetTrackedDeviceClass_callback GetTrackedDeviceClass; - /** C type : IsTrackedDeviceConnected_callback* */ - public VR_IVRSystem_FnTable.IsTrackedDeviceConnected_callback IsTrackedDeviceConnected; - /** C type : GetBoolTrackedDeviceProperty_callback* */ - public VR_IVRSystem_FnTable.GetBoolTrackedDeviceProperty_callback GetBoolTrackedDeviceProperty; - /** C type : GetFloatTrackedDeviceProperty_callback* */ - public VR_IVRSystem_FnTable.GetFloatTrackedDeviceProperty_callback GetFloatTrackedDeviceProperty; - /** C type : GetInt32TrackedDeviceProperty_callback* */ - public VR_IVRSystem_FnTable.GetInt32TrackedDeviceProperty_callback GetInt32TrackedDeviceProperty; - /** C type : GetUint64TrackedDeviceProperty_callback* */ - public VR_IVRSystem_FnTable.GetUint64TrackedDeviceProperty_callback GetUint64TrackedDeviceProperty; - /** C type : GetMatrix34TrackedDeviceProperty_callback* */ - public VR_IVRSystem_FnTable.GetMatrix34TrackedDeviceProperty_callback GetMatrix34TrackedDeviceProperty; - /** C type : GetArrayTrackedDeviceProperty_callback* */ - public VR_IVRSystem_FnTable.GetArrayTrackedDeviceProperty_callback GetArrayTrackedDeviceProperty; - /** C type : GetStringTrackedDeviceProperty_callback* */ - public VR_IVRSystem_FnTable.GetStringTrackedDeviceProperty_callback GetStringTrackedDeviceProperty; - /** C type : GetPropErrorNameFromEnum_callback* */ - public VR_IVRSystem_FnTable.GetPropErrorNameFromEnum_callback GetPropErrorNameFromEnum; - /** C type : PollNextEvent_callback* */ - public VR_IVRSystem_FnTable.PollNextEvent_callback PollNextEvent; - /** C type : PollNextEventWithPose_callback* */ - public VR_IVRSystem_FnTable.PollNextEventWithPose_callback PollNextEventWithPose; - /** C type : GetEventTypeNameFromEnum_callback* */ - public VR_IVRSystem_FnTable.GetEventTypeNameFromEnum_callback GetEventTypeNameFromEnum; - /** C type : GetHiddenAreaMesh_callback* */ - public VR_IVRSystem_FnTable.GetHiddenAreaMesh_callback GetHiddenAreaMesh; - /** C type : GetControllerState_callback* */ - public VR_IVRSystem_FnTable.GetControllerState_callback GetControllerState; - /** C type : GetControllerStateWithPose_callback* */ - public VR_IVRSystem_FnTable.GetControllerStateWithPose_callback GetControllerStateWithPose; - /** C type : TriggerHapticPulse_callback* */ - public VR_IVRSystem_FnTable.TriggerHapticPulse_callback TriggerHapticPulse; - /** C type : GetButtonIdNameFromEnum_callback* */ - public VR_IVRSystem_FnTable.GetButtonIdNameFromEnum_callback GetButtonIdNameFromEnum; - /** C type : GetControllerAxisTypeNameFromEnum_callback* */ - public VR_IVRSystem_FnTable.GetControllerAxisTypeNameFromEnum_callback GetControllerAxisTypeNameFromEnum; - /** C type : IsInputAvailable_callback* */ - public VR_IVRSystem_FnTable.IsInputAvailable_callback IsInputAvailable; - /** C type : IsSteamVRDrawingControllers_callback* */ - public VR_IVRSystem_FnTable.IsSteamVRDrawingControllers_callback IsSteamVRDrawingControllers; - /** C type : ShouldApplicationPause_callback* */ - public VR_IVRSystem_FnTable.ShouldApplicationPause_callback ShouldApplicationPause; - /** C type : ShouldApplicationReduceRenderingWork_callback* */ - public VR_IVRSystem_FnTable.ShouldApplicationReduceRenderingWork_callback ShouldApplicationReduceRenderingWork; - /** C type : DriverDebugRequest_callback* */ - public VR_IVRSystem_FnTable.DriverDebugRequest_callback DriverDebugRequest; - /** C type : PerformFirmwareUpdate_callback* */ - public VR_IVRSystem_FnTable.PerformFirmwareUpdate_callback PerformFirmwareUpdate; - /** C type : AcknowledgeQuit_Exiting_callback* */ - public VR_IVRSystem_FnTable.AcknowledgeQuit_Exiting_callback AcknowledgeQuit_Exiting; - /** C type : AcknowledgeQuit_UserPrompt_callback* */ - public VR_IVRSystem_FnTable.AcknowledgeQuit_UserPrompt_callback AcknowledgeQuit_UserPrompt; - /** native declaration : headers\openvr_capi.h:1752 */ - public interface GetRecommendedRenderTargetSize_callback extends Callback { - void apply(IntByReference pnWidth, IntByReference pnHeight); - }; - /** native declaration : headers\openvr_capi.h:1753 */ - public interface GetProjectionMatrix_callback extends Callback { - com.jme3.system.jopenvr.HmdMatrix44_t.ByValue apply(int eEye, float fNearZ, float fFarZ); - }; - /** native declaration : headers\openvr_capi.h:1754 */ - public interface GetProjectionRaw_callback extends Callback { - void apply(int eEye, FloatByReference pfLeft, FloatByReference pfRight, FloatByReference pfTop, FloatByReference pfBottom); - }; - /** native declaration : headers\openvr_capi.h:1755 */ - public interface ComputeDistortion_callback extends Callback { - byte apply(int eEye, float fU, float fV, DistortionCoordinates_t pDistortionCoordinates); - }; - /** native declaration : headers\openvr_capi.h:1756 */ - public interface GetEyeToHeadTransform_callback extends Callback { - HmdMatrix34_t.ByValue apply(int eEye); - }; - /** native declaration : headers\openvr_capi.h:1757 */ - public interface GetTimeSinceLastVsync_callback extends Callback { - byte apply(FloatByReference pfSecondsSinceLastVsync, LongByReference pulFrameCounter); - }; - /** native declaration : headers\openvr_capi.h:1758 */ - public interface GetD3D9AdapterIndex_callback extends Callback { - int apply(); - }; - /** native declaration : headers\openvr_capi.h:1759 */ - public interface GetDXGIOutputInfo_callback extends Callback { - void apply(IntByReference pnAdapterIndex); - }; - /** native declaration : headers\openvr_capi.h:1760 */ - public interface GetOutputDevice_callback extends Callback { - void apply(LongByReference pnDevice, int textureType, VkInstance_T pInstance); - }; - /** native declaration : headers\openvr_capi.h:1761 */ - public interface IsDisplayOnDesktop_callback extends Callback { - byte apply(); - }; - /** native declaration : headers\openvr_capi.h:1762 */ - public interface SetDisplayVisibility_callback extends Callback { - byte apply(byte bIsVisibleOnDesktop); - }; - /** native declaration : headers\openvr_capi.h:1763 */ - public interface GetDeviceToAbsoluteTrackingPose_callback extends Callback { - void apply(int eOrigin, float fPredictedSecondsToPhotonsFromNow, TrackedDevicePose_t pTrackedDevicePoseArray, int unTrackedDevicePoseArrayCount); - }; - /** native declaration : headers\openvr_capi.h:1764 */ - public interface ResetSeatedZeroPose_callback extends Callback { - void apply(); - }; - /** native declaration : headers\openvr_capi.h:1765 */ - public interface GetSeatedZeroPoseToStandingAbsoluteTrackingPose_callback extends Callback { - HmdMatrix34_t.ByValue apply(); - }; - /** native declaration : headers\openvr_capi.h:1766 */ - public interface GetRawZeroPoseToStandingAbsoluteTrackingPose_callback extends Callback { - HmdMatrix34_t.ByValue apply(); - }; - /** native declaration : headers\openvr_capi.h:1767 */ - public interface GetSortedTrackedDeviceIndicesOfClass_callback extends Callback { - int apply(int eTrackedDeviceClass, IntByReference punTrackedDeviceIndexArray, int unTrackedDeviceIndexArrayCount, int unRelativeToTrackedDeviceIndex); - }; - /** native declaration : headers\openvr_capi.h:1768 */ - public interface GetTrackedDeviceActivityLevel_callback extends Callback { - int apply(int unDeviceId); - }; - /** native declaration : headers\openvr_capi.h:1769 */ - public interface ApplyTransform_callback extends Callback { - void apply(TrackedDevicePose_t pOutputPose, TrackedDevicePose_t pTrackedDevicePose, HmdMatrix34_t pTransform); - }; - /** native declaration : headers\openvr_capi.h:1770 */ - public interface GetTrackedDeviceIndexForControllerRole_callback extends Callback { - int apply(int unDeviceType); - }; - /** native declaration : headers\openvr_capi.h:1771 */ - public interface GetControllerRoleForTrackedDeviceIndex_callback extends Callback { - int apply(int unDeviceIndex); - }; - /** native declaration : headers\openvr_capi.h:1772 */ - public interface GetTrackedDeviceClass_callback extends Callback { - int apply(int unDeviceIndex); - }; - /** native declaration : headers\openvr_capi.h:1773 */ - public interface IsTrackedDeviceConnected_callback extends Callback { - byte apply(int unDeviceIndex); - }; - /** native declaration : headers\openvr_capi.h:1774 */ - public interface GetBoolTrackedDeviceProperty_callback extends Callback { - byte apply(int unDeviceIndex, int prop, IntByReference pError); - }; - /** native declaration : headers\openvr_capi.h:1775 */ - public interface GetFloatTrackedDeviceProperty_callback extends Callback { - float apply(int unDeviceIndex, int prop, IntByReference pError); - }; - /** native declaration : headers\openvr_capi.h:1776 */ - public interface GetInt32TrackedDeviceProperty_callback extends Callback { - int apply(int unDeviceIndex, int prop, IntByReference pError); - }; - /** native declaration : headers\openvr_capi.h:1777 */ - public interface GetUint64TrackedDeviceProperty_callback extends Callback { - long apply(int unDeviceIndex, int prop, IntByReference pError); - }; - /** native declaration : headers\openvr_capi.h:1778 */ - public interface GetMatrix34TrackedDeviceProperty_callback extends Callback { - HmdMatrix34_t.ByValue apply(int unDeviceIndex, int prop, IntByReference pError); - }; - /** native declaration : headers\openvr_capi.h:1779 */ - public interface GetArrayTrackedDeviceProperty_callback extends Callback { - int apply(int unDeviceIndex, int prop, int propType, Pointer pBuffer, int unBufferSize, IntByReference pError); - }; - /** native declaration : headers\openvr_capi.h:1780 */ - public interface GetStringTrackedDeviceProperty_callback extends Callback { - int apply(int unDeviceIndex, int prop, Pointer pchValue, int unBufferSize, IntByReference pError); - }; - /** native declaration : headers\openvr_capi.h:1781 */ - public interface GetPropErrorNameFromEnum_callback extends Callback { - Pointer apply(int error); - }; - /** native declaration : headers\openvr_capi.h:1782 */ - public interface PollNextEvent_callback extends Callback { - byte apply(VREvent_t pEvent, int uncbVREvent); - }; - /** native declaration : headers\openvr_capi.h:1783 */ - public interface PollNextEventWithPose_callback extends Callback { - byte apply(int eOrigin, VREvent_t pEvent, int uncbVREvent, TrackedDevicePose_t pTrackedDevicePose); - }; - /** native declaration : headers\openvr_capi.h:1784 */ - public interface GetEventTypeNameFromEnum_callback extends Callback { - Pointer apply(int eType); - }; - /** native declaration : headers\openvr_capi.h:1785 */ - public interface GetHiddenAreaMesh_callback extends Callback { - com.jme3.system.jopenvr.HiddenAreaMesh_t.ByValue apply(int eEye, int type); - }; - /** native declaration : headers\openvr_capi.h:1786 */ - public interface GetControllerState_callback extends Callback { - byte apply(int unControllerDeviceIndex, VRControllerState_t pControllerState, int unControllerStateSize); - }; - /** native declaration : headers\openvr_capi.h:1787 */ - public interface GetControllerStateWithPose_callback extends Callback { - byte apply(int eOrigin, int unControllerDeviceIndex, VRControllerState_t pControllerState, int unControllerStateSize, TrackedDevicePose_t pTrackedDevicePose); - }; - /** native declaration : headers\openvr_capi.h:1788 */ - public interface TriggerHapticPulse_callback extends Callback { - void apply(int unControllerDeviceIndex, int unAxisId, short usDurationMicroSec); - }; - /** native declaration : headers\openvr_capi.h:1789 */ - public interface GetButtonIdNameFromEnum_callback extends Callback { - Pointer apply(int eButtonId); - }; - /** native declaration : headers\openvr_capi.h:1790 */ - public interface GetControllerAxisTypeNameFromEnum_callback extends Callback { - Pointer apply(int eAxisType); - }; - /** native declaration : headers\openvr_capi.h:1791 */ - public interface IsInputAvailable_callback extends Callback { - byte apply(); - }; - /** native declaration : headers\openvr_capi.h:1792 */ - public interface IsSteamVRDrawingControllers_callback extends Callback { - byte apply(); - }; - /** native declaration : headers\openvr_capi.h:1793 */ - public interface ShouldApplicationPause_callback extends Callback { - byte apply(); - }; - /** native declaration : headers\openvr_capi.h:1794 */ - public interface ShouldApplicationReduceRenderingWork_callback extends Callback { - byte apply(); - }; - /** native declaration : headers\openvr_capi.h:1795 */ - public interface DriverDebugRequest_callback extends Callback { - int apply(int unDeviceIndex, Pointer pchRequest, Pointer pchResponseBuffer, int unResponseBufferSize); - }; - /** native declaration : headers\openvr_capi.h:1796 */ - public interface PerformFirmwareUpdate_callback extends Callback { - int apply(int unDeviceIndex); - }; - /** native declaration : headers\openvr_capi.h:1797 */ - public interface AcknowledgeQuit_Exiting_callback extends Callback { - void apply(); - }; - /** native declaration : headers\openvr_capi.h:1798 */ - public interface AcknowledgeQuit_UserPrompt_callback extends Callback { - void apply(); - }; - public VR_IVRSystem_FnTable() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("GetRecommendedRenderTargetSize", "GetProjectionMatrix", "GetProjectionRaw", "ComputeDistortion", "GetEyeToHeadTransform", "GetTimeSinceLastVsync", "GetD3D9AdapterIndex", "GetDXGIOutputInfo", "GetOutputDevice", "IsDisplayOnDesktop", "SetDisplayVisibility", "GetDeviceToAbsoluteTrackingPose", "ResetSeatedZeroPose", "GetSeatedZeroPoseToStandingAbsoluteTrackingPose", "GetRawZeroPoseToStandingAbsoluteTrackingPose", "GetSortedTrackedDeviceIndicesOfClass", "GetTrackedDeviceActivityLevel", "ApplyTransform", "GetTrackedDeviceIndexForControllerRole", "GetControllerRoleForTrackedDeviceIndex", "GetTrackedDeviceClass", "IsTrackedDeviceConnected", "GetBoolTrackedDeviceProperty", "GetFloatTrackedDeviceProperty", "GetInt32TrackedDeviceProperty", "GetUint64TrackedDeviceProperty", "GetMatrix34TrackedDeviceProperty", "GetArrayTrackedDeviceProperty", "GetStringTrackedDeviceProperty", "GetPropErrorNameFromEnum", "PollNextEvent", "PollNextEventWithPose", "GetEventTypeNameFromEnum", "GetHiddenAreaMesh", "GetControllerState", "GetControllerStateWithPose", "TriggerHapticPulse", "GetButtonIdNameFromEnum", "GetControllerAxisTypeNameFromEnum", "IsInputAvailable", "IsSteamVRDrawingControllers", "ShouldApplicationPause", "ShouldApplicationReduceRenderingWork", "DriverDebugRequest", "PerformFirmwareUpdate", "AcknowledgeQuit_Exiting", "AcknowledgeQuit_UserPrompt"); - } - public VR_IVRSystem_FnTable(Pointer peer) { - super(peer); - } - public static class ByReference extends VR_IVRSystem_FnTable implements Structure.ByReference { - - }; - public static class ByValue extends VR_IVRSystem_FnTable implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRTrackedCamera_FnTable.java b/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRTrackedCamera_FnTable.java deleted file mode 100644 index 42ba86816b..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/jopenvr/VR_IVRTrackedCamera_FnTable.java +++ /dev/null @@ -1,105 +0,0 @@ -package com.jme3.system.jopenvr; -import com.sun.jna.Callback; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import com.sun.jna.ptr.IntByReference; -import com.sun.jna.ptr.LongByReference; -import com.sun.jna.ptr.PointerByReference; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : headers\openvr_capi.h:1833
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VR_IVRTrackedCamera_FnTable extends Structure { - /** C type : GetCameraErrorNameFromEnum_callback* */ - public VR_IVRTrackedCamera_FnTable.GetCameraErrorNameFromEnum_callback GetCameraErrorNameFromEnum; - /** C type : HasCamera_callback* */ - public VR_IVRTrackedCamera_FnTable.HasCamera_callback HasCamera; - /** C type : GetCameraFrameSize_callback* */ - public VR_IVRTrackedCamera_FnTable.GetCameraFrameSize_callback GetCameraFrameSize; - /** C type : GetCameraIntrinsics_callback* */ - public VR_IVRTrackedCamera_FnTable.GetCameraIntrinsics_callback GetCameraIntrinsics; - /** C type : GetCameraProjection_callback* */ - public VR_IVRTrackedCamera_FnTable.GetCameraProjection_callback GetCameraProjection; - /** C type : AcquireVideoStreamingService_callback* */ - public VR_IVRTrackedCamera_FnTable.AcquireVideoStreamingService_callback AcquireVideoStreamingService; - /** C type : ReleaseVideoStreamingService_callback* */ - public VR_IVRTrackedCamera_FnTable.ReleaseVideoStreamingService_callback ReleaseVideoStreamingService; - /** C type : GetVideoStreamFrameBuffer_callback* */ - public VR_IVRTrackedCamera_FnTable.GetVideoStreamFrameBuffer_callback GetVideoStreamFrameBuffer; - /** C type : GetVideoStreamTextureSize_callback* */ - public VR_IVRTrackedCamera_FnTable.GetVideoStreamTextureSize_callback GetVideoStreamTextureSize; - /** C type : GetVideoStreamTextureD3D11_callback* */ - public VR_IVRTrackedCamera_FnTable.GetVideoStreamTextureD3D11_callback GetVideoStreamTextureD3D11; - /** C type : GetVideoStreamTextureGL_callback* */ - public VR_IVRTrackedCamera_FnTable.GetVideoStreamTextureGL_callback GetVideoStreamTextureGL; - /** C type : ReleaseVideoStreamTextureGL_callback* */ - public VR_IVRTrackedCamera_FnTable.ReleaseVideoStreamTextureGL_callback ReleaseVideoStreamTextureGL; - /** native declaration : headers\openvr_capi.h:1821 */ - public interface GetCameraErrorNameFromEnum_callback extends Callback { - Pointer apply(int eCameraError); - }; - /** native declaration : headers\openvr_capi.h:1822 */ - public interface HasCamera_callback extends Callback { - int apply(int nDeviceIndex, Pointer pHasCamera); - }; - /** native declaration : headers\openvr_capi.h:1823 */ - public interface GetCameraFrameSize_callback extends Callback { - int apply(int nDeviceIndex, int eFrameType, IntByReference pnWidth, IntByReference pnHeight, IntByReference pnFrameBufferSize); - }; - /** native declaration : headers\openvr_capi.h:1824 */ - public interface GetCameraIntrinsics_callback extends Callback { - int apply(int nDeviceIndex, int eFrameType, HmdVector2_t pFocalLength, HmdVector2_t pCenter); - }; - /** native declaration : headers\openvr_capi.h:1825 */ - public interface GetCameraProjection_callback extends Callback { - int apply(int nDeviceIndex, int eFrameType, float flZNear, float flZFar, HmdMatrix44_t pProjection); - }; - /** native declaration : headers\openvr_capi.h:1826 */ - public interface AcquireVideoStreamingService_callback extends Callback { - int apply(int nDeviceIndex, LongByReference pHandle); - }; - /** native declaration : headers\openvr_capi.h:1827 */ - public interface ReleaseVideoStreamingService_callback extends Callback { - int apply(long hTrackedCamera); - }; - /** native declaration : headers\openvr_capi.h:1828 */ - public interface GetVideoStreamFrameBuffer_callback extends Callback { - int apply(long hTrackedCamera, int eFrameType, Pointer pFrameBuffer, int nFrameBufferSize, CameraVideoStreamFrameHeader_t pFrameHeader, int nFrameHeaderSize); - }; - /** native declaration : headers\openvr_capi.h:1829 */ - public interface GetVideoStreamTextureSize_callback extends Callback { - int apply(int nDeviceIndex, int eFrameType, VRTextureBounds_t pTextureBounds, IntByReference pnWidth, IntByReference pnHeight); - }; - /** native declaration : headers\openvr_capi.h:1830 */ - public interface GetVideoStreamTextureD3D11_callback extends Callback { - int apply(long hTrackedCamera, int eFrameType, Pointer pD3D11DeviceOrResource, PointerByReference ppD3D11ShaderResourceView, CameraVideoStreamFrameHeader_t pFrameHeader, int nFrameHeaderSize); - }; - /** native declaration : headers\openvr_capi.h:1831 */ - public interface GetVideoStreamTextureGL_callback extends Callback { - int apply(long hTrackedCamera, int eFrameType, IntByReference pglTextureId, CameraVideoStreamFrameHeader_t pFrameHeader, int nFrameHeaderSize); - }; - /** native declaration : headers\openvr_capi.h:1832 */ - public interface ReleaseVideoStreamTextureGL_callback extends Callback { - int apply(long hTrackedCamera, int glTextureId); - }; - public VR_IVRTrackedCamera_FnTable() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("GetCameraErrorNameFromEnum", "HasCamera", "GetCameraFrameSize", "GetCameraIntrinsics", "GetCameraProjection", "AcquireVideoStreamingService", "ReleaseVideoStreamingService", "GetVideoStreamFrameBuffer", "GetVideoStreamTextureSize", "GetVideoStreamTextureD3D11", "GetVideoStreamTextureGL", "ReleaseVideoStreamTextureGL"); - } - public VR_IVRTrackedCamera_FnTable(Pointer peer) { - super(peer); - } - public static class ByReference extends VR_IVRTrackedCamera_FnTable implements Structure.ByReference { - - }; - public static class ByValue extends VR_IVRTrackedCamera_FnTable implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/lwjgl/EmptyKeyInput.java b/jme3-xr/src/main/java/com/jme3/system/lwjgl/EmptyKeyInput.java new file mode 100644 index 0000000000..79469e24dc --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/lwjgl/EmptyKeyInput.java @@ -0,0 +1,40 @@ +package com.jme3.system.lwjgl; + +import static org.lwjgl.glfw.GLFW.glfwGetTime; + +import com.jme3.input.KeyInput; +import com.jme3.input.RawInputListener; + +public class EmptyKeyInput implements KeyInput { + + public EmptyKeyInput() { } + @Override + public void initialize() {} + + @Override + public boolean isInitialized() {return false;} + + @Override + public void update() {} + @Override + public void destroy() { + // TODO Auto-generated method stub + + } + @Override + public void setInputListener(RawInputListener listener) { + // TODO Auto-generated method stub + + } + @Override + public long getInputTimeNanos() { + return (long) (glfwGetTime() * 1000000000); + } + @Override + public String getKeyName(int key) { + // TODO Auto-generated method stub + return null; + } + + public void resetContext() {} +} diff --git a/jme3-xr/src/main/java/com/jme3/system/lwjgl/EmptyMouseInput.java b/jme3-xr/src/main/java/com/jme3/system/lwjgl/EmptyMouseInput.java new file mode 100644 index 0000000000..f58570def6 --- /dev/null +++ b/jme3-xr/src/main/java/com/jme3/system/lwjgl/EmptyMouseInput.java @@ -0,0 +1,52 @@ +package com.jme3.system.lwjgl; + +import static org.lwjgl.glfw.GLFW.glfwGetTime; + +import com.jme3.cursors.plugins.JmeCursor; +import com.jme3.input.MouseInput; +import com.jme3.input.RawInputListener; + +public class EmptyMouseInput implements MouseInput { + + public EmptyMouseInput() { } + @Override + public void initialize() {} + + @Override + public boolean isInitialized() {return false;} + @Override + public void update() { + // TODO Auto-generated method stub + + } + @Override + public void destroy() { + // TODO Auto-generated method stub + + } + @Override + public void setInputListener(RawInputListener listener) { + // TODO Auto-generated method stub + + } + @Override + public long getInputTimeNanos() { + return (long) (glfwGetTime() * 1000000000); + } + @Override + public void setCursorVisible(boolean visible) { + // TODO Auto-generated method stub + + } + @Override + public int getButtonCount() { + // TODO Auto-generated method stub + return 3; + } + @Override + public void setNativeCursor(JmeCursor cursor) { + // TODO Auto-generated method stub + } + + public void resetContext() {} +} diff --git a/jme3-xr/src/main/java/com/jme3/system/lwjgl/LwjglContextVR.java b/jme3-xr/src/main/java/com/jme3/system/lwjgl/LwjglContextXr.java similarity index 58% rename from jme3-xr/src/main/java/com/jme3/system/lwjgl/LwjglContextVR.java rename to jme3-xr/src/main/java/com/jme3/system/lwjgl/LwjglContextXr.java index aa02e3ab19..fd1203fc5a 100644 --- a/jme3-xr/src/main/java/com/jme3/system/lwjgl/LwjglContextVR.java +++ b/jme3-xr/src/main/java/com/jme3/system/lwjgl/LwjglContextXr.java @@ -1,310 +1,352 @@ -package com.jme3.system.lwjgl; - -/* - * Copyright (c) 2009-2023 jMonkeyEngine - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'jMonkeyEngine' nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -import com.jme3.input.lwjgl.GlfwJoystickInput; -import com.jme3.input.lwjgl.GlfwKeyInputVR; -import com.jme3.input.lwjgl.GlfwMouseInputVR; -import com.jme3.renderer.Renderer; -import com.jme3.renderer.RendererException; -import com.jme3.renderer.lwjgl.LwjglGL; -import com.jme3.renderer.lwjgl.LwjglGLExt; -import com.jme3.renderer.lwjgl.LwjglGLFboEXT; -import com.jme3.renderer.lwjgl.LwjglGLFboGL3; -import com.jme3.renderer.opengl.*; -import com.jme3.system.*; - -import org.lwjgl.glfw.GLFW; -import org.lwjgl.opengl.ARBDebugOutput; -import org.lwjgl.opengl.ARBFramebufferObject; -import org.lwjgl.opengl.EXTFramebufferMultisample; -import org.lwjgl.opengl.GLCapabilities; - -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.logging.Level; -import java.util.logging.Logger; - -import static org.lwjgl.opengl.GL.createCapabilities; -import static org.lwjgl.opengl.GL11.glGetInteger; - -/** - * A VR oriented LWJGL implementation of a graphics context. - * @author reden - phr00t - https://github.com/phr00t - * @author Julien Seinturier - (c) 2016 - JOrigin project - http:/www.jorigin.org - */ -public abstract class LwjglContextVR implements JmeContext { - - private static final Logger logger = Logger.getLogger(LwjglContextVR.class.getName()); - - protected static final String THREAD_NAME = "jME3 Main"; - - protected AtomicBoolean created = new AtomicBoolean(false); - protected AtomicBoolean renderable = new AtomicBoolean(false); - protected final Object createdLock = new Object(); - - protected AppSettings settings = new AppSettings(true); - protected Renderer renderer; - protected GlfwKeyInputVR keyInput; - protected GlfwMouseInputVR mouseInput; - protected GlfwJoystickInput joyInput; - protected Timer timer; - protected SystemListener listener; - - /** - * Accesses the listener that receives events related to this context. - * - * @return the pre-existing instance - */ - @Override - public SystemListener getSystemListener() { - return listener; - } - - @Override - public void setSystemListener(SystemListener listener) { - this.listener = listener; - } - - protected void printContextInitInfo() { - logger.log(Level.INFO, "LWJGL {0} context running on thread {1}\n" - + " * Graphics Adapter: GLFW {2}", - new Object[]{Integer.toString(org.lwjgl.Version.VERSION_MAJOR), Thread.currentThread().getName(), GLFW.glfwGetVersionString()}); - } - - protected int determineMaxSamples() { - // If we already have a valid context, determine samples using current context. - logger.log(Level.SEVERE, "glfwExtensionSupported(\"GL_ARB_framebuffer_object\"): "+GLFW.glfwExtensionSupported("GL_ARB_framebuffer_object")); - logger.log(Level.SEVERE, "glfwExtensionSupported(\"GL_EXT_framebuffer_multisample\"): "+GLFW.glfwExtensionSupported("GL_ARB_framebuffer_object")); - - if (GLFW.glfwExtensionSupported("GL_ARB_framebuffer_object")) { - return glGetInteger(ARBFramebufferObject.GL_MAX_SAMPLES); - } else if (GLFW.glfwExtensionSupported("GL_EXT_framebuffer_multisample")) { - return glGetInteger(EXTFramebufferMultisample.GL_MAX_SAMPLES_EXT); - } - - return Integer.MAX_VALUE; - } - - protected void loadNatives() { - if (JmeSystem.isLowPermissions()) { - return; - } - - if ("LWJGL".equals(settings.getAudioRenderer())) { - NativeLibraryLoader.loadNativeLibrary("openal-lwjgl3", true); - } - - if (NativeLibraryLoader.isUsingNativeBullet()) { - NativeLibraryLoader.loadNativeLibrary("bulletjme", true); - } - - NativeLibraryLoader.loadNativeLibrary("glfw-lwjgl3", true); - NativeLibraryLoader.loadNativeLibrary("jemalloc-lwjgl3", true); - NativeLibraryLoader.loadNativeLibrary("lwjgl3", true); - } - - /** - * Check if the display is a retina display. - * @return true if the display is a retina display and false otherwise. - */ - public boolean isRetinaDisplay() { - return GLFW.glfwGetVersionString().contains("retina"); - } - - protected int getNumSamplesToUse() { - int samples = 0; - if (settings.getSamples() > 1) { - samples = settings.getSamples(); - final int supportedSamples = determineMaxSamples(); - if (supportedSamples < samples) { - logger.log(Level.WARNING, - "Couldn't satisfy antialiasing samples requirement: x{0}. " - + "Video hardware only supports: x{1}", - new Object[]{samples, supportedSamples}); - - samples = supportedSamples; - } - } - return samples; - } - - protected void initContextFirstTime() { - final GLCapabilities capabilities = createCapabilities(settings.getRenderer().equals(AppSettings.LWJGL_OPENGL32)); - - if (!capabilities.OpenGL20) { - throw new RendererException("OpenGL 2.0 or higher is required for jMonkeyEngine"); - } - - if (settings.getRenderer().equals(AppSettings.LWJGL_OPENGL2) - || settings.getRenderer().equals(AppSettings.LWJGL_OPENGL32)) { - GL gl = new LwjglGL(); - GLExt glext = new LwjglGLExt(); - GLFbo glfbo; - - if (capabilities.OpenGL30) { - glfbo = new LwjglGLFboGL3(); - } else { - glfbo = new LwjglGLFboEXT(); - } - - if (settings.isGraphicsDebug()) { - gl = (GL) GLDebug.createProxy(gl, gl, GL.class, GL2.class, GL3.class, GL4.class); - glext = (GLExt) GLDebug.createProxy(gl, glext, GLExt.class); - glfbo = (GLFbo) GLDebug.createProxy(gl, glfbo, GLFbo.class); - } - - if (settings.isGraphicsTiming()) { - GLTimingState timingState = new GLTimingState(); - gl = (GL) GLTiming.createGLTiming(gl, timingState, GL.class, GL2.class, GL3.class, GL4.class); - glext = (GLExt) GLTiming.createGLTiming(glext, timingState, GLExt.class); - glfbo = (GLFbo) GLTiming.createGLTiming(glfbo, timingState, GLFbo.class); - } - - if (settings.isGraphicsTrace()) { - gl = (GL) GLTracer.createDesktopGlTracer(gl, GL.class, GL2.class, GL3.class, GL4.class); - glext = (GLExt) GLTracer.createDesktopGlTracer(glext, GLExt.class); - glfbo = (GLFbo) GLTracer.createDesktopGlTracer(glfbo, GLFbo.class); - } - - renderer = new GLRenderer(gl, glext, glfbo); - renderer.initialize(); - } else { - throw new UnsupportedOperationException("Unsupported renderer: " + settings.getRenderer()); - } - - if (capabilities.GL_ARB_debug_output && settings.isGraphicsDebug()) { - ARBDebugOutput.glDebugMessageCallbackARB(new LwjglGLDebugOutputHandler(), 0); - } - - renderer.setMainFrameBufferSrgb(settings.isGammaCorrection()); - renderer.setLinearizeSrgbImages(settings.isGammaCorrection()); - - // Init input - if (keyInput != null) { - keyInput.initialize(); - } - - if (mouseInput != null) { - mouseInput.initialize(); - } - - if (joyInput != null) { - joyInput.initialize(); - } - renderable.set(true); - } - - /** - * Context internal destroy. - */ - public void internalDestroy() { - renderer = null; - timer = null; - renderable.set(false); - synchronized (createdLock) { - created.set(false); - createdLock.notifyAll(); - } - } - - /** - * Context internal create. - */ - public void internalCreate() { - synchronized (createdLock) { - created.set(true); - createdLock.notifyAll(); - } - - initContextFirstTime(); - } - - /** - * Create the context. - */ - public void create() { - create(false); - } - - /** - * Destroy the context. - */ - public void destroy() { - destroy(false); - } - - /** - * - * @param createdVal - */ - protected void waitFor(boolean createdVal) { - synchronized (createdLock) { - while (created.get() != createdVal) { - try { - createdLock.wait(); - } catch (InterruptedException ignored) { - } - } - } - } - - @Override - public boolean isCreated() { - return created.get(); - } - - @Override - public boolean isRenderable() { - return renderable.get(); - } - - @Override - public void setSettings(AppSettings settings) { - this.settings.copyFrom(settings); - } - - @Override - public AppSettings getSettings() { - return settings; - } - - @Override - public Renderer getRenderer() { - return renderer; - } - - @Override - public Timer getTimer() { - return timer; - } - -} +/* + * Copyright (c) 2009-2023 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package com.jme3.system.lwjgl; + +import com.jme3.input.lwjgl.GlfwJoystickInput; +import com.jme3.lwjgl3.utils.APIUtil; +import com.jme3.opencl.Context; +import com.jme3.renderer.Renderer; +import com.jme3.renderer.RendererException; +import com.jme3.renderer.lwjgl.LwjglGL; +import com.jme3.renderer.lwjgl.LwjglGLExt; +import com.jme3.renderer.lwjgl.LwjglGLFboEXT; +import com.jme3.renderer.lwjgl.LwjglGLFboGL3; +import com.jme3.renderer.opengl.*; +import com.jme3.system.AppSettings; +import com.jme3.system.JmeContext; +import com.jme3.system.SystemListener; +import com.jme3.system.Timer; +import com.jme3.util.BufferAllocatorFactory; +import com.jme3.util.LWJGLBufferAllocator; +import com.jme3.util.LWJGLBufferAllocator.ConcurrentLWJGLBufferAllocator; +import static com.jme3.util.LWJGLBufferAllocator.PROPERTY_CONCURRENT_BUFFER_ALLOCATOR; +import java.util.*; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.logging.Level; +import java.util.logging.Logger; +import org.lwjgl.Version; +import org.lwjgl.glfw.GLFW; +import org.lwjgl.glfw.GLFWJoystickCallback; +import org.lwjgl.opengl.ARBDebugOutput; +import org.lwjgl.opengl.ARBFramebufferObject; +import org.lwjgl.opengl.EXTFramebufferMultisample; +import static org.lwjgl.opengl.GL.createCapabilities; +import static org.lwjgl.opengl.GL11.glGetInteger; +import org.lwjgl.opengl.GLCapabilities; + +/** + * A LWJGL implementation of a graphics context. + */ +public abstract class LwjglContextXr implements JmeContext { + + private static final Logger logger = Logger.getLogger(LwjglContextXr.class.getName()); + + static { + + final String implementation = BufferAllocatorFactory.PROPERTY_BUFFER_ALLOCATOR_IMPLEMENTATION; + + if (System.getProperty(implementation) == null) { + if (Boolean.parseBoolean(System.getProperty(PROPERTY_CONCURRENT_BUFFER_ALLOCATOR, "true"))) { + System.setProperty(implementation, ConcurrentLWJGLBufferAllocator.class.getName()); + } else { + System.setProperty(implementation, LWJGLBufferAllocator.class.getName()); + } + } + } + + private static final Set SUPPORTED_RENDERS = new HashSet<>(Arrays.asList( + AppSettings.LWJGL_OPENGL2, + AppSettings.LWJGL_OPENGL30, + AppSettings.LWJGL_OPENGL31, + AppSettings.LWJGL_OPENGL32, + AppSettings.LWJGL_OPENGL33, + AppSettings.LWJGL_OPENGL40, + AppSettings.LWJGL_OPENGL41, + AppSettings.LWJGL_OPENGL42, + AppSettings.LWJGL_OPENGL43, + AppSettings.LWJGL_OPENGL44, + AppSettings.LWJGL_OPENGL45 + )); + + public static final boolean CL_GL_SHARING_POSSIBLE = true; + + protected final Object createdLock = new Object(); + protected final AtomicBoolean created = new AtomicBoolean(false); + protected final AtomicBoolean renderable = new AtomicBoolean(false); + protected final AppSettings settings = new AppSettings(true); + + protected EmptyKeyInput keyInput; + protected EmptyMouseInput mouseInput; + protected GlfwJoystickInput joyInput; + + protected Timer timer; + + protected Renderer renderer; + protected SystemListener listener; + + protected com.jme3.opencl.lwjgl.LwjglContext clContext; + + /** + * Accesses the listener that receives events related to this context. + * + * @return the pre-existing instance + */ + @Override + public SystemListener getSystemListener() { + return listener; + } + + @Override + public void setSystemListener(final SystemListener listener) { + this.listener = listener; + } + + protected void printContextInitInfo() { + if (logger.isLoggable(Level.INFO)) { + logger.log(Level.INFO, "LWJGL {0} context running on thread {1}\n * Graphics Adapter: GLFW {2}", + APIUtil.toArray(Version.getVersion(), Thread.currentThread().getName(), GLFW.glfwGetVersionString())); + } + } + + protected int determineMaxSamples() { + + // If we already have a valid context, determine samples using current context. + if (GLFW.glfwExtensionSupported("GL_ARB_framebuffer_object")) { + return glGetInteger(ARBFramebufferObject.GL_MAX_SAMPLES); + } else if (GLFW.glfwExtensionSupported("GL_EXT_framebuffer_multisample")) { + return glGetInteger(EXTFramebufferMultisample.GL_MAX_SAMPLES_EXT); + } + + return Integer.MAX_VALUE; + } + + protected int getNumSamplesToUse() { + + int samples = 0; + + if (settings.getSamples() > 1) { + samples = settings.getSamples(); + final int supportedSamples = determineMaxSamples(); + if (supportedSamples < samples) { + logger.log(Level.WARNING, "Couldn't satisfy antialiasing samples requirement: x{0}. " + + "Video hardware only supports: x{1}", APIUtil.toArray(samples, supportedSamples)); + samples = supportedSamples; + } + } + + return samples; + } + + /** + * Reinitializes the relevant details of the context. For internal use only. + */ + protected void reinitContext() { + initContext(false); + } + + /** + * Initializes the LWJGL renderer and input for the first time. For internal + * use only. + */ + protected void initContextFirstTime() { + initContext(true); + } + + /** + * Initializes the LWJGL renderer and input. + * @param first - Whether this is the first time we are initializing and we + * need to create the renderer or not. Otherwise, we'll just reset the + * renderer as needed. + */ + private void initContext(boolean first) { + + settings.setRenderer(AppSettings.LWJGL_OPENGL45); // We force Opengl4 as needed for openxr + final String renderer = settings.getRenderer(); + final GLCapabilities capabilities = createCapabilities(!renderer.equals(AppSettings.LWJGL_OPENGL2)); + + if (!capabilities.OpenGL20) { + throw new RendererException("OpenGL 2.0 or higher is required for jMonkeyEngine"); + } else if (!SUPPORTED_RENDERS.contains(renderer)) { + throw new UnsupportedOperationException("Unsupported renderer: " + renderer); + } + + if (first) { + GL gl = new LwjglGL(); + GLExt glext = new LwjglGLExt(); + GLFbo glfbo; + + if (capabilities.OpenGL30) { + glfbo = new LwjglGLFboGL3(); + } else { + glfbo = new LwjglGLFboEXT(); + } + + if (settings.isGraphicsDebug()) { + gl = (GL) GLDebug.createProxy(gl, gl, GL.class, GL2.class, GL3.class, GL4.class); + glext = (GLExt) GLDebug.createProxy(gl, glext, GLExt.class); + glfbo = (GLFbo) GLDebug.createProxy(gl, glfbo, GLFbo.class); + } + + if (settings.isGraphicsTiming()) { + GLTimingState timingState = new GLTimingState(); + gl = (GL) GLTiming.createGLTiming(gl, timingState, GL.class, GL2.class, GL3.class, GL4.class); + glext = (GLExt) GLTiming.createGLTiming(glext, timingState, GLExt.class); + glfbo = (GLFbo) GLTiming.createGLTiming(glfbo, timingState, GLFbo.class); + } + + if (settings.isGraphicsTrace()) { + gl = (GL) GLTracer.createDesktopGlTracer(gl, GL.class, GL2.class, GL3.class, GL4.class); + glext = (GLExt) GLTracer.createDesktopGlTracer(glext, GLExt.class); + glfbo = (GLFbo) GLTracer.createDesktopGlTracer(glfbo, GLFbo.class); + } + + this.renderer = new GLRenderer(gl, glext, glfbo); + if (this.settings.isGraphicsDebug()) ((GLRenderer)this.renderer).setDebugEnabled(true); + } + this.renderer.initialize(); + + if (capabilities.GL_ARB_debug_output && settings.isGraphicsDebug()) { + ARBDebugOutput.glDebugMessageCallbackARB(new LwjglGLDebugOutputHandler(), 0); + } + + this.renderer.setMainFrameBufferSrgb(settings.isGammaCorrection()); + this.renderer.setLinearizeSrgbImages(settings.isGammaCorrection()); + + if (first) { + // Init input + if (keyInput != null) { + keyInput.initialize(); + } + + if (mouseInput != null) { + mouseInput.initialize(); + } + + if (joyInput != null) { + joyInput.initialize(); + } + + GLFW.glfwSetJoystickCallback(new GLFWJoystickCallback() { + @Override + public void invoke(int jid, int event) { + + // Invoke the disconnected event before we reload the joysticks or lose the reference to it. + // Invoke the connected event after we reload the joysticks to obtain the reference to it. + + if ( event == GLFW.GLFW_CONNECTED ) { + joyInput.reloadJoysticks(); + joyInput.fireJoystickConnectedEvent(jid); + } + else { + joyInput.fireJoystickDisconnectedEvent(jid); + joyInput.reloadJoysticks(); + } + } + }); + } + + renderable.set(true); + } + + public void internalDestroy() { + renderer = null; + timer = null; + renderable.set(false); + synchronized (createdLock) { + created.set(false); + createdLock.notifyAll(); + } + } + + public void internalCreate() { + synchronized (createdLock) { + created.set(true); + createdLock.notifyAll(); + } + initContextFirstTime(); + } + + public void create() { + create(false); + } + + public void destroy() { + destroy(false); + } + + protected void waitFor(boolean createdVal) { + synchronized (createdLock) { + while (created.get() != createdVal) { + try { + createdLock.wait(); + } catch (InterruptedException ignored) { + } + } + } + } + + @Override + public boolean isCreated() { + return created.get(); + } + + @Override + public boolean isRenderable() { + return renderable.get(); + } + + @Override + public void setSettings(AppSettings settings) { + this.settings.copyFrom(settings); + } + + @Override + public AppSettings getSettings() { + return settings; + } + + @Override + public Renderer getRenderer() { + return renderer; + } + + @Override + public Timer getTimer() { + return timer; + } + + @Override + public Context getOpenCLContext() { + return clContext; + } +} diff --git a/jme3-xr/src/main/java/com/jme3/system/lwjgl/LwjglDisplayVR.java b/jme3-xr/src/main/java/com/jme3/system/lwjgl/LwjglDisplayVR.java deleted file mode 100644 index 5df00bf08f..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/lwjgl/LwjglDisplayVR.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2009-2012 jMonkeyEngine - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'jMonkeyEngine' nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package com.jme3.system.lwjgl; - -import com.jme3.opencl.Context; - -/** - * A VR oriented LWJGL display. - * @author Daniel Johansson - * @author reden - phr00t - https://github.com/phr00t - * @author Julien Seinturier - (c) 2016 - JOrigin project - http:/www.jorigin.org - */ -public class LwjglDisplayVR extends LwjglWindowVR { - /** - * Create a new VR oriented LWJGL display. - */ - public LwjglDisplayVR() { - super(Type.Display); - } - - @Override - public Context getOpenCLContext() { - return null; - } -} diff --git a/jme3-xr/src/main/java/com/jme3/system/lwjgl/LwjglOffscreenBufferVR.java b/jme3-xr/src/main/java/com/jme3/system/lwjgl/LwjglOffscreenBufferVR.java deleted file mode 100644 index 234d36d8de..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/lwjgl/LwjglOffscreenBufferVR.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.jme3.system.lwjgl; - -/* - * Copyright (c) 2009-2012 jMonkeyEngine - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'jMonkeyEngine' nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import com.jme3.system.JmeContext; - -/** - * A VR oriented LWJGL offscreen buffer. - * @author Daniel Johansson - * @author reden - phr00t - https://github.com/phr00t - * @author Julien Seinturier - (c) 2016 - JOrigin project - http:/www.jorigin.org - */ -public class LwjglOffscreenBufferVR extends LwjglWindow { - /** - * Create a new VR oriented LWJGL offscreen buffer. - */ - public LwjglOffscreenBufferVR() { - super(JmeContext.Type.OffscreenSurface); - } -} diff --git a/jme3-xr/src/main/java/com/jme3/system/lwjgl/LwjglWindowVR.java b/jme3-xr/src/main/java/com/jme3/system/lwjgl/LwjglWindowXr.java similarity index 54% rename from jme3-xr/src/main/java/com/jme3/system/lwjgl/LwjglWindowVR.java rename to jme3-xr/src/main/java/com/jme3/system/lwjgl/LwjglWindowXr.java index 5c21cd6e92..1eb341f045 100644 --- a/jme3-xr/src/main/java/com/jme3/system/lwjgl/LwjglWindowVR.java +++ b/jme3-xr/src/main/java/com/jme3/system/lwjgl/LwjglWindowXr.java @@ -1,621 +1,667 @@ -package com.jme3.system.lwjgl; - -/* - * Copyright (c) 2009-2023 jMonkeyEngine - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'jMonkeyEngine' nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import com.jme3.input.JoyInput; -import com.jme3.input.KeyInput; -import com.jme3.input.MouseInput; -import com.jme3.input.TouchInput; -import com.jme3.input.lwjgl.GlfwJoystickInput; -import com.jme3.input.lwjgl.GlfwKeyInputVR; -import com.jme3.input.lwjgl.GlfwMouseInputVR; -import com.jme3.system.AppSettings; -import com.jme3.system.JmeContext; -import com.jme3.system.JmeSystem; -import com.jme3.system.NanoTimer; - -import org.lwjgl.glfw.*; - -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.logging.Level; -import java.util.logging.Logger; -import org.lwjgl.Version; - -import static org.lwjgl.glfw.GLFW.*; -import static org.lwjgl.opengl.GL11.GL_FALSE; -import static org.lwjgl.system.MemoryUtil.NULL; - -/** - * A wrapper class over the GLFW framework in LWJGL 3. - * - * @author Daniel Johansson - * @author reden - phr00t - https://github.com/phr00t - * @author Julien Seinturier - (c) 2016 - JOrigin project - http:/www.jorigin.org - */ -public abstract class LwjglWindowVR extends LwjglContextVR implements Runnable { - - private static final Logger LOGGER = Logger.getLogger(LwjglWindowVR.class.getName()); - - protected AtomicBoolean needClose = new AtomicBoolean(false); - protected final AtomicBoolean needRestart = new AtomicBoolean(false); - protected boolean wasActive = false; - protected boolean autoFlush = true; - protected boolean allowSwapBuffers = false; - private long window = NULL; - private final JmeContext.Type type; - private int frameRateLimit = -1; - private double frameSleepTime; - - private GLFWErrorCallback errorCallback; - private GLFWWindowSizeCallback windowSizeCallback; - private GLFWWindowFocusCallback windowFocusCallback; - private Thread mainThread; - - // reusable arrays for GLFW calls - final private int width[] = new int[1]; - final private int height[] = new int[1]; - - /** - * Create a new wrapper class over the GLFW framework in LWJGL 3. - * @param type the {@link com.jme3.system.JmeContext.Type type} of the display. - */ - public LwjglWindowVR(final JmeContext.Type type) { - if (!JmeContext.Type.Display.equals(type) && !JmeContext.Type.OffscreenSurface.equals(type) && !JmeContext.Type.Canvas.equals(type)) { - throw new IllegalArgumentException("Unsupported type '" + type.name() + "' provided"); - } - - this.type = type; - } - - /** - * @return Type.Display or Type.Canvas - */ - @Override - public JmeContext.Type getType() { - return type; - } - - /** - * Set the title if it's a windowed display - * - * @param title the title to set - */ - @Override - public void setTitle(final String title) { - if (created.get() && window != NULL) { - glfwSetWindowTitle(window, title); - } - } - - /** - * Restart if it's a windowed or full-screen display. - */ - @Override - public void restart() { - if (created.get()) { - needRestart.set(true); - } else { - LOGGER.warning("Display is not created, cannot restart window."); - } - } - - /** - * Apply the settings, changing resolution, etc. - * - * @param settings the settings to apply when creating the context. - */ - protected void createContext(final AppSettings settings) { - glfwSetErrorCallback(errorCallback = new GLFWErrorCallback() { - @Override - public void invoke(int error, long description) { - final String message = GLFWErrorCallback.getDescription(description); - listener.handleError(message, new Exception(message)); - } - }); - - if ( glfwInit() == false ) { - throw new IllegalStateException("Unable to initialize GLFW"); - } - - glfwDefaultWindowHints(); - - // just use defaults, which should provide the best compatibility - /*if (settings.getRenderer().equals(AppSettings.LWJGL_OPENGL3)) { - glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); - glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_FALSE); - glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); - glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); - } else { - glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2); - glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); - }*/ - - if (settings.getBoolean("RendererDebug")) { - glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GLFW_TRUE); - } - - if (settings.isGammaCorrection()) { - glfwWindowHint(GLFW_SRGB_CAPABLE, GLFW_TRUE); - } - - glfwWindowHint(GLFW_VISIBLE, GL_FALSE); - glfwWindowHint(GLFW_RESIZABLE, settings.isResizable() ? GLFW_TRUE : GLFW_FALSE); - glfwWindowHint(GLFW_DOUBLEBUFFER, GLFW_TRUE); - glfwWindowHint(GLFW_DEPTH_BITS, settings.getDepthBits()); - glfwWindowHint(GLFW_STENCIL_BITS, settings.getStencilBits()); - glfwWindowHint(GLFW_SAMPLES, settings.getSamples()); - glfwWindowHint(GLFW_STEREO, settings.useStereo3D() ? GLFW_TRUE : GLFW_FALSE); - glfwWindowHint(GLFW_REFRESH_RATE, settings.getFrequency()); - - if (settings.getBitsPerPixel() == 24) { - glfwWindowHint(GLFW_RED_BITS, 8); - glfwWindowHint(GLFW_GREEN_BITS, 8); - glfwWindowHint(GLFW_BLUE_BITS, 8); - } else if (settings.getBitsPerPixel() == 16) { - glfwWindowHint(GLFW_RED_BITS, 5); - glfwWindowHint(GLFW_GREEN_BITS, 6); - glfwWindowHint(GLFW_BLUE_BITS, 5); - } - - glfwWindowHint(GLFW_ALPHA_BITS, settings.getAlphaBits()); - - // TODO: Add support for monitor selection - long monitor = NULL; - - if (settings.isFullscreen()) { - monitor = glfwGetPrimaryMonitor(); - } - - final GLFWVidMode videoMode = glfwGetVideoMode(glfwGetPrimaryMonitor()); - - if (settings.getWidth() <= 0 || settings.getHeight() <= 0) { - settings.setResolution(videoMode.width(), videoMode.height()); - } - - window = glfwCreateWindow(settings.getWidth(), settings.getHeight(), settings.getTitle(), monitor, NULL); - - if (window == NULL) { - throw new RuntimeException("Failed to create the GLFW window"); - } - - glfwSetWindowFocusCallback(window, windowFocusCallback = new GLFWWindowFocusCallback() { - - @Override - public void invoke(long window, boolean focused) { - if (wasActive != focused) { - if (wasActive == false) { - listener.gainFocus(); - timer.reset(); - wasActive = true; - } else { - listener.loseFocus(); - wasActive = false; - } - } - } - }); - - // Center the window - if( Type.Display.equals(type) ) { - if (!settings.isFullscreen()) { - glfwSetWindowPos(window, - (videoMode.width() - settings.getWidth()) / 2, - (videoMode.height() - settings.getHeight()) / 2); - } - } - - // Make the OpenGL context current - glfwMakeContextCurrent(window); - - // Enable vsync - if (settings.isVSync()) { - glfwSwapInterval(1); - } else { - glfwSwapInterval(0); - } - - // Make the window visible - if (Type.Display.equals(type)) { - glfwShowWindow(window); - glfwFocusWindow(window); - } - - // Add a resize callback which delegates to the listener - glfwSetWindowSizeCallback(window, windowSizeCallback = new GLFWWindowSizeCallback() { - @Override - public void invoke(final long window, final int width, final int height) { - settings.setResolution(width, height); - listener.reshape(width, height); - } - }); - - allowSwapBuffers = settings.isSwapBuffers(); - - // TODO: When GLFW 3.2 is released and included in LWJGL 3.x then we should hopefully be able to set the window icon. - } - - /** - * Destroy the context. - */ - protected void destroyContext() { - try { - if (renderer != null) { - renderer.cleanup(); - } - - if (errorCallback != null) { - errorCallback.free(); - errorCallback = null; - } - - if (windowSizeCallback != null) { - windowSizeCallback.free(); - windowSizeCallback = null; - } - - if (windowFocusCallback != null) { - windowFocusCallback.free(); - windowFocusCallback = null; - } - - if (window != NULL) { - glfwDestroyWindow(window); - window = NULL; - } - } catch (Exception ex) { - listener.handleError("Failed to destroy context", ex); - } - } - - @Override - public void create(boolean waitFor) { - if (created.get()) { - LOGGER.warning("create() called when display is already created!"); - return; - } - - mainThread = Thread.currentThread(); - run(); - } - - /** - * Does LWJGL display initialization in the OpenGL thread - */ - protected boolean initInThread() { - try { - if (!JmeSystem.isLowPermissions()) { - // Enable uncaught exception handler only for current thread - Thread.currentThread().setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { - @Override - public void uncaughtException(Thread thread, Throwable thrown) { - listener.handleError("Uncaught exception thrown in " + thread.toString(), thrown); - if (needClose.get()) { - // listener.handleError() has requested the - // context to close. Satisfy request. - deinitInThread(); - } - } - }); - } - - loadNatives(); - timer = new NanoTimer(); - - // For canvas, this will create a PBuffer, - // allowing us to query information. - // When the canvas context becomes available, it will - // be replaced seamlessly. - createContext(settings); - printContextInitInfo(); - - created.set(true); - super.internalCreate(); - } catch (Exception ex) { - try { - if (window != NULL) { - glfwDestroyWindow(window); - window = NULL; - } - } catch (Exception ex2) { - LOGGER.log(Level.WARNING, null, ex2); - } - - listener.handleError("Failed to create display", ex); - return false; // if we failed to create display, do not continue - } - - listener.initialize(); - return true; - } - - /** - * execute one iteration of the render loop in the OpenGL thread - */ - protected void runLoop() { - // If a restart is required, lets recreate the context. - if (needRestart.getAndSet(false)) { - try { - destroyContext(); - createContext(settings); - } catch (Exception ex) { - LOGGER.log(Level.SEVERE, "Failed to set display settings!", ex); - } - - LOGGER.fine("Display restarted."); - } - - if (!created.get()) { - throw new IllegalStateException(); - } - - listener.update(); - - // All this does is call glfwSwapBuffers(). - // If the canvas is not active, there's no need to waste time - // doing that. - if (renderable.get()) { - // calls swap buffers, etc. - try { - if (allowSwapBuffers && autoFlush) { - glfwSwapBuffers(window); - } - } catch (Throwable ex) { - listener.handleError("Error while swapping buffers", ex); - } - } - - // Subclasses just call GLObjectManager. Clean up objects here. - // It is safe ... for now. - if (renderer != null) { - renderer.postFrame(); - } - - if (autoFlush) { - if (frameRateLimit != getSettings().getFrameRate()) { - setFrameRateLimit(getSettings().getFrameRate()); - } - } else if (frameRateLimit != 20) { - setFrameRateLimit(20); - } - - // If software frame rate limiting has been asked for, lets calculate sleep time based on a base value calculated - // from 1000 / frameRateLimit in milliseconds subtracting the time it has taken to render last frame. - // This gives an approximate limit within 3 fps of the given frame rate limit. - if (frameRateLimit > 0) { - final double sleep = frameSleepTime - (timer.getTimePerFrame() / 1000.0); - final long sleepMillis = (long) sleep; - final int additionalNanos = (int) ((sleep - sleepMillis) * 1000000.0); - - if (sleepMillis >= 0 && additionalNanos >= 0) { - try { - Thread.sleep(sleepMillis, additionalNanos); - } catch (InterruptedException ignored) { - } - } - } - - glfwPollEvents(); - } - - private void setFrameRateLimit(int frameRateLimit) { - this.frameRateLimit = frameRateLimit; - frameSleepTime = 1000.0 / this.frameRateLimit; - } - - /** - * De-initialize in the OpenGL thread. - */ - - protected void deinitInThread() { - listener.destroy(); - - destroyContext(); - super.internalDestroy(); - - LOGGER.fine("Display destroyed."); - } - - @Override - public void run() { - if (listener == null) { - throw new IllegalStateException("SystemListener is not set on context!" - + "Must set with JmeContext.setSystemListener()."); - } - - LOGGER.log(Level.FINE, "Using LWJGL {0}", Version.getVersion()); - - if (!initInThread()) { - LOGGER.log(Level.SEVERE, "Display initialization failed. Cannot continue."); - return; - } - - while (true) { - - runLoop(); - - if (needClose.get()) { - break; - } - - if (glfwWindowShouldClose(window) == true) { - listener.requestClose(false); - } - } - - deinitInThread(); - } - - @Override - public JoyInput getJoyInput() { - if (joyInput == null) { - joyInput = new GlfwJoystickInput(); - } - return joyInput; - } - - @Override - public MouseInput getMouseInput() { - if (mouseInput == null) { - mouseInput = new GlfwMouseInputVR(this); - } - return mouseInput; - } - - @Override - public KeyInput getKeyInput() { - if (keyInput == null) { - keyInput = new GlfwKeyInputVR(this); - } - - return keyInput; - } - - @Override - public TouchInput getTouchInput() { - return null; - } - - @Override - public void setAutoFlushFrames(boolean enabled) { - this.autoFlush = enabled; - } - - @Override - public void destroy(boolean waitFor) { - needClose.set(true); - if (mainThread == Thread.currentThread()) { - // Ignore waitFor. - return; - } - - if (waitFor) { - waitFor(false); - } - } - - /** - * Get the window handle. - * @return the window handle as an internal GLFW identifier. - */ - public long getWindowHandle() { - return window; - } - - /** - * Returns the height of the framebuffer. - * - * @return the height (in pixels) - */ - @Override - public int getFramebufferHeight() { - glfwGetFramebufferSize(window, width, height); - int result = height[0]; - return result; - } - - /** - * Returns the width of the framebuffer. - * - * @return the width (in pixels) - */ - @Override - public int getFramebufferWidth() { - glfwGetFramebufferSize(window, width, height); - int result = width[0]; - return result; - } - - /** - * Returns the screen X coordinate of the left edge of the content area. - * - * @return the screen X coordinate - */ - @Override - public int getWindowXPosition() { - glfwGetWindowPos(window, width, height); - int result = width[0]; - return result; - } - - /** - * Returns the screen Y coordinate of the top edge of the content area. - * - * @return the screen Y coordinate - */ - @Override - public int getWindowYPosition() { - glfwGetWindowPos(window, width, height); - int result = height[0]; - return result; - } - - // TODO: Implement support for window icon when GLFW supports it. - /* - private ByteBuffer[] imagesToByteBuffers(Object[] images) { - ByteBuffer[] out = new ByteBuffer[images.length]; - for (int i = 0; i < images.length; i++) { - BufferedImage image = (BufferedImage) images[i]; - out[i] = imageToByteBuffer(image); - } - return out; - } - - private ByteBuffer imageToByteBuffer(BufferedImage image) { - if (image.getType() != BufferedImage.TYPE_INT_ARGB_PRE) { - BufferedImage convertedImage = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_ARGB_PRE); - Graphics2D g = convertedImage.createGraphics(); - double width = image.getWidth() * (double) 1; - double height = image.getHeight() * (double) 1; - g.drawImage(image, (int) ((convertedImage.getWidth() - width) / 2), - (int) ((convertedImage.getHeight() - height) / 2), - (int) (width), (int) (height), null); - g.dispose(); - image = convertedImage; - } - - byte[] imageBuffer = new byte[image.getWidth() * image.getHeight() * 4]; - int counter = 0; - for (int i = 0; i < image.getHeight(); i++) { - for (int j = 0; j < image.getWidth(); j++) { - int colorSpace = image.getRGB(j, i); - imageBuffer[counter + 0] = (byte) ((colorSpace << 8) >> 24); - imageBuffer[counter + 1] = (byte) ((colorSpace << 16) >> 24); - imageBuffer[counter + 2] = (byte) ((colorSpace << 24) >> 24); - imageBuffer[counter + 3] = (byte) (colorSpace >> 24); - counter += 4; - } - } - return ByteBuffer.wrap(imageBuffer); - } - */ -} +/* + * Copyright (c) 2009-2023 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package com.jme3.system.lwjgl; + +import com.jme3.input.JoyInput; +import com.jme3.input.KeyInput; +import com.jme3.input.MouseInput; +import com.jme3.input.TouchInput; +import com.jme3.input.lwjgl.GlfwJoystickInput; +import com.jme3.math.Vector2f; +import com.jme3.system.AppSettings; +import com.jme3.system.JmeContext; +import com.jme3.system.JmeSystem; +import com.jme3.system.NanoTimer; +import com.jme3.util.BufferUtils; +import com.jme3.util.SafeArrayList; +import com.jme3.system.lwjgl.openxr.HelloOpenXRGL; + +import org.lwjgl.Version; +import org.lwjgl.glfw.GLFWErrorCallback; +import org.lwjgl.glfw.GLFWFramebufferSizeCallback; +import org.lwjgl.glfw.GLFWImage; +import org.lwjgl.glfw.GLFWWindowFocusCallback; +import org.lwjgl.glfw.GLFWWindowSizeCallback; +import org.lwjgl.system.Platform; + +import java.awt.Graphics2D; +import java.awt.image.BufferedImage; +import java.nio.ByteBuffer; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.logging.Level; +import java.util.logging.Logger; + +import static org.lwjgl.glfw.GLFW.*; +import static org.lwjgl.system.MemoryUtil.NULL; + +/** + * A wrapper class over the GLFW framework in LWJGL 3. + * + * @author Daniel Johansson + */ +public class LwjglWindowXr extends LwjglContextXr implements Runnable { + + private static final Logger LOGGER = Logger.getLogger(LwjglWindowXr.class.getName()); + + private static final Map RENDER_CONFIGS = new HashMap<>(); + + static { + RENDER_CONFIGS.put(AppSettings.LWJGL_OPENGL30, () -> { + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); + }); + RENDER_CONFIGS.put(AppSettings.LWJGL_OPENGL31, () -> { + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1); + }); + RENDER_CONFIGS.put(AppSettings.LWJGL_OPENGL32, () -> { + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); + }); + RENDER_CONFIGS.put(AppSettings.LWJGL_OPENGL33, () -> { + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); + }); + RENDER_CONFIGS.put(AppSettings.LWJGL_OPENGL40, () -> { + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); + }); + RENDER_CONFIGS.put(AppSettings.LWJGL_OPENGL41, () -> { + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1); + }); + RENDER_CONFIGS.put(AppSettings.LWJGL_OPENGL42, () -> { + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); + }); + RENDER_CONFIGS.put(AppSettings.LWJGL_OPENGL43, () -> { + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); + }); + RENDER_CONFIGS.put(AppSettings.LWJGL_OPENGL44, () -> { + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 4); + }); + RENDER_CONFIGS.put(AppSettings.LWJGL_OPENGL45, () -> { + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 5); + }); + } + + protected final AtomicBoolean needClose = new AtomicBoolean(false); + protected final AtomicBoolean needRestart = new AtomicBoolean(false); + + private final JmeContext.Type type; + private final SafeArrayList windowSizeListeners = new SafeArrayList<>(WindowSizeListener.class); + + private GLFWErrorCallback errorCallback; + private GLFWWindowSizeCallback windowSizeCallback; + private GLFWFramebufferSizeCallback framebufferSizeCallback; + private GLFWWindowFocusCallback windowFocusCallback; + + HelloOpenXRGL xr; + + private Thread mainThread; + + private long window = NULL; + private int frameRateLimit = -1; + + protected boolean wasActive = false; + protected boolean autoFlush = true; + protected boolean allowSwapBuffers = false; + + // temp variables used for glfw calls + private int width[] = new int[1]; + private int height[] = new int[1]; + + public LwjglWindowXr() { + this.type = JmeContext.Type.Display; + } + + public HelloOpenXRGL getXr() { return xr; } + + /** + * Registers the specified listener to get notified when window size changes. + * + * @param listener The WindowSizeListener to register. + */ + public void registerWindowSizeListener(WindowSizeListener listener) { + windowSizeListeners.add(listener); + } + + /** + * Removes the specified listener from the listeners list. + * + * @param listener The WindowSizeListener to remove. + */ + public void removeWindowSizeListener(WindowSizeListener listener) { + windowSizeListeners.remove(listener); + } + + /** + * @return Type.Display or Type.Canvas + */ + @Override + public JmeContext.Type getType() { + return type; + } + + /** + * Set the title if it's a windowed display + * + * @param title the title to set + */ + @Override + public void setTitle(final String title) { + if (created.get() && window != NULL) { + glfwSetWindowTitle(window, title); + } + } + + /** + * Restart if it's a windowed or full-screen display. + */ + @Override + public void restart() { + if (created.get()) { + needRestart.set(true); + } else { + LOGGER.warning("Display is not created, cannot restart window."); + } + } + + /** + * Apply the settings, changing resolution, etc. + * + * @param settings the settings to apply when creating the context. + */ + protected void createContext(final AppSettings settings) { + + glfwSetErrorCallback(errorCallback = new GLFWErrorCallback() { + @Override + public void invoke(int error, long description) { + final String message = GLFWErrorCallback.getDescription(description); + listener.handleError(message, new Exception(message)); + } + }); +System.out.println("Pre init xr"); +xr = new HelloOpenXRGL(settings); +System.out.println("Post init xr"); +window = xr.getWindow(); + } + + + protected void showWindow() { + glfwShowWindow(window); + } + + /** + * Set custom icons to the window of this application. + * + * @param settings settings for getting the icons + */ + protected void setWindowIcon(final AppSettings settings) { + + final Object[] icons = settings.getIcons(); + if (icons == null) return; + + final GLFWImage[] images = imagesToGLFWImages(icons); + + try (final GLFWImage.Buffer iconSet = GLFWImage.malloc(images.length)) { + + for (int i = images.length - 1; i >= 0; i--) { + final GLFWImage image = images[i]; + iconSet.put(i, image); + } + + glfwSetWindowIcon(window, iconSet); + } + } + + /** + * Convert array of images to array of {@link GLFWImage}. + */ + private GLFWImage[] imagesToGLFWImages(final Object[] images) { + + final GLFWImage[] out = new GLFWImage[images.length]; + + for (int i = 0; i < images.length; i++) { + final BufferedImage image = (BufferedImage) images[i]; + out[i] = imageToGLFWImage(image); + } + + return out; + } + + /** + * Convert the {@link BufferedImage} to the {@link GLFWImage}. + */ + private GLFWImage imageToGLFWImage(BufferedImage image) { + + if (image.getType() != BufferedImage.TYPE_INT_ARGB_PRE) { + + final BufferedImage convertedImage = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_ARGB_PRE); + final Graphics2D graphics = convertedImage.createGraphics(); + + final int targetWidth = image.getWidth(); + final int targetHeight = image.getHeight(); + + graphics.drawImage(image, 0, 0, targetWidth, targetHeight, null); + graphics.dispose(); + + image = convertedImage; + } + + final ByteBuffer buffer = BufferUtils.createByteBuffer(image.getWidth() * image.getHeight() * 4); + + for (int i = 0; i < image.getHeight(); i++) { + for (int j = 0; j < image.getWidth(); j++) { + int colorSpace = image.getRGB(j, i); + buffer.put((byte) ((colorSpace << 8) >> 24)); + buffer.put((byte) ((colorSpace << 16) >> 24)); + buffer.put((byte) ((colorSpace << 24) >> 24)); + buffer.put((byte) (colorSpace >> 24)); + } + } + + buffer.flip(); + + final GLFWImage result = GLFWImage.create(); + result.set(image.getWidth(), image.getHeight(), buffer); + + return result; + } + + /** + * Destroy the context. + */ + protected void destroyContext() { + try { + if (renderer != null) { + renderer.cleanup(); + } + + if (errorCallback != null) { + + // We need to specifically set this to null as we might set a new callback before we reinit GLFW + glfwSetErrorCallback(null); + + errorCallback.close(); + errorCallback = null; + } + + if (windowSizeCallback != null) { + windowSizeCallback.close(); + windowSizeCallback = null; + } + + if (framebufferSizeCallback != null) { + framebufferSizeCallback.close(); + framebufferSizeCallback = null; + } + + if (windowFocusCallback != null) { + windowFocusCallback.close(); + windowFocusCallback = null; + } + + if (window != NULL) { + glfwDestroyWindow(window); + window = NULL; + } + + } catch (final Exception ex) { + listener.handleError("Failed to destroy context", ex); + } + } + + @Override + public void create(boolean waitFor) { + if (created.get()) { + LOGGER.warning("create() called when display is already created!"); + return; + } + + if (Platform.get() == Platform.MACOSX) { + // NOTE: this is required for Mac OS X! + mainThread = Thread.currentThread(); + mainThread.setName("jME3 Main"); + if (waitFor) { + LOGGER.warning("create(true) is not supported for macOS!"); + } + run(); + } else { + mainThread = new Thread(this, "jME3 Main"); + mainThread.start(); + if (waitFor) { + waitFor(true); + } + } + + } + + /** + * Does LWJGL display initialization in the OpenGL thread + * + * @return returns {@code true} if the context initialization was successful + */ + protected boolean initInThread() { + try { + if (!JmeSystem.isLowPermissions()) { + // Enable uncaught exception handler only for current thread + Thread.currentThread().setUncaughtExceptionHandler((thread, thrown) -> { + listener.handleError("Uncaught exception thrown in " + thread.toString(), thrown); + if (needClose.get()) { + // listener.handleError() has requested the + // context to close. Satisfy request. + deinitInThread(); + } + }); + } + + timer = new NanoTimer(); + + // For canvas, this will create a PBuffer, + // allowing us to query information. + // When the canvas context becomes available, it will + // be replaced seamlessly. + createContext(settings); + printContextInitInfo(); + + created.set(true); + super.internalCreate(); //Try + } catch (Exception ex) { + try { + if (window != NULL) { + glfwDestroyWindow(window); + window = NULL; + } + } catch (Exception ex2) { + LOGGER.log(Level.WARNING, null, ex2); + } + + listener.handleError("Failed to create display", ex); + return false; // if we failed to create display, do not continue + } + + listener.initialize(); + + return true; + } + + + /** + * execute one iteration of the render loop in the OpenGL thread + */ + protected void runLoop() { + // If a restart is required, lets recreate the context. + if (needRestart.getAndSet(false)) { + restartContext(); + } + + if (!created.get()) { + throw new IllegalStateException(); + } + + + listener.update(); + + // All this does is call glfwSwapBuffers(). + // If the canvas is not active, there's no need to waste time + // doing that. + if (renderable.get()) { + // calls swap buffers, etc. + try { + if (allowSwapBuffers && autoFlush) { + glfwSwapBuffers(window); + } + } catch (Throwable ex) { + listener.handleError("Error while swapping buffers", ex); + } + } + xr.renderFrame(); + + // Subclasses just call GLObjectManager. Clean up objects here. + // It is safe ... for now. + if (renderer != null) { + renderer.postFrame(); + } + + if (autoFlush) { + if (frameRateLimit != getSettings().getFrameRate()) { + setFrameRateLimit(getSettings().getFrameRate()); + } + } else if (frameRateLimit != 20) { + setFrameRateLimit(20); + } + + Sync.sync(frameRateLimit); + + glfwPollEvents(); + } + + private void restartContext() { + try { + destroyContext(); + createContext(settings); + } catch (Exception ex) { + LOGGER.log(Level.SEVERE, "Failed to set display settings!", ex); + } + // Reinitialize context flags and such + reinitContext(); + + // We need to reinit the mouse and keyboard input as they are tied to a window handle + if (keyInput != null && keyInput.isInitialized()) { + keyInput.resetContext(); + } + if (mouseInput != null && mouseInput.isInitialized()) { + mouseInput.resetContext(); + } + + LOGGER.fine("Display restarted."); + } + + private void setFrameRateLimit(int frameRateLimit) { + this.frameRateLimit = frameRateLimit; + } + + /** + * De-initialize in the OpenGL thread. + */ + protected void deinitInThread() { + listener.destroy(); + + destroyContext(); + super.internalDestroy(); + glfwTerminate(); + + LOGGER.fine("Display destroyed."); + } + + @Override + public void run() { + if (listener == null) { + throw new IllegalStateException("SystemListener is not set on context!" + + "Must set with JmeContext.setSystemListener()."); + } + + LOGGER.log(Level.FINE, "Using LWJGL {0}", Version.getVersion()); + + if (!initInThread()) { + LOGGER.log(Level.SEVERE, "Display initialization failed. Cannot continue."); + return; + } + + while (true) { + + runLoop(); + if (needClose.get()) { + break; + } + + if (glfwWindowShouldClose(window)) { //Try + listener.requestClose(false); //Try + } //Try + } + + deinitInThread(); + } + + @Override + public JoyInput getJoyInput() { + if (joyInput == null) { + joyInput = new GlfwJoystickInput(); + } + return joyInput; + } + + @Override + public MouseInput getMouseInput() { + if (mouseInput == null) { + mouseInput = new EmptyMouseInput(); + } + return mouseInput; + } + + @Override + public KeyInput getKeyInput() { + if (keyInput == null) { + keyInput = new EmptyKeyInput(); + } + return keyInput; + } + + @Override + public TouchInput getTouchInput() { + return null; + } + + @Override + public void setAutoFlushFrames(boolean enabled) { + this.autoFlush = enabled; + } + + @Override + public void destroy(boolean waitFor) { + needClose.set(true); + + if (mainThread == Thread.currentThread()) { + // Ignore waitFor. + return; + } + + if (waitFor) { + waitFor(false); + } + } + + public long getWindowHandle() { + return window; + } + + /** + * Get the window content scale, for HiDPI support. + * + * The content scale is the ratio between the current DPI and the platform's default DPI. + * This is especially important for text and any UI elements. If the pixel dimensions of + * your UI scaled by this look appropriate on your machine then it should appear at a + * reasonable size on other machines regardless of their DPI and scaling settings. This + * relies on the system DPI and scaling settings being somewhat correct. + * + * @param store A vector2f to store the result + * @return The window content scale + * @see Window content scale + */ + public Vector2f getWindowContentScale(Vector2f store) { + if (store == null) store = new Vector2f(); + + glfwGetFramebufferSize(window, width, height); + store.set(width[0], height[0]); + + glfwGetWindowSize(window, width, height); + store.x /= width[0]; + store.y /= height[0]; + + return store; + } + + /** + * Returns the height of the framebuffer. + * + * @return the height (in pixels) + */ + @Override + public int getFramebufferHeight() { + glfwGetFramebufferSize(window, width, height); + int result = height[0]; + return result; + } + + /** + * Returns the width of the framebuffer. + * + * @return the width (in pixels) + */ + @Override + public int getFramebufferWidth() { + glfwGetFramebufferSize(window, width, height); + int result = width[0]; + return result; + } + + /** + * Returns the screen X coordinate of the left edge of the content area. + * + * @return the screen X coordinate + */ + @Override + public int getWindowXPosition() { + glfwGetWindowPos(window, width, height); + int result = width[0]; + return result; + } + + /** + * Returns the screen Y coordinate of the top edge of the content area. + * + * @return the screen Y coordinate + */ + @Override + public int getWindowYPosition() { + glfwGetWindowPos(window, width, height); + int result = height[0]; + return result; + } +} diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/HelloOpenXRGL.java b/jme3-xr/src/main/java/com/jme3/system/lwjgl/openxr/HelloOpenXRGL.java similarity index 87% rename from jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/HelloOpenXRGL.java rename to jme3-xr/src/main/java/com/jme3/system/lwjgl/openxr/HelloOpenXRGL.java index 0a87ecb52e..0891788cf9 100644 --- a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/HelloOpenXRGL.java +++ b/jme3-xr/src/main/java/com/jme3/system/lwjgl/openxr/HelloOpenXRGL.java @@ -3,7 +3,7 @@ * License terms: https://www.lwjgl.org/license * Source: https://github.com/LWJGL/lwjgl3/tree/master/modules/samples/src/test/java/org/lwjgl/demo/openxr */ -package com.jme3.input.vr.lwjgl_openxr; +package com.jme3.system.lwjgl.openxr; import org.joml.*; import org.lwjgl.*; @@ -11,8 +11,8 @@ import org.lwjgl.openxr.*; import org.lwjgl.system.*; -import com.jme3.app.VREnvironment; -import com.jme3.util.NativeObject; +import com.jme3.input.xr.XrHmd; +import com.jme3.system.AppSettings; import java.nio.*; import java.util.*; @@ -32,10 +32,10 @@ public class HelloOpenXRGL { private static final Logger logger = Logger.getLogger(HelloOpenXRGL.class.getName()); - VREnvironment environment; long window; - + AppSettings appSettings; + //XR globals //Init XrInstance xrInstance; @@ -60,10 +60,15 @@ public class HelloOpenXRGL { Map depthTextures; //Swapchain images only provide a color texture so we have to create depth textures seperatley int swapchainFramebuffer; + int cubeVertexBuffer; + int cubeIndexBuffer; + int quadVertexBuffer; + int cubeVAO; + int quadVAO; int screenShader; int textureShader; int colorShader; - + XrHmd xrHmd; static class Swapchain { XrSwapchain handle; int width; @@ -72,20 +77,15 @@ static class Swapchain { } //JME3: Split function main(args) to public functions constr+init+render+destroy - public HelloOpenXRGL(VREnvironment environment) + public HelloOpenXRGL(AppSettings appSettings) { - this.environment = environment; + this.appSettings = appSettings; createOpenXRInstance(); initializeOpenXRSystem(); initializeAndBindOpenGL(); createXRReferenceSpace(); createXRSwapchains(); - } - - private void initialize() - { createOpenGLResources(); - eventDataBuffer = XrEventDataBuffer.calloc() .type$Default(); } @@ -93,7 +93,6 @@ private void initialize() /** Returns true for continue */ public boolean renderFrame() { - if (eventDataBuffer == null) { initialize(); } if (pollEvents()) return false; if (glfwWindowShouldClose(window)) return false; if (sessionRunning) @@ -147,6 +146,11 @@ public void destroy() glDeleteTextures(texture); } glDeleteFramebuffers(swapchainFramebuffer); + glDeleteBuffers(cubeVertexBuffer); + glDeleteBuffers(cubeIndexBuffer); + glDeleteBuffers(quadVertexBuffer); + glDeleteVertexArrays(cubeVAO); + glDeleteVertexArrays(quadVAO); glDeleteProgram(screenShader); glDeleteProgram(textureShader); glDeleteProgram(colorShader); @@ -172,6 +176,8 @@ public void getRenderSize(com.jme3.math.Vector2f store) } store.set(swapchains[0].width,swapchains[0].height); } + public long getWindow() { return window; } + public void setHmd(XrHmd xrHmd) { this.xrHmd = xrHmd; } private void createOpenXRInstance() { try (MemoryStack stack = stackPush()) { @@ -204,7 +210,7 @@ private void createOpenXRInstance() { missingXrDebug = false; } if (extensionName.equals(XR_MNDX_EGL_ENABLE_EXTENSION_NAME)) { - //useEglGraphicsBinding = true; //JME3: Do not use EGL + useEglGraphicsBinding = true; } } @@ -300,7 +306,7 @@ public void initializeOpenXRSystem() { } } - public void initializeAndBindOpenGL() { + private void initializeAndBindOpenGL() { try (MemoryStack stack = stackPush()) { //Initialize OpenXR's OpenGL compatability XrGraphicsRequirementsOpenGLKHR graphicsRequirements = XrGraphicsRequirementsOpenGLKHR.malloc(stack) @@ -366,7 +372,8 @@ public void initializeAndBindOpenGL() { " and earlier, but we got OpenGL " + actualMajorVersion + "." + actualMinorVersion ); } - + logger.info("OnCreateXr: Win=" + window + " Egl=" + useEglGraphicsBinding); + //Bind the OpenGL context to the OpenXR instance and create the session PointerBuffer pp = stack.mallocPointer(1); check(xrCreateSession( @@ -523,6 +530,12 @@ public void createXRSwapchains() { .arraySize(1) .mipCount(1); + System.out.printf("Headset Eye:%d has Width:%d Height:%d\n", + i, + viewConfig.recommendedImageRectWidth(), + viewConfig.recommendedImageRectHeight()); + appSettings.setWidth(viewConfig.recommendedImageRectWidth()); + appSettings.setHeight(viewConfig.recommendedImageRectHeight()); PointerBuffer pp = stack.mallocPointer(1); check(xrCreateSwapchain(xrSession, swapchainCreateInfo, pp)); @@ -563,44 +576,6 @@ private void createOpenGLResources() { } } glBindTexture(GL_TEXTURE_2D, 0); - - textureShader = ShadersGL.createShaderProgram(ShadersGL.texVertShader, ShadersGL.texFragShader); - colorShader = ShadersGL.createShaderProgram(ShadersGL.colVertShader, ShadersGL.colFragShader); - screenShader = ShadersGL.createShaderProgram(ShadersGL.screenVertShader, ShadersGL.texFragShader); - - /* - { - cubeVertexBuffer = glGenBuffers(); - glBindBuffer(GL_ARRAY_BUFFER, cubeVertexBuffer); - glBufferData(GL_ARRAY_BUFFER, Geometry.cubeVertices, GL_STATIC_DRAW); - - cubeIndexBuffer = glGenBuffers(); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, cubeIndexBuffer); - glBufferData(GL_ELEMENT_ARRAY_BUFFER, Geometry.cubeIndices, GL_STATIC_DRAW); - - cubeVAO = glGenVertexArrays(); - glBindVertexArray(cubeVAO); - glEnableVertexAttribArray(0); - glEnableVertexAttribArray(1); - glVertexAttribPointer(0, 3, GL_FLOAT, false, 4 * 3 * 2, 0); - glVertexAttribPointer(1, 3, GL_FLOAT, false, 24, 12); - } - { - quadVAO = glGenVertexArrays(); - quadVertexBuffer = glGenBuffers(); - glBindVertexArray(quadVAO); - glBindBuffer(GL_ARRAY_BUFFER, quadVertexBuffer); - glBufferData(GL_ARRAY_BUFFER, Geometry.quadVertices, GL_STATIC_DRAW); - glEnableVertexAttribArray(0); - glVertexAttribPointer(0, 2, GL_FLOAT, false, 4 * 4, 0); - glEnableVertexAttribArray(1); - glVertexAttribPointer(1, 2, GL_FLOAT, false, 4 * 4, 2 * 4); - } - */ - -// glBindBuffer(GL_ARRAY_BUFFER, 0); -// glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); -// glBindVertexArray(0); } private boolean pollEvents() { @@ -835,14 +810,11 @@ private boolean renderLayerOpenXR(MemoryStack stack, long predictedDisplayTime, return true; } -// private static Matrix4f modelviewMatrix = new Matrix4f(); - private static Matrix4f projectionMatrix = new Matrix4f(); - private static Matrix4f viewMatrix = new Matrix4f(); + private static Matrix4f projectionMatrix = new Matrix4f(); //TODO: Do we need this? + private static Matrix4f viewMatrix = new Matrix4f(); //TODO: Do we need this? private static com.jme3.math.Vector3f viewPos = new com.jme3.math.Vector3f(); private static com.jme3.math.Quaternion viewRot = new com.jme3.math.Quaternion(); -// private static FloatBuffer mvpMatrix = BufferUtils.createFloatBuffer(16); - private void OpenGLRenderView(XrCompositionLayerProjectionView layerView, XrSwapchainImageOpenGLKHR swapchainImage, int viewIndex) { glBindFramebuffer(GL_FRAMEBUFFER, swapchainFramebuffer); @@ -856,10 +828,6 @@ private void OpenGLRenderView(XrCompositionLayerProjectionView layerView, XrSwap imageRect.extent().width(), imageRect.extent().height() ); - - float[] DarkSlateGray = {0.184313729f, 0.309803933f, 0.309803933f}; - glClearColor(DarkSlateGray[0], DarkSlateGray[1], DarkSlateGray[2], 1.0f); - glClearDepth(1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glFrontFace(GL_CW); @@ -877,58 +845,19 @@ private void OpenGLRenderView(XrCompositionLayerProjectionView layerView, XrSwap ); viewPos.set(pos.x(), pos.y(), pos.z()); viewRot.set(orientation.x(), orientation.y(), orientation.z(), orientation.w()); + xrHmd.onUpdateHmdOrientation(viewPos, viewRot); - /* glDisable(GL_CULL_FACE); // Disable back-face culling so we can see the inside of the world-space cube and backside of the plane - { // Rotating plane - modelviewMatrix.translation(0, 0, -3).rotate((float)-glfwGetTime(), 1, 0, 0); - glUseProgram(colorShader); - glUniformMatrix4fv(glGetUniformLocation(colorShader, "projection"), false, projectionMatrix.get(mvpMatrix)); - glUniformMatrix4fv(glGetUniformLocation(colorShader, "view"), false, viewMatrix.get(mvpMatrix)); - glUniformMatrix4fv(glGetUniformLocation(colorShader, "model"), false, modelviewMatrix.get(mvpMatrix)); - glBindVertexArray(quadVAO); - glDrawArrays(GL_TRIANGLES, 0, 6); - } - - { // World-space cube - modelviewMatrix.identity().scale(10); - glUniformMatrix4fv(glGetUniformLocation(colorShader, "model"), false, modelviewMatrix.get(mvpMatrix)); - glBindVertexArray(cubeVAO); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, cubeIndexBuffer); - glDrawElements(GL_TRIANGLES, 36, GL_UNSIGNED_SHORT, 0); - } + if (viewIndex == 0) { xrHmd.getLeftEye().render(); } + else if (viewIndex == 1) { xrHmd.getRightEye().render(); } glEnable(GL_CULL_FACE); - */ glBindFramebuffer(GL_FRAMEBUFFER, 0); - if (viewIndex == 0 || true) { // The view to the GLFW window - try (MemoryStack stack = stackPush()) { - Swapchain swapchain = swapchains[viewIndex]; - - IntBuffer ww = stack.mallocInt(1); - IntBuffer wh = stack.mallocInt(1); - glfwGetWindowSize(window, ww, wh); - - int wh2 = (int)(((float)swapchain.height / swapchain.width) * ww.get(0)); - if (wh2 > wh.get(0)) { - int ww2 = (int)(((float)swapchain.width / swapchain.height) * wh.get(0)); - glViewport(ww2 * viewIndex, 0, ww2, wh.get(0)); - } else { - glViewport(ww.get(0) * viewIndex, 0, ww.get(0), wh2); - } - } - glFrontFace(GL_CCW); - glUseProgram(screenShader); -// glBindVertexArray(quadVAO); - glDisable(GL_DEPTH_TEST); - glBindTexture(GL_TEXTURE_2D, swapchainImage.image()); - glDrawArrays(GL_TRIANGLES, 0, 6); - if (viewIndex == swapchains.length - 1) { - glFlush(); - } + if (viewIndex == swapchains.length - 1) { + glFlush(); } } diff --git a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/XRHelper.java b/jme3-xr/src/main/java/com/jme3/system/lwjgl/openxr/XRHelper.java similarity index 99% rename from jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/XRHelper.java rename to jme3-xr/src/main/java/com/jme3/system/lwjgl/openxr/XRHelper.java index dbcbeed37d..4a523b87b9 100644 --- a/jme3-xr/src/main/java/com/jme3/input/vr/lwjgl_openxr/XRHelper.java +++ b/jme3-xr/src/main/java/com/jme3/system/lwjgl/openxr/XRHelper.java @@ -3,7 +3,7 @@ * License terms: https://www.lwjgl.org/license * Source: https://github.com/LWJGL/lwjgl3/tree/master/modules/samples/src/test/java/org/lwjgl/demo/openxr */ -package com.jme3.input.vr.lwjgl_openxr; +package com.jme3.system.lwjgl.openxr; import org.joml.Math; import org.joml.*; diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientkit/OsvrClientKitLibrary.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientkit/OsvrClientKitLibrary.java deleted file mode 100644 index dd8792e399..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientkit/OsvrClientKitLibrary.java +++ /dev/null @@ -1,380 +0,0 @@ -package com.jme3.system.osvr.osvrclientkit; -import com.sun.jna.Callback; -import com.sun.jna.Library; -import com.sun.jna.Native; -import com.sun.jna.NativeLibrary; -import com.sun.jna.Pointer; -import com.sun.jna.PointerType; -import com.sun.jna.ptr.PointerByReference; -/** - * JNA Wrapper for library osvrClientKit
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class OsvrClientKitLibrary implements Library { - public static final String JNA_LIBRARY_NAME = "osvrClientKit"; - public static final NativeLibrary JNA_NATIVE_LIB = NativeLibrary.getInstance(OsvrClientKitLibrary.JNA_LIBRARY_NAME); - static { - Native.register(OsvrClientKitLibrary.class, OsvrClientKitLibrary.JNA_NATIVE_LIB); - } - /** - * Initialize the library. - * @param applicationIdentifier A null terminated string identifying your
- * application. Reverse DNS format strongly suggested.
- * @param flags initialization options (reserved) - pass 0 for now.
- * @return Client context - will be needed for subsequent calls
- * Original signature : OSVR_ClientContext osvrClientInit(const char[], uint32_t)
- * @deprecated use the safer method - * {@link #osvrClientInit(byte[], int)} - * instead - */ - @Deprecated - public static native OsvrClientKitLibrary.OSVR_ClientContext osvrClientInit(Pointer applicationIdentifier, int flags); - /** - * Initialize the library. - * @param applicationIdentifier A null terminated string identifying your
- * application. Reverse DNS format strongly suggested.
- * @param flags initialization options (reserved) - pass 0 for now.
- * @return Client context - will be needed for subsequent calls
- * Original signature : OSVR_ClientContext osvrClientInit(const char[], uint32_t) - */ - public static native OsvrClientKitLibrary.OSVR_ClientContext osvrClientInit(byte applicationIdentifier[], int flags); - /** - * Updates the state of the context - call regularly in your mainloop. - * @param ctx Client context
- * Original signature : OSVR_ReturnCode osvrClientUpdate(OSVR_ClientContext)
- * @deprecated use the safer method - * {@link #osvrClientUpdate(OsvrClientKitLibrary.OSVR_ClientContext)} - * instead - */ - @Deprecated - public static native byte osvrClientUpdate(Pointer ctx); - /** - * Updates the state of the context - call regularly in your mainloop. - * @param ctx Client context
- * Original signature : OSVR_ReturnCode osvrClientUpdate(OSVR_ClientContext) - */ - public static native byte osvrClientUpdate(OsvrClientKitLibrary.OSVR_ClientContext ctx); - /** - * Checks to see if the client context is fully started up and connected - * properly to a server.
- * If this reports that the client context is not OK, there may not be a server
- * running, or you may just have to call osvrClientUpdate() a few times to
- * permit startup to finish. The return value of this call will not change from
- * failure to success without calling osvrClientUpdate().
- * @param ctx Client context
- * @return OSVR_RETURN_FAILURE if not yet fully connected/initialized, or if
- * some other error (null context) occurs.
- * Original signature : OSVR_ReturnCode osvrClientCheckStatus(OSVR_ClientContext)
- * @deprecated use the safer method - * {@link #osvrClientCheckStatus(com.jme3.system.osvr.osvrclientkit.OsvrClientKitLibrary.OSVR_ClientContext)} - * instead - */ - @Deprecated - public static native byte osvrClientCheckStatus(Pointer ctx); - /** - * Checks to see if the client context is fully started up and connected - * properly to a server.
- * If this reports that the client context is not OK, there may not be a server
- * running, or you may just have to call osvrClientUpdate() a few times to
- * permit startup to finish. The return value of this call will not change from
- * failure to success without calling osvrClientUpdate().
- * @param ctx Client context
- * @return OSVR_RETURN_FAILURE if not yet fully connected/initialized, or if
- * some other error (null context) occurs.
- * Original signature : OSVR_ReturnCode osvrClientCheckStatus(OSVR_ClientContext) - */ - public static native byte osvrClientCheckStatus(OsvrClientKitLibrary.OSVR_ClientContext ctx); - /** - * Shut down the library. - * @param ctx Client context
- * Original signature : OSVR_ReturnCode osvrClientShutdown(OSVR_ClientContext)
- * @deprecated use the safer method - * {@link #osvrClientShutdown(OsvrClientKitLibrary.OSVR_ClientContext)} - * instead - */ - @Deprecated - public static native byte osvrClientShutdown(Pointer ctx); - /** - * Shut down the library. - * @param ctx Client context
- * Original signature : OSVR_ReturnCode osvrClientShutdown(OSVR_ClientContext) - */ - public static native byte osvrClientShutdown(OsvrClientKitLibrary.OSVR_ClientContext ctx); - /** - * Log a message from the client. - * Original signature : void osvrClientLog(OSVR_ClientContext, OSVR_LogLevel, const char*)
- * @deprecated use the safer method - * {@link #osvrClientLog(com.jme3.system.osvr.osvrclientkit.OsvrClientKitLibrary.OSVR_ClientContext, int, java.lang.String)} - * instead - */ - @Deprecated - public static native void osvrClientLog(Pointer ctx, int severity, Pointer message); - /** - * Log a message from the client. - * Original signature : void osvrClientLog(OSVR_ClientContext, OSVR_LogLevel, const char*) - */ - public static native void osvrClientLog(OsvrClientKitLibrary.OSVR_ClientContext ctx, int severity, String message); - /** - * Get the interface associated with the given path. - * @param ctx Client context
- * @param path A resource path (null-terminated string)
- * @param iface The interface object. May be freed when no longer needed,
- * otherwise it will be freed when the context is closed.
- * Original signature : OSVR_ReturnCode osvrClientGetInterface(OSVR_ClientContext, const char[], OSVR_ClientInterface*)
- * @deprecated use the safer method - * {@link #osvrClientGetInterface(com.jme3.system.osvr.osvrclientkit.OsvrClientKitLibrary.OSVR_ClientContext, byte[], com.sun.jna.ptr.PointerByReference)} - * instead - */ - @Deprecated - public static native byte osvrClientGetInterface(Pointer ctx, Pointer path, Pointer iface); - /** - * Get the interface associated with the given path. - * @param ctx Client context
- * @param path A resource path (null-terminated string)
- * @param iface The interface object. May be freed when no longer needed,
- * otherwise it will be freed when the context is closed.
- * Original signature : OSVR_ReturnCode osvrClientGetInterface(OSVR_ClientContext, const char[], OSVR_ClientInterface*) - */ - public static native byte osvrClientGetInterface(OsvrClientKitLibrary.OSVR_ClientContext ctx, byte path[], PointerByReference iface); - /** - * Get the interface associated with the given path. - * @param ctx Client context
- * @param path A resource path (null-terminated string)
- * @param iface The interface object. May be freed when no longer needed,
- * otherwise it will be freed when the context is closed.
- * Original signature : OSVR_ReturnCode osvrClientGetInterface(OSVR_ClientContext, const char[], OSVR_ClientInterface*) - */ - public static native byte osvrClientGetInterface(Pointer ctx, Pointer path, PointerByReference iface); - /** - * Free an interface object before context closure. - * @param ctx Client context
- * @param iface The interface object
- * @return OSVR_RETURN_SUCCESS unless a null context or interface was passed
- * or the given interface was not found in the context (i.e. had already been
- * freed)
- * Original signature : OSVR_ReturnCode osvrClientFreeInterface(OSVR_ClientContext, OSVR_ClientInterface)
- * @deprecated use the safer method - * {@link #osvrClientFreeInterface(com.jme3.system.osvr.osvrclientkit.OsvrClientKitLibrary.OSVR_ClientContext, com.jme3.system.osvr.osvrclientkit.OsvrClientKitLibrary.OSVR_ClientInterface)} - * instead - */ - @Deprecated - public static native byte osvrClientFreeInterface(Pointer ctx, Pointer iface); - /** - * Free an interface object before context closure. - * @param ctx Client context
- * @param iface The interface object
- * @return OSVR_RETURN_SUCCESS unless a null context or interface was passed
- * or the given interface was not found in the context (i.e. had already been
- * freed)
- * Original signature : OSVR_ReturnCode osvrClientFreeInterface(OSVR_ClientContext, OSVR_ClientInterface) - */ - public static native byte osvrClientFreeInterface(OsvrClientKitLibrary.OSVR_ClientContext ctx, OsvrClientKitLibrary.OSVR_ClientInterface iface); - /** - * Original signature : OSVR_ReturnCode osvrRegisterPoseCallback(OSVR_ClientInterface, OSVR_PoseCallback, void*)
- * @deprecated use the safer method - * {@link #osvrRegisterPoseCallback(OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} - * instead - */ - @Deprecated - public static native byte osvrRegisterPoseCallback(Pointer iface, Pointer cb, Pointer userdata); - /** Original signature : OSVR_ReturnCode osvrRegisterPoseCallback(OSVR_ClientInterface, OSVR_PoseCallback, void*) */ - public static native byte osvrRegisterPoseCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Pointer cb, Pointer userdata); - /** - * Original signature : OSVR_ReturnCode osvrRegisterPositionCallback(OSVR_ClientInterface, OSVR_PositionCallback, void*)
- * @deprecated use the safer method - * {@link #osvrRegisterPositionCallback(OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} - * instead - */ - @Deprecated - public static native byte osvrRegisterPositionCallback(Pointer iface, Pointer cb, Pointer userdata); - /** Original signature : OSVR_ReturnCode osvrRegisterPositionCallback(OSVR_ClientInterface, OSVR_PositionCallback, void*) */ - public static native byte osvrRegisterPositionCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Pointer cb, Pointer userdata); - /** - * Original signature : OSVR_ReturnCode osvrRegisterOrientationCallback(OSVR_ClientInterface, OSVR_OrientationCallback, void*)
- * @deprecated use the safer method - * {@link #osvrRegisterOrientationCallback(OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} - * instead - */ - @Deprecated - public static native byte osvrRegisterOrientationCallback(Pointer iface, Pointer cb, Pointer userdata); - /** Original signature : OSVR_ReturnCode osvrRegisterOrientationCallback(OSVR_ClientInterface, OSVR_OrientationCallback, void*) */ - public static native byte osvrRegisterOrientationCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Pointer cb, Pointer userdata); - /** - * Original signature : OSVR_ReturnCode osvrRegisterVelocityCallback(OSVR_ClientInterface, OSVR_VelocityCallback, void*)
- * @deprecated use the safer method - * {@link #osvrRegisterVelocityCallback(OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} - * instead - */ - @Deprecated - public static native byte osvrRegisterVelocityCallback(Pointer iface, Pointer cb, Pointer userdata); - /** Original signature : OSVR_ReturnCode osvrRegisterVelocityCallback(OSVR_ClientInterface, OSVR_VelocityCallback, void*) */ - public static native byte osvrRegisterVelocityCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Pointer cb, Pointer userdata); - /** - * Original signature : OSVR_ReturnCode osvrRegisterLinearVelocityCallback(OSVR_ClientInterface, OSVR_LinearVelocityCallback, void*)
- * @deprecated use the safer method - * {@link #osvrRegisterLinearVelocityCallback(OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} - * instead - */ - @Deprecated - public static native byte osvrRegisterLinearVelocityCallback(Pointer iface, Pointer cb, Pointer userdata); - /** Original signature : OSVR_ReturnCode osvrRegisterLinearVelocityCallback(OSVR_ClientInterface, OSVR_LinearVelocityCallback, void*) */ - public static native byte osvrRegisterLinearVelocityCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Pointer cb, Pointer userdata); - /** - * Original signature : OSVR_ReturnCode osvrRegisterAngularVelocityCallback(OSVR_ClientInterface, OSVR_AngularVelocityCallback, void*)
- * @deprecated use the safer method - * {@link #osvrRegisterAngularVelocityCallback(OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} - * instead - */ - @Deprecated - public static native byte osvrRegisterAngularVelocityCallback(Pointer iface, Pointer cb, Pointer userdata); - /** Original signature : OSVR_ReturnCode osvrRegisterAngularVelocityCallback(OSVR_ClientInterface, OSVR_AngularVelocityCallback, void*) */ - public static native byte osvrRegisterAngularVelocityCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Pointer cb, Pointer userdata); - /** - * Original signature : OSVR_ReturnCode osvrRegisterAccelerationCallback(OSVR_ClientInterface, OSVR_AccelerationCallback, void*)
- * @deprecated use the safer method - * {@link #osvrRegisterAccelerationCallback(OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} - * instead - */ - @Deprecated - public static native byte osvrRegisterAccelerationCallback(Pointer iface, Pointer cb, Pointer userdata); - /** Original signature : OSVR_ReturnCode osvrRegisterAccelerationCallback(OSVR_ClientInterface, OSVR_AccelerationCallback, void*) */ - public static native byte osvrRegisterAccelerationCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Pointer cb, Pointer userdata); - /** - * Original signature : OSVR_ReturnCode osvrRegisterLinearAccelerationCallback(OSVR_ClientInterface, OSVR_LinearAccelerationCallback, void*)
- * @deprecated use the safer method - * {@link #osvrRegisterLinearAccelerationCallback(OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} - * instead - */ - @Deprecated - public static native byte osvrRegisterLinearAccelerationCallback(Pointer iface, Pointer cb, Pointer userdata); - /** Original signature : OSVR_ReturnCode osvrRegisterLinearAccelerationCallback(OSVR_ClientInterface, OSVR_LinearAccelerationCallback, void*) */ - public static native byte osvrRegisterLinearAccelerationCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Pointer cb, Pointer userdata); - /** - * Original signature : OSVR_ReturnCode osvrRegisterAngularAccelerationCallback(OSVR_ClientInterface, OSVR_AngularAccelerationCallback, void*)
- * @deprecated use the safer method - * {@link #osvrRegisterAngularAccelerationCallback(OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} - * instead - */ - @Deprecated - public static native byte osvrRegisterAngularAccelerationCallback(Pointer iface, Pointer cb, Pointer userdata); - /** Original signature : OSVR_ReturnCode osvrRegisterAngularAccelerationCallback(OSVR_ClientInterface, OSVR_AngularAccelerationCallback, void*) */ - public static native byte osvrRegisterAngularAccelerationCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Pointer cb, Pointer userdata); - /** - * Original signature : OSVR_ReturnCode osvrRegisterButtonCallback(OSVR_ClientInterface, OSVR_ButtonCallback, void*)
- * @deprecated use the safer method - * {@link #osvrRegisterButtonCallback(com.jme3.system.osvr.osvrclientkit.OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Callback, com.sun.jna.Pointer)} - * instead - */ - @Deprecated - public static native byte osvrRegisterButtonCallback(Pointer iface, Pointer cb, Pointer userdata); - /** Original signature : OSVR_ReturnCode osvrRegisterButtonCallback(OSVR_ClientInterface, OSVR_ButtonCallback, void*) */ - public static native byte osvrRegisterButtonCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Callback cb, Pointer userdata); - /** - * Original signature : OSVR_ReturnCode osvrRegisterAnalogCallback(OSVR_ClientInterface, OSVR_AnalogCallback, void*)
- * @deprecated use the safer method - * {@link #osvrRegisterAnalogCallback(com.jme3.system.osvr.osvrclientkit.OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Callback, com.sun.jna.Pointer)} - * instead - */ - @Deprecated - public static native byte osvrRegisterAnalogCallback(Pointer iface, Pointer cb, Pointer userdata); - /** Original signature : OSVR_ReturnCode osvrRegisterAnalogCallback(OSVR_ClientInterface, OSVR_AnalogCallback, void*) */ - public static native byte osvrRegisterAnalogCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Callback cb, Pointer userdata); - /** - * Original signature : OSVR_ReturnCode osvrRegisterImagingCallback(OSVR_ClientInterface, OSVR_ImagingCallback, void*)
- * @deprecated use the safer method - * {@link #osvrRegisterImagingCallback(OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} - * instead - */ - @Deprecated - public static native byte osvrRegisterImagingCallback(Pointer iface, Pointer cb, Pointer userdata); - /** Original signature : OSVR_ReturnCode osvrRegisterImagingCallback(OSVR_ClientInterface, OSVR_ImagingCallback, void*) */ - public static native byte osvrRegisterImagingCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Pointer cb, Pointer userdata); - /** - * Original signature : OSVR_ReturnCode osvrRegisterLocation2DCallback(OSVR_ClientInterface, OSVR_Location2DCallback, void*)
- * @deprecated use the safer method - * {@link #osvrRegisterLocation2DCallback(OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} - * instead - */ - @Deprecated - public static native byte osvrRegisterLocation2DCallback(Pointer iface, Pointer cb, Pointer userdata); - /** Original signature : OSVR_ReturnCode osvrRegisterLocation2DCallback(OSVR_ClientInterface, OSVR_Location2DCallback, void*) */ - public static native byte osvrRegisterLocation2DCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Pointer cb, Pointer userdata); - /** - * Original signature : OSVR_ReturnCode osvrRegisterDirectionCallback(OSVR_ClientInterface, OSVR_DirectionCallback, void*)
- * @deprecated use the safer method - * {@link #osvrRegisterDirectionCallback(OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} - * instead - */ - @Deprecated - public static native byte osvrRegisterDirectionCallback(Pointer iface, Pointer cb, Pointer userdata); - /** Original signature : OSVR_ReturnCode osvrRegisterDirectionCallback(OSVR_ClientInterface, OSVR_DirectionCallback, void*) */ - public static native byte osvrRegisterDirectionCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Pointer cb, Pointer userdata); - /** - * Original signature : OSVR_ReturnCode osvrRegisterEyeTracker2DCallback(OSVR_ClientInterface, OSVR_EyeTracker2DCallback, void*)
- * @deprecated use the safer method - * {@link #osvrRegisterEyeTracker2DCallback(OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} - * instead - */ - @Deprecated - public static native byte osvrRegisterEyeTracker2DCallback(Pointer iface, Pointer cb, Pointer userdata); - /** Original signature : OSVR_ReturnCode osvrRegisterEyeTracker2DCallback(OSVR_ClientInterface, OSVR_EyeTracker2DCallback, void*) */ - public static native byte osvrRegisterEyeTracker2DCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Pointer cb, Pointer userdata); - /** - * Original signature : OSVR_ReturnCode osvrRegisterEyeTracker3DCallback(OSVR_ClientInterface, OSVR_EyeTracker3DCallback, void*)
- * @deprecated use the safer method - * {@link #osvrRegisterEyeTracker3DCallback(OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} - * instead - */ - @Deprecated - public static native byte osvrRegisterEyeTracker3DCallback(Pointer iface, Pointer cb, Pointer userdata); - /** Original signature : OSVR_ReturnCode osvrRegisterEyeTracker3DCallback(OSVR_ClientInterface, OSVR_EyeTracker3DCallback, void*) */ - public static native byte osvrRegisterEyeTracker3DCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Pointer cb, Pointer userdata); - /** - * Original signature : OSVR_ReturnCode osvrRegisterEyeTrackerBlinkCallback(OSVR_ClientInterface, OSVR_EyeTrackerBlinkCallback, void*)
- * @deprecated use the safer method - * {@link #osvrRegisterEyeTrackerBlinkCallback(OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} - * instead - */ - @Deprecated - public static native byte osvrRegisterEyeTrackerBlinkCallback(Pointer iface, Pointer cb, Pointer userdata); - /** Original signature : OSVR_ReturnCode osvrRegisterEyeTrackerBlinkCallback(OSVR_ClientInterface, OSVR_EyeTrackerBlinkCallback, void*) */ - public static native byte osvrRegisterEyeTrackerBlinkCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Pointer cb, Pointer userdata); - /** - * Original signature : OSVR_ReturnCode osvrRegisterNaviVelocityCallback(OSVR_ClientInterface, OSVR_NaviVelocityCallback, void*)
- * @deprecated use the safer method - * {@link #osvrRegisterNaviVelocityCallback(OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} - * instead - */ - @Deprecated - public static native byte osvrRegisterNaviVelocityCallback(Pointer iface, Pointer cb, Pointer userdata); - /** Original signature : OSVR_ReturnCode osvrRegisterNaviVelocityCallback(OSVR_ClientInterface, OSVR_NaviVelocityCallback, void*) */ - public static native byte osvrRegisterNaviVelocityCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Pointer cb, Pointer userdata); - /** - * Original signature : OSVR_ReturnCode osvrRegisterNaviPositionCallback(OSVR_ClientInterface, OSVR_NaviPositionCallback, void*)
- * @deprecated use the safer method - * {@link #osvrRegisterNaviPositionCallback(OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} - * instead - */ - @Deprecated - public static native byte osvrRegisterNaviPositionCallback(Pointer iface, Pointer cb, Pointer userdata); - /** Original signature : OSVR_ReturnCode osvrRegisterNaviPositionCallback(OSVR_ClientInterface, OSVR_NaviPositionCallback, void*) */ - public static native byte osvrRegisterNaviPositionCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Pointer cb, Pointer userdata); - public static class OSVR_ClientContext extends PointerType { - public OSVR_ClientContext(Pointer address) { - super(address); - } - public OSVR_ClientContext() { - super(); - } - }; - public static class OSVR_ClientInterface extends PointerType { - public OSVR_ClientInterface(Pointer address) { - super(address); - } - public OSVR_ClientInterface() { - super(); - } - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_AccelerationReport.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_AccelerationReport.java deleted file mode 100644 index c6ba614d1d..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_AccelerationReport.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.jme3.system.osvr.osvrclientreporttypes; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class OSVR_AccelerationReport extends Structure { - public int sensor; - /** C type : OSVR_AccelerationState */ - public OSVR_AccelerationState state; - public OSVR_AccelerationReport() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("sensor", "state"); - } - /** @param state C type : OSVR_AccelerationState */ - public OSVR_AccelerationReport(int sensor, OSVR_AccelerationState state) { - super(); - this.sensor = sensor; - this.state = state; - } - public OSVR_AccelerationReport(Pointer peer) { - super(peer); - } - public static class ByReference extends OSVR_AccelerationReport implements Structure.ByReference { - - }; - public static class ByValue extends OSVR_AccelerationReport implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_AccelerationState.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_AccelerationState.java deleted file mode 100644 index 379a7972b4..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_AccelerationState.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.jme3.system.osvr.osvrclientreporttypes; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class OSVR_AccelerationState extends Structure { - /** C type : OSVR_LinearAccelerationState */ - public OSVR_Vec3 linearAcceleration; - /** C type : OSVR_CBool */ - public byte linearAccelerationValid; - /** C type : OSVR_AngularAccelerationState */ - public OSVR_IncrementalQuaternion angularAcceleration; - /** C type : OSVR_CBool */ - public byte angularAccelerationValid; - public OSVR_AccelerationState() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("linearAcceleration", "linearAccelerationValid", "angularAcceleration", "angularAccelerationValid"); - } - /** - * @param linearAcceleration C type : OSVR_LinearAccelerationState
- * @param linearAccelerationValid C type : OSVR_CBool
- * @param angularAcceleration C type : OSVR_AngularAccelerationState
- * @param angularAccelerationValid C type : OSVR_CBool - */ - public OSVR_AccelerationState(OSVR_Vec3 linearAcceleration, byte linearAccelerationValid, OSVR_IncrementalQuaternion angularAcceleration, byte angularAccelerationValid) { - super(); - this.linearAcceleration = linearAcceleration; - this.linearAccelerationValid = linearAccelerationValid; - this.angularAcceleration = angularAcceleration; - this.angularAccelerationValid = angularAccelerationValid; - } - public OSVR_AccelerationState(Pointer peer) { - super(peer); - } - public static class ByReference extends OSVR_AccelerationState implements Structure.ByReference { - - }; - public static class ByValue extends OSVR_AccelerationState implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_AnalogReport.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_AnalogReport.java deleted file mode 100644 index 8b5aca7d1c..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_AnalogReport.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.jme3.system.osvr.osvrclientreporttypes; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class OSVR_AnalogReport extends Structure { - public int sensor; - /** C type : OSVR_AnalogState */ - public double state; - public OSVR_AnalogReport() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("sensor", "state"); - } - /** @param state C type : OSVR_AnalogState */ - public OSVR_AnalogReport(int sensor, double state) { - super(); - this.sensor = sensor; - this.state = state; - } - public OSVR_AnalogReport(Pointer peer) { - super(peer); - } - public static class ByReference extends OSVR_AnalogReport implements Structure.ByReference { - - }; - public static class ByValue extends OSVR_AnalogReport implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_AngularAccelerationReport.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_AngularAccelerationReport.java deleted file mode 100644 index c7a3821dd7..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_AngularAccelerationReport.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.jme3.system.osvr.osvrclientreporttypes; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class OSVR_AngularAccelerationReport extends Structure { - public int sensor; - /** C type : OSVR_AngularAccelerationState */ - public OSVR_IncrementalQuaternion state; - public OSVR_AngularAccelerationReport() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("sensor", "state"); - } - /** @param state C type : OSVR_AngularAccelerationState */ - public OSVR_AngularAccelerationReport(int sensor, OSVR_IncrementalQuaternion state) { - super(); - this.sensor = sensor; - this.state = state; - } - public OSVR_AngularAccelerationReport(Pointer peer) { - super(peer); - } - public static class ByReference extends OSVR_AngularAccelerationReport implements Structure.ByReference { - - }; - public static class ByValue extends OSVR_AngularAccelerationReport implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_AngularVelocityReport.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_AngularVelocityReport.java deleted file mode 100644 index bb526b7b1c..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_AngularVelocityReport.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.jme3.system.osvr.osvrclientreporttypes; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class OSVR_AngularVelocityReport extends Structure { - public int sensor; - /** C type : OSVR_AngularVelocityState */ - public OSVR_IncrementalQuaternion state; - public OSVR_AngularVelocityReport() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("sensor", "state"); - } - /** @param state C type : OSVR_AngularVelocityState */ - public OSVR_AngularVelocityReport(int sensor, OSVR_IncrementalQuaternion state) { - super(); - this.sensor = sensor; - this.state = state; - } - public OSVR_AngularVelocityReport(Pointer peer) { - super(peer); - } - public static class ByReference extends OSVR_AngularVelocityReport implements Structure.ByReference { - - }; - public static class ByValue extends OSVR_AngularVelocityReport implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_ButtonReport.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_ButtonReport.java deleted file mode 100644 index 4988433679..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_ButtonReport.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.jme3.system.osvr.osvrclientreporttypes; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class OSVR_ButtonReport extends Structure { - public int sensor; - /** C type : OSVR_ButtonState */ - public byte state; - public OSVR_ButtonReport() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("sensor", "state"); - } - /** @param state C type : OSVR_ButtonState */ - public OSVR_ButtonReport(int sensor, byte state) { - super(); - this.sensor = sensor; - this.state = state; - } - public OSVR_ButtonReport(Pointer peer) { - super(peer); - } - public static class ByReference extends OSVR_ButtonReport implements Structure.ByReference { - - }; - public static class ByValue extends OSVR_ButtonReport implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_DirectionReport.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_DirectionReport.java deleted file mode 100644 index 70af9a36ba..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_DirectionReport.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.jme3.system.osvr.osvrclientreporttypes; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class OSVR_DirectionReport extends Structure { - /** C type : OSVR_ChannelCount */ - public int sensor; - /** C type : OSVR_DirectionState */ - public OSVR_Vec3 direction; - public OSVR_DirectionReport() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("sensor", "direction"); - } - /** - * @param sensor C type : OSVR_ChannelCount
- * @param direction C type : OSVR_DirectionState - */ - public OSVR_DirectionReport(int sensor, OSVR_Vec3 direction) { - super(); - this.sensor = sensor; - this.direction = direction; - } - public OSVR_DirectionReport(Pointer peer) { - super(peer); - } - public static class ByReference extends OSVR_DirectionReport implements Structure.ByReference { - - }; - public static class ByValue extends OSVR_DirectionReport implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_EyeTracker2DReport.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_EyeTracker2DReport.java deleted file mode 100644 index f72a176f70..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_EyeTracker2DReport.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.jme3.system.osvr.osvrclientreporttypes; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class OSVR_EyeTracker2DReport extends Structure { - /** C type : OSVR_ChannelCount */ - public int sensor; - /** C type : OSVR_EyeTracker2DState */ - public OSVR_Vec2 state; - public OSVR_EyeTracker2DReport() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("sensor", "state"); - } - /** - * @param sensor C type : OSVR_ChannelCount
- * @param state C type : OSVR_EyeTracker2DState - */ - public OSVR_EyeTracker2DReport(int sensor, OSVR_Vec2 state) { - super(); - this.sensor = sensor; - this.state = state; - } - public OSVR_EyeTracker2DReport(Pointer peer) { - super(peer); - } - public static class ByReference extends OSVR_EyeTracker2DReport implements Structure.ByReference { - - }; - public static class ByValue extends OSVR_EyeTracker2DReport implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_EyeTracker3DReport.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_EyeTracker3DReport.java deleted file mode 100644 index 93af317c37..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_EyeTracker3DReport.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.jme3.system.osvr.osvrclientreporttypes; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class OSVR_EyeTracker3DReport extends Structure { - /** C type : OSVR_ChannelCount */ - public int sensor; - /** C type : OSVR_EyeTracker3DState */ - public OSVR_EyeTracker3DState state; - public OSVR_EyeTracker3DReport() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("sensor", "state"); - } - /** - * @param sensor C type : OSVR_ChannelCount
- * @param state C type : OSVR_EyeTracker3DState - */ - public OSVR_EyeTracker3DReport(int sensor, OSVR_EyeTracker3DState state) { - super(); - this.sensor = sensor; - this.state = state; - } - public OSVR_EyeTracker3DReport(Pointer peer) { - super(peer); - } - public static class ByReference extends OSVR_EyeTracker3DReport implements Structure.ByReference { - - }; - public static class ByValue extends OSVR_EyeTracker3DReport implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_EyeTracker3DState.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_EyeTracker3DState.java deleted file mode 100644 index 29da57b206..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_EyeTracker3DState.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.jme3.system.osvr.osvrclientreporttypes; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class OSVR_EyeTracker3DState extends Structure { - /** C type : OSVR_CBool */ - public byte directionValid; - /** C type : OSVR_DirectionState */ - public OSVR_Vec3 direction; - /** C type : OSVR_CBool */ - public byte basePointValid; - /** C type : OSVR_PositionState */ - public OSVR_Vec3 basePoint; - public OSVR_EyeTracker3DState() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("directionValid", "direction", "basePointValid", "basePoint"); - } - /** - * @param directionValid C type : OSVR_CBool
- * @param direction C type : OSVR_DirectionState
- * @param basePointValid C type : OSVR_CBool
- * @param basePoint C type : OSVR_PositionState - */ - public OSVR_EyeTracker3DState(byte directionValid, OSVR_Vec3 direction, byte basePointValid, OSVR_Vec3 basePoint) { - super(); - this.directionValid = directionValid; - this.direction = direction; - this.basePointValid = basePointValid; - this.basePoint = basePoint; - } - public OSVR_EyeTracker3DState(Pointer peer) { - super(peer); - } - public static class ByReference extends OSVR_EyeTracker3DState implements Structure.ByReference { - - }; - public static class ByValue extends OSVR_EyeTracker3DState implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_EyeTrackerBlinkReport.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_EyeTrackerBlinkReport.java deleted file mode 100644 index 0ad5f64361..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_EyeTrackerBlinkReport.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.jme3.system.osvr.osvrclientreporttypes; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class OSVR_EyeTrackerBlinkReport extends Structure { - /** C type : OSVR_ChannelCount */ - public int sensor; - /** C type : OSVR_EyeTrackerBlinkState */ - public byte state; - public OSVR_EyeTrackerBlinkReport() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("sensor", "state"); - } - /** - * @param sensor C type : OSVR_ChannelCount
- * @param state C type : OSVR_EyeTrackerBlinkState - */ - public OSVR_EyeTrackerBlinkReport(int sensor, byte state) { - super(); - this.sensor = sensor; - this.state = state; - } - public OSVR_EyeTrackerBlinkReport(Pointer peer) { - super(peer); - } - public static class ByReference extends OSVR_EyeTrackerBlinkReport implements Structure.ByReference { - - }; - public static class ByValue extends OSVR_EyeTrackerBlinkReport implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_IncrementalQuaternion.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_IncrementalQuaternion.java deleted file mode 100644 index 07cb64c949..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_IncrementalQuaternion.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.jme3.system.osvr.osvrclientreporttypes; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class OSVR_IncrementalQuaternion extends Structure { - /** C type : OSVR_Quaternion */ - public OSVR_Quaternion incrementalRotation; - public double dt; - public OSVR_IncrementalQuaternion() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("incrementalRotation", "dt"); - } - /** @param incrementalRotation C type : OSVR_Quaternion */ - public OSVR_IncrementalQuaternion(OSVR_Quaternion incrementalRotation, double dt) { - super(); - this.incrementalRotation = incrementalRotation; - this.dt = dt; - } - public OSVR_IncrementalQuaternion(Pointer peer) { - super(peer); - } - public static class ByReference extends OSVR_IncrementalQuaternion implements Structure.ByReference { - - }; - public static class ByValue extends OSVR_IncrementalQuaternion implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_LinearAccelerationReport.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_LinearAccelerationReport.java deleted file mode 100644 index 4baffbd65d..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_LinearAccelerationReport.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.jme3.system.osvr.osvrclientreporttypes; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class OSVR_LinearAccelerationReport extends Structure { - public int sensor; - /** C type : OSVR_LinearAccelerationState */ - public OSVR_Vec3 state; - public OSVR_LinearAccelerationReport() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("sensor", "state"); - } - /** @param state C type : OSVR_LinearAccelerationState */ - public OSVR_LinearAccelerationReport(int sensor, OSVR_Vec3 state) { - super(); - this.sensor = sensor; - this.state = state; - } - public OSVR_LinearAccelerationReport(Pointer peer) { - super(peer); - } - public static class ByReference extends OSVR_LinearAccelerationReport implements Structure.ByReference { - - }; - public static class ByValue extends OSVR_LinearAccelerationReport implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_LinearVelocityReport.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_LinearVelocityReport.java deleted file mode 100644 index c40b3e74ae..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_LinearVelocityReport.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.jme3.system.osvr.osvrclientreporttypes; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class OSVR_LinearVelocityReport extends Structure { - public int sensor; - /** C type : OSVR_LinearVelocityState */ - public OSVR_Vec3 state; - public OSVR_LinearVelocityReport() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("sensor", "state"); - } - /** @param state C type : OSVR_LinearVelocityState */ - public OSVR_LinearVelocityReport(int sensor, OSVR_Vec3 state) { - super(); - this.sensor = sensor; - this.state = state; - } - public OSVR_LinearVelocityReport(Pointer peer) { - super(peer); - } - public static class ByReference extends OSVR_LinearVelocityReport implements Structure.ByReference { - - }; - public static class ByValue extends OSVR_LinearVelocityReport implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_Location2DReport.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_Location2DReport.java deleted file mode 100644 index 8c05d755a8..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_Location2DReport.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.jme3.system.osvr.osvrclientreporttypes; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class OSVR_Location2DReport extends Structure { - /** C type : OSVR_ChannelCount */ - public int sensor; - /** C type : OSVR_Location2DState */ - public OSVR_Vec2 location; - public OSVR_Location2DReport() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("sensor", "location"); - } - /** - * @param sensor C type : OSVR_ChannelCount
- * @param location C type : OSVR_Location2DState - */ - public OSVR_Location2DReport(int sensor, OSVR_Vec2 location) { - super(); - this.sensor = sensor; - this.location = location; - } - public OSVR_Location2DReport(Pointer peer) { - super(peer); - } - public static class ByReference extends OSVR_Location2DReport implements Structure.ByReference { - - }; - public static class ByValue extends OSVR_Location2DReport implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_NaviPositionReport.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_NaviPositionReport.java deleted file mode 100644 index 47cb3d563a..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_NaviPositionReport.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.jme3.system.osvr.osvrclientreporttypes; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class OSVR_NaviPositionReport extends Structure { - /** C type : OSVR_ChannelCount */ - public int sensor; - /** C type : OSVR_NaviPositionState */ - public OSVR_Vec2 state; - public OSVR_NaviPositionReport() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("sensor", "state"); - } - /** - * @param sensor C type : OSVR_ChannelCount
- * @param state C type : OSVR_NaviPositionState - */ - public OSVR_NaviPositionReport(int sensor, OSVR_Vec2 state) { - super(); - this.sensor = sensor; - this.state = state; - } - public OSVR_NaviPositionReport(Pointer peer) { - super(peer); - } - public static class ByReference extends OSVR_NaviPositionReport implements Structure.ByReference { - - }; - public static class ByValue extends OSVR_NaviPositionReport implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_NaviVelocityReport.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_NaviVelocityReport.java deleted file mode 100644 index ff07a8a0a2..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_NaviVelocityReport.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.jme3.system.osvr.osvrclientreporttypes; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class OSVR_NaviVelocityReport extends Structure { - /** C type : OSVR_ChannelCount */ - public int sensor; - /** C type : OSVR_NaviVelocityState */ - public OSVR_Vec2 state; - public OSVR_NaviVelocityReport() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("sensor", "state"); - } - /** - * @param sensor C type : OSVR_ChannelCount
- * @param state C type : OSVR_NaviVelocityState - */ - public OSVR_NaviVelocityReport(int sensor, OSVR_Vec2 state) { - super(); - this.sensor = sensor; - this.state = state; - } - public OSVR_NaviVelocityReport(Pointer peer) { - super(peer); - } - public static class ByReference extends OSVR_NaviVelocityReport implements Structure.ByReference { - - }; - public static class ByValue extends OSVR_NaviVelocityReport implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_OrientationReport.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_OrientationReport.java deleted file mode 100644 index 7b8dc7bde0..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_OrientationReport.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.jme3.system.osvr.osvrclientreporttypes; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class OSVR_OrientationReport extends Structure { - public int sensor; - /** C type : OSVR_OrientationState */ - public OSVR_Quaternion rotation; - public OSVR_OrientationReport() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("sensor", "rotation"); - } - /** @param rotation C type : OSVR_OrientationState */ - public OSVR_OrientationReport(int sensor, OSVR_Quaternion rotation) { - super(); - this.sensor = sensor; - this.rotation = rotation; - } - public OSVR_OrientationReport(Pointer peer) { - super(peer); - } - public static class ByReference extends OSVR_OrientationReport implements Structure.ByReference { - - }; - public static class ByValue extends OSVR_OrientationReport implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_Pose3.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_Pose3.java deleted file mode 100644 index 5dacd27388..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_Pose3.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.jme3.system.osvr.osvrclientreporttypes; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class OSVR_Pose3 extends Structure { - /** C type : OSVR_Vec3 */ - public OSVR_Vec3 translation; - /** C type : OSVR_Quaternion */ - public OSVR_Quaternion rotation; - public OSVR_Pose3() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("translation", "rotation"); - } - /** - * @param translation C type : OSVR_Vec3
- * @param rotation C type : OSVR_Quaternion - */ - public OSVR_Pose3(OSVR_Vec3 translation, OSVR_Quaternion rotation) { - super(); - this.translation = translation; - this.rotation = rotation; - } - public OSVR_Pose3(Pointer peer) { - super(peer); - } - public static class ByReference extends OSVR_Pose3 implements Structure.ByReference { - - }; - public static class ByValue extends OSVR_Pose3 implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_PoseReport.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_PoseReport.java deleted file mode 100644 index e39eea50f6..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_PoseReport.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.jme3.system.osvr.osvrclientreporttypes; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class OSVR_PoseReport extends Structure { - public int sensor; - /** C type : OSVR_PoseState */ - public OSVR_Pose3 pose; - public OSVR_PoseReport() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("sensor", "pose"); - } - /** @param pose C type : OSVR_PoseState */ - public OSVR_PoseReport(int sensor, OSVR_Pose3 pose) { - super(); - this.sensor = sensor; - this.pose = pose; - } - public OSVR_PoseReport(Pointer peer) { - super(peer); - } - public static class ByReference extends OSVR_PoseReport implements Structure.ByReference { - - }; - public static class ByValue extends OSVR_PoseReport implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_PositionReport.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_PositionReport.java deleted file mode 100644 index d93fc4a1fe..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_PositionReport.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.jme3.system.osvr.osvrclientreporttypes; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class OSVR_PositionReport extends Structure { - public int sensor; - /** C type : OSVR_PositionState */ - public OSVR_Vec3 xyz; - public OSVR_PositionReport() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("sensor", "xyz"); - } - /** @param xyz C type : OSVR_PositionState */ - public OSVR_PositionReport(int sensor, OSVR_Vec3 xyz) { - super(); - this.sensor = sensor; - this.xyz = xyz; - } - public OSVR_PositionReport(Pointer peer) { - super(peer); - } - public static class ByReference extends OSVR_PositionReport implements Structure.ByReference { - - }; - public static class ByValue extends OSVR_PositionReport implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_Quaternion.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_Quaternion.java deleted file mode 100644 index 72952297a1..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_Quaternion.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.jme3.system.osvr.osvrclientreporttypes; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class OSVR_Quaternion extends Structure { - /** C type : double[4] */ - public double[] data = new double[4]; - public OSVR_Quaternion() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("data"); - } - /** @param data C type : double[4] */ - public OSVR_Quaternion(double data[]) { - super(); - if ((data.length != this.data.length)) - throw new IllegalArgumentException("Wrong array size !"); - this.data = data; - } - public OSVR_Quaternion(Pointer peer) { - super(peer); - } - public static class ByReference extends OSVR_Quaternion implements Structure.ByReference { - - }; - public static class ByValue extends OSVR_Quaternion implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_Vec2.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_Vec2.java deleted file mode 100644 index 7427d14461..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_Vec2.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.jme3.system.osvr.osvrclientreporttypes; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class OSVR_Vec2 extends Structure { - /** C type : double[2] */ - public double[] data = new double[2]; - public OSVR_Vec2() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("data"); - } - /** @param data C type : double[2] */ - public OSVR_Vec2(double data[]) { - super(); - if ((data.length != this.data.length)) - throw new IllegalArgumentException("Wrong array size !"); - this.data = data; - } - public OSVR_Vec2(Pointer peer) { - super(peer); - } - public static class ByReference extends OSVR_Vec2 implements Structure.ByReference { - - }; - public static class ByValue extends OSVR_Vec2 implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_Vec3.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_Vec3.java deleted file mode 100644 index b3b2ed8893..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_Vec3.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.jme3.system.osvr.osvrclientreporttypes; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class OSVR_Vec3 extends Structure { - /** C type : double[3] */ - public double[] data = new double[3]; - public OSVR_Vec3() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("data"); - } - /** @param data C type : double[3] */ - public OSVR_Vec3(double data[]) { - super(); - if ((data.length != this.data.length)) - throw new IllegalArgumentException("Wrong array size !"); - this.data = data; - } - public OSVR_Vec3(Pointer peer) { - super(peer); - } - public static class ByReference extends OSVR_Vec3 implements Structure.ByReference { - - }; - public static class ByValue extends OSVR_Vec3 implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_VelocityReport.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_VelocityReport.java deleted file mode 100644 index da65aaf62c..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_VelocityReport.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.jme3.system.osvr.osvrclientreporttypes; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class OSVR_VelocityReport extends Structure { - public int sensor; - /** C type : OSVR_VelocityState */ - public OSVR_VelocityState state; - public OSVR_VelocityReport() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("sensor", "state"); - } - /** @param state C type : OSVR_VelocityState */ - public OSVR_VelocityReport(int sensor, OSVR_VelocityState state) { - super(); - this.sensor = sensor; - this.state = state; - } - public OSVR_VelocityReport(Pointer peer) { - super(peer); - } - public static class ByReference extends OSVR_VelocityReport implements Structure.ByReference { - - }; - public static class ByValue extends OSVR_VelocityReport implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_VelocityState.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_VelocityState.java deleted file mode 100644 index 4a4589a077..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OSVR_VelocityState.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.jme3.system.osvr.osvrclientreporttypes; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class OSVR_VelocityState extends Structure { - /** C type : OSVR_LinearVelocityState */ - public OSVR_Vec3 linearVelocity; - /** C type : OSVR_CBool */ - public byte linearVelocityValid; - /** C type : OSVR_AngularVelocityState */ - public OSVR_IncrementalQuaternion angularVelocity; - /** C type : OSVR_CBool */ - public byte angularVelocityValid; - public OSVR_VelocityState() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("linearVelocity", "linearVelocityValid", "angularVelocity", "angularVelocityValid"); - } - /** - * @param linearVelocity C type : OSVR_LinearVelocityState
- * @param linearVelocityValid C type : OSVR_CBool
- * @param angularVelocity C type : OSVR_AngularVelocityState
- * @param angularVelocityValid C type : OSVR_CBool - */ - public OSVR_VelocityState(OSVR_Vec3 linearVelocity, byte linearVelocityValid, OSVR_IncrementalQuaternion angularVelocity, byte angularVelocityValid) { - super(); - this.linearVelocity = linearVelocity; - this.linearVelocityValid = linearVelocityValid; - this.angularVelocity = angularVelocity; - this.angularVelocityValid = angularVelocityValid; - } - public OSVR_VelocityState(Pointer peer) { - super(peer); - } - public static class ByReference extends OSVR_VelocityState implements Structure.ByReference { - - }; - public static class ByValue extends OSVR_VelocityState implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OsvrClientReportTypesLibrary.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OsvrClientReportTypesLibrary.java deleted file mode 100644 index 4289cb200f..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OsvrClientReportTypesLibrary.java +++ /dev/null @@ -1,79 +0,0 @@ -package com.jme3.system.osvr.osvrclientreporttypes; -import com.sun.jna.Library; -import com.sun.jna.Native; -import com.sun.jna.NativeLibrary; -/** - * JNA Wrapper for library osvrClientReportTypes
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class OsvrClientReportTypesLibrary implements Library { - public static final String JNA_LIBRARY_NAME = "osvrClientKit"; - public static final NativeLibrary JNA_NATIVE_LIB = NativeLibrary.getInstance(OsvrClientReportTypesLibrary.JNA_LIBRARY_NAME); - static { - Native.register(OsvrClientReportTypesLibrary.class, OsvrClientReportTypesLibrary.JNA_NATIVE_LIB); - } - public static final int OSVR_TRUE = 1; - public static final int OSVR_FALSE = 0; - public static final int OSVR_BUTTON_PRESSED = 1; - public static final int OSVR_BUTTON_NOT_PRESSED = 0; - public static final int OSVR_EYE_BLINK = 1; - public static final int OSVR_EYE_NO_BLINK = 0; - /** Original signature : double osvrVec3GetX(const OSVR_Vec3*) */ - public static native double osvrVec3GetX(OSVR_Vec3 v); - /** Original signature : void osvrVec3SetX(OSVR_Vec3*, double) */ - public static native void osvrVec3SetX(OSVR_Vec3 v, double val); - /** Original signature : double osvrVec3GetY(const OSVR_Vec3*) */ - public static native double osvrVec3GetY(OSVR_Vec3 v); - /** Original signature : void osvrVec3SetY(OSVR_Vec3*, double) */ - public static native void osvrVec3SetY(OSVR_Vec3 v, double val); - /** Original signature : double osvrVec3GetZ(const OSVR_Vec3*) */ - public static native double osvrVec3GetZ(OSVR_Vec3 v); - /** Original signature : void osvrVec3SetZ(OSVR_Vec3*, double) */ - public static native void osvrVec3SetZ(OSVR_Vec3 v, double val); - /** - * Set a Vec3 to the zero vector. - * Original signature : void osvrVec3Zero(OSVR_Vec3*) - */ - public static native void osvrVec3Zero(OSVR_Vec3 v); - /** Original signature : double osvrQuatGetW(const OSVR_Quaternion*) */ - public static native double osvrQuatGetW(OSVR_Quaternion q); - /** Original signature : void osvrQuatSetW(OSVR_Quaternion*, double) */ - public static native void osvrQuatSetW(OSVR_Quaternion q, double val); - /** Original signature : double osvrQuatGetX(const OSVR_Quaternion*) */ - public static native double osvrQuatGetX(OSVR_Quaternion q); - /** Original signature : void osvrQuatSetX(OSVR_Quaternion*, double) */ - public static native void osvrQuatSetX(OSVR_Quaternion q, double val); - /** Original signature : double osvrQuatGetY(const OSVR_Quaternion*) */ - public static native double osvrQuatGetY(OSVR_Quaternion q); - /** Original signature : void osvrQuatSetY(OSVR_Quaternion*, double) */ - public static native void osvrQuatSetY(OSVR_Quaternion q, double val); - /** Original signature : double osvrQuatGetZ(const OSVR_Quaternion*) */ - public static native double osvrQuatGetZ(OSVR_Quaternion q); - /** Original signature : void osvrQuatSetZ(OSVR_Quaternion*, double) */ - public static native void osvrQuatSetZ(OSVR_Quaternion q, double val); - /** - * Set a quaternion to the identity rotation. - * Original signature : void osvrQuatSetIdentity(OSVR_Quaternion*) - */ - public static native void osvrQuatSetIdentity(OSVR_Quaternion q); - /** - * Set a pose to identity. - * Original signature : void osvrPose3SetIdentity(OSVR_Pose3*) - */ - public static native void osvrPose3SetIdentity(OSVR_Pose3 pose); - /** Original signature : double osvrVec2GetX(const OSVR_Vec2*) */ - public static native double osvrVec2GetX(OSVR_Vec2 v); - /** Original signature : void osvrVec2SetX(OSVR_Vec2*, double) */ - public static native void osvrVec2SetX(OSVR_Vec2 v, double val); - /** Original signature : double osvrVec2GetY(const OSVR_Vec2*) */ - public static native double osvrVec2GetY(OSVR_Vec2 v); - /** Original signature : void osvrVec2SetY(OSVR_Vec2*, double) */ - public static native void osvrVec2SetY(OSVR_Vec2 v, double val); - /** - * Set a Vec2 to the zero vector. - * Original signature : void osvrVec2Zero(OSVR_Vec2*) - */ - public static native void osvrVec2Zero(OSVR_Vec2 v); -} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrdisplay/OsvrDisplayLibrary.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrdisplay/OsvrDisplayLibrary.java deleted file mode 100644 index de59467448..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrdisplay/OsvrDisplayLibrary.java +++ /dev/null @@ -1,851 +0,0 @@ -package com.jme3.system.osvr.osvrdisplay; -import com.jme3.system.osvr.osvrclientkit.OsvrClientKitLibrary; -import com.sun.jna.Library; -import com.sun.jna.Native; -import com.sun.jna.NativeLibrary; -import com.sun.jna.Pointer; -import com.sun.jna.PointerType; -import com.sun.jna.ptr.DoubleByReference; -import com.sun.jna.ptr.FloatByReference; -import com.sun.jna.ptr.IntByReference; -import com.sun.jna.ptr.PointerByReference; -import java.nio.ByteBuffer; -import java.nio.DoubleBuffer; -import java.nio.FloatBuffer; -import java.nio.IntBuffer; - -/** - * JNA Wrapper for library osvrDisplay
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class OsvrDisplayLibrary implements Library { - public static final String JNA_LIBRARY_NAME = "osvrClientKit"; - public static final NativeLibrary JNA_NATIVE_LIB = NativeLibrary.getInstance(OsvrDisplayLibrary.JNA_LIBRARY_NAME); - static { - Native.register(OsvrDisplayLibrary.class, OsvrDisplayLibrary.JNA_NATIVE_LIB); - } - /** - * Allocates a display configuration object populated with data from the
- * OSVR system.
- * Before this call will succeed, your application will need to be correctly
- * and fully connected to an OSVR server. You may consider putting this call in
- * a loop alternating with osvrClientUpdate() until this call succeeds.
- * Data provided by a display configuration object:
- * - The logical display topology (number and relationship of viewers, eyes,
- * and surfaces), which remains constant throughout the life of the
- * configuration object. (A method of notification of change here is TBD).
- * - Pose data for viewers (not required for rendering) and pose/view data for
- * eyes (used for rendering) which is based on tracker data: if used, these
- * should be queried every frame.
- * - Projection matrix data for surfaces, which while in current practice may
- * be relatively unchanging, we are not guaranteeing them to be constant:
- * these should be queried every frame.
- * - Video-input-relative viewport size/location for a surface: would like this
- * to be variable, but probably not feasible. If you have input, please
- * comment on the dev mailing list.
- * - Per-surface distortion strategy priorities/availabilities: constant. Note
- * the following, though...
- * - Per-surface distortion strategy parameters: variable, request each frame.
- * (Could make constant with a notification if needed?)
- * Important note: While most of this data is immediately available if you are
- * successful in getting a display config object, the pose-based data (viewer
- * pose, eye pose, eye view matrix) needs tracker state, so at least one (and in
- * practice, typically more) osvrClientUpdate() must be performed before a new
- * tracker report is available to populate that state. See
- * osvrClientCheckDisplayStartup() to query if all startup data is available.
- * todo Decide if relative viewport should be constant in a display config,
- * and update docs accordingly.
- * todo Decide if distortion params should be constant in a display config,
- * and update docs accordingly.
- * @return OSVR_RETURN_FAILURE if invalid parameters were passed or some other
- * error occurred, in which case the output argument is unmodified.
- * Original signature : OSVR_ReturnCode osvrClientGetDisplay(OSVR_ClientContext, OSVR_DisplayConfig*)
- * @deprecated use the safer method - * {@link #osvrClientGetDisplay(com.jme3.system.osvr.osvrclientkit.OsvrClientKitLibrary.OSVR_ClientContext, com.sun.jna.ptr.PointerByReference)} - * instead - */ - @Deprecated - public static native byte osvrClientGetDisplay(Pointer ctx, Pointer disp); - /** - * Allocates a display configuration object populated with data from the
- * OSVR system.
- * Before this call will succeed, your application will need to be correctly
- * and fully connected to an OSVR server. You may consider putting this call in
- * a loop alternating with osvrClientUpdate() until this call succeeds.
- * Data provided by a display configuration object:
- * - The logical display topology (number and relationship of viewers, eyes,
- * and surfaces), which remains constant throughout the life of the
- * configuration object. (A method of notification of change here is TBD).
- * - Pose data for viewers (not required for rendering) and pose/view data for
- * eyes (used for rendering) which is based on tracker data: if used, these
- * should be queried every frame.
- * - Projection matrix data for surfaces, which while in current practice may
- * be relatively unchanging, we are not guaranteeing them to be constant:
- * these should be queried every frame.
- * - Video-input-relative viewport size/location for a surface: would like this
- * to be variable, but probably not feasible. If you have input, please
- * comment on the dev mailing list.
- * - Per-surface distortion strategy priorities/availabilities: constant. Note
- * the following, though...
- * - Per-surface distortion strategy parameters: variable, request each frame.
- * (Could make constant with a notification if needed?)
- * Important note: While most of this data is immediately available if you are
- * successful in getting a display config object, the pose-based data (viewer
- * pose, eye pose, eye view matrix) needs tracker state, so at least one (and in
- * practice, typically more) osvrClientUpdate() must be performed before a new
- * tracker report is available to populate that state. See
- * osvrClientCheckDisplayStartup() to query if all startup data is available.
- * todo Decide if relative viewport should be constant in a display config,
- * and update docs accordingly.
- * todo Decide if distortion params should be constant in a display config,
- * and update docs accordingly.
- * @return OSVR_RETURN_FAILURE if invalid parameters were passed or some other
- * error occurred, in which case the output argument is unmodified.
- * Original signature : OSVR_ReturnCode osvrClientGetDisplay(OSVR_ClientContext, OSVR_DisplayConfig*) - */ - public static native byte osvrClientGetDisplay(OsvrClientKitLibrary.OSVR_ClientContext ctx, PointerByReference disp); - /** - * Allocates a display configuration object populated with data from the
- * OSVR system.
- * Before this call will succeed, your application will need to be correctly
- * and fully connected to an OSVR server. You may consider putting this call in
- * a loop alternating with osvrClientUpdate() until this call succeeds.
- * Data provided by a display configuration object:
- * - The logical display topology (number and relationship of viewers, eyes,
- * and surfaces), which remains constant throughout the life of the
- * configuration object. (A method of notification of change here is TBD).
- * - Pose data for viewers (not required for rendering) and pose/view data for
- * eyes (used for rendering) which is based on tracker data: if used, these
- * should be queried every frame.
- * - Projection matrix data for surfaces, which while in current practice may
- * be relatively unchanging, we are not guaranteeing them to be constant:
- * these should be queried every frame.
- * - Video-input-relative viewport size/location for a surface: would like this
- * to be variable, but probably not feasible. If you have input, please
- * comment on the dev mailing list.
- * - Per-surface distortion strategy priorities/availabilities: constant. Note
- * the following, though...
- * - Per-surface distortion strategy parameters: variable, request each frame.
- * (Could make constant with a notification if needed?)
- * Important note: While most of this data is immediately available if you are
- * successful in getting a display config object, the pose-based data (viewer
- * pose, eye pose, eye view matrix) needs tracker state, so at least one (and in
- * practice, typically more) osvrClientUpdate() must be performed before a new
- * tracker report is available to populate that state. See
- * osvrClientCheckDisplayStartup() to query if all startup data is available.
- * todo Decide if relative viewport should be constant in a display config,
- * and update docs accordingly.
- * todo Decide if distortion params should be constant in a display config,
- * and update docs accordingly.
- * @return OSVR_RETURN_FAILURE if invalid parameters were passed or some other
- * error occurred, in which case the output argument is unmodified.
- * Original signature : OSVR_ReturnCode osvrClientGetDisplay(OSVR_ClientContext, OSVR_DisplayConfig*) - */ - public static native byte osvrClientGetDisplay(Pointer ctx, PointerByReference disp); - /** - * Frees a display configuration object. The corresponding context must
- * still be open.
- * If you fail to call this, it will be automatically called as part of
- * clean-up when the corresponding context is closed.
- * @return OSVR_RETURN_FAILURE if a null config was passed, or if the given
- * display object was already freed.
- * Original signature : OSVR_ReturnCode osvrClientFreeDisplay(OSVR_DisplayConfig)
- * @deprecated use the safer method - * {@link #osvrClientFreeDisplay(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig)} - * instead - */ - @Deprecated - public static native byte osvrClientFreeDisplay(Pointer disp); - /** - * Frees a display configuration object. The corresponding context must
- * still be open.
- * If you fail to call this, it will be automatically called as part of
- * clean-up when the corresponding context is closed.
- * @return OSVR_RETURN_FAILURE if a null config was passed, or if the given
- * display object was already freed.
- * Original signature : OSVR_ReturnCode osvrClientFreeDisplay(OSVR_DisplayConfig) - */ - public static native byte osvrClientFreeDisplay(OsvrDisplayLibrary.OSVR_DisplayConfig disp); - /** - * Checks to see if a display is fully configured and ready, including
- * having received its first pose update.
- * Once this first succeeds, it will continue to succeed for the lifetime of
- * the display config object, so it is not necessary to keep calling once you
- * get a successful result.
- * @return OSVR_RETURN_FAILURE if a null config was passed, or if the given
- * display config object was otherwise not ready for full use.
- * Original signature : OSVR_ReturnCode osvrClientCheckDisplayStartup(OSVR_DisplayConfig)
- * @deprecated use the safer method - * {@link #osvrClientCheckDisplayStartup(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig)} - * instead - */ - @Deprecated - public static native byte osvrClientCheckDisplayStartup(Pointer disp); - /** - * Checks to see if a display is fully configured and ready, including
- * having received its first pose update.
- * Once this first succeeds, it will continue to succeed for the lifetime of
- * the display config object, so it is not necessary to keep calling once you
- * get a successful result.
- * @return OSVR_RETURN_FAILURE if a null config was passed, or if the given
- * display config object was otherwise not ready for full use.
- * Original signature : OSVR_ReturnCode osvrClientCheckDisplayStartup(OSVR_DisplayConfig) - */ - public static native byte osvrClientCheckDisplayStartup(OsvrDisplayLibrary.OSVR_DisplayConfig disp); - /** - * A display config can have one or more display inputs to pass pixels
- * over (HDMI/DVI connections, etcetera): retrieve the number of display inputs in
- * the current configuration.
- * @param disp Display config object.
- * @param numDisplayInputs Number of display inputs in the logical display
- * topology, **constant** throughout the active, valid lifetime of a display
- * config object.
- * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in
- * which case the output argument is unmodified.
- * Original signature : OSVR_ReturnCode osvrClientGetNumDisplayInputs(OSVR_DisplayConfig, OSVR_DisplayInputCount*)
- * @deprecated use the safer method - * {@link #osvrClientGetNumDisplayInputs(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, java.nio.ByteBuffer)} - * instead - */ - @Deprecated - public static native byte osvrClientGetNumDisplayInputs(Pointer disp, Pointer numDisplayInputs); - /** - * A display config can have one or more display inputs to pass pixels
- * over (HDMI/DVI connections, etcetera): retrieve the number of display inputs in
- * the current configuration.
- * @param disp Display config object.
- * @param numDisplayInputs Number of display inputs in the logical display
- * topology, **constant** throughout the active, valid lifetime of a display
- * config object.
- * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in
- * which case the output argument is unmodified.
- * Original signature : OSVR_ReturnCode osvrClientGetNumDisplayInputs(OSVR_DisplayConfig, OSVR_DisplayInputCount*) - */ - public static native byte osvrClientGetNumDisplayInputs(OsvrDisplayLibrary.OSVR_DisplayConfig disp, ByteBuffer numDisplayInputs); - /** - * Retrieve the pixel dimensions of a given display input for a display
- * config
- * @param disp Display config object.
- * @param displayInputIndex The zero-based index of the display input.
- * @param width Width (in pixels) of the display input.
- * @param height Height (in pixels) of the display input.
- * The out parameters are **constant** throughout the active, valid lifetime of
- * a display config object.
- * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in
- * which case the output arguments are unmodified.
- * Original signature : OSVR_ReturnCode osvrClientGetDisplayDimensions(OSVR_DisplayConfig, OSVR_DisplayInputCount, OSVR_DisplayDimension*, OSVR_DisplayDimension*)
- * @deprecated use the safer method - * {@link #osvrClientGetDisplayDimensions(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, byte, java.nio.IntBuffer, java.nio.IntBuffer)} - * instead - */ - @Deprecated - public static native byte osvrClientGetDisplayDimensions(Pointer disp, byte displayInputIndex, IntByReference width, IntByReference height); - /** - * Retrieve the pixel dimensions of a given display input for a display
- * config
- * @param disp Display config object.
- * @param displayInputIndex The zero-based index of the display input.
- * @param width Width (in pixels) of the display input.
- * @param height Height (in pixels) of the display input.
- * The out parameters are **constant** throughout the active, valid lifetime of
- * a display config object.
- * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in
- * which case the output arguments are unmodified.
- * Original signature : OSVR_ReturnCode osvrClientGetDisplayDimensions(OSVR_DisplayConfig, OSVR_DisplayInputCount, OSVR_DisplayDimension*, OSVR_DisplayDimension*) - */ - public static native byte osvrClientGetDisplayDimensions(OsvrDisplayLibrary.OSVR_DisplayConfig disp, byte displayInputIndex, IntBuffer width, IntBuffer height); - /** - * A display config can have one (or theoretically more) viewers:
- * retrieve the viewer count.
- * @param disp Display config object.
- * @param viewers Number of viewers in the logical display topology,
- * *constant** throughout the active, valid lifetime of a display config
- * object.
- * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case
- * the output argument is unmodified.
- * Original signature : OSVR_ReturnCode osvrClientGetNumViewers(OSVR_DisplayConfig, OSVR_ViewerCount*)
- * @deprecated use the safer method - * {@link #osvrClientGetNumViewers(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, java.nio.IntBuffer)} - * instead - */ - @Deprecated - public static native byte osvrClientGetNumViewers(Pointer disp, IntByReference viewers); - /** - * A display config can have one (or theoretically more) viewers:
- * retrieve the viewer count.
- * @param disp Display config object.
- * @param viewers Number of viewers in the logical display topology,
- * *constant** throughout the active, valid lifetime of a display config
- * object.
- * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case
- * the output argument is unmodified.
- * Original signature : OSVR_ReturnCode osvrClientGetNumViewers(OSVR_DisplayConfig, OSVR_ViewerCount*) - */ - public static native byte osvrClientGetNumViewers(OsvrDisplayLibrary.OSVR_DisplayConfig disp, IntBuffer viewers); - /** - * Get the pose of a viewer in a display config.
- * Note that there may not necessarily be any surfaces rendered from this pose
- * (it's the unused "center" eye in a stereo configuration, for instance) so
- * only use this if it makes integration into your engine or existing
- * applications (not originally designed for stereo) easier.
- * Will only succeed if osvrClientCheckDisplayStartup() succeeds.
- * @return OSVR_RETURN_FAILURE if invalid parameters were passed or no pose was
- * yet available, in which case the pose argument is unmodified.
- * Original signature : OSVR_ReturnCode osvrClientGetViewerPose(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_Pose3*)
- * @deprecated use the safer method - * {@link #osvrClientGetViewerPose(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, com.sun.jna.Pointer)} - * instead - */ - @Deprecated - public static native byte osvrClientGetViewerPose(Pointer disp, int viewer, Pointer pose); - /** - * Get the pose of a viewer in a display config.
- * Note that there may not necessarily be any surfaces rendered from this pose
- * (it's the unused "center" eye in a stereo configuration, for instance) so
- * only use this if it makes integration into your engine or existing
- * applications (not originally designed for stereo) easier.
- * Will only succeed if osvrClientCheckDisplayStartup() succeeds.
- * @return OSVR_RETURN_FAILURE if invalid parameters were passed or no pose was
- * yet available, in which case the pose argument is unmodified.
- * Original signature : OSVR_ReturnCode osvrClientGetViewerPose(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_Pose3*) - */ - public static native byte osvrClientGetViewerPose(OsvrDisplayLibrary.OSVR_DisplayConfig disp, int viewer, Pointer pose); - /** - * Each viewer in a display config can have one or more "eyes" which
- * have a substantially similar pose: get the count.
- * @param disp Display config object.
- * @param viewer Viewer ID
- * @param eyes Number of eyes for this viewer in the logical display
- * topology, **constant** throughout the active, valid lifetime of a display
- * config object
- * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case
- * the output argument is unmodified.
- * Original signature : OSVR_ReturnCode osvrClientGetNumEyesForViewer(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount*)
- * @deprecated use the safer method - * {@link #osvrClientGetNumEyesForViewer(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, java.nio.ByteBuffer)} - * instead - */ - @Deprecated - public static native byte osvrClientGetNumEyesForViewer(Pointer disp, int viewer, Pointer eyes); - /** - * Each viewer in a display config can have one or more "eyes" which
- * have a substantially similar pose: get the count.
- * @param disp Display config object.
- * @param viewer Viewer ID
- * @param eyes Number of eyes for this viewer in the logical display
- * topology, **constant** throughout the active, valid lifetime of a display
- * config object
- * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case
- * the output argument is unmodified.
- * Original signature : OSVR_ReturnCode osvrClientGetNumEyesForViewer(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount*) - */ - public static native byte osvrClientGetNumEyesForViewer(OsvrDisplayLibrary.OSVR_DisplayConfig disp, int viewer, ByteBuffer eyes); - /** - * Get the "viewpoint" for the given eye of a viewer in a display
- * config.
- * Will only succeed if osvrClientCheckDisplayStartup() succeeds.
- * @param disp Display config object
- * @param viewer Viewer ID
- * @param eye Eye ID
- * @param pose Room-space pose (not relative to pose of the viewer)
- * @return OSVR_RETURN_FAILURE if invalid parameters were passed or no pose was
- * yet available, in which case the pose argument is unmodified.
- * Original signature : OSVR_ReturnCode osvrClientGetViewerEyePose(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_Pose3*)
- * @deprecated use the safer method - * {@link #osvrClientGetViewerEyePose(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, byte, com.sun.jna.Pointer)} - * instead - */ - @Deprecated - public static native byte osvrClientGetViewerEyePose(Pointer disp, int viewer, byte eye, Pointer pose); - /** - * Get the "viewpoint" for the given eye of a viewer in a display
- * config.
- * Will only succeed if osvrClientCheckDisplayStartup() succeeds.
- * @param disp Display config object
- * @param viewer Viewer ID
- * @param eye Eye ID
- * @param pose Room-space pose (not relative to pose of the viewer)
- * @return OSVR_RETURN_FAILURE if invalid parameters were passed or no pose was
- * yet available, in which case the pose argument is unmodified.
- * Original signature : OSVR_ReturnCode osvrClientGetViewerEyePose(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_Pose3*) - */ - public static native byte osvrClientGetViewerEyePose(OsvrDisplayLibrary.OSVR_DisplayConfig disp, int viewer, byte eye, Pointer pose); - /** - * Get the view matrix (inverse of pose) for the given eye of a
- * viewer in a display config - matrix of **doubles**.
- * Will only succeed if osvrClientCheckDisplayStartup() succeeds.
- * @param disp Display config object
- * @param viewer Viewer ID
- * @param eye Eye ID
- * @param flags Bitwise OR of matrix convention flags (see @ref MatrixFlags)
- * @param mat Pass a double[::OSVR_MATRIX_SIZE] to get the transformation
- * matrix from room space to eye space (not relative to pose of the viewer)
- * @return OSVR_RETURN_FAILURE if invalid parameters were passed or no pose was
- * yet available, in which case the output argument is unmodified.
- * Original signature : OSVR_ReturnCode osvrClientGetViewerEyeViewMatrixd(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_MatrixConventions, double*)
- * @deprecated use the safer method - * {@link #osvrClientGetViewerEyeViewMatrixd(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, byte, short, java.nio.DoubleBuffer)} - * instead - */ - @Deprecated - public static native byte osvrClientGetViewerEyeViewMatrixd(Pointer disp, int viewer, byte eye, short flags, DoubleByReference mat); - /** - * Get the view matrix (inverse of pose) for the given eye of a
- * viewer in a display config - matrix of **doubles**.
- * Will only succeed if osvrClientCheckDisplayStartup() succeeds.
- * @param disp Display config object
- * @param viewer Viewer ID
- * @param eye Eye ID
- * @param flags Bitwise OR of matrix convention flags (see @ref MatrixFlags)
- * @param mat Pass a double[::OSVR_MATRIX_SIZE] to get the transformation
- * matrix from room space to eye space (not relative to pose of the viewer)
- * @return OSVR_RETURN_FAILURE if invalid parameters were passed or no pose was
- * yet available, in which case the output argument is unmodified.
- * Original signature : OSVR_ReturnCode osvrClientGetViewerEyeViewMatrixd(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_MatrixConventions, double*) - */ - public static native byte osvrClientGetViewerEyeViewMatrixd(OsvrDisplayLibrary.OSVR_DisplayConfig disp, int viewer, byte eye, short flags, DoubleBuffer mat); - /** - * Get the view matrix (inverse of pose) for the given eye of a
- * viewer in a display config - matrix of **floats**.
- * Will only succeed if osvrClientCheckDisplayStartup() succeeds.
- * @param disp Display config object
- * @param viewer Viewer ID
- * @param eye Eye ID
- * @param flags Bitwise OR of matrix convention flags (see @ref MatrixFlags)
- * @param mat Pass a float[::OSVR_MATRIX_SIZE] to get the transformation
- * matrix from room space to eye space (not relative to pose of the viewer)
- * @return OSVR_RETURN_FAILURE if invalid parameters were passed or no pose was
- * yet available, in which case the output argument is unmodified.
- * Original signature : OSVR_ReturnCode osvrClientGetViewerEyeViewMatrixf(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_MatrixConventions, float*)
- * @deprecated use the safer method - * {@link #osvrClientGetViewerEyeViewMatrixf(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, byte, short, java.nio.FloatBuffer)} - * instead - */ - @Deprecated - public static native byte osvrClientGetViewerEyeViewMatrixf(Pointer disp, int viewer, byte eye, short flags, FloatByReference mat); - /** - * Get the view matrix (inverse of pose) for the given eye of a
- * viewer in a display config - matrix of **floats**.
- * Will only succeed if osvrClientCheckDisplayStartup() succeeds.
- * @param disp Display config object
- * @param viewer Viewer ID
- * @param eye Eye ID
- * @param flags Bitwise OR of matrix convention flags (see @ref MatrixFlags)
- * @param mat Pass a float[::OSVR_MATRIX_SIZE] to get the transformation
- * matrix from room space to eye space (not relative to pose of the viewer)
- * @return OSVR_RETURN_FAILURE if invalid parameters were passed or no pose was
- * yet available, in which case the output argument is unmodified.
- * Original signature : OSVR_ReturnCode osvrClientGetViewerEyeViewMatrixf(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_MatrixConventions, float*) - */ - public static native byte osvrClientGetViewerEyeViewMatrixf(OsvrDisplayLibrary.OSVR_DisplayConfig disp, int viewer, byte eye, short flags, FloatBuffer mat); - /** - * Each eye of each viewer in a display config has one or more surfaces
- * (aka "screens") on which content should be rendered.
- * @param disp Display config object
- * @param viewer Viewer ID
- * @param eye Eye ID
- * @param surfaces Number of surfaces (numbered [0, surfaces - 1]) for the
- * given viewer and eye. **Constant** throughout the active, valid lifetime of
- * a display config object.
- * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case
- * the output argument is unmodified.
- * Original signature : OSVR_ReturnCode osvrClientGetNumSurfacesForViewerEye(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_SurfaceCount*)
- * @deprecated use the safer method - * {@link #osvrClientGetNumSurfacesForViewerEye(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, byte, java.nio.IntBuffer)} - * instead - */ - @Deprecated - public static native byte osvrClientGetNumSurfacesForViewerEye(Pointer disp, int viewer, byte eye, IntByReference surfaces); - /** - * Each eye of each viewer in a display config has one or more surfaces
- * (aka "screens") on which content should be rendered.
- * @param disp Display config object
- * @param viewer Viewer ID
- * @param eye Eye ID
- * @param surfaces Number of surfaces (numbered [0, surfaces - 1]) for the
- * given viewer and eye. **Constant** throughout the active, valid lifetime of
- * a display config object.
- * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case
- * the output argument is unmodified.
- * Original signature : OSVR_ReturnCode osvrClientGetNumSurfacesForViewerEye(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_SurfaceCount*) - */ - public static native byte osvrClientGetNumSurfacesForViewerEye(OsvrDisplayLibrary.OSVR_DisplayConfig disp, int viewer, byte eye, IntBuffer surfaces); - /** - * Get the dimensions/location of the viewport **within the display
- * input** for a surface seen by an eye of a viewer in a display config. (This
- * does not include other video inputs that may be on a single virtual desktop,
- * etc. or explicitly account for display configurations that use multiple
- * video inputs. It does not necessarily indicate that a viewport in the sense
- * of glViewport must be created with these parameters, though the parameter
- * order matches for convenience.)
- * @param disp Display config object
- * @param viewer Viewer ID
- * @param eye Eye ID
- * @param surface Surface ID
- * @param left Output: Distance in pixels from the left of the video input
- * to the left of the viewport.
- * @param bottom Output: Distance in pixels from the bottom of the video
- * input to the bottom of the viewport.
- * @param width Output: Width of viewport in pixels.
- * @param height Output: Height of viewport in pixels.
- * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case
- * the output arguments are unmodified.
- * Original signature : OSVR_ReturnCode osvrClientGetRelativeViewportForViewerEyeSurface(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_SurfaceCount, OSVR_ViewportDimension*, OSVR_ViewportDimension*, OSVR_ViewportDimension*, OSVR_ViewportDimension*)
- * @deprecated use the safer method - * {@link #osvrClientGetRelativeViewportForViewerEyeSurface(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, byte, int, java.nio.IntBuffer, java.nio.IntBuffer, java.nio.IntBuffer, java.nio.IntBuffer)} - * instead - */ - @Deprecated - public static native byte osvrClientGetRelativeViewportForViewerEyeSurface(Pointer disp, int viewer, byte eye, int surface, IntByReference left, IntByReference bottom, IntByReference width, IntByReference height); - /** - * Get the dimensions/location of the viewport **within the display
- * input** for a surface seen by an eye of a viewer in a display config. (This
- * does not include other video inputs that may be on a single virtual desktop,
- * etc. or explicitly account for display configurations that use multiple
- * video inputs. It does not necessarily indicate that a viewport in the sense
- * of glViewport must be created with these parameters, though the parameter
- * order matches for convenience.)
- * @param disp Display config object
- * @param viewer Viewer ID
- * @param eye Eye ID
- * @param surface Surface ID
- * @param left Output: Distance in pixels from the left of the video input
- * to the left of the viewport.
- * @param bottom Output: Distance in pixels from the bottom of the video
- * input to the bottom of the viewport.
- * @param width Output: Width of viewport in pixels.
- * @param height Output: Height of viewport in pixels.
- * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case
- * the output arguments are unmodified.
- * Original signature : OSVR_ReturnCode osvrClientGetRelativeViewportForViewerEyeSurface(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_SurfaceCount, OSVR_ViewportDimension*, OSVR_ViewportDimension*, OSVR_ViewportDimension*, OSVR_ViewportDimension*) - */ - public static native byte osvrClientGetRelativeViewportForViewerEyeSurface(OsvrDisplayLibrary.OSVR_DisplayConfig disp, int viewer, byte eye, int surface, IntBuffer left, IntBuffer bottom, IntBuffer width, IntBuffer height); - /** - * Get the index of the display input for a surface seen by an eye of a
- * viewer in a display config.
- * This is the OSVR-assigned display input: it may not (and in practice,
- * usually will not) match any platform-specific display indices. This function
- * exists to associate surfaces with video inputs as enumerated by
- * osvrClientGetNumDisplayInputs().
- * @param disp Display config object
- * @param viewer Viewer ID
- * @param eye Eye ID
- * @param surface Surface ID
- * @param displayInput Zero-based index of the display input pixels for
- * this surface are transmitted over.
- * This association is **constant** throughout the active, valid lifetime of a
- * display config object.
- * @see #osvrClientGetNumDisplayInputs(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, java.nio.ByteBuffer) - * @see #osvrClientGetRelativeViewportForViewerEyeSurface(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, byte, int, java.nio.IntBuffer, java.nio.IntBuffer, java.nio.IntBuffer, java.nio.IntBuffer) - * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which
- * case the output argument is unmodified.
- * Original signature : OSVR_ReturnCode osvrClientGetViewerEyeSurfaceDisplayInputIndex(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_SurfaceCount, OSVR_DisplayInputCount*)
- * @deprecated use the safer method - * {@link #osvrClientGetViewerEyeSurfaceDisplayInputIndex(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, byte, int, java.nio.ByteBuffer)} - * instead - */ - @Deprecated - public static native byte osvrClientGetViewerEyeSurfaceDisplayInputIndex(Pointer disp, int viewer, byte eye, int surface, Pointer displayInput); - /** - * Get the index of the display input for a surface seen by an eye of a
- * viewer in a display config.
- * This is the OSVR-assigned display input: it may not (and in practice,
- * usually will not) match any platform-specific display indices. This function
- * exists to associate surfaces with video inputs as enumerated by
- * osvrClientGetNumDisplayInputs().
- * @param disp Display config object
- * @param viewer Viewer ID
- * @param eye Eye ID
- * @param surface Surface ID
- * @param displayInput Zero-based index of the display input pixels for
- * this surface are transmitted over.
- * This association is **constant** throughout the active, valid lifetime of a
- * display config object.
- * @see #osvrClientGetNumDisplayInputs(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, java.nio.ByteBuffer) - * @see #osvrClientGetRelativeViewportForViewerEyeSurface(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, byte, int, java.nio.IntBuffer, java.nio.IntBuffer, java.nio.IntBuffer, java.nio.IntBuffer) - * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which
- * case the output argument is unmodified.
- * Original signature : OSVR_ReturnCode osvrClientGetViewerEyeSurfaceDisplayInputIndex(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_SurfaceCount, OSVR_DisplayInputCount*) - */ - public static native byte osvrClientGetViewerEyeSurfaceDisplayInputIndex(OsvrDisplayLibrary.OSVR_DisplayConfig disp, int viewer, byte eye, int surface, ByteBuffer displayInput); - /** - * Get the projection matrix for a surface seen by an eye of a viewer
- * in a display config. (double version)
- * @param disp Display config object
- * @param viewer Viewer ID
- * @param eye Eye ID
- * @param surface Surface ID
- * @param near Distance from viewpoint to near clipping plane - must be
- * positive.
- * @param far Distance from viewpoint to far clipping plane - must be positive
- * and not equal to near, typically greater than near.
- * @param flags Bitwise OR of matrix convention flags (see @ref MatrixFlags)
- * @param matrix Output projection matrix: supply an array of 16
- * (::OSVR_MATRIX_SIZE) doubles.
- * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case
- * the output argument is unmodified.
- * Original signature : OSVR_ReturnCode osvrClientGetViewerEyeSurfaceProjectionMatrixd(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_SurfaceCount, double, double, OSVR_MatrixConventions, double*)
- * @deprecated use the safer method - * {@link #osvrClientGetViewerEyeSurfaceProjectionMatrixd(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, byte, int, double, double, short, java.nio.DoubleBuffer)} - * instead - */ - @Deprecated - public static native byte osvrClientGetViewerEyeSurfaceProjectionMatrixd(Pointer disp, int viewer, byte eye, int surface, double near, double far, short flags, DoubleByReference matrix); - /** - * Get the projection matrix for a surface seen by an eye of a viewer
- * in a display config. (double version)
- * @param disp Display config object
- * @param viewer Viewer ID
- * @param eye Eye ID
- * @param surface Surface ID
- * @param near Distance from viewpoint to near clipping plane - must be
- * positive.
- * @param far Distance from viewpoint to far clipping plane - must be positive
- * and not equal to near, typically greater than near.
- * @param flags Bitwise OR of matrix convention flags (see @ref MatrixFlags)
- * @param matrix Output projection matrix: supply an array of 16
- * (::OSVR_MATRIX_SIZE) doubles.
- * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case
- * the output argument is unmodified.
- * Original signature : OSVR_ReturnCode osvrClientGetViewerEyeSurfaceProjectionMatrixd(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_SurfaceCount, double, double, OSVR_MatrixConventions, double*) - */ - public static native byte osvrClientGetViewerEyeSurfaceProjectionMatrixd(OsvrDisplayLibrary.OSVR_DisplayConfig disp, int viewer, byte eye, int surface, double near, double far, short flags, DoubleBuffer matrix); - /** - * Get the projection matrix for a surface seen by an eye of a viewer
- * in a display config. (float version)
- * @param disp Display config object
- * @param viewer Viewer ID
- * @param eye Eye ID
- * @param surface Surface ID
- * @param near Distance to near clipping plane - must be nonzero, typically
- * positive.
- * @param far Distance to far clipping plane - must be nonzero, typically
- * positive and greater than near.
- * @param flags Bitwise OR of matrix convention flags (see @ref MatrixFlags)
- * @param matrix Output projection matrix: supply an array of 16
- * (::OSVR_MATRIX_SIZE) floats.
- * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case
- * the output argument is unmodified.
- * Original signature : OSVR_ReturnCode osvrClientGetViewerEyeSurfaceProjectionMatrixf(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_SurfaceCount, float, float, OSVR_MatrixConventions, float*)
- * @deprecated use the safer method - * {@link #osvrClientGetViewerEyeSurfaceProjectionMatrixf(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, byte, int, float, float, short, java.nio.FloatBuffer)} - * instead - */ - @Deprecated - public static native byte osvrClientGetViewerEyeSurfaceProjectionMatrixf(Pointer disp, int viewer, byte eye, int surface, float near, float far, short flags, FloatByReference matrix); - /** - * Get the projection matrix for a surface seen by an eye of a viewer
- * in a display config. (float version)
- * @param disp Display config object
- * @param viewer Viewer ID
- * @param eye Eye ID
- * @param surface Surface ID
- * @param near Distance to near clipping plane - must be nonzero, typically
- * positive.
- * @param far Distance to far clipping plane - must be nonzero, typically
- * positive and greater than near.
- * @param flags Bitwise OR of matrix convention flags (see @ref MatrixFlags)
- * @param matrix Output projection matrix: supply an array of 16
- * (::OSVR_MATRIX_SIZE) floats.
- * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case
- * the output argument is unmodified.
- * Original signature : OSVR_ReturnCode osvrClientGetViewerEyeSurfaceProjectionMatrixf(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_SurfaceCount, float, float, OSVR_MatrixConventions, float*) - */ - public static native byte osvrClientGetViewerEyeSurfaceProjectionMatrixf(OsvrDisplayLibrary.OSVR_DisplayConfig disp, int viewer, byte eye, int surface, float near, float far, short flags, FloatBuffer matrix); - /** - * Get the clipping planes (positions at unit distance) for a surface
- * seen by an eye of a viewer
- * in a display config.
- * This is only for use in integrations that cannot accept a fully-formulated
- * projection matrix as returned by
- * osvrClientGetViewerEyeSurfaceProjectionMatrixf() or
- * osvrClientGetViewerEyeSurfaceProjectionMatrixd(), and may not necessarily
- * provide the same optimizations.
- * As all the planes are given at unit (1) distance, before passing these
- * planes to a consuming function in your application/engine, you will typically
- * divide them by your near clipping plane distance.
- * @param disp Display config object
- * @param viewer Viewer ID
- * @param eye Eye ID
- * @param surface Surface ID
- * @param left Distance to left clipping plane
- * @param right Distance to right clipping plane
- * @param bottom Distance to bottom clipping plane
- * @param top Distance to top clipping plane
- * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case
- * the output arguments are unmodified.
- * Original signature : OSVR_ReturnCode osvrClientGetViewerEyeSurfaceProjectionClippingPlanes(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_SurfaceCount, double*, double*, double*, double*)
- * @deprecated use the safer method - * {@link #osvrClientGetViewerEyeSurfaceProjectionClippingPlanes(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, byte, int, java.nio.DoubleBuffer, java.nio.DoubleBuffer, java.nio.DoubleBuffer, java.nio.DoubleBuffer)} - * instead - */ - @Deprecated - public static native byte osvrClientGetViewerEyeSurfaceProjectionClippingPlanes(Pointer disp, int viewer, byte eye, int surface, DoubleByReference left, DoubleByReference right, DoubleByReference bottom, DoubleByReference top); - /** - * Get the clipping planes (positions at unit distance) for a surface
- * seen by an eye of a viewer
- * in a display config.
- * This is only for use in integrations that cannot accept a fully-formulated
- * projection matrix as returned by
- * osvrClientGetViewerEyeSurfaceProjectionMatrixf() or
- * osvrClientGetViewerEyeSurfaceProjectionMatrixd(), and may not necessarily
- * provide the same optimizations.
- * As all the planes are given at unit (1) distance, before passing these
- * planes to a consuming function in your application/engine, you will typically
- * divide them by your near clipping plane distance.
- * @param disp Display config object
- * @param viewer Viewer ID
- * @param eye Eye ID
- * @param surface Surface ID
- * @param left Distance to left clipping plane
- * @param right Distance to right clipping plane
- * @param bottom Distance to bottom clipping plane
- * @param top Distance to top clipping plane
- * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case
- * the output arguments are unmodified.
- * Original signature : OSVR_ReturnCode osvrClientGetViewerEyeSurfaceProjectionClippingPlanes(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_SurfaceCount, double*, double*, double*, double*) - */ - public static native byte osvrClientGetViewerEyeSurfaceProjectionClippingPlanes(OsvrDisplayLibrary.OSVR_DisplayConfig disp, int viewer, byte eye, int surface, DoubleBuffer left, DoubleBuffer right, DoubleBuffer bottom, DoubleBuffer top); - /** - * Determines if a surface seen by an eye of a viewer in a display
- * config requests some distortion to be performed.
- * This simply reports true or false, and does not specify which kind of
- * distortion implementations have been parameterized for this display. For
- * each distortion implementation your application supports, you'll want to
- * call the corresponding priority function to find out if it is available.
- * @param disp Display config object
- * @param viewer Viewer ID
- * @param eye Eye ID
- * @param surface Surface ID
- * @param distortionRequested Output parameter: whether distortion is
- * requested. **Constant** throughout the active, valid lifetime of a display
- * config object.
- * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case
- * the output argument is unmodified.
- * Original signature : OSVR_ReturnCode osvrClientDoesViewerEyeSurfaceWantDistortion(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_SurfaceCount, OSVR_CBool*)
- * @deprecated use the safer method - * {@link #osvrClientDoesViewerEyeSurfaceWantDistortion(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, byte, int, java.nio.ByteBuffer)} - * instead - */ - @Deprecated - public static native byte osvrClientDoesViewerEyeSurfaceWantDistortion(Pointer disp, int viewer, byte eye, int surface, Pointer distortionRequested); - /** - * Determines if a surface seen by an eye of a viewer in a display
- * config requests some distortion to be performed.
- * This simply reports true or false, and does not specify which kind of
- * distortion implementations have been parameterized for this display. For
- * each distortion implementation your application supports, you'll want to
- * call the corresponding priority function to find out if it is available.
- * @param disp Display config object
- * @param viewer Viewer ID
- * @param eye Eye ID
- * @param surface Surface ID
- * @param distortionRequested Output parameter: whether distortion is
- * requested. **Constant** throughout the active, valid lifetime of a display
- * config object.
- * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case
- * the output argument is unmodified.
- * Original signature : OSVR_ReturnCode osvrClientDoesViewerEyeSurfaceWantDistortion(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_SurfaceCount, OSVR_CBool*) - */ - public static native byte osvrClientDoesViewerEyeSurfaceWantDistortion(OsvrDisplayLibrary.OSVR_DisplayConfig disp, int viewer, byte eye, int surface, ByteBuffer distortionRequested); - /** - * Returns the priority/availability of radial distortion parameters for
- * a surface seen by an eye of a viewer in a display config.
- * If osvrClientDoesViewerEyeSurfaceWantDistortion() reports false, then the
- * display does not request distortion of any sort, and thus neither this nor
- * any other distortion strategy priority function will report an "available"
- * priority.
- * @param disp Display config object
- * @param viewer Viewer ID
- * @param eye Eye ID
- * @param surface Surface ID
- * @param priority Output: the priority level. Negative values
- * (canonically OSVR_DISTORTION_PRIORITY_UNAVAILABLE) indicate this technique
- * not available, higher values indicate higher preference for the given
- * technique based on the device's description. **Constant** throughout the
- * active, valid lifetime of a display config object.
- * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case
- * the output argument is unmodified.
- * Original signature : OSVR_ReturnCode osvrClientGetViewerEyeSurfaceRadialDistortionPriority(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_SurfaceCount, OSVR_DistortionPriority*)
- * @deprecated use the safer method - * {@link #osvrClientGetViewerEyeSurfaceRadialDistortionPriority(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, byte, int, java.nio.IntBuffer)} - * instead - */ - @Deprecated - public static native byte osvrClientGetViewerEyeSurfaceRadialDistortionPriority(Pointer disp, int viewer, byte eye, int surface, IntByReference priority); - /** - * Returns the priority/availability of radial distortion parameters for
- * a surface seen by an eye of a viewer in a display config.
- * If osvrClientDoesViewerEyeSurfaceWantDistortion() reports false, then the
- * display does not request distortion of any sort, and thus neither this nor
- * any other distortion strategy priority function will report an "available"
- * priority.
- * @param disp Display config object
- * @param viewer Viewer ID
- * @param eye Eye ID
- * @param surface Surface ID
- * @param priority Output: the priority level. Negative values
- * (canonically OSVR_DISTORTION_PRIORITY_UNAVAILABLE) indicate this technique
- * not available, higher values indicate higher preference for the given
- * technique based on the device's description. **Constant** throughout the
- * active, valid lifetime of a display config object.
- * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case
- * the output argument is unmodified.
- * Original signature : OSVR_ReturnCode osvrClientGetViewerEyeSurfaceRadialDistortionPriority(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_SurfaceCount, OSVR_DistortionPriority*) - */ - public static native byte osvrClientGetViewerEyeSurfaceRadialDistortionPriority(OsvrDisplayLibrary.OSVR_DisplayConfig disp, int viewer, byte eye, int surface, IntBuffer priority); - /** - * Returns the radial distortion parameters, if known/requested, for a
- * surface seen by an eye of a viewer in a display config.
- * Will only succeed if osvrClientGetViewerEyeSurfaceRadialDistortionPriority()
- * reports a non-negative priority.
- * @param disp Display config object
- * @param viewer Viewer ID
- * @param eye Eye ID
- * @param surface Surface ID
- * @param params Output: the parameters for radial distortion
- * @return OSVR_RETURN_FAILURE if this surface does not have these parameters
- * described, or if invalid parameters were passed, in which case the output
- * argument is unmodified.
- * Original signature : OSVR_ReturnCode osvrClientGetViewerEyeSurfaceRadialDistortion(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_SurfaceCount, OSVR_RadialDistortionParameters*)
- * @deprecated use the safer method - * {@link #osvrClientGetViewerEyeSurfaceRadialDistortion(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, byte, int, com.sun.jna.Pointer)} - * instead - */ - @Deprecated - public static native byte osvrClientGetViewerEyeSurfaceRadialDistortion(Pointer disp, int viewer, byte eye, int surface, Pointer params); - /** - * Returns the radial distortion parameters, if known/requested, for a
- * surface seen by an eye of a viewer in a display config.
- * Will only succeed if osvrClientGetViewerEyeSurfaceRadialDistortionPriority()
- * reports a non-negative priority.
- * @param disp Display config object
- * @param viewer Viewer ID
- * @param eye Eye ID
- * @param surface Surface ID
- * @param params Output: the parameters for radial distortion
- * @return OSVR_RETURN_FAILURE if this surface does not have these parameters
- * described, or if invalid parameters were passed, in which case the output
- * argument is unmodified.
- * Original signature : OSVR_ReturnCode osvrClientGetViewerEyeSurfaceRadialDistortion(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_SurfaceCount, OSVR_RadialDistortionParameters*) - */ - public static native byte osvrClientGetViewerEyeSurfaceRadialDistortion(OsvrDisplayLibrary.OSVR_DisplayConfig disp, int viewer, byte eye, int surface, Pointer params); - public static class OSVR_ClientContext extends PointerType { - public OSVR_ClientContext(Pointer address) { - super(address); - } - public OSVR_ClientContext() { - super(); - } - }; - public static class OSVR_DisplayConfig extends PointerType { - public OSVR_DisplayConfig(Pointer address) { - super(address); - } - public OSVR_DisplayConfig() { - super(); - } - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrinterface/OsvrInterfaceLibrary.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrinterface/OsvrInterfaceLibrary.java deleted file mode 100644 index 2a1c69476f..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrinterface/OsvrInterfaceLibrary.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.jme3.system.osvr.osvrinterface; -import com.jme3.system.osvr.osvrclientkit.OsvrClientKitLibrary.OSVR_ClientInterface; -import com.jme3.system.osvr.osvrclientreporttypes.OSVR_Pose3; -import com.jme3.system.osvr.osvrtimevalue.OSVR_TimeValue; -import com.sun.jna.Library; -import com.sun.jna.Native; -import com.sun.jna.NativeLibrary; -/** - * JNA Wrapper for library osvrInterface
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class OsvrInterfaceLibrary implements Library { - public static final String JNA_LIBRARY_NAME = "osvrClientKit"; - public static final NativeLibrary JNA_NATIVE_LIB = NativeLibrary.getInstance(OsvrInterfaceLibrary.JNA_LIBRARY_NAME); - static { - Native.register(OsvrInterfaceLibrary.class, OsvrInterfaceLibrary.JNA_NATIVE_LIB); - } - - /** Manually added */ - public static native byte osvrGetPoseState(OSVR_ClientInterface iface, OSVR_TimeValue timestamp, OSVR_Pose3 state); - -} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrmatrixconventions/OSVR_Pose3.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrmatrixconventions/OSVR_Pose3.java deleted file mode 100644 index 8ec8f7cfa4..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrmatrixconventions/OSVR_Pose3.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.jme3.system.osvr.osvrmatrixconventions; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class OSVR_Pose3 extends Structure { - /** C type : OSVR_Vec3 */ - public OSVR_Vec3 translation; - /** C type : OSVR_Quaternion */ - public OSVR_Quaternion rotation; - public OSVR_Pose3() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("translation", "rotation"); - } - /** - * @param translation C type : OSVR_Vec3
- * @param rotation C type : OSVR_Quaternion - */ - public OSVR_Pose3(OSVR_Vec3 translation, OSVR_Quaternion rotation) { - super(); - this.translation = translation; - this.rotation = rotation; - } - public OSVR_Pose3(Pointer peer) { - super(peer); - } - public static class ByReference extends OSVR_Pose3 implements Structure.ByReference { - - }; - public static class ByValue extends OSVR_Pose3 implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrmatrixconventions/OSVR_Quaternion.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrmatrixconventions/OSVR_Quaternion.java deleted file mode 100644 index 4627040206..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrmatrixconventions/OSVR_Quaternion.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.jme3.system.osvr.osvrmatrixconventions; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class OSVR_Quaternion extends Structure { - /** C type : double[4] */ - public double[] data = new double[4]; - public OSVR_Quaternion() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("data"); - } - /** @param data C type : double[4] */ - public OSVR_Quaternion(double data[]) { - super(); - if ((data.length != this.data.length)) - throw new IllegalArgumentException("Wrong array size !"); - this.data = data; - } - public OSVR_Quaternion(Pointer peer) { - super(peer); - } - public static class ByReference extends OSVR_Quaternion implements Structure.ByReference { - - }; - public static class ByValue extends OSVR_Quaternion implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrmatrixconventions/OSVR_Vec3.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrmatrixconventions/OSVR_Vec3.java deleted file mode 100644 index 7aa44a9793..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrmatrixconventions/OSVR_Vec3.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.jme3.system.osvr.osvrmatrixconventions; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class OSVR_Vec3 extends Structure { - /** C type : double[3] */ - public double[] data = new double[3]; - public OSVR_Vec3() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("data"); - } - /** @param data C type : double[3] */ - public OSVR_Vec3(double data[]) { - super(); - if ((data.length != this.data.length)) - throw new IllegalArgumentException("Wrong array size !"); - this.data = data; - } - public OSVR_Vec3(Pointer peer) { - super(peer); - } - public static class ByReference extends OSVR_Vec3 implements Structure.ByReference { - - }; - public static class ByValue extends OSVR_Vec3 implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrmatrixconventions/OsvrMatrixConventionsLibrary.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrmatrixconventions/OsvrMatrixConventionsLibrary.java deleted file mode 100644 index 384dd827ce..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrmatrixconventions/OsvrMatrixConventionsLibrary.java +++ /dev/null @@ -1,192 +0,0 @@ -package com.jme3.system.osvr.osvrmatrixconventions; -import com.sun.jna.Library; -import com.sun.jna.Native; -import com.sun.jna.NativeLibrary; -import com.sun.jna.Pointer; -import com.sun.jna.PointerType; -import com.sun.jna.ptr.DoubleByReference; -import com.sun.jna.ptr.FloatByReference; -import java.nio.DoubleBuffer; -import java.nio.FloatBuffer; -/** - * JNA Wrapper for library osvrMatrixConventions
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class OsvrMatrixConventionsLibrary implements Library { - public static final String JNA_LIBRARY_NAME = "osvrUtil"; - public static final NativeLibrary JNA_NATIVE_LIB = NativeLibrary.getInstance(OsvrMatrixConventionsLibrary.JNA_LIBRARY_NAME); - static { - Native.register(OsvrMatrixConventionsLibrary.class, OsvrMatrixConventionsLibrary.JNA_NATIVE_LIB); - } - /** enum values */ - public static interface OSVR_MatrixMasks { - public static final int OSVR_MATRIX_MASK_ROWMAJOR = 0x1; - public static final int OSVR_MATRIX_MASK_ROWVECTORS = 0x2; - public static final int OSVR_MATRIX_MASK_LHINPUT = 0x4; - public static final int OSVR_MATRIX_MASK_UNSIGNEDZ = 0x8; - }; - /** enum values */ - public static interface OSVR_MatrixOrderingFlags { - public static final int OSVR_MATRIX_COLMAJOR = 0x0; - public static final int OSVR_MATRIX_ROWMAJOR = OsvrMatrixConventionsLibrary.OSVR_MatrixMasks.OSVR_MATRIX_MASK_ROWMAJOR; - }; - /** enum values */ - public static interface OSVR_MatrixVectorFlags { - public static final int OSVR_MATRIX_COLVECTORS = 0x0; - public static final int OSVR_MATRIX_ROWVECTORS = OsvrMatrixConventionsLibrary.OSVR_MatrixMasks.OSVR_MATRIX_MASK_ROWVECTORS; - }; - /** enum values */ - public static interface OSVR_ProjectionMatrixInputFlags { - public static final int OSVR_MATRIX_RHINPUT = 0x0; - public static final int OSVR_MATRIX_LHINPUT = OsvrMatrixConventionsLibrary.OSVR_MatrixMasks.OSVR_MATRIX_MASK_LHINPUT; - }; - /** enum values */ - public static interface OSVR_ProjectionMatrixZFlags { - public static final int OSVR_MATRIX_SIGNEDZ = 0x0; - public static final int OSVR_MATRIX_UNSIGNEDZ = OsvrMatrixConventionsLibrary.OSVR_MatrixMasks.OSVR_MATRIX_MASK_UNSIGNEDZ; - }; - public static final int OSVR_MATRIX_SIZE = 16; - public static final int OSVR_RETURN_SUCCESS = 0; - public static final int OSVR_RETURN_FAILURE = 1; - /** Original signature : double osvrVec3GetX(const OSVR_Vec3*) */ - public static native double osvrVec3GetX(OSVR_Vec3 v); - /** Original signature : void osvrVec3SetX(OSVR_Vec3*, double) */ - public static native void osvrVec3SetX(OSVR_Vec3 v, double val); - /** Original signature : double osvrVec3GetY(const OSVR_Vec3*) */ - public static native double osvrVec3GetY(OSVR_Vec3 v); - /** Original signature : void osvrVec3SetY(OSVR_Vec3*, double) */ - public static native void osvrVec3SetY(OSVR_Vec3 v, double val); - /** Original signature : double osvrVec3GetZ(const OSVR_Vec3*) */ - public static native double osvrVec3GetZ(OSVR_Vec3 v); - /** Original signature : void osvrVec3SetZ(OSVR_Vec3*, double) */ - public static native void osvrVec3SetZ(OSVR_Vec3 v, double val); - /** - * Set a Vec3 to the zero vector
- * Original signature : void osvrVec3Zero(OSVR_Vec3*) - */ - public static native void osvrVec3Zero(OSVR_Vec3 v); - /** Original signature : double osvrQuatGetW(const OSVR_Quaternion*) */ - public static native double osvrQuatGetW(OSVR_Quaternion q); - /** Original signature : void osvrQuatSetW(OSVR_Quaternion*, double) */ - public static native void osvrQuatSetW(OSVR_Quaternion q, double val); - /** Original signature : double osvrQuatGetX(const OSVR_Quaternion*) */ - public static native double osvrQuatGetX(OSVR_Quaternion q); - /** Original signature : void osvrQuatSetX(OSVR_Quaternion*, double) */ - public static native void osvrQuatSetX(OSVR_Quaternion q, double val); - /** Original signature : double osvrQuatGetY(const OSVR_Quaternion*) */ - public static native double osvrQuatGetY(OSVR_Quaternion q); - /** Original signature : void osvrQuatSetY(OSVR_Quaternion*, double) */ - public static native void osvrQuatSetY(OSVR_Quaternion q, double val); - /** Original signature : double osvrQuatGetZ(const OSVR_Quaternion*) */ - public static native double osvrQuatGetZ(OSVR_Quaternion q); - /** Original signature : void osvrQuatSetZ(OSVR_Quaternion*, double) */ - public static native void osvrQuatSetZ(OSVR_Quaternion q, double val); - /** - * Set a quaternion to the identity rotation
- * Original signature : void osvrQuatSetIdentity(OSVR_Quaternion*) - */ - public static native void osvrQuatSetIdentity(OSVR_Quaternion q); - /** - * Set a pose to identity
- * Original signature : void osvrPose3SetIdentity(OSVR_Pose3*) - */ - public static native void osvrPose3SetIdentity(OSVR_Pose3 pose); - /** - * Set a matrix of doubles based on a Pose3.
- * @param pose The Pose3 to convert
- * @param flags Memory ordering flag - see @ref MatrixFlags
- * @param mat an array of 16 doubles
- * Original signature : OSVR_ReturnCode osvrPose3ToMatrixd(const OSVR_Pose3*, OSVR_MatrixConventions, double*)
- * @deprecated use the safer method - * {@link #osvrPose3ToMatrixd(com.jme3.system.osvr.osvrmatrixconventions.OSVR_Pose3, short, java.nio.DoubleBuffer)} - * instead - */ - @Deprecated - public static native byte osvrPose3ToMatrixd(OSVR_Pose3 pose, short flags, DoubleByReference mat); - /** - * Set a matrix of doubles based on a Pose3.
- * @param pose The Pose3 to convert
- * @param flags Memory ordering flag - see @ref MatrixFlags
- * @param mat an array of 16 doubles
- * Original signature : OSVR_ReturnCode osvrPose3ToMatrixd(const OSVR_Pose3*, OSVR_MatrixConventions, double*) - */ - public static native byte osvrPose3ToMatrixd(OSVR_Pose3 pose, short flags, DoubleBuffer mat); - /** - * Set a matrix of floats based on a Pose3.
- * @param pose The Pose3 to convert
- * @param flags Memory ordering flag - see @ref MatrixFlags
- * @param mat an array of 16 floats
- * Original signature : OSVR_ReturnCode osvrPose3ToMatrixf(const OSVR_Pose3*, OSVR_MatrixConventions, float*)
- * @deprecated use the safer method - * {@link #osvrPose3ToMatrixf(com.jme3.system.osvr.osvrmatrixconventions.OSVR_Pose3, short, java.nio.FloatBuffer)} - * instead - */ - @Deprecated - public static native byte osvrPose3ToMatrixf(OSVR_Pose3 pose, short flags, FloatByReference mat); - /** - * Set a matrix of floats based on a Pose3.
- * @param pose The Pose3 to convert
- * @param flags Memory ordering flag - see @ref MatrixFlags
- * @param mat an array of 16 floats
- * Original signature : OSVR_ReturnCode osvrPose3ToMatrixf(const OSVR_Pose3*, OSVR_MatrixConventions, float*) - */ - public static native byte osvrPose3ToMatrixf(OSVR_Pose3 pose, short flags, FloatBuffer mat); - /** - * Set a matrix based on a Pose3. (C++-only overload - detecting scalar
- * type)
- * Original signature : OSVR_ReturnCode osvrPose3ToMatrix(const OSVR_Pose3*, OSVR_MatrixConventions, double*)
- * @deprecated use the safer method - * {@link #osvrPose3ToMatrix(com.jme3.system.osvr.osvrmatrixconventions.OSVR_Pose3, short, java.nio.DoubleBuffer)} - * instead - */ - @Deprecated - public static native byte osvrPose3ToMatrix(OSVR_Pose3 pose, short flags, DoubleByReference mat); - /** - * Set a matrix based on a Pose3. (C++-only overload - detecting scalar
- * type)
- * Original signature : OSVR_ReturnCode osvrPose3ToMatrix(const OSVR_Pose3*, OSVR_MatrixConventions, double*) - */ - public static native byte osvrPose3ToMatrix(OSVR_Pose3 pose, short flags, DoubleBuffer mat); - /** - * Set a matrix based on a Pose3. (C++-only overload - detecting scalar
- * type)
- * Original signature : OSVR_ReturnCode osvrPose3ToMatrix(const OSVR_Pose3*, OSVR_MatrixConventions, float*)
- * @deprecated use the safer method - * {@link #osvrPose3ToMatrix(com.jme3.system.osvr.osvrmatrixconventions.OSVR_Pose3, short, java.nio.FloatBuffer)} - * instead - */ - @Deprecated - public static native byte osvrPose3ToMatrix(OSVR_Pose3 pose, short flags, FloatByReference mat); - /** - * Set a matrix based on a Pose3. (C++-only overload - detecting scalar
- * type)
- * Original signature : OSVR_ReturnCode osvrPose3ToMatrix(const OSVR_Pose3*, OSVR_MatrixConventions, float*) - */ - public static native byte osvrPose3ToMatrix(OSVR_Pose3 pose, short flags, FloatBuffer mat); - /** - * Set a matrix based on a Pose3. (C++-only overload - detects scalar
- * and takes array rather than pointer)
- * Original signature : OSVR_ReturnCode osvrPose3ToMatrix(const OSVR_Pose3*, OSVR_MatrixConventions, Scalar[OSVR_MATRIX_SIZE])
- * @deprecated use the safer method - * {@link #osvrPose3ToMatrix(com.jme3.system.osvr.osvrmatrixconventions.OSVR_Pose3, short, java.nio.DoubleBuffer)} - * instead - */ - @Deprecated - public static native byte osvrPose3ToMatrix(OSVR_Pose3 pose, short flags, Pointer mat); - /** - * Set a matrix based on a Pose3. (C++-only overload - detects scalar
- * and takes array rather than pointer)
- * Original signature : OSVR_ReturnCode osvrPose3ToMatrix(const OSVR_Pose3*, OSVR_MatrixConventions, Scalar[OSVR_MATRIX_SIZE]) - */ - public static native byte osvrPose3ToMatrix(OSVR_Pose3 pose, short flags, OsvrMatrixConventionsLibrary.Scalar mat[]); - public static class Scalar extends PointerType { - public Scalar(Pointer address) { - super(address); - } - public Scalar() { - super(); - } - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanager/OSVR_ProjectionMatrix.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanager/OSVR_ProjectionMatrix.java deleted file mode 100644 index 2ebeb8f2fe..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanager/OSVR_ProjectionMatrix.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.jme3.system.osvr.osvrrendermanager; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class OSVR_ProjectionMatrix extends Structure { - public double left; - public double right; - public double top; - public double bottom; - /** Cannot name "near" because Visual Studio keyword */ - public double nearClip; - public double farClip; - public OSVR_ProjectionMatrix() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("left", "right", "top", "bottom", "nearClip", "farClip"); - } - /** @param nearClip Cannot name "near" because Visual Studio keyword */ - public OSVR_ProjectionMatrix(double left, double right, double top, double bottom, double nearClip, double farClip) { - super(); - this.left = left; - this.right = right; - this.top = top; - this.bottom = bottom; - this.nearClip = nearClip; - this.farClip = farClip; - } - public OSVR_ProjectionMatrix(Pointer peer) { - super(peer); - } - public static class ByReference extends OSVR_ProjectionMatrix implements Structure.ByReference { - - }; - public static class ByValue extends OSVR_ProjectionMatrix implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanager/OSVR_RGB.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanager/OSVR_RGB.java deleted file mode 100644 index 4fca69fc4c..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanager/OSVR_RGB.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.jme3.system.osvr.osvrrendermanager; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class OSVR_RGB extends Structure { - public float r; - public float g; - public float b; - public OSVR_RGB() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("r", "g", "b"); - } - public OSVR_RGB(float r, float g, float b) { - super(); - this.r = r; - this.g = g; - this.b = b; - } - public OSVR_RGB(Pointer peer) { - super(peer); - } - public static class ByReference extends OSVR_RGB implements Structure.ByReference { - - }; - public static class ByValue extends OSVR_RGB implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanager/OSVR_RenderParams.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanager/OSVR_RenderParams.java deleted file mode 100644 index ea094d4f3e..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanager/OSVR_RenderParams.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.jme3.system.osvr.osvrrendermanager; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class OSVR_RenderParams extends Structure { - /** - * Room space to insert
- * C type : OSVR_PoseState* - */ - public Pointer worldFromRoomAppend; - /** - * Overrides head space
- * C type : OSVR_PoseState* - */ - public Pointer roomFromHeadReplace; - public double nearClipDistanceMeters; - public double farClipDistanceMeters; - public OSVR_RenderParams() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("worldFromRoomAppend", "roomFromHeadReplace", "nearClipDistanceMeters", "farClipDistanceMeters"); - } - /** - * @param worldFromRoomAppend Room space to insert
- * C type : OSVR_PoseState*
- * @param roomFromHeadReplace Overrides head space
- * C type : OSVR_PoseState* - */ - public OSVR_RenderParams(Pointer worldFromRoomAppend, Pointer roomFromHeadReplace, double nearClipDistanceMeters, double farClipDistanceMeters) { - super(); - this.worldFromRoomAppend = worldFromRoomAppend; - this.roomFromHeadReplace = roomFromHeadReplace; - this.nearClipDistanceMeters = nearClipDistanceMeters; - this.farClipDistanceMeters = farClipDistanceMeters; - } - public OSVR_RenderParams(Pointer peer) { - super(peer); - } - public static class ByReference extends OSVR_RenderParams implements Structure.ByReference { - - }; - public static class ByValue extends OSVR_RenderParams implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanager/OSVR_ViewportDescription.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanager/OSVR_ViewportDescription.java deleted file mode 100644 index 2e38658290..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanager/OSVR_ViewportDescription.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.jme3.system.osvr.osvrrendermanager; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class OSVR_ViewportDescription extends Structure { - /** Left side of the viewport in pixels */ - public double left; - /** First pixel in the viewport at the bottom. */ - public double lower; - /** Last pixel in the viewport at the top */ - public double width; - /** Last pixel on the right of the viewport in pixels */ - public double height; - public OSVR_ViewportDescription() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("left", "lower", "width", "height"); - } - /** - * @param left Left side of the viewport in pixels
- * @param lower First pixel in the viewport at the bottom.
- * @param width Last pixel in the viewport at the top
- * @param height Last pixel on the right of the viewport in pixels - */ - public OSVR_ViewportDescription(double left, double lower, double width, double height) { - super(); - this.left = left; - this.lower = lower; - this.width = width; - this.height = height; - } - public OSVR_ViewportDescription(Pointer peer) { - super(peer); - } - public static class ByReference extends OSVR_ViewportDescription implements Structure.ByReference { - - }; - public static class ByValue extends OSVR_ViewportDescription implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanager/OsvrRenderManagerLibrary.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanager/OsvrRenderManagerLibrary.java deleted file mode 100644 index 649c222d26..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanager/OsvrRenderManagerLibrary.java +++ /dev/null @@ -1,117 +0,0 @@ -package com.jme3.system.osvr.osvrrendermanager; -import com.ochafik.lang.jnaerator.runtime.NativeSizeByReference; -import com.sun.jna.Library; -import com.sun.jna.Native; -import com.sun.jna.NativeLibrary; -import com.sun.jna.Pointer; -import com.sun.jna.ptr.DoubleByReference; -import com.sun.jna.ptr.FloatByReference; -import com.sun.jna.ptr.PointerByReference; -import java.nio.DoubleBuffer; -import java.nio.FloatBuffer; -/** - * JNA Wrapper for library osvrRenderManager
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class OsvrRenderManagerLibrary implements Library { - public static final String JNA_LIBRARY_NAME = "osvrRenderManager"; - public static final NativeLibrary JNA_NATIVE_LIB = NativeLibrary.getInstance(OsvrRenderManagerLibrary.JNA_LIBRARY_NAME); - static { - Native.register(OsvrRenderManagerLibrary.class, OsvrRenderManagerLibrary.JNA_NATIVE_LIB); - } - /** enum values */ - public static interface OSVR_OpenStatus { - public static final int OSVR_OPEN_STATUS_FAILURE = 0; - public static final int OSVR_OPEN_STATUS_PARTIAL = 1; - public static final int OSVR_OPEN_STATUS_COMPLETE = 2; - }; - /** - * todo OSVR_RenderTimingInfo. - * Original signature : OSVR_ReturnCode osvrDestroyRenderManager(OSVR_RenderManager) - */ - public static native byte osvrDestroyRenderManager(Pointer renderManager); - /** - * todo Make this actually cache, for now it does not.
- * Original signature : OSVR_ReturnCode osvrRenderManagerGetNumRenderInfo(OSVR_RenderManager, OSVR_RenderParams, OSVR_RenderInfoCount*) - */ - public static native byte osvrRenderManagerGetNumRenderInfo(Pointer renderManager, OSVR_RenderParams.ByValue renderParams, NativeSizeByReference numRenderInfoOut); - /** Original signature : OSVR_ReturnCode osvrRenderManagerGetDoingOkay(OSVR_RenderManager) */ - public static native byte osvrRenderManagerGetDoingOkay(Pointer renderManager); - /** Original signature : OSVR_ReturnCode osvrRenderManagerGetDefaultRenderParams(OSVR_RenderParams*) */ - public static native byte osvrRenderManagerGetDefaultRenderParams(OSVR_RenderParams renderParamsOut); - /** - * must be registered before they are presented.
- * Original signature : OSVR_ReturnCode osvrRenderManagerStartPresentRenderBuffers(OSVR_RenderManagerPresentState*) - */ - public static native byte osvrRenderManagerStartPresentRenderBuffers(PointerByReference presentStateOut); - /** - * buffers for a single frame. This sequence starts with the Start function.
- * Original signature : OSVR_ReturnCode osvrRenderManagerFinishPresentRenderBuffers(OSVR_RenderManager, OSVR_RenderManagerPresentState, OSVR_RenderParams, OSVR_CBool) - */ - public static native byte osvrRenderManagerFinishPresentRenderBuffers(Pointer renderManager, Pointer presentState, OSVR_RenderParams.ByValue renderParams, byte shouldFlipY); - /** - * must be registered before they are presented.
- * Original signature : OSVR_ReturnCode osvrRenderManagerStartRegisterRenderBuffers(OSVR_RenderManagerRegisterBufferState*) - */ - public static native byte osvrRenderManagerStartRegisterRenderBuffers(PointerByReference registerBufferStateOut); - /** - * buffers for a single frame. This sequence starts with the Start function.
- * Original signature : OSVR_ReturnCode osvrRenderManagerFinishRegisterRenderBuffers(OSVR_RenderManager, OSVR_RenderManagerRegisterBufferState, OSVR_CBool) - */ - public static native byte osvrRenderManagerFinishRegisterRenderBuffers(Pointer renderManager, Pointer registerBufferState, byte appWillNotOverwriteBeforeNewPresent); - /** Original signature : OSVR_ReturnCode osvrRenderManagerPresentSolidColorf(OSVR_RenderManager, OSVR_RGB_FLOAT) */ - public static native byte osvrRenderManagerPresentSolidColorf(Pointer renderManager, com.jme3.system.osvr.osvrrendermanager.OSVR_RGB.ByValue rgb); - /** - * when you're done.
- * Original signature : OSVR_ReturnCode osvrRenderManagerGetRenderInfoCollection(OSVR_RenderManager, OSVR_RenderParams, OSVR_RenderInfoCollection*) - */ - public static native byte osvrRenderManagerGetRenderInfoCollection(Pointer renderManager, OSVR_RenderParams.ByValue renderParams, PointerByReference renderInfoCollectionOut); - /** - * Releases the OSVR_RenderInfoCollection.
- * Original signature : OSVR_ReturnCode osvrRenderManagerReleaseRenderInfoCollection(OSVR_RenderInfoCollection) - */ - public static native byte osvrRenderManagerReleaseRenderInfoCollection(Pointer renderInfoCollection); - /** - * Get the size of the OSVR_RenderInfoCollection.
- * Original signature : OSVR_ReturnCode osvrRenderManagerGetNumRenderInfoInCollection(OSVR_RenderInfoCollection, OSVR_RenderInfoCount*) - */ - public static native byte osvrRenderManagerGetNumRenderInfoInCollection(Pointer renderInfoCollection, NativeSizeByReference countOut); - /** - * @return True on success, false on failure (null pointer).
- * Original signature : OSVR_ReturnCode OSVR_Projection_to_OpenGL(double*, OSVR_ProjectionMatrix)
- * @deprecated use the safer methods {@link #OSVR_Projection_to_OpenGL(java.nio.DoubleBuffer, com.jme3.system.osvr.osvrrendermanager.OSVR_ProjectionMatrix.ByValue)} and {@link #OSVR_Projection_to_OpenGL(com.sun.jna.ptr.DoubleByReference, com.jme3.system.osvr.osvrrendermanager.OSVR_ProjectionMatrix.ByValue)} instead - */ - @Deprecated - public static native byte OSVR_Projection_to_OpenGL(DoubleByReference OpenGL_out, com.jme3.system.osvr.osvrrendermanager.OSVR_ProjectionMatrix.ByValue projection_in); - /** - * @return True on success, false on failure (null pointer).
- * Original signature : OSVR_ReturnCode OSVR_Projection_to_OpenGL(double*, OSVR_ProjectionMatrix) - */ - public static native byte OSVR_Projection_to_OpenGL(DoubleBuffer OpenGL_out, com.jme3.system.osvr.osvrrendermanager.OSVR_ProjectionMatrix.ByValue projection_in); - /** - * @return True on success, false on failure (null pointer).
- * Original signature : OSVR_ReturnCode OSVR_Projection_to_D3D(float[16], OSVR_ProjectionMatrix)
- * @deprecated use the safer methods {@link #OSVR_Projection_to_D3D(java.nio.FloatBuffer, com.jme3.system.osvr.osvrrendermanager.OSVR_ProjectionMatrix.ByValue)} and {@link #OSVR_Projection_to_D3D(com.sun.jna.ptr.FloatByReference, com.jme3.system.osvr.osvrrendermanager.OSVR_ProjectionMatrix.ByValue)} instead - */ - @Deprecated - public static native byte OSVR_Projection_to_D3D(FloatByReference D3D_out, com.jme3.system.osvr.osvrrendermanager.OSVR_ProjectionMatrix.ByValue projection_in); - /** - * @return True on success, false on failure (null pointer).
- * Original signature : OSVR_ReturnCode OSVR_Projection_to_D3D(float[16], OSVR_ProjectionMatrix) - */ - public static native byte OSVR_Projection_to_D3D(FloatBuffer D3D_out, com.jme3.system.osvr.osvrrendermanager.OSVR_ProjectionMatrix.ByValue projection_in); - /** - * @return True on success, false on failure (null pointer).
- * Original signature : OSVR_ReturnCode OSVR_Projection_to_Unreal(float[16], OSVR_ProjectionMatrix)
- * @deprecated use the safer methods {@link #OSVR_Projection_to_Unreal(java.nio.FloatBuffer, com.jme3.system.osvr.osvrrendermanager.OSVR_ProjectionMatrix.ByValue)} and {@link #OSVR_Projection_to_Unreal(com.sun.jna.ptr.FloatByReference, com.jme3.system.osvr.osvrrendermanager.OSVR_ProjectionMatrix.ByValue)} instead - */ - @Deprecated - public static native byte OSVR_Projection_to_Unreal(FloatByReference Unreal_out, com.jme3.system.osvr.osvrrendermanager.OSVR_ProjectionMatrix.ByValue projection_in); - /** - * @return True on success, false on failure (null pointer).
- * Original signature : OSVR_ReturnCode OSVR_Projection_to_Unreal(float[16], OSVR_ProjectionMatrix) - */ - public static native byte OSVR_Projection_to_Unreal(FloatBuffer Unreal_out, com.jme3.system.osvr.osvrrendermanager.OSVR_ProjectionMatrix.ByValue projection_in); -} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_GraphicsLibraryOpenGL.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_GraphicsLibraryOpenGL.java deleted file mode 100644 index f52a83387b..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_GraphicsLibraryOpenGL.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.jme3.system.osvr.osvrrendermanageropengl; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class OSVR_GraphicsLibraryOpenGL extends Structure { - /** C type : const OSVR_OpenGLToolkitFunctions* */ - public com.jme3.system.osvr.osvrrendermanageropengl.OSVR_OpenGLToolkitFunctions.ByReference toolkit; - public OSVR_GraphicsLibraryOpenGL() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("toolkit"); - } - /** @param toolkit C type : const OSVR_OpenGLToolkitFunctions* */ - public OSVR_GraphicsLibraryOpenGL(com.jme3.system.osvr.osvrrendermanageropengl.OSVR_OpenGLToolkitFunctions.ByReference toolkit) { - super(); - this.toolkit = toolkit; - } - public OSVR_GraphicsLibraryOpenGL(Pointer peer) { - super(peer); - } - public static class ByReference extends OSVR_GraphicsLibraryOpenGL implements Structure.ByReference { - - }; - public static class ByValue extends OSVR_GraphicsLibraryOpenGL implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_OpenGLContextParams.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_OpenGLContextParams.java deleted file mode 100644 index 185a2d5bb8..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_OpenGLContextParams.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.jme3.system.osvr.osvrrendermanageropengl; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class OSVR_OpenGLContextParams extends Structure { - /** C type : const char* */ - public Pointer windowTitle; - /** C type : OSVR_CBool */ - public byte fullScreen; - public int width; - public int height; - public int xPos; - public int yPos; - public int bitsPerPixel; - public int numBuffers; - /** C type : OSVR_CBool */ - public byte visible; - public OSVR_OpenGLContextParams() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("windowTitle", "fullScreen", "width", "height", "xPos", "yPos", "bitsPerPixel", "numBuffers", "visible"); - } - /** - * @param windowTitle C type : const char*
- * @param fullScreen C type : OSVR_CBool
- * @param visible C type : OSVR_CBool - */ - public OSVR_OpenGLContextParams(Pointer windowTitle, byte fullScreen, int width, int height, int xPos, int yPos, int bitsPerPixel, int numBuffers, byte visible) { - super(); - this.windowTitle = windowTitle; - this.fullScreen = fullScreen; - this.width = width; - this.height = height; - this.xPos = xPos; - this.yPos = yPos; - this.bitsPerPixel = bitsPerPixel; - this.numBuffers = numBuffers; - this.visible = visible; - } - public OSVR_OpenGLContextParams(Pointer peer) { - super(peer); - } - public static class ByReference extends OSVR_OpenGLContextParams implements Structure.ByReference { - - }; - public static class ByValue extends OSVR_OpenGLContextParams implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_OpenGLToolkitFunctions.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_OpenGLToolkitFunctions.java deleted file mode 100644 index e32b3901f3..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_OpenGLToolkitFunctions.java +++ /dev/null @@ -1,92 +0,0 @@ -package com.jme3.system.osvr.osvrrendermanageropengl; -import com.ochafik.lang.jnaerator.runtime.NativeSize; -import com.sun.jna.Callback; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import com.sun.jna.ptr.IntByReference; -import java.util.Arrays; -import java.util.List; -/** - * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class OSVR_OpenGLToolkitFunctions extends Structure { - public NativeSize size; - /** C type : void* */ - public Pointer data; - /** C type : create_callback* */ - public OSVR_OpenGLToolkitFunctions.create_callback create; - /** C type : destroy_callback* */ - public OSVR_OpenGLToolkitFunctions.destroy_callback destroy; - /** C type : handleEvents_callback* */ - public OSVR_OpenGLToolkitFunctions.handleEvents_callback handleEvents; - /** C type : getDisplayFrameBuffer_callback* */ - public OSVR_OpenGLToolkitFunctions.getDisplayFrameBuffer_callback getDisplayFrameBuffer; - /** C type : getDisplaySizeOverride_callback* */ - public OSVR_OpenGLToolkitFunctions.getDisplaySizeOverride_callback getDisplaySizeOverride; - public interface create_callback extends Callback { - void apply(Pointer data); - }; - public interface destroy_callback extends Callback { - void apply(Pointer data); - }; - public interface OSVR_CBool_callback extends Callback { - int apply(Pointer data, OSVR_OpenGLContextParams p); - }; - public interface OSVR_CBool_callback2 extends Callback { - int apply(Pointer data); - }; - public interface OSVR_CBool_callback3 extends Callback { - int apply(Pointer data, NativeSize display); - }; - public interface OSVR_CBool_callback4 extends Callback { - int apply(Pointer data, NativeSize display); - }; - public interface OSVR_CBool_callback5 extends Callback { - int apply(Pointer data, byte verticalSync); - }; - public interface handleEvents_callback extends Callback { - byte apply(Pointer data); - }; - public interface getDisplayFrameBuffer_callback extends Callback { - byte apply(Pointer data, NativeSize display, IntByReference frameBufferOut); - }; - public interface getDisplaySizeOverride_callback extends Callback { - byte apply(Pointer data, NativeSize display, IntByReference width, IntByReference height); - }; - public OSVR_OpenGLToolkitFunctions() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("size", "data", "create", "destroy", "handleEvents", "getDisplayFrameBuffer", "getDisplaySizeOverride"); - } - /** - * @param data C type : void*
- * @param create C type : create_callback*
- * @param destroy C type : destroy_callback*
- * @param handleEvents C type : handleEvents_callback*
- * @param getDisplayFrameBuffer C type : getDisplayFrameBuffer_callback*
- * @param getDisplaySizeOverride C type : getDisplaySizeOverride_callback* - */ - public OSVR_OpenGLToolkitFunctions(NativeSize size, Pointer data, OSVR_OpenGLToolkitFunctions.create_callback create, OSVR_OpenGLToolkitFunctions.destroy_callback destroy, OSVR_OpenGLToolkitFunctions.handleEvents_callback handleEvents, OSVR_OpenGLToolkitFunctions.getDisplayFrameBuffer_callback getDisplayFrameBuffer, OSVR_OpenGLToolkitFunctions.getDisplaySizeOverride_callback getDisplaySizeOverride) { - super(); - this.size = size; - this.data = data; - this.create = create; - this.destroy = destroy; - this.handleEvents = handleEvents; - this.getDisplayFrameBuffer = getDisplayFrameBuffer; - this.getDisplaySizeOverride = getDisplaySizeOverride; - } - public OSVR_OpenGLToolkitFunctions(Pointer peer) { - super(peer); - } - public static class ByReference extends OSVR_OpenGLToolkitFunctions implements Structure.ByReference { - - }; - public static class ByValue extends OSVR_OpenGLToolkitFunctions implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_OpenResultsOpenGL.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_OpenResultsOpenGL.java deleted file mode 100644 index 85e020f6e7..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_OpenResultsOpenGL.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.jme3.system.osvr.osvrrendermanageropengl; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class OSVR_OpenResultsOpenGL extends Structure { - /** - * C type : OSVR_OpenStatus - */ - public int status; - /** C type : OSVR_GraphicsLibraryOpenGL */ - public OSVR_GraphicsLibraryOpenGL library; - /** C type : OSVR_RenderBufferOpenGL */ - public OSVR_RenderBufferOpenGL buffers; - public OSVR_OpenResultsOpenGL() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("status", "library", "buffers"); - } - /** - * @param status @see OsvrRenderManagerOpenGLLibrary.OSVR_OpenStatus
- * C type : OSVR_OpenStatus
- * @param library C type : OSVR_GraphicsLibraryOpenGL
- * @param buffers C type : OSVR_RenderBufferOpenGL - */ - public OSVR_OpenResultsOpenGL(int status, OSVR_GraphicsLibraryOpenGL library, OSVR_RenderBufferOpenGL buffers) { - super(); - this.status = status; - this.library = library; - this.buffers = buffers; - } - public OSVR_OpenResultsOpenGL(Pointer peer) { - super(peer); - } - public static class ByReference extends OSVR_OpenResultsOpenGL implements Structure.ByReference { - - }; - public static class ByValue extends OSVR_OpenResultsOpenGL implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_ProjectionMatrix.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_ProjectionMatrix.java deleted file mode 100644 index 94d2248543..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_ProjectionMatrix.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.jme3.system.osvr.osvrrendermanageropengl; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class OSVR_ProjectionMatrix extends Structure { - public double left; - public double right; - public double top; - public double bottom; - /** Cannot name "near" because Visual Studio keyword */ - public double nearClip; - public double farClip; - public OSVR_ProjectionMatrix() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("left", "right", "top", "bottom", "nearClip", "farClip"); - } - /** @param nearClip Cannot name "near" because Visual Studio keyword */ - public OSVR_ProjectionMatrix(double left, double right, double top, double bottom, double nearClip, double farClip) { - super(); - this.left = left; - this.right = right; - this.top = top; - this.bottom = bottom; - this.nearClip = nearClip; - this.farClip = farClip; - } - public OSVR_ProjectionMatrix(Pointer peer) { - super(peer); - } - public static class ByReference extends OSVR_ProjectionMatrix implements Structure.ByReference { - - }; - public static class ByValue extends OSVR_ProjectionMatrix implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_RGB.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_RGB.java deleted file mode 100644 index c74e15643b..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_RGB.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.jme3.system.osvr.osvrrendermanageropengl; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class OSVR_RGB extends Structure { - public float r; - public float g; - public float b; - public OSVR_RGB() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("r", "g", "b"); - } - public OSVR_RGB(float r, float g, float b) { - super(); - this.r = r; - this.g = g; - this.b = b; - } - public OSVR_RGB(Pointer peer) { - super(peer); - } - public static class ByReference extends OSVR_RGB implements Structure.ByReference { - - }; - public static class ByValue extends OSVR_RGB implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_RenderBufferOpenGL.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_RenderBufferOpenGL.java deleted file mode 100644 index 7f502dd053..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_RenderBufferOpenGL.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.jme3.system.osvr.osvrrendermanageropengl; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class OSVR_RenderBufferOpenGL extends Structure { - public int colorBufferName; - public int depthStencilBufferName; - public OSVR_RenderBufferOpenGL() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("colorBufferName", "depthStencilBufferName"); - } - public OSVR_RenderBufferOpenGL(int colorBufferName, int depthStencilBufferName) { - super(); - this.colorBufferName = colorBufferName; - this.depthStencilBufferName = depthStencilBufferName; - } - public OSVR_RenderBufferOpenGL(Pointer peer) { - super(peer); - } - public static class ByReference extends OSVR_RenderBufferOpenGL implements Structure.ByReference { - - }; - public static class ByValue extends OSVR_RenderBufferOpenGL implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_RenderInfoOpenGL.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_RenderInfoOpenGL.java deleted file mode 100644 index 997215f3cb..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_RenderInfoOpenGL.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.jme3.system.osvr.osvrrendermanageropengl; -import com.jme3.system.osvr.osvrmatrixconventions.OSVR_Pose3; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public /*abstract*/ class OSVR_RenderInfoOpenGL extends Structure { - /** C type : OSVR_GraphicsLibraryOpenGL */ - public OSVR_GraphicsLibraryOpenGL library; - /** C type : OSVR_ViewportDescription */ - public OSVR_ViewportDescription viewport; - public OSVR_Pose3 pose; - /** C type : OSVR_ProjectionMatrix */ - public OSVR_ProjectionMatrix projection; - public OSVR_RenderInfoOpenGL() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("library", "viewport", "pose", "projection"); - } - /** - * @param library C type : OSVR_GraphicsLibraryOpenGL
- * @param viewport C type : OSVR_ViewportDescription
- * @param projection C type : OSVR_ProjectionMatrix - */ - public OSVR_RenderInfoOpenGL(OSVR_GraphicsLibraryOpenGL library, OSVR_ViewportDescription viewport, OSVR_Pose3 pose, OSVR_ProjectionMatrix projection) { - super(); - this.library = library; - this.viewport = viewport; - this.pose = pose; - this.projection = projection; - } - public OSVR_RenderInfoOpenGL(Pointer peer) { - super(peer); - } - public static /*abstract*/ class ByReference extends OSVR_RenderInfoOpenGL implements Structure.ByReference { - - }; - public static /*abstract*/ class ByValue extends OSVR_RenderInfoOpenGL implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_RenderParams.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_RenderParams.java deleted file mode 100644 index 6df55bdc88..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_RenderParams.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.jme3.system.osvr.osvrrendermanageropengl; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class OSVR_RenderParams extends Structure { - /** - * Room space to insert
- * C type : OSVR_PoseState* - */ - public Pointer worldFromRoomAppend; - /** - * Overrides head space
- * C type : OSVR_PoseState* - */ - public Pointer roomFromHeadReplace; - public double nearClipDistanceMeters; - public double farClipDistanceMeters; - public OSVR_RenderParams() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("worldFromRoomAppend", "roomFromHeadReplace", "nearClipDistanceMeters", "farClipDistanceMeters"); - } - /** - * @param worldFromRoomAppend Room space to insert
- * C type : OSVR_PoseState*
- * @param roomFromHeadReplace Overrides head space
- * C type : OSVR_PoseState* - */ - public OSVR_RenderParams(Pointer worldFromRoomAppend, Pointer roomFromHeadReplace, double nearClipDistanceMeters, double farClipDistanceMeters) { - super(); - this.worldFromRoomAppend = worldFromRoomAppend; - this.roomFromHeadReplace = roomFromHeadReplace; - this.nearClipDistanceMeters = nearClipDistanceMeters; - this.farClipDistanceMeters = farClipDistanceMeters; - } - public OSVR_RenderParams(Pointer peer) { - super(peer); - } - public static class ByReference extends OSVR_RenderParams implements Structure.ByReference { - - }; - public static class ByValue extends OSVR_RenderParams implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_ViewportDescription.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_ViewportDescription.java deleted file mode 100644 index f504476e4c..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_ViewportDescription.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.jme3.system.osvr.osvrrendermanageropengl; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class OSVR_ViewportDescription extends Structure { - /** Left side of the viewport in pixels */ - public double left; - /** First pixel in the viewport at the bottom. */ - public double lower; - /** Last pixel in the viewport at the top */ - public double width; - /** Last pixel on the right of the viewport in pixels */ - public double height; - public OSVR_ViewportDescription() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("left", "lower", "width", "height"); - } - /** - * @param left Left side of the viewport in pixels
- * @param lower First pixel in the viewport at the bottom.
- * @param width Last pixel in the viewport at the top
- * @param height Last pixel on the right of the viewport in pixels - */ - public OSVR_ViewportDescription(double left, double lower, double width, double height) { - super(); - this.left = left; - this.lower = lower; - this.width = width; - this.height = height; - } - public OSVR_ViewportDescription(Pointer peer) { - super(peer); - } - public static class ByReference extends OSVR_ViewportDescription implements Structure.ByReference { - - }; - public static class ByValue extends OSVR_ViewportDescription implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OsvrRenderManagerOpenGLLibrary.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OsvrRenderManagerOpenGLLibrary.java deleted file mode 100644 index 6b3a02f065..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OsvrRenderManagerOpenGLLibrary.java +++ /dev/null @@ -1,169 +0,0 @@ -package com.jme3.system.osvr.osvrrendermanageropengl; -import com.jme3.system.osvr.osvrclientkit.OsvrClientKitLibrary; -import com.ochafik.lang.jnaerator.runtime.NativeSize; -import com.ochafik.lang.jnaerator.runtime.NativeSizeByReference; -import com.sun.jna.Library; -import com.sun.jna.Native; -import com.sun.jna.NativeLibrary; -import com.sun.jna.Pointer; -import com.sun.jna.PointerType; -import com.sun.jna.ptr.DoubleByReference; -import com.sun.jna.ptr.FloatByReference; -import com.sun.jna.ptr.IntByReference; -import com.sun.jna.ptr.PointerByReference; -import java.nio.DoubleBuffer; -import java.nio.FloatBuffer; -import java.nio.IntBuffer; -/** - * JNA Wrapper for library osvrRenderManagerOpenGL
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class OsvrRenderManagerOpenGLLibrary implements Library { - public static final String JNA_LIBRARY_NAME = "osvrRenderManager"; - public static final NativeLibrary JNA_NATIVE_LIB = NativeLibrary.getInstance(OsvrRenderManagerOpenGLLibrary.JNA_LIBRARY_NAME); - static { - Native.register(OsvrRenderManagerOpenGLLibrary.class, OsvrRenderManagerOpenGLLibrary.JNA_NATIVE_LIB); - } - /** enum values */ - public static interface OSVR_OpenStatus { - public static final int OSVR_OPEN_STATUS_FAILURE = 0; - public static final int OSVR_OPEN_STATUS_PARTIAL = 1; - public static final int OSVR_OPEN_STATUS_COMPLETE = 2; - }; - /** - * todo OSVR_RenderTimingInfo
- * Original signature : OSVR_ReturnCode osvrDestroyRenderManager(OSVR_RenderManager) - */ - public static native byte osvrDestroyRenderManager(Pointer renderManager); - /** - * todo Make this actually cache, for now it does not.
- * Original signature : OSVR_ReturnCode osvrRenderManagerGetNumRenderInfo(OSVR_RenderManager, OSVR_RenderParams, OSVR_RenderInfoCount*) - */ - public static native byte osvrRenderManagerGetNumRenderInfo(Pointer renderManager, OSVR_RenderParams.ByValue renderParams, NativeSizeByReference numRenderInfoOut); - /** Original signature : OSVR_ReturnCode osvrRenderManagerGetDoingOkay(OSVR_RenderManager) */ - public static native byte osvrRenderManagerGetDoingOkay(Pointer renderManager); - /** Original signature : OSVR_ReturnCode osvrRenderManagerGetDefaultRenderParams(OSVR_RenderParams*) */ - public static native byte osvrRenderManagerGetDefaultRenderParams(OSVR_RenderParams renderParamsOut); - /** - * must be registered before they are presented.
- * Original signature : OSVR_ReturnCode osvrRenderManagerStartPresentRenderBuffers(OSVR_RenderManagerPresentState*) - */ - public static native byte osvrRenderManagerStartPresentRenderBuffers(PointerByReference presentStateOut); - /** - * buffers for a single frame. This sequence starts with the Start function.
- * Original signature : OSVR_ReturnCode osvrRenderManagerFinishPresentRenderBuffers(OSVR_RenderManager, OSVR_RenderManagerPresentState, OSVR_RenderParams, OSVR_CBool) - */ - public static native byte osvrRenderManagerFinishPresentRenderBuffers(Pointer renderManager, Pointer presentState, OSVR_RenderParams.ByValue renderParams, byte shouldFlipY); - /** - * must be registered before they are presented.
- * Original signature : OSVR_ReturnCode osvrRenderManagerStartRegisterRenderBuffers(OSVR_RenderManagerRegisterBufferState*) - */ - public static native byte osvrRenderManagerStartRegisterRenderBuffers(PointerByReference registerBufferStateOut); - /** - * buffers for a single frame. This sequence starts with the Start function.
- * Original signature : OSVR_ReturnCode osvrRenderManagerFinishRegisterRenderBuffers(OSVR_RenderManager, OSVR_RenderManagerRegisterBufferState, OSVR_CBool) - */ - public static native byte osvrRenderManagerFinishRegisterRenderBuffers(Pointer renderManager, Pointer registerBufferState, byte appWillNotOverwriteBeforeNewPresent); - /** Original signature : OSVR_ReturnCode osvrRenderManagerPresentSolidColorf(OSVR_RenderManager, OSVR_RGB_FLOAT) */ - public static native byte osvrRenderManagerPresentSolidColorf(Pointer renderManager, com.jme3.system.osvr.osvrrendermanageropengl.OSVR_RGB.ByValue rgb); - /** - * when you're done.
- * Original signature : OSVR_ReturnCode osvrRenderManagerGetRenderInfoCollection(OSVR_RenderManager, OSVR_RenderParams, OSVR_RenderInfoCollection*) - */ - public static native byte osvrRenderManagerGetRenderInfoCollection(Pointer renderManager, OSVR_RenderParams.ByValue renderParams, PointerByReference renderInfoCollectionOut); - /** - * Releases the OSVR_RenderInfoCollection.
- * Original signature : OSVR_ReturnCode osvrRenderManagerReleaseRenderInfoCollection(OSVR_RenderInfoCollection) - */ - public static native byte osvrRenderManagerReleaseRenderInfoCollection(Pointer renderInfoCollection); - /** - * Get the size of the OSVR_RenderInfoCollection.
- * Original signature : OSVR_ReturnCode osvrRenderManagerGetNumRenderInfoInCollection(OSVR_RenderInfoCollection, OSVR_RenderInfoCount*) - */ - public static native byte osvrRenderManagerGetNumRenderInfoInCollection(Pointer renderInfoCollection, NativeSizeByReference countOut); - /** - * @return True on success, false on failure (null pointer).
- * Original signature : OSVR_ReturnCode OSVR_Projection_to_OpenGL(double*, OSVR_ProjectionMatrix)
- * @deprecated use the safer methods {@link #OSVR_Projection_to_OpenGL(java.nio.DoubleBuffer, com.jme3.system.osvr.osvrrendermanageropengl.OSVR_ProjectionMatrix.ByValue)} and {@link #OSVR_Projection_to_OpenGL(com.sun.jna.ptr.DoubleByReference, com.jme3.system.osvr.osvrrendermanageropengl.OSVR_ProjectionMatrix.ByValue)} instead - */ - @Deprecated - public static native byte OSVR_Projection_to_OpenGL(DoubleByReference OpenGL_out, com.jme3.system.osvr.osvrrendermanageropengl.OSVR_ProjectionMatrix.ByValue projection_in); - /** - * @return True on success, false on failure (null pointer).
- * Original signature : OSVR_ReturnCode OSVR_Projection_to_OpenGL(double*, OSVR_ProjectionMatrix) - */ - public static native byte OSVR_Projection_to_OpenGL(DoubleBuffer OpenGL_out, com.jme3.system.osvr.osvrrendermanageropengl.OSVR_ProjectionMatrix.ByValue projection_in); - /** - * @return True on success, false on failure (null pointer).
- * Original signature : OSVR_ReturnCode OSVR_Projection_to_D3D(float[16], OSVR_ProjectionMatrix)
- * @deprecated use the safer methods {@link #OSVR_Projection_to_D3D(java.nio.FloatBuffer, com.jme3.system.osvr.osvrrendermanageropengl.OSVR_ProjectionMatrix.ByValue)} and {@link #OSVR_Projection_to_D3D(com.sun.jna.ptr.FloatByReference, com.jme3.system.osvr.osvrrendermanageropengl.OSVR_ProjectionMatrix.ByValue)} instead - */ - @Deprecated - public static native byte OSVR_Projection_to_D3D(FloatByReference D3D_out, com.jme3.system.osvr.osvrrendermanageropengl.OSVR_ProjectionMatrix.ByValue projection_in); - /** - * @return True on success, false on failure (null pointer).
- * Original signature : OSVR_ReturnCode OSVR_Projection_to_D3D(float[16], OSVR_ProjectionMatrix) - */ - public static native byte OSVR_Projection_to_D3D(FloatBuffer D3D_out, com.jme3.system.osvr.osvrrendermanageropengl.OSVR_ProjectionMatrix.ByValue projection_in); - /** - * @return True on success, false on failure (null pointer).
- * Original signature : OSVR_ReturnCode OSVR_Projection_to_Unreal(float[16], OSVR_ProjectionMatrix)
- * @deprecated use the safer methods {@link #OSVR_Projection_to_Unreal(java.nio.FloatBuffer, com.jme3.system.osvr.osvrrendermanageropengl.OSVR_ProjectionMatrix.ByValue)} and {@link #OSVR_Projection_to_Unreal(com.sun.jna.ptr.FloatByReference, com.jme3.system.osvr.osvrrendermanageropengl.OSVR_ProjectionMatrix.ByValue)} instead - */ - @Deprecated - public static native byte OSVR_Projection_to_Unreal(FloatByReference Unreal_out, com.jme3.system.osvr.osvrrendermanageropengl.OSVR_ProjectionMatrix.ByValue projection_in); - /** - * @return True on success, false on failure (null pointer).
- * Original signature : OSVR_ReturnCode OSVR_Projection_to_Unreal(float[16], OSVR_ProjectionMatrix) - */ - public static native byte OSVR_Projection_to_Unreal(FloatBuffer Unreal_out, com.jme3.system.osvr.osvrrendermanageropengl.OSVR_ProjectionMatrix.ByValue projection_in); - /** - * Original signature : OSVR_ReturnCode osvrCreateRenderManagerOpenGL(OSVR_ClientContext, const char[], OSVR_GraphicsLibraryOpenGL, OSVR_RenderManager*, OSVR_RenderManagerOpenGL*)
- * @deprecated use the safer method - * {@link #osvrCreateRenderManagerOpenGL(com.jme3.system.osvr.osvrclientkit.OsvrClientKitLibrary.OSVR_ClientContext, byte[], com.jme3.system.osvr.osvrrendermanageropengl.OSVR_GraphicsLibraryOpenGL.ByValue, com.sun.jna.ptr.PointerByReference, com.sun.jna.ptr.PointerByReference)} - * instead - */ - @Deprecated - public static native byte osvrCreateRenderManagerOpenGL(Pointer clientContext, Pointer graphicsLibraryName, com.jme3.system.osvr.osvrrendermanageropengl.OSVR_GraphicsLibraryOpenGL.ByValue graphicsLibrary, PointerByReference renderManagerOut, PointerByReference renderManagerOpenGLOut); - /** Original signature : OSVR_ReturnCode osvrCreateRenderManagerOpenGL(OSVR_ClientContext, const char[], OSVR_GraphicsLibraryOpenGL, OSVR_RenderManager*, OSVR_RenderManagerOpenGL*) */ - public static native byte osvrCreateRenderManagerOpenGL(OsvrClientKitLibrary.OSVR_ClientContext clientContext, byte graphicsLibraryName[], com.jme3.system.osvr.osvrrendermanageropengl.OSVR_GraphicsLibraryOpenGL.ByValue graphicsLibrary, PointerByReference renderManagerOut, PointerByReference renderManagerOpenGLOut); - /** Original signature : OSVR_ReturnCode osvrRenderManagerGetRenderInfoOpenGL(OSVR_RenderManagerOpenGL, OSVR_RenderInfoCount, OSVR_RenderParams, OSVR_RenderInfoOpenGL*) */ - public static native byte osvrRenderManagerGetRenderInfoOpenGL(Pointer renderManager, NativeSize renderInfoIndex, OSVR_RenderParams.ByValue renderParams, OSVR_RenderInfoOpenGL renderInfoOut); - /** Original signature : OSVR_ReturnCode osvrRenderManagerOpenDisplayOpenGL(OSVR_RenderManagerOpenGL, OSVR_OpenResultsOpenGL*) */ - public static native byte osvrRenderManagerOpenDisplayOpenGL(Pointer renderManager, OSVR_OpenResultsOpenGL openResultsOut); - /** Original signature : OSVR_ReturnCode osvrRenderManagerPresentRenderBufferOpenGL(OSVR_RenderManagerPresentState, OSVR_RenderBufferOpenGL, OSVR_RenderInfoOpenGL, OSVR_ViewportDescription) */ - public static native byte osvrRenderManagerPresentRenderBufferOpenGL(Pointer presentState, com.jme3.system.osvr.osvrrendermanageropengl.OSVR_RenderBufferOpenGL.ByValue buffer, OSVR_RenderInfoOpenGL.ByValue renderInfoUsed, com.jme3.system.osvr.osvrrendermanageropengl.OSVR_ViewportDescription.ByValue normalizedCroppingViewport); - /** Original signature : OSVR_ReturnCode osvrRenderManagerRegisterRenderBufferOpenGL(OSVR_RenderManagerRegisterBufferState, OSVR_RenderBufferOpenGL) */ - public static native byte osvrRenderManagerRegisterRenderBufferOpenGL(Pointer registerBufferState, com.jme3.system.osvr.osvrrendermanageropengl.OSVR_RenderBufferOpenGL.ByValue renderBuffer); - /** - * Gets a given OSVR_RenderInfoOpenGL from an OSVR_RenderInfoCollection.
- * Original signature : OSVR_ReturnCode osvrRenderManagerGetRenderInfoFromCollectionOpenGL(OSVR_RenderInfoCollection, OSVR_RenderInfoCount, OSVR_RenderInfoOpenGL*) - */ - public static native byte osvrRenderManagerGetRenderInfoFromCollectionOpenGL(Pointer renderInfoCollection, NativeSize index, OSVR_RenderInfoOpenGL renderInfoOut); - /** - * Original signature : OSVR_ReturnCode osvrRenderManagerCreateColorBufferOpenGL(GLsizei, GLsizei, GLenum, GLuint*)
- * @deprecated use the safer methods {@link #osvrRenderManagerCreateColorBufferOpenGL(int, int, int, java.nio.IntBuffer)} and {@link #osvrRenderManagerCreateColorBufferOpenGL(int, int, int, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native byte osvrRenderManagerCreateColorBufferOpenGL(int width, int height, int format, IntByReference colorBufferNameOut); - /** Original signature : OSVR_ReturnCode osvrRenderManagerCreateColorBufferOpenGL(GLsizei, GLsizei, GLenum, GLuint*) */ - public static native byte osvrRenderManagerCreateColorBufferOpenGL(int width, int height, int format, IntBuffer colorBufferNameOut); - /** - * Original signature : OSVR_ReturnCode osvrRenderManagerCreateDepthBufferOpenGL(GLsizei, GLsizei, GLuint*)
- * @deprecated use the safer methods {@link #osvrRenderManagerCreateDepthBufferOpenGL(int, int, java.nio.IntBuffer)} and {@link #osvrRenderManagerCreateDepthBufferOpenGL(int, int, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native byte osvrRenderManagerCreateDepthBufferOpenGL(int width, int height, IntByReference depthBufferNameOut); - /** Original signature : OSVR_ReturnCode osvrRenderManagerCreateDepthBufferOpenGL(GLsizei, GLsizei, GLuint*) */ - public static native byte osvrRenderManagerCreateDepthBufferOpenGL(int width, int height, IntBuffer depthBufferNameOut); - public static class OSVR_ClientContext extends PointerType { - public OSVR_ClientContext(Pointer address) { - super(address); - } - public OSVR_ClientContext() { - super(); - } - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrtimevalue/OSVR_TimeValue.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrtimevalue/OSVR_TimeValue.java deleted file mode 100644 index e500f89b17..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrtimevalue/OSVR_TimeValue.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.jme3.system.osvr.osvrtimevalue; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import java.util.Arrays; -import java.util.List; -/** - * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class OSVR_TimeValue extends Structure { - /** C type : OSVR_TimeValue_Seconds */ - public long seconds; - /** C type : OSVR_TimeValue_Microseconds */ - public int microseconds; - public OSVR_TimeValue() { - super(); - } - @Override - protected List getFieldOrder() { - return Arrays.asList("seconds", "microseconds"); - } - /** - * @param seconds C type : OSVR_TimeValue_Seconds
- * @param microseconds C type : OSVR_TimeValue_Microseconds - */ - public OSVR_TimeValue(long seconds, int microseconds) { - super(); - this.seconds = seconds; - this.microseconds = microseconds; - } - public OSVR_TimeValue(Pointer peer) { - super(peer); - } - public static class ByReference extends OSVR_TimeValue implements Structure.ByReference { - - }; - public static class ByValue extends OSVR_TimeValue implements Structure.ByValue { - - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrtimevalue/OsvrTimeValueLibrary.java b/jme3-xr/src/main/java/com/jme3/system/osvr/osvrtimevalue/OsvrTimeValueLibrary.java deleted file mode 100644 index eb2731b5c0..0000000000 --- a/jme3-xr/src/main/java/com/jme3/system/osvr/osvrtimevalue/OsvrTimeValueLibrary.java +++ /dev/null @@ -1,119 +0,0 @@ -package com.jme3.system.osvr.osvrtimevalue; -import com.sun.jna.Library; -import com.sun.jna.Native; -import com.sun.jna.NativeLibrary; -import com.sun.jna.Pointer; -import com.sun.jna.PointerType; -/** - * JNA Wrapper for library osvrTimeValue
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class OsvrTimeValueLibrary implements Library { - public static final String JNA_LIBRARY_NAME = "osvrClientKit"; - public static final NativeLibrary JNA_NATIVE_LIB = NativeLibrary.getInstance(OsvrTimeValueLibrary.JNA_LIBRARY_NAME); - static { - Native.register(OsvrTimeValueLibrary.class, OsvrTimeValueLibrary.JNA_NATIVE_LIB); - } - public static final int OSVR_TRUE = 1; - public static final int OSVR_FALSE = 0; - /** - * Gets the current time in the TimeValue. Parallel to gettimeofday. - * Original signature : void osvrTimeValueGetNow(OSVR_TimeValue*) - */ - public static native void osvrTimeValueGetNow(OSVR_TimeValue dest); - /** - * Converts from a TimeValue struct to your system's struct timeval. - * @param dest Pointer to an empty struct timeval for your platform.
- * @param src A pointer to an OSVR_TimeValue you'd like to convert from.
- * If either parameter is NULL, the function will return without doing
- * anything.
- * Original signature : void osvrTimeValueToStructTimeval(timeval*, const OSVR_TimeValue*) - */ - public static native void osvrTimeValueToStructTimeval(OsvrTimeValueLibrary.timeval dest, OSVR_TimeValue src); - /** - * Converts from a TimeValue struct to your system's struct timeval. - * @param dest An OSVR_TimeValue destination pointer.
- * @param src Pointer to a struct timeval you'd like to convert from.
- * The result is normalized.
- * If either parameter is NULL, the function will return without doing
- * anything.
- * Original signature : void osvrStructTimevalToTimeValue(OSVR_TimeValue*, timeval*) - */ - public static native void osvrStructTimevalToTimeValue(OSVR_TimeValue dest, OsvrTimeValueLibrary.timeval src); - /** - * "Normalizes" a time value so that the absolute number of microseconds - * is less than 1,000,000, and that the sign of both components is the same.
- * @param tv Address of a struct TimeValue to normalize in place.
- * If the given pointer is NULL, this function returns without doing anything.
- * Original signature : void osvrTimeValueNormalize(OSVR_TimeValue*) - */ - public static native void osvrTimeValueNormalize(OSVR_TimeValue tv); - /** - * Sums two time values, replacing the first with the result. - * @param tvA Destination and first source.
- * @param tvB second source
- * If a given pointer is NULL, this function returns without doing anything.
- * Both parameters are expected to be in normalized form.
- * Original signature : void osvrTimeValueSum(OSVR_TimeValue*, const OSVR_TimeValue*) - */ - public static native void osvrTimeValueSum(OSVR_TimeValue tvA, OSVR_TimeValue tvB); - /** - * Computes the difference between two time values, replacing the first - * with the result.
- * Effectively, `*tvA = *tvA - *tvB`
- * @param tvA Destination and first source.
- * @param tvB second source
- * If a given pointer is NULL, this function returns without doing anything.
- * Both parameters are expected to be in normalized form.
- * Original signature : void osvrTimeValueDifference(OSVR_TimeValue*, const OSVR_TimeValue*) - */ - public static native void osvrTimeValueDifference(OSVR_TimeValue tvA, OSVR_TimeValue tvB); - /** - * Compares two time values (assumed to be normalized), returning - * the same values as strcmp
- * @return <0 if A is earlier than B, 0 if they are the same, and >0 if A
- * is later than B.
- * Original signature : int osvrTimeValueCmp(const OSVR_TimeValue*, const OSVR_TimeValue*) - */ - public static native int osvrTimeValueCmp(OSVR_TimeValue tvA, OSVR_TimeValue tvB); - /** - * Compute the difference between the two time values, returning the - * duration as a double-precision floating-point number of seconds.
- * Effectively, `ret = *tvA - *tvB`
- * @param tvA first source.
- * @param tvB second source
- * @return Duration of timespan in seconds (floating-point)
- * Original signature : double osvrTimeValueDurationSeconds(const OSVR_TimeValue*, const OSVR_TimeValue*) - */ - public static native double osvrTimeValueDurationSeconds(OSVR_TimeValue tvA, OSVR_TimeValue tvB); - /** - * True if A is later than B. - * Original signature : OSVR_CBool osvrTimeValueGreater(const OSVR_TimeValue*, const OSVR_TimeValue*) - */ - public static native byte osvrTimeValueGreater(OSVR_TimeValue tvA, OSVR_TimeValue tvB); - /** - * Returns true if the time value is normalized. Typically used in assertions.
- * Original signature : bool osvrTimeValueIsNormalized(const OSVR_TimeValue&) - */ - public static native byte osvrTimeValueIsNormalized(OSVR_TimeValue tv); - /** - * Operator > overload for time values
- * Original signature : bool operator>(const OSVR_TimeValue&, const OSVR_TimeValue&) - */ - public static native byte operatorGreater(OSVR_TimeValue tvA, OSVR_TimeValue tvB); - /** - * Operator == overload for time values
- * Original signature : bool operator==(const OSVR_TimeValue&, const OSVR_TimeValue&) - */ - public static native byte operatorIsEqual(OSVR_TimeValue tvA, OSVR_TimeValue tvB); - public static class timeval extends PointerType { - public timeval(Pointer address) { - super(address); - } - public timeval() { - super(); - } - }; -} diff --git a/jme3-xr/src/main/java/com/jme3/util/VRGUIPositioningMode.java b/jme3-xr/src/main/java/com/jme3/util/VRGUIPositioningMode.java deleted file mode 100644 index d3e32ea972..0000000000 --- a/jme3-xr/src/main/java/com/jme3/util/VRGUIPositioningMode.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.jme3.util; - -/** - * An enumeration that describes the GUI display positioning modes. - * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr - * - */ -public enum VRGUIPositioningMode { - MANUAL, - AUTO_CAM_ALL, - AUTO_CAM_ALL_SKIP_PITCH, - AUTO_OBSERVER_POS_CAM_ROTATION, - AUTO_OBSERVER_ALL, - AUTO_OBSERVER_ALL_CAMHEIGHT -} diff --git a/jme3-xr/src/main/java/com/jme3/util/VRGuiManager.java b/jme3-xr/src/main/java/com/jme3/util/VRGuiManager.java deleted file mode 100644 index 6bbd603ff6..0000000000 --- a/jme3-xr/src/main/java/com/jme3/util/VRGuiManager.java +++ /dev/null @@ -1,467 +0,0 @@ -package com.jme3.util; - -import com.jme3.app.VREnvironment; -import com.jme3.material.Material; -import com.jme3.material.RenderState.BlendMode; -import com.jme3.math.ColorRGBA; -import com.jme3.math.Matrix3f; -import com.jme3.math.Quaternion; -import com.jme3.math.Vector2f; -import com.jme3.math.Vector3f; -import com.jme3.renderer.Camera; -import com.jme3.renderer.ViewPort; -import com.jme3.renderer.queue.RenderQueue.Bucket; -import com.jme3.scene.Spatial; -import com.jme3.scene.Geometry; -import com.jme3.scene.Node; -import com.jme3.scene.shape.CenterQuad; -import com.jme3.system.AppSettings; -import com.jme3.texture.FrameBuffer; -import com.jme3.texture.Image.Format; -import com.jme3.texture.Texture; -import com.jme3.texture.Texture2D; -import java.awt.GraphicsEnvironment; -import java.util.Iterator; - -/** - * A class dedicated to the management and the display of a Graphical User Interface (GUI) within a VR environment. - * @author reden - phr00t - https://github.com/phr00t - * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr - * - */ -public class VRGuiManager { - private Camera camLeft, camRight; - private float guiDistance = 1.5f; - private float guiScale = 1f; - private float guiPositioningElastic; - - private VRGUIPositioningMode posMode = VRGUIPositioningMode.AUTO_CAM_ALL; - - private final Matrix3f orient = new Matrix3f(); - private Vector2f screenSize; - protected boolean wantsReposition; - - private Vector2f ratio; - - private final Vector3f EoldPos = new Vector3f(); - - private final Quaternion EoldDir = new Quaternion(); - - private final Vector3f look = new Vector3f(); - private final Vector3f left = new Vector3f(); - private final Vector3f temppos = new Vector3f(); - private final Vector3f up = new Vector3f(); - - private boolean useCurvedSurface = false; - private boolean overdraw = false; - private Geometry guiQuad; - private Node guiQuadNode; - private ViewPort offView; - private Texture2D guiTexture; - - private final Quaternion tempq = new Quaternion(); - - private VREnvironment environment = null; - - /** - * Create a new GUI manager attached to the given app state. - * @param environment the VR environment to which this manager is attached to. - */ - public VRGuiManager(VREnvironment environment){ - this.environment = environment; - } - - public boolean isWantsReposition() { - return wantsReposition; - } - - public void setWantsReposition(boolean wantsReposition) { - this.wantsReposition = wantsReposition; - } - - /** - * - * Makes auto GUI positioning happen not immediately, but like an - * elastic connected to the headset. Setting to 0 disables (default) - * Higher settings make it track the headset quicker. - * - * @param elastic amount of elasticity - */ - public void setPositioningElasticity(float elastic) { - guiPositioningElastic = elastic; - } - - public float getPositioningElasticity() { - return guiPositioningElastic; - } - - /** - * Get the GUI {@link VRGUIPositioningMode positioning mode}. - * @return the GUI {@link VRGUIPositioningMode positioning mode}. - * @see #setPositioningMode(VRGUIPositioningMode) - */ - public VRGUIPositioningMode getPositioningMode() { - return posMode; - } - - /** - * Set the GUI {@link VRGUIPositioningMode positioning mode}. - * @param mode the GUI {@link VRGUIPositioningMode positioning mode}. - * @see #getPositioningMode() - */ - public void setPositioningMode(VRGUIPositioningMode mode) { - posMode = mode; - } - - /** - * Get the GUI canvas size. This method return the size in pixels of the GUI available area within the VR view. - * @return the GUI canvas size. This method return the size in pixels of the GUI available area within the VR view. - */ - public Vector2f getCanvasSize() { - if (environment != null){ - - if (environment.getApplication() != null){ - if( screenSize == null ) { - if( environment.isInVR() && environment.getVRHardware() != null ) { - screenSize = new Vector2f(); - environment.getVRHardware().getRenderSize(screenSize); - screenSize.multLocal(environment.getVRViewManager().getResolutionMuliplier()); - } else { - AppSettings as = environment.getApplication().getContext().getSettings(); - screenSize = new Vector2f(as.getWidth(), as.getHeight()); - } - } - return screenSize; - } else { - throw new IllegalStateException("VR GUI manager underlying environment is not attached to any application."); - } - } else { - throw new IllegalStateException("VR GUI manager is not attached to any environment."); - } - } - - /** - * Get the ratio between the {@link #getCanvasSize() GUI canvas size} and the application main windows (if available) or the screen size. - * @return the ratio between the {@link #getCanvasSize() GUI canvas size} and the application main windows (if available). - * @see #getCanvasSize() - */ - public Vector2f getCanvasToWindowRatio() { - if (environment != null){ - - if (environment.getApplication() != null){ - if( ratio == null ) { - ratio = new Vector2f(); - Vector2f canvas = getCanvasSize(); - int width = Integer.min(GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDisplayMode().getWidth(), - environment.getApplication().getContext().getSettings().getWidth()); - int height = Integer.min(GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDisplayMode().getHeight(), - environment.getApplication().getContext().getSettings().getHeight()); - ratio.x = Float.max(1f, canvas.x / width); - ratio.y = Float.max(1f, canvas.y / height); - } - return ratio; - - } else { - throw new IllegalStateException("VR GUI manager underlying environment is not attached to any application."); - } - } else { - throw new IllegalStateException("VR GUI manager is not attached to any environment."); - } - } - - /** - * Inform this manager that it has to position the GUI. - */ - public void positionGui() { - wantsReposition = true; - } - - /** - * Position the GUI to the given location. - * @param pos the position of the GUI. - * @param dir the rotation of the GUI. - * @param tpf the time per frame. - */ - private void positionTo(Vector3f pos, Quaternion dir, float tpf) { - if (environment != null){ - Vector3f guiPos = guiQuadNode.getLocalTranslation(); - guiPos.set(0f, 0f, guiDistance); - dir.mult(guiPos, guiPos); - guiPos.x += pos.x; - guiPos.y += pos.y + environment.getVRHeightAdjustment(); - guiPos.z += pos.z; - if( guiPositioningElastic > 0f && posMode != VRGUIPositioningMode.MANUAL ) { - // mix pos & dir with current pos & dir - guiPos.interpolateLocal(EoldPos, guiPos, Float.min(1f, tpf * guiPositioningElastic)); - EoldPos.set(guiPos); - } - } else { - throw new IllegalStateException("VR GUI manager is not attached to any environment."); - } - } - - /** - * Update the GUI geometric state. This method should be called after GUI modification. - */ - public void updateGuiQuadGeometricState() { - guiQuadNode.updateGeometricState(); - } - - /** - * Position the GUI without delay. - * @param tpf the time per frame. - */ - public void positionGuiNow(float tpf) { - if (environment != null){ - wantsReposition = false; - if( environment.isInVR() == false ){ - return; - } - - guiQuadNode.setLocalScale(guiDistance * guiScale * 4f, 4f * guiDistance * guiScale, 1f); - - switch( posMode ) { - case MANUAL: - case AUTO_CAM_ALL_SKIP_PITCH: - case AUTO_CAM_ALL: - if( camLeft != null && camRight != null ) { - // get middle point - temppos.set(camLeft.getLocation()).interpolateLocal(camRight.getLocation(), 0.5f); - positionTo(temppos, camLeft.getRotation(), tpf); - } - rotateScreenTo(camLeft.getRotation(), tpf); - - break; - case AUTO_OBSERVER_POS_CAM_ROTATION: - Object obs = environment.getObserver(); - if( obs != null ) { - if( obs instanceof Camera ) { - positionTo(((Camera)obs).getLocation(), camLeft.getRotation(), tpf); - } else { - positionTo(((Spatial)obs).getWorldTranslation(), camLeft.getRotation(), tpf); - } - } - rotateScreenTo(camLeft.getRotation(), tpf); - - break; - case AUTO_OBSERVER_ALL: - case AUTO_OBSERVER_ALL_CAMHEIGHT: - obs = environment.getObserver(); - if( obs != null ) { - Quaternion q; - if( obs instanceof Camera ) { - q = ((Camera)obs).getRotation(); - temppos.set(((Camera)obs).getLocation()); - } else { - q = ((Spatial)obs).getWorldRotation(); - temppos.set(((Spatial)obs).getWorldTranslation()); - } - if( posMode == VRGUIPositioningMode.AUTO_OBSERVER_ALL_CAMHEIGHT ) { - temppos.y = camLeft.getLocation().y; - } - positionTo(temppos, q, tpf); - rotateScreenTo(q, tpf); - - } - break; - } - } else { - throw new IllegalStateException("VR GUI manager is not attached to any environment."); - } - } - - /** - * Rotate the GUI to the given direction. - * @param dir the direction to rotate to. - * @param tpf the time per frame. - */ - private void rotateScreenTo(Quaternion dir, float tpf) { - dir.getRotationColumn(2, look).negateLocal(); - dir.getRotationColumn(0, left).negateLocal(); - orient.fromAxes(left, dir.getRotationColumn(1, up), look); - Quaternion rot = tempq.fromRotationMatrix(orient); - if( posMode == VRGUIPositioningMode.AUTO_CAM_ALL_SKIP_PITCH ){ - VRUtil.stripToYaw(rot); - } - - if( guiPositioningElastic > 0f && posMode != VRGUIPositioningMode.MANUAL ) { - // mix pos & dir with current pos & dir - EoldDir.nlerp(rot, tpf * guiPositioningElastic); - guiQuadNode.setLocalRotation(EoldDir); - } else { - guiQuadNode.setLocalRotation(rot); - } - } - - /** - * Get the GUI distance from the observer. - * @return the GUI distance from the observer. - * @see #setGuiDistance(float) - */ - public float getGuiDistance() { - return guiDistance; - } - - /** - * Set the GUI distance from the observer. - * @param newGuiDistance the GUI distance from the observer. - * @see #getGuiDistance() - */ - public void setGuiDistance(float newGuiDistance) { - guiDistance = newGuiDistance; - } - - /** - * Get the GUI scale. - * @return the GUI scale. - * @see #setGuiScale(float) - */ - public float getGUIScale(){ - return guiScale; - } - - /** - * Set the GUI scale. - * @param scale the GUI scale. - * @see #getGUIScale() - */ - public void setGuiScale(float scale) { - guiScale = scale; - } - - /** - * Adjust the GUI distance from the observer. - * This method increment / decrement the {@link #getGuiDistance() GUI distance} by the given value. - * @param adjustAmount the increment (if positive) / decrement (if negative) value of the GUI distance. - */ - public void adjustGuiDistance(float adjustAmount) { - guiDistance += adjustAmount; - } - - /** - * Set up the GUI. - * @param leftCam the left-eye camera. - * @param rightCam the right-eye camera. - * @param left the left-eye viewport. - * @param right the right-eye viewport. - */ - public void setupGui(Camera leftCam, Camera rightCam, ViewPort left, ViewPort right) { - - if (environment != null){ - if( environment.hasTraditionalGUIOverlay() ) { - camLeft = leftCam; - camRight = rightCam; - Spatial guiScene = getGuiQuad(camLeft); - left.attachScene(guiScene); - if( right != null ) right.attachScene(guiScene); - setPositioningMode(posMode); - } - } else { - throw new IllegalStateException("VR GUI manager is not attached to any environment."); - } - } - - /** - * Get if the GUI has to use curved surface. - * @return true if the GUI has to use curved surface and false otherwise. - * @see #setCurvedSurface(boolean) - */ - public boolean isCurverSurface(){ - return useCurvedSurface; - } - - /** - * Set if the GUI has to use curved surface. - * @param set true if the GUI has to use curved surface and false otherwise. - * @see #isCurverSurface() - */ - public void setCurvedSurface(boolean set) { - useCurvedSurface = set; - } - - /** - * Get if the GUI has to be displayed even if it is behind objects. - * @return true if the GUI has to use curved surface and false otherwise. - * @see #setGuiOverdraw(boolean) - */ - public boolean isGuiOverdraw(){ - return overdraw; - } - - /** - * Set if the GUI has to be displayed even if it is behind objects. - * @param set true if the GUI has to use curved surface and false otherwise. - * @see #isGuiOverdraw() - */ - public void setGuiOverdraw(boolean set) { - overdraw = set; - } - - /** - * Create a GUI quad for the given camera. - * @param sourceCam the camera - * @return a GUI quad for the given camera. - */ - private Spatial getGuiQuad(Camera sourceCam){ - if (environment != null){ - - if (environment.getApplication() != null){ - if( guiQuadNode == null ) { - Vector2f guiCanvasSize = getCanvasSize(); - Camera offCamera = sourceCam.clone(); - offCamera.setParallelProjection(true); - offCamera.setLocation(Vector3f.ZERO); - offCamera.lookAt(Vector3f.UNIT_Z, Vector3f.UNIT_Y); - - offView = environment.getApplication().getRenderManager().createPreView("GUI View", offCamera); - offView.setClearFlags(true, true, true); - offView.setBackgroundColor(ColorRGBA.BlackNoAlpha); - - // create offscreen framebuffer - FrameBuffer offBuffer = new FrameBuffer((int)guiCanvasSize.x, (int)guiCanvasSize.y, 1); - - //setup framebuffer's texture - guiTexture = new Texture2D((int)guiCanvasSize.x, (int)guiCanvasSize.y, Format.RGBA8); - guiTexture.setMinFilter(Texture.MinFilter.BilinearNoMipMaps); - guiTexture.setMagFilter(Texture.MagFilter.Bilinear); - - //setup framebuffer to use texture - offBuffer.setDepthBuffer(Format.Depth); - offBuffer.setColorTexture(guiTexture); - - //set viewport to render to offscreen framebuffer - offView.setOutputFrameBuffer(offBuffer); - - // setup framebuffer's scene - Iterator spatialIter = environment.getApplication().getGuiViewPort().getScenes().iterator(); - while(spatialIter.hasNext()){ - offView.attachScene(spatialIter.next()); - } - - if( useCurvedSurface ) { - guiQuad = (Geometry)environment.getApplication().getAssetManager().loadModel("Common/Util/gui_mesh.j3o"); - } else { - guiQuad = new Geometry("guiQuad", new CenterQuad(1f, 1f)); - } - - Material mat = new Material(environment.getApplication().getAssetManager(), "Common/MatDefs/VR/GuiOverlay.j3md"); - mat.getAdditionalRenderState().setDepthTest(!overdraw); - mat.getAdditionalRenderState().setBlendMode(BlendMode.Alpha); - mat.getAdditionalRenderState().setDepthWrite(false); - mat.setTexture("ColorMap", guiTexture); - guiQuad.setQueueBucket(Bucket.Translucent); - guiQuad.setMaterial(mat); - - guiQuadNode = new Node("gui-quad-node"); - guiQuadNode.setQueueBucket(Bucket.Translucent); - guiQuadNode.attachChild(guiQuad); - } - return guiQuadNode; - } else { - throw new IllegalStateException("VR GUI manager underlying environment is not attached to any application."); - } - } else { - throw new IllegalStateException("VR GUI manager is not attached to any environment."); - } - } -} diff --git a/jme3-xr/src/main/java/com/jme3/util/VRUtil.java b/jme3-xr/src/main/java/com/jme3/util/VRUtil.java deleted file mode 100644 index 19a4c5c9be..0000000000 --- a/jme3-xr/src/main/java/com/jme3/util/VRUtil.java +++ /dev/null @@ -1,101 +0,0 @@ -package com.jme3.util; - -import com.jme3.math.FastMath; -import com.jme3.math.Matrix4f; -import com.jme3.math.Quaternion; - - -import java.util.concurrent.TimeUnit; - -/** - * - * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr - * - */ -public class VRUtil { - - private static final long SLEEP_PRECISION = TimeUnit.MILLISECONDS.toNanos(4); - private static final long SPIN_YIELD_PRECISION = TimeUnit.MILLISECONDS.toNanos(2); - - /** - * A private constructor to inhibit instantiation of this class. - */ - private VRUtil() { - } - - public static void sleepNanos(long nanoDuration) { - final long end = System.nanoTime() + nanoDuration; - long timeLeft = nanoDuration; - do { - try { - if (timeLeft > SLEEP_PRECISION) { - Thread.sleep(1); - } else if (timeLeft > SPIN_YIELD_PRECISION) { - Thread.sleep(0); - } - } catch(Exception e) { } - timeLeft = end - System.nanoTime(); - } while (timeLeft > 0); - } - - - - - public static void convertMatrix4toQuat(Matrix4f in, Quaternion out) { - // convert rotation matrix to quat - out.fromRotationMatrix(in.m00, in.m01, in.m02, in.m10, in.m11, in.m12, in.m20, in.m21, in.m22); - // flip the pitch - out.set(-out.getX(), out.getY(), -out.getZ(), out.getW()); - } - - public static Quaternion FastFullAngles(Quaternion use, float yaw, float pitch, float roll) { - float angle; - float sinRoll, sinPitch, sinYaw, cosRoll, cosPitch, cosYaw; - angle = roll * 0.5f; - sinPitch = (float)Math.sin(angle); - cosPitch = (float)Math.cos(angle); - angle = yaw * 0.5f; - sinRoll = (float)Math.sin(angle); - cosRoll = (float)Math.cos(angle); - angle = pitch * 0.5f; - sinYaw = (float)Math.sin(angle); - cosYaw = (float)Math.cos(angle); - - // variables used to reduce multiplication calls. - float cosRollXcosPitch = cosRoll * cosPitch; - float sinRollXsinPitch = sinRoll * sinPitch; - float cosRollXsinPitch = cosRoll * sinPitch; - float sinRollXcosPitch = sinRoll * cosPitch; - - use.set((cosRollXcosPitch * sinYaw + sinRollXsinPitch * cosYaw), - (sinRollXcosPitch * cosYaw + cosRollXsinPitch * sinYaw), - (cosRollXsinPitch * cosYaw - sinRollXcosPitch * sinYaw), - (cosRollXcosPitch * cosYaw - sinRollXsinPitch * sinYaw)); - - return use; - } - - public static Quaternion stripToYaw(Quaternion q) { - float yaw; - float w = q.getW(); - float x = q.getX(); - float y = q.getY(); - float z = q.getZ(); - float sqx = x*x; - float sqy = y*y; - float sqz = z*z; - float sqw = w*w; - float unit = sqx + sqy + sqz + sqw; // if normalized is one, otherwise - // is correction factor - float test = x * y + z * w; - if (test > 0.499 * unit) { // singularity at north pole - yaw = 2 * FastMath.atan2(x, w); - } else if (test < -0.499 * unit) { // singularity at south pole - yaw = -2 * FastMath.atan2(x, w); - } else { - yaw = FastMath.atan2(2 * y * w - 2 * x * z, sqx - sqy - sqz + sqw); // roll or heading - } - FastFullAngles(q, yaw, 0f, 0f); - return q; - } -} diff --git a/jme3-xr/src/main/java/test/TestInitHmd.java b/jme3-xr/src/main/java/test/TestInitHmd.java deleted file mode 100644 index a15ea732d1..0000000000 --- a/jme3-xr/src/main/java/test/TestInitHmd.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2009-2018 jMonkeyEngine - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'jMonkeyEngine' nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package test; - -import com.jme3.app.VREnvironment; -import com.jme3.input.vr.openvr.OpenVR; -import com.jme3.system.AppSettings; - -/** - * Testing OpenVR environment. - * @author Rickard (neph1 @ github) - */ -public class TestInitHmd { - - public static void main(String... args){ - testInitHmd(); - } - - public static void testInitHmd(){ - VREnvironment environment = new VREnvironment(new AppSettings(true)); - environment.initialize(); - OpenVR openVr = (OpenVR) environment.getVRHardware(); - System.out.println(openVr.getName()); - - openVr.updatePose(); - - openVr.destroy(); - - } -} \ No newline at end of file From 1155eb7644e485ab7369d759f8b9b49859b59ee1 Mon Sep 17 00:00:00 2001 From: Starcommander Date: Mon, 15 May 2023 21:15:22 +0200 Subject: [PATCH 12/18] Cleanup non used files. --- .../Common/MatDefs/VR/CartoonSSAO.frag | 109 ----------- .../Common/MatDefs/VR/CartoonSSAO.j3md | 47 ----- .../Common/MatDefs/VR/GuiOverlay.frag | 10 - .../Common/MatDefs/VR/GuiOverlay.j3md | 38 ---- .../Common/MatDefs/VR/GuiOverlay.vert | 12 -- .../Common/MatDefs/VR/GuiOverlay15.frag | 13 -- .../Common/MatDefs/VR/GuiOverlay15.vert | 14 -- .../resources/Common/MatDefs/VR/OpenVR.frag | 22 --- .../resources/Common/MatDefs/VR/OpenVR.j3md | 33 ---- .../resources/Common/MatDefs/VR/OpenVR.vert | 17 -- .../resources/Common/MatDefs/VR/OpenVR15.frag | 24 --- .../resources/Common/MatDefs/VR/OpenVR15.vert | 17 -- .../Common/MatDefs/VR/PostShadowFilter.frag | 184 ------------------ .../Common/MatDefs/VR/PostShadowFilter.j3md | 99 ---------- .../Common/MatDefs/VR/PostShadowFilter.vert | 11 -- .../resources/Common/MatDefs/VR/Unshaded.frag | 21 -- .../resources/Common/MatDefs/VR/Unshaded.j3md | 45 ----- .../resources/Common/MatDefs/VR/Unshaded.vert | 27 --- .../resources/Common/MatDefs/VR/normal.frag | 9 - .../resources/Common/MatDefs/VR/normal.vert | 19 -- .../Common/ShaderLib/InstanceVR.glsllib | 126 ------------ .../main/resources/Common/Util/gui_mesh.j3o | Bin 4995 -> 0 bytes .../resources/Common/Util/gui_mesh.j3odata | 3 - .../src/main/resources/Common/Util/mouse.png | Bin 2115 -> 0 bytes .../demo/openxr/vulkan/hello.frag.spv | Bin 1300 -> 0 bytes .../demo/openxr/vulkan/hello.vert.spv | Bin 1384 -> 0 bytes 26 files changed, 900 deletions(-) delete mode 100644 jme3-xr/src/main/resources/Common/MatDefs/VR/CartoonSSAO.frag delete mode 100644 jme3-xr/src/main/resources/Common/MatDefs/VR/CartoonSSAO.j3md delete mode 100644 jme3-xr/src/main/resources/Common/MatDefs/VR/GuiOverlay.frag delete mode 100644 jme3-xr/src/main/resources/Common/MatDefs/VR/GuiOverlay.j3md delete mode 100644 jme3-xr/src/main/resources/Common/MatDefs/VR/GuiOverlay.vert delete mode 100644 jme3-xr/src/main/resources/Common/MatDefs/VR/GuiOverlay15.frag delete mode 100644 jme3-xr/src/main/resources/Common/MatDefs/VR/GuiOverlay15.vert delete mode 100644 jme3-xr/src/main/resources/Common/MatDefs/VR/OpenVR.frag delete mode 100644 jme3-xr/src/main/resources/Common/MatDefs/VR/OpenVR.j3md delete mode 100644 jme3-xr/src/main/resources/Common/MatDefs/VR/OpenVR.vert delete mode 100644 jme3-xr/src/main/resources/Common/MatDefs/VR/OpenVR15.frag delete mode 100644 jme3-xr/src/main/resources/Common/MatDefs/VR/OpenVR15.vert delete mode 100644 jme3-xr/src/main/resources/Common/MatDefs/VR/PostShadowFilter.frag delete mode 100644 jme3-xr/src/main/resources/Common/MatDefs/VR/PostShadowFilter.j3md delete mode 100644 jme3-xr/src/main/resources/Common/MatDefs/VR/PostShadowFilter.vert delete mode 100644 jme3-xr/src/main/resources/Common/MatDefs/VR/Unshaded.frag delete mode 100644 jme3-xr/src/main/resources/Common/MatDefs/VR/Unshaded.j3md delete mode 100644 jme3-xr/src/main/resources/Common/MatDefs/VR/Unshaded.vert delete mode 100644 jme3-xr/src/main/resources/Common/MatDefs/VR/normal.frag delete mode 100644 jme3-xr/src/main/resources/Common/MatDefs/VR/normal.vert delete mode 100644 jme3-xr/src/main/resources/Common/ShaderLib/InstanceVR.glsllib delete mode 100644 jme3-xr/src/main/resources/Common/Util/gui_mesh.j3o delete mode 100644 jme3-xr/src/main/resources/Common/Util/gui_mesh.j3odata delete mode 100644 jme3-xr/src/main/resources/Common/Util/mouse.png delete mode 100644 jme3-xr/src/main/resources/demo/openxr/vulkan/hello.frag.spv delete mode 100644 jme3-xr/src/main/resources/demo/openxr/vulkan/hello.vert.spv diff --git a/jme3-xr/src/main/resources/Common/MatDefs/VR/CartoonSSAO.frag b/jme3-xr/src/main/resources/Common/MatDefs/VR/CartoonSSAO.frag deleted file mode 100644 index 5d121019fc..0000000000 --- a/jme3-xr/src/main/resources/Common/MatDefs/VR/CartoonSSAO.frag +++ /dev/null @@ -1,109 +0,0 @@ -//#define FRAGMENT_SHADER -#import "Common/ShaderLib/GLSLCompat.glsllib" - -uniform vec2 g_ResolutionInverse; -uniform vec2 m_FrustumNearFar; -uniform sampler2D m_Texture; -uniform sampler2D m_Normals; -uniform sampler2D m_DepthTexture; -uniform vec3 m_FrustumCorner; -uniform float m_Distance; - -varying vec2 texCoord; - -#define m_Scale 3.15 -#define m_Bias 0.025 -#define m_SampleRadius 200.0 - -vec4 fetchNormalDepth(vec2 tc){ - vec4 nd; - nd.xyz = texture2D(m_Normals, tc).rgb; - nd.w = 150.0 * texture2D(m_DepthTexture, tc).r; - return nd; -} - -vec3 getPosition(in vec2 uv){ - float depth= (2.0 * m_FrustumNearFar.x) / (m_FrustumNearFar.y + m_FrustumNearFar.x - texture2D(m_DepthTexture,uv).r * (m_FrustumNearFar.y-m_FrustumNearFar.x)); -#ifdef INSTANCING - float x = mix(-m_FrustumCorner.x, m_FrustumCorner.x, (uv.x - (uv.x > 0.5 ? 0.5 : 0.0)) * 2.0); -#else - float x = mix(-m_FrustumCorner.x, m_FrustumCorner.x, uv.x); -#endif - float y = mix(-m_FrustumCorner.y, m_FrustumCorner.y, uv.y); - return depth* vec3(x, y, m_FrustumCorner.z); -} - -vec3 getPosition(in vec2 uv, in float indepth){ - float depth= (2.0 * m_FrustumNearFar.x) / (m_FrustumNearFar.y + m_FrustumNearFar.x - indepth * (m_FrustumNearFar.y-m_FrustumNearFar.x)); -#ifdef INSTANCING - float x = mix(-m_FrustumCorner.x, m_FrustumCorner.x, (uv.x - (uv.x > 0.5 ? 0.5 : 0.0)) * 2.0); -#else - float x = mix(-m_FrustumCorner.x, m_FrustumCorner.x, uv.x); -#endif - float y = mix(-m_FrustumCorner.y, m_FrustumCorner.y, uv.y); - return depth* vec3(x, y, m_FrustumCorner.z); -} - -float doAmbientOcclusion(in vec2 tc, in vec3 pos, in vec3 norm){ - vec3 diff = getPosition(tc)- pos; - float d = length(diff) * m_Scale; - vec3 v = normalize(diff); - return step(0.00002,d)*max(0.0, dot(norm, v) - m_Bias) * ( 1.0/(1.0 + d) ) * smoothstep(0.00002,0.0027,d); -} - -void main(){ - float result; - - float firstdepth = texture2D(m_DepthTexture,texCoord).r; - vec4 color = texture2D(m_Texture, texCoord); - - if( firstdepth == 1.0 ) { - gl_FragColor = color; - return; - } - - vec3 position = getPosition(texCoord, firstdepth); - vec3 normal = texture2D(m_Normals, texCoord).xyz * 2.0 - 1.0; - - vec2 rad = m_SampleRadius * g_ResolutionInverse / max(16.0, position.z); - - float ao = doAmbientOcclusion(texCoord + vec2( rad.x, rad.y), position, normal); - ao += doAmbientOcclusion(texCoord + vec2(-rad.x, rad.y), position, normal); - ao += doAmbientOcclusion(texCoord + vec2( rad.x, -rad.y), position, normal); - ao += doAmbientOcclusion(texCoord + vec2(-rad.x, -rad.y), position, normal); - - ao += doAmbientOcclusion(texCoord + vec2(-rad.x, 0.0), position, normal); - ao += doAmbientOcclusion(texCoord + vec2( rad.x, 0.0), position, normal); - ao += doAmbientOcclusion(texCoord + vec2(0.0, -rad.y), position, normal); - ao += doAmbientOcclusion(texCoord + vec2(0.0, rad.y), position, normal); - - rad *= 0.7; - - ao += doAmbientOcclusion(texCoord + vec2(-rad.x, -rad.y), position, normal); - ao += doAmbientOcclusion(texCoord + vec2( rad.x, -rad.y), position, normal); - ao += doAmbientOcclusion(texCoord + vec2(-rad.x, rad.y), position, normal); - ao += doAmbientOcclusion(texCoord + vec2( rad.x, rad.y), position, normal); - - result = 1.0 - clamp(ao * 0.4 - position.z * m_Distance * 2.5, 0.0, 0.6); - -#ifndef NO_OUTLINE - // ok, done with ambient occlusion, do cartoon edge - - vec2 mv = 0.5 * g_ResolutionInverse; - - vec4 n1 = fetchNormalDepth(texCoord + vec2(-mv.x, -mv.y)); - vec4 n2 = fetchNormalDepth(texCoord + vec2( mv.x, mv.y)); - vec4 n3 = fetchNormalDepth(texCoord + vec2(-mv.x, mv.y)); - vec4 n4 = fetchNormalDepth(texCoord + vec2( mv.x, -mv.y)); - - // Work out how much the normal and depth values are changing. - vec4 diagonalDelta = abs(n1 - n2) + abs(n3 - n4); - - float normalDelta = dot(diagonalDelta.xyz, vec3(1.0)); - float totalDelta = (diagonalDelta.w + normalDelta * 0.4) - position.z * m_Distance; - - gl_FragColor = color * vec4(result, result, result, 1.0) * (1.0 - clamp(totalDelta, 0.0, 1.0)); -#else - gl_FragColor = color * vec4(result, result, result, 1.0); -#endif -} diff --git a/jme3-xr/src/main/resources/Common/MatDefs/VR/CartoonSSAO.j3md b/jme3-xr/src/main/resources/Common/MatDefs/VR/CartoonSSAO.j3md deleted file mode 100644 index 5faaf9260b..0000000000 --- a/jme3-xr/src/main/resources/Common/MatDefs/VR/CartoonSSAO.j3md +++ /dev/null @@ -1,47 +0,0 @@ -MaterialDef CartoonSSAO { - - MaterialParameters { - Int NumSamples - Int NumSamplesDepth - Texture2D DepthTexture - Texture2D Texture - Texture2D Normals - Vector3 FrustumCorner - Float Distance - Boolean disableOutline - Boolean useInstancing - Vector2 FrustumNearFar - } - - Technique { - VertexShader GLSL150: Common/MatDefs/Post/Post15.vert - FragmentShader GLSL150: Common/MatDefs/VR/CartoonSSAO.frag - - WorldParameters { - WorldViewProjectionMatrix - WorldViewMatrix - ResolutionInverse - } - - Defines { - NO_OUTLINE : disableOutline - INSTANCING : useInstancing - } - } - - Technique { - VertexShader GLSL100: Common/MatDefs/Post/Post.vert - FragmentShader GLSL100: Common/MatDefs/VR/CartoonSSAO.frag - - WorldParameters { - WorldViewProjectionMatrix - WorldViewMatrix - ResolutionInverse - } - - Defines { - NO_OUTLINE : disableOutline - INSTANCING : useInstancing - } - } -} diff --git a/jme3-xr/src/main/resources/Common/MatDefs/VR/GuiOverlay.frag b/jme3-xr/src/main/resources/Common/MatDefs/VR/GuiOverlay.frag deleted file mode 100644 index 555ef3eb49..0000000000 --- a/jme3-xr/src/main/resources/Common/MatDefs/VR/GuiOverlay.frag +++ /dev/null @@ -1,10 +0,0 @@ -#import "Common/ShaderLib/GLSLCompat.glsllib" - -uniform sampler2D m_ColorMap; - -varying vec2 texCoord1; - -void main(){ - gl_FragColor = texture2D(m_ColorMap, texCoord1); - gl_FragColor.a *= 12.0 / (1.0 + gl_FragColor.a * 11.0 ); -} \ No newline at end of file diff --git a/jme3-xr/src/main/resources/Common/MatDefs/VR/GuiOverlay.j3md b/jme3-xr/src/main/resources/Common/MatDefs/VR/GuiOverlay.j3md deleted file mode 100644 index 79b7759237..0000000000 --- a/jme3-xr/src/main/resources/Common/MatDefs/VR/GuiOverlay.j3md +++ /dev/null @@ -1,38 +0,0 @@ -MaterialDef GuiOverlay { - - MaterialParameters { - Texture2D ColorMap - - // For VR instancing - Matrix4 RightEyeViewProjectionMatrix - } - - Technique { - VertexShader GLSL150: Common/MatDefs/VR/GuiOverlay15.vert - FragmentShader GLSL150: Common/MatDefs/VR/GuiOverlay15.frag - - WorldParameters { - WorldViewProjectionMatrix - ViewProjectionMatrix // needed for VR instancing - } - - Defines { - INSTANCING : RightEyeViewProjectionMatrix // For VR instancing - } - } - - Technique { - VertexShader GLSL100: Common/MatDefs/VR/GuiOverlay.vert - FragmentShader GLSL100: Common/MatDefs/VR/GuiOverlay.frag - - WorldParameters { - WorldViewProjectionMatrix - ViewProjectionMatrix // needed for VR instancing - } - - Defines { - INSTANCING : RightEyeViewProjectionMatrix // For VR instancing - } - } - -} \ No newline at end of file diff --git a/jme3-xr/src/main/resources/Common/MatDefs/VR/GuiOverlay.vert b/jme3-xr/src/main/resources/Common/MatDefs/VR/GuiOverlay.vert deleted file mode 100644 index 8b05071961..0000000000 --- a/jme3-xr/src/main/resources/Common/MatDefs/VR/GuiOverlay.vert +++ /dev/null @@ -1,12 +0,0 @@ -// import the following for VR instancing -#import "Common/ShaderLib/InstanceVR.glsllib" - -attribute vec3 inPosition; -attribute vec2 inTexCoord; -varying vec2 texCoord1; - -void main(){ - texCoord1 = inTexCoord; - vec4 modelSpacePos = vec4(inPosition, 1.0); - gl_Position = TransformWorldViewProjectionVR(modelSpacePos); -} \ No newline at end of file diff --git a/jme3-xr/src/main/resources/Common/MatDefs/VR/GuiOverlay15.frag b/jme3-xr/src/main/resources/Common/MatDefs/VR/GuiOverlay15.frag deleted file mode 100644 index efaca8436c..0000000000 --- a/jme3-xr/src/main/resources/Common/MatDefs/VR/GuiOverlay15.frag +++ /dev/null @@ -1,13 +0,0 @@ -//#define FRAGMENT_SHADER -#import "Common/ShaderLib/GLSLCompat.glsllib" - -uniform sampler2D m_ColorMap; - -in vec2 texCoord1; - -out vec4 outColor; - -void main(){ - outColor = texture2D(m_ColorMap, texCoord1); - outColor.a *= 12.0 / (1.0 + outColor.a * 11.0 ); -} \ No newline at end of file diff --git a/jme3-xr/src/main/resources/Common/MatDefs/VR/GuiOverlay15.vert b/jme3-xr/src/main/resources/Common/MatDefs/VR/GuiOverlay15.vert deleted file mode 100644 index cb505d5cfe..0000000000 --- a/jme3-xr/src/main/resources/Common/MatDefs/VR/GuiOverlay15.vert +++ /dev/null @@ -1,14 +0,0 @@ -// import the following for VR instancing -//#define VERTEX_SHADER -#import "Common/ShaderLib/GLSLCompat.glsllib" -#import "Common/ShaderLib/InstanceVR.glsllib" - -in vec3 inPosition; -in vec2 inTexCoord; -out vec2 texCoord1; - -void main(){ - texCoord1 = inTexCoord; - vec4 modelSpacePos = vec4(inPosition, 1.0); - gl_Position = TransformWorldViewProjectionVR(modelSpacePos); -} \ No newline at end of file diff --git a/jme3-xr/src/main/resources/Common/MatDefs/VR/OpenVR.frag b/jme3-xr/src/main/resources/Common/MatDefs/VR/OpenVR.frag deleted file mode 100644 index 9d61ca057e..0000000000 --- a/jme3-xr/src/main/resources/Common/MatDefs/VR/OpenVR.frag +++ /dev/null @@ -1,22 +0,0 @@ -#import "Common/ShaderLib/GLSLCompat.glsllib" -uniform sampler2D m_Texture; - -varying vec2 UVred; -varying vec2 UVgreen; -varying vec2 UVblue; - -void main() { - // performance & FOV experiment by removing bounds check - //float fBoundsCheck = ( (dot( vec2( lessThan( UVgreen.xy, vec2(0.05, 0.05)) ), vec2(1.0, 1.0))+dot( vec2( greaterThan( UVgreen.xy, vec2( 0.95, 0.95)) ), vec2(1.0, 1.0))) ); - // - //if( fBoundsCheck > 1.0 ) { - // gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); - //} else { - - float red = texture2D(m_Texture, UVred).x; - float green = texture2D(m_Texture, UVgreen).y; - float blue = texture2D(m_Texture, UVblue).z; - gl_FragColor = vec4( red, green, blue, 1.0 ); - - //} -} diff --git a/jme3-xr/src/main/resources/Common/MatDefs/VR/OpenVR.j3md b/jme3-xr/src/main/resources/Common/MatDefs/VR/OpenVR.j3md deleted file mode 100644 index 7cadd0af08..0000000000 --- a/jme3-xr/src/main/resources/Common/MatDefs/VR/OpenVR.j3md +++ /dev/null @@ -1,33 +0,0 @@ -MaterialDef OpenVR { - MaterialParameters { - Int NumSamples - Texture2D Texture - - Vector2 inUVred - Vector2 inUVblue - Vector2 inUVgreen - } - - Technique { - VertexShader GLSL150: Common/MatDefs/VR/OpenVR15.vert - FragmentShader GLSL150: Common/MatDefs/VR/OpenVR15.frag - - WorldParameters { - } - - Defines { - } - - } - - Technique { - VertexShader GLSL100: Common/MatDefs/VR/OpenVR.vert - FragmentShader GLSL100: Common/MatDefs/VR/OpenVR.frag - - WorldParameters { - } - - Defines { - } - } -} \ No newline at end of file diff --git a/jme3-xr/src/main/resources/Common/MatDefs/VR/OpenVR.vert b/jme3-xr/src/main/resources/Common/MatDefs/VR/OpenVR.vert deleted file mode 100644 index 734a097e29..0000000000 --- a/jme3-xr/src/main/resources/Common/MatDefs/VR/OpenVR.vert +++ /dev/null @@ -1,17 +0,0 @@ -#import "Common/ShaderLib/GLSLCompat.glsllib" -attribute vec4 inPosition; - -attribute vec2 inTexCoord; // m_inUVred -attribute vec2 inTexCoord2; // m_inUVgreen -attribute vec2 inTexCoord3; // m_inUVblue - -varying vec2 UVred; -varying vec2 UVgreen; -varying vec2 UVblue; - -void main() { - gl_Position = inPosition; - UVred = inTexCoord; - UVgreen = inTexCoord2; - UVblue = inTexCoord3; -} \ No newline at end of file diff --git a/jme3-xr/src/main/resources/Common/MatDefs/VR/OpenVR15.frag b/jme3-xr/src/main/resources/Common/MatDefs/VR/OpenVR15.frag deleted file mode 100644 index 20d195c490..0000000000 --- a/jme3-xr/src/main/resources/Common/MatDefs/VR/OpenVR15.frag +++ /dev/null @@ -1,24 +0,0 @@ -#import "Common/ShaderLib/GLSLCompat.glsllib" -uniform sampler2D m_Texture; - -in vec2 UVred; -in vec2 UVgreen; -in vec2 UVblue; - -out vec4 outColor; - -void main() { - // performance & FOV improvement by removing bounds check - //float fBoundsCheck = ( (dot( vec2( lessThan( UVgreen.xy, vec2(0.05, 0.05)) ), vec2(1.0, 1.0))+dot( vec2( greaterThan( UVgreen.xy, vec2( 0.95, 0.95)) ), vec2(1.0, 1.0))) ); - // - //if( fBoundsCheck > 1.0 ) { - // gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); - //} else { - - float red = texture2D(m_Texture, UVred).x; - float green = texture2D(m_Texture, UVgreen).y; - float blue = texture2D(m_Texture, UVblue).z; - outColor = vec4( red, green, blue, 1.0 ); - - //} -} diff --git a/jme3-xr/src/main/resources/Common/MatDefs/VR/OpenVR15.vert b/jme3-xr/src/main/resources/Common/MatDefs/VR/OpenVR15.vert deleted file mode 100644 index e0c17a91b1..0000000000 --- a/jme3-xr/src/main/resources/Common/MatDefs/VR/OpenVR15.vert +++ /dev/null @@ -1,17 +0,0 @@ -#import "Common/ShaderLib/GLSLCompat.glsllib" -in vec4 inPosition; - -in vec2 inTexCoord; // m_inUVred -in vec2 inTexCoord2; // m_inUVgreen -in vec2 inTexCoord3; // m_inUVblue - -out vec2 UVred; -out vec2 UVgreen; -out vec2 UVblue; - -void main() { - gl_Position = inPosition; - UVred = inTexCoord; - UVgreen = inTexCoord2; - UVblue = inTexCoord3; -} \ No newline at end of file diff --git a/jme3-xr/src/main/resources/Common/MatDefs/VR/PostShadowFilter.frag b/jme3-xr/src/main/resources/Common/MatDefs/VR/PostShadowFilter.frag deleted file mode 100644 index c940462d8a..0000000000 --- a/jme3-xr/src/main/resources/Common/MatDefs/VR/PostShadowFilter.frag +++ /dev/null @@ -1,184 +0,0 @@ -#import "Common/ShaderLib/GLSLCompat.glsllib" -#import "Common/ShaderLib/MultiSample.glsllib" -#import "Common/ShaderLib/Shadows.glsllib" - - -uniform COLORTEXTURE m_Texture; -uniform DEPTHTEXTURE m_DepthTexture; -uniform mat4 m_ViewProjectionMatrixInverse; -uniform vec4 m_ViewProjectionMatrixRow2; - -#ifdef INSTANCING - uniform mat4 m_ViewProjectionMatrixInverseRight; - uniform vec4 m_ViewProjectionMatrixRow2Right; -#endif - -in vec2 texCoord; -out vec4 outFragColor; - -const mat4 biasMat = mat4(0.5, 0.0, 0.0, 0.0, - 0.0, 0.5, 0.0, 0.0, - 0.0, 0.0, 0.5, 0.0, - 0.5, 0.5, 0.5, 1.0); - -uniform mat4 m_LightViewProjectionMatrix0; -uniform mat4 m_LightViewProjectionMatrix1; -uniform mat4 m_LightViewProjectionMatrix2; -uniform mat4 m_LightViewProjectionMatrix3; - -uniform vec2 g_ResolutionInverse; - -#ifdef POINTLIGHT - uniform vec3 m_LightPos; - uniform mat4 m_LightViewProjectionMatrix4; - uniform mat4 m_LightViewProjectionMatrix5; -#else - uniform vec3 m_LightDir; - #ifndef PSSM - uniform vec3 m_LightPos; - #endif -#endif - -#ifdef FADE -uniform vec2 m_FadeInfo; -#endif - -vec3 getPosition(in float depth, in vec2 uv){ - #ifdef INSTANCING - vec4 pos; - mat4 usemat; - uv.x *= 2.0; - if( uv.x > 1.0 ) { - // right eye - uv.x -= 1.0; - usemat = m_ViewProjectionMatrixInverseRight; - } else { - // left eye - usemat = m_ViewProjectionMatrixInverse; - } - pos = vec4(uv, depth, 1.0) * 2.0 - 1.0; - pos = usemat * pos; - #else - vec4 pos = vec4(uv, depth, 1.0) * 2.0 - 1.0; - pos = m_ViewProjectionMatrixInverse * pos; - #endif - return pos.xyz / pos.w; -} - -#ifndef BACKFACE_SHADOWS - vec3 approximateNormal(in float depth,in vec4 worldPos,in vec2 texCoord, in int numSample){ - float step = g_ResolutionInverse.x ; - float stepy = g_ResolutionInverse.y ; - float depth1 = fetchTextureSample(m_DepthTexture,texCoord + vec2(-step,stepy),numSample).r; - float depth2 = fetchTextureSample(m_DepthTexture,texCoord + vec2(step,stepy),numSample).r; - vec3 v1, v2; - vec4 worldPos1 = vec4(getPosition(depth1,texCoord + vec2(-step,stepy)),1.0); - vec4 worldPos2 = vec4(getPosition(depth2,texCoord + vec2(step,stepy)),1.0); - - v1 = normalize((worldPos1 - worldPos)).xyz; - v2 = normalize((worldPos2 - worldPos)).xyz; - return normalize(cross(v2, v1)); - - } -#endif - -vec4 main_multiSample(in int numSample){ - float depth = fetchTextureSample(m_DepthTexture,texCoord,numSample).r;//getDepth(m_DepthTexture,texCoord).r; - vec4 color = fetchTextureSample(m_Texture,texCoord,numSample); - - //Discard shadow computation on the sky - if(depth == 1.0){ - return color; - } - - // get the vertex in world space - vec4 worldPos = vec4(getPosition(depth,texCoord),1.0); - - - vec3 lightDir; - #ifdef PSSM - lightDir = m_LightDir; - #else - lightDir = worldPos.xyz - m_LightPos; - #endif - - #ifndef BACKFACE_SHADOWS - vec3 normal = approximateNormal(depth, worldPos, texCoord, numSample); - float ndotl = dot(normal, lightDir); - if(ndotl > 0.0){ - return color; - } - #endif - - #if (!defined(POINTLIGHT) && !defined(PSSM)) - if( dot(m_LightDir,lightDir)<0){ - return color; - } - #endif - - // populate the light view matrices array and convert vertex to light viewProj space - vec4 projCoord0 = biasMat * m_LightViewProjectionMatrix0 * worldPos; - vec4 projCoord1 = biasMat * m_LightViewProjectionMatrix1 * worldPos; - vec4 projCoord2 = biasMat * m_LightViewProjectionMatrix2 * worldPos; - vec4 projCoord3 = biasMat * m_LightViewProjectionMatrix3 * worldPos; - #ifdef POINTLIGHT - vec4 projCoord4 = biasMat * m_LightViewProjectionMatrix4 * worldPos; - vec4 projCoord5 = biasMat * m_LightViewProjectionMatrix5 * worldPos; - #endif - - float shadow = 1.0; - - #if defined(PSSM) || defined(FADE) - #ifdef INSTANCING - vec4 useMat = (texCoord.x > 0.5 ? m_ViewProjectionMatrixRow2Right : m_ViewProjectionMatrixRow2); - float shadowPosition = useMat.x * worldPos.x + useMat.y * worldPos.y + useMat.z * worldPos.z + useMat.w; - #else - float shadowPosition = m_ViewProjectionMatrixRow2.x * worldPos.x + m_ViewProjectionMatrixRow2.y * worldPos.y + m_ViewProjectionMatrixRow2.z * worldPos.z + m_ViewProjectionMatrixRow2.w; - #endif - #endif - - #ifdef POINTLIGHT - shadow = getPointLightShadows(worldPos, m_LightPos, - m_ShadowMap0,m_ShadowMap1,m_ShadowMap2,m_ShadowMap3,m_ShadowMap4,m_ShadowMap5, - projCoord0, projCoord1, projCoord2, projCoord3, projCoord4, projCoord5); - #else - #ifdef PSSM - shadow = getDirectionalLightShadows(m_Splits, shadowPosition, - m_ShadowMap0,m_ShadowMap1,m_ShadowMap2,m_ShadowMap3, - projCoord0, projCoord1, projCoord2, projCoord3); - #else - //spotlight - shadow = getSpotLightShadows(m_ShadowMap0,projCoord0); - #endif - #endif - - - #ifdef FADE - shadow = clamp(max(0.0,mix(shadow, 1.0 ,(shadowPosition - m_FadeInfo.x) * m_FadeInfo.y)),0.0,1.0); - #endif - - shadow= shadow * m_ShadowIntensity + (1.0 - m_ShadowIntensity); - return color * vec4(shadow, shadow, shadow, 1.0); -} - -void main(){ - - #if !defined( RENDER_SHADOWS ) - outFragColor = fetchTextureSample(m_Texture,texCoord,0); - return; - #endif - - #ifdef RESOLVE_MS - vec4 color = vec4(0.0); - for (int i = 0; i < m_NumSamples; i++){ - color += main_multiSample(i); - } - outFragColor = color / m_NumSamples; - #else - outFragColor = main_multiSample(0); - #endif - -} - - - diff --git a/jme3-xr/src/main/resources/Common/MatDefs/VR/PostShadowFilter.j3md b/jme3-xr/src/main/resources/Common/MatDefs/VR/PostShadowFilter.j3md deleted file mode 100644 index 3bdd5b2ea1..0000000000 --- a/jme3-xr/src/main/resources/Common/MatDefs/VR/PostShadowFilter.j3md +++ /dev/null @@ -1,99 +0,0 @@ -MaterialDef Post Shadow { - - MaterialParameters { - Int FilterMode - Boolean HardwareShadows - - Texture2D ShadowMap0 - Texture2D ShadowMap1 - Texture2D ShadowMap2 - Texture2D ShadowMap3 - //pointLights - Texture2D ShadowMap4 - Texture2D ShadowMap5 - - Float ShadowIntensity - Vector4 Splits - Vector2 FadeInfo - - Matrix4 LightViewProjectionMatrix0 - Matrix4 LightViewProjectionMatrix1 - Matrix4 LightViewProjectionMatrix2 - Matrix4 LightViewProjectionMatrix3 - //pointLight - Matrix4 LightViewProjectionMatrix4 - Matrix4 LightViewProjectionMatrix5 - Vector3 LightPos - Vector3 LightDir - - Float PCFEdge - - Float ShadowMapSize - - Matrix4 ViewProjectionMatrixInverse - Vector4 ViewProjectionMatrixRow2 - - Int NumSamples - Int NumSamplesDepth - Texture2D Texture - Texture2D DepthTexture - - // is VR instancing? - Matrix4 ViewProjectionMatrixInverseRight - Vector4 ViewProjectionMatrixRow2Right - - Boolean BackfaceShadows: true - } - - Technique { - VertexShader GLSL150: Common/MatDefs/VR/PostShadowFilter.vert - FragmentShader GLSL150: Common/MatDefs/VR/PostShadowFilter.frag - - WorldParameters { - ResolutionInverse - } - - Defines { - RESOLVE_MS : NumSamples - RESOLVE_DEPTH_MS : NumSamplesDepth - HARDWARE_SHADOWS : HardwareShadows - FILTER_MODE : FilterMode - PCFEDGE : PCFEdge - SHADOWMAP_SIZE : ShadowMapSize - FADE : FadeInfo - PSSM : Splits - POINTLIGHT : LightViewProjectionMatrix5 - //if no shadow map don't render shadows - RENDER_SHADOWS : ShadowMap0 - INSTANCING : ViewProjectionMatrixInverseRight - BACKFACE_SHADOWS : BackfaceShadows - } - - } - - Technique { - VertexShader GLSL100: Common/MatDefs/Shadow/PostShadowFilter.vert - FragmentShader GLSL100: Common/MatDefs/Shadow/PostShadowFilter.frag - - WorldParameters { - ResolutionInverse - } - - Defines { - HARDWARE_SHADOWS : HardwareShadows - FILTER_MODE : FilterMode - PCFEDGE : PCFEdge - SHADOWMAP_SIZE : ShadowMapSize - FADE : FadeInfo - PSSM : Splits - POINTLIGHT : LightViewProjectionMatrix5 - INSTANCING : ViewProjectionMatrixInverseRight - BACKFACE_SHADOWS : BackfaceShadows - } - - } - - - - -} \ No newline at end of file diff --git a/jme3-xr/src/main/resources/Common/MatDefs/VR/PostShadowFilter.vert b/jme3-xr/src/main/resources/Common/MatDefs/VR/PostShadowFilter.vert deleted file mode 100644 index d8ffbbfcb9..0000000000 --- a/jme3-xr/src/main/resources/Common/MatDefs/VR/PostShadowFilter.vert +++ /dev/null @@ -1,11 +0,0 @@ -//#define VERTEX_SHADER -#import "Common/ShaderLib/GLSLCompat.glsllib" - -attribute vec4 inPosition; -attribute vec2 inTexCoord; -varying vec2 texCoord; - -void main() { - gl_Position = vec4(inPosition.xy * 2.0 - 1.0, 0.0, 1.0); - texCoord = inTexCoord; -} \ No newline at end of file diff --git a/jme3-xr/src/main/resources/Common/MatDefs/VR/Unshaded.frag b/jme3-xr/src/main/resources/Common/MatDefs/VR/Unshaded.frag deleted file mode 100644 index 14217abc4a..0000000000 --- a/jme3-xr/src/main/resources/Common/MatDefs/VR/Unshaded.frag +++ /dev/null @@ -1,21 +0,0 @@ -//#define FRAGMENT_SHADER -#import "Common/ShaderLib/GLSLCompat.glsllib" - -uniform vec4 m_Color; -uniform sampler2D m_ColorMap; - -varying vec2 texCoord1; - -void main(){ - vec4 color = vec4(1.0); - - #ifdef HAS_COLORMAP - color *= texture2D(m_ColorMap, texCoord1); - #endif - - #ifdef HAS_COLOR - color *= m_Color; - #endif - - gl_FragColor = color; -} \ No newline at end of file diff --git a/jme3-xr/src/main/resources/Common/MatDefs/VR/Unshaded.j3md b/jme3-xr/src/main/resources/Common/MatDefs/VR/Unshaded.j3md deleted file mode 100644 index 81e1ebecc4..0000000000 --- a/jme3-xr/src/main/resources/Common/MatDefs/VR/Unshaded.j3md +++ /dev/null @@ -1,45 +0,0 @@ -MaterialDef Unshaded { - - MaterialParameters { - Texture2D ColorMap - Color Color (Color) - - // For VR instancing - Matrix4 RightEyeViewProjectionMatrix - } - - Technique { - VertexShader GLSL150: Common/MatDefs/VR/Unshaded.vert - FragmentShader GLSL150: Common/MatDefs/VR/Unshaded.frag - - WorldParameters { - WorldViewProjectionMatrix - ViewProjectionMatrix // needed for VR instancing - ViewMatrix - } - - Defines { - INSTANCING : RightEyeViewProjectionMatrix // For VR instancing - HAS_COLORMAP : ColorMap - HAS_COLOR : Color - } - } - - Technique { - VertexShader GLSL100: Common/MatDefs/VR/Unshaded.vert - FragmentShader GLSL100: Common/MatDefs/VR/Unshaded.frag - - WorldParameters { - WorldViewProjectionMatrix - ViewProjectionMatrix // needed for VR instancing - ViewMatrix - } - - Defines { - INSTANCING : RightEyeViewProjectionMatrix // For VR instancing - HAS_COLORMAP : ColorMap - HAS_COLOR : Color - } - } - -} \ No newline at end of file diff --git a/jme3-xr/src/main/resources/Common/MatDefs/VR/Unshaded.vert b/jme3-xr/src/main/resources/Common/MatDefs/VR/Unshaded.vert deleted file mode 100644 index 6e72b10e7f..0000000000 --- a/jme3-xr/src/main/resources/Common/MatDefs/VR/Unshaded.vert +++ /dev/null @@ -1,27 +0,0 @@ -//#define VERTEX_SHADER -#import "Common/ShaderLib/GLSLCompat.glsllib" - -// import the following for VR instancing -#import "Common/ShaderLib/InstanceVR.glsllib" - -attribute vec3 inPosition; - -#if defined(HAS_COLORMAP) || (defined(HAS_LIGHTMAP) && !defined(SEPARATE_TEXCOORD)) - #define NEED_TEXCOORD1 -#endif - -attribute vec2 inTexCoord; -attribute vec4 inColor; - -varying vec2 texCoord1; - -void main(){ - #ifdef NEED_TEXCOORD1 - texCoord1 = inTexCoord; - #endif - - vec4 modelSpacePos = vec4(inPosition, 1.0); - - // use the following transform function for VR instancing - gl_Position = TransformWorldViewProjectionVR(modelSpacePos); -} \ No newline at end of file diff --git a/jme3-xr/src/main/resources/Common/MatDefs/VR/normal.frag b/jme3-xr/src/main/resources/Common/MatDefs/VR/normal.frag deleted file mode 100644 index 16d32cedcd..0000000000 --- a/jme3-xr/src/main/resources/Common/MatDefs/VR/normal.frag +++ /dev/null @@ -1,9 +0,0 @@ -//#define FRAGMENT_SHADER -#import "Common/ShaderLib/GLSLCompat.glsllib" - -varying vec3 normal; - -void main(void) -{ - gl_FragColor = vec4(normal.xy* 0.5 + 0.5,-normal.z* 0.5 + 0.5, 1.0); -} diff --git a/jme3-xr/src/main/resources/Common/MatDefs/VR/normal.vert b/jme3-xr/src/main/resources/Common/MatDefs/VR/normal.vert deleted file mode 100644 index 3f590101f5..0000000000 --- a/jme3-xr/src/main/resources/Common/MatDefs/VR/normal.vert +++ /dev/null @@ -1,19 +0,0 @@ -//#define VERTEX_SHADER -#import "Common/ShaderLib/GLSLCompat.glsllib" - -// import the following for VR instancing -#import "Common/ShaderLib/InstanceVR.glsllib" - -attribute vec3 inPosition; -attribute vec3 inNormal; - -varying vec3 normal; - -void main(void) -{ - vec4 modelSpacePos = vec4(inPosition, 1.0); - normal = normalize(TransformNormal(inNormal)); - - // use the following transform function for VR instancing - gl_Position = TransformWorldViewProjectionVR(modelSpacePos); -} \ No newline at end of file diff --git a/jme3-xr/src/main/resources/Common/ShaderLib/InstanceVR.glsllib b/jme3-xr/src/main/resources/Common/ShaderLib/InstanceVR.glsllib deleted file mode 100644 index 99629173f9..0000000000 --- a/jme3-xr/src/main/resources/Common/ShaderLib/InstanceVR.glsllib +++ /dev/null @@ -1,126 +0,0 @@ -// Instancing GLSL library. Modified for VR use. -// -// When the INSTANCING define is set in the shader, -// all global matrices are replaced with "instanced" versions. -// One exception is g_NormalMatrix which becomes unusable, -// instead the function ApplyNormalTransform is used to transform -// the normal and tangent vectors into world view space. - -// The world matrix and normal transform quaternion need to be passed -// as vertex attributes "inWorldMatrix" and "inNormalRotationQuaternion" -// respectively. -// The VertexBuffers for those two attributes -// need to be configured into instanced mode (VertexBuffer.setInstanced(true)). -// - inWorldMatrix should have 12 * numInstances floats. -// - inNormalRotationQuaternion should have 4 * numInstances. -// Thus, instancing data occupies 4 vertex attributes (16 / 4 = 4). -// -// The GL_ARB_draw_instanced and GL_ARB_instanced_arrays extensions -// are required (OGL 3.3). - -#if defined INSTANCING - -uniform mat4 g_ViewProjectionMatrix; -uniform mat4 g_ViewMatrix; -uniform mat4 m_RightEyeViewProjectionMatrix; - -// World Matrix + Normal Rotation Quaternion. -// The World Matrix is the top 3 rows - -// since the bottom row is always 0,0,0,1 for this transform. -// The bottom row is the transpose of the inverse of WorldView Transform -// as a quaternion. i.e. g_NormalMatrix converted to a quaternion. -// -// Using a quaternion instead of a matrix here allows saving approximately -// 2 vertex attributes which now can be used for additional per-vertex data. -attribute mat4 inInstanceData; - -// Extract the world matrix out of the instance data, leaving out the -// quaternion at the end. -mat4 worldMatrix = mat4(vec4(inInstanceData[0].xyz, 0.0), - vec4(inInstanceData[1].xyz, 0.0), - vec4(inInstanceData[2].xyz, 0.0), - vec4(inInstanceData[3].xyz, 1.0)); - -vec4 TransformWorld(vec4 position) -{ - return (worldMatrix * position); -} - -vec4 TransformWorldView(vec4 position) -{ - return g_ViewMatrix * TransformWorld(position); -} - -vec4 TransformWorldViewProjection(vec4 position) -{ - return g_ViewProjectionMatrix * TransformWorld(position); -} - -// VR specific variables -const float EyeOffsetScale[2] = float[](-0.5, 0.5); -const vec4 EyeClipEdge[2] = vec4[](vec4(-1.0,0.0,0.0,1.0), vec4(1.0,0.0,0.0,1.0)); -out float gl_ClipDistance[1]; -in int gl_InstanceID; - -vec4 TransformWorldViewProjectionVR(vec4 position) -{ - vec4 clipPos = (gl_InstanceID == 0 ? g_ViewProjectionMatrix : m_RightEyeViewProjectionMatrix) * TransformWorld(position); - gl_ClipDistance[0] = dot(clipPos, EyeClipEdge[gl_InstanceID]); - clipPos.x *= 0.5; // shrink to half of the screen - clipPos.x += EyeOffsetScale[gl_InstanceID] * clipPos.w; // scoot left or right. - return clipPos; -} - -vec3 TransformNormal(vec3 vec) -{ - vec4 quat = vec4(inInstanceData[0].w, inInstanceData[1].w, - inInstanceData[2].w, inInstanceData[3].w); - - vec3 worldNormal = vec + vec3(2.0) * cross(cross(vec, quat.xyz) + vec3(quat.w) * vec, quat.xyz); - - return (g_ViewMatrix * vec4(worldNormal, 0.0)).xyz; -} - -// Prevent user from using g_** matrices which will have invalid data in this case. -#define g_WorldMatrix use_TransformWorld_not_gWorldMatrix -#define g_WorldViewMatrix use_TransformWorldView_not_gWorldMatrix -#define g_WorldViewProjectionMatrix use_TransformWorldViewProjectionVR_not_gWorldViewProjectionMatrix -#define g_NormalMatrix use_TransformNormal_not_gNormalMatrix - -#else - -uniform mat4 g_WorldMatrix; -uniform mat4 g_WorldViewMatrix; -uniform mat4 g_WorldViewProjectionMatrix; -uniform mat3 g_NormalMatrix; -uniform mat3 g_WorldNormalMatrix; - -vec4 TransformWorld(vec4 position) -{ - return g_WorldMatrix * position; -} - -vec4 TransformWorldView(vec4 position) -{ - return g_WorldViewMatrix * position; -} - -vec4 TransformWorldViewProjection(vec4 position) -{ - return g_WorldViewProjectionMatrix * position; -} - -vec4 TransformWorldViewProjectionVR(vec4 position) -{ - return g_WorldViewProjectionMatrix * position; -} - -vec3 TransformNormal(vec3 normal) { - return g_NormalMatrix * normal; -} - -vec3 TransformWorldNormal(vec3 normal) { - return normalize(g_WorldNormalMatrix * normal); -} - -#endif \ No newline at end of file diff --git a/jme3-xr/src/main/resources/Common/Util/gui_mesh.j3o b/jme3-xr/src/main/resources/Common/Util/gui_mesh.j3o deleted file mode 100644 index 728a7060207cc28f5466abe45263f5e21caa3e5e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4995 zcmZu#U2L0I89v8NQ!~wT+V{{Y_IJCu!2AP12;vhQv+cC0`O3$6v9X zl8z01bVHM-2_e|HVHeYcxBwyUKmyHQ#Rc2|nm~XMyWpZ5LhND^0tpa;=Q%#db~9YP zKj%H~dC&9ye2qWfT$mXXLIgk!Q3=jZ&xX63xV!6&B?=o(&PhD) z{6+9Xo9SZuxm+Q$opUx=E75`6$!F5p#DY<@2eWOoTWg!nmb?o~>|Q#b-gR)G5VF~I)JEDtCpL<1 zeryZgLBXr#zD6J)Xt?slI(zVN11_%0(5C~vd%8j*B+7y+gm#i+2tT1lb0%0a*0UfPx_I zg+MG^803N?pjSY3pw~h5pl^esp!Yy*<6}?*=-;45gyz{Mg!%-s8AtvA*#Z|2vK6N9 zLmqS9YmqzOXG7yxJ5QYz$Y`T4C?)u!~ zKVR4EF0}eMCmvuZXv^w3d+9;k@7)mdHze3AW!||?Qu%2ztkKuddk?fPwBU* zAHYsscx^|1XnchC)-$gg-79_b8?RDNf=VsvkBu(8AFcl#y6{N968|;2S1Q}-pHk)c z`m8F)p}(if@u{bjxtH;iHSyK`H-2N|t53f2M;kv`j-OKWH~66o_3~f7MIWs{?0wJZ zUa}mA{+0SbxAmdFr@rtoWBgMlj>hj-@e98Ok6*=;^2_*jeBaa`F@;})$FJf^89V(w zTYvhS`V)`vOnmKQ@cZmjwZAq#`z!o1e(EXT^u0vg;D=tpul)@k?O(>}!Kcz+`rH1} z-{OJpm8y6u^{0=mo7Ss%yrh{Q#<%@teA{2`U&UklMLd=H;aNLB#9;dcz0xoG_-4lF zV``%3%`eZJo_Sjz?PHz`1w6Kf&?_@fyLlFLzsy2IGw zeO6V^mTSdF{qd8JdSsE`U9x!4V>@jMW!P-{_34hb?l`>B>&^(F50-K z?H9h6R3H5Q%gJm1>Q#U4y-pxv{lmCw`qP5e8wR@6&pwz@@n5^iH~-P0z8ZPI1WJDQ z;j;QjJw{Q5n0?yOzSNPF*0GnQ9kENe!)JWNC?S^5IP}CFKI2oz-9GO%@k@+<@~7V^ zz5IT^-#j#`ectIF_Fs84ZsV62pRsud<7f9z`-3YVmVW-@E;au32A{MN?pKV#Sd7Ek z)YQkf^*I{)UFq$yQU9-nBZ@H?i*XEo#rOt~s==cy9@dWdO?<`r8$8JxJc@Wsd_}v# zZ|m=~7L3DOsWZO8pEUS+hmFrzIzF%~;IaMEwPwBszn!0? zogd~}(=X!J{omOnhAv&YgV*%~}0yntOGv@Sq3Y`%LHelsZF z1tPR(ovHEv5}jgITKglmkYx6)q&*IsmD)}pL)N~IHT^tex6<0VM@pG}D`{Iddz7@- zQrzrwkK~zsD`|^^h@H|iIaoiAem`y;bYNqa2` zv(G(}Fn3$2ZLr4;7JWC|tfZYjR?_ZaZKbuZ8$ZwNTWRf2V1|$W5Kqm=o}uKOlmfJF z{8L71JGQhm*cgUu`cSSLNu3l|{Cjlj$-hV8x!k6+ACgT^yrGBj4VT~9`OP{Yf&yR3 z@rDo<5%79^*N%b5@J`T(_kb2qGk7b$^B)Gafw$w!btk9;yh|JvJ)myzW1?5|f%l2y zA}*f7_vtvOUkr$+#US{gI4MqvXT%xMY4EdRNDPA#;3MK$F$Nk1KPS$M3*Z;TMR7@7 z7USUK;)<9MS49#$DHN;|nk($I0pA4p1gtGUdlmdDR?p(x74R#F8UyZ2;FqvI4ByM( zm$3@to{QiYk^Lw<&w-!A`U>Kn2S1P15YQz+W8i(L%MfTp^B80d5l2J{*-V0l!KaXa z3UpTUKFB_JpB2-{{u<~E_#`~1L8mlNKqgR?Q>fYis`M1-gqXqW@BsJ#*0bU|syGW8 z5I0cQe(-)VCvJ*cSltBOfHniqTcEg@M<0%Z9|xK_cpd{khIK#U_Ja3fbp+k(0QG<` zh()Xyu_C_>c^h5r!hP-NTRS>E2n0)5FJVQ#0J#9~c1%nws?dsx#^BY7bthKj9grQE z8ct6ms@{msw87GYbq`kL-H_dwvPNL4M`e3KeL#5$^Gg)loIOzLS= zYz*r$tjI?pN71WFU8GbZ8()Nlj2>E@cM*00*Z@L_t(o!@ZboNR(?D z$N$ef^P*$Eq%)3=FT-Ry8k&l_iDjlI%Tm+vrAae{2nouN{ZJ{aQ4qEn!hR@h&sKO~ zV^PW$IwE@#i)w*>|UG9Vz}zX05-s;Y$V1`Y@aAOIE@7Y|6k-MMq; z`+((gIRP*wCFMFvF90}m=FG~1{r&xU;J^WzOeU&SD(2+m{0RU^t~_|}-n}GArBcb& zt5>tKvU0mLzEXccCVjEn?RfFx1w>KA)vH(A%gW0B004p@teoP~(o#-MP0`_Su(h?7 zq9{_U)edxZb!}czS4&{YYHDf-fF2$mf4_P2rrV0RJRl%|rKP2uoSdY?;h^1aCrMUR zR1g5OvaFTNxR)no6W|&ygUM6Sy|c7()^*Jq2&SV^?H_+l+b3gxxggp zbUHaWI7oxRKv5JY&1UlflCouw>Y2>X&kybG?NF=L%DZ>(UZ|_9O9gFK zJ18iK7K?>8n~n3?{{8z2fEgJXw@At?7R$GTgM))oK7e0b~~r0rg;4LaROjkTH1q=krBm$6&MVLMS~@{!{Ok> z!~`=lGYNpXxw(HMsanvUhlYl-sHlh&6BGOvlY-ID&yOmVim|b=5lgPs3pKml4y)A) zwOY--zP=a9$;q(*aPi{Bxm~>!#h+VeXD1a31@(IU#O2GE^XIJTVPRn`EG%?^7m~+w z*{M^f2!KYT@z<)VDxX;uYcv{WWo2=Ee0<4JX}#1srKhLgAt|3xd2nzrw{PFhv9Ylw zgFm<3yLS@+lai9I&w4s-+qR8kV`Iw(l?3SZdb+#2(_*nSk`zDZ%2g^AL{WrHCUd!C zsb{UU{`vFg2n!2COG}HzZns|t@UNnxB5d5a5ilB!%*n}_H>#zA;cz(E+uO_G;o$`- zfAr`PeSCbV)9IY`_4P3T(A(SldphmfwQEkWbZSX1Y-wqskB<-4YBjyQyy)%iO@DuX z>U278-n^OT&Yk0{SFc>_o12@tYSk)wd3gnsIRY&$BrH2hYue} zlB1)e)Mzx6$z*ngLh%&9zqMNJZ?Unl^zrc_fUiD+AW#%V1_lQHoRgCylgnhXSubaT zAYgoa9NF2~c=F^4Dl01i0G^(nFq_S2YHAWvQ&a!a(b4hayLa#WIy*aa8X6j=A3l7D z(a}*MBqU_@$jFGG)9JJtjV7$Ox7RHxDXGBA%j*}cUAva~`S~-t+GexSU@%Y+1Onj6 zlP6tcV`F0kK$FSz&$hNU_u0FG(5oSd8_Np9V`l@SpUJb3V6=%PbEEG&#>v-vA=Ha50$(csS&Pft&iBuyq0l}aV!;^G>lc?k&#KgeXV zvADQ6SKti|4KX@8n(^`R1b}PTt}PyHv)MQ?F~Qv2T&mS-CMG7f{@;E@Xtmn+TCJ8= ztJRfWQU}u1)bz(i-7vz#!-Ch&<-;2`Y=~blI5IL)y8Y8=G`7vv)&hXpY<}&wBxK^OSarAq|BlfX&U#Ut|FQMny&ar?9Zlb3rbTii%=NN=iq6e}9nlR&VFd zoiom@uC7L9Wo2k$Vj@i@(-&n`3bGqFZsY;LvuDrd24`es{7TXn0IXK)ynpoN%a`u) z@$uII&}y~16b}px5C9`0BANi;%9Sga?@Hne0FNI(o)fBb zpFVwJc6PQ?r_+(7ZbAF};K74M6&;dlnM`I43JRjb;c&V8?Afyfz|73dKQH?$s@Jby z0|3&}(z;bD6;JCX{lgtfJ`?FPU@hYo$Ay0Ea23WZ{-prD|1 z#oh|8S+iy^A|k@oAduvV6DJ6O2?+^5ExT%I@2ab-F9P8G`}bK+kAnwq&~Kzqr2QO42Ip#(kal5u52akuong{03jhZRVZ8xY7q|*MKh_0G)+cHrh+>p9*4K! zrC1~+{x8WvIg(@h_irEDC$0JZg4vw)Y{?#3b=GWNh}n7Tmf9bF91ikgJb3)1q%2#j zB*Iy-1#3$qr(v8B*pXb7tcnM&3uLua)$E6o+IG(TVc;Jf`NOxtXgUq@;>#ooCUFu4 z<2Z{(MSK>)>os_BGMdcBO+rVE=Di*3sIu88P4Xg4id=Tr7E4T~67+bXDxy1?l5i{^_t$m%ErVomJ$D+bQRshIw9A5csZ~ zmMFFGs~++Dd~})^yIO5v^aSs<#Mch#lRf&X%l*3&4n8|~{<>K3_R7syIa{*3!aT{g z_}qoh4tMnJNrT~U>bofINjSUmxf@P}xAlKiHu!VJ@!1t|@|UDN2{Rnj{&MYm@>gWT zMK;v!MQM2W>k^-nd41X7F7JkH^1xl*E!pHT zzstKV8{FmHkxd@>v0jOHx-0P{)O7Kenv-`U_FHo?GxISgwRxWd3HN=dXSrWvQvb0B iH8$741~tapxE>zLCLca=dUQPyYxY1dfAvQ^ll%j|lVOGc diff --git a/jme3-xr/src/main/resources/demo/openxr/vulkan/hello.vert.spv b/jme3-xr/src/main/resources/demo/openxr/vulkan/hello.vert.spv deleted file mode 100644 index 5157154da788c619e20a1fbaaa177490eb8da9c9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1384 zcmYk4%Wl&^6o!Y~X=zI-y#OVogv$b{VgU#VaZ^C)BB()?y0xstz(}qg*-izlcm-aG zr(%P||BXG7$2vZ9{`t>!rr8*Fjk#iaX2U!-<=Qq4A;zqmj??4G+2lAc=Eu*TKZUVr znvMu(%UpH)mi`x^O)xejwottL@ZL#?3y-*C#iiH2goRC?b(=SbO^h9R;di7M)XIKOyN>igvM+yfW7ET~ z{yph|g!QDddF8}Al)WYmAFQt(J^L7(Ap`NQN&ES{s%+i|7@5lFKsNIr zE_LW|XQ*}TO_aykk=bT=DD{k3enHvuE(ffS~_eXti)B*ND T;%j@PJ^gaV9I*eX` Date: Mon, 15 May 2023 21:26:44 +0200 Subject: [PATCH 13/18] Init-function commented. --- jme3-xr/src/main/java/com/jme3/input/xr/XrHmd.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/jme3-xr/src/main/java/com/jme3/input/xr/XrHmd.java b/jme3-xr/src/main/java/com/jme3/input/xr/XrHmd.java index 592e381a0a..729294afdc 100644 --- a/jme3-xr/src/main/java/com/jme3/input/xr/XrHmd.java +++ b/jme3-xr/src/main/java/com/jme3/input/xr/XrHmd.java @@ -53,9 +53,12 @@ public static void setRendererForSettings(AppSettings s) s.setRenderer("CUSTOM" + com.jme3.system.lwjgl.LwjglWindowXr.class.getName()); //see JmeDesktopSystem.newContext(...) } - public static XrHmd initHmd(SimpleApplication app) { - XrHmd xrHmd = new XrHmd(app, 0.8f); - ((LwjglWindowXr)app.getContext()).getXr().setHmd(xrHmd); - return xrHmd; - } + /** Must be called in init-function of SimpleApplication. + * @return The head-mounted-device object. */ + public static XrHmd initHmd(SimpleApplication app) + { + XrHmd xrHmd = new XrHmd(app, 0.8f); + ((LwjglWindowXr)app.getContext()).getXr().setHmd(xrHmd); + return xrHmd; + } } From 7e07b49958d9f0a461d3efc87cd3921b1ffb68cb Mon Sep 17 00:00:00 2001 From: Starcommander Date: Mon, 15 May 2023 21:28:25 +0200 Subject: [PATCH 14/18] Update comment of init function. --- jme3-xr/src/main/java/com/jme3/input/xr/XrHmd.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jme3-xr/src/main/java/com/jme3/input/xr/XrHmd.java b/jme3-xr/src/main/java/com/jme3/input/xr/XrHmd.java index 729294afdc..97c7e23c55 100644 --- a/jme3-xr/src/main/java/com/jme3/input/xr/XrHmd.java +++ b/jme3-xr/src/main/java/com/jme3/input/xr/XrHmd.java @@ -53,7 +53,7 @@ public static void setRendererForSettings(AppSettings s) s.setRenderer("CUSTOM" + com.jme3.system.lwjgl.LwjglWindowXr.class.getName()); //see JmeDesktopSystem.newContext(...) } - /** Must be called in init-function of SimpleApplication. + /** Must be called in simpleInitApp-function of SimpleApplication. * @return The head-mounted-device object. */ public static XrHmd initHmd(SimpleApplication app) { From 28ff3d74751ed490d21daaaac459477b5859c4d2 Mon Sep 17 00:00:00 2001 From: Starcommander Date: Tue, 16 May 2023 16:59:19 +0200 Subject: [PATCH 15/18] Also rotate eyes together, and adjust distance. --- .../src/main/java/com/jme3/input/xr/Eye.java | 18 ++++---- .../main/java/com/jme3/input/xr/XrHmd.java | 42 ++++++++++++++++--- 2 files changed, 46 insertions(+), 14 deletions(-) diff --git a/jme3-xr/src/main/java/com/jme3/input/xr/Eye.java b/jme3-xr/src/main/java/com/jme3/input/xr/Eye.java index f5dd474023..8f7159f316 100644 --- a/jme3-xr/src/main/java/com/jme3/input/xr/Eye.java +++ b/jme3-xr/src/main/java/com/jme3/input/xr/Eye.java @@ -16,19 +16,19 @@ import com.jme3.texture.Image.Format; public class Eye { + static int index = 0; SimpleApplication app; float posX; Vector3f tmpVec = new Vector3f(); Texture2D offTex; - Geometry offGeo; - Camera offCamera; - Vector3f centerPos = new Vector3f(0f, 0f, -5f); - Quaternion centerRot = new Quaternion(); + Geometry offGeo; + Camera offCamera; + Vector3f centerPos = new Vector3f(0f, 0f, -5f); + Quaternion centerRot = new Quaternion(); - public Eye(SimpleApplication app, float posX) + public Eye(SimpleApplication app) { this.app = app; - this.posX = posX; setupOffscreenView(app); Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); mat.setTexture("ColorMap", offTex); @@ -37,6 +37,9 @@ public Eye(SimpleApplication app, float posX) offGeo.setMaterial(mat); } + public void setPosX(float posX) { this.posX = posX; } + public float getPosX() { return posX; } + /** Moves the camera. * @param The new absolute center position. */ public void moveAbs(Vector3f newPos) @@ -61,14 +64,13 @@ private void setupOffscreenView(SimpleApplication app) int h = app.getContext().getSettings().getHeight(); offCamera = new Camera(w, h); - ViewPort offView = app.getRenderManager().createPreView("OffscreenViewX" + posX, offCamera); + ViewPort offView = app.getRenderManager().createPreView("OffscreenViewX" + (index++), offCamera); offView.setClearFlags(true, true, true); offView.setBackgroundColor(ColorRGBA.DarkGray); FrameBuffer offBuffer = new FrameBuffer(w, h, 1); //setup framebuffer's cam offCamera.setFrustumPerspective(45f, 1f, 1f, 1000f); - offCamera.setLocation(new Vector3f(-posX, 0f, -5f)); offCamera.lookAt(new Vector3f(0f, 0f, 0f), Vector3f.UNIT_Y); //setup framebuffer's texture diff --git a/jme3-xr/src/main/java/com/jme3/input/xr/XrHmd.java b/jme3-xr/src/main/java/com/jme3/input/xr/XrHmd.java index 97c7e23c55..d8855824a2 100644 --- a/jme3-xr/src/main/java/com/jme3/input/xr/XrHmd.java +++ b/jme3-xr/src/main/java/com/jme3/input/xr/XrHmd.java @@ -10,7 +10,12 @@ public class XrHmd { + public static final float DEFAULT_X_DIST = 0.4f; + public static final float DEFAULT_X_ROT = 0.028f; Quaternion tmpQ = new Quaternion(); + float[] tmpArr = new float[3]; + Quaternion tmpQdistRotL = new Quaternion().fromAngles(0, -DEFAULT_X_ROT, 0); + Quaternion tmpQdistRotR = new Quaternion().fromAngles(0, DEFAULT_X_ROT, 0); SimpleApplication app; Eye leftEye; Eye rightEye; @@ -18,11 +23,12 @@ public class XrHmd ArrayList contr1Listeners = new ArrayList(); ArrayList contr2Listeners = new ArrayList(); - public XrHmd(SimpleApplication app, float distX) + public XrHmd(SimpleApplication app) { this.app = app; - leftEye = new Eye(app, -distX/2.0f); - rightEye = new Eye(app, distX/2.0f); + leftEye = new Eye(app); + rightEye = new Eye(app); + setXDistance(DEFAULT_X_DIST); hmdListeners.add((p,r) -> doMoveRotate(p,r)); } @@ -30,8 +36,12 @@ private void doMoveRotate(Vector3f p, Quaternion r) { tmpQ.set(r); tmpQ.inverseLocal(); - leftEye.rotateAbs(tmpQ); - rightEye.rotateAbs(tmpQ); + tmpQ.set(tmpQ.getX(), tmpQ.getY(), -tmpQ.getZ(), tmpQ.getW()); + leftEye.rotateAbs(tmpQ.multLocal(tmpQdistRotL)); + tmpQ.set(r); + tmpQ.inverseLocal(); + tmpQ.set(tmpQ.getX(), tmpQ.getY(), -tmpQ.getZ(), tmpQ.getW()); + rightEye.rotateAbs(tmpQ.multLocal(tmpQdistRotR)); } public Eye getLeftEye() { return leftEye; } @@ -57,8 +67,28 @@ public static void setRendererForSettings(AppSettings s) * @return The head-mounted-device object. */ public static XrHmd initHmd(SimpleApplication app) { - XrHmd xrHmd = new XrHmd(app, 0.8f); + XrHmd xrHmd = new XrHmd(app); ((LwjglWindowXr)app.getContext()).getXr().setHmd(xrHmd); return xrHmd; } + + /** Gets the distance between the eyes. Default is DEFAULT_X_DIST */ + public float getXDistance() { return rightEye.getPosX() * 2f; } + + /** Sets the distance between the eyes. Default is DEFAULT_X_DIST */ + public void setXDistance(float xDist) + { + rightEye.setPosX(xDist / 2f); + leftEye.setPosX(xDist / -2f); + } + + /** Gets the rotation angle between the eyes. Default is DEFAULT_X_ROT */ + public float getXRotation() { return tmpQdistRotR.toAngles(tmpArr)[1]; } + + /** Sets the rotation angle between the eyes. Default is DEFAULT_X_ROT */ + public void setXRotation(float xRot) + { + tmpQdistRotR.fromAngles(0, xRot, 0); + tmpQdistRotL.fromAngles(0, xRot, 0); + } } From d374d4680aa4c48ff64e4111a9b1076391d08fb5 Mon Sep 17 00:00:00 2001 From: Starcommander Date: Tue, 16 May 2023 17:38:31 +0200 Subject: [PATCH 16/18] Revert changes in vr-project that should be done in separate pull-request. --- .../com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVR.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/jme3-vr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVR.java b/jme3-vr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVR.java index c0574bc46d..30c4ec2c99 100644 --- a/jme3-vr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVR.java +++ b/jme3-vr/src/main/java/com/jme3/input/vr/lwjgl_openvr/LWJGLOpenVR.java @@ -48,7 +48,7 @@ public class LWJGLOpenVR implements VRAPI { private Vector3f hmdPoseLeftEyeVec, hmdPoseRightEyeVec, hmdSeatToStand; - private LWJGLOpenVRInput vrInput; + private LWJGLOpenVRInput VRinput; private VREnvironment environment = null; @@ -91,7 +91,7 @@ public LWJGLOpenVR(VREnvironment environment){ @Override public LWJGLOpenVRInput getVRinput() { - return vrInput; + return VRinput; } @Override @@ -158,9 +158,9 @@ public boolean initialize() { hmdDisplayFrequency.get(0); TrackedDevicePose.create(VR.k_unMaxTrackedDeviceCount); // init controllers for the first time - vrInput = new LWJGLOpenVRInput(environment); - vrInput.init(); - vrInput.updateConnectedControllers(); + VRinput = new LWJGLOpenVRInput(environment); + VRinput.init(); + VRinput.updateConnectedControllers(); // init bounds & chaperone info LWJGLOpenVRBounds bounds = new LWJGLOpenVRBounds(); @@ -431,4 +431,4 @@ public void setTrackingSpace(boolean isSeated){ public Matrix4f[] getPoseMatrices() { return poseMatrices; } -} +} \ No newline at end of file From 81ae7722f667659ec21b30ce36fd69b5f35a057d Mon Sep 17 00:00:00 2001 From: Starcommander Date: Sat, 17 Jun 2023 16:35:45 +0200 Subject: [PATCH 17/18] Change rendering from Clockwise to Counter-Clockwise as it is the default in jme3. Fixes the issue, that object are only visible from inner side. --- .../main/java/com/jme3/system/lwjgl/openxr/HelloOpenXRGL.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jme3-xr/src/main/java/com/jme3/system/lwjgl/openxr/HelloOpenXRGL.java b/jme3-xr/src/main/java/com/jme3/system/lwjgl/openxr/HelloOpenXRGL.java index 0891788cf9..501e744ffe 100644 --- a/jme3-xr/src/main/java/com/jme3/system/lwjgl/openxr/HelloOpenXRGL.java +++ b/jme3-xr/src/main/java/com/jme3/system/lwjgl/openxr/HelloOpenXRGL.java @@ -830,7 +830,7 @@ private void OpenGLRenderView(XrCompositionLayerProjectionView layerView, XrSwap ); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); - glFrontFace(GL_CW); + glFrontFace(GL_CCW); glCullFace(GL_BACK); glEnable(GL_DEPTH_TEST); From c2ed049ccabb2162061363a9ba874268a2efac94 Mon Sep 17 00:00:00 2001 From: Starcommander Date: Wed, 8 Nov 2023 21:30:42 +0100 Subject: [PATCH 18/18] Move Head-Position relative to initial position. Multiply movement. --- jme3-xr/src/main/java/com/jme3/input/xr/XrHmd.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/jme3-xr/src/main/java/com/jme3/input/xr/XrHmd.java b/jme3-xr/src/main/java/com/jme3/input/xr/XrHmd.java index d8855824a2..0796571503 100644 --- a/jme3-xr/src/main/java/com/jme3/input/xr/XrHmd.java +++ b/jme3-xr/src/main/java/com/jme3/input/xr/XrHmd.java @@ -12,6 +12,7 @@ public class XrHmd { public static final float DEFAULT_X_DIST = 0.4f; public static final float DEFAULT_X_ROT = 0.028f; + public static final float DEFAULT_POS_MULT = 10.0f; Quaternion tmpQ = new Quaternion(); float[] tmpArr = new float[3]; Quaternion tmpQdistRotL = new Quaternion().fromAngles(0, -DEFAULT_X_ROT, 0); @@ -32,8 +33,14 @@ public XrHmd(SimpleApplication app) hmdListeners.add((p,r) -> doMoveRotate(p,r)); } + Vector3f initPos; + Vector3f diffPos = new Vector3f(); private void doMoveRotate(Vector3f p, Quaternion r) { + if (initPos == null) { initPos = new Vector3f(p.getX(), p.getY(), p.getZ()); } + initPos.subtract(p,diffPos); + leftEye.moveAbs(diffPos); + rightEye.moveAbs(diffPos); tmpQ.set(r); tmpQ.inverseLocal(); tmpQ.set(tmpQ.getX(), tmpQ.getY(), -tmpQ.getZ(), tmpQ.getW()); @@ -51,9 +58,13 @@ private void doMoveRotate(Vector3f p, Quaternion r) public ArrayList getContr1ButtonPressedListeners() { return contr1Listeners; } public ArrayList getContr2ButtonPressedListeners() { return contr2Listeners; } + Vector3f multPos = new Vector3f(); public void onUpdateHmdOrientation(Vector3f viewPos, Quaternion viewRot) { - for (XrListener.OrientationListener l : hmdListeners) { l.onUpdateOrientation(viewPos, viewRot); } + viewPos.mult(DEFAULT_POS_MULT, multPos); + multPos.setX(0.0f-multPos.getX()); + multPos.setY(0.0f-multPos.getY()); + for (XrListener.OrientationListener l : hmdListeners) { l.onUpdateOrientation(multPos, viewRot); } } /** Must be called in main function before init.