// ======================================================================
// CORES E TEXTURAS

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

#declare tx_tronco = 
  texture{
    pigment{ color rgb < 0.92, 0.64, 0.51 > }
    finish{ diffuse 0.8 ambient 0.1 specular 0.5 roughness 0.005 }
  }
  
#declare tx_folha = 
  texture{
    pigment{ color rgb < 0.47, 0.79, 0.47 > }
    finish{ diffuse 0.8 ambient 0.1 specular 0.5 roughness 0.005 }
  }


// ======================================================================

// Partes da cena: 

#macro arvore (n, comp, raio)
  #if (n=0)
    // Escreve a folha de dinheiro
    object {
      box{ 
        < 0,0,0 >, 
        < 0.2,0.2,0.2 > 
      }
      translate < 0,0,0 >
      texture{ tx_folha }
    }
  #else
    // Escreve mais uma iteracao da arvore
    union{
      object { 
        cylinder{
          < 0, 0, 0 >,
          < 0, 0, comp >,
          raio
        }
        translate < 0,0,0 >
        texture{ tx_tronco }
      }
    
      object {arvore(n-1, comp*0.65, raio*0.8) rotate < 0,60,0 > translate < 0,0,comp >  }
      object {arvore(n-1, comp*0.65, raio*0.8) rotate < 0,300,0 > translate < 0,0,comp >  }
    }
    #end
#end


#include "eixos.inc"

// Aqui está a cena, finalmente:

union{
  object{ eixos(3.00) }
  object{ arvore(7, 2, 0.2 ) }
}

#include "camlight.inc"
#declare centro_cena = < 0.00, 0.00, 1.00 >;
#declare raio_cena = 6.5;
#declare dir_camera = < 14.00, 20.00, 4.00 >;
#declare dist_camera = 16.0;
#declare intens_luz = 1.00;
camlight(centro_cena, raio_cena, dir_camera, dist_camera , z, intens_luz)