Post date: Feb 28, 2010 11:10:52 AM
This was half of my proposed project for the Graphical User Interfaces class in 2005 (the other half was the 3D + time function plotter with elastic surface simulation). Originally, students had to create a handmade OpenGL-based wireframe animation. In other words, mostly a party of trying values for lots of glTranslate, glRotate and glScale. However, I was more intersted in learning how 3D scenes and animations were encoded in real professional environments and formats, which was out of the scope of this class. I decided then, to look for information about the 3DS file format (incomplete and quite inaccurate, mostly coming from reverse engineering back then) do some extra research on the format myself and create a class able to load, render and animate them.
Probably there are now better solutions to this than my class hierarchy, but they allowed me to learn lots of interesting things. For example, I had to learn about keyframe animation and interpolation, which led me (at least! I was expecting that) to the use of quaternions. I also learned about other interesting spline curves like the TCB Splines used to track the camera position while avoiding noticeable and unwanted velocity changes during its movement along the curve. This linear interpolation and other spline curves were used to interpolate not only position and scaling (rotation uses quaternion hyperspherical linear interpolation to avoid the gimbal lock) but also ambient colors, materials and almost any other non-constant scalar values.
Learning about keyframe interpolation also led me to look for alternative methods for animation like inverse kinematics, but this is something I still have to test. An interesting approach based on the Jacobian transpose instead of the pseudoinverse can be found in the chapter The Jacobian Transpose Method for Inverse Kinematics of the Game Programming Gems 4 book. By the way, if looking to that book check the A Generic Tree Container in C++ chapter for a very clever STL-based tree implementation.