Exemplo n.º 1
0
Arquivo: animate.py Projeto: msarch/py
def animate(field):
    e = Engine(field,fullscreen=True)
    # normal loop : run the preview at good rate
    clock.schedule_interval(e.paint_a_frame, FRAMERATE)
    # and try (soft) to run anim at same speed
    clock.schedule_interval_soft(e.tick, FRAMERATE)
    pyglet.app.run()
Exemplo n.º 2
0
Arquivo: engine.py Projeto: msarch/py
def main():
        # schedule pyglet  loop at max framerate
        # and the tick function at more than fps
        # frame / time driven loop
    options = {
    'DEBUG': 1,
    'PREVIEW_SIZE': (800, 600),
    'BGCOLOR': (0.95, 0.95, 0.95, 0),  # background
    'FPS': 60,  # display max framerate
    'PicPS': 25,  # images per second for movie export
    'MODE': 'PREVIEW',  # options are: 'FULL'; 'PREVIEW'; 'EXPORT'
    'DURATION' : 3,
    'SCENE_FOLDER' : 'scene',
    }

    engine = Engine(**options)

    #---run loop options-------------------------------------------------------
    if  engine.MODE in ('FULL','PREVIEW'):
        clock.schedule_interval(engine.frame_paint,1.0/engine.FPS)
        clock.schedule_interval_soft(engine.tick, 1.0/(1.0*engine.FPS))
    elif engine.MODE == 'EXPORT': # export loop
        # try (soft) to run export method at final anim speed,
        clock.schedule_interval_soft(engine.export_loop,1.0/engine.PicPS)
        # while (soft) run the preview at good rate
        #clock.schedule_interval_soft(self.frame_, 1.0/self.FPS,scene)

    pyglet.app.run()
Exemplo n.º 3
0
def main():
    # schedule pyglet  loop at max framerate
    # and the tick function at more than fps
    # frame / time driven loop
    options = {
        'DEBUG': 1,
        'PREVIEW_SIZE': (800, 600),
        'BGCOLOR': (0.95, 0.95, 0.95, 0),  # background
        'FPS': 60,  # display max framerate
        'PicPS': 25,  # images per second for movie export
        'MODE': 'PREVIEW',  # options are: 'FULL'; 'PREVIEW'; 'EXPORT'
        'DURATION': 3,
        'SCENE_FOLDER': 'scene',
    }

    engine = Engine(**options)

    #---run loop options-------------------------------------------------------
    if engine.MODE in ('FULL', 'PREVIEW'):
        clock.schedule_interval(engine.frame_paint, 1.0 / engine.FPS)
        clock.schedule_interval_soft(engine.tick, 1.0 / (1.0 * engine.FPS))
    elif engine.MODE == 'EXPORT':  # export loop
        # try (soft) to run export method at final anim speed,
        clock.schedule_interval_soft(engine.export_loop, 1.0 / engine.PicPS)
        # while (soft) run the preview at good rate
        #clock.schedule_interval_soft(self.frame_, 1.0/self.FPS,scene)

    pyglet.app.run()
Exemplo n.º 4
0
def animate(field):
    e = Engine(field, fullscreen=True)
    # normal loop : run the preview at good rate
    clock.schedule_interval(e.paint_a_frame, FRAMERATE)
    # and try (soft) to run anim at same speed
    clock.schedule_interval_soft(e.tick, FRAMERATE)
    pyglet.app.run()
Exemplo n.º 5
0
    def setup_pyglet(self):
        """Configure Pyglet attributes.

        """
        self.window = window.Window(visible=False, caption=CAPTION,
                                    fullscreen=config.fullscreen)
        clock.schedule_interval_soft(self.tick, 1.0 / TICK_RATE)
        clock.schedule_interval_soft(self.update, 1.0 / UPDATE_RATE)
Exemplo n.º 6
0
    def pypen_loop(self, dt, *args):
        self.delta_time = dt
        self.passed_time += dt
        self.frame_count += 1

        clock.unschedule(self.pypen_loop)
        self.call_user_update()
        clock.schedule_interval_soft(self.pypen_loop, 1/self.pypen.user_sketch.settings.fps)
Exemplo n.º 7
0
    def setup_pyglet(self):
        """Configure Pyglet attributes.

        """
        self.window = window.Window(visible=False, caption=CAPTION,
                fullscreen=config.fullscreen)
        clock.schedule_interval_soft(self.tick, 1.0 / TICK_RATE)
        clock.schedule_interval_soft(self.update, 1.0 / UPDATE_RATE)
        self.window.set_mouse_cursor(window.ImageMouseCursor(data.load_image("cursor.png"), 4, 60))
Exemplo n.º 8
0
 def run(self):
     if self.mode in ('FULL', 'PREVIEW'):  # normal loop
         # run the preview at good rate
         clock.schedule_interval(self.frame_paint, self.framerate)
         # and try (soft) to run export method at final anim speed,
         clock.schedule_interval_soft(self.tick, self.framerate)
     elif self.mode == 'EXPORT':  # trigger the export loop
         clock.schedule_interval_soft(self.pic_export_loop, movie_framerate)
     pyglet.app.run()
Exemplo n.º 9
0
    def setup_pyglet(self):
        """Configure Pyglet attributes.

        """
        self.window = window.Window(visible=False,
                                    caption=CAPTION,
                                    fullscreen=config.fullscreen)
        clock.schedule_interval_soft(self.tick, 1.0 / TICK_RATE)
        clock.schedule_interval_soft(self.update, 1.0 / UPDATE_RATE)
Exemplo n.º 10
0
 def _update_schedule(self):
     clock.unschedule(self.dispatch_events)
     if self._playing and self._sources:
         interval = 1000.0
         if self._sources[0].video_format:
             interval = min(interval, 1 / 24.0)
         if self._audio:
             interval = min(interval, self._audio.UPDATE_PERIOD)
         clock.schedule_interval_soft(self.dispatch_events, interval)
Exemplo n.º 11
0
 def _update_schedule(self):
     clock.unschedule(self.dispatch_events)
     if self._playing and self._sources:
         interval = 1000.
         if self._sources[0].video_format:
             interval = min(interval, 1 / 24.)
         if self._audio:
             interval = min(interval, self._audio.UPDATE_PERIOD)
         clock.schedule_interval_soft(self.dispatch_events, interval)
Exemplo n.º 12
0
Arquivo: gui.py Projeto: msarch/py
 def run(self):
     if MODE in ('FULLSCREEN', 'PREVIEW'):  # normal loop
         # run the preview at good rate
         clock.schedule_interval(self.frame_paint, FRAMERATE)
         # and try (soft) to run export method at final anim speed,
         clock.schedule_interval_soft(self.tick, FRAMERATE)
     elif MODE == 'EXPORT':  # trigger the export loop
         clock.schedule_interval_soft(self.pic_export_loop, MOVIE_FRAMERATE)
     pyglet.app.run()
Exemplo n.º 13
0
Arquivo: engine.py Projeto: msarch/py
 def run(self):
     if MODE in ('FULLSCREEN', 'PREVIEW'):  # normal loop
         # run the preview at good rate
         clock.schedule_interval(self.frame_paint, FRAMERATE)
         # and try (soft) to run export method at final anim speed,
         clock.schedule_interval_soft(self.tick, FRAMERATE)
     elif MODE == 'EXPORT':  # trigger the export loop
         clock.schedule_interval_soft(self.pic_export_loop, MOVIE_FRAMERATE)
     pyglet.app.run()
Exemplo n.º 14
0
    def call_user_start(self, dt):
        if self.pypen.user_sketch.settings._user_has_start:
            self.pypen.user_sketch.start()
            if not self.arguments.fullscreen:
                self.set_size(self.pypen.user_sketch.settings.width, self.pypen.user_sketch.settings.height)

        self.set_visible()

        clock.schedule_interval_soft(self.pypen_loop, 1/self.pypen.user_sketch.settings.fps)
Exemplo n.º 15
0
 def run(self):
     if self.mode in ('FULL', 'PREVIEW'):  # normal loop
         # run the preview at good rate
         clock.schedule_interval(self.frame_paint, self.framerate)
         # and try (soft) to run export method at final anim speed,
         clock.schedule_interval_soft(self.tick, self.framerate)
     elif self.mode == 'EXPORT':  # trigger the export loop
         clock.schedule_interval_soft(self.pic_export_loop, movie_framerate)
     pyglet.app.run()
Exemplo n.º 16
0
    def setup_pyglet(self):
        """Configure Pyglet attributes.

        """
        self.window = window.Window(width=800, height=600, visible=False, caption="Ookoobah", resizable=True, fullscreen=False)
        self.window.set_fullscreen(True)
        self.gui = gui.Manager(self.window)
        clock.schedule_interval_soft(self.tick, 1 / 60)

        sounds.load()
Exemplo n.º 17
0
    def setup_pyglet(self):
        """Configure Pyglet attributes.

        """
        self.window = window.Window(visible=False,
                                    caption=CAPTION,
                                    fullscreen=config.fullscreen)
        clock.schedule_interval_soft(self.tick, 1.0 / TICK_RATE)
        clock.schedule_interval_soft(self.update, 1.0 / UPDATE_RATE)
        self.window.set_mouse_cursor(
            window.ImageMouseCursor(data.load_image("cursor.png"), 4, 60))
Exemplo n.º 18
0
Arquivo: animate.py Projeto: msarch/py
def export(field,duration):
    abspath = os.path.abspath(__file__)
    parent = os.path.dirname(os.path.dirname(abspath))
    imgdir = os.path.join (parent, 'out')
    try:
        os.makedirs(imgdir)
    except OSError:
        pass
    os.chdir(imgdir)
    field.duration=duration
    e = Engine(field,fullscreen=False)
    clock.schedule_interval_soft(e.pic_export_loop, MOVIE_FRAMERATE)
    pyglet.app.run()
Exemplo n.º 19
0
def export(field, duration):
    abspath = os.path.abspath(__file__)
    parent = os.path.dirname(os.path.dirname(abspath))
    imgdir = os.path.join(parent, 'out')
    try:
        os.makedirs(imgdir)
    except OSError:
        pass
    os.chdir(imgdir)
    field.duration = duration
    e = Engine(field, fullscreen=False)
    clock.schedule_interval_soft(e.pic_export_loop, MOVIE_FRAMERATE)
    pyglet.app.run()
Exemplo n.º 20
0
 def start_game(self, controller, player_name = "Samus", host="localhost", game_name = "Deathtroid"):
   self.menu = None
   #self.init_gl()
   if controller == "server" or controller == "both":
     if self.server == None:
       self.server = server_controller.ServerController(game_name)
     #clock.schedule(self.server.update)
     clock.schedule_interval_soft(self.server.update, 1./30.)
   
   if controller == "client" or controller == "both":
     if self.client == None:
       self.client = client_controller.ClientController(player_name, host)
     clock.schedule(self.client.update)
Exemplo n.º 21
0
def animiraj_beziera(dt):
    global normalan_bezier, t, t_pomak, prva

    if not normalan_bezier:
        t += t_pomak
        if t <= 0.0:
            t_pomak = 1.0
        elif t >= 100.0:
            t_pomak = -1.0
        t_t = t/100
        x, y, z = 0, 0, 0
        i = 0
        n = len(tijelo.kontrola) - 1
        glColor3f(1.0, 1.0, 1.0)
        glPointSize(8.0)
        glBegin(GL_POINTS)
        for x_k, y_k, z_k in tijelo.kontrola.values():
            b = (math.factorial(n) / (math.factorial(i) * math.factorial(n - i))) * pow(t_t, i) * pow(1 - t_t, n - i)
            x += b * x_k
            y += b * y_k
            z += b * z_k
            i += 1
        glVertex3f(x, y, z)
        glEnd()
        srediste = x, y, z, 1.0
        tijelo.animiranje(srediste)
        glPointSize(2.0)
        glColor3f(0, 0, 0)
        glBegin(GL_LINES)
        for ravnina in tijelo.ravnine.keys():
            a, b, c, d = tijelo.ravnine.get(ravnina)
            kut = a*tijelo.tocka_O[0] + b*tijelo.tocka_O[1] + c*tijelo.tocka_O[2] + d
            if kut < 0:
                continue
            t1, t2, t3 = tijelo.bridovi.get(ravnina)
            x1, y1, z1, h1 = tijelo.vrhovi_t.get(t1)
            x2, y2, z2, h2 = tijelo.vrhovi_t.get(t2)
            x3, y3, z3, h3 = tijelo.vrhovi_t.get(t3)
            glVertex3f(x1, y1, z1)
            glVertex3f(x2, y2, z2)
            glVertex3f(x2, y2, z2)
            glVertex3f(x3, y3, z3)
            glVertex3f(x3, y3, z3)
            glVertex3f(x1, y1, z1)
        glEnd()
    if prva:
        clock.schedule_interval_soft(animiraj_beziera, 1.0/10)
        prva = False
    return
Exemplo n.º 22
0
Arquivo: engine.py Projeto: msarch/py
def export(duration):
    VIEW.set_size(PREVIEW_SIZE[0], PREVIEW_SIZE[1])
    # @TODO : check if bigger than screen, then set fullscreen
    # or 80% of screen, print error message
    # then set XMAX,YMAX
    abspath = os.path.abspath(__file__)
    parent = os.path.dirname(os.path.dirname(abspath))
    imgdir = os.path.join(parent, 'out')
    try:
        os.makedirs(imgdir)
    except OSError:
        pass
    os.chdir(imgdir)
    clock.schedule_interval_soft(pic_export_loop, MOVIE_FRAMERATE)
    pyglet.app.run()
Exemplo n.º 23
0
Arquivo: engine.py Projeto: msarch/py
def export(duration):
    VIEW.set_size(PREVIEW_SIZE[0], PREVIEW_SIZE[1])
    # @TODO : check if bigger than screen, then set fullscreen
    # or 80% of screen, print error message
    # then set XMAX,YMAX
    abspath = os.path.abspath(__file__)
    parent = os.path.dirname(os.path.dirname(abspath))
    imgdir = os.path.join (parent, 'out')
    try:
        os.makedirs(imgdir)
    except OSError:
        pass
    os.chdir(imgdir)
    clock.schedule_interval_soft(pic_export_loop, MOVIE_FRAMERATE)
    pyglet.app.run()
Exemplo n.º 24
0
Arquivo: engine.py Projeto: msarch/py
    def run(self,scene):
            # schedule pyglet  loop at max framerate
            # and the update function at more than fps
            # frame / time driven loop
        self.scene=scene

        if  self.MODE in ('FULL','PREVIEW'):
            clock.schedule_interval(self.frame_,1.0/self.FPS)
            clock.schedule_interval_soft(self.update, 1.0/(1.0*self.FPS))
        elif self.MODE == 'EXPORT': # export loop
            # try (soft) to run export method at final anim speed,
            clock.schedule_interval_soft(self.export_loop,1.0/self.PicPS)
            # while (soft) run the preview at good rate
            #clock.schedule_interval_soft(self.frame_, 1.0/self.FPS,scene)

        pyglet.app.run()
Exemplo n.º 25
0
    def run(self, scene):
        # schedule pyglet  loop at max framerate
        # and the update function at more than fps
        # frame / time driven loop
        self.scene = scene

        if self.MODE in ('FULL', 'PREVIEW'):
            clock.schedule_interval(self.frame_, 1.0 / self.FPS)
            clock.schedule_interval_soft(self.update, 1.0 / (1.0 * self.FPS))
        elif self.MODE == 'EXPORT':  # export loop
            # try (soft) to run export method at final anim speed,
            clock.schedule_interval_soft(self.export_loop, 1.0 / self.PicPS)
            # while (soft) run the preview at good rate
            #clock.schedule_interval_soft(self.frame_, 1.0/self.FPS,scene)

        pyglet.app.run()
Exemplo n.º 26
0
Arquivo: engine.py Projeto: msarch/py
    def run(self):
            # schedule pyglet ondraw loop at max framerate
            # and the update function at more than fps
            # frame / time driven loop

        if  self.MODE in ('FULL','PREVIEW'):
            clock.schedule_interval(self.frame_draw,1.0/self.FPS)
            clock.schedule_interval_soft(self.update, 1.0/(1.0*self.FPS))
        elif self.MODE == 'EXPORT': # export loop
            # try to run export method at final anim speed,
            clock.schedule_interval_soft(self.export_loop,1.0/self.PicPS)
            # anyway run preview at good rate
            clock.schedule_interval_soft(self.frame_draw, 1.0/self.FPS)

        pyglet.app.run()
Exemplo n.º 27
0
    def run(self):
        # schedule pyglet ondraw loop at max framerate
        # and the update function at more than fps
        # frame / time driven loop

        if self.MODE in ('FULL', 'PREVIEW'):
            clock.schedule_interval(self.frame_draw, 1.0 / self.FPS)
            clock.schedule_interval_soft(self.update, 1.0 / (1.0 * self.FPS))
        elif self.MODE == 'EXPORT':  # export loop
            # try to run export method at final anim speed,
            clock.schedule_interval_soft(self.export_loop, 1.0 / self.PicPS)
            # anyway run preview at good rate
            clock.schedule_interval_soft(self.frame_draw, 1.0 / self.FPS)

        pyglet.app.run()
Exemplo n.º 28
0
 def schedule_update_if_needed(self):
   clock.unschedule(self.update)
   if self._callback or self.entity:
     clock.schedule_interval_soft(self.update, 1./10.)
Exemplo n.º 29
0
Arquivo: animate.py Projeto: msarch/py
def export(field):
    e = Engine(field)
    clock.schedule_interval_soft(e.pic_export_loop, MOVIE_FRAMERATE)
    pyglet.app.run()