Plasma Engine  2.0
Loading...
Searching...
No Matches
AnimGraphNode.h
1#pragma once
2
3#include <Core/ResourceManager/ResourceHandle.h>
4#include <Foundation/Time/Time.h>
5#include <RendererCore/AnimationSystem/AnimGraph/AnimGraphPins.h>
6
8class plGameObject;
11class plStreamWriter;
12class plStreamReader;
17
19
20namespace ozz
21{
22 namespace animation
23 {
24 class Animation;
25 }
26} // namespace ozz
27
35class PL_RENDERERCORE_DLL plAnimGraphNode : public plReflectedClass
36{
37 PL_ADD_DYNAMIC_REFLECTION(plAnimGraphNode, plReflectedClass);
38
39public:
41 virtual ~plAnimGraphNode();
42
44 // plAnimGraphNode
45
46 const char* GetCustomNodeTitle() const { return m_sCustomNodeTitle.GetString(); }
47 void SetCustomNodeTitle(const char* szSz) { m_sCustomNodeTitle.Assign(szSz); }
48
49protected:
50 friend class plAnimGraphInstance;
51 friend class plAnimGraph;
52 friend class plAnimGraphResource;
53
54 plHashedString m_sCustomNodeTitle;
55 plUInt32 m_uiInstanceDataOffset = plInvalidIndex;
56
57 virtual plResult SerializeNode(plStreamWriter& stream) const = 0;
58 virtual plResult DeserializeNode(plStreamReader& stream) = 0;
59
60 virtual void Step(plAnimController& ref_controller, plAnimGraphInstance& ref_graph, plTime tDiff, const plSkeletonResource* pSkeleton, plGameObject* pTarget) const = 0;
61 virtual bool GetInstanceDataDesc(plInstanceDataDesc& out_desc) const { return false; }
62};
63
67
68struct PL_RENDERERCORE_DLL plAnimState
69{
70 enum class State
71 {
72 Off,
73 StartedRampUp,
74 RampingUp,
75 Running,
76 StartedRampDown,
77 RampingDown,
78 Finished,
79 };
80
81 // Properties:
82 plTime m_FadeIn; // [ property ]
83 plTime m_FadeOut; // [ property ]
84 bool m_bImmediateFadeIn = false; // [ property ]
85 bool m_bImmediateFadeOut = false; // [ property ]
86 bool m_bLoop = false; // [ property ]
87 float m_fPlaybackSpeed = 1.0f; // [ property ]
88 bool m_bApplyRootMotion = false; // [ property ]
89
90 // Inputs:
91 bool m_bTriggerActive = false;
92 float m_fPlaybackSpeedFactor = 1.0f;
93 plTime m_Duration;
94 plTime m_DurationOfQueued;
95
96 bool WillStateBeOff(bool bTriggerActive) const;
97 void UpdateState(plTime diff);
98 State GetCurrentState() const { return m_State; }
99 float GetWeight() const { return m_fCurWeight; }
100 float GetNormalizedPlaybackPosition() const { return m_fNormalizedPlaybackPosition; }
101 bool HasTransitioned() const { return m_bHasTransitioned; }
102 bool HasLoopedStart() const { return m_bHasLoopedStart; }
103 bool HasLoopedEnd() const { return m_bHasLoopedEnd; }
104 float GetFinalSpeed() const { return m_fPlaybackSpeed * m_fPlaybackSpeedFactor; }
105
106 plResult Serialize(plStreamWriter& inout_stream) const;
107 plResult Deserialize(plStreamReader& inout_stream);
108
109private:
110 void RampWeightUpOrDown(float& inout_fWeight, float fTargetWeight, plTime tDiff) const;
111
112 State m_State = State::Off;
113 float m_fNormalizedPlaybackPosition = 0.0f;
114 bool m_bRequireLoopForRampDown = true;
115 bool m_bHasTransitioned = false;
116 bool m_bHasLoopedStart = false;
117 bool m_bHasLoopedEnd = false;
118 float m_fCurWeight = 0.0f;
119};
120
121PL_DECLARE_REFLECTABLE_TYPE(PL_RENDERERCORE_DLL, plAnimState);
Definition AnimController.h:52
Definition AnimGraph.h:11
Definition AnimGraphInstance.h:15
Base class for all nodes in an plAnimGraphInstance.
Definition AnimGraphNode.h:36
Definition AnimGraphResource.h:33
Definition AnimationClipResource.h:100
This class represents an object inside the world.
Definition GameObject.h:32
This class is optimized to take nearly no memory (sizeof(void*)) and to allow very fast checks whethe...
Definition HashedString.h:25
All classes that should be dynamically reflectable, need to be derived from this base class.
Definition DynamicRTTI.h:86
Definition SkeletonResource.h:47
Interface for binary in (read) streams.
Definition Stream.h:22
Interface for binary out (write) streams.
Definition Stream.h:107
Definition AnimController.h:24
Definition AnimController.h:31
Definition AnimGraphNode.h:69
Structure to describe an instance data type.
Definition InstanceDataAllocator.h:17
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