yaro_dup1
02-03-2003, 07:33 AM
Hi,
I need help with constructing animations.
In main loop I've got a function called RenderScene() which renders
a room.
Now I want to open the door of the room. I have the door in diffrent display list.
What is the best method to make this animation?
I tried that:
I'm breaking the main loop and calling OpenDoor() function which looks like that:
void OpenDoor()
{
for (float x = 0; x < DOOR_OPENED_ANGLE; x += 0.6f)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
gluLookAt(DOOR_CENTER_X, DOOR_CENTER_Y, DOOR_CENTER_Z - 0.6f,
DOOR_CENTER_X, DOOR_CENTER_Y, DOOR_CENTER_Z,
0, 1, 0);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glTranslatef(DOOR_LEFT + DOOR_WIDTH , 0, 0);
glRotatef(-x, 0, 1, 0);
glTranslatef(-DOOR_LEFT - DOOR_WIDTH, 0, 0);
glCallList(DOOR_CLOSED_LIST);
glPopMatrix();
glCallList(ROOM_LIST);
SwapBuffers(hDC);
Sleep(1);
}
}
Is it a good way? Because I don't think so.
For every animation I have to call glClear and SwapBuffers in else function?
Maybe is there any way to create main rendering function with glClear and SwapBuffers
and passing to it next frames of animation?
I have also the else problem. If I open the door, from that moment I have to call
list glCallList(DOOR_OPENED_LIST) or is there any fastest way to draw opened door?
I mean standard position of door which is described by glVertex position is door closed that
means I have to rotate the door modelview matrix every time after opening the door.
thanks for any help
I need help with constructing animations.
In main loop I've got a function called RenderScene() which renders
a room.
Now I want to open the door of the room. I have the door in diffrent display list.
What is the best method to make this animation?
I tried that:
I'm breaking the main loop and calling OpenDoor() function which looks like that:
void OpenDoor()
{
for (float x = 0; x < DOOR_OPENED_ANGLE; x += 0.6f)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
gluLookAt(DOOR_CENTER_X, DOOR_CENTER_Y, DOOR_CENTER_Z - 0.6f,
DOOR_CENTER_X, DOOR_CENTER_Y, DOOR_CENTER_Z,
0, 1, 0);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glTranslatef(DOOR_LEFT + DOOR_WIDTH , 0, 0);
glRotatef(-x, 0, 1, 0);
glTranslatef(-DOOR_LEFT - DOOR_WIDTH, 0, 0);
glCallList(DOOR_CLOSED_LIST);
glPopMatrix();
glCallList(ROOM_LIST);
SwapBuffers(hDC);
Sleep(1);
}
}
Is it a good way? Because I don't think so.
For every animation I have to call glClear and SwapBuffers in else function?
Maybe is there any way to create main rendering function with glClear and SwapBuffers
and passing to it next frames of animation?
I have also the else problem. If I open the door, from that moment I have to call
list glCallList(DOOR_OPENED_LIST) or is there any fastest way to draw opened door?
I mean standard position of door which is described by glVertex position is door closed that
means I have to rotate the door modelview matrix every time after opening the door.
thanks for any help