glPushMatrix();
glRotatef(yRot, 0.0f, 1.0f, 0.0f);
glRotatef(xRot, 1.0f, 0.0f, 0.0f);
glLightfv(GL_LIGHT0,GL_POSITION,lightPos);
glLightfv(GL_LIGHT0,GL_SPOT_DIRECTION,spotDir);
//画一个光源
glColor3ub(255,0,0);
glTranslatef(lightPos[0],lightPos[1],lightPos[2]);
glutSolidCone(0.3f,0.3f,10,10);
glPushAttrib(GL_LIGHTING_BIT);
glDisable(GL_LIGHTING);
glColor3ub(255,255,0);
glutSolidSphere(0.1f,10.0f,10);
glPopAttrib();
glPopMatrix();
glTranslatef (0.0, -0.5, 0.0);
glColor3f(0.8,1.0,0.2);
glPushMatrix();
glScalef (0.5, 1.0, 0.5);
glutSolidCube(1.0);
glPopMatrix();
glTranslatef (0.0, -0.5, 0.0);//提起右小腿
glRotatef ((GLfloat) elbow, 1.0, 0.0, 0.0);
glTranslatef (0.0, -0.5, 0.0);
glColor3f(0.5,0.1,0.8);
glPushMatrix();
glScalef (0.5, 1.0, 0.5);
glutSolidCube(1.0);
glPopMatrix();
glTranslatef (0.0, -0.5, -0.1);//右脚
glColor3f(0.5,0.2,1.0);
glPushMatrix();
glScalef (0.5, 0.1, 0.7);
glutSolidCube(1.0);
glPopMatrix();
glPopMatrix ();
glPushMatrix();
glTranslatef (forward,0.0,z);
glRotatef ((GLfloat) turn, 0.0, 1.0, 0.0);
glTranslatef (-0.375, 0.0, 0.0);//左大腿
glRotatef ((GLfloat) shoulder1, 1.0, 0.0, 0.0);
glTranslatef (0.0, -0.5, 0.0);
glColor3f(0.8,1.0,0.2);
glPushMatrix();
glScalef (0.5, 1.0, 0.5);
glutSolidCube(1.0);
glPopMatrix();
glTranslatef (0.0, -0.5, 0.0);//左小腿
glRotatef ((GLfloat) elbow, 1.0, 0.0, 0.0);
glTranslatef (0.0, -0.5, 0.0);
glColor3f(0.5,0.1,0.8);
glPushMatrix();
glScalef (0.5, 1.0, 0.5);//缩放四方体
glutSolidCube(1.0);//画四方体
glPopMatrix();
glTranslatef (0.0, -0.5, -0.1);//左脚
glColor3f(0.5,0.2,1.0);
glPushMatrix();
glScalef (0.5, 0.1, 0.7);
glutSolidCube(1.0);
glPopMatrix();
glPopMatrix();
glPushMatrix();
glTranslatef (forward,0.0,z);
glRotatef ((GLfloat) turn, 0.0, 1.0, 0.0);
glTranslatef (0.0, 1.0, 0.0);//躯干
glColor3f(0.5,0.5,1.0);
glPushMatrix();
glScalef (1.4, 2.0, 0.5);
glutSolidCube(1.0);
glPopMatrix();
glTranslatef (0.0, 1.25, 0.0);//头
glColor3f(1.0,0.3,0.2);
glPushMatrix();
glScalef (0.5, 0.5, 0.5);
glutSolidCube(1.0);
glPopMatrix();
glPopMatrix();
glPushMatrix();
glTranslatef (forward,0.0,z);
glRotatef ((GLfloat) turn, 0.0, 1.0, 0.0);
glTranslatef (0.85, 1.75, 0.0);//右臂
glRotatef ((GLfloat) shoulder1, 1.0, 0.0, 0.0);
glTranslatef (0.0, -0.5, 0.0);
glColor3f(1.0,0.0,1.0);
glPushMatrix();
glScalef (0.3, 1.3, 0.4);
glutSolidCube(1.0);
glPopMatrix();
glPopMatrix();
glPushMatrix();
glTranslatef (forward,0.0,z);
glRotatef ((GLfloat) turn, 0.0, 1.0, 0.0);
glTranslatef (-0.85, 1.75, 0.0);//左臂
glRotatef ((GLfloat) shoulder2, 1.0, 0.0, 0.0);
glTranslatef (0.0, -0.5, 0.0);
glColor3f(1.0,0.0,1.0);
glPushMatrix();
glScalef (0.3, 1.3, 0.4);
glutSolidCube(1.0);
glPopMatrix();
glPopMatrix();