Underwater Animation - CMPS 161
Alexander Chin
Summary:
This project is intended to simulate an animated undewrater environment.
Specifically, the environment contains numerous "fish" that follow particular
patterns of behavioral animation. The scene also contains surge to influence
the movement of the fish. The basic behaviors present here are point seeking
and avoidance.
Algorithms
Fish decisionmaking is accomplished here by producing an ideal direction and
speed for the desired movement, then attempting to reach these within the
physical contraints placed on the fish. A fish attempts to reach the ideal
vector by rotating itself along two of its axes in order to alter its heading.
However, it cannot turn
faster than a certain rate, and it is designed to avoid twists (rotations along
the z-axis), avoid vertical flips, and take the shorter set of rotations needed
to reach its goal.
The movement of the fish always involves turning along these and attempting
to move forward in relation to its current heading, rather than performing
transformations on the fish directly, in order to give it a more realistic
behavior system and "thought" processes.
The fish also has constraints on acceleration and maximum
possible speed.
The above was used to adapt simple point seeking and limited avoidance of
neighboring fish. Neighbor avoidance is accomplished by examining the
nearest neighbor within the fish's line of sight, defined by the area of a cone
extending from the fish. If a fish is near enough to another fish in its line
of sight, it attempts to avoid a collision by reducing its speed (based on the
proximity to the potential collision) and redirects itself in a consistent
direction around the other fish. (Fish formerly sought the farthest possible
vector from the collision, but this was replaced as it caused fish facing each
other to seek the same area and thus collide.)
Interface
After several failed attempts at successfully creating user interfaces and
video outputs, the program was re-designed to behave more or less without
user input, varying instead based on certain random numbers generated in the
execution of the program.
The project was developed and tested on a UNIX platform, but could conceivably
be run on others.
Relevant files:
Sources:
Images: