Plant object resource generation method and device
By generating spirals in the game and performing adsorption processing, determining the adsorption line segments and sprinkling points/lines, and obtaining and rendering plant object models, the problem of low efficiency and poor realism in the generation of plant object resources in existing technologies is solved, and efficient and realistic plant resource generation is achieved.
Patent Information
- Application Number
- CN202311703774.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-12
- Publication Date
- 2025-01-10
AI Technical Summary
Existing technologies have low efficiency in generating plant object resources, poor realism in the growth process, and high complexity in data processing.
By generating a spiral at the target growth location and applying the spiral to the scene objects of the plant to be grown, the application line segment is determined, the application point surface and application line are obtained, the plant object model is obtained and rendered, and the plant object resource is generated.
The complexity of generating plant object resources has been reduced, the generation speed has been increased, and the realistic effect of plant growth in the game scene has been ensured.
Smart Images

Figure CN119280801A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of game development, and in particular to a resource generation method and device for plant objects. Background Art
[0002] With the diversification and intelligent development of game development, the development of game scenes that simulate the real world has become the main focus of game developers. In order to make the game scenes more in line with the natural environment, the generation of plant resources also needs to be developed and generated according to the laws of natural growth, such as the natural growth of vines, to meet the interactive sensory needs of game players.
[0003] At present, the existing game resource generation of plant object growth is usually based on the simulation growth algorithm, which generates resources in an iterative manner after selecting an initial growth point. However, since the growth process of plant objects in the real world is relatively complex, only iterative resource generation will greatly affect the realistic effect of the growth process, and when the growth-related parameters need to be adjusted, the data processing complexity of resource generation is greatly increased, which reduces the resource generation speed of plant objects, thereby affecting the resource generation efficiency of plant objects. Summary of the invention
[0004] In view of this, the present invention provides a method and device for generating resources of plant objects, the main purpose of which is to solve the problem of low efficiency of generating resources of existing plant objects.
[0005] According to one aspect of the present invention, a method for generating resources of a plant object is provided, comprising:
[0006] Generate a spiral line at the target growth position, and adsorb the spiral line to the scene object of the plant object to be grown to obtain an adsorption line segment on the scene object;
[0007] Determine the dot-scattering surface and / or dot-scattering line on the scene object where the plant object is to grow by using the adsorption line segment;
[0008] A plant object model corresponding to the dot-scattering surface and / or the dot-scattering line is obtained, and the plant object model is rendered on the dot-scattering surface and / or the dot-scattering line to generate a plant object resource.
[0009] Further, the adsorption line segments include stem line segments and / or leaf line segments, and determining the scattering surface and / or scattering line of the plant object to be grown on the scene object by using the adsorption line segments includes:
[0010] Constructing a polygonal growth region on the scene object through the leaf line segments, and performing point scattering processing on the polygonal growth region to obtain the point scattering surface; and / or,
[0011] The hanging line corresponding to the branch-stem line segment is determined, and the hanging line is subjected to a dot-scattering process to obtain the dot-scattering line.
[0012] Furthermore, constructing a polygonal growth region on the scene object through the leaf line segments, and performing point scattering processing on the polygonal growth region to obtain the point scattering surface includes:
[0013] Generate a polygonal strip area based on the leaf line segment and the obtained leaf coverage width parameter, and adsorb the vertices of the polygonal strip area to the scene object to obtain a polygonal growth area on the scene object;
[0014] Point scattering processing is performed on the polygon growth area based on the point cloud, and the point cloud in the polygon growth area is adsorbed to the scene object to obtain the point scattering surface on the scene object.
[0015] Further, the determining of the hanging line corresponding to the branch-stem line segment and performing a point-scattering process on the hanging line to obtain the point-scattering line includes:
[0016] The branch-stem line segment is converted into a suspension line based on a suspension function, and the suspension line is fitted and converted based on a spline model to obtain a parameterized suspension line;
[0017] Point scattering processing is performed on the parameterized suspension line based on the point cloud to obtain the point scattering line.
[0018] Furthermore, the fitting conversion of the suspension line based on the spline model to obtain the parameterized suspension line includes:
[0019] Convert the suspension line into a two-dimensional curve, and construct a tangent vector of the endpoint tangent of the two-dimensional curve;
[0020] Under the condition that the loss value of the iterative solution of the tangent vector is minimized, the spline sampling points determined based on the normalized distance between the tangent vector and the curve points of the spline model are fitted to obtain the suspension line.
[0021] Furthermore, the step of performing adsorption processing on the spiral line toward the scene object of the plant object to be grown to obtain the adsorption line segment on the scene object comprises:
[0022] Determine a plurality of minimum distances between all spatial points on the spiral and model vertices of the scene object;
[0023] An initial adsorption line segment is generated based on the target model point corresponding to the minimum distance on the scene object, and the initial adsorption line segment is divided to obtain a branch-stem line segment and / or a leaf line segment.
[0024] Furthermore, the dividing the initial adsorption line segment to obtain the branch-stem line segment and / or the leaf line segment includes:
[0025] Constructing a basic line segment based on any two of the target model points;
[0026] If the line segment length of the basic line segment is greater than a preset length threshold, and the line segment horizontal inclination angle of the basic line segment is less than a preset angle threshold, then the basic line segment is determined to be the branch-stem line segment;
[0027] If the line segment length of the basic line segment is less than or equal to a preset length threshold, and the line segment horizontal inclination angle of the basic line segment is greater than or equal to a preset angle threshold, the basic line segment is determined to be the leaf line segment.
[0028] Further, generating a spiral line at the target growth position includes:
[0029] Determining a plant growth direction based on a selected target growth position and a model direction of the scene object;
[0030] In the plant growth direction, a spiral line is generated with the target growth position as the spatial center.
[0031] Further, the obtaining of the plant object model corresponding to the dot-scattering surface and / or the dot-scattering line, and rendering the plant object model on the dot-scattering surface and / or the dot-scattering line to generate the plant object resource includes:
[0032] Selecting a leaf object model that matches the point cloud on the dot-scattered surface, and rendering on the dot-scattered surface based on the leaf object model to generate a leaf object resource; and / or,
[0033] A branch-stem object model matching the point cloud on the point scattering line is selected, and rendering is performed on the point scattering line based on the branch-stem object model to generate a branch-stem object resource.
[0034] According to another aspect of the present invention, a resource generation device for plant objects is provided, comprising:
[0035] A processing module, used for generating a spiral line at a target growth position, and performing adsorption processing on the spiral line to a scene object of a plant object to be grown, so as to obtain an adsorption line segment on the scene object;
[0036] A determination module, used for determining a scattering surface and / or a scattering line on the scene object where the plant object is to grow by using the adsorption line segment;
[0037] The generating module is used to obtain the plant object model corresponding to the dot-scattering surface and / or the dot-scattering line, and render the plant object model on the dot-scattering surface and / or the dot-scattering line to generate the plant object resource.
[0038] Furthermore, the adsorption line segment includes a branch line segment and / or a leaf line segment.
[0039] The determination module is specifically used to construct a polygonal growth area on the scene object through the leaf line segments, and scatter points on the polygonal growth area to obtain the scatter point surface; and / or determine the suspension line corresponding to the branch and stem line segments, and scatter points on the suspension line to obtain the scatter point line.
[0040] Furthermore, the determination module is specifically used to generate a polygonal strip area based on the leaf segment and the obtained leaf coverage width parameter, and adsorb the vertices of the polygonal strip area to the scene object to obtain a polygonal growth area on the scene object; scatter points to the polygonal growth area based on the point cloud, and adsorb the point cloud in the polygonal growth area to the scene object to obtain the scattered point surface on the scene object.
[0041] Furthermore, the determination module is specifically used to convert the branch-stem line segment into a suspension line based on a drape function, and to perform fitting conversion on the suspension line based on a spline model to obtain a parameterized suspension line; and to perform point scattering processing on the parameterized suspension line based on a point cloud to obtain a point scattering line.
[0042] Furthermore, the determination module is specifically used to convert the suspension line into a two-dimensional curve and construct a tangent vector of the endpoint tangent of the two-dimensional curve; under the condition of iteratively solving the tangent vector with the minimum loss value, the spline sampling points determined based on the normalized distance between the tangent vector and the curve points of the spline model are fitted to obtain the suspension line.
[0043] Furthermore, the processing module is specifically used to determine multiple minimum distances between all spatial points on the spiral line and the model vertices of the scene object; generate initial adsorption line segments based on the target model points on the scene object corresponding to the minimum distances, and divide the initial adsorption line segments to obtain branch and stem line segments and / or leaf line segments.
[0044] Furthermore, the processing module is specifically used to construct a basic line segment based on any two of the target model points; if the line segment length of the basic line segment is greater than a preset length threshold, and the line segment horizontal inclination angle of the basic line segment is less than a preset angle threshold, then the basic line segment is determined to be the branch line segment; if the line segment length of the basic line segment is less than or equal to the preset length threshold, and the line segment horizontal inclination angle of the basic line segment is greater than or equal to the preset angle threshold, then the basic line segment is determined to be the leaf line segment.
[0045] According to another aspect of the present invention, a storage medium is provided, wherein at least one executable instruction is stored in the storage medium, and the executable instruction enables a processor to execute operations corresponding to the resource generation method of the plant object as described above.
[0046] According to another aspect of the present invention, there is provided a terminal, comprising: a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus;
[0047] The memory is used to store at least one executable instruction, and the executable instruction enables the processor to execute operations corresponding to the resource generation method of the plant object.
[0048] By means of the above technical solution, the technical solution provided by the embodiment of the present invention has at least the following advantages:
[0049] The present invention provides a method and device for generating resources of plant objects. Compared with the prior art, the embodiment of the present invention generates a spiral line at a target growth position, and adsorbs the spiral line to a scene object where the plant object is to be grown, so as to obtain an adsorption line segment on the scene object; determines a scattering surface and / or a scattering line on the scene object where the plant object is to be grown; obtains a plant object model corresponding to the scattering surface and / or the scattering line, and renders the plant object model on the scattering surface and / or the scattering line to generate plant object resources, thereby greatly reducing the processing complexity of generating plant objects as resources in games, ensuring the realistic effect of plant growth in game scenes, and greatly accelerating the resource generation speed of plant objects, thereby improving the resource generation efficiency of plant objects.
[0050] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented according to the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present invention. Moreover, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:
[0052] Figure 1 A flow chart of a resource generation method for a plant object provided by an embodiment of the present invention is shown;
[0053] Figure 2 A flow chart of another resource generation method for plant objects provided by an embodiment of the present invention is shown;
[0054] Figure 3 A schematic diagram of a target growth position provided by an embodiment of the present invention is shown;
[0055] Figure 4 A schematic diagram of a spiral line provided by an embodiment of the present invention is shown;
[0056] Figure 5 A schematic diagram of an adsorption line segment provided by an embodiment of the present invention is shown;
[0057] Figure 6 A schematic diagram of a polygonal strip area provided by an embodiment of the present invention is shown;
[0058] Figure 7 A schematic diagram of a polygonal growth region provided by an embodiment of the present invention is shown;
[0059] Figure 8 A schematic diagram of a dot-sprinkling surface provided by an embodiment of the present invention is shown;
[0060] Fig. 9 A schematic diagram of a suspension line provided by an embodiment of the present invention is shown;
[0061] Fig.10 A schematic diagram of a fitting curve provided by an embodiment of the present invention is shown;
[0062] Fig.11 A schematic diagram of a leaf object model provided by an embodiment of the present invention is shown;
[0063] Fig.12 A schematic diagram of a leaf resource provided by an embodiment of the present invention is shown;
[0064] Fig.13 A schematic diagram of a vine object model provided by an embodiment of the present invention is shown;
[0065] Fig.14 A schematic diagram of a vine resource provided by an embodiment of the present invention is shown;
[0066] Fig.15 A block diagram showing a plant object resource generation device provided by an embodiment of the present invention;
[0067] Fig.16 A schematic diagram of the structure of a terminal provided by an embodiment of the present invention is shown. DETAILED DESCRIPTION
[0068] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
[0069] The embodiment of the present invention provides a resource generation method for plant objects, such as Figure 1 As shown, the method includes:
[0070] 101. Generate a spiral line at a target growth position, and perform adsorption processing on the spiral line toward a scene object of a plant object to be grown, so as to obtain an adsorption line segment on the scene object.
[0071] In an embodiment of the present invention, when making the growth process of a plant object, the current execution end may be a terminal server or a cloud server that executes resource generation of the plant object. At the same time, a game plug-in is developed based on a game engine and C++ language to serve as an execution tool for executing resource generation of the plant object in an embodiment of the present invention, which is not specifically limited in the embodiment of the present invention. Among them, the target growth position is the location point selected by the attachment of the scene object that the plant object is expected to rely on or climb for growth. At this time, the scene object includes but is not limited to buildings, giant plants, etc. in game development. The target growth position can be selected by the developer to generate a spiral line. The spiral line uses this target growth position as the extension center of the spiral line. The extension direction of the spiral line can be parallel or perpendicular to the scene object, which is not specifically limited in the embodiment of the present invention.
[0072] It should be noted that in order to make the generated plant object and the scene object have the effect of climbing or relying on each other, the generated spiral line is adsorbed, that is, the spiral line is adsorbed to the scene object to obtain an adsorbed line segment. Among them, the adsorbed line segment includes a branch line segment and / or a leaf line segment, and the plant object may include a leaf object and a branch line segment. Therefore, when the generated spiral line is adsorbed to the scene object, the leaf line segment corresponding to the leaf object and the branch line segment corresponding to the branch line segment are divided, so as to scatter points based on the different line segments obtained by adsorption.
[0073] 102. Determine a scattering surface and / or scattering line on the scene object where the plant object is to grow by using the adsorption line segment.
[0074] In the embodiment of the present invention, different adsorption line segments can be obtained after adsorption for different plant objects, namely, stem line segments and / or leaf line segments. At this time, since the leaf object is inserted into the point cloud position of the scattered points during post-production, in order to show the realistic effect of leaf coverage, the scattered point surface where the leaf object is expected to grow on the scene object is determined based on the leaf line segments. Correspondingly, the scattered point line where the stem (such as vine) object is expected to grow on the scene object can be determined based on the stem line segments.
[0075] 103. Obtain a plant object model corresponding to the dot-scattering surface and / or the dot-scattering line, and render the plant object model on the dot-scattering surface and / or the dot-scattering line to generate a plant object resource.
[0076] In the embodiment of the present invention, after the determination of the scattering surface or scattering line is completed, the plant object model to be scattered is obtained, that is, including a leaf model or a branch model. At this time, the leaf model or the branch model can be a three-dimensional animation model pre-made based on the scene object or game development requirements, which is not specifically limited in the embodiment of the present invention. Furthermore, after the plant object is obtained, the leaf model is rendered on the scattering surface, or the branch model is rendered on the scattering line to obtain the plant object resource, which is called and used when the game scene animation is produced, which is not specifically limited in the embodiment of the present invention.
[0077] An embodiment of the present invention provides a resource generation method for plant objects. Compared with the prior art, the embodiment of the present invention generates a spiral line at a target growth position, and adsorbs the spiral line to a scene object where the plant object is to be grown, thereby obtaining an adsorption line segment on the scene object; determines a scattering surface and / or a scattering line on the scene object where the plant object is to be grown; obtains a plant object model corresponding to the scattering surface and / or the scattering line, and renders the plant object model on the scattering surface and / or the scattering line to generate plant object resources, thereby greatly reducing the processing complexity of generating plant objects as resources in games, ensuring the realistic effect of plant growth in game scenes, and greatly accelerating the resource generation speed of plant objects, thereby improving the resource generation efficiency of plant objects.
[0078] The embodiment of the present invention provides another resource generation method of plant objects, such as Figure 2 As shown, the method includes:
[0079] 201. Determine a plant growth direction based on a selected target growth position and a model direction of the scene object.
[0080] In order to achieve the purpose of flexible plant object resource generation, when determining the target growth position, the current execution end can select a target growth position around the scene object where the plant object needs to grow based on the game plug-in tool developed based on C++ in the game engine UE4, for example. Figure 3 As shown, the developer places the position block at the target position of the three-dimensional scene object so that the current execution end obtains the selected target growth position, which is not specifically limited in the embodiment of the present invention. At the same time, since the growth of plants can be determined according to the growth properties of different plants, for example, vines grow and extend downward, etc., after determining the target growth position, the plant growth direction is determined in combination with the model direction of the scene object. Among them, the scene objects may include buildings, large plants, etc. At this time, the model direction of the scene object is the direction in which the model is in the game world space. For example, the model direction of the building is vertically upward from the ground, that is, the direction vertically upward from the ground can be used as the plant growth direction at the selected target growth position, which is not specifically limited in the embodiment of the present invention.
[0081] 202. Generate a spiral line in the plant growth direction with the target growth position as the spatial center.
[0082] In order to divide the adsorption line segments based on the spiral line, so as to automatically generate the position where the plant object grows, the current execution end generates a spiral line in the growth direction of the plant with the target growth position as the spatial center. For example, after selecting the center position of the vine climbing as the target growth position, a spiral line is generated along the growth direction of the plant, such as Figure 4 The spiral line is generated by connecting a series of points in sequence. At this time, the length and radius of the spiral line can be configured based on plant objects, scene objects, game scene requirements, etc., and the embodiment of the present invention does not make specific limitations.
[0083] 203. Determine multiple minimum distances between all spatial points on the spiral line and model vertices of the scene object.
[0084] Since the spiral line is generated by connecting a series of points in sequence, in order to adaptively determine the area for generating plant objects, the current execution end first determines all the spatial points on the spiral line, and then determines multiple minimum distances between all the spatial points and the model vertices of the scene object by finding the closest distance. At this time, the minimum distance refers to the distance between each spatial point on the spiral line and the nearest position of the model point of the scene object, and the result is as follows: Figure 5 In addition, the model point of the scene object is not the vertex of the model on the building, but a position point on the surface of the building, which is not specifically limited in the embodiment of the present invention.
[0085] 204 . Generate an initial adsorption line segment corresponding to a target model point on the scene object based on the minimum distance, and divide the initial adsorption line segment to obtain a branch line segment and / or a leaf line segment.
[0086] In an embodiment of the present invention, since plant objects can be divided into branches and leaves, in order to realistically generate resources for plant objects, the current execution end, after determining multiple minimum distances, generates initial adsorption line segments based on target model points on the scene objects corresponding to these minimum distances, thereby dividing these initial adsorption line segments to obtain leaf line segments for scattering leaf objects and branch and stem line segments for scattering branch and stem objects.
[0087] It should be noted that the "adsorption" method used in the embodiment of the present invention when generating the initial adsorption line segment based on the target model point is to construct a BVH (Bounding Volume Hierarchy) three-dimensional space partition tree data structure for all the spatial points on the spiral line, and find the position closest to the point on the climbed scene object through any point in the space of the BVH tree, which is the target model point corresponding to the minimum distance. In this way, the point on the spiral line is moved to the position corresponding to the target model point with the minimum distance, and the "adsorption" is completed.
[0088] In another embodiment of the present invention, for further definition and explanation, the step of dividing the initial adsorption line segment to obtain branch and stem line segments and / or leaf line segments includes:
[0089] Constructing a basic line segment based on any two of the target model points;
[0090] If the line segment length of the basic line segment is greater than a preset length threshold, and the line segment horizontal inclination angle of the basic line segment is less than a preset angle threshold, then the basic line segment is determined to be the branch-stem line segment;
[0091] If the line segment length of the basic line segment is less than or equal to a preset length threshold, and the line segment horizontal inclination angle of the basic line segment is greater than or equal to a preset angle threshold, the basic line segment is determined to be the leaf line segment.
[0092] In order to achieve the purpose of generating different plant object resources, so as to make the generated plants more realistic and reduce the processing complexity of plant resource generation, the current execution end divides the initial adsorption line segment. Specifically, when generating the initial adsorption line segment based on the target model point, since the target model points are all on the scene object, and the generation of branches or leaves is not limited to the generation on the scene object, when dividing the branch and stem line segments and / or leaf line segments, any two target model points are first connected to construct the basic line segment. Furthermore, in order to obtain the effective and realistic plant growth position, when dividing, the line segment length and the horizontal inclination angle of each basic line segment are determined. The current execution end traverses each line segment length and line segment horizontal inclination angle and compares them with the preset length threshold and the preset angle threshold respectively. If the line segment length of the basic line segment is greater than the preset length threshold, and the line segment horizontal inclination angle of the basic line segment is less than the preset angle threshold, then the basic line segment is determined to be a branch and stem line segment. At the same time, if the line segment length of the basic line segment is less than or equal to the preset length threshold, and the line segment horizontal inclination angle of the basic line segment is greater than or equal to the preset angle threshold, then the basic line segment is determined to be a leaf line segment, which is not specifically limited in the embodiment of the present invention. In addition, the preset length threshold and the preset angle threshold can be configured based on the growth properties of different plants, which is not specifically limited in the embodiment of the present invention.
[0093] 205a. Construct a polygonal growth region on the scene object by using the leaf line segments, and perform point scattering processing on the polygonal growth region to obtain the point scattering surface.
[0094] In order to accurately scatter plant objects on the scene objects to achieve realistic growth of plants in the scene, when the adsorption line segment is a leaf line segment, that is, in the specific scene where the leaf object is scattered, the current execution end constructs a polygonal growth area on the scene object through the leaf line segment, and scatters point clouds in this polygonal area to obtain a scattering surface, thereby scattering points on this scattering surface to render the model of the leaf object.
[0095] In another embodiment of the present invention, for further definition and explanation, step 205a constructs a polygonal growth region on the scene object through the leaf line segments, and performs point scattering processing on the polygonal growth region to obtain the point scattering surface includes:
[0096] Generate a polygonal strip area based on the leaf line segment and the obtained leaf coverage width parameter, and adsorb the vertices of the polygonal strip area to the scene object to obtain a polygonal growth area on the scene object;
[0097] Point scattering processing is performed on the polygon growth area based on the point cloud, and the point cloud in the polygon growth area is adsorbed to the scene object to obtain the point scattering surface on the scene object.
[0098] In order to generate an effective scattering surface, so as to achieve scattering and rendering of plant objects on the scattering surface and reduce the tediousness of processing plant resources, the current execution end generates a polygonal strip area based on the leaf line segment and the obtained leaf coverage width parameter when scattering the surface. Among them, the polygonal strip area is a polygonal area constructed in space based on the leaf line segment, and the leaf coverage width parameter is used to represent the coverage range of the leaf object scattering. It can be configured based on the plant growth requirements of the game scene, so as to generate a polygonal strip area by combining the leaf coverage width parameter and the leaf line segment construction, such as Figure 6 The three-dimensional polygonal strip area shown in the figure is not specifically limited in the embodiment of the present invention. After the polygonal strip area is obtained, the polygonal strip area in the space is adsorbed to the scene object. At this time, the vertices on the polygonal strip area are moved to the points corresponding to the closest distance on the scene object, and the adsorption process is completed to obtain the polygonal growth area on the scene object, such as Figure 7 shown.
[0099] It should be noted that in order to generate a scattered point surface for rendering leaves, thereby saving the generation pressure of leaf resources, the current execution end scatters points to the polygon growth area based on the point cloud to obtain a regional surface composed of point clouds. However, since the point cloud and the scene object may not be completely aligned, the point cloud in the polygon growth area is adsorbed to the scene object again to obtain a scattered point surface on the scene object as the basis for scattering leaves, such as Figure 8 shown.
[0100] In the embodiment of the present invention, step 205b parallel to step 205a is to determine the hanging line corresponding to the branch-stem line segment, and to perform a dot-scattering process on the hanging line to obtain the dot-scattering line.
[0101] In order to accurately scatter plant objects on scene objects to achieve realistic growth of plants in the scene, when the adsorption line segment is a branch and stem line segment, that is, in the specific scene where the branch and stem objects are scattered, the current execution end determines the suspension line corresponding to the branch and stem line segment, and scatters the point cloud on this suspension line to obtain a scattering line, thereby scattering points on this scattering line to render the model of the branch and stem object.
[0102] In another embodiment of the present invention, for further definition and explanation, step 205b determines the hanging line corresponding to the branch-stem line segment, and performs a dot-scattering process on the hanging line to obtain the dot-scattering line, including:
[0103] The branch-stem line segment is converted into a suspension line based on a suspension function, and the suspension line is fitted and converted based on a spline model to obtain a parameterized suspension line;
[0104] Point scattering processing is performed on the parameterized suspension line based on the point cloud to obtain the point scattering line.
[0105] In order to generate effective dotted lines, so as to render plant objects on the dotted lines and reduce the complexity of processing plant resources, the current execution end converts the branch and stem line segments in space into hanging lines based on the hanging function when scattering the dotted lines. When converting to hanging lines, first convert the line segments in three-dimensional space into two-dimensional planes, calculate the coordinates after hanging in the two-dimensional plane based on the hanging function, and convert the coordinates after hanging into three-dimensional space to obtain hanging lines.
[0106] At this time, the drape function is x and y are the coordinates of the suspension line in the two-dimensional plane, a is the suspension parameter, and the coordinates of the two endpoints of the branch-stem segment after conversion to the two-dimensional plane are brought into the suspension function for solution. Since the suspension function is a transcendental equation and has no analytical solution, the suspension parameter of the equation is obtained numerically, the branch-stem segment is uniformly sampled, and the coordinates of the points after suspension are calculated and transformed back to three-dimensional space to obtain the suspension line.
[0107] It should be noted that after the conversion, the generated suspension line is a polygonal curve, that is, the suspension line is also formed by connecting a series of vertices in sequence, such as Fig. 9 As shown in the figure, the drape line cannot be passed into the vine model in the UE engine, so the drape line needs to be converted into a parametric curve, that is, the drape line can be fitted and converted through the spline model Spline spline to obtain a parameterized drape line. After the parameterized drape line is obtained, the parameterized drape line is scattered based on the point cloud to obtain the scattered point line.
[0108] In addition, the point scattering processing in the embodiment of the present invention can emit multiple point clouds to the hanging line or polygon growth area in a random manner. At this time, the emission direction and the number of emitted point clouds can be configured randomly or according to rendering requirements. The embodiment of the present invention does not make specific limitations.
[0109] In another embodiment of the present invention, for further definition and explanation, the step of performing fitting conversion on the suspension line based on the spline model to obtain the parameterized suspension line includes:
[0110] Convert the suspension line into a two-dimensional curve, and construct a tangent vector of the endpoint tangent of the two-dimensional curve;
[0111] Under the condition that the loss value of the iterative solution of the tangent vector is minimized, the spline sampling points determined based on the normalized distance between the tangent vector and the curve points of the spline model are fitted to obtain the suspension line.
[0112] To make the rendering of plants more realistic and reduce the pressure of resource processing, the current execution end first converts the catenary in three-dimensional space into a two-dimensional curve to construct the tangent vectors of the tangent lines at the endpoints of the two-dimensional curve. Among them, the spline model can be the Cubic Hermite Spline mathematical model in the UE engine, such as p(t)=(2t 3 -3t 2 +1)p0+(t 3 -2t 2 +t)m0+(-2t 3 +3t 2 )p1+(t 3 -t 2 )m1, t∈[0,1]. Among them, p0 and p1 are the two endpoints of the two-dimensional curve, m0 and m1 are the tangents of the two endpoints respectively. The two endpoints p0 and p1 of the two-dimensional curve are known, that is, they can be obtained through the endpoints of the stem line segment in three-dimensional space. Therefore, by solving the two tangents, that is, m0 and m1, the tangent vector can be obtained. To achieve solving the tangent vector for curve fitting, in the embodiment of the present invention, a loss function is constructed, that is, a function used to represent the fitting degree. The independent variable of the function is the two tangent vectors, and each tangent is a three-dimensional vector. To reduce the amount of calculation, the two-dimensional curve is transformed onto a two-dimensional plane to obtain a four-dimensional variable M integrating m0 and m1 as the independent variable of the loss function.
[0113] In the process of iteratively solving this tangent vector, the loss function is calculated in real time, that is, according to M (that is, the tangent vectors of the two endpoints), the normalized distance between the vector points in the tangent vector and the curve points of the spline model, that is, according to the serial number of each point divided by the total number of points as the normalized distance, that is, t(0<t<1). By substituting t into the Cubic Hermite Spline formula, the sampling value corresponding to t on the spline is obtained. At the same time, the sum of the squares of the distances from all the points on the uniformly sampled catenary to the corresponding points on the spline is calculated. The smaller the sum of the squares result is, the closer the spline is to the catenary to be fitted. Furthermore, when the four-dimensional vector M that minimizes the loss function is obtained through iterative calculation, fitting is performed based on the spline sampling points determined by the normalized distance between the tangent vector and the curve points of the spline model to obtain the parameterized catenary.
[0114] It should be noted that in each iteration, the gradient vector of the loss function is calculated to update the independent variable M so that it steps a certain distance in the opposite direction of the gradient. For example, M = M-StepSize*Grident(M); where M is the independent variable, the Grident(M) function is the gradient vector of the loss function at M, and StepSize is the step length. After multiple rounds of iterations, M will gradually tend to minimize the loss function, that is, the Spline spline can fit the incoming hanging line. Fig.10 The fitted curve shown is a spline line, and the dotted line is a parameterized suspension line.
[0115] In step 206a after step 205a, a leaf object model matching the point cloud on the dot-scattered surface is selected, and rendering is performed on the dot-scattered surface based on the leaf object model to generate a leaf object resource.
[0116] In order to achieve a realistic generation effect of leaf resources, when the current execution end generates leaf object resources, specifically, first determines the leaf object model to be rendered. The leaf object model can be a three-dimensional model of a leaf, or a three-dimensional model obtained by combining multiple single leaf three-dimensional models. It can be selected based on the needs of the plant based on the game scene, and the embodiment of the present invention does not make specific limitations. For example, a leaf object model to be scattered on the point cloud on the scattering surface is selected. At this time, the leaf object model is obtained by combining multiple single leaf object models, such as Fig.11 As shown, the leaf object model is rendered on the scattered surface to obtain the leaf object resource, such as Fig.12 Leaves shown.
[0117] In the embodiment of the present invention, step 206b parallel to step 206a selects a branch-stem object model that matches the point cloud on the point scattering line, and renders the branch-stem object model on the point scattering line to generate a branch-stem object resource.
[0118] In order to achieve a realistic generation effect of leaf resources, when the current execution end generates branch and stem object resources, specifically, it first determines the branch and stem object model to be rendered. The branch and stem object model can be a three-dimensional model of a branch and stem, or a three-dimensional model obtained by combining multiple single branch and stem three-dimensional models. It can be selected based on the needs of the plant based on the game scene, and the embodiment of the present invention does not make specific limitations. For example, a branch and stem object model to be scattered on the point cloud on the scattering line is selected. At this time, the branch and stem object model is obtained by combining multiple single branch and stem object models, such as Fig.13 The vine model shown in the figure is then rendered on the dotted line to obtain the stem object resource, such as Fig.14 The vines shown.
[0119] It should be noted that the leaf object resources and branch object resources generated in step 206a and step 206b can be generated simultaneously, or can be generated based on game development requirements, and the embodiment of the present invention does not make specific limitations.
[0120] In addition, in order to achieve the draping effect by fitting the draping line based on the Spline spline of the UE engine, a SplineMeshComponent component is configured for each spline, and the spline information is assigned to the SplineMeshComponent component through the SetStartAndEnd method. The selected branch model is assigned to the SplineMeshComponent component through the SetStaticMesh method, thereby realizing the generation of branches and stems, such as vines.
[0121] An embodiment of the present invention provides another resource generation method for plant objects. Compared with the prior art, the embodiment of the present invention generates a spiral line at a target growth position, and adsorbs the spiral line to a scene object on which the plant object is to be grown, thereby obtaining an adsorption line segment on the scene object; determines a scattering surface and / or a scattering line on which the plant object is to be grown on the scene object through the adsorption line segment; obtains a plant object model corresponding to the scattering surface and / or the scattering line, and renders the plant object model on the scattering surface and / or the scattering line to generate plant object resources, thereby greatly reducing the processing complexity of generating plant objects as resources in games, ensuring the realistic effect of plant growth in game scenes, and greatly accelerating the resource generation speed of plant objects, thereby improving the resource generation efficiency of plant objects.
[0122] Furthermore, as a response to the above Figure 1 The implementation of the method shown in the figure, the embodiment of the present invention provides a resource generation device for plant objects, such as Fig.15 As shown, the device comprises:
[0123] A processing module 31 is used to generate a spiral line at a target growth position, and adsorb the spiral line to a scene object of a plant object to be grown, so as to obtain an adsorption line segment on the scene object;
[0124] A determination module 32, configured to determine a scattering surface and / or a scattering line on the scene object where the plant object is to grow by using the adsorption line segment;
[0125] The generating module 33 is used to obtain the plant object model corresponding to the dot-scattering surface and / or the dot-scattering line, and render the plant object model on the dot-scattering surface and / or the dot-scattering line to generate a plant object resource.
[0126] Furthermore, the adsorption line segment includes a branch line segment and / or a leaf line segment.
[0127] The determination module is specifically used to construct a polygonal growth area on the scene object through the leaf line segments, and scatter points on the polygonal growth area to obtain the scatter point surface; and / or determine the suspension line corresponding to the branch and stem line segments, and scatter points on the suspension line to obtain the scatter point line.
[0128] Furthermore, the determination module is specifically used to generate a polygonal strip area based on the leaf segment and the obtained leaf coverage width parameter, and adsorb the vertices of the polygonal strip area to the scene object to obtain a polygonal growth area on the scene object; scatter points to the polygonal growth area based on the point cloud, and adsorb the point cloud in the polygonal growth area to the scene object to obtain the scattered point surface on the scene object.
[0129] Furthermore, the determination module is specifically used to convert the branch-stem line segment into a suspension line based on a drape function, and to perform fitting conversion on the suspension line based on a spline model to obtain a parameterized suspension line; and to perform point scattering processing on the parameterized suspension line based on a point cloud to obtain a point scattering line.
[0130] Furthermore, the determination module is specifically used to convert the suspension line into a two-dimensional curve and construct a tangent vector of the endpoint tangent of the two-dimensional curve; under the condition of iteratively solving the tangent vector with the minimum loss value, the spline sampling points determined based on the normalized distance between the tangent vector and the curve points of the spline model are fitted to obtain the suspension line.
[0131] Furthermore, the processing module is specifically used to determine multiple minimum distances between all spatial points on the spiral line and the model vertices of the scene object; generate initial adsorption line segments based on the target model points on the scene object corresponding to the minimum distances, and divide the initial adsorption line segments to obtain branch and stem line segments and / or leaf line segments.
[0132] Furthermore, the processing module is specifically used to construct a basic line segment based on any two of the target model points; if the line segment length of the basic line segment is greater than a preset length threshold, and the line segment horizontal inclination angle of the basic line segment is less than a preset angle threshold, then the basic line segment is determined to be the branch line segment; if the line segment length of the basic line segment is less than or equal to the preset length threshold, and the line segment horizontal inclination angle of the basic line segment is greater than or equal to the preset angle threshold, then the basic line segment is determined to be the leaf line segment.
[0133] According to another aspect of the present invention, a storage medium is provided, wherein at least one executable instruction is stored in the storage medium, and the executable instruction enables a processor to execute operations corresponding to the resource generation method of the plant object as described above.
[0134] According to another aspect of the present invention, there is provided a terminal, comprising: a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus;
[0135] The memory is used to store at least one executable instruction, and the executable instruction enables the processor to execute operations corresponding to the resource generation method of the plant object.
[0136] The present invention provides a storage medium storing at least one executable instruction, wherein the computer executable instruction can execute the resource generation method of the plant object in any of the above method embodiments.
[0137] Fig.16 A schematic diagram of the structure of a terminal provided according to an embodiment of the present invention is shown. The specific embodiment of the present invention does not limit the specific implementation of the terminal.
[0138] like Fig.16 As shown, the terminal may include: a processor (processor) 402 , a communication interface (Communications Interface) 404 , a memory (memory) 406 , and a communication bus 408 .
[0139] The processor 402 , the communication interface 404 , and the memory 406 communicate with each other via a communication bus 408 .
[0140] The communication interface 404 is used to communicate with other devices such as clients or other servers.
[0141] The processor 402 is used to execute the program 410, and specifically can execute the relevant steps in the above-mentioned plant object resource generation method embodiment.
[0142] Specifically, the program 410 may include program codes, which include computer operation instructions.
[0143] The processor 402 may be a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiment of the present invention. The one or more processors included in the terminal may be processors of the same type, such as one or more CPUs; or processors of different types, such as one or more CPUs and one or more ASICs.
[0144] The memory 406 is used to store the program 410. The memory 406 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
[0145] The program 410 may be specifically configured to enable the processor 402 to perform the following operations:
[0146] Generate a spiral line at the target growth position, and adsorb the spiral line to the scene object of the plant object to be grown to obtain an adsorption line segment on the scene object;
[0147] Determine the dot-scattering surface and / or dot-scattering line on the scene object where the plant object is to grow by using the adsorption line segment;
[0148] A plant object model corresponding to the dot-scattering surface and / or the dot-scattering line is obtained, and the plant object model is rendered on the dot-scattering surface and / or the dot-scattering line to generate a plant object resource.
[0149] Obviously, those skilled in the art should understand that the above modules or steps of the present invention can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, and optionally, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order than here, or they can be generated into individual integrated circuit modules, or multiple modules or steps therein can be generated into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.
[0150] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A resource generation method for plant objects, characterized in that: include: Generate a spiral line at the target growth position, and adsorb the spiral line to the scene object of the plant object to be grown to obtain an adsorption line segment on the scene object; Determine the dot-scattering surface and / or dot-scattering line on the scene object where the plant object is to grow by using the adsorption line segment; A plant object model corresponding to the dot-scattering surface and / or the dot-scattering line is obtained, and the plant object model is rendered on the dot-scattering surface and / or the dot-scattering line to generate a plant object resource.
2. The method according to claim 1, characterized in that The adsorption line segments include stem line segments and / or leaf line segments, and determining the scattering surface and / or scattering line of the plant object to be grown on the scene object by using the adsorption line segments includes: Constructing a polygonal growth region on the scene object through the leaf line segments, and performing point scattering processing on the polygonal growth region to obtain the point scattering surface; and / or, The hanging line corresponding to the branch-stem line segment is determined, and the hanging line is subjected to a dot-scattering process to obtain the dot-scattering line.
3. The method according to claim 2, characterized in that The step of constructing a polygonal growth region on the scene object by using the leaf line segments and performing point scattering processing on the polygonal growth region to obtain the point scattering surface comprises: Generate a polygonal strip area based on the leaf line segment and the obtained leaf coverage width parameter, and adsorb the vertices of the polygonal strip area to the scene object to obtain a polygonal growth area on the scene object; Point scattering processing is performed on the polygon growth area based on the point cloud, and the point cloud in the polygon growth area is adsorbed to the scene object to obtain the point scattering surface on the scene object.
4. The method according to claim 2, characterized in that: The step of determining the hanging line corresponding to the branch-stem line segment and performing a point-scattering process on the hanging line to obtain the point-scattering line comprises: The branch-stem line segment is converted into a suspension line based on a suspension function, and the suspension line is fitted and converted based on a spline model to obtain a parameterized suspension line; Point scattering processing is performed on the parameterized suspension line based on the point cloud to obtain the point scattering line.
5. The method according to claim 4, characterized in that The fitting conversion of the suspension line based on the spline model to obtain the parameterized suspension line includes: Convert the suspension line into a two-dimensional curve, and construct a tangent vector of the endpoint tangent of the two-dimensional curve; Under the condition that the loss value of the iterative solution of the tangent vector is minimized, the spline sampling points determined based on the normalized distance between the tangent vector and the curve points of the spline model are fitted to obtain the suspension line.
6. The method according to claim 1, characterized in that The step of performing adsorption processing on the spiral line toward the scene object of the plant object to be grown to obtain the adsorption line segment on the scene object comprises: Determine a plurality of minimum distances between all spatial points on the spiral and model vertices of the scene object; An initial adsorption line segment is generated based on the target model point corresponding to the minimum distance on the scene object, and the initial adsorption line segment is divided to obtain a branch-stem line segment and / or a leaf line segment.
7. The method according to claim 5, characterized in that The dividing of the initial adsorption line segment to obtain the branch-stem line segment and / or the leaf line segment comprises: Constructing a basic line segment based on any two of the target model points; If the line segment length of the basic line segment is greater than a preset length threshold, and the line segment horizontal inclination angle of the basic line segment is less than a preset angle threshold, then the basic line segment is determined to be the branch-stem line segment; If the line segment length of the basic line segment is less than or equal to a preset length threshold, and the line segment horizontal inclination angle of the basic line segment is greater than or equal to a preset angle threshold, the basic line segment is determined to be the leaf line segment.
8. The method according to any one of claims 1 to 7, characterized in that: Generating a spiral line at a target growth position comprises: Determining a plant growth direction based on a selected target growth position and a model direction of the scene object; In the plant growth direction, a spiral line is generated with the target growth position as the spatial center.
9. The method according to any one of claims 1 to 7, characterized in that: The obtaining of the plant object model corresponding to the dot-scattering surface and / or the dot-scattering line, and rendering the plant object model on the dot-scattering surface and / or the dot-scattering line to generate the plant object resource comprises: Selecting a leaf object model that matches the point cloud on the dot-scattered surface, and rendering on the dot-scattered surface based on the leaf object model to generate a leaf object resource; and / or, A branch-stem object model matching the point cloud on the point scattering line is selected, and rendering is performed on the point scattering line based on the branch-stem object model to generate a branch-stem object resource.
10. A plant object resource generation device, characterized in that: include: A processing module, used for generating a spiral line at a target growth position, and performing adsorption processing on the spiral line to a scene object of a plant object to be grown, so as to obtain an adsorption line segment on the scene object; A determination module, used for determining a scattering surface and / or a scattering line on the scene object where the plant object is to grow by using the adsorption line segment; The generating module is used to obtain the plant object model corresponding to the dot-scattering surface and / or the dot-scattering line, and render the plant object model on the dot-scattering surface and / or the dot-scattering line to generate the plant object resource.
11. A storage medium storing at least one executable instruction, wherein the executable instruction enables a processor to execute operations corresponding to the resource generation method of a plant object according to any one of claims 1 to 9.
12. A terminal, comprising: A processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus; The memory is used to store at least one executable instruction, and the executable instruction enables the processor to execute operations corresponding to the resource generation method of the plant object according to any one of claims 1-9.