# tools/blender/build_floppy_disk.py # FBC: NIGHT SHIFT — Hissed Floppy Disk (Security Booth OoP reward). # # Run inside Blender 5.x: # exec(open("/home/dandovlatov/Documents/cntrl/tools/blender/build_floppy_disk.py").read()) # # A 3.5" FBC issue disk, corrupted by the Hiss: dark shell, steel shutter, # redacted label, black-red rot growths and hot fissures. Exports as one GLB # with one merged mesh / material and painted COLOR_0, same path as the props. import math import os import sys import bpy from mathutils import Euler, Vector REPO = "/home/dandovlatov/Documents/cntrl" MODEL_DIR = os.path.join(REPO, "assets", "models", "props") BLEND_DIR = os.path.join(REPO, "assets", "blender") CONCEPT_DIR = os.path.join(REPO, "docs", "concept") for d in (MODEL_DIR, BLEND_DIR, CONCEPT_DIR): os.makedirs(d, 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({"plastic": "#2a2d33", "label": "#c8c4b4", "board_dk": "#8a6c12"}) # In Blender the disk faces -Y (engine +Z after glTF Y-up conversion). Parts # are authored standing up: local XY is the face, local Z becomes thickness. FACE_ROT = (math.pi / 2, 0.0, 0.0) FACE_OFFSET = (0.0, 0.025, 0.86) def place(obj, rot=FACE_ROT, offset=FACE_OFFSET): mat = Euler(rot).to_matrix() shift = Vector(offset) for v in obj.data.vertices: v.co = shift + mat @ v.co obj.data.update() return obj def face(root, name, outline, z0, z1, value, ao=0.05): """A flat plate on the disk face, extruded in local Z (world thickness).""" return place(K.plate(root, name, outline, z0, z1, 1.0, value, ao=ao)) def build_disk(): r = K.new_actor("HissedFloppyDisk") # Low plinth: the OoP sits on a plinth like the Pedestal and Duck. K.loft(r, "plinth", [ {"z": 0.0, "r": (0.38, 0.32), "n": 10}, {"z": 0.06, "r": (0.42, 0.35), "n": 10}, {"z": 0.40, "r": (0.36, 0.30), "n": 10, "fold": (0.02, 5)}, {"z": 0.46, "r": (0.40, 0.33), "n": 10}, ], P["concrete"], ao=0.14) K.plate(r, "plinth_top", K.octagon(0.34, 0.28), 0.46, 0.50, 0.98, P["redaction"]) K.ring(r, "plinth_seal", (0.0, 0.0, 0.08), 0.40, 0.016, P["hiss_dull"], segments=12) # Shell: chamfered top-right corner, the classic 3.5" silhouette. shell = [(-0.30, -0.30), (0.30, -0.30), (0.30, 0.19), (0.19, 0.30), (-0.30, 0.30)] face(r, "shell", shell, 0.0, 0.052, P["plastic"], ao=0.09) # Steel shutter across the top, slightly proud of the shell. face(r, "shutter", [(-0.23, 0.09), (0.23, 0.09), (0.23, 0.30), (-0.23, 0.30)], 0.052, 0.066, P["steel"]) face(r, "shutter_slot", [(-0.17, 0.24), (0.12, 0.24), (0.12, 0.27), (-0.17, 0.27)], 0.066, 0.070, P["redaction"], ao=0.0) # Paper label with two redaction bars (FBC form, not a consumer brand). face(r, "label", [(-0.25, -0.26), (0.25, -0.26), (0.25, 0.04), (-0.25, 0.04)], 0.052, 0.057, P["label"]) face(r, "label_bar_a", [(-0.21, -0.09), (0.17, -0.09), (0.17, -0.055), (-0.21, -0.055)], 0.057, 0.060, P["redaction"], ao=0.0) face(r, "label_bar_b", [(-0.21, -0.18), (0.08, -0.18), (0.08, -0.145), (-0.21, -0.145)], 0.057, 0.060, P["redaction"], ao=0.0) face(r, "label_stamp", [(-0.21, 0.005), (-0.10, 0.005), (-0.10, 0.030), (-0.21, 0.030)], 0.057, 0.061, P["board_dk"], ao=0.0) # Write-protect notch, bottom-left. face(r, "write_protect", [(-0.30, -0.30), (-0.23, -0.30), (-0.23, -0.24), (-0.30, -0.24)], 0.052, 0.058, P["redaction"], ao=0.0) # Hiss rot: black-red growths breaking out of the shell corners + a hot # fissure crawling across the label. Painted into the same vertex colours. for i, (x, z, tilt_v, size) in enumerate([ (-0.29, 1.11, (0.4, 0.2, 0.6), 0.13), (0.27, 1.09, (-0.3, 0.4, -0.5), 0.11), (0.15, 0.61, (0.2, -0.4, 0.3), 0.09), (-0.24, 0.63, (-0.5, 0.1, -0.2), 0.08), ]): K.crystal(r, "rot_%d" % i, (x, -0.04, z), size, P["hiss"] if i % 2 == 0 else P["hiss_dull"], sides=5, seed=70 + i, tilt=tilt_v) for i, pts in enumerate([ [(-0.13, -0.04, 0.60), (-0.05, -0.05, 0.77), (0.02, -0.05, 0.90), (0.11, -0.04, 1.06)], [(0.20, -0.04, 0.68), (0.26, -0.05, 0.82), (0.22, -0.04, 0.98)], ]): K.tube(r, "fissure_%d" % i, pts, [0.014, 0.017, 0.013, 0.010][:len(pts)], P["hiss_hot"], sides=5) K.blob(r, "rot_mass", (0.29, 0.06, 0.73), (0.10, 0.05, 0.13), P["hiss_dull"], subdiv=1, warp=0.34, seed=9, smooth=False, ao=0.04) return r root = build_disk() K.merge_actor(root, "HissedFloppyDisk") tris = K.triangle_count(root) CAP = 700 print("[budget] HissedFloppyDisk %d tris (cap %d) %s" % (tris, CAP, "OK" if tris <= CAP else "OVER")) if tris > CAP: raise RuntimeError("HissedFloppyDisk triangle budget exceeded: %d" % tris) out_glb = os.path.join(MODEL_DIR, "floppy_disk.glb") K.export_actor(root, "HissedFloppyDisk", out_glb) print("[export] %s (%d bytes)" % (out_glb, os.path.getsize(out_glb))) # Concept render: one centred disc against the House dark, Hiss fill + teal rim. world = bpy.data.worlds.new("FloppyWorld") bpy.context.scene.world = world world.use_nodes = True bg = next(n for n in world.node_tree.nodes if n.type == "BACKGROUND") bg.inputs["Color"].default_value = (*K.rgb("#0d0f12"), 1.0) bg.inputs["Strength"].default_value = 0.9 for name, loc, power, col in ( ("Key", (-2, -8, 9), 2200, "#eef2ff"), ("HissFill", (7, -2, 4), 1200, "#ff3b46"), ("Rim", (0, 6, 5), 900, "#4ec9b0"), ): data = bpy.data.lights.new(name, "AREA") data.energy = power data.shape = "DISK" data.size = 6 data.color = K.rgb(col) obj = bpy.data.objects.new(name, data) bpy.context.scene.collection.objects.link(obj) obj.location = loc obj.rotation_euler = (Vector((0, 0, 0.85)) - Vector(loc)).to_track_quat( "-Z", "Y").to_euler() cam_data = bpy.data.cameras.new("FloppyCam") cam = bpy.data.objects.new("FloppyCam", cam_data) bpy.context.scene.collection.objects.link(cam) cam.location = (1.6, -4.2, 2.2) cam.rotation_euler = (Vector((0, 0, 0.85)) - cam.location).to_track_quat( "-Z", "Y").to_euler() cam_data.lens = 55 scene = bpy.context.scene scene.camera = cam engines = [i.identifier for i in bpy.types.RenderSettings.bl_rna.properties[ "engine"].enum_items] scene.render.engine = "BLENDER_EEVEE_NEXT" if "BLENDER_EEVEE_NEXT" in engines else engines[0] scene.render.resolution_x = 900 scene.render.resolution_y = 900 scene.render.image_settings.file_format = "PNG" scene.render.filepath = os.path.join(CONCEPT_DIR, "floppy_disk_lineup.png") bpy.ops.render.render(write_still=True) bpy.ops.wm.save_as_mainfile(filepath=os.path.join(BLEND_DIR, "fbc_floppy_disk.blend")) print("[done] Hissed Floppy Disk: %d tris, %s" % (tris, out_glb))