Plasma Engine  2.0
Loading...
Searching...
No Matches
SkeletonPoseComponent.h
1#pragma once
2
3#include <Core/World/ComponentManager.h>
4#include <Foundation/Containers/ArrayMap.h>
5#include <Foundation/Types/RangeView.h>
6#include <RendererCore/AnimationSystem/EditableSkeleton.h>
7#include <RendererCore/AnimationSystem/SkeletonResource.h>
8
9class plSkeletonPoseComponentManager : public plComponentManager<class plSkeletonPoseComponent, plBlockStorageType::Compact>
10{
11public:
13
15 : SUPER(pWorld)
16 {
17 }
18
19 void Update(const plWorldModule::UpdateContext& context);
20 void EnqueueUpdate(plComponentHandle hComponent);
21
22private:
23 mutable plMutex m_Mutex;
24 plDeque<plComponentHandle> m_RequireUpdate;
25
26protected:
27 virtual void Initialize() override;
28};
29
31
34{
35 using StorageType = plUInt8;
36
37 enum Enum
38 {
42 Default = CustomPose
43 };
44};
45
46PL_DECLARE_REFLECTABLE_TYPE(PL_RENDERERCORE_DLL, plSkeletonPoseMode);
47
55class PL_RENDERERCORE_DLL plSkeletonPoseComponent : public plComponent
56{
58
60 // plComponent
61
62public:
63 virtual void SerializeComponent(plWorldWriter& inout_stream) const override;
64 virtual void DeserializeComponent(plWorldReader& inout_stream) override;
65
66protected:
67 virtual void OnActivated() override;
68 virtual void OnSimulationStarted() override;
69
71 // plSkeletonPoseComponent
72
73public:
76
78 void SetSkeletonFile(const char* szFile); // [ property ]
79 const char* GetSkeletonFile() const; // [ property ]
80
82 void SetSkeleton(const plSkeletonResourceHandle& hResource);
83 const plSkeletonResourceHandle& GetSkeleton() const { return m_hSkeleton; }
84
86 void SetPoseMode(plEnum<plSkeletonPoseMode> mode);
87 plEnum<plSkeletonPoseMode> GetPoseMode() const { return m_PoseMode; }
88
89 const plRangeView<const char*, plUInt32> GetBones() const; // [ property ] (exposed bones)
90 void SetBone(const char* szKey, const plVariant& value); // [ property ] (exposed bones)
91 void RemoveBone(const char* szKey); // [ property ] (exposed bones)
92 bool GetBone(const char* szKey, plVariant& out_value) const; // [ property ] (exposed bones)
93
95 void ResendPose();
96
97protected:
98 void Update();
99 void SendRestPose();
100 void SendCustomPose();
101
102 float m_fDummy = 0;
103 plUInt8 m_uiResendPose = 0;
104 plSkeletonResourceHandle m_hSkeleton;
105 plArrayMap<plHashedString, plExposedBone> m_Bones; // [ property ]
106 plEnum<plSkeletonPoseMode> m_PoseMode; // [ property ]
107};
See plArrayMapBase for details.
Definition ArrayMap.h:149
Base class of all component types.
Definition Component.h:25
virtual void SerializeComponent(plWorldWriter &inout_stream) const
Override this to save the current state of the component to the given stream.
Definition Component.cpp:54
virtual void OnSimulationStarted()
This method is called once for active components, at the start of the next world update,...
Definition Component.cpp:144
virtual void DeserializeComponent(plWorldReader &inout_stream)
Override this to load the current state of the component from the given stream.
Definition Component.cpp:58
virtual void OnActivated()
This method is called when the component gets activated.
Definition Component.cpp:140
Definition ComponentManager.h:88
Definition Deque.h:270
Provides a simple mechanism for mutual exclusion to prevent multiple threads from accessing a shared ...
Definition Mutex.h:13
This class uses delegates to define a range of values that can be enumerated using a forward iterator...
Definition RangeView.h:24
Used in conjunction with an plAnimatedMeshComponent to set a specific pose for the animated mesh.
Definition SkeletonPoseComponent.h:56
Definition SkeletonPoseComponent.h:10
virtual void Initialize() override
This method is called after the constructor. A derived type can override this method to do initializa...
Definition SkeletonPoseComponent.cpp:368
plVariant is a class that can store different types of variables, which is useful in situations where...
Definition Variant.h:44
A world encapsulates a scene graph of game objects and various component managers and their component...
Definition World.h:22
Reads a world description from a stream. Allows to instantiate that world multiple times in different...
Definition WorldReader.h:47
Stores an entire plWorld in a stream.
Definition WorldWriter.h:13
A handle to a component.
Definition Declarations.h:138
A custom enum implementation that allows to define the underlying storage type to control its memory ...
Definition Enum.h:37
Which pose to apply to an animated mesh.
Definition SkeletonPoseComponent.h:34
Enum
Definition SkeletonPoseComponent.h:38
@ CustomPose
Set a custom pose on the mesh.
Definition SkeletonPoseComponent.h:39
@ Disabled
Don't set any pose.
Definition SkeletonPoseComponent.h:41
@ RestPose
Set the rest pose (bind pose) on the mesh.
Definition SkeletonPoseComponent.h:40
Definition WorldModule.h:33