BoidTank
David Mayerich
mayerich@quantumkingdom.com
This simulation is a small, fluid-filled tank inhabited by flocking trapezoids. The surface is an example of a springy mesh structure. Forces acting on these particles end up propagating through the system and affecting other particles. The physics of the system is accomplished by linking particles together with a spring-damper, or dashpot constraint. Each link in the springy mesh consists of two components. The first is a spring whose state of rest is the original length of the link. When a force is applied on either of the particles, the spring exerts a force on both particles in the link. When a single impulse is applied to one of the particles, this will cause the spring to oscillate. Since these springs are computed mathematically, they are perfect springs. This means that the springs will oscillate indefinitely. In order to compensate for this, a damper system is also placed in each of the links. This damper applies a force in the opposite direction of the force produced by the spring. This force is proportional to the velocity at which the spring is expanding or contracting. These dampers effectively add resistance to the spring, keeping the simulation stable.
This springy mesh structure allows particles to be linked into meshes in a physical simulation. Solid objects can be created or, as in this example, fluid surfaces can be simulated. In this simulation, a surface is created using the particle system described above. Gravity is applied from above and minor random changes in pressure are applied from below, causing the fluid to churn. A fountain can also be activated within the tank. The fountain consists of a particle engine. The particles are released from the turbine and given a certain lifespan. In order to make the fountain look realistic, a vortex effect is applied by rotating each particle's velocity around a central axis.
The figures in the tank are examples of a simple flocking algorithm. They respond to the boundaries of the tank as well as to the turbine and the surface. They tend to keep away from the glass walls of the tank unless they are scared away by activating the fountain. Whenever a boid is near the surface, there is a probability that it will jump out of the tank.
Controls-
Holding down the left mouse button while moving the mouse will cause the camera to rotate around the tank.
Holding down the middle mouse button while moving the mouse will cause the camera to zoom in and zoom out.
Holding down the right mouse button, or pressing the spacebar will activate the fountain in the center of the tank.
The graphics where done using OpenGL with the GLUT library for the interface. I’ve included the DLLs but the binary libraries used to compile the code are available at www.opengl.org.