Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void drawSphere(float r, int lats, int longs) {
- int i, j;
- for(i = 0; i <= lats; i++) {
- float lat0 = PI * (-0.5 + (float) (i - 1) / lats);
- float z0 = sin(lat0);
- float zr0 = cos(lat0);
- float lat1 = PI * (-0.5 + (float) i / lats);
- float z1 = sin(lat1);
- float zr1 = cos(lat1);
- glBegin(GL_QUAD_STRIP);
- Material(vert, 0.25, 0.5, 0.0, 1.0, 1.);
- for(j = 0; j <= longs; j++) {
- float lng = 2 * PI * (float) (j - 1) / longs;
- float x = cos(lng);
- float y = sin(lng);
- glNormal3f(x * zr0, y * zr0, z0);
- glVertex3f(x * zr0, y * zr0, z0);
- glNormal3f(x * zr1, y * zr1, z1);
- glVertex3f(x * zr1, y * zr1, z1);
- }
- glEnd();
- }
- }
- static void bolster(void){
- glPushMatrix();
- glScalef(1.,1.,3.);
- gl_Cylinder(40);
- glPopMatrix();
- glPushMatrix();
- glTranslatef(0.,0.,3.);
- drawSphere(1.,40,40);
- glPopMatrix();
- glPushMatrix();
- glTranslatef(0.,0.,-3);
- drawSphere(1.,40,40);
- glPopMatrix();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement