shown in other instead.
Roads are generated by tiling a decal created from a primary static mesh along the vector data available.
Let's review the general workflow.
1. Preparing a Primary Object#
First, we create a Mesh Static object that will be used as a building block for the generation.
Create a mesh (we use a plane for the road here): click Create —> Primitive —> Plane on the Menu bar.
Specify the mesh parameters. For our road, we set the following:We recommend using more than a single segment to make road curves smoother.
Inherit a material from mesh_base, set all necessary textures and parameters, and assign it to the mesh.
The road is generated by tiling the primary mesh along one of the axes X, Y, or Z (forward axis), so make sure that your mesh is oriented correctly — in this case, the forward axis is X (red arrow).
Geometry is very resource-consuming. Thus, to maintain acceptable performance, you should set up LODs for the primary mesh. For each surface of the mesh, specify visibility and fade distances. These settings will be used for managing LODs of generated spline objects.
For more information on LOD settings, see Setting Up Object LODs.
Move the mesh to the origin and export it to a .node file.
Now that the primary node for roads (the *.node asset) is ready to use, you can delete it from the scene.
2. Adding a Vector Data Source#
Currently, Sandworm allows using only offline vector data sources for the generation.
In the Sources panel:
Clicking on Vector opens the window for adding Slots. Slots are designed to organize data.
- Clicking on + Add Layer provides the toolset for uploading vector data.
When adding a layer, define the type of Data Source to be used: Assets or External Files. Currently, only *.shp and *.geojson are supported as assets. Therefore, if you have other types of files, you can try to add them as External Files.
- In the window that opens, select the set of files to be used as vector data.
When the vector data is added, its image is displayed atop all the layers in the Preview panel (you may change the order of layers display by RMB click on a layer in the list of sources), and the Vector layer parameters become available.
3. Specifying Filters for Vector Data#
The Filter is a set of rules used to pick the specific data from the list of all available vector data. The rules are created using Attributes, and only the objects that fit the requirements of every attribute are generated based on this Filter.
Filters are created as follows:
Click the Add button in the Filters window of the Parameters panel.
Double-click on the Filter to specify a Filter name. To remove a Filter, use the Remove button. You can add as many Filters as necessary.
The Share button allows shared use of the Filter among source data layers. Select the source data layer that will share this Filter in the pop-up window. Changes in a shared Filter will be applied to it in all source data layers.
- Select a slot from those created by you (Sources -> Vector).
For each Filter, set an Attribute (or Attributes) to filter specific data from the vector source. The required data is filtered using the attribute value and a suitable operator. Autocomplete is available — you can type in Attribute names and values or select them from the Attribute list.
The available operators are: =, !=, >, <, ANY. ANY generates all the objects that have any value assigned for the selected attribute.When using > and <, make sure that the selected attribute type is a number. String comparison may cause issues.
You can also select attribute values from the Attributes table. The table opens using the sign on the right of the attribute expression.
Double-clicking on a value in the table adds it to the attribute value field.
To add more attributes, use the "+" (plus) button. You can add as many Attributes for one Filter as necessary. It is possible to set AND and OR relations between the Attributes in the Filter.
To remove an Attribute, use the button to the right of the Attribute expression.
4. Specifying Parameters of Vector Objects#
In this step, we set objects that will be generated and placed across the terrain's surface according to the data picked out by the Filter.
On the Sources panel, click + Add Object.
In the drop-down, select the type of object you are will generate according to the slot data. In our case, it is Roads. Click Import.
Set the following object parameters:
|Vector Slot||A Slot created by you to organize data using Filters.|
|Object Name||The object's name that is displayed in the Objects list in Sandworm and in the World Nodes hierarchy when the terrain is generated.|
|Node||The path to the primary object's *.node file.|
|Decal Texture Resolution||
Resolution of the decal texture into which road projections are baked.
Flag indicating whether the segment splitting mode is enabled. In this mode, all line segments will be divided into subsegments of the specified length (if this length does not exceed the length of the segment itself). This parameter can be used to provide smoother curving and better alignment of decals with the terrain.
|Split Segment Length||
Length of the subsegment for splitting mode, in units.
Splitting a segment into too many subsegments (i. e. using very small values) affects the generation time and memory consumption.
|Split Lines Length (km)||Roads are projected onto a terrain using the Decal object. A decal object might be too big, and it is split into segments for optimization purposes. Splitting the lines implies forming a grid with a cell size defined by this Split Lines Length value and making the grid cells individual Decal objects.|
|Adjust Terrain Heights and Masks||
Flag indicating whether terrain heights and masks will be adjusted for generated roads. When this option is enabled, the following terrain data will be modified in the areas along the roads (vector data) having the width specified by the Area Width parameter:
Width of the area along the spline to be affected by heights and masks adjustment.
Available only when heights and masks adjustment is enabled.
|Forward axis||Axis along which the primary mesh is to be extruded or tiled.|
5. Generating Roads#
If the terrain has already been generated and you made no changes to it, you can regenerate only the vector data. In the corresponding settings, disable the data types you don't need to be regenerated.
A terrain fragment with roads generated based on vector data using the primary mesh object: