Use gluLookAt to navigate around the world

I am trying to make a simple program that will zoom, pan, and rotate around a scene using the mouse. It seems natural to use gluLookAt to do this since I want to move the camera. I got zooming to work (using gluPerspective), but I dont know how to smoothly rotate or pan?

gluPerspective (50.0*ViewingFrustrum.zoom, ViewingFrustrum.aspect(), ViewingFrustrum.zNear, ViewingFrustrum.zFar); 

gluLookAt(0, 10, 10, 0, 0, 0, 0, 1, -1); // eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz

Then to zoom, I handle a middle mouse hold+move which does this

ViewingFrustrum.zoom += increment;

That is very easy because the zoom does not depend on the location. However, the pan and rotate are location dependent. Is there an easy way to modify this so that left mouse will rotate?



of course you can do it with gluLookAt. gluLookAt accepts 3 axes which makes up your transformation matrix. by your code those values are fixed so nothing gets changed. if you rotate something about the Y axis f.e. you get a left right rotation. so all you need is to compute right vectors and pass them to gluLookAt to update the matrix.

a sample on how to implement fps controls:

Also, I started a similar topic hereā€¦I have example JOGL code that you can run as well and you could get my code from one of the posts in the thread and basically convert it to OpenGL pretty easily.

Thanks for posting that, _NK47.