Пример #1
0
def __gather_texture_info_helper(
        primary_socket: bpy.types.NodeSocket,
        blender_shader_sockets: typing.Tuple[bpy.types.NodeSocket],
        kind: str,
        export_settings):
    if not __filter_texture_info(primary_socket, blender_shader_sockets, export_settings):
        return None

    tex_transform, tex_coord = __gather_texture_transform_and_tex_coord(primary_socket, export_settings)

    fields = {
        'extensions': __gather_extensions(tex_transform, export_settings),
        'extras': __gather_extras(blender_shader_sockets, export_settings),
        'index': __gather_index(blender_shader_sockets, export_settings),
        'tex_coord': tex_coord,
    }

    if kind == 'DEFAULT':
        texture_info = gltf2_io.TextureInfo(**fields)

    elif kind == 'NORMAL':
        fields['scale'] = __gather_normal_scale(primary_socket, export_settings)
        texture_info = gltf2_io.MaterialNormalTextureInfoClass(**fields)

    elif kind == 'OCCLUSION':
        fields['strength'] = __gather_occlusion_strength(primary_socket, export_settings)
        texture_info = gltf2_io.MaterialOcclusionTextureInfoClass(**fields)

    if texture_info.index is None:
        return None

    export_user_extensions('gather_texture_info_hook', export_settings, texture_info, blender_shader_sockets)

    return texture_info
def gather_material_occlusion_texture_info_class(
        blender_shader_sockets_or_texture_slots: typing.Union[
            typing.Tuple[bpy.types.NodeSocket],
            typing.Tuple[bpy.types.Texture]], export_settings):
    if not __filter_texture_info(blender_shader_sockets_or_texture_slots,
                                 export_settings):
        return None

    texture_info = gltf2_io.MaterialOcclusionTextureInfoClass(
        extensions=__gather_extensions(blender_shader_sockets_or_texture_slots,
                                       export_settings),
        extras=__gather_extras(blender_shader_sockets_or_texture_slots,
                               export_settings),
        strength=__gather_scale(blender_shader_sockets_or_texture_slots,
                                export_settings),
        index=__gather_index(blender_shader_sockets_or_texture_slots,
                             export_settings),
        tex_coord=__gather_tex_coord(blender_shader_sockets_or_texture_slots,
                                     export_settings))

    if texture_info.index is None:
        return None

    export_user_extensions('gather_material_occlusion_texture_info_class_hook',
                           export_settings, texture_info,
                           blender_shader_sockets_or_texture_slots)

    return texture_info