Confetti  0.1.0
A C++ particle system using Vulkan
Public Member Functions | Protected Attributes | List of all members
Confetti::BasicEmitter Class Referenceabstract

A particle emitter. More...

#include <Confetti/Emitter.h>

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

Public Member Functions

 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...
 
virtual void update (float dt)=0
 Updates the emitter's particles. More...
 
virtual void draw () const =0
 Draws all the emitter's particles. More...
 

Protected Attributes

Vkx::LocalBuffer vertexes_
 
Vkx::LocalBuffer indexes_
 
std::shared_ptr< Vkx::Device > device_
 

Detailed Description

A particle emitter.

Note
This class is an abstract base class and must be derived from in order to be used.

Constructor & Destructor Documentation

◆ BasicEmitter()

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.

Parameters
volumeEmitter volume.
environmentEnvironment applied to all particles.
appearanceAppearance shared by all particles.
sortedTrue, if the particles should be sorted back-to-front when updated

Member Function Documentation

◆ draw()

virtual void Confetti::BasicEmitter::draw ( ) const
pure virtual

Draws all the emitter's particles.

Note
This method must be overridden.

Implemented in Confetti::SphereEmitter, Confetti::TexturedEmitter, Confetti::StreakEmitter, and Confetti::PointEmitter.

◆ enable()

bool Confetti::BasicEmitter::enable ( bool  enable = true)

Enables/Disables the emitter. Returns the previous state.

Parameters
enabledIf true, the emitter is enabled, otherwise the emitter is disabled.

◆ update() [1/3]

void Confetti::BasicEmitter::update ( glm::vec3 const &  position,
glm::vec3 const &  velocity 
)

Sets the emitter's position and velocity.

Parameters
positionThe new position of the emitter.
velocityThe new velocity of the emitter.

◆ update() [2/3]

void Confetti::BasicEmitter::update ( float  dt,
glm::vec3 const &  position,
glm::vec3 const &  velocity 
)

Updates the emitter and its particles.

Parameters
dtAmount of time elapsed since the last update
positionThe new position of the emitter.
velocityThe new velocity of the emitter.

◆ update() [3/3]

virtual void Confetti::BasicEmitter::update ( float  dt)
pure virtual

Updates the emitter's particles.

Note
This method must be overridden.

Implemented in Confetti::SphereEmitter, Confetti::TexturedEmitter, Confetti::StreakEmitter, and Confetti::PointEmitter.