logo
Taal/language:uk flagnl flag

DTG Train Simulator Tech Article: Train Autonumbering

Locomotives and carriages can be automatically numbered by Train Simulator in the game itself. This means you can have more than one of a particular type of vehicle without the same serial number appearing on all of them.
Train Simulator is very particular about the setup for getting this to work.

Kuju Material setup in 3DS Max

3ds max kuju material setup

The most important concept to understand is this: in the source model, the digit textures are merely placeholders, not the actual numbers that are visible in the final game.
For each digit of the number, I suggest a TrainDecal.fx Kuju material be used. This allows 8-bit alpha in the texture which gives much more pleasing results than the 1-bit black/white alpha of stencils.
The materials must be named primarynumber_0 up to primarynumber_x where 'x' is the the number of digits in the serial number minus 1. So if there are four digits, the materials must be named from primarynumber_0 to primarynumber_3.
Each of these materials should reference a placeholder texture, and these textures must be named the same as the material name itself, prefixed with decal (a requirement of the TrainDecal.fx shader). ie. decal_primarynumber_0.ace up to decal_primarynumber_x.ace, again where 'x' is the number of digits in the number minus 1.
Pay attention to the case of the filenames - Train Simulator is very particular when it comes to case. decal_primarynumber_0.ace will work. decal_Primarynumber_0.ace will not.


How the multi/sub-material is applied to the digits

Once all the individual placeholder materials are created, they must be assembled into a Multi/Sub-Object material with the same number of elements as there are digits in the number. For a four digit number, this material must have four sub-materials. This material must be called primarydigits. The placeholder sub-materials must be applied to the polygons in the number object in reverse. ie. primarynumber_0 is the last digit. primarynumber_1 is the second to last digit etc.

Texture requirements

The diffuse (left) and 8-bit alpha (right) channels for the digit textures.

The TrainDecal.fx shader allows for 8-bit alpha channels in the number textures (256 levels of grey instead of just black and white). The Diffuse channel should be the required digit colour for the model - black, white, blue etc. The most appropriate size for these textures is 32x64. The placeholder textures can be any format as they are discarded in game and replaced with the digit textures.
There must be 10 textures corresponding to the 10 digits. Name these textures something logical like number_X_black.ace where 'X' is the digit.

Object requirements

The object containing the digits must be named 1_0128_primarydigits_4 or similar. The '4' at the end of the name denotes the number of digits. The '0128' is the range in metres that the numbers are visible. So for a 7 digit number visible to 256m, the name would be 1_0256_primarydigits_7.

.CSV file setup

Train Simulator uses a comma-separated-variable list to pick out the train or wagon numbers. This .CSV file is simply a text file with the .CSV extension. Each line in the file should have two zeros and a required number, separated by commas. So if the engine could have numbers 0234, 0235, 5543 and 6548, the .CSV file would contain the following:

0,0,0234
0,0,0235
0,0,5543
0,0,6548


Blueprint editor setup

The NamedTextureSet blueprint

Two areas need to be setup in the blueprint editor. First, a NamedTextureSet blueprint must be setup in the folder containing the .ace textures for the numbers (number_0_black.ace etc). This blueprint should be set up as shown in the image here. Note that each number corresponds to the logically-named texture .ACE files.

Referencing the NamedTextureSet and CSV files

Second, the main engine (or wagon) blueprint must associate with the NamedTextureSet blueprint in the Primary named texture set as well as a .CSV file (in the Numbering list) containing a list of numbers to choose from. This should be setup as shown in the image here.

Example file

The best way to figure all this out is to learn by example. I've made a simple model that has 7 digits in it, (so the object name is primarydigits_7), and provided both the placeholder digit textures as well as the final textures seen in the game. In this example, the textures have two different colour digits in each texture so you can see how they can be used to do multiple sets of different coloured digits on a train without having to try to do multiple autonumber objects. Finally there's a sample XML blueprint and CSV file: ChrisTrains autonumbering example.