CN114299199A - Fluid animation processing method and device, electronic equipment and storage medium - Google Patents

Fluid animation processing method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN114299199A
CN114299199A CN202111662958.3A CN202111662958A CN114299199A CN 114299199 A CN114299199 A CN 114299199A CN 202111662958 A CN202111662958 A CN 202111662958A CN 114299199 A CN114299199 A CN 114299199A
Authority
CN
China
Prior art keywords
fluid
particle
determining
particles
animation
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111662958.3A
Other languages
Chinese (zh)
Inventor
吕源丰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Netease Hangzhou Network Co Ltd
Original Assignee
Netease Hangzhou Network Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Netease Hangzhou Network Co Ltd filed Critical Netease Hangzhou Network Co Ltd
Priority to CN202111662958.3A priority Critical patent/CN114299199A/en
Publication of CN114299199A publication Critical patent/CN114299199A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Processing Or Creating Images (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

The application provides a fluid animation processing method and device, electronic equipment and a storage medium, wherein the method comprises the following steps: acquiring a first position and a first speed of each fluid particle in the fluid particle swarm at the current moment; determining the motion position of the fluid particle at the next moment according to the constrained projection equation of the fluid particle, the first position and the first speed; updating the motion position through collision detection to obtain a second position; determining an animation of the fluid particles from the current time to the next time based on the first position and the second position to obtain a fluid animation of the fluid particle group; the fluid particles are particlized, the motion state of the fluid particle group for forming the fluid is determined by determining the motion state of each fluid particle, the authenticity of the flow animation can be improved, and in the process of determining the motion state of the fluid particles, the motion state of the fluid particles is updated in combination with collision detection, and the interchangeability of the flow animation is realized.

Description

Fluid animation processing method and device, electronic equipment and storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to a fluid animation processing method and apparatus, an electronic device, and a storage medium.
Background
With the development of computer technology, fluid animation simulation is widely applied to the fields of animation movies, games and the like, and is a very important ring in visual special effect development. The fluid animation scheme of the related art focuses on reality and credibility of rendering, generally uses means of Flow map (Flow map) and Gerstner Wave (Gerstner Wave) for motion simulation, although the fluid form can be made, the fluid form is limited to restore the corresponding physical behavior through a specific algorithm, and the interactive requirement is not met.
Disclosure of Invention
In view of the above problems, the present application is proposed to provide a fluid animation processing method and apparatus, an electronic device, and a storage medium, which overcome the above problems or at least partially solve the above problems, including:
a fluid animation processing method, the method comprising:
acquiring a first position and a first speed of each fluid particle in the fluid particle swarm at the current moment;
determining the motion position of the fluid particle at the next moment according to the constrained projection equation of the fluid particle, the first position and the first speed;
updating the motion position through collision detection to obtain a second position;
determining an animation of the fluid particles based on the first location and the second location to arrive at a fluid animation of the population of fluid particles.
Optionally, the determining a moving position of the fluid particle at a next time according to the constrained projection equation of the fluid particle and the first position and the first velocity includes:
determining a gravitational positional deviation and acceleration of the fluid particles resulting from gravitational parameters;
updating the first position and the first velocity according to the gravity position offset and the acceleration;
and determining the motion position of the fluid particle at the next moment according to the constrained projection equation of the fluid particle, the updated first position and the updated first speed.
Optionally, the constraint condition of the constraint projection equation is a density constraint; determining the moving position of the fluid particle at the next moment according to the constrained projection equation of the fluid particle, the updated first position and the updated first speed, comprising:
determining a data structure of a neighbor particle search and determining neighbor particles of the fluid particles based on the data structure of the neighbor particle search;
obtaining a density constraint equation of the fluid particles;
solving the constrained projection equation according to the solution of the density constrained equation to determine the motion position of the fluid particle at the next moment.
Optionally, the method further comprises:
obtaining a relaxation factor, wherein the relaxation factor is used for restricting the projection range of the fluid particles;
updating the constrained projection equation based on the relaxation factor.
Optionally, the method further comprises:
when the pressure of the fluid particles is negative, acquiring the artificial repulsion corresponding to the fluid particles;
and determining a motion position obtained according to the constraint projection equation of the fluid particles, the first position and the first speed as an initial position, shifting a repulsive force position generated by the artificial repulsive force on the fluid particles, and updating the initial position to obtain the motion position of the fluid particles at the next moment.
Optionally, the updating the motion position through collision detection to obtain a second position includes:
when the moving position of the fluid particle is located inside the collider, the moving position of the fluid particle is adjusted to the outside of the collider to obtain a second position.
Optionally, the method further comprises:
calculating a second velocity of the fluid particles at a next time according to the second position, the first position and the first velocity, and a time step of the next time and the current time;
after determining the animation of the fluid particles from the current time to the next time, updating the first velocity with the second velocity and updating the first position with the second position.
Optionally, after the calculating a second velocity of the fluid particles at the next time according to the second position, the first position and the first velocity, and a time step of the next time and the current time, the method further comprises:
determining a viscous force damping velocity of the fluid particles caused by viscous force;
updating a second velocity of the fluid particles according to the viscous force damping velocity.
A fluid animation processing apparatus, the apparatus comprising:
the initial state acquisition module is used for acquiring a first position and a first speed of each fluid particle in the fluid particle swarm at the current moment;
the motion position determining module is used for determining the motion position of the fluid particle at the next moment according to the constrained projection equation of the fluid particle, the first position and the first speed;
the second position determining module is used for updating the motion position through collision detection to obtain a second position;
a fluid animation determination module for determining an animation of the fluid particles from the current time to the next time based on the first location and the second location to obtain a fluid animation of the fluid particle population.
Optionally, the motion position determination module includes:
a gravity parameter-based determination state module for determining a gravitational positional deviation and an acceleration of the fluid particles resulting from a gravitational parameter;
a gravity-based parameter update status module to update the first position and the first velocity according to the gravity position offset and acceleration;
and the motion position determining module is used for determining the motion position of the fluid particle at the next moment according to the constraint projection equation of the fluid particle, the updated first position and the updated first speed.
Optionally, the constraint condition of the constraint projection equation is a density constraint; the motion location determination module comprising:
a neighbor particle search determination module for determining a data structure of a neighbor particle search and determining neighbor particles of the fluid particles based on the data structure of the neighbor particle search;
a density constraint equation determination module for obtaining a density constraint equation of the fluid particles;
and the motion position determining module is used for solving the constraint projection equation according to the solution of the density constraint equation so as to determine the motion position of the fluid particle at the next moment.
Optionally, the apparatus further comprises:
a relaxation factor obtaining module, configured to obtain a relaxation factor, where the relaxation factor is used to constrain a projection range of the fluid particle;
and the constraint projection equation updating module is used for updating the constraint projection equation based on the relaxation factor.
Optionally, the apparatus further comprises:
the artificial repulsion acquiring module is used for acquiring the artificial repulsion corresponding to the fluid particles when the pressure of the fluid particles is negative;
and the movement position updating module is used for determining a movement position obtained according to the constraint projection equation of the fluid particles, the first position and the first speed as an initial position, shifting the position of the repulsion force generated by the artificial repulsion force on the fluid particles, and updating the initial position to obtain the movement position of the fluid particles at the next moment.
Optionally, the second position determination module includes:
and the collision detection module is used for adjusting the motion position of the fluid particles to the outside of the collision body to obtain a second position when the motion position of the fluid particles is positioned in the collision body.
Optionally, the apparatus further comprises:
a second velocity determination module, configured to calculate a second velocity of the fluid particle at a next time according to the second position, the first position, and the first velocity, and a time step of the next time and the current time;
an initial state update module to update the first velocity with the second velocity and update the first position with the second position after determining the animation of the fluid particles from the current time to the next time.
Optionally, the apparatus further comprises:
the viscous force damping speed acquisition module is used for determining the viscous force damping speed of the fluid particles generated by the viscous force;
and the velocity updating module is used for updating the second velocity of the fluid particles according to the viscous force damping velocity.
An electronic device comprising a processor, a memory and a computer program stored on the memory and capable of running on the processor, the computer program, when executed by the processor, implementing the steps of the fluid animation processing method as described above.
A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the fluid animation processing method as described above.
The application has the following advantages:
in an embodiment of the present application, by obtaining a first position and a first velocity of each fluid particle in a fluid particle group at a current time; determining the motion position of the fluid particle at the next moment according to the constrained projection equation of the fluid particle, the first position and the first speed; updating the motion position through collision detection to obtain a second position; determining an animation of the fluid particle from a current time to a next time based on the first location and the second location to obtain a fluid animation of the fluid particle population; the fluid particles are particlized, the motion state of the fluid particle group for forming the fluid is determined by determining the motion state of each fluid particle, the authenticity of the flow animation can be improved, and in the process of determining the motion state of the fluid particles, the motion state of the fluid particles is updated in combination with collision detection, and the interchangeability of the flow animation is realized.
Drawings
In order to more clearly illustrate the technical solutions of the present application, the drawings needed to be used in the description of the present application will be briefly introduced below, and it is apparent that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art that other drawings can be obtained according to the drawings without inventive labor.
FIG. 1 is a flow chart illustrating steps of a fluid animation processing method according to an embodiment of the present disclosure;
fig. 2 is a block diagram of a fluid animation processing apparatus according to an embodiment of the present application.
Detailed Description
In order to make the aforementioned objects, features and advantages of the present application more comprehensible, the present application is described in further detail with reference to the accompanying drawings and the detailed description. It is to be understood that the embodiments described are only a few embodiments of the present application and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
Related art fluid animation schemes generally use Flow map and Gerstner Wave to achieve the effects of fluid motion. The Flow map uses the principle of uv animation, that is, uv offset is required to be made according to information in the Flow map, and then the offset size is changed by time, so as to generate a Flow effect. Gerstner Wave controls the movement of the mesh vertices by a Gerstner Wave function to produce a flow effect. Although the above solutions can make fluid forms, they are limited to restoring the corresponding physical behaviors through specific algorithms, and do not satisfy the requirement of interaction.
In view of this, the embodiments of the present application provide a fluid animation processing method to overcome the defects of the prior art.
The fluid animation processing method in the embodiment of the application can be operated on a local terminal device or a server. When the fluid animation processing method runs on the server, the fluid animation processing method can be implemented and executed based on a cloud interaction system, wherein the cloud interaction system comprises the server and the client device.
In an optional embodiment, various cloud applications may be run under the cloud interaction system, for example: and (5) cloud games. Taking a cloud game as an example, a cloud game refers to a game mode based on cloud computing. In the running mode of the cloud game, the running main body of the game program and the game picture presenting main body are separated, the storage and the running of the fluid animation processing method are completed on the cloud game server, and the client device is used for receiving and sending data and presenting the game picture, for example, the client device can be a display device with a data transmission function close to a user side, such as a first terminal device, a television, a computer, a palm computer and the like; but the cloud game server of the cloud end is used for carrying out the fluid animation processing method. When a game is played, a player operates the client device to send an operation instruction to the cloud game server, the cloud game server runs the game according to the operation instruction, data such as game pictures and the like are encoded and compressed, the data are returned to the client device through a network, and finally the data are decoded through the client device and the game pictures are output.
In an optional implementation manner, taking a game as an example, the local terminal device stores a game program and is used for presenting a game screen. The local terminal device is used for interacting with the player through a graphical user interface, namely, a game program is downloaded and installed and operated through an electronic device conventionally. The manner in which the local terminal device provides the graphical user interface to the player may include a variety of ways, for example, it may be rendered for display on a display screen of the terminal or provided to the player through holographic projection. For example, the local terminal device may include a display screen for presenting a graphical user interface including a game screen and a processor for running the game, generating the graphical user interface, and controlling display of the graphical user interface on the display screen.
Referring to fig. 1, a flow chart illustrating steps of a fluid animation processing method according to an embodiment of the present application is provided, and in the embodiment of the present application, the method may include the following steps:
step 101, taking a first position and a first speed of each fluid particle in a fluid particle swarm at the current moment;
102, determining the motion position of the fluid particle at the next moment according to the constrained projection equation of the fluid particle, the first position and the first speed;
103, updating the motion position through collision detection to obtain a second position;
and 104, determining an animation of the fluid particles from the current time to the next time based on the first position and the second position to obtain a fluid animation of the fluid particle group.
The method comprises the steps of acquiring a first position and a first speed of each fluid particle in a fluid particle swarm at the current moment; determining the motion position of the fluid particle at the next moment according to the constrained projection equation of the fluid particle, the first position and the first speed; updating the motion position through collision detection to obtain a second position; determining an animation of the fluid particle from the current time to the next time based on the first location and the second location to arrive at a fluid animation of the population of fluid particles; the fluid particles are particlized, the motion state of the fluid particle group for forming the fluid is determined by determining the motion state of each fluid particle, the authenticity of the flow animation can be improved, and in the process of determining the motion state of the fluid particles, the motion state of the fluid particles is updated in combination with collision detection, and the interchangeability of the flow animation is realized.
Next, the fluid animation processing method in the present exemplary embodiment will be further described.
In step 101, a first position and a first velocity of each fluid particle in the fluid particle group at a current time are obtained.
The embodiments of the present application granulate a fluid, i.e. the fluid is represented by a group of fluid particles. A population of fluid particles consists of a plurality of fluid particles, with interactions between the fluid particles, each carrying a respective physical quantity comprising mass, density, velocity, etc. According to the position relation of the fluid particles in the corresponding virtual scene, the positions of the fluid particles can also be determined.
The current time may be any time, and the first position and the first velocity of each fluid particle at the current time are related to the position and the velocity at the previous time, and also affect the position and the velocity at the next time. When the current time is the initial time, the first position and the first speed of the current time are determined by preset system parameters. It can be understood that when the animation designer creates the fluid, the animation designer may configure the corresponding position parameter and velocity parameter for the fluid particles forming the fluid according to the actual requirement, as the velocity and position of the fluid particles at the initial moment.
In step 102, the moving position of the fluid particle at the next time is determined according to the constrained projection equation of the fluid particle and the first position and the first speed.
The fluid involved in the embodiment of the application is liquid fluid, the motion process of the fluid particles is subjected to various constraint effects, and the motion positions of the fluid particles at the next moment are determined by combining a constraint projection equation so as to simulate real fluid motion. In solving the constrained projection equation of the fluid particle, the first position and the first velocity of the fluid particle at the current time are combined to obtain the moving position of the fluid particle at the next time.
In an optional embodiment of the present application, in order to improve the simulation effect of the fluid animation, the determining the moving position of the fluid particle at the next time according to the constrained projection equation of the fluid particle and the first position and the first speed includes:
determining a gravitational positional deviation and acceleration of the fluid particles resulting from gravitational parameters;
updating the first position and the first velocity according to the gravity position offset and the acceleration;
and determining the motion position of the fluid particle at the next moment according to the constrained projection equation of the fluid particle, the updated first position and the updated first speed.
The present embodiment divides the force acting on the fluid particles into a force related to position constraint and a force unrelated to position constraint, and it is understood that the force related to position constraint means that the magnitude of the force acting on the fluid particles is related to the motion state of the fluid particles, including but not limited to the interaction force between the fluid particles; while forces unrelated to positional constraints refer to fixed magnitude forces, including but not limited to gravity. That is, the gravity parameter in the present embodiment means a force that cannot generate position restriction, and is not limited to gravity.
The gravity parameters can be set by animation designers according to actual requirements, and specifically include the magnitude and direction of the force. By obtaining the magnitude and direction of the force corresponding to the gravity parameter and combining Newton's second law, the gravity position offset and the acceleration of the fluid particles generated under the action of the gravity parameter can be calculated, and by combining the first position and the first speed of the fluid particles at the current moment, the updated first position and the updated first speed of the fluid particles at the current moment can be obtained.
In the embodiment, before the constrained projection equation of the fluid particles is adopted to determine the motion position of the fluid particles at the next moment, the accuracy of the calculated motion position of the fluid particles at the next moment can be ensured by calculating the influence of the gravity parameters on the position and the speed of the fluid particles and updating the first position and the first speed of the fluid particles.
In an optional embodiment of the application, the constraint condition of the constrained projection equation is a density constraint, and the determining the moving position of the fluid particle at the next time according to the constrained projection equation of the fluid particle, the updated first position and the updated first velocity includes:
determining a data structure of a neighbor particle search and determining neighbor particles of the fluid particles based on the data structure of the neighbor particle search;
obtaining a density constraint equation of the fluid particles;
solving the constrained projection equation according to the solution of the density constrained equation to determine the motion position of the fluid particle at the next moment.
Because of the interaction between fluid particles, when determining the motion state of a fluid particle, it is necessary to determine the influence of neighboring fluid particles adjacent to the fluid particle on the fluid particle. The neighboring particle search may be accelerated by a data structure of the neighboring particle search to determine neighboring fluid particles of the target fluid particle, which may be any fluid particle whose state of motion needs to be determined.
The data structures of neighbor particle search are many, the idea of Hash Hash uniform grid division is adopted in the example, the space Hash uses a Hash table to store grid information, and the corresponding Hash function is expressed as follows:
hash(Xgrid)=(xP1)XOR(yP2)XOR(zP3)mod N
wherein X represents grid coordinates, Xgrid=(x,y,z);
x, y, z are the spatial coordinates of the target fluid particle, P1、P2、P3Is a three-prime number, illustratively, P1=73856093,P2=19349663,P383492791; n is the total number of grids. The associated grid coordinates can be calculated from the fluid particle coordinates. When the space uniform division is used for neighbor search, 26 grid coordinates around the target fluid particle can be obtained according to the grid coordinates of the target fluid particle, after values of the 27 grids are respectively obtained, the fluid particles in the grids are inquired in a hash table, and whether the fluid particles are neighbor particles of the target fluid particles is judged.
Alternatively, since the fluid particles are not well located in the world space and the neighbor particle search is performed, the coordinates of the fluid particles need to be normalized by a normalization matrix, which is related to the data structure of the neighbor particle search employed. For the data structure that employs Hash uniform grid partitioning in this example, the corresponding normalization matrix is represented as follows:
Figure BDA0003447340560000101
in this embodiment, the constraint projection equation can be expressed as:
C(p+Δp)=0
where C represents the constraint equation, p represents position, and Δ p represents displacement offset.
In an alternative embodiment of the present application, the constraint equation for constraining the projection equation uses a density constraint equation, and in this case, the constraint equation C can be expressed as:
Figure BDA0003447340560000102
wherein, CiRepresenting the density constraint equation for the target fluid particle, p1, …, pnPosition, p, of a neighboring particle representing a target fluid particleiRepresenting the dynamic density of the target fluid particles; rho0Representing the static density of the fluid.
By obtaining a density constraint equation of the fluid particle, the constraint projection equation can be solved to obtain the motion position of the fluid particle at the next moment.
The density constraint equation obtained in an alternative embodiment of the present application is as follows:
Figure BDA0003447340560000103
where i represents a target fluid particle, j represents a neighboring particle of the target fluid particle, W represents a density kernel function, p represents a position, h represents a tight branch region, ρ0Represents the static density;
after determining the density constraint equation for the fluid particle, the density constraint equation may be subjected to data transformation, for example, taking a gradient for both sides of the density constraint equation, to obtain:
Figure BDA0003447340560000111
in the embodiment, a W _ spike kernel function of the Muller is used for gradient operation, wherein the W _ spike kernel function is one of the commonly used kernel functions in the field. The obtained result includes the density gradient of the target fluid particle and the neighboring particles, and the corresponding formula is as follows:
Figure BDA0003447340560000112
where k is two cases for distinguishing the target fluid particle from the neighboring particle, it can be understood that when k is i, the calculation is performed by using the previous line formula; when k is j, the next row of equations is used for the calculation.
In the process of solving the constraint projection equation, the constraint projection equation can be subjected to first-order taylor expansion to obtain a first-order taylor display formula of the constraint projection equation:
Figure BDA0003447340560000113
wherein λ is lagrange multiplier, and is expressed as follows:
Figure BDA0003447340560000114
after the solution of the density constraint equation is obtained, the value of the Lagrange multiplier can be obtained, the constraint projection equation is further solved to obtain the displacement offset, and the movement position of the fluid particles can be obtained by combining the first position.
Further, in order to prevent the system from being unstable when the edge of the nucleus is smoothed, in an optional embodiment of the present application, the fluid animation processing method may further include:
obtaining a relaxation factor, wherein the relaxation factor is used for restricting the projection range of the fluid particles;
updating the constrained projection equation based on the relaxation factor.
The size of the relaxation factor can be set by animation designers according to actual animation requirements, generally, the larger the relaxation factor is, the smaller the projection range of the fluid particles is, that is, the system can be always in a hard constraint state by adding the relaxation factor in a constraint projection equation, the size of the relaxation factor is reasonably controlled according to the actual requirements, and the fluid animation can be more truly represented.
By way of example, after introducing a relaxation factor in the above-mentioned constrained projection equation, one can obtain:
Figure BDA0003447340560000115
wherein, epsilon is a relaxation factor and is a constant, and lambda is Lagrange multiplier, and the corresponding expression is as follows:
Figure BDA0003447340560000121
the displacement offset obtained by sorting has the expression as follows:
Figure BDA0003447340560000122
after the mathematical transformation, the displacement offset can be expressed as:
Figure BDA0003447340560000123
the displacement offset can be obtained by solving the Lagrange multiplier, and then the movement position of the fluid particles at the next moment can be obtained by combining the first position of the current moment.
Further, in an alternative embodiment of the present application, it is also contemplated that the pressure gradient may be negative when there are insufficient neighboring particles to the fluid particles, thereby causing abnormal agglomeration of the particles. To solve this non-physical problem, the present embodiment introduces an additional repulsive force, i.e., an artificial repulsive force. The fluid animation processing method further comprises the following steps:
when the pressure of the fluid particles is negative, acquiring the artificial repulsion corresponding to the fluid particles;
and determining a motion position obtained according to the constraint projection equation of the fluid particles, the first position and the first speed as an initial position, shifting a repulsive force position generated by the artificial repulsive force on the fluid particles, and updating the initial position to obtain the motion position of the fluid particles at the next moment.
In this embodiment, when the pressure of the fluid particles becomes negative, the artificial repulsion corresponding to the fluid particles is obtained; updating the motion position of the fluid particles based on the artificial repulsion, wherein the corresponding displacement offset calculation formula is as follows:
Figure BDA0003447340560000124
wherein s iscorrWhich represents the force of repulsion of the human hand,
Figure BDA0003447340560000125
k is a constant, W represents a kernel function, which may be W _ poly6 kernel function, W _ poly6 kernel function is one of the commonly used kernel functions in the art; λ is the lagrange multiplier.
In step 103, the motion position is updated by collision detection, resulting in a second position.
And after the motion position of the fluid particle at the next moment is calculated through a constrained projection equation, collision detection is needed to be carried out, whether the motion position is in the collision body or not is judged, if yes, the motion position of the fluid particle is adjusted to the outside of the collision body, and the adjusted motion position is used as the final motion position of the fluid particle at the next moment, namely the second motion position.
Wherein, the collision body comprises a collision body corresponding to the neighboring particles and a boundary collision body. Alternatively, the collider corresponding to the neighboring particle may specifically be a spherical lattice coincident with the outer surface of the neighboring particle, and the boundary collider may specifically be a planar lattice coincident with the inner surface of the vessel for containing the fluid particle population.
When the collision body is a spherical grid body, the distance between the movement position and the center of the collision body is detected, whether the distance is smaller than the radius of the collision body or a certain threshold value is judged, if yes, the fluid particles are collided with the collision body, and at the moment, the movement position of the fluid particles is adjusted to be outside the collision body. Alternatively, the moving position of the fluid particles may be moved to the nearest position on the surface of the collider, resulting in an updated moving position of the fluid particles, i.e. the second position.
When the collision body is a patch mesh body, whether the first position and the movement position of the fluid particle are positioned on the two sides of the patch mesh body is detected, if so, the fluid particle is collided with the collision body, and at the moment, the movement position of the fluid particle is adjusted to be the same as the first position. Alternatively, the point where the connecting line intersects the patch mesh may be taken as the updated moving position of the fluid particle, i.e., the second position, by connecting the first position and the moving position.
In step 104, an animation of the fluid particles from the current time to the next time is determined based on the first location and the second location to obtain a fluid animation of the fluid particle population.
For each fluid particle in the fluid particle group, through the above-mentioned step 101-. According to the first position of each fluid particle at the current moment (namely the position state of the fluid particle swarm at the current moment), a frame of animation can be obtained through rendering, and the frame of animation is marked as a first animation frame; according to the second position of each fluid particle (namely the position state of the fluid particle swarm at the next moment), a frame of animation can be obtained through rendering, and the frame of animation is marked as a second animation frame; from the first frame animation and the second frame animation, the fluid animation of the fluid particle group from the current time to the next time can be obtained.
Further, after determining the first position and the first velocity at the current time and the moving position at the next time, based on the time step between the current time and the next time, the moving velocity of the fluid particles at the next time, i.e. the second velocity, can be calculated.
Note that the direction of the second speed obtained after the collision is opposite to the direction of the first speed.
After determining the animation of the fluid particles from the current moment to the next moment, namely after determining the fluid animation of the fluid particle swarm from the current moment to the next moment, adopting the second speed to update the first speed, and adopting the second position to update the first position so as to continuously obtain the fluid animation of the fluid particle swarm from the next moment to the next moment, and circulating the steps, so that animation frames at different moments can be obtained, and a plurality of animation frames are displayed according to the generated time sequence and time step, namely the fluid animation can be obtained.
Further, in an optional embodiment of the present application, after the calculating the second velocity of the fluid particle at the next time according to the second position, the first position, and the first velocity, and the time step of the next time and the current time, the method further includes:
determining a viscous force damping velocity of the fluid particles caused by viscous force;
updating a second velocity of the fluid particles according to the viscous force damping velocity.
In this embodiment, the influence of the viscous force is also considered for the calculation of the moving velocity of the fluid particles, the initial velocity calculated according to the second position, the first velocity, the time step of the next time and the current time is adjusted according to the damping velocity of the viscous force generated by the viscous force, the adjusted velocity is used as the second velocity of the fluid particles at the next time, and a calculation formula corresponding to the second velocity is as follows:
Figure BDA0003447340560000141
wherein the content of the first and second substances,
Figure BDA0003447340560000142
which is indicative of the second speed of the vehicle,
Figure BDA0003447340560000143
for viscous damping velocity, v denotes velocity, c is a constant, vijDenotes viAnd vjA difference of (v)ij=vi-vjW represents a kernel function, and may be a W _ viscisity kernel function, which is one of the commonly used kernel functions in the art.
In the process of calculating the second speed, the influence of the viscous force on the motion speed of the fluid particles is considered, so that the obtained fluid animation is more consistent with the physical behavior of the real fluid, and the reality of fluid animation simulation is improved.
The method comprises the steps of acquiring a first position and a first speed of each fluid particle in a fluid particle swarm at the current moment; determining the motion position of the fluid particle at the next moment according to the constrained projection equation of the fluid particle, the first position and the first speed; updating the motion position by collision detection to obtain a second position, and determining a second velocity of the fluid particles at a next moment based on the second position; determining an animation of the fluid particles based on the first location and the second location to arrive at a fluid animation of the population of fluid particles; the fluid particles are particlized, the motion state of the fluid particle group for forming the fluid is determined by determining the motion state of each fluid particle, the authenticity of the flow animation can be improved, and in the process of determining the motion state of the fluid particles, the motion state of the fluid particles is updated in combination with collision detection, and the interchangeability of the flow animation is realized.
It should be noted that, for simplicity of description, the method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the embodiments are not limited by the order of acts described, as some steps may occur in other orders or concurrently depending on the embodiments. Further, those skilled in the art will also appreciate that the embodiments described in the specification are presently preferred and that no particular act is required of the embodiments of the application.
Referring to fig. 2, a block diagram of a fluid animation processing apparatus according to an embodiment of the present application is shown, and the apparatus may include the following modules corresponding to the fluid animation processing method embodiment:
an initial state obtaining module 201, configured to obtain a first position and a first speed of each fluid particle in a fluid particle swarm at a current time;
a moving position determining module 202, configured to determine a moving position of the fluid particle at a next time according to the constrained projection equation of the fluid particle, the first position, and the first velocity;
a second position determining module 203, configured to update the motion position through collision detection to obtain a second position;
a fluid animation determination module 204, configured to determine, based on the first location and the second location, an animation of the fluid particles from the current time to the next time to obtain a fluid animation of the fluid particle group.
In an optional embodiment of the present application, the motion position determining module 202 includes:
a gravity parameter-based determination state module for determining a gravitational positional deviation and an acceleration of the fluid particles resulting from a gravitational parameter;
a gravity-based parameter update status module to update the first position and the first velocity according to the gravity position offset and acceleration;
and the motion position determining module is used for determining the motion position of the fluid particle at the next moment according to the constraint projection equation of the fluid particle, the updated first position and the updated first speed.
In an optional embodiment of the present application, the constraint condition of the constraint projection equation is a density constraint; the motion position determination module 202 includes:
a neighbor particle search determination module for determining a data structure of a neighbor particle search and determining neighbor particles of the fluid particles based on the data structure of the neighbor particle search;
a density constraint equation determination module for obtaining a density constraint equation of the fluid particles;
and the motion position determining module is used for solving the constraint projection equation according to the solution of the density constraint equation so as to determine the motion position of the fluid particle at the next moment.
In an optional embodiment of the present application, the apparatus further comprises:
a relaxation factor obtaining module, configured to obtain a relaxation factor, where the relaxation factor is used to constrain a projection range of the fluid particle;
and the constraint projection equation updating module is used for updating the constraint projection equation based on the relaxation factor.
In an optional embodiment of the present application, the apparatus further comprises:
the artificial repulsion acquiring module is used for acquiring the artificial repulsion corresponding to the fluid particles when the pressure of the fluid particles is negative;
and the movement position updating module is used for determining a movement position obtained according to the constraint projection equation of the fluid particles, the first position and the first speed as an initial position, shifting the position of the repulsion force generated by the artificial repulsion force on the fluid particles, and updating the initial position to obtain the movement position of the fluid particles at the next moment.
In an optional embodiment of the present application, the second position determining module 203 includes:
and the collision detection module is used for adjusting the motion position of the fluid particles to the outside of the collision body to obtain a second position when the motion position of the fluid particles is positioned in the collision body.
Optionally, the apparatus further comprises:
a second velocity determination module, configured to calculate a second velocity of the fluid particle at a next time according to the second position, the first position, and the first velocity, and a time step of the next time and the current time;
an initial state update module to update the first velocity with the second velocity and update the first position with the second position after determining the animation of the fluid particles from the current time to the next time.
In an optional embodiment of the present application, the apparatus further comprises:
the viscous force damping speed acquisition module is used for determining the viscous force damping speed of the fluid particles generated by the viscous force;
and the velocity updating module is used for updating the second velocity of the fluid particles according to the viscous force damping velocity.
For the device embodiment, since it is basically similar to the method embodiment, the description is simple, and for the relevant points, refer to the partial description of the method embodiment.
The embodiment of the application also discloses an electronic device, which comprises a processor, a memory and a computer program stored on the memory and capable of running on the processor, wherein the computer program realizes the steps of the fluid animation processing method when being executed by the processor.
The embodiment of the application also discloses a computer readable storage medium, wherein a computer program is stored on the computer readable storage medium, and when the computer program is executed by a processor, the steps of the fluid animation processing method are realized.
The embodiments in the present specification are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other.
As will be appreciated by one of skill in the art, embodiments of the present application may be provided as a method, apparatus, or computer program product. Accordingly, embodiments of the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, embodiments of the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
Embodiments of the present application are described with reference to flowchart illustrations and/or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing terminal to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing terminal to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing terminal to cause a series of operational steps to be performed on the computer or other programmable terminal to produce a computer implemented process such that the instructions which execute on the computer or other programmable terminal provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present application have been described, additional variations and modifications of these embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including the preferred embodiment and all such alterations and modifications as fall within the true scope of the embodiments of the application.
Finally, it should also be noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or terminal that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or terminal. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or terminal that comprises the element.
The foregoing describes in detail a fluid animation processing method and apparatus, an electronic device, and a storage medium, which are provided by the present application, and specific examples are applied herein to illustrate principles and embodiments of the present application, and the description of the foregoing examples is only used to help understand the method and core ideas of the present application; meanwhile, for a person skilled in the art, according to the idea of the present application, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present application.

Claims (11)

1. A fluid animation processing method, the method comprising:
acquiring a first position and a first speed of each fluid particle in the fluid particle swarm at the current moment;
determining the motion position of the fluid particle at the next moment according to the constrained projection equation of the fluid particle, the first position and the first speed;
updating the motion position through collision detection to obtain a second position;
determining an animation of the fluid particle from the current time to the next time based on the first location and the second location to arrive at a fluid animation of the population of fluid particles.
2. The method of claim 1, wherein determining the motion position of the fluid particle at the next time based on the constrained projection equation of the fluid particle and the first position, first velocity comprises:
determining a gravitational positional deviation and acceleration of the fluid particles resulting from gravitational parameters;
updating the first position and the first velocity according to the gravity position offset and the acceleration;
and determining the motion position of the fluid particle at the next moment according to the constrained projection equation of the fluid particle, the updated first position and the updated first speed.
3. The method of claim 2, wherein the constraint of the constrained projection equation is a density constraint; determining the moving position of the fluid particle at the next moment according to the constrained projection equation of the fluid particle, the updated first position and the updated first speed, comprising:
determining a data structure of a neighbor particle search and determining neighbor particles of the fluid particles based on the data structure of the neighbor particle search;
obtaining a density constraint equation of the fluid particles;
solving the constrained projection equation according to the solution of the density constrained equation to determine the motion position of the fluid particle at the next moment.
4. The method of claim 3, further comprising:
obtaining a relaxation factor, wherein the relaxation factor is used for restricting the projection range of the fluid particles;
updating the constrained projection equation based on the relaxation factor.
5. The method according to any one of claims 1-4, further comprising:
when the pressure of the fluid particles is negative, acquiring the artificial repulsion corresponding to the fluid particles;
and determining a motion position obtained according to the constraint projection equation of the fluid particles, the first position and the first speed as an initial position, shifting a repulsive force position generated by the artificial repulsive force on the fluid particles, and updating the initial position to obtain the motion position of the fluid particles at the next moment.
6. The method of claim 1, wherein said updating the motion location through collision detection to obtain a second location comprises:
when the moving position of the fluid particle is located inside the collider, the moving position of the fluid particle is adjusted to the outside of the collider to obtain a second position.
7. The method of claim 1, further comprising: calculating a second velocity of the fluid particles at a next time according to the second position, the first position and the first velocity, and a time step of the next time and the current time;
after determining the animation of the fluid particles from the current time to the next time, updating the first velocity with the second velocity and updating the first position with the second position.
8. The method of claim 7, wherein after said calculating a second velocity of the fluid particles at a next time based on the second position, the first position, and the first velocity, and a time step at the next time and the current time, the method further comprises:
determining a viscous force damping velocity of the fluid particles caused by viscous force;
updating a second velocity of the fluid particles according to the viscous force damping velocity.
9. A fluid animation processing apparatus, comprising:
the initial state acquisition module is used for acquiring a first position and a first speed of each fluid particle in the fluid particle swarm at the current moment;
the motion position determining module is used for determining the motion position of the fluid particle at the next moment according to the constrained projection equation of the fluid particle, the first position and the first speed;
the movement speed determining module is used for updating the movement position through collision detection to obtain a second position;
a fluid animation determination module for determining an animation of the fluid particles from the current time to the next time based on the first location and the second location to obtain a fluid animation of the fluid particle population.
10. An electronic device comprising a processor, a memory and a computer program stored on the memory and executable on the processor, the computer program, when executed by the processor, implementing the steps of the fluid animation processing method as claimed in any one of claims 1 to 8.
11. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the fluid animation processing method as claimed in any one of claims 1 to 8.
CN202111662958.3A 2021-12-30 2021-12-30 Fluid animation processing method and device, electronic equipment and storage medium Pending CN114299199A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111662958.3A CN114299199A (en) 2021-12-30 2021-12-30 Fluid animation processing method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111662958.3A CN114299199A (en) 2021-12-30 2021-12-30 Fluid animation processing method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN114299199A true CN114299199A (en) 2022-04-08

Family

ID=80973987

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111662958.3A Pending CN114299199A (en) 2021-12-30 2021-12-30 Fluid animation processing method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114299199A (en)

Similar Documents

Publication Publication Date Title
US10198847B2 (en) Physically based simulation methods for modeling and animating two-and three-dimensional deformable objects
US9440148B2 (en) Physics simulation apparatus and method
CN112915542B (en) Collision data processing method and device, computer equipment and storage medium
US8988435B1 (en) Deforming a skin representation using muscle geometries
Yeh et al. Fool me twice: Exploring and exploiting error tolerance in physics-based animation
US20080177763A1 (en) Apparatus and method of data organisation
CN104854622A (en) Method for forming an optimized polygon based shell mesh
O'Brien et al. Automatic simplification of particle system dynamics
EP3179390A1 (en) Method and apparatus for modeling movement of air bubble based on fluid particles
CN114299199A (en) Fluid animation processing method and device, electronic equipment and storage medium
Lozano et al. A distributed framework for scalable large-scale crowd simulation
US20180189996A1 (en) Animating a virtual object
Toledo et al. Fuzzy and data-driven urban crowds
Dharma et al. Interactive fluid simulation based on material point method for mobile devices
Kaufmann et al. Accurate Real-time Physics Simulation for Large Worlds.
Ifrim et al. REPLICATING IMPULSE-BASED PHYSICS ENGINE USING CLASSIC NEURAL NETWORKS.
KR101526050B1 (en) Crowd simulation reproducing apparatus and the method
KR101538141B1 (en) Apparatus and method for simulating fluid processing correction of density of gas
KR101566484B1 (en) Apparatus and method for simulating fluid using weight between node and particle
CN112843669B (en) Method and system for simulating physical gyro movement
Zhu et al. Cloth simulation based on neural network regression
Yahya Collision Resolution for Cloth Simulations Using Machine Learning
Goynov et al. 3D Transformation of 2D Captured Museum Objects at Risk
Toledo Díaz et al. Level of detail for complex urban scenes with varied animated crowds, using XML
Wang et al. XProtoSphere: an eXtended multi-sized sphere packing algorithm driven by particle size distribution

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination