Twisting Toy Animation with Motion Blur

James Herbold
W1113322
jherbold@ucsc.edu

The goal of this project was to create, as realistically as possible, an animation of a toy twisting around in space. The toy is comprised of several cylindrical rubber pieces, all arranged in a circle around the center, and is held up by a supporting vertical segment. This video contains footage of the toy in motion.



To begin working on my program, I first made a model of the toy, without any deformations on it. The model is a series of cylinders, rotated around the center, translated in three layers. The red and yellow layers are horizontal, while the blue layer is rotated vertically. I also added the red “string” cylinder to the top. This was the result:



The next step was to divide each cylinder into segments, and then translate and rotate each segment depending on the current velocity. By breaking up the cylinders into smaller pieces, each piece could be manipulated separately.



This still wasn’t quite enough. In order to make the segments appear connected, I increased the length of each segment so that they would overlap. This eliminated the spaces between each piece of the cylinder.



I then increased the number of segments of the cylinder so that you could no longer tell that they were separate pieces. The problem is, with more segments comes a lower framerate, so I had to find a balance between realism and smoothness.



Finally, I added a motion blur effect and started the animation.



Here is a video of the final result. Velocity is determined using the sin() function. Rotations and translations are determined based on a) how many segments of the cylinder there are, b) the length of the cylinder, and c) how many cylinders are around the circle. A motion blur effect was added with the glAccum() function: the accumulation buffer. The larger the velocity, the higher the blur value.



Essentially, the program functions by taking a basic cylinder object and drawing it hundreds of times, with varying coloration and orientation. Each cylinder's surface normals are calculated for lighting purposes. glRotate() and glTranslate() are used in nested loops to determine the location of each cylinder.

One largely important task of this program was to find a way to keep the framerate up while not sacrificing realism. To this end I created a way for users to adjust different aspects of the model. The user can increase or decrease the number of cylinders around the circle, increase or decrease the number of segments in each cylinder, and toggle motion blur and lighting.

The biggest impact on performance came from the number of segments in each cylinder. By increasing the number of segments by 1, you are in actuality increasing the number of cylinders rendered by a substatial amount. (One for each string around the circle.) Motion Blur and Lighting calculations cost some computing time- and disabling these can also improve framerate.

In the end, this program functions as a decent benchmark for a computer- by determining the highest settings your computer can render the animation in with full framerate (60), you can compare your computer's graphics abilities to others.

USER GUIDE

Controls:

1 : Set mode to change number of segments.
2 : Set mode to change length of each segment.
3 : Set mode to change number of cylinders around circle.
4 : Set mode to adjust starting angle of cylinders.

+/- : Increase or decrease the variable of the current mode.

w/s : Zoom in and out.
i/k : Rotate camera vertically around model.
j/l: Rotate camera horizontally around model.

b : Turn motion blur on/off.
o : Toggle segment overlap mode.
space : Turn lighting on/off.

p : Pause the animation.
r : Reset the velocity of the animation.

Source code

Unix Executable

Windows Executable