"""Grouper: the hull's three LODs side by side (critique round 1, M2), from the exported FBX files, Workbench with wireframe: blender.exe -b --factory-startup --python build/gr_lods_preview.py -> previews/lods_hull.png (nothing saved)""" import bpy, os, math from mathutils import Vector HERE = os.path.dirname(os.path.abspath(__file__)) ROOT = os.path.dirname(HERE) for o in list(bpy.data.objects): bpy.data.objects.remove(o) sc = bpy.context.scene objs = [] for k, name in enumerate(("SM_Grouper_Hull", "SM_Grouper_Hull_LOD1", "SM_Grouper_Hull_LOD2")): before = set(bpy.data.objects) bpy.ops.import_scene.fbx(filepath=os.path.join(ROOT, "fbx", name + ".fbx")) new = [o for o in bpy.data.objects if o not in before and o.type == 'MESH' and not o.name.startswith("UCX_")] for o in bpy.data.objects: if o not in before and o.name.startswith("UCX_"): o.hide_render = True for o in new: o.rotation_euler = (0.0, 0.0, math.radians(-28)) o.location.z += (1 - k) * 3.9 o["tris"] = sum(len(p.vertices) - 2 for p in o.data.polygons) objs.append((name, o)) sc.render.engine = 'BLENDER_WORKBENCH' sh = sc.display.shading sh.light = 'STUDIO'; sh.color_type = 'SINGLE'; sh.single_color = (0.62, 0.64, 0.67); sh.show_cavity = False sc.render.resolution_x, sc.render.resolution_y = 1400, 1900 wm = bpy.data.materials.new("_wire"); wm.diffuse_color = (0.02, 0.02, 0.03, 1) for nm, o in objs: m = o.modifiers.new("w", 'WIREFRAME'); m.thickness = 0.004; m.use_replace = False; m.material_offset = len(o.data.materials) o.data.materials.append(wm) sh.color_type = 'MATERIAL' for m in bpy.data.materials: if m.name != "_wire": m.diffuse_color = (0.62, 0.64, 0.67, 1) cam = bpy.data.objects.new("_c", bpy.data.cameras.new("_c")); sc.collection.objects.link(cam); sc.camera = cam cam.data.type = 'ORTHO'; cam.data.ortho_scale = 12.4 cam.location = Vector((-20.0, 0.0, 0.0)); cam.rotation_euler = (math.radians(90), 0.0, math.radians(-90)) sc.render.filepath = os.path.join(ROOT, "previews", "lods_hull.png") bpy.ops.render.render(write_still=True) print("LODS", [(nm, o["tris"]) for nm, o in objs])