Track Shape Generator Program

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Snowman
    Senior Member


    • Apr 2001
    • 214

    #1

    Track Shape Generator Program

    Hello,

    I’ve been working on a program that generates track shapes from decompressed MSTS/OR shape files.

    The workflow starts with a known reference shape—for example, a 10 m straight track such as a1t10mstrt.s. From there, the user can specify track spacing and number of parallel tracks to generate. At the moment the program is hard-coded to a maximum of eight tracks, though that limit may change.

    Spacing can be entered as:

    16.35 ft (default MSTS track spacing)

    14 ft (common North American spacing)

    meters (fully supported)

    Using these inputs, the program generates new track shapes to the requested length, spacing, and track count. This allows a user to model a simple straight track (for example, a 10 m segment) in SketchUp or Blender and then procedurally generate the desired multi-track configuration from it.

    Curved track generation is also supported. The same logic applies as with straight track: spacing, number of tracks, radius, and angle are derived from a known curve template.

    I plan to attempt switches/points next, though I’m cautiously pessimistic about how cooperative those will be.

    Future iterations will likely include:

    Batch (mass) shape generation, rather than one-at-a-time output

    Possibly bypassing .s files entirely and generating directly from formats like OBJ or 3DS

    The UI is admittedly rough and not currently the main focus.

    Testing so far has been done using:

    User-created track

    ScaleRails

    Default MSTS track

    USTracks / DBTracks

    ShapeGenerator01.jpg

    ShapeGenerator02.jpg
  • defect_detector
    Senior Member

    • Jul 2012
    • 807
    • ORTS

    #2
    This has the potential to be quite fantastic, keep up the hard work!
    MK

    Comment

    • johnnyboy99
      Senior Member


      • Nov 2014
      • 373
      • General

      #3
      will there be support for tunnels or xover nodes? I'd kill for a curved xover track or a tunnel xover track for subways

      Comment

      • eric
        9500 Post Veteran and Administrator



        • Dec 2002
        • 9583
        • NS MP245.4 CNO&TP South District
        • English, SQL
        • General

        #4
        Good luck. There's a Blender script on GitHub by Doug Jones that will create turnouts and crossovers, including guardrails ---> https://github.com/dajones42/dte

        That's what I used to create the pieces for ATracks. Thats might give you some inspiration for how to model the animations.

        What's really needed with all of this is a way to create the TSection entries to make these work.

        Some examples of what I built from Doug's script:
        https://www.trainsim.com/forums/foru...78#post2317678
        Last edited by eric; 01-18-2026, 18:59.
        If you like what you see here at Trainsim.com, be it the discussions and knowledge in the forums, or items available in our library, I hope you'll consider a paid membership to help support keeping the site operating.... Thanks!

        Comment

        • charland
          3000 Post Veteran


          • Dec 2006
          • 3107
          • Brockville, ON, CA
          • General

          #5
          Can either of these programs change track gauge, interested in 42 inch gauge.

          Paul :-)

          Comment

          • Snowman
            Senior Member


            • Apr 2001
            • 214

            #6
            Originally posted by johnnyboy99
            Will there be support for tunnels or crossover nodes? I’d kill for a curved crossover track or a tunnel crossover track for subways.
            At the moment, yes, tunnel shapes can be created using existing tunnel shapes as-is. However, if the source shape includes a tunnel opening, that opening will repeat along the generated track. To avoid visible gaps, the base shape needs to not rely on overhangs that normally hide joins—those overhangs can introduce spacing issues when repeated. This is something I’m actively working on. I have a tunnel check box which "fixes" this, but it's a WIP at the moment.

            Crossover tracks are still under investigation. They’re on the radar, but they’re a more complex problem and very much a work in progress.

            Originally posted by eric
            There's a Blender script on GitHub by Doug Jones that will create turnouts and crossovers, including guardrails.
            I’ve used that script in the past, and once it’s properly set up, it works quite well.

            Originally posted by charland
            Can either of these programs change track gauge? I’m interested in 42-inch gauge.
            Changing gauge shouldn’t be difficult to implement. The main requirement is that the gauge is supported in the tsection, which I’m also working on.

            LODs are automatically duplicated from the input shape file, which keeps the process very simple. In practice, you can model a single 10-meter straight track shape and generate an unlimited number of derived shapes with a single click.

            The generator also supports custom radii and angles that aren’t typically available in existing track systems. Any user-defined radius or angle can be created, and this currently works with the track systems mentioned earlier. As always, final usability depends on adding the resulting shapes to the tsection.

            I also have a companion program that automatically handles the tsection side of things. I may integrate it directly into this tool in the future. The overarching goal is to keep the workflow as frictionless and user-friendly as possible—powerful behind the scenes, but straightforward to use.

            Comment

            • charland
              3000 Post Veteran


              • Dec 2006
              • 3107
              • Brockville, ON, CA
              • General

              #7
              I had another question. Will Dynamic Track still work and will you be able to set the track gauge? It's a valuable tool.

              Paul :-)

              Comment

              • Snowman
                Senior Member


                • Apr 2001
                • 214

                #8
                Originally posted by charland
                Will Dynamic Track still work and will you be able to set the track gauge?
                Hi — if I’m understanding the question correctly:

                Dynamic Track will still work with track generated by the tool. As for changing gauge dynamically, I don’t believe that’s currently supported by TSRE itself (Open Rails does have a gauge setting). What my tool can do is export an entire track system in a different gauge, allowing you to generate standard, narrow, or broad gauge track from the same base template. If a track system is created with a specific gauge in mind, the generated track will follow that gauge accordingly. Regardless, my app will do this with any track system with track gauge setting.

                At the moment, the tool focuses on automating straight and curved track generation using an existing (or user-created) 10 m template section, including user-defined spacing and automatic tsection.dat creation (all optional). This makes it very fast to generate a complete track system without manually building every curve and straight.

                Turnouts, crossovers, diamonds, and similar components are a much harder problem due to their geometric complexity and still require manual creation for now. That’s an area I’m actively working toward supporting in the future.

                I'm also working on a Trprofile generator that will export from a sample track a complete profile for use with dynamic tracks.

                Comment

                • charland
                  3000 Post Veteran


                  • Dec 2006
                  • 3107
                  • Brockville, ON, CA
                  • General

                  #9
                  This is sounding pretty good. I have a friend who asked my a few years ago about making a route for Mewfoundland 42" gauge but changing the gauge of switches is pretty complicated. 42" gause is also what they use in Japan, ot sure why it was never included as part of xTracks years ago.

                  Paul :-)

                  Comment

                  • eric
                    9500 Post Veteran and Administrator



                    • Dec 2002
                    • 9583
                    • NS MP245.4 CNO&TP South District
                    • English, SQL
                    • General

                    #10
                    TSRE v8 absolutely supports variable gauge track and will render it within the editor, with the limitation that there is only one rendering width available at the moment.

                    Sent from my SM-S911U using Tapatalk

                    If you like what you see here at Trainsim.com, be it the discussions and knowledge in the forums, or items available in our library, I hope you'll consider a paid membership to help support keeping the site operating.... Thanks!

                    Comment

                    • Snowman
                      Senior Member


                      • Apr 2001
                      • 214

                      #11
                      I wanted to share a progress update on the Track Shape Generator since last month.
                      • Straight & Curve Generation – Now Fully Functional

                      All straight and curve generation is now working properly based on internal testing.

                      Previously, a 10-meter straight section was required for control purposes. That limitation has been removed. Straight sections of **any length** now generate accurate curves and straight track geometry.

                      Benefits of the update:

                      * Shorter sections reduce visible rail kinks
                      * Smoother overall rail transitions
                      * Greater flexibility in layout design

                      At this stage, I recommend using **4-meter straight sections**. This provides smooth geometry while reducing repetitive tie patterns.

                      While broader testing may uncover minor edge cases, the core straight and curve systems are stable.
                      • Turnouts – Active Development

                      Turnouts have been the main focus recently. As expected, they are significantly more complex due to the number of individual rail components involved.

                      Current progress:

                      * Single-rail input (no ballast)
                      * Automatic generation of:

                      * Outer rails
                      * Proper rail length
                      * Accurate curvature
                      * Rail taper (currently being implemented)

                      Default Kuju turnouts are the starting point, as they represent the most practical baseline configuration.

                      A standard turnout consists of **five separate rails**. The program currently generates each rail independently based on user input, then combines them into a single exportable shape file.
                      • Planned Turnout Improvements
                      The long-term goal is to simplify the workflow:

                      * A simple 1-meter rail as the base input
                      * One-button generation of a complete default turnout
                      * Adjustable parameters such as:

                      * Rail taper
                      * Check rail length
                      * Geometry refinements

                      Support for real-world **#N turnouts** based on user preference is also planned.
                      • Ballast & Tie Considerations

                      Ballast and tie behavior within turnouts introduces additional design challenges.

                      In real-world turnouts, ties run straight across the assembly.
                      Currently, the generator prefers ties that curve along the diverging route.

                      This may ultimately become a balance between realism and simplicity. The final implementation approach is still under evaluation.
                      The purpose of this program remains clear:

                      To allow users with limited modeling experience to easily create custom track sections.

                      The objective is to:

                      * Lower the technical barrier
                      * Encourage independent track creation
                      * Support private-use assets
                      * Enable users to build their own track systems from scratch

                      Further updates will follow as turnout automation progresses.

                      Image3.jpg Image4.jpg
                      Attached Files

                      Comment

                      • demando
                        Senior Member


                        • Aug 2008
                        • 387
                        • Woodland, California

                        #12
                        At this point, I won't really consider using this program until compatibility with ScaleRail is a feature. I never cared for default Kuju tracks, and ScaleRail is still missing customizable shapes. But this is still a good start, and I'll definitely be tracking your progress in hopes that it will make route building more time economical. Good work so far.
                        "Dream as if you'll live forever. Live as if you'll die today." - James Dean
                        calrouteprojectmstsorts.weebly.com/
                        https://cprrorts.weebly.com/
                        Cheers, S. J. Hjellum

                        Comment

                        • Snowman
                          Senior Member


                          • Apr 2001
                          • 214

                          #13
                          Originally posted by demando
                          At this point, I won't really consider using this program until compatibility with ScaleRail is a feature. I never cared for default Kuju tracks, and ScaleRail is still missing customizable shapes. But this is still a good start, and I'll definitely be tracking your progress in hopes that it will make route building more time economical. Good work so far.
                          You can use whatever shapes you want. You can no doubt generate ScaleRail track using this program. It has many shapes already and the program's current functionality only supports straight and curved track at the moment, but ScailRail generates wonderfully in the program.

                          Comment

                          • demando
                            Senior Member


                            • Aug 2008
                            • 387
                            • Woodland, California

                            #14
                            OK, that's fair. I may have missed that in your original post, so I stand corrected. So I'm to understand that your program just supports straight and curved track, got it. How far along are you on switches?
                            "Dream as if you'll live forever. Live as if you'll die today." - James Dean
                            calrouteprojectmstsorts.weebly.com/
                            https://cprrorts.weebly.com/
                            Cheers, S. J. Hjellum

                            Comment

                            • Snowman
                              Senior Member


                              • Apr 2001
                              • 214

                              #15
                              Originally posted by demando
                              OK, that's fair. I may have missed that in your original post, so I stand corrected. So I'm to understand that your program just supports straight and curved track, got it. How far along are you on switches?
                              This project started out as a personal one, so switches weren't a big deal for me as creating complex curves of multiple lengths. Switches are complex, but fewer relatively, so for now if the interest appears, I will continue, but if no interest, I will leave project here. I don't see many people using this, so maybe too little too late. I will see in a few months where this is at and I am making headway on creating turnouts, but it's a very complex engineering problem trying to solve an issue for many people, especially simplifying a complex issue. It can be done of course, but for a couple of people? This is monumental task for that. My last update on this page is where I am at the moment. I will release source soon when I'm not busy.

                              Comment

                              Working...