Hello everyone.
I am trying to define i spherical view volume.
This is what i mean:
void Passive(int x , int y)
{
float Xnew = x, Ynew = y;
glClearColor(0.0,0.0,0.0,0.0);
glClear (GL_COLOR_BUFFER_BIT);
Xnew = ( x / 500.0 ) * 360.0;/* Window is 500x500 */
Ynew = ( y / 500.0 ) * 360.0;/*So converting 0-500*/
/* to 0-360 degrees */
theta = (Xnew * 3.14 / 180.0);
phi = (Ynew * 3.14 / 180.0);
Xnew = 300 * sin(theta) * cos(phi);
Ynew = 300 * sin(theta) * sin(phi);
Z = 300 * cos(theta);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity ();
gluLookAt (Xnew , Ynew , Z ,0.0 , 0.0 ,0.0, 0.0, 1.0, 0.0);
glColor3f(1.0, 0.0 ,0.0);
glutWireCube (200);
glColor3f(1.0, 1.0 ,1.0);
glutWireSphere(100, 20 , 20);
glFlush ();
}
So i am tryiong to convert the 0-500 coordinate walues to 0-360 degrees range and using gluLookAt() to look at the rendered scene.
Now, this is working for the X axis. ie when i move my mouse on the X axis(changing X coords) , i can see the object from different angles. But this is not happening for the change in Y coordinate values!
Can anyone please explain what im doing wrong?
Thanks in advance.