INT32GP Graphics Programming: Tutorial #16
GLU Quadrics and Hierarchical Modelling

B1.11 3:00 pm Tue 17 Sep 02
B1.11 12 midday Wed 18 Sep 02

Start with dancer0.c. This program is a shell in which nothing is currently rendered. It has been set up with the following facilities. Use GLU quadrics objects to create a hierarchical model of a dancer - sphere for head, cylinder for body.

Render a green wireframe cylinder (base radius 1.0, top radius 0.25, length 1.7). Render a magenta sphere (radius 0.45) for the head. Move the head towards the top of the cylinder. Stand the dancer up.
  1. Globally declare a quadrics object.
    /* manage model */
    GLUquadricObj * wireTool;
  2. Create and delete wireTool in display().
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    wireTool=gluNewQuadric();
    gluQuadricDrawStyle(wireTool,GLU_LINE);
    renderView();
    glFlush();
    gluDeleteQuadric(wireTool);
  3. Render the body. It would be better programming style to use variable names for the gluCylinder function parameters.
    void renderDancer(){
       glColor3fv(colour[green]);
       gluCylinder(wireTool,1.0,0.25,1.7,9,2);
    }
    void renderView(){
       renderDancer();
    }
  4. Observe how the smaller top radius is facing towards the camera down the positive z-axis. The larger base radius is centred around the origin.
  5. Try toggling perspective projection on and off and changing the field of view.
  6. Render the head in magenta (radius 0.45). It will be rendered around the origin.
    glColor3fv(colour[magenta]);
    gluSphere(wireTool,0.45,15,15);
  7. Use a translation to move the head to the top of the body.
  8. Stand the dancer upright. Which axis do we have to rotate around?
  9. Use the special function arrow and page up and down keys to translate the dancer along the x, y, and z-axes.
  10. Rotate the dancer around the y-axis in response to the y key.
  11. Rotate the head independent of the body. You may need to push and pop a matrix for this to work.
Fran Soddell email:F.Soddell@bendigo.latrobe.edu.au
last updated 17 September 2002