Pyrogenesis trunk
|
Particle emitter. More...
#include <ParticleEmitter.h>
Public Member Functions | |
CParticleEmitter (const CParticleEmitterTypePtr &type) | |
void | SetPosition (const CVector3D &pos) |
Set the position to be used for emission of new particles. More... | |
CVector3D | GetPosition () const |
void | SetRotation (const CQuaternion &rot) |
Set the rotation to be used for emission of new particles (note: depends on particles). More... | |
const CQuaternion & | GetRotation () const |
const CBoundingBoxAligned & | GetParticleBounds () const |
Get the bounding box of the center points of particles at their current positions. More... | |
void | AddParticle (const SParticle &particle) |
Push a new particle onto the ring buffer. More... | |
void | UpdateArrayData (int frameNumber) |
Update particle and vertex array data. More... | |
void | PrepareForRendering () |
Make the vertex data available for subsequent binding and rendering. More... | |
void | UploadData (Renderer::Backend::IDeviceCommandContext *deviceCommandContext) |
Upload the vertex data to the backend. More... | |
void | Bind (Renderer::Backend::IDeviceCommandContext *deviceCommandContext, Renderer::Backend::IShaderProgram *shader) |
Bind rendering state (textures and blend modes). More... | |
void | RenderArray (Renderer::Backend::IDeviceCommandContext *deviceCommandContext) |
Draw the vertex array. More... | |
void | Unattach (const CParticleEmitterPtr &self) |
Stop this emitter emitting new particles, and pass responsibility for rendering to the CParticleManager. More... | |
void | SetEntityVariable (const std::string &name, float value) |
Public Attributes | |
CParticleEmitterTypePtr | m_Type |
bool | m_Active |
Whether this emitter is still emitting new particles. More... | |
CVector3D | m_Pos |
CQuaternion | m_Rot |
std::map< std::string, float > | m_EntityVariables |
std::vector< SParticle > | m_Particles |
size_t | m_NextParticleIdx |
float | m_LastUpdateTime |
float | m_EmissionRoundingError |
Private Attributes | |
CBoundingBoxAligned | m_ParticleBounds |
Bounding box of the current particle center points. More... | |
VertexIndexArray | m_IndexArray |
VertexArray | m_VertexArray |
VertexArray::Attribute | m_AttributePos |
VertexArray::Attribute | m_AttributeAxis |
VertexArray::Attribute | m_AttributeUV |
VertexArray::Attribute | m_AttributeColor |
Renderer::Backend::IVertexInputLayout * | m_VertexInputLayout = nullptr |
int | m_LastFrameNumber |
Particle emitter.
Emitters store particle data in two forms:
The number of particles is a constant for the entire life of the emitter, to simplify the updating and rendering. m_Particles acts like a ring buffer, so we don't have to worry about dynamically allocating particles. If particles have variable lifetimes, they'll exist in the array with alpha=0 until they're overwritten by a new particle after the maximum lifetime.
(It's quite likely this could be made more efficient, if the overhead of any added complexity is not high.)
CParticleEmitter::CParticleEmitter | ( | const CParticleEmitterTypePtr & | type | ) |
void CParticleEmitter::AddParticle | ( | const SParticle & | particle | ) |
Push a new particle onto the ring buffer.
(May overwrite an old particle.)
void CParticleEmitter::Bind | ( | Renderer::Backend::IDeviceCommandContext * | deviceCommandContext, |
Renderer::Backend::IShaderProgram * | shader | ||
) |
Bind rendering state (textures and blend modes).
|
inline |
Get the bounding box of the center points of particles at their current positions.
|
inline |
|
inline |
void CParticleEmitter::PrepareForRendering | ( | ) |
Make the vertex data available for subsequent binding and rendering.
void CParticleEmitter::RenderArray | ( | Renderer::Backend::IDeviceCommandContext * | deviceCommandContext | ) |
Draw the vertex array.
void CParticleEmitter::SetEntityVariable | ( | const std::string & | name, |
float | value | ||
) |
|
inline |
Set the position to be used for emission of new particles.
|
inline |
Set the rotation to be used for emission of new particles (note: depends on particles).
void CParticleEmitter::Unattach | ( | const CParticleEmitterPtr & | self | ) |
Stop this emitter emitting new particles, and pass responsibility for rendering to the CParticleManager.
This should be called before dropping the last std::shared_ptr to this object so that it will carry on rendering (until all particles have dissipated) even when it's no longer attached to a model.
self | the std::shared_ptr you're about to drop |
void CParticleEmitter::UpdateArrayData | ( | int | frameNumber | ) |
Update particle and vertex array data.
Must be called before RenderArray.
If frameNumber is the same as the previous call to UpdateArrayData, then the function will do no work and return immediately.
void CParticleEmitter::UploadData | ( | Renderer::Backend::IDeviceCommandContext * | deviceCommandContext | ) |
Upload the vertex data to the backend.
bool CParticleEmitter::m_Active |
Whether this emitter is still emitting new particles.
|
private |
|
private |
|
private |
|
private |
float CParticleEmitter::m_EmissionRoundingError |
std::map<std::string, float> CParticleEmitter::m_EntityVariables |
|
private |
|
private |
float CParticleEmitter::m_LastUpdateTime |
size_t CParticleEmitter::m_NextParticleIdx |
|
private |
Bounding box of the current particle center points.
std::vector<SParticle> CParticleEmitter::m_Particles |
CVector3D CParticleEmitter::m_Pos |
CQuaternion CParticleEmitter::m_Rot |
CParticleEmitterTypePtr CParticleEmitter::m_Type |
|
private |
|
private |