Ejemplo n.º 1
0
def fix_weights():
    for object_ in get_type("skins"):
        override = get_3d_context(object_)
        try:
            bpy.ops.object.vertex_group_normalize_all(override,
                                                      lock_active=False)
        except:
            raise exceptions.CryBlendException(
                "Please fix weightless vertices first.")
    cbPrint("Weights Corrected.")
Ejemplo n.º 2
0
def get_armature_from_node(group):
    armature_count = 0
    armature = None
    for object_ in group.objects:
        if object_.type == "ARMATURE":
            armature_count += 1
            armature = object_

    if armature_count == 1:
        return armature

    error_message = None
    if armature_count == 0:
        raise exceptions.CryBlendException("i_caf node has no armature!")
        error_message = "i_caf node has no armature!"
    elif armature_count > 1:
        raise exceptions.CryBlendException(
            "{} i_caf node have more than one armature!".format(node_name))

    return None
Ejemplo n.º 3
0
def raise_exception_if_textures_have_same_type(texture_types):
    ERROR_TEMPLATE = "There is more than one texture of type {!r}."
    error_messages = []

    for type_name, type_count in texture_types.items():
        if type_count > 1:
            error_messages.append(ERROR_TEMPLATE.format(type_name.lower()))

    if error_messages:
        raise exceptions.CryBlendException(
            "\n".join(error_messages) + "\n" +
            "Please correct that and try again.")
Ejemplo n.º 4
0
    def _get_blender_render_images(self, material, images):
        texture_slots = utils.get_texture_slots_for_material(material)
        for texture_slot in texture_slots:
            image = texture_slot.texture.image
            if not image:
                raise exceptions.CryBlendException(
                    "One of texture slots has no image assigned.")

            surface, sampler = self._create_surface_and_sampler(image.name)
            if texture_slot.use_map_color_diffuse:
                images[0] = [image.name, surface, sampler]
            if texture_slot.use_map_color_spec:
                images[1] = [image.name, surface, sampler]
            if texture_slot.use_map_normal:
                images[2] = [image.name, surface, sampler]
Ejemplo n.º 5
0
    def _get_cycles_render_images(self, material, images):
        cycles_nodes = utils.get_texture_nodes_for_material(material)
        for cycles_node in cycles_nodes:
            image = cycles_node.image
            if not image:
                raise exceptions.CryBlendException(
                    "One of texture slots has no image assigned.")

            surface, sampler = self._create_surface_and_sampler(image.name)
            if cycles_node.name == "Image Texture":
                images[0] = [image.name, surface, sampler]
            if cycles_node.name == "Specular":
                images[1] = [image.name, surface, sampler]
            if cycles_node.name == "Normal":
                images[2] = [image.name, surface, sampler]
Ejemplo n.º 6
0
    def pump(self, message, message_type='info'):
        if message_type == 'info':
            print("[Info] CryBlend: {!r}".format(message))

        elif message_type == 'debug':
            print("[Debug] CryBlend: {!r}".format(message))

        elif message_type == 'warning':
            print("[Warning] CryBlend: {!r}".format(message))

        elif message_type == 'error':
            print("[Error] CryBlend: {!r}".format(message))

        else:
            raise exceptions.CryBlendException(
                "No such message type {!r}".format(message_type))