Skip to content
1        10        20        30        40        50        60        70        80        901"""Build a small Torment prop and export it as a GLB.23This is a template for code-driven modelling: geometry, materials and export4all live in one file, so a model can be rebuilt and re-exported from a5terminal in seconds.67    blender -b --factory-startup -P tools/blender/example_prop.py -- \8      --out /tmp/torment-shard.glb910Then preview it with:1112    bunx gltf-transform inspect /tmp/torment-shard.glb13"""1415import argparse16import sys17from pathlib import Path1819import bpy2021sys.path.insert(0, str(Path(__file__).resolve().parent))22from export_glb import export_scene  # noqa: E402  (needs Blender's sys.path)232425def material(name, color, metallic=0.0, roughness=0.6):26    mat = bpy.data.materials.new(name)27    mat.use_nodes = True28    bsdf = mat.node_tree.nodes["Principled BSDF"]29    bsdf.inputs["Base Color"].default_value = (*color, 1.0)30    bsdf.inputs["Metallic"].default_value = metallic31    bsdf.inputs["Roughness"].default_value = roughness32    return mat333435def main(argv):36    parser = argparse.ArgumentParser()37    parser.add_argument("--out", required=True)38    args = parser.parse_args(argv)3940    bpy.ops.wm.read_factory_settings(use_empty=True)4142    # Six-sided plinth, matching the width of one battlefield hex.43    bpy.ops.mesh.primitive_cylinder_add(vertices=6, radius=0.5, depth=0.12, location=(0, 0, 0.06))44    plinth = bpy.context.object45    plinth.name = "Shard Base"46    plinth.data.materials.append(material("Slate", (0.16, 0.14, 0.2), roughness=0.85))4748    # A leaning crystal, the readable silhouette of a Torment shard.49    bpy.ops.mesh.primitive_cone_add(50        vertices=6, radius1=0.22, radius2=0.02, depth=1.1, location=(0, 0, 0.68)51    )52    shard = bpy.context.object53    shard.name = "Shard"54    shard.rotation_euler = (0.12, -0.18, 0.3)55    shard.data.materials.append(56        material("Torment Glass", (0.36, 0.08, 0.52), metallic=0.1, roughness=0.25)57    )5859    export_scene(args.out)606162if __name__ == "__main__":63    main(sys.argv[sys.argv.index("--") + 1 :] if "--" in sys.argv else [])