# Copyright (c) 2026 Dominic Masters # # This software is released under the MIT License. # https://opensource.org/licenses/MIT """ Writes DMF (Dusk Mesh Format) files. DMF format: Bytes 0-3: DMF\x00 (magic) Bytes 4-7: uint32_t version = 1 (little-endian) Bytes 8-11: uint32_t vertCount (little-endian) Bytes 12+: meshvertex_t vertices[vertCount] Each vertex is 20 bytes: uv[2] + pos[3] (5 floats, LE) Usage: python3 -m tools.asset.dmf Reads raw vertex bytes from vertices.bin and writes a DMF file. """ import struct import sys import os MAGIC = b'DMF\x00' VERSION = 1 VERTEX_SIZE = 20 def write_dmf(path, vertex_bytes): if len(vertex_bytes) % VERTEX_SIZE != 0: raise ValueError( f"Vertex data size {len(vertex_bytes)} is not a " f"multiple of {VERTEX_SIZE}" ) vert_count = len(vertex_bytes) // VERTEX_SIZE buf = bytearray() buf += MAGIC buf += struct.pack(' " ) sys.exit(1) dst = args[0] src = args[1] with open(src, 'rb') as f: vertex_bytes = f.read() write_dmf(dst, vertex_bytes) if __name__ == '__main__': main()