// Lab. 3 - Romeu Ribeiro M. da Fonseca RA: 993236

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

camera {
  location 0.8 * < +15.00, +50.00, 15.00 >	    // Posição do observador.
  right     < -0.60, 0.00, 0.00 >           // Largura RELATIVA da imagem.
  up        < 0.00, 0.00, 0.80 >            // Altura RELATIVA da imagem.      
  sky       < 0.00, 0.00, 1.00 >            // Qual direção é "para cima"?
  look_at   < 0.00, 0.00, 10.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 * < 0.90, 1.00, 0.90 >   // 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 semente = seed(13);

#declare tinta_Azul = 
  texture {
    pigment { color rgb < 0, 0, 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, 0 > }
    finish { diffuse 0.5 specular 0.5 roughness 0.005 ambient 0.1 }
  }

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

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

#declare corpo = 
   cylinder {
	    < 10 , -10, -10 >,
	    < 0, 10, -5 >,
	    10
	    texture { tinta_Amarela }
    }	

#declare i = -4;
#while (i <= 3)
	#declare a = -90 + 180*rand(semente);
	#declare b = -90 + 180*rand(semente);
	#declare c = -90 + 180*rand(semente);
	#declare d = -90 + 180*rand(semente);

	#declare dedo =
	  cylinder {
	    < 0 , 0, 0 >,
	    < 1, 0, 0 >,
	    0.25
	    texture { tinta_Amarela }
	  }	

	#declare pata = union {
	  box {
	    < 0, 0, 0 >,
	    < 3, 2, 1 >
	    texture { tinta_Azul }
	  }
	  object { dedo
		   rotate d*x
	           translate <3, 1, 0.5>
	  }
	}

	#declare canela = union {
 	 cone {
  	  < 0, 0, 0 >, 0.75, < 0, 0, 6>, 0
  	  texture { tinta_Vermelha }
  	 } 
       	 object { pata
	 	  rotate c*y
	     	  translate < -1.5, -1, 6>
        	}
	 }

	#declare perna = union {
 	 cylinder {
  	  < 0 , 0, 0 >,
   	  < 0, 0, 8 >,
    	  0.75
    	 texture { tinta_Verde }
  	 }
  	object { canela
	   rotate b*x
	   translate < 0, 0, 8 >
  	  }
	} 		
	#declare i = i + 1;

	// Aqui está a cena, finalmente:
	object { perna rotate a*y translate <2*i, 3*i, 0 > }
#end
	// object { corpo }