Flexible body simulation method, electronic device, storage medium, and computer program product

The simulation method iteratively calculates forces on unit vertices to determine the initial state of a flexible body, addressing the challenge of obtaining realistic deformation and interaction, thereby enhancing simulation accuracy.

CN118839537BActive Publication Date: 2024-12-27LINGDI (ZHEJIANG) TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411319395.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-20
Publication Date
2024-12-27
Estimated Expiration
2044-09-20

AI Technical Summary

Technical Problem

Existing simulation methods for flexible human bodies struggle to accurately determine the initial state from mesh data, which is crucial for achieving realistic deformation and interaction with external forces, as the initial state is difficult to obtain directly from the real world.

Method used

A simulation method that iteratively calculates the final forces on each unit vertex of a flexible body, including elastic, gravity, and support forces, to determine the target initial position, using morphology matrices and energy models to balance gravity and deformation.

Benefits of technology

Enables the determination of the initial state of a flexible body, leading to more realistic simulation effects by accurately representing the shape and interaction with external forces.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118839537B_ABST
    Figure CN118839537B_ABST
Patent Text Reader

Abstract

The present application provides a simulation method of a flexible body, an electronic device, a storage medium, and a computer program product, including: S1: taking the current position of each unit vertex of the target flexible body as a temporary initial position; S2: calculating the final force corresponding to each unit vertex based on the temporary initial position of each unit vertex; wherein the final force of each unit vertex is determined by the elastic force, gravity, and support force of the unit vertex; S3: judging whether the iteration termination condition is met according to the final force of all unit vertices of the target flexible body; S4: if not, updating the temporary initial position of each unit vertex with the final force of each unit vertex, and returning to step S2; S5: repeatedly iterating until the iteration termination condition is met, taking the latest temporary initial position of each unit vertex of the target flexible body as the target initial position. The present application scheme generates mesh data in the initial state for the flexible body.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of graphic simulation technology, and in particular to a simulation method and device for a flexible body, an electronic device, a computer-readable storage medium, and a computer program product. Background Art

[0002] Physical simulation is a computer technology based on the principles of mechanics that can be used to simulate various scenes in the real world, such as falling leaves and models walking on the catwalk. In the field of physical simulation in graphics, human body simulation plays a very core role. For example, when designers design clothes, they need to use simulation to simulate the effect of models wearing clothes in real time so that they can adjust the design at any time; in animation production, physical simulation can quickly obtain the effects of animated characters wearing different clothes in different actions, avoiding traditional high-intensity modeling work. In the simulation process of these scenes, the human body generally has two ways of expression: rigid human body and flexible human body.

[0003] The representation of the rigid human body assumes that the human body is rigid and will not deform. During the simulation, when the clothes touch the human body, the clothes will be deformed due to collision and stick to the surface of the human body, but the human body will not be deformed due to the restraint of the clothes. Figure 1 , which is a schematic diagram of a rigid human body simulated in related simulation technologies, such as Figure 1 As shown in Figure 1, the rigid human body does not deform under the restraint of the clothes. In this case, the change of human body shape under different postures and actions depends on the human body data input from the outside.

[0004] The representation of the flexible human body assumes that the human body is flexible and will deform when subjected to external forces. For example, when a person is wearing tight clothing, the body will be squeezed and deformed, and local areas of the body will have marks due to the deformation. Figure 2 , which is a schematic diagram of a flexible human body simulated in related simulation technology, Figure 2 compared to Figure 1 , which caused marks on the clothes due to squeezing.

[0005] These two simulation methods each have obvious advantages and disadvantages. The rigid human body method is simpler for simulation. The human body shape is completely input from the outside world and does not need to rely on simulation algorithm calculation. The simulation algorithm only needs to focus on other deformable bodies (such as clothing). The disadvantage is that the rigid human body interacts with other objects in the simulation and the impact on the human body itself cannot be reflected. For example: no marks will be produced, and the tightness of clothes cannot be seen. The advantages and disadvantages of the flexible human body are exactly the opposite of the rigid human body. In the simulation process, the human body shape needs to be calculated by the simulation algorithm, and there are many factors to consider. Therefore, the impact of the interaction between the human body and other objects can be shown in the simulation scene, and a more realistic human body effect can be obtained.

[0006] In the simulation of flexible human bodies, there is a very important requirement to balance the gravity of flexible human bodies. The human body shape in the natural state is the result of gravity, so the human body data obtained by modeling the natural human body takes into account the influence of gravity. In other words, the mesh data obtained by modeling the natural flexible body (flexible human body, or other flexible objects) takes into account the influence of gravity.

[0007] In the simulation algorithm, the concept of an "initial state" of a flexible body is very important. In the initial state, the flexible body can present the shape when it is not subjected to any external force (including gravity). When the flexible body is deformed under the action of external force, it can generate corresponding deformation force to resist the external force. The deformation force needs to be obtained by comparing and calculating the "current state" of the flexible body with the "initial state" to determine the degree of deformation. The greater the degree of deformation, the greater the deformation force. The stable flexible body shape finally obtained by the simulation is the shape in which the deformation force of the flexible body is equal to the gravity. It can be seen that the initial state of the flexible body required for the simulation is the shape of the flexible body in the absence of gravity, so that the stable state obtained by the simulation can be exactly the same as the state obtained by modeling the natural flexible body.

[0008] However, during the simulation process, the initial state of the flexible body is difficult to obtain directly from the real world, and there is an urgent need for a solution to restore the initial state from the mesh data obtained from the simulation. Summary of the invention

[0009] The purpose of the embodiments of the present application is to provide a simulation method of a flexible body, an electronic device, a storage medium, and a computer program product, which are used to generate mesh data in an initial state for the flexible body.

[0010] On the one hand, the present application provides a simulation method for a flexible body, comprising:

[0011] S1: The current position of each unit vertex of the target flexible body is used as a temporary initial position;

[0012] S2: Based on the temporary initial position of each unit vertex, the final force corresponding to each unit vertex is calculated; wherein the final force of each unit vertex is determined by the elastic force, gravity and support force of the unit vertex;

[0013] S3: judging whether an iteration termination condition is satisfied according to the final forces of all unit vertices of the target flexible body;

[0014] S4: If not, update the temporary initial position of each unit vertex with the final force of each unit vertex, and return to step S2;

[0015] S5: Repeatedly iterate until an iteration termination condition is met, and take the latest temporary initial position of each unit vertex of the target flexible body as the target initial position.

[0016] In one embodiment, the step of obtaining the elastic force of each unit vertex in step S2 includes:

[0017] For each unit vertex, determine a current morphology matrix and an initial morphology matrix according to the current positions and temporary initial positions of each unit vertex of the mesh unit where the unit vertex is located, and determine a deformation gradient based on the current morphology matrix and the initial morphology matrix;

[0018] Determining a first parameter based on an energy model of the target flexible body and the deformation gradient;

[0019] Determining a second parameter based on a specified constant matrix, the initial morphology matrix, and a preset identity matrix;

[0020] The elastic force of the unit vertex is determined according to the first parameter and the second parameter.

[0021] In one embodiment, the step of obtaining the gravity of each unit vertex in step S2 includes:

[0022] For each unit vertex, the volume of the grid unit is determined according to the temporary initial positions of each unit vertex of the grid unit where the unit vertex is located;

[0023] The gravity of the vertex of the unit is determined according to the volume of the grid unit, the density of the target flexible body and the gravitational acceleration.

[0024] In one embodiment, the step of obtaining the support force of each unit vertex in step S2 includes:

[0025] For each unit vertex, the support force of the unit vertex is determined according to the strength matrix, current position and temporary initial position of the unit vertex; if the unit vertex is not supported, its corresponding strength matrix is ​​zero; if the unit vertex is supported, its corresponding strength matrix is ​​a preset value.

[0026] In one embodiment, judging whether an iteration termination condition is satisfied according to the final forces of all unit vertices of the target flexible body includes:

[0027] Determine the force modulus of the target flexible body according to the final forces of all unit vertices of the target flexible body, and judge whether the force modulus is less than a preset residual;

[0028] If so, determine that the iteration termination condition is met;

[0029] If not, it is determined that the iteration termination condition is not satisfied.

[0030] In one embodiment, the updating of the temporary initial position of each unit vertex based on the final force of each unit vertex includes:

[0031] For each unit vertex, calculate the gradient of the final force on the unit vertex with respect to the temporary initial position of the unit vertex;

[0032] Based on the gradient and final force corresponding to each unit vertex, determine the position update amount corresponding to each unit vertex;

[0033] For each unit vertex, a new temporary initial position is determined according to the temporary initial position and position update amount of the unit vertex.

[0034] In one embodiment, the gradient corresponding to each unit vertex includes a first sub-gradient, where the first sub-gradient is a gradient of the elastic force of the unit vertex to the temporary initial position of the unit vertex;

[0035] The step of obtaining the first sub-gradient comprises:

[0036] Determine the type matrix according to the initial shape matrix of the grid cell where the cell vertex is located and the specified constant matrix;

[0037] Determining a first parameter and a third parameter based on an energy model of the target flexible body and a deformation gradient of a mesh unit where the unit vertex is located;

[0038] A first sub-gradient of the unit vertex is determined according to the type matrix, the first parameter, the third parameter, the deformation gradient, a preset unit matrix and a preset exchange matrix.

[0039] In one embodiment, the gradient corresponding to each unit vertex includes a second sub-gradient, where the second sub-gradient is a gradient of the gravity of the unit vertex to the temporary initial position of the unit vertex;

[0040] The step of obtaining the second sub-gradient comprises:

[0041] Determine the type matrix according to the initial shape matrix of the grid cell where the cell vertex is located and the specified constant matrix;

[0042] A second sub-gradient of the unit vertex is determined according to the density of the target flexible body, the gravitational acceleration, the type matrix and a preset unit matrix.

[0043] In one embodiment, the gradient corresponding to each unit vertex includes a third sub-gradient, and the third sub-gradient is the gradient of the support force of the unit vertex to the temporary initial position of the unit vertex. The third sub-gradient is equivalent to the strength matrix of the unit vertex.

[0044] On the other hand, the present application provides an electronic device, the electronic device comprising:

[0045] processor;

[0046] a memory for storing processor-executable instructions;

[0047] Wherein, the processor is configured to execute the above-mentioned flexible body simulation method.

[0048] Furthermore, 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 flexible body simulation method.

[0049] In addition, the present application provides a computer program product, including a computer program / instruction, which implements the above-mentioned flexible body simulation method when executed by a processor.

[0050] In the present application scheme, when simulating a flexible body, the target initial position of each unit vertex can be determined for the flexible body in the simulation software, thereby obtaining the initial state of the flexible body. Subsequent simulation processing based on the initial state of the flexible body can obtain a more realistic simulation effect. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] 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.

[0052] Figure 1 is a schematic diagram of a rigid human body simulated in a related simulation technology;

[0053] Figure 2 It is a schematic diagram of a flexible human body simulated in a related simulation technology;

[0054] Figure 3 A schematic diagram of the structure of an electronic device provided in one embodiment of the present application;

[0055] Figure 4 A schematic diagram of a flow chart of a simulation method for a flexible body provided in one embodiment of the present application;

[0056] Figure 5 A comparison diagram of simulation effects of a flexible human body provided in an embodiment of the present application;

[0057] Figure 6 A schematic diagram of a flow chart of a method for obtaining elastic force provided in an embodiment of the present application;

[0058] Figure 7 A schematic diagram of deformation comparison of a grid unit provided in an embodiment of the present application;

[0059] Figure 8 A schematic diagram of a flow chart of a method for obtaining gravity provided in an embodiment of the present application;

[0060] Fig. 9 A schematic diagram of a flow chart of a method for updating a temporary initial position provided in an embodiment of the present application;

[0061] Fig.10 A schematic diagram of a flow chart of a method for determining a first sub-gradient provided in an embodiment of the present application;

[0062] Fig.11 A schematic diagram of a flow chart of a method for determining a second sub-gradient provided in an embodiment of the present application;

[0063] Fig.12 A block diagram of a flexible body simulation device provided in one embodiment of the present application. DETAILED DESCRIPTION

[0064] 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.

[0065] 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.

[0066] like Figure 3 As shown, this embodiment provides an electronic device 1, including: at least one processor 11 and a memory 12, Figure 3 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 computing center, etc., for executing the simulation method of the flexible body.

[0067] 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, magnetic disk or optical disk.

[0068] 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 flexible body simulation method provided by the present application.

[0069] The present application also provides a computer program product, including a computer program / instruction, which implements the flexible body simulation method provided in the present application when the computer program / instruction is executed by a processor.

[0070] See also Figure 4 , is a flow chart of a simulation method for a flexible body provided in an embodiment of the present application, such as Figure 4 As shown, the method may include the following steps S1 to S5.

[0071] Step S1: taking the current position of each unit vertex of the target flexible body as a temporary initial position.

[0072] The target flexible body is a flexible body that needs to achieve gravity balance. For example, the target flexible body can be a flexible human body, a balloon, a rubber material, etc.

[0073] The grid file of the target flexible body is composed of a plurality of grid units. The grid unit is in the form of a polyhedron, and a suitable polyhedron can be selected as the grid unit as required. For example, the grid unit can be a tetrahedron, a hexahedron, an octahedron, a dodecahedron, etc.

[0074] The current position of each unit vertex is the position of the target flexible body at the current moment, and the current position is represented by the coordinates in the three-dimensional coordinate system established in the simulation software.

[0075] When simulating gravity balance of the target flexible body, there is no initial position of each unit vertex. It can be assumed that the initial position of each unit vertex is the current position. The initial position at this time is not the actual initial position and is called a temporary initial position.

[0076] Step S2: Based on the temporary initial position of each unit vertex, the final force corresponding to each unit vertex is calculated; wherein the final force of each unit vertex is determined by the elastic force, gravity and support force of the unit vertex.

[0077] Based on the temporary initial position of each unit vertex, the elastic force, gravity and support force of each unit vertex can be calculated. Here, the elastic force is the force on the unit vertex due to the deformation of the grid unit in which it is located; the gravity is the force on the unit vertex due to the weight of the grid unit in which it is located; the support force is the force on the unit vertex supported in the target flexible body. The elastic force, gravity and support force all have magnitude and direction. After determining the elastic force, gravity and support force, the final force on the unit vertex can be determined.

[0078] Step S3: judging whether the iteration termination condition is satisfied according to the final forces of all unit vertices of the target flexible body.

[0079] After obtaining the final forces of all unit vertices of the target flexible body, it can be determined whether the iteration termination condition is met.

[0080] In one embodiment, the modulus of force of the target flexible body can be determined according to the final forces of all unit vertices of the target flexible body. The square of the final force of each unit vertex is calculated respectively, and the sum of the squares of all squares is calculated, and the square root of the sum of squares is taken to obtain the modulus of force. Alternatively, the final force with the largest value can be selected from the final forces of all unit vertices of the target flexible body, and the magnitude of the final force is used as the modulus of force.

[0081] After obtaining the force modulus of the target flexible body, it can be determined whether the force modulus is less than the preset residual. Here, the residual can be configured as needed. The smaller the residual, the higher the accuracy of the solution. The size of the configured residual is adapted to the calculation method of the force modulus.

[0082] On the one hand, if the force modulus is smaller than the residual, it can be determined that the iteration termination condition is met.

[0083] On the other hand, if the force modulus is not less than the residual, it can be determined that the iteration termination condition is not met.

[0084] In addition, if the force modulus length does not decrease in multiple consecutive iterations, it can be determined that the iteration termination condition is met. Here, the round threshold can be configured as needed. Exemplarily, if the force modulus length does not decrease in five consecutive iterations, it can be determined that the iteration termination condition is met.

[0085] Step S4: If not, update the temporary initial position of each unit vertex with the final force of each unit vertex, and return to step S2.

[0086] Step S5: Repeat the iteration until the iteration termination condition is met, and take the latest temporary initial position of each unit vertex of the target flexible body as the target initial position.

[0087] If the iteration termination condition is not met, the temporary initial position of each unit vertex can be updated with the final force of each unit vertex. After obtaining the new temporary initial position of each unit vertex, the process can return to step S2 to start a new round of Newton iteration.

[0088] Through repeated iterations, when the iteration termination condition is met, it can be considered that the latest temporary initial position of each unit vertex is the actual initial position of each unit vertex when the target flexible body is in the initial state. Therefore, the latest temporary initial position of each unit vertex is used as the target initial position of the unit vertex. Here, the target initial position is the actual initial position obtained by the final solution.

[0089] See also Figure 5 , is a comparison diagram of the simulation effect of a flexible human body provided in an embodiment of the present application, Figure 5 The left side shows the flexible human body modeled based on the natural human body, which is the input data of the user in the simulation software; Figure 5 In the middle is the flexible human body after the relevant scheme is directly simulated with input data; Figure 5 The right side shows the flexible human body after simulating the input data according to this scheme. It can be seen that Figure 5 The chest and buttocks of the flexible human body in the middle have obvious sagging in places with thicker flesh. This is because the human body data obtained by modeling the natural human body is already affected by gravity, and gravity is applied in the simulation software. Figure 5 On the right, this solution achieves gravity balance for flexible human body simulation, which can maintain the human body shape desired by the input data.

[0090] Through the above measures, when simulating a flexible body, the target initial position of each unit vertex can be determined for the flexible body in the simulation software, thereby obtaining the initial state of the flexible body. Subsequent simulation processing based on the initial state of the flexible body can obtain a more realistic simulation effect.

[0091] In one embodiment, see Figure 6, is a flow chart of a method for obtaining elastic force provided in an embodiment of the present application, such as Figure 6 As shown, for each unit vertex, the elastic force of the unit vertex can be determined through the following steps 610 to 640.

[0092] Step 610: For each unit vertex, determine the current morphology matrix and the initial morphology matrix according to the current positions and temporary initial positions of each unit vertex of the mesh unit where the unit vertex is located, and determine the deformation gradient based on the current morphology matrix and the initial morphology matrix.

[0093] For each unit vertex, the current shape matrix can be determined according to the current positions of each unit vertex of the grid unit where the unit vertex is located. The current shape matrix can represent the current structural shape of the grid unit. For each unit vertex, the initial shape matrix can be determined according to the temporary initial positions of each unit vertex of the grid unit where the unit vertex is located. The initial shape matrix can represent the structural shape of the grid unit in the initial state.

[0094] After obtaining the current morphology matrix and the initial morphology matrix, the deformation gradient of the unit vertex can be determined. For example, the calculation method of the deformation gradient can be expressed by the following formula (1):

[0095] (1)

[0096] Among them, D s is the current morphology matrix; D m is the initial shape matrix.

[0097] For grid units of different forms, the current shape matrix and the initial shape matrix can be determined in a manner adapted to their forms. For example, the grid unit is a tetrahedron. Figure 7 , is a deformation comparison diagram of a grid unit provided in an embodiment of the present application, such as Figure 7 As shown in FIG. 1 , the temporary initial positions of the four unit vertices of the mesh unit are X0, X1, X2, and X3 respectively. After the deformation occurs, the current positions of the four unit vertices of the mesh unit are x0, x1, x2, and x3. Here, the temporary initial position and the current position with the same subscript belong to the same unit vertex.

[0098] At this point, the calculation method of the current morphology matrix can be expressed by the following formula (2):

[0099] (2)

[0100] The calculation method of the initial morphology matrix can be expressed by the following formula (3):

[0101] (3)

[0102] Step 620: Determine a first parameter based on the energy model and deformation gradient of the target flexible body.

[0103] For any type of target flexible body, an energy model can be preconfigured for it, and the energy model represents the energy per unit volume when the material of the target flexible body undergoes deformation indicated by the deformation gradient F. Different parts of the same target flexible body can be configured with different energy models as needed. For example, if the target flexible body is a flexible human body, the elastic forces generated by the deformation of the skin, muscles, fat and other parts of the flexible human body are different, so corresponding energy models can be configured respectively.

[0104] For example, the energy model may be a Neo-Hookean series model, a StVK model, etc. In this solution, the energy model is not specifically limited and is simplified as .

[0105] The first parameter can be obtained by calculating the first-order derivative of the energy model with respect to the deformation gradient.

[0106] Exemplarily, the first parameter can be expressed by the following formula (4):

[0107] (4)

[0108] Wherein, P is the first parameter; is the energy model; F is the deformation gradient.

[0109] Since the temporary initial positions of each unit vertex will change in each round during the calculation process of the Newton iteration algorithm, the initial morphological matrix will change in each round, and accordingly, the deformation gradient and the first parameter will also change.

[0110] Step 630: Determine the second parameter based on the specified constant matrix, the initial shape matrix and the preset unit matrix.

[0111] The specified constant matrix is ​​configured as needed. The second parameter is the first-order derivative of the deformation gradient with respect to the current position. Exemplarily, the calculation process of the second parameter can be represented by the following formula (5):

[0112] , (5)

[0113] here, is the second parameter; S is the specified constant matrix; D m is the initial shape matrix; I is the unit matrix. In this scheme, I is a 3*3 unit matrix.

[0114] Step 640: Determine the elastic force of the unit vertex according to the first parameter and the second parameter.

[0115] The elastic force of a cell vertex can be considered as the first-order derivative of the energy model with respect to the current position of each cell vertex of the grid cell where the cell vertex is located. Therefore, the elastic force can be expressed by the following formula (6):

[0116] , (6)

[0117] Where x is the current position of each unit vertex. Formula (6) takes the tetrahedral mesh unit as an example. If the mesh unit is other polyhedrons, the current position may include the coordinates of more unit vertices. For the energy model.

[0118] Based on the above formula (4), formula (6) is transformed so that the elastic force is expressed by the following formula (7):

[0119] (7)

[0120] It can be seen from formula (7) that by multiplying the first parameter by the second parameter, the negative of the product can be used as the elastic force of the cell vertex in the grid cell.

[0121] Through the above measures, the elastic force can be calculated for each unit vertex of the target flexible body.

[0122] In one embodiment, see Figure 8 , is a flow chart of a method for obtaining gravity provided in an embodiment of the present application, such as Figure 8 As shown, the method may include the following steps 810 to 820.

[0123] Step 810: For each unit vertex, determine the volume of the grid unit according to the temporary initial positions of each unit vertex of the grid unit where the unit vertex is located.

[0124] Since the temporary initial position of each unit vertex will change in each round of calculation in the Newton iteration algorithm, the volume of the grid unit calculated in each round will change.

[0125] Step 820: Determine the gravity of the cell vertex according to the volume of the grid cell, the density of the target flexible body and the gravitational acceleration.

[0126] The density of the target flexible body can be configured according to its actual density.

[0127] The multiple unit vertices of a mesh unit can be considered to divide the gravity of the mesh unit equally. Taking the tetrahedral mesh unit as an example, the gravity received by each unit vertex can be expressed by the following formula (8):

[0128] , (8)

[0129] in, is the density; is the gravitational acceleration; G represents the gravitational acceleration of the four unit vertices. If the mesh unit is another polyhedron, the number of g contained in G is equal to the number of unit vertices n, and 1 / 4 in formula (8) is replaced by 1 / n.

[0130] Through the above measures, the gravity received by each unit vertex of the target flexible body can be calculated.

[0131] In one embodiment, when obtaining the support force of each unit vertex in step S2, for each unit vertex, the support force of the unit vertex can be determined according to the strength matrix, current position and temporary initial position of the unit vertex. If the unit vertex is not supported, its corresponding strength matrix is ​​zero; if the unit vertex is supported, its corresponding strength matrix is ​​a preset value. The support force received by the unit vertex can come from the outside of the target flexible body or from the inside of the target flexible body. Exemplarily, the target flexible body is a flexible human body, and the unit vertices in the part where the flexible human body contacts the ground can be supported by the ground; the unit vertices in the flesh part of the flexible human body are supported by the mesh units of the skeletal part.

[0132] In the mesh data of the target flexible body, it can be pre-configured whether each unit vertex is subject to support force.

[0133] For example, the support force on the unit vertex can be expressed by the following formula (9):

[0134] (9)

[0135] Where X is the temporary initial position of the unit vertex; x is the current position of the unit vertex; K is the strength matrix of the unit vertex. If the unit vertex is not supported, K is 0. If the unit vertex is supported, K is a preset value. Here, the preset value can be a maximum value (such as 10 12 ), thereby ensuring The value is always very small, thus approximately guaranteeing .

[0136] In addition, as needed, different strength matrices can be pre-configured for unit vertices that are supported in different areas of the target flexible body, so as to obtain a more realistic simulation effect during the simulation process.

[0137] In one embodiment, see Fig. 9 , is a flow chart of a method for updating a temporary initial position provided in an embodiment of the present application, such as Fig. 9 As shown, when executing step S4 to update the temporary initial position, the following steps 910 to 930 may be included.

[0138] Step 910: For each unit vertex, calculate the gradient of the final force on the unit vertex with respect to the temporary initial position of the unit vertex.

[0139] Step 920: Based on the gradient and final force corresponding to each unit vertex, determine the position update amount corresponding to each unit vertex.

[0140] For each unit vertex, the final force of the unit vertex can be determined based on the elastic force, support force and gravity of the unit vertex. For example, the final force is expressed by the following formula (10):

[0141] (10)

[0142] in, is the elastic force; is gravity; is the supporting force. When the three are in equilibrium, the final force is 0. During the Newton iteration process from S1 to S5, f gradually decreases and approaches 0.

[0143] The relationship between the gradient of the final force on the temporary initial position of the unit vertex, the final force and the position update amount can be expressed by the following formula (11):

[0144] (11)

[0145] in, is the gradient of the final force to the temporary initial position of the unit vertex; f is the final force; is the position update amount.

[0146] By using formula (11), the corresponding position update amount can be calculated for each unit vertex.

[0147] Step 930: For each unit vertex, determine a new temporary initial position according to the temporary initial position and position update amount of the unit vertex.

[0148] After obtaining the position update amount of each unit vertex, the position update amount can be added to the latest temporary initial position to obtain a new temporary initial position. Exemplarily, the update process is represented by the following formula (12):

[0149] (12)

[0150] Where X represents the temporary initial position of the unit vertex; is the position update amount.

[0151] When executing the aforementioned steps 910 to 930 to update the temporary initial position, the gradient of the temporary initial position of the unit vertex by the final force can be decomposed into a first sub-gradient, a second sub-gradient, and a third sub-gradient. Among them, the first sub-gradient is the gradient of the elastic force of the unit vertex to the temporary initial position of the unit vertex. The second sub-gradient is the gradient of the gravity of the unit vertex to the temporary initial position of the unit vertex. The third sub-gradient is the gradient of the support force of the unit vertex to the temporary initial position of the unit vertex. The calculation process of the first sub-gradient, the second sub-gradient, and the third sub-gradient is described in detail below.

[0152] In one embodiment, see Fig.10 , is a flow chart of a method for determining a first sub-gradient provided in an embodiment of the present application, such as Fig.10 As shown, the method may include the following steps 1010 to 1030.

[0153] Step 1010: Determine the type matrix according to the initial shape matrix of the grid cell where the cell vertex is located and the specified constant matrix.

[0154] For example, the calculation method of the type matrix can be expressed by the following formula (13):

[0155] (13)

[0156] Where W is the type matrix; D m is the initial morphology matrix. The method for obtaining the initial morphology matrix refers to the relevant description above. S is the form of the specified constant matrix, see formula (5).

[0157] It can be seen from formula (13) that all cell vertices of the same grid cell share the same type of matrix.

[0158] Step 1020: Determine the first parameter and the third parameter based on the energy model of the target flexible body and the deformation gradient of the mesh unit where the unit vertex is located.

[0159] The method for determining the first parameter may refer to the method shown in the above formula (4), which will not be described in detail here.

[0160] The third parameter can be obtained by calculating the second-order derivative of the energy model with respect to the deformation gradient.

[0161] Exemplarily, the calculation method of the third parameter is represented by the following formula (14):

[0162] (14)

[0163] in, is the third parameter; is the energy model; F is the deformation gradient.

[0164] Step 1030: Determine the first sub-gradient of the unit vertex according to the type matrix, the first parameter, the third parameter, the deformation gradient, the preset unit matrix and the preset exchange matrix.

[0165] Among them, the commutation matrix is ​​a constant matrix. In this scheme, the commutation matrix can be expressed by the following formula (15):

[0166] (15)

[0167] Exemplarily, the calculation method of the first sub-gradient can be expressed by the following formula (16):

[0168] (16)

[0169] here, is the first sub-gradient; W is the type matrix; is the third parameter; F is the deformation gradient; I is the unit matrix, and a 3*3 unit matrix is ​​used in this scheme; P is the first parameter; k 33 For the switching matrix.

[0170] Through the above measures, the first sub-gradient can be calculated for each unit vertex.

[0171] In one embodiment, see Fig.11 , is a flow chart of a method for determining a second sub-gradient provided in an embodiment of the present application, such as Fig.11 As shown, the method may include the following steps 1110 to 1120.

[0172] Step 1110: Determine the type matrix according to the initial shape matrix of the grid cell where the cell vertex is located and the specified constant matrix.

[0173] Here, the method for determining the type matrix refers to the aforementioned formula (13), which will not be repeated here.

[0174] Step 1120: Determine the second sub-gradient of the unit vertex according to the density, gravity acceleration, type matrix and preset unit matrix of the target flexible body.

[0175] For the identity matrix, it can be vectorized and then transposed to obtain a new matrix, which can be expressed by the following formula (17):

[0176] (17)

[0177] Furthermore, the calculation process of the second sub-gradient can be expressed by the following formula (18):

[0178] (18)

[0179] in, is the second sub-gradient; is the density; G represents the gravitational acceleration of multiple unit vertices; Represents the new matrix obtained by transforming the identity matrix; W represents the type matrix.

[0180] Through the above measures, the second sub-gradient can be calculated for each unit vertex.

[0181] In one embodiment, the third sub-gradient corresponding to each unit vertex may be equivalent to the intensity matrix of the unit vertex. Exemplarily, the third sub-gradient is represented by the following formula (19):

[0182] (19)

[0183] in, is the third sub-gradient; K is the intensity matrix of the unit vertex.

[0184] After obtaining the first sub-gradient, the second sub-gradient, and the third sub-gradient of each unit vertex, formula (11) can be transformed to obtain formula (20):

[0185] (20)

[0186] The position update amount of each unit vertex can be calculated by formula (20): .

[0187] Fig.12 is a block diagram of a simulation device for a flexible body according to an embodiment of the present invention. Fig.12 As shown, the device may include:

[0188] The setting module 1210 is used to execute step S1: taking the current position of each unit vertex of the target flexible body as a temporary initial position;

[0189] The calculation module 1220 is used to execute step S2: based on the temporary initial position of each unit vertex, calculate the final force corresponding to each unit vertex; wherein the final force of each unit vertex is determined by the elastic force, gravity and support force of the unit vertex;

[0190] The judging module 1230 is used to execute step S3: judging whether an iteration termination condition is satisfied according to the final forces of all unit vertices of the target flexible body;

[0191] The updating module 1240 is used to execute step S4: if not, update the temporary initial position of each unit vertex with the final force of each unit vertex, and return to step S2;

[0192] The obtaining module 1250 is used to execute step S5: repeatedly iterate until an iteration termination condition is met, and the latest temporary initial position of each unit vertex of the target flexible body is used as the target initial position.

[0193] 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 flexible body simulation method, and will not be repeated here.

[0194] 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.

[0195] 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.

[0196] 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. The computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute 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 simulation method for a flexible body, characterized in that: include: S1: The current position of each unit vertex of the target flexible body is used as a temporary initial position; S2: Based on the temporary initial position of each unit vertex, the final force corresponding to each unit vertex is calculated; wherein the final force of each unit vertex is determined by the elastic force, gravity and support force of the unit vertex; S3: judging whether the iteration termination condition is satisfied according to the final forces of all unit vertices of the target flexible body, including: determining the force modulus of the target flexible body according to the final forces of all unit vertices of the target flexible body, and judging whether the force modulus is less than a preset residual; if so, determining that the iteration termination condition is satisfied; if not, determining that the iteration termination condition is not satisfied; S4: If not, update the temporary initial position of each unit vertex with the final force of each unit vertex, and return to step S2; wherein, updating the temporary initial position of each unit vertex with the final force of each unit vertex includes: for each unit vertex, calculating the gradient of the final force of the unit vertex to the temporary initial position of the unit vertex; based on the gradient and the final force corresponding to each unit vertex, determining the position update amount corresponding to each unit vertex; for each unit vertex, determining a new temporary initial position according to the temporary initial position and the position update amount of the unit vertex; S5: Repeatedly iterate until an iteration termination condition is met, and take the latest temporary initial position of each unit vertex of the target flexible body as the target initial position.

2. The method according to claim 1, characterized in that The step of obtaining the elastic force of each unit vertex in step S2 includes: For each unit vertex, determine a current morphology matrix and an initial morphology matrix according to the current positions and temporary initial positions of each unit vertex of the mesh unit where the unit vertex is located, and determine a deformation gradient based on the current morphology matrix and the initial morphology matrix; Determining a first parameter based on an energy model of the target flexible body and the deformation gradient; Determining a second parameter based on a specified constant matrix, the initial morphology matrix, and a preset identity matrix; The elastic force of the unit vertex is determined according to the first parameter and the second parameter.

3. The method according to claim 1, characterized in that The step of obtaining the gravity of each unit vertex in step S2 includes: For each unit vertex, the volume of the grid unit is determined according to the temporary initial positions of each unit vertex of the grid unit where the unit vertex is located; The gravity of the vertex of the unit is determined according to the volume of the grid unit, the density of the target flexible body and the gravitational acceleration.

4. The method according to claim 1, characterized in that The step of obtaining the support force of each unit vertex in step S2 includes: For each unit vertex, the support force of the unit vertex is determined according to the strength matrix, current position and temporary initial position of the unit vertex; if the unit vertex is not supported, its corresponding strength matrix is ​​zero; if the unit vertex is supported, its corresponding strength matrix is ​​a preset value.

5. The method according to claim 1, characterized in that The gradient corresponding to each unit vertex includes a first sub-gradient, where the first sub-gradient is a gradient of the elastic force of the unit vertex to the temporary initial position of the unit vertex; The step of obtaining the first sub-gradient comprises: Determine the type matrix according to the initial shape matrix of the grid cell where the cell vertex is located and the specified constant matrix; Determining a first parameter and a third parameter based on an energy model of the target flexible body and a deformation gradient of a mesh unit where the unit vertex is located; A first sub-gradient of the unit vertex is determined according to the type matrix, the first parameter, the third parameter, the deformation gradient, a preset unit matrix and a preset exchange matrix.

6. The method according to claim 1, characterized in that The gradient corresponding to each unit vertex includes a second sub-gradient, where the second sub-gradient is the gradient of the gravity of the unit vertex to the temporary initial position of the unit vertex; The step of obtaining the second sub-gradient comprises: Determine the type matrix according to the initial shape matrix of the grid cell where the cell vertex is located and the specified constant matrix; A second sub-gradient of the unit vertex is determined according to the density of the target flexible body, the gravitational acceleration, the type matrix and a preset unit matrix.

7. The method according to claim 1, characterized in that The gradient corresponding to each unit vertex includes a third sub-gradient, where the third sub-gradient is the gradient of the support force of the unit vertex to the temporary initial position of the unit vertex, and the third sub-gradient is equivalent to the strength matrix of the unit vertex.

8. An electronic device, characterized in that: The electronic device comprises: processor; a memory for storing processor-executable instructions; Wherein, the processor is configured to execute the flexible body simulation method according to any one of claims 1 to 7.

9. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and the computer program can be executed by a processor to complete the flexible body simulation method according to any one of claims 1 to 7.

10. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instruction is executed by a processor, the flexible body simulation method according to any one of claims 1 to 7 is implemented.