GIMC Particle System API


“Particle simulation in C++ made simple”

GitHub Source


The GIMC Particle API is for the person who cares about performance and wants to render the particles using their graphics API of choice. The API simulates the particles and outputs the data for rendering the simulated particles.


ParticleSystem The core from which Particle objects and Emitter objects are created.
Particle Initializes a particle’s properties.
Emitter Spawns particles within a shape with a frequency.
ParticleIterator Loops through the rendered particles. Returns an Output object when dereferenced.
Output Contains all data required for rendering a particle.

Code Example

Here is some example code for creating a simple fire effect.*

// Create the particle system
GIMC::ParticleSystem partSystem;

// Create the fire particle
GIMC::Particle fireParticle = partSystem.CreateParticle();

// Initialize the fire particles' properties
fireParticle.SetSpeed(96.0f, 512.0f, -64.0f);
fireParticle.SetDirection(-90.0f, -90.0f);
fireParticle.SetColor(GIMC::Color::Yellow, GIMC::Color::Red);

// Create the emitter source for the fire particle
GIMC::Emitter fireplace = partSystem.CreateEmitter(fireParticle);

// Initialize the emitter's properties
fireplace.SetCircle(32.0f, GIMC::Vector2(512.0f, 512.0f));
fireplace.SetFrequency(0.01f, 5);

// Game loop
    // Simulate particles

    // Render particles
    for(GIMC::ParticleIterator It(partSystem); It++)
        // Get particle output from ParticleIterator
        GIMC::Output outParticle = (*It);
        // Get data from outParticle
        GIMC::Vector2 location = outParticle.location;
        GIMC::Color color = outParticle.color;

        // Render the output particle using preferred method...

*The code wont display anything useful in its current bare-bone state and is only to demonstrate which steps are necessary to get a GIMC ParticleSystem running. You need to create a rendering method and game update loop yourself.

Last updated: 2015-12-13