Plasma Engine  2.0
Loading...
Searching...
No Matches
Skeleton.h
1#pragma once
2
3#include <RendererCore/RendererCoreDLL.h>
4
5#include <Foundation/Math/Mat3.h>
6#include <Foundation/Reflection/Reflection.h>
7#include <Foundation/Strings/HashedString.h>
8#include <Foundation/Types/UniquePtr.h>
9#include <RendererCore/AnimationSystem/Declarations.h>
10
11class plStreamWriter;
12class plStreamReader;
14class plSkeleton;
15
17
18namespace ozz::animation
19{
20 class Skeleton;
21}
22
26class PL_RENDERERCORE_DLL plSkeletonJoint
27{
28public:
29 const plTransform& GetRestPoseLocalTransform() const { return m_RestPoseLocal; }
30
32 plUInt16 GetParentIndex() const { return m_uiParentIndex; }
33
34 bool IsRootJoint() const { return m_uiParentIndex == plInvalidJointIndex; }
35 const plHashedString& GetName() const { return m_sName; }
36
37 plAngle GetHalfSwingLimitY() const { return m_HalfSwingLimitY; }
38 plAngle GetHalfSwingLimitZ() const { return m_HalfSwingLimitZ; }
39 plAngle GetTwistLimitHalfAngle() const { return m_TwistLimitHalfAngle; }
40 plAngle GetTwistLimitCenterAngle() const { return m_TwistLimitCenterAngle; }
41 plAngle GetTwistLimitLow() const;
42 plAngle GetTwistLimitHigh() const;
43 plEnum<plSkeletonJointType> GetJointType() const { return m_JointType; }
44
45 plQuat GetLocalOrientation() const { return m_qLocalJointOrientation; }
46
47 plSurfaceResourceHandle GetSurface() const { return m_hSurface; }
48 plUInt8 GetCollisionLayer() const { return m_uiCollisionLayer; }
49
50 float GetStiffness() const { return m_fStiffness; }
51 void SetStiffness(float fValue) { m_fStiffness = fValue; }
52
53private:
54 friend plSkeleton;
55 friend plSkeletonBuilder;
56
57 plTransform m_RestPoseLocal;
58 plUInt16 m_uiParentIndex = plInvalidJointIndex;
59 plHashedString m_sName;
60
61 plSurfaceResourceHandle m_hSurface;
62 plUInt8 m_uiCollisionLayer = 0;
63
65 plQuat m_qLocalJointOrientation = plQuat::MakeIdentity();
66 plAngle m_HalfSwingLimitY;
67 plAngle m_HalfSwingLimitZ;
68 plAngle m_TwistLimitHalfAngle;
69 plAngle m_TwistLimitCenterAngle;
70 float m_fStiffness = 0.0f;
71};
72
74class PL_RENDERERCORE_DLL plSkeleton
75{
76 PL_DISALLOW_COPY_AND_ASSIGN(plSkeleton);
77
78public:
79 plSkeleton();
82
83 void operator=(plSkeleton&& rhs);
84
86 plUInt16 GetJointCount() const { return static_cast<plUInt16>(m_Joints.GetCount()); }
87
89 const plSkeletonJoint& GetJointByIndex(plUInt16 uiIndex) const { return m_Joints[uiIndex]; }
90
92 plUInt16 FindJointByName(const plTempHashedString& sName) const;
93
95 // bool IsCompatibleWith(const plSkeleton& other) const;
96
98 void Save(plStreamWriter& inout_stream) const;
99
101 void Load(plStreamReader& inout_stream);
102
103 bool IsJointDescendantOf(plUInt16 uiJoint, plUInt16 uiExpectedParent) const;
104
105 const ozz::animation::Skeleton& GetOzzSkeleton() const;
106
107 plUInt64 GetHeapMemoryUsage() const;
108
111
112protected:
113 friend plSkeletonBuilder;
114
116 mutable plUniquePtr<ozz::animation::Skeleton> m_pOzzSkeleton;
117};
Float wrapper struct for a safe usage and conversions of angles.
Definition Angle.h:10
Definition DynamicArray.h:81
This class is optimized to take nearly no memory (sizeof(void*)) and to allow very fast checks whethe...
Definition HashedString.h:25
static const plQuatTemplate< float > MakeIdentity()
Definition Quat_inl.h:29
The skeleton builder class provides the means to build skeleton instances from scratch....
Definition SkeletonBuilder.h:10
The skeleton class encapsulates the information about the joint structure for a model.
Definition Skeleton.h:75
plEnum< plBasisAxis > m_BoneDirection
The direction in which the bones shall point for visualization.
Definition Skeleton.h:110
plUInt16 GetJointCount() const
Returns the number of joints in the skeleton.
Definition Skeleton.h:86
const plSkeletonJoint & GetJointByIndex(plUInt16 uiIndex) const
Returns the nth joint.
Definition Skeleton.h:89
Describes a single joint. The transforms of the joints are in their local space and thus need to be c...
Definition Skeleton.h:27
plUInt16 GetParentIndex() const
Returns plInvalidJointIndex if no parent.
Definition Skeleton.h:32
Interface for binary in (read) streams.
Definition Stream.h:22
Interface for binary out (write) streams.
Definition Stream.h:107
A class to use together with plHashedString for quick comparisons with temporary strings that need no...
Definition HashedString.h:151
A Unique ptr manages an object and destroys that object when it goes out of scope....
Definition UniquePtr.h:10
A custom enum implementation that allows to define the underlying storage type to control its memory ...
Definition Enum.h:37