// Exemplo de arquivo de descricao de cena para POV-ray
// Last edited on 2010-03-04 15:44:01 by stolfi





// ======================================================================
// CORES E TEXTURAS
#include "textures.inc" 

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

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

#declare tx_fosca = 
  texture{
    pigment{ color rgb < 1.00, 0.80, 0.10 > }
    finish{ diffuse 0.9 ambient 0.1 }
  }

#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.02 ambient 0.02 specular 0.25 roughness 0.005 }
  }


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

#declare arquibancada = 
  texture{
    pigment{ color rgb < 0, 1, 1.00 > }
    finish{ diffuse 0.8 ambient 0.1 specular 0.5 roughness 0.005 }
  }
  
#declare tx_escada = 
  texture{
    pigment{ color rgb < 1.00, 0.80, 0.10 > }
    finish{ diffuse 0.9 ambient 0.1 }
  }

#declare tx_pele =
  texture{
    pigment{ color rgb < 1.00, 0.721, 0.513 > }
    finish{ diffuse 0.9 ambient 0.1 }
  }

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

#declare tx_camisa_2 =
  texture{
    pigment{ checker color rgb < 0, 0, 0 >, color rgb < 1, 1, 1 > }
    finish{ diffuse 0.9 ambient 0.1 }
    scale 0.15
  }


#declare tx_junta = 
  texture{
    pigment{ color rgb < 1.00, 0.00, 0.00 > }
    finish{ diffuse 0.9 ambient 0.1 }
  }
  
#declare tx_verde = 
  texture{
    pigment{ color rgb < 0, 1, 0 > }
    finish{ diffuse 0.8 ambient 0.1 specular 0.5 roughness 0.005 }
  }

#declare tx_chao = 
		texture {
		  pigment { color rgb < 0.30, 0.80, 0.20 > }
		  finish { diffuse 0.5 specular 0.5 roughness 0.005 ambient 0.1 }
		}  
// ======================================================================
// DESCRIÇÃO DA CENA 


// Partes da cena:




#declare chao = 
  box{
		  < 50, 50, -10>,
		  < -50, -50, -11 >
		  texture{tx_chao}
		}


#declare chassi =
	
	union {
	
			box{<2,-2,0,> , <-2,2,1>
	
			texture{tx_verde}
	
		}	
		
		
		sphere { 
		
			<0,0,2> , 1.5
			texture {tx_fosca}	
		
		}
		
		cylinder{ 
			
			<3, 0, 0.5>,
			<-3, 0, 0.5>,
			0.5
			texture {tx_plastico}
		}
	
	
		sphere { 
		
			<3,0,0.5> , 0.5
			texture {tx_plastico}	
		
		}
		
		sphere { 
		
			<-3,0,0.5> , 0.5
			texture {tx_plastico}	
		
		}
	}
	
	
#macro pe()
	union{
		cylinder{
			<0, 0, 0>,
			<0, +2, 0>
			0.5
			texture {tx_pele}
		}
		
		
		sphere{ 
			<0,2,0> 
			0.5
			texture {tx_pele}
			
		}
		
		sphere{ 
			<0,0,0> 
			0.5
			texture {tx_verde}
			
		}
			
	}
#end			 	


#macro anteperna (gama)
	union{
		
		cylinder{
			<0, 0, 0>,
			<0, 0, -5>
			0.5
			texture {tx_pele}
		}
		
		sphere{ 
			<0,0,0> 
			0.5
			texture {tx_verde}
			
		}
			
		object{pe() rotate gama*x translate -5*z}
	
	}
#end	
	

#macro perna (teta, gama)
	union{
		
		cylinder{
			<0, 0, 0>,
			<0, 5, 0>
			0.5
			texture {tx_pele}
		}
		
		sphere{ 
			<0,0,0> 
			0.5
			texture {tx_junta}
			
		}
			
		object{anteperna(gama) rotate teta*x translate 5*y}
	
	}
#end

#macro corpo (alfa ,teta, gama)
	union{
		object{chassi translate <0, 0, -0.5>}
		
		
			
		object{perna(teta, gama) rotate (-1)*alfa*x translate 3*x}
		object{perna(teta, gama) rotate (-1)*alfa*x translate -3*x}
	}
#end

#macro interpola (ta, va, tb, vb, tt)
  
  #local s= (tt-ta)/(tb-ta);
  ((1-s)*va+s*vb)

#end



#declare gama0   = 0;
#declare gama1  = 60;
#declare gama2  = 0;
#declare gama3  = 0;
#declare gama4  = 0;

#declare teta0   = 60;
#declare teta1   = -40;
#declare teta2   = 40;
#declare teta3   = 60;
#declare teta4   = 60;


#declare alfa0    = 70;
#declare alfa1    = 10;
#declare alfa2    = 70;
#declare alfa3    = 70;
#declare alfa4    = 70;


#declare altura0 = 0;
#declare altura1 = -5;
#declare altura2 = 0;
#declare altura3 = 15;
#declare altura4 = 0;



background{ color rgb < 1, 1, 1 > }


#declare fase0 = 0.000;
#declare fase1 = 0.500;
#declare fase2 = 1.000;


#macro armacao(fase)

#if ((fase >= fase0) & (fase <= fase1))
  
  #declare gama   = interpola (fase0, gama0, fase1, gama1, fase);
  #declare teta   = interpola (fase0, teta0, fase1, teta1, fase);
  #declare alfa   = interpola (fase0, alfa0, fase1, alfa1, fase);
  #declare altura = interpola (fase0, altura0, fase1, altura1, fase);
  object{corpo(alfa, teta, gama) translate <0,0,altura>} 

#end

#if ((fase > fase1) & (fase <= fase2))
  
  #declare gama   = interpola (fase1, gama1, fase2, gama2, fase);
  #declare teta   = interpola (fase1, teta1, fase2, teta2, fase);
  #declare alfa   = interpola (fase1, alfa1, fase2, alfa2, fase);
  #declare altura = interpola (fase1, altura1, fase2, altura2, fase);
  object{corpo(alfa, teta, gama) translate <0,0,altura>}

#end

#end

#macro voo(h,fase)

#if ((fase >= fase0) & (fase <= fase1))
  
  #declare gama   = interpola (fase0, gama2, fase1, gama3, fase);
  #declare teta   = interpola (fase0, teta2, fase1, teta3, fase);
  #declare alfa   = interpola (fase0, alfa2, fase1, alfa3, fase);
  #declare altura = interpola (fase0, 0, fase1, h, fase);
  object{corpo(alfa, teta, gama) translate <0,0,altura>} 

#end

#if ((fase > fase1) & (fase <= fase2))
  
  #declare gama   = interpola (fase1, gama3, fase2, gama4, fase);
  #declare teta   = interpola (fase1, teta3, fase2, teta4, fase);
  #declare alfa   = interpola (fase1, alfa3, fase2, alfa4, fase);
  #declare altura = interpola (fase1, h, fase2, 0, fase);
  object{corpo(alfa, teta, gama) translate <0,0,altura>}

#end

#end

#macro armacao_geral(p, fase)
	
	object{ armacao(fase) 
		translate p
	}
#end

#macro voo_geral(p, q, h, fase)
	#declare r = interpola(0, p, 1, q, fase);
	
	object{	voo(h, fase)
		translate r
	}
#end

#declare t0 = 0.000;
#declare t1 = 0.250;
#declare t2 = 0.500;
#declare t3 = 0.750;
#declare t4 = 1.000; 


// Aqui está a cena, finalmente:
#macro quadro(tt)

union {

	#if ((tt >= t0) & (tt <= t1))
		#local fase = interpola (t0, 0, t1, 1, tt);
		
		object{armacao_geral(<0,0,0> , fase)}
	#end
	
	#if ((tt > t1) & (tt <= t2))
		#local fase = interpola (t1, 0, t2, 1, tt);
		
		object{voo_geral(<0,0,0>, <0,10,0>, 10, fase)}
	#end
	
	#if ((tt > t2) & (tt <= t3))
		#local fase = interpola (t2, 0, t3, 1, tt);
		
		object{armacao_geral(<0,10,0> , fase)}
	#end
	
	#if ((tt > t3) & (tt <= t4))
		#local fase = interpola (t3, 0, t4, 1, tt);
		
		object{voo_geral(<0,10,0>, <0,0,0>, 10, fase)}
	#end

object {chao}
}

#end
#include "eixos.inc"




#include "eixos.inc"
#include "camlight.inc"
#declare centro_cena = < 3.00, 2.00, 0.00 >;
#declare raio_cena =  20; //40.0;
#declare dir_camera =  <6 ,0, 0>;  //< 30, 12, 25.00 >;
#declare dist_camera =  20;  //40.0;
#declare intens_luz = 1.50;
camlight(centro_cena, raio_cena, dir_camera, dist_camera , z, intens_luz)



quadro(clock)