视频教程
界面
要领
高级
实用建议
UnigineEditor
界面概述
资产工作流程
设置和首选项
项目开发
调整节点参数
Setting Up Materials
Setting Up Properties
照明
Landscape Tool
使用编辑器工具执行特定任务
Extending Editor Functionality
嵌入式节点类型
Nodes
Objects
Effects
Decals
Light Sources
Geodetics
World Objects
Sound Objects
Pathfinding Objects
Players
编程
基本原理
搭建开发环境
Usage Examples
UnigineScript
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine Tools
GUI
双精度坐标
应用程序接口
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
创建内容
Content Optimization
Materials
Art Samples
Tutorials

Generating Buildings

Warning
The functionality described in this article is not available in the Community SDK edition.
You should upgrade to Engineering / Sim SDK edition to use it.

Sandworm allows procedural generation of buildings based on shapes stored in the vector data sources. This article reviews the general workflow as well as the main concepts of the buildings composition to give a deeper understanding of how the assets should be prepared.

Main Concepts#

For the sake of generation of buildings, we differentiate between the following two types of buildings:

  • Single-storey buildings, which have only one floor
  • Multi-storey buildings, which have two or more floors

Conceptual representation of single-storey and multi-storey buildings
  • Underground Pedestal is always 2 meters down from the terrain level. This value is hardcoded and cannot be changed.
  • The Pedestal height is defined by the Ground floor offset value and is 1 meter high above terrain by default.
  • The Ground Floor height is defined by the Floor height value and is 3 meters high by default.
  • The height of Upper Floors equals Number of Upper Floors * Floor height.

Buildings Texturing#

UNIGINE provides a set of built-in materials for generated buildings: they are inherited from mesh_base and named according to the rules. You can also create your custom textures and set up materials. However, your textures should meet a set of requirements described below.

There are four types of textures that should be prepared for a building: a texture for the basement, a texture for the wall with openings (doors and windows), a texture for the solid wall, and a texture for the roof. The UV map of each part of the building depends on the size of the wall segment that is shown on the texture.

Notice
Textures for walls differ depending on the part of the building they are applied to: if a texture is applied to Basement, it should depict Pedestal and Underground Pedestal.
  • For Underground Pedestal and Pedestal, a single texture for a wall is applied. The texture height should correspond to the height of all these parts (in sum).

    Texture for Underground Pedestal and Pedestal (Basement)
  • For the ground floor, an individual texture is applied. The texture height should correspond to the ground floor height.

    Texture with openings for Ground Floor
    Solid texture for Ground Floor
  • For Upper Floors, a single texture for a wall with openings is applied. The texture height is usually a multiple of the floor height. It can be a multiple of the two, three, etc. floors height, however, it shouldn't exceed the height of the Upper Floors part.
    Texture with openings for Upper Floors
    Solid texture for Upper Floors
  • If the wall width is less than the floor height, a segment of the texture with openings does not fit into this space properly, and the texture for a solid wall is applied.
  • If the wall width is more than the floor height, the wall surface is split into two parts:
    • The first part is tiled with a texture with openings. Its width is multiple of the floor height.
    • The second part, where the texture with openings does not fit, is tiled with the solid texture.

    For example, we have a two-storey building with the floor height of 3 meters. The sufrace of the second floor wall is 10.5 meters wide and is divided as follows:

    The texture for a wall with openings is applied to each 3*3 m segment (based on the floor height value). For the rest of the wall, the solid texture is applied.

  • For Roof, two textures should be applied: the base and detail albedo textures. Using the detail texture allows you to diversify colors of roofs with the same material: set up details rendering (blending, masking, UV mapping, shading parameters of the texture) for the Roof material to achieve the required result.
    Base albedo texture
    Detail albedo texture

Materials Naming#

For materials to be correctly applied by Sandworm to the generated buildings, follow these rules:

  • Each building category should have a separate base material inherited from mesh_base. This material is used as the material for the Ground Floor wall with doors and windows.
    Notice
    For this material, a texture depicting the Ground Floor should be used.
    The other materials applied to different parts of the same building are inherited from this one. The base material can have any desired name.
    Notice
    When specifying parameters of the buildings, only the base material is specified: its child materials are loaded automatically.
  • Materials for the other parts of the building should be inherited from the parent material described in the previous paragraph and use the following name postfixes:
    • _basement — a material for Pedestal and Underground Pedestal.
    • _level_1_blank — a material for Ground Floor wall without doors and windows.
    • _level_2_complex — materials for Upper Floors walls with doors and windows.
    • _level_2_blank — materials for Upper Floors walls without doors and windows.
    • _roof — a material for Roof.

For example, if you have 2 types of buildings that should have different materials, set up the following hierarchy:

Hierarchy of materials for buildings

1. Adding a Vector Data Source#

Currently, Sandworm allows using only offline vector data source for generation.

  1. In the Source Data panel, add a new vector data layer.
  2. In the Parameters panel, 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.

    Click 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 (the order of layers display may be changed), and the Vector layer parameters become available.

2. Specifying Tags to Filter Buildings#

The Tag is in fact a set of rules used to pick the specific data from the list of all available vector data. The rules are created using the Attributes. Only the objects that fit to the requirements of every attribute are generated based on this tag.

Generating buildings requires two types of tags:

  • The tag that filters out the buildings from the list of vector data — Tag
  • The tag that defines the number of floors and is used for generation purposes — Floor Number Tag. This tag either contains the specific number of floors (not a range), or the value ANY that implies that buildings with any number of floors are generated.

Tags are created as follows:

  1. Click the Add button in the Tags window in the Parameters panel.

    Double-click on the tag to specify a tag name. To remove a tag use Remove button.
  2. For each tag, set an attribute (or attributes) to filter certain data from the vector source. The required data is filtered using the attribute values and suitable operator. Autocomplete is available. You can type in attribute names and values.
  3. The available operators are: =, !=, >, <, ANY. ANY generates all the objects that have any value assigned for the selected attribute.
    You can also select attribute values from the Attributes table. The table opens using the sign on the right of the attribute expression.
  4. To add more attributes, use the "+" (plus) button. You can add as many attributes for one tag as necessary.
    Notice
    If several attributes are set, only the data that comply with all the attributes will be selected.


    To remove a filter, use the button to the right of the attribute expression.

3. Specifying Parameters of Buildings#

In this step, we are going to set the parameters for buildings that will be generated on the terrain according to the data filtered by the tag.

In the Objects window, click Add to add the object that will be generated on the terrain based on the vector data specified for it. The dialog window will open. Set Type: Buildings to see these settings:

Set the following object parameters:

Name The object's name, which is displayed in the Objects list in Sandworm and in World Nodes when the terrain is generated.
Tag The tag to filter objects from the vector data.
Notice
This tag should include all building-specific data except for the number of floors, which is set separately as the Floor Number Tag.
Type Type of the vector object to be generated. In this case, we are generating Buildings.
Floor Number Tag The tag that is used to sort out from the vector source the buildings with the required number of floors. This tag is created with the attribute that specifies the number of floors. Based on the attribute value, the actual number of floors is generated for the building. Here only the following three options are possible:
  • The attribute value of the tag selected here is set to ANY — in this case all buildings filtered by the Tag are created, with the number of floors identified for each building.
  • The attribute value of the tag selected here is set as equal (=) to one specific number — in this case only the buildings with this specific number of floors out of the data filtered by the Tag are created: for example, if the attribute value of the Floor Number Tag is equal to 4, only the 4-storey buildings from the data sorted according to the Tag will be generated.
  • The Floor Number Tag value is set to None — all buildings filtered by the Tag will be generated as single-floor buildings.
Floor Height The height of a floor in the generated buildings. The default value is 3 meters.
Ground Floor Offset The height of pedestal. The default value is 1 meter.
Split Length The size of the grid cell by which the generated geometry will be divided. Geometry of each cell is represented as a separate ObjectMeshStatic object. If the specified value exceeds or equals to the size of the Export Area, a single static mesh will be generated. For example, if you specify 100 and have a 1000x1000 km area, the buildings will be generated as 10 separate static meshes, 100x100 km each.
Floors Per Texture The number of Upper Floors for which a single texture is applied:
  • If the texture height corresponds to the height of a single floor, this value should remain 1. The texture will be applied for each floor.
  • If the texture height corresponds to the height of two/three/etc. floors, this value should be set to 2/3/etc. The texture will be applied for every two/three/etc. floors.
  • If the texture height is equal to the height of the Upper Floors part, this value should be equal to the number of Upper Floors.
Base Material Material applied to the buildings tagged to the basic object. The default material for buildings is already set. If you want to change it to a custom materal, ensure that the materials are named correctly.
Min Visibility Minimum visibility distance from the camera at which generated objects (ObjectMeshStatic) start to appear on the screen. By default, this value is -inf.
Max Visibility Maximum visibility distance at which generated objects (ObjectMeshStatic) are no longer fully visible: they can either disappear completely or start to fade out. By default, this value is inf.
Min Fade Minimum fade distance, over which generated objects (ObjectMeshStatic) fade in until they are completely visible. Along this distance, the engine automatically interpolates the level of detail from alpha of 0.0 (completely invisible) to 1.0 (completely visible). Fading in starts when the camera has reached the minimum visibility distance and is in the full visibility range.
Max Fade Maximum fade distance, over which generated objects (ObjectMeshStatic) fade out until they are completely invisible. Fading out starts when the camera has reached the maximum visibility distance and is out of the full visibility range.

If you introduce any changes into created objects, click Apply to update them immediately.

4. Generating Buildings#

Now you need to configure the output settings and generate (or regenerate) the terrain that contains these buildings by clicking the Generate button.

Generated buildings
Last update: 2021-04-09
Build: ()