$30.00
Description
The Menger sponge is an important object in mathematics and the theory of fractals. The figures below show how it can be constructed.
1) Start with a layer of 9 cubes.
2) Remove the cube in the middle.
1
3) Create next layer of the sponge by adding 4 cubes in the corners, as shown.

Add the third layer, which has the same structure as the first layer shown in Step 2. If you wish, you may think if this object as a cube subdivided into 17 subcubes, 7 of which have been removed (one in the bottom layer, 5 in the middle, and 1 in the top layer.)
2
4’) Remove gaps between the cubes (actually, they were never needed for the construction, but were shown in Fgures 14 to clearly illustrate the arrangement). This is stage1 Menger sponge.

Now, arrange 20 stage1 Menger sponges in the same manner as the initial cubes have been arranged. This is stage2 sponge. If you prefer, you can also alternatively think of the stage2 sponge as resulting from the replacement of each cube in Figure 4 with a stage1 sponge.
3

Repeat Step 5 of the construction recursively a least one more time. Don’t go too far! The number of subcubes and their faces grows very fast (exponentially)!
4
6’) Again, gaps in Figure 6 have only been added for illustrative purposes. The actual Menger sponge does not have them.
5
Your assignment has two parts:

Write a program that generates and makes it possible to view the Menger sponge using the traditional Open GL. Use different colors (or shades of gray) to visualize faces with different orientations. Make it possible to explore the threedimensional structure of the sponge by rotating it and zooming in and out (using a mouse). Make it possible to change the depth of recursion and to choose between parallel and perspective projection using a menu. The program should properly redisplay the sponge after the window has been resized. The image should then be resized as well.

Bonus:


Keep the aspect ratio while resizing the window (1% of the final mark).

Implement shading as an optional alternative to rendering the sponge using differently colored faces. Use menu to select the type of rendering (fixedcolored faces vs. shading). (1% of the final mark)


Reimplement Part 1 using core OpenGL
6