예제 #1
0
    def __init__(self, parent=None, x=0, y=0, chb_callback=None,
                 chb_args=None, chb_checked=True, text="", text_size=18,
                 radio=False, text_color=None, expand_width=100, enabled=True):
        """ Constructs a new checkbox, forwarding most of the elements to the
        underlying Checkbox and Text. """
        RPObject.__init__(self)
        if chb_args is None:
            chb_args = []

        if text_color is None:
            text_color = Vec3(1)

        if not enabled:
            text_color = Vec3(1.0, 0, 0.28)

        self.text_color = text_color

        self._checkbox = Checkbox(
            parent=parent, x=x, y=y, enabled=enabled, callback=chb_callback,
            extra_args=chb_args, checked=chb_checked, radio=radio,
            expand_width=expand_width)
        self._text = Text(
            x=x + 26, y=y + 10 + text_size // 4, text=text, align="left",
            parent=parent, size=text_size, color=text_color, may_change=True)

        if enabled:
            self._checkbox.node.bind(DGG.WITHIN, self._on_node_enter)
            self._checkbox.node.bind(DGG.WITHOUT, self._on_node_leave)
 def __init__(self):
     """ Initializes a new probe manager """
     RPObject.__init__(self)
     self.probes = []
     self.max_probes = 3
     self.resolution = 128
     self.diffuse_resolution = 4
예제 #3
0
 def __init__(self, pipeline):
     """ Inits the plugin """
     self._pipeline = pipeline
     self._assigned_stages = []
     self.plugin_id = str(self.__class__.__module__).split(".")[-2]
     RPObject.__init__(self, "plugin:" + self.plugin_id)
     self._set_debug_color("magenta", "bright")
예제 #4
0
    def __init__(self, outdated_parameter=None):
        """ Creates a new pipeline with a given showbase instance. This should
        be done before intializing the ShowBase, the pipeline will take care of
        that. """
        RPObject.__init__(self)
        if outdated_parameter is not None:
            self.fatal("The render pipeline no longer takes the ShowBase argument "
                       "as constructor parameter. Please have a look at the "
                       "00-Loading the pipeline sample to see how to initialize "
                       "the pipeline properly.")
        self.debug("Using Python {}.{} with architecture {}".format(
            sys.version_info.major, sys.version_info.minor, PandaSystem.get_platform()))
        self.debug("Using Panda3D {} built on {}".format(
            PandaSystem.get_version_string(), PandaSystem.get_build_date()))
        if PandaSystem.get_git_commit():
            self.debug("Using git commit {}".format(PandaSystem.get_git_commit()))
        else:
            self.debug("Using custom Panda3D build")
        self.mount_mgr = MountManager(self)
        self.settings = {}
        self._pre_showbase_initialized = False
        self._first_frame = None
        self.set_default_loading_screen()

        # Check for the right Panda3D version
        if not self._check_version():
            self.fatal("Your Panda3D version is outdated! Please update to the newest \n"
                       "git version! Checkout https://github.com/panda3d/panda3d to "
                       "compile panda from source, or get a recent buildbot build.")
예제 #5
0
 def __init__(self, pipeline, parent):
     """ Inits the widget """
     RPObject.__init__(self)
     self._pipeline = pipeline
     self._parent = parent
     self._node = self._parent.attach_new_node("ExposureWidgetNode")
     self._create_components()
예제 #6
0
 def __init__(self, pipeline, parent):
     """ Inits the widget """
     RPObject.__init__(self)
     self._pipeline = pipeline
     self._parent = parent
     self._node = self._parent.attach_new_node("FPSChartNode")
     self._create_components()
예제 #7
0
    def __init__(self, outdated_parameter=None):
        """ Creates a new pipeline with a given showbase instance. This should
        be done before intializing the ShowBase, the pipeline will take care of
        that. """
        RPObject.__init__(self)
        if outdated_parameter is not None:
            self.fatal(
                "The render pipeline no longer takes the ShowBase argument "
                "as constructor parameter. Please have a look at the "
                "00-Loading the pipeline sample to see how to initialize "
                "the pipeline properly.")
        self.debug("Using Python {}.{} with architecture {}".format(
            sys.version_info.major, sys.version_info.minor,
            PandaSystem.get_platform()))
        self.debug("Using Panda3D {} built on {}".format(
            PandaSystem.get_version_string(), PandaSystem.get_build_date()))
        if PandaSystem.get_git_commit():
            self.debug("Using git commit {}".format(
                PandaSystem.get_git_commit()))
        else:
            self.debug("Using custom Panda3D build")
        self.mount_mgr = MountManager(self)
        self.settings = {}
        self._pre_showbase_initialized = False
        self._first_frame = None
        self.set_default_loading_screen()

        # Check for the right Panda3D version
        if not self._check_version():
            self.fatal(
                "Your Panda3D version is outdated! Please update to the newest \n"
                "git version! Checkout https://github.com/panda3d/panda3d to "
                "compile panda from source, or get a recent buildbot build.")
예제 #8
0
 def __init__(self, pipeline):
     """ Inits the plugin """
     self._pipeline = pipeline
     self._assigned_stages = []
     self.plugin_id = str(self.__class__.__module__).split(".")[-2]
     RPObject.__init__(self, "plugin:" + self.plugin_id)
     self._set_debug_color("magenta", "bright")
예제 #9
0
    def __init__(self,
                 font="/$$rp/rpcore/data/font/Roboto-Bold.ttf",
                 pixel_size=16,
                 align="left",
                 pos=Vec2(0),
                 color=Vec3(1),
                 parent=None):
        """ Constructs a new text node, forwaring the parameters to the internal
        panda3d implementation """
        RPObject.__init__(self)
        self._node = TextNodeImpl('FTN')
        self._node.set_text("")
        self._node.set_align(getattr(TextNodeImpl, "A_" + align))
        self._node.set_text_color(color.x, color.y, color.z, 1)

        if parent is None:
            parent = Globals.base.aspect2d

        self._nodepath = parent.attach_new_node(self._node)
        self._nodepath.set_pos(pos.x, 0, pos.y)

        font = RPLoader.load_font(font)
        # font.set_outline(Vec4(0, 0, 0, 0.78), 1.6, 0.37)
        font.set_outline(Vec4(0, 0, 0, 1), 1.6, 0.37)
        font.set_scale_factor(1.0)
        font.set_texture_margin(int(pixel_size / 4.0 * 2.0))
        font.set_bg(Vec4(0, 0, 0, 0))
        self._node.set_font(font)
        self.set_pixel_size(pixel_size)
 def __init__(self, parent_stage, name="Cubemap", size=128):
     """ Inits the filter from a given stage """
     RPObject.__init__(self)
     self._stage = parent_stage
     self._name = name
     self._size = size
     self._make_maps()
예제 #11
0
 def __init__(self):
     """ Constructs a new empty effect """
     RPObject.__init__(self)
     self._effect_id = Effect._EFFECT_ID
     Effect._EFFECT_ID += 1
     self._options = copy.deepcopy(self._DEFAULT_OPTIONS)
     self._source = ""
예제 #12
0
파일: effect.py 프로젝트: croxis/SpaceDrive
 def __init__(self):
     """ Constructs a new empty effect """
     RPObject.__init__(self)
     self._effect_id = Effect._EFFECT_ID
     Effect._EFFECT_ID += 1
     self._options = copy.deepcopy(self._DEFAULT_OPTIONS)
     self._source = ""
예제 #13
0
 def __init__(self, pipeline):
     """ Creates a new render stage """
     RPObject.__init__(self)
     self.stage_id = self.__class__.__name__
     self._pipeline = pipeline
     self._active = True
     self._targets = {}
예제 #14
0
 def __init__(self):
     """ Initializes a new probe manager """
     RPObject.__init__(self)
     self.probes = []
     self.max_probes = 3
     self.resolution = 128
     self.diffuse_resolution = 4
예제 #15
0
 def __init__(self, pipeline):
     """ Creates a new render stage """
     RPObject.__init__(self)
     self.stage_id = self.__class__.__name__
     self._pipeline = pipeline
     self._active = True
     self._targets = {}
    def __init__(self,
                 x=0,
                 y=0,
                 parent=None,
                 size=100,
                 min_value=0,
                 max_value=100,
                 value=50,
                 page_size=1,
                 callback=None,
                 extra_args=None):
        """ Inits the slider """
        RPObject.__init__(self)
        if extra_args is None:
            extra_args = []

        # Scale has to be 2.0, otherwise there will be an error.
        self._node = DirectSlider(
            pos=(size * 0.5 + x, 1, -y),
            parent=parent,
            range=(min_value, max_value),
            value=value,
            pageSize=page_size,
            scale=2.0,
            command=callback,
            extraArgs=extra_args,
            frameColor=(0.0, 0.0, 0.0, 1),
            frameSize=(-size * 0.25, size * 0.25, -5, 5),
            relief=DGG.FLAT,
            thumb_frameColor=(0.35, 0.53, 0.2, 1.0),
            thumb_relief=DGG.FLAT,
            thumb_frameSize=(-2.5, 2.5, -5.0, 5.0),
        )
예제 #17
0
    def __init__(self, data):
        self.type = data.pop("type")
        self.label = data.pop("label").strip()
        self.description = data.pop("description").strip()
        self.curves = []

        RPObject.__init__(self, "dsetting:{}".format(self.label))
예제 #18
0
    def __init__(self, data):
        self.type = data.pop("type")
        self.label = data.pop("label").strip()
        self.description = data.pop("description").strip()
        self.curves = []

        RPObject.__init__(self, "dsetting:{}".format(self.label))
예제 #19
0
    def __init__(self, text="", parent=None, x=0, y=0, size=10, align="left",
                 color=None, may_change=False, font=None):
        """ Constructs a new text. The parameters are almost equal to the
        parameters of OnscreenText """
        RPObject.__init__(self)

        if color is None:
            color = Vec3(1)

        align_mode = TextNode.A_left

        if align == "center":
            align_mode = TextNode.A_center
        elif align == "right":
            align_mode = TextNode.A_right

        if font is None:
            font = Globals.font
            # Should always have a global font. Never use the default panda font!
            assert font

        self._initial_pos = Vec2(x, -y)
        self._node = OnscreenText(
            text=text, parent=parent, pos=self._initial_pos, scale=size,
            align=align_mode, fg=Vec4(color.x, color.y, color.z, 1.0),
            font=font, mayChange=may_change)
예제 #20
0
 def __init__(self):
     """ Creates a new pipeline with a given showbase instance. This should
     be done before intializing the ShowBase, the pipeline will take care of
     that. If the showbase has been initialized before, have a look at
     the alternative initialization of the render pipeline (the first sample)."""
     RPObject.__init__(self)
     self.debug("Using Python {}.{} with architecture {}".format(
         sys.version_info.major, sys.version_info.minor,
         PandaSystem.get_platform()))
     self.debug("Using Panda3D {} built on {}".format(
         PandaSystem.get_version_string(), PandaSystem.get_build_date()))
     if PandaSystem.get_git_commit():
         self.debug("Using git commit {}".format(
             PandaSystem.get_git_commit()))
     else:
         self.debug("Using custom Panda3D build")
     if not self._check_version():
         self.fatal(
             "Your Panda3D version is outdated! Please update to the newest \n"
             "git version! Checkout https://github.com/panda3d/panda3d to "
             "compile panda from source, or get a recent buildbot build.")
     self.mount_mgr = MountManager(self)
     self.settings = {}
     self._pre_showbase_initialized = False
     self._first_frame = None
     self.set_loading_screen_image("/$$rp/data/gui/loading_screen_bg.txo")
예제 #21
0
 def __init__(self, parent_stage, name="Cubemap", size=128):
     """ Inits the filter from a given stage """
     RPObject.__init__(self)
     self._stage = parent_stage
     self._name = name
     self._size = size
     self._make_maps()
예제 #22
0
 def __init__(self, name):
     """ Internal method to create a new image """
     RPObject.__init__(self, name)
     Texture.__init__(self, name)
     Image.REGISTERED_IMAGES.append(self)
     self.set_clear_color(0)
     self.clear_image()
     self.sort = RenderTarget.CURRENT_SORT
예제 #23
0
 def __init__(self, name):
     """ Internal method to create a new image """
     RPObject.__init__(self, name)
     Texture.__init__(self, name)
     Image.REGISTERED_IMAGES.append(self)
     self.set_clear_color(0)
     self.clear_image()
     self.sort = RenderTarget.CURRENT_SORT
 def __init__(self,
              pipeline,
              image_source="/$$rp/data/gui/loading_screen_bg.txo"):
     """ Inits the loading screen with a given image source. By default,
     this is the pipeline loading screen, but it can be overridden. """
     RPObject.__init__(self)
     self.pipeline = pipeline
     self.image_source = image_source
예제 #25
0
 def __init__(self, pipeline):
     RPObject.__init__(self)
     self._pipeline = pipeline
     self._showbase = Globals.base
     self._ptas = {}
     self._load_fonts()
     self._load_textures()
     self._setup_inputs()
예제 #26
0
 def __init__(self, pipeline):
     RPObject.__init__(self)
     self._pipeline = pipeline
     self._showbase = Globals.base
     self._ptas = {}
     self._load_fonts()
     self._load_textures()
     self._setup_inputs()
예제 #27
0
    def __init__(self,
                 image=None,
                 parent=None,
                 x=0,
                 y=0,
                 w=None,
                 h=None,
                 transparent=True,
                 near_filter=True,
                 any_filter=True):
        """ Creates a new image, taking (x,y) as topleft coordinates.

        When near_filter is set to true, a near filter will be set to the
        texture passed. This provides sharper images.

        When any_filter is set to false, the passed image won't be modified at
        all. This enables you to display existing textures, otherwise the
        texture would get a near filter in the 3D View, too. """

        RPObject.__init__(self)

        if not isinstance(image, Texture):
            if not isinstance(image, str):
                self.warn("Invalid argument to image parameter:", image)
                return
            image = RPLoader.load_texture(image)

            if w is None or h is None:
                w, h = image.get_x_size(), image.get_y_size()
        else:
            if w is None or h is None:
                w = 10
                h = 10

        self._width, self._height = w, h
        self._initial_pos = self._translate_pos(x, y)

        self.node = OnscreenImage(image=image,
                                  parent=parent,
                                  pos=self._initial_pos,
                                  scale=(self._width / 2.0, 1,
                                         self._height / 2.0))

        if transparent:
            self.node.set_transparency(TransparencyAttrib.M_alpha)

        tex = self.node.get_texture()

        # Apply a near filter, but only if the parent has no scale, otherwise
        # it will look weird
        if near_filter and any_filter and parent.get_sx() == 1.0:
            tex.set_minfilter(SamplerState.FT_nearest)
            tex.set_magfilter(SamplerState.FT_nearest)

        if any_filter:
            tex.set_anisotropic_degree(8)
            tex.set_wrap_u(SamplerState.WM_clamp)
            tex.set_wrap_v(SamplerState.WM_clamp)
예제 #28
0
 def __init__(self, pipeline):
     """ Constructs the light manager """
     RPObject.__init__(self)
     self.pipeline = pipeline
     self.compute_tile_size()
     self.init_internal_manager()
     self.init_command_queue()
     self.initshadow_manager()
     self.init_stages()
    def __init__(self, internal_buffer, *args):
        RPObject.__init__(self)
        self._buffer = internal_buffer
        self._region = self._buffer.make_display_region(*args)
        self._node = NodePath("RTRoot")

        self._make_fullscreen_tri()
        self._make_fullscreen_cam()
        self._init_function_pointers()
예제 #30
0
 def __init__(self, pipeline):
     """ Constructs the light manager """
     RPObject.__init__(self)
     self.pipeline = pipeline
     self.compute_tile_size()
     self.init_internal_manager()
     self.init_command_queue()
     self.initshadow_manager()
     self.init_stages()
예제 #31
0
    def __init__(self, internal_buffer, *args):
        RPObject.__init__(self)
        self._buffer = internal_buffer
        self._region = self._buffer.make_display_region(*args)
        self._node = NodePath("RTRoot")

        self._make_fullscreen_tri()
        self._make_fullscreen_cam()
        self._init_function_pointers()
예제 #32
0
 def __exit__(self, *args):
     duration = (time.clock() - self.start_time) * 1000.0
     if duration > 80.0 and timed_loading_operation.WARNING_COUNT < 5:
         RPObject.global_warn(
             "RPLoader", "Loading '" + self.resource + "' took", round(duration, 2), "ms")
         timed_loading_operation.WARNING_COUNT += 1
         if timed_loading_operation.WARNING_COUNT == 5:
             RPObject.global_warn(
                 "RPLoader", "Skipping further loading warnings (max warning count reached)")
 def __init__(self):
     """ Inits a new environment probe """
     RPObject.__init__(self)
     self.index = -1
     self.last_update = -1
     self._transform = TransformState.make_identity()
     self._bounds = BoundingSphere(Vec3(0), 1.0)
     self._modified = True
     self._parallax_correction = True
     self._border_smoothness = 0.1
예제 #34
0
 def __init__(self, pipeline):
     RPObject.__init__(self)
     self._pipeline = pipeline
     self._commands_per_frame = 1024
     self._command_list = GPUCommandList()
     self._pta_num_commands = PTAInt.empty_array(1)
     self._create_data_storage()
     self._create_command_target()
     self._commands = []
     self._register_defines()
예제 #35
0
 def __init__(self):
     """ Constructs a new empty effect, this is a private constructor and
     should not be called. Instead, use Effect.load() """
     RPObject.__init__(self)
     self.effect_id = Effect._EFFECT_ID
     Effect._EFFECT_ID += 1
     self.filename = None
     self._options = self._DEFAULT_OPTIONS.copy()
     self._generated_shader_paths = {}
     self._shader_objs = {}
예제 #36
0
 def __init__(self, pipeline):
     RPObject.__init__(self)
     self._pipeline = pipeline
     self._commands_per_frame = 128
     self._command_list = GPUCommandList()
     self._pta_num_commands = PTAInt.empty_array(1)
     self._create_data_storage()
     self._create_command_target()
     self._commands = []
     self._register_defines()
예제 #37
0
 def __init__(self):
     """ Constructs a new empty effect, this is a private constructor and
     should not be called. Instead, use Effect.load() """
     RPObject.__init__(self)
     self.effect_id = Effect._EFFECT_ID
     Effect._EFFECT_ID += 1
     self.filename = None
     self._options = self._DEFAULT_OPTIONS.copy()
     self._generated_shader_paths = {}
     self._shader_objs = {}
예제 #38
0
 def __init__(self):
     """ Inits a new environment probe """
     RPObject.__init__(self)
     self.index = -1
     self.last_update = -1
     self._transform = TransformState.make_identity()
     self._bounds = BoundingSphere(Vec3(0), 1.0)
     self._modified = True
     self._parallax_correction = True
     self._border_smoothness = 0.1
 def __init__(self, width=800, height=500, title="Window", parent=None):
     """ Constructs a new window with the given dimensions and title """
     RPObject.__init__(self, "Window-" + title)
     self._width = width
     self._height = height
     self._title = title
     self._visible = True
     self._parent = parent if parent else Globals.base.pixel2d
     self._dragging = False
     self._drag_offset = Vec2(0)
     self._pos = Vec2(0)
예제 #40
0
 def __init__(self, width=800, height=500, title="Window", parent=None):
     """ Constructs a new window with the given dimensions and title """
     RPObject.__init__(self, "Window-" + title)
     self._width = width
     self._height = height
     self._title = title
     self._visible = True
     self._parent = parent if parent else Globals.base.pixel2d
     self._dragging = False
     self._drag_offset = Vec2(0)
     self._pos = Vec2(0)
예제 #41
0
 def __init__(self, pipeline):
     """ Creates the listener service. This also starts listening on the various
     ports for updates """
     RPObject.__init__(self)
     self._pipeline = pipeline
     self._config_updates = set()
     self._daytime_updates = set()
     self._config_thread = self.listen_threaded(
         self.CONFIG_PORT, self._config_updates.add)
     self._daytime_thread = self.listen_threaded(
         self.DAYTIME_PORT, self._daytime_updates.add)
예제 #42
0
    def __init__(self, data):
        """ Fills in all settings from the given setting data """
        self.value = None
        self.type = data.pop("type")
        self.label = data.pop("label").strip()
        self.description = data.pop("description").strip()
        self.runtime = data.pop("runtime", False)
        self.shader_runtime = data.pop("shader_runtime", False)
        self.display_conditions = data.pop("display_if", {})

        RPObject.__init__(self, "psetting:{}".format(self.label))
예제 #43
0
 def __init__(self, pipeline):
     """ Creates the listener service. This also starts listening on the various
     ports for updates """
     RPObject.__init__(self)
     self._pipeline = pipeline
     self._config_updates = set()
     self._daytime_updates = set()
     self._config_thread = self.listen_threaded(self.CONFIG_PORT,
                                                self._config_updates.add)
     self._daytime_thread = self.listen_threaded(self.DAYTIME_PORT,
                                                 self._daytime_updates.add)
예제 #44
0
    def __init__(self, pipeline):
        """ Constructs a new manager with no plugins loaded. To load settings
        and plugins, call load(). """
        RPObject.__init__(self)
        self._pipeline = pipeline
        self.settings = {}
        self.day_settings = {}
        self.instances = {}
        self.enabled_plugins = set()

        # Used by the plugin configurator and to only load the required data
        self.requires_daytime_settings = True
    def __init__(self,
                 parent=None,
                 x=0,
                 y=0,
                 callback=None,
                 extra_args=None,
                 radio=False,
                 expand_width=100,
                 checked=False,
                 enabled=True):
        RPObject.__init__(self)

        prefix = "checkbox" if not radio else "radiobox"

        if enabled:
            checked_img = RPLoader.load_texture("/$$rp/data/gui/" + prefix +
                                                "_checked.png")
            unchecked_img = RPLoader.load_texture("/$$rp/data/gui/" + prefix +
                                                  "_default.png")
        else:
            checked_img = RPLoader.load_texture("/$$rp/data/gui/" + prefix +
                                                "_disabled.png")
            unchecked_img = checked_img

        # Set near filter, otherwise textures look like crap
        for tex in [checked_img, unchecked_img]:
            tex.set_minfilter(SamplerState.FT_linear)
            tex.set_magfilter(SamplerState.FT_linear)
            tex.set_wrap_u(SamplerState.WM_clamp)
            tex.set_wrap_v(SamplerState.WM_clamp)
            tex.set_anisotropic_degree(0)

        self._node = DirectCheckBox(parent=parent,
                                    pos=(x + 11, 1, -y - 8),
                                    scale=(10 / 2.0, 1, 10 / 2.0),
                                    checkedImage=checked_img,
                                    uncheckedImage=unchecked_img,
                                    image=unchecked_img,
                                    extraArgs=extra_args,
                                    state=DGG.NORMAL,
                                    relief=DGG.FLAT,
                                    command=self._update_status)

        self._node["frameColor"] = (0, 0, 0, 0)
        self._node["frameSize"] = (-2.6, 2 + expand_width / 7.5, -2.35, 2.5)
        self._node.set_transparency(TransparencyAttrib.M_alpha)

        self._callback = callback
        self._extra_args = extra_args
        self._collection = None

        if checked:
            self.set_checked(True, False)
예제 #46
0
    def __init__(self, pipeline):
        """ Constructs a new manager with no plugins loaded. To load settings
        and plugins, call load(). """
        RPObject.__init__(self)
        self._pipeline = pipeline
        self.settings = {}
        self.day_settings = {}
        self.instances = {}
        self.enabled_plugins = set()

        # Used by the plugin configurator and to only load the required data
        self.requires_daytime_settings = True
 def __exit__(self, *args):
     duration = (time.clock() - self.start_time) * 1000.0
     if duration > 80.0 and timed_loading_operation.WARNING_COUNT < 5:
         RPObject.global_warn("RPLoader",
                              "Loading '" + self.resource + "' took",
                              round(duration, 2), "ms")
         timed_loading_operation.WARNING_COUNT += 1
         if timed_loading_operation.WARNING_COUNT == 5:
             RPObject.global_warn(
                 "RPLoader",
                 "Skipping further loading warnings (max warning count reached)"
             )
    def __init__(self, pipeline):
        """ Creates a new mount manager """
        RPObject.__init__(self)
        self._pipeline = pipeline
        self._base_path = self._find_basepath()
        self._lock_file = "instance.pid"
        self._model_paths = []
        self._write_path = None
        self._mounted = False
        self._do_cleanup = True

        self.debug("Auto-Detected base path to", self._base_path)
        atexit.register(self._on_exit_cleanup)
예제 #49
0
 def __init__(self):
     """ Creates a new pipeline with a given showbase instance. This should
     be done before intializing the ShowBase, the pipeline will take care of
     that. If the showbase has been initialized before, have a look at
     the alternative initialization of the render pipeline (the first sample)."""
     RPObject.__init__(self)
     self._analyze_system()
     self.mount_mgr = MountManager(self)
     self.settings = {}
     self._applied_effects = []
     self._pre_showbase_initialized = False
     self._first_frame = None
     self.set_loading_screen_image("/$$rp/data/gui/loading_screen_bg.txo")
예제 #50
0
    def __init__(self, pipeline):
        RPObject.__init__(self)
        self.debug("Creating debugger")
        self.pipeline = pipeline
        self.analyzer = SceneGraphAnalyzer()

        self.fullscreen_node = Globals.base.pixel2d.attach_new_node("rp_debugger")
        self.create_components()
        self.init_keybindings()

        Globals.base.doMethodLater(
            0.5, lambda task: self.collect_scene_data(), "RPDebugger_collectSceneData_initial")
        Globals.base.doMethodLater(0.1, self.update_stats, "RPDebugger_updateStats")
예제 #51
0
 def __init__(self):
     """ Creates a new pipeline with a given showbase instance. This should
     be done before intializing the ShowBase, the pipeline will take care of
     that. If the showbase has been initialized before, have a look at
     the alternative initialization of the render pipeline (the first sample)."""
     RPObject.__init__(self)
     self._analyze_system()
     self.mount_mgr = MountManager(self)
     self.settings = {}
     self._applied_effects = []
     self._pre_showbase_initialized = False
     self._first_frame = None
     self.set_loading_screen_image("/$$rp/data/gui/loading_screen_bg.txo")
    def __init__(self, name):
        """ Constructs the input block with a given name """
        RPObject.__init__(self)
        self.ptas = {}
        self.name = name
        self.use_ubo = bool(TypeRegistry.ptr().find_type("GLUniformBufferContext"))

        # Acquire a unique index for each UBO to store its binding
        self.bind_id = GroupedInputBlock.UBO_BINDING_INDEX
        GroupedInputBlock.UBO_BINDING_INDEX += 1

        if self.bind_id == 0:
            # Only output the bind support debug output once (for the first ubo)
            self.debug("Native UBO support =", self.use_ubo)
예제 #53
0
 def load(cls, filename, options):
     """ Loads an effect from a given filename with the specified options.
     This lookups in the global effect cache, and checks if a similar effect
     (i.e. with the same hash) was already loaded, and in that case returns it.
     Otherwise a new effect with the given options is created. """
     effect_hash = cls._generate_hash(filename, options)
     if effect_hash in cls._GLOBAL_CACHE:
         return cls._GLOBAL_CACHE[effect_hash]
     effect = cls()
     effect.set_options(options)
     if not effect.do_load(filename):
         RPObject.global_error("Effect", "Could not load effect!")
         return None
     return effect
예제 #54
0
    def __init__(self, pipeline):
        """ Creates a new mount manager """
        RPObject.__init__(self)
        self._pipeline = pipeline
        self._base_path = self._find_basepath()
        self._lock_file = "instance.pid"
        self._model_paths = []
        self._write_path = None
        self._mounted = False
        self._do_cleanup = True
        self._config_dir = None

        self.debug("Auto-Detected base path to", self._base_path)
        atexit.register(self._on_exit_cleanup)
예제 #55
0
파일: effect.py 프로젝트: croxis/SpaceDrive
 def load(cls, filename, options):
     """ Loads an effect from a given filename with the specified options.
     This lookups in the global effect cache, and checks if a similar effect
     (i.e. with the same hash) was already loaded, and in that case returns it.
     Otherwise a new effect with the given options is created. """
     effect_hash = cls._generate_hash(filename, options)
     if effect_hash in cls._GLOBAL_CACHE:
         return cls._GLOBAL_CACHE[effect_hash]
     effect = cls()
     effect.set_options(options)
     if not effect.do_load(filename):
         RPObject.global_error("Effect", "Could not load effect!")
         return None
     return effect
예제 #56
0
 def __init__(self, width=800, height=500, title="Window", parent=None):
     """ Constructs a new window with the given dimensions and title """
     RPObject.__init__(self, "Window-" + title)
     self._width = width
     self._height = height
     self._title = title
     self._visible = True
     self._parent = parent if parent else Globals.base.pixel2d
     self._context_scale = 1.0 / parent.get_sx()
     self._context_width = Globals.base.win.get_x_size() * self._context_scale
     self._context_height = Globals.base.win.get_y_size() * self._context_scale
     self._pos = Vec2((self._context_width - self._width) / 2,
                      (self._context_height - self._height) / 2)
     self._dragging = False
     self._drag_offset = Vec2(0)
예제 #57
0
    def __init__(self, image=None, parent=None, x=0, y=0, w=None, h=None,
                 transparent=True, near_filter=True, any_filter=True):
        """ Creates a new image, taking (x,y) as topleft coordinates.

        When near_filter is set to true, a near filter will be set to the
        texture passed. This provides sharper images.

        When any_filter is set to false, the passed image won't be modified at
        all. This enables you to display existing textures, otherwise the
        texture would get a near filter in the 3D View, too. """

        RPObject.__init__(self)

        if not isinstance(image, Texture):
            if not isinstance(image, str):
                self.warn("Invalid argument to image parameter:", image)
                return
            image = RPLoader.load_texture(image)

            if w is None or h is None:
                w, h = image.get_x_size(), image.get_y_size()
        else:
            if w is None or h is None:
                w = 10
                h = 10

        self._width, self._height = w, h
        self._initial_pos = self._translate_pos(x, y)

        self.node = OnscreenImage(
            image=image, parent=parent, pos=self._initial_pos,
            scale=(self._width / 2.0, 1, self._height / 2.0))

        if transparent:
            self.node.set_transparency(TransparencyAttrib.M_alpha)

        tex = self.node.get_texture()

        # Apply a near filter, but only if the parent has no scale, otherwise
        # it will look weird
        if near_filter and any_filter and parent.get_sx() == 1.0:
            tex.set_minfilter(SamplerState.FT_nearest)
            tex.set_magfilter(SamplerState.FT_nearest)

        if any_filter:
            tex.set_anisotropic_degree(8)
            tex.set_wrap_u(SamplerState.WM_clamp)
            tex.set_wrap_v(SamplerState.WM_clamp)
예제 #58
0
    def __init__(self, x=0, y=0, parent=None, size=100, min_value=0,
                 max_value=100, value=50, page_size=1, callback=None,
                 extra_args=None):
        """ Inits the slider """
        RPObject.__init__(self)
        if extra_args is None:
            extra_args = []

        # Scale has to be 2.0, otherwise there will be an error.
        self._node = DirectSlider(
            pos=(size * 0.5 + x, 1, -y), parent=parent, range=(min_value, max_value),
            value=value, pageSize=page_size, scale=2.0, command=callback,
            extraArgs=extra_args, frameColor=(0.0, 0.0, 0.0, 1),
            frameSize=(-size * 0.25, size * 0.25, -5, 5), relief=DGG.FLAT,
            thumb_frameColor=(0.35, 0.53, 0.2, 1.0), thumb_relief=DGG.FLAT,
            thumb_frameSize=(-2.5, 2.5, -5.0, 5.0),)