LumixEngine/src/animation/controller.h

67 lines
1.4 KiB
C
Raw Normal View History

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-09-10 18:12:05 +02:00
struct BoneMask;
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
2020-02-21 22:09:11 +01:00
struct Controller final : 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);
2019-09-22 14:35:18 +02:00
~Controller();
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);
2020-04-11 20:42:36 +02:00
void update(RuntimeContext& ctx, Ref<LocalRigidTransform> root_motion) const;
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();
2019-09-22 14:35:18 +02:00
void destroy();
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;
2019-09-03 19:07:09 +02:00
u32 slot;
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;
2019-09-10 18:12:05 +02:00
Array<BoneMask> m_bone_masks;
2019-08-29 19:12:13 +02:00
InputDecl m_inputs;
enum class Flags : u32 {
USE_ROOT_MOTION = 1 << 0
};
FlagSet<Flags, u32> m_flags;
2019-09-04 17:33:54 +02:00
struct IK {
enum { MAX_BONES_COUNT = 8 };
u16 max_iterations = 5;
u16 bones_count = 4;
u32 bones[MAX_BONES_COUNT];
} m_ik[4];
u32 m_ik_count = 0;
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