#include <GL/glut.h> #include <stdlib.h> #include <math.h> // Define the kid's parameters const float HEAD_RADIUS = 0.5f; // The radius of the kid's head const float BODY_RADIUS = 0.3f; // The radius of the kid's body const float ARM_LENGTH = 0.2f; // The length of the kid's arms const float LEG_LENGTH = 0.3f; // The length of the kid's legs // Draw the kid's head void drawHead() { // Draw the head as a sphere glPushMatrix(); glTranslatef(0.0f, 0.0f, 0.0f); glutSolidSphere(HEAD_RADIUS, 10, 10); glPopMatrix(); // Draw the eyes glPushMatrix(); glTranslatef(0.1f, 0.1f, 0.0f); glColor3f(0.0f, 0.0f, 0.0f); glutSolidSphere(0.01f, 5, 5); glPopMatrix(); glPushMatrix(); glTranslatef(-0.1f, 0.1f, 0.0f); glColor3f(0.0f, 0.0f, 0.0f); glutSolidSphere(0.01f, 5, 5); glPopMatrix(); // Draw the mouth glPushMatrix(); glTranslatef(0.0f, -0.1f, 0.0f); glLineWidth(2.0f); glBegin(GL_LINES); glVertex3f(-0.05f, 0.0f, 0.0f); glVertex3f(0.05f, 0.0f, 0.0f); glEnd(); glPopMatrix(); } // Draw the kid's body void drawBody() { // Draw the body as a cylinder glPushMatrix(); glTranslatef(0.0f, -0.5f, 0.0f); glutSolidCylinder(BODY_RADIUS, 0.5f, 10, 10); glPopMatrix(); } // Draw the kid's arms void drawArms() { // Draw the left arm glPushMatrix(); glTranslatef(-0.2f, -0.25f, 0.0f); glRotatef(90.0f, 0.0f, 0.0f, 1.0f); glutSolidCylinder(0.05f, ARM_LENGTH, 10, 10); glPopMatrix(); // Draw the right arm glPushMatrix(); glTranslatef(0.2f, -0.25f, 0.0f); glRotatef(-90.0f, 0.0f, 0.0f, 1.0f); glutSolidCylinder(0.05f, ARM_LENGTH, 10, 10); glPopMatrix(); } // Draw the kid's legs void drawLegs() { // Draw the left leg glPushMatrix(); glTranslatef(-0.1f, -0.75f, 0.0f); glRotatef(90.0f, 1.0f, 0.0f, 0.0f); glutSolidCylinder(0.05f, LEG_LENGTH, 10, 10); glPopMatrix(); // Draw the right leg glPushMatrix(); glTranslatef(0.1f, -0.75f, 0.0f); glRotatef(-90.0f, 1.0f, 0.0f, 0.0f); glutSolidCylinder(0.05f, LEG_LENGTH, 10, 10); glPopMatrix(); } // Display function void display() { // Clear the screen glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Draw the kid