Terrain city programmed generation method based on unreal engine, medium and equipment

Through Unreal Engine combined with Poisson Disk and multi-scale noise technology, natural and complex terrain is generated, and flexible urban layout is generated through dynamic parameter control, which solves the problems of large-scale terrain and urban environment generation efficiency and flexibility in the existing technology, and achieves efficient and flexible scene generation and optimization.

CN119830400AActive Publication Date: 2025-04-15SHANGHAI JIAOTONG UNIV
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202411866689.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-18
Publication Date
2025-04-15
Estimated Expiration
2044-12-18

AI Technical Summary

Technical Problem

When the prior art generates large-scale terrain and urban environments, it is difficult to achieve efficient and flexible scene generation, and lacks an effective combination between terrain and urban elements.

Method used

The terrain city programmatic generation method based on Unreal Engine is adopted, and the terrain points are initialized through Poisson Disk and Vino map, the landform features are calculated in combination with multi-scale noise, and the surface vegetation layout information is sampled and generated. At the same time, dynamic parameter control generates urban areas, road networks, plots and green space layouts, supporting user customization and optimization.

Benefits of technology

It improves the efficiency and controllability of large-scale scene generation, ensures natural and diverse terrain details, improves the authenticity and flexibility of the scene, supports real-time adjustment of the generation effect, and significantly improves design efficiency and user interaction experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119830400A_ABST
    Figure CN119830400A_ABST
Patent Text Reader

Abstract

The invention provides a terrain city programmed generation method based on an unreal engine, a medium and equipment. The terrain city programmed generation method comprises the steps of 1, sampling Poisson Disk based on Poisson distribution and initializing terrain points based on a Voronoi diagram; step 2, calculating altitude information of mountains and hills by mixing multi-scale noise; step 3, sampling and generating surface vegetation layout information; 4, calculating a city generation area according to the topographic information; 5, calculating and generating urban road network information; 6, plot polygon information is calculated, and house and green land layout information is divided; and step 7, calculating other city decoration element information. According to the method, the random number seeds can be set to quickly generate total element contents in a large-scale scene containing terrains and cities, and dynamic adjustment is realized through parameter exposure. And a user can quickly adjust the generation effect in the parameter panel, so that the generation effect better fits the expectation, and the design efficiency and flexibility are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of computer graphics, and in particular to a method, medium and device for programmatically generating a terrain city based on an Unreal Engine. Background Art

[0002] With the continuous development of computer graphics and virtual reality (VR) and augmented reality (AR) technologies, the construction of virtual environments has become an important topic in many fields. In particular, in applications such as game development, architectural design, urban planning, and environmental simulation, how to quickly and accurately generate large-scale terrain and urban scenes has become the key to improving production efficiency, reducing costs, and achieving high-quality virtual worlds.

[0003] Traditional scene modeling methods usually rely on manual design and manual editing. Although this method can ensure high-precision details, its generation process is cumbersome and time-consuming, and it is not feasible for the construction of large-scale scenes. With the increase in scene complexity, especially when facing large-scale terrain and urban environments, manual modeling is both inefficient and difficult to adapt to the needs of real-time generation and dynamic adjustment. Therefore, developing a technology that can automatically generate terrain and urban scenes and support flexible customization and optimization has become an important goal of current technological development.

[0004] As an effective way to solve this problem, procedural generation technology can greatly improve modeling efficiency and enhance the diversity and authenticity of scenes by defining a set of rules or algorithms to automatically generate large-scale scene content. Especially when generating complex terrain and urban layouts, procedural generation can not only reduce development costs, but also ensure the coordination between elements in the scene. However, most of the existing procedural generation methods have the following problems:

[0005] 1. Single element generation: Many existing methods focus only on the generation of terrain or urban layout, lack a comprehensive generation framework, and have difficulty in simultaneously processing multiple elements such as terrain, urban planning, architecture, vegetation, etc. These methods often require the terrain and urban design to be processed separately, lacking an effective combination of terrain and urban elements.

[0006] 2. Insufficient parameter adjustment capabilities: Traditional procedural generation methods generally lack the ability to fully control and flexibly adjust the generation process. Although some methods support a certain degree of parameter adjustment, in actual applications, these methods cannot provide sufficient dynamic adjustment space, and users have a low degree of customization of the generation effect.

[0007] 3. Balance between generation efficiency and quality: In large-scale scene generation, the generation algorithm needs to balance efficiency and quality. Especially when dealing with complex terrain features and urban layouts, how to maintain the quality and details of the scene while ensuring the generation speed remains a challenge.

[0008] In order to deal with these problems, in recent years, researchers have tried to combine advanced graphics engines (such as Unreal Engine) and procedural generation algorithms to propose new generation frameworks and technologies. Unreal Engine has become one of the important tools for building virtual worlds due to its powerful graphics rendering capabilities and flexible development platform. However, the existing procedural generation methods based on Unreal Engine still face the problem of how to ensure scene quality, details and flexibility while maintaining generation efficiency when dealing with large-scale terrain and urban elements. Summary of the invention

[0009] In view of the defects in the prior art, the purpose of the present invention is to provide a method, medium and device for programmatically generating a terrain city based on Unreal Engine.

[0010] The method for procedurally generating a terrain city based on Unreal Engine provided by the present invention comprises:

[0011] Step 1: Initialize terrain points based on Poisson Disk sampling and Voronoi diagram;

[0012] Step 2: Calculate the elevation information of peaks and hills by mixing multi-scale noise;

[0013] Step 3: Sampling and generating surface vegetation layout information;

[0014] Step 4: Calculate the city generation area based on terrain information;

[0015] Step 5: Calculate and generate urban road network information;

[0016] Step 6: Calculate the polygon information of the plot and divide the layout information of houses and green spaces;

[0017] Step 7: Calculate the remaining city decoration element information.

[0018] Preferably, the step 1 comprises:

[0019] Based on the Poisson Disk sampling method, two types of point sets, common terrain points and local peak points, are generated. Specifically, random points are generated on a two-dimensional plane. During the generation process, Poisson Disk sampling sets a minimum distance parameter to ensure that a certain interval is maintained between the generated points.

[0020] According to the existing point set, the Delaunay triangulation algorithm is used to construct a Voronoi diagram on a two-dimensional plane, and the initial Dual-Mesh data structure for terrain generation is constructed, in which triangles are used to describe the geometric structure of the terrain, and dual polygons are used to describe the logical result of the terrain.

[0021] Preferably, step 2 comprises:

[0022] Input multi-scale noise information and mix them;

[0023] Calculate the local peak altitude and humidity information based on the mixed noise sampling results and parameter settings;

[0024] Interpolate the altitude and humidity information of common terrain points based on local peak point information;

[0025] Grid generation and mapping based on altitude and humidity information;

[0026] Among them, high-frequency noise is used to describe the characteristics of mountain peaks, and low-frequency noise is used to describe the characteristics of hills and basins. Noises of multiple scales are mixed together to generate details of multiple scales on the surface.

[0027] Preferably, the step 3 comprises:

[0028] Calculate the surface vegetation layout information of different terrain types based on PCG Graph;

[0029] Calculate and set the terrain vegetation layout type based on altitude, humidity and parameter setting information;

[0030] Among them, the PCG Graph based on UE5 performs point sampling on the surface area, and calculates the vegetation layout suitable for different surface types by adjusting the sampling density parameter information. Finally, the surface vegetation layout information matching the terrain characteristics is generated to ensure the naturalness and diversity of the generated surface scene.

[0031] Preferably, step 4 comprises:

[0032] Calculate the slope of each point: Calculate the height difference between each point (i, j) and its four neighbors:

[0033] Horizontal gradient: dx = (height_map[i+1][j]-height_map[i-1][j]) / 2;

[0034] Vertical gradient: dy = (height_map[i][j+1]-height_map[i][j-1]) / 2;

[0035] Among them, height_map[i+1][j] represents the height of point (i+1, j);

[0036] Then calculate the slope at each point:

[0037] If the slope is less than the set threshold, the point is considered to belong to a flat area; otherwise, the point is considered to be an area not suitable for urban construction;

[0038] Generate a binary array mask of the same size as the input height map, where the value of the flat area is 1 and the non-flat area is 0;

[0039] In manual generation mode, users manually define the city generation area by drawing a closed curve on the terrain map. The system generates the corresponding city area mask based on the curve drawn by the user, and directly marks the construction area specified by the user;

[0040] The generated urban area Mask is processed by Gaussian blur. Gaussian blur gradually transitions the value of the area edge from 1 in the central area to 0 in the edge area, thereby softening the area boundary. The urban area Mask after Gaussian blur processing will be used as the input of the subsequent city generation pipeline to calculate the urban road network, building distribution and green space layout.

[0041] By analyzing the terrain data of the area covered by the Mask, the terrain points with significant height differences are adjusted to make the terrain surface smoother while maintaining a natural transition between the edge of the area and the surrounding terrain.

[0042] Preferably, step 5 comprises:

[0043] Perform sampling based on the Gaussian blurred Mask to find the direction of the road section;

[0044] Randomly generate bypass information based on preset rules and set primary and secondary roads;

[0045] Conduct rationality check and connectivity processing of road sections;

[0046] At the end of the road network generation, a road connectivity check is performed, and after the road growth and expansion are completed, a procedural grid is generated based on the preset road width and road category information.

[0047] Preferably, step 6 comprises:

[0048] The vector closing algorithm is used to detect and generate plots. Vectors with opposite directions are generated on both sides of the line segment of each road section. If these vectors can form a closed area, the area is regarded as a plot. In this way, the plot polygons are effectively identified and constructed, laying the foundation for the layout of subsequent buildings and green spaces. Within the plot polygons, the key vertical polygon segmentation algorithm will be used for further segmentation to obtain sub-polygon information.

[0049] Calculate house polygons and urban green space polygons based on polygon partitioning algorithm;

[0050] Calculate the layout information of green space trees and shrubs according to parameter settings and sampling specifications.

[0051] Preferably, the step 7 comprises:

[0052] Based on the road information, the relative position of the vehicle guide line is calculated through the road section position and road width parameters, the corresponding mesh is generated using Procedural Mesh, and the guide line map is set to realize the layout of the vehicle guide line;

[0053] Based on the city plot information, the layout of the sidewalk is generated according to the location information of the plot polygon and the preset sidewalk width and height parameters. The corresponding mesh is created through Procedural Mesh, and the sidewalk map is set to complete the generation of the sidewalk.

[0054] Calculate the layout of street lights along the trunk road based on the location information and sampling interval of the urban plot polygons, including determining the location and rotation information of the street lights, and pass it to the downstream asset generation node to generate a complete street light layout;

[0055] The location information of the plot polygons is used in combination with the sampling interval to calculate the location and rotation information of the trees along the main roads. The calculation results will be passed to the asset generation node to generate the tree layout along the main roads, further enriching the greening characteristics of the city.

[0056] Through the detection algorithm of adjacent plots, adjacent plot pairs are identified, the location information of zebra crossings is calculated between adjacent edges, and the corresponding mesh is generated using Procedural Mesh, and the zebra crossing map is set to realize the generation of zebra crossing layout;

[0057] According to the zebra crossing layout information and the detection results of adjacent plots, the position and rotation information of the traffic light are calculated, and the generated position of the traffic light is passed to the asset generation node to complete the traffic light layout;

[0058] Based on the location information of the plot polygon and the sampling density parameters, the location and rotation information of the fire hydrant are calculated, and the final result is passed to the asset generation node to generate the layout of the city fire hydrants.

[0059] According to the computer-readable storage medium storing a computer program provided by the present invention, when the computer program is executed by a processor, the steps of the programmatic generation method of a terrain city based on an Unreal Engine are implemented.

[0060] The electronic device provided according to the present invention includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, the steps of the method for programmatically generating a terrain city based on an Unreal Engine are implemented.

[0061] Compared with the prior art, the present invention has the following beneficial effects:

[0062] (1) The present invention adopts a phased processing method, which solves the problems of terrain characteristics and urban layout respectively through two major stages of terrain generation and urban planning, thereby improving the efficiency and controllability of large-scale scene generation;

[0063] (2) The present invention initializes terrain points through Poisson Disk and Voronoi diagram, and calculates the elevation information of landforms such as mountains and hills in combination with multi-scale noise, which can accurately describe complex terrain features, ensure that the terrain details are natural and diverse, and improve the authenticity of the generated terrain;

[0064] (3) The present invention generates surface vegetation layout information by sampling and classifies it according to rules such as altitude and humidity, generating a vegetation layout that conforms to the terrain characteristics for each area, thereby ensuring the rationality and naturalness of the distribution of surface plants;

[0065] (4) The present invention realizes flexible adjustment of urban area, road network, plot and green space layout through dynamic parameter control. Users can easily adjust the urban generation effect according to their needs, thereby improving the efficiency and flexibility of the design;

[0066] (5) Through random number seeds and parameterized control, the present invention enables the system to quickly generate full-element content in large-scale scenes and supports real-time adjustment of generation effects, greatly improving design efficiency and user interaction experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0067] Other features, objects and advantages of the present invention will become more apparent from the detailed description of non-limiting embodiments made with reference to the following drawings:

[0068] Figure 1 Shown is a schematic diagram of the overall process of the Unreal Engine-based procedural generation method of terrain cities in an application example of the present invention. DETAILED DESCRIPTION

[0069] The present invention is described in detail below in conjunction with specific embodiments. The following embodiments will help those skilled in the art to further understand the present invention, but are not intended to limit the present invention in any form. It should be noted that, for those of ordinary skill in the art, several changes and improvements can also be made without departing from the concept of the present invention. These all belong to the protection scope of the present invention.

[0070] Example

[0071] Specifically, Figure 1 As shown, this embodiment provides a method for programmatically generating a terrain city based on an Unreal Engine, and the method for programmatically generating a terrain city based on an Unreal Engine includes:

[0072] Step S11, initializing terrain points based on Poisson Disk and Voronoi diagram;

[0073] Step S12, calculating the altitude and other information of landforms such as mountains and hills by mixing multi-scale noise;

[0074] Step S13, sampling and generating surface vegetation layout information;

[0075] Step S14, calculating the city generation area;

[0076] Step S15, calculating and generating urban road network information;

[0077] Step S16, calculating the polygon information of the plot and dividing the layout information of the house and green space;

[0078] Step S17, calculating the remaining city decoration element information.

[0079] The following will describe in detail steps S11 to S17 of the Unreal Engine-based terrain city programmatic generation method of this embodiment with reference to the diagrams:

[0080] Step S11, initializing terrain points based on Poisson Disk and Voronoi diagram.

[0081] 1) Generate two types of point sets: common terrain points and local peak points

[0082] The Poisson Disk sampling method is used here. It is an effective method for generating random points on a two-dimensional plane, which aims to meet the characteristics of uniform and non-dense distribution of the generated point set. This method is particularly suitable for terrain generation and can effectively describe the diversity and complexity of terrain. During the generation process, Poisson Disk sampling sets a minimum distance parameter to ensure that a certain interval is maintained between the generated points, thereby avoiding excessive aggregation of points. This interval not only improves the diversity of samples, but also enables the generated points to better reflect the characteristics of natural terrain. The generated point set is divided into two types of points: ordinary terrain points and local peak points. These peak points have important terrain features in the entire terrain. They not only determine the contour and shape of the terrain, but also affect the details of subsequent generation.

[0083] 2) Dual-Mesh structure construction

[0084] Based on the existing point set, the Delaunay triangulation algorithm is used to construct a Voronoi diagram on a two-dimensional plane, and the initial Dual-Mesh data structure for terrain generation is constructed. Based on this dual representation method, triangles are used to describe the geometric structure of the terrain, and dual polygons are used to describe the logical results of the terrain, such as altitude, humidity and other characteristics, making data organization more efficient. Such a dual mesh representation method allows the two data structures to be interpolated and converted to each other, supports accurate modeling of complex terrain, and realizes flexible query and processing of attribute data. This design enhances the expressiveness and application potential of the terrain model.

[0085] Step S12, calculating the altitude and other information of landforms such as mountains and hills by mixing multi-scale noise.

[0086] The method of constructing global terrain features adopts a variety of noise aliasing methods. In actual processing, this project uses high-frequency noise to describe the characteristics of peaks, and low-frequency noise to describe the characteristics of hills and basins. Multiple scales of noise are aliased together to generate details of multiple scales on the surface. Changes in phase will cause the noise function to shift in space, thereby changing the appearance of the generated terrain. Superimposing noise with different phases can increase the randomness of the terrain and make it look more natural. Users can adjust and control the degree of peaks and hills of the overall terrain according to the UI panel. The two can respectively represent the final contribution of low-frequency noise and high-frequency noise to the altitude of a peak point. The formula is as follows:

[0087] Elevation peak =samplingValue m *e m +samplingValue h *e h

[0088] Among them, samplingValue m with samplingValue h Represent the sampling results of high-frequency noise and low-frequency noise respectively, e m With e h They respectively represent the mountain and hill levels of the global terrain that can be adjusted by the UI. Finally, the information of the global terrain point can be obtained by interpolating the information of the peak point.

[0089] In addition, the terrain generation system also supports manual editing to meet the user's local adjustment needs. The system supports setting a certain hardness and strength of the blueprint brush, and by fine-tuning the height information, the generated terrain can be adjusted in real time. Lakes, rivers and other landforms can change adaptively according to the altitude.

[0090] Step S13, calculating and generating surface vegetation layout information.

[0091] The present invention realizes the vegetation layout characteristics of three different surface types: desert, forest and snow. Based on UE5's PCG Graph, point sampling is performed on the surface area, and by adjusting parameter information such as sampling density, the vegetation layout suitable for different surface types is calculated. Finally, the surface vegetation layout information matching the terrain characteristics is generated to ensure that the generated surface scene is natural and diverse.

[0092] Step S14, calculating the city generation area.

[0093] The first step in city generation is to determine the generation area. The core task of this step is to calculate the area suitable for city construction based on terrain information. The specific process is as follows:

[0094] 1) Automatic generation mode: based on terrain slope calculation

[0095] In automatic generation mode, the system calculates the slope (steepness) of each surface point by analyzing the terrain data generated upstream. The terrain slope value reflects the undulations of the surface. A smaller slope value indicates that the terrain is relatively flat and suitable for urban construction. According to the preset threshold, the system automatically identifies areas with smaller slopes and generates corresponding urban area masks, marking them as target areas suitable for construction. At the same time, areas with larger slopes will be excluded to ensure that the generated areas meet planning requirements.

[0096] The specific calculation method is as follows:

[0097] 1. Calculate the slope (height difference) of each point: We calculate the height difference between each point and its four neighbors:

[0098] Horizontal gradient: dx = (height_map[i+1][j]-height_map[i-1][j]) / 2;

[0099] Vertical gradient: dy = (height_map[i][j+1]-height_map[i][j-1]) / 2;

[0100] The slope (magnitude of the gradient) can then be calculated for each point:

[0101]

[0102] 2. Mark the flat area:

[0103] If the slope is less than the set threshold, the point is considered to belong to the flat area.

[0104] Otherwise, the point is considered as an area unsuitable for urban construction.

[0105] 3. Output the Mask of the flat area:

[0106] Generates a binary array mask of the same size as the input heightmap, with values ​​of 1 for flat areas and 0 for non-flat areas.

[0107] 2) Manual generation mode: user-defined area

[0108] In manual generation mode, users manually define the city generation area by drawing a closed curve (Curve) in the terrain map. The system generates the corresponding city area Mask based on the curve drawn by the user, and directly marks the construction area specified by the user. This mode does not rely on terrain slope calculation, and completely defines the city range according to the user's intention.

[0109] 3) Gaussian blur processing

[0110] Regardless of whether the urban area is automatically generated or manually defined, the system will perform Gaussian blur processing on the generated urban area Mask. Gaussian blur gradually transitions the value of the area edge from 1 (center area) to 0 (edge ​​area), thereby softening the area boundary. Through this processing, the transition between the generated urban area and the non-construction area is natural, avoiding unreasonable layout caused by hard boundaries.

[0111] 4) Regional input and subsequent processes

[0112] The urban area mask after Gaussian blur processing will be used as the input of the subsequent urban generation pipeline to calculate factors such as urban road network, building distribution and green space layout. This process not only ensures the precise control of urban boundaries, but also makes the generated urban structure match the terrain characteristics to avoid exceeding the scope of suitable construction.

[0113] Through the above method, the system accurately delineates the city generation area according to the mode selected by the user. The automatic mode uses the terrain slope calculation to ensure scientific planning, and the manual mode provides flexibility to support user customization. Gaussian blur further optimizes the boundary transition to ensure that the city layout is reasonable and in line with the actual terrain characteristics.

[0114] 5) Post-processing of terrain based on urban areas

[0115] Based on the generated urban area Mask, the system flattens the terrain in the area to ensure that the urban construction area has flat terrain conditions. Specifically, the system analyzes the terrain data of the area covered by the Mask and adjusts the terrain points with significant height differences to make the terrain surface flat while maintaining a natural transition between the edge of the area and the surrounding terrain. Through this processing step, the system can effectively ensure that the urban generation area is located on flat ground, providing a reliable terrain foundation for the subsequent layout and generation of urban structures.

[0116] Step S15, calculate and generate urban road network information.

[0117] In the process of city generation, the construction of urban road network is a crucial step. This step calculates the road layout in the urban area to form a road network structure suitable for urban planning. The specific process is as follows:

[0118] 1) Input urban area Mask for sampling

[0119] First, the system performs sampling operations based on the input urban area Mask information. The Mask information defines the boundaries of the urban area, and after Gaussian blurring, a smooth boundary area is formed. The selection of sampling points follows certain rules, mainly based on the size of the sampling value, and the area with a smaller sampling value is preferentially selected as the starting point of the road. In this way, the system can ensure that the road grows in a relatively flat area that is suitable for construction.

[0120] 2) Road growth and priority queue management

[0121] The core method of road growth is to use the priority queue to determine the expansion direction. Each time the system grows, it starts from the end of the current road segment (end point p2) and calculates and selects the growth direction of the next road segment. Based on preset parameters, the system will evaluate multiple possible road growth directions and select the direction with a smaller sampling value and in line with planning requirements to expand the new road segment. In this process, the priority queue is sorted based on factors including the sampling value of the current road direction, the curvature of the road, and the distance from the existing road. After considering these factors comprehensively, it can be ensured that the generated road network not only conforms to the terrain characteristics, but also has a certain degree of randomness and naturalness. The growth of the road is carried out step by step. Whenever a new road segment is expanded, it will be added to the priority queue to continue calculating the next expansion direction. The sorting comparison formula of the priority queue is:

[0122] priorityValue=pointValue(roadMiddle)+detriment

[0123] The calculation formula of detriment is:

[0124]

[0125] The function of detriment is to optimize the global road network layout and avoid the distance between main roads being too close. Through this design, the system can generate a reasonable road layout, balance the distance between main roads and optimize the overall road network structure; priorityValue indicates that the processing priority of a road segment is determined by its weight, and the road segment with a lower weight is processed first; roadMiddle indicates that since the road segment is represented by a line segment, the position of the midpoint of the line segment is used as the noise sampling point when sampling the noise information of the road segment; detriment indicates that since the road segments cannot be too close to each other, a penalty weight is set. If there are many road segments around a road segment, it has a larger penalty weight; detrimentRange indicates the range in which the penalty item is effective; detrimentImpact indicates the weight coefficient of the penalty item; road indicates the location of the road segment, where the midpoint of the road segment is used to indicate the location of the road segment; roads indicates all road segments within the detrimentRange range of the current road segment; num_roads indicates the total number of road segments; n indicates the current number of iterations.

[0126] 3) Road curvature control and diversity generation

[0127] In order to avoid the generated roads being too regular, the system allows the curvature of the roads to be controlled. Specifically, users can adjust the curvature weight of the road through the UI panel to determine the degree of offset when the road grows. During the expansion process, the system will try to offset a certain angle to generate a new road segment based on the previous road segment according to the current direction of the road and the maximum angle change range. By adjusting the curvature weight, you can control whether the generated road is straighter or more curved, thereby increasing the complexity and diversity of the road network.

[0128] 4) Road network structure characteristics and intersection generation

[0129] In order to enhance the richness and feasibility of the urban road network, the system will also add a certain probability of bypass generation when generating the road network. For example, in the middle part of the road, vertical bypasses will be randomly generated according to certain rules to form crossroads or T-junctions. These intersections can further enrich the city's road network structure, avoid the road layout being too monotonous, and provide higher traffic convenience. In this process, the system will divide the forks in the road network into main roads and secondary roads according to certain rules and random numbers. Main roads usually connect the core areas of the city and carry the main traffic flow, while secondary roads are used to connect the main roads with the surrounding areas to form a hierarchical road network structure.

[0130] 5) Avoid inspection and adjustment of roads that are too close to each other

[0131] During the road network generation process, the system will also check the distance between adjacent roads to prevent them from being too close. During this process, the system will perform a "midpoint check" on each newly added road segment, that is, each time a new road segment is added, it will check whether it is too close to the generated road segment. If it is detected that the distance between roads is too small, the system will adjust the position or growth direction of the road segment to ensure a reasonable distance between roads.

[0132] 6) Road connectivity and extension detection

[0133] At the end of the road network generation, the system will perform a road connectivity check. Specifically, for each end road segment, the system will try to extend the segment and detect whether it intersects with other road segments. If two roads are detected to intersect, the system will automatically extend one of the roads and connect them, thus ensuring the integrity and connectivity of the urban road network.

[0134] 7) Generate procedural grid and distinguish between primary and secondary roads

[0135] After the road growth and expansion is completed, the system generates a procedural mesh based on the preset road width, road category and other information.

[0136] Step S16, calculating the polygon information of the plot and dividing the layout information of the house and green space.

[0137] The detection and generation of plots uses a vector closure algorithm. Vectors with opposite directions are generated on both sides of the line segment of each road section. If these vectors can form a closed area, the area is considered a plot. In this way, the system can effectively identify and construct plot polygons, laying the foundation for the layout of subsequent buildings and green spaces. Within the plot polygon, the system will use the key vertical polygon segmentation algorithm to further segment and obtain sub-polygon information.

[0138] The decision to subdivide the plot depends on the size of the plot and certain random number rules. The polygons after segmentation will be processed as the base of the house, and these polygons have a certain probability of being transformed into green space. On the green space, the system will place elements such as trees, shrubs, and flowers according to certain random rules to increase the natural atmosphere and beauty of the urban environment.

[0139] Step S17, calculating the remaining city decoration element information.

[0140] 1) Calculation of vehicle flow line layout information

[0141] Based on the road information, the system calculates the relative position of the vehicle guide line through parameters such as the road section location and road width. Then, the corresponding mesh is generated using Procedural Mesh, and the guide line map is set to realize the layout of the vehicle guide line.

[0142] The specific processing method is to calculate the following based on the number of lanes, the width of each road section, and the size (length and width) and spacing of the vehicle guide lines:

[0143] 1. Vertical layout: By dividing the length of the road section by the sum of the length and interval of the vehicle guide line, calculate how many rectangles are needed vertically to represent the vehicle guide line polygon.

[0144] 2. Horizontal layout: By dividing the road section width by the sum of the width and spacing of the vehicle guide line, calculate how many rectangles are needed to represent the vehicle guide line polygon in the horizontal direction.

[0145] Finally, the system saves the polygon information and uses Procedural Mesh technology to generate the corresponding mesh, while setting the drainage line map to complete the layout.

[0146] 2) Calculation of sidewalk layout information

[0147] Based on the city plot information, the system generates the layout of the sidewalk according to the location information of the plot polygon and the preset sidewalk width and height parameters. The corresponding mesh is created through Procedural Mesh, and the sidewalk texture is set to complete the generation of the sidewalk.

[0148] The specific processing methods are:

[0149] 1. Extracting plot information: The system first obtains the location information of the global plot polygon and extracts the vertex coordinates of each plot.

[0150] 2. Calculate the sidewalk size: According to the sidewalk width and height parameters specified by the user, calculate the polygon organization information and vertex positions of each sidewalk.

[0151] 3. Mesh generation: Combined with Procedural Mesh technology, use the vertex positions and preset sizes of the plot polygons to generate the corresponding sidewalk mesh.

[0152] 4. Texture design and application: Design a texture that matches the characteristics of the sidewalk and apply it to the generated grid to complete the layout of the sidewalk.

[0153] 3) Calculation of street light layout information along the trunk road

[0154] The system calculates the layout of street lights along the trunk road based on the location information and sampling interval of the urban plot polygons. The specific steps include determining the location and rotation information of the street lights and passing it to the downstream asset generation node to generate a complete street light layout.

[0155] The specific processing methods are:

[0156] 1. Extracting plot information: The system first obtains the location information of the global plot polygon and extracts the boundary data of the polygon to determine the scope of the street light layout.

[0157] 2. Uniform sampling: uniform sampling is performed on the edges of the polygon. The sampling interval is determined by the parameters entered by the user. Each sampling point is a potential installation location for the street light.

[0158] 3. Calculate street light rotation information: Calculate the rotation angle of each street light based on the direction of the polygon edge and the location of the sampling point. This rotation information ensures that the street light faces the correct direction, meeting the actual needs of urban layout.

[0159] 4. Output position and rotation information: The sampled street light position and calculated rotation information are passed to the downstream asset generation node for subsequent generation of the complete street light layout and related assets.

[0160] 4) Calculation of tree layout information along the main road

[0161] The system uses the location information of the plot polygons and the sampling interval to calculate the location and rotation information of the trees along the main roads. The calculation results will be passed to the asset generation node to generate the tree layout along the main roads, further enriching the greening characteristics of the city.

[0162] The specific processing methods are:

[0163] 1. Extracting plot information: The system first obtains the location information of the global plot polygon and extracts the boundary data of the polygon to determine the scope of the street light layout.

[0164] 2. Uniform sampling: uniform sampling is performed on the edges of the polygon. The sampling spacing is determined by the parameters entered by the user. Each sampling point is a potential installation location for the tree.

[0165] 3. Calculate the rotation information of trees along the road: Calculate the rotation angle of each street lamp based on the direction of the polygon edge and the location of the sampling point. This rotation information ensures that the street lamp faces the correct direction, meeting the actual needs of urban layout.

[0166] 4. Output position and rotation information: The sampled tree positions and calculated rotation information are passed to the downstream asset generation node for subsequent generation of the complete tree layout and related assets.

[0167] 5) Zebra crossing layout information calculation

[0168] The system uses the detection algorithm of adjacent plots to identify adjacent plots, calculate the location information of zebra crossings between adjacent edges, generate corresponding meshes using Procedural Mesh, and set the zebra crossing map to realize the generation of zebra crossing layout.

[0169] The specific processing methods are:

[0170] 1. Plot adjacency judgment: Based on the location information of the global plot polygon, taking polygon A as an example, check the distance between each edge of A and the edges of other polygons.

[0171] If the distance between the edges of two polygons is less than the preset road width, the two plots are adjacent.

[0172] 2. Zebra crossing position calculation: After determining the adjacent plots, the system calculates the position of the zebra crossing based on the zebra crossing spacing, road width and zebra crossing length

[0173] 3. Texture design and application: Attach a texture that matches the characteristics of the zebra crossing and apply it to the generated grid to complete the layout of the zebra crossing.

[0174] 6) Calculation of traffic light layout information

[0175] The system calculates the position and rotation information of the traffic light based on the zebra crossing layout information and the detection results of the adjacent plots. The generated position of the traffic light is passed to the asset generation node to complete the traffic light layout.

[0176] The specific processing methods are:

[0177] 1. Plot adjacency judgment: Based on the location information of the global plot polygon, taking polygon A as an example, check the distance between each edge of A and the edges of other polygons.

[0178] For each edge of polygon A, check its distance from the edges of other polygons.

[0179] If the distance between the edges of two polygons is less than the preset road width, the two plots are considered to be adjacent.

[0180] 2. Traffic light position calculation: After determining the adjacent plots, the system calculates the position and rotation of the zebra crossing according to the following parameters

[0181] Calculate the specific location of the traffic light based on the width of the road and the direction of the road section.

[0182] Traffic lights will be located on both sides of the road and facing opposite directions.

[0183] The rotation angle of the traffic light is calculated based on the road direction and width to ensure the correct orientation of the traffic light.

[0184] 3. Generation and transmission: The location information and rotation angle of the traffic light will be transmitted to the asset generation node to complete the layout generation of the traffic light.

[0185] 7) Calculation of fire hydrant layout information

[0186] The system calculates the location and rotation information of the fire hydrants based on the location information of the plot polygons and the sampling density parameters. The final result is passed to the asset generation node to generate the layout of the city fire hydrants.

[0187] 1. Extracting plot information: The system first obtains the location information of the global plot polygon and extracts the boundary data of the polygon to determine the scope of the street light layout.

[0188] 2. Random sampling: Random sampling is performed on the edges of the polygon. The sampling frequency is determined by the parameters entered by the user. Each sampling point is a potential location for the generation of a fire hydrant.

[0189] 3. Calculate the rotation information of fire hydrants: According to the direction of the polygon edge and the location of the sampling point, the rotation angle of each fire hydrant is calculated. This rotation information ensures that the fire hydrant faces the correct direction and meets the actual needs of urban layout.

[0190] 4. Output position and rotation information: The sampled fire hydrant position and calculated rotation information are passed to the downstream asset generation node for subsequent generation of the complete fire hydrant layout and related assets.

[0191] The Unreal Engine-based terrain city programmatic generation method of the present invention realizes efficient and flexible city and terrain generation through two-stage steps. First, the terrain points are initialized by Poisson Disk and Voronoi diagram, and multi-scale noise is combined to generate landform features such as mountains and hills and their altitude, humidity and other information, so that natural and complex terrain can be quickly created. Secondly, on this basis, urban areas, road networks, plot layouts, housing and green space distribution and other decorative elements are automatically generated, which greatly simplifies the complexity of urban planning and design. Compared with traditional methods, the present invention enables users to adjust generation parameters in real time, dynamically optimize scene effects, improve design efficiency and flexibility, and can quickly generate large-scale, full-factor urban terrain scenes that meet expectations through parametric design and random number seed settings, which has significant technical advantages.

[0192] Those skilled in the art know that, in addition to implementing the system, device and its various modules provided by the present invention in a purely computer-readable program code, it is entirely possible to implement the same program in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers and embedded microcontrollers by logically programming the method steps. Therefore, the system, device and its various modules provided by the present invention can be considered as a hardware component, and the modules included therein for implementing various programs can also be considered as structures within the hardware component; the modules for implementing various functions can also be considered as both software programs for implementing the method and structures within the hardware component.

[0193] The above describes the specific embodiments of the present invention. It should be understood that the present invention is not limited to the above specific embodiments, and those skilled in the art can make various changes or modifications within the scope of the claims, which does not affect the essence of the present invention. In the absence of conflict, the embodiments of the present application and the features in the embodiments can be combined with each other arbitrarily.

Claims

1. A method for procedurally generating a terrain city based on Unreal Engine, characterized in that: include: Step 1: Initialize terrain points based on Poisson Disk sampling and Voronoi diagram; Step 2: Calculate the elevation information of peaks and hills by mixing multi-scale noise; Step 3: Sampling and generating surface vegetation layout information; Step 4: Calculate the city generation area based on terrain information; Step 5: Calculate and generate urban road network information; Step 6: Calculate the polygon information of the plot and divide the layout information of houses and green spaces; Step 7: Calculate the remaining city decoration element information.

2. The method for procedurally generating a terrain city based on Unreal Engine according to claim 1, characterized in that: The step 1 comprises: Based on the Poisson Disk sampling method, two types of point sets, ordinary terrain points and local peak points, are generated. Specifically, random points are generated on a two-dimensional plane. During the generation process, Poisson Disk sampling sets a minimum distance parameter to ensure that a certain interval is maintained between the generated points. According to the existing point set, the Delaunay triangulation algorithm is used to construct a Voronoi diagram on a two-dimensional plane, and the initial Dual-Mesh data structure for terrain generation is constructed, in which triangles are used to describe the geometric structure of the terrain, and dual polygons are used to describe the logical result of the terrain.

3. The method for procedurally generating a terrain city based on Unreal Engine according to claim 1, characterized in that: The step 2 comprises: Input multi-scale noise information and mix them; Calculate the local peak altitude and humidity information based on the mixed noise sampling results and parameter settings; Interpolate the altitude and humidity information of common terrain points based on local peak point information; Generate grids and map according to altitude and humidity information; Among them, high-frequency noise is used to describe the characteristics of mountain peaks, and low-frequency noise is used to describe the characteristics of hills and basins. Noises of multiple scales are mixed together to generate details of multiple scales on the surface.

4. The method for procedurally generating a terrain city based on Unreal Engine according to claim 1, characterized in that: The step 3 comprises: Calculate the surface vegetation layout information of different terrain types based on PCG Graph; Calculate and set the terrain vegetation layout type based on altitude, humidity and parameter setting information; Among them, the PCG Graph based on UE5 performs point sampling on the surface area, and calculates the vegetation layout suitable for different surface types by adjusting the sampling density parameter information. Finally, the surface vegetation layout information matching the terrain characteristics is generated to ensure the naturalness and diversity of the generated surface scene.

5. The method for procedurally generating a terrain city based on Unreal Engine according to claim 1, characterized in that: The step 4 comprises: Calculate the slope of each point: Calculate the height difference between each point (i, j) and its four neighbors: Horizontal gradient: dx = (height_map[i+1][j]-height_map[i-1][j]) / 2; Vertical gradient: dy = (height_map[i][j+1]-height_map[i][j-1]) / 2; Among them, height_map[i+1][j] represents the height of point (i+1, j); Then calculate the slope at each point: If the slope is less than the set threshold, the point is considered to belong to a flat area; otherwise, the point is considered to be an area not suitable for urban construction; Generate a binary array mask of the same size as the input height map, where the value of the flat area is 1 and the non-flat area is 0; In manual generation mode, users manually define the city generation area by drawing a closed curve on the terrain map. The system generates the corresponding city area mask based on the curve drawn by the user, and directly marks the construction area specified by the user; The generated urban area Mask is processed by Gaussian blur. Gaussian blur gradually transitions the value of the area edge from 1 in the central area to 0 in the edge area, thereby softening the area boundary. The urban area Mask after Gaussian blur processing will be used as the input of the subsequent city generation pipeline to calculate the urban road network, building distribution and green space layout. By analyzing the terrain data of the area covered by the Mask, the terrain points with significant height differences are adjusted to make the terrain surface smoother while maintaining a natural transition between the edge of the area and the surrounding terrain.

6. The method for procedurally generating a terrain city based on Unreal Engine according to claim 1, characterized in that: The step 5 comprises: Perform sampling based on the Gaussian blurred Mask to find the direction of the road section; Randomly generate bypass information based on preset rules and set primary and secondary roads; Conduct rationality check and connectivity processing of road sections; At the end of the road network generation, a road connectivity check is performed, and after the road growth and expansion are completed, a procedural grid is generated based on the preset road width and road category information.

7. The method for procedurally generating a terrain city based on Unreal Engine according to claim 1, characterized in that: The step 6 comprises: The vector closing algorithm is used to detect and generate plots. Vectors with opposite directions are generated on both sides of the line segment of each road section. If these vectors can form a closed area, the area is regarded as a plot. In this way, the plot polygons are effectively identified and constructed, laying the foundation for the layout of subsequent buildings and green spaces. Within the plot polygons, the key vertical polygon segmentation algorithm will be used for further segmentation to obtain sub-polygon information. Calculate house polygons and urban green space polygons based on polygon partitioning algorithm; Calculate the layout information of green space trees and shrubs according to parameter settings and sampling specifications.

8. The method for procedurally generating a terrain city based on Unreal Engine according to claim 1, characterized in that: The step 7 comprises: Based on the road information, the relative position of the vehicle guide line is calculated through the road section position and road width parameters, the corresponding mesh is generated using Procedural Mesh, and the guide line map is set to realize the layout of the vehicle guide line; Based on the city plot information, the layout of the sidewalk is generated according to the location information of the plot polygon and the preset sidewalk width and height parameters. The corresponding mesh is created through Procedural Mesh, and the sidewalk map is set to complete the generation of the sidewalk. Calculate the layout of street lights along the trunk road based on the location information and sampling interval of the urban plot polygons, including determining the location and rotation information of the street lights, and pass it to the downstream asset generation node to generate a complete street light layout; The location information of the plot polygons is used in combination with the sampling interval to calculate the location and rotation information of the trees along the main roads. The calculation results will be passed to the asset generation node to generate the tree layout along the main roads, further enriching the greening characteristics of the city. Through the detection algorithm of adjacent plots, adjacent plot pairs are identified, the location information of zebra crossings is calculated between adjacent edges, and the corresponding mesh is generated using Procedural Mesh, and the zebra crossing map is set to realize the generation of zebra crossing layout; According to the zebra crossing layout information and the detection results of adjacent plots, the position and rotation information of the traffic light are calculated, and the generated position of the traffic light is passed to the asset generation node to complete the traffic light layout; Based on the location information of the plot polygon and the sampling density parameters, the location and rotation information of the fire hydrant are calculated, and the final result is passed to the asset generation node to generate the layout of the city fire hydrants.

9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method for procedurally generating a terrain city based on Unreal Engine according to any one of claims 1 to 8 are implemented.

10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the computer program is executed by a processor, the steps of the method for procedurally generating a terrain city based on Unreal Engine according to any one of claims 1 to 8 are implemented.

Citation Information

Patent Citations

  • Method for high-precision reverse time migration imaging based on severe relief surface ground penetrating radar data

    CN106707277A

  • Method for creating 3D model

    CN110148219A

  • Scene line virtual design system

    CN118196353A

  • Terrain analysis and design tool based on virtual reality and augmented reality technology

    CN118656886A

  • Virtual reality system and method for natural environment simulation

    CN119006751A