// Last edited on 2003-11-27 01:35:44 by stolfi
#include "colors.inc"
#include "textures.inc"

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

#declare ctr = < 0.00, 0.00, 0.00 >;
#declare camDir = < 0.00, 0.00, 52.00 >;

camera {
  location   ctr + 1.00*camDir
  right      1.60*x
  up         1.20*y
  sky        y
  look_at    ctr
}
 

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

light_source {
  10 * < -10.0, 8.0, 10.0 >              // Posição da lâmpada.
  color rgb 1.8 * < 1.00, 1.00, 1.00 >   // Intensidade e corda luz.
} 

light_source {
  10 * < 20.0, 10.0, 0.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 SkyBlue }
#declare raio = 2.000;

// textura do céu
  sky_sphere {
    pigment {
      gradient y
      color_map {
        [0.000 0.002 color rgb <1.0, 0.2, 0.0>
                     color rgb <1.0, 0.2, 0.0>]
        [0.002 0.200 color rgb <0.8, 0.1, 0.0>
                     color rgb <0.2, 0.2, 0.3>]
      }
      scale 2
      translate -1
    }
    pigment {
      bozo
      turbulence 0.65
      octaves 6
      omega 0.7
      lambda 2
      color_map {
          [0.0 0.1 color rgb <0.85, 0.85, 0.85>
                   color rgb <0.75, 0.75, 0.75>]
          [0.1 0.5 color rgb <0.75, 0.75, 0.75>
                   color rgbt <1, 1, 1, 1>]
          [0.5 1.0 color rgbt <1, 1, 1, 1>
                   color rgbt <1, 1, 1, 1>]
      }
      scale <0.2, 0.5, 0.2>
    }
    rotate -135*x
  }
  
#declare tx_cristal =
  texture {
    pigment{color White filter 1}
    finish {
      specular 1
      roughness 0.001
      ambient 0.1
      diffuse 0.1
      reflection 0.25      
    }
  }     
  
#declare tx_espelho =
  texture {
    pigment { color Gray20 }
    finish {
      specular 0.20
      roughness 0.05
      ambient 0.05
      diffuse 0.05
      reflection Gray20
    }
  }     

#declare tx_gold =
  texture {
    pigment { color Gold }
    finish {
      specular 0.20
      roughness 0.55
      ambient 0.05
      diffuse 0.05
      reflection Gold
    }
  }   

#declare logotipo =
  text {
    ttf "comic.ttf"
    "FORMULA 0"
    0.5, 0
    pigment{color Red}
    translate<-2.8,-0.4,0>
    scale<1.1,2,1>
    #if(clock < 0.25)
      rotate<180*clock,0,0>
    #else
      #if(clock<0.75)
        rotate<45-180*(clock-0.25),0,0>
      #else
        rotate<-45+180*(clock-0.75),0,0>
      #end
    #end
  }  
     
#declare anel =
  torus{13, 1
    texture{tx_espelho}
    finish{phong 1}
    rotate<90+clock*180,0,0>
    translate<0,0,1>
  }

      
#declare chao =
  plane {
    y,
    -15
    //texture{tx_espelho}
    pigment { Gray40 }
    finish{ambient 0.7 diffuse 0.7}
    
  } 

#declare bola =
  sphere{<0,0,0> 3
    pigment{DMFWood4}
    rotate<0,0,clock*1440>
    #if (clock < 0.5)
      translate <-40+clock*80,-49*clock*clock,20>
    #else
      translate <-40+clock*80,-49*(1-clock)*(1-clock),20>
    #end    
  }

#declare rolo =
    cylinder{
      <0,0,-2.5><0,0,2.5>,2
      pigment{checker color Black color White}
      finish{phong 1}
      rotate<0,0,-clock*1440>
      translate <12*clock-15,-13,17.5>
      
    }

#declare armadilha =
  lathe {
    bezier_spline
    4,
    <8,-15>, <1,-5>, <10,0>, <1, 5>
    texture { tx_gold }
    translate<0,40-40*clock,20>
    
  }    

#declare chegada =  
   prism {
    cubic_spline
    0, // sweep the following shape from here ...
    1, // ... up through here
    16, // the number of points making up the shape ...
    < 10, -8>,
    < -10, -8>, //primeiro ponto
    < -10,  8>, 
    < 10,  8 >,
    < 10, 8>, 
    < 10, -8>, 
    < -10, -8>,//ultimo ponto = primeiro
    <-10, 8>,
    <8, -6>
    < -8, -6>,  //primeiro ponto
    < -8,  6>, 
    < 8,  6>,
    <8, 6>, 
    < 8, -6>, 
    < -8, -6>, // ultimo ponto
    < -8, 6>
    texture { tx_espelho }
    rotate<0,0,-90>
    translate<18,-6,18>
  }
              
// exibiçao  
union{
  object{anel}
  object{logotipo scale <4,4,4>}
  object{bola}
  object{rolo}
  object{chao}
  object{armadilha}
  object{chegada}
  
}