View Full Version : How to use gluLookAt() to rotate around object created

03-07-2015, 04:20 AM
I'm new to openGl, I am starting on 3d stuff, but can't get gluLookAt() to work, right now it works by just pressing a button, the "camera" moves , which is fine, I want it to rotate around the object..How would I go about doing this?
Here's what I have so far. I have attached a text file as they won't let me paste the code as a new member..

Dark Photon
03-07-2015, 12:40 PM
If you refer to the arguments (gluLookAt (https://www.opengl.org/sdk/docs/man2/xhtml/gluLookAt.xml)), you see that you specify three things:

1) where the eye is
2) what point it is looking towards
3) and direction is generally toward "up" in your view

In your case, you already know #2

03-07-2015, 01:40 PM
I'm not sure I get you. I know how to move the camera around a little bit, and that the 0,0,0 is where it will look at, the final 3 values are just the up and down on each axis. But I am confused as to how to get the camera to actual orbit my object.

Dark Photon
03-08-2015, 11:13 AM
If you want it to orbit, the first thing you need to do is come up with some formula which gives you the world-space position of the camera at any given time (x,y,z) as a function of time (t). For instance, Parametric Equation of a Circle (http://www.mathopenref.com/coordparamcircle.html). Then it's just a matter of computing the time (e.g. based on system time) and computing the camera position each frame, plug it in, and you're done.