Official VR module

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.

@tlf30 thanks, it would be nice to see if you experience similar issues. My hardware:

  • single GTX Titan X (couldn’t get jME to work with two GPUs) , which should provide enough VRAM
  • 80-core Xeon E5-2698
  • 144GB RAM

Interesting, I have not had issues with two GPUs. I will see if I can recreate.

Ah, OK. I will get my GPU server out for testing. It has two Xeon 20 core chips, and 128 GB of ram. That will get a similar profile to you.

Hi
I’m using latest JME

Product Version: jMonkeyEngine SDK 3.3.0-SNAPSHOT
Java: 1.8.0_212; OpenJDK 64-Bit Server VM 25.212-b04
Runtime: OpenJDK Runtime Environment 1.8.0_212-b04
System: Windows 10 version 10.0 running on amd64; Cp1252; en_US (jmonkeyplatform)
Running this code snippet from VR test source code

VREnvironment environment = new VREnvironment(new AppSettings(true));
environment.initialize();
OpenVR openVr = (OpenVR) environment.getVRHardware();
System.out.println(openVr.getName());
openVr.updatePose();
openVr.destroy();

I get the following exception:

Exception in thread “main” java.lang.IllegalStateException: Pointer native@0x7ff8068eaa78 already mapped to Proxy interface to native function@0x7ff8068eaa78 (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:124)
at com.sun.jna.CallbackReference.getCallback(CallbackReference.java:107)
at com.sun.jna.Pointer.getValue(Pointer.java:430)
at com.sun.jna.Structure.readField(Structure.java:705)
at com.sun.jna.Structure.read(Structure.java:565)
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:23)

Any idea where I might be going wrong here?

Best regards
dbm

Using :

Blockquote

AppSettings settings = new AppSettings(true);
settings.put(VRConstants.SETTING_VRAPI, VRConstants.SETTING_VRAPI_OPENVR_LWJGL_VALUE);//.SETTING_VRAPI_OPENVR_VALUE);//
settings.put(VRConstants.SETTING_ENABLE_MIRROR_WINDOW, false);

    VREnvironment env = new VREnvironment(settings);

Blockquote

Getting Exception:
Exception in thread “main” java.lang.NoClassDefFoundError: org/lwjgl/BufferUtils
at com.jme3.input.vr.lwjgl_openvr.LWJGLOpenVR.(LWJGLOpenVR.java:48)
at com.jme3.app.VREnvironment.initialize(VREnvironment.java:469)
at mygame.Main.main(Main.java:26)
Caused by: java.lang.ClassNotFoundException: org.lwjgl.BufferUtils