LumixEngine/src/animation/controller.h

94 lines
1.7 KiB
C
Raw Normal View History

2016-11-15 20:52:37 +01:00
#pragma once
#include "engine/resource.h"
#include "engine/resource_manager.h"
2016-11-15 20:52:37 +01:00
#include "state_machine.h"
namespace Lumix
{
namespace Anim
{
class ControllerManager final : public ResourceManager
2016-11-15 20:52:37 +01:00
{
public:
2016-11-23 17:03:29 +01:00
explicit ControllerManager(IAllocator& allocator)
: ResourceManager(allocator)
2016-11-15 20:52:37 +01:00
, m_allocator(allocator)
{}
~ControllerManager() {}
2017-11-28 19:37:15 +01:00
IAllocator& getAllocator() const { return m_allocator; }
2016-11-15 20:52:37 +01:00
protected:
Resource* createResource(const Path& path) override;
void destroyResource(Resource& resource) override;
private:
IAllocator& m_allocator;
};
class ControllerResource : public Resource
{
2017-03-23 01:07:16 +01:00
public:
enum class Version : int
{
ANIMATION_SETS,
2017-04-07 13:45:00 +02:00
MAX_ROOT_ROTATION_SPEED,
2017-05-16 15:58:45 +02:00
INPUT_REFACTOR,
2017-09-07 19:24:24 +02:00
ENTER_EXIT_EVENTS,
ANIMATION_SPEED_MULTIPLIER,
MASKS,
END_GUARD,
EVENTS_FIX,
2017-03-23 01:07:16 +01:00
LAST
};
2016-11-15 20:52:37 +01:00
public:
ControllerResource(const Path& path, ResourceManager& resource_manager, IAllocator& allocator);
~ControllerResource();
2016-11-15 20:52:37 +01:00
2018-01-11 21:13:59 +01:00
ResourceType getType() const override { return TYPE; }
2017-12-08 00:34:11 +01:00
void create() { onCreated(State::READY); }
void destroy() { doUnload(); }
2017-11-28 19:37:15 +01:00
void unload() override;
2016-11-15 20:52:37 +01:00
bool load(FS::IFile& file) override;
2017-11-28 19:37:15 +01:00
ComponentInstance* createInstance(IAllocator& allocator) const;
2016-11-15 20:52:37 +01:00
void serialize(OutputBlob& blob);
bool deserialize(InputBlob& blob, int& version);
2017-11-28 19:37:15 +01:00
IAllocator& getAllocator() const { return m_allocator; }
2017-03-23 01:07:16 +01:00
void addAnimation(int set, u32 hash, Animation* animation);
2016-11-15 20:52:37 +01:00
2017-03-23 01:07:16 +01:00
struct AnimSetEntry
{
int set;
u32 hash;
Animation* animation;
};
Array<AnimSetEntry> m_animation_set;
Array<StaticString<32>> m_sets_names;
Array<BoneMask> m_masks;
2016-11-15 20:52:37 +01:00
InputDecl m_input_decl;
Component* m_root;
2017-03-23 01:07:16 +01:00
2018-01-11 21:13:59 +01:00
static const ResourceType TYPE;
2017-03-23 01:07:16 +01:00
private:
void clearAnimationSets();
2016-11-15 20:52:37 +01:00
IAllocator& m_allocator;
};
} // namespace Anim
} // namespace Lumix