-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathEntityAnimatorSystem.hpp
More file actions
50 lines (38 loc) · 1.63 KB
/
EntityAnimatorSystem.hpp
File metadata and controls
50 lines (38 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#ifndef ENTITYANIMATORSYSTEM_HPP
#define ENTITYANIMATORSYSTEM_HPP
#include <EntityAnimatorPluginMacros.hpp>
#include <Core/Animation/KeyFramedValue.hpp>
#include <Core/Animation/KeyFramedValueInterpolators.hpp>
#include <Engine/Entity/Entity.hpp>
#include <Engine/System/System.hpp>
#include <GuiBase/Timeline/Timeline.hpp>
namespace EntityAnimatorPlugin {
class ENTITY_ANIMATOR_PLUGIN_API EntityAnimatorSystem : public Ra::Engine::System
{
public:
EntityAnimatorSystem() {}
~EntityAnimatorSystem() override {}
void setTimeline( Ra::GuiBase::Timeline* timeline ) {
m_timeline = timeline;
}
void handleAssetLoading( Ra::Engine::Entity* entity,
const Ra::Core::Asset::FileData* data ) override {
if ( !m_timeline ) return;
using namespace Ra::Core::Animation;
using Ra::Core::Transform;
auto keyframe = new KeyFramedValue<Transform>( entity->getTransform(), 0_ra );
auto inserter = [keyframe, entity]( const Scalar& t ) {
keyframe->insertKeyFrame( t, entity->getTransform() );
};
auto updater = [keyframe, entity]( const Scalar& t ) {
entity->setTransform( keyframe->at( t, linearInterpolate<Transform> ) );
};
m_timeline->registerKeyFramedValue( entity, KeyFramedValueController( keyframe, "Entity Transform", inserter, updater ) );
}
void generateTasks( Ra::Core::TaskQueue* taskQueue,
const Ra::Engine::FrameInfo& frameInfo ) override {}
private:
Ra::GuiBase::Timeline* m_timeline{nullptr};
};
} // namespace EntityAnimatorPlugin
#endif // ENTITYANIMATORSYSTEM_HPP