2
# Copyright (C) 2001-2002 Jean-Baptiste LAMY
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
# Lesson 103: Particle system : firework !
20
# This lesson shows how to use do a firework !
23
import soya, soya.soya3d as soya3d, soya.model as model, soya.particle as particle, soya.idler as idler, soya.widget as widget
27
scene = soya3d.World()
29
camera = soya3d.Camera(scene)
32
soya.set_root_widget(widget.Group())
33
soya.root_widget.add(camera)
34
soya.root_widget.add(widget.FPSLabel())
36
material = particle._default()
38
class Generator(particle.FireworkGenerator):
39
def __init__(self, colors = ((0.9, 0.7, 0.0, 0.4), (1.0, 1.0, 0.0, 1.0), (1.0, 1.0, 1.0, 1.0)), acceleration = None, initial_speed = 0.08, subgenerator = None):
40
particle.FireworkGenerator.__init__(self, colors, acceleration, initial_speed, subgenerator = self)
41
self.other_generator = particle.FountainGenerator()
43
def set_system(self, system):
44
particle.FireworkGenerator.set_system(self, system)
45
self.other_generator.set_system(system)
48
#if len(self.system.particles) <= 1:
49
if (len(self.system.particles) == 0) or (len(self.system.particles) == 38) or (len(self.system.particles) == 15):
50
return particle.FireworkGenerator.__call__(self)
52
return self.other_generator()
55
firework = particle.MultiSpriteSystem(scene, Generator(), material, nb_particles = 1, particle_width = 0.2, particle_height = 0.2)
59
idler.Idler(scene).idle()