I’m taking introduction to computer graphics this semester which focuses on OpenGL and our first project is due Monday. Conceptually speaking the project was supposed to be very easy as a similar project’s code was given to us, the Sierpinski Tetrahedron. The difference here is that the Menger Sponge removes central cubes from cubes.

I was agonizing over how I was going to do it for 3 days this week, then I had a breakthrough moment and spent the last 2 days working on it. This is the executable. There is a right click menu which shows allows different modes to be set as well as show you the keyboard shortcuts.

  • W, A, S, D, Q, E rotate the cube
  • F will swap between wireframe and solid cube mode
  • L will change the lighting. Useful in wireframe mode
  • V will display the inverse sponge.
  • 0-4 changes the level of iteration. I could have gone to 5 but time to render 5 iterations is about 10 seconds on my computer and on 4 iterations the rotation is very sluggish.
  • +/- Will scale the size of the cubes

If I really want to spend some extra time working on it, I’d like the change the lighting a bit and add mouse based rotation. The main function I used for drawing the cube doesn’t allow for texturing so I’d probably look into rewriting that entire function.

No source code in this zip, just the executable and the required DLL.

Download

UPDATE: Corrected the inversion function and discovered that you need Visual Studio installed or the executable might not run. I’ll post source at the end of the semester.

1 Iteration

1 Iteration

3 Iterations

3 Iterations

Inverse 1 Iteration

Inverse 1 Iteration

Inverse 2 Iterations

Inverse 2 Iterations

Inverse 3 Iterations

Inverse 3 Iterations