If you wish to follow this tutorial to the letter, you'll need to download the example files first. This tutorial naturally cannot teach you to create 3D models; it is merely focused on using an existing model, importing it into the game and adding so it can be placed in the game world.
Let's first open the Watchtower_TM.blend blender file. In it you'll see 4 build stages, with the fourth one being the completed building.
We'll also need the hit mesh. Without it, you won't be able to select the object in the game using the mouse. The hit mesh should be a simple, low-poly model that encompasses the entire object. The hit mesh model should have a material assigned, but the UV map and normals are ignored.
The next step is to separate the individual meshes by material; only one material per mesh. Then export each mesh as a separate .fbx file.
Before exporting, double check that all mesh faces are oriented properly, triangulated, have well placed pivots and normals and applied scale and rotation. Additionally, the model should be facing the Y axis, with Z axis as up in Blender. The Material editor, which comes quite soon, has Z axis as forward and Y axis as up.
The image below shows the desired Blender export settings for static models (no bones / armature). A good practice is to create an export preset in Blender.
Now that all the models have been exported, we'll go into the game folder. Data\Models\Buildings to be more precise. We'll create a new folder for the watchtower called Watchtower_TM. To keep things clean, and that's always a good idea, let's create a sub-folder called Mesh. Here's we'll export/copy all the model (.fbx) files exported from Blender. Later we'll be adding lights, particles etc. so it's good practice to keep everything clean from the start and on each step.
It's time to dive into the Material editor. Start the .exe located in the game installation folder.
- Click on the New Assembly button
- Drag and drop fbx files to import them. For easier tracking, import one whole building stage set at a time.
- The imported models appear in the Assembly Properties / Elements panel
- Let's select the first model in the list
- To save an imported .fbx model as a compressed (game-native) .mdl model, click on the Model Editor icon
- Then click on the Save As New Compressed Whale Model button
Save the .mdl into the same folder as the .fbx file. Once the .mdl file is don, return to the Material Editor and switch back to the Assembly Editor (shortuct: A) and repeat the process for all individual imported models in the list. Once all the models are handled, it's time to save the entire object, the assembly, as an assembly file (.asb).
- Return to the Assembly editor (shortcut: A)
- Click on the Save Assembly button
Save the Assembly into the same folder we created earlier Data\Models\Buildings\Watchtower_TM . Repeat the same process outlined above for all the remaining building stages. If everything went as expected, this should be the situation inside the Mesh\ folder
HINT: Right-click inside the folder, go to Group by and then select Type, to sort files in the manner shown in the image. This should make it easier to see if everything is in order, regarding files.
One level above, in the main folder, the situation should be the following:
Great! We have all the parts, collected and contained properly in the assembly file. Let's open that .asb file in any text editor and tweak some things.
- Link the materials to the materials already in the folder
- Set the DrawDistance to 500. There is no need to render the model outside of the camera view. We can add LOD (level of detail) models to optimize model rendering.
As a nice double-check, we'll load up the Watchtower_TM assembly in the Material Editor. Also open the PatronLog.txt to make sure there are no errors in there. If everything checks out, we should have a complete Stage_A model with textures.
Resolve all the remaining assembly files (stages) in the same manner. The only exception is the final stage, WatchtowerTM_Final.asb requires several additional materials to be relinked.
- Doors
- Flowers
- Roof Clay
It's time to finish up the final stage of the model (WatchtowerTM_Final.asb). First position the doors in their proper place. The door model has a specifically placed pivot so they could be opened properly. This is not required, though. The doors can be positioned by dragging the doors in their place or by typing in the position manually.
- We've added a slight rotation to the doors so they look opened a bit. This is, of course, a thing of personal preference.
- Click on the Help button (shortcut : H) to get a list of helpful tips and shortcuts
- This is the list of available controls
- We can also enable the Show Coords (X, Y, Z) in the editor for additional help when moving models around
- Also, don't ignore the various view modes of the model editor
Next up is setting up the Frustum ball. The frustum must encompass the entire assembly in order for it to render properly in the game.
- Toggle displaying frustum
- Frustum size
What remains is the AABB box, used when rendering shadows.
- Toggle displaying AABB box
- Enable AABB box
- AABB box size
Don't forget to save the WatchtowerTM_Final.asb assembly. To make things faster, we'll simply copy/paste the Frustum and the AABB box into the other building stage assembly files using a text editor.
Remember that hit mesh from the beginning? Yep. We're on it now. Export it from Blender and import it into the Material editor following the same steps we used before. This time, however, we only need the .mdl file. Proceed to add it into the assembly.
- Click on the arrow to add a hit mesh. We'll be prompted for the hit mesh .mdl file
- Toggle displaying the hit mesh
- Save the assembly
It's good practice to double check if the path to the hit mesh .mdl is correct, by checking the file in the text editor. The hit mesh (collision) must be the last .mdl in the list.
We're almost there Patron. All we need now is the After burn variant. If a raging fire burns down the building, this assembly is what will remain. To make the tutorial easier and quicker, we'll simply duplicate the Stage_A assembly and only relink the WatchtowerTM_A_FloorPlanks to the burnt material version, so it looks... well... like it burned up.
- Set the material path to the new "burned" value
Let's now open the .bui (building) file and scroll to the bottom, to the BuildingStage section
- Relink to the new build stages
- Add/relink to the new "burned" variant
Save the .bui file. The building is ready to be added into the game for usage and for that proceed to the Adding a watchtower to the game article.