CS320      Lab6 - Room with a View

Objectives:

  1. Download and RoomView.java and try it out.  We have two views of the room display and you can move the viewer with the arrow keys.
     
  2. We will start with a look at how rooms are constructed.  A list of vertices are given for a generic wall.  The methods colorcube and polygon are used to draw the wall in the given color.  Take a look now are the method room.

    This method translates and rotates that single wall to build the room.  One way to view this is having a local coordinate system on the wall objects.  That local coordinate system is then changed with a series of translations and rotations.  This view of model translations, rather than having a single global coordinate system, allows the transformations and the code to appear in the same order.  (Remember with the global system the code appears in reverse order of the transformations).

    Consider the transformations necessary for constructing:

     

     

    when what you have to start with is the one block.

    Steps:

    load identity matrix;
    push matrix;
    move 4 left and render;
    move 8 right and render;
    pop matrix;
    push matrix;
    move 11 left, 5 down;
    
    // Repeat the following 4 times.
    render;
    move 10 up and render;
    move 6 right and 6 up;
    rotate -90 and render;  // Don't forget that we also rotated the
                             // local coordinate system!
    
    pop matrix;
    
    See room() for the real code. 
    
    Make sure that you understand why this works!
  3. The display method sets up two viewports.  In one there is an overhead orthographic project and in the second there is an immersed view with perspective projection.  Also note the gluLookAt call to position the camera.  Note that the viewer transformation occurs before the model transformations.
     
    Add viewer rotation and fix the left, right, forward and backward motion to work correctly

     


  4.  
    Add collision detection so we can't walk through walls.

     

  5. Email your completed Lab6 program to me.