CS 381  >  Week 9 Review Problems

CS 381, Fall 2003
Week 9 Review Problems

Below are some problems related to the material covered in class recently. Answers are in the Answers section, below. Do not turn these in. We may certainly discuss any of these problems in class, if you want.

You can expect Test 2 (on Friday, November 7) to contain problems similar to some of these.

Problems

Note: On the test you will be expected to do problems like these without books or notes.
  1. What steps need to be taken to add a display-affecting global variable to a GLUT program?
     
  2. How can we use OpenGL to conveniently set the value of a matrix variable? Either explain in a couple of sentences or give some sample code/pseudocode.
     
  3. We divided advanced viewing interfaces into two categories. For each category: name it, indicate its distinguishing characteristic(s), indicate how its being in this category affects the internal implementation, and give an example of an interface in the category.
     
  4. When indicating scene rotations via mouse motions, what line do we often what to rotate about?
     
  5. What problem often occurs in flying-style interfaces in which the user can only turn up, down, left, and right?
     
  6. Briefly explain how we can use projection techniques to draw a shadow.
     
  7. When we do shadowing via projection, where in the pipeline transformations should the shadow projection occur?
     
  8. List some problems or important issues with the projection-based shadowing technique discussed in class.
     
  9. In the example shadow-projection code I gave, the shadowing matrix is computed only once. Under what circumstances would the matrix need to be recomputed?
     
  10. For each of the following, if it can be done with a single glRotate* call, write out the call. If not, answer “impossible”. Do not worry about clockwise or counterclockwise.
    1. Rotate 30° about the x axis.
    2. Rotate 30° about the line through the points (0, 0, 0) and (1, 2, 3).
    3. Rotate 30° about the line through the points (1, 0, 0) and (1, 1, 0).
    4. Rotate 30° about the line through the points (1, 1, 1) and (–1, –1, –1). (Be careful!)

     

Answers

  1. To add a display-affecting global to a GLUT program:
  2. We can use the OpenGL matrix operations to set a matrix variable by The code would look something like this:
    glPushMatrix();
       Use transformation commands here.
       glGetDoublev(GL_MODELVIEW_MATRIX, my_matrix_variable);
    glPopMatrix();
    
  3. The two categories are “view the world” and “move in the world”.
    “View the world”: “Move in the world”:
  4. When indicating scene rotations with mouse motions, we often want to rotate about a line perpendicular to the mouse motion. So, if the mouse motion is expressed as the 2-D vector (xy), then we probably want to rotate about the line through the origin and the point (–yx, 0).
  5. When the user can only turn up, down, left, and right, the “up” direction often becomes rotated, resulting in a slanted view of the world. This can be fixed by allowing the user to roll.
  6. A shadow is just a projection of (the shape of) an object on another object. Thus, to draw a shadow, determine a matrix giving the required projection, draw the object once without this matrix (draws the object itself) and once with this matrix (draws the shadow). The shadow and the object should be colored or lit differently, in order to make the shadow look like a shadow.
  7. The shadow projection places an object (the shadow) in the scene. Thus it goes in the model/view transformation, after the viewing transformations. The shadow projection should also go before those transformations that place the object that is casting the shadow.
  8. Here are six issues:
  9. The shadowing matrix depends on the light position and the equation of the plane that the shadow falls on. It would thus need to be recomputed if either the light source or the plane moves.
    1. glRotated(30, 1,0,0);
    2. glRotated(30, 1,2,3);
    3. Impossible.
    4. glRotated(30, 1,1,1);
      (This line passes through the origin.)


CS 381, Fall 2003: Week 9 Review Problems / Last update: 6 Nov 2002 / Glenn G. Chappell / ffggc@uaf.edu