Hierarchical animation using trigonometric functions:




This program was written in C++ for my Computer Graphics MSc assignment. It is a simulation where a varying number of robots made by transformed cubes walk in different directions without collisions. The robot parts are parts of a transformation hierarchy. Trigonometric functions are used for the animation.

Youtube Demo:






Robot Construction - Hierarchy

The robot parts are part of a hierarchy tree:
  • Each robot part is a cube scaled and transformed to have the desired size and position.
  • It is then rotated around a point (pivot), whose position is calculated relatively to its parent pivot point position.



The hierarchy tree.





Robot Animation

The robot is animated using trigonometric functions. Their output is restricted to match the rotation angles of the human joints.

The total transformation of each part consists of its transformation parameters concatenated with its parent transformation. In essence, while rendering the robot we traverse the hierarchy multiplying transformations as we go down the tree.




Number of animated robots

The program was extended to support an arbitrary number of animated robots. The robots are walking in circles with different radii and offsets. Hence, there are no collisions between them and they look like running in random points around the circuimference. The scene (a children room) is resized automatically to account for the number of robots running around in order to avoid collisions with the walls as you can see in figures 4 and 5.



Code

The code can be downloaded from here
It runs on Linux, BSD, MacOSX.
  • Extract and cd the directory
  • Type $ make
  • To run it on Linux/BSD type ./bob <number_of_robots> on Mac OS X it's just: bob <number_of_robots>




Screenshots from early development stages