I would like discuss here about wider VR hardware support. A few weeks ago an open VR/AR standard has been was presented: OpenXR.
Waiting for OpenXR hardware adoption (manufacturers like Oculus or Valve announced future support) I've started experimenting with another API: OpenVR.
OpenVR is not quite open as name suggest - it still needs a proprietary runtime (SteamVR), but unlike Oculus SDK it is supported on different operating systems and supports hardware from other manufacturers.
UPDATE OpenXR
The OpenXR support is almost done.
You can download Windows build and Linux Appimage here.This is a pre-release introducing OpenXR support. Open View->FreeCAD-XR to view scene in virtual reality headset.
Requirements:
virtual reality headset
OpenXR runtime supporting OpenGL (XR_KHR_opengl_enable extension) eg. SteamVR, Monado
(optionally) motion controllers
Scene navigation using motion controllers:
analog stick/trackpad of the first controller moves viewer forward or backward along controller axis
analog stick/trackpad of the second controller rotates viewer around center of controller
Scene navigation using keyboard:
WSAD and Up/Down keys move in 3D space
Left/Right keys rotate
+/- keys scale scene
How to start:
Enable/run your OpenXR runtime (eg. by starting SteamVR) - make sure that OpenXR loader path is set up (Windows registry key "ActiveRuntime" in HKEY_LOCAL_MACHINE\SOFTWARE\Khronos\OpenXR\1, Linux: /etc/xdg/openxr/1/active_runtime.json)
Turn on motion controllers if you want use them
Run FreeCAD, open a 3D model
Start OpenXR session clicking View->FreeCAD-XR menu
The code can be found in this fork https://github.com/kwahoo2/FreeCAD
Notes about compilation:
0. Download and install OpenXR SDK from https://github.com/KhronosGroup/OpenXR-SDK (note: on Windows build the OpenXR Loader as a DLL)
1. Set BUILD_OPENXR to ON
2. Set BUILD_QT5 to ON
Outdated:
The Windows binary and Linux AppImage release can be downloaded here https://github.com/kwahoo2/FreeCAD/rele ... 19_preVR-1
Connect headset, run SteamVR and then start bin/FreeCAD.exe. Open a model and run View->FreeCAD OpenVR. A new, preview window should appear as soon as SteamVR detects active HMD.
Use analog stick or touchpad of first controller to translate world. Move stick forward - view will move where the controller is pointing. Use second controller to rotate world around two axes. Position of the controller sets center of rotation.
The implementation should work with all OpenVR compatible headsets, including Oculus Rift, HTC Vive, Valve Index and Windows Mixed Reality HMD's. Please report if this works (or not) for you.
I stopped working on the Python script and moved to C++. The code can be found in this fork https://github.com/kwahoo2/FreeCAD
Notes about compilation:
0. Download and install OpenVR SDK from https://github.com/ValveSoftware/openvr
1. Set BUILD_OPENVR to ON
2. Set BUILD_QT5 to ON
3. You may need to specify OpenVR_INCLUDE_DIR (/usr/local/include/openvr in my case)
4. You may need to specify OpenVR_LIBRARY (/usr/local/lib/libopenvr_api.a in my case)
Additional notes about compilation on Windows:
1. OpenVR_LIBRARY should point to lib/win64/openvr_api.lib distributed with the OpenVR SDK
2. openvr_api.dll can be found in openvr\bin\win64
End of update.
Known issues:
1. The code renders two exactly same pictures - wrong buffer configuration?
2. Head tracking is not implemented yet
3. SoFrustumCamera needs further investigation. I'm trying to get necessary variables for the camera from IVRSystem::GetProjectionMatrix and IVRSystem::GetEyeToHeadTransform matrices, but maybe there is a better way? Update: Use IVRSystem::GetProjectionRaw
Future work:
1. Fix issues
2. Remove SDL dependency, use QOpenGLWidget (?) Update: Check the new offscreen rendering driver in SDL https://hg.libsdl.org/SDL/rev/9692ad570003
3. Port to C++ Initial OpenVR C++ port https://github.com/kwahoo2/FreeCAD/comm ... b8ab0c1e28
4. Add basic navigation
5. Add controllers support (for navigation) Initial work done
6. Improve rendering quality (antialiasing etc.) and performance - Initial work done
7. Move to OpenXR - initial OpenXR support done https://forum.freecadweb.org/viewtopic. ... 03#p379203
Initially, I started tinkering with jriegel Rift's implementation, but later i found Python bindings for OpenVR pyopenvr. Basic idea is: write (and experiment with) an implementation in pyopenvr, and then port the code to C++.
Here is the repository: https://github.com/kwahoo2/freecad-pyopenvr
Steps to run the code:
1. Install pyopenvr, and SDL + OpenGL Python packages
2. Run SteamVR
3. Paste the code into FreeCAD