Open RubyNova opened 4 years ago
This probably needs a bit of additional design work to make it what I envisioned fully? And I imagine there will also be questions, but this would be a good feature ticket for @FiniteReality as a nice break from CMake stuff for a while.
Not the button I meant to press.. :unamused:
I've got a work-in-progress screenshot for a new keyframing and animation system, which supports custom easing functions:
That was created byrunning gnuplot with the output of this:
class myThing
{
private:
float _position = 0;
public:
inline const float& position() const { return _position; }
inline float& position() { return _position; }
};
int main()
{
myThing thing;
auto sequence = create_keyframe_sequence(
create_keyframe<ease_out_quad>(0, 10, thing, &myThing::position, 10.0f),
create_keyframe<ease_in_quad>(5, 10, thing, &myThing::position, 20.0f),
create_keyframe<ease_linear>(0, 10, thing, &myThing::position, 30.0f),
create_keyframe<ease_in_out_elastic>(0, 10, thing, &myThing::position, 0.0f)
);
std::ofstream stream("sequence.dat");
stream << sequence.elapsed() << ' ' << thing.position() << '\n';
while (sequence.step(1.0f / 60.0f))
{
stream << sequence.elapsed() << ' ' << thing.position() << '\n';
}
stream << sequence.elapsed() << ' ' << thing.position() << '\n';
}
So the current design I'm thinking of works something like this:
From what I can tell the last three points are effectively what exists already, but it requires more polish.
At this current moment in time, we have
NovelRT::Animation::SpriteAnimator
which is hard-coded to update anImageRect
in a certain fashion based on the engine delta, like so:The proposed rewrite would allow for a lot of this logic to be defined by
T
, which we would assert inheritsValueAnimatorDefinition
. This new abstract type would (roughly) look something like this:Then a rough implementation for sprites of those two methods would probably look like:
Then the animator would create an instance of
T
and use it to figure out how to manage the animation state machine.A similar implementation might exist for specific value tweens such as
Transform._position
that generates thestd::vector<ValueAnimatorFrame>
based on the duration of theValueAnimatorState
, it may just ignore it completely and usedelta
to achieve a similar effect to a basic tweener that I am introducing (soon tm).If we did do this, at the very least, it would make the actual animator testable, which would be great for code coverage.
I personally think this is a "nice to have" and probably won't happen for quite some time, but as another "thought I had while on the train home", I figured it would be good to share my thoughts.