//创建整个雪人
void snowman(void){
//帽子
glTranslated(-.05, 0, 0);
glPushMatrix();
glColor3f(1, 1, 1);
glTranslated(0, .7, 0);
glutSolidSphere(.04, 40, 40);
glColor3f(1, 0, 0);
glTranslated(0, -.30, 0);
glRotated(-90, 1, 0, 0);
glutSolidCone(.1, .3, 40, 40);
glColor3f(1, 1, 1);
glTranslated(0, 0, -.015);
glutSolidTorus(.05, .07, 10, 10);
glPopMatrix();
//身体
glPushMatrix();
glColor3f(1, 1, 1);
glTranslated(0, .2, 0);
glutSolidSphere(.19, 40, 40);
glTranslated(0.0, -.45, 0);
glutSolidSphere(.3, 40, 40);
glTranslated(0.0, -.6, 0);
glutSolidSphere(.4, 40, 40);
glPopMatrix();
//眼睛
glPushMatrix();
glPushMatrix(); //脸
glTranslated(-.07, .3, .15);
glColor3f(0, 0, 0);
glutSolidSphere(.02, 40, 40);
glTranslated(.13, 0, 0);
glutSolidSphere(.02, 40, 40);
glColor3f(.8, .3, 0);
//鼻子
glTranslated(-.065, -.06, .028);
glutSolidCone(.03, .2, 40, 40);
//嘴
glColor3f(0, 0, 0);
glTranslated(-.06, -.08, 0);
glutSolidSphere(.014, 40, 40);
glTranslated(.03, -.015, 0);
glutSolidSphere(.014, 40, 40);
glTranslated(.03, -.001, 0);
glutSolidSphere(.014, 40, 40);
glTranslated(.03, .001, 0);
glutSolidSphere(.014, 40, 40);
glTranslated(.03, .015, 0);
glutSolidSphere(.014, 40, 40);
glPopMatrix(); //pop face objects
//身体
glColor3f(0, 0, 0);
glTranslated(.03, -.09, .26);
glutSolidSphere(.02, 40, 40);
glTranslated(0, -.09, .03);
glutSolidSphere(.02, 40, 40);
glTranslated(0, -.09, .01);
glutSolidSphere(.02, 40, 40);
glPopMatrix(); //pop features objects
//胳膊
glPushMatrix();
glColor3f(.388, .2, .0039);
GLUquadric* qobj = gluNewQuadric(); //创建圆柱体形状
glRotated(45, 0, 0, 1);
glRotated(90, 0, 1, 0);
glTranslated(-.04, -.3, 0);
gluCylinder(qobj, .02, .02, .3, 30, 30);
glRotated(-90, 1, 0, 0);
glTranslated(0, .3, .3);
gluCylinder(qobj, .02, .02, .3, 30, 30);
glPopMatrix();
}
代码存档