# tools/blender/build_archive_shelf.py # FBC: NIGHT SHIFT — records archive shelf row for the Security Gate refit. # # Run headlessly: # blender --background --factory-startup --python tools/blender/build_archive_shelf.py # # One merged mesh / one material, painted-vertex path via actor_kit. The row is # 14 m long along local X, 0.9 m deep along local Y and 2.8 m tall along Z. import os import sys import bpy from mathutils import Vector REPO = "/home/dandovlatov/Documents/cntrl" MODEL_DIR = os.path.join(REPO, "assets", "models", "props") BLEND_DIR = os.path.join(REPO, "assets", "blender") os.makedirs(MODEL_DIR, exist_ok=True) os.makedirs(BLEND_DIR, exist_ok=True) sys.path.insert(0, os.path.join(REPO, "tools", "blender")) import importlib import actor_kit as K importlib.reload(K) K.clear_scene() P = K.PALETTE P.update({"folder_tan": "#c8b99b", "folder_red": "#7d2028", "folder_blue": "#3b4a5e", "folder_paper": "#b5b0a3"}) def box(root, name, cx, cy, z0, dx, dy, dz, value, ao=0.06): hw, hd = dx * 0.5, dy * 0.5 return K.plate(root, name, [(-hw, -hd), (hw, -hd), (hw, hd), (-hw, hd)], z0, z0 + dz, 1.0, value, shift=(cx, cy), ao=ao) def build_archive_shelf(): r = K.new_actor("ArchiveShelf") length, depth, height = 14.0, 0.92, 2.8 bays = 5 bay_len = length / bays levels = (0.28, 0.96, 1.64, 2.32) folders = (P["folder_tan"], P["folder_blue"], P["folder_red"], P["redaction"], P["folder_paper"]) for i in range(bays + 1): x = -length * 0.5 + i * bay_len box(r, "upright_%d" % i, x, 0.0, 0.0, 0.10, depth, height, P["steel_dk"], ao=0.12) for b in range(bays): cx = -length * 0.5 + (b + 0.5) * bay_len for li, z in enumerate(levels): box(r, "board_%d_%d" % (b, li), cx, 0.0, z, bay_len - 0.12, depth - 0.06, 0.055, P["steel"], ao=0.10) for k in range(3): fx = cx - bay_len * 0.30 + k * bay_len * 0.30 dz = 0.30 + 0.035 * ((b + k + li) % 3) box(r, "file_%d_%d_%d" % (b, li, k), fx, 0.0, z + 0.055, bay_len * 0.25, depth - 0.18, dz, folders[(b * 2 + k + li) % len(folders)], ao=0.04) box(r, "label", length * 0.5 - 0.09, 0.0, 2.08, 0.035, depth * 0.7, 0.48, P["board"], ao=0.0) return r root = build_archive_shelf() tris = K.triangle_count(root) K.merge_actor(root, "ArchiveShelf") path = os.path.join(MODEL_DIR, "archive_shelf.glb") K.export_actor(root, "ArchiveShelf", path) bpy.ops.wm.save_as_mainfile( filepath=os.path.join(BLEND_DIR, "fbc_archive_shelf.blend")) print("[archive_shelf] %d tris -> %s (%d bytes)" % (tris, path, os.path.getsize(path))) scene = bpy.context.scene scene.render.engine = "BLENDER_WORKBENCH" scene.display.shading.light = "STUDIO" scene.display.shading.color_type = "VERTEX" scene.render.resolution_x = 960 scene.render.resolution_y = 540 cam_data = bpy.data.cameras.new("ShelfPreview") cam = bpy.data.objects.new("ShelfPreview", cam_data) scene.collection.objects.link(cam) cam.location = (12.0, -15.0, 8.0) cam.rotation_euler = (Vector((0.0, 0.0, 1.4)) - cam.location).to_track_quat( "-Z", "Y").to_euler() scene.camera = cam scene.render.filepath = "/tmp/opencode/archive_shelf.png" bpy.ops.render.render(write_still=True)