Menger Sponge

This is something I cooked up a few weeks ago.

I start by making a 27X27X27 cube made up of 1X1X1 cubes. I then detect which cubes need to go away. I collect these cubes into an ArrayList and move them according to random vectors. This essentially "scoops out" these cubes, leaving the next iteration of the sponge. My method is iterative and will theoretically work for many, many iterations. Unfortunately, I am limited to 3 iterations. I would be able to accomplish 4 if i could generate a 87X87X87 cube. But jme crashes when I go above 27X27X27. I understand a custom trimesh would grant me many more iterations at much greater efficiency, but I don't want to go that way.

Enjoy, and criticism is welcome :)
1 Like

Very Nice!

Cool! What kind of error are you getting with 87X87X87 cube btw?

1 Like

No specific error comes up, but jme stops adding cubes to the node and initialization never finishes. I think it may have something to do with the fact that 81X81X81 is 531,441. Thats a lot of cubes to keep track of. lol.