This tutorial requires the Mesh Buildings Enabler to be installed. Download here: Mesh Buildings Enabler
Step 1: Create the mesh
First of all you need to know what type of building you want to create. There are residential, commercial, industrial and leisure buildings in the game. Next you need to choose a size. It must always be dividable through eight. Here are the sizes for the default lots::
Width | Depth | |
Small | 16m | 24m |
Medium | 24m | 24m |
Large | 32m | 32m |
Very Large | 48m | 40m |
The width is the y-axis in the modeler and the x-axis in the game. The depth is the x-axis in the modeler and the y-axis in the game. The house gets always placed in the center of the lot with the positive x-axis (in the modeler) facing the road. The axes mentioned refer to a right-handed, z-up system.
Next you need to choose a capacity of workers/residents/customers for your lot. Here you can see the capacities of the default lots:
Residential | Commercial | Industrial | Leisure | |
Small | 1-4 | 1-16 | 1-8 | 1-16 |
Medium | 5-10 | 17-40 | 9-20 | 17-40 |
Large | 11-18 | 41-72 | 21-36 | 41-72 |
Very Large | 19-100 | 73-400 | 37-200 | 73-400 |
Since the house can be placed on a sloped road, you should create a foundation for your building, that goes a few meters into the ground.
Step 2: Placement of files
Files should be placed here:
MESHES (.msh/.msh.blob):
– res\models\mesh\building\{YourSetName} (if you create a set of buildings)
– res\models\mesh\building\residential
– res\models\mesh\building\commercial
– res\models\mesh\building\industrial
– res\models\mesh\building\leisure
TEXTURES (.tga):
– res\textures\models\building\{YourSetName} (if you create a set of buildings)
– res\textures\models\building\residential
– res\textures\models\building\commercial
– res\textures\models\building\industrial
– res\textures\models\building\leisure
MATERIALS (.mtl):
– res\models\material\building\{YourSetName} (if you create a set of buildings)
– res\models\material\building\residential
– res\models\material\building\commercial
– res\models\material\building\industrial
– res\models\material\building\leisure
MODELS (.mdl):
– res\models\model\building\{YourSetName} (if you create a set of buildings)
– res\models\model\building\residential
– res\models\model\building\commercial
– res\models\model\building\industrial
– res\models\model\building\leisure
BUILDING UTILITY DATA (.bud):
– res\config\building\bud\meshbuildings\{YourSetName} (if you create a set of buildings)
– res\config\building\bud\meshbuildings\residential
– res\config\building\bud\meshbuildings\commercial
– res\config\building\bud\meshbuildings\industrial
– res\config\building\bud\meshbuildings\leisure
Step 3: Create your model
A typical .mdl file for a model looks like this:
function data()
return{
boundingInfo = {
bbMax = { 7.9, 11.9, 8.5, },
bbMin = { -7.9, -11.9, 0, },
},
collider = {
params = { },
type = "MESH",
},
lods = {
{
children = {
{
id = "building/residential0/mymesh.msh",
transf = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, },
type = "MESH",
},
},
matConfigs = { { 0, }, },
static = false,
visibleFrom = 0,
visibleTo = 2500,
},
},
metadata = {
},
}
end
Display More
The bounding box is (as always) very important. If it's too big, the model will not be displayed / the building will not be chosen. Always make it 0.5m to 1m in each direction smaller than the ground size is. Is the size of one direction not equal to the opposite direction, the model will be centered so that the bounding box is centered.
Also of importance is the “visibleTo” value. Buildings should be displayed even when fully zoomed out. So turn it up real high (as in the example above) and make the mesh either very low-poly or create multiple LODs.
Step 4: Create the building data
Now comes the part which is probably new to you. Create a .bud text file with the following content in the appropriate folder (see step 2):
QuoteDisplay Morelocal dasmatze_meshbuildings = require "dasmatze_meshbuildings"
function data()
result = dasmatze_meshbuildings.create()
result.availability.yearFrom = 1800
result.availability.yearTo = 99999
result.type = "RESIDENTIAL"
result.capacity = { 1, 4 }
result.parcelWidth = { 3, 3 }
result.parcelDepth = { 3, 3 }
result.params.assetCenter = "building/residential0/mymodel.mdl"
result.params.assetGarden = { "asset/park_fountain_1.mdl", "asset/park_fountain_2.mdl" }
result.params.assetTree = { "all" }
result.params.assetProbGarden = .0
result.params.assetProbTree = .0
result.params.matWall = { "wall_stone1.btd", "wall_stone2.btd" }
result.params.shapeGridSize = 6.0
return result;
end
The green colored lines are completely optional. If you leave them out, the default parameters are used most of the time.
"result.availability.yearFrom" and "result.availability.yearTo" must not be 0 otherwise they might crash the game. Use a very high number if you want to make it available almost forever.
Here are the rest of the parameters:
Parameter | Description |
result.type = "RESIDENTIAL" | The type of the lot. Possible values are RESIDENTIAL, COMMERCIAL, INDUSTRIAL and LEISURE |
result.capacity = { 1, 4 } | The capacity of the lot. A random value between the first value (low value) and the second value (high value) is chosen when a building gets built. It always fits the cities needs. |
result.parcelWidth = { 3, 3 } | The width of the lot. Caluclated by width divided by eight. No decimal values are allowed. If the value is too high, the chance of it appearing sinks drastically. See the data table in step 1 for default sizes which are always appearing. Both values should be the same. |
result.parcelDepth = { 3, 3 } | The width of the lot. Caluclated by width divided by eight. No decimal values are allowed. If the value is above six, it will never appear. See the data table in step 1 for default sizes which are always appearing. Both values should be the same. |
result.params.assetCenter = "" | The model you created which gets placed in the center of the lot. |
result.params.assetGarden = { } | An array of garden assets (.mdl) placed randomly in the part of the lot that is not blocked by the bounding box of the building's mdl file. By default no assets are used. |
result.params.assetTree = { } | An array of possible tree models you want to use on your lot. |
result.params.assetProbGarden = .0 | Not sure what this does, but the higher the number, the more garden assets are placed. It's probably a value between 0 and 1. By default it won't spawn any garden assets. |
result.params.assetProbTree = .0 | Not sure what this does, but the higher the number, the more trees are placed. It's probably a value between 0 and 1. By default it won't spawn any trees. |
result.params.matWall = { } | An array of walls from the folder "res\config\building\btd\wall" which are placed at the edges of the lot beneath the ground (so that there is a wall when the house is placed on a sloped road and floats in the air). By default, there won't be any walls. |
result.params.shapeGridSize = 6.0 | This defines how accurate the terrain gets leveled around the building. The higher the value, the more precise it'll be. Six is a good value to work with. |
Step 5: Test it in the game
If you did everything right, you should have a a custom building in the game.
[Blocked Image: http://www.train-fever.net/index.php/Attachment/15221-Picture-jpg/]
Congratulations! The Train Fever Community awaits some cool buildings from you now.
If you have any trouble concerning this tutorial/mod, leave a comment/reply here or in the Mesh Buildings Enabler Thread.