Brunot
Loading...
Searching...
No Matches
ParticleEmitter Class Referencefinal

An object that manages many of a single type of particle. More...

#include <ParticleEmitter.h>

Collaboration diagram for ParticleEmitter:
[legend]

Public Member Functions

 ParticleEmitter ()
 ~ParticleEmitter ()
 ParticleEmitter (const ParticleEmitter &other)
 ParticleEmitter (ParticleEmitter &&other) noexcept
auto operator= (const ParticleEmitter &other) -> ParticleEmitter &
auto operator= (ParticleEmitter &&other) noexcept -> ParticleEmitter &
auto setParentTransform (const AffineMatrix &affineMatrix, Vector4D scale, float rot) -> void
 set the transforms for the parent Entity, so that Particles will be generated at the right scale and position
auto registerWithParticles () const -> void
 registers the ParticleEmitter with sys::ParticleManager, so that the particles can be updated
auto update (float dt) -> void
 runs update for the emitter, the emitter will automatically count down to decide when to emit particles next
auto showMenu () -> void
 Draw the ImGui menu for the Emitter, has controls for what types of particles are emitted, how they behave, etc.
auto reset () -> void
 resets the timer on the emitter, so that particles will be emitted next time it updates
auto getName () const -> std::string

Private Member Functions

auto getTimeBetweenSpawns () const -> float
 helper function for calculating time between spawns, based on how many spawnsPerSecond

Private Attributes

std::string name = "Emitter"
 The name of the emitter, for ease of reference in editor.
std::shared_ptr< ParticleBlockblock
 where the particles generated by the emitter are stored. this block is also referenced by sys::ParticleManager
std::unique_ptr< ParticleSpawnerspawner
 the ParticleSpawner is what actually creates the particles
AffineMatrix parentTransform
 parent transform, as last set by setParentTransform
Vector4D parentScale
 parent scale, as last set by setParentTransform
float parentRot = 0
 parent rotation, as last set by setParentTransform
float spawnsPerSecond = 1.f
 how often particles should spawn
float timeToNextSpawn = 0.f
 how long until particles will spawn next

Friends

auto to_json (json &j, const ParticleEmitter &n) ->void
auto from_json (const json &j, ParticleEmitter &n) ->void

Detailed Description

An object that manages many of a single type of particle.

It creates them by using a ParticleSpawner, and then sends them to a ParticleBlock, where they are stored and updated

Constructor & Destructor Documentation

◆ ParticleEmitter() [1/3]

ParticleEmitter::ParticleEmitter ( )
Here is the caller graph for this function:

◆ ~ParticleEmitter()

ParticleEmitter::~ParticleEmitter ( )
Here is the call graph for this function:

◆ ParticleEmitter() [2/3]

ParticleEmitter::ParticleEmitter ( const ParticleEmitter & other)
Here is the call graph for this function:

◆ ParticleEmitter() [3/3]

ParticleEmitter::ParticleEmitter ( ParticleEmitter && other)
noexcept
Here is the call graph for this function:

Member Function Documentation

◆ getName()

auto ParticleEmitter::getName ( ) const->std::string
nodiscard

◆ getTimeBetweenSpawns()

auto ParticleEmitter::getTimeBetweenSpawns ( ) const->float
private

helper function for calculating time between spawns, based on how many spawnsPerSecond

Here is the caller graph for this function:

◆ operator=() [1/2]

auto ParticleEmitter::operator= ( const ParticleEmitter & other) ->ParticleEmitter &
Here is the call graph for this function:

◆ operator=() [2/2]

auto ParticleEmitter::operator= ( ParticleEmitter && other) ->ParticleEmitter &
noexcept
Here is the call graph for this function:

◆ registerWithParticles()

auto ParticleEmitter::registerWithParticles ( ) const->void

registers the ParticleEmitter with sys::ParticleManager, so that the particles can be updated

Here is the call graph for this function:

◆ reset()

auto ParticleEmitter::reset ( ) ->void

resets the timer on the emitter, so that particles will be emitted next time it updates

◆ setParentTransform()

auto ParticleEmitter::setParentTransform ( const AffineMatrix & affineMatrix,
Vector4D scale,
float rot )->void

set the transforms for the parent Entity, so that Particles will be generated at the right scale and position

Parameters
affineMatrixModeling transform for parent
scalescale of the parent
rotrotation of the parent

◆ showMenu()

auto ParticleEmitter::showMenu ( ) ->void

Draw the ImGui menu for the Emitter, has controls for what types of particles are emitted, how they behave, etc.

Here is the call graph for this function:

◆ update()

auto ParticleEmitter::update ( float dt) ->void

runs update for the emitter, the emitter will automatically count down to decide when to emit particles next

Parameters
dttime in seconds elapsed since last frame

setup timer

Here is the call graph for this function:

◆ from_json

auto from_json ( const json & j,
ParticleEmitter & n )->void
friend

◆ to_json

auto to_json ( json & j,
const ParticleEmitter & n )->void
friend

Member Data Documentation

◆ block

std::shared_ptr<ParticleBlock> ParticleEmitter::block
private

where the particles generated by the emitter are stored. this block is also referenced by sys::ParticleManager

◆ name

std::string ParticleEmitter::name = "Emitter"
private

The name of the emitter, for ease of reference in editor.

◆ parentRot

float ParticleEmitter::parentRot = 0
private

parent rotation, as last set by setParentTransform

◆ parentScale

Vector4D ParticleEmitter::parentScale
private

parent scale, as last set by setParentTransform

◆ parentTransform

AffineMatrix ParticleEmitter::parentTransform
private

parent transform, as last set by setParentTransform

◆ spawner

std::unique_ptr<ParticleSpawner> ParticleEmitter::spawner
private

the ParticleSpawner is what actually creates the particles

◆ spawnsPerSecond

float ParticleEmitter::spawnsPerSecond = 1.f
private

how often particles should spawn

◆ timeToNextSpawn

float ParticleEmitter::timeToNextSpawn = 0.f
private

how long until particles will spawn next


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