1

I have a fps "camera", and just recently managed to set up mouse movement to rotate the angle of viewing. The one problem with the camera is that the mouse can leave the window and the angles will not rotate anymore. I know I can use a robot method like mouseMove(), however, I've heard that it makes the camera rotation feel very jerky. Is there any other way to keep the mouse in the window, say like, Minecraft? I'm using Minecraft as an example because my program uses LWJGL too, and I was wondering how Notch does it. Any suggestions?

1 Answers1

2

Mouse.setGrabbed(true) at a start-up moment,

and for every game-loop(frame):

catch mouse movement with Y_Angle += Mouse.getDX()*0.1f,

then rotate your view matrix around Y axis on Y_Angle degrees/radians.

For rotation around X and Z axes use Mouse.getDY() and think on your own how to implement right matrix rotation for those, but this is the main idea.

TomatoMato
  • 703
  • 2
  • 8
  • 19