Particle Effects

Don't mind the mess!

We're currently in the process of migrating the Panda3D Manual to a new service. This is a temporary layout in the meantime.

Fire,  smoke, glowing, explosion, water fountain, falling leaves, fur, hair and many other fuzzy effects are created procedurally using particle systems. It's important not to make the assumption that particles must have the size of a 'particle' that is very small, particles can have any size and any mass. Particles are physical entities which inherit PhysicsObject.

Panda3D provides a tool which simplifies testing particle systems. The tool is called (Particle Panel) and is written in python. The link to run the particle panel is in the same folder as the particle sample which comes with Panda3D.


A particle system in Panda3D consists of 6 components:

  1. Factory
  2. Emitter
  3. Physics engine
  4. Renderer
  5. Particle System Controller (Particle System)
  6. Particle System Manager (Optional)


Particles are generated in this stage using the provided parameters. Panda3D Provides 2 Factories:

  • PointParticleFactory: Generates particles with default rotation.
  • ZspintParticleFactory:  [From Source Code] Generates particles which spin along their z-axis. this is kind of an intermediary class- if you're using a SpriteParticleRenderer and you want your sprites to spin without having them be full-blown oriented (i.e. angry quat math), use this. Note:  'set_final_angle' and 'angular_velocity' are mutually exclusive APIs  if angular-velocity is specified, final_angle is ignored.


PT(PointParticleFactory) pt_particle_factory = new PointParticleFactory();


The emitter is used to emit the particles generated by the factory. The shape of the emitter determins the initial position and motion direction of the particles.

Available Emitters:

  • ArcEmitter
  •  BoxEmitter
  •  DiscEmitter
  •  LineEmitter
  •  RectangleEmitter
  •  RingEmitter
  •  SphereSurfaceEmitter
  •  SphereVolumeEmitter
  •  TangentRingEmitter

Each emitter is declared in a separate .h file with the same name as the emitter. For example: ArcEmitter is declared in arcEmitter.h


PT(SphereVolumeEmitter) sphere_emitter = new SphereVolumeEmitter;
// negative values emit the particles toward the sphere center
sphere_emitter->set_offset_force(LVector3f(0, 0, 0));
sphere_emitter->set_explicit_launch_vector(LVector3f(1, 0, 0));
sphere_emitter->set_radiate_origin(LPoint3f(0, 0, 0));


The renderer is used to specify how the particle appears on screen.

Available renderers:

  • GeomParticleRenderer: displays each particle on the shape of a selected PandaNode
  • LineParticleRenderer: displays each particle as a line
  • PointParticleRenderer: displays each particle as a point
  • SparkleParticleRenderer displayes each particle as a plus (+)
  • SpriteParticleRenderer:  displays each particle as a sprite

Each renderer is declared in a separate .h file with the same name as the renderer. For example: GeomParticleRenderer is declared in geomParticleRenderer.h


PT(PointParticleRenderer) pt_particle_rend = new PointParticleRenderer();
pt_particle_rend->set_start_color(Colorf(1, 0, 0, 1)); // alpha value is ignored
pt_particle_rend->set_end_color(Colorf(1, 1, 0, 1));


This class is the controller of the particle system.  The main parameters are:

  • Pool Size: the maximum number of particles the factory can generate Birth Rate: number of seconds between particle births, also it is the time after which the first birth occurs. So if the value is 6 the first litter will be born after 6 seconds.
  • Litter Size: number of particles created at each birth. If you want all the particles to be born at the same time, set this value to the value of (Pool Size) Litter Spread: this adds a random value in the range [-spread, +spread] to the value of Litter Size.
  • Lifespan:  number of seconds the system will live.
  • System Grows Older: this flag must be set for the Lifespan value to be used. It's very important to remember that particle systems which reach the end of their lifespan are automatically removed from the ParticleSystemManager and if you want to reuse them, they should be added to the ParticleSystemManager again.


PT(ParticleSystem) particle_sys = new ParticleSystem();
//particle_sys->set_spawn_on_death_flag(true); // this caused an exception!!
// use it to advance system age, or start at some age
// system_age is updated only when set_system_grows_older_flag(true);
// get_system_age() returns 0 unless system_grows_older_flag is set

The particle factory, emitter and renderer should be attached to the ParticleSystem and most important the render node should be set.

// if spawn and render parents should be different


This class is responsible for simplifying control of particle systems. Instead of stepping each particle system in the scene they are all added to the ParticleSystemManager and they can be all stepped using a single command or they can be stepped individually. This class is not count referenced so PT() and CPT() should not be used with it.

To attach a particle system to the manager:


To step all the particle systems:


To step a specific particle system:


NOTE: particle systems which reach the end of their lifespan are automatically removed from the ParticleSystemManager and if you want to reuse them, they should be added to the ParticleSystemManager again.

Previous Top Next