M3-org / loot-assets

Remixable assets for 3D avatars and game dev inspired by loot (for adventurers)
https://m3-org.github.io/loot-assets/
4 stars 2 forks source link

take thumbnails / thumbnail script #7

Open madjin opened 10 months ago

madjin commented 10 months ago

atm using screenshot glb + bash script, maybe can have blender script for thumbnailer?

madjin commented 10 months ago

would be great to export thumbnails + manifest.json. some reference pseudocode

import os
import sys
import json

# Copy and run this in the directory you want to generate JSON for
# For example: cp _utilities/add_manifest.py character-assets/anata/HAIR/
# Then run like python3 add_manifest.py HAIR *.vrm

def generate_json_data(vrm_directory, vrm_files):
    json_data = []

    for vrm_file in vrm_files:
        id = vrm_file.split(".")[0]
        name = id.replace("_", " ")
        directory = os.path.join(vrm_directory, vrm_file)
        thumbnail = os.path.join(vrm_directory, id + ".png")

        vrm_data = {
            "id": id,
            "name": name,
            "directory": directory,
            "thumbnail": thumbnail
        }

        json_data.append(vrm_data)

    return json_data

if __name__ == "__main__":
    if len(sys.argv) < 3:
        print("Usage: python generate_json.py <vrm_directory> <vrm_file1> <vrm_file2> ...")
        sys.exit(1)

    vrm_directory = sys.argv[1]
    vrm_files = sys.argv[2:]

    json_data = generate_json_data(vrm_directory, vrm_files)

    # Print the generated JSON data
    print(json.dumps(json_data, indent=2))