Plasma Engine  2.0
Loading...
Searching...
No Matches
AnimationClipResource.h
1#pragma once
2
3#include <RendererCore/RendererCoreDLL.h>
4
5#include <Core/ResourceManager/Resource.h>
6#include <Foundation/Containers/ArrayMap.h>
7#include <Foundation/Strings/HashedString.h>
8#include <Foundation/Tracks/Curve1D.h>
9#include <Foundation/Tracks/EventTrack.h>
10
12
13namespace ozz::animation
14{
15 class Animation;
16}
17
18struct PL_RENDERERCORE_DLL plAnimationClipResourceDescriptor
19{
20public:
24
25 void operator=(plAnimationClipResourceDescriptor&& rhs) noexcept;
26
27 plResult Serialize(plStreamWriter& inout_stream) const;
28 plResult Deserialize(plStreamReader& inout_stream);
29
30 plUInt64 GetHeapMemoryUsage() const;
31
32 plUInt16 GetNumJoints() const;
33 plTime GetDuration() const;
34 void SetDuration(plTime duration);
35
36 void SetConstantRootMotion(const plVec3& vMotion);
37
38 const ozz::animation::Animation& GetMappedOzzAnimation(const plSkeletonResource& skeleton) const;
39
40 struct JointInfo
41 {
42 plUInt32 m_uiPositionIdx = 0;
43 plUInt32 m_uiRotationIdx = 0;
44 plUInt32 m_uiScaleIdx = 0;
45 plUInt16 m_uiPositionCount = 0;
46 plUInt16 m_uiRotationCount = 0;
47 plUInt16 m_uiScaleCount = 0;
48 };
49
51 {
52 float m_fTimeInSec;
53 plVec3 m_Value;
54 };
55
57 {
58 float m_fTimeInSec;
59 plQuat m_Value;
60 };
61
62 JointInfo CreateJoint(const plHashedString& sJointName, plUInt16 uiNumPositions, plUInt16 uiNumRotations, plUInt16 uiNumScales);
63 const JointInfo* GetJointInfo(const plTempHashedString& sJointName) const;
64 void AllocateJointTransforms();
65
66 plArrayPtr<KeyframeVec3> GetPositionKeyframes(const JointInfo& jointInfo);
67 plArrayPtr<KeyframeQuat> GetRotationKeyframes(const JointInfo& jointInfo);
68 plArrayPtr<KeyframeVec3> GetScaleKeyframes(const JointInfo& jointInfo);
69
70 plArrayPtr<const KeyframeVec3> GetPositionKeyframes(const JointInfo& jointInfo) const;
71 plArrayPtr<const KeyframeQuat> GetRotationKeyframes(const JointInfo& jointInfo) const;
72 plArrayPtr<const KeyframeVec3> GetScaleKeyframes(const JointInfo& jointInfo) const;
73
74 plVec3 GetRootMotion(plTime sampleTime) const;
75 plVec3 GetRootMotionAtNormalizedPos(float fNormalizedTime) const;
76
77 plCurve1D m_RootMotionCurves[3];
78
79 plEventTrack m_EventTrack;
80
81 bool m_bAdditive = false;
82
83private:
85 plDataBuffer m_Transforms;
86 plUInt32 m_uiNumTotalPositions = 0;
87 plUInt32 m_uiNumTotalRotations = 0;
88 plUInt32 m_uiNumTotalScales = 0;
89 plTime m_Duration;
90
91 struct OzzImpl;
92 plUniquePtr<OzzImpl> m_pOzzImpl;
93};
94
96
98
99class PL_RENDERERCORE_DLL plAnimationClipResource : public plResource
100{
101 PL_ADD_DYNAMIC_REFLECTION(plAnimationClipResource, plResource);
102 PL_RESOURCE_DECLARE_COMMON_CODE(plAnimationClipResource);
103 PL_RESOURCE_DECLARE_CREATEABLE(plAnimationClipResource, plAnimationClipResourceDescriptor);
104
105public:
107
108 const plAnimationClipResourceDescriptor& GetDescriptor() const { return *m_pDescriptor; }
109
110private:
111 virtual plResourceLoadDesc UnloadData(Unload WhatToUnload) override;
112 virtual plResourceLoadDesc UpdateContent(plStreamReader* Stream) override;
113 virtual void UpdateMemoryUsage(MemoryUsage& out_NewMemoryUsage) override;
114
116};
Definition AnimationClipResource.h:100
See plArrayMapBase for details.
Definition ArrayMap.h:149
This class encapsulates an array and it's size. It is recommended to use this class instead of plain ...
Definition ArrayPtr.h:37
A 1D curve for animating a single value over time.
Definition Curve1D.h:29
An event track is a time line that contains named events.
Definition EventTrack.h:15
This class is optimized to take nearly no memory (sizeof(void*)) and to allow very fast checks whethe...
Definition HashedString.h:25
The base class for all resources.
Definition Resource.h:10
Definition SkeletonResource.h:47
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
Definition AnimationClipResource.h:41
Definition AnimationClipResource.h:57
Definition AnimationClipResource.h:51
Definition AnimationClipResource.h:19
Definition Resource.h:34
Describes in which loading state a resource currently is, and how many different quality levels there...
Definition Declarations.h:102
Default enum for returning failure or success, instead of using a bool.
Definition Types.h:54
The time class encapsulates a double value storing the time in seconds.
Definition Time.h:12