Sign in to follow this  

Camera question

This topic is 3588 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

Hello, I have a camera class that is basically transforming vectors to be used with gluLookAt later... I am trying to turn the camera using mouse events... Here is a very basic idea behind the code, (PS: I'm just testing, this is not the real implementation...)
int x = LOWORD(msg.lParam);
int y = HIWORD(msg.lParam);

if (x > width/2)
	c->TurnCamera((float)-x/500);
else if (x < width/2)
	c->TurnCamera((float)x/500);

if (y > height/2)
	c->CameraLookUp((float)-y/500);
else if (y < height/2)
	c->CameraLookUp((float)y/500);

SetCursorPos((float)width/2,(float)height/2);

c is a pointer to camera x and y will represent the x and y of the mouse on screen each frame... each frame i center the cursor using SetCursorPos ... Now I am assuming there's nothing wrong with my camera methods because, when I remove this part:
if (y > height/2)
	c->CameraLookUp((float)-y/500);
else if (y < height/2)
	c->CameraLookUp((float)y/500);

the camera will just turn perfectly... and when I remove this part:
if (y > height/2)
	c->CameraLookUp((float)-y/500);
else if (y < height/2)
	c->CameraLookUp((float)y/500);

again everything works fine and the camera will look up and down.. but when I combine both transformations, it works ALMOST fine, but looks as if the camera has been rotated around the Z axis.. After thinking about this for a while I have concluded that I should rotate the camera around the Z axis manually and with a Delta Angle of arccos (x/y) ... But of course it didnt work... Anyway can help on this? Thanks in advance

Share this post


Link to post
Share on other sites

This topic is 3588 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this