Skip to main content
gamedev.net
🔒 Locked

Camera problem

Started by sheepsteak Jan 2, 2006 at 4:20 PM 0 replies 650+ views
Original Post
sheepsteak
sheepsteak
I've used a camera tutorial that I found on Flipcode. I'm having trouble with the rotations but the translations seem fine. I'm using GLUT and my mouse callback looks like this:

void Mouse(int pX, int pY)
{
	static int lastX, lastY;
		
	if(pX > lastX)
		gCamera.RotateLocal(-1.0, 0.0, 1.0, 0.0);
	else
		if(pX < lastX)
			gCamera.RotateLocal(1.0, 0.0, 1.0, 0.0);

	if(pY > lastY)
		gCamera.RotateLocal(-1.0, 1.0, 0.0, 0.0);
	else
		if(pY < lastY)
			gCamera.RotateLocal(1.0, 1.0, 0.0, 0.0);

	lastX = pX;
	lastY = pY;
}



If you try the compiled exe from here and hold down a mouse button and rotate the pointer in circles you will see how it goes wrong. The teapot starts to rotate around the Z axis. If you do circles in the other direction then it goes back. Use W, A, S and D for FPS-like movement. Any ideas how I can stop this from happening?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.