#include "mymacros.inc" #version unofficial MegaPov 0.5; background{color rgb 1} light_source{<200, 200, 200> color rgb<1, 1, 1>} light_source{<-10, 8, 100> color rgb<1, 1, 1>} camera{location<0, 0, 50> sky<0, 0, 1> right<-4/3, 0, 0> angle 50 look_at<0, 0, 0>} #declare Rand01=seed(121); //X,Y,Z - initial sphere positions //R - initial radius //L - recursion level //Next - incrementer for sphere position while loop, higher the Next, longer the sphere_sweep #macro Tree_Root(XYZ,R,L,Next) #local Co=; sphere_sweep { linear_sphere_sweep, Next, #while(Next>0) XYZ,R #local R=R/1.05; #local X=rand(Rand01); #local Y=rand(Rand01); #local Z=rand(Rand01); #local XYZ=XYZ-; #local Next=Next-1; #end pigment{rgb Co} } #if(L>0) #local New_L = L-1; #local New_R=R; #local PX=XYZ.x; #local PY=XYZ.y; #local PZ=XYZ.z; #local New_R2=R; #local RX=XYZ.x; //This duplicate parameter block fixes the problem, #local RY=XYZ.y; //otherwise the second branch is reset. #local RZ=XYZ.z; union{ union{ Tree_Root(,New_R,New_L,10) translate - rotate 35/L*z translate } union{ Tree_Root(,New_R2,New_L,10) translate - rotate -35/L*z translate } } #end #end union{ Tree_Root(0,2,3,10) }