// TP04 - MC930
// Tabata Reis - RA 003384
// Last edited on 2003-11-26 05:59:49 by stolfi

#include "colors.inc"
#include "golds.inc"
#include "stones.inc"
#include "textures.inc"

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

#declare ctr = <  -2.00, 5.00, 0.00 >;
#declare camdir = <  8.00, 5.00, 20.00 >;

camera {
  location ctr + 0.85*camdir
  right    -1.00*x
  up       0.75*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 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.
} 



//----------------------------------------------
// Parâmetros da Animação

#if (clock < 0.6)
  #declare tp = (clock-0.0)/(0.6-0.0);
  #declare pos_carro = (1-tp)*8 + tp*(-5);
  #declare pos_letreiro = (1-tp)*(-32) + tp*(-10);
  #declare pos_formula = 50;
  #declare pos_torus = 50;
  #declare raio_torus = 0.5;
#else
  #declare tp = (clock-0.6)/(1.0-0.6);
  #declare pos_carro = -5;
  #declare pos_letreiro = 50;
  #declare pos_formula = -10;
  #declare pos_torus = 2;
  #declare raio_torus = (1-tp)*(0) + tp*(0.5);
#end

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


//----------------------------------------------
// Cores e Texturas

#declare dourado = 
  texture {
    T_Gold_4A
  }

#declare vermelho = 
  texture {
    pigment { Red }
    finish { diffuse 0.5 specular 0.5 roughness 0.005 ambient 0.1 }
  }

#declare preto = 
  texture {
    pigment { Black }
    finish { diffuse 0.5 specular 0.5 roughness 0.005 ambient 0.1 }
  }

//----------------------------------------------
// Objetos

#declare pneu = 
  torus {
    0.5,0.2 
    texture { preto }
  }

#declare corpo =
  difference{
    cone {
      < 0.00 ,0.00 ,0.00 >, 0.0
      < 5.00, 0.00, 0.00 >, 1.5
    }
    box {
      < 0.00, 0.00, -1.70 >
      < 5.20, -1.70, 1.70 >
    }
   texture { vermelho }
  }

#declare carro =
  union {
    object { corpo }
    object { pneu rotate -90*x translate<4.0,0,1.3> }
    object { pneu rotate -90*x translate<4.0,0,-1.3> }
    object { pneu rotate -90*x translate<2.0,0,0.8> }
    object { pneu rotate -90*x translate<2.0,0,-0.8> }
    rotate 50*y
  }

#declare zero =
  torus {
    1.0, raio_torus
    texture { dourado }
    rotate -90*x
    rotate 30*y
  }

#declare letreiro_p1 =
  text {
    ttf "alger.ttf"
    "Formula Zero"
    0.2, 0
    texture { dourado }
    rotate 30*y
    scale <2,2,2>
  }

#declare letreiro_p2 =
  text {
    ttf "alger.ttf"
    "Formula"
    0.2, 0
    texture { dourado }
    rotate 30*y
    scale <2,2,2>
  }


//----------------------------------------------
// Cena

object {
  carro
  translate<pos_carro,0,0>
}

object {
  letreiro_p1
  translate<pos_letreiro,7,0>
}

object {
  letreiro_p2
  translate<pos_formula,7,0>
}

object {
  zero
  translate<pos_torus,7.1,0>
}