Official VR module

Could this have something to do with the JNA ? is there a particular jna.jar or dll that need to be in the working directory?

Just to be clear: You intend to use an OSVR headset?

Edit:

Reading up on the previous posts. If it is an oculus rift @xefox and @dbmapit are using, the setting should be:
settings.put(VRConstants.SETTING_VRAPI, SETTING_VRAPI_OCULUSVR_VALUE);

No I’m using an HTC Vive and SteamVR I believe it is OpenVR.

then you can use either
SETTING_VRAPI_OPENVR_VALUE

or SETTING_VRAPI_OPENVR_LWJGL_VALUE
if JNA is giving you trouble or you want to tap into LWJGL directly.

Firstly thank you for you time.

  1. When I run the following main function with out the headset plugged in:

public static void main(String[] args) {

AppSettings settings = new AppSettings(true);

settings.put(VRConstants.SETTING_VRAPI, VRConstants.SETTING_VRAPI_OPENVR_VALUE);

settings.put(VRConstants.SETTING_ENABLE_MIRROR_WINDOW, true);

VREnvironment env = new VREnvironment(settings);

env.initialize();

// Checking if the VR environment is well initialized

// (access to the underlying VR system is effective, VR devices are detected).

if (env.isInitialized()){

VRAppState vrAppState = new VRAppState(settings, env);

vrAppState.setMirrorWindowSize(1024, 800);

Main app = new Main(vrAppState);

app.setLostFocusBehavior(LostFocusBehavior.Disabled);

app.setSettings(settings);

app.setShowSettings(false);

app.start();

}

}

The output is :

run:

May 22, 2019 3:20:44 AM com.jme3.input.vr.openvr.OpenVR initialize

SEVERE: OpenVR Initialize Result: Hmd Not Found (108)

May 22, 2019 3:20:44 AM com.jme3.input.vr.openvr.OpenVR initialize

SEVERE: Initializing OpenVR system [FAILED]

May 22, 2019 3:20:44 AM com.jme3.app.VREnvironment initialize

WARNING: VR native wrapper initialized [FAILED]

May 22, 2019 3:20:44 AM com.jme3.app.VREnvironment initialize

SEVERE: Cannot initialize VR environment [FAILED]

Then I connect ad turn on the head set and run I get the following output:

run:

Exception in thread “main” java.lang.IllegalStateException: Pointer native@0x7ffb02730560 already mapped to Proxy interface to native function@0x7ffb02730560 (com.jme3.system.jopenvr.VR_IVRSystem_FnTable$ComputeDistortion_callback).

Native code may be re-using a default function pointer, in which case you may need to use a common Callback class wherever the function pointer is reused.

at com.sun.jna.CallbackReference.getCallback(CallbackReference.java:148)

at com.sun.jna.CallbackReference.getCallback(CallbackReference.java:131)

at com.sun.jna.Pointer.getValue(Pointer.java:425)

at com.sun.jna.Structure.readField(Structure.java:720)

at com.sun.jna.Structure.read(Structure.java:580)

at com.jme3.input.vr.openvr.OpenVR.initialize(OpenVR.java:202)

at com.jme3.app.VREnvironment.initialize(VREnvironment.java:477)

at mygame.Main.main(Main.java:25)

C:\Users\dbmapit\AppData\Roaming.jmonkeyplatform\v3.2.2-stable-sdk1\var\cache\executor-snippets\run.xml:53: Java returned: 1

BUILD FAILED (total time: 6 seconds)

And if you use this setting?

SETTING_VRAPI_OPENVR_LWJGL_VALUE

The LWJGL implementation uses JNI rather than JNA. (I’m unsure which version it’s available in, or if you use master, so it might be unavailable)

Hello,

Make your tests with settings.put(VRConstants.SETTING_VRAPI, SETTING_VRAPI_OPENVR_LWJGL_VALUE);

In this case you’re avoiding all problems related to JNA, OpenVR version as the VR module will delegate to LWJGL the wrap with the headset.

For more information OPENVR API has to be used with HTC vive headsets and OSVR API has to be used with OCULUS Headsets.

Thank you “seinturier”

I tried settings.put(VRConstants.SETTING_VRAPI, VRConstants.SETTING_VRAPI_OPENVR_LWJGL_VALUE);

and got the following error:

Exception in thread “main” java.lang.IllegalStateException: Pointer native@0x7ffb01360560 already mapped to Proxy interface to native function@0x7ffb01360560 (com.jme3.system.jopenvr.VR_IVRSystem_FnTable$ComputeDistortion_callback).

Native code may be re-using a default function pointer, in which case you may need to use a common Callback class wherever the function pointer is reused.

at com.sun.jna.CallbackReference.getCallback(CallbackReference.java:148)

at com.sun.jna.CallbackReference.getCallback(CallbackReference.java:131)

at com.sun.jna.Pointer.getValue(Pointer.java:425)

at com.sun.jna.Structure.readField(Structure.java:720)

at com.sun.jna.Structure.read(Structure.java:580)

at com.jme3.input.vr.openvr.OpenVR.initialize(OpenVR.java:202)

at com.jme3.app.VREnvironment.initialize(VREnvironment.java:477)

at mygame.Main.main(Main.java:25)

C:\Users\dbmapit\AppData\Roaming.jmonkeyplatform\v3.2.2-stable-sdk1\var\cache\executor-snippets\run.xml:53: Java returned: 1

BUILD FAILED (total time: 1 second)

Try disabling the camera in SteamVR

Edit: It shouldn’t try to initialize OpenVR if VRConstants.SETTING_VRAPI_OPENVR_LWJGL_VALUE is used, rather “OpenVrLwjgl”

and OSVR API has to be used with OCULUS Headsets.

You should be using OCULUSVR with Oculus headsets?

OSVR is something else entirely.

Have you developed for the VIVE? If so what did you use?
Best regards

I had the modified branch of jme3 working with my HDK2.0, but from reading some of these threads it looked like the jme3-vr library would become part of the master branch. Download of the latest SDK release (3.2.3) suggest that it isn’t included. Any advice on the best way to get the HDK OSVR working with Jmonkey?

It is part of the master branch. But version 3.2.3 is not the same thing as master. The master is a work in progress for version 3.3.

I have used it for the VIVE PRO just fine. Works great with great performance.

1 Like

Thanks tfl30, so I need to build from the Master branch? Is it easier to use the resulting libraries with the JME SDK, or just NetBeans?

Hello,

Jme-vr has some specific requirments according to LWJGL 3. The 3.2.x branch does not contains them, this is the reason why you has to use 3.3 branch.

I will work on the module this summer in order to get it tested with new génération of VR de vices.

2 Likes

Thanks seinturier, today I got as far as building the master 3.3.x branch, getting it working with Netbeans 11 and Maven. The VRSample launches and seens to try and take over SteamVR but then crashes, I tried the OSVR and VRAPI settings, but no luck.

Which VR devices do you use ?

Hi all,

I can confirm that I also used successfully VIVE Pro on branch 3.2. I changed gradle settings to set compatibility with java 1.8 and explicitly to build jme3-lwjgl3 and jme3-vr. So far I have spotted the following issues:

  • Developing for Linux required more tweaks in the code. I think it was mentioned earlier in this thread that there are specific checks which fail if not Windows is used. I managed to get my app to build and run on Linux, but with poor quality. There were some issues with SteamVR Beta as well.
  • On Windows after 15-30min application starts to lag. Not sure what is causing it, I’m just running Lab game on Steam and will check in some time if it also lags.
  • Using wireless adapter for VIVE Pro (Windows required, Linux drivers do not support provided wigig chip) may cause significant lags in jME VR app. Whenever I turn off and back on the headset and restart application, I get lags. This may be related to the wireless adapter itself, nevertheless it is worth to be aware of it.
  • I had to set VRConstants.SETTING_ENABLE_MIRROR_WINDOW to false in order to get is correctly mirrored on my screen.

I must admit I haven’t tried the master branch, but since we are about to present results to our customer, I will not play with it now. Overall the quality of VIVE Pro with jME is very good.

edit: just checked. I actually use 3.2.2 version (SDK) with lwjgl3 and vr modules from version 3.2.3 (built from sources).

3 Likes

@Malin thank you for the info on the Vive Pro.
I have the wireless adapter, but was not using it during my tests. I will hook mine up and test to see if causes any lag on my end.

What GPU/CPU are you using. I am running my tests on an RTX Titan, so if the lag issue is usage VRAM it may be harder for me to recreate, I have some GTX 1080 TIs laying around. I can swap one of those in and test with it as well. If it helps I can also test with NVLINK on the RTX Titans, or SLI on the GTX 1080 TIs. The only smaller GPU I have is a 960, which is a little under powered for VR.

As for CPU my two test rigs are using a Intel i7 6850K and AMD 2nd gen threadripper 2950x.
Both have 32 GB RAM on the first, 64 GB on the second.

Let me know your setup and we can troubleshoot the lag.