Engine
Frameworkcreatedbymeusableforthecreationofsimplegames.CurrentlysupportsOpenGL(Verysimple)andVulkan.
Public Types | Public Member Functions | Protected Attributes | List of all members
Engine::Emitter Class Reference

#include <Emitter.hpp>

Public Types

enum  MaxParticleReachedAction { MaxParticleReachedAction::DELETE_OLDEST = 0, MaxParticleReachedAction::DELETE_NEWEST, MaxParticleReachedAction::DO_NOT_SPAWN }
 
enum  EmitterType { EmitterType::CONTINUOUS = 0, EmitterType::BURST }
 
enum  EmitterShape {
  EmitterShape::SPHERE = 0, EmitterShape::SPHERE_OUTLINE, EmitterShape::BOX, EmitterShape::BOX_OUTLINE,
  EmitterShape::LINE, EmitterShape::POINT
}
 
enum  ParticleGenerationStyle { ParticleGenerationStyle::CONSTANT = 0, ParticleGenerationStyle::RANDOM }
 

Public Member Functions

 Emitter ()
 
 ~Emitter ()
 
virtual void Compile ()
 Compiles the emitter and associated particle. After this, the particle can't be changed. Any particle enum values are also no longer changeable. NOTE: This needs to be called before the emitter can be used. More...
 
virtual void Update (float deltaTime)
 Update the emitter. More...
 
void SetParticle (eastl::shared_ptr< Particle > particle)
 Sets the particle of the emitter. More...
 
eastl::weak_ptr< ParticleGetParticle () const
 Returns a copy of the particle of the emitter. More...
 
void SetMaxParticleCount (uint32_t count)
 Sets the maximum number of particles this emitter can have alive at the same time. More...
 
uint32_t GetMaxParticleCount () const
 Returns the maximum number of particles this emitter can have alive at the same time. More...
 
void SetMaxParticleCountReachedAction (MaxParticleReachedAction action)
 Sets the action that should be used when trying to spawn a new particle while already having the maximum number of particles alive. More...
 
MaxParticleReachedAction GetMaxParticleCountReachedAction () const
 Returns the action that should be used when trying to spawn a new particle while already having the maximum number of particles alive. More...
 
void SetEmitterType (EmitterType type)
 Sets the type of the emitter. More...
 
EmitterType GetEmitterType () const
 Returns the type of the emitter. More...
 
void SetEmitterShape (EmitterShape shape)
 Sets the shape of the area the emitter will emit particles in (outline means particles will only be generated along the edges of the shape). More...
 
EmitterShape GetEmitterShape () const
 Returns the shape of emitter. More...
 
void SetParticleGenerationStyle (ParticleGenerationStyle style)
 Sets how the particles are generated. Constant indicates that a new particle is generated every x amount of time, while random indicates that an average of x particles is generated every second. More...
 
ParticleGenerationStyle GetParticleGenerationStyle () const
 Returns the style in which particles are generated. More...
 
void SetBurstDuration (float durationMin, float durationMax)
 Sets the minimum and maximum duration a burst can have. When activated, a random duration will be picked somewhere in between these values. More...
 
eastl::pair< float, float > GetBurstDuration ()
 Returns the minimum and maximum duration of a burst. More...
 
void SetBurstParticleCount (float particlesMin, float particlesMax)
 sets the minimum and maximum amount of particles spawned when the burst is triggered. When activated, a random number will be picked somewhere in between these values. More...
 
eastl::pair< float, float > GetBurstParticleCount ()
 Returns the minimum and maximum amount of particles spawned when the burst is triggered. More...
 
void SetParticlesPerSecond (float particles)
 Sets the amount of particles generated by a continuous emitter. More...
 
float GetParticlesPerSecond () const
 Returns the amount of particles generated by a continuous emitter. More...
 
void SetEmitterSphereRadius (float radius)
 Sets the radius of the emitter sphere. More...
 
float GetEmitterSphereRadius () const
 Returns the radius of the emitter sphere. More...
 
void SetEmitterSphereCenter (glm::vec3 center)
 Sets the center of the emitter sphere. More...
 
glm::vec3 GetEmitterSphereCenter () const
 Returns the center of the emitter sphere. More...
 
void SetEmitterBox (glm::vec3 corner1, glm::vec3 corner2)
 Sets the corners of the box emitter. More...
 
eastl::pair< glm::vec3, glm::vec3 > GetEmitterBox ()
 Returns the corners of the emitter box. More...
 
void SetEmitterLine (glm::vec3 start, glm::vec3 end)
 Sets the start and end of the emitter line. More...
 
eastl::pair< glm::vec3, glm::vec3 > GetEmitterLine ()
 Returns the start and end of the emitter line. More...
 
void SetEmitterPointLocation (glm::vec3 point)
 Sets the location of a point emitter. More...
 
glm::vec3 GetEmitterPointLocation () const
 Returns the location of a point emitter. More...
 

Protected Attributes

eastl::shared_ptr< Particleparticle
 
uint32_t maxParticleCount
 
MaxParticleReachedAction maxParticleReachedAction
 
EmitterType emitterType
 
EmitterShape emitterShape
 
ParticleGenerationStyle particleGenerationStyle
 
bool active
 
bool compiled
 
float particlesPerSecond
 
float burstParticleCountMin
 
float burstParticleCountMax
 
float burstParticles
 
float burstParticlesPerSecond
 
float burstDurationMin
 
float burstDurationMax
 
float burstDuration
 
float burstActiveTime
 
float sphereRadius
 
glm::vec3 sphereCenter
 
glm::vec3 boxCorner1
 
glm::vec3 boxCorner2
 
glm::vec3 lineStart
 
glm::vec3 lineEnd
 
glm::vec3 pointLocation
 

Detailed Description

Definition at line 7 of file Emitter.hpp.

Member Enumeration Documentation

Enumerator
SPHERE 
SPHERE_OUTLINE 
BOX 
BOX_OUTLINE 
LINE 
POINT 

Definition at line 30 of file Emitter.hpp.

Enumerator
CONTINUOUS 
BURST 

Definition at line 25 of file Emitter.hpp.

Enumerator
DELETE_OLDEST 
DELETE_NEWEST 
DO_NOT_SPAWN 

Definition at line 13 of file Emitter.hpp.

Enumerator
CONSTANT 
RANDOM 

Definition at line 39 of file Emitter.hpp.

Constructor & Destructor Documentation

Engine::Emitter::Emitter ( )

Definition at line 5 of file Emitter.cpp.

Engine::Emitter::~Emitter ( )

Definition at line 12 of file Emitter.cpp.

Member Function Documentation

void Engine::Emitter::Compile ( )
virtual

Compiles the emitter and associated particle. After this, the particle can't be changed. Any particle enum values are also no longer changeable. NOTE: This needs to be called before the emitter can be used.

Definition at line 16 of file Emitter.cpp.

eastl::pair< float, float > Engine::Emitter::GetBurstDuration ( )

Returns the minimum and maximum duration of a burst.

Returns
A pair of floats containing the durations.

Definition at line 95 of file Emitter.cpp.

eastl::pair< float, float > Engine::Emitter::GetBurstParticleCount ( )

Returns the minimum and maximum amount of particles spawned when the burst is triggered.

Returns

Definition at line 106 of file Emitter.cpp.

eastl::pair< glm::vec3, glm::vec3 > Engine::Emitter::GetEmitterBox ( )

Returns the corners of the emitter box.

Returns
A pair of vec3s containing the corners.

Definition at line 155 of file Emitter.cpp.

eastl::pair< glm::vec3, glm::vec3 > Engine::Emitter::GetEmitterLine ( )

Returns the start and end of the emitter line.

Returns
A pair of vec3s containing the start and end.

Definition at line 166 of file Emitter.cpp.

glm::vec3 Engine::Emitter::GetEmitterPointLocation ( ) const

Returns the location of a point emitter.

Returns
A vec3 containing the position.

Definition at line 176 of file Emitter.cpp.

Emitter::EmitterShape Engine::Emitter::GetEmitterShape ( ) const

Returns the shape of emitter.

Returns
The emitter shape.

Definition at line 74 of file Emitter.cpp.

glm::vec3 Engine::Emitter::GetEmitterSphereCenter ( ) const

Returns the center of the emitter sphere.

Returns
A vec3 containing the center.

Definition at line 136 of file Emitter.cpp.

float Engine::Emitter::GetEmitterSphereRadius ( ) const

Returns the radius of the emitter sphere.

Returns
The radius.

Definition at line 126 of file Emitter.cpp.

Emitter::EmitterType Engine::Emitter::GetEmitterType ( ) const

Returns the type of the emitter.

Returns
The emitter type.

Definition at line 64 of file Emitter.cpp.

uint32_t Engine::Emitter::GetMaxParticleCount ( ) const

Returns the maximum number of particles this emitter can have alive at the same time.

Returns
The maximum number of particles.

Definition at line 44 of file Emitter.cpp.

Emitter::MaxParticleReachedAction Engine::Emitter::GetMaxParticleCountReachedAction ( ) const

Returns the action that should be used when trying to spawn a new particle while already having the maximum number of particles alive.

Returns
The action to perform.

Definition at line 54 of file Emitter.cpp.

eastl::weak_ptr< Particle > Engine::Emitter::GetParticle ( ) const

Returns a copy of the particle of the emitter.

Returns
A copy of the emitter's particle.

Definition at line 33 of file Emitter.cpp.

Emitter::ParticleGenerationStyle Engine::Emitter::GetParticleGenerationStyle ( ) const

Returns the style in which particles are generated.

Returns
The particle generation style.

Definition at line 84 of file Emitter.cpp.

float Engine::Emitter::GetParticlesPerSecond ( ) const

Returns the amount of particles generated by a continuous emitter.

Returns
The number of particles per second.

Definition at line 116 of file Emitter.cpp.

void Engine::Emitter::SetBurstDuration ( float  durationMin,
float  durationMax 
)

Sets the minimum and maximum duration a burst can have. When activated, a random duration will be picked somewhere in between these values.

Parameters
durationMinThe minimum duration in seconds.
durationMaxThe minimum duration in seconds.

Definition at line 89 of file Emitter.cpp.

void Engine::Emitter::SetBurstParticleCount ( float  particlesMin,
float  particlesMax 
)

sets the minimum and maximum amount of particles spawned when the burst is triggered. When activated, a random number will be picked somewhere in between these values.

Parameters
particlesMin
particlesMax

Definition at line 100 of file Emitter.cpp.

void Engine::Emitter::SetEmitterBox ( glm::vec3  corner1,
glm::vec3  corner2 
)

Sets the corners of the box emitter.

Parameters
corner1A vec3 containing the first corner.
corner2A vec3 containing the second corner.

Definition at line 141 of file Emitter.cpp.

void Engine::Emitter::SetEmitterLine ( glm::vec3  start,
glm::vec3  end 
)

Sets the start and end of the emitter line.

Parameters
startThe start position.
endThe end position.

Definition at line 160 of file Emitter.cpp.

void Engine::Emitter::SetEmitterPointLocation ( glm::vec3  point)

Sets the location of a point emitter.

Parameters
pointThe postion of the emitter.

Definition at line 171 of file Emitter.cpp.

void Engine::Emitter::SetEmitterShape ( EmitterShape  shape)

Sets the shape of the area the emitter will emit particles in (outline means particles will only be generated along the edges of the shape).

Parameters
shapeThe new shape.

Definition at line 69 of file Emitter.cpp.

void Engine::Emitter::SetEmitterSphereCenter ( glm::vec3  center)

Sets the center of the emitter sphere.

Parameters
centerA vec3 containing the center.

Definition at line 131 of file Emitter.cpp.

void Engine::Emitter::SetEmitterSphereRadius ( float  radius)

Sets the radius of the emitter sphere.

Parameters
radiusThe radius.

Definition at line 121 of file Emitter.cpp.

void Engine::Emitter::SetEmitterType ( EmitterType  type)

Sets the type of the emitter.

Parameters
typeThe new type.

Definition at line 59 of file Emitter.cpp.

void Engine::Emitter::SetMaxParticleCount ( uint32_t  count)

Sets the maximum number of particles this emitter can have alive at the same time.

Parameters
countThe maximum number of particles.

Definition at line 38 of file Emitter.cpp.

void Engine::Emitter::SetMaxParticleCountReachedAction ( MaxParticleReachedAction  action)

Sets the action that should be used when trying to spawn a new particle while already having the maximum number of particles alive.

Parameters
actionThe action to perform.

Definition at line 49 of file Emitter.cpp.

void Engine::Emitter::SetParticle ( eastl::shared_ptr< Particle particle)

Sets the particle of the emitter.

Parameters
particleThe particle to set the emitter to.

Definition at line 27 of file Emitter.cpp.

void Engine::Emitter::SetParticleGenerationStyle ( ParticleGenerationStyle  style)

Sets how the particles are generated. Constant indicates that a new particle is generated every x amount of time, while random indicates that an average of x particles is generated every second.

Parameters
styleThe style of how the particles are generated.

Definition at line 79 of file Emitter.cpp.

void Engine::Emitter::SetParticlesPerSecond ( float  particles)

Sets the amount of particles generated by a continuous emitter.

Parameters
particlesThe number of particles per second.

Definition at line 111 of file Emitter.cpp.

void Engine::Emitter::Update ( float  deltaTime)
virtual

Update the emitter.

Parameters
deltaTimeThe time since the last call in seconds.

Definition at line 21 of file Emitter.cpp.

Member Data Documentation

bool Engine::Emitter::active
protected

Definition at line 247 of file Emitter.hpp.

glm::vec3 Engine::Emitter::boxCorner1
protected

Definition at line 269 of file Emitter.hpp.

glm::vec3 Engine::Emitter::boxCorner2
protected

Definition at line 269 of file Emitter.hpp.

float Engine::Emitter::burstActiveTime
protected

Definition at line 263 of file Emitter.hpp.

float Engine::Emitter::burstDuration
protected

Definition at line 261 of file Emitter.hpp.

float Engine::Emitter::burstDurationMax
protected

Definition at line 259 of file Emitter.hpp.

float Engine::Emitter::burstDurationMin
protected

Definition at line 259 of file Emitter.hpp.

float Engine::Emitter::burstParticleCountMax
protected

Definition at line 253 of file Emitter.hpp.

float Engine::Emitter::burstParticleCountMin
protected

Definition at line 253 of file Emitter.hpp.

float Engine::Emitter::burstParticles
protected

Definition at line 255 of file Emitter.hpp.

float Engine::Emitter::burstParticlesPerSecond
protected

Definition at line 257 of file Emitter.hpp.

bool Engine::Emitter::compiled
protected

Definition at line 249 of file Emitter.hpp.

EmitterShape Engine::Emitter::emitterShape
protected

Definition at line 243 of file Emitter.hpp.

EmitterType Engine::Emitter::emitterType
protected

Definition at line 241 of file Emitter.hpp.

glm::vec3 Engine::Emitter::lineEnd
protected

Definition at line 271 of file Emitter.hpp.

glm::vec3 Engine::Emitter::lineStart
protected

Definition at line 271 of file Emitter.hpp.

uint32_t Engine::Emitter::maxParticleCount
protected

Definition at line 237 of file Emitter.hpp.

MaxParticleReachedAction Engine::Emitter::maxParticleReachedAction
protected

Definition at line 239 of file Emitter.hpp.

eastl::shared_ptr<Particle> Engine::Emitter::particle
protected

Definition at line 235 of file Emitter.hpp.

ParticleGenerationStyle Engine::Emitter::particleGenerationStyle
protected

Definition at line 245 of file Emitter.hpp.

float Engine::Emitter::particlesPerSecond
protected

Definition at line 251 of file Emitter.hpp.

glm::vec3 Engine::Emitter::pointLocation
protected

Definition at line 273 of file Emitter.hpp.

glm::vec3 Engine::Emitter::sphereCenter
protected

Definition at line 267 of file Emitter.hpp.

float Engine::Emitter::sphereRadius
protected

Definition at line 265 of file Emitter.hpp.


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