Plasma Engine  2.0
Loading...
Searching...
No Matches
SpriteComponent.h
1#pragma once
2
3#include <Core/ResourceManager/ResourceHandle.h>
4#include <Core/World/World.h>
5#include <RendererCore/Components/RenderComponent.h>
6#include <RendererCore/Pipeline/RenderData.h>
7
8struct plMsgSetColor;
10
12{
13 using StorageType = plUInt8;
14
15 enum Enum
16 {
17 Masked,
18 Transparent,
19 Additive,
20 ShapeIcon,
21
22 Default = Masked
23 };
24
25 static plTempHashedString GetPermutationValue(Enum blendMode);
26};
27
28PL_DECLARE_REFLECTABLE_TYPE(PL_RENDERERCORE_DLL, plSpriteBlendMode);
29
30class PL_RENDERERCORE_DLL plSpriteRenderData : public plRenderData
31{
32 PL_ADD_DYNAMIC_REFLECTION(plSpriteRenderData, plRenderData);
33
34public:
35 void FillBatchIdAndSortingKey();
36
38
39 float m_fSize;
40 float m_fMaxScreenSize;
41 float m_fAspectRatio;
42 plEnum<plSpriteBlendMode> m_BlendMode;
43
44 plColor m_color;
45
46 plVec2 m_texCoordScale;
47 plVec2 m_texCoordOffset;
48
49 plUInt32 m_uiUniqueID;
50};
51
53
62class PL_RENDERERCORE_DLL plSpriteComponent : public plRenderComponent
63{
65
67 // plComponent
68
69public:
70 virtual void SerializeComponent(plWorldWriter& inout_stream) const override;
71 virtual void DeserializeComponent(plWorldReader& inout_stream) override;
72
74 // plRenderComponent
75
76public:
77 virtual plResult GetLocalBounds(plBoundingBoxSphere& ref_bounds, bool& ref_bAlwaysVisible, plMsgUpdateLocalBounds& ref_msg) override;
78
80 // plSpriteComponent
81
82public:
85
86 void SetTexture(const plTexture2DResourceHandle& hTexture);
87 const plTexture2DResourceHandle& GetTexture() const;
88
89 void SetTextureFile(const char* szFile); // [ property ]
90 const char* GetTextureFile() const; // [ property ]
91
92 void SetColor(plColor color); // [ property ]
93 plColor GetColor() const; // [ property ]
94
96 void SetSize(float fSize); // [ property ]
97 float GetSize() const; // [ property ]
98
100 void SetMaxScreenSize(float fSize); // [ property ]
101 float GetMaxScreenSize() const; // [ property ]
102
103 void OnMsgSetColor(plMsgSetColor& ref_msg); // [ property ]
104
105private:
106 void OnMsgExtractRenderData(plMsgExtractRenderData& msg) const;
107
108 plTexture2DResourceHandle m_hTexture;
109 plEnum<plSpriteBlendMode> m_BlendMode;
110 plColor m_Color = plColor::White;
111
112 float m_fSize = 1.0f;
113 float m_fMaxScreenSize = 64.0f;
114 float m_fAspectRatio = 1.0f;
115};
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
Definition ComponentManager.h:88
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
Renders a screen-oriented quad (billboard) with a maximum screen size.
Definition SpriteComponent.h:63
Definition SpriteComponent.h:31
A class to use together with plHashedString for quick comparisons with temporary strings that need no...
Definition HashedString.h:151
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
Definition RenderData.h:116
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
Definition SpriteComponent.h:12