//NOME: Plinio A. S. Freire  ra082505
// ============================================================================================
#include "eixos.inc"

//camera e luz 

#include "camlight.inc"
#declare centro_cena = < 0.00, 0.00, 1.00 >;
#declare raio_cena = 13.0;
#declare dir_camera = < 20, 1, 4.50 >;
#declare dist_camera = 16.0;
#declare intens_luz = 1.00;
camlight(centro_cena, raio_cena, dir_camera, dist_camera , z, intens_luz)


// cores e texturas

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

#declare tx_plastico = 
  texture{
    pigment{ color rgb < 0.10, 0.80, 1.00 > }
    finish{ diffuse 0.8 ambient 0.1 specular 0.5 roughness 0.005 }
  }

#declare tx_fosca = 
  texture{
    pigment{ color rgb < 1.00, 0.80, 0.10 > }
    finish{ diffuse 0.9 ambient 0.1 }
  }

#declare tx_espelho = 
  texture{
    pigment{ color rgb < 1.00, 0.85, 0.30 > }
    finish{ diffuse 0.2 reflection 0.7*< 1.00, 0.85, 0.30 > ambient 0.1 }
  }

#declare tx_vidro = 
  texture{
    pigment{ color rgb < 0.85, 0.95, 1.00 > filter 0.70 }
    finish{ diffuse 0.03 reflection 0.25 ambient 0.02 specular 0.25 roughness 0.005 }
  }


#declare tx_xadrez =
  texture{
    pigment{ checker color rgb < 0.10, 0.32, 0.60 >, color rgb < 1.00, 0.97, 0.90 > }
    finish{ diffuse 0.9 ambient 0.1 }
    scale 2.0
  }

#declare tx_red =
  texture{
    pigment{ color rgb <1, 0, 0 >}
    finish{ diffuse 0.9 ambient 0.1 }
}

#declare tx_green = 
  texture{
    pigment{ color rgb <0, 1, 0>}
    finish{ diffuse 0.9 ambient 0.1 }
}

#declare tx_blue = 
  texture{
    pigment{ color rgb <0, 0, 1>}
    finish{ diffuse 0.9 ambient 0.1 }
}

#declare tx_marrom =
  texture{
    pigment{ color rgb <0.8,0.6,0.3>}
}


//macro

#macro arvore(n,xi,yi,zi,xf,yf,zf,R,A) //xi,yi,zi: posicoes da base do galho (cilindro) xf,yf,zf: posicoes do topo do galho (cilindro)  R: raio do galho (cilindro) A: tamanho do galho


  #if(n=0) 
    union{
      cylinder{ <xi,yi,zi>, <xf,yf,zf>, R texture{tx_marrom}}
      box{<xf,yf,zf>, <xf,yf+0.5,zf+0.5> texture{tx_green}}
   }
  #else

    union{  
      cylinder{ <xi,yi,zi>, <xf,yf,zf>, R texture{tx_marrom}}
      object{arvore(n-1,xf,yf,zf,xf,yf-1.5*A,zf+1*A,R/2,A/2)  }
      object{arvore(n-1,xf,yf,zf,xf,yf,zf+1.5*A,R/2,A/2) }
      object{arvore(n-1,xf,yf,zf,xf,yf+1.5*A,zf+0.5*A,R/2,A/2) }
 
    }  

  #end
#end

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


union{

 // object{ eixos(3.00) }

  cone {<0,0,-4>, 1  <0,0,-2>, 0.3 texture{tx_marrom}}  
  object{arvore(3,0,0,-2,0,0,2,0.25,2)}

  
  

}