So basically, by using left, right, up and down keys I need to achieve this animation probably using gluLookAt
.
I have tried everything but I can't get it to move exactly like this. Do you have any tips? Here is my current function for camera movement.
void specialKeys(int key, int x, int y) {
switch (key) {
case GLUT_KEY_DOWN:
ex -= 0.04;
break;
case GLUT_KEY_UP:
ex += 0.04;
break;
case GLUT_KEY_LEFT:
ey += 0.05;
cy -= 0.05;
std::cout << ex << " " << cx << " " << uy << std::endl;
break;
case GLUT_KEY_RIGHT:
ey -= 0.05;
cy += 0.05;
std::cout << ex << " " << cx << " " << uy << std::endl;
break;
default:
break;
}
glutPostRedisplay();
}
The rest of the code can be found in the previous questions Why does my wired sphere turn into ellipsoid when translating and changing camera angle? and Issues with animation - translation, projection OpenGL/C++.
my gluLookAt
is:
gluLookAt(ex + 0.0, ey + 0.0, ez*ex - 5.5, cx, cy, -1.0 + cz, -1.0, 0.0, 0.0);
Somehow my up and down keys are not doing what they should be doing when elements get translated to the right. I think I'm on the right path but I've been working on this for two days and can't manage to solve it.