Wednesday, May 18, 2011

Multiple animations

Multiple animations are now supported.  Previously, only the animation stored in the model file was playable, so the character had no idle animation (or pose).  Because there was no pose for being "idle", I jury rigged the animation code to zero the bone position/orientation if the player didn't want the character moving.  This resulted in the character springing back to its "arms-wide and legs straight" modeling "pose", which looked really awkward as you moved around the room.

Each animation is stored in its own model file, so I created another array of models but called them "animations" instead.  I also added an animation ID to each instance.  Changing the current animation is as simple as changing the animation ID and resetting the animation time to zero.

Now that I have animations more defined, I created separate "skinned" and "not skinned" vertex shaders.  I'm not really looking for a speed increase with this change, just trying to separate things more so that I can understand them easier.

I also started researching lighting.  Lighting is somewhat confusing, but one interesting thing I learned was the definition of diffuse and specular colors.  Diffuse color is from light which has been partially absorbed by the material, bounced around a bit, and finally shot back out.  Specular color is from light which has bounced right off the material.  I'm a bit confused as to why each material can have its own specular color, since it should be the color of the light which bounced off, but I'm sure I'll figure that out eventually.

No comments:

Post a Comment