Esempio n. 1
0
	def test_Line(self):
		from lepton.domain import Line
		line = Line((0, 1.0, 2.0), (1.0, 2.0, 3.0))
		self.assertEqual(tuple(line.start_point), (0, 1.0, 2.0))
		self.assertEqual(tuple(line.end_point), (1.0, 2.0, 3.0))
		for i in range(10):
			x,y,z = line.generate()
			self.failUnless(0 <= x <= 1.0 and 1.0 <= y <= 2.0 and 2.0 <= z <= 3.0, (x, y, z))
			self.assertAlmostEqual(x, y - 1.0, 3)
			self.assertAlmostEqual(x, z - 2.0, 3)
			self.failIf((x, y, x) in line)
		self.assertEqual(line.intersect((1.0, 1.0, 2.0), (0, 2.0, 3.0)), (None, None))
Esempio n. 2
0
 def test_line_closest_pt_to(self):
     from lepton.domain import Line
     from lepton.particle_struct import Vec3
     line = Line((0, -1, 0), (0, 2, 0))
     for point, closest, normal in [
         ((-1, 0, 0), (0, 0, 0), (-1, 0, 0)),
         ((1, 1, 1), (0, 1, 0), Vec3(1, 0, 1).normalize()),
         ((0, -2, 0), (0, -1, 0), (0, 0, 0)),
         ((0, 30, 400), (0, 2, 0), (0, 0, 1)),
     ]:
         p, N = line.closest_point_to(point)
         self.assertVector(p, closest)
         self.assertVector(N, normal)
Esempio n. 3
0
	def test_line_closest_pt_to(self):
		from lepton.domain import Line
		from lepton.particle_struct import Vec3
		line = Line((0, -1, 0), (0, 2, 0))
		for point, closest, normal in [
			((-1, 0, 0), (0, 0, 0), (-1, 0, 0)),
			((1, 1, 1), (0, 1, 0), Vec3(1, 0, 1).normalize()),
			((0, -2, 0), (0, -1, 0), (0, 0, 0)),
			((0, 30, 400), (0, 2, 0), (0, 0, 1)),
			]:
			p, N = line.closest_point_to(point)
			self.assertVector(p, closest)
			self.assertVector(N, normal)
Esempio n. 4
0
 def test_Line(self):
     from lepton.domain import Line
     line = Line((0, 1.0, 2.0), (1.0, 2.0, 3.0))
     self.assertEqual(tuple(line.start_point), (0, 1.0, 2.0))
     self.assertEqual(tuple(line.end_point), (1.0, 2.0, 3.0))
     for i in range(10):
         x, y, z = line.generate()
         self.failUnless(
             0 <= x <= 1.0 and 1.0 <= y <= 2.0 and 2.0 <= z <= 3.0,
             (x, y, z))
         self.assertAlmostEqual(x, y - 1.0, 3)
         self.assertAlmostEqual(x, z - 2.0, 3)
         self.failIf((x, y, x) in line)
     self.assertEqual(line.intersect((1.0, 1.0, 2.0), (0, 2.0, 3.0)),
                      (None, None))
Esempio n. 5
0
 def __init__(self, x1, y1, x2, y2):
     self.emitter = emitter.StaticEmitter(
         rate = (x2-x1) // 5,
         template = Particle(
             position=(x1, y1, 0),
             color=(1, 1, 1, .5),
             velocity=(0, 0, 0),
             size=(32, 32, 0),
         ),
         position=Line((x1, y1, 0), (x2, y1, 0)),
         velocity=AABox((-100, -50, 0), (100, -200, 1)),
     )
     self.group = ParticleGroup(
         controllers=[
             self.emitter,
             controller.Movement(),
             controller.Growth(100),
             controller.Gravity((0, -50, 0)),
             controller.Fader(start_alpha=1,fade_out_start=0,fade_out_end=1,end_alpha=0),
             controller.Lifetime(2),
         ],
         renderer = Render('black-bubble.png'),
     )
     self.emitter.emit(1, self.group)
Esempio n. 6
0
win = pyglet.window.Window(resizable=True, visible=False)
win.clear()

glEnable(GL_BLEND)
glShadeModel(GL_SMOOTH)
glBlendFunc(GL_SRC_ALPHA, GL_ONE)
glDisable(GL_DEPTH_TEST)

flame = StaticEmitter(rate=500,
                      template=Particle(
                          position=(300, 25, 0),
                          velocity=(0, 0, 0),
                          color=(1, 1, 1, 1),
                      ),
                      position=Line((win.width / 2 - 85, -15, 0),
                                    (win.width / 2 + 85, -15, 0)),
                      deviation=Particle(position=(10, 0, 0),
                                         velocity=(7, 50, 0),
                                         age=0.75))

default_system.add_global_controller(
    Lifetime(6),
    Gravity((0, 20, 0)),
    Movement(),
    ColorBlender([
        (0, (0, 0, 0.5, 0)),
        (0.5, (0, 0, 0.5, 0.2)),
        (0.75, (0, 0.5, 1, 0.6)),
        (1.5, (1, 1, 0, 0.2)),
        (2.7, (0.9, 0.2, 0, 0.4)),
        (3.2, (0.6, 0.1, 0.05, 0.2)),