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

A particle group that spawns particles from the positions of particles in a parent group. More...

#include <ParticleSystem/Particles/CSubGroup.h>

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

Public Member Functions

 CSubGroup (CGroup *group)
void initParticles ()
 Initializes internal born data for all emitters based on current parent particles.
virtual void OnParticleBorn (CParticle &p)
 Callback when a parent particle is born.
virtual void OnParticleDead (CParticle &p)
 Callback when a parent particle dies.
virtual void OnSwapParticleData (CParticle &p1, CParticle &p2)
 Callback when parent particle data is swapped in the array.
virtual void OnGroupDestroy ()
 Callback when the parent group is destroyed.
virtual void updateLaunchEmitter ()
 Internal: updates launch emitters based on parent particles.
virtual void bornParticle ()
 Internal: spawns new particles at parent positions.
virtual core::vector3df getTransformPosition (const core::vector3df &pos)
 Transforms position from parent local space to world space.
virtual core::vector3df getTransformVector (const core::vector3df &vec)
 Transforms vector from parent local space to world space.
void setFollowParentTransform (bool b)
 Enables/disables following the parent's movement.
void setEmitterWorldOrientation (bool b)
 Sets emitter orientation mode.
void syncParentParams (bool life, bool color)
 Configures synchronization of life and color from parent.
CGroup * getParentGroup ()
 Gets the parent group.
virtual CObjectSerializablecreateSerializable ()
 Creates a serializable object for property editing or saving.
virtual void loadSerializable (CObjectSerializable *object)
 Loads properties from a serializable object.
Public Member Functions inherited from Skylicht::Particle::CGroup
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.
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.
Public Member Functions inherited from Skylicht::Particle::IParticleCallback
virtual void OnParticleUpdate (CParticle *particles, int num, CGroup *group, float dt)

Protected Attributes

CGroup * m_parentGroup
 Pointer to the parent particle group.
ISystemm_parentSystem
 System that syncs this group's particles to parent particles.
core::vector3df m_position
 Spawn position (derived from parent particle).
core::vector3df m_direction
 Spawn direction (derived from parent velocity).
core::quaternion m_rotate
 Spawn rotation (derived from parent orientation).
bool m_followParentTransform
 Whether particles should follow the parent's current position every frame.
bool m_emitterWorldOrientation
 Whether emitter orientation should be in world space or relative to parent.
bool m_syncLife
 Whether to sync child age/life with parent.
bool m_syncColor
 Whether to sync child color with parent.
Protected Attributes inherited from Skylicht::Particle::CGroup
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

Additional Inherited Members

Public Attributes inherited from Skylicht::Particle::CGroup
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 inherited from Skylicht::Particle::CGroup
virtual bool launchParticle (CParticle &p, SLaunchParticle &launch)
void initParticleModel (CParticle &p)
void initParticleLifeTime (CParticle &p)
CParticlecreate (u32 num)
void remove (u32 i)

Detailed Description

A particle group that spawns particles from the positions of particles in a parent group.

Useful for sub-emitter effects like trails, explosions upon death, or complex multi-stage particles.

Example

// Create a sub-group attached to projectileGroup
Particle::CSubGroup *arcaneGroup = ps->createParticleSubGroup(projectileGroup);
arcaneGroup->setFollowParentTransform(true);
arcaneGroup->syncParentParams(true, true); // Sync life and color
A particle group that spawns particles from the positions of particles in a parent group.
Definition CSubGroup.h:50
void syncParentParams(bool life, bool color)
Configures synchronization of life and color from parent.
void setFollowParentTransform(bool b)
Enables/disables following the parent's movement.
Definition CSubGroup.h:107

Member Function Documentation

◆ bornParticle()

virtual void Skylicht::Particle::CSubGroup::bornParticle ( )
virtual

Internal: spawns new particles at parent positions.

Reimplemented from Skylicht::Particle::CGroup.

◆ createSerializable()

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

Creates a serializable object for property editing or saving.

Returns
Pointer to a new CObjectSerializable instance.

Reimplemented from Skylicht::Particle::CGroup.

◆ getTransformPosition()

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

Transforms position from parent local space to world space.

Reimplemented from Skylicht::Particle::CGroup.

◆ getTransformVector()

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

Transforms vector from parent local space to world space.

Reimplemented from Skylicht::Particle::CGroup.

◆ loadSerializable()

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

Loads properties from a serializable object.

Parameters
objectThe serializable data to load.

Reimplemented from Skylicht::Particle::CGroup.

◆ OnGroupDestroy()

virtual void Skylicht::Particle::CSubGroup::OnGroupDestroy ( )
virtual

Callback when the parent group is destroyed.

Reimplemented from Skylicht::Particle::IParticleCallback.

◆ OnParticleBorn()

virtual void Skylicht::Particle::CSubGroup::OnParticleBorn ( CParticle & p)
virtual

Callback when a parent particle is born.

Reimplemented from Skylicht::Particle::IParticleCallback.

◆ OnParticleDead()

virtual void Skylicht::Particle::CSubGroup::OnParticleDead ( CParticle & p)
virtual

Callback when a parent particle dies.

Reimplemented from Skylicht::Particle::IParticleCallback.

◆ OnSwapParticleData()

virtual void Skylicht::Particle::CSubGroup::OnSwapParticleData ( CParticle & p1,
CParticle & p2 )
virtual

Callback when parent particle data is swapped in the array.

Reimplemented from Skylicht::Particle::IParticleCallback.

◆ updateLaunchEmitter()

virtual void Skylicht::Particle::CSubGroup::updateLaunchEmitter ( )
virtual

Internal: updates launch emitters based on parent particles.

Reimplemented from Skylicht::Particle::CGroup.


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