HowTo/Configure a spline for collisions

From TrainzOnline
< HowTo
Revision as of 09:13, 17 January 2018 by Tonyhilliam (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Tunnels, bridges, and other types of splines can interact with smoke particles by preventing penetration, which provides a more realistic effect. In order for this functionality to work as efficiently as possible, it is important to correctly configure spline assets.

This functionality is only available from trainz-build 4.1.

Selecting meshes to use for collisions

This is generally done on a case-by-case basis and will depend on how the asset was built. If the spline contains several meshes then the most important thing is to only enable collision detection for the relevant meshes. For a tunnel, this means that the walls, roof and tunnel mouth are likely to be the only relevant meshes. Catenaries, tracks and other slim/flat objects will add little to no benefit and can generally be ignored. The same principles apply to other types of splines.

By default, each sub-mesh of a spline will participate in collision detection by generating a collision object based on the mesh geometry. To override that and exclude specific meshes, simply set the mesh-table entry's collision-data-generation-mode tag to "disabled".

Notes:

  • "separate-shape-triangle-mesh" is the default behavior for spline meshes.
  • "separate-shape-convex-hull" provides faster collision detection at the expense of accuracy. If the mesh is a concave surface (such as the inner arch of a tunnel), this will not give suitable results.
  • "collated" is not supported for spline meshes and will result in the default behavior being applied.

Extract of an example config file:

kind                                    "track"
istrack                                 1
trainz-build                            4.1 
enable-pfx-collisions                   1

mesh-table
{
  track
  {
    mesh                                 "track.im"
    collision-data-generation-mode       "disabled"
  }
  
  roof
  {
    mesh                                 "roof.im"
    collision-data-generation-mode       "separate-shape-triangle-mesh"
  }
 
  wall
  {
    mesh                                "wall.im"
    collision-data-generation-mode      "separate-shape-convex-hull"
  }
}

Disabling collisions for an entire spline

Some splines as a whole won't have any visible impact on collision detection and should therefore be completely ignored. This is done by setting the enable-pfx-collisions boolean tag to 0 in the config file of a given spline asset. Tracks and roads are good examples of assets that serve no purpose regarding collision detection, as they are slim and generally positioned directly on the ground. This makes them unlikely to be reached by smoke particles and even if this were to happen, the particles would just hit the terrain instead. Turning off collision detection for spline-based grass or bushes can also be a good idea. These are also quite unlikely to be in situations where smoke will collide with them and are typically sparse enough to allow large smoke particles to travel through/around them with no visible impact.

Return to Index

<< How To Guides

Personal tools