95.402 Fall 2001 Assignment #1


Due: Tuesday, September 18, 2001 (1 week) in the assignment box, before midnight


Familiarize yourself with the existing game builder, game engine, and worldcraft editor and add facilities for the following:

1. Extend the builder to output a ".wrl" file (wrl is short for world) in the format of your own choosing. It can already read in Worldcraft files (".map" files) giving you the information in a manner that is easy to manipulate. Before you do that however, you should

a) Extend the World object to contain a collection of texture names. To find out what these are, cycle through the faces in the objects. If a face has a texture name that is NOT in the collection,add it. Output this list of texture names before you output the objects in your world.

2. Extend the game engine to read a ".wrl" files and place the information in a World object which the game can tick and draw. The world object should keep track of everything you need including the textures that are used. Issues that you will have to deal with include the following:
a) In the world object, create a collection of textures (NOT texture names) to keep track of all the known textures for that world. As you read a texture name in, create a texture with that name. There are methods for doing this already). Once you have them all, load them into the graphics card. Then, when you read in a face, use the texture name to find the appropriate texture for that face (MANY MANY faces will share the same texture object). When you delete a world, you will have to unload the textures from the graphics card (to make room for the next world that you might load in).

b) Add code in the World's draw method for cycling through all the faces, activating the texture, and drawing all the game points (the existing World method pretends to draw a face's game points). Don't do this with dozens of loops within loops. Instead, be object-oriented; i.e., make the world ask its objects to draw themselves, which should ask their faces to draw themselves, which cycles through the game points to draw the polygons...

c) Add code in main that permits the camera to be translated and rotated. To make it easier for others to play your game, we'll use the following classwide convention:

a. The UP and DOWN arrow keys mean move FORWARD and BACKWARD (a good default).
b. If CTL is down, the UP and DOWN arrow keys mean move UP and DOWN.
c. If ALT is down, the UP and DOWN arrow keys mean look UP and DOWN; i.e. rotate.
d. The LEFT and RIGHT arrow keys mean rotate LEFT and RIGHT (a good default).
e. If CTL is down, the LEFT and RIGHT arrow keys mean move LEFT and RIGHT (straffing).
f. If ALT is down, the LEFT and RIGHT arrow keys mean rotate counter-clockwise and clockwise.

Of course, you may wire up any other hot keys you like.

3. Build two half-life maps: (a) one with at least two rooms (not necessarily rectangular) with a passageway between them and (b) a more sophisticated map with a courtyard (perhaps bounded by a wall) inside of which there are at least 2 houses (or a castle with multiple entrances).

4. (Part of 2c above) We are now using a new version of "glut" which supports the following (this will make movement in your game much smoother). The idea is to disable auto repeating and deal with the fact that when a key goes down, you remember it in a boolean. When the key goes up, you change the boolean.

a. KeyboardUpFunc and SpecialUpFunc (just like KeyboardDownFunc and SpecialDownFunc in the code).
b. glutEnterGameMode () and glutLeaveGameMode () gives you full screen capability.
c. IgnoreKeyRepeat (true or false)
d. You can determine the state of special modifiers without using Microsoft specific code.

long key = gluGetModifiers ();
bool shiftIsDown = key & GLUT_ACTIVE_SHIFT;
bool controlIsDown = key & GLUT_ACTIVE_CTRL;
bool alternatetIsDown = key & GLUT_ACTIVE_ALT;