void drawBall() { glTranslatef(10.0f, 10.0f, 5.5f); glRotatef(ballRot, 0, 0, 1); glRotatef(20.0f, 1, 0, 0); glRotatef(180.0f, 0, 1, 0); glColor3f(1.0f, 0.0f, 0.0f); drawHemisphere(20, 20, 7, true); glColor3f(1.0f, 1.0f, 1.0f); drawHemisphere(20, 20, 7, false); glPushMatrix(); glColor3f(0.0, 0.0, 0.0); glRotatef(90.0f, 1.0, 0.0, 0.0); GLUquadricObj* ring = gluNewQuadric(); gluCylinder(ring, 7, 7, 1.5, 100, 10); gluDeleteQuadric(ring); glPopMatrix(); glPushMatrix(); glColor3f(0.0, 0.0, 0.0); glBegin(GL_POLYGON); for (int i = 0; i < 360; i++) { float angle = i * RADIAN; glVertex3f(cos(angle) * 3, sin(angle) * 3, 7.0f); } glEnd(); glPushMatrix(); glColor3f(1.0, 1.0, 1.0); glBegin(GL_POLYGON); for (int i = 0; i < 360; i++) { float angle = i * RADIAN; glVertex3f(cos(angle) * 2, sin(angle) * 2, 7.5f); } glEnd(); glPopMatrix(); glPopMatrix(); }
void setup() { // PARTS pipe = glGenLists(1); seat = glGenLists(1); cover = glGenLists(1); wheel = glGenLists(1); wheelCenter = glGenLists(1); cycles = glGenLists(1); glNewList(pipe, GL_COMPILE); // Any cylinder on the motorcycle GLUquadricObj *cylinder; cylinder=gluNewQuadric(); glPushMatrix(); glColor3f(0.0,0.0,1.0); gluCylinder(cylinder,0.2,0.2,3,5,5); glPushMatrix(); glPopMatrix(); glPopMatrix(); glEndList(); glNewList(seat, GL_COMPILE); glPushMatrix(); glColor3f(1.0, 0.3, 0.05); glutSolidCube(1);//size glPushMatrix(); glPopMatrix(); glPopMatrix(); glEndList(); glNewList(cover, GL_COMPILE); glPushMatrix(); glColor3f(1.0, 0.5, 0.5); drawHemisphere(); glPushMatrix(); glPopMatrix(); glPopMatrix(); glEndList(); glNewList(wheel, GL_COMPILE); glPushMatrix(); glColor3f(0.1, 0.1, 0.1); glutSolidTorus(0.2, 1.2, 20, 20);//doughnut glPushMatrix(); glPopMatrix(); glPopMatrix(); glEndList(); glNewList(wheelCenter, GL_COMPILE); glPushMatrix(); glColor3f(0.4, 0.5, 1.5); glScalef(1.0, 0.5, 1.0); glutSolidSphere(0.8, 5, 5); glPushMatrix(); glPopMatrix(); glPopMatrix(); glEndList(); glNewList(cycles, GL_COMPILE); glColor3f(0.5, 0.5, 0.5); glScalef(0.25, 0.25, 0.25); cylinder=gluNewQuadric(); gluCylinder(cylinder,0.5,0.5,5,15,5); glEndList(); }