Emitters - ZackWilde27/Z3dPy GitHub Wiki
z3dpy.Emitter( vPosition, templateMesh, iMax, vVelocity, fLifetime, vGravity, *fRandomness )
myEmitter = z3dpy.Emitter([0.0, 0.0, 0.0], myMesh, 50, [0.0, 1.0, 0.0], 5.0, [0, 9.8, 0], 50.0)
Properties
-
particles Tuple of currently active particles
-
position
-
template The template mesh to draw at each particle location
-
max The max number of particles
-
velocity Starting velocity of each particle
-
lifetime Lifetime for each particle
-
gravity Gravity for each particle
-
active
-
randomness Randomness of starting velocity
-
user
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
myEmitter = z3dpy.Emitter([0, 0, 0], myMesh, 100, [0, -5, 0], 1.0, [0, 9.8, 0], 15.0)
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.Render():
# ...
Your own list
HandleEmitters() and RenderThings() have parameters for emitters
while True:
z3dpy.HandleEmitters([myEmitter])
for tri in z3dpy.RenderThings([myThing, myOtherThing], [myEmitter]):