Click or drag to resize
DigitalRuneFAQ
General

How can I play/loop a character animation in reverse?

How can I get the total duration of an AnimationClip?

If AnimationClipTDuration is set to null, the clip plays only once and GetTotalDuration returns the actual duration. Often Duration is set to TimeSpan.MaxValue to repeat the animation forever. In this case GetTotalDuration also returns TimeSpan.MaxValue.

Other ways to get the duration:

  • If ClipStart and ClipEnd are not set, you can simply call AnimationClip<T>.Animation.GetTotalDuration().
  • If ClipStart or ClipEnd is set, the duration is:
    C#
    var start = clip.ClipStart ?? TimeSpan.Zero;
    var end = clip.ClipEnd ?? clip.Animation.GetTotalDuration();
    var duration = end - start;

    (This does not consider any Delay or Speed factor.)

Character animation

How can I get the length of a bone which has no child?

There is no built-in way to get the length of a bone which has no child. Following methods could be used:

  • Use a dummy bone to mark the end.
  • Or, create and use a custom exporter tool for your 3D modeling app where you can enter the length of the last bones manually and export this info with the model.

My animations exported from Maya/3ds Max/etc. are not working!?

Per default, DigitalRune Animation uses the XNA content pipeline to import models. The XNA content pipeline has some limitations and not all exported 3D models work with it.

If you are using the XNA content pipeline, please test if your model works with the standard XNA Skinned Model Sample

If it does not work, please check the XNA forum for possible solutions.

If the model works with the XNA Skinned Model Sample, but it does not work with the DigitalRune Engine, please let us know and we will provide a fix.

How can I convert a SkeletonPose to an Animation that can be mixed (blended) with other animations?

Following animation class "wraps" a SkeletonPose. The current pose of the SkeletonPose property is copied to the value that should be animated.

C#
using System;
using DigitalRune.Animation;
using DigitalRune.Animation.Character;
using DigitalRune.Animation.Traits;

namespace CharacterAnimationSample
{
  // A custom SkeletonPose animation that simply "wraps" a SkeletonPose. The current pose
  // of the SkeletonPose property is copied to the SkeletonPose that should be animated.
  public class WrappedSkeletonPoseAnimation : Animation<SkeletonPose>
  {
    // The source SkeletonPose.
    public SkeletonPose SkeletonPose { get; set; }

    // Traits tell the animation system how to create/recycle/add/blend/etc. the animated
    // value type. Trait classes are usually singletons.
    public override IAnimationValueTraits<SkeletonPose> Traits
    {
      get { return SkeletonPoseTraits.Instance; }
    }

    // This animation goes on forever.
    public override TimeSpan GetTotalDuration()
    {
      return TimeSpan.MaxValue;
    }

    // Compute the animation value for the given time and stores it in result. 
    protected override void GetValueCore(TimeSpan time, ref SkeletonPose defaultSource, ref SkeletonPose defaultTarget, ref SkeletonPose result)
    {
      var source = SkeletonPose ?? defaultSource;
      Traits.Copy(ref source, ref result);
    }
  }
}