Animations Implementation

I probably should’ve posted this before starting to code it, but better late than never I guess.

This is a discussion about how to implement the animation functionality, how it will work and how to use it. The animation discussed here is the type which controls properties of sprites/other objects at runtime, they aren’t spritesheet-animations.

I’m gonna start of by explaining the way I see it (and foolishly started working on already):
There is always only one animator class, a GameComponent bound to the game (updates when game updates…).

  • Animator play stored and non-stored animations, accessing them via name.

  • Animations will have a Layer (int) property, animations can be layered so there’s only one running animation per layer possible. Ex: (Layer 1: movement(walking, running) Layer 2: actions(shoot, open door).
    They also hold events to invoke at certain times.

  • Animations contain AnimationTrackGroups which group AnimationTracks per transformable (the object being transformed). They can swap out the transformable at runtime for one of the same type (even while the animation is running)

  • AnimationTracks contain Transformations, grouped by type (basically a Row in any animator software) this to make sure values are only interpolated between members of the same type.

  • Transformations contain a time and a value. They can interpolate (tween) or just set the value at the desired time. These are different types (ITweenTransform, ISetTransform) tweening means it will interpolate the value and previous value based on time and previous time, there is an Easing class to change this interpolation.

they can be added to the animation directly (which will handle the track/trackgroup):
syntax: transformable, property, time, value
animation.AddTweenTransform(sprite, s => s.Position, 100, Vector2.One); animation.AddSetTransform(sprite, s => s.IsVisible, 0, true);

or they can be constructed and added to the animation:
var scaletransform1= new ScaleTransform<Sprite>(0, Vector2.One); var scaletransform2 = new ScaleTransform<Sprite>(100, Vector2.Zero); animation.AddTransformations(sprite, scaletransform1, scaletransform2 );

Transforms can be based on interfaces (such as IMoveable, IScalable…) or use reflection to select properties.

How do you even animate anything using Monogame.Extended. There’s absolutely zero documentation on how to get things working.

You can’t right now, that’s the reason for this discussion.

Ah, that would make sense. Thanks for clearing that up.

DigitalRune Animation is our (commercial) animation library. It covers pretty much all aspects of animation. (If there is anything we have missed, please let us know. :wink: Comments and critics are also welcome.)

Feel free to review our API and compare it with yours. Perhaps you find helpful ideas for your design.
Samples and documentation are freely available.

Features
Documentation
Class diagrams
Class library reference

1 Like

You’re right. I think it needs some discussion before it’s incorporated into the library. It’s a pretty big feature and I’ve had it floating around in my head for quite a while now. I’m sure we’ll both have a lot of ideas to bring to the table.

I noticed you already submitted a PR to discuss the code. I think that’s a good idea. There’s only so much we can talk about with a high level design. It’s the type of thing we’ll need to play with and iterate on. I suspect we’ll refactor the API a few times before pulling it into the main branch.

I get it. The documentation is lacking. Everyone likes to complain about it but nobody likes to write it :wink:

We have made a start on the wiki and there’s quite a few demos in the repository. You can of course ask questions here or various other places.

Rest assured, I’m completely aware of the documentation issues and I’d like to improve the situation. Better documentation means I spend less time answering questions and more time working on new features. That’s a win for everyone. Unfortunately, writing good documentation takes a lot of time and I’ve only got a limited about of that.

Thanks. I appreciate it. Our library is currently only focused on 2D and you’re appears to be mostly 3D but I’m sure we can get a few ideas from it.