Home

This website details a project for CSCE 450, Animation for the Fall 2023 Semester at Texas A&M University

Steps

  • Convert a 3D mesh from the "skin" to a volumetric, tetrahedral mesh
  • Modify the XPBD Algorithm to account for edge and volume constraints
  • Organize the new mesh data and draw it to the screen each frame
  • If time permits, add collision detection and more detailed scenes and mesh optimizations

Further details can be found in Details regarding the steps at large. Below you can find a video quickly going over the project.

Details

This sections contains most of the details about the project.

Overview

The project as a whole was completed in C++ using the OpenGL library as the framework for the graphics code. I also made use of the Eigen library to store matrix info, vectors, and most of the vector math in the algorithm. The basic framework for the project came from a simple position based dynamics cloth simulator that made use of springs as "edge" constraints to hold together a system of particles.

TetGen

TetGen is a open source software that allows its users to conver STL and other mesh files into tetrahedralized meshes. The way it does this is by splitting down into 4 separate files (really 3, the 4th is toggleable, but important for my use case). I split basic poly files into: node, edge, ele, and face files. Each file's first line contains the number of lines, each line starts with an index, and everything revolves around the node file. The node file contains vertex data, but more importantly, it fills in points within the mesh models. The file will directly be translated into particle data in the simulator. The edge and ele files contain the 2 main constraints used in this project, egdes (of course) and tetrahedrons. The file format is the same, but instead of position data, it is arranged like an element buffer and just has number of indicies from the node file for however many particles are in the system (2 and 4). Like the nodes, the tetrahedral mesh contains internal edges and tetrahedrons. The face file is structed the same way, but contains data for surface triangles of the mesh arranged in counter clockwise orientation. This will be important in the next section.

OpenGL

OpenGL is used in the project as the primary graphics rendering tool. It is used to control the window, but more importantly I use dynamic buffers that update as the objects move around in the scene to store and display position data of the meshes. It uses the faces file organize the buffer then I simply draw GL_TRIANGLES.

Extended Postion Based Dynamics (XPBD)

My main point of guidance through the project was the excellent papers and videos by Matthias Müller His projects in his 10 minute physics series, "XPBD" and "Simple and Unbreakable Simulation of Soft Bodies" were the original inspirations to persue this project in the first place.
The basic algorith for the XPBD method is broken into a few steps. While simulating, you take the change in time between update frames. For each particle update the previous particle position, update velecity by the current force of gravity exerted on it, then update the current position based on that velocity. The next step is the constraint step. In this step, iterate over every constraint, in this case it is every edge and tetrahedron. Caculate the lagrange multiplier based on the constraint formula over the sum of the inverse masses and gradients of each constraint acting on a particle x. Then update the particle's posision by a factor of the system mass, lagrange multiplier, and constraint gradients. The next step is to detect collisions and adjust those accordingly. Lastly update the velocities of the particles based on the change in the position since the first step over the time step. (Matthias Müller's paper for reference)

Demo

Compliance

The following series of videos deomonstrate the change in compliance and the effect on the mesh. The more compliant (opposite of stiff) of the 2 demos show the shape collapsing and springing back up as volume constraints kick in. The other video shows a stiffer model that comes to a rest on the plane.

Squash and Stretch

The next 2 videos here show a sphere shape being squeezed in an invisible box and being pulled apart by 2 pins. The important thing to note is that when the sphere is squashed and stretched out, the volume remains consistent in the shape as a whole, even if this part is a little glitchy and the sphere gains some angular momentum when being pushed to the limits. The bug has to do with the layout of the tetrahedrons and the stiffness of the spheres used in this simulation. As soon as the sphere spins a little bit, the effect continues and it speeds up without stop. Given more time on the project it it first on my list of fixes to the simulator along with greater customization of factors and control values in the simulator.

Citations