// Last edited on 2003-11-27 02:16:49 by stolfi
// Portão do Fórmula Zero - por Gilberto Sgarbi Filho - RA 001754
// Data: 25/09/2003
// ======================================================================

#declare ctr = <0, 0, 0>;
#declare camDir = < 30, 12, 12 >;

camera {
  location   ctr + 1.00*camDir
  right      0.80*x
  up         0.60*y
  sky        y
  look_at    ctr
}
 

// ======================================================================
// 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 cor da luz.
} 

light_source {
  10 * < +50.0, -10.0, +10.0 >             // Posição da lâmpada.
  color rgb 0.5 * < 1.00, 1.00, 1.00 >   // Intensidade e cor da luz.
} 

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

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

#declare raio = 0.5;

#declare preto =
  texture {
    pigment { color rgb < 0.00, 0.00, 0.00 > }
  }

#declare verde =
  texture {
    pigment { color rgb < 0.00, 1.00, 0.00 > }
  }

#declare amarelo =
  texture {
    pigment { color rgb < 1.00, 1.00, 0.00 > }
  }

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

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

#declare cor_cristal =  < 0.80, 0.80, 0.80 >;
#declare tx_cristal =
  texture {
    finish { 
    	ambient 0.1 diffuse 0.1 reflection 0.25
	specular 2.5 roughness 0.01 
    }
    pigment { color cor_cristal filter .7 }
  }

  
 
#declare predio = 
  cone {
    <-6, 6, 2>, 2,
    <-6, 2, 2>, 3
    texture { azul }
  }

  
#declare carro = 
  box {
    < 0, 0, 10 >,
    < 4, 1.5, 6 >
    texture { vermelho }
  }
   
#declare pneu =
   cylinder {
    < 0.5, 0.5, 9>,
    < 4.5, 0.5, 9 >,
    raio
    texture { preto }
   }
   
#declare comida = 
  box {
    < 0.5,  0, 8 >,
    < 3.5, 4, 11 >
    texture { verde }
  }
   
#declare chao =
  box {
    <-5, 0, -12>,
    <5, 0, 9>
    texture { checker texture {preto},
    		      texture {tx_cristal} }
  }

#declare portao =  
 difference{
  prism {
    0, 7, 		// Alturas do prisma (coordenadas y)
    4, <-4,0>, <-1,-4>, <1,-4>, <4,0>
    texture {amarelo}
  }

  lathe {		// Cilindro simples...
    4,  <0, 0>, <2, 0>, <2, 6>, <0, 6>
    texture {amarelo}
  }  
 }
    
// Cena:

#declare pA = <0,0,0>;		// Ponto de origem do carro
#declare pB = <-5,5,-3>;	// Ponto em que chega ao armazém
#declare pC = <0,0,-6>;		// Ponto na estrada
#declare pD = <0,0,-9>;	// Ponto de chegada (sertão...)


union {
  #declare tempo = (clock - 0.5) / (0.5 - 1.0);
  
  object { chao }

  #if (clock < 0.4)	// Vai em direção ao armazém...
    #declare pos = (1-tempo)*pB + tempo*pA;
  #else
    #if (clock <0.75)		// Continua o caminho, já com a comida...
      #declare pos = (1-tempo)*pC + tempo*pB;
    #else
      #declare pos = (1-tempo)*pD + tempo*pC;  
    #end
  #end
  
  object {pneu   translate pos  } 
  object {pneu rotate 180*y translate <5,0,16>
  	   	translate pos  } 
  object {carro  translate pos}
  
  #if (clock >= 0.2)
    object {predio}
  #end
  #if (clock >= 0.5)
    object {comida translate pos}
  #end
  #if (clock >=0.7)
      object {portao translate <0,0,-7>}
  #end
}