-
-
Notifications
You must be signed in to change notification settings - Fork 49
User guide: Custom road meshes
This page provides an overview of how to hand model custom road pieces to use in Godot.
While the roads created by this addon are suitable for a wide range of scenarios, and will soon support procedural intersections as well (reference), sometimes you need to author or customize the meshes for more control.
However, you also might want to benefit from the other road generator features such as AI path lanes, roadside decoration curves, and connection/snapping tools. This tutorial shows a way to get the best of both worlds, even starting with the adodn's procedurally generated geometry in order to save a little time while making your own meshes.
For the purpose of this tutorial, you can start with a pre-existing road layout or start a fresh scene. We will visualize creating a custom 2x2 intersection, but the concepts apply to any RoadContainer with 1 or more "open edges".
-
Create your road network, with these best practices in mind (or start with step 3, if you just want to create an intersection)
- Add a RoadManager parent node for your roads
- Add RoadContainers as children to group logical sections together
- Plan or identify which set of RoadPoints you want to use for custom mesh creation, and put them into their own RoadContainer
- Use the connection tool (+ mode) to bridge the gap between two RoadContainers to ensure the entire network gets closed up.
-
Identify one RoadContainer you want convert into a hand-modeled mesh
-
Optional: If you want to make this a reusable component, then right click that container, and save to a scene to a new file
- Notice how the RoadPoints of this RoadContainer in the original scene are now more grayed out and cannot be directly selected.
- For all intents and purposes, the parent road manager now treats your saved subscene as a static block, like a puzzle piece.
- Double click and enter the saved subscene - you might want to change the root node name to something descriptive if you haven't already, but be aware that changing node names in your source scene may break the connections between other road elements.
- For our 2x2 intersection, we start with a fresh scene which looks like this - we have overlapping geometry, but we'll fix that later
-
-
Select the RoadContainer node, and then press the Export to gLTF button in the Inspector panel or from the Roads menu
-
- This will prompt you to save it somewhere. You likely want to save the path into a folder in your project to make it easy for future editing
- You likely will want to tick the box for "instance after export", which will automatically import the gLTF as a child of the RoadContainer. This way, when you overwrite the gLTF with update geometry, you'll see the results immediately in godot.
-
-
-
Now open this gLTF file in any 3D modeler, and edit away!
- For the purpose of this tutorial, we'll showcase using Blender
- Even if you completely throw away the original geometry provided by the Road Generator, you still can use it as a reference for the positions of the RoadPoints which are exported as empties.
- Some tips from my own experience, written with Blender operations in mind:
- Clear all parents and apply position, followed by deleting all empties that came from the gltf file - we don't need to keep them, as we only really care about exporting a single mesh
- Start by selecting all verts in edit mode across all meshes, and use the "merge by distance" operaetor to ensure all faces are connected
- Then, use tris-to-quads to make the meshes easier to work with
- Consider duplicating your original import meshes into an archive or separate collection, so it's easy to debug if you accidentally shifted the verts that should not be touched, ie those on the outside edges which form the profiles of the connections.
- At this point, your scene could look like this:
-
- After you finish your modeling, you should end up with a single mesh more like this. How to achieve this modeling outcome is beyond the scope of this tutorial.
-
-
Once ready, export the minimal part of your new mesh out to a new gLTF (suggested), this time into the godot project structure in a final persistent location.
- If you are using Blender 4.2 or higher, it's a good idea to set up an "export collection" to make it very fast and easy to re-export the mesh in the future. There's a decent chance you realize you need to tweak something, and you don't want the hassle of figuring out settings each time
- Suggested settings to change from the defaults for blender:
-
-
Back in Godot, load up your saved RoadContainer scene. Select that root container node, and uncheck the box for "Create geo"
- This step is already done for you if you used the "Instance after Export" button in the prior steps
- This is how we'll tell the addon to skip the mesh creation stage, while keeping all the other connection-related tooling.
-
Drag in your new gltf export, making sure the transforms are cleared out.
- This step is already done for you if you used the "Instance after Export" button in the prior steps
- If you exported materials as placeholders as suggested, you'll need to go in and reconnect the original material that is currently referenced on your parent RoadContainer object
-
- You probably also want to create a trimesh static body based on the imported geometry. The built in colliders are typically set up by the Road Generator, but this was disabled when we unticked "create geo" before. Be sure this gets saved into your editing scene, as it might get lost if you leave it as a child of the glb referenced child scene.
-
If you rely on the RoadLanes for AI path following, now is the time to create some extra lanes.
- Thankfully you don't have to create all of the RoadLanes, just those not already auto generated by the original connected RoadPoints. If you haven't already, enable "Generate Ai Lanes" on the RoadContainer to save time creating these ones manually.
- In the case of our 4way intersection, I decided to connect the inner most lanes as left turns, and the outter most lanes to right turns since that is most common. Once you set it up for one cardinal direction, you can use the transform dialog to create the other four orientations, result in 8 total custom placed RoadLanes (but sharing the same 2 curves between them all). If you turn off "Display RoadLanes in Editor" on the source scene, we can easily see just the ones we've added:
-
-
Return to your source full scene, and you should find your custom model in place ready to go. Or, if you were creating this scene from scratch, you're now able to drop it into another scene and move it around until is snaps to other open RoadPoint's. Either way, this is now a reusable scene!
-
This above example worths the same for any RoadContainer, including those that have more than just two edge RoadPoints. That means this is a great way to create custom geometry for your intersections, something the plugin is not highly capable of doing just yet.
If you are mocking up an intersection which requires some "internal" RoadPoints, be sure to mark them as "terminated" so they are not considered edges from the standpoint of the RoadContainer. If you don't do this, it would be possible to snap and connect other roads to the one lane edge below closest to the viewport camera: