Method, device and electronic device for generating vegetation in virtual scene
By obtaining the vegetation resource information and topographic information of the terrain model, determining the vegetation distribution area and generating a vegetation model, the problems of insufficient vegetation functionality and random distribution in the prior art are solved, and regular and functional vegetation is generated in the game scene.
Patent Information
- Application Number
- CN202211021787.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-24
- Publication Date
- 2025-05-23
- Estimated Expiration
- 2042-08-24
AI Technical Summary
In the prior art, vegetation distribution lacks preliminary planning intervention in game scenarios, resulting in insufficient functional and distribution of generated vegetation, making it difficult to apply to game scenarios with specific needs.
By obtaining the vegetation resource information and topographic information corresponding to the terrain model, the final distribution area of vegetation in the terrain model is determined, and a vegetation model is generated in this area to ensure that the vegetation distribution has certain regularity and functionality.
It realizes the generation of functional vegetation in game scenes, avoids the problem of too random distribution, and is suitable for game scenes with specific needs.
Smart Images

Figure CN115518374B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of model rendering, and in particular to a method, device and electronic equipment for generating vegetation in a virtual scene. Background Art
[0002] Vegetation is a very important part of the natural environment of the game scene. In related technologies, vegetation distribution is based on terrain mask or point cloud distribution through random noise, and then the point cloud data is used to distribute instantiated vegetation in the game engine. The point cloud will record the axis point, scale, rotation and corresponding model of each vegetation. However, this method lacks the intervention of pre-planning, so it cannot guarantee the functionality of the generated vegetation, such as vegetation as a cover or vegetation felling and building houses, and the generated vegetation effect is too random, which is difficult to apply to game scenes with specific needs. 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 to ensure the functionality of the vegetation generated in the virtual scene and avoid the generated vegetation effect being too random, which is suitable for game scenes with specific requirements.
[0004] In a first aspect, the present invention provides a method for generating vegetation in a virtual scene, the method comprising: obtaining vegetation resource information and terrain information corresponding to a terrain model; wherein the vegetation resource information includes an initial distribution area of vegetation in the terrain model, and vegetation types of a plurality of preset vegetation models; based on the terrain information, obtaining a sub-area with specified attributes from the initial distribution area, and determining a final distribution area of vegetation in the terrain model based on the sub-area with the specified attributes; determining a vegetation position in the final distribution area, and generating a vegetation model at the vegetation position based on the vegetation types of the plurality of preset vegetation models, to obtain a virtual scene containing vegetation.
[0005] In a second aspect, the present invention provides a vegetation generation device in a virtual scene, the device comprising: an information acquisition module, used to acquire vegetation resource information and terrain information corresponding to a terrain model; wherein the vegetation resource information includes an initial distribution area of vegetation in the terrain model, and vegetation types of a plurality of preset vegetation models; a final area determination module, used to acquire a sub-area with specified attributes from the initial distribution area based on the terrain information, and determine the final distribution area of vegetation in the terrain model based on the sub-area with the specified attributes; a vegetation generation module, used to determine a vegetation position in the final distribution area, and generate a vegetation model at the vegetation position based on the vegetation types of a plurality of preset vegetation models, to obtain a virtual scene containing vegetation.
[0006] In a third aspect, the present invention provides an electronic device, comprising 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-mentioned vegetation generation method in the virtual scene.
[0007] In a fourth aspect, the present invention 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 prompt the processor to implement the vegetation generation method in the above-mentioned virtual scene.
[0008] The embodiments of the present invention bring the following beneficial effects:
[0009] The present invention provides a method, device and electronic device for generating vegetation in a virtual scene. First, vegetation resource information and terrain information corresponding to a terrain model are obtained. The vegetation resource information includes an initial distribution area of vegetation in the terrain model and vegetation types of multiple vegetation models that are preset. Then, based on the terrain information, a sub-area with specified attributes is obtained from the initial distribution area. Based on the sub-area with the specified attributes, the final distribution area of vegetation in the terrain model is determined. Then, the vegetation position is determined in the final distribution area, and a vegetation model is generated at the vegetation position based on the vegetation types of multiple vegetation models that are preset, so as to obtain a virtual scene containing vegetation. In this method, the final distribution area of vegetation is determined on the terrain model according to the vegetation resource information and terrain information, so that the vegetation distribution has a certain regularity, and the vegetation distribution is avoided to be too random, so that the method can be applied to game scenes with specific requirements. In addition, since the vegetation resource information intervenes in the vegetation distribution, the functionality of the vegetation generated in the virtual scene can be guaranteed.
[0010] Other features and advantages of the present invention will be set forth in the following description, or some features and advantages may be inferred or unambiguously determined from the description, or may be learned by implementing the above-mentioned technology of the present invention.
[0011] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, preferred embodiments are specifically listed below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0013] Figure 1A flowchart of a method for generating vegetation in a virtual scene provided by an embodiment of the present invention;
[0014] Figure 2 A flowchart of another method for generating vegetation in a virtual scene provided by an embodiment of the present invention;
[0015] Figure 3 A schematic diagram of an area where vegetation is distributed on the surface of the earth provided by an embodiment of the present invention;
[0016] Figure 4 A schematic diagram of the area where vegetation is distributed on the ground surface minus the stone area provided by an embodiment of the present invention;
[0017] Figure 5 A schematic diagram of a river area provided by an embodiment of the present invention;
[0018] Figure 6 A schematic diagram of a road area provided by an embodiment of the present invention;
[0019] Figure 7 A schematic diagram of an area where the slope is greater than a first preset threshold provided by an embodiment of the present invention;
[0020] Figure 8 A schematic diagram of a final sub-area where vegetation is distributed on the ground surface provided by an embodiment of the present invention;
[0021] Fig. 9 A schematic diagram of a randomly distributed area where dotted vegetation randomly corresponds to an embodiment of the present invention;
[0022] Fig.10 A flowchart of another method for generating vegetation in a virtual scene provided by an embodiment of the present invention;
[0023] Fig.11 A schematic diagram of the structure of a vegetation generation device in a virtual scene provided by an embodiment of the present invention;
[0024] Fig.12 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0025] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.
[0026] Therefore, 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 invention claimed for protection, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0027] Vegetation is a very important part of the natural environment of the game scene. If these vegetation are manually edited by artists, it will consume a lot of man-days and energy. In addition, the current programmatic vegetation generation solutions are generally only suitable for MMO (Massively Multiplayer Online) type games, not SLG (Simulation Game, strategy game).
[0028] In related technologies, vegetation distribution is based on terrain mask or point cloud distribution through random noise, and then the point cloud data is used to distribute instantiated vegetation in the game engine. The point cloud will record the axis point, scale, rotation and corresponding model of each vegetation. After this method implements a certain functional framework, no matter how large the production volume is, it can generate the required results with one click, complete the generation of most art resources, and improve the work efficiency of art staff. However, this method lacks the intervention of pre-planning, and thus cannot guarantee the functionality of the generated vegetation, such as vegetation as a cover or vegetation felling trees to build houses, and the generated vegetation effect is too random, making it difficult to apply to game scenes with specific needs.
[0029] Based on the above problems, an embodiment of the present invention provides a method, device and electronic device for generating vegetation in a virtual scene. The technology can be applied to vegetation generation scenes in virtual scenes in various games, especially vegetation generation scenes in SLG games.
[0030] In order to facilitate understanding of the embodiment of the present invention, a method for generating vegetation in a virtual scene disclosed in an embodiment of the present invention is first described in detail. Figure 1 As shown, the method comprises the following specific steps:
[0031] Step S102, obtaining vegetation resource information and terrain information corresponding to the terrain model; wherein the vegetation resource information includes the initial distribution area of vegetation in the terrain model, and vegetation types of a plurality of preset vegetation models.
[0032] The above vegetation resource information is usually set by planners according to the game functions. The vegetation resource information includes the initial distribution area of vegetation in the terrain model and the vegetation types of multiple vegetation models. The vegetation types include shrubs, trees, etc. Each vegetation type has different vegetation functions. The vegetation function is used to indicate the purpose of vegetation, which includes using vegetation as a shelter or cutting down trees to build houses.
[0033] In the specific implementation, planners will set the vegetation resource layer information (equivalent to the above vegetation resource information) in the early design stage of the game level. This information can be recorded in the layer of Photoshop software, and the information is finally stored as PSD, which is a file format. The setting of vegetation resource information is very critical, and it is also a key step for planners to participate in the generation of vegetation distribution. Planners can design which places need vegetation and wood according to their own game content. For example, SLG games generally need to stipulate how much wood resources a country has, or vegetation in strategic locations is generally used as a cover to attack the enemy unexpectedly, etc.
[0034] Step S104: based on the terrain information, a sub-region with a specified attribute is obtained from the initial distribution region, and based on the sub-region with the specified attribute, a final distribution region of the vegetation in the terrain model is determined.
[0035] The above-mentioned terrain information includes terrain highlands, river information, mountain information, road information and cliff information, etc. Based on the terrain information, the terrain characteristics, terrain slope and terrain distribution of each part of the terrain model can be accurately determined. In specific implementation, the area in the terrain model that is not suitable for generating vegetation can be determined based on the terrain information, and the area that is not suitable for generating vegetation in the initial distribution area can be subtracted, and a sub-area with a specified attribute can be obtained from the initial distribution area based on the terrain characteristics of the terrain model. The specified attribute can be set according to research and development needs. The specified attribute can be the distribution area of vegetation of different vegetation types, or the distribution area of vegetation with different terrain characteristics, etc. For example, the specified characteristic attribute can be vegetation distributed on the surface, vegetation distributed on high mountains, vegetation on waters or small islands, randomly distributed dotted vegetation in the terrain, vegetation distributed in the city area, etc.
[0036] In specific implementation, the final sub-region corresponding to each sub-region can be determined according to the attribute characteristics of the sub-region with the specified attribute, and each final sub-region is integrated to obtain the final distribution area of the vegetation in the terrain model.
[0037] Step S106, determining the vegetation position in the final distribution area, generating a vegetation model at the vegetation position based on the vegetation types of the preset multiple vegetation models, and obtaining a virtual scene containing vegetation.
[0038] In the specific implementation, it is also necessary to determine the vegetation position in the final distribution area according to the vegetation distribution law in the real scene. The vegetation position is also the position where vegetation can be generated in the final distribution area. Then, according to the specified attributes corresponding to each sub-area in the final distribution area, a vegetation model of the vegetation type matching the specified attributes is generated at the vegetation position to obtain a virtual scene containing vegetation. In this way, the vegetation model is generated according to the vegetation type, which can ensure the functionality of the vegetation generated in the virtual scene.
[0039] The embodiment of the present invention provides a method for generating vegetation in a virtual scene. First, vegetation resource information and terrain information corresponding to a terrain model are obtained. The vegetation resource information includes an initial distribution area of vegetation in the terrain model and vegetation types of multiple vegetation models that are preset. Then, based on the terrain information, a sub-area with specified attributes is obtained from the initial distribution area. Based on the sub-area with the specified attributes, the final distribution area of vegetation in the terrain model is determined. Then, the vegetation position is determined in the final distribution area, and a vegetation model is generated at the vegetation position based on the vegetation types of multiple vegetation models that are preset, so as to obtain a virtual scene containing vegetation. In this method, the final distribution area of vegetation is determined on the terrain model according to the vegetation resource information and terrain information, so that the vegetation distribution has a certain regularity, and the vegetation distribution is avoided to be too random, so that the method can be applied to game scenes with specific requirements. In addition, since the vegetation resource information intervenes in the vegetation distribution, the functionality of the vegetation generated in the virtual scene can be guaranteed.
[0040] The embodiment of the present invention also provides another method for generating vegetation in a virtual scene. The method is implemented on the basis of the above embodiment. The method focuses on the specific process of obtaining a sub-region with specified attributes from an initial distribution region based on terrain information, and determining the final distribution region of vegetation in a terrain model based on the sub-region with specified attributes (specifically implemented through the following steps S202-S206); Figure 2 As shown, the method comprises the following specific steps:
[0041] Step S202, obtaining vegetation resource information and terrain information corresponding to the terrain model; wherein the vegetation resource information includes the initial distribution area of vegetation in the terrain model, and vegetation types of multiple preset vegetation models; the terrain information includes terrain highlands, river information, mountain information and road information.
[0042] Step S204: dividing the initial distribution area into a plurality of sub-areas with specified attributes according to the terrain information.
[0043] In specific implementation, after determining the initial distribution area of vegetation according to vegetation resource information, it is also necessary to specify the distribution areas of vegetation of different vegetation types, so as to obtain the final distribution area of vegetation. Specifically, the vegetation types generated in areas with different terrain features are different, so that the initial distribution area can be divided into multiple sub-areas with specified attributes according to the terrain information, and the specified attributes match the terrain features in the terrain model.
[0044] Step S206: for each sub-region with the specified attribute, determine the final sub-region corresponding to the current sub-region according to the terrain features of the current sub-region.
[0045] Each of the multiple sub-regions with the specified attributes is used as a current sub-region, and then the terrain characteristics of the current sub-region are determined according to the terrain information, and then the final sub-region corresponding to the current sub-region is determined according to the terrain characteristics.
[0046] In a specific implementation, multiple sub-areas with specified attributes may include: areas where vegetation is distributed on the surface, areas where vegetation is distributed on high mountains, areas where vegetation is distributed around water areas, areas where vegetation is distributed in cities, and areas where vegetation is randomly distributed, etc.
[0047] When the sub-area with the specified attribute includes an area where vegetation is distributed on the surface; according to the terrain information, the specified area in the terrain model is determined; wherein the specified area includes one or more of a river area, a road area, a stone area and an area with a slope greater than a first preset threshold; the specified area in the area where vegetation is distributed on the surface is removed to obtain a final sub-area where vegetation is distributed on the surface.
[0048] In specific implementation, the designated area in the terrain model that is not suitable for generating vegetation can be determined based on the terrain information, and then the designated area can be subtracted from the area where the vegetation is distributed on the surface to obtain the correct distribution area, that is, the final sub-area where the vegetation is distributed on the surface. Specifically, based on the highlands, river information, mountain information and road information in the terrain information, the river areas, road areas, stone areas and areas with a slope greater than a first preset threshold in the terrain model can be determined. The specific value of the first preset threshold can be set according to research and development needs. For example, the first preset threshold can be set to 45 degrees or 60 degrees. Among them, the area with a slope greater than the first preset threshold is also the area with a steeper slope in the terrain model.
[0049] like Figure 3 FIG. 1 is a schematic diagram of a region where vegetation is distributed on the ground surface provided by an embodiment of the present invention. Figure 3 The dark areas in the figure are where vegetation is distributed on the surface. Figure 3 The light-colored area in the figure is the terrain model. Figure 4The diagram shows the area where vegetation is distributed on the surface minus the area of stone. Figure 4 The dark areas in the middle terrain model are the areas where vegetation is distributed on the surface minus the rocky areas; Figure 5 Shown is a schematic diagram of the river area. Figure 5 The darker areas in the middle terrain model are river areas; Figure 6 Shown is a schematic diagram of the road area. Figure 6 The dark area in the figure is the road area; Figure 7 FIG. 1 is a schematic diagram showing an area where the slope is greater than a first preset threshold value. Figure 7 The dark area in is the area where the slope is greater than the first preset threshold; Figure 8 Shown is a schematic diagram of the final sub-area where vegetation is distributed on the surface. Figure 8 The dark area in the figure is the final sub-area where vegetation is distributed on the surface.
[0050] When the above-mentioned current sub-area includes an area where vegetation is distributed in high mountains, the mountain distribution area in the terrain model is determined according to the mountain information; the first area in the terrain model with a slope less than a second preset threshold is determined; the first area in the mountain distribution area is removed to obtain the final sub-area where vegetation is distributed in the high mountains.
[0051] In specific implementation, it is necessary to calculate the mountain distribution area in the terrain model according to the terrain information, and then calculate the first area in the terrain model with a slope less than the second preset threshold. The specific value of the second preset threshold can be set according to research and development needs. The second preset threshold can be the same as the first preset threshold or different. For example, the second preset threshold can be set to 45 degrees or 60 degrees. Among them, the first area with a slope less than the second preset threshold is also a relatively gentle area in the terrain model that is suitable for generating vegetation.
[0052] Specifically, in the terrain model, the mask value of the mountain distribution area can be set to 1, and the mask value of the remaining areas can be set to 0; in the terrain model, the mask value of the first area can be set to 1, and the mask value of the area other than the first area can be set to 0, so that the mask value of the terrain model corresponding to the mountain distribution area is multiplied by the mask value of the terrain model corresponding to the first area, and the final sub-area where vegetation is distributed in the mountains can be obtained.
[0053] If the current sub-region includes an area where vegetation is distributed around a water area, the water distribution area in the terrain model can be determined based on the river information; the water distribution area is widened, and noise processing is performed on the widened water distribution area to obtain a second area; a third area in the terrain model whose slope is within a specified range is determined; and the second area is multiplied by the third area to obtain a final sub-region where vegetation is distributed around the water area.
[0054] In the specific implementation, it is necessary to calculate the water distribution area in the terrain model according to the terrain information, and then widen the water distribution area through a preset function (for example, use the mask expand node to directly expand the water distribution area in all directions) so as to generate vegetation on the widened water distribution area; then use Sparse Convolution noise to perform noise processing on the widened water distribution area to find out the distribution area of vegetation in the water distribution area (equivalent to the area of the second area); then calculate the third area with a slope within a specified range in the terrain model according to the terrain information. The specified range can be set according to research and development needs. For example, the specified range can be an area with a slope between 15 degrees and 45 degrees, or an area with a slope between 20 degrees and 40 degrees, etc., so that the third area suitable for generating vegetation near the water area can be calculated. Specifically, in the terrain model, the mask value of the second area can be set to 1, and the mask value of the area other than the second area can be set to 0; in the terrain model, the mask value of the third area can be set to 1, and the mask value of the area other than the third area can be set to 0, so that the mask value of the terrain model corresponding to the second area is multiplied by the mask value of the terrain model corresponding to the third area, and the final sub-area where vegetation is distributed around the water area can be obtained.
[0055] If the current sub-region includes an area where vegetation is distributed in the city, the city area in the terrain model can be determined based on the terrain information; and the final sub-region where vegetation is distributed in the city can be determined in the city area. In actual practice, the city area in the terrain model can be calculated based on the planning table data (which can be vegetation resource information) and terrain information, and then the vegetation distributable area can be determined based on the terrain characteristics of the city, and the final sub-region where vegetation is distributed in the city can be obtained.
[0056] In some embodiments, since some randomly distributed dotted vegetation is common in some games, the terrain model can be processed with noise to obtain the random distribution area of the dotted vegetation in the terrain model; wherein the random distribution area is the final distribution area corresponding to the dotted vegetation. Fig. 9 The diagram shows the random distribution area where the dotted vegetation randomly corresponds to. Fig. 9 The dark dotted areas in the figure are randomly distributed areas corresponding to the dotted vegetation.
[0057] Step S208, stitching each final sub-area to obtain the final distribution area of vegetation in the terrain model.
[0058] Step S210, determining the vegetation position in the final distribution area, generating a vegetation model at the vegetation position based on the vegetation types of the preset multiple vegetation models, and obtaining a virtual scene containing vegetation.
[0059] The vegetation generation method in the above virtual scene determines the distribution area of vegetation in the terrain model according to the planned vegetation resource information, so that the vegetation distribution is not too random and the vegetation distribution can meet the needs of SLG games; at the same time, since the vegetation resource information intervenes in the vegetation distribution, the functionality of the vegetation generated in the virtual scene can be guaranteed.
[0060] The embodiment of the present invention also provides another method for generating vegetation in a virtual scene. The method is implemented on the basis of the above embodiment. The method focuses on determining the vegetation position in the final distribution area, generating a vegetation model at the vegetation position based on the vegetation type of the preset multiple vegetation models, and obtaining a specific process of a virtual scene containing vegetation (specifically implemented by the following steps S806-S808); Fig.10 As shown, the method comprises the following specific steps:
[0061] Step S802, obtaining vegetation resource information and terrain information corresponding to the terrain model; wherein the vegetation resource information includes the initial distribution area of vegetation in the terrain model, and vegetation types of multiple preset vegetation models.
[0062] Step S804: based on the terrain information, a sub-region with a specified attribute is obtained from the initial distribution region, and based on the sub-region with the specified attribute, a final distribution region of the vegetation in the terrain model is determined.
[0063] Step S806, generating a vegetation point cloud in the final distribution area according to a preset vegetation distribution rule; wherein the vegetation point cloud includes a plurality of point clouds, and one point cloud corresponds to one vegetation position.
[0064] In the specific implementation, after calculating the final distribution area of vegetation in the terrain model, it is necessary to generate vegetation based on the vegetation distribution law in the real world and the final distribution area that has been calculated. The vegetation distribution law is roughly as follows:
[0065] 1. Vegetation is generally distributed in large populations, showing a trend of being high in the middle and low around.
[0066] 2. There will also be random size changes under the influence of the larger population size trend.
[0067] 3. Vegetation generally does not exist in areas with very steep terrain.
[0068] 4. Vegetation faces the sun and grows towards the sky against the force of gravity.
[0069] 5. The rotation of each plant is generally random, but must conform to the trend of the terrain.
[0070] In the specific implementation, according to the vegetation distribution law, a vegetation point cloud can be automatically generated in the final distribution area. The vegetation point cloud includes multiple point clouds. The position of each point cloud corresponds to the generation position of a vegetation. At the same time, the point cloud will record the axis point, scale, rotation and reference path of each vegetation model.
[0071] Step S808: Generate a vegetation model at the vegetation position based on the vegetation type of the vegetation model corresponding to each sub-area in the final distribution area to obtain a virtual scene containing vegetation.
[0072] Since the final distribution area includes distribution areas of different vegetation in areas with different terrain characteristics, it is necessary to generate a vegetation model at the vegetation position corresponding to each area according to the terrain characteristics of each area and the vegetation type corresponding to each area set in the vegetation resource information, so as to obtain a virtual scene containing vegetation.
[0073] In actual implementation, the generated vegetation point cloud can be transferred to the game engine through Houdini Engine, and then the corresponding vegetation resources can be applied to automatically obtain a virtual scene containing vegetation. The vegetation results generated in this way will not be too random, but driven by multiple rules, but there is no lack of consistent artistic results.
[0074] In practical applications, all the functional implementations of the present invention are encapsulated in a HAD (Houdini Digital Asset) node. The HDA node is used to encapsulate custom nodes with specific functions and logics. HDAs can be freely combined and nested to form new HDA nodes. The input terminal 1 of the HDA node is the input terrain information, which needs to contain the information of each terrain layer. The output terminal 1 of the HDA node outputs the vegetation point cloud, the output terminal 2 outputs the preview effect of the point cloud, and the output terminal 3 is the information of the calculated terrain vegetation layer.
[0075] In a specific implementation, the present invention provides a graphical user interface, which provides multiple options for users to adjust the parameters of the entire functional framework:
[0076] The Scatter tab is used to control the density of vegetation distribution, the number of communities, and the distribution of vegetation due to different terrain slopes; the Instance tab is used to fill in the vegetation resource path in the game engine for the final instanced vegetation model generation. The Decoration tab is used to turn on or off different decorative vegetation. If it is turned on, the corresponding decorative vegetation will be generated, and vice versa. The Exclude Layers tab is used to exclude vegetation on the corresponding terrain layer, such as vegetation in river areas and road areas will be excluded. The Size tab is used to adjust the scaling of vegetation. The size of each vegetation can be controlled by adjusting the curve; the Rotation tab is used to adjust the rotation of vegetation, as well as the alignment angle with the terrain, whether it is facing the sky. This method, by modifying the parameters, can automatically generate corresponding visually and functionally consistent vegetation effects, so as to achieve the purpose of flexible modification.
[0077] The vegetation generation method in the above virtual scene provides a rich and complete solution for the distribution of vegetation in the SLG world. Vegetation can be automatically generated through rules in Houdini, which greatly reduces man-days and improves efficiency; and the generated results have consistency in artistic expression. At the same time, the generated vegetation point cloud can be imported into various game engines to generate corresponding vegetation. It is a universal solution that is not limited to the engine platform. In addition, planners deeply intervene in the rules for generating vegetation by setting vegetation resource information to meet the functional design of SLG games, and also meet the changing needs of vegetation in SLG games by formulating vegetation distribution rules.
[0078] Corresponding to the above method embodiment, the embodiment of the present invention also provides a vegetation generation device in a virtual scene, such as Fig.11 As shown, the device comprises:
[0079] The information acquisition module 90 is used to acquire vegetation resource information and terrain information corresponding to the terrain model; wherein the vegetation resource information includes the initial distribution area of vegetation in the terrain model and the vegetation types of the preset multiple vegetation models.
[0080] The final area determination module 91 is used to obtain a sub-area with a specified attribute from the initial distribution area based on the terrain information, and determine the final distribution area of the vegetation in the terrain model based on the sub-area with the specified attribute.
[0081] The vegetation generation module 92 is used to determine the vegetation position in the final distribution area, generate a vegetation model at the vegetation position based on the vegetation types of the preset multiple vegetation models, and obtain a virtual scene containing vegetation.
[0082] The vegetation generation device in the above virtual scene first obtains the vegetation resource information and terrain information corresponding to the terrain model. The vegetation resource information includes the initial distribution area of the vegetation in the terrain model and the vegetation types of a variety of preset vegetation models. Furthermore, based on the terrain information, it obtains sub-regions with specified attributes from the initial distribution area, and determines the final distribution area of the vegetation in the terrain model based on the sub-regions with specified attributes. Then, it determines the vegetation positions in the final distribution area, and generates vegetation models at the vegetation positions based on the vegetation types of a variety of preset vegetation models to obtain a virtual scene containing vegetation. In this way, according to the vegetation resource information and terrain information, the final distribution area of the vegetation is determined on the terrain model, making the vegetation distribution have a certain regularity and avoiding overly random vegetation distribution, so that this method can be applied to game scenes with specific requirements. In addition, since the vegetation resource information intervenes in the vegetation distribution, the functionality of the vegetation generated in the virtual scene can be guaranteed.
[0083] Specifically, the above terrain information includes the highlands, river information, mountain information, and road information of the terrain. The above final area determination module 91 is used to: divide the initial distribution area into multiple sub-regions with specified attributes according to the terrain information; for each sub-region with specified attributes, determine the corresponding final sub-region according to the terrain characteristics of the current sub-region; splice each final sub-region to obtain the final distribution area of the vegetation in the terrain model.
[0084] Furthermore, the sub-regions with specified attributes include the regions where the vegetation is distributed on the ground surface. The above final area determination module 91 is used to: determine the specified areas in the terrain model according to the terrain information; where the specified areas include one or more of the river areas, road areas, stone areas, and areas with a slope greater than the first preset threshold; remove the specified areas in the regions where the vegetation is distributed on the ground surface to obtain the final sub-regions where the vegetation is distributed on the ground surface.
[0085] Furthermore, the current sub-region includes the regions where the vegetation is distributed on high mountains. The above final area determination module 91 is used to: determine the mountain distribution areas in the terrain model according to the mountain information; determine the first areas in the terrain model where the slope is less than the second preset threshold; remove the first areas from the mountain distribution areas to obtain the final sub-regions where the vegetation is distributed on high mountains.
[0086] Furthermore, the current sub-region includes the regions where the vegetation is distributed around water areas. The above final area determination module 91 is used to: determine the water area distribution areas in the terrain model according to the river information; widen the water area distribution areas, perform noise processing on the widened water area distribution areas to obtain the second areas; determine the third areas in the terrain model where the slope is within the specified range; multiply the second areas by the third areas to obtain the final sub-regions where the vegetation is distributed around water areas.
[0087] Furthermore, the current sub-region includes an area where vegetation is distributed in the city; the above-mentioned final area determination module 91 is used to: determine the city area in the terrain model according to the terrain information; and determine the final sub-region where vegetation is distributed in the city in the city area.
[0088] In a specific implementation, the final region determination module 91 is used to: perform noise processing on the terrain model to obtain a random distribution region of the dotted vegetation in the terrain model; wherein the random distribution region is the final distribution region corresponding to the dotted vegetation.
[0089] Furthermore, the above-mentioned vegetation generation module 92 is used to: generate a vegetation point cloud in the final distribution area according to a preset vegetation distribution rule; wherein the vegetation point cloud includes multiple point clouds, and one point cloud corresponds to a vegetation position; based on the vegetation type of the vegetation model corresponding to each sub-area in the final distribution area, generate a vegetation model at the vegetation position to obtain a virtual scene containing vegetation.
[0090] The implementation principle and technical effects of the vegetation generation device in the virtual scene provided by the embodiment of the present invention are the same as those of the aforementioned method embodiment. For the sake of brief description, for matters not mentioned in the device embodiment, reference may be made to the corresponding contents in the aforementioned method embodiment.
[0091] The embodiment of the present invention further provides an electronic device, such as Fig.12 As 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 vegetation generation method in the above virtual scene.
[0092] Specifically, the vegetation generation method in the above-mentioned virtual scene includes: obtaining vegetation resource information and terrain information corresponding to the terrain model; wherein the vegetation resource information includes the initial distribution area of the vegetation in the terrain model, and the vegetation types of multiple vegetation models that are preset; based on the terrain information, a sub-area with specified attributes is obtained from the initial distribution area, and based on the sub-area with the specified attributes, the final distribution area of the vegetation in the terrain model is determined; the vegetation position is determined in the final distribution area, and based on the vegetation types of multiple vegetation models that are preset, a vegetation model is generated at the vegetation position to obtain a virtual scene containing vegetation.
[0093] The above-mentioned vegetation generation method in the virtual scene determines the final distribution area of the vegetation on the terrain model according to the vegetation resource information and the terrain information, so that the vegetation distribution has a certain regularity and avoids the vegetation distribution being too random, so that this method can be applied to game scenes with specific requirements. In addition, since the vegetation resource information intervenes in the vegetation distribution, the functionality of the vegetation generated in the virtual scene can be guaranteed.
[0094] In an optional embodiment, the terrain information includes highlands, river information, mountain information and road information of the terrain; the step of obtaining a sub-area with specified attributes from the initial distribution area based on the terrain information, and determining the final distribution area of the vegetation in the terrain model based on the sub-area with the specified attributes includes: dividing the initial distribution area into multiple sub-areas with specified attributes according to the terrain information; for each sub-area with the specified attributes, determining the final sub-area corresponding to the current sub-area according to the terrain features of the current sub-area; and splicing each final sub-area to obtain the final distribution area of the vegetation in the terrain model.
[0095] In an optional embodiment, the sub-area with specified attributes includes an area where vegetation is distributed on the surface; the step of determining the final sub-area corresponding to the current sub-area based on the terrain features of the current sub-area includes: determining the specified area in the terrain model based on the terrain information; wherein the specified area includes one or more of a river area, a road area, a stone area, and an area with a slope greater than a first preset threshold; removing the specified area from the area where vegetation is distributed on the surface to obtain the final sub-area where vegetation is distributed on the surface.
[0096] In an optional embodiment, the above-mentioned current sub-region includes an area where vegetation is distributed in high mountains; the above-mentioned step of determining the final sub-region corresponding to the current sub-region based on the terrain characteristics of the current sub-region includes: determining the mountain distribution area in the terrain model based on the mountain information; determining the first area in the terrain model whose slope is less than a second preset threshold; removing the first area in the mountain distribution area to obtain the final sub-region where vegetation is distributed in the high mountains.
[0097] In an optional embodiment, the above-mentioned current sub-region includes an area where vegetation is distributed around a water area; the above-mentioned step of determining the final sub-region corresponding to the current sub-region based on the terrain characteristics of the current sub-region includes: determining the water distribution area in the terrain model based on river information; widening the water distribution area, and performing noise processing on the widened water distribution area to obtain a second area; determining a third area in the terrain model whose slope is within a specified range; and multiplying the second area by the third area to obtain the final sub-region where vegetation is distributed around the water area.
[0098] In an optional embodiment, the above-mentioned current sub-area includes an area where vegetation is distributed in the city; the above-mentioned step of determining the final sub-area corresponding to the current sub-area based on the terrain characteristics of the current sub-area includes: determining the city area in the terrain model based on the terrain information; and determining the final sub-area where vegetation is distributed in the city in the city area.
[0099] In an optional embodiment, the above-mentioned step of obtaining a sub-area with specified attributes from the initial distribution area based on terrain information, and determining the final distribution area of vegetation in the terrain model based on the sub-area with specified attributes includes: performing noise processing on the terrain model to obtain a random distribution area of dotted vegetation in the terrain model; wherein the randomly distributed area is the final distribution area corresponding to the dotted vegetation.
[0100] In an optional embodiment, the above-mentioned steps of determining the vegetation position in the final distribution area, generating a vegetation model at the vegetation position based on the vegetation type of a plurality of vegetation models preset, and obtaining a virtual scene containing vegetation include: generating a vegetation point cloud in the final distribution area according to a preset vegetation distribution law; wherein the vegetation point cloud includes multiple point clouds, and one point cloud corresponds to one vegetation position; generating a vegetation model at the vegetation position based on the vegetation type of the vegetation model corresponding to each sub-area in the final distribution area, and obtaining a virtual scene containing vegetation.
[0101] Further, Fig.12 The electronic device shown further includes a bus 102 and a communication interface 103 , and the processor 101 , the communication interface 103 and the memory 100 are connected via the bus 102 .
[0102] The memory 100 may include a high-speed random access memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk storage. The communication connection between the system network element and at least one other network element is realized through at least one communication interface 103 (which may be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. may be used. The bus 102 may be an ISA bus, a PCI bus, or an EISA bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig.12 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0103] The processor 101 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 101. The above processor 101 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can 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 gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present invention can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor. The steps of the method disclosed in the embodiment of the present invention can be directly embodied as a hardware decoding processor for execution, or a combination of hardware and software modules in the decoding processor for execution. The software module may be located in a storage medium mature 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. The storage medium is located in the memory 100, and the processor 101 reads the information in the memory 100 and completes the steps of the method of the above embodiment in combination with its hardware.
[0104] An embodiment of the present invention also provides a computer-readable storage medium, which stores computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to implement the vegetation generation method in the above-mentioned virtual scene. The specific implementation can be found in the method embodiment, which will not be repeated here.
[0105] Specifically, the vegetation generation method in the above-mentioned virtual scene includes: obtaining vegetation resource information and terrain information corresponding to the terrain model; wherein the vegetation resource information includes the initial distribution area of the vegetation in the terrain model, and the vegetation types of multiple vegetation models that are preset; based on the terrain information, a sub-area with specified attributes is obtained from the initial distribution area, and based on the sub-area with the specified attributes, the final distribution area of the vegetation in the terrain model is determined; the vegetation position is determined in the final distribution area, and based on the vegetation types of multiple vegetation models that are preset, a vegetation model is generated at the vegetation position to obtain a virtual scene containing vegetation.
[0106] The above-mentioned vegetation generation method in the virtual scene determines the final distribution area of the vegetation on the terrain model according to the vegetation resource information and the terrain information, so that the vegetation distribution has a certain regularity and avoids the vegetation distribution being too random, so that this method can be applied to game scenes with specific requirements. In addition, since the vegetation resource information intervenes in the vegetation distribution, the functionality of the vegetation generated in the virtual scene can be guaranteed.
[0107] In an optional embodiment, the terrain information includes highlands, river information, mountain information and road information of the terrain; the step of obtaining a sub-area with specified attributes from the initial distribution area based on the terrain information, and determining the final distribution area of the vegetation in the terrain model based on the sub-area with the specified attributes includes: dividing the initial distribution area into multiple sub-areas with specified attributes according to the terrain information; for each sub-area with the specified attributes, determining the final sub-area corresponding to the current sub-area according to the terrain features of the current sub-area; and splicing each final sub-area to obtain the final distribution area of the vegetation in the terrain model.
[0108] In an optional embodiment, the sub-area with specified attributes includes an area where vegetation is distributed on the surface; the step of determining the final sub-area corresponding to the current sub-area based on the terrain features of the current sub-area includes: determining the specified area in the terrain model based on the terrain information; wherein the specified area includes one or more of a river area, a road area, a stone area, and an area with a slope greater than a first preset threshold; removing the specified area from the area where vegetation is distributed on the surface to obtain the final sub-area where vegetation is distributed on the surface.
[0109] In an optional embodiment, the above-mentioned current sub-region includes an area where vegetation is distributed in high mountains; the above-mentioned step of determining the final sub-region corresponding to the current sub-region based on the terrain characteristics of the current sub-region includes: determining the mountain distribution area in the terrain model based on the mountain information; determining the first area in the terrain model whose slope is less than a second preset threshold; removing the first area in the mountain distribution area to obtain the final sub-region where vegetation is distributed in the high mountains.
[0110] In an optional embodiment, the above-mentioned current sub-region includes an area where vegetation is distributed around a water area; the above-mentioned step of determining the final sub-region corresponding to the current sub-region based on the terrain characteristics of the current sub-region includes: determining the water distribution area in the terrain model based on river information; widening the water distribution area, and performing noise processing on the widened water distribution area to obtain a second area; determining a third area in the terrain model whose slope is within a specified range; and multiplying the second area by the third area to obtain the final sub-region where vegetation is distributed around the water area.
[0111] In an optional embodiment, the above-mentioned current sub-area includes an area where vegetation is distributed in the city; the above-mentioned step of determining the final sub-area corresponding to the current sub-area based on the terrain characteristics of the current sub-area includes: determining the city area in the terrain model based on the terrain information; and determining the final sub-area where vegetation is distributed in the city in the city area.
[0112] In an optional embodiment, the above-mentioned step of obtaining a sub-area with specified attributes from the initial distribution area based on terrain information, and determining the final distribution area of vegetation in the terrain model based on the sub-area with specified attributes includes: performing noise processing on the terrain model to obtain a random distribution area of dotted vegetation in the terrain model; wherein the randomly distributed area is the final distribution area corresponding to the dotted vegetation.
[0113] In an optional embodiment, the above-mentioned steps of determining the vegetation position in the final distribution area, generating a vegetation model at the vegetation position based on the vegetation type of a plurality of vegetation models preset, and obtaining a virtual scene containing vegetation include: generating a vegetation point cloud in the final distribution area according to a preset vegetation distribution law; wherein the vegetation point cloud includes multiple point clouds, and one point cloud corresponds to one vegetation position; generating a vegetation model at the vegetation position based on the vegetation type of the vegetation model corresponding to each sub-area in the final distribution area, and obtaining a virtual scene containing vegetation.
[0114] If the functions are implemented in the form of 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 solution of the present invention, or the part that contributes to the prior art or the 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, including several instructions for a computer device (which can be a personal computer, a terminal device, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0115] In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicating the orientation or positional relationship, are based on the orientation or positional relationship shown in the drawings, and are 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 therefore cannot be understood as limiting the present invention. In addition, the terms "first", "second", and "third" are used for descriptive purposes only, and cannot be understood as indicating or implying relative importance.
[0116] Finally, it should be noted that the above-described embodiments are only specific implementations of the present invention, which are used to illustrate the technical solutions of the present invention, rather than to limit them. The protection scope of the present invention is not limited thereto. Although the present invention is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed by the present invention, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.
Claims
1. A method for generating vegetation in a virtual scene, It is characterized in that The method comprises: Obtaining vegetation resource information and terrain information corresponding to the terrain model; wherein the vegetation resource information includes an initial distribution area of vegetation in the terrain model and vegetation types of a plurality of preset vegetation models; different vegetation types have different vegetation functions, and the vegetation functions include using vegetation as a shelter or using vegetation for felling trees and building houses; Based on the terrain information, a sub-region with a specified attribute is obtained from the initial distribution area, and based on the sub-region with the specified attribute, a final distribution area of vegetation in the terrain model is determined; wherein the specified attribute is used to indicate the terrain characteristics and / or vegetation type corresponding to the sub-region; The vegetation position is determined in the final distribution area, and a vegetation model is generated at the vegetation position based on the vegetation types of the preset multiple vegetation models to obtain a virtual scene containing vegetation.
2. The method according to claim 1, It is characterized in that The terrain information includes highlands, river information, mountain information and road information; The step of acquiring a sub-region with a specified attribute from the initial distribution region based on the terrain information, and determining a final distribution region of vegetation in the terrain model based on the sub-region with the specified attribute comprises: According to the terrain information, the initial distribution area is divided into a plurality of sub-areas with specified attributes; For each of the sub-regions having the specified attributes, determining a final sub-region corresponding to the current sub-region according to the terrain features of the current sub-region; Each of the final sub-areas is spliced to obtain a final distribution area of vegetation in the terrain model.
3. The method according to claim 2, It is characterized in that The sub-area with the specified attribute includes an area where vegetation is distributed on the surface; The step of determining the final sub-region corresponding to the current sub-region according to the terrain features of the current sub-region comprises: Determine a designated area in the terrain model according to the terrain information; wherein the designated area includes one or more of a river area, a road area, a stone area, and an area with a slope greater than a first preset threshold; The designated area in the area where the vegetation is distributed on the ground surface is removed to obtain a final sub-area where the vegetation is distributed on the ground surface.
4. The method according to claim 2, It is characterized in that The current sub-region includes an area where vegetation is distributed in high mountains; The step of determining the final sub-region corresponding to the current sub-region according to the terrain features of the current sub-region comprises: Determining the mountain distribution area in the terrain model according to the mountain information; Determine a first area in the terrain model having a slope less than a second preset threshold; The first area in the mountain distribution area is removed to obtain a final sub-area where vegetation is distributed on high mountains.
5. The method according to claim 2, It is characterized in that The current sub-area includes an area where vegetation is distributed around a water area; The step of determining the final sub-region corresponding to the current sub-region according to the terrain features of the current sub-region comprises: Determining the water distribution area in the terrain model according to the river information; widening the water area distribution area, and performing noise processing on the widened water area distribution area to obtain a second area; determining a third area in the terrain model having a slope within a specified range; The second area is multiplied by the third area to obtain a final sub-area where vegetation is distributed around the water area.
6. The method according to claim 2, It is characterized in that The current sub-region includes an area where vegetation is distributed in the city; The step of determining the final sub-region corresponding to the current sub-region according to the terrain features of the current sub-region comprises: Determining a city area in the terrain model according to the terrain information; A final sub-area where vegetation is distributed in the city is determined in the city area.
7. The method according to claim 1, It is characterized in that The step of acquiring a sub-region with a specified attribute from the initial distribution region based on the terrain information, and determining a final distribution region of vegetation in the terrain model based on the sub-region with the specified attribute comprises: Noise processing is performed on the terrain model to obtain a random distribution area of the dotted vegetation in the terrain model; wherein the random distribution area is a final distribution area corresponding to the dotted vegetation.
8. The method according to claim 1, It is characterized in that The step of determining the vegetation position in the final distribution area, generating a vegetation model at the vegetation position based on the vegetation types of the preset multiple vegetation models, and obtaining a virtual scene containing vegetation includes: According to a preset vegetation distribution law, a vegetation point cloud is generated in the final distribution area; wherein the vegetation point cloud includes a plurality of point clouds, and one point cloud corresponds to one vegetation position; Based on the vegetation type of the vegetation model corresponding to each sub-area in the final distribution area, a vegetation model is generated at the vegetation position to obtain a virtual scene containing vegetation.
9. A vegetation generation device in a virtual scene, It is characterized in that The device comprises: An information acquisition module is used to acquire vegetation resource information and terrain information corresponding to the terrain model; wherein the vegetation resource information includes the initial distribution area of vegetation in the terrain model and the vegetation types of multiple vegetation models; different vegetation types have different vegetation functions, and the vegetation functions include vegetation as a shelter or vegetation felling and building houses; A final area determination module is used to obtain a sub-area with a specified attribute from the initial distribution area based on the terrain information, and determine a final distribution area of vegetation in the terrain model based on the sub-area with the specified attribute; wherein the specified attribute is used to indicate the terrain characteristics and / or vegetation type corresponding to the sub-area; The vegetation generation module is used to determine the vegetation position in the final distribution area, generate a vegetation model at the vegetation position based on the vegetation types of the preset multiple vegetation models, and obtain a virtual scene containing vegetation.
10. An electronic device, It is characterized in that The method comprises 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 vegetation generation method in a virtual scene according to any one of claims 1 to 8.
11. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to implement the vegetation generation method in a virtual scene according to any one of claims 1 to 8.
Citation Information
Patent Citations
Vegetation biocoenosis manufacturing method and device
CN111524214A
Method and device for making virtual terrain scene
CN111617485A