loop.c, loop.h, object.c, print.c
This is an extension of project 2: Loop's subdivision. I've added color-cycling and animation. I also patched a couple of bugs along the way.
Using the modified object viewer
Most of this program is described in the Project 2 README; however, some of the interface is different. I've added 3 commands:
[M] toggle |
Turn the animation on or off.
In each pass through the animation loop:
- The diffuse color value for the light is shifted slightly for a rainbow effect.
- The model is spun slightly for a rotating effect.
- Each vertex is mapped to a new position as follows: Before the animation begins (ie. when you turn it on), the average distance from the origin is computed from all the points in the model. For each pass through the animation loop, the position of each vertex is scaled:
v' = v0 + (|v0| - r) * cos(theta)
where v0 is the position of the vertex before the animation began, r is the average distance from the origin of all v0's, and theta is a value that is incremented by pi / 16 for each pass through the loop. The result is a wobbly shape that oscillates across an invisible sphere of radius r.
|
[+] faster |
Speed up the animation. |
[+] slower |
Slow down the animation. |
One interesting thing about the animation is that is functions as a measure of how badly Loop's subdivision of ball.obj fails to approximate a sphere. After each subdivision, the shape just gets wobblier.
|
|
Want to drop me a note? Do so: 
|
|
|