So I have a requirement to rotate around a scene. The scene is just a revolving sun with an earth and moon revolving around that.
I have to use gluLookAt() to rotate around that sceen. I do it with this code:
GLdouble theta = -anglex * PI / latiGrid; GLdouble phi = angley * 2 * PI / longiGrid; gluLookAt(eyeZ * cos(theta) * sin(phi), eyeZ * sin(theta), eyeZ * cos(theta) * cos(phi), 0, 0, 0, 0, 1, 0);
Where anglex and angley is simply the difference in angles of the X and Y screen coordinates... First I extracted this code from a similar project, so I was hoping someone could explain why it works in the first place. How are the eye coordinates derived exactly? I'm a bit at a loss of how this works.
Also, It rotates fine in the horizontal direction, but in the vertical direction it gets to the top it translates the orbiting earth from one end to the other.