Plasma Engine  2.0
Loading...
Searching...
No Matches
SkeletonComponent.h
1#pragma once
2
3#include <Foundation/Math/Declarations.h>
4#include <RendererCore/AnimationSystem/SkeletonResource.h>
5#include <RendererCore/Components/RenderComponent.h>
6#include <RendererCore/Debug/DebugRenderer.h>
7
9
11
18class PL_RENDERERCORE_DLL plSkeletonComponent : public plRenderComponent
19{
21
23 // plComponent
24
25public:
26 virtual void SerializeComponent(plWorldWriter& inout_stream) const override;
27 virtual void DeserializeComponent(plWorldReader& inout_stream) override;
28
29protected:
30 virtual void OnActivated() override;
31
32
34 // plRenderComponent
35
36public:
37 virtual plResult GetLocalBounds(plBoundingBoxSphere& ref_bounds, bool& ref_bAlwaysVisible, plMsgUpdateLocalBounds& ref_msg) override;
38
40 // plSkeletonComponent
41
42public:
45
46 void SetSkeletonFile(const char* szFile); // [ property ]
47 const char* GetSkeletonFile() const; // [ property ]
48
49 void SetSkeleton(const plSkeletonResourceHandle& hResource);
50 const plSkeletonResourceHandle& GetSkeleton() const { return m_hSkeleton; }
51
57 void SetBonesToHighlight(const char* szFilter); // [ property ]
58 const char* GetBonesToHighlight() const; // [ property ]
59
60 bool m_bVisualizeBones = true; // [ property ]
61 bool m_bVisualizeColliders = false; // [ property ]
62 bool m_bVisualizeJoints = false; // [ property ]
63 bool m_bVisualizeSwingLimits = false; // [ property ]
64 bool m_bVisualizeTwistLimits = false; // [ property ]
65
66protected:
67 void Update();
68 void VisualizeSkeletonDefaultState();
69 void OnAnimationPoseUpdated(plMsgAnimationPoseUpdated& msg); // [ msg handler ]
70
71 void BuildSkeletonVisualization(plMsgAnimationPoseUpdated& msg);
72 void BuildColliderVisualization(plMsgAnimationPoseUpdated& msg);
73 void BuildJointVisualization(plMsgAnimationPoseUpdated& msg);
74
75 void OnQueryAnimationSkeleton(plMsgQueryAnimationSkeleton& msg);
76 plDebugRenderer::Line& AddLine(const plVec3& vStart, const plVec3& vEnd, const plColor& color);
77
78 plSkeletonResourceHandle m_hSkeleton;
79 plTransform m_RootTransform = plTransform::MakeIdentity();
80 plUInt32 m_uiSkeletonChangeCounter = 0;
81 plString m_sBonesToHighlight;
82
83 plBoundingBox m_MaxBounds;
85
87 {
88 plTransform m_Transform;
89 plBoundingSphere m_Shape;
90 plColor m_Color;
91 };
92
93 struct BoxShape
94 {
95 plTransform m_Transform;
96 plBoundingBox m_Shape;
97 plColor m_Color;
98 };
99
101 {
102 plTransform m_Transform;
103 float m_fLength;
104 float m_fRadius;
105 plColor m_Color;
106 };
107
109 {
110 plTransform m_Transform;
111 plColor m_Color;
112 plAngle m_StartAngle;
113 plAngle m_EndAngle;
114 };
115
117 {
118 plTransform m_Transform;
119 plColor m_Color;
120 plAngle m_Angle1;
121 plAngle m_Angle2;
122 };
123
125 {
126 plTransform m_Transform;
127 plColor m_Color;
128 float m_fRadius1;
129 float m_fRadius2;
130 float m_fLength;
131 };
132
133 plDynamicArray<SphereShape> m_SpheresShapes;
134 plDynamicArray<BoxShape> m_BoxShapes;
135 plDynamicArray<CapsuleShape> m_CapsuleShapes;
136 plDynamicArray<AngleShape> m_AngleShapes;
137 plDynamicArray<ConeLimitShape> m_ConeLimitShapes;
138 plDynamicArray<CylinderShape> m_CylinderShapes;
139};
Float wrapper struct for a safe usage and conversions of angles.
Definition Angle.h:10
plColor represents an RGBA color in linear color space. Values are stored as float,...
Definition Color.h:44
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 DeserializeComponent(plWorldReader &inout_stream)
Override this to load the current state of the component from the given stream.
Definition Component.cpp:58
Simple component manager implementation that calls an update method on all components every frame.
Definition ComponentManager.h:142
Definition DynamicArray.h:81
Base class for objects that should be rendered.
Definition RenderComponent.h:9
virtual void OnActivated() override
This method is called when the component gets activated.
Definition RenderComponent.cpp:33
virtual plResult GetLocalBounds(plBoundingBoxSphere &ref_bounds, bool &ref_bAlwaysVisible, plMsgUpdateLocalBounds &ref_msg)=0
Called by plRenderComponent::OnUpdateLocalBounds(). If PL_SUCCESS is returned, bounds and bAlwaysVisi...
Uses debug rendering to visualize various aspects of an animation skeleton.
Definition SkeletonComponent.h:19
static plTransformTemplate< float > MakeIdentity()
Definition Transform_inl.h:25
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
Definition DebugRenderer.h:84
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
Default enum for returning failure or success, instead of using a bool.
Definition Types.h:54
Definition SkeletonComponent.h:109
Definition SkeletonComponent.h:94
Definition SkeletonComponent.h:101
Definition SkeletonComponent.h:117
Definition SkeletonComponent.h:125
Definition SkeletonComponent.h:87