Book Image

Direct3D Rendering Cookbook

By : Justin Stenning, Justin Stenning
Book Image

Direct3D Rendering Cookbook

By: Justin Stenning, Justin Stenning

Overview of this book

Table of Contents (19 chapters)
Direct3D Rendering Cookbook
About the Author
About the Reviewers
Further Reading

Animating bones

With an armature loaded and our vertex skinning in place, we are now ready to playback bone animations. In this recipe, we will access the animation's keyframes that are loaded from the first animation in a mesh, and playback within a loop.

Getting ready

For this recipe, we will continue from where we left off in the Loading bones in the mesh renderer recipe.

The completed project for this recipe, called Ch04_02Animate, is available within the companion source code provided with this book's code bundle. It is available on Packt website.

How to do it…

We will start by adding a few new properties to our mesh renderer.

  1. Open MeshRenderer.cs and add the following code:

    // Create and allow access to a timer
    System.Diagnostics.Stopwatch clock = new System.Diagnostics.Stopwatch();
    public System.Diagnostics.Stopwatch Clock
      get { return clock; }
      set { clock = value; }
    // The currently active animation (allows nulls)
    public Mesh.Animation? CurrentAnimation { get; set; }
    // Play...