Пример #1
0
    def run(self):
        if window.show_ursina_splash:
            from ursina.prefabs import ursina_splash

        application.load_settings()
        print('development mode:', application.development_mode)
        print('application successfully started')

        super().run()
Пример #2
0
    def run(self, info=True):
        if window.show_ursina_splash:
            from ursina.prefabs import ursina_splash

        application.load_settings()
        if info:
            print('screen resolution:', window.screen_resolution)
            print('os:', platform.system())
            print('development mode:', application.development_mode)
            print('application successfully started')

        super().run()
Пример #3
0
    def __init__(
        self, **kwargs
    ):  # optional arguments: title, fullscreen, size, position, vsync, borderless, show_ursina_splash, render_mode, development_mode, editor_ui_enabled.
        for name in ('size', 'vsync'):
            if name in kwargs and hasattr(window, name):
                setattr(window, name, kwargs[name])

        if 'development_mode' in kwargs:
            application.development_mode = kwargs['development_mode']

        super().__init__()
        application.base = base
        gltf.patch_loader(self.loader)

        window.late_init()
        for name in ('title', 'fullscreen', 'position', 'show_ursina_splash',
                     'borderless', 'render_mode'):
            if name in kwargs and hasattr(window, name):
                setattr(window, name, kwargs[name])

        # camera
        camera._cam = base.camera
        camera._cam.reparent_to(camera)
        camera.render = base.render
        camera.position = (0, 0, -20)
        scene.camera = camera
        camera.set_up()

        # input
        base.buttonThrowers[0].node().setButtonDownEvent('buttonDown')
        base.buttonThrowers[0].node().setButtonUpEvent('buttonUp')
        base.buttonThrowers[0].node().setButtonRepeatEvent('buttonHold')
        self._input_name_changes = {
            'mouse1': 'left mouse down',
            'mouse1 up': 'left mouse up',
            'mouse2': 'middle mouse down',
            'mouse2 up': 'middle mouse up',
            'mouse3': 'right mouse down',
            'mouse3 up': 'right mouse up',
            'wheel_up': 'scroll up',
            'wheel_down': 'scroll down',
            'arrow_left': 'left arrow',
            'arrow_left up': 'left arrow up',
            'arrow_up': 'up arrow',
            'arrow_up up': 'up arrow up',
            'arrow_down': 'down arrow',
            'arrow_down up': 'down arrow up',
            'arrow_right': 'right arrow',
            'arrow_right up': 'right arrow up',
            'lcontrol': 'left control',
            'rcontrol': 'right control',
            'lshift': 'left shift',
            'rshift': 'right shift',
            'lalt': 'left alt',
            'ralt': 'right alt',
            'lcontrol up': 'left control up',
            'rcontrol up': 'right control up',
            'lshift up': 'left shift up',
            'rshift up': 'right shift up',
            'lalt up': 'left alt up',
            'ralt up': 'right alt up',
            'control-mouse1': 'left mouse down',
            'control-mouse2': 'middle mouse down',
            'control-mouse3': 'right mouse down',
            'shift-mouse1': 'left mouse down',
            'shift-mouse2': 'middle mouse down',
            'shift-mouse3': 'right mouse down',
            'alt-mouse1': 'left mouse down',
            'alt-mouse2': 'middle mouse down',
            'alt-mouse3': 'right mouse down',
            'page_down': 'page down',
            'page_down up': 'page down up',
            'page_up': 'page up',
            'page_up up': 'page up up',
        }
        self.accept('buttonDown', self.input)
        self.accept('buttonUp', self.input_up)
        self.accept('buttonHold', self.input_hold)

        base.disableMouse()
        mouse._mouse_watcher = base.mouseWatcherNode
        mouse.enabled = True
        self.mouse = mouse

        from ursina import gamepad

        scene.set_up()
        self._update_task = taskMgr.add(self._update, "update")

        # try to load settings that need to be applied before entity creation
        application.load_settings()

        from ursina import HotReloader
        # make sure it's running from a file and not an interactive session.
        application.hot_reloader = HotReloader(
            __main__.__file__ if hasattr(__main__, '__file__') else 'None')

        window.make_editor_gui()
        if 'editor_ui_enabled' in kwargs:
            window.editor_ui.enabled = kwargs['editor_ui_enabled']
Пример #4
0
    def __init__(self):
        super().__init__()
        application.base = base
        window.late_init()
        time.dt = 0

        # camera
        camera._cam = base.camera
        camera._cam.reparent_to(camera)
        camera.parent = base.render
        camera.render = base.render
        camera.position = (0, 0, -20)
        scene.camera = camera
        camera.reparent_to(base.render)
        camera.set_up()
        # base.render.set_antialias(AntialiasAttrib.MMultisample)
        self.accept('aspectRatioChanged', window.update_aspect_ratio)

        # input
        base.buttonThrowers[0].node().setButtonDownEvent('buttonDown')
        base.buttonThrowers[0].node().setButtonUpEvent('buttonUp')
        base.buttonThrowers[0].node().setButtonRepeatEvent('buttonHold')
        self._input_name_changes = {
            'mouse1': 'left mouse down',
            'mouse1 up': 'left mouse up',
            'mouse2': 'middle mouse down',
            'mouse2 up': 'middle mouse up',
            'mouse3': 'right mouse down',
            'mouse3 up': 'right mouse up',
            'wheel_up': 'scroll up',
            'wheel_down': 'scroll down',
            'arrow_left': 'left arrow',
            'arrow_left up': 'left arrow up',
            'arrow_up': 'up arrow',
            'arrow_up up': 'up arrow up',
            'arrow_down': 'down arrow',
            'arrow_down up': 'down arrow up',
            'arrow_right': 'right arrow',
            'arrow_right up': 'right arrow up',
            'lcontrol': 'left control',
            'rcontrol': 'right control',
            'lshift': 'left shift',
            'rshift': 'right shift',
            'lalt': 'left alt',
            'ralt': 'right alt',
            'lcontrol up': 'left control up',
            'rcontrol up': 'right control up',
            'lshift up': 'left shift up',
            'rshift up': 'right shift up',
            'lalt up': 'left alt up',
            'ralt up': 'right alt up',
            'control-mouse1': 'left mouse down',
            'control-mouse2': 'middle mouse down',
            'control-mouse3': 'right mouse down',
            'shift-mouse1': 'left mouse down',
            'shift-mouse2': 'middle mouse down',
            'shift-mouse3': 'right mouse down',
            'alt-mouse1': 'left mouse down',
            'alt-mouse2': 'middle mouse down',
            'alt-mouse3': 'right mouse down',
            'page_down': 'page down',
            'page_down up': 'page down up',
            'page_up': 'page up',
            'page_up up': 'page up up',
        }
        self.accept('buttonDown', self.input)
        self.accept('buttonUp', self.input_up)
        self.accept('buttonHold', self.input_hold)

        base.disableMouse()
        mouse._mouse_watcher = base.mouseWatcherNode
        mouse.enabled = True
        self.mouse = mouse

        scene.set_up()
        self._update_task = taskMgr.add(self._update, "update")

        # try to load settings that need to be applied before entity creation
        application.load_settings()

        from ursina import HotReloader
        # make sure it's running from a file and not an interactive session.
        application.hot_reloader = HotReloader(
            __main__.__file__ if hasattr(__main__, '__file__') else 'None')

        window.make_editor_gui()