Skylicht Engine
Loading...
Searching...
No Matches
CMeshParticleRenderer.h
1/*
2!@
3MIT License
4
5Copyright (c) 2025 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 "IRenderer.h"
28#include "RenderMesh/CMesh.h"
29
30namespace Skylicht
31{
32 namespace Particle
33 {
47 class COMPONENT_API CMeshParticleRenderer : public IRenderer
48 {
49 public:
61
62 protected:
64 std::string m_meshFile;
65
68
71
78
81
82 public:
83 CMeshParticleRenderer();
84
85 virtual ~CMeshParticleRenderer();
86
88 virtual void getParticleBuffer(IMeshBuffer* buffer);
89
91
93
94 DECLARE_GETTYPENAME(CMeshParticleRenderer)
95
96
97 bool loadMesh(const char* meshFile);
98
101
104
106 inline const SColor& getDissolveColor()
107 {
108 return m_dissolveColor;
109 }
110
112 inline void setDissolveColor(const SColor& c)
113 {
114 m_dissolveColor = c;
115 }
116
119 {
120 return m_noiseScale;
121 }
122
124 inline void setNoiseScale(const core::vector3df& n)
125 {
126 m_noiseScale = n;
127 }
128
130 inline float getDissolveCutoff()
131 {
132 return m_dissolve;
133 }
134
136 inline void setDissolveCutoff(float d)
137 {
138 m_dissolve = d;
139 }
140
141 protected:
142
145
147 void addMesh(const core::matrix4& transform, CMesh* mesh);
148
149 };
150 }
151}
This object class is created to store data in an array of multiple CEntities.
Definition CEntityPrefab.h:38
Definition CMesh.h:75
Definition CObjectSerializable.h:36
virtual void loadSerializable(CObjectSerializable *object)
Loads properties from a serializable object.
EBaseShaderType m_baseShaderType
Current shader mode.
Definition CMeshParticleRenderer.h:70
virtual CObjectSerializable * createSerializable()
Creates a serializable object for property editing or saving.
float m_dissolve
Cutoff value for dissolve effect.
Definition CMeshParticleRenderer.h:77
bool m_velocityDirection
Whether to align mesh Z-axis to particle velocity.
Definition CMeshParticleRenderer.h:80
void initFromPrefab(CEntityPrefab *prefab)
Internal: extracts static meshes from a prefab.
virtual void getParticleBuffer(IMeshBuffer *buffer)
Internal: merges prefab meshes into a single buffer.
void setDissolveCutoff(float d)
Sets dissolve progression (0.0 to 1.0).
Definition CMeshParticleRenderer.h:136
bool loadMesh(const char *meshFile)
Loads a 3D model (FBX, DAE, OBJ) to be used as a particle.
core::vector3df & getNoiseScale()
Gets dissolve noise scale.
Definition CMeshParticleRenderer.h:118
IMeshBuffer * m_meshBuffer
Aggregated mesh buffer for instancing.
Definition CMeshParticleRenderer.h:67
float getDissolveCutoff()
Gets current dissolve progression.
Definition CMeshParticleRenderer.h:130
std::string m_meshFile
Path to the source mesh file.
Definition CMeshParticleRenderer.h:64
void addMesh(const core::matrix4 &transform, CMesh *mesh)
Internal: adds a transformed mesh to the instancing buffer.
void setDissolveColor(const SColor &c)
Sets dissolve edge color.
Definition CMeshParticleRenderer.h:112
const SColor & getDissolveColor()
Gets dissolve edge color.
Definition CMeshParticleRenderer.h:106
void setVelocityDirection(bool b)
Enables/disables velocity-based orientation.
core::vector3df m_noiseScale
Scale for dissolve noise effect.
Definition CMeshParticleRenderer.h:73
void setNoiseScale(const core::vector3df &n)
Sets dissolve noise scale.
Definition CMeshParticleRenderer.h:124
void setMaterialType(EBaseShaderType shader)
Configures blending mode and shader.
SColor m_dissolveColor
Edge color for dissolve effect.
Definition CMeshParticleRenderer.h:75
EBaseShaderType
Blending modes for mesh particles.
Definition CMeshParticleRenderer.h:55
@ Additive
Definition CMeshParticleRenderer.h:58
@ SoildColor
Definition CMeshParticleRenderer.h:57
@ Soild
Definition CMeshParticleRenderer.h:56
@ Transparent
Definition CMeshParticleRenderer.h:59
Struct for holding a mesh with a single material.
Definition IMeshBuffer.h:42
Class representing a 32 bit ARGB color.
Definition SColor.h:285
Everything in the Skylicht Engine. You can start by looking at the topics.
Definition AudioDebugLog.h:29
vector3d< f32 > vector3df
Typedef for a f32 3d vector.
Definition vector3d.h:445
CMatrix4< f32 > matrix4
Typedef for f32 matrix.
Definition matrix4.h:2241