Esempio n. 1
0
    def __init__(self, window):
        self.window = window
        window.set_fullscreen(True)

        self.fps = ClockDisplay()
        self.mesh_width = 512
        self.mesh_height = 512

        self.width = 1024
        self.height = 1024
        self.shaders = {}

        self.framebuffer = Framebuffer()
        self.window.push_handlers(self)
        
        font_dir = here('style/fonts')
        for name in res_listdir(here('style/fonts')):
            font_path = os.path.join(font_dir, name)
            pyglet.font.add_file(res_open(font_path))
        
        self.root = Root(self.window, here('style/style.hss'))

        self.file_open = FileOpen(self.root, pattern=r'.*\.lth$')
        self.file_open.on_file = self.open
        
        self.file_save = FileSave(self.root, pattern=r'.*\.lth$')
        self.file_save.on_file = self.save

        self.export_png_dialog = FileSave(self.root, pattern=r'.*\.png$')
        self.export_png_dialog.on_file = self.export_png
        
        self.viewport = View3d(self).append_to(self.root)

        self.work_area = Area(id='sidebar').append_to(self.root)
        self.workspace = Workspace().append_to(self.work_area)
        self.canvas = LineCanvas().append_to(self.workspace)
        self.processing_view = Screen(0, 0, self.width, self.height)
        self.ambient_occlusion = AmbientOcclusion(self)
        self.terrain = Terrain(self)
        
        self.export_obj_dialog = FileSave(self.root, pattern=r'.*\.obj$')
        self.export_obj_dialog.on_file = self.terrain.export_obj
        
        self.export_heights_dialog = FileSave(self.root, pattern=r'.*\.farr$')
        self.export_heights_dialog.on_file = self.terrain.export_float_array

        self.toolbar = Toolbar(self)
        self.node_factory = NodeFactory(self)
        pyglet.clock.schedule_interval(self.update, 0.05)
        pyglet.clock.schedule(lambda delta: None) #DEBUG
        self.temp = self.create_texture()
        self.height_reset = self.shader('height_reset.frag')

        self.nodes = []
        self.export_target = Texture(self.width, self.height, format=GL_RGB)
Esempio n. 2
0
    def __init__(self, window):
        self.window = window
        window.set_fullscreen(False)

        font_dir = here('style/fonts')
        window.push_handlers(self.on_draw)
        for name in res_listdir(here('style/fonts')):
            font_path = os.path.join(font_dir, name)
            pyglet.font.add_file(res_open(font_path))

        self.root = Root(window, here('style/style.hss'))
Esempio n. 3
0
    def __init__(self, window):
        self.window = window
        window.set_fullscreen(False)

        font_dir = here('style/fonts')
        window.push_handlers(self.on_draw)
        for name in res_listdir(here('style/fonts')):
            font_path = os.path.join(font_dir, name)
            pyglet.font.add_file(res_open(font_path))
        
        self.root = Root(window, here('style/style.hss'))
Esempio n. 4
0
 def shader(self, *names, **kwargs):
     if names in self.shaders:
         return self.shaders[names]
     else:
         shader = ShaderProgram(*[
             FragmentShader.open(res_open(here('shaders/%s' % name)))
             if name.endswith('.frag') else
             VertexShader.open(res_open(here('shaders/%s' % name)))
             for name in names
         ], **kwargs)
         self.shaders[names] = shader
         return shader
    def __init__(self, window):
        self.window = window
        window.set_fullscreen(True)

        self.fps = ClockDisplay()
        self.mesh_width = 512
        self.mesh_height = 512

        self.width = 1024
        self.height = 1024
        self.shaders = {}

        self.framebuffer = Framebuffer()
        self.window.push_handlers(self)

        font_dir = here('style/fonts')
        for name in res_listdir(here('style/fonts')):
            font_path = os.path.join(font_dir, name)
            pyglet.font.add_file(res_open(font_path))

        self.root = Root(self.window, here('style/style.hss'))

        self.file_open = FileOpen(self.root, pattern=r'.*\.lth$')
        self.file_open.on_file = self.open

        self.file_save = FileSave(self.root, pattern=r'.*\.lth$')
        self.file_save.on_file = self.save

        self.export_png_dialog = FileSave(self.root, pattern=r'.*\.png$')
        self.export_png_dialog.on_file = self.export_png

        self.work_area = Area(id='sidebar').append_to(self.root)
        self.workspace = Workspace().append_to(self.work_area)
        self.canvas = LineCanvas().append_to(self.workspace)
        self.processing_view = Screen(0, 0, self.width, self.height)
        self.terrain = Terrain(self)

        self.export_obj_dialog = FileSave(self.root, pattern=r'.*\.obj$')
        self.export_obj_dialog.on_file = self.terrain.export_obj

        self.export_heights_dialog = FileSave(self.root, pattern=r'.*\.farr$')
        self.export_heights_dialog.on_file = self.terrain.export_float_array

        self.viewport = View3d(self).append_to(self.root)
        self.toolbar = Toolbar(self)
        self.node_factory = NodeFactory(self)
        pyglet.clock.schedule_interval(self.update, 0.05)
        pyglet.clock.schedule(lambda delta: None)  #DEBUG
        self.temp = self.create_texture()
        self.height_reset = self.shader('height_reset.frag')

        self.nodes = []
        self.export_target = Texture(self.width, self.height, format=GL_RGB)
 def shader(self, *names, **kwargs):
     if names in self.shaders:
         return self.shaders[names]
     else:
         shader = ShaderProgram(
             *[
                 FragmentShader.open(res_open(here('shaders/%s' % name)))
                 if name.endswith('.frag') else VertexShader.open(
                     res_open(here('shaders/%s' % name))) for name in names
             ], **kwargs)
         self.shaders[names] = shader
         return shader
 def load_lighting(self, name, **kwargs):
     return ShaderProgram(
         VertexShader.open(res_open(here('shaders/lighting/default.vert'))),
         FragmentShader.open(res_open(here('shaders/lighting/%s' % name))),
         **kwargs
     )