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

Represents a group of particles with shared settings, emitters, and a renderer. More...

#include <ParticleSystem/Particles/CGroup.h>

Inheritance diagram for Skylicht::Particle::CGroup:
Skylicht::Particle::CParticleSerializable Skylicht::Particle::CSubGroup

Public Member Functions

void clearParticles ()
 Clears all active particles.
void clearImmortalParticles ()
 Clears only immortal particles.
void update ()
 Main update loop for particle physics and lifecycle.
void updateForRenderer ()
 Updates buffers for rendering.
void setGravityRotation (const core::vector3df &euler)
 Sets gravity direction using euler rotation.
void setParticleRotation (const core::vector3df &euler)
 Sets particle orientation using euler rotation.
void setParentWorldMatrix (const core::matrix4 &m)
 Sets the parent entity's world matrix.
void setWorldMatrix (const core::matrix4 &m)
 Sets the local-to-world transform of this group.
const core::matrix4getWorld ()
 Gets the world matrix of this group.
virtual core::vector3df getTransformPosition (const core::vector3df &pos)
 Transforms a position from local group space to world space.
virtual core::vector3df getTransformVector (const core::vector3df &vec)
 Transforms a vector (rotation only) from local group space to world space.
const core::aabbox3dfgetBBox ()
 Gets the bounding box of all active particles.
u32 getNumParticles ()
 Gets current particle count.
CParticlegetParticlePointer ()
 Gets raw pointer to particle array.
CEmitteraddEmitter (CEmitter *e)
 Adds an emitter to the group.
std::vector< CEmitter * > & getEmitters ()
 Gets all emitters.
void removeEmitter (CEmitter *e)
 Removes an emitter.
void addCallback (IParticleCallback *cb)
 Adds a lifecycle callback.
void removeCallback (IParticleCallback *cb)
 Removes a lifecycle callback.
std::vector< IParticleCallback * > & getCallback ()
 Gets all callbacks.
void addSystem (ISystem *s)
 Adds a custom system to process particles.
std::vector< ISystem * > & getSystems ()
 Gets all systems.
void removeSystem (ISystem *s)
 Removes a system.
int addParticle (u32 emiterID, const core::vector3df &position, const core::vector3df &subEmitterDirection)
 Manually spawns a particle using an emitter index.
int addParticleVelocity (u32 emiterID, const core::vector3df &position, const core::vector3df &velocity)
 Manually spawns a particle with initial velocity using an emitter index.
int addParticleByEmitter (CEmitter *emitter, const core::vector3df &position, const core::vector3df &subEmitterDirection)
 Manually spawns a particle using a pointer to an emitter.
int addParticleVelocityByEmitter (CEmitter *emitter, const core::vector3df &position, const core::vector3df &velocity)
 Manually spawns a particle with initial velocity using a pointer to an emitter.
IRenderersetRenderer (IRenderer *r)
 Assigns a renderer to this group.
IRenderergetRenderer ()
 Gets the current renderer.
CParticleInstancinggetIntancing ()
 Internal: gets instancing buffer.
CParticleCPUBuffergetParticleBuffer ()
 Internal: gets CPU mesh buffer.
u32 getCurrentParticleCount ()
 Gets current particle count.
CModelcreateModel (const std::wstring &attributeName)
 Creates or retrieves a model for a specific parameter name.
CModelcreateModel (EParticleParams param)
 Creates or retrieves a model for a specific parameter type.
CModelgetModel (EParticleParams param)
 Finds a model for a parameter type.
void deleteModel (EParticleParams param)
 Deletes a model.
std::vector< CModel * > & getModels ()
 Gets all models.
CInterpolatorcreateInterpolator ()
 Creates a new interpolator.
void deleteInterpolator (CInterpolator *interpolator)
 Deletes an interpolator.
std::vector< CInterpolator * > & getInterpolators ()
 Gets all interpolators.
core::array< CParticle > & getParticles ()
 Gets raw access to particle list.
int getFrameUpdate ()
 Gets last frame index update.
void updateFrame (int frame)
 Syncs frame count.
virtual CObjectSerializablecreateSerializable ()
 Creates a serializable object for property editing or saving.
virtual void loadSerializable (CObjectSerializable *object)
 Loads properties from a serializable object.

Public Attributes

float Friction
 Global friction for all particles in this group.
float LifeMin
 Minimum life time for newly born particles.
float LifeMax
 Maximum life time for newly born particles.
bool Immortal
 If true, particles do not die from age.
float GravityValue
 Gravity magnitude.
core::vector3df GravityRotation
 Gravity rotation (euler angles).
core::vector3df ParticleRotation
 Global rotation for all particles.
core::vector3df Gravity
 Calculated gravity vector.
core::vector3df OrientationNormal
 Custom orientation normal for fixed billboarding.
core::vector3df OrientationUp
 Custom orientation up vector for fixed billboarding.
bool UseOrientationAsBillboard
 Whether to use custom orientation instead of camera billboard.
std::wstring Name
 Friendly name of the group.
bool Visible
 Visibility flag.
bool Optimized
 If true, uses optimized particle swap on deletion (may affect sorting).

Protected Member Functions

virtual void updateLaunchEmitter ()
virtual void bornParticle ()
virtual bool launchParticle (CParticle &p, SLaunchParticle &launch)
void initParticleModel (CParticle &p)
void initParticleLifeTime (CParticle &p)
CParticlecreate (u32 num)
void remove (u32 i)

Protected Attributes

core::array< CParticlem_particles
 Active particles in this group.
core::array< SLaunchParticlem_launch
 Buffer of particles to be launched in the current frame.
std::vector< CEmitter * > m_emitters
 List of emitters assigned to this group.
std::vector< ISystem * > m_systems
 Custom update systems affecting this group's particles.
std::vector< CModel * > m_models
 Models defining parameter animation (e.g. ColorA over life).
std::vector< CInterpolator * > m_interpolators
 Interpolators shared by models.
CParticleSystemm_particleSystem
 Core particle movement and lifecycle system.
CParticleInstancingSystemm_instancingSystem
 Internal system for GPU instancing updates.
CParticleCPUBufferSystemm_cpuBufferSystem
 Internal system for CPU buffer updates.
IRendererm_renderer
 The renderer used to draw this group.
CParticleInstancingm_instancing
 Buffer for GPU instancing data.
CParticleCPUBufferm_cpuBuffer
 Buffer for CPU rendering data.
std::vector< IParticleCallback * > m_callback
 Callbacks for particle lifecycle events.
core::matrix4 m_parentWorld
core::matrix4 m_world
core::aabbox3df m_bbox
int m_frameUpdate

Detailed Description

Represents a group of particles with shared settings, emitters, and a renderer.

Groups manage the lifecycle of particles, their properties (life, friction, gravity), and the systems that affect them.

Example

Particle::CGroup *group = ps->createParticleGroup();
group->LifeMin = 0.5f;
group->LifeMax = 1.0f;
group->Gravity.set(0.0f, -10.0f, 0.0f);
group->Friction = 0.5f;
// Setup color over life
group->createModel(Particle::ColorA)->setStart(1.0f)->setEnd(0.0f);
Represents a group of particles with shared settings, emitters, and a renderer.
Definition CGroup.h:132
float Friction
Global friction for all particles in this group.
Definition CGroup.h:169
float LifeMin
Minimum life time for newly born particles.
Definition CGroup.h:171
core::vector3df Gravity
Calculated gravity vector.
Definition CGroup.h:185
float LifeMax
Maximum life time for newly born particles.
Definition CGroup.h:173
CModel * createModel(const std::wstring &attributeName)
Creates or retrieves a model for a specific parameter name.
CModel * setEnd(float f)
Sets fixed end value.
Definition CModel.h:112
CModel * setStart(float f)
Sets fixed start value.
Definition CModel.h:94

Member Function Documentation

◆ bornParticle()

virtual void Skylicht::Particle::CGroup::bornParticle ( )
protectedvirtual

Reimplemented in Skylicht::Particle::CSubGroup.

◆ createSerializable()

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

Creates a serializable object for property editing or saving.

Returns
Pointer to a new CObjectSerializable instance.

Reimplemented from Skylicht::Particle::CParticleSerializable.

Reimplemented in Skylicht::Particle::CSubGroup.

◆ getTransformPosition()

virtual core::vector3df Skylicht::Particle::CGroup::getTransformPosition ( const core::vector3df & pos)
virtual

Transforms a position from local group space to world space.

Reimplemented in Skylicht::Particle::CSubGroup.

◆ getTransformVector()

virtual core::vector3df Skylicht::Particle::CGroup::getTransformVector ( const core::vector3df & vec)
virtual

Transforms a vector (rotation only) from local group space to world space.

Reimplemented in Skylicht::Particle::CSubGroup.

◆ loadSerializable()

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

Loads properties from a serializable object.

Parameters
objectThe serializable data to load.

Reimplemented from Skylicht::Particle::CParticleSerializable.

Reimplemented in Skylicht::Particle::CSubGroup.

◆ updateLaunchEmitter()

virtual void Skylicht::Particle::CGroup::updateLaunchEmitter ( )
protectedvirtual

Reimplemented in Skylicht::Particle::CSubGroup.


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