Objectives:
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!
Add viewer rotation and fix the left, right, forward and backward motion to work correctly |
Add collision detection so we can't walk through walls. |