Particle System - ZackWilde27/Z3dPy GitHub Wiki
Z3dPy features a particle system for creating effects.
Emitters keep track of their particles, then when drawing, the template mesh is re-used to draw at each particle's location.
Load a mesh to serve as the template
myMesh = z3dpy.LoadMesh("z3dpy/mesh/cube.obj")
Now create an emitter with some info about starting particles
# Emitter(position, template, max, velocity, lifetime, gravity, randomness)
myEmitter = z3dpy.Emitter([0, 0, 0], myMesh, 100, [0, -5, 0], 1.0, [0, 9.8, 0], 15.0)
Position is the starting location of particles
Template is the mesh to draw at the location of each particle
Max is the max number of particles
Velocity is the starting velocity of particles
Lifetime is the life-time of each particle
Gravity is the gravity for each particle
Randomness is the randomness of starting velocity for each particle
Internal List
Add the emitter to the internal list
z3dpy.emitters.append(myEmitter)
To get particles to spawn, call HandleEmitters() during the draw loop
while True:
z3dpy.HandleEmitters()
for tri in z3dpy.Raster():
# ...
Your own list
HandleEmitters() and RasterThings() have parameters for emitters
while True:
z3dpy.HandleEmitters([myEmitter])
for tri in z3dpy.RasterThings([myThing, myOtherThing], [myEmitter]):