// Last edited on 2003-12-09 15:15:47 by stolfi
// Animação
// Daniel Kalil Franulovic ra 001525

// ======================================================================

#if (clock < 0.6)
        #declare temp_cam = clock;
        #declare c_roda = 0;
#else
        #declare temp_cam = 0.6;
        #declare c_roda = clock;
#end

#if (clock < 0.55)
        #declare temp_car = clock;
#else
        #declare temp_car = 0.55;
#end

//declarar aqui as posicoes da camera, ira centralizar no carro quando ele parar e depois começara a rotacionar para cima, mostrando o logotipo

#if (clock < 0.3)
        #declare pos_cam = <10,-70,8>;
        #declare pos_look = <0,0,15>;
#end
#if ((clock > 0.3)&(clock < 0.6))
        #declare pos_cam = <45,-70,8>+<140*(temp_cam - 0.3),0,0>;
        #declare pos_look = <35,0,15>+<140*(temp_cam - 0.3),0,0>;
#end
#if (clock > 0.6)
        #declare pos_cam = <47,-70,8> + 40 * <cos(5*pi*(clock-0.6)),sin(5*pi*(clock-0.6)),1.5*(clock - 0.6)>; // A camera irá rotacionar

// e depois dar "zoom" no logotipo

        #declare pos_look = <77,0,15>;
#end

#declare ctr = pos_look;
#declare camDir = pos_cam - pos_look;

camera {
  location   ctr + 1.00*camDir
  right      1.00*x
  up         0.75*y
  sky        z
  look_at    ctr
}

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

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

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

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


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

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

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

 
#declare tinta_marrom = 
  texture {
    pigment { color rgb < 0.3, 0.2, 0.05 > }
    finish { diffuse 0.9 specular 0.5 roughness 0.05 ambient 0.1 }
  }


#declare cor_dourado = <0.9,0.9,0.1>;

#declare dourado = 
  texture {
    pigment {rgb cor_dourado}
    finish {
	ambient 0.05 diffuse 0.05
	reflection cor_dourado
	specular 0.20 roughness 0.05
	}
}

#declare cor_borracha = <0.1,0.1,0.1>;

#declare borracha = 
  texture {
    pigment {rgb cor_borracha}
    finish {
	ambient 0.05 diffuse 0.05
	reflection cor_borracha
	specular 0.10 roughness 0.2
	}
}

#declare cor_prata = <0.7,0.7,0.7>;

#declare prateado = 
  texture {
    pigment {rgb cor_prata}
    finish {
	ambient 0.05 diffuse 0.05
	reflection cor_prata
	specular 0.20 roughness 0.05
	}
}

#declare cor_cristal = <0.8,0.8,1>;

#declare tx_cristal = 
  texture {
    finish {
	ambient 0.1 diffuse 0.1
	reflection 0.1
	specular 1 roughness 0.001
	}
	pigment {color cor_cristal filter 1}
}

#declare chao = 
	plane { z,0
	texture {tinta_marrom}
}

#declare raio1 = 
	cylinder{
	<0,0,-2>
	<0,0,2>
	0.05
	texture{borracha}
	}
 
#declare raio2 = 
	cylinder{
	<-2,0,0>
	<2,0,0>
	0.05
	texture{borracha}
	}

#declare pneu = 
	object{ union {
			object {raio1}
			object {raio2}
			object {torus {
    					2,0.8	
				    	texture { borracha }
  					}
				}
			}
	rotate clock*3600*y
	}
#declare prato_fora = 
  cone  {
	<0,0,0>, 10
	<0,0,3>, 13
	texture {prateado}
}

#declare prato_dentro = 
  cone  {
	<0,0,1>, 8
	<0,0,4>, 10.4
	texture {prateado}
}

#declare slogan = 
	text {
	  ttf "comic.ttf"
	 "FOME ZERO"
	 0.1, 0
	texture {tinta_verde}
	scale 2
}

#declare prato = 
	union{
	     difference {
		object {prato_fora translate <0,0,10>}
		object {prato_dentro translate <0,0,10>}
		}
	     object {slogan translate<-5,0,11>}
}


#declare carro = 
	object { union{
			object {prato}
			object {pneu translate <-5,-2.6,7.6>}
			object {pneu translate <5,-2.6,7.6>}
			}
}

#declare carro_anda = 
	object { carro	translate <140*temp_car,0,-4.8> }

#declare poste = 

  lathe {
    linear_spline
    7,
    <0,0>, <1.5,3>, <1.5,12>, <0.5,15>,<1.5,18>, <1.5,27>, <0,30>
    texture{dourado}
    rotate<90,0,0>
  }


#declare faixa = 

  prism {
    linear_sweep
    linear_spline
    -15, // sweep the following shape from here ...
    15, // ... up through here
    6, // the number of points making up the shape ...
    <-3,0>, <3,0>, <1.5,2>, <0,1>, <-1.5, 2>, <-3,0>
    texture { dourado }
  }

#declare chegada = 
  union {
	object {poste translate<45,15,0>}
	object {poste translate<45,-15,0>}
	object {faixa translate<45,0,30>}
	}


// Aqui está a cena, finalmente:


//coluna
//parede_lateral

chao
carro_anda
chegada