Confetti  0.1.0
A C++ particle system using Vulkan
Public Member Functions | List of all members
Confetti::StreakEmitter Class Reference

An Emitter that emits StreakParticles. More...

#include <Confetti/Emitter.h>

Inheritance diagram for Confetti::StreakEmitter:
Inheritance graph
[legend]

Public Member Functions

 StreakEmitter (std::shared_ptr< Vkx::Device > device, int n, std::shared_ptr< EmitterVolume > volume, std::shared_ptr< Environment > environment, std::shared_ptr< Appearance > appearance, bool sorted)
 Constructor. More...
 
 StreakEmitter (std::shared_ptr< Vkx::Device > device, std::vector< StreakParticle > particles, std::shared_ptr< EmitterVolume > volume, std::shared_ptr< Environment > environment, std::shared_ptr< Appearance > appearance, bool sorted)
 Constructor. More...
 
void initialize ()
 Initializes the emitter.
 
void uninitialize ()
 Uninitializes the emitter.
 
std::vector< StreakParticle > & particles ()
 
std::vector< StreakParticle > const & particles () const
 
Overrides BasicEmitter
virtual void update (float dt) override
 
virtual void draw () const override
 Draws all the emitter's particles. More...
 
- Public Member Functions inherited from Confetti::BasicEmitter
 BasicEmitter (std::shared_ptr< Vkx::Device > device, std::shared_ptr< EmitterVolume > volume, std::shared_ptr< Environment > environment, std::shared_ptr< Appearance > appearance, bool sorted)
 Constructor. More...
 
virtual ~BasicEmitter ()=default
 Destructor.
 
std::shared_ptr< EmitterVolumeemitterVolume () const
 Returns the emitter volume.
 
std::shared_ptr< Appearanceappearance () const
 Returns the appearance.
 
std::shared_ptr< Environmentenvironment () const
 Returns the environment.
 
glm::vec3 currentPosition () const
 Returns the current position.
 
glm::vec3 currentVelocity () const
 Returns the current velocity.
 
bool enabled () const
 Returns true if the emitter is enabled.
 
bool sorted () const
 Returns true if the particles are sorted.
 
bool enable (bool enable=true)
 Enables/Disables the emitter. Returns the previous state. More...
 
void update (glm::vec3 const &position, glm::vec3 const &velocity)
 Sets the emitter's position and velocity. More...
 
void update (float dt, glm::vec3 const &position, glm::vec3 const &velocity)
 Updates the emitter and its particles. More...
 

Additional Inherited Members

- Protected Attributes inherited from Confetti::BasicEmitter
Vkx::LocalBuffer vertexes_
 
Vkx::LocalBuffer indexes_
 
std::shared_ptr< Vkx::Device > device_
 

Detailed Description

An Emitter that emits StreakParticles.

Constructor & Destructor Documentation

◆ StreakEmitter() [1/2]

Confetti::StreakEmitter::StreakEmitter ( std::shared_ptr< Vkx::Device >  device,
int  n,
std::shared_ptr< EmitterVolume volume,
std::shared_ptr< Environment environment,
std::shared_ptr< Appearance appearance,
bool  sorted 
)

Constructor.

Parameters
nNumber of particles to create.
volumeEmitter volume.
environmentEnvironment.
appearanceAppearance.
sortedIf true, then the particles will be sorted back to front during the update
Warning
std::bad_alloc is thown if memory is unable to be allocated for the particles.

◆ StreakEmitter() [2/2]

Confetti::StreakEmitter::StreakEmitter ( std::shared_ptr< Vkx::Device >  device,
std::vector< StreakParticle particles,
std::shared_ptr< EmitterVolume volume,
std::shared_ptr< Environment environment,
std::shared_ptr< Appearance appearance,
bool  sorted 
)

Constructor.

Parameters
deviceDevice the emitter draws on
particlesParticle array (the emitter assumes ownership).
volumeEmitter volume.
environmentEnvironment applied to all particles.
appearanceAppearance shared by all particles.
sortedIf true, then the particles will be sorted back to front during the update

Member Function Documentation

◆ draw()

void Confetti::StreakEmitter::draw ( ) const
overridevirtual

Draws all the emitter's particles.

Note
This method must be overridden.

Implements Confetti::BasicEmitter.

◆ update()

void Confetti::StreakEmitter::update ( float  dt)
overridevirtual
Parameters
dtAmount of time elapsed since the last update

Implements Confetti::BasicEmitter.