VRMouseManager problem

Hey there!

I’ve been trying to set up a very simple VR program before I start my actual project so I can test the features of jMonkeyVR.
However, no matter what I do, I can’t run the TestOVRApp because everytime the same error appears and, after searching and dissecating the problem a little bit, I realized that the VRMouseManager.class has an error on line 69:

68  if( mi instanceof GlfwMouseInput )
69      (GlfwMouseInput)mi.setCursorPosition(as.getWidth() / 2, as.getHeight() / 2);

The method “setCursorPosition” doesn’t exist in any other related Class!
Not in the MouseInput.class, neither GlfwMouseInput.class.

With this, everytime I import jMonkeyVR.jar to any project, a runtime error pops up concerning this specific method.

I am using the latest version of jMonkeyVR downloaded from here:

Am I missing something? Another lib I am forgetting to add?

PS: if it is using a non-existent method, how can it be even compiled?

Are you using the phr00t build or regular jMonkeyEngine? If you’re using the jMonkeyVR .jars the class file is already compiled. It can also happen if the project inherits jars from another project (so that it compiles against a working version but in runtime another incompatible one is run on the classpath)

Just a bystander notice but that code seems to be missing parenthesis else the cast is meaningless. Don’t know if it was a cut-paste issue or…

     ((GlfwMouseInput)mi).setCursorPosition(as.getWidth() / 2, as.getHeight() / 2);
1 Like

What rickard said: I’m not yet at this point - so sorry for this simple question: Why is there a need for a special ‘phr00t build’ ? Could jME not be modified to support VR out-of-the-box? (Why not?)
I’ve seen phr00t ask people who commit changes to jME also to commit these to his fork. This seems very cumbersome and maybe a unification of some semi-core libraries would help to get out of this situation?

Major philosophical differences in how the integration should be done. The main one being that phr00ts approach is to have VR application extend a special VRApplication base class and JME prefers a compositional approach (more app states, less default garbage).

Our end goals are slightly different and they manifest in some fundamental forking in approaches.

To build a modular engine we prefer modular approaches. For example, if the “JME way” works then you could trivially roll a VRApplication base class if you wanted. But if VRApplication is the only way to build a VR application then you are stuck if you need to extend some different base class for some reason or need to otherwise replace bits of the functionality.

Neither is wrong… just different. phr00t’s approach does let him ‘kludge’ some things inside of his app base class to work around various vendors’ different VR toolkit issues. He’s also pumped a lot of time into it and has made a bunch of progress.


I’m using phr00t’s build. Not sure if done correctly but I need to run it as a NetBeans project (that’s the only way I got it working properly).

As to the ‘.jar’ file, I tried adding the jMonkeyVR.jar and the “jna-x-x”.jar to a new basic game.
I have set up a few configurations jus to enable a VR camera, no movement or anything. Still can’t get it running.

Here is the sample code I’m trying to run using a VR camera:
(It’s onde of the jME tutorial codes)

package mygame;

import com.jme3.animation.AnimChannel;
import com.jme3.animation.AnimControl;
import com.jme3.animation.AnimEventListener;
import com.jme3.animation.LoopMode;
import com.jme3.input.KeyInput;
import com.jme3.input.controls.ActionListener;
import com.jme3.input.controls.KeyTrigger;
import com.jme3.light.DirectionalLight;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.scene.Node;
//import com.jme3.app.SimpleApplication;
import jmevr.app.VRApplication;

public class Main extends VRApplication implements AnimEventListener{
    private AnimChannel channel;
    private AnimControl control;
    Node player;
    public static void main(String[] args) {
        Main app = new Main();
        app.preconfigureVRApp(PRECONFIG_PARAMETER.USE_CUSTOM_DISTORTION, false); // use full screen distortion, maximum FOV, possibly quicker (not compatible with instancing)
        app.preconfigureVRApp(PRECONFIG_PARAMETER.DISABLE_SWAPBUFFERS_COMPLETELY, false); // runs faster, but only VR Compositor visibility available
        app.preconfigureVRApp(PRECONFIG_PARAMETER.FORCE_VR_MODE, true); // render two eyes, regardless of SteamVR
        app.preconfigureVRApp(PRECONFIG_PARAMETER.SET_GUI_CURVED_SURFACE, true);
        app.preconfigureVRApp(PRECONFIG_PARAMETER.FLIP_EYES, false);
        app.preconfigureVRApp(PRECONFIG_PARAMETER.SET_GUI_OVERDRAW, true); // show gui even if it is behind things
        app.preconfigureVRApp(PRECONFIG_PARAMETER.INSTANCE_VR_RENDERING, true); // faster VR rendering, requires some vertex shader changes (see jmevr/shaders/Unshaded.j3md)
        app.preconfigureVRApp(PRECONFIG_PARAMETER.NO_GUI, false);
        app.preconfigureFrustrumNearFar(0.1f, 512f); // set frustum distances here before app starts

    public void simpleInitApp() {
        DirectionalLight dl = new DirectionalLight();
        dl.setDirection(new Vector3f(-0.1f, -1f, -1).normalizeLocal());
        player = (Node) assetManager.loadModel("Models/Oto/Oto.mesh.xml");
        control = player.getControl(AnimControl.class);
        channel = control.createChannel();
    public void onAnimCycleDone(AnimControl control, AnimChannel channel, String animName) {
    if (animName.equals("Walk")) {
      channel.setAnim("stand", 0.50f);
  public void onAnimChange(AnimControl control, AnimChannel channel, String animName) {
    // unused
  /** Custom Keybinding: Map named actions to inputs. */
  private void initKeys() {
    inputManager.addMapping("Walk", new KeyTrigger(KeyInput.KEY_SPACE));
    inputManager.addListener(actionListener, "Walk");
  private final ActionListener actionListener = new ActionListener() {
    public void onAction(String name, boolean keyPressed, float tpf) {
      if (name.equals("Walk") && !keyPressed) {
        if (!channel.getAnimationName().equals("Walk")) {
          channel.setAnim("Walk", 0.50f);

And here is the runtime error I get:

You need to use LWJGL 3… you are probably trying to use LWJGL 2. Use jme3-lwjgl3.jar in your project, not jme3-lwjgl.jar. That should do the trick.

EDIT: Updated the jMonkeyVR github with this important piece of information

All good points. pspeed. For the record, VRApplication no longer extends SimpleApplication, only Application. This makes is far more leaner than it was. Rickard was going to try and make a modular version to work into the main branch of jMonkeyEngine… but we all are bound by time constraints. I’m trying to commercially support multiple games on Steam, and I just don’t have the time to retrofit things that work into the “jME way”. Anyone who wants to take on that task is more than welcome, but I kinda have to push forward on the rapidly advancing VR front.

Not sure whether the plan is to get into the main branch but for the record my fork is here and fairly up to date:
It doesn’t have the instancing though as that requires other modifications to core. It does work off-the-bat with jme, so if anyone wants to try it out, feel free!

1 Like