Model processing method and device, electronic equipment and storage medium
Through programmatic skinning processing, the sub-model vertex information of the object model is obtained, bone points are determined and skin weights are assigned, which solves the problem of high cost of vegetation model development and poor interaction experience, and achieves efficient skin binding and immersion improvement.
Patent Information
- Application Number
- CN202510416650.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-03
- Publication Date
- 2025-07-25
AI Technical Summary
In the development of existing games, skinning treatment of vegetation models is difficult to simultaneously reduce development costs and improve players' gaming experience. Traditional methods lead to a lack of realism in vegetation interactions with players and a decrease in immersion.
Through programmatic skinning processing, the sub-model vertex information of the object model is obtained, bone points are determined and skin weights are assigned to realize automated skin binding and improve skin efficiency.
It reduces the cost of game development, improves the interactive experience between vegetation models and players, and enhances the immersion and vividness of the game.
Smart Images

Figure CN120374815A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of model processing, and in particular, to a model processing method, apparatus, electronic device, and storage medium. Background Art
[0002] In existing game scenes, there are usually a large number of vegetation.
[0003] In order to reduce game development costs, for a large number of vegetation, skinning processing is usually not performed, which results in a poor gaming experience for players. If skinning processing is to be performed on the vegetation, manual skinning binding is required, resulting in high game development costs.
[0004] Therefore, the existing skinning processing solutions are difficult to balance reducing game development costs and improving the gaming experience of players at the same time. Summary of the Invention
[0005] Embodiments of this application provide a model processing method, apparatus, electronic device, and storage medium, which can perform procedural skinning processing on sub-models of an object model, thereby determining the skinning weights of the model vertices of the sub-models, so as to improve the skinning efficiency of the object model, reduce development costs, and at the same time, based on the object model after skinning processing, improve the interactive experience of game players.
[0006] In a first aspect, embodiments of this application provide a model processing method, the method includes:
[0007] Obtain an object model, where the object model includes a plurality of sub-models;
[0008] For each of the sub-models, obtain the vertex information of the model vertices included in the sub-model;
[0009] Based on the vertex information of the sub-model, determine a plurality of bone points of the sub-model, where the shape formed by connecting the bone points matches the shape of the sub-model;
[0010] From the plurality of bone points, determine a plurality of skinning bone points corresponding to the model vertices in the sub-model;
[0011] Based on the distances between the plurality of skinning bone points and the corresponding model vertices, determine the skinning weights of the skinning bone points for the model vertices;
[0012] According to the skinning weights of the model vertices of each sub-model, obtain the skinning result of the object model.
[0013] In a second aspect, embodiments of this application provide a model processing apparatus, including:
[0014] A model acquisition module, configured to acquire an object model, where the object model includes a plurality of sub-models;
[0015] An information acquisition module, configured to, for each of the sub-models, acquire vertex information of the model vertices included in the sub-model;
[0016] A bone point determination module, configured to determine a plurality of bone points of the sub-model based on the vertex information of the sub-model, where the shape formed by connecting the bone points matches the shape of the sub-model;
[0017] A skinning bone point determination module, configured to determine, from the plurality of bone points, a plurality of skinning bone points corresponding to each of the model vertices in the sub-model;
[0018] A weight determination module, configured to determine the skinning weight of the skinning bone point for the model vertex based on the distances between the plurality of skinning bone points and the corresponding model vertices;
[0019] A skinning module, configured to obtain a skinning result of the object model according to the skinning weights of the model vertices of each of the sub-models.
[0020] In a third aspect, an embodiment of the present application further provides an electronic device, which includes a processor and a memory, where the memory stores a computer program, and when the computer program is executed by the processor, the processor is caused to execute the steps of any of the model processing methods.
[0021] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, which includes a processor and a memory, where the memory stores a computer program, and when the computer program is executed by the processor, the processor is caused to execute the steps of any of the model processing methods.
[0022] In a fifth aspect, an embodiment of the present application further provides a computer program product, including a computer program, where the computer program is stored in a computer-readable storage medium; when a processor of an electronic device reads the computer program from the computer-readable storage medium, the processor executes the computer program, so that the electronic device executes the steps of any of the model processing methods provided in the embodiments of the present application.
[0023] By adopting the solution of the embodiment of the present application, an object model can be obtained, where the object model includes several sub-models. For each sub-model, the vertex information of the model vertices included in the sub-model is obtained; based on the vertex information of the sub-model, a plurality of skeleton points of the sub-model are determined, where the shape formed by connecting the skeleton points matches the shape of the sub-model; from the plurality of skeleton points, several skinning skeleton points corresponding to the model vertices in the sub-model are determined; based on the distances between the several skinning skeleton points and the corresponding model vertices, the skinning weights of the skinning skeleton points for the model vertices are determined, and according to the skinning weights of the model vertices of each sub-model, the skinning result of the object model is obtained. Based on this, programmed skinning processing is performed on the sub-models of the object model, so as to determine the skinning weights of the model vertices of the sub-models, thereby improving the skinning efficiency of the object model, reducing the development cost, and at the same time improving the interaction experience of game players based on the skinned object model. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the following drawings are only some embodiments of the present application. For those skilled in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0025] Figure 1 It is a schematic diagram of an implementation environment scenario of the model processing method provided in the embodiment of the present application;
[0026] Figure 2 It is a schematic diagram of an embodiment process of the model processing method provided in the embodiment of the present application;
[0027] Figure 3 It is a schematic diagram of an object model provided in the embodiment of the present application;
[0028] Figure 4 It is a schematic diagram of a sub-model provided in the embodiment of the present application;
[0029] Figure 5 It is a schematic diagram of a first model vertex provided in the embodiment of the present application;
[0030] Figure 6 It is a schematic diagram of a target line segment provided in the embodiment of the present application;
[0031] Figure 7 It is a schematic diagram of a backbone skeleton point provided in the embodiment of the present application;
[0032] Figure 8 It is a schematic diagram of the tangent direction vector of the backbone skeleton point provided in the embodiment of the present application;
[0033] Figure 9It is a schematic diagram of the target direction vector provided in the embodiment of the present application;
[0034] Figure 10 It is a schematic diagram of the target plane provided in the embodiment of the present application;
[0035] Figure 11 It is a schematic diagram of the projection point provided in the embodiment of the present application;
[0036] Figure 12 It is a schematic diagram of the bone system of an object model including multiple sub-models provided in the embodiment of the present application;
[0037] Figure 13 It is a schematic diagram of the structure of the model processing device provided in the embodiment of the present application;
[0038] Figure 14 It is a schematic diagram of the structure of the electronic device provided in the embodiment of the present application. Detailed implementation manners
[0039] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without creative efforts belong to the scope of protection of the present application. At the same time, in the description of the embodiments of the present application, terms such as "first" and "second" are only used for distinguishing descriptions and cannot be understood as indicating or implying relative importance. Thus, the features defined with "first" and "second" may explicitly or implicitly include one or more features. In the description of the embodiments of the present application, the meaning of "a plurality" is two or more, unless otherwise clearly and specifically defined.
[0040] After research, it is found that during the current game development process, there are usually a large number of vegetation elements (such as leaf elements) in a single game scene. In order to reduce the game development cost, in most games, the vegetation elements are usually not skinned and bound. However, the above approach will result in the inability of the vegetation to have a real interaction effect with the player, and the immersion and interaction experienced by the player in the game will significantly decrease. The lack of realism in the interaction between the vegetation and the player makes the overall game experience less vivid, especially in game types that require a high level of immersion, such a processing method is particularly insufficient.
[0041] However, if it is necessary to skin and bind the vegetation elements in the game scene, usually manual operation is used to skin and bind each vegetation element. This will cause the development cost to increase exponentially.
[0042] Therefore, the existing skinning processing solutions are difficult to balance reducing the game development cost and improving the player's game experience at the same time.
[0043] To this end, to solve the above problems, the embodiments of the present application provide a model processing method, apparatus, electronic device, and computer-readable storage medium. Among them, the model processing apparatus can be integrated in the electronic device, and the electronic device can be a server or a terminal device, etc.
[0044] Among them, the server can be an independent physical server, a server cluster or a distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, network acceleration services (Content Delivery Network, CDN), and big data and artificial intelligence platforms. The terminal can include, but is not limited to, mobile phones, computers, intelligent voice interaction devices, smart home appliances, vehicle terminals, aircraft, etc. The terminal and the server can be directly or indirectly connected through wired or wireless communication methods, and the present application does not make any restrictions here.
[0045] Please refer to Figure 1 , taking the model processing apparatus integrated in the electronic device as an example, Figure 1 is a schematic diagram of the implementation scenario of the model processing method provided by the embodiments of the present application. Among them, the electronic device can be a terminal device. By obtaining an object model, where the object model includes several sub-models, for each sub-model, obtain the vertex information of the model vertices included in the sub-model; based on the vertex information of the sub-model, determine multiple skeleton points of the sub-model, where the shape formed by connecting the skeleton points matches the shape of the sub-model; from the multiple skeleton points, determine several skinning skeleton points corresponding to the model vertices in the sub-model; based on the distances between the several skinning skeleton points and the corresponding model vertices, determine the skinning weights of the skinning skeleton points for the model vertices; according to the skinning weights of the model vertices of each sub-model, obtain the skinning result of the object model. Based on this, perform procedural skinning processing on the sub-models of the object model, thereby determining the skinning weights of the model vertices of the sub-models, so as to improve the skinning efficiency of the object model, reduce the development cost, and at the same time, based on the skinned object model, improve the interaction experience of game players.
[0046] It should be noted that Figure 1 the schematic diagram of the implementation environment scenario of the model processing method shown is only an example. The implementation environment scenario of the model processing method described in the embodiments of the present application is for more clearly explaining the technical solutions of the embodiments of the present application, and does not constitute a limitation to the technical solutions provided by the embodiments of the present application. Those of ordinary skill in the art know that with the evolution of data processing and the emergence of new business scenarios, the technical solutions provided by the present application are equally applicable to similar technical problems.
[0047] The solution provided by the embodiment of the present application will be specifically described through the following embodiments. It should be noted that the description order of the following embodiments does not limit the preferred order of the embodiments.
[0048] This embodiment will be described from the perspective of a model processing device, which can be specifically integrated in an electronic device. The electronic device can be a terminal and / or a server, and the present application does not limit this here.
[0049] Please refer to Figure 2 , Figure 2 which is the model processing method provided by the embodiment of the present application. The specific process of the model processing method can be as follows in steps 101 to 106, where:
[0050] Step 101: Obtain an object model, where the object model includes several sub-models.
[0051] Among them, the object model refers to a model of a virtual object that simulates certain elements in the game screen in a virtual space. The virtual space is a three-dimensional coordinate system used to represent and operate three-dimensional objects. The virtual object can be a plant, an animal, etc., and can be specifically adjusted according to the actual situation. For example, the object model refers to a plant model such as a flower, a tree, or grass in the virtual space. Another example, the object model refers to an animal model such as a bird or a chicken in the virtual space. The following embodiments will be explained by taking the plant model as an example.
[0052] The sub-model refers to the model on the object model that needs to be skinned and bound. The sub-model is adjusted according to the object model. For example, when the object model is a plant model, the sub-model can be the leaf model on the plant model. Another example, when the object model is an animal model, the sub-model can be the feather model on the animal model.
[0053] It should be noted that the number of sub-models included in the object model can be one or more. Multiple sub-models perform the following same operations to achieve skinning and binding. That is, through the model processing method provided by the embodiment of the present application, multiple sub-models on the object model can be skinned and bound in batches and automatically, so as to improve the skinning efficiency of the object model and reduce the development cost.
[0054] Step 102: For each sub-model, obtain the vertex information of the model vertices included in the sub-model.
[0055] Among them, the model vertex refers to the basic unit that constitutes the geometric shape matching the sub-model. Model vertices are connected to form edges, and the edges form faces, and these faces together constitute the geometric shape of the sub-model.
[0056] Among them, the vertex information is used to indicate the relevant information of the model vertices. The specific content of the vertex information can be adjusted according to the actual situation, and the embodiments of the present application do not make any restrictions. For example, the vertex information includes the coordinates of the model vertices, the height information of the model vertices, the normal vectors of the model vertices, the position vectors of the model vertices, etc.
[0057] Exemplarily, please refer to Figure 3 , Figure 3 which is a schematic diagram of the object model provided by the embodiments of the present application. As Figure 3 shown, the object model is a plant model, and the plant model includes a plurality of leaf models as Figure 4 shown. Each leaf model is the sub-model mentioned in the embodiments of the present application. As Figure 3 shown, the position where the blue dots are located is the model vertex mentioned in the present application.
[0058] Step 103: Based on the vertex information of the sub-model, determine a plurality of skeleton points of the sub-model, where the shape formed by connecting the skeleton points matches the shape of the sub-model.
[0059] Among them, the skeleton point refers to a key element used to control the deformation and / or animation of the sub-model.
[0060] The shape formed by connecting the skeleton points matches the shape of the sub-model. For example, when the sub-model is a leaf model, the shape formed by connecting the skeleton points is the shape of a leaf. Another example is that when the sub-model is a feather model, the shape formed by connecting the skeleton points is the shape of a feather. The specific situation can be adjusted according to the actual situation, and the embodiments of the present application do not make any restrictions.
[0061] The number of skeleton points can be adjusted according to the actual situation, and the embodiments of the present application do not make any restrictions. For example, the number of skeleton points is 7. Another example is that the number of skeleton points is 10.
[0062] The skeleton points can be skeleton points with multiple tree-like hierarchical relationships, where the hierarchical relationship can be adjusted according to the actual situation. For example, the number of layers of the tree-like hierarchical relationship can be 2, and another example is that the number of layers of the tree-like hierarchical relationship can be 3.
[0063] In some embodiments, the above-mentioned plurality of skeleton points include main trunk skeleton points and secondary skeleton points.
[0064] Specifically, a plurality of main trunk skeleton points constitute the main trunk skeleton of the sub-model. The main trunk skeleton is the core structure of the sub-model and is used to support and drive the main movements of the sub-model.
[0065] A plurality of secondary skeleton points constitute the secondary skeleton of the sub-module. The secondary skeleton branches out from the main trunk skeleton and is used to refine and enhance the animation effect of the sub-model.
[0066] Based on this, the process of determining multiple bone points of the sub-model based on the vertex information of the sub-model may include: determining multiple main bone points on the sub-model based on the vertex information of the sub-model; determining secondary bone points corresponding to the main bone points based on the vertex information of the sub-model and the main bone points.
[0067] Among them, there are various ways to determine the main bone points, and the embodiments of the present application do not limit them.
[0068] In some embodiments, it is also possible to determine the main axis or midrib of the sub-model by obtaining the shape of the sub-model, and determine multiple main bone points of the sub-model from the model vertices where the main axis or midrib exists.
[0069] In some embodiments, it is possible to obtain the outer contour edge segments of the sub-model, where the model vertices included in the outer contour edge segments are outer contour vertices; obtain the first model vertices among the model vertices of the sub-model that are outside the outer contour vertices; and determine multiple main bone points of the sub-model based on the first model vertices.
[0070] Among them, the outer contour edge segments are the line segments corresponding to each side on the outer contour of the sub-model. The outer contour vertices are the model vertices corresponding to each side on the outer contour among the model vertices of the sub-model.
[0071] There are various ways to obtain the outer contour edge segments, and the embodiments of the present application do not limit them.
[0072] For example, perform contour recognition on the sub-model, and determine the outer contour edge segments according to the recognition result. Another example is to traverse each face of the sub-model, extract each edge that constitutes the face, where edge AB and edge BA are regarded as the same edge, and edge AB and edge BA are only for generality. Count the number of times each edge appears. Extract all edges that appear only once to obtain the outer contour edge segments.
[0073] The first model vertices refer to the other vertices among the model vertices of the sub-model except the outer contour vertices.
[0074] Specifically, extract the outer contour edge segments of the sub-model and determine the outer contour vertices of the sub-model. Determine multiple first model vertices based on the outer contour vertices of the sub-model and the model vertices of the sub-model. Determine multiple main bone points of the sub-model based on the first model vertices.
[0075] Among them, there are various ways to determine multiple main bone points of the sub-model based on the first model vertices.
[0076] Exemplarily, the second number of backbone skeleton points in the sub-model can be directly determined from the first number of first-model vertices, where the first number is not less than the second number. For example, the number of first-model vertices is 10 and the number of backbone skeleton points is 5. Another example is that the number of first-model vertices is 10 and the number of backbone skeleton points is 10.
[0077] Exemplarily, the first-model vertices can also be sorted according to the distance between the first-model vertices and a reference point; the sorted first-model vertices are connected into a target line segment; vertex sampling is performed on the target line segment to obtain multiple backbone skeleton points of the sub-model.
[0078] Among them, the reference point can be determined according to the actual situation. For example, the reference point is the origin in the world coordinate system where the object model is located. Another example is that the reference point is the origin in the world coordinate system where the sub-model is located. Another example is that the reference point is the root vertex among the first-model vertices.
[0079] Among them, the target line segment refers to a line segment formed by connecting multiple first-model vertices in sequence.
[0080] Among them, the rules of vertex sampling can be adjusted according to the actual situation, and the embodiments of the present application do not limit it. For example, according to the sampling quantity set manually or by empirical values, random vertex sampling is performed on the target line segment to obtain the backbone skeleton points of the sub-model that meet the sampling quantity. Another example is to obtain the length of the target line segment, obtain the sampling quantity of vertices, and select the backbone skeleton points from multiple first-model vertices according to the ratio between the length and the sampling quantity. For example, if the length is 10 and the sampling quantity is 5, the backbone skeleton points are the 0th point, 2nd point, 4th point, 6th point, and 8th point among the multiple first-model vertices arranged in sequence.
[0081] Exemplarily, please refer to Figure 4 , Figure 4 is a schematic diagram of the sub-model provided by the embodiments of the present application, and this sub-model is a blade model. For any blade model on the plant model shown in Figure 3 , each face of the blade model is traversed, and each edge constituting the face is extracted, where edge AB and edge BA are regarded as the same edge, and edge AB and edge BA are only for generality. The number of times each edge appears is counted. All edges that appear only once are extracted to obtain the outer contour edge line segments of the blade. Among them, the essence of the outer contour line segment is the edge that is shared by only one face constituting the sub-model, while the internal edges constituting the sub-model will be shared by two faces. All line segments on the sub-model are deleted, and all model vertices are retained; all model vertices (i.e., outer contour vertices) on the sub-model on the outer contour edge line segments are deleted, so as to obtain as shown in Figure 4 and Figure 5The apex of the main vein of the leaf shown in blue (i.e., the first model vertex). For the apex of the main vein of the leaf, sort the vertex according to the distance from the reference point (such as the origin of the world coordinates {0, 0, 0} where the sub-model is located). That is, the apex of the main vein closest to the reference point is point 0, and they are sorted in order according to the distance, and the sorted main vein vertices are connected to form a target line segment as shown in Figure 6 Resample the target line segment. For example, resample the target line segment to obtain 4 backbone skeleton points as shown in Figure 7 .
[0082] In some embodiments, the backbone skeleton points include a root skeleton point, intermediate skeleton points, and a top skeleton point.
[0083] Among them, the root skeleton point refers to the backbone skeleton point where the root of the backbone skeleton of the sub-model is located. The top skeleton point refers to the backbone skeleton point where the top of the backbone skeleton of the sub-model is located. The intermediate skeleton points refer to the other backbone skeleton points of the backbone skeleton of the sub-model except for the root and the top.
[0084] Among them, the number of intermediate skeleton points can be one or more. It is specifically determined according to the number of backbone skeleton points.
[0085] Based on this, the process of determining the secondary skeleton points corresponding to the backbone skeleton points based on the vertex information of the sub-model and the backbone skeleton points can include: constructing a target plane according to the root skeleton point and the target direction vector; projecting each outer contour vertex onto the target plane to obtain the projection points of each outer contour vertex; for each intermediate skeleton point, calculate the target distance between the intermediate skeleton point and the projection points of the outer contour vertices on both sides of the intermediate skeleton point; based on the target distance, select the secondary skeleton points of the intermediate skeleton point from the outer contour vertices on both sides respectively.
[0086] Among them, the target direction vector refers to the direction vector for constructing the target plane. The target plane refers to the projection space of each outer contour vertex. The projection point refers to the projection position of the outer contour vertex on the target plane.
[0087] Among them, there are various ways to determine the target direction vector, and the embodiments of the present application do not limit it.
[0088] For example, the target direction vector can be determined according to a custom direction vector.
[0089] For another example, the tangent direction vector of the backbone skeleton point can be determined according to the position difference between the backbone skeleton point and the adjacent backbone skeleton point; zero out the first vector component in the tangent direction vector, and swap the second vector component and the third vector component in the tangent direction vector to obtain the target direction vector.
[0090] Among them, the first vector component, the second vector component, and the third vector component constitute three vector components in the tangential direction vector.
[0091] Specifically, for each backbone bone point, calculate the position difference between the current backbone bone point and the adjacent backbone bone point to obtain the Figure 8 tangent direction vector of the backbone bone point as shown. Zero the Y vector component (i.e., the first vector component) in the tangent direction vector, and swap the X vector component (i.e., the second vector component) and the Z vector component (i.e., the third vector component) in the tangent direction vector to obtain the Figure 9 target direction vector as shown, which is also the forking direction of the secondary bone of the sub-model.
[0092] There are various ways to project each outer contour vertex onto the target plane, and the embodiments of the present application do not limit this.
[0093] For example, perform orthogonal projection or perspective projection on each outer contour vertex to project each outer contour vertex onto the target plane to obtain the projection points of each outer contour vertex.
[0094] For another example, according to the position difference between the root bone point and the outer contour vertex, determine the projection vector corresponding to the outer contour vertex; determine the projection value of the projection vector projected onto the tangent direction vector of the root bone point; offset the outer contour vertex onto the target plane according to the projection value to obtain the projection point of the outer contour vertex.
[0095] Among them, the projection point of the outer contour vertex refers to the point where the outer contour vertex is offset onto the target plane and intersects with the target plane.
[0096] Specifically, loop through the outer contour vertices, subtract the position of the root bone in the backbone bone from the vertex position of the current outer contour vertex to obtain the projection vector from the root bone point to the current outer contour vertex. Project this projection vector onto the tangent direction vector of the root bone point to obtain the projection value corresponding to the current outer contour vertex. Offset the position of the current outer contour vertex according to this projection value to move this outer contour vertex onto the target plane. Based on this, each outer contour vertex converges onto the target plane.
[0097] Among them, the target distance refers to the distance between an intermediate bone point and an outer contour vertex.
[0098] Based on the target distance, there are various ways to select the secondary bone points of the intermediate bone point from the outer contour vertices on both sides, and the embodiments of the present application do not limit this.
[0099] For example, for the outer contour vertices on each side, use the outer contour vertex with the smallest target distance on that side as the secondary bone point of the intermediate bone point on that side.
[0100] For another example, for the outer contour vertices on each side, the outer contour vertices on that side whose target distance is close to the preset distance threshold are used as the secondary bone points of the intermediate bone points on that side.
[0101] Exemplarily, please refer to Figure 10 , Figure 10 where the yellow line in is the visualization of the target plane. Figure 10 The blue dots in are the outer contour vertices. Loop through each outer contour vertex, subtract the position of the current outer contour vertex from the position of the root bone point of the main bone to obtain a vector from the root bone to the current outer contour vertex. Project this vector onto the tangent direction vector of the root bone to obtain the projection value of the current outer contour vertex. Subtract the projection value from the position of the current outer contour vertex, and all points can be converged onto the target plane to obtain the projection points of each outer contour vertex as shown in Figure 11 . When the subtraction of the position of the outer contour vertex and the projection value is greater than 0, mark the outer contour vertex as @_onleft. Loop through each intermediate bone point in the main bone. Query the outer contour vertices marked as @_onleft with the position of the current intermediate bone point to obtain the identifier of the outer contour vertex closest to the current intermediate bone point. Query the outer contour vertices not marked as @_onleft with the position of the current intermediate bone point to obtain the identifier of the outer contour vertex closest to the current intermediate bone point. Obtain the vertex positions of the corresponding outer contour vertices according to the identifiers of the above two outer contour vertices. Generate new vertices based on the vertex positions, and connect the generated new vertices to the intermediate bone point to form the secondary bone as shown in Figure 12 .
[0102] Step 104: Determine several skinning bone points corresponding to the model vertices in the sub-model from multiple bone points.
[0103] Among them, the skinning bone points can assign the influence weights of one or more bone points to the model vertices of the sub-model, so as to correctly deform the model when the bone moves.
[0104] Specifically, one model vertex corresponds to several skinning bone points. The number of skinning bone points can be adjusted according to the actual situation, and the embodiments of the present application do not make any restrictions. For example, one model vertex corresponds to 4 skinning bone points. For another example, one model vertex corresponds to 5 skinning bone points.
[0105] The number of skinning bone points is less than the number of bone points of the sub-model.
[0106] There are various ways to determine the skinning bone points, and the embodiments of the present application do not make any restrictions.
[0107] For example, according to the predetermined number of skinning bone points, several skinning bone points corresponding to the model vertices in the sub-model can be randomly determined from multiple bone points.
[0108] For another example, according to the predetermined number of skinning bone points, several skinning bone points corresponding to the model vertices in the sub-model can be determined based on the distance magnitude relationship between the skinning bone points and the corresponding model vertices.
[0109] Among them, the distance magnitude relationship includes the distance from small to large or the distance from large to small.
[0110] Step 105: Determine the skinning weight of the skinning bone points for the model vertices based on the distances between several skinning bone points and the corresponding model vertices.
[0111] Exemplarily, loop through each model vertex on the sub-model. At the position of the current vertex, obtain the identifiers of the 4 bone points closest to it. At this time, these 4 bone points are the skinning bone points mentioned in the embodiments of the present application. According to the identifiers of these 4 skinning bone points, obtain the corresponding positions of the skinning bone points, and calculate the distance between each skinning bone point and the model vertex. Set the bone weight value of the skinning bone point within the range of 0 to 1 through 1 / distance. For the 4 skinning bone points of a model vertex, make the sum of the weight values of all skinning bone points equal to 1 by dividing the current weight value by the total weight value. Based on this, the skinning calculation of the sub-model is completed.
[0112] In some embodiments, the object model includes multiple sub-models. For each sub-model, the steps in the above embodiments can be executed. Such as obtaining the vertex information of the model vertices included in the sub-model; based on the vertex information of the sub-model, determining multiple bone points of the sub-model, and the shape formed by connecting the bone points matches the shape of the sub-model; determining several skinning bone points corresponding to the model vertices in the sub-model from multiple bone points; and determining the skinning weight of the skinning bone points for the model vertices based on the distances between several skinning bone points and the corresponding model vertices.
[0113] Exemplarily, as Figure 3 shown, the plant model includes multiple leaf models. For each leaf model, model processing can be performed to determine several skinning bone points corresponding to the model vertices in the sub-model and the skinning weight of the skinning bone points for the model vertices. After all leaf models of the plant model are processed, a bone schematic diagram of the plant model as shown in Figure 12 can be obtained. Compared with the traditional offline production solution, the present application quickly and efficiently completes the bone binding and weight assignment of the sub-models of the object model through a programmed and automated method, solving problems such as high cost and poor effect in the traditional skinning binding process.
[0114] Step 106: Obtain the skinning result of the object model according to the skinning weights of the model vertices of each sub-model.
[0115] The skinning result refers to the result obtained after skinning binding with the object model. The skinning result includes the skinning weights of the model vertices of several sub-models included in the object model.
[0116] By adopting the solution of the embodiment of the present application, an object model can be obtained. The object model includes several sub-models. For each sub-model, obtain the vertex information of the model vertices included in the sub-model; based on the vertex information of the sub-model, determine multiple bone points of the sub-model, where the shape formed by connecting the bone points matches the shape of the sub-model; from the multiple bone points, determine several skinning bone points corresponding to the model vertices in the sub-model; based on the distances between the several skinning bone points and the corresponding model vertices, determine the skinning weights of the skinning bone points for the model vertices; obtain the skinning result of the object model according to the skinning weights of the model vertices of each sub-model. Based on this, perform procedural skinning processing on the sub-models of the object model, thereby determining the skinning weights of the model vertices of the sub-models, improving the skinning efficiency of the object model, reducing the development cost, and at the same time improving the interaction experience of game players based on the skinned object model.
[0117] This embodiment also provides a model processing device, which can be specifically integrated in a terminal device.
[0118] For example, as Figure 13 shown, the model processing device may include:
[0119] A model acquisition module 201, configured to acquire an object model, where the object model includes several sub-models;
[0120] An information acquisition module 202, configured to, for each sub-model, acquire the vertex information of the model vertices included in the sub-model;
[0121] A bone point determination module 203, configured to determine multiple bone points of the sub-model based on the vertex information of the sub-model, where the shape formed by connecting the bone points matches the shape of the sub-model;
[0122] A skinning bone point determination module 204, configured to determine several skinning bone points corresponding to each model vertex in the sub-model from the multiple bone points;
[0123] A weight determination module 205, configured to determine the skinning weights of the skinning bone points for the model vertices based on the distances between the several skinning bone points and the corresponding model vertices;
[0124] A skinning module 206, configured to obtain the skinning result of the object model according to the skinning weights of the model vertices of each sub-model.
[0125] In some embodiments, the multiple skeletal points described above include trunk skeletal points and secondary skeletal points.
[0126] Based on this, the skeletal point determination module 203 described above includes:
[0127] A trunk skeletal point determination sub-module, configured to determine multiple trunk skeletal points on the sub-model based on the vertex information of the sub-model;
[0128] A secondary skeletal point determination sub-module, configured to determine secondary skeletal points corresponding to the trunk skeletal points based on the vertex information of the sub-model and the trunk skeletal points.
[0129] In some embodiments, the trunk skeletal point determination sub-module described above includes:
[0130] A line segment acquisition unit, configured to acquire the outer contour edge line segments of the sub-model, where the model vertices included in the outer contour edge line segments are outer contour vertices;
[0131] A first model vertex acquisition unit, configured to acquire first model vertices other than the outer contour vertices among the model vertices of the sub-model;
[0132] A trunk skeletal point determination unit, configured to determine multiple trunk skeletal points of the sub-model based on the first model vertices.
[0133] In some embodiments, the trunk skeletal point determination unit described above includes:
[0134] A sorting sub-unit, configured to sort the first model vertices according to the distance between the first model vertices and a reference point;
[0135] A line segment linking sub-unit, configured to connect the sorted first model vertices into target line segments;
[0136] A sampling sub-unit, configured to perform vertex sampling on the target line segments to obtain multiple trunk skeletal points of the sub-model.
[0137] In some embodiments, the trunk skeletal points described above include a root skeletal point, intermediate skeletal points, and a top skeletal point.
[0138] Based on this, the secondary skeletal point determination sub-module described above includes:
[0139] A plane construction unit, configured to construct a target plane according to the root skeletal point and a target direction vector;
[0140] A projection unit, configured to project each outer contour vertex onto the target plane to obtain projection points of each outer contour vertex;
[0141] A distance calculation unit, configured to calculate, for each intermediate bone point, a target distance between the intermediate bone point and the projection points of the outer contour vertices on both sides of the intermediate bone point;
[0142] A secondary bone point determination unit, configured to respectively select the secondary bone points of the intermediate bone point from the outer contour vertices on both sides based on the target distance.
[0143] In some embodiments, before the above-mentioned plane construction unit, the model processing device further includes:
[0144] A first vector determination unit, configured to determine the tangent direction vector of the main bone point according to the position difference between the main bone point and the adjacent main bone point;
[0145] A second vector determination unit, configured to zero the first vector component in the tangent direction vector, and swap the second vector component and the third vector component in the tangent direction vector to obtain the target direction vector.
[0146] In some embodiments, the above-mentioned projection unit includes:
[0147] A vector determination sub-unit, configured to determine the projection vector corresponding to the outer contour vertex according to the position difference between the root bone point and the outer contour vertex;
[0148] A projection value determination sub-unit, configured to determine the projection value of the projection vector projected onto the tangent direction vector of the root bone point;
[0149] An offset sub-unit, configured to offset the outer contour vertex to the target plane according to the projection value to obtain the projection point of the outer contour vertex.
[0150] By adopting the solution of the embodiment of the present application, an object model can be obtained through the model acquisition module 201, where the object model includes several sub-models; the information acquisition module 202 acquires the vertex information of the model vertices included in the sub-model for the sub-model in the object model; the bone point determination module 203 determines multiple bone points of the sub-model based on the vertex information of the sub-model, and the shape formed by connecting the bone points matches the shape of the sub-model; the skinning bone point determination module 204 determines several skinning bone points corresponding to the model vertices in the sub-model from the multiple bone points; the weight determination module 205 determines the skinning weight of the skinning bone point for the model vertex based on the distance between the several skinning bone points and the corresponding model vertex; the skinning module 206 obtains the skinning result of the object model according to the skinning weight of the model vertices of each sub-model. Based on this, programmed skinning processing is performed on the sub-model of the object model, so as to determine the skinning weight of the model vertices of the sub-model, improve the skinning efficiency of the object model, reduce the development cost, and at the same time improve the interaction experience of game players based on the skinned object model.
[0151] Correspondingly, an embodiment of the present application further provides an electronic device, which may be a terminal. The terminal may be a terminal device such as a smart phone, a tablet computer, a notebook computer, a touch screen, a game console, a personal computer (PC), a personal digital assistant (PDA), etc. Alternatively, the electronic device may be a server.
[0152] As Figure 14 shown, Figure 14 is a schematic structural diagram of the electronic device provided by the embodiment of the present application. The electronic device 300 includes a processor 301 having one or more processing cores, a memory 302 having one or more computer-readable storage media, and a computer program stored on the memory 302 and executable on the processor. Among them, the processor 301 is electrically connected to the memory 302. Those skilled in the art can understand that the structure of the electronic device shown in the figure does not constitute a limitation on the electronic device, and may include more or fewer components than shown, or combine certain components, or different component arrangements.
[0153] The processor 301 is the control center of the electronic device 300, connects various parts of the entire electronic device 300 through various interfaces and lines, and executes various functions and processes data of the electronic device 300 by running or loading software programs and / or units stored in the memory 302, and calling data stored in the memory 302, so as to monitor the electronic device 300 as a whole. The processor 301 may be a central processing unit CPU, a graphics processing unit GPU, a network processor (NP), etc., and may implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of the present application.
[0154] In the embodiment of the present application, the processor 301 in the electronic device 300 will load the instructions corresponding to the processes of one or more application programs into the memory 302 according to the following steps, and the processor 301 will run the application programs stored in the memory 302 to implement various functions, such as:
[0155] Obtain an object model, where the object model includes several sub-models;
[0156] For each sub-model, obtain the vertex information of the model vertices included in the sub-model;
[0157] Based on the vertex information of the sub-model, determine multiple skeleton points of the sub-model, where the shape formed by connecting the skeleton points matches the shape of the sub-model;
[0158] Determine a number of skinning bone points corresponding to the model vertices in the sub-model from multiple bone points;
[0159] Determine the skinning weight of the skinning bone points for the model vertices based on the distances between the number of skinning bone points and the corresponding model vertices;
[0160] Obtain the skinning result of the object model according to the skinning weights of the model vertices of each sub-model.
[0161] By using the electronic device provided in the embodiments of the present application, an object model can be obtained, where the object model includes several sub-models; for each sub-model, obtain the vertex information of the model vertices included in the sub-model; based on the vertex information of the sub-model, determine multiple bone points of the sub-model, where the shape formed by connecting the bone points matches the shape of the sub-model; determine a number of skinning bone points corresponding to the model vertices in the sub-model from the multiple bone points; determine the skinning weight of the skinning bone points for the model vertices based on the distances between the number of skinning bone points and the corresponding model vertices; obtain the skinning result of the object model according to the skinning weights of the model vertices of each sub-model. Based on this, perform programmatic skinning processing on the sub-models of the object model, so as to determine the skinning weights of the model vertices of the sub-models, improve the skinning efficiency of the object model, reduce the development cost, and at the same time improve the interaction experience of game players based on the skinned object model.
[0162] For the specific implementation of each of the above operations, reference may be made to the previous embodiments, and details are not described herein again.
[0163] Optionally, as Figure 14 shown, the electronic device 300 further includes: a touch display screen 303, a radio frequency circuit 304, an audio circuit 305, an input unit 306, and a power supply 307. Among them, the processor 301 is electrically connected to the touch display screen 303, the radio frequency circuit 304, the audio circuit 305, the input unit 306, and the power supply 307 respectively. Those skilled in the art can understand that Figure 14 the structure of the electronic device shown in
[0164] The touch display screen 303 can be used to display a graphical user interface and receive operation instructions generated by a user acting on the graphical user interface. The touch display screen 303 may include a display panel and a touch panel. Among them, the display panel can be used to display information input by the user or information provided to the user, as well as various graphical user interfaces of the electronic device. These graphical user interfaces can be composed of graphics, text, icons, videos, and any combination thereof. Optionally, the display panel can be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), or the like. The touch panel can be used to collect touch operations of the user on or near it (such as operations of the user using a finger, a stylus, or any suitable object or accessory on or near the touch panel), and generate corresponding operation instructions, and the operation instructions execute the corresponding program. Optionally, the touch panel can include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the touch orientation of the user, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into contact coordinates, and then sends it to the processor 301, and can receive and execute the commands sent by the processor 301. The touch panel can cover the display panel. When the touch panel detects a touch operation on or near it, it is transmitted to the processor 301 to determine the type of touch event. Subsequently, the processor 301 provides a corresponding visual output on the display panel according to the type of touch event. In the embodiments of the present application, the touch panel and the display panel can be integrated into the touch display screen 303 to implement input and output functions. However, in some embodiments, the touch panel and the touch panel can be implemented as two independent components to implement input and output functions. That is, the touch display screen 303 can also be used as a part of the input unit 306 to implement the input function.
[0165] The radio frequency circuit 304 can be used to transmit and receive radio frequency signals to establish wireless communication with a network device or other electronic devices through wireless communication, and transmit and receive signals with the network device or other electronic devices.
[0166] The audio circuit 305 can be used to provide an audio interface between the user and the electronic device through a speaker and a microphone. The audio circuit 305 can transmit the electrical signal converted from the received audio data to the speaker, and the speaker converts it into a sound signal for output; on the other hand, the microphone converts the collected sound signal into an electrical signal, which is received by the audio circuit 305 and then converted into audio data. After the audio data is output to the processor 301 for processing, it is transmitted through the radio frequency circuit 304 to, for example, another electronic device, or the audio data is output to the memory 302 for further processing. The audio circuit 305 may also include an earphone jack to provide communication between a peripheral earphone and the electronic device.
[0167] The input unit 306 can be used to receive the object model input by the user, the number of skeleton points input by the user, etc.
[0168] The power supply 307 is used to supply power to each component of the electronic device 300. Optionally, the power supply 307 can be logically connected to the processor 301 through a power management system, so as to realize functions such as management of charging, discharging, and power consumption management through the power management system. The power supply 307 can also include any components such as one or more DC or AC power supplies, a recharge system, a power failure detection circuit, a power converter or inverter, and a power status indicator.
[0169] Although Figure 14 not shown in the figure, the electronic device 300 may also include a camera, a sensor, a Wi-Fi module, a Bluetooth module, etc., which will not be elaborated here.
[0170] In the above embodiments, the descriptions of the respective embodiments have their own emphases. For the parts not detailed in a certain embodiment, reference may be made to the relevant descriptions of other embodiments.
[0171] Those of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructions, or by controlling relevant hardware through instructions. The instructions can be stored in a computer-readable storage medium and loaded and executed by a processor.
[0172] Therefore, an embodiment of the present application provides a computer-readable storage medium, in which multiple computer programs are stored. The computer programs can be loaded by a processor to execute any model processing method provided by the embodiments of the present application. The computer programs can execute the steps of the following model processing method:
[0173] Obtain an object model, where the object model includes a number of sub-models;
[0174] For each sub-model, obtain the vertex information of the model vertices included in the sub-model;
[0175] Based on the vertex information of the sub-model, determine multiple skeleton points of the sub-model, where the shape formed by connecting the skeleton points matches the shape of the sub-model;
[0176] From the multiple skeleton points, determine a number of skinning skeleton points corresponding to the model vertices in the sub-model;
[0177] Based on the distances between the number of skinning skeleton points and the corresponding model vertices, determine the skinning weights of the skinning skeleton points for the model vertices;
[0178] According to the skinning weights of the model vertices of each sub-model, obtain the skinning result of the object model.
[0179] By using the computer-readable storage medium provided in the embodiments of the present application, an object model can be obtained, where the object model includes several sub-models; for each sub-model, vertex information of the model vertices included in the sub-model is obtained; based on the vertex information of the sub-model, multiple bone points of the sub-model are determined, where the shape formed by connecting the bone points matches the shape of the sub-model; from the multiple bone points, several skinning bone points corresponding to the model vertices in the sub-model are determined; based on the distances between the several skinning bone points and the corresponding model vertices, the skinning weights of the skinning bone points for the model vertices are determined; according to the skinning weights of the model vertices of each sub-model, the skinning result of the object model is obtained. Based on this, programmed skinning processing is performed on the sub-models of the object model, so as to determine the skinning weights of the model vertices of the sub-models, improve the skinning efficiency of the object model, reduce the development cost, and at the same time improve the interaction experience of game players based on the object model after skinning processing.
[0180] For the specific implementation of each of the above operations, reference may be made to the previous embodiments, which will not be elaborated here.
[0181] Among them, the computer-readable storage medium may include: read-only memory (ROM, Read Only Memory), random access memory (RAM, Random Access Memory), magnetic disk or optical disc, etc.
[0182] Since the computer program stored in the computer-readable storage medium can execute any one of the model processing methods provided in the embodiments of the present application, the beneficial effects that can be achieved by any one of the model processing methods provided in the embodiments of the present application can be realized. For details, reference may be made to the previous embodiments, which will not be elaborated here.
[0183] According to one aspect of the present application, a computer program product or a computer program is further provided. The computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. The processor of the electronic device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the electronic device executes the methods provided in the various alternative implementation manners in the above embodiments.
[0184] In the above embodiments of the model processing apparatus, computer-readable storage medium, electronic device, and computer program product, the descriptions of the respective embodiments have their own focuses. For parts not detailed in a certain embodiment, reference may be made to the relevant descriptions of other embodiments. Those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working processes and the beneficial effects brought by the above-described model processing apparatus, computer-readable storage medium, computer program product, electronic device, and their corresponding units can refer to the description of the model processing method in the above embodiments, and will not be elaborated herein specifically.
[0185] The above has introduced in detail a model processing method, apparatus, electronic device, computer-readable storage medium, and computer program product provided by the embodiments of the present application. Specific examples are used herein to elaborate on the principle and implementation manner of the present application. The description of the above embodiments is only used to help understand the method and its core idea of the present application; at the same time, for those skilled in the art, according to the idea of the present application, there will be changes in the specific implementation manner and application scope. In summary, the content of this specification should not be construed as a limitation to the present application.
Claims
1. A model processing method, characterized in that, The method includes: Obtain an object model, where the object model includes a number of sub-models; For each of the sub-models, obtain the vertex information of the model vertices included in the sub-model; Based on the vertex information of the sub-model, determine a plurality of bone points of the sub-model, where the shape formed by connecting the bone points matches the shape of the sub-model; From the plurality of bone points, determine a number of skinning bone points corresponding to the model vertices in the sub-model; Based on the distances between the number of skinning bone points and the corresponding model vertices, determine the skinning weights of the skinning bone points for the model vertices; According to the skinning weights of the model vertices of each sub-model, obtain the skinning result of the object model.
2. The model processing method according to claim 1, wherein The plurality of bone points include main bone points and secondary bone points. The determining the plurality of bone points of the sub-model based on the vertex information of the sub-model includes: Based on the vertex information of the sub-model, determine a plurality of main bone points on the sub-model; Based on the vertex information of the sub-model and the main bone points, determine the secondary bone points corresponding to the main bone points.
3. The model processing method according to claim 2, wherein The determining a plurality of main bone points on the sub-model based on the vertex information of the sub-model includes: Obtain the outer contour edge segments of the sub-model, where the model vertices included in the outer contour edge segments are outer contour vertices; Obtain the first model vertices among the model vertices of the sub-model that are outside the outer contour vertices; Based on the first model vertices, determine a plurality of main bone points of the sub-model.
4. The model processing method according to claim 3, wherein The determining a plurality of main bone points of the sub-model based on the first model vertices includes: Sort the first model vertices according to the distances between the first model vertices and a reference point; Connect the sorted first model vertices into a target line segment; Perform vertex sampling on the target line segment to obtain a plurality of main bone points of the sub-model.
5. The model processing method according to claim 3, wherein The main bone points include a root bone point, intermediate bone points, and top bone points; The determining the secondary bone points corresponding to the main bone points based on the vertex information of the sub-model and the main bone points includes: Construct a target plane according to the root bone point and a target direction vector; Project each of the outer contour vertices onto the target plane to obtain the projection points of each of the outer contour vertices; For each of the intermediate bone points, calculate the target distance between the intermediate bone point and the projection points of the outer contour vertices on both sides of the intermediate bone point; Based on the target distance, select the secondary bone points of the intermediate bone point from the outer contour vertices on both sides respectively.
6. The model processing method according to claim 5, wherein Before the constructing the target plane according to the root bone point and the target direction vector, it further includes: Determine the tangent direction vector of the main bone point according to the position difference between the main bone point and the adjacent main bone points; Zero out the first vector component in the tangent direction vector, and swap the second vector component and the third vector component in the tangent direction vector to obtain the target direction vector.
7. The model processing method according to claim 6, wherein Projecting each of the outer contour vertices onto the target plane to obtain the projection points of each of the outer contour vertices includes: Determining a projection vector corresponding to the outer contour vertex according to the positional difference between the root bone point and the outer contour vertex; Determining the projection value of the projection vector projected onto the tangent direction vector of the root bone point; Shifting the outer contour vertex to the target plane according to the projection value to obtain the projection point of the outer contour vertex.
8. A model processing device, characterized in that, The device includes: A model acquisition module, configured to acquire an object model, where the object model includes a plurality of sub-models; An information acquisition module, configured to, for each of the sub-models, acquire vertex information of the model vertices included in the sub-model; A bone point determination module, configured to determine a plurality of bone points of the sub-model based on the vertex information of the sub-model, where the shape formed by connecting the bone points matches the shape of the sub-model; A skinning bone point determination module, configured to determine, from the plurality of bone points, a plurality of skinning bone points corresponding to each of the model vertices in the sub-model; A weight determination module, configured to determine the skinning weight of the skinning bone point for the model vertex based on the distances between the plurality of skinning bone points and the corresponding model vertices; A skinning module, configured to obtain a skinning result of the object model according to the skinning weights of the model vertices of each of the sub-models.
9. An electronic device, characterized in that, It includes a processor and a memory, where the memory stores a computer program, and when the computer program is executed by the processor, the processor is caused to execute the steps of the model processing method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, It includes a computer program, and when the computer program runs on an electronic device, the computer program is used to cause the electronic device to execute the steps of the model processing method according to any one of claims 1 to 7.