I'm encountering the following problem. I've got a dinosaur which I'd like to rotate around a point that is not the origin. Well that's not the problem, but here it comes.
I'm moving the dinosaur using the numeric keyboard, 4+6 rotates, 8 moves, 2 stops the dinosaur. I cannot rotate the dinosaur and then translate it into it's correct position. This is my code:
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
gluLookAt(camera, camera, camera, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
glTranslatef(10.5, 0.0, 1.55);
glRotatef(angle, 0.0, 1.0, 0.0);
glTranslatef(-10.5, 0.0, -1.55);
void keyboard(unsigned char key, int posx, int posy)
if (tolower(key) == 'q')
if (key == '8')
move = GL_TRUE;
else if (key == '4')
else if (key == '6')
else if (key == '2')
move = GL_FALSE;
As you can see, I try to rotate the dino itself around the y-axis at the point (10.5, 0.0, 1.55). But I have to translate the dino to the position (dino_pos, dino_pos, dino_pos). I've tried to add those coordinates to the rotation point, but that doesn't work, at least not in the way I'm doing it .
Can anybody please help me out (trying to be really desperate here...) ??