Something like what you see in the video you contacted can be done using the mass-w760 system. However, since you are changing the number of masses and springs, keeping the spring constants the same, you will get wildly changing results. In short, spring mass systems are not good approximations of the continuum of matter.
Typically, these types of animations are created using the finite element method (FEM). FEM converges to a continuum, which is nice. And although it requires a little more know-how than a mass spring system, it really is not so bad. The basic idea obtained from the study of continuum mechanics can be posed as follows:
Break the volume of your object into many small parts (elements), usually tetrahedra . Let me call the whole set of these elements a grid. You really want to make two copies of this grid. Call one a "net of rest" and the other a "world" grid. I will tell you why the following.
For each tetrahedron in your world grid, measure how much it is deformed relative to its corresponding remaining tetrahedron. A measure of how it deforms is called a "deformation." This is usually done using the first measurement of the so-called deformation gradient (often denoted by F ). There are some good papers that describe how to do this. When you have F , one very typical way of defining strain (e) is: e = 1/2 ( F ^ T * F ) - I. This is called a Green strain. It is invariant to rotations, which makes it very convenient.
Using the properties of the material you are trying to simulate (gelatin, rubber, steel, etc.), and using the voltage that you measured in the step above, output the " stress " of each tetrader.
For each tetrahedron, visit each node (vertex, angle, point (they all mean the same thing)) and average the area-weighted normal vectors (in the rest of the form) of three triangular faces, share this node. Multiply the voltage of the tetrahedron by this averaged vector, and there is the elastic force acting on this node due to the voltage of this tetrahedron. Of course, each node can potentially belong to several tetrahedra, so you will need to summarize these forces.
Integration ! There are simple ways to do this and difficult ways. In any case, you will need to iterate over all the nodes in your world grid and divide your forces by mass to determine its acceleration. A simple way to come from here:
- Multiply its acceleration by some small dt. This gives you a change in speed, dv.
- Add dv to current node speed to get a new full speed.
- Multiply this speed by dt to get the change in position, dx.
- Add dx to the current node position to get a new position.
This approach is known as Euler explicit forward integration . You will need to use very small dt values ββto make it work without exploding, but it is so easy to implement that it works well as a starting point.
Repeat steps 2 through 5 until you want.
I forgot a lot of details and fancy additions, but I hope you can conclude that I forgot. Here is a link to some of the instructions that I used the first time I did this. The web page contains useful pseudo-code, as well as links to some relevant materials.
http://sealab.cs.utah.edu/Courses/CS6967-F08/Project-2/
The following link is also very useful:
http://sealab.cs.utah.edu/Courses/CS6967-F08/FE-notes.pdf
This is a very interesting topic, and I wish you good luck! If you're stuck, just drop me a line.
source share