// Last edited on 2005-01-06 00:20:18 by stolfi
// Processed by remove-cam-lights

#include "colors.inc"
#include "math.inc"

background{ color rgb < 0.75, 0.80, 0.85 > }

#declare raio = 2.000;

#declare tinta_cinza =
  texture {
    pigment { color rgb < 0.85, 0.85, 0.85 > }
    finish { diffuse 0.8 specular 0.2 roughness 0.05 ambient 0.1 }
  }

#declare Glass =
  texture {
    pigment { White filter 1 }
    finish {
 diffuse 0.25
 specular 0.2
 roughness 0.001
 ambient 0.1
 reflection 0.25
 }
  }

#declare DarkGlass =
  texture {
    pigment { White filter 0.5 }
    finish {
 diffuse 0.25
 specular 0.2
 roughness 0.001
 ambient 0.1
 reflection 0.25
 }
  }
#declare vertice =
  texture {
    pigment { color rgbf < 0.40, 0.40, 0.80, 0.1 > }
    finish { diffuse 0.8 specular 0.2 roughness 0.005 ambient 0.1 }
  }

#declare aresta =
  texture {
    pigment { color rgbf < 0.40, 0.80, 0.40, 0.1 > }
    finish { diffuse 0.8 specular 0.2 roughness 0.005 ambient 0.1 }
  }

#declare gerador = seed(9999);

#macro Arvore(n,filhos,px,py,pz,min_delta,max_delta)
 union {
  sphere {
 <px,py,pz>, 0.5
 texture { vertice } }
  #local i=0;
  #while (i<filhos & n>1)
   #local k = 2/tand(min_delta)*2/filhos;

   #local delta = min_delta + (max_delta/(filhos-1))*i;

   #local nx = px + 2/tand(delta);
   #local ny = py + 0;
   #local nz = pz + 2;

   cylinder {
 <px,py,pz>,
 <nx,ny,nz>,
 0.1
 texture { aresta }
   }

   #local n_min_delta = atan2d((k-0.5),2);
   Arvore(n-1,filhos,nx,ny,nz,n_min_delta, 180 - 2*n_min_delta)
   #declare i=i+1;
  #end
 }
#end

 Arvore(6,3,0,0,0,30,120)

#include "camlight.inc"
camlight(<0,0,20>,<0,-50,0>,1.00,z,1.0)