Mouse problem

I'm switching between firstperson and the JMEDesktop. When it's time to switch to firstperson from JMEDesktop I remove the JMEDesktop from the rootNode and try to MouseInput.get().setCursorVisible(false);

The problem is that the mouse remains. Not only that, It moves in the entire screen area even though my app is windowed. This i strange because in my firstperson code, I force the mouse to the center of the screen each frame. Its like there are two mice.

Did you probably call setCursorVisible(false) from the swing thread? (e.g. within an actionPerformed)

That'd explain it - lwjgl does not support multiple threads. Call it from the jme thread e.g. via JMEAction if you want it to be caused by a swing event (see HelloJMEDesktop for short example).

To try your theory I'm calling it inside update. Still nothing.

Using a custom mouse and not the system mouse solves it but now I'm having trouble with the placement of the cursor. The picture representation of the cursor appears in the center of the screen while the accual mouseposition is at (0,0). When moving the mouse they continue to be that far apart.

AbsoluteMouse has two operating modes. The default is to compute the visual cursor location from the movement delta -> coordinates may differ from MouseInput.get().get… You can force AbsoluteMouse to match them by calling setUsingDeltas(false).

If you can use a custom mouse hiding the system mouse cursor seems possible - just calling setCursorVisible once from awt thread causes it to break - double check that you never call it from another thread than the jme thread. It really works. (See TestJMEDesktop for a demonstration of both - custom cursor with correct coordinates and hiding/showing system cursor)

Thanks irrisor, I've got it working with the JMEAction now. However. I'm using a JFileChooser, and the event fires only when pressing the Cancel button, not when pressing the Open button. Do you think it's possible to use actionPerformed and store the result in a variable that get checked in the next update?

Oops, same thing with actionPerformed(). I'm doing something stupid probably.

Well, I knew I was doing something stupid but I didn't realize the magnitude of it. :oops:

Apparently the JFileChooser doesn't fire any events from the Open button if nothing has been chosen. It's to smart.

We learn better from our stupidity than from our intelligence. :slight_smile:


In some camera angles the desktop doesn't show. Could it be related to the localrotation?

I'm setting the local rotation on the desktop node as in the JMEDesktoptest like this :

desktopNode.getLocalRotation().set( 0, 0, 0, 1 );

Should It be set in relation to the cameras direction or something?

I can imagine two possible reasons: you set invalid values like (0, 1, 0, 0.3f) or similar (rotation Quats must be normalized), or the node that contains the desktop is culled because of too small boundings.

Accually I didn't set any bounding cause I "cull" manually by removing the desktopNode from it's parent.

I don't quite get Quaternions. What am I doing when I set this: desktopNode.getLocalRotation().set( 0, 0, 0, 1 );

Am I supposed to rotate the desktopNode according to the camera?

If so how do I do that?