Add scripts to convert .blend to glT
Goodbye Makefile, hello tup!
This commit is contained in:
parent
912b8381a7
commit
1ce9621ec6
0
Tupfile.ini
Normal file
0
Tupfile.ini
Normal file
3
models/Tupfile
Normal file
3
models/Tupfile
Normal file
|
@ -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
|
39
scripts/bpy/blend2glb.py
Normal file
39
scripts/bpy/blend2glb.py
Normal file
|
@ -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)
|
41
scripts/bpy/blend2gltf.py
Normal file
41
scripts/bpy/blend2gltf.py
Normal file
|
@ -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)
|
Loading…
Reference in a new issue