~jtaylor/ubuntu/oneiric/soya/fix-780305

« back to all changes in this revision

Viewing changes to tutorial/lesson-103.py

  • Committer: Bazaar Package Importer
  • Author(s): Marc Dequènes (Duck)
  • Date: 2005-01-30 09:55:06 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 hoary)
  • Revision ID: james.westby@ubuntu.com-20050130095506-f21p6v6cgaobhn5j
Tags: 0.9.2-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Soya 3D tutorial
2
 
# Copyright (C) 2001-2002 Jean-Baptiste LAMY
3
 
#
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.
8
 
#
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.
13
 
#
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
17
 
 
18
 
# Lesson 103: Particle system : firework !
19
 
 
20
 
# This lesson shows how to use do a firework !
21
 
 
22
 
import sys
23
 
import soya, soya.soya3d as soya3d, soya.model as model, soya.particle as particle, soya.idler as idler, soya.widget as widget
24
 
 
25
 
soya.init()
26
 
 
27
 
scene = soya3d.World()
28
 
 
29
 
camera = soya3d.Camera(scene)
30
 
camera.z = 5.0
31
 
 
32
 
soya.set_root_widget(widget.Group())
33
 
soya.root_widget.add(camera)
34
 
soya.root_widget.add(widget.FPSLabel())
35
 
 
36
 
material = particle._default()
37
 
 
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()
42
 
    
43
 
  def set_system(self, system):
44
 
    particle.FireworkGenerator.set_system(self, system)
45
 
    self.other_generator.set_system(system)
46
 
    
47
 
  def __call__(self):
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)
51
 
    else:
52
 
      return self.other_generator()
53
 
    
54
 
 
55
 
firework = particle.MultiSpriteSystem(scene, Generator(), material, nb_particles = 1, particle_width = 0.2, particle_height = 0.2)
56
 
firework.y = -2.0
57
 
 
58
 
 
59
 
idler.Idler(scene).idle()