Void animate() {
// Update geometry
const double joint_rot_speed = 0.1;
double joint_rot_t = (sin(animation_frame * joint_rot_speed) + 1.0) / 2.0;
joint_rot_head = joint_rot_t * HEAD_MIN + (1 - joint_rot_t) * HEAD_MAX;
joint_rot_left_hand = joint_rot_t * LEFT_HAND_MIN + (1 - joint_rot_t) * LEFT_HAND_MAX;
joint_rot_right_hand = joint_rot_t * RIGHT_HAND_MAX + (1 - joint_rot_t) * RIGHT_HAND_MIN;
// Update user interface
glui->sync_live();
// Tell glut window to update itself. This will cause the display()
// callback to be called, which renders the object (once you've written
// the callback).
glutSetWindow(windowID);
glutPostRedisplay();
// increment the frame number.
animation_frame++;
// Wait 50 ms between frames (20 frames per second)
Sleep(50);
}
Void myReshape(int w, int h) {
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(-w / 2, w / 2, -h / 2, h / 2);
glViewport(0, 0, w, h);
Win[0] = w;
Win[1] = h;
}
Void display(void) {
glClearColor(0.7, 0.7, 0.9, 1.0);//цвет фона
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();//считывает текущую матрицу.
const float HEAD_SIZE = 120.0f;
const float BODY_SIZE = 130.0f;
const float BOTTOM_SIZE = 60.0f;
const float EYE_SIZE = 20.0f;
const float EYES_SIZE=13.0f;
const float EYESS_SIZE=6.0f;
const float NOSE_SIZE = 50.0f;
const float MOUTH_WIDTH = 100.0f;
const float MOUTH_HEIGHT = 2.0f;
const float HAT_SIZE = 40.0f;
const float HAND_WIDTH = 200.0f;
const float HAND_HEIGHT = 10.0f;
const float LEG_SIZE = 60.0f;
const float IROKEZ_SIZE = 40.0f;
glPushMatrix();
// Body rotation should be defined here if necessary
glTranslatef(joint_rot_head, 0.0, 0.0);
// draw the head, face, hat
glPushMatrix();
//Head rotation makes all its children rotate as well
glRotatef(joint_rot_head, 0.0, 0.0, 1.0);
glPushMatrix();
glTranslatef(0.0, 0, 0.0);
glScalef(HEAD_SIZE, HEAD_SIZE, 1.0);
glColor3f(1.0, 1.0, 0.0);
drawCircle();
glPopMatrix();
// Draw the face
// left eye
glPushMatrix();
glColor3f(1.0, 1.0, 1.0);
glTranslatef(-40, 70, 0.0);
glScalef(EYE_SIZE, EYE_SIZE, 1.0);
drawCircle();
glPopMatrix();
glPushMatrix();
glColor3f(0.0, 0.0, 1.0);
glTranslatef(-40, 70, 0.0);
glScalef(EYES_SIZE, EYES_SIZE, 1.0);
drawCircle();
glPopMatrix();
glPushMatrix();
glColor3f(0.0,0.0,0.0);
glTranslatef(-40, 70, 0.0);
glScalef(EYESS_SIZE, EYESS_SIZE, 1.0);
drawCircle();
glPopMatrix();
//Draw body
glPushMatrix();
glTranslatef(0, -170, 0.0);
glScalef(BODY_SIZE, BODY_SIZE, 1.0);
glColor3f(1.0, 1.0, 0.0);
drawCircle();
glPopMatrix();
glPushMatrix();
// right eye
glPushMatrix();
glColor3f(1.0, 1.0, 1.0);
glTranslatef(40, 70, 0.0);
glScalef(EYE_SIZE, EYE_SIZE, 1.0);
drawCircle();
glPopMatrix();
glPushMatrix();
glColor3f(0.0, 0.0, 1.0);
glTranslatef(40, 70, 0.0);
glScalef(EYES_SIZE, EYES_SIZE, 1.0);
drawCircle();
glPopMatrix();
glPushMatrix();
glColor3f(0.0,0.0,0.0);
glTranslatef(40, 70, 0.0);
glScalef(EYESS_SIZE, EYESS_SIZE, 1.0);
drawCircle();
glPopMatrix();
//nose
glPushMatrix();
glTranslatef(0.0, 0.0, 0.0);
glScalef(NOSE_SIZE, NOSE_SIZE, 1.0);
glColor3f(1.0, 0.7, 0.0);
drawCircle();
glPopMatrix();
//mouth
glPushMatrix();
glTranslatef(-50, 0.0, 0.0);
glScalef(MOUTH_WIDTH, MOUTH_HEIGHT, 1.0);
glColor3f(0.0,0.0,0.0);
glPopMatrix();
//ruki
glPushMatrix();
glTranslatef(0, 0, 0.0);
//glScalef(HAND_WIDTH, HAND_HEIGHT, 1.0);
glRotatef(joint_rot_right_hand, 0.0, 0.0, 1.0);
glBegin(GL_TRIANGLES);
glColor3f(1.0, 1.0, 0.0);
glVertex2f(-90, -80);
glVertex2f(-150, -180);
glVertex2f(-250, -170);
glEnd();
glPopMatrix();
glPushMatrix();
glTranslatef(0, 0, 0.0);
//glScalef(HAND_WIDTH, HAND_HEIGHT, 1.0);
glRotatef(joint_rot_left_hand, 0.0, 0.0, 1.0);
glBegin(GL_TRIANGLES);
glColor3f(1.0, 1.0, 0.0);
glVertex2f(90, -80);
glVertex2f(150, -180);
glVertex2f(250, -170);
glEnd();
glPopMatrix();
// Leg
glPushMatrix();
glBegin(GL_TRIANGLES);
glColor3f(1.0, 0.7, 0.0);
glVertex2f(-60, -280);
glVertex2f(-110, -330);
glVertex2f(-10, -330);
glEnd();
glBegin(GL_TRIANGLES);
glVertex2f(60, -280);
glVertex2f(110, -330);
glVertex2f(10, -330);
glEnd();
glScalef(LEG_SIZE, LEG_SIZE, 1.0);
glPopMatrix();
//irokez
glPushMatrix();
glBegin(GL_POLYGON);
glColor3f(1.0, 0.7, 0.0);
glVertex2f(-10, 120);
glVertex2f(-30, 160);
glVertex2f(-5, 140);
glVertex2f(0, 170);
glVertex2f(10, 140);
glVertex2f(30, 160);
glVertex2f(15, 120);
glScalef(IROKEZ_SIZE, IROKEZ_SIZE, 1.0);
glEnd();
glPopMatrix();
glPopMatrix();
glFlush();
glutSwapBuffers();
}
// Function that draws a circle of a given size
// at a given location
Здравствуйте! Подскажите как сделать чтобы у утенка правильно двигались крылья?
