예제 #1
0
    def run(self):
        """ Loads rocks."""

        rocks_settings = self.config.get_list("batches", [])
        for subsec_num, subsec_settings in enumerate(rocks_settings):
            subsec_config = Config(subsec_settings)

            subsec_objects = RockEssentialsRockLoader.load_rocks(
                path=subsec_config.get_string("path"),
                subsec_num=subsec_num,
                objects=subsec_config.get_list("objects", []),
                sample_objects=subsec_config.get_bool("sample_objects", False),
                amount=subsec_config.get_int("amount", None)
            )

            RockEssentialsRockLoader.set_rocks_properties(
                objects=subsec_objects,
                physics=subsec_config.get_bool("physics", False),
                render_levels=subsec_config.get_int("render_levels", 3),
                high_detail_mode=subsec_config.get_bool("high_detail_mode", False),
                scale=subsec_config.get_vector3d("scale", [1, 1, 1]),
                reflection_amount=subsec_config.get_float("reflection_amount", None),
                reflection_roughness=subsec_config.get_float("reflection_roughness", None),
                hsv=subsec_config.get_list("HSV", None)
            )
예제 #2
0
    def _infuse_texture(material: Material, config: Config):
        """
        Overlays the selected material with a texture, this can be either a color texture like for example dirt or
        it can be a texture, which is used as an input to the Principled BSDF of the given material.

        :param material: Material, which will be changed
        :param config: containing the config information
        """
        used_mode = config.get_string("mode", "overlay")
        used_textures = config.get_list("used_texture")
        invert_texture = config.get_bool("invert_texture", False)
        used_connector = config.get_string("connection", "Base Color")
        texture_scale = config.get_float("texture_scale", 0.05)
        strength = config.get_float("strength", 0.5)

        if config.has_param("strength") and used_mode == "set":
            raise Exception(
                "The strength can only be used if the mode is not \"set\"!")

        if len(used_textures) == 0:
            raise Exception(
                f"You have to select a texture, which is {used_mode} over the material!"
            )
        texture = random.choice(used_textures)

        material.infuse_texture(texture=texture,
                                mode=used_mode,
                                invert_texture=invert_texture,
                                connection=used_connector,
                                texture_scale=texture_scale,
                                strength=strength)