Following this 1997 Siggraph course and 1999 paper, I implemented realistic physics simulation over two weeks in C++ and OpenGL utilizing the Finite Element Method.
![](/assets/images/graphicsCaptures/fem/cone.gif)
![](/assets/images/graphicsCaptures/fem/sphere.gif)
![](/assets/images/graphicsCaptures/fem/ellipsoid.gif)
The simulation takes in an input tetrahedral mesh from an obj file, and performs calculations for forces such as gravity, stress, strain, and internal viscous damping.
![](/assets/images/graphicsCaptures/fem/meshroom%20x%20sphere.gif)
![](/assets/images/graphicsCaptures/fem/sphereSphere.gif)
The program uses the RK4-5 iterative method to simulate each timestep and runs in realtime. Collisions are discrete and involves pushing the tetrahedron away from the other object along the collision’s normal vector.
![](/assets/images/graphicsCaptures/fem/spherecubeHitEdge.gif)
![](/assets/images/graphicsCaptures/fem/spherecubeHitFace.gif)
![](/assets/images/graphicsCaptures/fem/spherecubeHitVertex.gif)
When objects are not being deformed, we don’t need to simulate them too precisely. I implemented adaptive stepsizing to adjust my timestep to ensure that the simulation uses the largest possible timestep while staying under an error threshold.
![](/assets/images/graphicsCaptures/fem/sphereSphere.gif)
![](/assets/images/graphicsCaptures/fem/adaptiveStepping.gif)