Hi,
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:
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
gluLookAt(camera[0], camera[1], camera[2], 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
drawEnvironment();
if (move)
moveDino();
glTranslatef(10.5, 0.0, 1.55);
glRotatef(angle, 0.0, 1.0, 0.0);
glTranslatef(-10.5, 0.0, -1.55);
drawDino();
glFlush();
glutSwapBuffers();
}
void keyboard(unsigned char key, int posx, int posy)
{
if (tolower(key) == 'q')
exit(0);
if (key == '8')
move = GL_TRUE;
else if (key == '4')
rotateDino(left);
else if (key == '6')
rotateDino(right);
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[0], dino_pos[1], dino_pos[2]). 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...) ??



.
