// Last edited on 2005-01-05 22:55:43 by stolfi
// Processed by remove-cam-lights

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

#declare tinta_A =
  texture {
    pigment { color rgb < 0.00, 0.00, 0.80 > }
    finish { diffuse 0.8 specular 0.2 roughness 0.005 ambient 0.1 }
  }

#declare tinta_B =
  texture {
    pigment { color rgb < 0.50, 0.60, 0.70 > }
    finish { diffuse 0.8 specular 0.2 roughness 0.001 ambient 0.1  }
  }

#declare tinta_C =
  texture {
    pigment { color rgb < 0.90, 0.40, 0.00 > }
    finish { diffuse 0.8 specular 0.2 roughness 0.005 ambient 0.1 }
  }

#declare tinta_D =
  texture {
    pigment { color rgb < 1.00, 0.80, 0.25 > }
    finish { diffuse 0.8 specular 0.2 roughness 0.005 ambient 0.1 }
  }

#declare tx_amarelo =
  texture {
    pigment { color rgb < 1.00, 1.00, 0.00 > }
    finish { diffuse 0.8 specular 0.2 roughness 0.005 ambient 0.1 }
  }

#declare tinta_F =
  texture {
    pigment { color rgb < 0.80, 0.90, 0.80 > }
    finish { diffuse 0.8 specular 0.2 roughness 0.005 ambient 0.1 }
  }

#declare trilho_ext =
  torus {  15.00, 2.00
   rotate 90*x
          texture { tinta_F }
}

#declare trilho_int =
  torus {  15.00, 1.00
   rotate 90*x
          texture { tinta_F }
}

#declare corte1_trilho =
   box {
    <  17.00, -17.00, -0.15>
    < -17.00, 17.00,  -5.50>
    texture { tinta_F }
}

#declare corte2_trilho =
   box {
    <  17.00, -17.00, 0.35>
    < -17.00, 17.00,  5.50>
    texture { tinta_F }
}

#declare vagao1 =
  box {
    <  0.00, 0.00, 0.00 >
    <  5.00, 7.00, 3.00>
    texture { tinta_A }
}

#declare furo_interno =
  box {
    <  0.10, 0.10, 0.10 >
    <  4.90, 6.90, 2.90>
    texture { tinta_A }
}

#declare janela =
  box {
    < -0.50, 0.50, 1.50>
    <  5.50, 2.00, 2.50>
    texture { tinta_A }
}

#declare fileira_janela =
union{
    #declare i=0;
    #while (i<6)
       object { janela translate <0, i, 0> }
       #declare i = i + 2.25;
    #end
}

#declare roda_esq =
 cylinder {
   < 0.25, 0.75, -0.50>
   < 0.40, 0.75, -0.50>
   0.75
   texture {tinta_B}
}

#declare roda_dir =
 cylinder {
   < 3.75, 0.75, -0.50>
   < 4.00, 0.75, -0.50>
   0.75
   texture {tinta_B}
}

#declare fileira_rodaE =
union{
    #declare i=0;
    #while (i<7)
       object { roda_esq translate <0, i, 0> }
       #declare i = i + 1.75;
    #end
}

#declare fileira_rodaD =
union{
    #declare i=0;
    #while (i<7)
       object { roda_dir translate <0, i, 0> }
       #declare i = i + 1.75;
    #end
}

#declare vagao =
union{
  difference {
    object {vagao1}
    object {furo_interno}
    object {fileira_janela}
  }
  object {fileira_rodaE}
  object {fileira_rodaD}
}

#declare vagoes =
union{
 #declare i=0;
 #while (i<8)
   object {vagao
    translate <12.75,-3.00,1.35>
    rotate 40*i*z
   }
  #declare i=i+1;
 #end
}

#declare engate =
 cylinder {
   < 0, -6,0>
   < 0, 0,0>
   0.25
   texture {tinta_B}
}

#declare engates =
union{
 #declare i=0;
 #while (i<8)
   #if (i > 0)
      object {engate
         translate <15,-3.00,1.75>
         rotate 40*i*z
      }
   #end
  #declare i=i+1;
 #end
}

#declare madeira =
 box {
   < 0,0,0>
   < 5.00,0.75,0.15>
   texture {tinta_C}
}

#declare madeiras =
union{
 #declare i=0;
 #while (i<40)
   object {madeira
    translate <12.5,0,0>
    rotate 10*i*z
   }
  #declare i=i+1;
 #end
}

#declare CLK = clock;
#declare D = 360;
#declare A1 = 1100;
#declare A2 = 1300;
#declare B = -44;
#declare C = 440;

#declare tremCompleto =
  union {
    #if (CLK < 0.20)
        #declare posicao = A1*CLK*CLK;
    #else
      #if (CLK < 0.80)
        #declare posicao = B+C*CLK;
      #else
 #declare posicao = D-A2*(1-CLK)*(1-CLK);
      #end
    #end
     object{vagoes}
     object{engates}
     rotate posicao*z
  }

#declare estacaobase =
  box {
     <0,0,0>
     <15,6,7>
     texture{tx_amarelo}
}

#declare teto =
  box {
     <0,0,7>
     <15,8,7.5>
     texture{tinta_C}
}

#declare porta1=
  box {
     <6,6,0>
     <10,6.25,4>
     texture{tinta_B}
}

#declare estacao =
union{
   object {estacaobase}
   object {teto}
   object {porta1}
   rotate 8*z
   translate <-3,-29,0>
}

plane {z,0
  texture {
    pigment {color rgb < 1.00, 0.80, 0.25 > }
    finish {ambient 0.1 diffuse 0.9 }
    scale 2
    rotate 45*y
  }
}

union {
  difference {
    object{trilho_ext}
    union {
      object {corte1_trilho}
      object {corte2_trilho}
      object {trilho_int}
    }
  }
  object{tremCompleto}
  object{madeiras}
  object{estacao}
}

#include "camlight.inc"
camlight(<2.50,-5.50,1.00>,<51.50,-0.50,17.50>,1.00,z,1.0)