// André Luiz Gomide Papa - ra002793
// Árvore - 23/11/2004

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

camera {
  location  < 100, 60, 10 >  // 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.
} 
// 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.
} 

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

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

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

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

#declare copa1 = 
	sphere{<0,-1.5,0>,1 texture{tinta_C}}

#declare copa2 =
	sphere{<0,1.5,0>,1 texture{tinta_C}}

#declare tronco = 
	cylinder{<0,0,0>,<0,0,-6>,0.5 texture{tinta_A}}

#declare arv = 
	union{object{copa1}
		object{copa2}
		object{tronco}
	}

#macro arvore(n)
	#if(n=1)
		object{arv}
	#end
	#if(n > 1)
		union{
			object{arv translate<0,1.5*n-1.5,6*n-6> rotate 15*y}
			object{arv translate<0,1.5*n-1.5,6*n-6> rotate -15*y}
			object{arv translate<0,-1.5*n+1.5,6*n-6> rotate -15*y}
			object{arv translate<0,-1.5*n+1.5,6*n-6> rotate 15*y}			
		}
	
	arvore(n-1)
	#end
#end

arvore(9)