예제 #1
0
 def _set_texture(self, node_tree, name):
     _LOG.enter()
     expected_name = name + "Texture"
     node = NodeService.find_node_by_name(node_tree, expected_name)
     self._settings[expected_name] = None
     if not node is None:
         node_info = NodeService.get_node_info(node)
         if "filename" in node_info and node_info["filename"]:
             self._settings[expected_name] = node_info["filename"]
         else:
             _LOG.warn(
                 "The following texture node did not have an image file, so cannot set a MHMAT key for it",
                 expected_name)
     else:
         _LOG.debug("Could not find a node for", expected_name)
예제 #2
0
    def check_that_all_textures_are_saved(self, blender_object):
        material = blender_object.material_slots[0].material
        node_tree = material.node_tree

        for texture_name_base in _TEXTURE_NAMES:
            texture_name = texture_name_base + "Texture"
            node = NodeService.find_node_by_name(node_tree, texture_name)
            if node:
                # The material has this kind of texture, check that its image exists
                node_info = NodeService.get_node_info(node)
                if not "filename" in node_info or not node_info["filename"]:
                    return "The " + texture_name + " node has an unsaved image"
                if not os.path.exists(node_info["filename"]):
                    return "The " + texture_name + " refers to an image which does not exist as a file"
            else:
                # The material isn't using this kind of texture
                _LOG.debug("No node was found for", texture_name)

        return None