CGVIS Utils
Loading...
Searching...
No Matches
AbstractParticleSystem Class Referenceabstract

Abstract additive point‑sprite particle system with a ready‑made GL path. More...

#include <AbstractParticleSystem.h>

Public Member Functions

 AbstractParticleSystem (float pointSize, float refDepth=1.0f)
 Construct the renderer state.
virtual ~AbstractParticleSystem ()
 Virtual destructor.
virtual void update (float t)=0
 Advance simulation by t seconds (override in derived classes).
void setPointSize (float pointSize, float refDepth=1.0f)
 Set the base point size and reference depth used by the shader.
float getPointSize () const
 Current point size at the configured reference depth.
float getRefDepth () const
 Current reference depth for size computation.
virtual void setColor (const Vec3 &color)=0
 Set a global color used by the emitter (override in derived classes).
void render (const Mat4 &v, const Mat4 &p)
 Render all particles using the internal program and point sprite.
Data interface (to implement in subclasses)
virtual std::vector< float > getData () const =0
 Return interleaved particle attributes.
virtual size_t getParticleCount () const =0
 Number of particles to draw.

Static Public Member Functions

static Vec3 computeColor (const Vec3 &c)
 Interpret special color sentinel values.

Detailed Description

Abstract additive point‑sprite particle system with a ready‑made GL path.

The class owns a small shader program, a point‑sprite texture, and a dynamic VBO/VAO pair. Derived classes only need to supply the particle data packed as (x,y,z,r,g,b,a) and report the particle count. Colors are multiplied in the fragment stage and blended additively (ONE, ONE).

Constructor & Destructor Documentation

◆ AbstractParticleSystem()

AbstractParticleSystem::AbstractParticleSystem ( float pointSize,
float refDepth = 1.0f )

Construct the renderer state.

Parameters
pointSizeDesired point size at refDepth (in pixels).
refDepthReference eye‑space depth at which pointSize applies.

◆ ~AbstractParticleSystem()

virtual AbstractParticleSystem::~AbstractParticleSystem ( )
inlinevirtual

Virtual destructor.

Member Function Documentation

◆ computeColor()

Vec3 AbstractParticleSystem::computeColor ( const Vec3 & c)
static

Interpret special color sentinel values.

Parameters
cInput color; if equal to RANDOM_COLOR a random color is returned; otherwise the input is forwarded unchanged.
Here is the call graph for this function:

◆ getData()

virtual std::vector< float > AbstractParticleSystem::getData ( ) const
pure virtual

Return interleaved particle attributes.

The vector must contain 7 floats per particle in the order (x,y,z,r,g,b,a).

Here is the caller graph for this function:

◆ getParticleCount()

virtual size_t AbstractParticleSystem::getParticleCount ( ) const
pure virtual

Number of particles to draw.

Here is the caller graph for this function:

◆ getPointSize()

float AbstractParticleSystem::getPointSize ( ) const
inline

Current point size at the configured reference depth.

◆ getRefDepth()

float AbstractParticleSystem::getRefDepth ( ) const
inline

Current reference depth for size computation.

◆ render()

void AbstractParticleSystem::render ( const Mat4 & v,
const Mat4 & p )

Render all particles using the internal program and point sprite.

Parameters
vView matrix.
pProjection matrix.

Uploads current particle data (via getData()) to a dynamic VBO, sets uniforms, and draws a GL_POINTS array with additive blending. Returns immediately if getParticleCount() is zero.

Here is the call graph for this function:

◆ setColor()

virtual void AbstractParticleSystem::setColor ( const Vec3 & color)
pure virtual

Set a global color used by the emitter (override in derived classes).

Implementations may treat RANDOM_COLOR and RAINBOW_COLOR as special cases. See also computeColor().

◆ setPointSize()

void AbstractParticleSystem::setPointSize ( float pointSize,
float refDepth = 1.0f )
inline

Set the base point size and reference depth used by the shader.

Parameters
pointSizeDesired apparent size in pixels at refDepth.
refDepthEye‑space depth at which pointSize holds (z of clip‑space before division).

◆ update()

virtual void AbstractParticleSystem::update ( float t)
pure virtual

Advance simulation by t seconds (override in derived classes).


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