Flexible body surface grid processing method and device, electronic equipment and storage medium
By using energy optimization algorithms and particle models to optimize the mesh distribution of flexible body surfaces without changing the mesh topological relationship, the problems of complex operation and high computational consumption in the existing technology are solved, and more efficient and high-precision simulation is achieved.
Patent Information
- Application Number
- CN202311647795.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-04
- Publication Date
- 2025-06-06
AI Technical Summary
The prior art is used to optimize the flexible body surface mesh adaptively, with high degrees of freedom, and the grid information needs to be updated after each optimization, which increases the calculation consumption during the physical simulation process.
By obtaining the mesh parameters of the graph file of the flexible body, calculating deformation parameters, using energy optimization algorithms and particle models to optimize the mesh distribution without changing the mesh topological relationship, and adjusting the resolution and distribution of the mesh in real time.
The calculation amount during the physical simulation process is reduced, the simulation is achieved with higher precision, and the grid distribution can be optimized in real time according to the deformation characteristics of the flexible body.
Smart Images

Figure CN120107507A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of graphic simulation technology, and in particular to a method and device for processing a flexible body surface mesh, an electronic device, and a computer-readable storage medium. Background Art
[0002] Flexible body mesh optimization is an important research direction in the field of computer graphics and simulation. With the continuous development of computer graphics and simulation technology, the demand for simulating objects with deformation and elastic properties is increasing. At present, the adaptive optimization method aims to dynamically adjust the topology, resolution or metric of the mesh according to the deformation of the flexible body during the physical simulation process, so as to achieve high-quality simulation and animation effects. This is because the shape characteristics of the flexible body will change in real time during the deformation process, so the number of meshes or mesh distribution required should also change accordingly to obtain better detail control and realism. For example, during the deformation process of cloth, its curved part and flat part will constantly change. As the key feature area of the cloth, the curved part needs to use a higher resolution mesh to obtain more accurate simulation results.
[0003] Mesh reshaping is the mainstream method for adaptive optimization of flexible body surface meshes. The algorithm needs to define a dynamic metric to detect the deformation characteristics of the flexible body in real time in order to achieve the ideal spatial and directional distribution of mesh resolution. The dynamic metric can be composed of geometric features of a single or multiple meshes, such as the normal direction of mesh vertices, the area or volume of the mesh, the velocity difference of mesh vertices, the deformation of mesh edges, etc. Different topological operations are performed on the mesh through the judgment of dynamic metrics, such as: flipping, collapsing and splitting of mesh edges, adding and deleting mesh vertices.
[0004] However, although this method can optimize the quality and distribution of the mesh according to the deformation characteristics of the flexible body, its operation on the mesh edges and points is relatively complex and has a high degree of freedom. At the same time, this method changes the topological relationship of the mesh, so that the mesh information needs to be updated after each optimization, which increases the computational consumption in the physical simulation process. Summary of the invention
[0005] The purpose of the embodiments of the present application is to provide a method and device for processing the mesh of a flexible body surface, an electronic device, and a computer-readable storage medium, which are used to optimize the mesh distribution of the deformed area and the potential deformed area on the surface of the flexible body while maintaining the topological relationship of the mesh, thereby greatly reducing the amount of calculation in the physical simulation process, and can optimize the distribution of the mesh in real time according to the deformation characteristics of the flexible body, so as to perform higher-precision simulation later.
[0006] In one aspect, the present application provides a method for processing a flexible body surface mesh, comprising:
[0007] Obtaining mesh parameters of a graphic file of a flexible body, and calculating deformation parameters of the graphic file based on the mesh parameters; wherein the mesh parameters include a first UV coordinate and a three-dimensional coordinate of each mesh vertex; and the deformation parameters include a curvature of each mesh and a curvature of each mesh vertex;
[0008] Determine the auxiliary UV coordinates of the mesh vertices of the auxiliary mesh corresponding to each mesh according to the curvature of each mesh and the first UV coordinates of the mesh vertices;
[0009] Based on the energy optimization algorithm, the first UV coordinates of the mesh vertices of each mesh and the auxiliary UV coordinates of the mesh vertices of the auxiliary mesh corresponding to each mesh are processed to update the second UV coordinates of the mesh vertices of each mesh;
[0010] Determine a curvature gradient of each mesh vertex based on the second UV coordinate and the curvature of the mesh vertex of each mesh;
[0011] Under the updated curvature gradient of each mesh vertex, the second UV coordinate of each mesh vertex is redistributed based on the particle model to obtain the third UV coordinate of the mesh vertex of each mesh;
[0012] Based on the third UV coordinates of the mesh vertices of each mesh, the three-dimensional coordinates of the mesh vertices of each mesh are updated to obtain updated three-dimensional coordinates of the mesh vertices of each mesh.
[0013] In one embodiment, the calculating the deformation parameters of the graphic file based on the grid parameters includes:
[0014] Based on the mesh parameters, the curvature of each mesh vertex and the curvature of each mesh in the graphic file are calculated by using the Laplace-Beltrami operator.
[0015] In one embodiment, determining the auxiliary UV coordinates of the mesh vertices of the auxiliary mesh corresponding to each mesh based on the curvature of each mesh and the first UV coordinates of the mesh vertices includes:
[0016] Calculating a target optimized area of each mesh based on the curvature and initial mesh area of each mesh; wherein the initial mesh area is determined based on the first UV coordinates of the mesh vertices of the mesh;
[0017] Determining an area weighting coefficient according to the sum of the initial mesh areas of all meshes in the graphic file and the sum of the target optimization areas of all meshes;
[0018] Based on the area weighting coefficient and the first UV coordinates of the mesh vertices of each mesh, auxiliary UV coordinates of the mesh vertices of the auxiliary mesh corresponding to each mesh are determined.
[0019] In one embodiment, the energy optimization algorithm includes an iterative algorithm and an energy function;
[0020] The energy optimization algorithm is used to process the first UV coordinates of the mesh vertices of each mesh and the auxiliary UV coordinates of the mesh vertices of the auxiliary mesh corresponding to each mesh, and the second UV coordinates of the mesh vertices of each mesh are updated, including:
[0021] Using the first UV coordinates of the mesh vertices of all meshes in the graphic file and the auxiliary UV coordinates of the mesh vertices of all auxiliary meshes as inputs of the iterative algorithm, to obtain the updated first UV coordinates of the mesh vertices of each mesh;
[0022] Evaluate the energy value of the grid area after all grids are updated through the energy function, and determine whether the energy value is reduced compared to the energy value before the update;
[0023] If the energy value decreases, returning to the step of using the first UV coordinates of the mesh vertices of all meshes in the graphic file and the auxiliary UV coordinates of the mesh vertices of all auxiliary meshes as inputs of the iterative algorithm;
[0024] After repeated iterations, when the energy value of the energy function tends to be stable, the iteratively updated first UV coordinates of all mesh vertices are determined as second UV coordinates.
[0025] In one embodiment, before determining the auxiliary UV coordinates of the mesh vertices of the auxiliary mesh corresponding to each mesh based on the curvature of each mesh and the first UV coordinates of the mesh vertices, the method further comprises:
[0026] Smooths the curvature of each mesh vertex until the smoothing number is reached.
[0027] In one embodiment, the smoothing process is a Laplace smoothing process, the smoothing times are Laplace smoothing times, and the step of obtaining the Laplace smoothing times includes:
[0028] Selecting a maximum curvature from the curvatures of all mesh vertices, and determining a target curvature using the maximum curvature and a preset adjustment coefficient;
[0029] Screening out a plurality of target mesh vertices; wherein the curvature of the target mesh vertices is greater than the target curvature;
[0030] Calculate the target ratio between the sum of the Voronoi areas corresponding to all target mesh vertices and the sum of the Voronoi areas corresponding to all mesh vertices;
[0031] The Laplace smoothing order is calculated according to the target ratio.
[0032] In one embodiment, before determining the curvature gradient of each mesh vertex based on the second UV coordinate and the curvature of the mesh vertex of each mesh, the method comprises:
[0033] For any mesh vertex to be processed, based on the second UV coordinate of the mesh vertex to be processed and the first UV coordinate of the mesh vertex of the initial mesh, determine the initial mesh where the mesh vertex to be processed is located; wherein the initial mesh is the mesh before being updated by the energy optimization algorithm;
[0034] Determine three triangles in the initial mesh according to the connection between the mesh vertices to be processed and the mesh vertices of the initial mesh, and use the areas of the three triangles as three weight values;
[0035] Taking a weighted sum of the curvatures of the mesh vertices of the initial mesh using the three weight values, to obtain the curvatures of the mesh vertices to be processed;
[0036] Each mesh vertex is used as a mesh vertex to be processed, so as to update the curvature of each mesh vertex under the second UV coordinate.
[0037] In one embodiment, determining the curvature gradient of each mesh vertex based on the second UV coordinate and the curvature of the mesh vertex of each mesh includes:
[0038] For any specified mesh vertex, a single edge curvature gradient of the specified mesh vertex along an adjacent edge is calculated; the magnitude of the single edge curvature gradient is a quotient of a curvature difference between the specified mesh vertex and an adjacent vertex on the adjacent edge divided by a length of the adjacent edge; the direction of the single edge curvature gradient is a unit direction along the adjacent edge to the specified mesh vertex; the length and direction of the adjacent edge are determined based on a second UV coordinate of the specified mesh vertex and a second UV coordinate of an adjacent vertex on the adjacent edge;
[0039] For the specified mesh vertex, determine the processed curvature gradient based on two single curvature gradients of every two adjacent neighboring edges and the adjacent edge angle;
[0040] Determining the curvature gradient of the specified mesh vertex according to a plurality of processed curvature gradients on the specified mesh vertex;
[0041] Each mesh vertex is used as a designated mesh vertex to determine the curvature gradient of all mesh vertices.
[0042] In one embodiment, the updating of the three-dimensional coordinates of the mesh vertices of each mesh based on the third UV coordinates of the mesh vertices of each mesh to obtain the updated three-dimensional coordinates of the mesh vertices of each mesh includes:
[0043] For any mesh vertex to be updated, based on the third UV coordinate of the mesh vertex to be updated and the first UV coordinate of the mesh vertex of the initial mesh, determine the initial mesh where the mesh vertex to be updated is located; wherein the initial mesh is the mesh before being updated by the energy optimization algorithm;
[0044] Determine three triangles in the initial mesh according to the connection between the mesh vertices to be updated and the mesh vertices of the initial mesh, and use the areas of the three triangles as three weight values;
[0045] Taking weighted sum of the three-dimensional coordinates of the mesh vertices of the initial mesh using the three weight values, to obtain the three-dimensional coordinates of the mesh vertices to be updated;
[0046] Each mesh vertex is used as a mesh vertex to be updated to obtain the updated three-dimensional coordinates of each mesh vertex.
[0047] In one embodiment, after obtaining the third UV coordinate of each mesh vertex, the method further includes:
[0048] Update the curvature of each mesh vertex at the third UV coordinate based on the third UV coordinate of each mesh vertex;
[0049] Update the curvature of each mesh using the curvature of each mesh vertex under the third UV coordinate;
[0050] Determine the auxiliary UV coordinates of the mesh vertices of the auxiliary mesh corresponding to each mesh according to the updated curvature of each mesh and the third UV coordinates of each mesh vertex;
[0051] Processing the third UV coordinates of the mesh vertices of each mesh and the auxiliary UV coordinates of the mesh vertices of the auxiliary mesh corresponding to each mesh based on the energy optimization algorithm to update the third UV coordinates of the mesh vertices of each mesh;
[0052] Return to the step of updating the curvature of each mesh vertex under the third UV coordinate based on the third UV coordinate of each mesh vertex, until the loop is repeated multiple times, and the iteratively updated third UV coordinates of all mesh vertices are used as the fourth UV coordinates;
[0053] Based on the fourth UV coordinates of the mesh vertices of each mesh, the three-dimensional coordinates of the mesh vertices of each mesh are updated to obtain the updated three-dimensional coordinates of the mesh vertices of each mesh.
[0054] In one embodiment, before updating the curvature of each mesh using the curvature of each mesh vertex under the third UV coordinate, the method includes:
[0055] Smooths the curvature of each mesh vertex at the third UV coordinate until the smoothing number is reached.
[0056] In one embodiment, determining the auxiliary UV coordinates of the mesh vertices of the auxiliary mesh corresponding to each mesh by using the updated curvature of each mesh and the third UV coordinates of each mesh vertex includes:
[0057] Calculating the target optimized area of each mesh by using the updated curvature of each mesh, the third mesh area and the area weighted correction coefficient; wherein the third mesh area is determined based on the third UV coordinates of the mesh vertices of the mesh;
[0058] Determining an area weighting coefficient according to the sum of the third grid areas of all grids in the graphic file and the sum of the target optimization areas of all grids;
[0059] Based on the area weighting coefficient and the third UV coordinates of the mesh vertices of each mesh, auxiliary UV coordinates of the mesh vertices of the auxiliary mesh corresponding to each mesh are determined.
[0060] In one embodiment, the step of obtaining the area weighted correction coefficient includes:
[0061] Selecting a maximum curvature from the curvatures of all mesh vertices under the first UV coordinate, and determining a target curvature using the maximum curvature and a preset adjustment coefficient;
[0062] Screening out a plurality of target mesh vertices; wherein the curvature of the target mesh vertices under the first UV coordinate is greater than the target curvature;
[0063] Calculate the target ratio between the sum of the Voronoi areas corresponding to all target mesh vertices and the sum of the Voronoi areas corresponding to all mesh vertices;
[0064] The area weighted correction coefficient is calculated according to the target ratio.
[0065] In one embodiment, the method further comprises:
[0066] Update the curvature of each mesh vertex at the fourth UV coordinate based on the fourth UV coordinate of each mesh vertex;
[0067] Update the curvature of each mesh using the curvature of each mesh vertex under the fourth UV coordinate;
[0068] Determine the auxiliary UV coordinates of the mesh vertices of the auxiliary mesh corresponding to each mesh according to the updated curvature of each mesh and the fourth UV coordinates of each mesh vertex;
[0069] Processing the fourth UV coordinates of the mesh vertices of each mesh and the auxiliary UV coordinates of the mesh vertices of the auxiliary mesh corresponding to each mesh based on the energy optimization algorithm to update the fourth UV coordinates of the mesh vertices of each mesh;
[0070] Return to the step of updating the curvature of each mesh vertex under the fourth UV coordinate based on the fourth UV coordinate of each mesh vertex, until the loop is repeated multiple times, and the iteratively updated fourth UV coordinates of all mesh vertices are used as the fifth UV coordinates;
[0071] Based on the fifth UV coordinates of the mesh vertices of each mesh, the three-dimensional coordinates of the mesh vertices of each mesh are updated to obtain the updated three-dimensional coordinates of the mesh vertices of each mesh.
[0072] In one embodiment, determining the auxiliary UV coordinates of the mesh vertices of the auxiliary mesh corresponding to each mesh by using the updated curvature of each mesh and the fourth UV coordinates of each mesh vertex includes:
[0073] Calculating the target optimized area of each mesh by using the updated curvature of each mesh, the fourth mesh area and the area weighted correction coefficient; wherein the fourth mesh area is determined based on the fourth UV coordinates of the mesh vertices of the mesh;
[0074] Determining an area weighting coefficient according to the sum of the fourth grid areas of all grids in the graphic file and the sum of the target optimization areas of all grids;
[0075] Based on the area weighting coefficient and the fourth UV coordinates of the mesh vertices of each mesh, auxiliary UV coordinates of the mesh vertices of the auxiliary mesh corresponding to each mesh are determined.
[0076] In one embodiment, the step of acquiring grid parameters of a graphic file of a flexible body and calculating deformation parameters of the graphic file based on the grid parameters includes:
[0077] Acquire mesh parameters of a graphic file of a flexible body, and determine whether a mesh in the graphic file is a triangular mesh based on the mesh parameters;
[0078] If not, dividing the graphic file so that all meshes in the graphic file are divided into triangular meshes, and obtaining mesh parameters of the graphic file after the division process;
[0079] According to the grid parameters of the divided graphic file, the deformation parameters of the divided graphic file are calculated.
[0080] On the other hand, the present application provides a processing device for a flexible body surface grid, comprising:
[0081] An acquisition module, used for acquiring mesh parameters of a graphic file of a flexible body, and calculating deformation parameters of the graphic file based on the mesh parameters; wherein the mesh parameters include a first UV coordinate and a three-dimensional coordinate of each mesh vertex; and the deformation parameters include a curvature of each mesh and a curvature of each mesh vertex;
[0082] A first determination module is used to determine the auxiliary UV coordinates of the mesh vertices of the auxiliary mesh corresponding to each mesh based on the curvature of each mesh and the first UV coordinates of the mesh vertices;
[0083] A first processing module is used to process the first UV coordinates of the mesh vertices of each mesh and the auxiliary UV coordinates of the mesh vertices of the auxiliary mesh corresponding to each mesh based on an energy optimization algorithm, and update the second UV coordinates of the mesh vertices of each mesh;
[0084] A second determination module, configured to determine a curvature gradient of each mesh vertex based on a second UV coordinate and a curvature of the mesh vertex of each mesh;
[0085] A second processing module is used for redistributing the second UV coordinates of each mesh vertex based on the particle model under the updated curvature gradient of each mesh vertex to obtain the third UV coordinates of the mesh vertex of each mesh;
[0086] The updating module is used to update the three-dimensional coordinates of the mesh vertices of each mesh based on the third UV coordinates of the mesh vertices of each mesh to obtain the updated three-dimensional coordinates of the mesh vertices of each mesh.
[0087] Furthermore, the present application provides an electronic device, the electronic device comprising:
[0088] processor;
[0089] a memory for storing processor-executable instructions;
[0090] Wherein, the processor is configured to execute the above-mentioned method for processing the surface mesh of a flexible body.
[0091] In addition, the present application provides a computer-readable storage medium, wherein the storage medium stores a computer program, and the computer program can be executed by a processor to complete the above-mentioned method for processing the surface mesh of a flexible body.
[0092] The solution of this application combines the energy optimization algorithm and the particle model to optimize the mesh distribution of the deformation area and potential deformation area on the surface of the flexible body without changing the topological relationship of the mesh, and the optimized mesh has the smoothness and directionality required for simulation. Compared with related solutions, there is no need for complex topological operations and no need to change the topological relationship of the mesh, which greatly reduces the amount of calculation in the physical simulation process, and can optimize the distribution of the mesh in real time according to the deformation characteristics of the flexible body, so as to perform higher-precision simulation later. BRIEF DESCRIPTION OF THE DRAWINGS
[0093] In order to more clearly illustrate the technical solution of the embodiments of the present application, the drawings required for use in the embodiments of the present application are briefly introduced below.
[0094] Figure 1 A schematic diagram of the structure of an electronic device provided in one embodiment of the present application;
[0095] Figure 2 A schematic flow chart of a method for processing a flexible body surface mesh provided in one embodiment of the present application;
[0096] Figure 3 An embodiment of the present application provides Figure 2 Detailed flow chart of step 220;
[0097] Figure 4 An embodiment of the present application provides Figure 2 Detailed flow chart of step 230;
[0098] Figure 5 A flowchart of a method for determining the number of Laplace smoothing times provided in an embodiment of the present application;
[0099] Figure 6 A schematic diagram of a flow chart of a method for updating the curvature of mesh vertices provided in one embodiment of the present application;
[0100] Figure 7 An embodiment of the present application provides Figure 2 Detailed flow chart of step 240;
[0101] Figure 8 An embodiment of the present application provides Figure 2 Detailed flow chart of step 260;
[0102] Fig. 9 A schematic diagram of a process for encrypting a mesh in a high curvature area provided in an embodiment of the present application;
[0103] Fig.10 An embodiment of the present application provides Fig. 9 Detailed flowchart of step 930;
[0104] Fig.11 A schematic flow chart of a method for determining an area weighted correction coefficient provided in an embodiment of the present application;
[0105] Fig.12 A schematic diagram of a process for re-encrypting a mesh in a high curvature area provided in an embodiment of the present application;
[0106] Fig.13 An embodiment of the present application provides Fig.12 Detailed flow chart of step 1230;
[0107] Fig.14 A block diagram of a flexible body surface mesh processing device provided in one embodiment of the present application. DETAILED DESCRIPTION
[0108] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.
[0109] Similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of this application, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.
[0110] like Figure 1 As shown, this embodiment provides an electronic device 1, including: at least one processor 11 and a memory 12, Figure 1 A processor 11 is taken as an example. The processor 11 and the memory 12 are connected via a bus 10. The memory 12 stores instructions that can be executed by the processor 11. The instructions are executed by the processor 11 so that the electronic device 1 can execute all or part of the process of the method in the following embodiment. In one embodiment, the electronic device 1 can be a host, a server, a server cluster or a cloud service center, etc., for executing the method for processing the surface mesh of a flexible body.
[0111] The memory 12 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable red-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, disk or optical disk.
[0112] The present application also provides a computer-readable storage medium, which stores a computer program. The computer program can be executed by the processor 11 to complete the method for processing the flexible body surface mesh provided in the present application.
[0113] See also Figure 2, is a flow chart of a method for processing a flexible body surface mesh provided in an embodiment of the present application, such as Figure 2 As shown, the method may include the following steps 210 - 260 .
[0114] Step 210: Obtaining mesh parameters of the graphic file of the flexible body, and calculating deformation parameters of the graphic file based on the mesh parameters; wherein the mesh parameters include the first UV coordinates and three-dimensional coordinates of each mesh vertex; and the deformation parameters include the curvature of each mesh and the curvature of each mesh vertex.
[0115] The graphics file of the flexible body is a mesh parameter including the mesh number of the mesh, the number of mesh vertices of the mesh, the first UV coordinates and three-dimensional coordinates of the mesh vertices, the number of the edge of the mesh and the number of the connection point of the edge (the connection point of the edge is the mesh vertex), and the number of the mesh vertex on the boundary of the graphics file. Here, the first UV coordinate of the mesh vertex is the coordinate of the mesh vertex in the UV coordinate system in the initial state; the three-dimensional coordinate of the mesh vertex is the coordinate of the mesh vertex in the three-dimensional coordinate system in the initial state.
[0116] In the present application, the triangle mesh can be used as the processing object, and the deformation parameters can be calculated through the mesh parameters of the triangle mesh. The mesh in the graphic file is usually a triangle mesh, but it can also be a polygonal mesh, such as a quadrilateral mesh, a pentagonal mesh, etc.
[0117] In one embodiment, when executing step 210, the mesh parameters of the graphic file of the flexible body can be obtained, and whether the mesh in the graphic file is a triangular mesh can be determined based on the mesh parameters. According to the numbers of the mesh vertices corresponding to each mesh number, the number of mesh vertices contained in a single mesh can be determined, and then whether the mesh in the graphic file is a triangular mesh can be determined.
[0118] In one case, if the mesh in the graphics file is a triangular mesh, the mesh parameters of the triangle can be directly calculated to obtain the deformation parameters of the graphics file. In another case, if the mesh in the graphics file is not a triangular mesh, the graphics file can be divided so that all meshes in the graphics file are divided into triangular meshes to obtain the mesh parameters of the graphics file after the division process. Exemplarily, the mesh in the graphics file is a quadrilateral mesh, and each quadrilateral mesh can be divided into two triangular meshes. After the division process, a new mesh number can be assigned to each triangular mesh obtained by the division, and the association between the mesh number of the quadrilateral mesh and the mesh number of the divided triangular mesh can be recorded. In addition, the association between the mesh number obtained by the divided triangular mesh and the number of the corresponding mesh vertices and the number of the edges can be recorded.
[0119] After the graphic file is divided, the deformation parameters of the divided graphic file can be calculated according to the mesh parameters of the divided graphic file. After the division, the triangle mesh in the graphic file is used as the processing object, and the deformation parameters can be calculated according to the mesh parameters of the triangle mesh.
[0120] Through this measure, the present solution can process polygonal mesh graphics files.
[0121] Step 220: Determine auxiliary UV coordinates of mesh vertices of the auxiliary mesh corresponding to each mesh based on the curvature of each mesh and the first UV coordinates of the mesh vertices.
[0122] Each grid corresponds to an auxiliary grid, and the auxiliary grid is the target of the corresponding grid during energy optimization.
[0123] Based on the curvature of each mesh in the deformation parameters and the first UV coordinates of the mesh vertices, the auxiliary UV coordinates of the mesh vertices of the auxiliary mesh corresponding to each mesh vertex can be calculated, wherein the auxiliary UV coordinates are the coordinates of the auxiliary mesh in the UV coordinate system.
[0124] Step 230: Based on the energy optimization algorithm, the first UV coordinates of the mesh vertices of each mesh and the auxiliary UV coordinates of the mesh vertices of the auxiliary mesh corresponding to each mesh are processed to update the second UV coordinates of the mesh vertices of each mesh.
[0125] The energy optimization algorithm includes an iterative algorithm and an energy function. The iterative algorithm may be a Newton iterative algorithm or a quasi-Newton iterative algorithm. For example, the iterative algorithm may be any one of an L-BFGS algorithm, an SR1 algorithm, and a DFP algorithm.
[0126] The first UV coordinates of the mesh vertices of each mesh and the auxiliary UV coordinates of the mesh vertices of the auxiliary mesh corresponding to each mesh are used as inputs of the iterative algorithm to obtain updated UV coordinates of the mesh vertices output by the iterative algorithm.
[0127] After the iteration function updates the UV coordinates of the mesh vertices, the energy value is evaluated by the energy function as a basis for whether to perform a new round of iteration. Here, the energy function can be a function of the mesh area, mesh edge length, mesh angle, or mesh vertex coordinates.
[0128] The updated UV coordinates of the mesh vertices of each mesh and the auxiliary UV coordinates of the mesh vertices of the auxiliary mesh corresponding to each mesh are used as inputs of the iterative algorithm again to obtain the further updated UV coordinates of the mesh vertices output by the iterative algorithm.
[0129] Through repeated iterations, the updated UV coordinates of the mesh vertices output by the iterative algorithm for the last time may be used as the second UV coordinates.
[0130] Step 240: Determine the curvature gradient of each mesh vertex based on the second UV coordinate and the curvature of the mesh vertex of each mesh.
[0131] After obtaining the second UV coordinates of the mesh vertices of each mesh, the meshes in the graphic file are initially encrypted. At this time, since the UV coordinates of the mesh vertices are updated from the first UV coordinates to the second UV coordinates, the curvature of each mesh vertex under the second UV coordinates can be recalculated.
[0132] After the curvature of each mesh vertex is updated, the curvature gradient of each mesh vertex may be updated based on the second UV coordinate and the curvature of each mesh vertex.
[0133] Step 250: Under the updated curvature gradient of each mesh vertex, redistribute the second UV coordinate of each mesh vertex based on the particle model to obtain the third UV coordinate of the mesh vertex of each mesh.
[0134] Among them, the particle model can regard each mesh vertex as a particle to redistribute the mesh vertices, thereby adjusting the mesh density of different areas in the graphic file. The particle model can be based on a spring particle system and a strain limiting model, using the curvature gradient to construct a vector field for particle motion. Here, the spring particle system can be replaced by other forms of algorithms to update the mesh point position, such as the PBD (Position Based Dynamics) algorithm and the PD (Projective dynamics) algorithm.
[0135] When the mass model is based on a spring mass system and a strain limit model, relevant parameters can be preconfigured for the spring mass system, for example, the mass and step size of the spring mass can be set to 1, the spring stiffness is 105, and the allowable strain is 0.1, that is, the edge of the mesh can be stretched or shrunk by 10%. In order to make the distribution of the mesh meet the expected optimization results, this solution constructs a vector field similar to an external force applied to the mesh vertices. The direction of the vector field is the curvature gradient of the mesh vertices, and the magnitude is the force that produces one percent of the allowable strain on the mesh vertices, that is, 0.01*allowable strain*spring stiffness*average length of the adjacent edges of the mesh vertices.
[0136] After configuring the relevant parameters for the spring mass system of the mass model, the second UV coordinates of each mesh vertex and the updated curvature gradient are input into the mass model, and the third UV coordinates of the mesh vertices of each mesh output by the mass model can be obtained. Here, the third UV coordinates of each mesh vertex are UV coordinates obtained by redistribution based on the second UV coordinates of each mesh vertex.
[0137] Step 260: Based on the third UV coordinates of the mesh vertices of each mesh, the three-dimensional coordinates of the mesh vertices of each mesh are updated to obtain updated three-dimensional coordinates of the mesh vertices of each mesh.
[0138] After the UV coordinates of each mesh vertex in the UV coordinate system are converted from the first UV coordinates to the third UV coordinates, the three-dimensional coordinates of the vertex in the three-dimensional coordinate system should also change accordingly. Therefore, for each mesh vertex, a linear interpolation algorithm is used to map the third UV coordinates to the three-dimensional coordinate system, thereby obtaining the three-dimensional coordinates of the mesh vertex in the three-dimensional coordinate system.
[0139] After the third UV coordinates and the three-dimensional coordinates are updated for each mesh vertex in the graphic file of the flexible body, the updated mesh parameters of the graphic file can be obtained, and the updated mesh parameters can be output for subsequent simulation calculations. In addition, for a graphic file whose mesh is not a triangular mesh, after the third UV coordinates and the updated three-dimensional coordinates of each mesh vertex are obtained, the previously divided triangular mesh can be deleted, and the mesh parameters can be recorded in the form of the original polygonal mesh.
[0140] Through the above measures, combined with the energy optimization algorithm and the particle model, the mesh distribution of the deformation area and potential deformation area on the surface of the flexible body is optimized on the basis of maintaining the topological relationship of the mesh, and the optimized mesh has the smoothness and directionality required for simulation. Compared with related solutions, there is no need for complex topological operations and no need to change the topological relationship of the mesh, which greatly reduces the amount of calculation in the physical simulation process, and can optimize the distribution of the mesh in real time according to the deformation characteristics of the flexible body, so as to carry out higher-precision simulation later.
[0141] In one embodiment, when executing step 210 to calculate the deformation parameters of the graphic file based on the mesh parameters, the curvature of each mesh vertex and the curvature of each mesh in the graphic file may be calculated based on the mesh parameters using a Laplace-Beltrami operator.
[0142] For each triangle mesh of the graphic file (if the graphic file contains a polygonal mesh, the split triangle mesh is used as the processing object), the coordinate difference of each edge of the mesh and the cotangent value of the diagonal of the edge are calculated. For an edge formed by mesh vertices i and j, when calculating the coordinate difference corresponding to mesh vertex i, the first UV coordinate of j is subtracted from the first UV coordinate of i; when calculating the coordinate difference corresponding to mesh vertex j, the first UV coordinate of i is subtracted from the first UV coordinate of j. After calculating the coordinate difference of the mesh vertex on an edge, the coordinate difference is multiplied by the cotangent value of the diagonal of the edge, and the product is stored in association with the mesh vertex.
[0143] For any mesh vertex, there are at least two adjacent edges, and a product can be calculated for the mesh vertex on each adjacent edge to be stored in association, so a mesh vertex can be stored in association with multiple products. Here, if an adjacent edge is an edge of two triangle meshes, the mesh vertex can store two products in association with the adjacent edge (the cotangent value of the diagonal of the edge in the two triangle meshes). After calculating all the associated stored products for the mesh vertex, the multiple products can be added to obtain the target sum corresponding to the mesh vertex, and the target sum is used to calculate the curvature of the mesh vertex.
[0144] For each triangular mesh of the graphic file, the Voronoi area of the mesh vertices of each mesh is calculated respectively. First, the radius of the circumscribed circle of the mesh can be calculated based on the first UV coordinates of the three mesh vertices of the mesh. For each mesh vertex, the area of the quadrilateral formed by its two adjacent sides and the perpendicular bisectors of the two adjacent sides is calculated. The length of the hypotenuse of the quadrilateral is the radius of the circumscribed circle of the mesh. Thus, the area of the quadrilateral where each mesh vertex is located can be associated with the mesh vertex and stored. Since a mesh vertex may be in multiple triangular meshes, a mesh vertex can be associated with the areas of multiple quadrilaterals and stored. For any mesh vertex, the several areas associated with the mesh vertex are added to obtain the sum of the areas corresponding to the mesh vertex as the Voronoi area of the mesh vertex.
[0145] For each mesh vertex, the target sum corresponding to the mesh vertex is divided by twice the Voronoi area of the mesh vertex to obtain the curvature of the mesh vertex.
[0146] For each mesh, after the curvatures of three mesh vertices of the mesh are calculated, the average of the three curvatures may be calculated as the curvature of the mesh.
[0147] Through the above measures, the curvature can be calculated for each mesh vertex and each mesh in the graphics file.
[0148] In one embodiment, see Figure 3 , provided in one embodiment of the present application Figure 2 The detailed flow chart of step 220 is as follows: Figure 3 As shown, when step 220 is executed to determine the auxiliary UV coordinates of the auxiliary grid for each grid, the following steps 221 to 223 may be executed.
[0149] Step 221: Calculate the target optimized area of each mesh based on the curvature of each mesh and the initial mesh area; wherein the initial mesh area is determined based on the first UV coordinates of the mesh vertices of the mesh.
[0150] For any triangular mesh, the mesh area of the mesh may be converted based on the first UV coordinates of the mesh vertices of the mesh as the initial mesh area.
[0151] For each grid, the target optimized area of the grid can be obtained by dividing the initial grid area of the grid by the curvature of the grid.
[0152] Since the curvature can directly reflect the deformation characteristics of the flexible body surface (for example, the curvature of the folds of the cloth is larger), the target optimization area obtained by dividing the initial mesh area by the curvature can be used as the optimization target of the mesh in the area dimension. The target optimization area of the mesh is small in the area with large curvature, and the target optimization area of the mesh is large in the area with small curvature, thereby realizing adaptive mesh encryption.
[0153] In one embodiment, considering that the curvature of the flexible body surface is related to the overall size and deformation of the flexible body, there may be a large difference between the maximum and minimum values. At this time, if the target optimization area is calculated directly by dividing the initial mesh area by the curvature, mesh distortion may result.
[0154] In order to reduce the gap between the maximum target optimization area and the minimum target optimization area to prevent mesh distortion, the target optimization area can be calculated using either of the following two methods.
[0155] The first method: when calculating the target optimization area for each grid, determine whether the curvature of the grid is within the specified curvature range, and the specified curvature range can limit the maximum and minimum values of the curvature used in the calculation process. Exemplarily, the maximum curvature is determined from the curvatures of all grids, and 0.25 times the maximum curvature is used as the minimum value in the specified curvature range, and 0.5 times the maximum curvature is used as the maximum value in the specified curvature range. In one case, the curvature of the grid is within the specified curvature range, and the initial grid area of the grid can be directly divided by the curvature to obtain the target optimization area of the grid. In another case, the curvature of the grid is not within the specified curvature range, and the value closest to the curvature can be selected from the specified curvature range (if the curvature is less than the minimum value of the specified curvature range, the minimum value is the selected value; if the curvature is greater than the maximum value of the specified curvature range, the maximum value is the selected value), and the initial grid area of the grid is divided by the value to obtain the target optimization area of the grid.
[0156] The second method: When calculating the target optimization area for each grid, perform a square root operation on the curvature of the grid to obtain the square root of the curvature. Divide the initial grid area of the grid by the square root to obtain the target optimization area of the grid.
[0157] Step 222: Determine the area weighting coefficient according to the sum of the initial mesh areas of all meshes in the graphic file and the sum of the target optimization areas of all meshes.
[0158] In order to ensure that the sum of the target optimization areas of all grids is equal to the sum of the initial grid areas of all grids, the target optimization area needs to be corrected, in other words, the area weighting coefficient based on the initial grid area is determined. The sum of the initial grid areas of all grids and the sum of the target optimization areas of all grids are calculated, and the sum of the initial grid areas is divided by the sum of the target optimization areas to obtain the area weighting coefficient.
[0159] Step 223: Determine auxiliary UV coordinates of mesh vertices of the auxiliary mesh corresponding to each mesh based on the area weighting coefficient and the first UV coordinates of the mesh vertices of each mesh.
[0160] The square root of the area weighting coefficient is obtained by performing a square root operation on the area weighting coefficient. For each mesh, the first UV coordinates of the three mesh vertices of the mesh are multiplied by the square root respectively (the horizontal coordinate and the vertical coordinate of the first UV coordinate are multiplied by the square root respectively), and the auxiliary UV coordinates of the three mesh vertices of the auxiliary mesh corresponding to the mesh can be obtained.
[0161] Through the above measures, the auxiliary UV coordinates of the mesh vertices of the auxiliary mesh can be calculated for each mesh. Since the auxiliary mesh is obtained based on the initial mesh based on curvature scaling and maintaining area conservation, the initial mesh can be optimized based on curvature through the subsequent energy optimization algorithm. In addition, in this scheme, the target optimization area is calculated by curvature limitation, which may make it easy for the energy optimization algorithm to filter out the deformation characteristics of the low curvature area in the graphic file (for example: the area where the mesh with a curvature between 0.1 and 0.2 times the maximum curvature is located), which may easily cause adverse effects on subsequent simulations. The deformation characteristics of the low curvature area can be effectively focused on through the particle model. Therefore, the hybrid algorithm of the energy optimization algorithm and the particle model in this application can achieve good mesh density optimization effects.
[0162] In one embodiment, the energy optimization algorithm may include an energy function and an iterative algorithm, and the energy function evaluates the energy value by the area of the grid. Figure 4 , provided in one embodiment of the present application Figure 2 The detailed flow chart of step 230 is as follows: Figure 4 As shown, when the UV coordinates for each mesh vertex are updated by the energy optimization algorithm, the following steps 231 to 234 may be performed.
[0163] Step 231: taking the first UV coordinates of the mesh vertices of all meshes in the graphic file and the auxiliary UV coordinates of the mesh vertices of all auxiliary meshes as inputs of the iterative algorithm, and obtaining the updated first UV coordinates of the mesh vertices of each mesh.
[0164] The first UV coordinates of the mesh vertices of all meshes in the graphic file and the auxiliary UV coordinates of the mesh vertices of all auxiliary meshes are input into the iterative algorithm. In the iterative algorithm, the mesh area is represented by the first UV coordinates of three mesh vertices, and the mesh area of the auxiliary mesh is represented by the auxiliary UV coordinates of three mesh vertices. The mesh area of each mesh is adjusted to the mesh area of its corresponding auxiliary mesh through the iterative algorithm, thereby outputting the updated first UV coordinates of the mesh vertices of each mesh.
[0165] Step 232: Evaluate the energy values of the grid areas after all grids are updated using an energy function, and determine whether the energy values are reduced compared to the energy values before the update.
[0166] After obtaining the first UV coordinates of all mesh vertices after being updated, the energy values of the updated mesh areas of all meshes may be evaluated by an energy function.
[0167] For example, for a single grid, the energy function can be expressed as follows:
[0168]
[0169] Among them, E is the energy value; A is the grid area; A' is the grid area of the auxiliary grid corresponding to the grid; α is the proportional coefficient; the proportional coefficient is greater than 0 and less than or equal to 1, and can be configured as needed. For example, the proportional coefficient can be 1.
[0170] The mesh area A in formula (1) can be determined by the first UV coordinates of the three mesh vertices of the mesh, and the mesh area A′ of the auxiliary mesh can be determined by the auxiliary UV coordinates of the three mesh vertices of the auxiliary mesh.
[0171] After updating the first UV coordinates of the mesh vertices of each mesh in each round, the energy value corresponding to each mesh can be calculated by the energy function, and the sum of the energy values corresponding to all meshes can be calculated to determine whether the sum of the energy values decreases after the first UV coordinates are updated.
[0172] In addition, in the process of updating the first UV coordinate, a gradient may be calculated for the energy function, so as to update the first UV coordinate for the mesh vertices of each mesh by means of a gradient-assisted iterative algorithm. Here, the method of calculating the gradient for the energy function may refer to the prior art, such as the literature "Isometric energies for recovering injectivity inconstrained mapping", "Dynamic deformables: implementation and production practicalities", etc.
[0173] Step 233: If the energy value decreases, return to the step of using the first UV coordinates of the mesh vertices of all meshes in the graphic file and the auxiliary UV coordinates of the mesh vertices of all auxiliary meshes as inputs of the iterative algorithm.
[0174] When the sum of all energy values decreases, the process returns to step 231, and the updated first UV coordinates of the mesh vertices of all meshes and the auxiliary UV coordinates of the mesh vertices of all auxiliary meshes are input into the iterative algorithm, and the first UV coordinates of the mesh vertices of each mesh are updated again through the iterative algorithm. Further, the energy values of the mesh areas of all meshes after the update are re-evaluated through the energy function to determine whether the sum of the energy values decreases, and the next round of update is performed when the sum of the energy values decreases.
[0175] Step 234: After repeated iterations, when the energy value of the energy function tends to be stable, the iteratively updated first UV coordinates of all mesh vertices are determined as second UV coordinates.
[0176] After repeated iterations, after the first UV coordinates of the mesh vertices of each mesh are updated multiple times, the sum of the energy values of all meshes tends to be stable. At this time, it can be determined that the first UV coordinates of the mesh vertices of all meshes after more iterations are the second UV coordinates.
[0177] Through the above measures, the energy optimization process can be realized through the energy optimization algorithm, so that the grid of the graphic file can be initially encrypted.
[0178] In one embodiment, before executing step 220, the curvature of each mesh vertex may be smoothed, and after multiple smoothing processes until the smoothing times are reached, step 220 may be executed with the smoothed curvature to prevent mesh distortion caused by mesh encryption with the help of the auxiliary UV coordinates after the auxiliary UV coordinates of the mesh vertices of each auxiliary mesh are subsequently determined with the help of the curvature. Here, the smoothing method may be a Laplace smoothing algorithm or other algorithms such as a Taubin smoothing algorithm. The smoothing times may be an empirical value, and different smoothing times may be selected for different smoothing algorithms.
[0179] Exemplarily, Laplace smoothing may be performed on the curvature of each mesh vertex until the Laplace smoothing order is reached.
[0180] Here, Laplace smoothing can use the Laplace-Cotan formula to construct a linear equation system and solve the linear equation system. The curvature of the mesh vertex of each mesh is calculated, so that the updated curvature can be obtained. Here, the solution to the linear equation system can include but is not limited to the conjugate gradient method, the Gauss-Seidel iteration method, the Jacobi iteration method, and the multi-grid algorithm.
[0181] The curvature of all mesh vertices is used as the input of the linear equation system, and the output is the updated curvature of all mesh vertices. This process is called a Laplace smoothing process. After obtaining the updated curvature of all mesh vertices, it can be re-input into the linear equation system to update the curvature again.
[0182] When the number of Laplace smoothing processes reaches the number of Laplace smoothing processes, the curvature of each mesh vertex can be determined and obtained, which is used for subsequently calculating the auxiliary UV coordinates of the mesh vertices of the auxiliary mesh corresponding to each mesh.
[0183] In one embodiment, see Figure 5 , is a flow chart of a method for determining the number of Laplace smoothing times provided in an embodiment of the present application, such as Figure 5 As shown, the Laplace smoothing order can be calculated through the following steps 510 to 540.
[0184] Step 510: Select a maximum curvature from the curvatures of all mesh vertices, and determine a target curvature using the maximum curvature and a preset adjustment coefficient.
[0185] After Laplace smoothing, the maximum curvature can be selected from the curvatures of all mesh vertices, and the maximum curvature can be multiplied by the adjustment coefficient to obtain the target curvature. Here, the adjustment coefficient can be configured based on experience. Exemplarily, the adjustment coefficient can be any one of 0.25, 0.26, 0.27, 0.28, 0.29, and 0.3. Preferably, the adjustment coefficient is 0.25.
[0186] Step 520: Filter out a plurality of target mesh vertices; wherein the curvature of the target mesh vertices is greater than the target curvature.
[0187] Compare the curvature of each mesh vertex with the target curvature, if the curvature of any mesh vertex is greater than the target curvature, then determine that the mesh vertex is the target mesh vertex. Traverse all mesh vertices of the graphic file to filter out multiple target mesh vertices.
[0188] Step 530: Calculate a target ratio between the sum of the Voronoi areas corresponding to all target mesh vertices and the sum of the Voronoi areas corresponding to all mesh vertices.
[0189] After selecting multiple target mesh vertices, the sum of the Voronoi areas of all target mesh vertices can be calculated. Here, the Voronoi area of any mesh vertex can refer to the relevant description above, or, when calculating the curvature for each mesh vertex, the Voronoi area corresponding to each mesh vertex can be saved. In addition, the sum of the Voronoi areas corresponding to all mesh vertices can be calculated.
[0190] After calculating the sum of the two Voronoi areas, the former can be divided by the latter to obtain the target ratio.
[0191] Step 540: Calculate the Laplace smoothing order according to the target ratio.
[0192] After the target ratio is obtained, it can be converted into the Laplace smoothing order based on the step function.
[0193] Exemplarily, when the target ratio is less than or equal to 0.02, the number of Laplace smoothing is 10; when the target ratio increases by 0.02, the number of Laplace smoothing decreases by 1; when the target ratio reaches 0.2, the number of smoothing is 1.
[0194] In this case, the target ratio is negatively correlated with the number of Laplace smoothing. This measure can ensure that when the high curvature area is large (for example, greater than 20% of the total area), the area to be encrypted will not be too large due to too many Laplace smoothing processes.
[0195] In one embodiment, see Figure 6, is a flow chart of a method for updating the curvature of mesh vertices provided in an embodiment of the present application, such as Figure 6 As shown, before executing step 240 to determine the curvature gradient of each mesh vertex, the following steps 610 to 640 may be executed to update the curvature of each mesh vertex under the second UV coordinate.
[0196] Step 610: For any mesh vertex to be processed, based on the second UV coordinate of the mesh vertex to be processed and the first UV coordinate of the mesh vertex of the initial mesh, determine the initial mesh where the mesh vertex to be processed is located; wherein the initial mesh is the mesh before being updated by the energy optimization algorithm.
[0197] The mesh vertices to be processed are mesh vertices that require curvature update.
[0198] Based on the second UV coordinate of the vertex of the mesh to be processed and the first UV coordinate of the mesh vertex of the initial mesh, the initial mesh in which the vertex of the mesh to be processed is located can be determined.
[0199] Step 620: Determine three triangles in the initial mesh according to the connection lines between the mesh vertices to be processed and the mesh vertices of the initial mesh, and use the areas of the three triangles as three weight values.
[0200] After determining the initial mesh where the mesh vertex to be processed is located, connect the mesh vertex to be processed with the three mesh vertices of the initial mesh, and three triangles can be determined based on the three connecting lines and the three edges of the initial mesh. Since the vertex coordinates of each triangle are determined (including the second UV coordinates of the mesh vertex to be processed and the first UV coordinates of the two mesh vertices of the initial mesh), the area of the triangle can be calculated. After calculating the three areas for the three triangles respectively, the three areas can be used as three weight values.
[0201] Step 630: weighted summing the curvatures of the mesh vertices of the initial mesh using the three weight values to obtain the curvatures of the mesh vertices to be processed.
[0202] After obtaining the three weight values, each weight value can be assigned to the mesh vertices of the initial mesh. Exemplarily, for any weight value, it can be used as the weight value of a mesh vertex other than the triangle corresponding to the weight value. For example: the mesh vertices of the initial mesh are A, B, and C, and the mesh vertex to be processed is O, then the area of triangle ABO can be used as the weight value of mesh vertex C; the area of triangle ACO can be used as the weight value of mesh vertex B; the area of triangle BCO can be used as the weight value of mesh vertex A.
[0203] After assigning weight values to the mesh vertices of the initial mesh, the curvatures of the mesh vertices may be weighted summed to obtain the curvatures of the mesh vertices to be processed. If the curvatures of the mesh vertices have been smoothed before, the smoothed curvatures may be weighted summed to obtain the curvatures of the mesh vertices to be processed when step 630 is executed.
[0204] In one embodiment, before weighted summing of the curvatures of the mesh vertices is performed, each weight value may be normalized so that the sum of the three weight values is 1.
[0205] Step 640: Use each mesh vertex as a mesh vertex to be processed to update the curvature of each mesh vertex under the second UV coordinate.
[0206] Each mesh vertex is taken as a mesh vertex to be processed, and its curvature under the second UV coordinate is calculated, so that the curvature under the second UV coordinate can be updated for all mesh vertices.
[0207] Through the above measures, the curvature under the second UV coordinates can be calculated for each mesh vertex, so as to facilitate the subsequent calculation of the curvature gradient with the help of the second UV coordinates of each mesh vertex and the updated curvature.
[0208] In one embodiment, see Figure 7 , provided in one embodiment of the present application Figure 2 The detailed flow chart of step 240 is as follows: Figure 7 As shown, when executing step 240 to calculate the curvature gradient of each mesh vertex, the following steps 241 to 244 may be executed.
[0209] Step 241: for any specified mesh vertex, calculate the single edge curvature gradient of the specified mesh vertex along the adjacent edge; the magnitude of the single edge curvature gradient is the quotient of the curvature difference between the specified mesh vertex and the adjacent vertex on the adjacent edge divided by the length of the adjacent edge, and the direction of the single edge curvature gradient is the unit direction along the adjacent edge to the specified mesh vertex; the length and direction of the adjacent edge are determined based on the second UV coordinate of the specified mesh vertex and the second UV coordinate of the adjacent vertex on the adjacent edge.
[0210] Specify the mesh vertices for which the curvature gradient needs to be calculated.
[0211] For any specified mesh vertex, there are multiple adjacent edges, and the single edge curvature gradient on each adjacent edge can be calculated for the specified mesh vertex. The other mesh vertex on the adjacent edge other than the specified mesh vertex is the adjacent vertex of the specified mesh vertex. The curvature of the specified mesh vertex is subtracted from the curvature of the adjacent vertex to obtain a curvature difference. Further, the curvature difference is divided by the length of the adjacent edge to obtain a quotient, which is the size of the single edge curvature gradient. Here, the length of the adjacent edge can be calculated by the second UV coordinate of the specified mesh vertex and the second UV coordinate of the adjacent vertex. In addition, the unit direction along the adjacent edge to the specified mesh vertex can be obtained by subtracting the second UV coordinate of the adjacent vertex from the second UV coordinate of the specified mesh vertex, and it can be used as the direction of the single edge curvature gradient.
[0212] Step 242: For a specified mesh vertex, determine a processed curvature gradient based on two single curvature gradients of every two adjacent neighboring edges and the adjacent edge angle.
[0213] Every two adjacent adjacent edges form an adjacent edge angle, and the vertex of the adjacent edge angle is the specified mesh vertex. The two single curvature gradients of the specified mesh vertex at every two adjacent adjacent edges are multiplied by the adjacent edge angle in radians, and the two products are divided by two, the two quotients are summed, and the summation result is stored on the specified mesh vertex. The two single curvature gradients of every two adjacent adjacent edges can calculate a summation result, and the summation result is the processed curvature gradient. Therefore, multiple processed curvature gradients can be stored on a specified mesh vertex.
[0214] Step 243: Determine the curvature gradient of the specified mesh vertex according to a plurality of processed curvature gradients on the specified mesh vertex.
[0215] The multiple processed curvature gradients stored on the specified mesh vertex are further added, and the final summation result is divided by 2π to obtain the curvature gradient of the specified mesh vertex.
[0216] Step 244: Taking each mesh vertex as a designated mesh vertex to determine the curvature gradient of all mesh vertices.
[0217] By taking each mesh vertex as a designated mesh vertex and executing the calculations from step 241 to step 243, the curvature gradients of all mesh vertices can be obtained.
[0218] In one embodiment, see Figure 8 , provided in one embodiment of the present application Figure 2 The detailed flow chart of step 260 is as follows: Figure 8 As shown, when executing step 260 to update the three-dimensional coordinates of each mesh vertex, the following steps 261 to 264 may be executed.
[0219] Step 261: For any mesh vertex to be updated, determine the initial mesh where the mesh vertex to be updated is located based on the third UV coordinate of the mesh vertex to be updated and the first UV coordinate of the mesh vertex of the initial mesh; wherein the initial mesh is the mesh before being updated by the energy optimization algorithm.
[0220] The mesh vertices to be updated are mesh vertices whose three-dimensional coordinates need to be updated.
[0221] Based on the third UV coordinate of the mesh vertex to be updated and the first UV coordinate of the initial mesh vertex, the initial mesh in which the mesh vertex to be updated is located can be determined.
[0222] Step 262: Determine three triangles in the initial mesh based on the lines between the mesh vertices to be updated and the mesh vertices of the initial mesh, and use the areas of the three triangles as three weight values.
[0223] After determining the initial mesh where the mesh vertex to be updated is located, connect the mesh vertex to be updated with the three mesh vertices of the initial mesh, and three triangles can be determined based on the three connecting lines and the three edges of the initial mesh. Since the vertex coordinates of each triangle are determined (including the third UV coordinate of the mesh vertex to be updated and the first UV coordinates of the two mesh vertices of the initial mesh), the area of the triangle can be calculated. After calculating the three areas for the three triangles respectively, the three areas can be used as three weight values.
[0224] Step 263: weighted summing of the three-dimensional coordinates of the mesh vertices of the initial mesh using the three weight values to obtain the three-dimensional coordinates of the mesh vertices to be updated.
[0225] After obtaining the three weight values, each weight value may be assigned to a mesh vertex of the initial mesh. Here, the assignment method may refer to the weight assignment method in step 630 above.
[0226] After assigning weight values to each mesh vertex of the initial mesh, the three-dimensional coordinates of each mesh vertex can be weighted summed. For example, the three-dimensional coordinates include x-coordinates, y-coordinates, and z-coordinates. The x-coordinates of three mesh vertices, the y-coordinates of three mesh vertices, and the z-coordinates of three mesh vertices are weighted summed. After weighted summation, the three-dimensional coordinates of the mesh vertices to be updated can be obtained.
[0227] In one embodiment, before weighted summing of the curvatures of the mesh vertices is performed, each weight value may be normalized so that the sum of the three weight values is 1.
[0228] Step 264: Use each mesh vertex as a mesh vertex to be updated to obtain the updated three-dimensional coordinates of each mesh vertex.
[0229] Each mesh vertex is used as a mesh vertex to be updated, and its three-dimensional coordinate under the third UV coordinate is calculated, so that the three-dimensional coordinates under the third UV coordinate can be updated for all meshes.
[0230] In one embodiment, see Fig. 9 , is a schematic diagram of a process for encrypting a mesh in a high curvature region according to an embodiment of the present application, such as Fig. 9 As shown, after executing the processing method of step 210 to step 260, the following steps 910 to step 960 may be continued to be executed to further adjust the grid density of different areas.
[0231] Step 910: Update the curvature of each mesh vertex at the third UV coordinate based on the third UV coordinate of each mesh vertex.
[0232] For each mesh vertex under the third UV coordinate, it can be used as a mesh vertex to be processed. Based on the third UV coordinate of the mesh vertex to be processed, the intermediate mesh where the mesh vertex to be processed is located can be determined. Here, the intermediate mesh is a mesh composed of the previous UV coordinates of the mesh vertex. For example, when the curvature of the mesh vertex under the third UV coordinate is updated for the first time, the intermediate mesh is composed of the second UV coordinates of each mesh vertex. The role of the intermediate mesh is the same as the initial mesh in the process of steps 610 to 640. Based on the processing logic similar to steps 610 to 640 above, the curvature under the third UV coordinate can be updated for each mesh vertex to be processed.
[0233] Step 920: Update the curvature of each mesh using the curvature of each mesh vertex under the third UV coordinate.
[0234] For each mesh, after calculating the curvature of the three mesh vertices of the mesh under the third UV coordinate, the average of the three curvatures can be calculated as the curvature of the mesh. This calculation process is performed on all meshes to update the curvature of all meshes.
[0235] Step 930: Determine the auxiliary UV coordinates of the mesh vertices of the auxiliary mesh corresponding to each mesh using the updated curvature of each mesh and the third UV coordinates of each mesh vertex.
[0236] After the curvature of each mesh is updated, the auxiliary UV coordinates of the mesh vertices of the auxiliary mesh corresponding to each mesh may be determined based on the curvature of each mesh and the third UV coordinates of each mesh vertex.
[0237] Step 940: Process the third UV coordinates of the mesh vertices of each mesh and the auxiliary UV coordinates of the mesh vertices of the auxiliary mesh corresponding to each mesh based on the energy optimization algorithm to update the third UV coordinates of the mesh vertices of each mesh.
[0238] The third UV coordinates of the mesh vertices of each mesh and the auxiliary UV coordinates of the mesh vertices of the auxiliary mesh corresponding to each mesh are used as inputs of the iterative algorithm to obtain updated UV coordinates of the mesh vertices output by the iterative algorithm.
[0239] The updated UV coordinates of the mesh vertices of each mesh and the auxiliary UV coordinates of the mesh vertices of the auxiliary mesh corresponding to each mesh are used as inputs of the iterative algorithm again to obtain the further updated UV coordinates of the mesh vertices output by the iterative algorithm.
[0240] Through repeated iterations, the updated UV coordinates of the mesh vertices outputted by the iterative algorithm in the energy optimization algorithm for the last time may be used as the updated third UV coordinates.
[0241] Step 950: Return to the step of updating the curvature of each mesh vertex under the third UV coordinate based on the third UV coordinate of each mesh vertex, until the loop is repeated multiple times, and the iteratively updated third UV coordinates of all mesh vertices are used as the fourth UV coordinates.
[0242] After the third UV coordinates are updated by the energy optimization algorithm, the process may return to step 910 to re-update the curvature of each mesh vertex using the updated third UV coordinates of each mesh vertex. At this point, the intermediate mesh is composed of the third UV coordinates used by the mesh vertices when the curvature was last updated.
[0243] The process from step 910 to step 950 can be repeated multiple times, and multiple energy optimizations can be performed with the help of the energy optimization algorithm, so as to further adjust the mesh density of different regions. After the adjustment is completed, the third UV coordinates of the mesh vertices that have been iteratively updated are used as the fourth UV coordinates.
[0244] Step 960: Based on the fourth UV coordinates of the mesh vertices of each mesh, the three-dimensional coordinates of the mesh vertices of each mesh are updated to obtain the updated three-dimensional coordinates of the mesh vertices of each mesh.
[0245] After the UV coordinates of the mesh vertex of each mesh in the UV coordinate system are converted from the third UV coordinates to the fourth UV coordinates, the three-dimensional coordinates of the mesh vertex in the three-dimensional coordinate system should also change accordingly. Therefore, for each mesh vertex, a linear interpolation algorithm is used to map the fourth UV coordinates to the three-dimensional coordinate system, thereby obtaining the three-dimensional coordinates of the mesh vertex in the three-dimensional coordinate system. The specific updating method can refer to the process of updating the three-dimensional coordinates of the mesh vertex under the first UV coordinates to the three-dimensional coordinates under the third UV coordinates in steps 261 to 264.
[0246] After the fourth UV coordinates and three-dimensional coordinates are updated for each mesh vertex in the graphic file of the flexible body, the updated mesh parameters of the graphic file can be obtained, and the updated mesh parameters can be output for subsequent simulation calculations. In addition, for a graphic file whose mesh is not a triangular mesh, after the fourth UV coordinates and three-dimensional coordinates under the fourth UV coordinates of each mesh vertex are obtained, the previously divided triangular mesh can be deleted, and the mesh parameters can be recorded in the form of the original polygonal mesh.
[0247] Through the above measures, after optimizing the mesh distribution of the deformation area and potential deformation area on the surface of the flexible body by combining the energy optimization algorithm and the particle model, the mesh distribution of the graphic file is further adjusted by the energy optimization algorithm. On the basis of keeping the topological relationship of the mesh unchanged, a better mesh distribution optimization effect is obtained.
[0248] In one embodiment, after executing step 910 and before executing step 920, the curvature of each mesh vertex under the third UV coordinate may be smoothed until the number of smoothing times is reached. Here, the smoothing method may be a Laplace smoothing algorithm or other algorithms such as a Taubin smoothing algorithm. The number of smoothing times may be an empirical value, and different smoothing times may be selected for different smoothing algorithms. For details, see the relevant description above. For example, if the Laplace smoothing algorithm is selected, the number of smoothing times may be 1 or 2.
[0249] By smoothing the curvature of the mesh vertices, a smooth mesh optimization result can be formed in the local high curvature areas caused by some sharp protrusions or creases, avoiding sudden changes in mesh density.
[0250] In one embodiment, see Fig.10 , provided in one embodiment of the present application Fig. 9 The detailed flow chart of step 930 is as follows: Fig.10 As shown, when 930 is executed to determine the auxiliary UV coordinates, the following steps 931 to 933 may be specifically performed.
[0251] Step 931: Calculate the target optimized area of each mesh using the updated curvature of each mesh, the third mesh area and the area weighted correction coefficient; wherein the third mesh area is determined based on the third UV coordinates of the mesh vertices of the mesh.
[0252] For any triangular mesh, the mesh area of the mesh may be converted based on the third UV coordinates of the mesh vertices of the mesh as the third mesh area.
[0253] For each grid, the target optimization area of the grid can be obtained by dividing the third grid area of the grid by the current curvature of the grid and then dividing it by the area weighted correction coefficient. Here, the area weighted correction coefficient is used to correct the target optimization area of each grid in the process of mesh encryption in the high curvature area, so that when the grid is subsequently encrypted by the energy optimization algorithm, a smooth grid optimization result is formed in the local high curvature area caused by sharp protrusions or folds, avoiding sudden changes in grid density. The area weighted correction coefficient can be configured based on experience. Exemplarily, the value range of the area weighted correction coefficient is 1 to between.
[0254] In one embodiment, considering that the curvature of the flexible body surface is related to the overall size and deformation of the flexible body, there may be a large difference between the maximum and minimum values. At this time, if the target optimization area is calculated directly by dividing the third grid area by the curvature, grid distortion may result.
[0255] In order to reduce the gap between the maximum target optimization area and the minimum target optimization area to prevent mesh distortion, the target optimization area can be calculated using either of the following two methods.
[0256] The first method: when calculating the target optimization area for each grid, determine whether the curvature of the grid is within the specified curvature range. The specified curvature range can limit the maximum and minimum values of the curvature used in the calculation process. Exemplarily, the maximum curvature is determined from the current curvatures of all grids, and 0.25 times the maximum curvature is used as the minimum value in the specified curvature range, and 0.5 times the maximum curvature is used as the maximum value in the specified curvature range. In one case, the curvature of the grid is within the specified curvature range, and the third grid area of the grid can be directly divided by the curvature, and then divided by the area weighted correction coefficient to obtain the target optimization area of the grid. In another case, the curvature of the grid is not within the specified curvature range, and the value closest to the curvature can be selected from the specified curvature range, and the third grid area of the grid is divided by the value, and then divided by the area weighted correction coefficient to obtain the target optimization area of the grid.
[0257] The second method: when calculating the target optimization area for each grid, perform a square root operation on the curvature of the grid to obtain the square root of the curvature. Divide the third grid area of the grid by the square root and then by the area weighted correction coefficient to obtain the target optimization area of the grid.
[0258] Step 932: Determine the area weighting coefficient according to the sum of the third grid areas of all grids in the graphic file and the sum of the target optimization areas of all grids.
[0259] In order to ensure that the sum of the target optimization areas of all grids is equal to the sum of the third grid areas of all grids, the target optimization area needs to be corrected, in other words, the area weighting coefficient based on the third grid area is determined. The sum of the third grid areas of all grids and the sum of the target optimization areas of all grids are calculated, and the sum of the third grid areas is divided by the sum of the target optimization areas to obtain the area weighting coefficient.
[0260] Step 933: Determine the auxiliary UV coordinates of the mesh vertices of the auxiliary mesh corresponding to each mesh based on the area weighting coefficient and the third UV coordinates of the mesh vertices of each mesh.
[0261] Perform a square root operation on the area weighting coefficient to obtain the square root of the area weighting coefficient. For each mesh, the third UV coordinates of the three mesh vertices of the mesh are multiplied by the square root (the horizontal and vertical coordinates of the third UV coordinate are multiplied by the square root respectively), and the auxiliary UV coordinates of the three mesh vertices of the auxiliary mesh corresponding to the mesh can be obtained.
[0262] Through the above measures, auxiliary UV coordinates of the mesh vertices of the auxiliary mesh can be calculated for each mesh. Since the auxiliary mesh is obtained based on the mesh determined by the third UV coordinate based on curvature scaling and maintaining area conservation, the mesh determined by the third UV coordinate can be subsequently optimized based on curvature through an energy optimization algorithm.
[0263] In one embodiment, before executing step 931, it is necessary to determine the area weighted correction coefficient. Fig.11 , is a flow chart of a method for determining an area weighted correction coefficient provided in an embodiment of the present application, such as Fig.11 As shown, the method may include the following steps 1110 to 1140.
[0264] Step 1110: Select a maximum curvature from the curvatures of all mesh vertices under the first UV coordinate, and determine a target curvature using the maximum curvature and a preset adjustment coefficient.
[0265] Step 1120: Filter out a plurality of target mesh vertices; wherein the curvature of the target mesh vertices under the first UV coordinate is greater than the target curvature.
[0266] Step 1130: Calculate a target ratio between the sum of the Voronoi areas corresponding to all target mesh vertices and the sum of the Voronoi areas corresponding to all mesh vertices.
[0267] When executing the aforementioned steps 510 to 540 to determine the number of Laplace smoothing times, the area weighted correction coefficient can be calculated at the same time, so the execution process of steps 1110 to 1130 can be equivalent to the execution process of steps 510 to 540. Alternatively, if Laplace smoothing is not selected before, after obtaining the curvature of each mesh vertex under the first UV coordinate, the process of steps 1110 to 1130 can be executed to obtain the target ratio. Here, the relevant content of calculating the target ratio is referred to the above text and will not be repeated here.
[0268] Step 1140: Calculate the area weighted correction coefficient according to the target ratio.
[0269] After obtaining the target ratio, it is determined whether the target ratio is not greater than 0.1. On the one hand, if the target ratio is not greater than 0.1, the area weighted correction coefficient is determined to be 1. On the other hand, if the target ratio is greater than 0.1, the area weighted correction coefficient can be converted by the following formula (2):
[0270] X=0.757+0.586 / (20*L) (2)
[0271] Where X is the area weighted correction coefficient; L is the target ratio.
[0272] Through this measure, the area-weighted correction coefficient can be calculated to ensure that mesh distortion will not occur during mesh density optimization when there are too many high curvature areas.
[0273] In one embodiment, see Fig.12 , which is a schematic diagram of a process of re-encrypting the grid in the high curvature area according to an embodiment of the present application, such as Fig.12 As shown, after executing steps 910 to 960 to encrypt the mesh of the high curvature area, the following steps 1210 to 1260 may be continued to be executed to further adjust the mesh density of different areas.
[0274] Step 1210: Update the curvature of each mesh vertex at the fourth UV coordinate based on the fourth UV coordinate of each mesh vertex.
[0275] For each mesh vertex under the fourth UV coordinate, it can be used as a mesh vertex to be processed. Based on the fourth UV coordinate of the mesh vertex to be processed, the intermediate mesh where the mesh vertex to be processed is located can be determined. Here, the intermediate mesh is a mesh composed of the previous UV coordinates of the mesh vertex. For example, when the curvature of the mesh vertex under the fourth UV coordinate is updated for the first time, the intermediate mesh is composed of the third UV coordinates of each mesh vertex. The role of the intermediate mesh is the same as the initial mesh in the process of steps 610 to 640. Based on the processing logic similar to steps 610 to 640 above, the curvature under the fourth UV coordinate can be updated for each mesh vertex to be processed.
[0276] Step 1220: Update the curvature of each mesh using the curvature of each mesh vertex under the fourth UV coordinate.
[0277] For each mesh, after calculating the curvatures of the three mesh vertices of the mesh under the fourth UV coordinate, the average of the three curvatures can be calculated as the curvature of the mesh. This calculation process is performed on all meshes to update the curvatures of all meshes.
[0278] Step 1230: Determine the auxiliary UV coordinates of the mesh vertices of the auxiliary mesh corresponding to each mesh using the updated curvature of each mesh and the fourth UV coordinates of each mesh vertex.
[0279] After the curvature of each mesh is updated, the auxiliary UV coordinates of the mesh vertices of the auxiliary mesh corresponding to each mesh may be determined based on the curvature of each mesh and the fourth UV coordinate of each mesh vertex.
[0280] Step 1240: Process the fourth UV coordinates of the mesh vertices of each mesh and the auxiliary UV coordinates of the mesh vertices of the auxiliary mesh corresponding to each mesh based on the energy optimization algorithm to update the fourth UV coordinates of the mesh vertices of each mesh.
[0281] The fourth UV coordinates of the mesh vertices of each mesh and the auxiliary UV coordinates of the mesh vertices of the auxiliary mesh corresponding to each mesh are used as inputs of the iterative algorithm to obtain updated UV coordinates of the mesh vertices output by the iterative algorithm.
[0282] The updated UV coordinates of the mesh vertices of each mesh and the auxiliary UV coordinates of the mesh vertices of the auxiliary mesh corresponding to each mesh are used as inputs of the iterative algorithm again to obtain the further updated UV coordinates of the mesh vertices output by the iterative algorithm.
[0283] Through repeated iterations, the updated UV coordinates of the mesh vertices output by the iterative algorithm for the last time may be used as the updated fourth UV coordinates.
[0284] Step 1250: Return to the step of updating the curvature of each mesh vertex under the fourth UV coordinate based on the fourth UV coordinate of each mesh vertex, until the loop is repeated multiple times, and the iteratively updated fourth UV coordinates of all mesh vertices are used as the fifth UV coordinates.
[0285] After the fourth UV coordinates are updated by the energy optimization algorithm, the process may return to step 1210 to re-update the curvature of each mesh vertex using the updated fourth UV coordinates of each mesh vertex. At this point, the intermediate mesh is composed of the fourth UV coordinates used by the mesh vertices when the curvature was last updated.
[0286] The process from step 1210 to step 1250 can be repeated multiple times, and multiple energy optimizations can be performed with the help of the energy optimization algorithm, so as to further adjust the mesh density of different regions. After the adjustment is completed, the fourth UV coordinate of the mesh vertex after iterative update is used as the fifth UV coordinate.
[0287] Step 1260: Based on the fifth UV coordinates of the mesh vertices of each mesh, the three-dimensional coordinates of the mesh vertices of each mesh are updated to obtain updated three-dimensional coordinates of the mesh vertices of each mesh.
[0288] After the UV coordinates of the mesh vertex of each mesh in the UV coordinate system are converted from the fourth UV coordinates to the fifth UV coordinates, the three-dimensional coordinates of the mesh vertex in the three-dimensional coordinate system should also change accordingly. Therefore, for each mesh vertex, a linear interpolation algorithm is used to map the fifth UV coordinates to the three-dimensional coordinate system, thereby obtaining the three-dimensional coordinates of the mesh vertex in the three-dimensional coordinate system. The specific updating method can refer to the process of updating the three-dimensional coordinates of the mesh vertex under the first UV coordinates to the three-dimensional coordinates under the third UV coordinates in steps 261 to 264.
[0289] After the fifth UV coordinate and the three-dimensional coordinate are updated for each mesh vertex in the graphic file of the flexible body, the updated mesh parameters of the graphic file can be obtained, and the updated mesh parameters can be output for subsequent simulation calculations. In addition, for a graphic file whose mesh is not a triangular mesh, after the fifth UV coordinate and the three-dimensional coordinate under the fifth UV coordinate of each mesh vertex are obtained, the previously divided triangular mesh can be deleted, and the mesh parameters can be recorded in the form of the original polygonal mesh.
[0290] Through the above measures, after optimizing the mesh distribution of the deformation area and potential deformation area on the surface of the flexible body by combining the energy optimization algorithm and the particle model, the mesh distribution of the graphic file is further adjusted in two stages through the energy optimization algorithm. On the basis of keeping the topological relationship of the mesh unchanged, a better mesh distribution optimization effect is obtained.
[0291] In one embodiment, see Fig.13 , provided in one embodiment of the present application Fig.12 The detailed flow chart of step 1230 is as follows: Fig.13 As shown, when executing 1230 to determine the auxiliary UV coordinates, the following steps 1231 to 1233 may be specifically performed.
[0292] Step 1231: Calculate the target optimized area of each mesh using the updated curvature of each mesh, the fourth mesh area and the area weighted correction coefficient; wherein the fourth mesh area is determined based on the fourth UV coordinates of the mesh vertices of the mesh.
[0293] For any triangular mesh, the mesh area of the mesh may be converted based on the fourth UV coordinates of the mesh vertices of the mesh as the fourth mesh area.
[0294] For each grid, the fourth grid area of the grid is divided by the current curvature of the grid, and then divided by the area weighted correction coefficient to obtain the target optimization area of the grid. Here, the area weighted correction coefficient is used to correct the target optimization area of each grid in the process of mesh encryption in the high curvature area. The area weighted correction coefficient can be configured based on experience. For example, the value range of the area weighted correction coefficient is 1 to between.
[0295] In one embodiment, considering that the curvature of the flexible body surface is related to the overall size and deformation of the flexible body, there may be a large difference between the maximum and minimum values. At this time, if the target optimization area is calculated directly by dividing the fourth grid area by the curvature, grid distortion may result.
[0296] In order to reduce the gap between the maximum target optimization area and the minimum target optimization area to prevent mesh distortion, the target optimization area can be calculated using either of the following two methods.
[0297] The first method: when calculating the target optimization area for each grid, determine whether the curvature of the grid is within the specified curvature range. The specified curvature range can limit the maximum and minimum values of the curvature used in the calculation process. Exemplarily, the maximum curvature is determined from the current curvatures of all grids, and 0.25 times the maximum curvature is used as the minimum value in the specified curvature range, and 0.5 times the maximum curvature is used as the maximum value in the specified curvature range. In one case, the curvature of the grid is within the specified curvature range, and the fourth grid area of the grid can be directly divided by the curvature, and then divided by the area weighted correction coefficient to obtain the target optimization area of the grid. In another case, the curvature of the grid is not within the specified curvature range, and the value closest to the curvature can be selected from the specified curvature range, and the fourth grid area of the grid is divided by the value, and then divided by the area weighted correction coefficient to obtain the target optimization area of the grid.
[0298] The second method: when calculating the target optimization area for each grid, perform a square root operation on the curvature of the grid to obtain the square root of the curvature. Divide the fourth grid area of the grid by the square root and then by the area weighted correction coefficient to obtain the target optimization area of the grid.
[0299] Step 1232: Determine the area weighting coefficient according to the sum of the fourth grid areas of all grids in the graphic file and the sum of the target optimization areas of all grids.
[0300] In order to ensure that the sum of the target optimization areas of all grids is equal to the sum of the fourth grid areas of all grids, the target optimization area needs to be corrected, in other words, the area weighting coefficient based on the fourth grid area is determined. The sum of the fourth grid areas of all grids and the sum of the target optimization areas of all grids are calculated, and the sum of the fourth grid areas is divided by the sum of the target optimization areas to obtain the area weighting coefficient.
[0301] Step 1233: Determine the auxiliary UV coordinates of the mesh vertices of the auxiliary mesh corresponding to each mesh based on the area weighting coefficient and the fourth UV coordinates of the mesh vertices of each mesh.
[0302] Perform a square root operation on the area weighting coefficient to obtain the square root of the area weighting coefficient. For each mesh, the fourth UV coordinates of the three mesh vertices of the mesh are multiplied by the square root (the horizontal and vertical coordinates of the fourth UV coordinate are multiplied by the square root respectively), and the auxiliary UV coordinates of the three mesh vertices of the auxiliary mesh corresponding to the mesh can be obtained.
[0303] Through the above measures, auxiliary UV coordinates of the mesh vertices of the auxiliary mesh can be calculated for each mesh. Since the auxiliary mesh is obtained based on the mesh determined by the fourth UV coordinate based on curvature scaling and maintaining area conservation, the mesh determined by the fourth UV coordinate can be subsequently optimized based on curvature through an energy optimization algorithm.
[0304] In summary, the method of combining the energy optimization algorithm and the particle model for grid processing provided by the present application scheme can optimize the grid distribution on the surface of the flexible body in real time according to the deformation characteristics of the flexible body, and this process does not change the topological relationship of the grid, which greatly reduces the amount of calculation and improves the efficiency and accuracy of subsequent simulations.
[0305] In the present application, based on the combination of energy optimization algorithm and particle model, the energy optimization algorithm is applied to several stages of preliminary encryption and further encryption after the particle model redistributes the mesh vertices. The advantages of different algorithms can be integrated, while ensuring a larger mesh density ratio or area ratio, smooth mesh distribution, and identifying potential deformation areas, so that the mesh encryption direction is along the deformation direction, which is more in line with the simulation needs.
[0306] The solution of the present application provides functions on the deformation characteristics of the flexible body, such as the smoothing times and the area weighted correction coefficient, so that the hybrid algorithm combining the energy optimization algorithm and the particle model can be applied to different deformation states of the flexible body.
[0307] Fig.14 is a block diagram of a processing device for a flexible body surface mesh according to an embodiment of the present invention, such as Fig.14 As shown, the device may include:
[0308] The acquisition module 1410 is used to acquire the mesh parameters of the graphic file of the flexible body, and calculate the deformation parameters of the graphic file based on the mesh parameters; wherein the mesh parameters include the first UV coordinates and the three-dimensional coordinates of each mesh vertex; and the deformation parameters include the curvature of each mesh and the curvature of each mesh vertex;
[0309] A first determining module 1420 is used to determine auxiliary UV coordinates of mesh vertices of the auxiliary mesh corresponding to each mesh based on the curvature of each mesh and the first UV coordinates of the mesh vertices;
[0310] The first processing module 1430 is used to process the first UV coordinates of the mesh vertices of each mesh and the auxiliary UV coordinates of the mesh vertices of the auxiliary mesh corresponding to each mesh based on the energy optimization algorithm, and update the second UV coordinates of the mesh vertices of each mesh;
[0311] A second determination module 1440, configured to determine a curvature gradient of each mesh vertex based on a second UV coordinate and a curvature of the mesh vertex of each mesh;
[0312] The second processing module 1450 is used to redistribute the second UV coordinates of each mesh vertex based on the particle model under the updated curvature gradient of each mesh vertex to obtain the third UV coordinates of the mesh vertex of each mesh;
[0313] The updating module 1460 is used to update the three-dimensional coordinates of the mesh vertices of each mesh based on the third UV coordinates of the mesh vertices of each mesh to obtain the updated three-dimensional coordinates of the mesh vertices of each mesh.
[0314] The implementation process of the functions and effects of each module in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method for processing the surface mesh of a flexible body, and will not be repeated here.
[0315] In several embodiments provided in the present application, the disclosed devices and methods may also be implemented in other ways. The device embodiments described above are merely schematic, for example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to the multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram may represent a module, a program segment or a part of a code, and a module, a program segment or a part of a code contains one or more executable instructions for implementing a specified logical function. In some alternative implementations, the functions marked in the box may also occur in an order different from that marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they may sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or the flowchart, and the combination of boxes in the block diagram and / or the flowchart, can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0316] In addition, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
[0317] If the function is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, and other media that can store program codes.
Claims
1. A method for processing the surface mesh of a flexible body, It is characterized in that include: Obtaining mesh parameters of a graphic file of a flexible body, and calculating deformation parameters of the graphic file based on the mesh parameters; wherein the mesh parameters include a first UV coordinate and a three-dimensional coordinate of each mesh vertex; and the deformation parameters include a curvature of each mesh and a curvature of each mesh vertex; Determine the auxiliary UV coordinates of the mesh vertices of the auxiliary mesh corresponding to each mesh according to the curvature of each mesh and the first UV coordinates of the mesh vertices; Based on the energy optimization algorithm, the first UV coordinates of the mesh vertices of each mesh and the auxiliary UV coordinates of the mesh vertices of the auxiliary mesh corresponding to each mesh are processed to update the second UV coordinates of the mesh vertices of each mesh; Determine a curvature gradient of each mesh vertex based on the second UV coordinate and the curvature of the mesh vertex of each mesh; Under the updated curvature gradient of each mesh vertex, the second UV coordinate of each mesh vertex is redistributed based on the particle model to obtain the third UV coordinate of the mesh vertex of each mesh; Based on the third UV coordinates of the mesh vertices of each mesh, the three-dimensional coordinates of the mesh vertices of each mesh are updated to obtain updated three-dimensional coordinates of the mesh vertices of each mesh.
2. The method according to claim 1, It is characterized in that The step of calculating the deformation parameters of the graphic file based on the grid parameters comprises: Based on the mesh parameters, the curvature of each mesh vertex and the curvature of each mesh in the graphic file are calculated by using the Laplace-Beltrami operator.
3. The method according to claim 1, It is characterized in that The method of determining the auxiliary UV coordinates of the mesh vertices of the auxiliary mesh corresponding to each mesh by using the curvature of each mesh and the first UV coordinates of the mesh vertices includes: Calculating a target optimized area of each mesh based on the curvature and initial mesh area of each mesh; wherein the initial mesh area is determined based on the first UV coordinates of the mesh vertices of the mesh; Determining an area weighting coefficient according to the sum of the initial mesh areas of all meshes in the graphic file and the sum of the target optimization areas of all meshes; Based on the area weighting coefficient and the first UV coordinates of the mesh vertices of each mesh, auxiliary UV coordinates of the mesh vertices of the auxiliary mesh corresponding to each mesh are determined.
4. The method according to claim 1, It is characterized in that The energy optimization algorithm includes an iterative algorithm and an energy function; The energy optimization algorithm is used to process the first UV coordinates of the mesh vertices of each mesh and the auxiliary UV coordinates of the mesh vertices of the auxiliary mesh corresponding to each mesh, and the second UV coordinates of the mesh vertices of each mesh are updated, including: Using the first UV coordinates of the mesh vertices of all meshes in the graphic file and the auxiliary UV coordinates of the mesh vertices of all auxiliary meshes as inputs of the iterative algorithm, to obtain the updated first UV coordinates of the mesh vertices of each mesh; Evaluate the energy value of the grid area after all grids are updated through the energy function, and determine whether the energy value is reduced compared to the energy value before the update; If the energy value decreases, returning to the step of using the first UV coordinates of the mesh vertices of all meshes in the graphic file and the auxiliary UV coordinates of the mesh vertices of all auxiliary meshes as inputs of the iterative algorithm; After repeated iterations, when the energy value of the energy function tends to be stable, the iteratively updated first UV coordinates of all mesh vertices are determined as second UV coordinates.
5. The method according to claim 1, It is characterized in that Before determining the auxiliary UV coordinates of the mesh vertices of the auxiliary mesh corresponding to each mesh based on the curvature of each mesh and the first UV coordinates of the mesh vertices, the method further includes: Smooths the curvature of each mesh vertex until the smoothing number is reached.
6. The method according to claim 5, It is characterized in that The smoothing process is a Laplace smoothing process, the smoothing times are Laplace smoothing times, and the step of obtaining the Laplace smoothing times includes: Selecting a maximum curvature from the curvatures of all mesh vertices, and determining a target curvature using the maximum curvature and a preset adjustment coefficient; Screening out a plurality of target mesh vertices; wherein the curvature of the target mesh vertices is greater than the target curvature; Calculate the target ratio between the sum of the Voronoi areas corresponding to all target mesh vertices and the sum of the Voronoi areas corresponding to all mesh vertices; The Laplace smoothing order is calculated according to the target ratio.
7. The method according to claim 1 or 5, It is characterized in that Before determining the curvature gradient of each mesh vertex based on the second UV coordinate and the curvature of the mesh vertex of each mesh, the method includes: For any mesh vertex to be processed, based on the second UV coordinate of the mesh vertex to be processed and the first UV coordinate of the mesh vertex of the initial mesh, determine the initial mesh where the mesh vertex to be processed is located; wherein the initial mesh is the mesh before being updated by the energy optimization algorithm; Determine three triangles in the initial mesh according to the connection between the mesh vertices to be processed and the mesh vertices of the initial mesh, and use the areas of the three triangles as three weight values; Taking a weighted sum of the curvatures of the mesh vertices of the initial mesh using the three weight values, to obtain the curvatures of the mesh vertices to be processed; Each mesh vertex is used as a mesh vertex to be processed, so as to update the curvature of each mesh vertex under the second UV coordinate.
8. The method according to claim 7, It is characterized in that The step of determining the curvature gradient of each mesh vertex based on the second UV coordinate and the curvature of the mesh vertex of each mesh comprises: For any specified mesh vertex, a single edge curvature gradient of the specified mesh vertex along an adjacent edge is calculated; the magnitude of the single edge curvature gradient is a quotient of a curvature difference between the specified mesh vertex and an adjacent vertex on the adjacent edge divided by a length of the adjacent edge; the direction of the single edge curvature gradient is a unit direction along the adjacent edge to the specified mesh vertex; the length and direction of the adjacent edge are determined based on a second UV coordinate of the specified mesh vertex and a second UV coordinate of an adjacent vertex on the adjacent edge; For the specified mesh vertex, determine the processed curvature gradient based on two single curvature gradients of every two adjacent neighboring edges and the adjacent edge angle; Determining the curvature gradient of the specified mesh vertex according to a plurality of processed curvature gradients on the specified mesh vertex; Each mesh vertex is used as a designated mesh vertex to determine the curvature gradient of all mesh vertices.
9. The method according to claim 1, It is characterized in that The updating of the three-dimensional coordinates of the mesh vertices of each mesh based on the third UV coordinates of the mesh vertices of each mesh to obtain the updated three-dimensional coordinates of the mesh vertices of each mesh includes: For any mesh vertex to be updated, based on the third UV coordinate of the mesh vertex to be updated and the first UV coordinate of the mesh vertex of the initial mesh, determine the initial mesh where the mesh vertex to be updated is located; wherein the initial mesh is the mesh before being updated by the energy optimization algorithm; Determine three triangles in the initial mesh according to the connection between the mesh vertices to be updated and the mesh vertices of the initial mesh, and use the areas of the three triangles as three weight values; Taking weighted sum of the three-dimensional coordinates of the mesh vertices of the initial mesh using the three weight values, to obtain the three-dimensional coordinates of the mesh vertices to be updated; Each mesh vertex is used as a mesh vertex to be updated to obtain the updated three-dimensional coordinates of each mesh vertex.
10. The method according to claim 1, It is characterized in that After obtaining the third UV coordinate of each mesh vertex, the method further includes: Update the curvature of each mesh vertex at the third UV coordinate based on the third UV coordinate of each mesh vertex; Update the curvature of each mesh using the curvature of each mesh vertex under the third UV coordinate; Determine the auxiliary UV coordinates of the mesh vertices of the auxiliary mesh corresponding to each mesh according to the updated curvature of each mesh and the third UV coordinates of each mesh vertex; Processing the third UV coordinates of the mesh vertices of each mesh and the auxiliary UV coordinates of the mesh vertices of the auxiliary mesh corresponding to each mesh based on the energy optimization algorithm to update the third UV coordinates of the mesh vertices of each mesh; Return to the step of updating the curvature of each mesh vertex under the third UV coordinate based on the third UV coordinate of each mesh vertex, until the loop is repeated multiple times, and the iteratively updated third UV coordinates of all mesh vertices are used as the fourth UV coordinates; Based on the fourth UV coordinates of the mesh vertices of each mesh, the three-dimensional coordinates of the mesh vertices of each mesh are updated to obtain the updated three-dimensional coordinates of the mesh vertices of each mesh.
11. The method according to claim 10, It is characterized in that Before updating the curvature of each mesh according to the curvature of each mesh vertex under the third UV coordinate, the method further includes: Smooths the curvature of each mesh vertex at the third UV coordinate until the smoothing number is reached.
12. The method according to claim 10, It is characterized in that The method of determining the auxiliary UV coordinates of the mesh vertices of the auxiliary mesh corresponding to each mesh by using the updated curvature of each mesh and the third UV coordinates of each mesh vertex comprises: Calculating the target optimized area of each mesh by using the updated curvature of each mesh, the third mesh area and the area weighted correction coefficient; wherein the third mesh area is determined based on the third UV coordinates of the mesh vertices of the mesh; Determining an area weighting coefficient according to the sum of the third grid areas of all grids in the graphic file and the sum of the target optimization areas of all grids; Based on the area weighting coefficient and the third UV coordinates of the mesh vertices of each mesh, auxiliary UV coordinates of the mesh vertices of the auxiliary mesh corresponding to each mesh are determined.
13. The method according to claim 12, It is characterized in that The step of obtaining the area weighted correction coefficient comprises: Selecting a maximum curvature from the curvatures of all mesh vertices under the first UV coordinate, and determining a target curvature using the maximum curvature and a preset adjustment coefficient; Screening out a plurality of target mesh vertices; wherein the curvature of the target mesh vertices under the first UV coordinate is greater than the target curvature; Calculate the target ratio between the sum of the Voronoi areas corresponding to all target mesh vertices and the sum of the Voronoi areas corresponding to all mesh vertices; The area weighted correction coefficient is calculated according to the target ratio.
14. The method according to claim 10, It is characterized in that The method further comprises: Update the curvature of each mesh vertex at the fourth UV coordinate based on the fourth UV coordinate of each mesh vertex; Update the curvature of each mesh using the curvature of each mesh vertex under the fourth UV coordinate; Determine the auxiliary UV coordinates of the mesh vertices of the auxiliary mesh corresponding to each mesh according to the updated curvature of each mesh and the fourth UV coordinates of each mesh vertex; Processing the fourth UV coordinates of the mesh vertices of each mesh and the auxiliary UV coordinates of the mesh vertices of the auxiliary mesh corresponding to each mesh based on the energy optimization algorithm to update the fourth UV coordinates of the mesh vertices of each mesh; Return to the step of updating the curvature of each mesh vertex under the fourth UV coordinate based on the fourth UV coordinate of each mesh vertex, until the loop is repeated multiple times, and the iteratively updated fourth UV coordinates of all mesh vertices are used as the fifth UV coordinates; Based on the fifth UV coordinates of the mesh vertices of each mesh, the three-dimensional coordinates of the mesh vertices of each mesh are updated to obtain the updated three-dimensional coordinates of the mesh vertices of each mesh.
15. The method according to claim 14, It is characterized in that The method of determining the auxiliary UV coordinates of the mesh vertices of the auxiliary mesh corresponding to each mesh by using the updated curvature of each mesh and the fourth UV coordinates of each mesh vertex comprises: Calculating the target optimized area of each mesh by using the updated curvature of each mesh, the fourth mesh area and the area weighted correction coefficient; wherein the fourth mesh area is determined based on the fourth UV coordinates of the mesh vertices of the mesh; Determining an area weighting coefficient according to the sum of the fourth grid areas of all grids in the graphic file and the sum of the target optimization areas of all grids; Based on the area weighting coefficient and the fourth UV coordinates of the mesh vertices of each mesh, auxiliary UV coordinates of the mesh vertices of the auxiliary mesh corresponding to each mesh are determined.
16. The method according to claim 1, It is characterized in that The step of acquiring the grid parameters of the graphic file of the flexible body and calculating the deformation parameters of the graphic file based on the grid parameters includes: Acquire mesh parameters of a graphic file of a flexible body, and determine whether a mesh in the graphic file is a triangular mesh based on the mesh parameters; If not, dividing the graphic file so that all meshes in the graphic file are divided into triangular meshes, and obtaining mesh parameters of the graphic file after the division process; According to the grid parameters of the divided graphic file, the deformation parameters of the divided graphic file are calculated.
17. A processing device for a flexible body surface grid, It is characterized in that include: An acquisition module, used for acquiring mesh parameters of a graphic file of a flexible body, and calculating deformation parameters of the graphic file based on the mesh parameters; wherein the mesh parameters include a first UV coordinate and a three-dimensional coordinate of each mesh vertex; and the deformation parameters include a curvature of each mesh and a curvature of each mesh vertex; A first determination module is used to determine the auxiliary UV coordinates of the mesh vertices of the auxiliary mesh corresponding to each mesh based on the curvature of each mesh and the first UV coordinates of the mesh vertices; A first processing module is used to process the first UV coordinates of the mesh vertices of each mesh and the auxiliary UV coordinates of the mesh vertices of the auxiliary mesh corresponding to each mesh based on an energy optimization algorithm, and update the second UV coordinates of the mesh vertices of each mesh; A second determination module, configured to determine a curvature gradient of each mesh vertex based on a second UV coordinate and a curvature of the mesh vertex of each mesh; A second processing module is used for redistributing the second UV coordinates of each mesh vertex based on the particle model under the updated curvature gradient of each mesh vertex to obtain the third UV coordinates of the mesh vertex of each mesh; The updating module is used to update the three-dimensional coordinates of the mesh vertices of each mesh based on the third UV coordinates of the mesh vertices of each mesh to obtain the updated three-dimensional coordinates of the mesh vertices of each mesh.
18. An electronic device, It is characterized in that The electronic device comprises: processor; a memory for storing processor-executable instructions; Wherein, the processor is configured to execute the method for processing a flexible body surface mesh according to any one of claims 1-16.
19. A computer-readable storage medium, It is characterized in that The storage medium stores a computer program, and the computer program can be executed by a processor to complete the method for processing a flexible body surface mesh according to any one of claims 1 to 16.