/* Scene for POVRay Short Code Contest, Round 4 * Copyright 2006 Mike Kost * mike@tashcorp.net * http://povray.tashcorp.net */ #macro p(s,c,d) #local b=s/2; // Uses less space than having several s/2's laying around #if(d=0) difference{ box{1,y-1} plane{x-y,-.1} plane{-x-y,-.1} plane{z-y,-.1} plane{-z-y,-.1} translate c-y finish{reflection{1 .4}} } #else p(b,c+y*b,d-1) p(b,c+(x-z)*b,d-1) p(b,c+(y-1)*b,d-1) #end #end p(4,8*z,5) sky_sphere { pigment{agate} } /* Original recursive macro : #macro p(s,c,d) #local b=s/2; #if(d=0) difference{ box{1,-1+y} plane{x-y,-.7} plane{-x-y,-.7} plane{z-y,-.7} plane{-z-y,-.7} scale s translate c finish{reflection {1 .4}} } #else p(b,c+y*b,d-1) p(b,c+(x-z)*b,d-1) p(b,c+(-x-z)*b,d-1) p(b,c+(x+z)*b,d-1) p(b,c+(-x+z)*b,d-1) #end #end In reality, the scale s does not need to be there since we can pre-calculate the final triagle size to get close using 1-2 characters. Assuming initial s = 4: D ... S ... Plane values 0 4 4*.7 = 2.8 1 2 2*.7 = 1.4 2 1 1*.7 = 0.7 3 0.5 0.5*0.7 = 0.35 4 0.25 0.25*0.7 = 0.175 ~ 0.2 5 0.125 0.125*0.7 = 0.0875 ~ 0.1 */