How to add collision to an asset
(Created page with "== How to add Collision to an Asset == Since T:ANE, assets have the ability to have collision meshes for PhysX simulation. By default, Trainz will create an rectangular outli...") |
(→How to add Collision to an Asset) |
||
Line 1: | Line 1: | ||
== How to add Collision to an Asset == | == How to add Collision to an Asset == | ||
− | Since T:ANE, assets have the ability to have collision meshes for PhysX simulation. By default, Trainz will create an rectangular outline of the mesh using the highest point of the mesh for the top of the collision mesh. As a result, smoke will not react properly. To rectify this, collision must be disabled completely in the Trainz Settings, or the mesh must have it disabled manually. In this tutorial, we will be adding a collision asset to a [[KIND_MOCrossing]] asset, but it can be applied to any asset type in the game. This tutorial will work for [[FBX file format]] or legacy [[IM files]]. | + | Since T:ANE, assets have the ability to have collision meshes for PhysX simulation. By default, Trainz will create an rectangular outline of the mesh using the highest point of the mesh for the top of the collision mesh. As a result, smoke will not react properly. |
+ | |||
+ | [[File:DefaultTrainzCollision.png|800px]] [[File:ThomasCollision.png |800px]] | ||
+ | |||
+ | To rectify this, collision must be disabled completely in the Trainz Settings, or the mesh must have it disabled manually. In this tutorial, we will be adding a collision asset to a [[KIND_MOCrossing]] asset, but it can be applied to any asset type in the game. This tutorial will work for [[FBX file format]] or legacy [[IM files]]. | ||
'''At the moment, self-collision (smoke generated by a locomotive hitting locomotive collision volumes) is not supported.''' | '''At the moment, self-collision (smoke generated by a locomotive hitting locomotive collision volumes) is not supported.''' |
Revision as of 07:33, 17 September 2019
Contents |
How to add Collision to an Asset
Since T:ANE, assets have the ability to have collision meshes for PhysX simulation. By default, Trainz will create an rectangular outline of the mesh using the highest point of the mesh for the top of the collision mesh. As a result, smoke will not react properly.
To rectify this, collision must be disabled completely in the Trainz Settings, or the mesh must have it disabled manually. In this tutorial, we will be adding a collision asset to a KIND_MOCrossing asset, but it can be applied to any asset type in the game. This tutorial will work for FBX file format or legacy IM files.
At the moment, self-collision (smoke generated by a locomotive hitting locomotive collision volumes) is not supported.
Making the Collision mesh
A collision mesh should be a very simple representation of your asset, with all of the important areas you want to have collision water tight (no gaps in the mesh). This asset should be no more than a couple hundred triangles, with a M.notex material used to prevent extra draw calls.
In this example, I am using a Thomas the tank tunnel. The pink tracks are examples where trains run through the "tunnels" inside Thomas. We will want to make a mesh that contains cut outs for the trains to go through. The holes in this mesh will represent the surface area the particles can bounce off of.
Here is the main body separated from the rest of the asset. The holes represents where we want our smoke particles to be able to hit, but nothing else.
Our collision mesh does not include the smoke box area since this part is animated. Notice the faces on the "tunnel" part are facing inward, since we want the smoke particles to hit the top of the "tunnel". Every part of the mesh you'd like to have a particle hit, make sure it is solid on your collision mesh.
In this final picture we can see what our collision mesh looks like overlaid on top of the asset.
Setup In-game
When the collision mesh is complete, export it like any other mesh for Trainz. While no specific name is required for the mesh, a good name for it could be mesh_collision.trainzmesh (or im).
TODO
Sample Files
Included in this zip are the .blend and FBX files for the base Thomas body and the collision mesh. Textures are not included but are not necessary for this example.