Method, device and electronic equipment for generating virtual building cluster

CN119378059BActive Publication Date: 2026-08-11NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-26
Publication Date
2026-08-11

AI Technical Summary

Technical Problem

然而该方式的效率较低,人工成本较高

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119378059B_ABST
    Figure CN119378059B_ABST
Patent Text Reader

Abstract

This disclosure provides a method, apparatus, and electronic device for generating a virtual building cluster. The method involves obtaining a preset initial position located on the terrain surface of a preset virtual scene; determining multiple target positions based on a preset seed algorithm, the initial position, and preset constraints; limiting the slope of the target positions; and setting virtual buildings at the multiple target positions to form a virtual building cluster. This method can automatically determine multiple locations for setting virtual buildings, quickly generate virtual building clusters, improve the efficiency of building virtual settlements, and reduce labor costs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of virtual scene technology, and more specifically, to a method, apparatus, and electronic device for generating virtual building clusters. Background Technology

[0002] In virtual environments, to simulate the real world, numerous virtual villages, virtual cities, and other biological settlements need to be established. In related technologies, artists typically define the boundaries of these settlements based on the terrain of the virtual scene and then place virtual buildings within those boundaries. However, this method is inefficient and labor-intensive. Summary of the Invention

[0003] In view of this, the purpose of this disclosure is to provide a method, apparatus and electronic device for generating virtual building clusters, so as to automatically determine multiple locations for setting up virtual buildings, quickly generate virtual building clusters, improve the efficiency of building virtual settlements and reduce labor costs.

[0004] In a first aspect, embodiments of this disclosure provide a method for generating a virtual building cluster. The method includes: obtaining a preset initial position; the initial position being located on the terrain surface of a preset virtual scene; determining multiple target positions based on a preset seed algorithm, the initial position, and preset constraints; the constraints being used to limit the slope of the target positions; and setting virtual buildings at the multiple target positions to form a virtual building cluster.

[0005] Secondly, embodiments of this disclosure provide a device for generating a virtual building cluster. The device includes: an initial position acquisition module for acquiring a preset initial position; the initial position is located on the terrain surface of a preset virtual scene; a target position determination module for determining multiple target positions based on a preset seed algorithm, the initial position, and preset constraints; the constraints are used to limit the slope of the target positions; and a virtual building setting module for setting virtual buildings at the multiple target positions to form a virtual building cluster.

[0006] Thirdly, embodiments of the present invention provide an electronic device, including a processor and a memory, wherein the memory stores machine-executable instructions that can be executed by the processor, and the processor executes the machine-executable instructions to implement the above-described method for generating virtual building clusters.

[0007] Fourthly, embodiments of the present invention provide a machine-readable storage medium storing machine-executable instructions. When the machine-executable instructions are invoked and executed by a processor, the machine-executable instructions cause the processor to implement the above-described method for generating a virtual building cluster.

[0008] The embodiments of the present invention bring the following beneficial effects:

[0009] The aforementioned method, apparatus, and electronic device for generating a virtual building cluster involve obtaining a preset initial position; the initial position being located on the terrain surface of a preset virtual scene; determining multiple target positions based on a preset seed algorithm, the initial position, and preset constraints; the constraints limiting the slope of the target positions; and setting virtual buildings at the multiple target positions to form a virtual building cluster. This method can automatically determine multiple locations for setting virtual buildings, quickly generate virtual building clusters, improve the efficiency of building virtual settlements, and reduce labor costs.

[0010] Other features and advantages of this disclosure will be set forth in the following description and will be apparent in part from the description or may be learned by practicing the disclosure. The objects and other advantages of this disclosure are realized and obtained through the structures particularly pointed out in the description, claims and drawings.

[0011] To make the above-mentioned objects, features and advantages of this disclosure more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description

[0012] To more clearly illustrate the technical solutions in the specific embodiments of this disclosure or the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this disclosure. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0013] Figure 1 A flowchart illustrating a method for generating a virtual building cluster as provided in this embodiment of the disclosure;

[0014] Figure 2 A schematic diagram illustrating the location after diffusion, provided as an embodiment of this disclosure;

[0015] Figure 3 A schematic diagram illustrating another post-diffusion location provided by an embodiment of this disclosure;

[0016] Figure 4 A schematic diagram of a normal direction provided for an embodiment of this disclosure;

[0017] Figure 5 A schematic diagram showing the seed point positions before and after the disturbance, provided in an embodiment of this disclosure;

[0018] Figure 6 A schematic diagram of a waypoint provided in an embodiment of this disclosure;

[0019] Figure 7 A schematic diagram comparing two types of roads provided in this embodiment of the disclosure;

[0020] Figure 8 A schematic diagram comparing two types of roads provided in this embodiment of the disclosure;

[0021] Figure 9 A schematic diagram of a virtual village and roads provided in an embodiment of this disclosure;

[0022] Figure 10 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure. Detailed Implementation

[0023] To make the objectives, technical solutions, and advantages of the embodiments of this disclosure clearer, the technical solutions of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this disclosure, and not all embodiments. Based on the embodiments of this disclosure, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this disclosure.

[0024] In virtual environments, to simulate the real world, numerous virtual villages, virtual cities, and other biological settlements need to be established. In related technologies, artists typically define the boundaries of these settlements based on the terrain of the virtual scene and then place virtual buildings within those boundaries. Artificially creating villages on complex terrain and generating roads between them is a challenging task. These details generally require a significant amount of time from the relevant staff and are relatively inefficient.

[0025] Based on this, the present disclosure provides a method, apparatus, and electronic device for generating virtual building clusters, which can be applied to scenarios of generating biological habitats in a virtual environment.

[0026] See Figure 1 First, a method for generating a virtual building cluster according to an embodiment of the present invention will be introduced, which provides a graphical user interface through a terminal device. The method includes the following steps:

[0027] Step S102: Obtain the preset initial position; the initial position is located on the terrain surface of the preset virtual scene.

[0028] The initial location can be specified by relevant personnel or randomly generated within a preset terrain surface area. The initial location corresponds to the number of virtual building clusters to be generated, and can be one or more. The initial location can be the center or edge of the virtual building clusters to be generated by the user, depending on parameters such as the diffusion direction used in the subsequent seed algorithm.

[0029] Typically, virtual building clusters are built in relatively flat terrain areas. The flatness of the terrain at the initial location can be predetermined, for example, by checking if the slope of the initial location is less than a preset slope threshold. If it is greater than or equal to this slope threshold, the currently obtained initial location can be considered unsuitable as the initial location in this method, thus prompting the user to request a new initial location.

[0030] Step S104: Based on the preset seed algorithm, initial position and preset constraints, determine multiple target positions; the constraints are used to limit the slope of the target positions.

[0031] The seed filling algorithm is an algorithm that starts with a seed point within a connected region and gradually expands outwards to fill the entire region. This algorithm is very common in computer graphics and is frequently used for region filling operations. The seed filling algorithm has a wide range of applications, primarily in image processing and computer graphics. For example, in image processing, it can be used to fill polygonal regions and process connected components of an image.

[0032] In this method, an initial position can be used as a seed to diffuse outwards, resulting in multiple seed positions. Then, the diffusion process is repeated based on these new positions to obtain further diffused positions, until a specified number of diffusions or seed positions are obtained. Both the diffusion direction and distance can be pre-specified. These can be constant or vary with the number of diffusions; the choice is made based on requirements and is not limited here.

[0033] It's worth noting that since buildings are typically located on relatively flat terrain, it's necessary to determine whether the resulting locations are flat. This can be achieved by setting constraints, such as a pre-defined slope threshold. By checking if the slope of each seed location is less than the threshold, if it is greater than or equal to the threshold, the seed location is considered unsuitable for building a virtual structure and is deleted.

[0034] The step of determining whether a seed position meets the constraints can be performed after diffusion is complete, or it can be performed after a certain seed position has been obtained. If the constraints are not met, diffusion will not be performed based on that seed position to obtain other seed positions. The specific settings can be configured according to the requirements, and will not be configured here.

[0035] The obtained seed positions can be directly used as target positions, in which case the distance between adjacent seed positions is related to the diffusion distance. When the diffusion distance remains constant, the distance between seed positions is usually constant. When the distance between buildings in a building cluster needs to be random, the obtained seed positions can be perturbed. The larger the perturbation scale, the greater the randomness of the distance between the perturbed positions. However, when the perturbation scale is too large, overlapping of seed positions is likely to occur, so the perturbation scale needs to be controlled to avoid being too large. The perturbed seed positions can then be determined as the target positions.

[0036] Step S106: Set up virtual buildings at multiple target locations to form a virtual building cluster.

[0037] Once the target locations are determined, virtual buildings can be set up at the target locations in a certain order. For example, virtual buildings can be set up at each target location according to the generation time of the seed locations corresponding to the target locations, or they can be set up in the order from south to north or from west to east. There are no restrictions on this.

[0038] When setting up a virtual building, there may already be other virtual buildings set up at other target locations around it, and each virtual building has a certain volume. It is necessary to determine whether the virtual building set up at the current location will overlap with other virtual buildings. If so, the current target location can be adjusted appropriately, or a smaller virtual building can be selected, or the virtual building at that target location can be abandoned. The specific settings depend on the needs and are not restricted here.

[0039] The aforementioned method for generating a virtual building cluster involves obtaining a preset initial location; the initial location is situated on the terrain surface of a preset virtual scene; based on a preset seed algorithm, the initial location, and preset constraints, multiple target locations are determined; the constraints limit the slope of the target locations; and virtual buildings are set at these multiple target locations to form a virtual building cluster. This method can automatically determine multiple locations for setting up virtual buildings, quickly generating virtual building clusters, improving the efficiency of building virtual settlements, and reducing labor costs.

[0040] The following embodiments provide a specific method for determining multiple target locations based on a preset seed algorithm, an initial position, and preset constraints.

[0041] In practical implementation, the initial position is first determined as the initial seed position. Then, based on a preset seed algorithm and the initial seed position, multiple diffusion positions are determined. During the diffusion process, the seed algorithm determines multiple diffusion positions corresponding to the initial seed position based on the initial seed position, multiple preset diffusion directions, and diffusion distances. Seed positions typically diffuse in multiple directions; unidirectional diffusion would result in virtual buildings arranged in a single row, which does not meet the visual requirements of building clusters.

[0042] In practical applications, the terrain surface in a virtual scene is typically composed of multiple connected quadrilaterals, with adjacent quadrilaterals sharing two vertices. The aforementioned diffusion distance can be a multiple of the side length of the quadrilateral. When the initial seed position is a vertex of a quadrilateral, diffusion occurs along the edge of the quadrilateral, resulting in a diffused position at a vertex of the quadrilateral.

[0043] The aforementioned quadrilateral can be a square. In this case, the multiple diffusion directions can be various directions along the terrain surface, including a first direction, a second direction, a third direction, and a fourth direction. The first direction is opposite to the second direction, the third direction is opposite to the fourth direction, and the first direction is perpendicular to the third direction. For example... Figure 2 As shown, a, b, c, and d represent the first, second, third, and fourth directions, respectively. When diffusion is performed once according to the first, second, and third directions, the resulting diffused position is represented by a black dot, and the initial seed position is represented by a hollow dot.

[0044] After obtaining multiple diffused positions, the target seed position needs to be determined from these positions. The slope of the determined target seed position must satisfy a preset constraint. In practice, the slope of the diffused position can be represented by the normal direction at that position. The constraint can be that the dot product of the normal direction of the target seed position and the target normal direction is greater than a preset first threshold, and the target normal direction is vertically upward. The larger the dot product, the smaller the slope of the diffused position, thus limiting the slope of the target seed position through the constraint.

[0045] Specifically, for each of the multiple diffused locations, it is necessary to calculate the dot product of the normal direction of the diffused location and the target normal direction; if the dot product is greater than a first threshold, the diffused location is determined to be the target seed location; otherwise, the diffused location is determined not to be the target seed location.

[0046] After each of the above diffusion processes, it is necessary to determine whether the diffusion termination condition is met. The diffusion termination condition can be that the number of diffusion iterations reaches a preset threshold, the number of target seed positions is greater than or equal to a preset threshold, or both of these conditions can be used as the diffusion termination condition. If not, multiple diffusion positions are further determined using a preset seed algorithm and the target seed position, and the target seed position is then determined from these multiple diffusion positions until the preset diffusion termination condition is met. Finally, multiple target positions need to be determined based on the initial seed position and the target seed position.

[0047] After obtaining the seed positions, the initial and target seed positions can be perturbed based on a preset perturbation scale to obtain the perturbed positions. It is worth noting that, in order to reduce the overlap between seed positions, the perturbation scale needs to be controlled to be less than half the distance between the initial position and the target seed position adjacent to the initial position; and the perturbed position is then determined as the target position.

[0048] In practical applications, multiple virtual building clusters are typically established, and roads need to be created between these clusters. Taking a virtual scene containing three virtual building clusters as an example, the method for creating roads will be explained.

[0049] Generally, the first virtual building cluster has a first starting waypoint; the second virtual building cluster has a second starting waypoint; and the third virtual building cluster has a third starting waypoint. These starting waypoints can be located within or near the area where the corresponding virtual building cluster is situated; there are no restrictions on this.

[0050] First, a road can be established between the first and second virtual building clusters. These two virtual building clusters can be selected randomly or based on preset conditions, such as minimizing or maximizing the distance between them. The specific settings can be configured according to requirements and are not restricted here.

[0051] In practical implementation, the first target waypoint can be determined based on terrain parameters, a first starting waypoint, and a second starting waypoint. There are usually multiple first target waypoints. These multiple first target waypoints form the first virtual road between the first and second starting waypoints. Various pathfinding algorithms can be used, such as Depth-First Search (DFS), Breadth-First Search (BFS), Dijkstra's algorithm, and A* algorithm, etc., without limitation. Since the road is usually required to be relatively flat, the terrain parameters of the waypoints should also be considered when determining them; locations with gentle slopes can be selected as waypoints.

[0052] After determining the first target waypoint, a second target waypoint needs to be determined based on the third starting waypoint and the first target waypoint. There are usually multiple second target waypoints, forming a second virtual road connecting the third starting waypoint and the first virtual road. Specifically, it's typically necessary to determine the first waypoint closest to the third starting waypoint among the multiple first target waypoints. This can be done by calculating and comparing the distances between each first target waypoint and the third starting waypoint. Then, based on a pre-defined pathfinding algorithm, the second target waypoint located between the third starting waypoint and the first waypoint can be determined. During this process, the slope of the second target waypoint also needs to be considered to create a relatively gentle road.

[0053] This disclosure also provides another method for generating virtual building clusters. This method in... Figure 1 This method is implemented based on the method shown. It represents virtual building clusters as villages, defines suitable areas for villages by analyzing the terrain, and generates roads connecting them. The defined area for each village is determined by terrain features, while the road system is generated by a modified A* algorithm. Users can easily modify relevant parameters to better meet their needs. Since this method does not require complete iteration of all terrain elevation points, it is much faster than existing procedural methods. Furthermore, the improved A* algorithm allows users to control the radius of search waypoints, which also speeds up road generation.

[0054] This method mainly consists of two steps: generating village building locations and generating roads.

[0055] The first step, to speed up the generation process, requires the user to specify a seed location (equivalent to the "initial location" mentioned above). Then, using the user-provided seed location, four new seed points are generated along both the horizontal and vertical directions. Next, it's determined whether the slope of each seed point is within a threshold. If it is not, the seed point is discarded; otherwise, these new seeds are used for the next expansion step.

[0056] In practice, the system first searches for suitable seed point locations along both the horizontal and vertical directions, using a user-specified seed point location and a user-defined radius. If a seed point location is found, the search continues based on the currently found seed point. Figure 3 The image shows the seed point positions after three iterations, with an expansion radius of 2. Figure 3 In the diagram, point S is the seed point specified by the user, and points 1 and 2 are the seed points for the two iterations of expansion. The search radius used in the diagram above is 2, and users can set the search radius and number of iterations according to their needs.

[0057] To determine if a seed point is suitable, its slope can be assessed. The slope of a seed point is determined by calculating the dot product of the current point's normal and its vertical upward vector. A smaller dot product value indicates a steeper slope, making it less suitable as a seed point. Figure 4 As shown, P represents a candidate seed point, P0 and P1 represent its neighboring points, N is the normal to P, and N' is the upward direction.

[0058] To calculate the normal of the seed point, we use its gradient to calculate the horizontal and vertical vectors, i.e., the vectors from P1 to P and from P0 to P. We then perform a cross product of these two vectors to obtain N. Finally, we calculate the dot product of N and N' to get the slope. The second step is to stop expanding after reaching the user-specified number of expansion steps (equivalent to the "diffusion count" mentioned above). Then, we randomly perturb the generated seed point with a perturbation radius half the expansion radius. Next, we randomly select seed points and gradually place buildings. Each placement requires checking if it overlaps with a previous building; if it does, the seed point is discarded.

[0059] After obtaining the final seed points, it is necessary to randomly perturb all seed points in the horizontal and vertical directions to obtain an irregular distribution, such as... Figure 5 As shown, the left image displays the distribution of seed points without disturbance, while the right image shows the distribution of seed points after disturbance. Note that the radius of the disturbance should be less than half of the expansion radius to avoid overlapping seed points. Finally, random points can be selected from these to serve as the locations for village buildings.

[0060] The third step is to use the A* algorithm to find paths to the village seed points given by the user. The cost function of the path needs to take into account the slope between the current point and the surrounding points. The higher the slope, the higher the cost. After the first road is created, the endpoint of subsequent roads should be the point among the existing roads that is closest to the starting point, in order to create T-junctions.

[0061] In the specific implementation, an improved A* algorithm is used to generate roads connecting two villages. First, the search radius of the A* algorithm is user-customizable. This allows for faster road generation, such as... Figure 6 As shown, white dots represent confirmed waypoints, and black dots represent candidate points. A search radius of 2 is used to accelerate pathfinding calculations. Waypoints are determined using the following formula:

[0062] Weight=DistXY(p1, p2)+DistXY(p1, p2)×(1-a)×β

[0063] Where is the Eulerian distance or Manhattan distance from the current waypoint to the destination. α is the slope, here directly taken as the slope values ​​(partial derivatives) of the current waypoint and candidate waypoints. β determines the impact of slope on pathfinding. The effects of different values ​​of β on pathfinding are as follows: Figure 7As shown, the slope has a smaller impact on the left image, while it has a larger impact on the right image.

[0064] After calculation, the candidate point with the smallest weight is selected as the waypoint. Once the first road is created, the endpoint of subsequent roads should be the point on the existing road closest to the starting point to create a T-junction. To simplify the calculation, this method directly uses the Eulerian distance from the current point to all points on the road to obtain the closest distance.

[0065] After the user specifies three village points, the automatically generated building locations and roads are as follows: Figure 8 As shown.

[0066] This method does not require iterating over all terrain elevation points, making it significantly faster than existing procedural methods. Furthermore, the improved A* algorithm allows users to control the radius of search waypoints, further accelerating road generation. The greatest advantages of this method are its flexibility, speed, and ability to generate realistic T-junctions.

[0067] For the above method embodiments, see Figure 9 A virtual building cluster generation device is shown, the device comprising:

[0068] The initial position acquisition module 802 is used to acquire a preset initial position; the initial position is located on the terrain surface of the preset virtual scene;

[0069] The target location determination module 804 is used to determine multiple target locations based on a preset seed algorithm, an initial location, and preset constraints; the constraints are used to limit the slope of the target locations.

[0070] The virtual building setting module 806 is used to set up virtual buildings at multiple target locations to form a virtual building cluster.

[0071] The aforementioned device for generating a virtual building cluster obtains a preset initial position; the initial position is located on the terrain surface of a preset virtual scene; based on a preset seed algorithm, the initial position, and preset constraints, multiple target positions are determined; the constraints are used to limit the slope of the target positions; virtual buildings are set at the multiple target positions to form a virtual building cluster. This method can automatically determine multiple locations for setting virtual buildings, quickly generate virtual building clusters, improve the efficiency of building virtual settlements, and reduce labor costs.

[0072] The aforementioned target location determination module is further configured to: determine the initial location as the initial seed location; determine multiple diffusion locations based on a preset seed algorithm and the initial seed location; determine the target seed location from the multiple diffusion locations, wherein the slope of the target seed location satisfies a preset constraint condition; determine whether the diffusion termination condition is met; the diffusion termination condition includes at least one of the following: the number of diffusions reaches a preset number threshold, and / or, the number of target seed locations is greater than or equal to a preset number threshold; if not met, determine multiple diffusion locations using the preset seed algorithm and the target seed location, and continue to execute the step of determining the target seed location from the multiple diffusion locations based on the terrain parameters corresponding to the multiple diffusion locations, until the preset diffusion termination condition is met; and determine multiple target locations based on the initial seed location and the target seed location.

[0073] The slope of the aforementioned diffused location is represented by the normal direction at the diffused location; the constraints include that the dot product of the normal direction of the target seed location and the target normal direction is greater than a preset first threshold; the target normal direction is vertically upward; the aforementioned target location determination module is also used to: calculate the dot product of the normal direction of the diffused location and the target normal direction for each of the multiple diffused locations; if the dot product is greater than the first threshold, determine the diffused location as the target seed location.

[0074] The aforementioned target location determination module is also used to: determine multiple post-diffusion locations corresponding to the initial seed location based on the initial seed location, multiple preset diffusion directions, and diffusion distance using a preset seed algorithm.

[0075] The aforementioned multiple diffusion directions include at least two of the following: a first direction, a second direction, a third direction, and a fourth direction along the terrain surface; the first direction is opposite to the second direction, the third direction is opposite to the fourth direction, and the first direction is perpendicular to the third direction.

[0076] The aforementioned target location determination module is also used to: perturb the initial location and the target seed location based on a preset perturbation scale to obtain the perturbed location; the perturbation scale is less than half the distance between the initial location and the target seed location adjacent to the initial location; and determine the perturbed location as the target location.

[0077] The aforementioned virtual scene includes a first virtual building cluster, a second virtual building cluster, and a third virtual building cluster; the first virtual building cluster has a first starting waypoint; the second virtual building cluster has a second starting waypoint; and the third virtual building cluster has a third starting waypoint. The aforementioned device further includes: a first target waypoint determination module, used to determine a first target waypoint based on terrain parameters of the terrain surface, the first starting waypoint, and the second starting waypoint; the first target waypoint forms a first virtual road between the first starting waypoint and the second starting waypoint; and a second target waypoint determination module, used to determine a second target waypoint based on the third starting waypoint and the first target waypoint; the second target waypoint forms a second virtual road connected by the third starting waypoint and the first virtual road.

[0078] The aforementioned first target waypoints include multiple ones; the second target waypoint determination module is also used to: determine the first waypoint among the multiple first target waypoints that is closest to the third starting waypoint; and determine the second target waypoint located between the third starting waypoint and the first waypoint based on a preset pathfinding algorithm.

[0079] This embodiment also provides an electronic device, including a processor and a memory. The memory stores machine-executable instructions that can be executed by the processor. The processor executes the machine-executable instructions to implement the above-described method for generating virtual building clusters, for example:

[0080] Obtain a preset initial position; the initial position is located on the terrain surface of a preset virtual scene; based on a preset seed algorithm, the initial position, and preset constraints, determine multiple target positions; the constraints are used to limit the slope of the target positions; set up virtual buildings at multiple target positions to form a virtual building cluster.

[0081] The above method can automatically determine multiple locations for setting up virtual buildings, quickly generate virtual building clusters, improve the efficiency of building virtual settlements, and reduce labor costs.

[0082] Optionally, the steps for determining multiple target locations based on a preset seed algorithm, initial position, and preset constraints include: determining the initial position as the initial seed position; determining multiple diffused positions based on the preset seed algorithm and the initial seed position; determining the target seed position from the multiple diffused positions, wherein the slope of the target seed position satisfies the preset constraints; determining whether the diffusion termination condition is met; the diffusion termination condition includes at least one of the following: the number of diffusions reaches a preset number threshold, and / or, the number of target seed positions is greater than or equal to a preset number threshold; if not met, determining multiple diffused positions using the preset seed algorithm and the target seed position, and continuing to execute the steps for determining the target seed position from the multiple diffused positions based on the terrain parameters corresponding to the multiple diffused positions, until the preset diffusion termination condition is met; and determining multiple target locations based on the initial seed position and the target seed position.

[0083] Optionally, the slope of the diffused location is represented by the normal direction at the diffused location; the constraints include that the dot product of the normal direction of the target seed location and the target normal direction is greater than a preset first threshold; the target normal direction is vertically upward; the step of determining the target seed location from multiple diffused locations, wherein the slope of the target seed location satisfies the preset constraints, includes: for each of the multiple diffused locations, calculating the dot product of the normal direction of the diffused location and the target normal direction; if the dot product is greater than the first threshold, determining the diffused location as the target seed location.

[0084] Optionally, the step of determining multiple diffusion positions based on a preset seed algorithm and an initial seed position includes: determining multiple diffusion positions corresponding to the initial seed position based on the initial seed position, multiple preset diffusion directions, and diffusion distances using a preset seed algorithm.

[0085] Optionally, the above-mentioned multiple diffusion directions include at least two of the following: a first direction, a second direction, a third direction, and a fourth direction along the terrain surface; the first direction is opposite to the second direction, the third direction is opposite to the fourth direction, and the first direction is perpendicular to the third direction.

[0086] Optionally, the above steps for determining multiple target locations based on the initial seed location and the target seed location include: perturbing the initial location and the target seed location based on a preset perturbation scale to obtain the perturbed location; the perturbation scale is less than half the distance between the initial location and the target seed location adjacent to the initial location; and determining the perturbed location as the target location.

[0087] Optionally, the virtual scene includes a first virtual building cluster, a second virtual building cluster, and a third virtual building cluster; the first virtual building cluster has a first starting waypoint; the second virtual building cluster has a second starting waypoint; and the third virtual building cluster has a third starting waypoint. The method further includes: determining a first target waypoint based on terrain parameters of the terrain surface, the first starting waypoint, and the second starting waypoint; the first target waypoint forming a first virtual road between the first starting waypoint and the second starting waypoint; determining a second target waypoint based on the third starting waypoint and the first target waypoint; and the second target waypoint forming a second virtual road connected to the third starting waypoint and the first virtual road.

[0088] Optionally, the aforementioned first target waypoint includes multiple ones; the step of determining the second target waypoint based on the third starting waypoint and the first target waypoint includes: determining the first waypoint among the multiple first target waypoints that is closest to the third starting waypoint; and determining the second target waypoint located between the third starting waypoint and the first waypoint based on a preset pathfinding algorithm.

[0089] See Figure 10 As shown, the electronic device includes a processor 100 and a memory 101. The memory 101 stores machine-executable instructions that can be executed by the processor 100. The processor 100 executes the machine-executable instructions to implement the above-described method for generating virtual building clusters.

[0090] Furthermore, Figure 10 The electronic device shown also includes a bus 102 and a communication interface 103, with the processor 100, the communication interface 103 and the memory 101 connected via the bus 102.

[0091] The memory 101 may include high-speed random access memory (RAM) or non-volatile memory, such as at least one disk storage device. Communication between this system network element and at least one other network element is achieved through at least one communication interface 103 (which can be wired or wireless), such as the Internet, wide area network, local area network, or metropolitan area network. The bus 102 may be an ISA bus, PCI bus, or EISA bus, etc. The bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 10 The symbol is represented by a single double-headed arrow, but this does not mean that there is only one bus or one type of bus.

[0092] The processor 100 may be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above method can be completed by the integrated logic circuitry in the hardware of the processor 100 or by instructions in software form. The processor 100 may be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this disclosure. The general-purpose processor may be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this disclosure can be directly manifested as execution by a hardware decoding processor, or execution by a combination of hardware and software modules in the decoding processor. The software module can reside in a readily available storage medium in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, or registers. This storage medium is located in memory 101, and the processor 100 reads the information from memory 101 and, in conjunction with its hardware, completes the steps of the method described in the foregoing embodiments.

[0093] This embodiment also provides a machine-readable storage medium storing machine-executable instructions. When the machine-executable instructions are called and executed by a processor, the machine-executable instructions cause the processor to implement the above-described method for generating virtual building clusters.

[0094] This disclosure provides a method, apparatus, and electronic device for generating a virtual building cluster, including a computer-readable storage medium storing program code. The program code includes instructions that can be used to execute the methods described in the preceding method embodiments, for example:

[0095] Obtain a preset initial position; the initial position is located on the terrain surface of a preset virtual scene; based on a preset seed algorithm, the initial position, and preset constraints, determine multiple target positions; the constraints are used to limit the slope of the target positions; set up virtual buildings at multiple target positions to form a virtual building cluster.

[0096] The above method can automatically determine multiple locations for setting up virtual buildings, quickly generate virtual building clusters, improve the efficiency of building virtual settlements, and reduce labor costs.

[0097] Optionally, the steps for determining multiple target locations based on a preset seed algorithm, initial position, and preset constraints include: determining the initial position as the initial seed position; determining multiple diffused positions based on the preset seed algorithm and the initial seed position; determining the target seed position from the multiple diffused positions, wherein the slope of the target seed position satisfies the preset constraints; determining whether the diffusion termination condition is met; the diffusion termination condition includes at least one of the following: the number of diffusions reaches a preset number threshold, and / or, the number of target seed positions is greater than or equal to a preset number threshold; if not met, determining multiple diffused positions using the preset seed algorithm and the target seed position, and continuing to execute the steps for determining the target seed position from the multiple diffused positions based on the terrain parameters corresponding to the multiple diffused positions, until the preset diffusion termination condition is met; and determining multiple target locations based on the initial seed position and the target seed position.

[0098] Optionally, the slope of the diffused location is represented by the normal direction at the diffused location; the constraints include that the dot product of the normal direction of the target seed location and the target normal direction is greater than a preset first threshold; the target normal direction is vertically upward; the step of determining the target seed location from multiple diffused locations, wherein the slope of the target seed location satisfies the preset constraints, includes: for each of the multiple diffused locations, calculating the dot product of the normal direction of the diffused location and the target normal direction; if the dot product is greater than the first threshold, determining the diffused location as the target seed location.

[0099] Optionally, the step of determining multiple diffusion positions based on a preset seed algorithm and an initial seed position includes: determining multiple diffusion positions corresponding to the initial seed position based on the initial seed position, multiple preset diffusion directions, and diffusion distances using a preset seed algorithm.

[0100] Optionally, the above-mentioned multiple diffusion directions include at least two of the following: a first direction, a second direction, a third direction, and a fourth direction along the terrain surface; the first direction is opposite to the second direction, the third direction is opposite to the fourth direction, and the first direction is perpendicular to the third direction.

[0101] Optionally, the above steps for determining multiple target locations based on the initial seed location and the target seed location include: perturbing the initial location and the target seed location based on a preset perturbation scale to obtain the perturbed location; the perturbation scale is less than half the distance between the initial location and the target seed location adjacent to the initial location; and determining the perturbed location as the target location.

[0102] Optionally, the virtual scene includes a first virtual building cluster, a second virtual building cluster, and a third virtual building cluster; the first virtual building cluster has a first starting waypoint; the second virtual building cluster has a second starting waypoint; and the third virtual building cluster has a third starting waypoint. The method further includes: determining a first target waypoint based on terrain parameters of the terrain surface, the first starting waypoint, and the second starting waypoint; the first target waypoint forming a first virtual road between the first starting waypoint and the second starting waypoint; determining a second target waypoint based on the third starting waypoint and the first target waypoint; and the second target waypoint forming a second virtual road connected to the third starting waypoint and the first virtual road.

[0103] Optionally, the aforementioned first target waypoint includes multiple ones; the step of determining the second target waypoint based on the third starting waypoint and the first target waypoint includes: determining the first waypoint among the multiple first target waypoints that is closest to the third starting waypoint; and determining the second target waypoint located between the third starting waypoint and the first waypoint based on a preset pathfinding algorithm.

[0104] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the system and apparatus described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0105] Furthermore, in the description of the embodiments of this disclosure, unless otherwise expressly specified and limited, the terms "installation," "connection," and "linking" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection of two components. Those skilled in the art can understand the specific meaning of the above terms in this disclosure based on the specific circumstances.

[0106] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of this disclosure, in essence, or the parts that contribute to the prior art, or parts of the technical solutions, can be embodied in the form of software products. These computer software products are stored in a storage medium and include several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this disclosure. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0107] In the description of this disclosure, it should be noted that the terms "center," "upper," "lower," "left," "right," "vertical," "horizontal," "inner," and "outer," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings, and are only for the convenience of describing this disclosure and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of this disclosure. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance.

[0108] Finally, it should be noted that the above embodiments are merely specific implementations of this disclosure, used to illustrate the technical solutions of this disclosure, and not to limit it. The protection scope of this disclosure is not limited thereto. Although this disclosure has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features, within the scope of the technology disclosed in this disclosure. Such modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this disclosure, and should all be covered within the protection scope of this disclosure. Therefore, the protection scope of this disclosure should be determined by the protection scope of the claims.

Claims

1. A method for generating a virtual building cluster, characterized in that, The method includes: Obtain a preset initial position; the initial position is located on the terrain surface of a preset virtual scene; Based on a preset seed algorithm, the initial position, and preset constraints, multiple target positions are determined; the constraints are used to limit the slope of the target positions. Virtual buildings are set up at the multiple target locations to form a virtual building cluster; The virtual scene includes a first virtual building cluster, a second virtual building cluster, and a third virtual building cluster; the first virtual building cluster has a first starting waypoint; the second virtual building cluster has a second starting waypoint; and the third virtual building cluster has a third starting waypoint. The method further includes: Based on the terrain parameters of the terrain surface, the first starting waypoint, and the second starting waypoint, a first target waypoint is determined; the first target waypoint forms a first virtual road between the first starting waypoint and the second starting waypoint. Determine the first waypoint among the plurality of first target waypoints that is closest to the third starting waypoint; Based on a preset pathfinding algorithm, a second target waypoint is determined between the third starting waypoint and the first waypoint; the second target waypoint forms a second virtual road connecting the third starting waypoint and the first virtual road. The steps for determining multiple target locations based on a preset seed algorithm, the initial position, and preset constraints include: Using the initial position as a seed, the seeds are diffused outwards at a fixed diffusion distance to obtain multiple seed positions after diffusion. The multiple seed positions after diffusion are perturbed according to a preset perturbation scale, and the processed seed positions are determined as target positions; the perturbation scale is less than half of the diffusion distance.

2. The method according to claim 1, characterized in that, The steps for determining multiple target locations based on a preset seed algorithm, the initial position, and preset constraints include: The initial position is determined as the initial seed position; Based on the preset seed algorithm and the initial seed position, multiple diffusion positions are determined; The target seed position is determined from the plurality of diffused positions, wherein the slope of the target seed position satisfies a preset constraint condition; Determine whether the diffusion termination condition is met; the diffusion termination condition includes at least one of the following: the number of diffusions reaches a preset number threshold, and / or, the number of target seed positions is greater than or equal to a preset number threshold; If not, multiple diffusion locations are determined using a preset seed algorithm and the target seed location. The process continues to execute the step of determining the target seed location from the multiple diffusion locations based on the terrain parameters corresponding to the multiple diffusion locations, until the preset diffusion termination condition is met. Based on the initial seed position and the target seed position, multiple target positions are determined.

3. The method according to claim 2, characterized in that, The slope of the diffused position is represented by the normal direction at the diffused position; the constraint condition includes that the dot product of the normal direction of the target seed position and the target normal direction is greater than a preset first threshold. The target normal direction is vertically upward; The steps for determining the target seed location from multiple post-diffusion locations include: For each of the plurality of diffused positions, calculate the dot product of the normal direction of the diffused position and the target normal direction; If the dot product result is greater than the first threshold, the diffused position is determined as the target seed position.

4. The method according to claim 2, characterized in that, The steps for determining multiple diffusion positions based on a preset seed algorithm and the initial seed position include: Based on the initial seed position, multiple preset diffusion directions, and diffusion distances, a preset seed algorithm is used to determine multiple diffusion positions corresponding to the initial seed position.

5. The method according to claim 4, characterized in that, The plurality of diffusion directions include at least two of the following: a first direction, a second direction, a third direction, and a fourth direction along the terrain surface; the first direction is opposite to the second direction, the third direction is opposite to the fourth direction, and the first direction is perpendicular to the third direction.

6. The method according to claim 2, characterized in that, The step of determining multiple target locations based on the initial seed location and the target seed location includes: The initial position and the target seed position are perturbed based on a preset perturbation scale to obtain the perturbed position; the perturbation scale is less than half the distance between the initial position and the target seed position adjacent to the initial position; The disturbed location is determined as the target location.

7. A device for generating a virtual building cluster, characterized in that, The device includes: An initial position acquisition module is used to acquire a preset initial position; the initial position is located on the terrain surface of a preset virtual scene; The target location determination module is used to determine multiple target locations based on a preset seed algorithm, the initial location, and preset constraints; the constraints are used to limit the slope of the target locations. The virtual building setting module is used to set up virtual buildings at the multiple target locations to form a virtual building cluster. The virtual scene includes a first virtual building cluster, a second virtual building cluster, and a third virtual building cluster; the first virtual building cluster has a first starting waypoint; the second virtual building cluster has a second starting waypoint; and the third virtual building cluster has a third starting waypoint. The device further includes: The first target waypoint determination module is used to determine a first target waypoint based on the terrain parameters of the terrain surface, the first starting waypoint, and the second starting waypoint; the first target waypoint forms a first virtual road between the first starting waypoint and the second starting waypoint; The second target waypoint determination module is used for: Determine the first waypoint among the plurality of first target waypoints that is closest to the third starting waypoint; Based on a preset pathfinding algorithm, a second target waypoint is determined between the third starting waypoint and the first waypoint; the second target waypoint forms a second virtual road connecting the third starting waypoint and the first virtual road. The target location determination module is also used for: Using the initial position as a seed, the seeds are diffused outwards at a fixed diffusion distance to obtain multiple seed positions after diffusion. The multiple seed positions after diffusion are perturbed according to a preset perturbation scale, and the processed seed positions are determined as target positions; the perturbation scale is less than half of the diffusion distance.

8. An electronic device, characterized in that, The system includes a processor and a memory, the memory storing machine-executable instructions that can be executed by the processor, the processor executing the machine-executable instructions to implement the method for generating a virtual building cluster as described in any one of claims 1-6.

9. A machine-readable storage medium, characterized in that, The machine-readable storage medium stores machine-executable instructions, which, when invoked and executed by a processor, cause the processor to implement the method for generating a virtual building cluster as described in any one of claims 1-6.

Citation Information

Patent Citations

  • Method for determining gradient of geographical position of transmission line pole tower

    CN102645204A

  • Virtual scene generation method and device

    CN115531883A