Game Development Reference
In-Depth Information
Exploring 3D animation further
Congratulations! You're now able to render fully animated 3D models! While this
is a pretty cool achievement, the functionality we've seen so far has only scratched
the surface of what the IwAnim API allows us to do. The following sections describe
some of the other features that we have at our disposal.
Playing an animation backwards
There are some occasions when it is useful to be able to play an animation
backwards. As an example, imagine a character kneeling down to examine an object.
Rather than create a whole new animation to enable them to stand up again, we
could just play the kneeling animation backwards instead.
Playing an animation backwards is achieved simply by passing a negative animation
speed into the call to PlayAnim , so a value of -1 will play the animation backwards
at normal speed.
Blending between animations
When transitioning between two animations, we often don't want to just snap
straight to the beginning of the new sequence, as this can result in a noticeable jump
between the current frame of animation and the first frame of the new animation.
We can solve this problem by blending between animations.
We touched on how to achieve this earlier, when we first introduced the PlayAnim
method. The final parameter in this method is the blending time, which is specified
as a value in seconds using a floating point number.
By specifying a non-zero blending interval, the animation player will calculate the
frames of animation required for both the old and new animations, then generate a
third transition frame by interpolating between these two frames over the specified
time. The transition frame is what is then used to draw the 3D model. Once the
blend interval is over, the original animation will stop being calculated as it is no
longer required.
Detecting animation playback events
Being able to detect when an animation has looped or has finished playing is
important because we can start to link animations together or prevent the user from
performing a task until an animation has completed. For instance, imagine a player
has to reload a weapon and an animation is played to show this happening. We
need to know when the animation has completed so we can allow the player to start
attacking again.
 
Search WWH ::




Custom Search