Skylicht Engine
Loading...
Searching...
No Matches
IRenderer.h
1/*
2!@
3MIT License
4
5Copyright (c) 2020 Skylicht Technology CO., LTD
6
7Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
8(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify,
9merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
10subject to the following conditions:
11
12The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19
20This file is part of the "Skylicht Engine".
21https://github.com/skylicht-lab/skylicht-engine
22!#
23*/
24
25#pragma once
26
27#include "ComponentsConfig.h"
28#include "Material/CMaterial.h"
29#include "ParticleSystem/Particles/CParticleSerializable.h"
30
31namespace Skylicht
32{
33 namespace Particle
34 {
41 {
42 Quad,
43 CPURenderer,
44 MeshInstancing
45 };
46
53 class COMPONENT_API IRenderer : public CParticleSerializable
54 {
55 protected:
58
63
71 bool m_ztest;
74
76 std::string m_texturePath;
77
82
84 std::string m_materialPath;
85
88
89 public:
91 float SizeX;
93 float SizeY;
95 float SizeZ;
96
97 public:
98 IRenderer(ERenderer type);
99
100 virtual ~IRenderer();
101
104 {
105 return m_type;
106 }
107
110
113 {
114 return m_material;
115 }
116
119 {
120 return m_customMaterial;
121 }
122
124 void setTexturePath(const char* path);
125
127 void setTexture(int slot, ITexture* texture);
128
130 inline void setEmission(bool b)
131 {
132 m_emission = b;
133 }
134
136 inline bool isEmission()
137 {
138 return m_emission;
139 }
140
142 inline bool useInstancing()
143 {
144 return m_useInstancing;
145 }
146
148 inline void setEmissionIntensity(float b)
149 {
151 }
152
154 inline float getEmissionIntensity()
155 {
156 return m_emissionIntensity;
157 }
158
160 inline bool needUpdateMesh()
161 {
162 return m_needUpdateMesh;
163 }
164
166 inline const wchar_t* getName()
167 {
168 if (m_type == Quad)
169 return L"Quad (Instancing)";
170 else if (m_type == MeshInstancing)
171 return L"Mesh (Instancing)";
172 else
173 return L"CPU Renderer";
174 }
175
177
179
181 virtual void getParticleBuffer(IMeshBuffer* buffer) = 0;
182
184 void setAtlas(u32 x, u32 y);
185
187 inline u32 getAtlasX()
188 {
189 return m_atlasNx;
190 }
191
193 inline u32 getAtlasY()
194 {
195 return m_atlasNy;
196 }
197
200 {
201 return m_atlasNx * m_atlasNy;
202 }
203
205 inline float getFrameWidth()
206 {
207 return 1.0f / m_atlasNx;
208 }
209
211 inline float getFrameHeight()
212 {
213 return 1.0f / m_atlasNy;
214 }
215 };
216 }
217}
The object class describes material information such as which shader it's associated with,...
Definition CMaterial.h:84
Definition CObjectSerializable.h:36
u32 getAtlasX()
Gets atlas column count.
Definition IRenderer.h:187
bool isEmission()
Checks emission status.
Definition IRenderer.h:136
bool m_useInstancing
Whether this renderer uses hardware instancing.
Definition IRenderer.h:67
bool needUpdateMesh()
Checks if internal mesh requires rebuilding.
Definition IRenderer.h:160
CMaterial * getMaterial()
Gets active material (custom or default).
float getFrameWidth()
Gets UV width of a single frame.
Definition IRenderer.h:205
void setEmissionIntensity(float b)
Sets emission intensity.
Definition IRenderer.h:148
u32 getAtlasY()
Gets atlas row count.
Definition IRenderer.h:193
void setTexture(int slot, ITexture *texture)
Sets texture for a specific slot.
bool m_emission
Whether the particles have emission.
Definition IRenderer.h:69
CMaterial * getDefaultMaterial()
Gets default internal material.
Definition IRenderer.h:112
const wchar_t * getName()
Gets display name.
Definition IRenderer.h:166
std::string m_materialPath
Path to custom material file.
Definition IRenderer.h:84
float getFrameHeight()
Gets UV height of a single frame.
Definition IRenderer.h:211
virtual void getParticleBuffer(IMeshBuffer *buffer)=0
Implementation: fills the mesh buffer with renderer-specific geometry.
ERenderer m_type
Type of the renderer.
Definition IRenderer.h:57
CMaterial * m_customMaterial
Optional custom material.
Definition IRenderer.h:62
CMaterial * m_material
Default material for the particles.
Definition IRenderer.h:60
std::string m_texturePath
Primary texture path.
Definition IRenderer.h:76
bool m_useCustomMaterial
Whether custom material is enabled.
Definition IRenderer.h:65
void setEmission(bool b)
Enables/disables emission.
Definition IRenderer.h:130
float getEmissionIntensity()
Gets emission intensity.
Definition IRenderer.h:154
bool m_ztest
Depth test flag.
Definition IRenderer.h:71
bool m_needUpdateMesh
Internal: flag to trigger mesh buffer updates.
Definition IRenderer.h:87
u32 m_atlasNy
Atlas vertical frame count.
Definition IRenderer.h:81
u32 m_atlasNx
Atlas horizontal frame count.
Definition IRenderer.h:79
u32 getTotalFrames()
Gets total frames in atlas.
Definition IRenderer.h:199
float m_emissionIntensity
Emission intensity multiplier.
Definition IRenderer.h:73
virtual CObjectSerializable * createSerializable()
Creates a serializable object for property editing or saving.
void setTexturePath(const char *path)
Loads and sets the main texture.
bool useInstancing()
Checks instancing support.
Definition IRenderer.h:142
float SizeX
Default base scale X.
Definition IRenderer.h:91
float SizeZ
Default base scale Z.
Definition IRenderer.h:95
virtual void loadSerializable(CObjectSerializable *object)
Loads properties from a serializable object.
void setAtlas(u32 x, u32 y)
Configures texture atlas dimensions.
float SizeY
Default base scale Y.
Definition IRenderer.h:93
CMaterial * getCustomMaterial()
Gets custom material if set.
Definition IRenderer.h:118
ERenderer getType()
Gets renderer type enum.
Definition IRenderer.h:103
Struct for holding a mesh with a single material.
Definition IMeshBuffer.h:42
Interface of a Video Driver dependent Texture.
Definition ITexture.h:119
ERenderer
Available particle renderer types.
Definition IRenderer.h:41
Everything in the Skylicht Engine. You can start by looking at the topics.
Definition AudioDebugLog.h:29
unsigned int u32
32 bit unsigned variable.
Definition irrTypes.h:58