Exemple #1
0
def init(window):
    flame = StaticEmitter(
        rate=500,
        template=Particle(position=(300, 25, 0), velocity=(0, 0, 0), color=(1, 1, 1, 1)),
        position=Line((window.width / 2 - 85, 200, 0), (window.width / 2 + 85, 200, 0)),
        deviation=Particle(position=(200, 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)),
                (4.0, (0.8, 0.8, 0.8, 0.1)),
                (6.0, (0.8, 0.8, 0.8, 0)),
            ]
        ),
    )

    group = ParticleGroup(
        controllers=[flame], renderer=PointRenderer(64, SpriteTexturizer(create_point_texture(64, 5)))
    )

    pyglet.clock.schedule_interval(default_system.update, (1.0 / 100.0))
    pyglet.clock.set_fps_limit(None)

    return default_system
Exemple #2
0
def init(window):
    smoke = StaticEmitter(
	rate=10,
	template=Particle(
		position=(400,100,0), 
		velocity=(0,35,0), 
		color=(0.8,0.8,0.8,0.005),
	),
	deviation=Particle(
		position=(100,5,0), 
		velocity=(3,6,0), 
		color=(0.05,0.05,0.05,0.0),
                )
        )
    
    default_system.add_global_controller(
	Lifetime(20),
	Gravity((0, -2, 0)), 
	Movement(), 
	Fader(fade_in_end=1.5, max_alpha=0.05, fade_out_start=12, fade_out_end=20),
        )
    group1 = ParticleGroup(controllers=[smoke],
                           renderer=PointRenderer(64, 
                                                  SpriteTexturizer(create_point_texture(64, 1))))
    pyglet.clock.schedule_interval(default_system.update, (1.0/30.0))
    return default_system
Exemple #3
0
		velocity=(0,35,0), 
		color=(0.8,0.8,0.8,0.005),
	),
	deviation=Particle(
		position=(10,5,0), 
		velocity=(3,6,0), 
		color=(0.05,0.05,0.05,0.0),
	)
)

default_system.add_global_controller(
	Lifetime(20),
	Gravity((0, -2, 0)), 
	Movement(), 
	Fader(fade_in_end=1.5, max_alpha=0.05, fade_out_start=12, fade_out_end=20),
)
group1 = ParticleGroup(controllers=[smoke],
	renderer=PointRenderer(64, SpriteTexturizer(create_point_texture(64, 1))))

win.set_visible(True)
pyglet.clock.schedule_interval(default_system.update, (1.0/30.0))

@win.event
def on_draw():
	win.clear()
	glLoadIdentity()
	default_system.draw()

if __name__ == '__main__':
	pyglet.app.run()
Exemple #4
0
import os
import math
from random import expovariate, uniform, gauss
from pyglet import image
from pyglet.gl import *

from lepton import Particle, ParticleGroup, default_system, domain
from lepton.renderer import PointRenderer
from lepton.texturizer import SpriteTexturizer, create_point_texture
from lepton.emitter import StaticEmitter, PerParticleEmitter
from lepton.controller import Gravity, Lifetime, Movement, Fader, ColorBlender

spark_tex = image.load(os.path.join(os.path.dirname(__file__),
                                    'flare3.png')).get_texture()
spark_texturizer = SpriteTexturizer(spark_tex.id)
trail_texturizer = SpriteTexturizer(create_point_texture(8, 50))


class Kaboom:

    lifetime = 5

    def __init__(self):
        color = (uniform(0, 1), uniform(0, 1), uniform(0, 1), 1)
        while max(color[:3]) < 0.9:
            color = (uniform(0, 1), uniform(0, 1), uniform(0, 1), 1)

        spark_emitter = StaticEmitter(
            template=Particle(position=(uniform(-50, 50), uniform(-30, 30),
                                        uniform(-30, 30)),
                              color=color),
Exemple #5
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)),
        (4.0, (0.8, 0.8, 0.8, 0.1)),
        (6.0, (0.8, 0.8, 0.8, 0)),
    ]),
)

group = ParticleGroup(controllers=[flame],
                      renderer=PointRenderer(
                          64, SpriteTexturizer(create_point_texture(64, 5))))

win.set_visible(True)
pyglet.clock.schedule_interval(default_system.update, (1.0 / 30.0))
pyglet.clock.set_fps_limit(None)


@win.event
def on_draw():
    win.clear()
    glLoadIdentity()
    default_system.draw()


if __name__ == '__main__':
    default_system.run_ahead(2, 30)
def init(lokumBorg=None):

    platform = pyglet.window.get_platform() 
    display = platform.get_default_display() 
    
    W = 200
    H = 200
    X = 0
    Y = 0
    screens = display.get_screens() 
    window = pyglet.window.Window(fullscreen=True, screen=screens[1])
    # window = pyglet.window.Window(width=W, height=H, resizable=True)
    # window = pyglet.window.Window(resizable=True, visible=False)
    win = window
    win.clear()
    console = Console(x=X, y=Y,width=W, height=H, window=window)

    @window.event
    def on_draw():
        glEnable(GL_BLEND)
        glShadeModel(GL_SMOOTH)
        glBlendFunc(GL_SRC_ALPHA,GL_ONE)
        glDisable(GL_DEPTH_TEST)

        # glClearColor(1,1,1,1)
        glClearColor(1,0,0,1)
        window.clear()
        glLoadIdentity()
        default_system.draw()
        # player.get_texture().blit(100, 200,width=400,height=300)
        console.draw()


    @window.event
    def on_resize(width, height):
        console.resize(width,height)

    @console.event
    def on_command(command):
        global ANS,NBSEC
        if lokumBorg:
            ANS, dursec = lokumBorg.reply(command)
            if ANS: lokumBorg.save_line(ANS.strip())
            ANS = list(ANS)
            ANS.reverse()
            if dursec!=0:
                nblettres = len(ANS)
                NBSEC = float(dursec)/nblettres
                # set color for the borg
                console.write ('\n',attributes={'color': (0, 255, 0, 255)})
                clock.schedule_interval(callborg, NBSEC)

    console.prompt(" ")
    window.push_handlers(console)

    def callborg(dt):
        global ANS, NBSEC
        if ANS:
            c = ANS.pop()
            console.write(c)
            # time.sleep(NBSEC)
            console._caret.position = len(console._document.text)

        elif ANS==[]:
            console.write (' ',attributes={'color': (255, 255, 255, 120)})
            console.write ('\n')
            console.prompt()
            #console._document.delete_text(0, len(console._document.text)-1)
            #console._prompt_end = 0
            ANS = None
            clock.unschedule(callborg)
        else: ANS=None

    ### ---------- fire

    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)), 
                    (4.0, (0.8,0.8,0.8,0.1)),
                    (6.0, (0.8,0.8,0.8,0)), ]
            ),
    )


    group = ParticleGroup(controllers=[flame], 
            renderer=PointRenderer(64, SpriteTexturizer(create_point_texture(64, 5))))

    #win.set_visible(True)
    #win.set_visible(True)
    pyglet.clock.schedule_interval(default_system.update, (1.0/100.0))
    pyglet.clock.set_fps_limit(None)

    if 0:
        source = pyglet.media.load('/data/video/test.dv')
        format = source.video_format
        global player
        player = pyglet.media.Player()
        player.queue(source)
        player.play()


    default_system.run_ahead(2, 30)
    ### ------------- fire


    pyglet.app.run()
	"""Setup 3D projection"""
	glViewport(0, 0, width, height)
	glMatrixMode(GL_PROJECTION)
	glLoadIdentity()
	gluPerspective(30, 1.0*width/height, 0.1, 1000.0)
	glMatrixMode(GL_MODELVIEW)
	glLoadIdentity()
win.on_resize = on_resize

glEnable(GL_BLEND)
glShadeModel(GL_SMOOTH)
glBlendFunc(GL_SRC_ALPHA,GL_ONE)
glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);
glDisable(GL_DEPTH_TEST)

renderer = PointRenderer(7, SpriteTexturizer(create_point_texture(16, 10)))

domains = [
	domain.Sphere((0,0,0), 1),
	domain.Disc((0,0,0), (-1,0,0), 1),
	domain.Cylinder((-0.5,0,0), (0.5,0,0), 1),
	domain.Cone((-0.5,0,0), (0.5,0,0), 1),
	]

groups = [
	ParticleGroup(
		controllers=[
			StaticEmitter(
				rate=15000,
				position=domain,
				template=Particle(
Exemple #8
0
		velocity=(0,35,0), 
		color=(0.8,0.8,0.8,0.005),
	),
	deviation=Particle(
		position=(10,5,0), 
		velocity=(3,6,0), 
		color=(0.05,0.05,0.05,0.0),
	)
)

default_system.add_global_controller(
	Lifetime(20),
	Gravity((0, -2, 0)), 
	Movement(), 
	Fader(fade_in_end=1.5, max_alpha=0.05, fade_out_start=12, fade_out_end=20),
)
group1 = ParticleGroup(controllers=[smoke],
	renderer=PointRenderer(64, SpriteTexturizer(create_point_texture(64, 1))))

win.set_visible(True)
pyglet.clock.schedule_interval(default_system.update, (1.0/30.0))

@win.event
def on_draw():
	win.clear()
	glLoadIdentity()
	default_system.draw()

if __name__ == '__main__':
	pyglet.app.run()
Exemple #9
0
    glMatrixMode(GL_PROJECTION)
    glLoadIdentity()
    gluPerspective(30, 1.0 * width / height, 0.1, 1000.0)
    glMatrixMode(GL_MODELVIEW)
    glLoadIdentity()


win.on_resize = on_resize

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

renderer = PointRenderer(7, SpriteTexturizer(create_point_texture(16, 10)))

domains = [
    domain.Sphere((0, 0, 0), 1),
    domain.Disc((0, 0, 0), (-1, 0, 0), 1),
    domain.Cylinder((-0.5, 0, 0), (0.5, 0, 0), 1),
    domain.Cone((-0.5, 0, 0), (0.5, 0, 0), 1),
]

groups = [
    ParticleGroup(controllers=[
        StaticEmitter(rate=15000,
                      position=domain,
                      template=Particle(
                          color=(1, 1, 1),
                          size=(.1, .1, 0),
import os
import math
from random import expovariate, uniform, gauss
from pyglet import image
from pyglet.gl import *

from lepton import Particle, ParticleGroup, default_system, domain
from lepton.renderer import PointRenderer
from lepton.texturizer import SpriteTexturizer, create_point_texture
from lepton.emitter import StaticEmitter, PerParticleEmitter
from lepton.controller import Gravity, Lifetime, Movement, Fader, ColorBlender

spark_tex = image.load(os.path.join(os.path.dirname(__file__), 'flare3.png')).get_texture()
spark_texturizer = SpriteTexturizer(spark_tex.id)
trail_texturizer = SpriteTexturizer(create_point_texture(8, 50))

class Kaboom:
	
	lifetime = 5

	def __init__(self):
		color=(uniform(0,1), uniform(0,1), uniform(0,1), 1)
		while max(color[:3]) < 0.9:
			color=(uniform(0,1), uniform(0,1), uniform(0,1), 1)

		spark_emitter = StaticEmitter(
			template=Particle(
				position=(uniform(-50, 50), uniform(-30, 30), uniform(-30, 30)), 
				color=color), 
			deviation=Particle(