Rendering Animated Meshes

What you want to do now is to render your animated character. The rendering method itself appears deceptively simple, so add the code from Listing 13.8 to your class now.

Listing 13.8. Rendering Your Animated Character
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
    ProcessNextFrame();

    device.Clear(ClearFlags.Target | ClearFlags.ZBuffer,
        Color.CornflowerBlue, 1.0f, 0);

    device.BeginScene();

    // Draw our root frame
    DrawFrame((FrameDerived)rootFrame.FrameHierarchy);

    device.EndScene();

    device.Present();

    this.Invalidate();
}

As you can see, the method is quite simple. Process the next frame, clear the device, draw the root frame, and you're done. A lot of things need to happen in these steps, though. ...

Get Managed DirectX® 9 Kick Start: Graphics and Game Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.