Archived

This topic is now archived and is closed to further replies.

Jo

Viewport rotations:

Recommended Posts

Here''s my problem: I''m using gluLookAt to focus on a particular point on my scene, while maintaining a set distance. I''ve added rotation about the x and y axis by using glRotatef after the intial call to gluLookAt. This works fine at the origon, however I move the point of focus around which causes everything to get misaligned. Please note that I''m trying to avoid doing a manual rotation of the camera vector, which would probably fix the problem. My question is, as always, is there another way? ----------------------------- Mice are an excellent source of mice.

Share this post


Link to post
Share on other sites
I made this post late at night and I didn''t manage to get any responses before it got pushed down to the bottom of the list.

If anybody has any ideas it would be apreciated.

-----------------------------
Mice are an excellent source of mice.

Share this post


Link to post
Share on other sites
Jo, do you mean that the camera''s position is at (0, 0, 0) or the object that the camera is focused on?

Share this post


Link to post
Share on other sites
The rotations work fine when the object the camera focuses on is at 0, 0, 0. When I move the object (which also moves the camera) things go haywire.

Share this post


Link to post
Share on other sites
Well I got back from work and about an hour later I got the problem fixed. For reference here's the solution I used:

glTranslatef( 0.0f, 0.0f, -distance );
glRotatef( -camAnglex, 1.0f, 0.0f, 0.0f );
glRotatef( -camAngley, 0.0f, 1.0f, 0.0f );
glTranslatef( -playerx, -playery, -playerz );

// Draw Scene

glTranslatef( playerx, playery, playerz );

// Draw Player

Notice there's no anoying vector math or any need to deal with the up vector. Since I had no need for roll gimble lock shouldn't be an issue (only two axis of rotation).

Edited by - Jo on October 5, 2000 9:47:46 PM

Share this post


Link to post
Share on other sites
I''m glad you figured out the problem, I was just about to post the reply for you. Good luck with your program.

Share this post


Link to post
Share on other sites