Files
animation/characters/female/lena_nude/hires_claude/08_export.py
T

33 lines
1.0 KiB
Python
Raw Normal View History

# Stage 8: export the finished hires nude sculpt as a packed GLB.
# blender --background --python 08_export.py -- <07_polished.blend> <out.glb>
import bpy, sys, time
import numpy as np
argv = sys.argv[sys.argv.index("--") + 1:]
BLEND, OUT = argv[0], argv[1]
t0 = time.time()
bpy.ops.wm.open_mainfile(filepath=BLEND)
ob = max([o for o in bpy.data.objects if o.type == 'MESH'],
key=lambda o: len(o.data.vertices))
me = ob.data
co = np.empty(len(me.vertices) * 3)
me.vertices.foreach_get("co", co)
co = co.reshape(-1, 3)
print(f"[export] {ob.name}: {len(me.vertices)}v {len(me.polygons)}f "
f"height {co[:,2].max()-co[:,2].min():.4f} units, "
f"images {[i.name for i in bpy.data.images if i.has_data]}")
bpy.ops.export_scene.gltf(
filepath=OUT,
export_format='GLB',
export_image_format='AUTO',
export_yup=True,
export_apply=False,
export_animations=False,
export_skins=True,
export_morph=False,
)
print(f"[export] WROTE {OUT} ({time.time()-t0:.1f}s)")
print("EXPORT_DONE")