"""Convert a Quaternius outfit gltf to glb with optional solidify.""" import sys import bpy CLOTHING_THICKNESS = 0.025 # 25mm outward solidify if __name__ == "__main__": argv = sys.argv if "--" not in argv: print("Usage: blender --background --python convert_outfit.py -- ") sys.exit(1) args = argv[argv.index("--") + 1:] input_path = args[0] output_path = args[1] bpy.ops.wm.read_factory_settings(use_empty=True) bpy.ops.import_scene.gltf(filepath=input_path) # Solidify clothing meshes for thickness meshes = [o for o in bpy.context.scene.objects if o.type == 'MESH'] for m in meshes: if m.name.startswith("Icosphere") or len(m.data.vertices) < 50: continue bpy.context.view_layer.objects.active = m m.select_set(True) # Recalculate normals for consistent outward direction bpy.ops.object.mode_set(mode='EDIT') bpy.ops.mesh.select_all(action='SELECT') bpy.ops.mesh.normals_make_consistent(inside=False) bpy.ops.object.mode_set(mode='OBJECT') # Solidify sol = m.modifiers.new(name="Solidify", type='SOLIDIFY') sol.thickness = CLOTHING_THICKNESS sol.offset = 1.0 # grow outward only sol.use_rim = True bpy.ops.object.modifier_apply(modifier=sol.name) m.select_set(False) print(f" Solidified: {m.name} ({CLOTHING_THICKNESS*1000:.0f}mm)") bpy.ops.object.select_all(action='SELECT') bpy.ops.export_scene.gltf( filepath=output_path, use_selection=True, export_format='GLB', export_animations=False, export_yup=True, export_texcoords=True, export_normals=True, export_skins=True, export_materials='EXPORT', ) print(f"Exported: {output_path}")