// menger3.pov // Make memger's sponge using macro // $Id: menger3.pov,v 1.1 2004-03-27 22:25:02+09 msato Exp $ #include "colors.inc" #include "stones.inc" #include "shapes.inc" // *************************** // declare // *************************** #declare Length = 100; // unit length #declare MaxIter = 4; // number of iteration #declare Base_Cube = object { Cube scale Length } // define next cavity using macro // NextCavity_z(base_obj) // reduce the size of base_obj, then put it to 8 places #macro NextCavity_z(base_obj) #local mNextCavity = object { base_obj scale <1/3, 1/3, 1.1> }; object { merge { object { mNextCavity translate } object { mNextCavity translate } object { mNextCavity translate } object { mNextCavity translate <0, Length * 2/3, 0> } object { mNextCavity translate <0, -Length * 2/3, 0> } object { mNextCavity translate <-Length * 2/3, Length * 2/3, 0> } object { mNextCavity translate <-Length * 2/3, 0, 0> } object { mNextCavity translate <-Length * 2/3, -Length * 2/3, 0> } } } #end // NextCavity_all(base_obj) // rotate base_obj along x-axis and y-axis, and merge them #macro NextCavity_all(base_obj) object { merge { object { base_obj } object { base_obj rotate <90, 0, 0> } object { base_obj rotate <0, 90, 0> } } } #end // make all cavities #declare TotalCavity = object { Cube scale Length / 1000 }; // almost empty #declare Cavity_z = object { // 1 cavity Base_Cube scale <1/3, 1/3, 1.1> } #declare Num = 0; #while (Num < MaxIter) #declare TotalCavity = object { merge { object { TotalCavity } object { NextCavity_all(Cavity_z) } } } #declare Cavity_z = NextCavity_z(Cavity_z); #declare Num = Num + 1; #end // *************************** // camera // *************************** camera { location look_at <0, 0, 0> angle 20 } // *************************** // light // *************************** light_source { color White * 2 } light_source { color White * 0.8 } // *************************** // object // *************************** object { difference { object { Base_Cube } object { TotalCavity } } texture { T_Stone1 scale Length } } /* Local Variables: tab-width: 4 End: */