"""Tiger: its outside in its own (Tender) frame for the checks against the ship and the docking arm (the cockpit left out): checks/tiger_points.npy every vertex and face centre, tool arm folded down (docking) checks/tiger_tris.npz all triangles (v, t, names), tool arm folded down checks/tiger_points_armaft.npy the same points with the tool arm pointing aft (as the picture draws it) blender -b Tender_Tiger.blend --python build/tg_dump.py (the file is not saved; the handle is put back)""" import bpy import os import numpy as np HERE = os.path.dirname(os.path.abspath(__file__)) root = bpy.data.objects["Tiger_Root"] NAMES = ("SM_Tiger_Hull", "SM_Tiger_Glass", "SM_Tiger_ToolArm") def refresh(): for ob in bpy.data.objects: if ob.animation_data: for fc in ob.animation_data.drivers: fc.driver.expression = fc.driver.expression fc.driver.is_valid = True ob.update_tag() root.update_tag() bpy.context.view_layer.update() def collect(): dg = bpy.context.evaluated_depsgraph_get() V, T, N, P, off = [], [], [], [], 0 for n in NAMES: o = bpy.data.objects[n] ev = o.evaluated_get(dg) me = ev.to_mesh() me.calc_loop_triangles() M = np.array(ev.matrix_world) co = np.empty(len(me.vertices) * 3) me.vertices.foreach_get("co", co) co = co.reshape(-1, 3) @ M[:3, :3].T + M[:3, 3] tr = np.empty(len(me.loop_triangles) * 3, np.int64) me.loop_triangles.foreach_get("vertices", tr) tr = tr.reshape(-1, 3) ev.to_mesh_clear() V.append(co) T.append(tr + off) N += [n] * len(tr) P.append(np.concatenate([co, co[tr].mean(1)])) off += len(co) return np.concatenate(V), np.concatenate(T), np.array(N), np.concatenate(P) keep = root.get("tool_arm_down_deg", 0.0) root["tool_arm_down_deg"] = 0.0 refresh() v, t, n, p_aft = collect() np.save(os.path.join(HERE, "checks", "tiger_points_armaft.npy"), p_aft) root["tool_arm_down_deg"] = 90.0 refresh() v, t, n, p = collect() np.save(os.path.join(HERE, "checks", "tiger_points.npy"), p) np.savez(os.path.join(HERE, "checks", "tiger_tris.npz"), v=v, t=t, names=n) root["tool_arm_down_deg"] = keep refresh() print("DUMP", len(v), len(t), "y range %.3f .. %.3f" % (p[:, 1].min(), p[:, 1].max()), "armaft y max %.3f" % p_aft[:, 1].max())