// Exemplo de arquivo de descricao de cena para POV-ray
// Last edited on 2003-09-04 15:25:26 by stolfi

// ======================================================================
// CÂMERA 

camera {
  location  <40, 100, 24>  // Posição do observador.
  right     -0.75*x                // Largura RELATIVA da imagem.
  up        1.00*y                 // Altura RELATIVA da imagem.      
  sky       z                      // Qual direção é "para cima"?
  look_at   <  0.00, 0.00, 0.00 >  // Para onde a câmera está apontando.
//  look_at   <  0.00, 8.00, 0.00 >  // Para onde a câmera está apontando.
} 
// Nota: os parâmetros "right" e "up" devem ter a mesma proporção
// que os parâmetros ${WIDTH} e ${HEIGHT} no Makefile.

// ======================================================================
// FONTES DE LUZ

light_source {
  10 * < +50.0, +30.0, +50.0 >              // Posição da lâmpada.
  color rgb 1.2 * < 1.00, 1.00, 1.00 >   // Intensidade e corda luz.
} 

light_source {
  10 * < +50.0, -10.0, +10.0 >             // Posição da lâmpada.
  color rgb 0.8 * < 1.00, 1.00, 1.00 >   // Intensidade e corda luz.
} 

//light_source {
//  10 * < -50.0, -10.0, +10.0 >             // Posição da lâmpada.
//  color rgb 0.8 * < 1.00, 1.00, 1.00 >   // Intensidade e corda luz.
//}

// ======================================================================
// DESCRIÇÃO DA CENA 

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

#declare raio = 2.000;


#declare cor_Amarela = <1, 0.8, 0.1>;

#declare tinta_Azul = 
  texture {
    pigment { color rgb < 0.00, 0.00, 1.00 > }
    finish { diffuse 0.5 specular 0.5 roughness 0.005 ambient 0.1 }
  }

#declare tinta_Verde = 
  texture {
    pigment { color rgb < 0.00, 1.00, 1.00 > }
    finish { diffuse 0.5 specular 0.5 roughness 0.005 ambient 0.1 }
  }

#declare tinta_Vermelha = 
  texture {
    pigment { color rgb < 1.00, 0.00, 0.00 > }
    finish { diffuse 0.5 specular 0.5 roughness 0.005 ambient 0.1 }
  }

//plane { z,0
//  texture{
//    pigment { color rgb < 0.60, 0.30, 0.10 > }
//    finish { ambient 0.1 diffuse 0.9 }
//    scale 5
//  }  
//}

#declare galho = cylinder{<0,0,0>,<0,0,8>,1 texture{tinta_Vermelha}}

#declare folha = sphere{<0,0,0>,3 texture{tinta_Verde}}

#declare G=seed(99999);

#macro SubArvore(n,posX,posY,posZ)
  union{
    #if (n=1)      
      object {folha translate <posX,posY,posZ>}
    #else
      object {folha translate <posX,posY,posZ>}
      #if (rand(G)>0.5)
        object {galho rotate 45*y translate <posX,posY,posZ>}
        object {galho rotate -45*y translate <posX,posY,posZ>}   
        #local posX1 = posX + 8*sin(45);
        #local posY1 = posY;
        #local posZ1 = posZ + 8*sin(45);
        #local posX2 = posX - 8*sin(45);
        #local posY2 = posY;
        #local posZ2 = posZ + 8*sin(45);
      #else
        object {galho rotate 45*x translate <posX,posY,posZ>}
        object {galho rotate -45*x translate <posX,posY,posZ>}   
        #local posX1 = posX;
        #local posY1 = posY + 8*sin(45);
        #local posZ1 = posZ + 8*sin(45);
        #local posX2 = posX;
        #local posY2 = posY - 8*sin(45);
        #local posZ2 = posZ + 8*sin(45);
      #end

      object {SubArvore((n-1),posX1,posY1,posZ1)}
      object {SubArvore((n-1),posX2,posY2,posZ2)}
    #end
  }
#end

object{SubArvore(4,0,0,0)}