diff --git a/Tupfile.ini b/Tupfile.ini new file mode 100644 index 0000000..e69de29 diff --git a/models/Tupfile b/models/Tupfile new file mode 100644 index 0000000..dca495a --- /dev/null +++ b/models/Tupfile @@ -0,0 +1,3 @@ +MODELS = hedgehog.blend \ + flag.blend +: foreach $(MODELS) |> blender %f --background --python ../scripts/bpy/blend2glb.py -- --output %o > /dev/null |> %B.glb diff --git a/scripts/bpy/blend2glb.py b/scripts/bpy/blend2glb.py new file mode 100644 index 0000000..115e9f1 --- /dev/null +++ b/scripts/bpy/blend2glb.py @@ -0,0 +1,39 @@ +import sys +import os +import argparse +import bpy + +# get all args after "--" +argv = sys.argv +argv = argv[argv.index("--") + 1:] + +parser = argparse.ArgumentParser() +parser.add_argument('-o','--output') + +args = parser.parse_args(argv) +basedir = os.path.dirname(args.output) +if basedir is not '': + os.makedirs(basedir, exist_ok=True) + +# You can read the documentation at: +# https://github.com/KhronosGroup/glTF-Blender-Exporter/blob/master/docs/user.md +bpy.ops.export_scene.glb(filepath=args.output, + # Embedding + export_copyright="Zenly", + # Nodes + export_selected=False, + export_layers=True, + export_extras=True, + # Mesh + export_apply=True, + # Attributes + export_texcoords=True, + export_normals=True, + export_tangents=True, + export_colors=True, + # Objects + export_materials=True, + export_cameras=True, + export_camera_infinite=False, + # Animation + export_animations=True) diff --git a/scripts/bpy/blend2gltf.py b/scripts/bpy/blend2gltf.py new file mode 100644 index 0000000..07d51a9 --- /dev/null +++ b/scripts/bpy/blend2gltf.py @@ -0,0 +1,41 @@ +import sys +import os +import argparse +import bpy + +# get all args after "--" +argv = sys.argv +argv = argv[argv.index("--") + 1:] + +parser = argparse.ArgumentParser() +parser.add_argument('-o','--output') + +args = parser.parse_args(argv) +basedir = os.path.dirname(args.output) +os.makedirs(basedir, exist_ok=True) + +# You can read the documentation at: +# https://github.com/KhronosGroup/glTF-Blender-Exporter/blob/master/docs/user.md +bpy.ops.export_scene.gltf(filepath=args.output, + # Embedding + export_copyright="Zenly", + export_embed_buffers=False, # leave binary data in .bin + export_embed_images=False, + export_strip=False, # JSON not striped + # Nodes + export_selected=False, + export_layers=True, + export_extras=True, + # Mesh + export_apply=False, + # Attributes + export_texcoords=True, + export_normals=True, + export_tangents=True, + export_colors=True, + # Objects + export_materials=True, + export_cameras=True, + export_camera_infinite=False, + # Animation + export_animations=True)