Model simplification method, device, electronic device and storage medium
By simplifying the vertices and triangles in the 3D model, the problem of excessive computational volume of existing 3D models is solved, and efficient rendering and action-driven on devices with limited computing power is achieved.
Patent Information
- Application Number
- CN202011416428.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-04
- Publication Date
- 2025-04-22
- Estimated Expiration
- 2040-12-04
AI Technical Summary
Due to the excessive number of triangle surfaces, the existing 3D models are too complex and have huge calculations, making it difficult to render and actuate on devices with limited computing power.
By obtaining the model data of the 3D model, calculate the vertex degree of each triangle, determine that the vertex with a degree of 5 is the vertex to be simplified, and delete the vertices and triangles that meet the preset conditions based on the simplification times of the vertex and the area of the target triangle, and create a new triangle composed of two target reference vertices and any remaining reference vertices.
The structure of the 3D model is simplified, the calculation amount is reduced, and equipment with limited computing power can effectively render and drive the 3D model, and meet the application scenarios that meet real-time requirements.
Smart Images

Figure CN112465954B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer graphics, and in particular to a model simplification method, device, electronic equipment and storage medium. Background Art
[0002] With the development of computer graphics, 3D (three-dimensional, three-dimensional graphics) technology has made great progress in many fields. At present, 3D models represented by triangular meshes are more common in 3D technology, such as Figure 1 As shown, Figure 1 The model 110 is a 3D model formed by stitching together a large number of triangles.
[0003] However, the current 3D models have too many triangles and are too complex, which results in a huge amount of computation required for rendering and action driving of the 3D models. This problem of excessive computation caused by the complexity of the 3D models will make it difficult for model-driven devices with limited computing power to perform model rendering and action driving operations on the current 3D models. In other words, the current 3D models are too complex to meet the needs of some application scenarios with real-time requirements. Summary of the invention
[0004] The purpose of the embodiments of the present invention is to provide a model simplification method, device, electronic device and storage medium to simplify the structure of a 3D model so that a model driving device with limited computing power can perform operations such as model rendering and action driving on the 3D model.
[0005] In order to achieve the above object, an embodiment of the present invention provides a model simplification method, including:
[0006] Obtaining model data of a 3D model to be simplified; the 3D model to be simplified is a model formed by splicing a plurality of triangles; the model data includes: an identifier of each triangle of the 3D model to be simplified and coordinate data of each vertex of each triangle;
[0007] Based on the identifier of each triangle, the degree of each vertex of each triangle of the 3D model to be simplified is calculated; wherein the degree of a triangle vertex is: the number of sides of the triangle connected to the vertex;
[0008] The vertices with a degree of 5 are determined as the vertices to be simplified;
[0009] For each vertex to be simplified, other vertices directly connected to the vertex to be simplified are obtained as reference vertices of the vertex to be simplified; and triangles formed between the vertex to be simplified and two adjacent reference vertices of the vertex to be simplified in the 3D model to be simplified are all used as target triangles corresponding to the vertex to be simplified;
[0010] For each vertex to be simplified, the simplification times of the vertex to be simplified and each reference vertex of the vertex to be simplified are obtained; and based on the coordinate data of the vertex to be simplified and each reference vertex of the vertex to be simplified, the areas of each target triangle corresponding to the vertex to be simplified are calculated; wherein the simplification times of each vertex of the triangle is: the number of other vertices in the same triangle as the vertex that are deleted;
[0011] For each vertex to be simplified, based on the simplification times of each reference vertex and the area of each target triangle, determine whether the preset simplification times and area conditions are met;
[0012] If satisfied, deleting the vertex to be simplified and each target triangle corresponding to the vertex to be simplified in the 3D model to be simplified; and determining a reference vertex from each reference vertex of the vertex to be simplified as a target reference vertex according to the areas of each target triangle corresponding to the vertex to be simplified;
[0013] Create a new triangle in the 3D model to be simplified, which is formed by any two adjacent reference vertices of the vertex to be simplified and the target reference vertex, to obtain three newly created triangles;
[0014] The simplification times of each reference vertex are updated, and the 3D model to be simplified is updated.
[0015] Further, the step of determining a reference vertex from the reference vertices of the vertex to be simplified as a target reference vertex according to the areas of the target triangles corresponding to the vertex to be simplified includes:
[0016] For each reference vertex of the vertex to be simplified, a triangle formed between the reference vertex and any two remaining adjacent reference vertices is used as a reference triangle corresponding to the reference vertex, and the sum of the areas of the reference triangles corresponding to the reference vertex is calculated;
[0017] From all reference vertices of the vertex to be simplified, the reference vertex with the smallest sum of areas of corresponding reference triangles is selected as the target reference vertex.
[0018] Furthermore, the step of creating a new triangle in the 3D model to be simplified, which is formed by any two adjacent reference vertices of the vertex to be simplified and the target reference vertex, obtains three newly created triangles, including:
[0019] According to the coordinate data of each reference vertex of the vertex to be simplified, a triangle formed by any two adjacent reference vertices of the vertex to be simplified and the target reference vertex is created in the 3D model to be simplified to obtain three newly created triangles; and a new identifier is generated for each newly created triangle.
[0020] Furthermore, for each vertex to be simplified, based on the simplification times of each reference vertex and the area of each target triangle, judging whether the preset simplification times and area conditions are met includes:
[0021] Determine whether the simplification times of each vertex to be simplified are less than the first preset simplification times, and whether the simplification times of each reference vertex of the vertex to be simplified are all less than the second preset simplification times; if they are all less than, the preset simplification times condition is met;
[0022] Determine whether the area of each target triangle is smaller than the preset area. If so, the preset area condition is met.
[0023] Furthermore, after the 3D model to be simplified is updated, the method further includes:
[0024] Determine whether the current number of iterations reaches the preset number of iterations;
[0025] If the current number of iterations reaches the preset number of iterations, the simplification operation ends;
[0026] If the current number of iterations does not reach the preset number of iterations, the number of iterations is updated; and for the updated 3D model to be simplified, the step of calculating the degree of each vertex of each triangle of the 3D model to be simplified based on the identifier of each triangle is returned.
[0027] Furthermore, after the updating of the number of simplifications of each reference vertex, the method further includes:
[0028] Add each reference vertex after updating the simplification times to the preset reference vertex set;
[0029] The step of obtaining, for each vertex to be simplified, other vertices directly connected to the vertex to be simplified as reference vertices for the vertex to be simplified comprises:
[0030] For each vertex to be simplified, determine whether the vertex to be simplified is in the preset reference vertex set. If not, it means that the vertex to be simplified has not been simplified. Obtain other vertices directly connected to the vertex to be simplified as reference vertices for the vertex to be simplified.
[0031] In order to achieve the above object, an embodiment of the present invention provides a model simplification device, including:
[0032] A first data acquisition module is used to obtain model data of a 3D model to be simplified; the 3D model to be simplified is a model formed by splicing a plurality of triangles; the model data includes: an identifier of each triangle of the 3D model to be simplified and coordinate data of each vertex of each triangle;
[0033] A vertex degree calculation module, used to calculate the degree of each vertex of each triangle of the 3D model to be simplified based on the identifier of each triangle; wherein the degree of a triangle vertex is: the number of sides of the triangle connected to the vertex;
[0034] A vertex determination module, used for determining vertices with a degree equal to 5 as vertices to be simplified;
[0035] The second data acquisition module is used to obtain, for each vertex to be simplified, other vertices directly connected to the vertex to be simplified as reference vertices of the vertex to be simplified; and use triangles formed between the vertex to be simplified and two adjacent reference vertices of the vertex to be simplified in the 3D model to be simplified as target triangles corresponding to the vertex to be simplified;
[0036] The third data acquisition module is used to obtain, for each vertex to be simplified, the simplification times of the vertex to be simplified and each reference vertex of the vertex to be simplified; and, based on the coordinate data of the vertex to be simplified and each reference vertex of the vertex to be simplified, calculate the area of each target triangle corresponding to the vertex to be simplified; wherein the simplification times of each vertex of the triangle is: the number of other vertices in the same triangle as the vertex that are deleted;
[0037] A first judgment module is used to judge, for each vertex to be simplified, whether the preset simplification times and area conditions are met based on the simplification times of each reference vertex and the area of each target triangle;
[0038] A processing module, configured to delete the vertex to be simplified and each target triangle corresponding to the vertex to be simplified in the 3D model to be simplified if the conditions are met; and determine a reference vertex from each reference vertex of the vertex to be simplified as a target reference vertex according to the areas of each target triangle corresponding to the vertex to be simplified;
[0039] A triangle creation module, used to create a triangle formed by any two adjacent reference vertices of the vertex to be simplified and a target reference vertex in the 3D model to be simplified, to obtain three newly created triangles;
[0040] The updating module is used to update the simplification times of each reference vertex and to update the 3D model to be simplified.
[0041] Furthermore, the processing module, for each reference vertex of the vertex to be simplified, takes the triangle formed by the reference vertex and any two remaining adjacent reference vertices as the reference triangle corresponding to the reference vertex, and calculates the sum of the areas of the reference triangles corresponding to the reference vertex; from all the reference vertices of the vertex to be simplified, selects the reference vertex with the smallest sum of the areas of the corresponding reference triangles as the target reference vertex.
[0042] Furthermore, the triangle creation module is specifically used to create a triangle formed by any two adjacent reference vertices of the vertex to be simplified and the target reference vertex in the 3D model to be simplified according to the coordinate data of each reference vertex of the vertex to be simplified, so as to obtain three newly created triangles; and generate a new identifier for each newly created triangle.
[0043] Furthermore, the first judgment module includes:
[0044] A first judgment submodule is used to judge whether the number of simplification times of each vertex to be simplified is less than a first preset number of simplification times, and whether the number of simplification times of each reference vertex of the vertex to be simplified is less than a second preset number of simplification times; if they are all less than, the preset number of simplification times condition is met;
[0045] The second judgment submodule is used to judge whether the area of each target triangle is smaller than a preset area. If so, the preset area condition is met.
[0046] Furthermore, the device also includes: a second judgment module, used to judge whether the current number of iterations reaches the preset number of iterations; if the current number of iterations reaches the preset number of iterations, end the simplification operation; if the current number of iterations does not reach the preset number of iterations, update the number of iterations; and for the updated 3D model to be simplified, return the identification based on each triangle, and calculate the degree of each vertex of each triangle of the 3D model to be simplified.
[0047] Furthermore, the device further comprises:
[0048] An adding module is used to add each reference vertex after the simplification times are updated to the preset reference vertex set;
[0049] The second data acquisition module is specifically used to determine whether each vertex to be simplified is in a preset reference vertex set. If not, it means that the vertex to be simplified has not been simplified, and obtains other vertices directly connected to the vertex to be simplified as reference vertices of the vertex to be simplified.
[0050] In order to achieve the above object, an embodiment of the present invention provides an electronic device, including a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus;
[0051] Memory, used to store computer programs;
[0052] The processor is used to implement any of the above-mentioned model simplification method steps when executing the program stored in the memory.
[0053] In order to achieve the above-mentioned purpose, an embodiment of the present invention provides a computer-readable storage medium, characterized in that a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, any of the above-mentioned model simplification method steps is implemented.
[0054] In order to achieve the above-mentioned purpose, an embodiment of the present invention further provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute any of the above-mentioned steps of the model simplification method.
[0055] Beneficial effects of the embodiments of the present invention:
[0056] The method provided by the embodiment of the present invention is used to obtain model data of a 3D model to be simplified; based on the identifier of each triangle, the degree of each vertex of each triangle of the 3D model to be simplified is calculated; the vertex with a degree equal to 5 is determined as the vertex to be simplified; for each vertex to be simplified, other vertices directly connected to the vertex to be simplified are obtained as reference vertices of the vertex to be simplified; and the triangles formed between the reference vertex of the vertex to be simplified and the vertex to be simplified in the 3D model to be simplified are all used as target triangles corresponding to the vertex to be simplified; for each vertex to be simplified, the simplification times of the vertex to be simplified and each reference vertex of the vertex to be simplified are obtained; and based on the coordinate data of the vertex to be simplified and each reference vertex of the vertex to be simplified, the simplification times of the vertex to be simplified and each reference vertex of the vertex to be simplified are calculated. The area of each target triangle corresponding to the vertex to be simplified; for each vertex to be simplified, based on the simplification times of each reference vertex and the area of each target triangle, determine whether the preset simplification times and area conditions are met; if met, delete the vertex to be simplified and the target triangles corresponding to the vertex to be simplified in the 3D model to be simplified; and, according to the areas of each target triangle corresponding to the vertex to be simplified, determine a reference vertex from each reference vertex of the vertex to be simplified as the target reference vertex; create a triangle formed by any two adjacent reference vertices of the vertex to be simplified and the target reference vertex in the 3D model to be simplified, and obtain three newly created triangles; update the simplification times of each reference vertex, and update the 3D model to be simplified. By deleting the target triangle that meets the preset simplification times and area conditions in the 3D model to be simplified from the 3D model, and creating a triangle formed by two target reference vertices and any remaining reference vertex in the 3D model to be simplified, that is, deleting multiple target triangles and creating three new triangles, the purpose of simplifying the 3D model is achieved, so that the model driving device with limited computing power can perform model rendering and action driving operations on the 3D model. That is, the 3D model can meet the application scenarios that have real-time requirements for operations such as model rendering and action driving.
[0057] Of course, it is not necessary to achieve all of the advantages described above at the same time to implement any product or method of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0059] Figure 1 It is a 3D model represented by a triangular mesh in the prior art;
[0060] Figure 2 A flow chart of a model simplification method provided by an embodiment of the present invention;
[0061] Figure 3 Another flow chart of the model simplification method provided by the embodiment of the present invention;
[0062] Figure 4 A schematic diagram of a γ structure of a 3D model to be simplified in an embodiment of the present invention;
[0063] Figure 5a A schematic diagram of creating three triangles in a 3D model to be simplified by applying the method provided by an embodiment of the present invention;
[0064] Figure 5b Another schematic diagram of creating three triangles in a 3D model to be simplified by applying the method provided by an embodiment of the present invention;
[0065] Figure 5c Another schematic diagram of applying the method provided by the embodiment of the present invention to create three triangles in the 3D model to be simplified;
[0066] Figure 5d Another schematic diagram of applying the method provided by the embodiment of the present invention to create three triangles in the 3D model to be simplified;
[0067] Figure 5e Another schematic diagram of applying the method provided by the embodiment of the present invention to create three triangles in the 3D model to be simplified;
[0068] Figure 6 A structural diagram of a model simplification device provided by an embodiment of the present invention;
[0069] Figure 7 Another structural diagram of the model simplification device provided by an embodiment of the present invention;
[0070] Figure 8 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0071] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0072] Since existing 3D models are too complex, it is difficult for model-driven devices with limited computing power to perform operations such as model rendering and action driving on the existing 3D models. In order to simplify the structure of the 3D model so that the simplified 3D model can meet the needs of model-driven devices with limited computing power to perform operations such as model rendering and action driving on the 3D model, an embodiment of the present invention provides a model simplification method, device, electronic device and storage medium.
[0073] See also Figure 2 , Figure 2 A process of a model simplification method provided in an embodiment of the present invention includes:
[0074] Step 201: Obtain model data of a 3D model to be simplified.
[0075] The 3D model to be simplified is a model formed by splicing multiple triangles; the model data includes: the identifier of each triangle of the 3D model to be simplified and the coordinate data of each vertex of each triangle.
[0076] Step 202: Calculate the degree of each vertex of each triangle of the 3D model to be simplified based on the identifier of each triangle.
[0077] The degree of a triangle vertex is the number of edges of the triangle connected to the vertex.
[0078] Step 203: determine the vertices with a degree equal to 5 as vertices to be simplified.
[0079] Step 204, for each vertex to be simplified, obtain other vertices directly connected to the vertex to be simplified as reference vertices of the vertex to be simplified; and use the triangles formed between the reference vertex of the vertex to be simplified and the vertex to be simplified in the 3D model to be simplified as target triangles corresponding to the vertex to be simplified.
[0080] Step 205, for each vertex to be simplified, obtain the simplification times of the vertex to be simplified and each reference vertex of the vertex to be simplified; and, based on the coordinate data of the vertex to be simplified and each reference vertex of the vertex to be simplified, calculate the area of each target triangle corresponding to the vertex to be simplified.
[0081] The number of simplifications for each vertex of a triangle is: the number of other vertices deleted in the same triangle as the vertex.
[0082] Step 206 : for each vertex to be simplified, based on the simplification times of each reference vertex and the area of each target triangle, determine whether the preset simplification times and area conditions are met.
[0083] Step 207, if satisfied, delete the vertex to be simplified and each target triangle corresponding to the vertex to be simplified in the 3D model to be simplified; and, according to the area of each target triangle corresponding to the vertex to be simplified, determine a reference vertex from each reference vertices of the vertex to be simplified as the target reference vertex.
[0084] Step 208: Create a new triangle in the 3D model to be simplified, which is formed by any two adjacent reference vertices of the vertex to be simplified and the target reference vertex, to obtain three newly created triangles.
[0085] Step 209: updating the simplification times of each reference vertex, and updating the 3D model to be simplified.
[0086] The method provided by the embodiment of the present invention is used to obtain model data of a 3D model to be simplified; based on the identifier of each triangle, the degree of each vertex of each triangle of the 3D model to be simplified is calculated; the vertex with a degree equal to 5 is determined as the vertex to be simplified; for each vertex to be simplified, other vertices directly connected to the vertex to be simplified are obtained as reference vertices of the vertex to be simplified; and the triangles formed between the reference vertex of the vertex to be simplified and the vertex to be simplified in the 3D model to be simplified are all used as target triangles corresponding to the vertex to be simplified; for each vertex to be simplified, the simplification times of the vertex to be simplified and each reference vertex of the vertex to be simplified are obtained; and based on the coordinate data of the vertex to be simplified and each reference vertex of the vertex to be simplified, the simplification times of the vertex to be simplified and each reference vertex of the vertex to be simplified are calculated. The area of each target triangle corresponding to the vertex to be simplified; for each vertex to be simplified, based on the simplification times of each reference vertex and the area of each target triangle, determine whether the preset simplification times and area conditions are met; if met, delete the vertex to be simplified and the target triangles corresponding to the vertex to be simplified in the 3D model to be simplified; and, according to the areas of each target triangle corresponding to the vertex to be simplified, determine a reference vertex from each reference vertex of the vertex to be simplified as the target reference vertex; create a triangle formed by any two adjacent reference vertices of the vertex to be simplified and the target reference vertex in the 3D model to be simplified, and obtain three newly created triangles; update the simplification times of each reference vertex, and update the 3D model to be simplified. By deleting the target triangle that meets the preset simplification times and area conditions in the 3D model to be simplified from the 3D model, and creating a triangle formed by two target reference vertices and any remaining reference vertex in the 3D model to be simplified, that is, deleting multiple target triangles and creating three new triangles, the purpose of simplifying the 3D model is achieved, so that the model driving device with limited computing power can perform model rendering and action driving operations on the 3D model. That is, the 3D model can meet the application scenarios that have real-time requirements for operations such as model rendering and action driving.
[0087] See also Figure 3 , Figure 3 Another process of the model simplification method provided by the embodiment of the present invention includes:
[0088] Step 301: Obtain model data of a 3D model to be simplified.
[0089] In the embodiment of the present invention, the 3D model to be simplified is a model formed by splicing multiple triangles, and each triangle has an identifier. The model data of the 3D model to be simplified includes: the identifier of each triangle of the 3D model to be simplified and the coordinate data of each vertex of each triangle.
[0090] For example, if the 3D model to be simplified includes multiple triangles such as triangle T1 and triangle T2, where the three vertices of triangle T1 and their 3D coordinates are P1(x1, y1, z1), P2(x2, y2, z2) and P3(x3, y3, z3); the identifier "SG T1 "; The three vertices and vertex coordinates of triangle T2 are P4 (x4, y4, z4), P5 (x5, y5, z2) and P6 (x6, y6, z6), and the logo corresponding to triangle T2 is "SG T2 ”.
[0091] The model data of the 3D model to be simplified includes: the coordinate data of the three vertices of triangle T1 P1 (x1, y1, z1), P2 (x2, y2, z2) and P3 (x3, y3, z3) and the identifier "SGD" corresponding to triangle T2 T1 "; and the three vertex coordinate data of triangle T2 P4 (x4, y4, z4), P5 (x5, y5, z2) and P6 (x6, y6, z6), and the logo "SG corresponding to triangle T2 T2 ”.
[0092] Step 302: Calculate the degree of each vertex of each triangle of the 3D model to be simplified based on the identifier of each triangle.
[0093] The degree of a triangle vertex is the number of edges of the triangle connected to the vertex.
[0094] In an embodiment of an embodiment of the present invention, after obtaining the model data of the 3D model to be simplified, each triangle in the 3D model to be simplified can be determined based on the identification of the triangle, and then for each vertex of each triangle, the number of edges of the triangle connected to the vertex is calculated as the degree of the vertex.
[0095] For an example, see Figure 4 , Figure 4 It is the part of the 3D model structure to be simplified. Figure 4 The following figure shows the triangles ABC, ACD, ADE, AEF and AFB in the 3D model to be simplified. If the triangle ABC is marked as “SG ABC ", in this step, you can use the identifier "SG ABC" Determine triangle ABC. Then, for vertex A of triangle ABC, the number of edges of the triangle connected to vertex A can be calculated to be 5, that is, the degree of vertex A can be obtained as 5. In the same way, the number of edges of the triangle connected to vertex B can be calculated to be 3, that is, the degree of vertex B can be obtained as 3, and the degree of vertex C can be obtained as 3, the degree of vertex D is 3, the degree of vertex E is 3, and the degree of vertex F is 3.
[0096] Step 303: determine the vertices with a degree equal to 5 as vertices to be simplified.
[0097] See also Figure 4 , Figure 4 The degree of vertex A is 5, and the degrees of vertices B, C, D, E, and F are all 3. Vertex A can be used as the vertex to be simplified. Figure 4 The structure composed of triangle ABC, triangle ACD, triangle ADE, triangle AEF and triangle AFB is shown as the γ structure in the 3D model to be simplified. In the embodiment of the present invention, the γ structure in the 3D model to be simplified can be simplified to achieve the purpose of simplifying the 3D model to be simplified.
[0098] In the embodiment of the present invention, the determined vertices to be simplified can be put into a preset set X. For example, Figure 4 The vertices A to be simplified are put into the preset set X.
[0099] Step 304: for each vertex to be simplified, obtain other vertices directly connected to the vertex to be simplified as reference vertices of the vertex to be simplified.
[0100] Furthermore, triangles formed between two adjacent reference vertices of the vertex to be simplified in the 3D model to be simplified and the vertex to be simplified can all be used as target triangles corresponding to the vertex to be simplified.
[0101] For example, see Figure 4 , for the vertex A to be simplified, five vertices directly connected to it can be obtained: vertex B, vertex C, vertex D, vertex E and vertex F, and vertex B, vertex C, vertex D, vertex E and vertex F are all used as reference vertices of the vertex A to be simplified. Moreover, in the 3D model to be simplified, the triangles formed by the vertex A to be simplified and the adjacent reference vertices of the vertex A to be simplified include: triangle ABC, triangle ACD, triangle ADE, triangle AEF and triangle AFB. In this step, triangle ABC, triangle ACD, triangle ADE, triangle AEF and triangle AFB can all be used as target triangles corresponding to the vertex A to be simplified.
[0102] In an embodiment of the present invention, a counter may be set for each vertex of each triangle in the 3D model to be simplified, and the counter of each vertex is used to count the number of times the vertex is simplified. The number of times each vertex of a triangle is simplified is the number of other vertices in the same triangle as the vertex that are deleted. In this step, the value of the counter of each vertex of each triangle in the 3D model to be simplified may be set to 0, that is, the initial value of the number of times each vertex is simplified is set to 0.
[0103] Step 305 : For each vertex to be simplified, based on the coordinate data of the vertex to be simplified and each reference vertex of the vertex to be simplified, calculate the area of each target triangle corresponding to the vertex to be simplified.
[0104] Specifically, the area of the target triangle can be calculated based on the coordinate data of the three vertices of the target triangle:
[0105]
[0106] Among them, S ΔABC represents the area of the target triangle ABC, The vector representing the side AB of the target triangle ABC and the vector of side AC The vector product between them, |AB| is the length of side AB in the target triangle ABC, and |AC| is the length of side AC in the target triangle ABC.
[0107] Step 306, randomly select a vertex to be simplified from the set X, and for the vertex to be simplified, determine whether the number of simplification times of the vertex to be simplified is less than the first preset number of simplification times, and whether the number of simplification times of each reference vertex of the vertex to be simplified is less than the second preset number of simplification times. If the judgment result is yes, execute step 307; if the judgment result is no, execute step 312.
[0108] The first preset number of simplifications may be set to 2 or 3, etc., and the second preset number of simplifications may also be set to 2 or 3, etc., without any specific limitation.
[0109] Step 307 , determining whether the areas of the target triangles corresponding to the vertices to be simplified are all smaller than a preset area; if the determination result is yes, executing step 308 , if the determination result is no, executing step 312 .
[0110] The preset area may be set according to the complexity of the 3D model to be simplified. If the complexity of the 3D model to be simplified is relatively high, the preset area may be set larger.
[0111] Step 308: Delete the vertex to be simplified and each target triangle corresponding to the vertex to be simplified in the 3D model to be simplified.
[0112] Specifically, the coordinates of the vertex to be simplified may be deleted, and the three target triangles corresponding to the vertex to be simplified and the identifiers of the three target triangles may be deleted.
[0113] For example, if the first preset simplification times and the second preset simplification times are both set to 2, and the preset area is set to 15 cm 2 , see Figure 4 , if the vertex A to be simplified is selected from the set X in step 306, it can be obtained that the current simplification times of the vertex A to be simplified is 0, and the reference vertices of the vertex A to be simplified are reference vertex B, reference vertex C, reference vertex D, reference vertex E and reference vertex F, and the current simplification times of reference vertex B, reference vertex C, reference vertex D, reference vertex E and reference vertex F are all 0. The five target triangles corresponding to the vertex A to be simplified are: triangle ABC, triangle ACD, triangle ADE, triangle AEF and triangle AFB. If the areas of triangle ABC, triangle ACD, triangle ADE, triangle AEF and triangle AFB are 5cm respectively 2 、7cm 2 、8cm 2 、9cm 2 and 11cm 2 , it can be obtained that: the simplification times of the vertex A to be simplified is less than the first preset simplification times, and the simplification times of the reference vertex B, reference vertex C, reference vertex D, reference vertex E and reference vertex F are all less than the second preset simplification times, and the areas of the target triangle ABC, target triangle ACD, target triangle ADE, target triangle AEF and target triangle AFB corresponding to the vertex A to be simplified are all less than the preset area. Therefore, the coordinates of the vertex A to be simplified can be deleted from the 3D model to be simplified, and the five target triangles corresponding to the vertex A to be simplified and the identifiers of the five target triangles can be deleted.
[0114] In this step, each reference vertex of the deleted vertex to be simplified can also be put into a preset reference vertex set. Figure 4 , if Figure 4 If the vertex A to be simplified is deleted, the reference vertices "reference vertex B, reference vertex C, reference vertex D, reference vertex E and reference vertex F" of the vertex A to be simplified can be put into the preset reference vertex set.
[0115] Step 309 : According to the areas of the target triangles corresponding to the vertex to be simplified, a reference vertex is determined from the reference vertices of the vertex to be simplified as a target reference vertex.
[0116] The specific steps of determining the target reference vertex may include steps A1 and A2:
[0117] Step A1: for each reference vertex of the vertex to be simplified, a triangle formed between the reference vertex and any two remaining adjacent reference vertices is used as a reference triangle corresponding to the reference vertex, and the sum of the areas of the reference triangles corresponding to the reference vertex is calculated;
[0118] Step A2: From all reference vertices of the vertex to be simplified, select the reference vertex with the smallest sum of areas of corresponding reference triangles as the target reference vertex.
[0119] For an example, see Figure 4 , for each reference vertex of the vertex A to be simplified, the triangle formed between the reference vertex and any two remaining adjacent reference vertices is used as the reference triangle corresponding to the reference vertex. For example, see Figure 5a , for the reference vertex B of the vertex A to be simplified, the triangles BCD, BDE and BEF formed between the reference vertex B and any two adjacent reference vertices are all used as the reference triangles corresponding to the reference vertex B; and the sum of the areas of the three reference triangles corresponding to the reference vertex B can be calculated: S1 = S BCD +S BDE +S BEF .
[0120] See also Figure 5b , for the reference vertex C of the vertex A to be simplified, the triangles CDE, CEF and CFB formed between the reference vertex C and any two adjacent reference vertices are all used as reference triangles corresponding to the reference vertex C; and the sum of the areas of the three reference triangles corresponding to the reference vertex C can be calculated: S2 = S CDE +S CEF +S CFB .
[0121] See also Figure 5c , for the reference vertex D of the vertex A to be simplified, the triangle DEF, triangle DFB and triangle DBC formed between the reference vertex D and any two adjacent reference vertices are all used as the reference triangles corresponding to the reference vertex D; and the sum of the areas of the three reference triangles corresponding to the reference vertex D can be calculated: S3 = S DEF +S DFB +S DBC .
[0122] See also Figure 5d , for the reference vertex E of the vertex A to be simplified, the triangles EFB, EBC and ECD formed between the reference vertex E and any two adjacent reference vertices are all used as reference triangles corresponding to the reference vertex E; and the sum of the areas of the three reference triangles corresponding to the reference vertex E can be calculated: S4 = SEFB +S EBC +S ECD .
[0123] See also Figure 5e , for the reference vertex F of the vertex A to be simplified, the triangles FBC, FCD and FDE formed between the reference vertex F and any two adjacent reference vertices are all used as reference triangles corresponding to the reference vertex F, and the sum of the areas of the three reference triangles corresponding to the reference vertex F can be calculated: S5 = S FBC +S FCD +S FDE .
[0124] Then, from all the reference vertices of the to-be-simplified vertex A, the reference vertex with the smallest sum of the areas of the corresponding reference triangles can be selected as the target reference vertex. For example, if S1 is the smallest among S1, S2, S3, S4, and S5, it means that the sum of the areas of the three reference triangles corresponding to the reference vertex B is the smallest, and the reference vertex B can be determined as the target reference vertex.
[0125] Step 310, based on the coordinate data of each reference vertex of the vertex to be simplified, create a triangle formed by any two adjacent reference vertices of the vertex to be simplified and the target reference vertex in the 3D model to be simplified, and obtain three newly created triangles; and generate a new identifier for each newly created triangle.
[0126] For an example, see Figure 4 , if the coordinates of the to-be-simplified vertex A are deleted from the to-be-simplified 3D model, and the five target triangles corresponding to the to-be-simplified vertex A and the identifiers of the five target triangles are deleted.
[0127] If S1 is the smallest among the sum of the areas of the reference triangles corresponding to the reference vertex B, reference vertex C, reference vertex D, reference vertex E and reference vertex F of the vertex A to be simplified, then reference vertex B can be determined as the target reference vertex. Then, a triangle formed by any two adjacent reference vertices of the vertex A to be simplified and the target reference vertex B can be created in the 3D model to be simplified, and three newly created triangles can be obtained, such as Figure 5a As shown, three reference triangles corresponding to reference vertex B are created: triangle BCD, triangle BDE and triangle BEF. In addition, a new identifier can be generated for the created new triangles. That is, according to the coordinate data of target reference vertex B, reference vertex C and reference vertex D, a new triangle BCD is created, and an identifier "SGD" is generated for triangle BCD. BCD"; At the same time, a new triangle BDE with the target reference vertex B, the reference vertex D and the reference vertex E as vertices can be created in the 3D model to be simplified, and a new identifier "SG BDE "; At the same time, a new triangle BEF with the target reference vertex B, the reference vertex E and the reference vertex F as vertices can be created in the 3D model to be simplified, and a new identifier "SG BEF ”.
[0128] If the sum of the areas of the reference triangles corresponding to the reference vertex B, reference vertex C, reference vertex D, reference vertex E and reference vertex F of the vertex A to be simplified is S2, which is the smallest among S1, S2, S3, S4 and S5, then the reference vertex C can be determined as the target reference vertex. Then, a triangle formed by any two adjacent reference vertices of the vertex A to be simplified and the target reference vertex C can be created in the 3D model to be simplified, and three newly created triangles can be obtained, such as Figure 5b As shown, three reference triangles corresponding to the reference vertex C are created: triangle CDE, triangle CEF and triangle CFB. In addition, a new identifier can be generated for the created new triangles. That is, according to the coordinate data of the target reference vertex C, reference vertex D and reference vertex E, a new triangle CDE is created, and an identifier "SGD" is generated for the triangle CDE. CDE "; At the same time, a new triangle CEF with the target reference vertex C, the reference vertex E and the reference vertex F as vertices can be created in the 3D model to be simplified, and a new identifier "SG CEF "; At the same time, a new triangle CFB with the target reference vertex C, the reference vertex F and the reference vertex B as vertices can be created in the 3D model to be simplified, and a new identifier "SG CFB ”.
[0129] If the sum of the areas of the reference triangles corresponding to the reference vertex B, reference vertex C, reference vertex D, reference vertex E and reference vertex F of the vertex A to be simplified is S3, which is the smallest among S1, S2, S3, S4 and S5, then the reference vertex D can be determined as the target reference vertex. Then, a triangle formed by any two adjacent reference vertices of the vertex A to be simplified and the target reference vertex D can be created in the 3D model to be simplified, and three newly created triangles can be obtained, such as Figure 5c As shown, three reference triangles corresponding to reference vertex D are created: triangle DEF, triangle DFB, and triangle DBC. In addition, a new identifier can be generated for the created new triangles. That is, according to the coordinate data of target reference vertex D, reference vertex E, and reference vertex F, a new triangle DEF is created, and an identifier "SGDEF "; At the same time, a new triangle DFB with the target reference vertex D, the reference vertex F and the reference vertex B as vertices can be created in the 3D model to be simplified, and a new identifier "SG DFB "; At the same time, a new triangle DBC with the target reference vertex D, the reference vertex B and the reference vertex C as vertices can be created in the 3D model to be simplified, and a new identifier "SG DBC ”.
[0130] If the sum of the areas of the reference triangles corresponding to the reference vertex B, reference vertex C, reference vertex D, reference vertex E and reference vertex F of the vertex A to be simplified is the smallest among S4, then the reference vertex E can be determined as the target reference vertex. Then, a triangle formed by any two adjacent reference vertices of the vertex A to be simplified and the target reference vertex E can be created in the 3D model to be simplified, and three newly created triangles can be obtained, such as Figure 5d As shown, three reference triangles corresponding to the target reference vertex E are created according to the coordinate data of each vertex: triangle EFB, triangle EBC and triangle ECD. In addition, a new identifier can be generated for the created new triangles. That is, an identifier "SG EFB "; At the same time, a new identifier "SG EBC "; At the same time, a new identifier "SG ECD ”.
[0131] If the sum of the areas of the reference triangles corresponding to the reference vertex B, reference vertex C, reference vertex D, reference vertex E and reference vertex F of the vertex A to be simplified is the smallest among S5, then the reference vertex F can be determined as the target reference vertex. Then, a triangle formed by any two adjacent reference vertices of the vertex A to be simplified and the target reference vertex F can be created in the 3D model to be simplified, and three newly created triangles can be obtained. Figure 5d As shown, three reference triangles corresponding to the target reference vertex F are created according to the coordinate data of each vertex: triangle FBC, triangle FCD and triangle FDE. In addition, a new identifier can be generated for the created new triangles. That is, an identifier "SG FBC "; At the same time, a new identifier "SG FCD "; At the same time, a new identifier "SG FDE ”.
[0132] Step 311: update the simplification times of each reference vertex, and update the 3D model to be simplified.
[0133] In this step, the value in the counter of each reference vertex of the deleted vertex to be simplified can be added by 1 as the value of the new counter, that is, the number of simplifications of each reference vertex is added by 1 as the new number of simplifications. The structure of the 3D model to be simplified is updated to obtain a new 3D model to be simplified.
[0134] Step 312: When the set X is not an empty set, a new vertex to be simplified is randomly selected from the set X again.
[0135] Step 313, determine whether the vertex to be simplified is in the preset reference vertex set. If the judgment result is no, obtain other vertices directly connected to the vertex to be simplified as reference vertices of the vertex to be simplified, and return to step 306 for the vertex to be simplified; if the judgment result is yes, return to step 312.
[0136] The fact that the vertex to be simplified is not in the preset reference vertex set indicates that the vertex to be simplified has not been simplified.
[0137] Step 314, when the set X is an empty set, determine whether the current number of iterations reaches the preset number of iterations. If the determination result is yes, execute step 315; if the determination result is no, update the number of iterations, and return to execute step 302 for the updated 3D model to be simplified.
[0138] The preset number of iterations may be set to 50 or 100 times, etc., without any specific limitation.
[0139] Step 315, end the simplification operation.
[0140] By adopting the method provided by the embodiment of the present invention, the target triangles that meet the preset simplification times and area conditions in the 3D model to be simplified are deleted from the 3D model, and a triangle consisting of two target reference vertices and any remaining reference vertex is newly created in the 3D model to be simplified, that is, multiple target triangles are deleted and three new triangles are created, so as to achieve the purpose of simplifying the 3D model, so that the model driving device with limited computing power can perform operations such as model rendering and action driving on the 3D model. That is, the 3D model can meet the application scenarios with real-time requirements for operations such as model rendering and action driving.
[0141] Based on the same inventive concept, according to the model simplification method provided by the above embodiment of the present invention, correspondingly, another embodiment of the present invention further provides a model simplification device, whose structural schematic diagram is shown in FIG. Figure 6 As shown, specifically including:
[0142] The first data acquisition module 601 is used to obtain model data of a 3D model to be simplified; the 3D model to be simplified is a model formed by splicing a plurality of triangles; the model data includes: an identifier of each triangle of the 3D model to be simplified and coordinate data of each vertex of each triangle;
[0143] The vertex degree calculation module 602 is used to calculate the degree of each vertex of each triangle of the 3D model to be simplified based on the identifier of each triangle; wherein the degree of a triangle vertex is: the number of sides of the triangle connected to the vertex;
[0144] A vertex determination module 603, configured to determine vertices with a degree equal to 5 as vertices to be simplified;
[0145] The second data acquisition module 604 is used to obtain, for each vertex to be simplified, other vertices directly connected to the vertex to be simplified as reference vertices of the vertex to be simplified; and use triangles formed between the vertex to be simplified and two adjacent reference vertices of the vertex to be simplified in the 3D model to be simplified as target triangles corresponding to the vertex to be simplified;
[0146] The third data acquisition module 605 is used to obtain the simplification times of each vertex to be simplified and each reference vertex of the vertex to be simplified for each vertex to be simplified; and calculate the areas of each target triangle corresponding to the vertex to be simplified based on the coordinate data of the vertex to be simplified and each reference vertex of the vertex to be simplified; wherein the simplification times of each vertex of the triangle is: the number of other vertices in the same triangle as the vertex that are deleted;
[0147] A first judgment module 606 is used to judge, for each vertex to be simplified, whether the preset simplification times and area conditions are met based on the simplification times of each reference vertex and the area of each target triangle;
[0148] Processing module 607 is used to delete the vertex to be simplified and each target triangle corresponding to the vertex to be simplified in the 3D model to be simplified if the conditions are met; and determine a reference vertex from each reference vertex of the vertex to be simplified as a target reference vertex according to the areas of each target triangle corresponding to the vertex to be simplified;
[0149] A triangle creation module 608 is used to create a triangle in the 3D model to be simplified, which is formed by any two adjacent reference vertices of the vertex to be simplified and the target reference vertex, to obtain three newly created triangles;
[0150] The updating module 609 is used to update the simplification times of each reference vertex and to update the 3D model to be simplified.
[0151] It can be seen that, by using the device provided by the embodiment of the present invention, the model data of the 3D model to be simplified is obtained; based on the identification of each triangle, the degree of each vertex of each triangle of the 3D model to be simplified is calculated; the vertex with a degree equal to 5 is determined as the vertex to be simplified; for each vertex to be simplified, other vertices directly connected to the vertex to be simplified are obtained as reference vertices of the vertex to be simplified; and the triangles formed between the reference vertex of the vertex to be simplified and the vertex to be simplified in the 3D model to be simplified are all used as target triangles corresponding to the vertex to be simplified; for each vertex to be simplified, the simplification times of the vertex to be simplified and each reference vertex of the vertex to be simplified are obtained; and based on the coordinate data of the vertex to be simplified and each reference vertex of the vertex to be simplified, Calculate the area of each target triangle corresponding to the vertex to be simplified; for each vertex to be simplified, based on the simplification times and areas of each target triangle of each reference vertex, determine whether the preset simplification times and area conditions are met; if met, delete the vertex to be simplified and each target triangle corresponding to the vertex to be simplified in the 3D model to be simplified; and, according to the areas of each target triangle corresponding to the vertex to be simplified, determine a reference vertex from each reference vertex of the vertex to be simplified as the target reference vertex; create a triangle formed by any two adjacent reference vertices of the vertex to be simplified and the target reference vertex in the 3D model to be simplified, and obtain three newly created triangles; update the simplification times of each reference vertex, and update the 3D model to be simplified. By deleting the target triangle that meets the preset simplification times and area conditions in the 3D model to be simplified from the 3D model, and creating a triangle formed by two target reference vertices and any remaining reference vertex in the 3D model to be simplified, that is, deleting multiple target triangles and creating three new triangles, the purpose of simplifying the 3D model is achieved, so that the model driving device with limited computing power can perform model rendering and action driving operations on the 3D model. That is, the 3D model can meet the application scenarios that have real-time requirements for operations such as model rendering and action driving.
[0152] Furthermore, the processing module 607, for each reference vertex of the vertex to be simplified, takes the triangle formed by the reference vertex and any two remaining adjacent reference vertices as the reference triangle corresponding to the reference vertex, and calculates the sum of the areas of the reference triangles corresponding to the reference vertex; from all the reference vertices of the vertex to be simplified, selects the reference vertex with the smallest sum of the areas of the corresponding reference triangles as the target reference vertex.
[0153] Furthermore, the triangle creation module 608 is specifically used to create a triangle consisting of any two adjacent reference vertices of the vertex to be simplified and the target reference vertex in the 3D model to be simplified according to the coordinate data of each reference vertex of the vertex to be simplified, so as to obtain three newly created triangles; and generate a new identifier for each newly created triangle.
[0154] For further information, see Figure 7 , the first determining module 606 includes:
[0155] The first judgment submodule 701 is used to judge whether the number of simplification times of each vertex to be simplified is less than a first preset number of simplification times, and whether the number of simplification times of each reference vertex of the vertex to be simplified is less than a second preset number of simplification times; if they are all less than, the preset number of simplification times condition is met;
[0156] The second judgment submodule 702 is used to judge whether the area of each target triangle is smaller than a preset area. If so, the preset area condition is satisfied.
[0157] For further information, see Figure 7 The device also includes: a second judgment module 703, used to judge whether the current number of iterations reaches the preset number of iterations; if the current number of iterations reaches the preset number of iterations, end the simplification operation; if the current number of iterations does not reach the preset number of iterations, update the number of iterations; and for the updated 3D model to be simplified, return the identification based on each triangle, and calculate the degree of each vertex of each triangle of the 3D model to be simplified.
[0158] For further information, see Figure 7 , the device further includes: an adding module 704, configured to add each reference vertex after the number of simplifications is updated to the preset reference vertex set;
[0159] The second data acquisition module 604 is specifically used to determine whether each vertex to be simplified is in a preset reference vertex set. If not, it means that the vertex to be simplified has not been simplified, and obtains other vertices directly connected to the vertex to be simplified as reference vertices of the vertex to be simplified.
[0160] It can be seen that, by using the device provided by the embodiment of the present invention, the target triangles that meet the preset simplification times and area conditions in the 3D model to be simplified are deleted from the 3D model, and a new triangle consisting of two target reference vertices and any remaining reference vertex is created in the 3D model to be simplified, that is, multiple target triangles are deleted and three new triangles are created, so as to achieve the purpose of simplifying the 3D model, so that the model driving device with limited computing power can perform operations such as model rendering and action driving on the 3D model. That is, the 3D model can meet the application scenarios with real-time requirements for operations such as model rendering and action driving.
[0161] The embodiment of the present invention further provides an electronic device, such as Figure 8 As shown, it includes a processor 801, a communication interface 802, a memory 803 and a communication bus 804, wherein the processor 801, the communication interface 802, and the memory 803 communicate with each other through the communication bus 804.
[0162] Memory 803, used for storing computer programs;
[0163] The processor 801 is used to execute the program stored in the memory 803, and implements the following steps:
[0164] Obtaining model data of a 3D model to be simplified; the 3D model to be simplified is a model formed by splicing a plurality of triangles; the model data includes: an identifier of each triangle of the 3D model to be simplified and coordinate data of each vertex of each triangle;
[0165] Based on the identifier of each triangle, the degree of each vertex of each triangle of the 3D model to be simplified is calculated; wherein the degree of a triangle vertex is: the number of sides of the triangle connected to the vertex;
[0166] The vertices with a degree of 5 are determined as the vertices to be simplified;
[0167] For each vertex to be simplified, other vertices directly connected to the vertex to be simplified are obtained as reference vertices of the vertex to be simplified; and triangles formed between the vertex to be simplified and two adjacent reference vertices of the vertex to be simplified in the 3D model to be simplified are all used as target triangles corresponding to the vertex to be simplified;
[0168] For each vertex to be simplified, the simplification times of the vertex to be simplified and each reference vertex of the vertex to be simplified are obtained; and based on the coordinate data of the vertex to be simplified and each reference vertex of the vertex to be simplified, the areas of each target triangle corresponding to the vertex to be simplified are calculated; wherein the simplification times of each vertex of the triangle is: the number of other vertices in the same triangle as the vertex that are deleted;
[0169] For each vertex to be simplified, based on the simplification times of each reference vertex and the area of each target triangle, determine whether the preset simplification times and area conditions are met;
[0170] If satisfied, deleting the vertex to be simplified and each target triangle corresponding to the vertex to be simplified in the 3D model to be simplified; and determining a reference vertex from each reference vertex of the vertex to be simplified as a target reference vertex according to the areas of each target triangle corresponding to the vertex to be simplified;
[0171] Create a triangle formed by any two adjacent reference vertices of the vertex to be simplified and the target reference vertex in the 3D model to be simplified, to obtain three newly created triangles;
[0172] The simplification times of each reference vertex are updated, and the 3D model to be simplified is updated.
[0173] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0174] The communication interface is used for communication between the above electronic device and other devices.
[0175] The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0176] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0177] In another embodiment of the present invention, a computer-readable storage medium is provided, in which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above-mentioned model simplification methods are implemented.
[0178] In another embodiment provided by the present invention, a computer program product including instructions is also provided, which, when executed on a computer, enables the computer to execute any one of the model simplification methods in the above embodiments.
[0179] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk Solid State Disk (SSD)), etc.
[0180] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0181] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device, electronic device and storage medium, since they are basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0182] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.
Claims
1. A model simplification method, characterized in that: include: Obtaining model data of the 3D model to be simplified; The 3D model to be simplified is a model formed by splicing multiple triangles; The model data includes: the identifier of each triangle of the 3D model to be simplified and the coordinate data of each vertex of each triangle; Based on the identifier of each triangle, the degree of each vertex of each triangle of the 3D model to be simplified is calculated; wherein the degree of a triangle vertex is: the number of sides of the triangle connected to the vertex; The vertices with a degree of 5 are determined as the vertices to be simplified; For each vertex to be simplified, other vertices directly connected to the vertex to be simplified are obtained as reference vertices of the vertex to be simplified; and triangles formed between the vertex to be simplified and two adjacent reference vertices of the vertex to be simplified in the 3D model to be simplified are all used as target triangles corresponding to the vertex to be simplified; For each vertex to be simplified, the simplification times of the vertex to be simplified and each reference vertex of the vertex to be simplified are obtained; and based on the coordinate data of the vertex to be simplified and each reference vertex of the vertex to be simplified, the areas of each target triangle corresponding to the vertex to be simplified are calculated; wherein the simplification times of each vertex of the triangle is: the number of other vertices in the same triangle as the vertex that are deleted; For each vertex to be simplified, based on the simplification times of each reference vertex and the area of each target triangle, determine whether the preset simplification times and area conditions are met; The step of determining, for each vertex to be simplified, whether the preset simplification times and area conditions are met based on the simplification times of each reference vertex and the area of each target triangle, includes: Determine whether the simplification times of each vertex to be simplified are less than the first preset simplification times, and whether the simplification times of each reference vertex of the vertex to be simplified are all less than the second preset simplification times; if they are all less than, the preset simplification times condition is met; Determine whether the area of each target triangle is smaller than the preset area. If so, the preset area condition is met. If satisfied, deleting the vertex to be simplified and each target triangle corresponding to the vertex to be simplified in the 3D model to be simplified; and determining a reference vertex from each reference vertex of the vertex to be simplified as a target reference vertex according to the areas of each target triangle corresponding to the vertex to be simplified; Create a triangle formed by any two adjacent reference vertices of the vertex to be simplified and the target reference vertex in the 3D model to be simplified, to obtain three newly created triangles; The simplification times of each reference vertex are updated, and the 3D model to be simplified is updated, so that the model driving device performs model rendering and action driving on the updated 3D model to be simplified.
2. The method according to claim 1, characterized in that The step of determining a reference vertex from the reference vertices of the vertex to be simplified as a target reference vertex according to the areas of the target triangles corresponding to the vertex to be simplified includes: For each reference vertex of the vertex to be simplified, a triangle formed between the reference vertex and any two remaining adjacent reference vertices is used as a reference triangle corresponding to the reference vertex, and the sum of the areas of the reference triangles corresponding to the reference vertex is calculated; From all reference vertices of the vertex to be simplified, the reference vertex with the smallest sum of areas of corresponding reference triangles is selected as the target reference vertex.
3. The method according to claim 1, characterized in that The step of creating a triangle formed by any two adjacent reference vertices of the vertex to be simplified and the target reference vertex in the 3D model to be simplified, and obtaining three newly created triangles includes: According to the coordinate data of each reference vertex of the vertex to be simplified, a triangle formed by any two adjacent reference vertices of the vertex to be simplified and the target reference vertex is created in the 3D model to be simplified to obtain three newly created triangles; and a new identifier is generated for each newly created triangle.
4. The method according to claim 1, characterized in that: After the 3D model to be simplified is updated, the method further includes: Determine whether the current number of iterations reaches the preset number of iterations; If the current number of iterations reaches the preset number of iterations, the simplification operation ends; If the current number of iterations does not reach the preset number of iterations, the number of iterations is updated; and for the updated 3D model to be simplified, the step of calculating the degree of each vertex of each triangle of the 3D model to be simplified based on the identifier of each triangle is returned.
5. The method according to claim 4, characterized in that After updating the number of simplifications of each reference vertex, the method further includes: Add each reference vertex after updating the simplification times to the preset reference vertex set; The step of obtaining, for each vertex to be simplified, other vertices directly connected to the vertex to be simplified as reference vertices for the vertex to be simplified comprises: For each vertex to be simplified, determine whether the vertex to be simplified is in the preset reference vertex set. If not, it means that the vertex to be simplified has not been simplified. Obtain other vertices directly connected to the vertex to be simplified as reference vertices for the vertex to be simplified.
6. A model simplification device, characterized in that: include: A first data acquisition module, used to obtain model data of the 3D model to be simplified; The 3D model to be simplified is a model formed by splicing multiple triangles; The model data includes: the identifier of each triangle of the 3D model to be simplified and the coordinate data of each vertex of each triangle; A vertex degree calculation module, used to calculate the degree of each vertex of each triangle of the 3D model to be simplified based on the identifier of each triangle; wherein the degree of a triangle vertex is: the number of sides of the triangle connected to the vertex; A vertex determination module, used for determining vertices with a degree equal to 5 as vertices to be simplified; The second data acquisition module is used to obtain, for each vertex to be simplified, other vertices directly connected to the vertex to be simplified as reference vertices of the vertex to be simplified; and use triangles formed between the vertex to be simplified and two adjacent reference vertices of the vertex to be simplified in the 3D model to be simplified as target triangles corresponding to the vertex to be simplified; The third data acquisition module is used to obtain, for each vertex to be simplified, the simplification times of the vertex to be simplified and each reference vertex of the vertex to be simplified; and, based on the coordinate data of the vertex to be simplified and each reference vertex of the vertex to be simplified, calculate the area of each target triangle corresponding to the vertex to be simplified; wherein the simplification times of each vertex of the triangle is: the number of other vertices in the same triangle as the vertex that are deleted; A first judgment module is used to judge, for each vertex to be simplified, whether the preset simplification times and area conditions are met based on the simplification times of each reference vertex and the area of each target triangle; The first judgment module includes: A first judgment submodule is used to judge whether the number of simplification times of each vertex to be simplified is less than a first preset number of simplification times, and whether the number of simplification times of each reference vertex of the vertex to be simplified is less than a second preset number of simplification times; if they are all less than, the preset number of simplification times condition is met; The second judgment submodule is used to judge whether the area of each target triangle is smaller than a preset area. If so, the preset area condition is met; A processing module, configured to delete the vertex to be simplified and each target triangle corresponding to the vertex to be simplified in the 3D model to be simplified if the conditions are met; and determine a reference vertex from each reference vertex of the vertex to be simplified as a target reference vertex according to the areas of each target triangle corresponding to the vertex to be simplified; A triangle creation module, used to create a triangle formed by any two adjacent reference vertices of the vertex to be simplified and a target reference vertex in the 3D model to be simplified, to obtain three newly created triangles; The updating module is used to update the simplification times of each reference vertex and update the 3D model to be simplified, so that the model driving device performs model rendering and action driving on the updated 3D model to be simplified.
7. The device according to claim 6, characterized in that The processing module, for each reference vertex of the vertex to be simplified, takes the triangle formed by the reference vertex and any two remaining adjacent reference vertices as the reference triangle corresponding to the reference vertex, and calculates the sum of the areas of the reference triangles corresponding to the reference vertex; From all reference vertices of the vertex to be simplified, the reference vertex with the smallest sum of areas of corresponding reference triangles is selected as the target reference vertex.
8. The device according to claim 6, characterized in that The triangle creation module is specifically used to create a triangle formed by any two adjacent reference vertices of the vertex to be simplified and the target reference vertex in the 3D model to be simplified according to the coordinate data of each reference vertex of the vertex to be simplified, so as to obtain three newly created triangles; and generate a new identifier for each newly created triangle.
9. The device according to claim 6, characterized in that Also includes: The second judgment module is used to judge whether the current number of iterations reaches the preset number of iterations; If the current number of iterations reaches the preset number of iterations, the simplification operation ends; If the current number of iterations does not reach the preset number of iterations, update the number of iterations; And for the updated 3D model to be simplified, the step of calculating the degree of each vertex of each triangle of the 3D model to be simplified based on the identifier of each triangle is returned.
10. The device according to claim 9, characterized in that Also includes: An adding module is used to add each reference vertex after the simplification times are updated to the preset reference vertex set; The second data acquisition module is specifically used to determine whether each vertex to be simplified is in a preset reference vertex set. If not, it means that the vertex to be simplified has not been simplified, and obtains other vertices directly connected to the vertex to be simplified as reference vertices of the vertex to be simplified.
11. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, for implementing any of the methods described in claims 1-5 when executing a program stored in a memory.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Three-dimensional model simplification method and system
CN108460836A
Processing method for triangular mesh model, processing terminal and storage medium
CN109448125A