|
CGVIS Utils
|
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. | |
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).
| AbstractParticleSystem::AbstractParticleSystem | ( | float | pointSize, |
| float | refDepth = 1.0f ) |
Construct the renderer state.
| pointSize | Desired point size at refDepth (in pixels). |
| refDepth | Reference eye‑space depth at which pointSize applies. |
|
inlinevirtual |
Virtual destructor.
Interpret special color sentinel values.
| c | Input color; if equal to RANDOM_COLOR a random color is returned; otherwise the input is forwarded unchanged. |
|
pure virtual |
Return interleaved particle attributes.
The vector must contain 7 floats per particle in the order (x,y,z,r,g,b,a).
|
pure virtual |
Number of particles to draw.
|
inline |
Current point size at the configured reference depth.
|
inline |
Current reference depth for size computation.
Render all particles using the internal program and point sprite.
| v | View matrix. |
| p | Projection 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.
|
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().
|
inline |
Set the base point size and reference depth used by the shader.
| pointSize | Desired apparent size in pixels at refDepth. |
| refDepth | Eye‑space depth at which pointSize holds (z of clip‑space before division). |
|
pure virtual |
Advance simulation by t seconds (override in derived classes).