// Last edited on 2003-05-31 11:44:12 by stolfi
// Universidade Estadual de Campinas
// Instituto de Computação
// Aluno: Ricardo Capitanio Martins da Silva
// RA: 992386    Disciplina: MC930A
// Professor: Stolfi
// Trabalho Prático 08

#include "colors.inc"
#include "textures.inc"  

background{ color rgb < 1.00, 1.00, 1.00 > }  

#declare ctr = <0,-12,0>;

camera {
  location ctr + 1.0 * < 20, -14, 7 >
  right 1.2*x  up 0.9*y
  sky z
  look_at ctr
}

light_source { 100*<  25,  -5, 30> color 1.2*White }
light_source { 100*<   0, -40, 10> color 0.8*White } 
light_source { 100*< -12,  20, 50> color 0.5*White } 

// Eixos de coordenadas
#declare eixoX = 
  cylinder {
    10*< -3, 0, 0 >,
    10*< 3, 0, 0 >,
    0.01
    texture {pigment{Red}}
  }

#declare eixoY = 
  cylinder {
    10*< 0,-3, 0 >,
    10*< 0, 3, 0 >,
    0.01
    texture { pigment{Blue} }
  }

#declare eixoZ = 
  cylinder {
    10*< 0, 0, -3 >,
    10*< 0, 0, 3 >,
    0.01
    texture {pigment{Green}}
  }


#declare corpo_metalico =
  texture 
  {
    pigment { Brown }
    finish { Metallic_Finish reflection .09}
  }


#declare amarelo_transp = 
  texture
  {
    pigment { Yellow filter 1}
    finish
    {
      ambient 0.1 diffuse 0.1
      reflection 0.35
      specular 1 roughness 0.001
    }
  }

#declare vermelho_transp = 
  texture
  {
    pigment { Red filter 1}
    finish
    {
      ambient 0.1 diffuse 0.1
      reflection 0.35
      specular 1 roughness 0.001
    }
  }

#declare cristal =
 texture
  {
    pigment {White filter 1}
    finish
    {
      ambient 0.1 diffuse 0.1
      reflection 0.35
      specular 1 roughness 0.001
    }
  }

#declare espelho_laranja =
  texture
  {
    pigment {Orange}
    finish 
    {
      ambient 0.05 diffuse 0.05
      reflection Orange
      specular 0.2 roughness 0.05
    } 
  }


declare chao = 
   plane 
   { 
     z, -4.0
     pigment { checker color White, color Gray }
   }
	

declare prisma =
 prism {
    linear_sweep
    linear_spline
    0,
    0.2,
    5, 
    <0,1>, <0.5, 0>, <0,-1>, <-0.5,0>, <0,1> 
    texture{amarelo_transp}
  }

declare chave =
  object{prisma rotate -x*90}

declare corpo =
lathe {
    linear_spline
    11,
    <0,10>, <1,7>, <1,3.0>, <2,1>, <1,-1>, <1,-5>, <2,-7>, <1, -9>, <1, -13>, <3, -17>, <3, - 23>
    texture{corpo_metalico}
    finish {
      ambient .3
      phong .75
    }
  }


object{chao}
union 
{ 

#declare posY = 5.5;
#while (posY > -10.6)   
  object{chave translate<0, posY,-2.15>}
  #declare posY = posY - 4;
#end
  
  object{corpo}

  //somente para mostrar os eixos cartesianos
  //object{eixoX}     // eixo X (Red)
  //object{eixoY}     // eixo Y (Blue)
  //object{eixoZ}     // eixo Z (Green)
  scale <1,1,-1>
}