"""Grouper: one Workbench close-up of the built file (read-only), for looking at a place: blender.exe -b Tender_Grouper.blend --python build/gr_shot.py -- out= loc=x,y,z tgt=x,y,z [lens=35] [hide=] [cull] [wire] [nocn] (backface culling, wireframe over the shading, without the custom normals)""" import bpy, os, sys, math from mathutils import Vector args = sys.argv[sys.argv.index("--") + 1:] hide = [a[5:] for a in args if a.startswith("hide=")] cull = "cull" in args out = [a[4:] for a in args if a.startswith("out=")][0] loc = Vector([float(v) for v in [a[4:] for a in args if a.startswith("loc=")][0].split(",")]) tgt = Vector([float(v) for v in [a[4:] for a in args if a.startswith("tgt=")][0].split(",")]) lens = float(([a[5:] for a in args if a.startswith("lens=")] or ["35"])[0]) sc = bpy.context.scene for o in bpy.data.objects: if o.name.startswith("UCX_") or any(o.name.startswith(h) for h in hide): o.hide_render = True PREV = {"M_Grouper_Gunmetal": (0.56, 0.58, 0.61), "M_Grouper_Band": (0.40, 0.42, 0.45), "M_Grouper_FrameDark": (0.16, 0.17, 0.18), "M_Grouper_Strip": (0.15, 0.85, 1.0), "M_Grouper_Acrylic": (0.70, 0.86, 0.95), "M_Grouper_LampWhite": (1.0, 1.0, 0.92), "M_Grouper_ScannerLens": (0.35, 0.65, 1.0), "M_Grouper_DuctGlow": (0.10, 0.55, 0.65), "M_Grouper_Recess": (0.06, 0.06, 0.06), "M_Grouper_Steel": (0.7, 0.72, 0.75), "M_Grouper_Cabin": (0.5, 0.3, 0.3), "M_Grouper_CabinDark": (0.3, 0.2, 0.2), "M_Grouper_Seat": (0.5, 0.45, 0.2), "M_Grouper_Screen": (0.1, 0.9, 0.9), "M_Grouper_CabinFloor": (0.4, 0.4, 0.2)} for m in bpy.data.materials: if m.name in PREV: m.diffuse_color = PREV[m.name] + (1.0,) if "nocn" in args: import bmesh as _bm h = bpy.data.objects["SM_Grouper_Hull"] with bpy.context.temp_override(object=h, active_object=h, selected_editable_objects=[h]): bpy.ops.mesh.customdata_custom_splitnormals_clear() sc.render.engine = 'BLENDER_WORKBENCH' sh = sc.display.shading sh.light = 'STUDIO'; sh.color_type = 'MATERIAL'; sh.show_cavity = False; sh.show_backface_culling = cull sh.show_object_outline = True sc.render.resolution_x, sc.render.resolution_y = 1400, 860 cam = bpy.data.objects.new("_c", bpy.data.cameras.new("_c")); sc.collection.objects.link(cam); sc.camera = cam cam.location = loc; cam.rotation_euler = (tgt - loc).normalized().to_track_quat('-Z', 'Y').to_euler(); cam.data.lens = lens cam.data.clip_start = 0.02 if "wire" in args: wm = bpy.data.materials.new("_wink"); wm.diffuse_color = (0.02, 0.02, 0.03, 1) for o in list(bpy.data.objects): if o.type == 'MESH' and not o.hide_render and not o.name.startswith("UCX_"): t = o.copy(); t.data = o.data.copy(); t.name = "_w_" + o.name t.data.materials.clear(); t.data.materials.append(wm) t.parent = None; t.matrix_world = o.matrix_world.copy() sc.collection.objects.link(t) md = t.modifiers.new("w", 'WIREFRAME'); md.thickness = 0.002; md.use_relative_offset = False sc.render.filepath = out bpy.ops.render.render(write_still=True) print("SHOT OK")