// Last edited on 2005-01-05 22:33:53 by stolfi
// Processed by remove-cam-lights
#include "colors.inc"
#include "stones.inc"
#include "textures.inc"

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

#declare eixo =
union {

  cylinder {
    < 0, -2.6, 0>,
    < 0,  2.6, 0>,
    0.3
    texture { pigment {color Gray} }
  }

  torus {
    0.6 , 0.4
    translate 2.1*y
    texture { pigment { color Gray } }
  }

  torus {
    0.6 , 0.4
    translate -2.1*y
    texture { pigment { color Gray } }
  }
}

#declare locomotiva =
union {
  lathe {
    linear_spline
    4,
    <1,0>, <2,3>, <1,3>, <1,0>
    texture { pigment {color Gray} }
    rotate x*90
    translate z*3
    translate x*2
  }

  cylinder {
    < 4, 0, 2>,
    < 4.2, 0, 2>,
    1.5
    texture { pigment {color rgb <0.5,0.5,0.5>} }
  }

  cylinder {
    < 0, 0, 2>,
    < 4, 0, 2>,
    2
    texture { pigment {color Gray} }
  }

  difference {
    box {
      <-3, -2, 0>,
      < 0, +2, 8>
      texture {
        pigment { color Gray }
      }
    }

    box {
      <-2.8, -1.8, 0.2>,
      <-0.2, +1.8, 7.8>
      texture {
        pigment { color Gray }
      }
    }

    box {
      <-2, -2.1, 3>,
      <-1, +2.1, 6>
    }
  }

  object {eixo translate x*-1}
  object {eixo translate x*3}
}

#declare vagao =
union {

  box {
    <-5, +0.5, 0>,
    <-3, -0.5, 1>
    texture {
      pigment { color Black }
    }
  }

  difference {
    box {
      <-11, +2, 0>,
      < -5, -2, 7>
      texture {
        pigment { color Blue }
      }
    }

    box {
      <-10.8, +1.8, 0.2>,
      < -5.2, -2.2, 6.8>
      texture {
        pigment { color Blue }
      }
    }

    cylinder {
      < -6.5, -2.1, 4>,
      < -6.5,  2.1, 4>,
      0.6
    }

    cylinder {
      < -8, -2.1, 4>,
      < -8,  2.1, 4>,
      0.6
    }

    cylinder {
      < -9.5, -2.1, 4>,
      < -9.5,  2.1, 4>,
      0.6
    }
  }

  box {
      <-9, +1, 7>,
      <-7, -1, 8>
      texture {
        pigment { color Cyan }
      }
    }

  object { eixo translate -5*x}
  object { eixo translate -7*x}
  object { eixo translate -9*x}
  object { eixo translate -11*x}

}

#declare trilho =
union {

  box {
      <-100, 2.6, -1.2>,
      <100, 1.8, -1>
      texture {
        pigment { color Silver }
      }
    }

#declare i = 0;
#while (i < 200)
  box {
    <-0.2, -2, -1.2>,
    < 0.2, 2, -1>
    texture {
      pigment { color Brown }
    }
    translate (i-100)*x
  }
  #declare i = i + 1;
#end

  box {
      <-100, -1.8, -1.2>,
      <100, -2.6, -1>
      texture {
        pigment { color Silver }
      }
    }
}

object {locomotiva}
#declare G = seed(1273);
#declare i = 0;
#declare a=rand(G)*5 + 5;
#while (i < a)
  object {vagao translate (-(8*i))*x}
  #declare i = i + 1;
#end
object {trilho}

plane { <0, 0, 1>, -1.3
  texture {
    Jade
  }
}

#include "camlight.inc"
camlight(<-10.00,0.00,0.00>,<45.00,30.00,20.00>,1.00,z,1.0)