OpenVR Support - No head tracking

Hi everyone, I am trying to get a 3D viewer (subclassed from AIS_ViewController) to work with VR support. So far, the device is connected and detected correctly through OpenVR. The image appears in the device stereoscopically at the correct IOD. However, only orientation tracking appears to work. No positional tracking works. In addition, the hand controllers do not appear in the 3D viewport.

The only code that has been added to the viewer is as follows;

m_view->ChangeRenderingParams().StereoMode = Graphic3d_StereoMode_OpenVR;
m_view->Camera()->SetProjectionType(Graphic3d_Camera::Projection_Stereo);

I have tested the device with CAD Assistant and everything works as expected (head tracking, devices visible). However, teleportation is not available on the controller. I figured this is to do with controller bindings so any hints in this area would also be appreciated.

The device I am using is an Oculus Quest 2 through OpenVR (Steam VR)

Kirill Gavrilov's picture

No positional tracking works.
...
I have tested the device with CAD Assistant and everything works as expected (head tracking, devices visible).

Do you mean that you achieved the same behavior in application as in CAD Assistant, or "positional tracking" does work in CAD Assistant, and doesn't in your application? Are you familiar with Draw Harness to test VR there?

I figured this is to do with controller bindings so any hints in this area would also be appreciated.

Indeed, you may find several predefined control bindings in "src/XRResources" like "occtvr_bindings_vive.json". It is necessary generating such files for each HMD headset model and for each controller model (head-tracking and hand-controllers are tracked and configured independently in OpenVR). It should be possible generating new configs for your device directly from SteamVR, though I found an interface for that not user-friendly and have to modify .json files manually anyway.

So far, configurations coming with OCCT have been tested only with HTC Vive. I haven't found a reliable way to write these configs without having a particular HMD model at hand - SteamVR doesn't want to generate them. So the other bindings like "occtvr_bindings_rift.json" have been written in a blind effort based on similar configs coming with "Half-Life: Alyx" game.

Win Holzapfel's picture

Hi Kirill, Thanks for your response!

Quote:
Do you mean that you achieved the same behavior in application as in CAD Assistant, or "positional tracking" does work in CAD Assistant, and doesn't in your application? Are you familiar with Draw Harness to test VR there?

I meant that VR support in CAD Assistant (which I understand is an OpenCascade application) works perfectly (except for the bindings not being assigned, of course).

I just opened up Draw Harness and tried it with the headset. Everything works as expected (the controllers appear as AIS_Trihedron displays and positional head tracking works). I used the cube tcl code from your blog.

I have dug through some of the code for Draw Harness, but I'm not sure entirely where to look. My understanding is that because we implement AIS_ViewController everything should work identically, but for some reason there is no head tracking nor are the AIS_Trihedron displays visible for controllers as they are in Draw Harness.

Quote:
So the other bindings like "occtvr_bindings_rift.json" have been written in a blind effort based on similar configs coming with "Half-Life: Alyx" game.

Makes sense. I'll have a fiddle with the bindings and see if I can get teleport working in Draw Harness

Kirill Gavrilov's picture

Maybe you haven't copied XR resource files from "src/XRResources" to your application distribution folder? The paths could be resolved from %CSF_OCCTResourcePath% environment variable (or %CASROOT%), so that either "%CSF_OCCTResourcePath%/occtvr_actions.json" or "%CSF_OCCTResourcePath%/XRResources/occtvr_actions.json" should exist.

Win Holzapfel's picture

Just a quick update, all of our issues are fixed!

The problem was that the unit size was set incorrectly. In our software, we have our units in millimeters. This meant that the world was very big! It also meant that the tracked hands were tiny relative to the world, and also rendered incorrectly.

To fix we just set; view->View()->XRContext()->SetUnitFactor(1000);

We also configured bindings for the Oculus Quest 2 using SteamVR. They are attached.

Kirill Gavrilov's picture

Thanks for sharing.