I’m trying to learn camera movement…but here when i go up in y-axis it dose’t move further after 90 degree and moves back down and then same till -90 degree…
Here i use this gluLookAt(3 * cos(angle), 3*sin(angleY), 3 * sin(angle), 0, 0, 0, 0, 1,0);
i have doubt in above line, is that good or something is wrong?..
Here is my Inputs-
void KeyIn(int key, int x, int y)
{
switch (key)
case GLUT_KEY_RIGHT:
angle += 0.1;
Display();
break;
case GLUT_KEY_LEFT:
angle -= 0.1;
Display();
break;
case GLUT_KEY_UP:
angleY += 0.1;
Display();
break;
}
}
If you’re controlling the angles directly, use glRotate and glTranslate rather than gluLookAt.
Assuming that you’re trying to specify yaw and pitch directly, the first three parameters should probably be: gluLookAt(3*cos(angleY)*cos(angle), 3*sin(angleY), 3*cos(angleY)*sin(angle), ...);
If you try to “go over the top”, it will spin 180° around the Y axis, as the “up” direction is fixed.
Modify angle and angleY based upon the mouse position (either the current position or the difference between the current position and the previous position) then call glutPostRedisplay to force a redraw.
The matrix operations remain in the draw function; the input callbacks should only modify variables.
but now problem is that after clicking & moving, camera view always get sets to original view from where it started and then starts moving…below are inputs given to:
you do neatly collect the changes of the angle in the ‘angle’ variable, but you never uses that angle anywhere. You ‘DO’ use ‘changeAngle’, and it behaves as ‘angle’ (grows as long as you drag the mouse). Remember that the move() function is called many times more than the mouse-up/down. It seems right that you should use the accumulated ‘angle’ in the glRotate().
You’r almost there!