/* Track: As with the rest, 1 unit = 1m. Usage: #declare gauge=0.000; //Track gauge in meters - 1.435 for standard, 1.6 for broad, etc #declare Track_Length=0.000; //Length of track section - in meters. #declare Track_Transform=transform { //Any valid transformations - eg //rotate y*0 //To put the track at a different angle //translate <0,0,0> //To center the track about the specified point } #include "Track.INC" Track section is initially centered about the origin, is aligned such that trains run in the X direction, and the rails are at +gauge/2*z and -gauge/2*z. y=0 is at wheel level. The specified transformations are then applied. */ #ifndef (gauge) #error "Must #declare gauge before calling Track.inc\n" #end #ifndef (Track_Length) #error "Must #declare Track_Length before calling Track.inc\n" #end #ifndef (Track_Transform) #warning "Should #declare Track_Transform before calling Track.inc\n" #declare Track_Transform=transform {} #end #ifndef (TrackIncluded) #declare TrackIncluded=1; //Once-only declarations go here - will only be processed the first time Track.INC is #included #include "metals.inc" //#declare Rusty=texture {pigment {rgb <.6,.1,.1>}} //Based largely on the example from povuser.txt #declare RustyPigment = pigment { granite color_map { [ 0 rgb <0.2, 0, 0> ] [ 1 rgb <.6,.1,.1> ] } frequency 20 } // And this part applies it // Notice that our original layered texture // "Speckled_Metal" is now part of the map #declare Rusty = texture { bozo texture_map { [ 0.0 pigment {RustyPigment} ] [ 0.75 T_Silver_5A ] [ 1.0 T_Silver_5A ] } } /* Metal finish, very bright and shiny */ #declare Track_VeryShinyMetal= texture { pigment {color rgb 1} finish { //This part is based on F_MetalE from metals.inc ambient 0.001 brilliance 500 diffuse 0.7 metallic //specular 0.80 //roughness 1/120 reflection 1 irid //This part based on the example from povuser.txt { .5 thickness .2 turbulence 1 } } } #declare Track_Clip=union //<0,0,0> of this union is same as for the lug. { #declare Clip_MaxX=.12; #declare Clip_MaxY=.04; #declare Clip_MaxZ=.10; #declare Clip_Thickness=.025; //Thickness of the metal - diameter of the cylinders etc. cylinder //Bar to go inside the lug's hole { #declare Clip_FirstBarLen=.07; -Clip_FirstBarLen*x/2,+Clip_FirstBarLen*x/2,Clip_Thickness/2 } #declare Clip_EstSmallCurveDist=.02; //Distance between bars on small curve intersection //Small curve, towards rail { torus {Clip_EstSmallCurveDist/2+Clip_Thickness/2,Clip_Thickness/2} plane {x,0} #declare Clip_Mm=Clip_EstSmallCurveDist/2+Clip_Thickness; //Major + minor radii (sum of) rotate degrees(atan2(.01,Clip_Mm))*x translate - } cylinder //Bar between small & large curves { #declare Clip_EstSecondBarLen=.02; <-Clip_FirstBarLen/2,0,-Clip_Thickness-Clip_EstSmallCurveDist>, <+Clip_FirstBarLen/2,0,-Clip_Thickness-Clip_EstSmallCurveDist>, Clip_Thickness/2 translate <0,.005,Clip_Mm-sqrt(Clip_Mm*Clip_Mm-.01*.01)> } //texture {Rusty} pigment {color rgb .5} } #declare Track_ClipLug=union //<0,0,0> is middle of hole { //<0,.025/2,.1+.0425/2> difference { union { box {<-.035,-.02,.05>,<.035,.0075,0>} cylinder {<-.035,0,0>,<.035,0,0>,.0425/2} } cylinder {<-.0351,0,0>,<.0351,0,0>,.025/2} } object {Track_Clip} //pigment {color rgb .75} texture {Rusty} translate <0,.025/2,.08+.0425/2> } #end //Once-only declarations #declare Track_Sleeper=union //0 of sleeper is center, bottom of rail, center - non-standard. Sleeper must be translated down by the height of the rail. { box {<-.11,-.025,-1.305>,<.11,-.215,1.305>} #declare Track_RailHead=union { intersection //Raised part of concrete { box {<-.11,-.03,gauge/2-.1>,<.11,0,gauge/2+.38>} plane {y,0 rotate 15*x translate <0,-.025,gauge/2+.38>} plane {y,0 rotate degrees(atan2(2.5,-3))*x translate <0,-.025,gauge/2-.1> inverse} } object {Track_ClipLug translate <0,0,gauge/2+.11>} object {Track_ClipLug rotate y*180 translate <0,0,gauge/2+.12>} translate <0,0,-.06> } object {Track_RailHead} object {Track_RailHead rotate y*180} pigment { granite turbulence 1 color_map { [0.0 color rgb 0] [0.2 color rgb .9] } scale .1 //color rgb .9 } finish {specular .5 roughness .15} } #declare Track_Rail=union //0 of rail is center of piece (goes from -length to +length), top (where wheels would go), negative z edge of upper lobe (where wheels would go on +z rail). Rails in -z of the track section must be rotated 180*y. { box //Top of rail - shiny { <-Track_Length,-.005,-.07>,<+Track_Length,0,0> //texture {T_Silver_5E} texture {Track_VeryShinyMetal} //finish {ambient .01 metallic} /** This is too bright. It needs to be a little bit blue and less reflective **/ //pigment {color rgb .625} } union //rest of rail - rusty { box {<-Track_Length,-.15,-.11 >,<+Track_Length,-.14,.04>} box {<-Track_Length,-.14,-.045>,<+Track_Length,-.04,-.025>} box {<-Track_Length,-.04,-.07 >,<+Track_Length,-.005,0>} texture {Rusty} //pigment {color rgb .375} } } #declare Track_Section=union { object {Track_Rail translate -gauge/2*z} object {Track_Rail rotate 180*y translate gauge/2*z} object {Track_Sleeper translate y*-.15} #declare i=1; #while (i<=Track_Length) object {Track_Sleeper translate <+i,-.15,0>} object {Track_Sleeper translate <-i,-.15,0>} #declare i=i+.75; #end } object {Track_Section transform Track_Transform}