Skip to content

Track Pieces Format

Olivier Wervers edited this page Dec 11, 2023 · 1 revision

Track Pieces Format

The track pieces format is a JSON file format used to define track pieces. Track pieces are separate from track types. Track types refer to predefined track pieces from the main track pieces file which is written in this format.

Root : TrackPiece[]

At the root of the file format lies an array containing track piece elements. The format for a track piece element is defined in the next section.

A basic example of a track pieces file defining one simple track piece:

[
    {
        "name": "flat_straight",
        "spline_points": [
            {
                "position": [-2, 0, 0],
                "direction": "north",
                "is_entry_connection": true
            },
            {
                "position": [2, 0, 0],
                "direction": "north",
                "is_exit_connection": true
            }
        ]
    }
]

Track Piece (TrackPiece)

Each track piece primarily defines the shape of a track piece, as well as how the rendered sprites are processed.

Example:

{
    "name": "flat_straight_station",
    "spline_points": [...],
    "width": 1,
    "length": 1,
    "orientations": [...]
}

name

The name field contains the internal name of the track piece. This has to be unqique and should follow the snake_case naming convention.

spline_points : SplinePoint[]

A list of spline points. These spline points define the shape of the track.

width (optional) : number

Default value: 1

The width of the track piece (along the Y-axis). This is used for track pieces that take up more then one tile.

width (optional) : number

Default value: 1

The length of the track piece (along the X-axis). This is used for track pieces that take up more then one tile.

orientations (optional) : Orientation[]

Default value: [ {"view_angle": 0}, {"view_angle": 1}, {"view_angle": 2}, {"view_angle": 3} ]

The orientations for which the track piece can be rendered.

Orientation

view_angle : number

Range (inclusive): 0-3

The view angle defines the direction from which the scene is rendered. The camera turns anti-clockwise around the object as the value increases.

  • A value of 0 represents the camera at -x, -y (0 degrees)
  • A value of 1 represents the camera at x, -y (90 degrees)
  • A value of 2 represents the camera at x, y (180 degrees)
  • A value of 3 represents the camera at -x, y (270 degrees)

outputs (optional) : Output[]

A list of outputs. Track pieces that take up several tiles may require tiles, or quadrants of tiles to be merged into a single sprite.

E.g: A medium turn takes up 2*2 tiles, but only consists of 3 sprites. The fourth tile is included in some of the 3 sprites depending on the viewing angle.

Output

The output object is used for advanced control of a view-angle's sprite processing. This is usually only necessary for track pieces that take up multiple tiles.

origin_tile_index : number

Default value: First tile_index from the coverage field

The tile index of the tile from which the sprite is drawn in-game.

coverage