Following rdb’s thread update on VR support in Panda3D, my curiosity was aroused again and I googled around to learn what is required to have a VR compatible application. As expected it is not trivial in most case
The only exception is OpenVR which not only provides drivers for the headset hardware but also an application layer that take care of all the projection, compositing and extra work needed to have a proper VR rendering. Better, there is a python binding pyopenvr with a decent implementation. (The downside is that the only implementation of OpenVR is SteamVR, so you need Steam and a steam account to use it. So not really open after all…)
So, after some tinkering, I managed to properly bind pyopenvr, configure the camera in Panda3D, retrieve the textures from the draw context to submit to the compositor and voilà :
Link
Installation
The installation is as usual :
git clone https://github.com/el-dee/panda3d-openvr
cd panda3d-openvr
python3 setup.py install
(I might create a pypi package later on)
Examples
Minimal
The first example, showcases how to initialize the VR system and retrieve the information about the HMD, controllers, tracking stations, …
It displays the panda avatar in front of you, the default rgb cube for the controllers and cameras for the tracking stations (if any).
Actions
This example is pretty similar to the minimal example, except that it uses actions manifest to manage the interaction with the user. It’s a little bit more complicated that using directly events, but that allows the user to rebind the actions from the Steam interface.
Ralph
The last example is the mandatory Roaming Ralph demo, except this time you are Ralph This example shows how to move the tracking space in your scene to simulate displacement.
You can use the trackpad of the left controller to move forward and backward in the direction you’re facing, or turn yourself around inworld.
Final notes
This has been only tested by me on my setup (Linux + HTC Vive) so it may not work for you (yet), but theoretically it should work on Windows and macOS too.
Also, on Linux the NVidia controller does not seem to allow an app to disable v-sync. If you get 45 fps instead of 90 fps, that means you have to open the NVidia control panel and deactivate V-Sync there.