gluLookAt Problem

Started by
2 comments, last by Nairb 21 years, 8 months ago
Hi, I''ve recently been trying to learn 3d programming, and I''ve got a problem that I haven''t been able to work around for weeks. I have a camera. Moving it around is no problem. I can move it forward and backward, strafe, and rotate with the mouse. I''m using quaternions for rotation, so I know my problem isn''t Gimbal Lock. When I''m rotating with the mouse, I get a problem when the Z Direction of the camera should equal/cross over the Z Position of the camera. In this instance, the image starts to mirror itself wildly and I can''t move the camera any further in that direction. I think I''ve traced the problem to the gluLookAt function and the Up Vector. I''ve tried changing the Up Vector to solve the problem (changing it from 0,1,0 to 0,-1,0 in certain instances), but the solution does not work flawlessly. I''ve also tried changing the way I handle my camera via not using gluLookAt and instead using glTranslate and glMultMatrixf with a rotation matrix. However, I haven''t really been able to get this approach to produce realistic looking results. I was hoping someone would know the solution to my problem or be able to point me in the right direction toward making a realistic looking camera with translations and matrix multiplications. Thanks, --Nairb
Advertisement
The problem with gluLookAt is that when you look past the up vector, i.e., your looking behind you, everything will be upside down. So then the the view gets rotated around too keep up pointing up, rather than down. You essentially face the opposite direction instantly. If you continue to look up, you will look past this again it will again flip. That can be very annoying, jerky, and disorienting.

You probably don''t need 6 degrees of freedom, and can get away with using the x position of the mouse to rotate around the x/z plane, and the y position to rotate that around the x/y plane.
Chess is played by three people. Two people play the game; the third provides moral support for the pawns. The object of the game is to kill your opponent by flinging captured pieces at his head. Since the only piece that can be killed is a pawn, the two armies agree to meet in a pawn-infested area (or even a pawn shop) and kill as many pawns as possible in the crossfire. If the game goes on for an hour, one player may legally attempt to gouge out the other player's eyes with his King.
Hello Nairb,

I''ve great interest in your mouse moviment code. can you send me?

Thanks a lot!

Daniel Vivas
_________________________________   Daniel Vivas   Founder/CEO - Lúmen Technology   daniel@lumentechnology.com.br   http://www.lumentechnology.com.br
Don''t there exist alternatives to gnuLookAt then?

I''m just working with OpenGL cameras too and I''d like to have it as much freedom as my Raytracer''s camera!

This topic is closed to new replies.

Advertisement