Final Project: Real Time FEM Simulation of Elasto Plastic Simulation
Web Report
1 Background of real time FEM
Computer games or simulators, demand a continuously growing degree of visual realism and technical sophistication. Many computer games have some destruction with deformation effects which is playing some pre-defined animations without using physically based calculation. However, we are seeking for more precise ways to compute the deformation and cracking. The state of art techniques are Linear FEM, Warped Stiffness FEM and Remesh Method. In this project we implement real time FEM using Linear FEM with pre-defined cracking method. The main challenges in the project are guarantee for accuracy (Physically Valid), real time simulation frame rate and stability.
2 Approaches and Techniques
Computer games or simulators, demand a continuously growing degree of visual realism and technical sophistication. Many computer games have some destruction with deformation effects which is playing some pre-defined animations without using physically based calculation. However, we are seeking for more precise ways to compute the deformation and cracking. The state of art techniques are Linear FEM, Warped Stiffness FEM and Remesh Method. In this project we implement real time FEM using Linear FEM with pre-defined cracking method. The main challenges in the project are guarantee for accuracy (Physically Valid), real time simulation frame rate and stability.
2 Approaches and Techniques
2.1Create a Tetrahedral Mesh
The method is simple, we first create a cube grid with cubes cell inside, and nodes are the vertices of cubes, note that some cube cells shares one node. The cubes can be divided into 5 tetrahedrons with 4 nodes on the vertices of cubes.
The method is simple, we first create a cube grid with cubes cell inside, and nodes are the vertices of cubes, note that some cube cells shares one node. The cubes can be divided into 5 tetrahedrons with 4 nodes on the vertices of cubes.
The element stiffness matrix setting is tricky, we should use the we can first get a matrix which is12X12 where M[i][i]=1, and M[i][3+i], M[i][9+i] is between 0 to which means we move one point and The adjacent point move following it, which is d=Mf, if we want to know the f we should use f=Kd where K is inverse of M, and also the element stiffness matrix. For example we can set the M like this: .
It means the movement of one specific point is a ratio of other 3 other points.And then we can set the K as the inverse of M. Get the Stiffness Matrix for the mesh using element stiffness matrix(Some vertices are shared by multiple tetrahedrons)(Assembling Method)
The simulation loop is updating the positions of each node and also updating the forces on each node, mainly based on the following formula:
Mx¨ + Cx˙ +K(x − x0) = fext (1)
f= Kd (2)
Actually, it is pretty simple, first we calculate force then we get the force by (2), then Update the displacement of each vertex by(1) , Then we make it as a loop.
2.2Triangle Mesh Deformation( Creavity)
Now we have the tetrahedron mesh deformation, but we haven’t got the triangle mesh deformation. We should firstly let the tetrahedron mesh totally cover the triangle mesh, and then we map the triangle into the nearest vertex in the tetrahedron mesh. If there is displacement on the vertex, we simply apply:
The simulation loop is updating the positions of each node and also updating the forces on each node, mainly based on the following formula:
Mx¨ + Cx˙ +K(x − x0) = fext (1)
f= Kd (2)
Actually, it is pretty simple, first we calculate force then we get the force by (2), then Update the displacement of each vertex by(1) , Then we make it as a loop.
2.2Triangle Mesh Deformation( Creavity)
Now we have the tetrahedron mesh deformation, but we haven’t got the triangle mesh deformation. We should firstly let the tetrahedron mesh totally cover the triangle mesh, and then we map the triangle into the nearest vertex in the tetrahedron mesh. If there is displacement on the vertex, we simply apply:
Where the displacement
is the triangle displacement and d is the distance between triangle vertex to
nearest node. and min(d), u is displacement of node, min(d) is minimum distance
of node to all vertices.
When the triangle vertex number is equal o the node number it is the same thing, we have no difference between triangle vertex and node displacement, since min(d)/d is 1. If not, there is a damping which is min(d)/d.
2.3 Fragile Effect
We firstly predefine some points which are more easily to tear apart, then at each simulation step, we check the displacement of the points, if one exceeds threshold, we should make all crack points tore apart. Advantage is it’s easy to implement and disadvantage is it’s hard to mark the predefine crack points.
3 What have actually been accomplished
3.1 Written by myself:
Render Engine:
Just reuse the code when I complete the previous HWs of COMP 768
Physics Simulation Module:
All written by myself, partially because all libs don’t support C# . And I have to implement all features including high rank matrix multiplication, inverse of matrix, and other trivial stuffs.
Collision Detection:
Written by myself. Reuse some code from previous HWs. Bullet EngineDoes not working very well because it is a little complex and a little bit harder to integrate.
Borrowed:
SlimDX: API for DirectX11 in C#
3.2 Architecture
When the triangle vertex number is equal o the node number it is the same thing, we have no difference between triangle vertex and node displacement, since min(d)/d is 1. If not, there is a damping which is min(d)/d.
2.3 Fragile Effect
We firstly predefine some points which are more easily to tear apart, then at each simulation step, we check the displacement of the points, if one exceeds threshold, we should make all crack points tore apart. Advantage is it’s easy to implement and disadvantage is it’s hard to mark the predefine crack points.
3 What have actually been accomplished
3.1 Written by myself:
Render Engine:
Just reuse the code when I complete the previous HWs of COMP 768
Physics Simulation Module:
All written by myself, partially because all libs don’t support C# . And I have to implement all features including high rank matrix multiplication, inverse of matrix, and other trivial stuffs.
Collision Detection:
Written by myself. Reuse some code from previous HWs. Bullet EngineDoes not working very well because it is a little complex and a little bit harder to integrate.
Borrowed:
SlimDX: API for DirectX11 in C#
3.2 Architecture
3.3 Demos
After all is done, in the demo we will see that we actually build a whole physics engine, including collision between soft-body to rigid body and rigid body to rigid body. After Implementing all the features of FEM, I also have done some demos to show the correctness and efficiency for my method: Two Demos: Stretch Bunny , Pull the tail of the bunny to stretch down and see what happens. Balls Hitting Deformable Body Show the interaction with rigid body and fragile effect. In the first demo, the bunny is stretched down, all adjacent parts in around the tail are moving following the tail, but it does not exceed the movement of tail. The head of bunny moves down with the greatest “latency” which means the tetrahedrons movement are damping to the head. In the second demo, the soft body is hit by several balls, I predefined the upside of the deformable body having a line of crack points. So it is obvious that if they are colliding, there exists a big crack. It is visual convincing and shows a nice deformation intuitively.
3.4 Efficiency
Ø In the whole simulation procedural, the mesh has been preprocessed, and once it has been processed, it has no updating. So the main part which affects the simulation is calculating the forces and displacement.
Ø In our method, the displacement and forced computing is done in linear time complexity. See the previous slides…
In our demos, our laptop is using Nvidia GF170M with 2 GB memory and Pentium 4 processor. The triangle consists of 1K vertices. In our demos, it can reach 62 FPS.
4 Summary of the course project contribution(s)
Ø Implement real time FEM with fragile effect.
Ø Triangle Mesh displacement Computing Method is novel and easy to implement.
Ø Integrate FEM with rigid body dynamics which makes the system like a physics engine.
Ø Write all stuff from scratch, without using any physics tools or libs. Just leverage DirectX11. Best way to avoid some illegal infringement.
5 Possible future work
Release or modify some parts of Bullet Engine, because it is open source engine, but Softbody module solves it using spring mass model. Adding FEM will add more fantastic effect
Using CUDA to accelerate calculation
Here is the demo video and source code. Feel Free to download it!!
NOTE: if you want to run the code, don't forget to add reference SlimDX.dll and FarseerPhysics.dll in bin/debug/, and download a SlimDX package: http://slimdx.org/download.php and choose End User Runtime package.
After all is done, in the demo we will see that we actually build a whole physics engine, including collision between soft-body to rigid body and rigid body to rigid body. After Implementing all the features of FEM, I also have done some demos to show the correctness and efficiency for my method: Two Demos: Stretch Bunny , Pull the tail of the bunny to stretch down and see what happens. Balls Hitting Deformable Body Show the interaction with rigid body and fragile effect. In the first demo, the bunny is stretched down, all adjacent parts in around the tail are moving following the tail, but it does not exceed the movement of tail. The head of bunny moves down with the greatest “latency” which means the tetrahedrons movement are damping to the head. In the second demo, the soft body is hit by several balls, I predefined the upside of the deformable body having a line of crack points. So it is obvious that if they are colliding, there exists a big crack. It is visual convincing and shows a nice deformation intuitively.
3.4 Efficiency
Ø In the whole simulation procedural, the mesh has been preprocessed, and once it has been processed, it has no updating. So the main part which affects the simulation is calculating the forces and displacement.
Ø In our method, the displacement and forced computing is done in linear time complexity. See the previous slides…
In our demos, our laptop is using Nvidia GF170M with 2 GB memory and Pentium 4 processor. The triangle consists of 1K vertices. In our demos, it can reach 62 FPS.
4 Summary of the course project contribution(s)
Ø Implement real time FEM with fragile effect.
Ø Triangle Mesh displacement Computing Method is novel and easy to implement.
Ø Integrate FEM with rigid body dynamics which makes the system like a physics engine.
Ø Write all stuff from scratch, without using any physics tools or libs. Just leverage DirectX11. Best way to avoid some illegal infringement.
5 Possible future work
Release or modify some parts of Bullet Engine, because it is open source engine, but Softbody module solves it using spring mass model. Adding FEM will add more fantastic effect
Using CUDA to accelerate calculation
Here is the demo video and source code. Feel Free to download it!!
NOTE: if you want to run the code, don't forget to add reference SlimDX.dll and FarseerPhysics.dll in bin/debug/, and download a SlimDX package: http://slimdx.org/download.php and choose End User Runtime package.
real_time_fem_simulator.zip | |
File Size: | 1546 kb |
File Type: | zip |
Demo Video