DUE Monday February 16 at 11:59pm
You are to write a program to produce a a Menger sponge as shown below:
Like the Sierpinski tetrahedron in our example in class,
this is a 3-dimensional fractal, defined recursively. Unlike the
tetrahedron, where you think of the recursion as a subdivision of each
edge of an original tetrahedron to form smaller tetrahedra, the
sponge is probably best defined by recursively replacing each cube of
side length s with an arrangement of cubes of side length
s/3 such that the original cube's volume is nearly filled by
the smaller cubes, omitting the center cube of each face and the
center cube of the entire volume.
You must allow the level of recursion to be varied as in the gasket program. You should also start with this program for a Sierpinski gasket. You should change the view from the orthographic view used in this program to a perspective view. You can use a similar coloring of faces as used in this program for your cube.
You must make it possible for the user to control the drawing with a mouse-based interface and menu-based system. The recursion level along with the viewing position and any extra credit options must be controlled via mouse/menu. Here is some example source code that uses openGL and glut for a variety of functions including mouse-based control. No particular interface for the viewing position changes is required in this assignment, but you should be able to move the camera position and orientation sufficiently to be able to look at the cube from any arbitrary angle.
Oh, and be careful not to allow a user to specify a large number of recursion levels. To see why, tell me how many cubes would be required at level 5 and at level 10.
For extra credit, try one or more of these: