Start animation from specific frame

How to start the animation from the specific frame?
I tried next:

// animation starts from first frame

But it always animates from the first frame
Pause/Resume also doesn't work as I wish
Good question. Currently there is no easy way to do that.

But you can derive your own class from AssimpAnimationController and then override the GetFrameNumber to provide a custom frame number based on the animation time. This allows you to add an offset to the frame number. The following code shows an example:

public class MyAnimationController : AssimpAnimationController
    public double FrameNumberOffset { get; set; }

    public MyAnimationController(AssimpWpfImporter assimpWpfImporter)
        : base(assimpWpfImporter)

    public override double GetFrameNumber(double animationTimeInSeconds)
        double frameNumber = base.GetFrameNumber(animationTimeInSeconds);

        frameNumber = (frameNumber + FrameNumberOffset) % LastFrameNumber;

        return frameNumber;

// then start animation by:
_assimpAnimationController.FrameNumberOffset = startFrameNumber;

To provide an easier way to support that case in the future I have added an overload to the StartAnimation method that takes the start frame number as a parameter. This will be available in the next version.
Andrej Benedik
Thank you!
In general, it works, but if the animation has been paused, then you need to call the StopAnimation () method before StartAnimation ();

In another case, a frame will jump.

if (_assimpAnimationController.IsAnimationPaused)
    // Have to stop for starting from required frame
    _assimpAnimationController.FrameNumberOffset = AnimationSlider.Value;

Forum Jump:

Users browsing this thread:
1 Guest(s)