Wasabi
Public Member Functions | Protected Member Functions | List of all members
WParticlesBehavior Class Referenceabstract

#include <WParticles.hpp>

Inheritance diagram for WParticlesBehavior:
WDefaultParticleBehavior

Public Member Functions

 WParticlesBehavior (uint32_t maxParticles, uint32_t particleSize)
 
uint32_t UpdateAndCopyToBuffer (float curTime, void *buffer, uint32_t maxParticles, const WMatrix &worldMatrix, class WCamera *camera)
 
virtual void UpdateSystem (float curTime, const WMatrix &worldMatrix, class WCamera *camera)=0
 
virtual bool UpdateParticle (float curTime, void *particleData, WParticlesInstance *outputInstance, const WMatrix &worldMatrix, class WCamera *camera)=0
 
virtual WVector3GetMinPoint ()=0
 
virtual WVector3GetMaxPoint ()=0
 

Protected Member Functions

void Emit (void *particle)
 

Detailed Description

This class can be derived to implement custom behavior for particles. Custom behavior includes rules for emission, motion, growth, etc... The typename T must have identical bytes to a WParticlesVertex at its beginning.

Constructor & Destructor Documentation

◆ WParticlesBehavior()

WParticlesBehavior::WParticlesBehavior ( uint32_t  maxParticles,
uint32_t  particleSize 
)
Parameters
maxParticlesMaximum number of particles that the target system can render
particleSizeSize of each particle structure

Member Function Documentation

◆ Emit()

void WParticlesBehavior::Emit ( void *  particle)
protected

Emits a particle if not at the limit. Emittion means placing the particle data in m_buffer and incrementing m_numParticles.

Parameters
particleParticle to emit

◆ GetMaxPoint()

virtual WVector3& WParticlesBehavior::GetMaxPoint ( )
inlinepure virtual

Must be implemented to return the maximum point in the bounding box of the particles in local space of the instances.

Implemented in WDefaultParticleBehavior.

◆ GetMinPoint()

virtual WVector3& WParticlesBehavior::GetMinPoint ( )
inlinepure virtual

Must be implemented to return the minimum point in the bounding box of the particles in local space of the instances.

Implemented in WDefaultParticleBehavior.

◆ UpdateAndCopyToBuffer()

uint32_t WParticlesBehavior::UpdateAndCopyToBuffer ( float  curTime,
void *  buffer,
uint32_t  maxParticles,
const WMatrix worldMatrix,
class WCamera camera 
)

Called by the WParticles implementation to update the particles and fill in the particles buffer with instance data. The size of the buffer is m_maxParticles * sizeof(WParticlesInstance)

Parameters
curTimeThe time elapsed since the beginning of the program
bufferPointer to the buffer to be filled
maxParticlesMaximum number of particles in the vb
worldMatrixThe world matrix of the particles system
cameraThe camera used to render the frame
Returns
Number of particles copied

◆ UpdateParticle()

virtual bool WParticlesBehavior::UpdateParticle ( float  curTime,
void *  particleData,
WParticlesInstance outputInstance,
const WMatrix worldMatrix,
class WCamera camera 
)
inlinepure virtual

Must be implemented by a derived class to define the per-frame behavior of a single particle.

Parameters
curTimeThe time elapsed since the beginning of the program
particleDataA pointer to the beginning of the vertices memory to fill. The memory will have sizeof(WParticlesInstance) bytes to be filled with the 4 vertices of the particle billboard. The output vertex must be in VIEW SPACE
outputInstanceA pointer to the buffer to be filled with the instance data for the particle particleData. The transformation matrix is used as-is to transform from local space to projection space
worldMatrixThe world matrix of the particles system
cameraThe camera used to render the frame
Returns
True if the particle should die, false otherwise

Implemented in WDefaultParticleBehavior.

◆ UpdateSystem()

virtual void WParticlesBehavior::UpdateSystem ( float  curTime,
const WMatrix worldMatrix,
class WCamera camera 
)
pure virtual

Must be implemented by a derived class to define the per-frame behavior of the particle system. Typically this should control emission by calling Emit() when a particle needs to be emitted.

Parameters
curTimeThe time elapsed since the beginning of the program
worldMatrixThe world matrix of the camera rendering the particles
cameraThe camera used to render the frame

Implemented in WDefaultParticleBehavior.


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