Plasma Engine  2.0
Loading...
Searching...
No Matches
SubstancePackageAsset.h
1#pragma once
2
3#include <EditorFramework/Assets/SimpleAssetDocument.h>
4#include <Texture/TexConv/TexConvEnums.h>
5
7{
8 using StorageType = plUInt8;
9
10 enum Enum
11 {
12 Unknown,
13
14 BaseColor,
15 Emissive,
16 Height,
17 Metallic,
18 Mask,
19 Normal,
20 Occlusion,
21 Opacity,
22 Roughness,
23
24 Count,
25
26 Default = Unknown
27 };
28};
29
30PL_DECLARE_REFLECTABLE_TYPE(PL_EDITORPLUGINSUBSTANCE_DLL, plSubstanceUsage);
31
32
34{
35 bool m_bEnabled = true;
36 plEnum<plTexConvCompressionMode> m_CompressionMode = plTexConvCompressionMode::High;
38 plEnum<plTexConvMipmapMode> m_MipmapMode;
39 plUInt8 m_uiNumChannels = 1;
40 bool m_bPreserveAlphaCoverage = false;
41 plString m_sName;
42 plString m_sLabel;
43 plUuid m_Uuid;
44
45 bool operator==(const plSubstanceGraphOutput& other) const
46 {
47 return m_bEnabled == other.m_bEnabled &&
48 m_CompressionMode == other.m_CompressionMode &&
49 m_Usage == other.m_Usage &&
50 m_uiNumChannels == other.m_uiNumChannels &&
51 m_MipmapMode == other.m_MipmapMode &&
52 m_bPreserveAlphaCoverage == other.m_bPreserveAlphaCoverage &&
53 m_sName == other.m_sName &&
54 m_sLabel == other.m_sLabel &&
55 m_Uuid == other.m_Uuid;
56 }
57};
58
59PL_DECLARE_REFLECTABLE_TYPE(PL_EDITORPLUGINSUBSTANCE_DLL, plSubstanceGraphOutput);
60
61
63{
64 bool m_bEnabled = true;
65
66 plString m_sName;
67
68 plUInt8 m_uiOutputWidth = 0;
69 plUInt8 m_uiOutputHeight = 0;
70
72
73 bool operator==(const plSubstanceGraph& other) const
74 {
75 return m_bEnabled == other.m_bEnabled &&
76 m_sName == other.m_sName &&
79 m_Outputs == other.m_Outputs;
80 }
81};
82
83PL_DECLARE_REFLECTABLE_TYPE(PL_EDITORPLUGINSUBSTANCE_DLL, plSubstanceGraph);
84
85
87{
88 PL_ADD_DYNAMIC_REFLECTION(plSubstancePackageAssetProperties, plReflectedClass);
89
90public:
92
93 plString m_sSubstancePackage;
94 plString m_sOutputPattern;
95
97};
98
99
101{
102 PL_ADD_DYNAMIC_REFLECTION(plSubstancePackageAssetMetaData, plReflectedClass);
103
104public:
105 plDynamicArray<plUuid> m_OutputUuids;
106 plDynamicArray<plString> m_OutputNames;
107};
108
110
111class plSubstancePackageAssetDocument : public plSimpleAssetDocument<plSubstancePackageAssetProperties>
112{
114
115public:
118
119private:
120 virtual void UpdateAssetDocumentInfo(plAssetDocumentInfo* pInfo) const override;
121 virtual plTransformStatus InternalTransformAsset(plStreamWriter& stream, plStringView sOutputTag, const plPlatformProfile* pAssetProfile, const plAssetFileHeader& AssetHeader, plBitflags<plTransformFlags> transformFlags) override { return plStatus(PL_SUCCESS); }
122 virtual plTransformStatus InternalTransformAsset(const char* szTargetFile, plStringView sOutputTag, const plPlatformProfile* pAssetProfile,
123 const plAssetFileHeader& AssetHeader, plBitflags<plTransformFlags> transformFlags) override;
124
125 void OnPropertyChanged(const plDocumentObjectPropertyEvent& e);
126
127private:
128 plResult GetTempDir(plStringBuilder& out_sTempDir) const;
129 void GenerateOutputName(const plSubstanceGraph& graph, const plSubstanceGraphOutput& graphOutput, plStringBuilder& out_sOutputName) const;
130 plTransformStatus UpdateGraphOutputs(plStringView sAbsolutePath, bool bAllowPropertyModifications);
131 plStatus RunTexConv(const char* szInputFile, const char* szTargetFile, const plAssetFileHeader& assetHeader, const plSubstanceGraphOutput& graphOutput, plStringView sThumbnailFile, const plTextureAssetProfileConfig* pAssetConfig);
132};
Definition AssetDocumentInfo.h:7
Simple class to handle asset file headers (the very first bytes in all transformed asset files)
Definition AssetFileHeader.h:8
Definition DynamicArray.h:81
A hybrid array uses in-place storage to handle the first few elements without any allocation....
Definition HybridArray.h:12
Definition PlatformProfile.h:25
All classes that should be dynamically reflectable, need to be derived from this base class.
Definition DynamicRTTI.h:86
Definition SimpleAssetDocument.h:23
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
Definition SubstancePackageAsset.h:112
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 SubstancePackageAsset.h:121
virtual void UpdateAssetDocumentInfo(plAssetDocumentInfo *pInfo) const override
Override this to add custom data (e.g. additional file dependencies) to the info struct.
Definition SubstancePackageAsset.cpp:511
Definition SubstancePackageAsset.h:101
Definition SubstancePackageAsset.h:87
Definition TextureAssetManager.h:8
This data type is the abstraction for 128-bit Uuid (also known as GUID) instances.
Definition Uuid.h:11
The plBitflags class allows you to work with type-safe bitflags.
Definition Bitflags.h:82
Used by plDocumentObjectManager::m_PropertyEvents.
Definition DocumentObjectManager.h:77
A custom enum implementation that allows to define the underlying storage type to control its memory ...
Definition Enum.h:37
Default enum for returning failure or success, instead of using a bool.
Definition Types.h:54
An plResult with an additional message for the reason of failure.
Definition Status.h:12
Definition SubstancePackageAsset.h:63
plUInt8 m_uiOutputHeight
In base 2.
Definition SubstancePackageAsset.h:69
plUInt8 m_uiOutputWidth
In base 2, e.g. 8 = 2^8 = 256.
Definition SubstancePackageAsset.h:68
Definition SubstancePackageAsset.h:34
Definition SubstancePackageAsset.h:7
Definition Declarations.h:114