Trainz/containers/track part container

From Wikibooks, open books for an open world
Jump to navigation Jump to search

A Track Part container is a config.txt file entry used by the kind track content type. It does not correspond to a single specific tag, but rather is a format which is reused by several different tags.

This page describes a data model introduced in TS2009 when spline objects were consolidated into the Kind Track data type and is defaulted for trainz-build.


Supported Tags[edit | edit source]

The Track Part Container supports the following tags. Each tag is shown here with its default value. In some cases, the Track Part Container may inherit the values set on a parent container (excepting the track-lod-tree container) rather than using these defaults; see the individual content type descriptions for additional details.

mesh-length 0.0
adjust-height-to-ground-threshold -3.402823466e+38
adjust-height-to-ground-offset 0.0
adjust-cross-section-to-ground 1
track-lod-tree
{
}
coordinate-transformation "spline"
follows-spline-gradient 0
follows-ground-height-at-ends-of-mesh 0
dont-scale-mesh-to-fit-length 0

mesh-length[edit | edit source]

The mesh-length value is a track distance in meters which defines the basic unit length of track that the track-lod-tree describes. The track-lod-tree may supply a single mesh of this length, or may subdivide the unit mesh-length into a number of smaller mesh pieces.

adjust-height-to-ground-threshold[edit | edit source]

Any vertex with a model-space Z value less than this threshold number will be adjusted based on the height of the ground under that vertex.

The math behind the adjustment is roughly as follows:

outputVertexPosition.z = modelVertexPosition.z + adjustHeightToGroundOffset + groundHeight

Typically, this height adjustment is used when building a bridge or similar structure - the bulk of the model is maintained at the actual spline height, but the bottom vertices of the legs or supporting pillars are dropped to ground height.

adjust-height-to-ground-offset[edit | edit source]

Provides an offset along the model-space Z axis that is used when a vertex is being adjusted to ground height. If set to the negative of the adjust-height-to-ground-threshold value, this will effectively cause any vertex at that height to be dropped to exactly ground level. Any vertex below that height will drop below ground level. Any vertex above that height will not be modified.

By varying the offset, this allows vertices to float slightly above the actual ground height.

adjust-cross-section-to-ground[edit | edit source]

If this boolean value is set (1), the track mesh is distorted across its X axis to follow the ground plane upon which it rests. If clear (0) the mesh will assume the ground height from the center point. This setting has no effect on vertices which are within the adjust-height-to-ground-threshold range.

track-lod-tree[edit | edit source]

The track-lod-tree container is used to select appropriate meshes for runtime mesh stitching.

coordinate-transformation[edit | edit source]

The coordinate-transformation setting determines how vertices from the model are mapped into the world. The following techniques are available:

  • "spline" (default) - this option gives the default, fit-to-spline behavior.
  • "linear" - this option gives simple linear scaling. This will not attempt to shear the ends of the mesh to fit the neighbors.
  • "shear" - this option gives simple linear scaling. This will 'shear' (linear stretch) the ends of the mesh to fit the neighbors.
  • "horizontal" - this option gives an effect similar to 'linear' except that height is fixed throughout a given component mesh. This is useful if lack of vertical distortion is more important that meeting end-to-end with the next mesh.
  • "horizontal shear" - this option gives an effect similar to 'shear' except that height is fixed throughout a given component mesh. This is useful if lack of vertical distortion is more important that meeting end-to-end with the next mesh.

Note! This replaces the bendy tag from Trainz versions previous to 2.7.

follows-spline-gradient[edit | edit source]

If this boolean value is set (1), the mesh is deformed to smoothly follow the height-gradient of the spline. If clear (0), the mesh is instead deformed to follow the ground height along the centre-line of the spline ("adjust-cross-section-to-ground 1") or under each vertex ("adjust-cross-section-to-ground 0"). Certain in-game state, such as having set a height gradient onto the spline (yellow track vertices in Surveyor) or residing on a parent bridge spline, may override this option.

follows-ground-height-at-ends-of-mesh[edit | edit source]

If this boolean value is set(1), the spline height is effectively deformed such that the end-points of each repeat of the mesh follow the ground height. Spline height throughout the mesh varies in a linear fashion. If clear (0), the spline height is not affected. Certain other options, such as ("follows-spline-gradient 0") or ("coordinate-transformation spline") may cause this option to be largely meaningless.

dont-scale-mesh-to-fit-length[edit | edit source]

If this boolean value is clear (0), the length of each component mesh is scaled to fit the available area in the spline. Since the number of repeats and subdivisions is integer, spline meshes are typically stretched or contracted slightly to ensure that the mesh repeats end-to-end. If set (1), the mesh is rendered at its natural length, even if this means that meshes will overlap or stretch apart and not touch each other. This might typically used where a spline represents a set of repeating poles or pylons, rather than a continuous beam.

 

Notes and references[edit | edit source]

Footnotes[edit | edit source]