The 'mesh-asset' tag provides a very useful function - the ability to make one asset load a mesh file from a different asset.
Consider a set of houses to represent a housing estate. You will often find a number of very similar but subtly different houses grouped together. Making these in the traditional style (with each house having a different mesh and texture stored within it) can result in a scene that renders rather slowly. The alternative of using the same house (with no variation) repeatedly is a lot faster, but can look very artificial.
If you can arrange for the different meshes to use the same texture without significantly increasing either the size of the texture or the polygon count of the mesh, you can have your cake and eat it - keep the subtle variation between the different assets, but have the faster rendering too.
Set this up by exporting all the different meshes into a single asset (generally a 'kind mesh'), and make all the houses ('kind scenery') with a mesh table which reads something like:
The house assets only need their config file and DLS screenshot in them. They do not need a copy of the mesh or the texture. When the house asset is loaded, Trainz will load suburban-house-01.im from <kuid2:447264:12345:1> instead of from the current asset. Each mesh loaded from <kuid2:447264:12345:1> is a candidate for mesh stitching - so if all the houses use the same single texture file, you can place all the different houses together in a scene and they will all be stitched together into the same buffer. (If there is multiple textures, one buffer is used per texture). A reduction in the number of buffers used in a scene will result in a significant performance improvement in Trainz. An example of this (using cars rather than houses) is documented in detail in the HowTo section of the TrainzDev Wiki.
Another way that 'mesh-asset' can be used is to re-use the same mesh multiple times in assets with different kinds. Consider a road vehicle. You might want one version as a scenery asset to place in surveyor, another version that can be used as automated road traffic (and thus needs to be 'kind trackside'), and a third version as part of a product to load onto car carrying rail wagons. Using the 'mesh-asset' tag, you can make all these assets use the same copy of the mesh file.
It is important to note that you can reference any mesh based asset in a 'mesh-asset' tag. The convention if you are making a mesh library yourself is to use 'kind mesh', but there is no requirement to do so. You can load a mesh from any asset kind that might reasonably be expected to contain a mesh. That's approximately anything that inherits from the MeshObject class.
Note that 'mesh-asset' isn't a replacement for 'alias'. It is not a method of reskinning - the texture file will always be loaded from the referenced asset along with the mesh. It does, however, allow you to pick and choose which meshes are loaded, and control how they are attached to your model using your local mesh table.
Consider a set of houses to represent a housing estate. You will often find a number of very similar but subtly different houses grouped together. Making these in the traditional style (with each house having a different mesh and texture stored within it) can result in a scene that renders rather slowly. The alternative of using the same house (with no variation) repeatedly is a lot faster, but can look very artificial.
If you can arrange for the different meshes to use the same texture without significantly increasing either the size of the texture or the polygon count of the mesh, you can have your cake and eat it - keep the subtle variation between the different assets, but have the faster rendering too.
Set this up by exporting all the different meshes into a single asset (generally a 'kind mesh'), and make all the houses ('kind scenery') with a mesh table which reads something like:
Code:
mesh-table
{
default
{
mesh suburban-house-01.im
mesh-asset <kuid2:447264:12345:1>
}
}
The house assets only need their config file and DLS screenshot in them. They do not need a copy of the mesh or the texture. When the house asset is loaded, Trainz will load suburban-house-01.im from <kuid2:447264:12345:1> instead of from the current asset. Each mesh loaded from <kuid2:447264:12345:1> is a candidate for mesh stitching - so if all the houses use the same single texture file, you can place all the different houses together in a scene and they will all be stitched together into the same buffer. (If there is multiple textures, one buffer is used per texture). A reduction in the number of buffers used in a scene will result in a significant performance improvement in Trainz. An example of this (using cars rather than houses) is documented in detail in the HowTo section of the TrainzDev Wiki.
Another way that 'mesh-asset' can be used is to re-use the same mesh multiple times in assets with different kinds. Consider a road vehicle. You might want one version as a scenery asset to place in surveyor, another version that can be used as automated road traffic (and thus needs to be 'kind trackside'), and a third version as part of a product to load onto car carrying rail wagons. Using the 'mesh-asset' tag, you can make all these assets use the same copy of the mesh file.
It is important to note that you can reference any mesh based asset in a 'mesh-asset' tag. The convention if you are making a mesh library yourself is to use 'kind mesh', but there is no requirement to do so. You can load a mesh from any asset kind that might reasonably be expected to contain a mesh. That's approximately anything that inherits from the MeshObject class.
Note that 'mesh-asset' isn't a replacement for 'alias'. It is not a method of reskinning - the texture file will always be loaded from the referenced asset along with the mesh. It does, however, allow you to pick and choose which meshes are loaded, and control how they are attached to your model using your local mesh table.