INT32GP Graphics Programming: Tutorial #19
Extrusions - Barn

B1.11 Indy Lab 3:00pm Mon 07 Oct 02
B1.11 Indy Lab 12midday Tues 08 Oct 02

Start with extrude1.c.
  1. Press d to toggle depth testing on and off.
  2. Press p to toggle between orthographic and perspective (the default) projection.
  3. Press f to zoom out by incrementing fovy.
  4. Press F to zoom in by decrementing fovy.
  5. This program uses the nGon algorithm to set up an array to hold the vertices of an nGon with 8 sides. Try changing the following definition so the nGon has the least number of sides possible and a number required for the nGon to become a circle.
    #define NGON_SIZE 8
  6. The nGon array is duplicated into another array. Examine the following code fragment and the code in the function initialise() to understand how this is done.
    #define NGON_SIZE 8
    vertexType nGon[NGON_SIZE];
    vertexType duplicate[NGON_SIZE];
  7. The extrusion creates all the side faces of the polygonal mesh. Notice that every side face has exactly four sides. This is typical of extrusions. By default I have rendered the sides as wire frames (GL_LINE_LOOP). Examine the code in extrude to understand how this is done.
  8. The following keys control how the side faces are rendered. Examine the code in keyboard and display to understand how I have done this.
  9. For each of these modes, observe what happens when you toggle depth testing.
  10. Two cameras have been set up. Toggle between them by pressing uppercase C.
Use an extrusion algorithm to set up a barn that looks like the following.
  1. Instead of using the nGon algorithm to set up the near face, hard code the values of the vertices into an array. I suggest you set them up around the origin.
  2. Duplicate the vertices to create the distant face and then extrude the sides as in the example program.
  3. Try rendering inside and as well as outside faces and use backface culling. You may like to try front face culling as well.
  4. Add a third camera in a place of your choice behind the object. Edit the keyboard facility to toggle between cameras to circle through the three.


Fran Soddell email:F.Soddell@bendigo.latrobe.edu.au
last updated 07 October 2002