first-person-shooter mouselook

hello,

i am trying to implement a camera-model like in a first person shooter.
so i am getting mousemovement from a mouselistener and i use java.awt.Robot to reset the mousecursor to the center of the window so that the cursor cant leave the window accidentally.

this is the code i use in the mouse move listener:


			java.awt.Point p = canvas.getLocationOnScreen();
			int x = p.x + (int) Math.round(cur_width / 2.0);
			int y = p.y + (int) Math.round(cur_height / 2.0);
			if ((p.x + e.getX() != x || p.y + e.getY() != y)) {
				Vector3f dir = mf.camera.look.minus(mf.camera.pos);
				dir = dir.rotateY((mouseXlast - mouseX) * (float) getFrameTime());
				dir = dir.rotateAxis((-mouseYlast + mouseY) * (float) getFrameTime(), dir.cross(mf.camera.up));
				camera.look.set(camera.pos.add(dir));
				robot.mouseMove(x, y);
			}

unfortunately i get a very jittery movement. especially with low framerates.
could this be caused by the fact that movement messages run in another thread than the display loop?

thanks!

anyone? :slight_smile:
thanks!

U r multiplying dir with frameTime so it means that if u have smaller amount of fps(this time will be bigger then) u get jittery movement.
U should probably set max angle of rotation by frameā€¦that could solve the jitter.
Take note tho that when u have low framerates u ll turn more slowly(just like in many games).

Hope this helps.