/* Sierpinski Triangle in 3D by Anders Haglund. At n iterations 5^n pyramids (6*5^n triangles) are generated. I could only test up to 7 iterations before running out of memory... At 7 iterations 78125 pyramids are generated wich are made up by 468750 triangles. It took about 4 minues to parse on my p2-266 with 64mb running under Windows 98 (with lots of shit running in the background). I forgot the rendering time but it wasn't too high. Should be rendered with radiosity. */ #include "colors.inc" #include "stones1.inc" camera { location <2,2,-5> look_at <0,0,0> } // I have very little knowledge about radiosity... global_settings { radiosity { brightness 0.5 count 20 nearest_count 8 gray_threshold 0.3 error_bound 0.3 minimum_reuse 0.01 distance_maximum 5 low_error_factor 0.6 } } light_source { <40,30,-30> color rgb 1 } light_source { <-30,40,-40> color rgb 1 } // The params are: position of top corner of pyramid, size (height) of pyramid, // current recursion and maximum recursion. #macro pyramid(pos,size,rec,maxrec) #local halfsize = size / 2; #if (rec >= maxrec) triangle { pos,pos+< halfsize,-size, halfsize>,pos+<-halfsize,-size, halfsize> } triangle { pos,pos+<-halfsize,-size, halfsize>,pos+<-halfsize,-size,-halfsize> } triangle { pos,pos+<-halfsize,-size,-halfsize>,pos+< halfsize,-size,-halfsize> } triangle { pos,pos+< halfsize,-size,-halfsize>,pos+< halfsize,-size, halfsize> } triangle { pos+< halfsize,-size, halfsize>,pos+<-halfsize,-size, halfsize>,pos+<-halfsize,-size,-halfsize> } triangle { pos+<-halfsize,-size,-halfsize>,pos+< halfsize,-size,-halfsize>,pos+< halfsize,-size, halfsize> } #else #local fourthsize = halfsize / 2; pyramid(pos,halfsize,rec+1,maxrec) pyramid(pos+< fourthsize,-halfsize, fourthsize>,halfsize,rec+1,maxrec) pyramid(pos+<-fourthsize,-halfsize, fourthsize>,halfsize,rec+1,maxrec) pyramid(pos+<-fourthsize,-halfsize,-fourthsize>,halfsize,rec+1,maxrec) pyramid(pos+< fourthsize,-halfsize,-fourthsize>,halfsize,rec+1,maxrec) #end #end mesh { pyramid(<0,2.5,0>,3.5,0,7) texture { T_Stone9 } finish { phong 0.2 } } // Way ugly... plane { y,-1 pigment { checker color rgb <0,0,0.4>,color rgb 1 } finish { diffuse 0.8 reflection 0.4 } normal { granite 0.005 scale 0.1 } }