artificial life

Chapter 3: Cellular Automata

3.8 OpenGL Boids

An example of the flocking boids is implemented in OpenGL for the purposes of this project. This program is available for the PC. The program creates a flock of 30 boids that fly around in a circle, avoiding four spheres along the way. Figure 3.10 depicts a birds-eye view of the flock avoiding one of the spheres. It is possible to see that the flock separates to avoid the sphere and then flies back together after moving past the sphere to maintain a tight formation.


Figure 3.10 : A Flock Avoiding an Obstacle

Figure 3.10 : A Flock Avoiding an Obstacle




Win32 Executable for OpenGL Boids (requires OpenGL and GLUT):

Boids.zip


Source Code for OpenGL Boids Application:

Flock.h

Flock.cpp

main.cpp



To navigate through the environment the user may drag the mouse to rotate around the center of the flock. Pressing the ‘z’ key zooms away from the flock, while ‘Z’ zooms in on the flock. The ‘p’ key pauses and unpauses the motion of the flock.