Last time I meet this problem, I tried to correct the mouse position with a fake cursor appstate. It works fine for me.
private Camera cam;
private Vector2f position;
public void initialize(Application app) {
cam = app.getCamera();
position = new Vector2f();
// ...
inputManager.addRawInputListener(inputListener);
}
private RawInputListener inputListener = new RawInputListener() {
private float x;
private float y;
public void onMouseMotionEvent(MouseMotionEvent evt) {
// get current position
x = evt.getX();
y = evt.getY();
// keep them in screen space
x = FastMath.clamp(x, 0, cam.getWidth());
y = FastMath.clamp(y, 0, cam.getHeight());
position.x = x;
position.y = y;
}
public void beginInput() {}
public void endInput() {}
public void onJoyAxisEvent(JoyAxisEvent evt) {}
public void onJoyButtonEvent(JoyButtonEvent evt) {}
public void onMouseButtonEvent(MouseButtonEvent evt) {}
public void onKeyEvent(KeyInputEvent evt) {}
public void onTouchEvent(TouchEvent evt) {}
};
public Vector2f getPosition() {
return position;
}
It can also get deltaX & deltaY from MouseMotionEvent
int dx = evt.getDX();
int dy = evt.getDY();
I think you can move camera with those values. Just ignore what inputManager.getCursorPosition() provides you.
Luxurious for resetting mouse positions. It remains to write another code for the four mouse axes based on the listeners. And you can compare the number of lines with the assembler.
If you think that you are smarter when pointing to documentation, you are mistaken. Paul He claimed that the coordinates are reset, then suddenly it was not so.
I think if you want a FPS camera with sensitivity, the easiest way is extends the FlyByCamera and add a sensitivity field to it. Override rotateCamera() method and apply sensitivity in it.
I was mistaken. It happens. In the 25+ years that I’ve been developing software professionally, I have used a lot of graphics frameworks. Some of them reset the coordinates and some don’t. So I looked in the code and found out I was wrong.
The reason it doesn’t matter to any of the rest of our camera implementations is because we are using the delta X and delta Y and never use the accumulated cursor position because it’s ridiculous to do so.
I already posted an FPS camera implementation that has the ability control sensitivity (even separate for each type of input). It has no issues with frame rate, etc…
Since it seems like you are making a client/server application then this all matters even less.
getCursorPosition() is useful for getting the cursor position on the screen when the cursor is enabled. Note how many times I used the word “cursor” in that sentence.
For tracking non-cursor mouse movement it is totally useless… and you are likely the only one really trying to do it.
Register a listener. That listener will be notified about deltaX and deltaY every frame there is movement. You don’t need cursor position unless you want to know the position of the cursor.
Edit: blah blah… which is in my camera example… blah blah… repeating myself…blah blah.
Or on OpenGL it is done only, confidence that still there is an assembler. I think that it will be necessary to develop a cheat at a low level. (Sarcasm)
JME doesn’t provide a way of setting the mouse cursor location. You can start another thread about alternatives where you can describe why you need it since it has nothing to do with this thread.
There is a common, I need to reset cursor data for camera operation. And use the listeners deltaX and deltaY. Still a lot of lines of code to replace the mathematical operations on the cursor. I think it’s funny.
All logic is built on the behavior of the cursor and provides redundancy of the rotation data of the camera. Also this implementation is visual and short by code.