Author, Designer and Project Maintainer: Stephen Manley - firstname.lastname@example.org
Like to see more of this software? Send me an email or check out my other cool projects.
This program was attempted as a class term project for a 3D computer graphics course that I was taking. It beat doing the endless maze assignments and lighting stuff :). I'm interested in ways to model irregular objects and fluid motion, and this is one of the classic approaches to solving these problems with realistic effects that are possible in a realtime environment. I didn't find any software resources available on the web, so this might help someone, too.
The theory is quite simple - take a collection of particles, or nodes, and connect them with springs, or a damped spring system. Applying a force varys the compression in the spring. By changing the spring contants in the system, different density effects can be realized.
Objects have a natural surface tension and a higher rigidity, or resistance to applied force. Fluids have minimal internal cohesion. Right now I haven't mastered the latter case, but if you build on this model please contact me.
Features of note:
Discussion of Objects Used
The system is comprised of a number of C++ classes which can scale to N nodes and springs to simulate very high resolution or very low resolution systems. Many different behaviours can be studied by varing the parameters for the springs and node motion.
This class contains the mesh of nodes that comprise the boundaries of the volume represented. Forces are applied to this object, and it is also lit and textured based on the parameters of the program. Applying a force will result in the deformation of the mesh and a new stability point reached based on the new equilribrium.
All that is required is the ability to generate a pointset mesh of the model you which to render as a soft body. It can then be deformed, loaded or saved in the program.
This is the base particle in the system. The object is comprised of many instances of this class connected together with springs. Scaling the number of nodes will allow to scale the resolution of your model (and also drop the speed!)
This is a very simple model that works well for most effects. A force is applied to a node, and then a single node is moved (you're welcome to calculate this position any way you like, for example, an equation for position based on velocity). Once a node has been moved and a force applied (For instance, the magnitude of the vector between the new and old node position), the force will propagate through the mesh being attenuated by a small factor as the distance from the original node increases.
This is simple, and it works very well. One idea not explored is to change the propagation model from a linear attenuation to a exponential decay to see how this would change the effect; A wide varity of possible behaviours can be changed. In addition, given the object oriented nature of the program, the force propagation model can be changed at any node!
Springs connect nodes. They compress based on applied force, with minimum and maximum lengths, and provide a certain degree of force attenutation. Changing the behaviour of the spring will have vast effects on the overall model behaviour to an applied force. In addition, models can possibly be comprised of any number of different spring models, resulting in many other nifty effects (for example, mixing rigid and flexible springs; Implementing breaking points in springs, etc etc).
Currently, the spring class is largly there for visualization purposes only, and all of the work gets done in the node class. This would be very easy to adjust and/or modify though. Makes keeping track of vectors easier for my noggin.
Allows for multiple viewports to be defined quickly. Handles projections, rotations, etc. If you expand on this class please let me know because I use it all the time! Turns a miserable job (setting up scenes) into something that's a little more fun. This makes use of actual camera motion - relying on gluLookAt() and not the more common stationary camera model. I deem this to be superior as it makes animation of objects in the scene much easier.
Run the program. Note that more extensive documentation can be found in the source code, but that's what you were interested in anyhow, right? From within the program you can rotate around the object, change spring constants, pull up some interesting effects, etc.
Summary of keys:
The following links were of use, and will probably be if you are interested in this topic:
Download and Liscencing
This program is released under the terms of the GNU Public Liscence. Do what you will with it. If you are interested in it closed-source, email me and we can work something out. Please contact me if you are / are interested in working on this project further.
Source Code and Makefiles