Method, apparatus, electronic device and storage medium for generating tree model
By constructing leaf surface, trunk and branch models, determining the wrapping model and sprinkling points, the problems of poor leaf display and high construction cost of tree model are solved, and efficient normal mapping and multi-level tree model display are achieved.
Patent Information
- Application Number
- CN202111583714.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-22
- Publication Date
- 2025-08-01
- Estimated Expiration
- 2041-12-22
AI Technical Summary
In the game scene, the tree model's leaves are poorly displayed and the construction cost is high. Manually adjusting the normal mapping effect is difficult to control and inefficient.
By obtaining several leaf surfaces, building a leaf model, creating a trunk and branch model, determining the wrapping model and obtaining the model normal, sprinkling point processing to obtain the bearing position points and number, assembling and normal mapping to generate a tree model.
It improves the authenticity of the leaf model and the quality of the normal mapping effect, improves the efficiency of normal mapping, and enhances the sense of hierarchy and authenticity of the tree model.
Smart Images

Figure CN114266853B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to a method for generating a tree model, a device for generating a tree model, an electronic device, and a computer-readable storage medium. Background Art
[0002] In game scenes, it is usually necessary to use virtual object models with various shapes to represent the game screen, so as to render a more realistic game environment. It is particularly important to construct virtual objects with diverse styles and realistic shapes. Among them, trees and vegetation are common components of game scenes. For realistic numerical modeling, the plug-in method is adopted to bake part of the high-poly model information into the normal map, and then map the other part of the information to the low-poly model. Finally, these baked static information are rendered through the rendering engine to restore the high-poly model information. Then, through large-scale generation, the corresponding trees and vegetation are obtained. At the same time, in order to avoid poor projection effects caused by plug-ins, it is often necessary to manually perform normal mapping on the plug-ins to control the light and dark projection effects. However, it is difficult to control the image quality by manually adjusting the normal mapping effect. It takes a long time to bake a good image effect, and the efficiency is very low. Summary of the Invention
[0003] The embodiments of the present invention provide a method, device, electronic device and computer-readable storage medium for generating a tree model to solve or partially solve the problem of poor leaf display effect of tree models in games and high construction cost of tree models.
[0004] An embodiment of the present invention discloses a method for generating a tree model, comprising:
[0005] In response to a leaf creation operation, obtaining a plurality of leaf patches corresponding to the leaf creation operation, and constructing a leaf model with the plurality of leaf patches;
[0006] Creating a trunk model and a target branch model corresponding to the trunk model;
[0007] Determining a wrapping model corresponding to the target branch model, and obtaining a model normal of the wrapping model;
[0008] Performing point spreading processing on the package model to obtain the bearing position points and the number of leaves of the leaf model in the target branch model;
[0009] The leaf models corresponding to the number of leaves are assembled with the trunk model and the target branch model according to the bearing position points, and normal mapping is performed on the leaf models according to the model normals to generate a tree model.
[0010] Optionally, constructing the leaf model from the plurality of leaf patches includes:
[0011] Inserting the plurality of leaf patches at a preset angle to obtain a leaf model.
[0012] Optionally, inserting the plurality of leaf patches at a preset angle to construct a leaf model includes:
[0013] Inserting three of the leaf patches in a 90-degree perpendicular manner to construct a leaf model.
[0014] Optionally, creating the trunk model and the target branch model corresponding to the trunk model includes:
[0015] In response to a model drawing operation, determining the trunk model corresponding to the model drawing operation and the initial branch model corresponding to the trunk model;
[0016] Obtaining a rotation value parameter for the initial branch model;
[0017] Rotating the initial branch model according to the rotation value parameter to obtain the target branch model corresponding to the initial branch model.
[0018] Optionally, determining the wrapping model corresponding to the target branch model includes:
[0019] Obtaining the branch parameters of the target branch model;
[0020] Using the branch parameters to generate a branch curve corresponding to the target branch model;
[0021] Coloring the branch curve to divide the target branch model into branch model groups;
[0022] Obtaining the coordinate information of each target branch model and constructing a wrapping model corresponding to each target branch model group based on the coordinate information.
[0023] Optionally, constructing the wrapping model corresponding to each target branch model group based on the coordinate information includes:
[0024] Using the coordinate information of the target branch models in each branch model group to construct a rectangular contour model corresponding to the branch model group according to preset dimension information;
[0025] Smoothing each rectangular contour model to obtain a wrapping model corresponding to each branch model group.
[0026] Optionally, the process of scattering points on the wrapped model to obtain the bearing position points and the number of leaves of the leaf model in the target branch model includes:
[0027] Scatter points on each of the wrapped models to obtain initial bearing position points;
[0028] Obtain the jitter parameter for the branch curve;
[0029] Use the jitter parameter to distort the branch curve to obtain the leaf area corresponding to the target branch model;
[0030] Shrink the initial bearing position points towards the leaf area to obtain the target bearing position points of the leaf model in the target branch model;
[0031] Take the number of target bearing position points corresponding to each target branch model as the number of leaves.
[0032] Optionally, the process of scattering points on each of the target wrapped models to obtain initial bearing position points includes:
[0033] Obtain the model volume of each of the wrapped models;
[0034] Scatter points on the wrapped models according to the size of the model volume to obtain the initial bearing position points corresponding to each target wrapped model.
[0035] Optionally, the process of assembling the leaf models corresponding to the number of leaves with the trunk model and the target branch model according to the bearing position points, and performing normal mapping on the leaf models according to the model normals to generate a tree model includes:
[0036] Map the model normal of the contour model to the leaf model to obtain leaf normals;
[0037] Use the leaf normals to calculate the normal values of the leaf models;
[0038] Add the leaf models corresponding to the number of leaves to the target branch model corresponding to the trunk model according to the bearing position points, and render the leaf models according to the normal values to generate a tree model.
[0039] An embodiment of the present invention also discloses a device for generating a tree model, including:
[0040] A leaf model construction module, configured to obtain a plurality of leaf patches corresponding to the leaf creation operation in response to the leaf creation operation, and construct a leaf model from the plurality of leaf patches;
[0041] A branch model creation module for creating a tree trunk model and a target branch model corresponding to the tree trunk model;
[0042] A wrapping model determination module for determining a wrapping model corresponding to the target branch model and obtaining the model normal of the wrapping model;
[0043] An information determination module for performing dot scattering on the wrapping model to obtain the bearing position points and the number of leaves of the leaf model in the target branch model;
[0044] A tree model generation module for assembling the leaf model corresponding to the number of leaves with the tree trunk model and the target branch model according to the bearing position points, and performing normal mapping on the leaf model according to the model normal to generate a tree model.
[0045] Optionally, the leaf model construction module is specifically configured to:
[0046] Insert the plurality of leaf patches at a preset angle to obtain a leaf model.
[0047] Optionally, the leaf model construction module is specifically configured to:
[0048] Insert three of the leaf patches in a perpendicular manner at 90 degrees to construct a leaf model.
[0049] Optionally, the branch model creation module includes:
[0050] A model drawing sub-module for determining a tree trunk model corresponding to the model drawing operation and an initial branch model corresponding to the tree trunk model in response to a model drawing operation;
[0051] A rotation value parameter acquisition sub-module for acquiring a rotation value parameter for the initial branch model;
[0052] A branch model generation sub-module for rotating the initial branch model according to the rotation value parameter to obtain a target branch model corresponding to the initial branch model.
[0053] Optionally, the wrapping model determination module includes:
[0054] A branch parameter acquisition sub-module for acquiring branch parameters of the target branch model;
[0055] A branch curve generation sub-module for generating a branch curve corresponding to the target branch model by using the branch parameters;
[0056] A model grouping sub-module for coloring the branch curve to divide the target branch model into branch model groups;
[0057] A wrapping model generation sub-module, configured to obtain the coordinate information of each of the target branch models, and construct a wrapping model corresponding to each group of the target branch models based on the coordinate information.
[0058] Optionally, the wrapping model generation sub-module is specifically configured to:
[0059] Adopt the coordinate information of the target branch models in each of the branch model groups, and construct a rectangular contour model corresponding to the branch model group according to the preset size information;
[0060] Perform smoothing processing on each of the rectangular contour models to obtain a wrapping model corresponding to each of the branch model groups.
[0061] Optionally, the information determination module includes:
[0062] An initial position point determination sub-module, configured to perform a point scattering process on each of the wrapping models to obtain an initial bearing position point;
[0063] A jitter parameter acquisition sub-module, configured to acquire a jitter parameter for the branch curve;
[0064] A leaf area determination sub-module, configured to perform a distortion process on the branch curve by using the jitter parameter to obtain a leaf area corresponding to the target branch model;
[0065] A target position point determination sub-module, configured to contract the initial bearing position point towards the leaf area to obtain a target bearing position point of the leaf model in the target branch model;
[0066] A leaf quantity determination sub-module, configured to use the quantity of the target bearing position points corresponding to each of the target branch models as the leaf quantity.
[0067] Optionally, the initial position point determination sub-module is specifically configured to:
[0068] Obtain the model volume of each of the wrapping models;
[0069] Perform a point scattering process on the wrapping models according to the size of the model volume to obtain the initial bearing position points corresponding to each of the target wrapping models.
[0070] Optionally, the tree model generation module includes:
[0071] A leaf normal generation sub-module, configured to map the model normal of the contour model to the leaf model to obtain a leaf normal;
[0072] A normal value calculation sub-module, configured to calculate the normal value of the leaf model by using the leaf normal;
[0073] A tree model generation sub-module, configured to add leaf models corresponding to the number of leaves to the target branch model corresponding to the trunk model according to the bearing position points, and render the leaf models according to the normal values to generate a tree model.
[0074] An embodiment of the present invention also discloses an electronic device, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory complete communication with each other through the communication bus;
[0075] The memory is used to store a computer program;
[0076] The processor is configured to implement the method as described in the embodiment of the present invention when executing the program stored in the memory.
[0077] An embodiment of the present invention also discloses a computer-readable storage medium, on which instructions are stored, and when executed by one or more processors, cause the processors to execute the method as described in the embodiment of the present invention.
[0078] The embodiments of the present invention have the following advantages:
[0079] In the embodiment of the present invention, in the process of constructing a tree model, several leaf patches can be obtained through leaf creation operations, and a leaf model can be constructed by using the several leaf patches, and a trunk model and a branch model corresponding to the trunk model can be created. Then, a wrapping model corresponding to the branch model can be determined, and the model normal corresponding to the wrapping model can be obtained. Then, the wrapping model can be subjected to point scattering processing to obtain the bearing position points and the number of leaves of the leaf model in the branch model. Then, according to the bearing position points, the leaf models corresponding to the number of leaves can be assembled with the trunk model and the branch model, and the leaf models can be subjected to normal mapping according to the model normal to generate a tree model. On the one hand, for a single leaf model, it can be constructed by using several leaf patches to obtain leaf models at different levels, effectively improving the authenticity of the leaf models. On the other hand, by baking the corresponding model normal of the wrapping model and performing point scattering processing to determine the position and number of the leaf models, and using the model normal to perform normal mapping on the leaf models when assembling the tree model, not only can the quality of the normal mapping effect be effectively guaranteed and the efficiency of normal mapping be improved, but also the overall layering of the tree model can be improved by adjusting the position, number, etc. of the leaves, ensuring the authenticity of the tree model. Description of the Drawings
[0080] Figure 1It is a flowchart of the steps of a method for generating a tree model provided in an embodiment of the present invention;
[0081] Figure 2 It is a schematic diagram of a tree model provided in an embodiment of the present invention;
[0082] Figure 3 It is a schematic diagram of a tree model provided in an embodiment of the present invention;
[0083] Figure 4 It is a schematic diagram of a position point provided in an embodiment of the present invention;
[0084] Figure 5 It is a schematic diagram of a branch curve provided in an embodiment of the present invention;
[0085] Figure 6 It is a schematic diagram of a position point provided in an embodiment of the present invention;
[0086] Figure 7 It is a schematic diagram of a leaf model provided in an embodiment of the present invention;
[0087] Figure 8 It is a schematic diagram of a tree model provided in an embodiment of the present invention;
[0088] Figure 9 It is a structural block diagram of a device for generating a tree model provided in an embodiment of the present invention;
[0089] Figure 10 It is a block diagram of an electronic device provided in an embodiment of the present invention;
[0090] Figure 11 It is a schematic diagram of a computer-readable storage medium provided in an embodiment of the present invention. Detailed implementation manners
[0091] To make the above objects, features, and advantages of the present invention more obvious and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific implementation manners.
[0092] To enable those skilled in the art to better understand the technical solutions of the embodiments of the present invention, the following explains and describes relevant technical terms:
[0093] Automated modeling: It refers to using tools or scripts to automatically run and quickly generate models. For example, in a game scene, developers need to design and batch generate models. Through automated modeling, when batch constructing the same or similar models is required, model construction can be automated, greatly reducing the repetitive work of developers; in addition, in the case where there are subjective differences in manual model construction, the differences in the effects of manual production can be effectively avoided through automated modeling, ensuring the quality of the models.
[0094] Particle systems are a technique used in 3D computer graphics to simulate specific, fuzzy phenomena that are difficult to reproduce realistically using traditional rendering techniques. Particle systems are commonly used to simulate fire, explosions, smoke, water, sparks, falling leaves, clouds, fog, snow, dust, meteor trails, and abstract visual effects like glowing trails.
[0095] Inserts: In order to make the leaves visible in 360°, developers can insert the patches perpendicular to each other in a cross to form a unit leaf model.
[0096] Low-poly and high-poly: In order to achieve better effects for a virtual model in the game process, it is necessary to first make a model with a relatively high number of faces, referred to as a high-poly; in order to have better performance when put into the game, it is necessary to make a corresponding model with a low number of faces, referred to as a low-poly.
[0097] Baking: It converts the light and shadow relationship between models into pictures to form corresponding maps.
[0098] Normal Mapping: Bake out a normal map (NormalMap) from a model with high details through mapping, and then stick it on the normal map channel of the low-end model.
[0099] Houdini: A feature-rich 3D computer graphics software.
[0100] Quickbaisctree node: a package built into Houdini that encapsulates the components needed to easily generate plants
[0101] As an example, tree vegetation is an indispensable part of the game scene. For the modeling of tree leaves in realistic games, the main method is still to use the method of inserting slices. Part of the information of the high-poly model is baked into the normal map, and then another part of the information is projected onto the low-poly model. Finally, these baked static information are combined in the engine to restore the high-poly information. Through a large number of generations, an effect similar to that of leaves is achieved. At the same time, in order to avoid poor projection effects caused by inserting slices, it is often necessary to manually use a large spherical model to wrap the leaves and perform normal mapping on the internal inserts. Among them, in the related technology, the particle system of 3D image processing software is used to generate leaf inserts, or the developers manually arrange the leaf inserts and perform spherical normal mapping in the software to construct the tree model. However, in the above process, it is difficult to control the quality by manually adjusting the normal mapping effect. It takes a long time to bake a good effect, and the quality of different developers is uneven. At the same time, for games, the LOD (Levels of Detail) of leaves is an important factor affecting the overall effect. The method of manually adjusting to make the LOD of leaves often makes the LOD very rigid or the shape difference is large, and it is impossible to effectively form a multi-level display effect, resulting in poor authenticity of the tree model. In addition, when the model is modified and adjusted, a series of normal mapping bakings need to be performed again, which greatly increases the cost of modification and reduces the efficiency of model generation.
[0102] In this regard, one of the core inventive points of the embodiments of the present invention is to construct the shape of a single leaf model by creating a plurality of leaf patches, so as to construct a leaf model with a multi-level effect. At the same time, in the process of constructing a tree model, a wrapping model corresponding to the branch model is constructed, and the number, position, etc. of the leaf models are adjusted through the wrapping model, so as to construct a leaf model with a multi-level effect from the overall effect. Thus, by processing the shape, position, number, etc. of the leaf models, a leaf display effect with multiple levels of detail is constructed, and an excellent vegetation effect of the tree model is achieved. Specifically, in the process of constructing a tree model, several leaf patches can be obtained through a leaf creation operation, and a leaf model can be constructed by the several leaf patches. At the same time, a trunk model and a branch model corresponding to the trunk model are created. Then, a wrapping model corresponding to the branch model is determined, and the model normal corresponding to the wrapping model is obtained. Then, the wrapping model can be scattered with points to obtain the bearing position points and the number of leaf models on the branch model. Then, the leaf models corresponding to the number of leaves are assembled with the trunk model and the branch model according to the bearing position points, and the leaf models are subjected to normal mapping according to the model normal to generate a tree model. On the one hand, for a single leaf model, by constructing it with several leaf patches, leaf models at different levels can be obtained, effectively improving the authenticity of the leaf model. On the other hand, by baking the corresponding model normal through the wrapping model and performing point scattering to determine the position and number of the leaf models, and using the model normal to perform normal mapping on the leaf models when assembling the tree model, not only can the quality of the normal mapping effect be effectively guaranteed and the efficiency of normal mapping be improved, but also the overall sense of hierarchy of the tree model can be improved by adjusting the position, number, etc. of the leaves, ensuring the authenticity of the tree model.
[0103] Referring to Figure 1 , a flowchart of the steps of a method for generating a tree model provided in an embodiment of the present invention is shown, which may specifically include the following steps:
[0104] Step 101, in response to a leaf creation operation, obtain a plurality of leaf patches corresponding to the leaf creation operation, and construct a leaf model with the plurality of leaf patches;
[0105] Optionally, the technical solution of the embodiments of the present invention can be applied to houdini. By constructing an automated modeling script corresponding to the method for generating a tree model, the automated construction of the tree model can be realized in houdini through this script. For this automated modeling script, it can be processed on the basis of the built-in quick baisc tree node in houdini. A leaf model is constructed by creating leaf patches, the point scattering effect of the leaf model is modified, a corresponding wrapping model is made for the leaf model, and normal mapping is performed on the leaf model through the wrapping model, etc., to construct a corresponding tree model.
[0106] In a specific implementation, for the leaf model provided in the quick basic tree node, it is an unordered leaf model. This type of unordered leaf model has a weak sense of hierarchy and cannot bring the performance effect of multiple levels of detail. In response to this, in response to a leaf creation operation, several leaf patches corresponding to the leaf creation operation can be obtained, and the several leaf patches can be used to construct a leaf model. Among them, the leaf creation operation can be an operation for a developer to manually create a leaf model. For a script, it can be an operation for software to create a leaf model according to a set operation process.
[0107] Specifically, after several leaf patches are created, each leaf patch can be inserted at a preset angle to obtain a leaf insert, and then the leaf insert can replace the default, unordered leaf insert to obtain the corresponding leaf model. For example, three leaf patches can be created, and each leaf patch can be inserted at a 90-degree vertical angle to construct a leaf insert, that is, a leaf model. Thus, by inserting multiple leaf patches at corresponding angles, the leaf model can be designed to construct a leaf model with multiple levels of detail, ensuring the LOD of the leaf model.
[0108] Step 102, create a trunk model and a target branch model corresponding to the trunk model;
[0109] In houdini, creating a tree with quick basic tree is through hierarchical creation. The first level is the trunk, then thicker second-level branches are generated on the first level, and then thinner third-level branches are generated on the second-level branches, and so on, to obtain the corresponding trunk model and branch model.
[0110] In the embodiment of the present invention, a developer can manually draw the basic models of the first-level trunk and the second-level, third-level, fourth-level, etc. branches, and then add corresponding adjustment parameters to the basic trunk model and branch model to obtain the target trunk model and target branch model. Specifically, in response to a model drawing operation, the trunk model corresponding to the model drawing operation and the initial branch model corresponding to the trunk model are determined. Then, the rotation value parameter for the initial branch model is obtained, and then the initial branch model is rotated according to the rotation value parameter to obtain the target branch model corresponding to the initial branch model.
[0111] Specifically, after drawing the trunk model and the initial branch model corresponding to the trunk model, the performance effects of the trunk model and the branch model are similar to a "cross shape", which is quite different from the performance effects of real trees. In this regard, the rotation value parameter for the branch model (which can be the rotation value multiplier in Houdini) can be obtained, and the branch model can be controlled to rotate through the rotation value parameter to generate target branch models with different forms. Thus, by adding the corresponding rotation value parameter to the branch model to make it rotate, the authenticity of the branch model can be improved, and further the authenticity of the tree model can be improved.
[0112] In one example, developers can generate the basic shapes of the first-level trunk and the second-, third-, and fourth-level branches through hand-drawing. Then, in the stage of generating the second-level branches, the add_rand_rotate attribute (rotation attribute) is added to the second-, third-, and fourth-level branches, and the second-, third-, and fourth-level branches are controlled to rotate through the rotation value multiplier to quickly and randomly generate the branch shapes of trees with different forms. Thus, by adding the corresponding rotation value parameter to the branch model to make it rotate, the authenticity of the branch model can be improved, and further the authenticity of the tree model can be improved. Optionally, when modeling automatically through a script, it can also first construct the basic trunk model and branch model, and then quickly generate the branch shapes of trees with different forms by rotating the branch model through the rotation value multiplier. The present invention does not limit this.
[0113] Step 103: Determine the wrapping model corresponding to the target branch model, and obtain the model normal of the wrapping model.
[0114] For the wrapping model, it can be a spherical wrapper constructed in Houdini. By constructing this spherical wrapper, on the one hand, the position of the leaf model on the branch model can be located and the quantity can be determined, and on the other hand, the leaf normal corresponding to the leaf model can be baked through the spherical wrapper, avoiding manually adjusting the normal mapping of the leaf model. This can not only ensure the quality of the normal mapping but also improve the processing efficiency of the normal mapping.
[0115] In specific implementation, after the branch model is rotated through the rotation value multiplier to obtain the target branch model, the branch parameters of the target branch model can be obtained. Then, the branch parameters are used to generate a branch curve corresponding to the target branch model. Then, the branch curve is colored to divide the target branch model into branch model groups. Next, the coordinate information of each target branch model is obtained, and a wrapping model corresponding to each branch model group is constructed based on the coordinate information.
[0116] Among them, the branch parameters can be the coordinate information of the target branch model after being processed by the rotation value parameters. Then, according to the coordinate information, branch curves corresponding to each target branch model can be constructed. Then, random color regions can be drawn on the branch curves. The target branch models corresponding to the color regions of the same color can correspond to the same cluster of leaf models. Then, the target branch models can be grouped according to the color. The target branch models of the same color are used as a branch model group. The purpose is to divide the leaf models corresponding to the branches in the same area into a group, so as to determine the position and quantity of the leaf models in the subsequent steps, etc.
[0117] After the grouping of the target branch models is completed according to the color, the coordinate information of the target branch models in each branch model group can be used to construct rectangular contour models corresponding to the branch model groups according to the preset size information. Then, smooth processing is performed on each rectangular contour model to obtain the wrapping models corresponding to each branch model group. Among them, the rectangular contour model can be the bounding box provided in houdini. When determining the bearing position of the leaf models, in order to avoid the generation of unnecessary overhead when the leaf models are generated inside the tree, the tree can be wrapped by a bounding box, and then point scattering processing is performed on it to determine the position of the leaf models. Specifically, when creating the bounding box, the tree trunk does not need to be included. Then, the coordinate information of the target branch models of the same color can be obtained, and then multiple rectangular contour models can be generated according to the preset size ratio to wrap the branch model groups corresponding to the same color region, so as to merge multiple rectangular bounding boxes to construct a complex rectangular model for the whole tree, and then smooth processing is performed to obtain the wrapping models corresponding to each branch model group.
[0118] In one example, referring to Figure 2 , a schematic diagram of the tree model provided by the embodiment of the present invention is shown. After the grouping of the target branch models is completed according to the color, the coordinate information of the target branch models in each branch model group can be used to construct a bounding box corresponding to the branch model group according to the preset size information, and multiple bounding boxes are combined into a complex-shaped bounding box. Referring to Figure 3 , a schematic diagram of the tree model provided by the embodiment of the present invention is shown. By performing smooth processing on the complex-shaped bounding box, spherical wrapping bodies corresponding to each group of branch model groups can be obtained, so as to determine the position and quantity of the leaf models through the spherical wrapping bodies.
[0119] Step 104, perform point scattering processing on the wrapping model to obtain the bearing position points and the number of leaves of the leaf models in the target branch models;
[0120] In the embodiments of the present invention, the functions of the wrapping model may include: ① Sprinkling points according to the model volume in the wrapping model to achieve the distinction of the density of the number of leaves in different regions; ② Performing normal mapping on the normals of each group of leaf models corresponding to the branch models with the normal of the wrapping model to obtain multi-level leaf normals. Thus, by processing the number, position, and normal mapping of the leaf models through the wrapping model, not only can the quality of the normal mapping effect be effectively guaranteed and the efficiency of normal mapping be improved, but also the overall layering of the tree model can be enhanced by adjusting the position and number of the leaves, etc., to ensure the authenticity of the tree model.
[0121] In a specific implementation, the sprinkling process can be first performed on each wrapping model to obtain the initial bearing position points. At this time, since the sprinkling range is too large, the relationship between the position points and the original branch models is not obvious. Then, the jitter parameters for the branch curves can be obtained, and then the branch curves are distorted using the jitter parameters to obtain the leaf areas corresponding to the target branch models. Then, the initial bearing position points are contracted towards the leaf areas to obtain the target bearing position points of the leaf models in the target branch models. At the same time, the number of target bearing position points corresponding to each target branch model is used as the number of leaves. For the sprinkling of the wrapping model, the model volume of each wrapping model can be first obtained, and then the wrapping models are sprinkled according to the size of the model volume to obtain the initial bearing position points corresponding to each target wrapping model. Then, the initial bearing position points are contracted to determine the target bearing position points matching the branch models. Optionally, the larger the model volume of the wrapping model, the more the number of sprinkled points, that is, the more the number of leaf models owned by the target branch models in the same region.
[0122] When sprinkling points on the wrapping model, since the sprinkling is performed in an average scattering manner according to the wrapping model, the obtained bearing position points may not necessarily adhere to the branch models. In this regard, the jitter parameters for the branch curves can be obtained to randomly distort the branch models, simulating the range areas corresponding to the leaves around the branches. Then, the initial bearing position points obtained from the initial sprinkling are contracted towards the distorted areas, and the position where they stop is the target bearing position point. Each target bearing position point corresponds to a leaf model, thus obtaining relatively real leaf positions that are more matched with the branch models.
[0123] In one example, referring to Figure 4 , a schematic diagram of the position points provided in the embodiments of the present invention is shown. When the wrapping model is obtained, the scatter node can be used to sprinkle points on the wrapping model to obtain the initial bearing position points. Since the sprinkling range is large at this time, resulting in a large deviation between the position points and the branch models, corresponding processing is required. Referring to Figure 5, which shows a schematic diagram of the branch curve provided in the embodiment of the present invention. The pointjitter node can be used to distort the branch curve to simulate the position range of the leaves around the branch. Then, the initial bearing position point is contracted towards the distorted area, and the position where it stops after contraction is the target bearing position point of the leaf model. Refer to Figure 6 , which shows a schematic diagram of the position point provided in the embodiment of the present invention. Each target bearing position point corresponds to a leaf model. Thus, by processing the wrapping model, the leaf position, the number of leaves, and the leaf normal of the leaf model that are relatively matched with the branch model can be obtained.
[0124] Step 105: Assemble the leaf models corresponding to the number of leaves with the trunk model and the target branch model according to the bearing position points, and perform normal mapping on the leaf models according to the model normals to generate a tree model.
[0125] In a specific implementation, the model normal of the contour model can be mapped to the leaf model to obtain the leaf normal. Then, the leaf normal is used to calculate the normal value of the leaf model. Then, the leaf models corresponding to the number of leaves are added to the branch model corresponding to the trunk model according to the bearing position points, and the leaf models are rendered according to the normal value to generate a tree model.
[0126] Among them, the leaf model can be the leaf insert piece constructed by several leaf patches. Then, the leaf insert piece with a random rotation value can be generated at the determined target bearing position point, and the model normal corresponding to the wrapping model (i.e., the normal of the wrapper) is mapped to the leaf insert piece to obtain the leaf normal corresponding to each leaf model. Then, the normal value corresponding to the leaf normal can be obtained. Then, the leaf model, the branch model, and the trunk model are assembled, and the leaf model is rendered based on the normal value to obtain a tree model. Thus, in the process of constructing the tree model, on the one hand, for a single leaf model, it is constructed by several leaf patches, and different levels of leaf models can be obtained, effectively improving the authenticity of the leaf model. On the other hand, by baking the corresponding model normal of the wrapping model and performing scatter point processing to determine the position and number of leaf models, and using the model normal to perform normal mapping on the leaf models when assembling the tree model, not only can the quality of the normal mapping effect be effectively guaranteed and the efficiency of normal mapping be improved, but also the overall sense of hierarchy of the tree model can be improved by adjusting the position, number, etc. of the leaves, ensuring the authenticity of the tree model.
[0127] In one example, refer to Figure 7, which shows a schematic diagram of the leaf model provided in the embodiment of the present invention. After determining the position points of the leaf model, leaf inserts with random rotation values can be generated at the corresponding position points, and then the model normal of the wrapping model is mapped onto the leaf inserts to obtain the leaf normal. Finally, the leaf model, branch model, and trunk model are assembled to obtain the corresponding tree model, as Figure 8 shown, which is a schematic diagram of the tree model provided in the embodiment of the present invention. Thus, by creating a certain number of leaf patches to construct the shape of a single leaf model, a leaf model with a multi-level effect is constructed. At the same time, during the process of constructing the tree model, by constructing a wrapping model corresponding to the branch model and adjusting the quantity, position, etc. of the leaf model through the wrapping model, a leaf model with a multi-level effect is constructed from the overall effect. Thus, by processing the shape, position, quantity, etc. of the leaf model, a leaf display effect with multiple levels of detail is constructed, achieving an excellent vegetation effect for the tree model.
[0128] In the embodiment of the present invention, during the process of constructing the tree model, first, through the leaf creation operation, a certain number of leaf patches can be obtained, and the leaf model is constructed by the certain number of leaf patches, and the trunk model and the branch model corresponding to the trunk model are created. Then, the wrapping model corresponding to the branch model is determined, and the model normal corresponding to the wrapping model is obtained. Then, the wrapping model can be subjected to a point scattering process to obtain the bearing position points and the number of leaves of the leaf model in the branch model. Then, according to the bearing position points, the leaf models corresponding to the number of leaves are assembled with the trunk model and the branch model, and the leaf models are subjected to normal mapping according to the model normal to generate the tree model. On the one hand, for a single leaf model, by constructing it with a certain number of leaf patches, different levels of leaf models can be obtained, effectively improving the authenticity of the leaf model. On the other hand, by baking the corresponding model normal through the wrapping model and performing a point scattering process to determine the position and number of the leaf model, and using the model normal to perform normal mapping on the leaf model when assembling the tree model, not only can the quality of the normal mapping effect be effectively guaranteed and the efficiency of normal mapping be improved, but also the overall sense of hierarchy of the tree model can be improved by adjusting the position, number, etc. of the leaves, ensuring the authenticity of the tree model.
[0129] It should be noted that for the method embodiments, for the sake of simple description, they are all expressed as a series of action combinations. However, those skilled in the art should know that the embodiments of the present invention are not limited by the described action sequences, because according to the embodiments of the present invention, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily essential for the embodiments of the present invention.
[0130] Referring to Figure 8, showing a structural block diagram of a device for generating a tree model provided in an embodiment of the present invention, specifically including the following modules:
[0131] A leaf model construction module 901, configured to, in response to a leaf creation operation, obtain a plurality of leaf patches corresponding to the leaf creation operation, and construct a leaf model from the plurality of leaf patches;
[0132] A branch model creation module 902, configured to create a trunk model and a target branch model corresponding to the trunk model;
[0133] A wrapping model determination module 903, configured to determine a wrapping model corresponding to the target branch model, and obtain the model normal of the wrapping model;
[0134] An information determination module 904, configured to perform point scattering on the wrapping model, and obtain the bearing position points and the number of leaves of the leaf model on the target branch model;
[0135] A tree model generation module 905, configured to assemble the leaf model corresponding to the number of leaves with the trunk model and the target branch model according to the bearing position points, and perform normal mapping on the leaf model according to the model normal to generate a tree model.
[0136] In an alternative embodiment, the leaf model construction module 901 is specifically configured to:
[0137] Insert the plurality of leaf patches at a preset angle to obtain a leaf model.
[0138] In an alternative embodiment, the leaf model construction module 901 is specifically configured to:
[0139] Insert three of the leaf patches in a 90-degree perpendicular manner to construct a leaf model.
[0140] In an alternative embodiment, the branch model creation module 902 includes:
[0141] A model drawing sub-module, configured to, in response to a model drawing operation, determine a trunk model corresponding to the model drawing operation and an initial branch model corresponding to the trunk model;
[0142] A rotation value parameter acquisition sub-module, configured to acquire a rotation value parameter for the initial branch model;
[0143] A branch model generation sub-module, configured to perform a rotation process on the initial branch model according to the rotation value parameter to obtain a target branch model corresponding to the initial branch model.
[0144] In an alternative embodiment, the package model determination module 903 includes:
[0145] A branch parameter acquisition sub-module, configured to acquire branch parameters of the target branch model;
[0146] A branch curve generation sub-module, configured to generate a branch curve corresponding to the target branch model by using the branch parameters;
[0147] A model grouping sub-module, configured to color the branch curve to divide the target branch model into branch model groups;
[0148] A package model generation sub-module, configured to acquire coordinate information of each of the target branch models, and construct a package model corresponding to each of the target branch model groups based on the coordinate information.
[0149] In an alternative embodiment, the package model generation sub-module is specifically configured to:
[0150] Use the coordinate information of the target branch models in each of the branch model groups to construct a rectangular contour model corresponding to the branch model group according to preset dimension information;
[0151] Perform smoothing processing on each of the rectangular contour models to obtain a package model corresponding to each of the branch model groups.
[0152] In an alternative embodiment, the information determination module 904 includes:
[0153] An initial position point determination sub-module, configured to perform a point scattering process on each of the package models to obtain an initial bearing position point;
[0154] A jitter parameter acquisition sub-module, configured to acquire a jitter parameter for the branch curve;
[0155] A leaf area determination sub-module, configured to perform a distortion process on the branch curve by using the jitter parameter to obtain a leaf area corresponding to the target branch model;
[0156] A target position point determination sub-module, configured to contract the initial bearing position point towards the leaf area to obtain a target bearing position point of the leaf model in the target branch model;
[0157] A leaf quantity determination sub-module, configured to use the quantity of the target bearing position points corresponding to each of the target branch models as the leaf quantity.
[0158] In an alternative embodiment, the initial position point determination sub-module is specifically configured to:
[0159] Acquire the model volume of each of the package models;
[0160] Perform dotting processing on the package model according to the size of the model volume to obtain the initial bearing position points corresponding to each of the target package models.
[0161] In an alternative embodiment, the tree model generation module 905 includes:
[0162] A leaf normal generation sub-module, configured to map the model normal of the contour model to the leaf model to obtain leaf normals;
[0163] A normal value calculation sub-module, configured to calculate the normal value of the leaf model by using the leaf normals;
[0164] A tree model generation sub-module, configured to add leaf models corresponding to the number of leaves to the target branch model corresponding to the trunk model according to the bearing position points, and render the leaf models with the normal values to generate a tree model.
[0165] For the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and for the related parts, refer to the partial description of the method embodiment.
[0166] In addition, an embodiment of the present invention further provides an electronic device, as Figure 10 shown, including a processor 1001, a communication interface 1002, a memory 1003, and a communication bus 1004, wherein the processor 1001, the communication interface 1002, and the memory 1003 complete communication with each other through the communication bus 1004,
[0167] The memory 1003 is used for storing a computer program;
[0168] The processor 1001, when executing the program stored in the memory 1003, implements the following steps:
[0169] In response to a leaf creation operation, obtain a plurality of leaf patches corresponding to the leaf creation operation, and construct a leaf model from the plurality of leaf patches;
[0170] Create a trunk model and a target branch model corresponding to the trunk model;
[0171] Determine a package model corresponding to the target branch model, and obtain the model normal of the package model;
[0172] Perform dotting processing on the package model to obtain the bearing position points and the number of leaves of the leaf model in the target branch model;
[0173] Assemble the leaf model corresponding to the number of leaves with the trunk model and the target branch model according to the bearing position points, and perform normal mapping on the leaf model according to the model normal to generate a tree model.
[0174] In an alternative embodiment, the constructing the leaf model from the plurality of leaf patches includes:
[0175] Insert the plurality of leaf patches at a preset angle to obtain a leaf model.
[0176] In an alternative embodiment, the inserting the plurality of leaf patches at a preset angle to construct a leaf model includes:
[0177] Insert three of the leaf patches in a perpendicular manner at 90 degrees to construct a leaf model.
[0178] In an alternative embodiment, the creating the trunk model and the target branch model corresponding to the trunk model includes:
[0179] In response to a model drawing operation, determine the trunk model corresponding to the model drawing operation and the initial branch model corresponding to the trunk model;
[0180] Obtain the rotation value parameter for the initial branch model;
[0181] Perform a rotation process on the initial branch model according to the rotation value parameter to obtain the target branch model corresponding to the initial branch model.
[0182] In an alternative embodiment, the determining the wrapping model corresponding to the target branch model includes:
[0183] Obtain the branch parameters of the target branch model;
[0184] Use the branch parameters to generate a branch curve corresponding to the target branch model;
[0185] Color the branch curve to divide the target branch model into branch model groups;
[0186] Obtain the coordinate information of each of the target branch models, and construct a wrapping model corresponding to each of the target branch model groups based on the coordinate information.
[0187] In an alternative embodiment, the constructing the wrapping model corresponding to each of the target branch model groups based on the coordinate information includes:
[0188] Using the coordinate information of the target branch model in each of the branch model groups, construct a rectangular contour model corresponding to the branch model group according to the preset size information;
[0189] Perform smoothing processing on each of the rectangular contour models to obtain a wrapping model corresponding to each of the branch model groups.
[0190] In an alternative embodiment, the performing scatter point processing on the wrapping model to obtain the bearing position points and the number of leaves of the leaf model in the target branch model includes:
[0191] Perform scatter point processing on each of the wrapping models to obtain initial bearing position points;
[0192] Obtain the jitter parameter for the branch curve;
[0193] Use the jitter parameter to distort the branch curve to obtain a leaf area corresponding to the target branch model;
[0194] Shrink the initial bearing position points towards the leaf area to obtain the target bearing position points of the leaf model in the target branch model;
[0195] Take the number of target bearing position points corresponding to each of the target branch models as the number of leaves.
[0196] In an alternative embodiment, the performing scatter point processing on each of the target wrapping models to obtain initial bearing position points includes:
[0197] Obtain the model volume of each of the wrapping models;
[0198] Perform scatter point processing on the wrapping models according to the size of the model volume to obtain the initial bearing position points corresponding to each of the target wrapping models.
[0199] In an alternative embodiment, the assembling the leaf models corresponding to the number of leaves with the trunk model and the target branch model according to the bearing position points and performing normal mapping on the leaf models according to the model normals to generate a tree model includes:
[0200] Map the model normal of the contour model to the leaf model to obtain a leaf normal;
[0201] Use the leaf normal to calculate the normal value of the leaf model;
[0202] Add the leaf models corresponding to the number of leaves to the target branch model corresponding to the trunk model according to the bearing position points, and render the leaf models according to the normal value to generate a tree model.
[0203] The communication bus mentioned in the above terminal may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into an address bus, a data bus, a control bus, etc. For the convenience of representation, only a thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0204] The communication interface is used for communication between the above terminal and other devices.
[0205] The memory may include a Random Access Memory (RAM), or may also include a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located far from the aforementioned processor.
[0206] The above-mentioned processor may be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0207] As Figure 11 shown, in another embodiment provided by the present invention, there is also provided a computer-readable storage medium 1101. Instructions are stored in the computer-readable storage medium. When it runs on a computer, it causes the computer to execute the method for generating a tree model described in the above embodiment.
[0208] In another embodiment provided by the present invention, there is also provided a computer program product containing instructions. When it runs on a computer, it causes the computer to execute the method for generating a tree model described in the above embodiment.
[0209] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in the embodiments of the present invention are generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center by wire (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that the computer can access or a data storage device such as a server or data center that includes one or more integrated available media. The available medium can be a magnetic medium (such as a floppy disk, hard disk, magnetic tape), an optical medium (such as a DVD), or a semiconductor medium (such as a solid state disk (SSD)).
[0210] It should be noted that, in this document, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise", or any other variant thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or device that includes a series of elements includes not only those elements but also other elements that are not explicitly listed, or also includes elements that are inherent to such process, method, article, or device. Without further limitation, an element defined by the statement "including a..." does not exclude the existence of additional identical elements in the process, method, article, or device that includes the element.
[0211] Each embodiment in this specification is described in a related manner. For the same or similar parts among the embodiments, reference can be made to each other. Each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and reference can be made to the corresponding part of the method embodiment for the relevant content.
[0212] The above are only the preferred embodiments of the present invention and are not intended to limit the protection scope of the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present invention are all included in the protection scope of the present invention.
Claims
1. A method for generating a tree model, characterized in that, Including: In response to a leaf creation operation, obtain a plurality of leaf patches corresponding to the leaf creation operation, and construct a leaf model from the plurality of leaf patches; Create a trunk model and a target branch model corresponding to the trunk model; Determine a wrapping model corresponding to the target branch model, and obtain the model normal of the wrapping model; Perform a point scattering process on the wrapping model to obtain the bearing position points and the number of leaves of the leaf model in the target branch model; Assemble the leaf model corresponding to the number of leaves with the trunk model and the target branch model according to the bearing position points, and perform normal mapping on the leaf model according to the model normal to generate a tree model; Among them, the determining the wrapping model corresponding to the target branch model includes: Obtain the branch parameters of the target branch model; Use the branch parameters to generate a branch curve corresponding to the target branch model; Color the branch curve to divide the target branch model into branch model groups; Obtain the coordinate information of each target branch model, and construct a wrapping model corresponding to each branch model group based on the coordinate information; Among them, the performing a point scattering process on the wrapping model to obtain the bearing position points and the number of leaves of the leaf model in the target branch model includes: Perform a point scattering process on each wrapping model to obtain initial bearing position points; Obtain the jitter parameter for the branch curve; Use the jitter parameter to distort the branch curve to obtain a leaf area corresponding to the target branch model; Shrink the initial bearing position points towards the leaf area to obtain the target bearing position points of the leaf model in the target branch model; Take the number of target bearing position points corresponding to each target branch model as the number of leaves.
2. The method according to claim 1, characterized in that, The constructing the leaf model from the plurality of leaf patches includes: Insert the plurality of leaf patches at a preset angle to obtain a leaf model.
3. The method according to claim 2, characterized in that, The inserting the plurality of leaf patches at a preset angle to construct a leaf model includes: Insert three of the leaf patches in a perpendicular manner at 90 degrees to construct a leaf model.
4. The method according to claim 1, wherein The creating the trunk model and the target branch model corresponding to the trunk model includes: In response to a model drawing operation, determine a trunk model corresponding to the model drawing operation and an initial branch model corresponding to the trunk model; Obtain the rotation value parameter for the initial branch model; Perform a rotation process on the initial branch model according to the rotation value parameter to obtain the target branch model corresponding to the initial branch model.
5. The method according to claim 1, characterized in that, The constructing the wrapping model corresponding to each branch model group based on the coordinate information includes: Use the coordinate information of the target branch models in each branch model group to construct a rectangular contour model corresponding to the branch model group according to the preset size information; Perform a smoothing process on each rectangular contour model to obtain a wrapping model corresponding to each branch model group.
6. The method according to claim 1, wherein Performing scatter point processing on each of the package models to obtain initial bearing position points includes: Obtaining the model volume of each of the package models; Performing scatter point processing on the package models according to the size of the model volume to obtain the initial bearing position points corresponding to each of the package models.
7. The method according to claim 1, characterized in that, Assembling the leaf models corresponding to the number of leaves with the trunk model and the target branch model according to the bearing position points, and performing normal mapping on the leaf models according to the model normals to generate a tree model, including: Mapping the model normal of the package model to the leaf model to obtain a leaf normal; Calculating the normal value of the leaf model by using the leaf normal; Adding the leaf models corresponding to the number of leaves to the target branch model corresponding to the trunk model according to the bearing position points, and rendering the leaf models according to the normal value to generate a tree model.
8. A generating device for a tree model, characterized in that, Including: A leaf model construction module, configured to, in response to a leaf creation operation, obtain a plurality of leaf patches corresponding to the leaf creation operation, and construct a leaf model from the plurality of leaf patches; A branch model creation module, configured to create a trunk model and a target branch model corresponding to the trunk model; A package model determination module, configured to determine a package model corresponding to the target branch model, and obtain the model normal of the package model; An information determination module, configured to perform scatter point processing on the package model to obtain the bearing position points of the leaf models in the target branch model and the number of leaves; A tree model generation module, configured to assemble the leaf models corresponding to the number of leaves with the trunk model and the target branch model according to the bearing position points, and perform normal mapping on the leaf models according to the model normals to generate a tree model; Wherein, the package model determination module includes: A branch parameter acquisition sub-module, configured to acquire the branch parameters of the target branch model; A branch curve generation sub-module, configured to generate a branch curve corresponding to the target branch model by using the branch parameters; A model grouping sub-module, configured to color the branch curve to divide the target branch model into branch model groups; A package model generation sub-module, configured to acquire the coordinate information of each of the target branch models, and construct a package model corresponding to each of the target branch model groups based on the coordinate information; Wherein, the information determination module includes: An initial position point determination sub-module, configured to perform scatter point processing on each of the package models to obtain initial bearing position points; A jitter parameter acquisition sub-module, configured to acquire the jitter parameters for the branch curve; A leaf area determination sub-module, configured to perform distortion processing on the branch curve by using the jitter parameters to obtain a leaf area corresponding to the target branch model; A target position point determination sub-module, configured to contract the initial bearing position points towards the leaf area to obtain the target bearing position points of the leaf models in the target branch model; The leaf quantity determination sub-module is configured to use the quantity of the target bearing position points corresponding to each of the target branch models as the leaf quantity.
9. An electronic device, characterized in that, It includes a processor, a communication interface, a memory, and a communication bus. Among them, the processor, the communication interface, and the memory complete communication with each other through the communication bus; The memory is used to store computer programs; When the processor is configured to execute the programs stored on the memory, it implements the method according to any one of claims 1-7.
10. A computer-readable storage medium, on which instructions are stored. When executed by one or more processors, the instructions cause the processor to execute the method according to any one of claims 1-7.
Citation Information
Patent Citations
Method and system of three-dimensional reconstruction of shape structure of trees in leaved state
CN103106684A
Vegetation model rendering method and device, equipment and storage medium
CN112206528A
Tree modeling method, device and equipment
CN112634432A
Tree model processing method and device
CN113223153A