// André Luiz Gomide Papa - ra002793
// Robô - 16/11/2004

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

camera {
  location  < 60, 20, 2 >  // Posição do observador.
  right     -1.00*x                // Largura RELATIVA da imagem.
  up        0.5*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_A1 = 
  texture {
    pigment { color rgb < 0.5, 0.5, 5 > }
    finish { diffuse 0.5 specular 0.5 roughness 0.005 ambient 0.1 }
  }

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

#declare T1 = 0.5;

#declare dedo1 = 
	cylinder{<-0.3,0,0>,<2.7,0,0>,0.3 texture{tinta_A}}

#declare dedo2 =
	cylinder{<-0.3,0,0>,<2.7,0,0>,0.3 texture{tinta_A}}

#declare mao =
	union{ 
		box{<-0.3,-1,-0.5>,<1.7,1,0.5> texture{tinta_B}}
		#if(clock < T1)	
			#declare teta = (-70/0.5)*clock; 
			object{dedo1 rotate teta*y translate <2,-0.7,0>}
			object{dedo2 rotate teta*y translate <2,0.7,0>}
		#else
			#declare teta = -70;
			object{dedo1 rotate teta*y translate <2,-0.7,0>}
			object{dedo2 rotate teta*y translate <2,0.7,0>}
		#end
	}

#declare antebraco =
	union{
		cylinder{<-0.3,0,0>,<7.7,0,0>,1 texture{tinta_C}}
		#if(clock < T1)
			#declare gama = (-90/0.5)*clock;
			object{mao rotate gama*x translate <8,0,0>}
		#else
			#declare gama = -90;
			object{mao rotate gama*x translate <8,0,0>}
		#end
}

#declare braco =
	union{
		cone{<-0.3,0,0>,2,<8.7,0,0>,1 texture{tinta_D}}
		#if(clock < T1)
			#declare beta = (5/0.5)*clock;
			object{antebraco rotate beta*z translate <9,0,0>}
		#else
			#declare beta = 5;
			object{antebraco rotate beta*z translate <9,0,0>}
		#end
	}

#declare braco1 =
	#if(clock < T1)
		#declare alfa = (15/0.5)*clock;
		object{braco rotate alfa*z}
	#else		
		#declare alfa1 = (15/0.5)*(clock - 0.5);
		#declare alfa = 15;
		object{braco rotate alfa*z rotate alfa1*-y}
	#end

#declare dois_bracos =
	union{
	object{braco1}
	object{braco1 translate <0,-20,0> scale <1,-1,1>}
	}

#declare corpo = box{<0,-2,-2>,<2,22,5>} 

#declare robo =
	union{
		object{corpo texture{tinta_D}}
		object{dois_bracos}
	}

#declare coisa = cylinder{<0,0,0>,<0,0,20>,2 texture{tinta_A}}

object{robo}

#if(clock <= T1)
	object{coisa translate <20.5,10,-10>}
#else
	object{coisa translate <20.5,10,-10> rotate 20*-y*clock}
#end

plane {z,0
	texture{
		pigment{ checker <0.5,0.2,0.1>, <0.3,0.3,0.3>}
		finish{ambient 0.2 diffuse 0.5}
		scale 2
		}
	translate <0,0,-20>
}