Brunot
Loading...
Searching...
No Matches
ParticleSpawner Class Reference

Creates Particles, based on initial conditions set in the editor, with potential randomness. More...

#include <ParticleSpawner.h>

Collaboration diagram for ParticleSpawner:
[legend]

Public Member Functions

 ParticleSpawner ()=default
virtual ~ParticleSpawner ()=default
virtual auto activate (const AffineMatrix &parentTransform, const Vector4D &scale, float rot) -> std::vector< Particle >
 spawns particles, based on values set in the editor
virtual auto particleSpawnMenu () -> void
 draw the menu for the particle editor that pertains to how particles spawn
auto particleUpdateMenu () -> void
 draws the menu for the particle editor that pertains to the

Protected Attributes

Particle maxParticle
 holds the initial state for a particle when it is spawned.
Particle minParticle
 for particle values that are randomized, this holds the minimum value they could be
unsigned spawnCount = 1u
 how many particles to spawn at a time
bool positionRandomize = false
bool velocityRandomize = false
bool scaleRandomize = false
bool rotationRandomize = false
bool rotationalVelocityRandomize = false
bool rotationalAccelerationRandomize = false
bool colorRandomize = false
bool startFrameRandomize = false
bool lifetimeRandomize = false

Private Types

enum  type { sphere = 1 , cone = 2 , orbit = 3 , singleLoopingParticle = 4 }
 a type enum that is a remnant of the original plan for subclasses. More...

Private Member Functions

template<typename T>
auto randIf (bool &isRandom, const T &min, const T &max) -> T
 randomizes between 2 values, if a boolean is true if the boolean isn't true, simply return max (even if max isn't greater)
template<typename T>
auto randBetween (const T &lhs, const T &rhs) -> T
 returns a random number between 2 numbers
template<>
auto randBetween (const Vector4D &lhs, const Vector4D &rhs) -> Vector4D
 explicit specialization of randBetween to work on Vector4Ds.

Private Attributes

std::ranlux24_base randSeed {std::random_device()()}

Friends

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

Detailed Description

Creates Particles, based on initial conditions set in the editor, with potential randomness.

This class was originally intended to be able to be overridden, but Aidan quickly realized that was more along the lines of a QOL feature, and so subclasses were relegated to something between postponed and unplanned.

Member Enumeration Documentation

◆ type

enum ParticleSpawner::type
private

a type enum that is a remnant of the original plan for subclasses.

It is unused, but Aidan feels it's a good indicator of what subclasses could be for ParticleSpawner, and so Aidan thinks it should be kept for now

Enumerator
sphere 
cone 
orbit 
singleLoopingParticle 

Constructor & Destructor Documentation

◆ ParticleSpawner()

ParticleSpawner::ParticleSpawner ( )
default
Here is the caller graph for this function:

◆ ~ParticleSpawner()

virtual ParticleSpawner::~ParticleSpawner ( )
virtualdefault
Here is the call graph for this function:

Member Function Documentation

◆ activate()

auto ParticleSpawner::activate ( const AffineMatrix & parentTransform,
const Vector4D & scale,
float rot )->std::vector< Particle >
virtual

spawns particles, based on values set in the editor

Parameters
parentTransformModeling transform for parent
scalescale of the parent
rotrotation of the parent
Returns
a vector of newly generated particles
Here is the call graph for this function:

◆ particleSpawnMenu()

auto ParticleSpawner::particleSpawnMenu ( ) ->void
virtual

draw the menu for the particle editor that pertains to how particles spawn

◆ particleUpdateMenu()

auto ParticleSpawner::particleUpdateMenu ( ) ->void

draws the menu for the particle editor that pertains to the

Here is the call graph for this function:

◆ randBetween() [1/2]

template<typename T>
auto ParticleSpawner::randBetween ( const T & lhs,
const T & rhs )->T
inlineprivate

returns a random number between 2 numbers

Template Parameters
Ttype of number
Parameters
lhsone bound
rhsthe other bound
Returns
a random number somewhere between lhs and rhs
Here is the caller graph for this function:

◆ randBetween() [2/2]

template<>
auto ParticleSpawner::randBetween ( const Vector4D & lhs,
const Vector4D & rhs )->Vector4D
inlineprivate

explicit specialization of randBetween to work on Vector4Ds.

does randomization independently for every value

Parameters
lhsone bound
rhsthe other bound
Returns
a vector between lhs and rhs

◆ randIf()

template<typename T>
auto ParticleSpawner::randIf ( bool & isRandom,
const T & min,
const T & max )->T
inlineprivate

randomizes between 2 values, if a boolean is true if the boolean isn't true, simply return max (even if max isn't greater)

Template Parameters
TType of value to randomize
Parameters
isRandomwhether to randomize the values
minthe first value
maxthe second value
Returns
either a random value between min and max, or max, depending on isRandom
Here is the call graph for this function:
Here is the caller graph for this function:

◆ from_json

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

◆ to_json

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

Member Data Documentation

◆ colorRandomize

bool ParticleSpawner::colorRandomize = false
protected

◆ lifetimeRandomize

bool ParticleSpawner::lifetimeRandomize = false
protected

◆ maxParticle

Particle ParticleSpawner::maxParticle
protected

holds the initial state for a particle when it is spawned.

for values that are randomized, this holds the maximum value a particle could possibly spawn with

◆ minParticle

Particle ParticleSpawner::minParticle
protected

for particle values that are randomized, this holds the minimum value they could be

◆ positionRandomize

bool ParticleSpawner::positionRandomize = false
protected

◆ randSeed

std::ranlux24_base ParticleSpawner::randSeed {std::random_device()()}
private

◆ rotationalAccelerationRandomize

bool ParticleSpawner::rotationalAccelerationRandomize = false
protected

◆ rotationalVelocityRandomize

bool ParticleSpawner::rotationalVelocityRandomize = false
protected

◆ rotationRandomize

bool ParticleSpawner::rotationRandomize = false
protected

◆ scaleRandomize

bool ParticleSpawner::scaleRandomize = false
protected

◆ spawnCount

unsigned ParticleSpawner::spawnCount = 1u
protected

how many particles to spawn at a time

◆ startFrameRandomize

bool ParticleSpawner::startFrameRandomize = false
protected

◆ velocityRandomize

bool ParticleSpawner::velocityRandomize = false
protected

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