CAVEConfigure
and CAVEInit
.
Then, CAVEInitApplication
is called which calls my function, Make_Maze
, once before the looping processes begin.
The display loop is started with a call to CAVEDisplay
, which continuously calls my function, Display_Maze
.
The CAVE's event loop is started after this.
The event loop continues until the Escape key is pressed, which closes the application.
A call to CAVEExit
exits the CAVE.
For a detailed description of the CAVE, see the CAVE User's Guide.
Calculate_Maze_Array
.
The user is prompted to enter a number from 0 to 1000.
The number entered becomes the seed for the random number generator.
A different maze is generated for each number entered.
Entering the same number on another run will generate the same maze again.
An N by N array to represent squares in a grid is constructed and initialized to zero.
Each member of the array is conisdered a cell.
A parallel array to keep track of which cells have been visited is also initialized.
Four cells in the center of the array are initialized to 1 to form the seed for the percolation cluster.
A loop goes through all the members of the array, checking to see how many of each cell's perpendicular neighbors are set to 1.
If this sum is 1 or 2, then a random number is generated and if the number is less than the cutoff value, the cell is set to 1.
Otherwise, the cell is left as 0.
The cutoff value for the random number was very important.
If it was too low the maze would not grow out to the outside walls and if it was too high, the maze would have no walls.
The cutoff value is 21830.
In either case, the visited flag for that cell is set to 1.
Cells which have 3 or 4 neighbors that are 1 are left as 0 with the visited flag set to 1.
In this way, the cells that are set to 1 move out from the initial seed cells, until the entire array has been visited.
After the array is initialized, calls are made to configure and initialize the CAVE.
The function Make_Maze
is then called. It goes through the array and determines where the 0's are.
Then it determines if the cells perpendicularly adjacent to the cell are 1's or 0's.
A polygon is added to the display list for the maze at every position corresponding to a 1 adjacent to a 0.
Polygons for the floor, the ceiling, the starting position, and the outside walls (leaving a space for the exit) are also added to the display list.
The ceiling polygon is only drawn if the user types "y" or "Y" at the prompt at the start of the program.
Texture maps are applied to all surfaces and a normal vector is assigned to each polygon.
The floor of the starting area has a different texture than the rest of the floor.
The display loop of the CAVE calls Display_Maze
, which clears the buffers and calls the display list.
The display loop is continuously looping and drawing the polygons for the maze relative to where the user is located.
Makefile
compiles my main program, maze.c
with image.c
and generates the executable JulietMaze
.
Here is the code for my program, maze.c,
image.c, Makefile.
* The CAVE is an application created by the Electronic Visualization Laboratory, University of Illinois at Chicago.