PDA

View Full Version : Some animation



Kronos259
06-12-2003, 11:12 PM
I have a question about animation.I have created a door and i want to open it (actually by pressing a button the two parts of the door will move along the x -axis).I have read some tutorials and i am really having trouble doing what seems simple.Can anybody help me because it is getting really tiring.
Thank you!

starman
06-13-2003, 02:57 AM
You're going to have to be more specific. What's not working? Do you have some code to show us?

nexusone
06-13-2003, 03:37 AM
Simple code example:


// Object Door

glPushMatrix();
glTranslate // Location of door
glRotatef( Rotate_x, 1,0,0); // rotate door on axis, 0= closed, 90 = open.
Draw_door();
glPopMatrix(); //End door object


Add to key board:

if ( key == "O" ) Door_state = 1;
if ( key == "C" ) Door_state = 0;

Add to idle or timmer routine for animation.

if (Door_state)
{
Rotate_x++;
if (Rotate_x > 90) Rotate_x = 90; // open angel max.
}else {
Rotate_x--;
if (Rotate_x < 0) Rotate_x = 0; // close door min angle.

This will open the door on a O keypress or close on a C keypress

Hope this helps



Originally posted by Kronos259:
I have a question about animation.I have created a door and i want to open it (actually by pressing a button the two parts of the door will move along the x -axis).I have read some tutorials and i am really having trouble doing what seems simple.Can anybody help me because it is getting really tiring.
Thank you!