Animation is something that would make Balder shine. It is very important it is feature rich, but also at the same time easy to use.
Animation should be possible to export from software and use directly in Balder.
Since Balder supports multiple platforms, we can not tie it directly into the Storyboard model of Silverlight, but the Storyboard model is very interesting as a reference for how it could be done. But obviously, we can't name it the same since that would
It should also be possible to animate several things inside one Animation.
I'm suggesting the following class hierarchy :
- Animation - top level animation object, can contain other Animations, but also keyframes
- IKeyFrame - represents the abstract concept of a keyframe
- KeyFrame - abstract base class for a keyframe
- SpriteKeyFrame - concrete keyframe for sprites
- NodeKeyFrame - concrete keyframe for nodes
- BoneKeyFrame - concrete keyframe for bones
- MaterialKeyFrame - concrete keyframe for materials
Animation - should have an IAnimation interface representing its functionality.
The animation class should be the organizer of an animation, but it should be able to have child animations as well. That way one can combine node animations and sprite animations and so forth. It also holds information about what object it animates. Starting
an animation should start any child animations as well.
- Play() - with multiple overloads - the simplest without any parameters
- Play(float speedFactor)
- Play(AnimationRepeatBehavior repeat) - repeat behaviors could be : Loop, PingPong
- Play(float speedFactor, AnimationRepeatBehavior repeat)
Represents a keyframe and what one can do with it.
- Handle() - should take a time object - suggest a KeyTime object
Implements IKeyFrame and also implements the methods needed and provides a base class for keyframes - it will handle the common things for all KeyFrames
Basically just holds what frame within a bitmap animation to show - framenumber.
Holds information about Position, Rotation and Scale at the given keyframe
Holds information about animatable properties on a material - typically color
Sprites can basically be animated in two ways; frame based - "bitmap changes" and through the fact that it is a node, Rotation, Scaling and Positioning can also be animated.
Since Balder has a hierarchy and changing the position of a parent node the children will be affected directly. So skeleton animation should be a walk in the park.
Bones is not something Balder has today, but is something we need for skin animation. Bones will be nodes, at least the root bone, with a Quaternion representing it.
Transitioning from one animation to another
Lets say one has a person, it has a bunch of animations - typically walking, jumping, running and such. Transitioning between these should be something that should be easy to do.
Typically one should have a method called TransitionTo(Animation animation) with overloads for controlling speed of the transition.
Something that can be very handy is the ability to create hookups between animations. Points in an animation where it looks better to transition to other specified animation. That means that when doing TransitionTo() and there are hookups defined for the animation
one wants to transition to - it will start the transition at the hookup point. The hookup must then hold information about Time and what Animation it can hook up to.