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

#include "colors.inc"

#declare fonte=seed(314159);

sky_sphere {
  pigment {
    gradient y
    color_map {
      [0.0 rgb <0.6,0.7,1.0>]
      [0.7 rgb <0.0,0.1,0.8>]
    }
  }
}

plane {
  y, -1
  pigment { color rgb <0.7,0.5,0.3> }
}

#declare tx_espelho =
  texture{
    pigment {Gray70}
    finish{
      ambient 0.05 diffuse 0.05
      reflection{
         Silver
         metallic
       }
      specular 0.20 roughness 0.05
    }
  }

#declare tx_pedras =
  texture{
     finish {
         ambient 0.1 diffuse 0.1 reflection 0.25
         specular 1 roughness 0.001
     }
     pigment {color rgb <0, 1, 1>}
  }

declare box_janela =
     box{
          <-15, 11.5, -16.25> <-9, 13.6, -16.25001>
          texture{tx_espelho}

         }

declare cilindro_janela =
  cylinder{
            <-14, 11.0, -16.25>,
            <-14, 11.0, -16.25001>,
            1.7
            texture{tx_espelho}

          }

#declare vagao =
   union{
     #declare r = 1*rand(fonte);
     #declare g = 1*rand(fonte);
     #declare b = 1*rand(fonte);
     box {
       <-16.25,0,-16.25> <16.25, 15, 16.25>
 pigment {color rgb <r, g, b>}
        translate<0,2.5,0>
     }
     #declare i =0;
     #while (i<4)
       cylinder{
         <-12.75, 2.5, -16.25>,
         <-12.75, 2.5, -17.5>,
         2.7
         translate<i*8.5, 0, 0>
         pigment { color Red }
       }

       cylinder{
         <-12.75, 2.5, 16.251>,
         <-12.75, 2.5, 15.5>,
         2.7
         translate<i*8.5, 0, 0>
         pigment { color Red }
       }
       #declare i = i +1;
     #end
     #declare i=0;
     #declare flag = 0;
     #while (i<5)
       #if (flag = 0)
        object{
           box_janela
           translate<i*6,2,0>
        }
        object{
           box_janela
           translate<i*6,2,0>
           rotate 180*y
        }
        #declare flag= 1;
       #else
        object{
           cilindro_janela
           translate<i*7,-1,0>
         }
        object{
           cilindro_janela
           translate<i*7,-1,0>
           rotate 180*y
        }
        #declare flag = 0;
      #end
      #declare i = i +1;
    #end
    translate<0, 0, -130>
  }

declare ligacao =
  box{
     0 <10, 1.5, 1.5>
     translate<16.26, 3, -130>
  }

declare trilho =

   union{
     torus {
       155, 0.5
       pigment{Green}
       translate<0, 0, 9.5>
     }
     torus{
      130, 0.5
      pigment{Green}
      translate<0, 0, 9.5>
     }
  }

declare vagoes =
union{

  #declare r = 10*rand(fonte);
  #declare i = 0;
  #while (i<r)
    object{
     vagao
     rotate i*-18*y

    }
    #if (i < (r-1))
     object {
      ligacao
      rotate i*-18*y
     }
     #end
   #declare i = i+1;
 #end

}

#declare tt = clock;

#declare h = 0.2;

#declare d = 360;

#declare a = d/(2*h*(1-h));

#declare c = 2*a*h;

#declare b = -a*h*h;

#if (tt < 0.20)
   object {vagoes rotate (a*tt*tt)*y}
#else
  #if (tt < 0.80)
    object {vagoes rotate (b+c*tt)*y}
  #else
   object {vagoes rotate (d-a*(1-tt)*(1-tt))*y}
  #end
#end

declare estacao =

 box {
  <-17, 0, -160> <-80, 50, -180>
  pigment {color Yellow}
 }

declare nome =
text {
    ttf "timrom.ttf" "ESTACAO" 1, 0
    pigment { Red }
    translate <-37, 35, 0>

  }

object {estacao}
object {trilho}
object {nome }

#include "camlight.inc"
camlight(<0,0,0>,<0.0,0.5,450.0>,1.00,y,1.0)