Cloth simulation method, device and equipment and computer readable storage medium
By starting from the (N-1)th layer of the mesh pyramid, interpolating from sparse mesh layers to dense mesh layers and performing lightweight optimization, the problem of low data processing efficiency in cloth simulation is solved, achieving faster simulation speed and topological continuity.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- MIGU CO LTD
- Filing Date
- 2022-05-24
- Publication Date
- 2026-04-14
AI Technical Summary
Existing cloth simulation technologies have low data processing efficiency, mainly due to the large number of triangular meshes, which leads to a large amount of computation.
Starting from the (N-1)th layer of the N-layer mesh pyramid corresponding to the target cloth image, based on the interpolation relationship between two adjacent layers, the vertex positions of the sparser layer are used to interpolate to the denser layer, and lightweight optimization is performed. The calculation is performed layer by layer until the simulation result of the first layer of the mesh pyramid is obtained, ensuring topological continuity.
It effectively improves the speed of fabric simulation, increases data processing efficiency, and ensures the topological continuity of interpolation.
Smart Images

Figure CN114818376B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of fabric simulation technology, and in particular to a fabric simulation method, apparatus, equipment and computer-readable storage medium. Background Technology
[0002] Cloth simulation technology involves inputting specific materials, geometries, and scene constraints, and then using variable material physics simulation techniques to calculate the physical animation of the cloth. In cloth simulation, cloth is often represented as a triangular mesh, using thousands, hundreds of thousands, or even more triangular faces to approximate the cloth surface. The more triangular meshes there are, the more finely the material details of the cloth can be expressed, such as wrinkles and smoothness. However, a larger number of triangular meshes requires a greater amount of computation, leading to a decrease in the data processing efficiency of cloth simulation. Summary of the Invention
[0003] This application provides a fabric simulation method, apparatus, device, and computer-readable storage medium, which solves the problem of low data processing efficiency in existing fabric simulation technologies.
[0004] To solve the above problems, this application is implemented as follows:
[0005] In a first aspect, embodiments of this application provide a fabric simulation method, comprising:
[0006] Starting from the (N-1)th layer of the N-layer grid pyramid corresponding to the target fabric image, based on the interpolation relationship between two adjacent layers, the vertex positions of the first layer of the two adjacent layers are used to perform interpolation calculations on the second layer of the two adjacent layers to obtain the vertex interpolation positions of the second layer of the grid.
[0007] Lightweight optimization is performed on the vertex interpolation positions of the second layer mesh to obtain the vertex positions of the second layer mesh, where the mesh density of the first layer mesh is less than that of the second layer mesh;
[0008] The vertex positions of the first layer of the grid in the grid pyramid are used as the simulation results of the target fabric image;
[0009] Where N is greater than or equal to 2.
[0010] Optionally, the method further includes:
[0011] Perform cloth simulation calculations on the Nth layer of the mesh pyramid to obtain the vertex positions of the Nth layer of the mesh;
[0012] The Nth layer of the grid has the lowest grid density, and the grid density gradually increases from the Nth layer to the 1st layer.
[0013] Optionally, cloth simulation calculations are performed on the Nth layer of the mesh pyramid to obtain the vertex positions of the Nth layer mesh, including:
[0014] The local linearization solution is obtained by using the elastic material equation of the Nth layer mesh to obtain the vertex position deviation between two adjacent time points;
[0015] Based on the vertex position deviation and the vertex position of the Nth layer mesh at the previous moment, calculate the mesh vertex position of the Nth layer mesh at the current moment.
[0016] Optionally, the step of performing lightweight optimization on the vertex interpolation positions of the second layer mesh to obtain the vertex positions of the second layer mesh includes:
[0017] The vertex interpolation positions of the second layer mesh are initialized to obtain the first position of each vertex of the second layer mesh;
[0018] The first position is subjected to stretching and bending constraints to obtain the second position of each vertex of the second layer mesh.
[0019] Interpolation constraint optimization is performed on the second position to obtain the third position of each vertex of the second layer mesh;
[0020] If the third position satisfies a preset condition with the first position, then the third position is determined to be the vertex position of the second layer mesh.
[0021] Optionally, the preset condition includes: the norm of the difference between the first position and the third position is less than a first value.
[0022] Optionally, the method further includes:
[0023] Construct a grid pyramid of the target cloth image and record the topological correlation set of the grid vertices;
[0024] Based on the aforementioned topology-related set, an interpolation relationship is established between two adjacent grid layers in the grid pyramid.
[0025] Optionally, constructing the grid pyramid of the target fabric image includes:
[0026] Based on the vertices of the nth layer of the grid pyramid and the connection relationships between the vertices, an iterative optimization is performed using a predetermined algorithm to obtain the vertex positions of the (n+1)th layer of the grid and the connection relationships between the vertices. Based on the topology-related set, the geodesic distance projection error of the (n+1)th layer of the grid is optimized.
[0027] When n+1 equals N, a grid pyramid consisting of N layers of grids is obtained for the target fabric;
[0028] Wherein, the grid density of the (n+1)th layer is less than the grid density of the nth layer, and n = 1, 2, ... N.
[0029] Optionally, the step of iteratively optimizing the vertices of the (n+1)th layer of the grid, based on the vertices of the nth layer and the connections between them, using a predetermined algorithm, includes:
[0030] The vertices of the nth layer mesh and the connections between the vertices are used as the initial vertices and initial connections of the (n+1)th layer mesh to obtain the initial (n+1)th layer mesh.
[0031] Short edge merging is performed on all edges of the initial (n+1)th layer grid to obtain the first updated (n+1)th layer grid.
[0032] The (n+1)th layer mesh of the first update is optimized by equilateral triangles to obtain the (n+1)th layer mesh of the second update.
[0033] The (n+1)th layer mesh of the second update is subjected to Laplacian smoothing to obtain the vertex positions and the connection relationships between the vertices of the (n+1)th layer mesh.
[0034] Optionally, optimizing the geodesic distance projection error of the (n+1)th layer grid based on the topology correlation set includes:
[0035] Based on the first target topology related set corresponding to the vertices of the (n+1)th layer grid, calculate the minimum geodesic distance from the vertex of the (n+1)th layer grid to the nth layer grid; wherein, the first target topology related set includes at least one first target vertex associated with the vertex of the (n+1)th layer grid, and the first target vertex is a vertex on the nth layer grid;
[0036] Project the vertices of the (n+1)th layer grid onto the projection point corresponding to the minimum geodesic distance on the nth layer grid.
[0037] Optionally, calculating the minimum geodesic distance from a vertex of the (n+1)th layer grid to the nth layer grid based on the first target topology correlation set corresponding to the vertices of the (n+1)th layer grid includes:
[0038] Based on the first target topology-related set, determine at least one triangular facet in the nth layer mesh that contains the target vertex;
[0039] The minimum distance from the vertex of the (n+1)th layer of the mesh to the triangular facet is determined as the minimum geodesic distance from the vertex of the (n+1)th layer of the mesh to the nth layer of the mesh.
[0040] Optionally, establishing the interpolation relationship between two adjacent grid layers in the grid pyramid based on the topology-related set includes:
[0041] Based on the topology-related set, determine the set of triangle facets related to the vertices of the nth layer network from the (n+1)th layer of the grid pyramid, where n = 1, 2, ..., N;
[0042] From the set of triangle faces, determine the target triangle face that has the smallest distance to the vertex of the nth layer network;
[0043] The vertices of the nth layer network are represented by interpolation using the three vertices of the target triangular facet.
[0044] Optionally, based on the topology-related set, a set of triangle faces related to the vertices of the nth layer network is determined from the (n+1)th layer mesh of the mesh pyramid, including:
[0045] If a vertex of the nth layer network belongs to the second target topology related set corresponding to the second target vertex in the (n+1)th layer mesh, then the triangle facet containing the second target vertex belongs to the triangle facet set.
[0046] Secondly, embodiments of this application provide a fabric simulation device, comprising:
[0047] The first processing module is used to start from the (N-1)th layer of the N-layer grid pyramid corresponding to the target fabric image, and according to the interpolation relationship between two adjacent layers, use the vertex position of the first layer of the two adjacent layers to perform interpolation calculation on the second layer of the two adjacent layers to obtain the vertex interpolation position of the second layer of the grid.
[0048] The second processing module is used to perform lightweight optimization on the vertex interpolation positions of the second layer mesh to obtain the vertex positions of the second layer mesh, wherein the mesh density of the first layer mesh is less than the mesh density of the second layer mesh.
[0049] The third processing module is used to take the vertex position of the first layer of the grid in the grid pyramid as the simulation result of the target cloth image;
[0050] Where N is greater than or equal to 2.
[0051] Thirdly, embodiments of this application provide a fabric simulation device, including: a transceiver, a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the fabric simulation method described above.
[0052] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the fabric simulation method described above.
[0053] In this embodiment, starting from the (N-1)th layer of the mesh pyramid, based on the interpolation relationship between adjacent layers, the vertices of the sparser layer are used to interpolate to the denser layer, obtaining the interpolated expression of the vertices of the denser layer. Lightweight optimization is then performed to obtain the vertex positions of the denser layer. This method is used to calculate layer by layer until the simulation result of the first layer of the mesh pyramid is obtained, effectively improving the cloth simulation speed. Furthermore, in this embodiment, adjacent layers of the mesh pyramid have an interpolation relationship that guarantees topological continuity. When performing interpolation calculations, the interpolation expression is based on this relationship, ensuring the topological continuity of the interpolation. Attached Figure Description
[0054] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments of this application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0055] Figure 1 A flowchart illustrating the fabric simulation method according to an embodiment of this application;
[0056] Figure 2 A schematic diagram of a grid representing an embodiment of this application;
[0057] Figure 3 This diagram illustrates an application of the embodiments of this application to clothing simulation.
[0058] Figure 4 This is a schematic diagram showing the structure of the fabric simulation device according to an embodiment of this application;
[0059] Figure 5 This is a schematic diagram illustrating the structure of the fabric simulation device according to an embodiment of this application. Detailed Implementation
[0060] To make the technical problems, technical solutions, and advantages of this application clearer, a detailed description will be provided below in conjunction with the accompanying drawings and specific embodiments. In the following description, specific details such as particular configurations and components are provided merely to aid in a comprehensive understanding of the embodiments of this application. Therefore, those skilled in the art should understand that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of this application. Furthermore, for clarity and brevity, descriptions of known functions and structures have been omitted.
[0061] It should be understood that the phrase "one embodiment" or "an embodiment" throughout the specification means that a specific feature, structure, or characteristic related to the embodiment is included in at least one embodiment of this application. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. Furthermore, these specific features, structures, or characteristics can be combined in any suitable manner in one or more embodiments.
[0062] In the various embodiments of this application, it should be understood that the sequence numbers of the following processes do not imply a specific order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application. Furthermore, the terms "system" and "network" are often used interchangeably herein.
[0063] like Figure 1 As shown, an embodiment of this application provides a fabric simulation method, specifically including the following steps:
[0064] Step 101: Starting from the (N-1)th layer of the N-layer grid pyramid corresponding to the target fabric image, based on the interpolation relationship between two adjacent layers, use the vertex position of the first layer of the two adjacent layers to perform interpolation calculation on the second layer of the two adjacent layers to obtain the vertex interpolation position of the second layer of the grid.
[0065] Step 102: Perform lightweight optimization on the vertex interpolation positions of the second layer mesh to obtain the vertex positions of the second layer mesh, where the mesh density of the first layer mesh is less than that of the second layer mesh;
[0066] Step 103: Use the vertex position of the first layer of the grid in the grid pyramid as the simulation result of the target fabric image;
[0067] Where N is greater than or equal to 2.
[0068] In this embodiment, the fabric simulation technology simulates an image of the input fabric based on parameters such as the fabric material, geometry, and application scenario, and then calculates the physical animation process of that fabric image. In the simulation technology, the fabric is represented as a triangular mesh, with multiple triangular facets representing the curved surface of the fabric.
[0069] When simulating the target fabric, a triangular mesh pyramid corresponding to the target fabric is constructed based on the input number of fabric facets. This mesh pyramid is a high-quality mesh pyramid that has undergone optimization processing. For example, each triangle in each layer of the mesh pyramid is as close to an equilateral triangle as possible, and the area of each triangle is as consistent as possible. In the mesh pyramid, the mesh density of each layer decreases sequentially from bottom to top, that is, the bottom layer has the highest density and the top layer has the lowest density.
[0070] The mesh pyramid corresponding to the target fabric image comprises N layers, where N is greater than or equal to 2. During fabric simulation, starting from the (N-1)th layer of the mesh pyramid, vertex positions are calculated layer by layer using interpolation until the vertex positions of the first layer are obtained, at which point the simulation result is output. Specifically, adjacent layers in the mesh pyramid have an interpolation relationship that ensures topological continuity. When calculating vertex positions using interpolation, the vertices of the layer with lower mesh density are used to interpolate towards the layer with higher mesh density, obtaining the interpolated representation of the vertices of the layer with higher mesh density. This interpolated representation is then calculated and lightweight optimized to obtain the vertex positions of the layer with higher mesh density. This process is repeated layer by layer until the vertex positions of the densest layer of the mesh pyramid are obtained, thus yielding the simulation result for the target fabric image.
[0071] It should be noted that when performing cloth simulation calculations, starting from the (N-1)th layer of the mesh pyramid, the vertex positions are calculated layer by layer using interpolation. The vertex positions of the (N-1)th layer are obtained by interpolating the vertex positions of the Nth layer. The Nth layer is the sparsest layer of the mesh pyramid, and its vertex positions are obtained through cloth simulation calculations.
[0072] For example, if N is 4, the mesh pyramid has 4 layers, arranged from bottom to top as follows: layer 1, layer 2, layer 3, and layer 4. Layer 4 is the sparsest layer, and layer 1 is the densest. The vertex positions of layer 4 can be obtained through cloth simulation. Starting from layer 3, the vertex positions of layer 3 are obtained by interpolation using the vertex positions of layer 4. The vertex positions of layer 2 are then obtained by interpolation using the vertex positions of layer 3, and the vertex positions of layer 1 are obtained by interpolation using the vertex positions of layer 2, thus obtaining the cloth simulation result.
[0073] In this embodiment, starting from the (N-1)th layer of the mesh pyramid, based on the interpolation relationship between adjacent layers, the vertices of the sparser layer are used to interpolate to the denser layer, obtaining the interpolated expression of the vertices of the denser layer. Lightweight optimization is then performed to obtain the vertex positions of the denser layer. This method is used to calculate layer by layer until the simulation result of the first layer of the mesh pyramid is obtained, effectively improving the cloth simulation speed. Furthermore, in this embodiment, adjacent layers of the mesh pyramid have an interpolation relationship that guarantees topological continuity. When performing interpolation calculations, the interpolation expression is based on this relationship, ensuring the topological continuity of the interpolation.
[0074] Optionally, the method further includes: performing cloth simulation calculations on the Nth layer of the mesh in the mesh pyramid to obtain the vertex positions of the Nth layer of the mesh; wherein the mesh density of the Nth layer of the mesh is the lowest, and the mesh density gradually increases from the Nth layer of the mesh to the 1st layer of the mesh.
[0075] In this embodiment, for the Nth layer of the mesh pyramid with the sparsest mesh density, the positions of the mesh vertices are obtained using cloth simulation calculation. When calculating the vertices of the (N-1)th layer of the mesh, the vertex positions of the Nth layer are interpolated to the (N-1)th layer to obtain the interpolated positions of the vertices of the (N-1)th layer. The vertex positions of the (N-1)th layer are obtained through lightweight optimization, and this interpolation method is used to calculate layer by layer until the vertex positions of the 1st layer are obtained.
[0076] Optionally, cloth simulation calculations are performed on the Nth layer of the mesh pyramid to obtain the vertex positions of the Nth layer mesh, including:
[0077] The vertex position deviation between two adjacent moments is obtained by using the elastic material equation of the Nth layer mesh for local linearization solution; based on the vertex position deviation and the vertex position of the Nth layer mesh at the previous moment, the mesh vertex position of the Nth layer mesh at the current moment is calculated.
[0078] In this embodiment, the elastic material equation of the Nth layer mesh is as follows:
[0079]
[0080] in, This represents the vertex positions of all meshes on the Nth layer mesh at the current time t in the cloth simulation; At the previous time t-1 in the cloth simulation, the vertex positions of all meshes on the Nth layer mesh; h represents the time step; W(P) represents the vertex velocity of the Nth layer of the mesh at the previous time t-1 in the cloth simulation; M represents the standard mass matrix in the simulation; W(P) represents the velocity of the vertex of the Nth layer of the mesh. N ) is a commonly used quantity in cloth simulation, representing the internal forces between the vertices of the Nth layer mesh.
[0081] The above elastic material equation can be solved using local linearization. The locally linearized differential equation is constructed as follows:
[0082]
[0083] The aforementioned locally linearized differential equations can be efficiently solved using the conjugate gradient method to obtain the vertex position deviation ΔP between two adjacent time points. Finally, the accurate cloth simulation results for the Nth layer are obtained.
[0084]
[0085] In this embodiment, accurate cloth simulation calculations are performed on the sparsest layer of the mesh pyramid (i.e., the Nth layer mesh) to obtain the vertex positions of the Nth layer mesh. Using these vertex positions, interpolation is performed on the next higher layer (i.e., the (N-1)th layer) to obtain the interpolated vertex positions of the (N-1)th layer mesh. Specifically, this embodiment utilizes the difference relationships that ensure topological continuity in the mesh pyramid to calculate the vertex interpolation position for each vertex of the (N-1)th layer. This step effectively interpolates the vertex interpolation positions of the denser (N-1)th layer mesh based on the vertex positions of the sparser Nth layer mesh. The vertex interpolation positions in this step effectively inherit the simulated physical properties of the bottom Nth layer mesh results, such as cloth stretching, bending, and stiffness properties.
[0086] After obtaining the vertex interpolation positions of the N+1 layer mesh, lightweight optimization of the vertex interpolation positions of the N-1 layer mesh is performed through multiple iterations of Position-based Dynamics (PBD) simulations to optimize the simulation details of the N-1 layer and obtain the vertex positions of the N-1 layer mesh. Optionally, the lightweight optimization of the vertex interpolation positions of the second layer mesh to obtain the vertex positions of the second layer mesh includes:
[0087] Step 1: Initialize the vertex interpolation positions of the second layer mesh to obtain the first position of each vertex of the second layer mesh.
[0088] In this embodiment, the initialization may be to initialize the vertex interpolation positions of the second layer mesh to the vertex positions, assuming the second layer mesh is represented as follows: but The vertex interpolation positions for the second-layer mesh are λ←0.5. Optionally, the positions of the second-layer mesh before optimization are saved as follows:
[0089] Step 2: Perform stretching and bending constraints optimization on the first position to obtain the second position of each vertex of the second layer mesh.
[0090] In this embodiment, the position of each vertex of the second layer mesh is updated through stretch constraint optimization. The update formula for stretch constraint optimization is:
[0091]
[0092] in, This represents the position of vertex i in the grid at the current time t. The superscript 0 in the text indicates the initial position at the start of the mesh simulation; j indicates... A ring of neighboring vertices, j traverses the grid vertices A ring of neighborhood vertices; L i It is the total number of vertices in the neighborhood of a ring; the purpose of this step is to ensure that the local edge length of the mesh does not deviate from the input edge length, thereby maintaining the stretching properties of the cloth while increasing simulation details.
[0093] In this embodiment, the position of each vertex of the second layer mesh is updated using bending constraint optimization. The update formula for bending constraint optimization is:
[0094]
[0095] The update formula for bending constraint optimization is the same as that for stretching constraint optimization, except that in the bending constraint optimization update formula, j traverses the mesh vertices. A vertex in the neighborhood of a ring on a curved graph; L i * This represents the total number of vertices in the corresponding one-ring neighborhood. The bending graph is defined as follows: if two triangles ABC and ABD are two adjacent triangles in the original mesh (sharing edge AB), then CD is added as an edge in the bending graph. The edge length of the bending graph can effectively express the bending properties of the original mesh while increasing simulation detail.
[0096] Step 3: Perform interpolation constraint optimization on the second position to obtain the third position of each vertex of the second layer mesh.
[0097] In this embodiment, the vertex positions of the second layer mesh can also be updated using interpolation constraint optimization. The update formula for the interpolation constraint optimization is:
[0098]
[0099] Where r = 4 mm, this embodiment ensures that the interpolated grid position cannot deviate from the interpolated grid position after optimization. Too far.
[0100] Step 4: If the third position and the first position satisfy a preset condition, then the third position is determined to be a vertex position of the second layer mesh. Optionally, the preset condition includes: the norm of the difference between the first position and the third position is less than a first value.
[0101] In this embodiment, the vertex positions of the second layer mesh obtained after the above-described stretching constraint optimization, bending constraint optimization, and interpolation constraint optimization are... The position P of the second layer mesh before optimization, as recorded before optimization. * The following conditions must be met: Then the process ends, outputting the vertex positions of the second layer of the mesh. If the above preset conditions are not met, then set λ←0.99λ and repeat step 1.
[0102] In the embodiments of this application, the second layer of mesh is the layer with the higher mesh density among two adjacent layers. The vertex positions of each layer of mesh in the mesh pyramid are obtained layer by layer using the aforementioned interpolation method and lightweight optimization method, progressing layer by layer until the simulation result of the first layer of mesh in the mesh pyramid is output. For example, if the two adjacent layers are the second and third layers of mesh in the mesh pyramid, and the mesh density of the third layer is less than that of the second layer, then the third layer is the first layer, and the second layer is the second layer. After obtaining the vertex interpolation position of the second layer using the vertex interpolation of the third layer, lightweight optimization is performed on the vertex interpolation position to obtain the vertex position of the second layer. The second layer and the first layer of mesh in the mesh pyramid are also two adjacent layers. Using the same method, the vertex position of the first layer can be obtained using the vertex position of the second layer. The first layer is the bottom layer of the mesh pyramid, and obtaining the vertex position of the first layer is the final simulation result.
[0103] As an optional embodiment, the mesh pyramid corresponding to the target fabric image used in the fabric simulation solution can be preprocessed, that is, the corresponding mesh pyramid can be pre-built and stored for different fabrics, which can be used continuously in subsequent fabric simulations.
[0104] Optionally, the method further includes:
[0105] Step A: Construct a grid pyramid of the target cloth image and record the topologically related set of the grid vertices.
[0106] Step B: Based on the topology-related set, establish the interpolation relationship between two adjacent grid layers in the grid pyramid.
[0107] Optionally, constructing the grid pyramid of the target fabric image includes: iteratively optimizing the vertices of the nth layer grid and the connection relationships between the vertices using a predetermined algorithm to obtain the vertex positions and connection relationships between the vertices of the (n+1)th layer grid, and optimizing the geodesic distance projection error of the (n+1)th layer grid according to the topological correlation set; when n+1 equals N, obtaining a grid pyramid of the target fabric including N layers of grids; wherein the grid density of the (n+1)th layer grid is less than the grid density of the nth layer grid, and n = 1, 2, ..., N.
[0108] In this embodiment, when constructing the mesh pyramid, the network is built layer by layer from the layer with higher mesh density to the layer with lower mesh density. For example, when n is 1, the vertices of the first layer mesh and the connections between them are used for multiple iterations of optimization to obtain the second layer mesh; the vertices of the second layer mesh and the connections between them are used for multiple iterations of optimization to obtain the third layer mesh, and so on, until the sparsest layer mesh is obtained. After each iteration of optimization, the number of vertices gradually decreases, thus the mesh density of the resulting mesh pyramid gradually decreases from the first layer upwards. When obtaining the vertices and connections of the (n+1)th layer mesh, the topological correlation set of each vertex of the (n+1)th layer mesh is simultaneously recorded. This topological correlation set includes at least one vertex in the nth layer mesh that is related to a vertex of the (n+1)th layer mesh.
[0109] Optionally, for the calculation process of the vertex positions and connections between vertices of the (n+1)th layer mesh and the optimization of the geodesic distance projection error of the (n+1)th layer mesh, the number of iterations can be set to m. That is, the vertex positions and connections between vertices of the (n+1)th layer mesh are obtained by iterative optimization through a predetermined algorithm, and the process of optimizing the geodesic distance projection error of the (n+1)th layer mesh is iteratively executed m times according to the topology-related set.
[0110] Optionally, the step of iteratively optimizing the vertices of the (n+1)th layer of the grid, based on the vertices of the nth layer and the connections between them, using a predetermined algorithm, includes:
[0111] 1) Take the vertices of the nth layer mesh and the connection relationships between the vertices as the initial vertices and initial connection relationships of the (n+1)th layer mesh to obtain the initial (n+1)th layer mesh;
[0112] 2) Perform short edge merging on all edges in the initial (n+1)th layer mesh to obtain the first updated (n+1)th layer mesh;
[0113] 3) Perform equilateral triangle optimization on the (n+1)th layer mesh of the first update to obtain the (n+1)th layer mesh of the second update;
[0114] 4) Perform Laplacian smoothing on the (n+1)th layer mesh of the second update to obtain the vertex positions and the connection relationships between the vertices of the (n+1)th layer mesh.
[0115] During iterative optimization of the mesh, the (n+1)th layer mesh is first initialized to match the nth layer mesh. That is, in the initial setup phase, the vertex positions and connectivity of the (n+1)th layer mesh are set to be the same as those of the nth layer mesh. Optionally, each vertex P in the (n+1)th layer mesh is simultaneously recorded. n+1,i The topologically related set G n+1,i ={P n,k The meaning of this topologically related set can be represented as: vertex P in the (n+1)th layer of the mesh. n+1,i The corresponding topology-related set is G. n+1,i G n+1,i The vertex P of the nth layer of the mesh contained therein n,k With the vertex P n+1,i Related. During the initialization phase, for each vertex of the (n+1)th layer mesh, G n+1,i It is a set that contains only itself (at this time, the vertices and vertex connections of the (n+1)th layer mesh and the nth layer mesh are the same).
[0116] All edges of the initialized (n+1)th layer mesh are sorted in ascending order of edge length. Edges with lengths less than a predetermined threshold are merged, combining two vertices into a single vertex. The corresponding topology-related sets are also merged in the same way. The predetermined threshold is selected such that the current iteration reduces the number of vertices to be reduced by 1 / m. After the short edge merging process, the first updated vertices of the (n+1)th layer mesh and the connections between them are obtained.
[0117] For the (n+1)th layer mesh after short-side merging, equilateral triangle optimization is performed. Specifically, all edges of the (n+1)th layer mesh are traversed. For two triangles ABC and ABD with the same edge AB, edge AB is deleted while edge CD is added. If triangles ACD and BCD are closer to equilateral triangles than the original triangles ABC and ABD, the deletion and addition operation is retained; otherwise, no changes are made.
[0118] After optimizing the (n+1)th layer mesh with equilateral triangles, the vertices and their connections are obtained in the second update. Laplacian smoothing is then applied to the (n+1)th layer mesh after equilateral triangle optimization. Specifically, all vertices of the (n+1)th layer mesh are traversed. For each vertex, the average position of its one-ring neighboring vertices is used as the target position, and the vertex is moved towards the target position by a small step of 1 / m.
[0119] After initializing, merging short sides, optimizing equilateral triangles, and smoothing with Laplace, the geodesic distance projection error of the (n+1)th layer mesh is optimized.
[0120] Optionally, optimizing the geodesic distance projection error of the (n+1)th layer grid based on the topological correlation set includes:
[0121] Based on the first target topology correlation set corresponding to the vertices of the (n+1)th layer grid, calculate the minimum geodesic distance from the vertices of the (n+1)th layer grid to the nth layer grid; wherein, the first target topology correlation set includes at least one first target vertex associated with the vertices of the (n+1)th layer grid, and the first target vertex is a vertex on the nth layer grid; project the vertices of the (n+1)th layer grid onto the projection point on the nth layer grid corresponding to the minimum geodesic distance.
[0122] Optionally, calculating the minimum geodesic distance from a vertex of the (n+1)th layer grid to the nth layer grid based on the first target topology correlation set corresponding to the vertices of the (n+1)th layer grid includes:
[0123] Based on the first target topology related set, at least one triangular facet containing the target vertex is determined in the nth layer mesh; the minimum distance from the vertex of the (n+1)th layer mesh to the triangular facet is determined as the minimum geodesic distance from the vertex of the (n+1)th layer mesh to the nth layer mesh.
[0124] In this embodiment, all vertices of the (n+1)th layer grid are traversed. For each vertex i, the geodesic distance from that vertex to the nth layer grid is calculated, and the vertex is projected onto the point with the closest geodesic distance. Since the (n+1)th layer grid and the nth layer grid are two disconnected grids, but the first target topology-related set G... n+1,i The topological correspondence between the two mesh layers is recorded, so it is only necessary to traverse all meshes containing G on the nth mesh layer. n+1,i For each triangle facet of the target vertex, calculate the distance from the point to the face. The minimum distance can be defined as the minimum geodesic distance, and then the projection point that satisfies the minimum geodesic distance can be obtained. Finally, move vertex i to the projection point position.
[0125] In this embodiment, by combining short-side merging, opposing triangle optimization, Laplace smoothing and other related operations, the geodesic distance projection error of the mesh is optimized, so that a high-quality sparse mesh that is closest to the original mesh can be obtained, and the matching error problem in different parts of the mesh can be avoided.
[0126] In the above-described process of constructing the mesh pyramid of the target cloth image, when determining the vertices and connection relationships of the (n+1)th layer mesh using the nth layer mesh, the number of vertices and connection relationships of the vertices of the second layer mesh are given when determining the vertices of the second layer mesh using the first layer mesh. That is, the parameters of the initial layer mesh when constructing the mesh pyramid are given, and the input parameters of the first layer mesh are the input parameters set during cloth simulation (e.g., number of faces, number of vertices, vertex connection relationships, etc.). Therefore, the formed first layer mesh is the initial mesh representation of the cloth simulation. After constructing the mesh pyramid, starting from the Nth layer mesh, the vertex positions of each layer mesh are calculated layer by layer until the vertex positions of the first layer mesh are obtained, thus obtaining the simulation results of the target cloth image simulation.
[0127] This embodiment can simplify the mesh and optimize geodesic distance projection error based on a fabric triangle mesh with a large number of faces, generating a high-quality N-layer mesh pyramid. The number of faces in each layer of the mesh pyramid is less than the number of faces in the layer above it (i.e., the number of faces in the (n+1)th layer is less than the number of faces in the nth layer). For each fabric triangle mesh, the preprocessing stage for obtaining the mesh pyramid only needs to be performed once and can be stored for subsequent use.
[0128] In constructing the mesh pyramid, optimizing the geodesic distance projection error ensures that the geodesic distance from each vertex of each triangular mesh layer to the previous mesh layer is sufficiently small. This scheme uses geodesic distance instead of the commonly used Euclidean distance, guaranteeing that the simplified mesh projection process is only affected by vertices related to the original mesh topology, and not by other irrelevant parts of the mesh. Each layer of the triangular pyramid can be constructed as follows: Figure 2 As shown, if Euclidean distance is used to calculate the projection error, point A may be affected by point B. This application uses geodesic distance to avoid grid vertices being affected by unrelated vertices.
[0129] The mesh pyramid constructed in this application is a high-quality triangular mesh pyramid. Each layer of triangular mesh guarantees high quality: each triangle in a single layer is as close as possible to an equilateral triangle, and the area of each triangle is as consistent as possible. High-quality triangular meshes improve the quality of physical simulation results. In this application's embodiments, an optimized multi-mesh generation scheme for geodesic distance projection errors can generate a high-quality triangular mesh pyramid and establish a mesh interpolation scheme that ensures topological continuity. The mesh pyramid preprocessing scheme only needs to process each mesh once to meet subsequent acceleration requirements.
[0130] Optionally, when constructing the grid pyramid, an interpolation relationship ensuring topological continuity between two adjacent grid layers in the grid pyramid can be established based on the recorded topology-related set. Establishing the interpolation relationship between two adjacent grid layers in the grid pyramid based on the topology-related set includes:
[0131] Based on the topology-related set, from the (n+1)th layer of the grid pyramid, determine the set of triangle faces related to the vertices of the nth layer network, n = 1, 2, ..., N; from the set of triangle faces, determine the target triangle face that has the smallest distance to the vertex of the nth layer network; use the three vertices of the target triangle face to interpolate and express the vertex of the nth layer network.
[0132] Optionally, based on the topology-related set, determining the set of triangle faces related to the vertices of the nth layer network from the (n+1)th layer of the grid pyramid includes: if a vertex of the nth layer network belongs to the second target topology-related set corresponding to the second target vertex in the (n+1)th layer network, then the triangle face containing the second target vertex belongs to the set of triangle faces.
[0133] In this embodiment, when establishing interpolation relationships that guarantee topological continuity between different levels, the approach is to consider a vertex P of the nth layer mesh. n,i (i.e., vertex i of the nth layer mesh), find the most relevant set of triangle faces from the (n+1)th layer mesh, and then find the nearest triangle face. Use the three vertices of the nearest triangle face to interpolate P. n,i .
[0134] In determining the nearest triangle in the nth layer mesh, a set of triangles associated with the vertices of the nth layer mesh needs to be constructed. This set of triangles contains triangles determined from the (n+1)th layer mesh. Wherein, if vertex P of the nth layer mesh... n,i Belongs to the topologically related set G n+1,k That is, the G n+1,k Includes the vertex P n,i Then the topologically related set G n+1,k The corresponding vertex P of the (n+1)th layer of the mesh n+1,k The triangular facet containing the second target vertex belongs to the set of triangular faces, which can be denoted as the set of triangular faces F. n,i ={f n+1,i,j}
[0135] Traverse the set F of triangle faces n,i Calculate f for each triangular facet in the set. n+1,i,j With the vertex P n,iChoose the target triangle face with the smallest distance from the given distance. Using the target triangular patch The difference between the three vertices represents the vertex P. n,i Specifically, vertex P can be... n,i Projected onto the target triangular facet And calculate the centroid coordinates {w} of the projection point. l,i,k |k=0,1,2}, using the centroid coordinates and the target triangular facet The three vertices can represent the vertex P. n,i .
[0136] In this embodiment, establishing an interpolation relationship that guarantees topological continuity between different levels means that when interpolating from a sparser grid to a denser grid, topological continuity needs to be guaranteed: for a topologically adjacent grid vertex on the (n+1)th layer grid, it is also obtained by interpolating from a topologically adjacent vertex on the nth layer grid. The interpolation relationship can ensure that the vertices of the grid are not affected by vertices in other unrelated positions. For example, when a long-sleeved garment is held in a cross-arm pose, the fabric at the cuffs should not be affected by the fabric at the chest.
[0137] For example, when the fabric simulation method of this application is specifically implemented on a complex garment, as shown in the example... Figure 3 As shown, this includes three frames of simulation results at different times; the original mesh has approximately 100,000 triangular faces, and the mesh pyramid constructed in this invention has N=2, with the number of new two layers of faces being approximately 25,000 and 6,000 respectively; in this implementation, the number of iterations for preprocessing mesh simplification is m=10. Figure 3 As shown, the simulated clothing changes shape and position at different times, and clearly displays changes in clothing details (such as the position of folds in the skirt). Compared to simulation methods without this invention, the time consumption can be reduced to 10% of the original, while the simulation effect is not significantly affected.
[0138] In the embodiments of this application, during the preprocessing stage, mesh simplification is performed to optimize the geodesic distance projection error. For each vertex, the set of topologically corresponding points associated with it during the mesh simplification process is recorded. An interpolation relationship is established between different mesh layers to ensure topological continuity, resulting in a high-quality mesh pyramid. During the actual operation stage, accurate cloth-laying simulation calculations are performed on the sparsest mesh layer to obtain the vertex positions of that layer. The vertices of that layer are then interpolated to the adjacent denser mesh layer to obtain the vertex interpolation positions. Lightweight optimization is performed to obtain the vertex positions. This method is used to advance layer by layer, finally outputting the simulation results of the first layer mesh.
[0139] The multi-grid generation scheme for optimizing geodesic distance projection error can generate high-quality triangular grid pyramids and establish a grid interpolation scheme that ensures topological continuity. The preprocessing scheme for the grid pyramid only needs to process each grid once to meet the subsequent acceleration requirements.
[0140] In this embodiment, starting from the (N-1)th layer of the mesh pyramid, based on the interpolation relationship between adjacent layers, the vertices of the sparser layer are used to interpolate to the denser layer, obtaining the interpolated expression of the vertices of the denser layer. Lightweight optimization is then performed to obtain the vertex positions of the denser layer. This method is used to calculate layer by layer until the simulation result of the first layer of the mesh pyramid is obtained, effectively improving the cloth simulation speed. Furthermore, in this embodiment, adjacent layers of the mesh pyramid have an interpolation relationship that guarantees topological continuity. When performing interpolation calculations, the interpolation expression is based on this relationship, ensuring the topological continuity of the interpolation.
[0141] like Figure 4 As shown in the illustration, this application also provides a fabric simulation device, comprising:
[0142] The first processing module 410 is used to start from the (N-1)th layer of the N-layer grid pyramid corresponding to the target fabric image, and according to the interpolation relationship between two adjacent layers, use the vertex position of the first layer of the two adjacent layers to perform interpolation calculation on the second layer of the two adjacent layers to obtain the vertex interpolation position of the second layer of the grid.
[0143] The second processing module 420 is used to perform lightweight optimization on the vertex interpolation position of the second layer mesh to obtain the vertex position of the second layer mesh, wherein the mesh density of the first layer mesh is less than the mesh density of the second layer mesh.
[0144] The third processing module 430 is used to take the vertex position of the first layer of the grid in the grid pyramid as the simulation result of the target fabric image;
[0145] Where N is greater than or equal to 2.
[0146] Optionally, the device further includes:
[0147] The fourth processing module is used to perform cloth simulation calculation on the Nth layer of the mesh in the mesh pyramid to obtain the vertex positions of the Nth layer of the mesh;
[0148] The Nth layer of the grid has the lowest grid density, and the grid density gradually increases from the Nth layer to the 1st layer.
[0149] Optionally, the fourth processing module is specifically used for:
[0150] The local linearization solution is obtained by using the elastic material equation of the Nth layer mesh to obtain the vertex position deviation between two adjacent time points;
[0151] Based on the vertex position deviation and the vertex position of the Nth layer mesh at the previous moment, calculate the mesh vertex position of the Nth layer mesh at the current moment.
[0152] Optionally, the second processing module includes:
[0153] An initialization unit is used to initialize the vertex interpolation positions of the second layer mesh, thereby obtaining the first position of each vertex of the second layer mesh;
[0154] The first optimization unit is used to perform stretching constraint optimization and bending constraint optimization on the first position to obtain the second position of each vertex of the second layer mesh.
[0155] The second optimization unit is used to perform interpolation constraint optimization on the second position to obtain the third position of each vertex of the second layer mesh;
[0156] The first determining unit is configured to determine the third position as the vertex position of the second layer mesh if the third position and the first position satisfy a preset condition.
[0157] Optionally, the preset condition includes: the norm of the difference between the first position and the third position is less than a first value.
[0158] Optionally, the device further includes:
[0159] The mesh pyramid construction module is used to construct the mesh pyramid of the target cloth image and record the topological correlation set of the mesh vertices;
[0160] The interpolation relationship establishment module is used to establish the interpolation relationship between two adjacent grid layers in the grid pyramid based on the topology-related set.
[0161] Optionally, the grid pyramid building module includes:
[0162] The first processing unit is used to perform iterative optimization using a predetermined algorithm based on the vertices of the nth layer of the grid and the connection relationships between the vertices, to obtain the vertex positions and connection relationships between the vertices of the (n+1)th layer of the grid, and to optimize the geodesic distance projection error of the (n+1)th layer of the grid based on the topology-related set.
[0163] The first acquisition unit is used to acquire the grid pyramid of the target fabric, which includes N layers of grid, when n+1 equals N.
[0164] Wherein, the grid density of the (n+1)th layer is less than the grid density of the nth layer, and n = 1, 2, ... N.
[0165] Optionally, the first processing unit is specifically used for:
[0166] The vertices of the nth layer mesh and the connections between the vertices are used as the initial vertices and initial connections of the (n+1)th layer mesh to obtain the initial (n+1)th layer mesh.
[0167] Short edge merging is performed on all edges of the initial (n+1)th layer grid to obtain the first updated (n+1)th layer grid.
[0168] The (n+1)th layer mesh of the first update is optimized by equilateral triangles to obtain the (n+1)th layer mesh of the second update.
[0169] The (n+1)th layer mesh of the second update is subjected to Laplacian smoothing to obtain the vertex positions and the connection relationships between the vertices of the (n+1)th layer mesh.
[0170] Optionally, the first processing unit is specifically used for:
[0171] Based on the first target topology related set corresponding to the vertices of the (n+1)th layer grid, calculate the minimum geodesic distance from the vertex of the (n+1)th layer grid to the nth layer grid; wherein, the first target topology related set includes at least one first target vertex associated with the vertex of the (n+1)th layer grid, and the first target vertex is a vertex on the nth layer grid;
[0172] Project the vertices of the (n+1)th layer grid onto the projection point corresponding to the minimum geodesic distance on the nth layer grid.
[0173] Optionally, calculating the minimum geodesic distance from a vertex of the (n+1)th layer grid to the nth layer grid based on the first target topology correlation set corresponding to the vertices of the (n+1)th layer grid includes:
[0174] Based on the first target topology-related set, determine at least one triangular facet in the nth layer mesh that contains the target vertex;
[0175] The minimum distance from the vertex of the (n+1)th layer of the mesh to the triangular facet is determined as the minimum geodesic distance from the vertex of the (n+1)th layer of the mesh to the nth layer of the mesh.
[0176] Optionally, the interpolation relationship establishment module includes:
[0177] The second determining unit is used to determine, based on the topology-related set, the set of triangle facets related to the vertices of the nth layer network from the (n+1)th layer of the grid pyramid, where n = 1, 2, ..., N;
[0178] The third determining unit is used to determine the target triangular facet with the smallest distance to the vertex of the nth layer network from the set of triangular facets;
[0179] The vertices of the nth layer network are represented by interpolation using the three vertices of the target triangular facet.
[0180] Optionally, the second determining unit is specifically used to: if the vertex of the nth layer network belongs to the second target topology related set corresponding to the second target vertex in the (n+1)th layer mesh, then the triangle facet containing the second target vertex belongs to the triangle facet set.
[0181] In this embodiment, starting from the (N-1)th layer of the mesh pyramid, based on the interpolation relationship between adjacent layers, the vertices of the sparser layer are used to interpolate to the denser layer, obtaining the interpolated expression of the vertices of the denser layer. Lightweight optimization is then performed to obtain the vertex positions of the denser layer. This method is used to calculate layer by layer until the simulation result of the first layer of the mesh pyramid is obtained, effectively improving the cloth simulation speed. Furthermore, in this embodiment, adjacent layers of the mesh pyramid have an interpolation relationship that guarantees topological continuity. When performing interpolation calculations, the interpolation expression is based on this relationship, ensuring the topological continuity of the interpolation.
[0182] like Figure 5 As shown, this application embodiment also provides a fabric simulation device, including: a transceiver 501, a processor 502, a memory 503, and a computer program stored in the memory 503 and executable on the processor 502. When the computer program is executed by the processor, it implements the steps of the fabric simulation method. Specifically, the processor 502 is used for:
[0183] Starting from the (N-1)th layer of the N-layer grid pyramid corresponding to the target fabric image, based on the interpolation relationship between two adjacent layers, the vertex positions of the first layer of the two adjacent layers are used to perform interpolation calculations on the second layer of the two adjacent layers to obtain the vertex interpolation positions of the second layer of the grid.
[0184] Lightweight optimization is performed on the vertex interpolation positions of the second layer mesh to obtain the vertex positions of the second layer mesh, where the mesh density of the first layer mesh is less than that of the second layer mesh;
[0185] The vertex positions of the first layer of the grid in the grid pyramid are used as the simulation results of the target fabric image;
[0186] Where N is greater than or equal to 2.
[0187] Optionally, the processor is further configured to:
[0188] Perform cloth simulation calculations on the Nth layer of the mesh pyramid to obtain the vertex positions of the Nth layer of the mesh;
[0189] The Nth layer of the grid has the lowest grid density, and the grid density gradually increases from the Nth layer to the 1st layer.
[0190] Optionally, the processor performs cloth simulation calculations on the Nth layer of the mesh pyramid to obtain the vertex positions of the Nth layer mesh, including:
[0191] The local linearization solution is obtained by using the elastic material equation of the Nth layer mesh to obtain the vertex position deviation between two adjacent time points;
[0192] Based on the vertex position deviation and the vertex position of the Nth layer mesh at the previous moment, calculate the mesh vertex position of the Nth layer mesh at the current moment.
[0193] Optionally, the processor performs lightweight optimization on the vertex interpolation positions of the second layer mesh to obtain the vertex positions of the second layer mesh, including:
[0194] The vertex interpolation positions of the second layer mesh are initialized to obtain the first position of each vertex of the second layer mesh;
[0195] The first position is subjected to stretching and bending constraints to obtain the second position of each vertex of the second layer mesh.
[0196] Interpolation constraint optimization is performed on the second position to obtain the third position of each vertex of the second layer mesh;
[0197] If the third position satisfies a preset condition with the first position, then the third position is determined to be the vertex position of the second layer mesh.
[0198] Optionally, the preset condition includes: the norm of the difference between the first position and the third position is less than a first value.
[0199] Optionally, the processor is further configured to:
[0200] Construct a grid pyramid of the target cloth image and record the topological correlation set of the grid vertices;
[0201] Based on the aforementioned topology-related set, an interpolation relationship is established between two adjacent grid layers in the grid pyramid.
[0202] Optionally, the processor constructs a grid pyramid of the target fabric image, including:
[0203] Based on the vertices of the nth layer of the grid pyramid and the connection relationships between the vertices, an iterative optimization is performed using a predetermined algorithm to obtain the vertex positions of the (n+1)th layer of the grid and the connection relationships between the vertices. Based on the topology-related set, the geodesic distance projection error of the (n+1)th layer of the grid is optimized.
[0204] When n+1 equals N, a grid pyramid consisting of N layers of grids is obtained for the target fabric;
[0205] Wherein, the grid density of the (n+1)th layer is less than the grid density of the nth layer, and n = 1, 2, ... N.
[0206] Optionally, the processor, based on the vertices of the nth layer of the grid and the connections between them, iteratively optimizes using a predetermined algorithm to obtain the vertex positions and connections between the (n+1)th layer of the grid, including:
[0207] The vertices of the nth layer mesh and the connections between the vertices are used as the initial vertices and initial connections of the (n+1)th layer mesh to obtain the initial (n+1)th layer mesh.
[0208] Short edge merging is performed on all edges of the initial (n+1)th layer grid to obtain the first updated (n+1)th layer grid.
[0209] The (n+1)th layer mesh of the first update is optimized by equilateral triangles to obtain the (n+1)th layer mesh of the second update.
[0210] The (n+1)th layer mesh of the second update is subjected to Laplacian smoothing to obtain the vertex positions and the connection relationships between the vertices of the (n+1)th layer mesh.
[0211] Optionally, the processor optimizes the geodesic distance projection error of the (n+1)th layer grid based on the topology correlation set, including:
[0212] Based on the first target topology related set corresponding to the vertices of the (n+1)th layer grid, calculate the minimum geodesic distance from the vertex of the (n+1)th layer grid to the nth layer grid; wherein, the first target topology related set includes at least one first target vertex associated with the vertex of the (n+1)th layer grid, and the first target vertex is a vertex on the nth layer grid;
[0213] Project the vertices of the (n+1)th layer grid onto the projection point corresponding to the minimum geodesic distance on the nth layer grid.
[0214] Optionally, the processor calculates the minimum geodesic distance from the vertex of the (n+1)th layer mesh to the nth layer mesh based on the first target topology correlation set corresponding to the vertices of the (n+1)th layer mesh, including:
[0215] Based on the first target topology-related set, determine at least one triangular facet in the nth layer mesh that contains the target vertex;
[0216] The minimum distance from the vertex of the (n+1)th layer of the mesh to the triangular facet is determined as the minimum geodesic distance from the vertex of the (n+1)th layer of the mesh to the nth layer of the mesh.
[0217] Optionally, the processor establishes an interpolation relationship between two adjacent mesh layers in the mesh pyramid based on the topology-related set, including:
[0218] Based on the topology-related set, determine the set of triangle facets related to the vertices of the nth layer network from the (n+1)th layer of the grid pyramid, where n = 1, 2, ..., N;
[0219] From the set of triangle faces, determine the target triangle face that has the smallest distance to the vertex of the nth layer network;
[0220] The vertices of the nth layer network are represented by interpolation using the three vertices of the target triangular facet.
[0221] Optionally, the processor determines the set of triangle faces associated with the vertices of the nth layer network from the (n+1)th layer mesh of the mesh pyramid based on the topology-related set, including:
[0222] If a vertex of the nth layer network belongs to the second target topology related set corresponding to the second target vertex in the (n+1)th layer mesh, then the triangle facet containing the second target vertex belongs to the triangle facet set.
[0223] The bus architecture may include any number of interconnected buses and bridges, specifically linking various circuits of one or more processors 502 (represented by processor 502) and memory 503 (represented by memory 503). The bus architecture may also link various other circuits, such as peripheral devices, voltage regulators, and power management circuits, which are well known in the art and therefore will not be described further herein. The bus interface provides an interface. The transceiver 501 may be multiple elements, including transmitters and transceivers, providing a unit for communicating with various other devices over a transmission medium. The processor 502 is responsible for managing the bus architecture and general processing, and the memory 503 may store data used by the processor during operation.
[0224] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware or by a computer program instructing the relevant hardware to implement them. The computer program includes instructions to perform some or all of the steps of the above methods; and the computer program can be stored in a readable storage medium, which can be any form of storage medium.
[0225] In addition, specific embodiments of the present invention also provide a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the steps in the above-described fabric simulation method. This achieves the same technical effect, and to avoid repetition, will not be described further here.
[0226] In the several embodiments provided in this application, it should be understood that the disclosed methods and apparatus can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0227] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can be physically comprised separately, or two or more units can be integrated into one unit. The integrated unit described above can be implemented in hardware or in the form of hardware plus software functional units.
[0228] The integrated units implemented as software functional units described above can be stored in a computer-readable storage medium. These software functional units, stored in a storage medium, include several instructions that cause a computer device (which may be a personal computer, server, or network device, etc.) to execute some steps of the transmission and reception methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0229] The above describes the preferred embodiments of the present invention. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principles of the present invention, and these improvements and modifications are also within the scope of protection of the present invention.
Claims
1. A cloth simulation method characterized by, include: Starting from the (N-1)th layer of the N-layer grid pyramid corresponding to the target fabric image, based on the interpolation relationship between two adjacent layers, the vertex positions of the first layer of the two adjacent layers are used to perform interpolation calculations on the second layer of the two adjacent layers to obtain the vertex interpolation positions of the second layer of the grid. Lightweight optimization is performed on the vertex interpolation positions of the second layer mesh to obtain the vertex positions of the second layer mesh, where the mesh density of the first layer mesh is less than that of the second layer mesh; The vertex positions of the first layer of the grid in the grid pyramid are used as the simulation results of the target fabric image; Where N is greater than or equal to 2; the grid pyramid is a triangular grid pyramid; The step of performing lightweight optimization on the vertex interpolation positions of the second layer mesh to obtain the vertex positions of the second layer mesh includes: The vertex interpolation positions of the second layer mesh are initialized to obtain the first position of each vertex of the second layer mesh; The first position is subjected to stretching and bending constraints to obtain the second position of each vertex of the second layer mesh. Interpolation constraint optimization is performed on the second position to obtain the third position of each vertex of the second layer mesh; If the third position satisfies a preset condition with the first position, then the third position is determined to be the vertex position of the second layer mesh.
2. The method of claim 1, wherein, The method further includes: Perform cloth simulation calculations on the Nth layer of the mesh pyramid to obtain the vertex positions of the Nth layer of the mesh; The Nth layer of the grid has the lowest grid density, and the grid density gradually increases from the Nth layer to the 1st layer.
3. The method of claim 2, wherein, Perform cloth simulation calculations on the Nth layer of the mesh pyramid to obtain the vertex positions of the Nth layer mesh, including: The local linearization solution is obtained by using the elastic material equation of the Nth layer mesh to obtain the vertex position deviation between two adjacent time points; Based on the vertex position deviation and the vertex position of the Nth layer mesh at the previous moment, calculate the mesh vertex position of the Nth layer mesh at the current moment.
4. The method of claim 1, wherein, The preset conditions include: the norm of the difference between the first position and the third position is less than a first value.
5. The method according to claim 1, characterized in that, The method further includes: Construct a grid pyramid of the target cloth image and record the topological correlation set of the grid vertices; Based on the aforementioned topology-related set, an interpolation relationship is established between two adjacent grid layers in the grid pyramid.
6. The method according to claim 5, characterized in that, The construction of the grid pyramid for the target fabric image includes: Based on the vertices of the nth layer of the grid pyramid and the connection relationships between the vertices, an iterative optimization is performed using a predetermined algorithm to obtain the vertex positions of the (n+1)th layer of the grid and the connection relationships between the vertices. Based on the topology-related set, the geodesic distance projection error of the (n+1)th layer of the grid is optimized. When n+1 equals N, a grid pyramid consisting of N layers of grids is obtained for the target fabric; Wherein, the grid density of the (n+1)th layer is less than the grid density of the nth layer, and n = 1, 2, ... N.
7. The method according to claim 6, characterized in that, The step of obtaining the vertex positions and connection relationships of the (n+1)th layer of the grid by iterative optimization using a predetermined algorithm based on the vertices of the nth layer of the grid and the connections between them includes: The vertices of the nth layer mesh and the connections between the vertices are used as the initial vertices and initial connections of the (n+1)th layer mesh to obtain the initial (n+1)th layer mesh. Short edge merging is performed on all edges of the initial (n+1)th layer grid to obtain the first updated (n+1)th layer grid. The (n+1)th layer mesh of the first update is optimized by equilateral triangles to obtain the (n+1)th layer mesh of the second update. The (n+1)th layer mesh of the second update is subjected to Laplacian smoothing to obtain the vertex positions and the connection relationships between the vertices of the (n+1)th layer mesh.
8. The method according to claim 6, characterized in that, The step of optimizing the geodesic distance projection error of the (n+1)th layer grid based on the topological correlation set includes: Based on the first target topology related set corresponding to the vertices of the (n+1)th layer grid, calculate the minimum geodesic distance from the vertex of the (n+1)th layer grid to the nth layer grid; wherein, the first target topology related set includes at least one first target vertex associated with the vertex of the (n+1)th layer grid, and the first target vertex is a vertex on the nth layer grid; Project the vertices of the (n+1)th layer grid onto the projection point corresponding to the minimum geodesic distance on the nth layer grid.
9. The method according to claim 8, characterized in that, The step of calculating the minimum geodesic distance from a vertex of the (n+1)th layer grid to the nth layer grid based on the first target topology correlation set corresponding to the vertices of the (n+1)th layer grid includes: Based on the first target topology-related set, determine at least one triangular facet in the nth layer mesh that contains the target vertex; The minimum distance from the vertex of the (n+1)th layer of the mesh to the triangular facet is determined as the minimum geodesic distance from the vertex of the (n+1)th layer of the mesh to the nth layer of the mesh.
10. The method according to claim 5, characterized in that, The step of establishing the interpolation relationship between two adjacent grid layers in the grid pyramid based on the topological correlation set includes: Based on the topology-related set, determine the set of triangle facets related to the vertices of the nth layer network from the (n+1)th layer of the grid pyramid, where n = 1, 2, ..., N; From the set of triangle faces, determine the target triangle face that has the smallest distance to the vertex of the nth layer network; The vertices of the nth layer network are represented by interpolation using the three vertices of the target triangular facet.
11. The method according to claim 10, characterized in that, Based on the topology-related set, from the (n+1)th layer of the mesh pyramid, determine the set of triangle faces related to the vertices of the nth layer network, including: If a vertex of the nth layer network belongs to the second target topology related set corresponding to the second target vertex in the (n+1)th layer mesh, then the triangle facet containing the second target vertex belongs to the triangle facet set.
12. A fabric simulation device, characterized in that, include: The first processing module is used to start from the (N-1)th layer of the N-layer grid pyramid corresponding to the target fabric image, and according to the interpolation relationship between two adjacent layers, use the vertex position of the first layer of the two adjacent layers to perform interpolation calculation on the second layer of the two adjacent layers to obtain the vertex interpolation position of the second layer of the grid. The second processing module is used to perform lightweight optimization on the vertex interpolation positions of the second layer mesh to obtain the vertex positions of the second layer mesh, wherein the mesh density of the first layer mesh is less than the mesh density of the second layer mesh. The third processing module is used to take the vertex position of the first layer of the grid in the grid pyramid as the simulation result of the target cloth image; Where N is greater than or equal to 2; the grid pyramid is a triangular grid pyramid; The second processing module includes: An initialization unit is used to initialize the vertex interpolation positions of the second layer mesh, thereby obtaining the first position of each vertex of the second layer mesh; The first optimization unit is used to perform stretching constraint optimization and bending constraint optimization on the first position to obtain the second position of each vertex of the second layer mesh. The second optimization unit is used to perform interpolation constraint optimization on the second position to obtain the third position of each vertex of the second layer mesh; The first determining unit is configured to determine the third position as the vertex position of the second layer mesh if the third position and the first position satisfy a preset condition.
13. A fabric simulation device, characterized in that, include: A transceiver, a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the fabric simulation method as described in any one of claims 1 to 11.
14. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the fabric simulation method as described in any one of claims 1 to 11.