Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Counters for the index of the vertex in the fan vertices and quad vertices arrays respectively.
- int f = 1, q = 0;
- // The first vertex for the triangle fan is at the origin.
- fanPoints[0][0] = 0.0;
- fanPoints[0][1] = 0.0;
- fanPoints[0][2] = 0.0;
- /**
- * Produce the vertices for the triangle fans and the quads.
- * Using parametric circle equations to determine the co-ordinates of a vertex.
- */
- for (i = 0; i <= SEGMENTS; i++) {
- // Calculate the sine and cosine of the angle between the line connecting the vertex to the origin and the X-axis.
- angle = i * (((float) PI * 2.0) / (float) SEGMENTS);
- sine = (GLfloat) sin(angle);
- cosine = (GLfloat) cos(angle);
- fanPoints[f++][0] = 1.0 * cosine;
- fanPoints[f++][1] = 0.0;
- fanPoints[f++][2] = 1.0 * sine;
- quadsPoints[q++][0] = 1.0 * cosine;
- quadsPoints[q++][1] = 0.0;
- quadsPoints[q++][2] = 1.0 * sine;
- quadsPoints[q++][0] = 2.0 * cosine;
- quadsPoints[q++][1] = 0.0;
- quadsPoints[q++][2] = 2.0 * sine;
- }
- glNewList(dish, GL_COMPILE);
- // Draw the quad strips.
- glBegin(GL_QUAD_STRIP);
- // All the vertices of the quad strips are coloured the same.
- glColor3f(0.1, 0.7, 0.2);
- glVertex3f(quadsPoints[0][0], quadsPoints[0][1], quadsPoints[0][2]);
- glEnd();
- glEndList();
Add Comment
Please, Sign In to add comment