hoganh
11-27-2003, 10:43 AM
Hi im rotating a swing and i only want it to an angle of 40 and then back but at the moment the swing is just going all around.I put an IF statement in but it doesnt seem to be working
glTranslatef(0,0,-50);
drawBar();
glRotatef(rotate,60,0,0);
glPushMatrix();
glTranslatef(2,0,0);
glRotatef(rotate,1,0,0);
glTranslatef(0,-12,0);
drawRope();
glTranslatef(5,0,0);
// glRotatef(rotate,1,0,0);
drawSeat();
glTranslatef(0,12,0);
drawRope2();
glPopMatrix();
// Make the it swing back or forth depending upon direction
if (direction == 1)
angle++;
else
angle--;
// Change the direction if 40 or -40 is reached
if (angle == -40.0) {
direction = 1;
}
if (angle == 40.0) {
direction = 0;
glTranslatef(0,0,-50);
drawBar();
glRotatef(rotate,60,0,0);
glPushMatrix();
glTranslatef(2,0,0);
glRotatef(rotate,1,0,0);
glTranslatef(0,-12,0);
drawRope();
glTranslatef(5,0,0);
// glRotatef(rotate,1,0,0);
drawSeat();
glTranslatef(0,12,0);
drawRope2();
glPopMatrix();
// Make the it swing back or forth depending upon direction
if (direction == 1)
angle++;
else
angle--;
// Change the direction if 40 or -40 is reached
if (angle == -40.0) {
direction = 1;
}
if (angle == 40.0) {
direction = 0;