Method, apparatus and electronic device for generating vegetation in a virtual scene

By applying the vegetation generation method in virtual scenes in the game engine and using preset control parameters to generate multi-level vegetation, the problems of high repeatability, limitations and low construction efficiency in the existing technology are solved, and a more natural and efficient game scene construction is achieved.

CN115501585BActive Publication Date: 2025-05-27SHANGHAI NETEASE CUICAN NETWORK TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210997361.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-19
Publication Date
2025-05-27
Estimated Expiration
2042-08-19

AI Technical Summary

Technical Problem

The vegetation generation method in existing game scenarios has problems such as high repetition, limitations and low construction efficiency, which affects the player's gaming experience.

Method used

By applying the vegetation generation method in the virtual scene in the game engine, using preset control parameters to generate multi-layered and multiple vegetation in the target area, including the first vegetation and the second vegetation, the growth parameters of the vegetation are controlled through random factors to avoid repetition and limitations.

Benefits of technology

It realizes the repetition and limitations of reducing vegetation in virtual scenes, improves the sense of hierarchy and construction efficiency of the game scene, and improves the player's gaming experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115501585B_ABST
    Figure CN115501585B_ABST
Patent Text Reader

Abstract

The present invention provides a method, apparatus and electronic device for generating vegetation in a virtual scene. The game engine acquires a target area in the virtual scene where vegetation is to be generated; based on a first control parameter that controls the randomness of the growth parameters of the first vegetation, a plurality of first position points of the first vegetation are determined within the target area, and the first vegetation is generated at the first position points; based on a second control parameter that controls the randomness of the growth parameters of the second vegetation, the second vegetation is generated within a specified range of the first vegetation; the vegetation volume and / or vegetation height of the first vegetation and the second vegetation are different. This method can control the randomness of the generation parameters of the vegetation in the target area through the control parameters, and nestedly generate vegetation of different sizes in the virtual scene, so as to avoid the repetition and limitation of the vegetation in the virtual scene while making the virtual scene have a sense of hierarchy; at the same time, this method is automatically completed by the game engine, which can improve the efficiency of virtual scene construction.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of game scene design, and in particular, to a method, device, and electronic device for generating vegetation in a virtual scene. Background Art

[0002] In large-world games, vegetation is a very important part of the natural environment of the game scene. In game engines, the generation of vegetation mostly relies on the built-in tools or related plugins of the engine. However, in the game scenes generated by means of tools, the generation rules of vegetation are mostly single-generation, that is, the generation of the scene is the superposition of multiple single-vegetation objects, resulting in deficiencies such as high repetition and limitations in the game scene, which affect the player's game experience. In order to avoid the repetition of vegetation, external tools of the engine can also be used to generate superimposed or layered vegetation, and then transplanted into the game engine. However, the method of using external tools has poor convenience and intuitiveness, a large learning difficulty, and low scene construction efficiency. Summary of the Invention

[0003] The purpose of the present invention is to provide a method, device, and electronic device for generating vegetation in a virtual scene, so as to reduce the repetition of the game scene, improve the player's game experience, and improve the game scene construction efficiency.

[0004] In a first aspect, the present invention provides a method for generating vegetation in a virtual scene. The method is applied to a game engine and includes: obtaining a target area in the virtual scene where vegetation is to be generated; determining a plurality of first position points of first vegetation in the target area based on a preset first control parameter, and generating first vegetation at the first position points; wherein the first control parameter includes a first random factor and a growth parameter of the first vegetation; the first random factor is used to control the randomness of the growth parameter of the first vegetation; generating second vegetation within a specified range relative to the first vegetation based on a preset second control parameter; the second control parameter includes a second random factor and a growth parameter of the second vegetation; the second random factor is used to control the randomness of the growth parameter of the second vegetation; wherein the vegetation volume and / or vegetation height of the first vegetation and the second vegetation are different.

[0005] In a second aspect, the present invention provides a vegetation generation device in a virtual scene. The device is arranged in a game engine and includes: a region acquisition module for acquiring a target region in the virtual scene where vegetation is to be generated; a first vegetation generation module for determining a plurality of first position points of the first vegetation in the target region based on preset first control parameters and generating the first vegetation at the first position points; wherein the first control parameters include a first random factor and growth parameters of the first vegetation; the first random factor is used to control the randomness of the growth parameters of the first vegetation; a second vegetation generation module for generating second vegetation within a specified range relative to the first vegetation based on preset second control parameters; the second control parameters include a second random factor and growth parameters of the second vegetation; the second random factor is used to control the randomness of the growth parameters of the second vegetation; wherein the vegetation volume and / or vegetation height of the first vegetation and the second vegetation are different.

[0006] In a third aspect, the present invention provides an electronic device, which includes a processor and a memory. 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-mentioned vegetation generation method in the virtual scene.

[0007] In a fourth aspect, the present invention provides a computer-readable storage medium that stores computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions cause the processor to implement the above-mentioned vegetation generation method in the virtual scene.

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

[0009] A vegetation generation method, device and electronic device provided by the present invention are applied to a game engine. First, a target region in the virtual scene where vegetation is to be generated is acquired; then, based on the first control parameters, a plurality of first position points of the first vegetation are determined in the target region, and the first vegetation is generated at the first position points; the first control parameters include a first random factor and growth parameters of the first vegetation; the first random factor is used to control the randomness of the growth parameters of the first vegetation; then, based on the second control parameters, second vegetation is generated within a specified range relative to the first vegetation; the second control parameters include a second random factor and growth parameters of the second vegetation; the second random factor is used to control the randomness of the growth parameters of the second vegetation; wherein the vegetation volume and / or vegetation height of the first vegetation and the second vegetation are different. This method can control the randomness of the generation parameters of vegetation in the target region through control parameters, and generate vegetation of different sizes nested in the virtual scene, so that while the virtual scene has a sense of hierarchy, the repetition and limitation of vegetation in the virtual scene can be avoided; at the same time, this method is automatically completed by the game engine, which can improve the efficiency of virtual scene construction.

[0010] Other features and advantages of the present invention will be set forth in the following description, or may be learned by inference from the description, or may be learned by implementing the above technologies of the present invention without any doubt.

[0011] In order to make the above objects, features, and advantages of the present invention more obvious and understandable, the following specifically describes preferred embodiments in conjunction with the accompanying drawings as follows. Description of the Drawings

[0012] In order to more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the following will briefly introduce the drawings required for the description of the specific embodiments or the prior art. Obviously, the drawings in the following description are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0013] Figure 1 It is a flowchart of a vegetation generation method in a virtual scene provided by an embodiment of the present invention;

[0014] Figure 2 It is a flowchart of another vegetation generation method in a virtual scene provided by an embodiment of the present invention;

[0015] Figure 3 It is a display schematic diagram of a target area provided by an embodiment of the present invention;

[0016] Figure 4 It is a flowchart of another vegetation generation method in a virtual scene provided by an embodiment of the present invention;

[0017] Figure 5 It is a vegetation schematic diagram in a virtual scene provided by an embodiment of the present invention;

[0018] Figure 6 It is a structural schematic diagram of a vegetation generation device in a virtual scene provided by an embodiment of the present invention;

[0019] Figure 7 It is a structural schematic diagram of an electronic device provided by an embodiment of the present invention. Detailed Embodiments

[0020] In order to make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are some, but not all, of the embodiments of the present invention. Usually, the components of the embodiments of the present invention described and illustrated in the drawings here can be arranged and designed in various different configurations.

[0021] Accordingly, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely represents selected embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the scope of protection of the present invention.

[0022] In the large world game, vegetation is a very important part of the natural environment of the game scene. In the game engine, the generation of vegetation mostly relies on the built-in tools or related plugins of the engine. However, in the game scenes generated by these tools, although a randomness factor is introduced in the generation point algorithm to make the vegetation distribution more natural, there are still deficiencies such as high repeatability, rigidity, and limitations in these tool-generated game scenes, which cannot meet specific scattering requirements and affect the player experience. In the existing methods, the Houdini tool can form the layering of vegetation by means of a series of nodes (that is, by using the Houdini tool to establish an overlay scene of vegetation or establish a vegetation rule with layering), but this method must be generated by the Houdini tool and then transplanted into the game engine, with poor convenience and intuitiveness and difficult later adjustment.

[0023] Based on the above problems, the embodiments of the present invention provide a method, device, and electronic device for generating vegetation in a virtual scene. This technology can be applied to various vegetation creation scenarios in virtual scenes, especially in the vegetation creation of game scenes.

[0024] To facilitate the understanding of the embodiments of the present invention, a method for generating vegetation in a virtual scene provided by the embodiments of the present invention will be introduced in detail first. This method is applied to a game engine, which can be a Unity engine, a UE4 engine, etc. As Figure 1 shown, the method includes the following specific steps:

[0025] Step S102, obtain the target area in the virtual scene where vegetation is to be generated.

[0026] In specific implementation, the above target area can be arbitrarily set by the user in the virtual scene according to requirements, can also be set according to the layout in the virtual scene, or can be randomly selected according to the terrain features in the virtual scene, and no specific limitation is made here.

[0027] Step S104, based on a preset first control parameter, determine a plurality of first position points of the first vegetation in the target area, and generate the first vegetation at the first position points; wherein, the first control parameter includes a first random factor and the growth parameter of the first vegetation; the first random factor is used to control the randomness of the growth parameter of the first vegetation.

[0028] The above first control parameter can control the growth parameters of the first vegetation in the target area, so that the first vegetation generated in the target area has a certain degree of randomness. The growth parameters of the first vegetation include one or more of growth density, vegetation size, and vegetation height. Specifically, the growth density of the first vegetation is used to indicate the quantity of the first vegetation in the target area; there can be multiple pre-set values for the vegetation size and vegetation height of the first vegetation, and one or more can be randomly selected from the multiple pre-set first vegetation based on the first random factor as the vegetation size and vegetation height of the first vegetation in the target area.

[0029] In specific implementation, multiple first position points can be determined in the target area according to the growth density of the first vegetation, and then the first vegetation with the vegetation size and vegetation height determined by the first random factor is generated at the first position points.

[0030] Step S106, generate second vegetation within a specified range relative to the first vegetation based on a preset second control parameter; the second control parameter includes a second random factor and the growth parameters of the second vegetation; the second random factor is used to control the randomness of the growth parameters of the second vegetation.

[0031] The above second control parameter can control the growth parameters of the second vegetation generated within the specified range of the first vegetation, so that the second vegetation generated within the specified range has a certain degree of randomness. The growth parameters of the second vegetation include multiple of growth density, vegetation size, and vegetation height. Specifically, the growth density of the second vegetation is used to indicate the quantity of the second vegetation within the specified range; there can be multiple pre-set values for the vegetation size and vegetation height of the second vegetation, and one or more can be randomly selected therefrom based on the second random factor as the vegetation size and vegetation height of the second vegetation within the specified range.

[0032] In specific implementation, the specified range relative to the first vegetation can be a certain area around the first vegetation, and this area can be an annular area around the first vegetation, or a certain area in a certain direction of the first vegetation, or a certain area in several directions of the first vegetation.

[0033] It should be noted that the vegetation volume and / or vegetation height of the above first vegetation and second vegetation are different. Specifically, the first vegetation can only be different from the second vegetation in terms of vegetation volume. For example, the vegetation volume of the first vegetation is greater than that of the second vegetation; the first vegetation can also only be different from the second vegetation in terms of vegetation height. For example, the vegetation height of the first vegetation is higher than that of the second vegetation; the first vegetation can also be different from the second vegetation in both vegetation height and vegetation volume. In practical applications, the vegetation can be trees, flowers, grass, etc.

[0034] A method for generating vegetation in a virtual scene provided by an embodiment of the present invention is applied to a game engine. First, a target area for generating vegetation in the virtual scene is obtained; then, based on a first control parameter, a plurality of first position points of the first vegetation are determined within the target area, and the first vegetation is generated at the first position points; the first control parameter includes a first random factor and a growth parameter of the first vegetation; the first random factor is used to control the randomness of the growth parameter of the first vegetation; then, based on a second control parameter, the second vegetation is generated within a specified range relative to the first vegetation; the second control parameter includes a second random factor and a growth parameter of the second vegetation; the second random factor is used to control the randomness of the growth parameter of the second vegetation; wherein, the vegetation volume and / or vegetation height of the first vegetation and the second vegetation are different. This method can control the randomness of the generation parameters of the vegetation in the target area through the control parameters, and generate vegetation of different sizes nested in the virtual scene, so that while the virtual scene has a sense of hierarchy, the repetition and limitation of the vegetation in the virtual scene can be avoided; at the same time, this method is automatically completed by the game engine, which can improve the efficiency of virtual scene construction.

[0035] Another method for generating vegetation in a virtual scene provided by an embodiment of the present invention is implemented on the basis of the above embodiment. This method focuses on describing the specific process of obtaining the target area for generating vegetation in the virtual scene (specifically implemented through the following steps S202 - S206); as Figure 2 shown, this method includes the following specific steps:

[0036] Step S202, generate a point set storage linked list based on a preset rectangular frame; wherein, the point set storage linked list includes: a plurality of vertices, and the position coordinates of each vertex.

[0037] In specific implementation, when the user selects the target area for generating vegetation in the virtual scene, a preset rectangular frame will be displayed in the graphical user interface of the scene screen showing the virtual scene. The user can drag the preset rectangular frame to slide in the virtual scene, and determine the area surrounded by the preset rectangular frame in the virtual scene when the sliding stops as the initial area. The size of the initial area is the same as that of the preset rectangular frame, and the initial area contains four vertices, which are also the vertices that make up the preset rectangular frame; when the position of the initial area is determined, the coordinates of these four vertices are also determined, and then more vertices can be added on the basis of these four vertices to obtain the target area surrounded by the added vertices and these four vertices. Specifically, the added vertices and these four vertices need to be stored in the point set storage linked list, which is used to store the attribute information of the vertices, and the attribute information includes the position coordinates of the vertices, the boolean attributes of the vertices, etc.

[0038] In practical applications, first, a polygon point set needs to be established based on the four vertices included in the initial area. This polygon point set contains multiple vertices, and each vertex is pre-set with a Node class. The Node class includes the position coordinates and boolean attributes of the vertex, etc. Then, based on the Node class of each vertex, a variable point set storage linked list is established. Among them, the number of vertices included in the point set storage linked list can change, and while the number of vertices increases, the attribute information of the vertices can also change accordingly. For example, the change in the position coordinates of the vertices.

[0039] In some embodiments, the initial area can also be determined as the target area. At this time, only four vertices and the attribute information of each vertex are stored in the point set storage linked list.

[0040] Step S204: Display the vertices included in the point set storage linked list in the virtual scene, and connect the vertices included in the point set storage linked list in this virtual scene.

[0041] In specific implementation, based on the OnSceneGUI() function of the game engine, the vertices in the point set storage linked list can be taken out in sequence, and the vertices can be displayed in the virtual scene in counterclockwise order in sequence. Then, two points are connected in the order of taking out the vertices to form a visualization line. As Figure 3 shown in a schematic diagram of the display of a target area, Figure 3 the target area in it contains 8 vertices. Among them, the positions at both ends of the visualization line and where the three-dimensional coordinate system is set are the positions of the vertices. The polygonal area surrounded by these 8 vertices is the target area.

[0042] Step S206: Determine the area surrounded by connecting the vertices included in the point set storage linked list as the target area.

[0043] Step S208: Based on a preset first control parameter, determine multiple first position points of the first vegetation in the target area, and generate the first vegetation at the first position points; among them, the first control parameter includes a first random factor and the growth parameters of the first vegetation; the first random factor is used to control the randomness of the growth parameters of the first vegetation.

[0044] Step S210: Based on a preset second control parameter, generate the second vegetation within a specified range relative to the first vegetation; among them, the second control parameter includes a second random factor and the growth parameters of the second vegetation; the second random factor is used to control the randomness of the growth parameters of the second vegetation.

[0045] Step S212: Generate the third vegetation within a specified range relative to the second vegetation based on a preset third control parameter. The third control parameter includes a third random factor and the growth parameters of the third vegetation. The third random factor is used to control the randomness of the growth parameters of the third vegetation. Among them, the vegetation volumes and / or vegetation heights of the first vegetation, the second vegetation, and the third vegetation are different.

[0046] The above-mentioned third control parameter can control the growth parameters of the third vegetation generated within the specified range of the second vegetation, so that the third vegetation generated within the specified range has a certain degree of randomness. The growth parameters of the third vegetation include one or more of growth density, vegetation size, and vegetation height. Specifically, the growth density of the third vegetation is used to indicate the quantity of the third vegetation within the specified range of the second vegetation. There can be multiple preset values for the vegetation size and vegetation height of the third vegetation, and one or more of them can be randomly selected based on the third random factor as the vegetation size and vegetation height of the third vegetation within the specified range of the second vegetation.

[0047] In specific implementation, the specified range relative to the second vegetation can be a certain area around the second vegetation. This area can be an annular area around the second vegetation, a certain area in a certain direction of the second vegetation, or a certain area in several directions of the second vegetation.

[0048] In some embodiments, the above-mentioned first vegetation can be referred to as a large object, the second vegetation can be referred to as a medium object, and the third vegetation can be referred to as a small object. Thus, the present invention can generate large, medium, and small multi-level nested vegetation in a virtual scene. In the real-world scene, there is a certain nesting pattern in the vegetation scene, that is, there will be some medium objects (sub-objects) around a large object (parent object), and there will be some small objects (grandchildren objects) around the medium object (sub-object). These scene objects generate a more natural real world based on the principle of multi-level nesting such as large, medium, and small. The present invention can generate three types of objects, large, medium, and small, in a virtual scene based on this regular phenomenon to simulate the natural vegetation distribution.

[0049] The above-mentioned method for generating vegetation in a virtual scene can generate a virtual scene with multiple sets of large, medium, and small vegetation nesting types based on a set target area. At the same time, this method introduces a random factor, so that the vegetation in the virtual scene has a sense of hierarchy without losing randomness. In addition, this method is realized through programmed operations, which can improve the efficiency of scene construction and also save labor.

[0050] The embodiment of the present invention also provides another method for generating vegetation in a virtual scene. This method is implemented on the basis of the above embodiment, and focuses on describing the specific process of determining multiple first position points of the first vegetation in the target area based on a preset first control parameter and generating the first vegetation at the first position points (specifically implemented through the following steps S404 - S410); as Figure 4 shown, the method includes the following specific steps:

[0051] Step S402, obtain the target area of the vegetation to be generated in the virtual scene.

[0052] Step S404, scatter points into the target area based on a preset point set to obtain multiple initial position points.

[0053] The above preset point set contains multiple points, and the number of points contained in the preset point set can be set according to requirements. For example, the preset point set can contain 10,000 points or 2,000 points, etc. The points in the preset point set can be scattered evenly into the target area, scattered according to a preset rule, or scattered randomly into the target area. The specific scattering rule can be generated according to the R & D requirements, and the positions of the points finally scattered into the target area are determined as the initial position points.

[0054] In specific implementation, the above step S404 can be implemented through the following steps 10 - 12:

[0055] Step 10, construct the minimum circumscribed regular quadrilateral of the target area.

[0056] In specific implementation, the above target area is an area surrounded by multiple vertices. Traverse the vertices corresponding to the target area, and sequentially obtain the position coordinates of all vertices on the plane where the X - axis and Z - axis are located, obtain the vertex corresponding to the maximum coordinate and the vertex corresponding to the minimum coordinate in this plane, and then extend the vertices in the X - axis direction and Z - axis direction respectively to establish a regular quadrilateral area of the target area. This regular quadrilateral area is also the minimum circumscribed regular quadrilateral of the target area, and this regular quadrilateral can be a rectangle or a square.

[0057] In some embodiments, the minimum circumscribed regular quadrilateral of the target area can also be directly constructed through a preset function.

[0058] Step 11, evenly scatter the preset points in the preset point set within the minimum circumscribed regular quadrilateral.

[0059] In specific implementation, the length and width of the minimum circumscribed regular quadrilateral can be obtained according to the coordinates of the minimum circumscribed regular quadrilateral, and then the preset points contained in the preset point set are evenly distributed within the minimum circumscribed regular quadrilateral to complete the operation of scattering the preset points in the preset point set.

[0060] Step 12: Among the preset points within the minimum circumscribed regular quadrilateral, determine the preset points located within the target area as the initial position points.

[0061] In specific implementation, it is necessary to determine whether the preset points are within the target area. Based on the judgment result, determine the preset points within the target area as the initial position points. Specifically, for each preset point within the minimum circumscribed regular quadrilateral, the following steps 20 - 21 need to be executed to determine whether the preset point is within the target area:

[0062] Step 20: Starting from the current preset point, emit a ray in a preset direction.

[0063] Take each preset point within the minimum circumscribed regular quadrilateral as the current preset point once. The above preset direction can be the direction of the X-axis or the Z-axis, etc.

[0064] Step 21: Count the number of intersection points between the ray emitted from the current preset point and the border of the target area; if the number of intersection points is odd, determine that the current preset point is within the target area and determine the current preset point as the initial position point.

[0065] In specific implementation, if the number of intersection points between the ray emitted from the preset point and the border of the target area is odd, determine that the preset point is within the target area and determine the position of the preset point as the initial position point; if the number of intersection points between the ray emitted from the preset point and the border of the target area is even, determine that the preset point is not within the target area and discard the preset point.

[0066] Step S406: Determine the growth density of the first vegetation according to the first random factor; where the growth density is used to indicate the growth quantity of the first vegetation within the target area.

[0067] For the density control weight corresponding to the above first random factor, multiplying the number of initial position points by the density control weight can obtain the growth quantity of the first vegetation. The amount of this growth quantity is used to characterize the growth density of the first vegetation. The above growth density is also one of the growth parameters.

[0068] Step S408: Based on multiple initial position points and the growth density of the first vegetation, determine multiple first position points of the first vegetation.

[0069] In specific implementation, the first position points matching the growth density can be selected from multiple initial positions. For example, if the growth density indicates that the growth quantity of the first vegetation is 1000 and the number of initial position points is 2000, then 1000 initial position points can be randomly selected or selected according to the program - set rules from the 2000 initial position points as the first position points.

[0070] In some embodiments, multiple intermediate position points matching the growth density may first be selected from multiple initial position points, and then, based on the volume of the first vegetation, the multiple intermediate position points are offset to determine the first position points as the offset intermediate position points. Specifically, the bounding box size of the first vegetation may be determined according to the volume of the first vegetation, and then, on the basis of the bounding box size, the intermediate position points are randomly offset or moderately offset to make the distribution of the first position points more natural. Multiple intermediate position points matching the growth density may be selected from multiple initial position points randomly or according to a program-set rule.

[0071] Step S410: Generate the first vegetation at each first position point.

[0072] In specific implementation, the growth parameters of the vegetation may include the growth density, and may also include the vegetation size and / or the vegetation height. Therefore, for each first position point, the vegetation size and / or the vegetation height of the first vegetation generated at the current first position point may be determined based on the first random factor to generate the first vegetation at the current first position point.

[0073] When generating the first vegetation at the first position point, first determine the initial X-axis coordinate and Z-axis coordinate corresponding to the first position point, and then obtain the vertical direction coordinate (Y value) of the first position point through the Ray() function of the ray detection of the game engine. The Ray() function of the ray detection can obtain the coordinate information of the current point on the terrain, so as to obtain the Y value of the first vegetation coordinate. After obtaining the coordinates of the first position point, it is necessary to generate the first vegetation at the first position point based on the vegetation size and vegetation height of the first vegetation determined based on the first random factor.

[0074] To increase the randomness of the scene, the first random factor is introduced in this solution to randomize attributes such as the vegetation position, vegetation size, and vegetation height. Specifically, the first random factor includes the first type control factor; the above step S410 may be implemented through the following steps 30-32:

[0075] Step 30: Based on the first type control factor, select the target type of the first vegetation from multiple preset types of the first vegetation; wherein, at least one of the vegetation size, vegetation height, and vegetation type of each type of the first vegetation is different.

[0076] In specific implementation, multiple types of the first vegetation are preset. The vegetation size, vegetation height, and vegetation type of each type of the first vegetation may all be different, or only one or two of them may be different. The number of preset types of the first vegetation may be set according to the R & D requirements. For example, three different types of the first vegetation may be preset in advance, so that the types of the first vegetation generated in the virtual scene are diverse, making the virtual scene more natural on the basis of the hierarchical distribution.

[0077] Step 31, determine the vegetation growth direction of the first vegetation of the target type.

[0078] In specific implementation, the methods for determining the vegetation growth direction of the first vegetation of the target type include the following two:

[0079] Method 1: According to the terrain information corresponding to the current first position point of the first vegetation, determine the normal direction of the current first position point, and determine the normal direction as the vegetation growth direction of the first vegetation.

[0080] Specifically, according to the terrain information of the position where the current first position point is located, the normal direction of the current first position point on the terrain (that is, the direction perpendicular to the position where the current first position point is located) can be determined, so as to use the determined normal direction as the vegetation growth direction of the first vegetation. For example, when some vegetation needs to grow vertically on a plane (this plane is also the plane where the first position point is located), the interest rate control factor can be adjusted to achieve this.

[0081] Method 2: Determine the direction vertically upward in the virtual scene as the vegetation growth direction of the first vegetation.

[0082] The above two methods can increase the naturalness of the virtual scene distribution and special growth requirements.

[0083] Step 32, based on the growth direction of the first vegetation of the target type, generate the first vegetation of the target type at the current first position point.

[0084] In practical applications, before generating the first vegetation at the first position point, the second position points with slopes greater than the preset slope threshold can also be determined from the multiple first position points through the slope control factor; then the second position points among the multiple first position points are deleted to obtain the final first position points for generating the first vegetation. This method can prevent vegetation from being generated at positions with too large slopes, making the vegetation distribution more in line with the real scene.

[0085] Step S412, generate the second vegetation within a specified range relative to the first vegetation based on the second control parameter; the second control parameter includes a second random factor and the growth parameters of the second vegetation; the second random factor is used to control the randomness of the growth parameters of the second vegetation.

[0086] In specific implementation, to generate the second vegetation within a specified range relative to the first vegetation, the following steps 40 - 42 need to be executed for each first position point where the first vegetation is generated:

[0087] Step 40, establish a first adjustment ring area with the current first position point as the center.

[0088] Each first position point for generating the first vegetation usually needs to be determined as the current first position point once, and a first adjustment circular ring area is established around the current first position point, so that the generation of the second vegetation can avoid the self - range of the first vegetation, and the second vegetation is randomly generated within the first adjustment circular ring area.

[0089] Step 41: Based on the second random factor, determine the growth parameters of the second vegetation within the first adjustment circular ring area.

[0090] Specifically, the above - mentioned growth parameters may include growth density, and the second random factor includes a density control factor; thus, based on the density control factor, the growth density of the second vegetation within the first adjustment circular ring area can be determined; where the growth density is used to indicate the growth quantity of the second vegetation within the first adjustment circular ring area; and then, according to the growth density, the second vegetation is generated within the first adjustment area. The above - mentioned density control factor includes a minimum quantity value and a maximum quantity value, and the density control factor can randomly select a value from the range between the minimum quantity value and the maximum quantity value, and use this value as the growth quantity of the second vegetation within the first adjustment circular ring area, so as to make the generation of the second vegetation more natural.

[0091] Furthermore, the above - mentioned growth parameters may also include vegetation size and / or vegetation height; the second random factor may also include a second type control factor; thus, based on the second type control factor, at least one type of the second vegetation can be selected from a preset variety of types of the second vegetation to generate at least one type of the second vegetation within the first adjustment circular ring area.

[0092] In specific implementation, there are a variety of preset types of the second vegetation. The vegetation size, vegetation height, and vegetation type of each type of the second vegetation may all be different, or only one or two of them may be the same. The number of preset types of the second vegetation can be set according to R & D requirements. For example, three different types of the second vegetation can be preset in advance, so that the types of the second vegetation generated in the virtual scene are diverse, and the virtual scene is more natural on the basis of hierarchical distribution.

[0093] Step 42: Based on the determined growth parameters of the second vegetation, generate the second vegetation within the first adjustment circular ring area.

[0094] When generating the second vegetation within the first adjustment circular ring area, first determine the initial X - axis coordinate and Z - axis coordinate corresponding to the points scattered within the first adjustment circular ring area (one point generates one second vegetation), and then use the ray detection Ray() function of the game engine to obtain the vertical direction coordinate (Y value) of the points. The ray detection Ray() function can obtain the coordinate information of the current point on the terrain, so as to obtain the Y value of the second vegetation coordinate.

[0095] In some embodiments, before generating the second vegetation within a specified range relative to the first vegetation based on a preset second control parameter, an instruction for setting the object attribute of the first vegetation may also be received, and the first vegetation may be set as all objects, or the first vegetation may be set as partial objects; wherein, if the first vegetation is set as all objects, the second vegetation will be generated within the specified range of each first vegetation; if the first vegetation is set as partial objects, the second vegetation will be generated within the specified range of some of the first vegetation (that is, the second vegetation will not be generated around some of the first vegetation, and the second vegetation will be generated around some of the first vegetation).

[0096] In terms of the generation quantity of the second vegetation, this solution adopts a random control of the maximum / minimum quantity (equivalent to the above density control factor) setting and a random generation control of all objects or partial objects. Among them, in terms of quantity, the Ramdom() function can randomly take values within this interval by reading the minimum / maximum value, making the generation more natural. In terms of the generation of partial objects and all objects, the generation of partial objects is based on probability control, so that the second vegetation will not be generated around some of the first vegetation, and the generation of all objects means that the second vegetation will be generated around all of the first vegetation.

[0097] Step S414, generate the third vegetation within a specified range relative to the second vegetation based on a third control parameter; the third control parameter includes a third random factor and the growth parameter of the third vegetation; the third random factor is used to control the randomness of the growth parameter of the third vegetation.

[0098] The vegetation volumes and / or vegetation heights of the above-mentioned first vegetation, second vegetation, and third vegetation are different. In some embodiments, the above-mentioned first vegetation may be referred to as a large object, the second vegetation may be referred to as a medium object, and the third vegetation may be referred to as a small object. Thus, the present invention can generate large, medium, and small multi-level nested vegetation in a virtual scene. As Figure 5 shown is a schematic diagram of vegetation in a virtual scene.

[0099] Specifically, the generation rule of the third vegetation around the second vegetation is the same as the principle of the generation rule of the second vegetation around the first vegetation. The difference is that the coordinate acquisition position of the third vegetation takes the generation position point of the second vegetation as a reference. In specific implementation, to generate the third vegetation within a specified range relative to the second vegetation, the following steps 60-62 need to be executed for each position point where the second vegetation is generated:

[0100] Step 60, establish a second adjustment ring area with the current position point as the center.

[0101] Each position point for generating the second vegetation usually needs to be determined as the current position point once, and a second adjustment ring area is established around the current position point, so that the generation of the third vegetation can avoid the self - range of the second vegetation, and the third vegetation is randomly generated within the second adjustment ring area.

[0102] Step 61: Based on the third random factor, determine the growth parameters of the third vegetation within the second adjustment ring area; wherein, the growth parameters include at least one of growth density, vegetation size, and vegetation height.

[0103] Specifically, the above - mentioned third random factor includes a density control factor and a third type control factor; thus, based on the density control factor, the growth density of the third vegetation within the second adjustment ring area can be determined; where the growth density is used to indicate the growth quantity of the third vegetation within the second adjustment ring area; and then based on the third type control factor, at least one type of the third vegetation is selected from a preset variety of types of the third vegetation to generate at least one type of the third vegetation within the second adjustment ring area.

[0104] Step 62: Based on the determined growth parameters of the third vegetation, generate the third vegetation within the second adjustment ring area.

[0105] In specific implementation, for the vegetation growth direction of the above - mentioned second vegetation, the normal direction of the growth position can be determined according to the terrain information corresponding to the growth position of the second vegetation, and this normal direction is determined as the vegetation growth direction of the second vegetation; or the vertically upward direction in the virtual scene can be determined as the vegetation growth direction of the second vegetation.

[0106] Similarly, for the vegetation growth direction of the above - mentioned third vegetation, the normal direction of the growth position can be determined according to the terrain information corresponding to the growth position of the third vegetation, and this normal direction is determined as the vegetation growth direction of the third vegetation; or the vertically upward direction in the virtual scene can be determined as the vegetation growth direction of the third vegetation.

[0107] In specific implementation, the attribute information of the first vegetation generated at the first position point is saved to a preset configuration file; wherein, the attribute information includes position information and growth parameters; the attribute information of the second vegetation generated within the specified range relative to the first vegetation is saved to the configuration file; the attribute information of the third vegetation generated within the specified range relative to the second vegetation is saved to the configuration file. This method adds a save setting for the already - scattered vegetation. Based on the game engine file configuration script, the scattered objects and related setting parameters are saved, which is convenient for the reuse or sharing of scene objects (generated vegetation), thereby improving the scene construction efficiency.

[0108] The above-mentioned vegetation generation method in the virtual scene. This solution can build a virtual scene with multi-level and multi-layer vegetation distribution, making the vegetation objects in the scene more natural on the basis of layering. At the same time, this solution is simply designed and easy to operate, which can greatly improve the efficiency of scene building.

[0109] Corresponding to the above method embodiment, an embodiment of the present invention further provides a vegetation generation device in a virtual scene. This device is set in a game engine, such as Figure 6 as shown, this device includes:

[0110] An area acquisition module 60, configured to acquire a target area in the virtual scene where vegetation is to be generated.

[0111] A first vegetation generation module 61, configured to determine a plurality of first position points of the first vegetation in the target area based on a preset first control parameter, and generate the first vegetation at the first position points; wherein, the first control parameter includes a first random factor and a growth parameter of the first vegetation; the first random factor is used to control the randomness of the growth parameter of the first vegetation.

[0112] A second vegetation generation module 62, configured to generate the second vegetation within a specified range relative to the first vegetation based on a preset second control parameter; the second control parameter includes a second random factor and a growth parameter of the second vegetation; the second random factor is used to control the randomness of the growth parameter of the second vegetation.

[0113] Wherein, the vegetation volume and / or vegetation height of the first vegetation and the second vegetation are different.

[0114] For the above-mentioned vegetation generation device in the virtual scene, the game engine first acquires the target area in the virtual scene where vegetation is to be generated; then, based on the first control parameter, determines a plurality of first position points of the first vegetation in the target area, and generates the first vegetation at the first position points; the first control parameter includes a first random factor and a growth parameter of the first vegetation; the first random factor is used to control the randomness of the growth parameter of the first vegetation; then, based on the second control parameter, generates the second vegetation within a specified range relative to the first vegetation; the second control parameter includes a second random factor and a growth parameter of the second vegetation; the second random factor is used to control the randomness of the growth parameter of the second vegetation; wherein, the vegetation volume and / or vegetation height of the first vegetation and the second vegetation are different. This method can control the randomness of the generation parameters of the vegetation in the target area through the control parameters, and generate vegetation of different sizes nested in the virtual scene, so as to avoid the repetition and limitation of the vegetation in the virtual scene while the virtual scene has a sense of hierarchy; at the same time, this method is automatically completed by the game engine, which can improve the efficiency of virtual scene building.

[0115] Specifically, the above-mentioned region acquisition module 60 is further configured to: generate a point set storage linked list based on a preset rectangular frame; wherein, the point set storage linked list includes: multiple vertices and the position coordinates of each vertex; display the vertices included in the point set storage linked list in the virtual scene, and connect the vertices included in the point set storage linked list in the virtual scene; determine the region enclosed by connecting the vertices included in the point set storage linked list as the target region.

[0116] Furthermore, the above-mentioned growth parameters include growth density; the above-mentioned first vegetation generation module 61 includes: an initial position point determination unit, configured to scatter points into the target region based on a preset point set to obtain multiple initial position points; a growth density determination unit, configured to determine the growth density of the first vegetation according to a first random factor; wherein, the growth density is used to indicate the growth quantity of the first vegetation in the target region; a first position point determination unit, configured to determine multiple first position points of the first vegetation based on the multiple initial position points and the growth density of the first vegetation; a first vegetation generation unit, configured to generate the first vegetation at each first position point.

[0117] Specifically, the above-mentioned initial position point determination unit is configured to: construct the minimum circumscribed regular quadrilateral of the target region; evenly scatter the preset points in the preset point set within the minimum circumscribed regular quadrilateral; determine the preset points within the minimum circumscribed regular quadrilateral and located in the target region as the initial position points.

[0118] In specific implementation, the above-mentioned initial position point determination unit is further configured to: for each preset point within the minimum circumscribed regular quadrilateral, perform the following operations: emit a ray in a preset direction with the current preset point as the starting point; count the number of intersection points between the emitted ray of the current preset point and the border of the target region; if the number of intersection points is odd, determine that the current preset point is within the target region and determine the current preset point as the initial position point.

[0119] Furthermore, the above-mentioned first position point determination unit is configured to: select the first position points that match the growth density from the multiple initial positions.

[0120] Furthermore, the above-mentioned first position point determination unit is further configured to: select multiple intermediate position points that match the growth density from the multiple initial position points; offset the multiple intermediate position points based on the volume of the first vegetation, and determine the offset intermediate position points as the first position points.

[0121] Specifically, the above-mentioned growth parameters further include vegetation size and / or vegetation height; the above-mentioned first vegetation generation unit is further configured to: for each first position point, determine the vegetation size and / or vegetation height of the first vegetation generated at the current first position point based on a first random factor, so as to generate the first vegetation at the current first position point.

[0122] In specific implementation, the above-mentioned first random factor includes a first type of control factor; the above-mentioned first vegetation generation unit is further configured to: based on the first type of control factor, select a target type of first vegetation from a preset variety of first vegetation types; wherein, at least one of the vegetation size, vegetation height, and vegetation type of each type of first vegetation is different; determine the vegetation growth direction of the target type of first vegetation; and generate the target type of first vegetation at the current first position point based on the growth direction of the target type of first vegetation.

[0123] Further, the above-mentioned first vegetation generation unit is further configured to: according to the terrain information corresponding to the current first position point corresponding to the first vegetation, determine the normal direction of the current first position point, and determine the normal direction as the vegetation growth direction of the first vegetation; or, determine the vertically upward direction in the virtual scene as the vegetation growth direction of the first vegetation.

[0124] In specific implementation, the above-mentioned device further includes a growth control module, configured to: before generating the first vegetation at the first position point, determine, through a slope control factor, a second position point among the multiple first position points where the slope is greater than a preset slope threshold; delete the second position points among the multiple first position points to obtain the final first position point for generating the first vegetation.

[0125] Further, the above-mentioned second vegetation generation module 62 is configured to: for each first position point where the first vegetation is generated, perform the following operations: establish a first adjustment ring area centered on the current first position point; determine the growth parameters of the second vegetation within the first adjustment ring area based on a second random factor; and generate the second vegetation within the first adjustment ring area based on the determined growth parameters of the second vegetation.

[0126] Specifically, the above-mentioned growth parameters include growth density; the second random factor includes a density control factor; the above-mentioned second vegetation generation module 62 is further configured to: determine the growth density of the second vegetation within the first adjustment ring area based on the density control factor; wherein, the growth density is used to indicate the growth quantity of the second vegetation within the first adjustment ring area; and generate the second vegetation within the first adjustment area according to the growth density.

[0127] Further, the above-mentioned growth parameters further include vegetation size and / or vegetation height; the second random factor includes a second type of control factor; the above-mentioned second vegetation generation module 62 is further configured to: based on the second type of control factor, select at least one type of second vegetation from a preset variety of second vegetation types to generate at least one type of second vegetation within the first adjustment ring area; wherein, at least one of the vegetation size, vegetation height, and vegetation type of each type of second vegetation is different.

[0128] Further, the above device further includes a vegetation type setting module, configured to: before generating the second vegetation within a specified range relative to the first vegetation based on a preset second control parameter, receive an instruction to set the object attributes of the first vegetation, and set the first vegetation as all objects, or set the first vegetation as partial objects; wherein, if the first vegetation is set as all objects, the second vegetation will be generated within the specified range of each first vegetation; if the first vegetation is set as partial objects, the second vegetation will be generated within the specified range of partial first vegetation.

[0129] Further, the above device further includes a third vegetation generation module, configured to: after generating the second vegetation within a specified range relative to the first vegetation based on a preset second control parameter, generate a third vegetation within a specified range relative to the second vegetation based on a preset third control parameter; the third control parameter includes a third random factor and the growth parameters of the third vegetation; the third random factor is used to control the randomness of the growth parameters of the third vegetation; wherein, the vegetation volumes and / or vegetation heights of the first vegetation, the second vegetation, and the third vegetation are different.

[0130] In specific implementation, the above third vegetation generation module is further configured to: for the position points where the second vegetation is generated, perform the following operations: establish a second adjustment ring area with the current position point as the center; determine the growth parameters of the third vegetation within the second adjustment ring area based on the third random factor; wherein, the growth parameters include at least one of growth density, vegetation size, and vegetation height; generate the third vegetation within the second adjustment ring area based on the determined growth parameters of the third vegetation.

[0131] Further, the above device further includes an information storage module, configured to: save the attribute information of the first vegetation generated at the first position point to a preset configuration file; wherein, the attribute information includes position information and growth parameters; save the attribute information of the second vegetation generated within the specified range relative to the first vegetation to the configuration file.

[0132] The vegetation generation device in the virtual scene provided by the embodiments of the present invention has the same implementation principle and the same technical effects as those of the foregoing method embodiments. For a brief description, for the parts not mentioned in the device embodiments, reference may be made to the corresponding content in the foregoing method embodiments.

[0133] The embodiments of the present invention further provide an electronic device, as Figure 7 shown, the electronic device includes a processor and a memory, 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-mentioned vegetation generation method in the virtual scene.

[0134] Further, Figure 7The electronic device shown also includes a bus 102 and a communication interface 103. The processor 101, the communication interface 103, and the memory 100 are connected through the bus 102.

[0135] Among them, the memory 100 may include a high-speed random access memory (RAM, Random Access Memory), and may also include a non-volatile memory, such as at least one disk memory. Through at least one communication interface 103 (which can be wired or wireless), a communication connection is realized between this system network element and at least one other network element. The Internet, wide area network, local area network, metropolitan area network, etc. can be used. The bus 102 can be an ISA bus, a PCI bus, an EISA bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For the sake of convenience of representation, Figure 7 only a bidirectional arrow is used in the figure, but it does not mean that there is only one bus or one type of bus.

[0136] The processor 101 may be an integrated circuit chip with signal processing capabilities. In the implementation process, the steps of the above method can be completed by the integrated logic circuit in the hardware of the processor 101 or the instructions in the form of software. The above-mentioned processor 101 can be a general-purpose processor, including a central processing unit (CPU, Central Processing Unit for short), a network processor (NP, Network Processor for short), etc.; it can also be a digital signal processor (DSP, Digital Signal Processing for short), an application specific integrated circuit (ASIC, Application Specific Integrated Circuit for short), a field-programmable gate array (FPGA, Field-Programmable Gate Array for short), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. It can implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of the present invention. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in combination with the embodiments of the present invention can be directly embodied as being executed and completed by the hardware decoding processor, or executed and completed by the combination of the hardware and software modules in the decoding processor. The software module can be located in a mature storage medium in the art, such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. This storage medium is located in the memory 100, and the processor 101 reads the information in the memory 100 and combines its hardware to complete the steps of the method in the foregoing embodiments.

[0137] An embodiment of the present invention further provides a computer-readable storage medium storing computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions cause the processor to implement the vegetation generation method in the above virtual scenario. For specific implementation, reference may be made to the method embodiment, which will not be elaborated here.

[0138] If the above functions are implemented in the form of software function units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on such understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a terminal device, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The foregoing storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memories (ROMs), random access memories (RAMs), magnetic disks, or optical discs that can store program codes.

[0139] In the description of the present invention, it should be noted that the orientation or positional relationship indicated by the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc. is based on the orientation or positional relationship shown in the drawings. It is only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and thus should not be construed as a limitation to the present invention. In addition, the terms "first", "second", "third" are only used for descriptive purposes and cannot be construed as indicating or implying relative importance.

[0140] Finally, it should be noted that the above-described embodiments are only specific embodiments of the present invention, used to illustrate the technical solutions of the present invention, rather than limiting them. The protection scope of the present invention is not limited thereto. Although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: any person skilled in the art within the technical scope disclosed by the present invention can still modify the technical solutions described in the foregoing embodiments or easily conceive of changes, or perform equivalent replacements for some of the technical features; and these modifications, changes, or replacements 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 the present invention and should all be covered within the protection scope of the present invention. Therefore, the protection scope of the present invention should be determined by the protection scope of the claims.

Claims

1. A method for generating vegetation in a virtual scene, characterized in that, the method includes: Obtaining a target area in the virtual scene where vegetation is to be generated; Based on a preset first control parameter, determining multiple first position points of the first vegetation in the target area, and generating the first vegetation at the first position points; wherein, the first control parameter includes a first random factor and the growth parameters of the first vegetation; the first random factor is used to control the randomness of the growth parameters of the first vegetation; Based on a preset second control parameter, generating second vegetation within a specified range relative to the first vegetation; the second control parameter includes a second random factor and the growth parameters of the second vegetation; the second random factor is used to control the randomness of the growth parameters of the second vegetation; wherein, the vegetation volume and / or vegetation height of the first vegetation and the second vegetation are different.

2. The method according to claim 1, characterized in that, the step of obtaining a target area in the virtual scene where vegetation is to be generated includes: Based on a preset rectangular frame, generating a point set storage linked list; wherein, the point set storage linked list includes: multiple vertices, and the position coordinates of each vertex; Displaying the vertices included in the point set storage linked list in the virtual scene, and connecting the vertices included in the point set storage linked list in the virtual scene; Determining the area enclosed by connecting the vertices included in the point set storage linked list as the target area.

3. The method according to claim 1, characterized in that, the growth parameter includes growth density; the step of determining multiple first position points of the first vegetation in the target area based on a preset first control parameter and generating the first vegetation at the first position points includes: Scattering points into the target area based on a preset point set to obtain multiple initial position points; Determining the growth density of the first vegetation according to the first random factor; wherein, the growth density is used to indicate the growth quantity of the first vegetation in the target area; Based on the multiple initial position points and the growth density of the first vegetation, determining multiple first position points of the first vegetation; Generating the first vegetation at each first position point.

4. The method according to claim 3, characterized in that, the step of scattering points into the target area based on a preset point set to obtain multiple initial position points includes: Constructing the minimum circumscribed regular quadrilateral of the target area; Evenly distributing the preset points in the preset point set within the minimum circumscribed regular quadrilateral; Determining the preset points within the minimum circumscribed regular quadrilateral that are located within the target area as the initial position points.

5. The method according to claim 4, characterized in that, the step of determining the preset points within the minimum circumscribed regular quadrilateral that are located within the target area as the initial position points includes: For each preset point within the minimum circumscribed regular quadrilateral, perform the following operations: Emitting a ray in a preset direction starting from the current preset point; Count the number of intersection points between the emitted rays of the current preset point and the border of the target area; if the number of intersection points is odd, determine that the current preset point is within the target area and determine the current preset point as the initial position point.

6. The method according to claim 3, wherein, the step of determining multiple first position points of the first vegetation based on the multiple initial position points and the growth density includes: Select first position points that match the growth density from the multiple initial positions.

7. The method according to claim 3, wherein, the step of determining multiple first position points of the first vegetation based on the multiple initial position points and the growth density includes: Select multiple intermediate position points that match the growth density from the multiple initial position points; Based on the volume of the first vegetation, offset the multiple intermediate position points, and determine the offset intermediate position points as the first position points.

8. The method according to claim 3, wherein, the growth parameters further include vegetation size and / or vegetation height; the step of generating the first vegetation at each of the first position points includes: For each of the first position points, based on the first random factor, determine the vegetation size and / or vegetation height of the first vegetation generated at the current first position point, so as to generate the first vegetation at the current first position point.

9. The method according to claim 8, wherein, the first random factor includes a first type control factor; the step of determining the vegetation size and vegetation height of the first vegetation generated at the current first position point based on the first random factor, so as to generate the first vegetation at the current first position point includes: Based on the first type control factor, select a target type of first vegetation from multiple preset types of first vegetation; wherein, at least one of the vegetation size, vegetation height, and vegetation type of each type of first vegetation is different; Determine the vegetation growth direction of the target type of first vegetation; Based on the growth direction of the target type of first vegetation, generate the target type of first vegetation at the current first position point.

10. The method according to claim 9, wherein, the step of determining the vegetation growth direction of the target type of first vegetation includes: According to the terrain information corresponding to the current first position point corresponding to the first vegetation, determine the normal direction of the current first position point, and determine the normal direction as the vegetation growth direction of the first vegetation; Or, determine the vertically upward direction in the virtual scene as the vegetation growth direction of the first vegetation.

11. The method according to claim 1, wherein, before the step of generating the first vegetation at the first position point, the method further includes: Determine, through a slope control factor, second position points among the multiple first position points with a slope greater than a preset slope threshold; Delete the second position points among the multiple first position points to obtain the final first position points for generating the first vegetation.

12. The method according to claim 1, wherein, the step of generating the second vegetation within a specified range relative to the first vegetation based on a preset second control parameter includes: for each of the first position points where the first vegetation is generated, performing the following operations: establishing a first adjustment ring region centered on the current first position point; determining the growth parameters within the first adjustment ring region based on the second random factor; generating the second vegetation within the first adjustment ring region based on the determined growth parameters of the second vegetation.

13. The method according to claim 12, wherein, the growth parameters include growth density; the second random factor includes a density control factor; the step of determining the growth parameters within the first adjustment ring region based on the second random factor includes: determining the growth density of the second vegetation within the first adjustment ring region based on the density control factor; wherein the growth density is used to indicate the growth quantity of the second vegetation within the first adjustment ring region; generating the second vegetation within the first adjustment ring region according to the growth density.

14. The method according to claim 12, wherein, the growth parameters include vegetation size and / or vegetation height; the second random factor includes a second type control factor; the step of determining the growth parameters within the first adjustment ring region based on the second random factor includes: selecting at least one type of the second vegetation from a preset variety of types of the second vegetation based on the second type control factor to generate the at least one type of the second vegetation within the first adjustment ring region; wherein at least one of the vegetation size, vegetation height, and vegetation type of each type of the second vegetation is different.

15. The method according to claim 1, wherein, before the step of generating the second vegetation within a specified range relative to the first vegetation based on a preset second control parameter, the method further includes: receiving an instruction to set an object attribute for the first vegetation, and setting the first vegetation as all objects, or setting the first vegetation as partial objects; wherein, if the first vegetation is set as all objects, the second vegetation will be generated within the specified range of each of the first vegetation; if the first vegetation is set as partial objects, the second vegetation will be generated within the specified range of some of the first vegetation.

16. The method according to claim 1, wherein, after the step of generating the second vegetation within a specified range relative to the first vegetation based on a preset second control parameter, the method further includes: generating a third vegetation within a specified range relative to the second vegetation based on a preset third control parameter; the third control parameter includes a third random factor and the growth parameters of the third vegetation; the third random factor is used to control the randomness of the growth parameters of the third vegetation; wherein, the vegetation volumes and / or vegetation heights of the first vegetation, the second vegetation, and the third vegetation are different.

17. The method according to claim 16, wherein, the step of generating the third vegetation within a specified range relative to the second vegetation based on a preset third control parameter includes: performing the following operations on the position point where the second vegetation is generated: establishing a second adjustment circular ring area centered on the current position point; determining the growth parameters within the second adjustment circular ring area based on the third random factor; wherein the growth parameters include at least one of growth density, vegetation size, and vegetation height; generating the third vegetation within the second adjustment circular ring area based on the determined growth parameters of the third vegetation.

18. The method according to claim 1, wherein, the method further includes: saving the attribute information of the first vegetation generated at the first position point to a preset configuration file; wherein the attribute information includes position information and growth parameters; saving the attribute information of the second vegetation generated within a specified range relative to the first vegetation to the configuration file.

19. A vegetation generation device in a virtual scene, wherein, the device includes: a region acquisition module for acquiring a target region in the virtual scene where vegetation is to be generated; a first vegetation generation module for determining a plurality of first position points of the first vegetation within the target region based on a preset first control parameter and generating the first vegetation at the first position points; wherein the first control parameter includes a first random factor and the growth parameters of the first vegetation; the first random factor is used to control the randomness of the growth parameters of the first vegetation; a second vegetation generation module for generating the second vegetation within a specified range relative to the first vegetation based on a preset second control parameter; the second control parameter includes a second random factor and the growth parameters of the second vegetation; the second random factor is used to control the randomness of the growth parameters of the second vegetation; wherein, the vegetation volumes and / or vegetation heights of the first vegetation and the second vegetation are different.

20. An electronic device, wherein, it includes a processor and a memory, the memory stores machine-executable instructions that can be executed by the processor, and the processor executes the machine-executable instructions to implement the vegetation generation method in a virtual scene according to any one of claims 1 to 18.

21. A computer-readable storage medium, wherein, the computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are called and executed by a processor, the computer-executable instructions cause the processor to implement the vegetation generation method in a virtual scene according to any one of claims 1 to 18.

Citation Information

Patent Citations

  • Digital video rendering

    CN107005689A

  • Virtual vegetation display method and device, computer equipment and storage medium

    CN110880204A