Game Development Reference
In-Depth Information
The lTimeStep parameter is a float value indicating the amount of time (in
seconds) by which the current animation state should be advanced. When this
call completes, a copy of the skeleton will have been created with all the bones
positioned and rotated correctly in order to render the current frame of animation.
Rendering a 3D animation
With the animation player now merrily updating away, the final step is to render
the animated model. This is possibly the easiest part of the entire process, as the
following code demonstrates:
IwGxSetViewMatrix(&lViewMatrix);
IwGxSetModelMatrix(&lModelMatrix);
IwAnimSetSkelContext(lpAnim->GetSkel());
IwAnimSetSkinContext(lpSkin);
lpFlag->Render();
IwAnimSetSkelContext(NULL);
IwAnimSetSkinContext(NULL);
Hopefully most of this already looks familiar to you. The first step is to set the view
and model matrices we want to use for rendering. We then need to provide some
information about the frame of animation, namely the animated skeleton and the
skin data.
The skeleton information is maintained by the CIwAnimPlayer instance and can
be retrieved using the GetSkel method. The skin is just the CIwAnimSkin instance
as loaded by the resource manager. We use the IwAnimSetSkelContext and
IwAnimSetSkinContext functions to provide this data to the rendering engine.
To render the animated model to the screen, all we have to do is call the Render
method on lpFlag , which is a pointer to a CIwModel instance, just as we would
if we were rendering the model without any animation.
After rendering, we clear the skin and skeleton contexts so that future model
rendering calls won't try and use incorrect data during rendering. This is a good
habit to get into as determining why an unanimated model has suddenly started
deforming wildly could be a tricky bug to track down.
 
Search WWH ::




Custom Search