Plasma Engine  2.0
Loading...
Searching...
No Matches
AnimatedMeshComponent.h
1#pragma once
2
3#include <GameEngine/GameEngineDLL.h>
4#include <RendererCore/AnimationSystem/AnimationPose.h>
5#include <RendererCore/Debug/DebugRenderer.h>
6#include <RendererCore/Meshes/SkinnedMeshComponent.h>
7
9
10class PL_GAMEENGINE_DLL plAnimatedMeshComponentManager : public plComponentManager<class plAnimatedMeshComponent, plBlockStorageType::FreeList>
11{
12public:
15
16 virtual void Initialize() override;
17
18 void Update(const plWorldModule::UpdateContext& context);
19 void AddToUpdateList(plAnimatedMeshComponent* pComponent);
20
21private:
22 void ResourceEventHandler(const plResourceEvent& e);
23
24 plDeque<plComponentHandle> m_ComponentsToUpdate;
25};
26
37class PL_GAMEENGINE_DLL plAnimatedMeshComponent : public plMeshComponentBase
38{
40
41
43 // plComponent
44
45public:
46 virtual void SerializeComponent(plWorldWriter& inout_stream) const override;
47 virtual void DeserializeComponent(plWorldReader& inout_stream) override;
48
49protected:
50 virtual void OnActivated() override;
51 virtual void OnDeactivated() override;
52
54 // plMeshComponentBase
55
56protected:
57 virtual plMeshRenderData* CreateRenderData() const override;
58 virtual plResult GetLocalBounds(plBoundingBoxSphere& bounds, bool& bAlwaysVisible, plMsgUpdateLocalBounds& msg) override;
59
61 // plAnimatedMeshComponent
62
63public:
66
67 void RetrievePose(plDynamicArray<plMat4>& out_modelTransforms, plTransform& out_rootTransform, const plSkeleton& skeleton);
68
69protected:
70 void OnAnimationPoseUpdated(plMsgAnimationPoseUpdated& msg); // [ msg handler ]
71 void OnQueryAnimationSkeleton(plMsgQueryAnimationSkeleton& msg); // [ msg handler ]
72
73 void InitializeAnimationPose();
74
75 void MapModelSpacePoseToSkinningSpace(const plHashTable<plHashedString, plMeshResourceDescriptor::BoneData>& bones, const plSkeleton& skeleton, plArrayPtr<const plMat4> modelSpaceTransforms, plBoundingBox* bounds);
76
77 plTransform m_RootTransform = plTransform::MakeIdentity();
78 plBoundingBox m_MaxBounds;
79 plSkinningState m_SkinningState;
80 plSkeletonResourceHandle m_hDefaultSkeleton;
81};
82
83
85{
86 using StorageType = plInt8;
87
88 enum Enum
89 {
90 Ignore,
91 ApplyToOwner,
92 SendMoveCharacterMsg,
93
94 Default = Ignore
95 };
96
97 PL_GAMEENGINE_DLL static void Apply(plRootMotionMode::Enum mode, plGameObject* pObject, const plVec3& vTranslation, plAngle rotationX, plAngle rotationY, plAngle rotationZ);
98};
99
100PL_DECLARE_REFLECTABLE_TYPE(PL_GAMEENGINE_DLL, plRootMotionMode);
Float wrapper struct for a safe usage and conversions of angles.
Definition Angle.h:10
Instantiates a mesh that can be animated through skeletal animation.
Definition AnimatedMeshComponent.h:38
Definition AnimatedMeshComponent.h:11
This class encapsulates an array and it's size. It is recommended to use this class instead of plain ...
Definition ArrayPtr.h:37
Definition ComponentManager.h:88
Definition Deque.h:270
Definition DynamicArray.h:81
This class represents an object inside the world.
Definition GameObject.h:32
Definition HashTable.h:333
Base class for components that render static or animated meshes.
Definition MeshComponentBase.h:67
Definition MeshComponentBase.h:13
The skeleton class encapsulates the information about the joint structure for a model.
Definition Skeleton.h:75
static plTransformTemplate< float > MakeIdentity()
Definition Transform_inl.h:25
A world encapsulates a scene graph of game objects and various component managers and their component...
Definition World.h:22
virtual void Initialize()
This method is called after the constructor. A derived type can override this method to do initializa...
Definition WorldModule.h:98
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
Used by components that skin a mesh to inform children whenever a new pose has been computed.
Definition Declarations.h:68
The animated mesh component listens to this message and 'answers' by filling out the skeleton resourc...
Definition Declarations.h:99
Definition UpdateLocalBoundsMessage.h:9
These events may be sent by a specific plResource or by the plResourceManager.
Definition Declarations.h:22
Default enum for returning failure or success, instead of using a bool.
Definition Types.h:54
Definition AnimatedMeshComponent.h:85
Definition SkinnedMeshComponent.h:21
Definition WorldModule.h:33