iMSTK
Interactive Medical Simulation Toolkit
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
imstk::RenderParticleEmitter Class Reference

Animation method for rendering particles Common use cases include smoke and fire. More...

#include <imstkRenderParticleEmitter.h>

Inheritance diagram for imstk::RenderParticleEmitter:
Inheritance graph
[legend]
Collaboration diagram for imstk::RenderParticleEmitter:
Collaboration graph
[legend]

Public Types

enum  Shape { Cube }
 Shape of emitter.
 
enum  Mode { Mode::Continuous, Mode::Burst }
 Mode of emitter. More...
 

Public Member Functions

 RenderParticleEmitter (std::shared_ptr< Geometry > geometry, const float time=3000.0f, Mode mode=Mode::Continuous)
 Constructor.
 
virtual void setGeometry (std::shared_ptr< Geometry > renderParticles)
 Set animation geometry. More...
 
RenderParticleEmitter::Mode getEmitterMode () const
 Get mode of emitter. More...
 
void setEmitterSize (const float size)
 Set size of emitter. More...
 
void setInitialVelocityRange (const Vec3f minDirection, const Vec3f maxDirection, const float minSpeed, const float maxSpeed, const float minRotationSpeed, const float maxRotationSpeed)
 Set velocity range This functions sets minimum and maximum rotation values for determining the initial trajectory of the particles. The values are randomly selected (according to a uniform distribution) between the min and max values. If the values are the same, then the particle direction will not behave randomly. More...
 
bool addKeyFrame (RenderParticleKeyFrame keyFrame)
 Add keyframe to particle emitter. More...
 
RenderParticleKeyFramegetStartKeyFrame ()
 Get start and end frames.
 
RenderParticleKeyFramegetEndKeyFrame ()
 
std::vector< RenderParticleKeyFrame > & getKeyFrames ()
 Get key frames. More...
 
virtual void reset ()
 Reset the emitter Only works for burst particles.
 
virtual void update ()
 Update.
 
- Public Member Functions inherited from imstk::AnimationModel
 AnimationModel (std::shared_ptr< Geometry > geometry)
 
std::shared_ptr< GeometrygetGeometry ()
 Get/set geometry.
 

Protected Member Functions

void initializeParticles ()
 Initialize particles.
 
void interpolateColor (Color &destination, const Color &sourceA, const Color &sourceB, const float alpha)
 Interpolate color.
 
void emitParticle (std::unique_ptr< RenderParticle > &particle)
 Emit particle.
 
float getRandomNormalizedFloat ()
 Get uniformly-distributed float. More...
 

Protected Attributes

std::vector< RenderParticleKeyFramem_keyFrames
 Particle keyframes.
 
RenderParticleEmitter::Mode m_mode = RenderParticleEmitter::Mode::Continuous
 
RenderParticleEmitter::Shape m_shape = RenderParticleEmitter::Shape::Cube
 
Vec3f m_minDirection
 
Vec3f m_maxDirection
 
float m_minSpeed
 
float m_maxSpeed
 
float m_minRotationSpeed
 
float m_maxRotationSpeed
 
float m_time
 total time for particle system
 
float m_emitTime
 
std::unique_ptr< StopWatchm_stopWatch
 
double m_lastUpdateTime = 0.0
 
bool m_started = false
 
float m_emitterSize = 1.0f
 
const int c_maxNumKeyFrames = 16
 Maximum key frames.
 
std::shared_ptr< Geometrym_animationGeometry = nullptr
 
std::vector< std::unique_ptr< RenderParticle > > * m_particles
 
- Protected Attributes inherited from imstk::AnimationModel
std::shared_ptr< Geometrym_geometry = nullptr
 

Detailed Description

Animation method for rendering particles Common use cases include smoke and fire.

Definition at line 38 of file imstkRenderParticleEmitter.h.

Member Enumeration Documentation

◆ Mode

Mode of emitter.

Enumerator
Continuous 

Emitter continuously releases/recycles particles.

Burst 

Emitter releases particles once until manually reset.

Definition at line 52 of file imstkRenderParticleEmitter.h.

Member Function Documentation

◆ addKeyFrame()

bool imstk::RenderParticleEmitter::addKeyFrame ( RenderParticleKeyFrame  keyFrame)

Add keyframe to particle emitter.

Parameters
keyFramekey frame to add
Returns
True if key frame added, false if too many key frames

Definition at line 81 of file imstkRenderParticleEmitter.cpp.

◆ getEmitterMode()

RenderParticleEmitter::Mode imstk::RenderParticleEmitter::getEmitterMode ( ) const

Get mode of emitter.

Returns
mode Mode of emitter

Definition at line 51 of file imstkRenderParticleEmitter.cpp.

◆ getKeyFrames()

std::vector< RenderParticleKeyFrame > & imstk::RenderParticleEmitter::getKeyFrames ( )

Get key frames.

Returns
key frames that are unsorted

Definition at line 125 of file imstkRenderParticleEmitter.cpp.

◆ getRandomNormalizedFloat()

float imstk::RenderParticleEmitter::getRandomNormalizedFloat ( )
protected

Get uniformly-distributed float.

Returns
float in the range of [0, 1]

Definition at line 291 of file imstkRenderParticleEmitter.cpp.

Here is the caller graph for this function:

◆ setEmitterSize()

void imstk::RenderParticleEmitter::setEmitterSize ( const float  size)

Set size of emitter.

Parameters
sizeWidth of emitter

Definition at line 57 of file imstkRenderParticleEmitter.cpp.

◆ setGeometry()

void imstk::RenderParticleEmitter::setGeometry ( std::shared_ptr< Geometry renderParticles)
virtual

Set animation geometry.

Parameters
renderParticlesparticles for rendering

Reimplemented from imstk::AnimationModel.

Definition at line 41 of file imstkRenderParticleEmitter.cpp.

Here is the caller graph for this function:

◆ setInitialVelocityRange()

void imstk::RenderParticleEmitter::setInitialVelocityRange ( const Vec3f  minDirection,
const Vec3f  maxDirection,
const float  minSpeed,
const float  maxSpeed,
const float  minRotationSpeed,
const float  maxRotationSpeed 
)

Set velocity range This functions sets minimum and maximum rotation values for determining the initial trajectory of the particles. The values are randomly selected (according to a uniform distribution) between the min and max values. If the values are the same, then the particle direction will not behave randomly.

Parameters
minDirectionMaximum initial angle of trajectory
maxDirectionMinimum initial angle of trajectory
minSpeedMinimum initial speed
maxSpeedMaximum initial speed
minRotationSpeedMinimum initial rotation speed
maxRotationSpeedMaximum initial rotation speed

Definition at line 63 of file imstkRenderParticleEmitter.cpp.


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