コード例 #1
0
def extract_data(json_path, json_filename):
    data = {
        "main_file": json_filename
    }

    # get json file
    data[json_filename] = exporter.get_main_json_data()

    # get binaries
    json_parsed = json.loads(data[json_filename])
    if "binaries" in json_parsed:
        relpath = json_parsed["binaries"][0]["binfile"]
        if relpath is not None:
            data[relpath] = encode_binary_sequence(exporter.get_binaries_data())

    # get resources
    if "images" in json_parsed:
        for i in range(len(json_parsed["images"])):
            img = json_parsed["images"][i]
            if img["source"] == "FILE":
                data[img["filepath"]] = get_encoded_resource_data(img["filepath"], 
                        json_path)

    if "sounds" in json_parsed:
        for i in range(len(json_parsed["sounds"])):
            snd = json_parsed["sounds"][i]
            data[snd["filepath"]] = get_encoded_resource_data(snd["filepath"],
                    json_path)

    get_smaa_textures(data, json_path);

    return data
コード例 #2
0
def extract_data(json_path, json_filename):
    data = {"main_file": json_filename}

    # get json file
    data[json_filename] = exporter.get_main_json_data()

    # get binaries
    json_parsed = json.loads(data[json_filename])
    if "binaries" in json_parsed:
        relpath = json_parsed["binaries"][0]["binfile"]
        if relpath is not None:
            data[relpath] = encode_binary_sequence(
                exporter.get_binaries_data())

    # get resources
    if "images" in json_parsed:
        for i in range(len(json_parsed["images"])):
            img = json_parsed["images"][i]
            if img["source"] == "FILE":
                data[img["filepath"]] = get_encoded_resource_data(
                    img["filepath"], json_path)

    if "sounds" in json_parsed:
        for i in range(len(json_parsed["sounds"])):
            snd = json_parsed["sounds"][i]
            data[snd["filepath"]] = get_encoded_resource_data(
                snd["filepath"], json_path)

    get_smaa_textures(data, json_path)

    return data
コード例 #3
0
ファイル: html_exporter.py プロジェクト: rewiko/Blend4Web
def extract_data(json_path, json_filename, export_converted_media):
    data = {
        "main_file": json_filename
    }

    # get json file
    data[json_filename] = exporter.get_main_json_data()

    # get binaries
    json_parsed = json.loads(data[json_filename])
    if "binaries" in json_parsed:
        relpath = json_parsed["binaries"][0]["binfile"]
        if relpath is not None:
            data[relpath] = encode_binary_sequence(exporter.get_binaries_data())

    # get resources
    if "images" in json_parsed:
        for i in range(len(json_parsed["images"])):
            img = json_parsed["images"][i]
            file_path = img["filepath"]
            if img["source"] == "FILE" or img["source"] == "MOVIE":
                data[file_path] = get_encoded_resource_data(file_path,
                        json_path)
            if img["source"] == "MOVIE" and export_converted_media:
                ext = os.path.splitext(file_path)[1]
                file_name = os.path.splitext(file_path)[0]
                conv_file_path = None
                if ext == ".ogv" or ext == ".m4v":
                    conv_file_path = file_name + ".altconv.webm"
                elif ext == ".webm":
                    conv_file_path = file_name + ".altconv.m4v"
                if conv_file_path:
                    data[conv_file_path] = get_encoded_resource_data(conv_file_path,
                    json_path)
                data[file_name + ".altconv.seq"] = get_encoded_resource_data(file_name + ".altconv.seq",
                    json_path)

    if "sounds" in json_parsed:
        for i in range(len(json_parsed["sounds"])):
            snd = json_parsed["sounds"][i]
            file_path = snd["filepath"]
            data[file_path] = get_encoded_resource_data(snd["filepath"],
                    json_path)
            if export_converted_media:
                ext = os.path.splitext(file_path)[1]
                file_name = os.path.splitext(file_path)[0]
                conv_file_path = None
                if ext == ".mp3" or ext == ".mp4":
                    conv_file_path = file_name + ".altconv.ogg"
                elif ext == ".ogg":
                    conv_file_path = file_name + ".altconv.mp4"
                if conv_file_path:
                    data[conv_file_path] = get_encoded_resource_data(conv_file_path,
                    json_path)

    get_smaa_textures(data, json_path);

    return data
コード例 #4
0
def extract_data(json_path, json_filename, export_converted_media):
    data = {"main_file": json_filename}

    # get json file
    data[json_filename] = exporter.get_main_json_data()

    # get binaries
    json_parsed = json.loads(data[json_filename])
    if "binaries" in json_parsed:
        relpath = json_parsed["binaries"][0]["binfile"]
        if relpath is not None:
            data[relpath] = encode_binary_sequence(
                exporter.get_binaries_data())

    # get resources
    if "images" in json_parsed:
        for i in range(len(json_parsed["images"])):
            img = json_parsed["images"][i]
            file_path = img["filepath"]
            if img["source"] == "FILE" or img["source"] == "MOVIE":
                data[file_path] = get_encoded_resource_data(
                    file_path, json_path)
            if img["source"] == "MOVIE" and export_converted_media:
                ext = os.path.splitext(file_path)[1]
                file_name = os.path.splitext(file_path)[0]
                conv_file_path = None
                if ext == ".ogv" or ext == ".m4v":
                    conv_file_path = file_name + ".altconv.webm"
                elif ext == ".webm":
                    conv_file_path = file_name + ".altconv.m4v"
                if conv_file_path:
                    data[conv_file_path] = get_encoded_resource_data(
                        conv_file_path, json_path)
                data[file_name + ".altconv.seq"] = get_encoded_resource_data(
                    file_name + ".altconv.seq", json_path)

    if "sounds" in json_parsed:
        for i in range(len(json_parsed["sounds"])):
            snd = json_parsed["sounds"][i]
            file_path = snd["filepath"]
            data[file_path] = get_encoded_resource_data(
                snd["filepath"], json_path)
            if export_converted_media:
                ext = os.path.splitext(file_path)[1]
                file_name = os.path.splitext(file_path)[0]
                conv_file_path = None
                if ext == ".mp3" or ext == ".mp4":
                    conv_file_path = file_name + ".altconv.ogg"
                elif ext == ".ogg":
                    conv_file_path = file_name + ".altconv.mp4"
                if conv_file_path:
                    data[conv_file_path] = get_encoded_resource_data(
                        conv_file_path, json_path)

    get_smaa_textures(data, json_path)

    return data