Set mouse location?

Hello all.



I have an AbsoluteMouse (am) I'd like to center onscreen. The best result I had was with

MouseInput.get().setCursorPosition(getRenderer().getWidth() / 2, getRenderer().getHeight() / 2);
am.setLocalTranslation(new Vector3f(getRenderer().getWidth() / 2, getRenderer().getHeight() / 2, 0));


however there is a slight difference between the two positions, and on moving the mouse, it jumps slightly. Of course, leave one of the two out, and it's completely wrong.

I don't really see how to do this. The only way I could devise (without changing the library) is by injecting things into PerformAction, but really... Anything easier?

Also, usingDelta() doesn't cut it for this. It seems to drift far away from the actual mouse pointer values used in for example PhysicsPicker (which I'm using to test my code).

the first line of code u r using hardward mouse, and the second line u r using absolute mouse.



and thats y u get the slight difference.



i recommand u use hardware mouse since its faster and easier to use

Yeah, hardware mouse is easier.  For setting its position, try this:



http://www.jmonkeyengine.com/jmeforum/index.php?topic=5500.msg43966#msg43966



I had the issue of not being able to set the position with the hardware mouse, but using the java.awt.Robot class, you can do it (at least on machines without security against it…seems like it should be OK)

Can you clip the hardware cursor to the window, like with AbsoluteMouse?



EDIT: anyway, I solved it in the end with usingDelta and a bit of rewriting to use the hotspot coordinates it returns. Seems to work fine. Probably the small jump was because setLocalTranslation doesn't account for the hotspot.