/* Feito por Andre Cesarino, RA 041939.*/

#include "eixos.inc"
#include "camlight.inc"
#declare centro_cena = < 5.00, 0.00, +20.00 >;
#declare raio_cena = 30.0;
#declare dir_camera = < 1.00, 7.00, 5.00 >;
#declare dist_camera = 100.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.50, 0.50, 0.50 > }

#declare vermelho_fosco = texture
{
  pigment{ color rgb <1.00, 0.00, 0.00>}
  finish { diffuse 1 specular 0.2 }
}

#declare verde_fosco = texture
{
  pigment{ color rgb <0.00, 0.70, 0.00>}
  finish { diffuse 1 specular 0.2 }
}

#declare verde_escuro = texture
{
  pigment{ color rgb <0.00, 0.30, 0.00>}
  finish { diffuse 1 specular 0.2 }
}

#declare azul_fosco = texture
{
  pigment{ color rgb <0.00, 0.00, 1.00>}
  finish { diffuse 1 specular 0.2 }
}

#declare branco_fosco = texture
{
  pigment{ color rgb <1.00, 1.00, 1.00>}
  finish { diffuse 1 specular 0.2 }
}

#declare cinza_fosco = texture
{
  pigment{ color rgb <0.40, 0.40, 0.40>}
  finish { diffuse 1 specular 0.2 }
}

#declare marrom_fosco = texture
{
  pigment{ color rgb <0.60, 0.30, 0.20>}
  finish { diffuse 1 specular 0.2 }
}

#declare amarelo_fosco = texture
{
  pigment{ color rgb <1.00, 1.00, 0.00>}
  finish { diffuse 1 specular 0.2 }
}

#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_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 }
  }

/* DESCRICAO DA CENA */

#declare chao = 
  box{ <-100,-100,-1>, <+100,+100,0>}

#macro arvore (inicio, raio, num_galhos, angulo)
  
  #local fim = <0,0,raio*12>;
  
  #if (num_galhos = 0)
    union
    {
      box{<-0.7,-0.05,0>,  <0.7,0.05,2>  texture {verde_escuro} rotate -20*y}
      box{<-0.7,-0.05,0>,  <0.7,0.05,2>  texture {verde_escuro} rotate  20*y}
      translate inicio
    }
  #else
  
  union
  {
    cylinder
    {<0,0,0>, fim, raio texture {marrom_fosco}}

    object {arvore (fim - <raio/3,0,0>,2*raio/3,num_galhos-1,angulo-15)}
    object {arvore (fim + <raio/3,0,0>,2*raio/3,num_galhos-1,angulo+15)}
    rotate angulo*y
    translate inicio
  }
  
  #end
#end


/*Aqui comeca a cena. */
union
{
  object{ eixos(3.00) }

  object{ chao  translate < 0,0,-5> texture{verde_fosco} }

  object{ arvore (<0,0,0>,1,5,0)}

  /*
  object {robo_movel (30) translate <-1,0,0> }
  
  object {robo_movel (60) translate <0,-3,0> }

  object {robo_movel (90) translate <+1,-6,0> }
  */
}

/*
#macro robo_movel (giro)
  union
  {
    
    box{ <-2,-1,-1>, <+2,+1,+7> texture {cinza_fosco}}

   
    box{ <-1,-0.5,7>,<1,0.5,8> texture {cinza_fosco}}

  
    intersection
    {
      box{ <-1,-0.5,7>,<1,0.6,8> texture {branco_fosco}}
      box{ <-0.8, 0.5,7.5>,<0.8,0.6,7.7> texture {branco_fosco}}
    }


   

  cylinder{<2,0,6>,<6,0,6>,0.25  texture {cinza_fosco}}
    
    difference
    {
      difference
      {
	cylinder{<7,-0.5, 6>,< 7, 0.5, 6>,1.00  texture{ cinza_fosco }}
	cylinder{<7,-0.65,6>,<7,0.65,6>,0.90 texture{ cinza_fosco }}
      }
      box{ <6,-1,5>,<8,1,6> texture{ cinza_fosco }}
      translate <-7,0,-6>
      rotate -giro*y
      translate <7,0,6>
    }  
    
    
    difference
    {
      difference
      {
	cylinder{<7,-0.5, 6>,< 7, 0.5, 6>,1.00  texture{ cinza_fosco }}
	cylinder{<7,-0.65,6>,<7,0.65,6>,0.90 texture{ cinza_fosco }}
      }
      box{ <6,-1,6>,<8,1,7> texture{ cinza_fosco }}
      translate <-7,0,-6>
      rotate  giro*y
      translate <7,0,6>
    }
    torus { 1,0.3 rotate -90*x translate< +8.5,0,+6 > texture {marrom_fosco}}
  }
#end
*/