// Last edited on 2004-03-13 20:21:02 by stolfi

// LAB-05  -- 25/Set/2003
// ANIMACOES!!

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

#declare ctr = < 0.00, 0.00, 0.00 >;
#declare camDir = < 5.00, 4.00, 1.50 >;

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

// Nota: os parâmetros "right" e "up" devem ter a mesma proporção
// que os parâmetros ${WIDTH} e ${HEIGHT} no Makefile.

// ======================================================================
// 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 {
  1 * < +3.0, +3.0, +1.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 rgb < 0.50, 0.50, 1.0 > }

#declare raio = 2.000;
#include "colors.inc"

// ======================================================================
// CORES USADAS
// ======================================================================
 
#declare bgcolor =
  texture {
    pigment { color rgb < 0.75, 0.80, 0.85 > }
    finish { diffuse 0.9 specular 0.5 roughness 0.005 ambient 0.1 }
  }

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

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

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

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

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

// ======================================================================
// Cristais e Espelhos
// ======================================================================

#declare cor_cristal =  < 0.70, 0.0, 0.0 >;
#declare tx_cristal =
  texture {
    finish { ambient 0.1 diffuse 0.1 reflection 0.25 specular 1.0 roughness 0.001 }
    pigment { color cor_cristal filter 1 }
  }


#declare cor_espelho = < 0.5, 0.5, 0.5 >;
#declare tx_espelho = 
  texture {
    pigment { rgb cor_espelho }
    finish { ambient 0.05 diffuse 0.05 reflection cor_espelho specular 0.20 roughness 0.05  }
  }



// ======================================================================
// FORMAS USADAS
// ======================================================================


#declare chao = 
  plane { <0, 0, 1>, -0.05
          texture {laranja}
	}


#declare grande =
  sphere {
    <0.00, 0.00, 0.00>, 30.00
    texture {branco}
    translate <0, 0, 4>
  }

#declare pequena =
  sphere {
    <0.00, 20.00, -15.00>, 15.00
    texture {branco}
    translate <0, 0, 4>
  }

#declare haste_base =
  difference { 
	object {pequena}
	object {grande}
	}  




#declare torre =
  cylinder {
	<0.00, 0.00, +0.00>,
	<0.00, 0.00, +35.0>,
	5.0
	texture {tx_cristal}
	}

#declare toro =
  torus { 20, 5
	 texture {tx_espelho}
	 rotate 90*x
	}

// ======================================================================
// LAB04 - Itens Especificos
// ======================================================================

#declare p1 = <  0, 0 ,0>;
#declare p2 = <-7, -0, 0>;
#declare p3 = <+10, +10, 0>;
#declare p4 = <  0,0,+10>;
#declare p5 = <  0,0,-10>;

#declare time1 = (clock - 0.0)/(0.2 - 0.0);
#declare time2 = (clock - 0.2)/(0.4 - 0.2);
#declare time3 = (clock - 0.4)/(0.6 - 0.4);
#declare time4 = (clock - 0.6)/(0.8 - 0.6);
#declare time5 = (clock - 0.8)/(1.0 - 0.8);

#declare Texto1 =
   text { ttf "ariblk"
	"Ajude voce tambem"
	0.10, 0
	texture {branco}
	}

#declare Texto2 =
   text { ttf "ariblk"
	"O FOME ZERO"
	0.10, 0
	texture {branco}
	}

#declare Texto3 =
   text { ttf "ariblk"
	"Venha para Interlagos"
	0.10, 0
	texture {azul}
	}

#declare Texto4 =
   text { ttf "ariblk"
	"10% da renda da corrida"
	0.10, 0
	texture {branco}
	}

#declare Texto5 =
   text { ttf "ariblk"
	"sera destinada ao programa"
	0.10, 0
	texture {branco}
	}

// ======================================================================
// LAB05 - Itens Especificos
// ======================================================================

#declare chassis = 
   box {
	<0, -1, 0.5>, < -2, 0, 0>
	texture { azul }
       }  


#declare coisa1 = 
   lathe {
	linear_spline
	4,
	<1,0>, <3,1>, <3,5>, <2,3>
	texture { cinza }
	finish {
		ambient .3
		phong .75
    		}
  	}


#declare carro = 
   union {
	object {coisa1 
		scale <0.1, 0.1, 0.1>
		translate <0,0,0.3>}

	object {coisa1 
		scale <0.1, 0.1, 0.1>
		rotate 180*z
		translate <0,-1,0.3>
		}

	object {coisa1 
		scale <0.1, 0.1, 0.1>
		translate <-2,0,0.3>}

	object {coisa1 
		scale <0.1, 0.1, 0.1>
		rotate 180*z
		translate <-2,-1,0.3>
		}

	object {chassis}
	}


#declare linha_chegada =
   box {
	<-0.5, -50, 0.05>, < -2.5, +50, 0>
	pigment { checker color White, color Black }
       }  

#declare texto_total = 
   union {
object {Texto1
	rotate 90*x
	rotate 140*z
	translate <7,0,5>
	scale .2}

object {Texto2
	rotate 90*x
	rotate 140*z
	translate <7,0,4>
	scale .2}

object {Texto3
	rotate 90*x
	rotate 140*z
	translate <7,0,3>
	scale .2}

object {Texto4
	rotate 90*x
	rotate 140*z
	translate <7,0,2>
	scale .2}

object {Texto5
	rotate 90*x
	rotate 140*z
	translate <7,0,1>
	scale .2}

   }



#declare portao =
prism {
    linear_sweep
    linear_spline
    0, // sweep the following shape from here ...
    0.4, // ... up through here
    8, // the number of points making up the shape ...
    <-3,0>, <-2, 1.5>, <2,1.5>, <3,0>,
    <2,0>, <1.5, 1>, <-1.5, 1>, <-2, 0>
    texture { tx_cristal }
  }




// ======================================================================
// CENA!
// ======================================================================

// object {chao}
//
// object {haste translate <0,-5,0> rotate -45*z}
// object {haste translate <0,-5,0> rotate +45*z}
// object {haste translate <0,-5,0> rotate -135*z}
// object {haste translate <0,-5,0> rotate +135*z}
// 
// object {torre translate <0,0,-10>}
//
// object {toro translate <0,0,-5>}

object {chao}

object {linha_chegada}

object {portao
	rotate 90*z
	translate <-1, -1, 0>}

object {carro
	translate p2 - time1*p2/4}


object {texto_total
	translate p1 + time1*p4/50}