camera {
  location  < 80, 40, 120 >
  right     -1.00*x                // Largura RELATIVA da imagem.
  up        0.75*y                 // Altura RELATIVA da imagem.      
  sky       y                      // Qual direção é "para cima"?
  look_at   < 40, 0, 0 >  // Para onde a câmera está apontando.
} 

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

light_source {
  //1 * < 10.0, 10.0, -10.0 >              // Posição da lâmpada.
  <100, 180, 100>
  color rgb 5 * < 1.00, 1.00, 1.00 >   // Intensidade e corda luz.
}

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

#declare amarelo = <1,1,0.1>;
#declare azul = <0.2,0.8,1>;
#declare verde = <0.2,1,0.1>;
#declare vermelho = <1,0.2,0.1>;
#declare preto = <0.1,0.1,0.1>;
#declare marrom = <0.2,0.2,0.2>;

#declare vagao =
  union {
  // RODAS !!!
  #declare i = 0;
  #while(i<8)
  #declare temp =
    cylinder {
      <0,3,0>,
      <0,3,7>,
      0.7
      pigment {color preto filter 1}
    }
  object { temp  translate -1*y+1.2*i*x}
  #declare i=i+1;
  #end

  // CAIXA CENTRAL
    box {
      <0,3,3>,<10,7,7>
      pigment {color azul filter 0.8}
    }

  // JANELAS ALEATORIAS !!!
    #declare i = 0;
    #declare gerador = seed(12345);
    #while(i<10)
       #declare treco =
         #if(i>4)
           cylinder { <1,3,0.1>, <1,3,0.2>, 1 pigment {color amarelo filter 0.5} }
         #else
           cylinder { <1,3,0.1>, <1,3,0.2>, 0.6 pigment {color amarelo filter 0.5} }
         #end
      object { treco translate <7*rand(gerador),4*rand(gerador),7.1>}
      #declare i=i+1;
    #end
  }




#declare vagoes =
  union {
 
  // VARIOS VAGOES !!!
    #declare i = 0;
    #while(i<7)
      object { vagao translate <15*i,-4,2>}
      #declare i=i+1;
    #end
  }

#declare trem =
  union {

  // RODAS !!!
  #declare i = 0;
  #while(i<8)
  #declare temp =
    cylinder {
      <0,0,0>,
      <0,0,10>,
      2
      pigment {color preto filter 1}
    }
  object { temp  translate -1*y+2.8*i*x}
  #declare i=i+1;
  #end

  // CAIXA CENTRAL !!!
    box {
      <0,0,0>,<20,10,10>
      pigment {color vermelho filter 0.8}
    }

  // CHAMINEH !!!
    cylinder {
      <3,10.1,5>,
      <3,18,5>,
      2
      pigment {color vermelho filter 1}
    }

  // JANELAS ALEATORIAS !!!
    #declare i = 0;
    #declare gerador = seed(12345);
    #while(i<5)
      #declare treco =
        box { <0,0,0>,<+3,+1.7,0.3> pigment {color amarelo filter 0.5}}
      object { treco translate <16*rand(gerador),8*rand(gerador),10.1>}
      #declare i=i+1;
    #end
  }

#declare trilho =
  union {
    box { <0,-3,0>,<300,-3.5,10> pigment {color marrom filter 0.5} translate -100*x+50*z}
    box { <0,-3,0>,<300,-3.5,10> pigment {color marrom filter 0.5} translate -100*x}
    difference {
      cylinder {
        0, 0.5*y, 30
      }
      cylinder {
        -0.1*y, 0.5*y+0.1*y, 20
      }
      translate -100*x+30*z-3.5*y
      pigment { color marrom }
    }
    difference {
      cylinder {
        0, 0.5*y, 30
      }
      cylinder {
        -0.1*y, 0.5*y+0.1*y, 20
      }
      translate 200*x+30*z-3.5*y
      pigment { color marrom }
    }
  }

object {trem}
object {vagoes
	translate 30*x}
object {trilho
	translate 50*x}