Plasma Engine  2.0
Loading...
Searching...
No Matches
DecalComponent.h
1#pragma once
2
3#include <Foundation/Math/Color16f.h>
4#include <Foundation/Types/VarianceTypes.h>
5#include <RendererCore/Components/RenderComponent.h>
6#include <RendererCore/Declarations.h>
7#include <RendererCore/Pipeline/RenderData.h>
8
12struct plMsgSetColor;
13
14class PL_RENDERERCORE_DLL plDecalComponentManager final : public plComponentManager<class plDecalComponent, plBlockStorageType::Compact>
15{
16public:
18
19 virtual void Initialize() override;
20
21private:
22 friend class plDecalComponent;
23 plDecalAtlasResourceHandle m_hDecalAtlas;
24};
25
26class PL_RENDERERCORE_DLL plDecalRenderData : public plRenderData
27{
28 PL_ADD_DYNAMIC_REFLECTION(plDecalRenderData, plRenderData);
29
30public:
31 plUInt32 m_uiApplyOnlyToId;
32 plUInt32 m_uiFlags;
33 plUInt32 m_uiAngleFadeParams;
34
35 plColorLinearUB m_BaseColor;
36 plColorLinear16f m_EmissiveColor;
37
38 plUInt32 m_uiBaseColorAtlasScale;
39 plUInt32 m_uiBaseColorAtlasOffset;
40
41 plUInt32 m_uiNormalAtlasScale;
42 plUInt32 m_uiNormalAtlasOffset;
43
44 plUInt32 m_uiORMAtlasScale;
45 plUInt32 m_uiORMAtlasOffset;
46};
47
54class PL_RENDERERCORE_DLL plDecalComponent final : public plRenderComponent
55{
57
59 // plComponent
60
61public:
62 virtual void SerializeComponent(plWorldWriter& inout_stream) const override;
63 virtual void DeserializeComponent(plWorldReader& inout_stream) override;
64
65protected:
66 virtual void OnSimulationStarted() override;
67 virtual void OnActivated() override;
68
70 // plRenderComponent
71
72protected:
73 virtual plResult GetLocalBounds(plBoundingBoxSphere& bounds, bool& bAlwaysVisible, plMsgUpdateLocalBounds& msg) override;
74 void OnMsgExtractRenderData(plMsgExtractRenderData& msg) const;
75
76
78 // plDecalComponent
79
80public:
83
85 void SetExtents(const plVec3& value); // [ property ]
86 const plVec3& GetExtents() const; // [ property ]
87
89 void SetSizeVariance(float fVariance); // [ property ]
90 float GetSizeVariance() const; // [ property ]
91
93 void SetColor(plColorGammaUB color); // [ property ]
94 plColorGammaUB GetColor() const; // [ property ]
95
97 void SetEmissiveColor(plColor color); // [ property ]
98 plColor GetEmissiveColor() const; // [ property ]
99
101 void SetInnerFadeAngle(plAngle fadeAngle); // [ property ]
102 plAngle GetInnerFadeAngle() const; // [ property ]
103
105 void SetOuterFadeAngle(plAngle fadeAngle); // [ property ]
106 plAngle GetOuterFadeAngle() const; // [ property ]
107
109 void SetSortOrder(float fOrder); // [ property ]
110 float GetSortOrder() const; // [ property ]
111
113 void SetWrapAround(bool bWrapAround); // [ property ]
114 bool GetWrapAround() const; // [ property ]
115
116 void SetMapNormalToGeometry(bool bMapNormal); // [ property ]
117 bool GetMapNormalToGeometry() const; // [ property ]
118
122 void SetDecal(plUInt32 uiIndex, const plDecalResourceHandle& hResource); // [ property ]
123 const plDecalResourceHandle& GetDecal(plUInt32 uiIndex) const; // [ property ]
124
127
129 plTime m_FadeOutDuration; // [ property ]
130
133
135 void SetProjectionAxis(plEnum<plBasisAxis> projectionAxis); // [ property ]
136 plEnum<plBasisAxis> GetProjectionAxis() const; // [ property ]
137
142 void SetApplyOnlyTo(plGameObjectHandle hObject);
143 plGameObjectHandle GetApplyOnlyTo() const;
144
145 plUInt32 DecalFile_GetCount() const; // [ property ]
146 const char* DecalFile_Get(plUInt32 uiIndex) const; // [ property ]
147 void DecalFile_Set(plUInt32 uiIndex, const char* szFile); // [ property ]
148 void DecalFile_Insert(plUInt32 uiIndex, const char* szFile); // [ property ]
149 void DecalFile_Remove(plUInt32 uiIndex); // [ property ]
150
151
152protected:
153 void SetApplyToRef(const char* szReference); // [ property ]
154 void UpdateApplyTo();
155
156 void OnTriggered(plMsgComponentInternalTrigger& msg);
157 void OnMsgDeleteGameObject(plMsgDeleteGameObject& msg);
158 void OnMsgOnlyApplyToObject(plMsgOnlyApplyToObject& msg);
159 void OnMsgSetColor(plMsgSetColor& msg);
160
161 plVec3 m_vExtents = plVec3(1.0f);
162 float m_fSizeVariance = 0;
164 plColor m_EmissiveColor = plColor::Black;
165 plAngle m_InnerFadeAngle = plAngle::MakeFromDegree(50.0f);
166 plAngle m_OuterFadeAngle = plAngle::MakeFromDegree(80.0f);
167 float m_fSortOrder = 0;
168 bool m_bWrapAround = false;
169 bool m_bMapNormalToGeometry = false;
170 plUInt8 m_uiRandomDecalIdx = 0xFF;
171 plEnum<plBasisAxis> m_ProjectionAxis;
173
174 plGameObjectHandle m_hApplyOnlyToObject;
175 plUInt32 m_uiApplyOnlyToId = 0;
176
177 plTime m_StartFadeOutTime;
178 plUInt32 m_uiInternalSortKey = 0;
179
180private:
181 const char* DummyGetter() const { return nullptr; }
182};
Definition AbstractObjectGraph.h:17
Float wrapper struct for a safe usage and conversions of angles.
Definition Angle.h:10
static constexpr plAngle MakeFromDegree(float fDegree)
Creates an instance of plAngle that was initialized from degree. (Performs a conversion)
Definition Angle_inl.h:33
A 8bit per channel unsigned normalized (values interpreted as 0-1) color storage format that represen...
Definition Color8UNorm.h:99
plColor represents an RGBA color in linear color space. Values are stored as float,...
Definition Color.h:44
static const plColor White
#FFFFFF
Definition Color.h:194
static const plColor Black
#000000
Definition Color.h:57
A 16bit per channel float color storage format.
Definition Color16f.h:11
A 8bit per channel unsigned normalized (values interpreted as 0-1) color storage format that represen...
Definition Color8UNorm.h:61
Definition ComponentManager.h:88
Projects a decal texture onto geometry within a box volume.
Definition DecalComponent.h:55
plTime m_FadeOutDuration
How much time the fade out takes.
Definition DecalComponent.h:129
plEnum< plOnComponentFinishedAction > m_OnFinishedAction
If fade-out is used, the decal may delete itself afterwards.
Definition DecalComponent.h:132
plVarianceTypeTime m_FadeOutDelay
If non-zero, the decal fades out after this time and then vanishes.
Definition DecalComponent.h:126
Definition DecalComponent.h:15
Definition DecalComponent.h:27
A hybrid array uses in-place storage to handle the first few elements without any allocation....
Definition HybridArray.h:12
Base class for objects that should be rendered.
Definition RenderComponent.h:9
Base class for all render data. Render data must contain all information that is needed to render the...
Definition RenderData.h:14
A world encapsulates a scene graph of game objects and various component managers and their component...
Definition World.h:22
virtual void OnSimulationStarted()
This method is called at the start of the next world update when the world is simulated....
Definition WorldModule.h:105
virtual void Initialize()
This method is called after the constructor. A derived type can override this method to do initializa...
Definition WorldModule.h:98
Reads a world description from a stream. Allows to instantiate that world multiple times in different...
Definition WorldReader.h:47
Stores an entire plWorld in a stream.
Definition WorldWriter.h:13
A custom enum implementation that allows to define the underlying storage type to control its memory ...
Definition Enum.h:37
A handle to a game object.
Definition Declarations.h:76
For internal use by components to trigger some known behavior. Usually components will post this mess...
Definition TriggerMessage.h:26
Definition DeleteObjectMessage.h:7
Definition RenderData.h:116
Definition ApplyOnlyToMessage.h:7
A message to modify the main color of some thing.
Definition SetColorMessage.h:32
Definition UpdateLocalBoundsMessage.h:9
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
Definition VarianceTypes.h:49