# 生成道路

Roads are generated by tiling a decal created from a primary static mesh along the vector data available.道路是通过沿着可用的矢量数据平铺从基本静态网格创建的贴花来生成的。

Let's review the general workflow.让我们回顾一下基本的工作流程。

The article assumes that you have already added the data required for the terrain surface.假设您已经添加了所需的数据地形表面.

## 1. 准备一个基本对象#

First, we create a Mesh Static object that will be used as a building block for the generation.首先，我们创建一个 Mesh Static 对象，它将用作生成的构建块。

The Mesh Static object must be located and have a pivot at the origin (0, 0, 0).必须找到 Mesh Static 对象并在原点 (0, 0, 0) 处有一个枢轴。
1. Create a mesh (we use a plane for the road here): click Create —> Primitive —> Plane on the Menu bar.创建一个网格（我们在这里使用平面作为道路）：在菜单栏上，单击 Create —> Primitive —> Plane

2. Specify the mesh parameters. For our road, we set the following:指定网格参数。对于我们的道路，我们设置了以下内容：

注意
We recommend using more than a single segment to make road curves smoother.建议使用多个路段，以使道路曲线更平滑。
3. Inherit a material from mesh_base, set all necessary textures and parameters, and assign it to the mesh.mesh_base 继承材质，设置所有必要的纹理和参数并将其分配给网格。

4. 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).道路是通过沿轴 X, YZ向前轴）之一平铺基本网格来生成的，因此请确保您的网格方向正确——在这种情况下，向前轴是 X（红色箭头）。

5. 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.Geometry 非常消耗资源。因此，为了保持可接受的性能，您应该为基本网格设置 LOD。对于网格的每个表面，指定可见性和淡入淡出距离。这些设置将用于管理生成的样条对象的 LOD。

For more information on LOD settings, see Setting Up Object LODs.有关 LOD 设置的更多信息，请参见设置对象 LOD .

6. Move the mesh to the origin and export it to a .node file.将网格移动到原点并将其导出到 .node 文件.

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 Source2. 添加矢量数据源#

Currently, Sandworm allows using only offline vector data sources for the generation.目前，Sandworm 只允许使用离线矢量数据源进行生成。

1. In the Sources panel:Sources

• Clicking on Vector opens the window for adding Slots. Slots are designed to organize data.点击 Vector 打开添加插槽的窗口。槽被设计成将数据组织到不同的地形掩模中。

2. 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.当添加一个层，定义数据源类型使用：AssetsExternal Files。目前仅支持 *.shp*.geojson 作为资产。因此，如果您有其他类型的文件，您可以尝试将它们添加为 External Files

Click Import.单击 Import

3. 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 Data3. 指定过滤器来过滤矢量数据#

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. Filter 实际上是一组规则，用于从所有可用矢量数据的列表中挑选特定数据。规则是使用 Attributes 创建的。只有符合每个属性要求的对象才会基于此过滤器生成。

Filters are created as follows:过滤器创建如下：

1. Click the Add button in the Filters window of the Parameters panel.单击 Parameters 面板的 Filters 窗口中的 Add 按钮。

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.双击过滤器以指定过滤器名称。要删除过滤器，请使用 Remove 按钮。您可以根据需要添加任意数量的过滤器。

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.Share 按钮允许在掩码之间共享使用过滤器。在弹出窗口中选择共享此过滤器的掩码。共享过滤器中的更改将应用于所有遮罩中

2. 从您创建的槽中选择一个槽 (Sources -> Vector)。槽被设计成将数据组织到不同的地形掩模中。
3. 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.可用的运算符是：=, !=, >, <, ANYANY 生成为所选属性分配了任何值的所有对象。

You can also select attribute values from the Attributes table. The table opens using the sign on the right of the attribute expression.您还可以从 Attributes 表中选择属性值。该表使用属性表达式右侧的 符号打开。

Double-clicking on a value in the table adds it to the attribute value field.双击表中的值将其添加到属性值字段。

4. 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.要添加更多属性，请使用“+” （加号）按钮。您可以根据需要为一个过滤器添加任意数量的属性。 可以在过滤器中的属性之间设置 ANDOR 交互。

To remove an Attribute, use the button to the right of the Attribute expression.要移除过滤器，请使用属性表达式右侧的 按钮。

## 4. Specifying Parameters of Vector Objects4. 指定矢量对象的参数#

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.在这一步中，我们将设置对象，将生成和放置在表面的地形，根据数据挑选出的过滤器

1. On the Sources panel, click + Add Object.Sources 面板上，单击 + Add Object.