How to write shape data files
Shape data files contain information about a shape that train simulator needs to
display it properly, and optionally allow it to interact with trains during
derailments. A shape data file will have the same name as the shape file and be
in the same directory, but it will have the extension SD instead of S.
Inside the shape data file, the data is always wrapped by a shape block, e.g.
Shape (
…data
)
The first thing in this block should be the shape filename (i.e. the shape data
filename but with an .S extension), after that there are three optional
components.
ESD_Detail_Level ( n )
The in-game options allow the user to specify an object density setting from 0 to
10, which limits how many objects are in the world for performance reasons. An
object’s detail level is how train simulator decides whether to load the shape.
Objects with a detail level higher than the current setting will be excluded, so set
this to 0 for things like bridges supporting track that should always be loaded and
anything up to 10 for trees and other details depending on how important you
deem them. Note that this can be set, per object, in the route editor and this will
override the setting here.
ESD_Alternative_Texture ( n )
Shapes can have a range of optional textures that are applied dependant on the
time of day or the weather.
If n is 0 - The simplest option is to have one set of textures that is used all the
time. The object will be lit realistically, becoming darker at night as you would
expect. The weather will have no effect.
If n is 1 - The object has two sets of textures, one in the standard texture
directory and one in the snow subdirectory. The snow textures will be used when
the weather is appropriate. The object will be lit realistically, becoming darker at
night as you would expect.
If n is 252 - The object has a texture for each of the seasons with and without
snow. This is different from the simple snow texture, allowing more subtle
variation by season. These textures should go in the subdirectories named by
season, i.e. Autumn, AutumnSnow, Summer, SummerSnow, Winter and
WinterSnow
If n is 256 - The object has two sets of textures, one in the standard texture
directory and one in the night subdirectory. The night textures will be used when
the sun sets, and when a night texture is in use the object will not be lit
realistically. When night textures are applied the object is lit very brightly from all
directions, so that parts of the texture that are light in colour will seem very bright
at night. To make the object look realistic therefore, parts of the texture that
would not be bright at night must be darkened.
The following entries describe collision data for a shape. This data is used to
decide if two objects are colliding, and is the only way an object can be ‘solid’.
Objcts with no collision data are insubstantial and the train will pass through
them. Generally, because the real time physics needs to run very fast in order to
be accurate, train simulator does not attempt to make the collision data too
accurate. It is a question of deciding which components of your world the train
should definitely not pass through, balanced against performance considerations.
These entries are mutually exclusive.
ESD_Bounding_Box ( minx miny minz maxx maxy maxz )
For simple objects like small buildings or vehicles these values are the extents of
the object. The minx, miny and minz values are the minimum extents on each
axis, the maxx, maxy and maxz values are the maximum extents on each axis.
Note that these do not have to be the actual extents of the shape - just the bits
the train should not pass through.
Notice how the bounding boxes leave out the eaves, because on balance it will look better for the
train to pass through the eaves than bounce off thin air.
Z X
Y
ESD_Complex ( nboxes
ESD_Complex_Box ( rotx roty rotz posx posy posz minx miny minz maxx
maxy maxz )
…
)
A complex bounding box structure is a list of single bounding boxes with a
position and rotation relative to the object. Nboxes is the number of boxes used
in this structure.
Each box is described with an ESD_Complex_Box entry. The first three elements
of ESD_Complex_Box are the rotation in degrees of the box around each axis.
The boxes are rotated in the order X, Y then Z. The next three elements are the
position of the box, or if you like the offset from the pivot point of the shape. The
last six elements are just the same as for single bounding boxes, defining the
extents
The axes have been drawn on for clarity, but the pivot point of the object is its actual center in X
and Z, with the Y set to the base of the object. So measurements used in the collision data will be
relative to that point.
X
Z
Y
The collision data for this shape might look like this:
ESD_Complex ( 3
ESD_Complex_Box (
0 0 8
-25 0 0
-13 -4 -5
13 4 5 )
ESD_Complex_Box (
0 0 -8
25 0 0
-13 -4 -5
13 4 5)
ESD_Complex_Box (
0 0 0
0 9 0
-12 0 -5
12 0.5 5)
)
The first two boxes are the symmetrical sloped boxes on either side of the bridge,
notice that they have been rotated by 8 degrees around the Z axis to get the
slope. Then their centers have been offset by 25 meters along the X axis.
ESD_Tunnel ( length borderwidth tunnelwidth tunnelheight mouthlength)
The ESD_Tunnel collision type is used to define tunnel mouth entrances. Tunnel
mouth entrances are somewhat unusual, in that they are literally an interface
between below and above ground. A derailed train can slide into the influence of
a tunnel mouth and will then be allowed to continue sliding below ground, as long
as there is a continuous series of tunnel pieces to contain it. Without the tunnel
mouth being properly set up a derailed train will bounce off an invisible barrier
when it tries to pass under the ground.
The first value, length, is fairly arbitrary. and should be set to a length which will
comfortably contain a wagon’s length.
Borderwidth is the width of the outer face of the tunnel mouth – the distance from
the inner edge of the tunnel to the outer edge of the shape.
Tunnelwidth is the width of the actual tunnel.
Tunnelheight is the height of the actual tunnel.
Mouthlength is the depth of the tunnel mouth, from the face to the pivot point of
the shape.
Example contents of an .SD file:
SIMISA@@@@@@@@@@JINX0t1t______
shape ( Bridgepiece.s
ESD_Detail_Level ( 0 )
ESD_Alternative_Texture ( 1 )
ESD_Complex ( 2
ESD_Complex_Box (
0 -5 0
0.18204 21.1035 -0.0196628
-24.8481 -0.685221 -9.48568
24.8481 0.685221 9.48568 )
ESD_Complex_Box (
0 35 0
15.8677 10.2528 2.1172
-8.44162 -10.2528 -1.63386
8.44162 10.2528 1.63386 )
)
)