Skylicht Engine
Loading...
Searching...
No Matches
Skylicht::Particle::CParticleComponent Class Reference

Main component for creating and managing a particle system in Skylicht. More...

#include <ParticleSystem/CParticleComponent.h>

Inheritance diagram for Skylicht::Particle::CParticleComponent:
Skylicht::CComponentSystem Skylicht::IActivatorObject

Public Member Functions

virtual void initComponent ()
 Initializes component data and required ECS systems.
virtual void startComponent ()
 Starts the component, loading the particle source if set.
virtual void updateComponent ()
 Updates the internal frame counter.
virtual CObjectSerializablecreateSerializable ()
 Creates a serializable object for property editing.
virtual void loadSerializable (CObjectSerializable *object)
 Loads properties from a serializable object.
CFactorygetParticleFactory ()
 Gets the internal particle factory.
CParticleBufferDatagetData ()
 Gets the ECS entity data holding particle groups.
void setGroupTransform (const core::matrix4 &world)
 Updates the transform of all particle groups.
CGroupcreateParticleGroup ()
 Creates a new top-level particle group managed by this component.
CSubGroupcreateParticleSubGroup (CGroup *group)
 Creates a sub-group attached to a parent group.
u32 getNumOfGroup ()
 Gets the number of top-level groups.
CGroupgetGroup (int i)
 Retrieves a specific group by index.
void removeParticleGroup (CGroup *group)
 Removes a specific group from the component.
void updateParticleCountByPercentage (float f, bool includeSubGroup=false)
 Dynamically adjusts the emission rate of all emitters.
void Play ()
 Resets all emitters and starts playback.
void Stop ()
 Stops all emitters and clears immortal particles.
bool IsPlaying ()
 Checks if any particle is currently alive.
void clearParticles ()
 Immediately removes all active particles across all groups.
u32 getTotalParticle ()
 Gets the total count of active particles in all groups.
const char * getSourcePath ()
 Gets the current .particle file path.
void setSourcePath (const char *path)
 Sets the .particle file path.
bool load ()
 Loads the particle system configuration from m_sourcePath.
bool save ()
 Saves the current particle system configuration to m_sourcePath.
int getFrameUpdated ()
 Gets the current frame update count.
CGroupduplicateGroup (CGroup *group)
 Clones a particle group.
CEmitterduplicateEmitter (CGroup *group, CEmitter *emitter)
 Clones an emitter within a group.
Public Member Functions inherited from Skylicht::CComponentSystem
const char * getName ()
virtual void reset ()
virtual void endUpdate ()
virtual void onEnable (bool b)
virtual void onUpdateCullingLayer (u32 mask)
void setEnable (bool b)
bool isEnable ()
CGameObject * getGameObject ()
void setEnableSerializable (bool b)
bool isSerializable ()
void addLinkComponent (CComponentSystem *comp)
void removeAllLink ()
Public Member Functions inherited from Skylicht::IActivatorObject
virtual ~IActivatorObject ()
 Virtual destructor for polymorphic activator objects.

Protected Member Functions

void saveGroups (CObjectSerializable *groups)
 Internal serialization helper.
void saveGroup (Particle::CGroup *group, CObjectSerializable *object)
 Internal serialization helper for a specific group.
void loadGroup (Particle::CGroup *group, io::IXMLReader *reader)
 Internal XML loading helper for a specific group.
void loadGroup (Particle::CGroup *group, CObjectSerializable *object)
 Internal serialization loading helper for a specific group.
void loadEmitters (Particle::CGroup *group, io::IXMLReader *reader)
 Internal XML loading helper for emitters.
void loadModels (Particle::CGroup *group, io::IXMLReader *reader)
 Internal XML loading helper for models.
void loadRenderer (Particle::CGroup *group, io::IXMLReader *reader)
 Internal XML loading helper for renderers.
void loadSubGroups (Particle::CGroup *group, io::IXMLReader *reader)
 Internal XML loading helper for sub-groups.
Protected Member Functions inherited from Skylicht::CComponentSystem
void setOwner (CGameObject *obj)

Protected Attributes

CParticleBufferDatam_data
 Cached pointer to the ECS entity data.
CFactory m_factory
 Internal factory for creating particle objects.
std::string m_sourcePath
 Path to the .particle source file.
int m_frameUpdate
 Frame counter for update synchronization.
Protected Attributes inherited from Skylicht::CComponentSystem
CGameObject * m_gameObject
bool m_enable
bool m_serializable
std::vector< CComponentSystem * > m_linkComponent

Additional Inherited Members

Static Public Member Functions inherited from Skylicht::CComponentSystem
static int useComponent (CComponentSystem *used)

Detailed Description

Main component for creating and managing a particle system in Skylicht.

This component integrates the particle engine with the ECS architecture. It manages particle groups, emitters, and zones, and handles serialization to .particle files.

Example

// Create a particle system object
CGameObject *psObj = zone->createEmptyObject();
// Setup a basic group with a quad renderer
group->LifeMin = 1.0f;
group->LifeMax = 2.0f;
renderer->setTexturePath("Particles/Textures/point.png");
group->setRenderer(renderer);
// Setup a random emitter in a sphere zone
Particle::CEmitter *emitter = group->addEmitter(factory->createRandomEmitter());
emitter->setZone(factory->createSphereZone(core::vector3df(0,0,0), 1.0f));
emitter->setFlow(100.0f);
emitter->setForce(0.1f, 0.5f);
Base class for particle emitters.
Definition CEmitter.h:88
void setFlow(float flow)
Sets continuous birth rate (particles per second).
Definition CEmitter.h:213
void setForce(float min, float max)
Sets initial velocity force range.
Definition CEmitter.h:247
CZone * setZone(CZone *z)
Sets the spawn zone.
Definition CEmitter.h:151
Factory class for creating emitters, zones, and renderers.
Definition CFactory.h:61
CRandomEmitter * createRandomEmitter()
Creates a new Random emitter.
CSphere * createSphereZone(const core::vector3df &pos, float radius)
Creates a Sphere zone.
CQuadRenderer * createQuadRenderer()
Creates a GPU instanced quad renderer.
Represents a group of particles with shared settings, emitters, and a renderer.
Definition CGroup.h:132
float LifeMin
Minimum life time for newly born particles.
Definition CGroup.h:171
Main component for creating and managing a particle system in Skylicht.
Definition CParticleComponent.h:66
CFactory * getParticleFactory()
Gets the internal particle factory.
Definition CParticleComponent.h:124
CGroup * createParticleGroup()
Creates a new top-level particle group managed by this component.
Optimized GPU instancing renderer for billboard particles.
Definition CQuadRenderer.h:72
void setTexturePath(const char *path)
Loads and sets the main texture.
vector3d< f32 > vector3df
Typedef for a f32 3d vector.
Definition vector3d.h:445

Member Function Documentation

◆ createParticleGroup()

CGroup * Skylicht::Particle::CParticleComponent::createParticleGroup ( )

Creates a new top-level particle group managed by this component.

Returns
Pointer to the new CGroup.

◆ createParticleSubGroup()

CSubGroup * Skylicht::Particle::CParticleComponent::createParticleSubGroup ( CGroup * group)

Creates a sub-group attached to a parent group.

Parameters
groupThe parent group.
Returns
Pointer to the new CSubGroup.

◆ createSerializable()

virtual CObjectSerializable * Skylicht::Particle::CParticleComponent::createSerializable ( )
virtual

Creates a serializable object for property editing.

Reimplemented from Skylicht::CComponentSystem.

◆ getData()

CParticleBufferData * Skylicht::Particle::CParticleComponent::getData ( )
inline

Gets the ECS entity data holding particle groups.

Returns
Pointer to CParticleBufferData.

◆ getParticleFactory()

CFactory * Skylicht::Particle::CParticleComponent::getParticleFactory ( )
inline

Gets the internal particle factory.

Returns
Pointer to CFactory.

◆ initComponent()

virtual void Skylicht::Particle::CParticleComponent::initComponent ( )
virtual

Initializes component data and required ECS systems.

Implements Skylicht::CComponentSystem.

◆ load()

bool Skylicht::Particle::CParticleComponent::load ( )

Loads the particle system configuration from m_sourcePath.

Returns
True if successful.

◆ loadSerializable()

virtual void Skylicht::Particle::CParticleComponent::loadSerializable ( CObjectSerializable * object)
virtual

Loads properties from a serializable object.

Reimplemented from Skylicht::CComponentSystem.

◆ save()

bool Skylicht::Particle::CParticleComponent::save ( )

Saves the current particle system configuration to m_sourcePath.

Returns
True if successful.

◆ setGroupTransform()

void Skylicht::Particle::CParticleComponent::setGroupTransform ( const core::matrix4 & world)

Updates the transform of all particle groups.

Parameters
worldThe new world matrix.

◆ startComponent()

virtual void Skylicht::Particle::CParticleComponent::startComponent ( )
virtual

Starts the component, loading the particle source if set.

Reimplemented from Skylicht::CComponentSystem.

◆ updateComponent()

virtual void Skylicht::Particle::CParticleComponent::updateComponent ( )
virtual

Updates the internal frame counter.

Implements Skylicht::CComponentSystem.

◆ updateParticleCountByPercentage()

void Skylicht::Particle::CParticleComponent::updateParticleCountByPercentage ( float f,
bool includeSubGroup = false )

Dynamically adjusts the emission rate of all emitters.

Parameters
fScaling factor (0.0 to 1.0).
includeSubGroupWhether to affect sub-groups.

The documentation for this class was generated from the following file: