Plasma Engine  2.0
Loading...
Searching...
No Matches
PropertyAnimAsset.h
1#pragma once
2
3#include <EditorFramework/Assets/SimpleAssetDocument.h>
4#include <EditorFramework/Document/GameObjectContextDocument.h>
5#include <EditorFramework/Object/ObjectPropertyPath.h>
6#include <EditorPluginAssets/ColorGradientAsset/ColorGradientAsset.h>
7#include <Foundation/Communication/Event.h>
8#include <GameEngine/Animation/PropertyAnimResource.h>
9#include <GuiFoundation/Widgets/CurveEditData.h>
10#include <GuiFoundation/Widgets/EventTrackEditData.h>
11
16
18{
19 PL_ADD_DYNAMIC_REFLECTION(plPropertyAnimationTrack, plReflectedClass);
20
21public:
24 plString m_sPropertyPath;
26
27 plSingleCurveData m_FloatCurve;
28 plColorGradientAssetData m_ColorGradient;
29};
30
32{
33 PL_ADD_DYNAMIC_REFLECTION(plPropertyAnimationTrackGroup, plReflectedClass);
34
35public:
40
41 plUInt32 m_uiFramesPerSecond = 60;
42 plUInt64 m_uiCurveDuration = 480;
45 plEventTrackData m_EventTrack;
46};
47
49{
50 enum class Type
51 {
52 AnimationLengthChanged,
53 ScrubberPositionChanged,
54 PlaybackChanged,
55 };
56
57 const plPropertyAnimAssetDocument* m_pDocument;
58 Type m_Type;
59};
60
61class plPropertyAnimAssetDocument : public plSimpleAssetDocument<plPropertyAnimationTrackGroup, plGameObjectContextDocument>
62{
64 PL_ADD_DYNAMIC_REFLECTION(plPropertyAnimAssetDocument, BaseClass);
65
66public:
69
70 void SetAnimationDurationTicks(plUInt64 uiNumTicks);
71 plUInt64 GetAnimationDurationTicks() const;
72 plTime GetAnimationDurationTime() const;
73 void AdjustDuration();
74
75 bool SetScrubberPosition(plUInt64 uiTick);
76 plUInt64 GetScrubberPosition() const { return m_uiScrubberTickPos; }
77
79
80 void SetPlayAnimation(bool bPlay);
81 bool GetPlayAnimation() const { return m_bPlayAnimation; }
82 void SetRepeatAnimation(bool bRepeat);
83 bool GetRepeatAnimation() const { return m_bRepeatAnimation; }
84 void ExecuteAnimationPlaybackStep();
85
86 const plPropertyAnimationTrack* GetTrack(const plUuid& trackGuid) const;
87 plPropertyAnimationTrack* GetTrack(const plUuid& trackGuid);
88
89 plStatus CanAnimate(const plDocumentObject* pObject, const plAbstractProperty* pProp, plVariant index, plPropertyAnimTarget::Enum target) const;
90
91 plUuid FindTrack(const plDocumentObject* pObject, const plAbstractProperty* pProp, plVariant index, plPropertyAnimTarget::Enum target) const;
92 plUuid CreateTrack(const plDocumentObject* pObject, const plAbstractProperty* pProp, plVariant index, plPropertyAnimTarget::Enum target);
93
94 plUuid FindCurveCp(const plUuid& trackGuid, plInt64 iTickX);
95 plUuid InsertCurveCpAt(const plUuid& trackGuid, plInt64 iTickX, double fNewPosY);
96
97 plUuid FindGradientColorCp(const plUuid& trackGuid, plInt64 iTickX);
98 plUuid InsertGradientColorCpAt(const plUuid& trackGuid, plInt64 iTickX, const plColorGammaUB& color);
99
100 plUuid FindGradientAlphaCp(const plUuid& trackGuid, plInt64 iTickX);
101 plUuid InsertGradientAlphaCpAt(const plUuid& trackGuid, plInt64 iTickX, plUInt8 uiAlpha);
102
103 plUuid FindGradientIntensityCp(const plUuid& trackGuid, plInt64 iTickX);
104 plUuid InsertGradientIntensityCpAt(const plUuid& trackGuid, plInt64 iTickX, float fIntensity);
105
106 plUuid InsertEventTrackCpAt(plInt64 iTickX, const char* szValue);
107
108 virtual plManipulatorSearchStrategy GetManipulatorSearchStrategy() const override
109 {
110 return plManipulatorSearchStrategy::ChildrenOfSelectedObject;
111 }
112
113protected:
114 virtual plTransformStatus InternalTransformAsset(plStreamWriter& stream, plStringView sOutputTag, const plPlatformProfile* pAssetProfile,
115 const plAssetFileHeader& AssetHeader, plBitflags<plTransformFlags> transformFlags) override;
116 virtual void InitializeAfterLoading(bool bFirstTimeCreation) override;
117
118private:
119 void GameObjectContextEventHandler(const plGameObjectContextEvent& e);
120 void TreeStructureEventHandler(const plDocumentObjectStructureEvent& e);
121 void TreePropertyEventHandler(const plDocumentObjectPropertyEvent& e);
122
123 struct PropertyValue
124 {
125 plVariant m_InitialValue;
127 };
128 struct PropertyKeyHash
129 {
130 PL_ALWAYS_INLINE static plUInt32 Hash(const plPropertyReference& key)
131 {
132 return plHashingUtils::xxHash32(&key.m_Object, sizeof(plUuid)) + plHashingUtils::xxHash32(&key.m_pProperty, sizeof(const plAbstractProperty*)) +
133 (plUInt32)key.m_Index.ComputeHash();
134 }
135
136 PL_ALWAYS_INLINE static bool Equal(const plPropertyReference& a, const plPropertyReference& b)
137 {
138 return a.m_Object == b.m_Object && a.m_pProperty == b.m_pProperty && a.m_Index == b.m_Index;
139 }
140 };
141
142 void RebuildMapping();
143 void RemoveTrack(const plUuid& track);
144 void AddTrack(const plUuid& track);
145 plStatus FindTrackKeys(
146 const char* szObjectSearchSequence, const char* szComponentType, const char* szPropertyPath, plHybridArray<plPropertyReference, 1>& keys) const;
147 void GenerateTrackInfo(const plDocumentObject* pObject, const plAbstractProperty* pProp, plVariant index, plStringBuilder& sObjectSearchSequence,
148 plStringBuilder& sComponentType, plStringBuilder& sPropertyPath) const;
149 void ApplyAnimation();
150 void ApplyAnimation(const plPropertyReference& key, const PropertyValue& value);
151
154
155 bool m_bPlayAnimation = false;
156 bool m_bRepeatAnimation = false;
157 plTime m_LastFrameTime;
158 plUInt64 m_uiScrubberTickPos = 0;
159};
This is the base interface for all properties in the reflection system. It provides enough informatio...
Definition AbstractProperty.h:150
Simple class to handle asset file headers (the very first bytes in all transformed asset files)
Definition AssetFileHeader.h:8
A 8bit per channel unsigned normalized (values interpreted as 0-1) color storage format that represen...
Definition Color8UNorm.h:99
Definition ColorGradientAsset.h:49
Definition DocumentObjectBase.h:11
Definition DynamicArray.h:81
Definition Event.h:177
Definition EventTrackEditData.h:25
Definition HashTable.h:333
static plUInt32 xxHash32(const void *pKey, size_t uiSizeInByte, plUInt32 uiSeed=0)
Calculates the 32bit xxHash of the given key.
Definition HashingUtils.cpp:209
A hybrid array uses in-place storage to handle the first few elements without any allocation....
Definition HybridArray.h:12
Definition PlatformProfile.h:25
Definition PropertyAnimAsset.h:62
virtual plManipulatorSearchStrategy GetManipulatorSearchStrategy() const override
Needed by plManipulatorManager to know where to look for the manipulator attributes.
Definition PropertyAnimAsset.h:108
virtual plTransformStatus InternalTransformAsset(plStreamWriter &stream, plStringView sOutputTag, const plPlatformProfile *pAssetProfile, const plAssetFileHeader &AssetHeader, plBitflags< plTransformFlags > transformFlags) override
Override this and write the transformed file for the given szOutputTag into the given stream.
Definition PropertyAnimAsset.cpp:164
Definition PropertyAnimObjectAccessor.h:8
Definition PropertyAnimAsset.h:32
Definition PropertyAnimAsset.h:18
plString m_sObjectSearchSequence
Sequence of named objects to search for the target.
Definition PropertyAnimAsset.h:22
plString m_sComponentType
Empty to reference the game object properties (position etc.)
Definition PropertyAnimAsset.h:23
All classes that should be dynamically reflectable, need to be derived from this base class.
Definition DynamicRTTI.h:86
Definition SimpleAssetDocument.h:23
Definition CurveEditData.h:82
Interface for binary out (write) streams.
Definition Stream.h:107
plStringBuilder is a class that is meant for creating and modifying strings.
Definition StringBuilder.h:35
plStringView represent a read-only sub-string of a larger string, as it can store a dedicated string ...
Definition StringView.h:34
This data type is the abstraction for 128-bit Uuid (also known as GUID) instances.
Definition Uuid.h:11
plVariant is a class that can store different types of variables, which is useful in situations where...
Definition Variant.h:44
plUInt64 ComputeHash(plUInt64 uiSeed=0) const
Computes the hash value of the stored data. Returns uiSeed (unchanged) for an invalid Variant.
Definition Variant.cpp:532
The plBitflags class allows you to work with type-safe bitflags.
Definition Bitflags.h:82
Definition CommandHistory.h:31
Used by plDocumentObjectManager::m_PropertyEvents.
Definition DocumentObjectManager.h:77
Used by plDocumentObjectManager::m_StructureEvents.
Definition DocumentObjectManager.h:45
A custom enum implementation that allows to define the underlying storage type to control its memory ...
Definition Enum.h:37
Definition GameObjectContextDocument.h:7
Definition PropertyAnimAsset.h:49
Enum
Definition PropertyAnimResource.h:16
Definition ObjectPropertyPath.h:17
An plResult with an additional message for the reason of failure.
Definition Status.h:12
The time class encapsulates a double value storing the time in seconds.
Definition Time.h:12
Definition Declarations.h:114