2016-11-15 20:52:37 +01:00
|
|
|
#pragma once
|
|
|
|
|
2019-08-29 19:12:13 +02:00
|
|
|
#include "condition.h"
|
|
|
|
#include "engine/flag_set.h"
|
2016-11-15 20:52:37 +01:00
|
|
|
#include "engine/resource.h"
|
2019-08-29 19:12:13 +02:00
|
|
|
#include "engine/stream.h"
|
2016-11-15 20:52:37 +01:00
|
|
|
|
2019-08-29 19:12:13 +02:00
|
|
|
namespace Lumix {
|
2016-11-15 20:52:37 +01:00
|
|
|
|
2019-08-29 19:12:13 +02:00
|
|
|
struct LocalRigidTransform;
|
|
|
|
struct Pose;
|
2016-11-15 20:52:37 +01:00
|
|
|
|
2019-08-29 19:12:13 +02:00
|
|
|
namespace Anim {
|
2016-11-15 20:52:37 +01:00
|
|
|
|
2019-08-29 19:12:13 +02:00
|
|
|
struct GroupNode;
|
|
|
|
struct RuntimeContext;
|
2016-11-15 20:52:37 +01:00
|
|
|
|
2019-08-29 19:12:13 +02:00
|
|
|
class Controller final : public Resource {
|
2017-03-23 01:07:16 +01:00
|
|
|
public:
|
2019-08-29 19:12:13 +02:00
|
|
|
Controller(const Path& path, ResourceManager& resource_manager, IAllocator& allocator);
|
2017-03-23 01:07:16 +01:00
|
|
|
|
2019-08-29 19:12:13 +02:00
|
|
|
void serialize(OutputMemoryStream& stream);
|
|
|
|
bool deserialize(InputMemoryStream& stream);
|
2017-03-23 01:07:16 +01:00
|
|
|
|
2019-08-29 19:12:13 +02:00
|
|
|
RuntimeContext* createRuntime(u32 anim_set);
|
|
|
|
void destroyRuntime(RuntimeContext& ctx);
|
|
|
|
void update(RuntimeContext& ctx, Ref<LocalRigidTransform> root_motion);
|
2019-09-01 17:33:18 +02:00
|
|
|
void getPose(RuntimeContext& ctx, Ref<struct Pose> pose);
|
2019-08-29 19:12:13 +02:00
|
|
|
void initEmpty();
|
2016-11-15 20:52:37 +01:00
|
|
|
|
2018-01-11 21:13:59 +01:00
|
|
|
ResourceType getType() const override { return TYPE; }
|
2019-08-29 19:12:13 +02:00
|
|
|
static const ResourceType TYPE;
|
2017-12-08 00:34:11 +01:00
|
|
|
|
2019-08-29 19:12:13 +02:00
|
|
|
struct AnimationEntry {
|
|
|
|
u32 set;
|
|
|
|
u32 slot_hash;
|
2017-03-23 01:07:16 +01:00
|
|
|
Animation* animation;
|
|
|
|
};
|
|
|
|
|
2019-08-29 19:12:13 +02:00
|
|
|
IAllocator& m_allocator;
|
|
|
|
GroupNode* m_root = nullptr;
|
|
|
|
Array<AnimationEntry> m_animation_entries;
|
|
|
|
Array<String> m_animation_slots;
|
|
|
|
InputDecl m_inputs;
|
|
|
|
enum class Flags : u32 {
|
|
|
|
USE_ROOT_MOTION = 1 << 0
|
|
|
|
};
|
|
|
|
FlagSet<Flags, u32> m_flags;
|
2018-01-11 21:13:59 +01:00
|
|
|
|
2017-03-23 01:07:16 +01:00
|
|
|
private:
|
2019-08-29 19:12:13 +02:00
|
|
|
void unload() override;
|
|
|
|
bool load(u64 size, const u8* mem) override;
|
2016-11-15 20:52:37 +01:00
|
|
|
};
|
|
|
|
|
2019-08-29 19:12:13 +02:00
|
|
|
} // ns Anim
|
|
|
|
} // ns Lumix
|