/* ......Micquie Bradford's Object for the Object Library...... Function: Draws a table fan whose blades can rotate. The color of the base of the fan can be chosen by the user. mbradforDrawFan takes only 2 parameters, the base color (in the form of a twTriple), and the initial rotation angle of the fan blades (in the form of a GLfloat). */ static twTriple bladeColor = {75/255.0,75/255.0,75/255.0}; static twTriple cageColor = {30/255.0,30/255.0,30/255.0}; static twTriple blade[5] = { {1,4.5,-1}, {6,6,-6}, {9,6,-1}, {1,4.5,0} }; static void drawCage(){ glPushMatrix();//draw cage glTranslatef(0,6,0); glRotatef(90,1,0,0); glutWireTorus(0.05,10,50,50); for (int i=1; i<=4; i++){ glPushMatrix(); glRotatef(i*40,0,0,1); glRotatef(90,1,0,0); glScalef(1,0.3,1); glutWireTorus(0.05,10,50,50); glPopMatrix(); } glPopMatrix(); } static void drawBlades(){ glPushMatrix(); for (int i=1;i<=4;i++){//draw blades glRotatef(90,0,1,0); glBegin(GL_POLYGON); { glVertex3fv(blade[0]); glVertex3fv(blade[1]); glVertex3fv(blade[2]); glVertex3fv(blade[3]); } glEnd(); } glPopMatrix(); } void mbradforDrawFan(twTriple fanColor,GLfloat rotA){ glPushMatrix();//initial push twColor(fanColor,0,0.2);//draw base glPushMatrix(); glTranslatef(10,5,-10); glRotatef(90,1,0,0); twTube(8,8,1,30,30);//very bottom of base glTranslatef(0,0,-1);//upper base level twTube(7,7,1,30,30); glTranslatef(0,0,-10);//standing part of base twTube(2,6,10,30,30); glTranslatef(0,0,-2); glPushMatrix();//isolate scale of sphere glScalef(0.8,1,0.8); glutSolidSphere(4,20,20); glPopMatrix(); glPushMatrix();//isolate positioning of fan head glTranslatef(0,4,0); glRotatef(90,0,1,0); glRotatef(90,1,0,0); twTube(2,3,4,30,30); glTranslatef(0,0,-0.8); twColor(cageColor,0.3,0.6); twTube(1,1,0.8,30,30); glPopMatrix(); drawCage(); twColor(bladeColor,3,2); glRotatef(rotA,0,1,0); drawBlades(); glPopMatrix();//pop from origin in progress glPopMatrix();//final pop twError();}