• Advertisement
Sign in to follow this  

Camera problem

This topic is 4432 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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);
		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);
		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?

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement