# model/qb fixtures: Qubicle Binary files from a reader / writer written here from the format description in the # Qubicle documentation (no Qubicle tool runs under nix), with every option: RGBA / BGRA, left- / right-handed, # uncompressed / RLE, visibility masks; plus our encoder's output (tools/fixtures/_qb_encode.luau) read back by it. # tests/gen/qb.luau { cases = { { name, data, colorFormat, rightHanded, compressed, visibilityMask, # matrices = { { name, size, pos (scene coordinates: left-handed files mirrored on z), crc # (CRC-32 of the r, g, b, a bytes of every cell in Voxels order), filled } } } }, # ours = { [name] = { same fields as cases } } } import importlib.util, os, pickle, struct, subprocess, zlib, random INPUTS = ["src/Formats/model/qb", "tools/fixtures/_qb_encode.luau"] _spec = importlib.util.spec_from_file_location("_model_ref", os.path.join(os.path.dirname(os.path.abspath(__file__)), "_model_ref.py")) R = importlib.util.module_from_spec(_spec) _spec.loader.exec_module(R) CODEFLAG, NEXTSLICEFLAG = 2, 6 def write_qb(matrices, bgra, right, compressed, mask): """matrices: [(name, (sx, sy, sz), (px, py, pz), {(x, y, z): (r, g, b, a)})] in file coordinates""" out = bytearray(b"\x01\x01\x00\x00") out += struct.pack(" 2: out += struct.pack(" settings, [(name, size, pos, {(x, y, z): (r, g, b, a)})] in file coordinates""" assert data[:4] == b"\x01\x01\x00\x00" fmt, zaxis, comp, mask, n = struct.unpack_from("> 24 == 0: return r, g, b, a = v & 255, v >> 8 & 255, v >> 16 & 255, v >> 24 if fmt == 1: r, b = b, r cells[(x, y, z)] = (r, g, b, a) for z in range(sz): if not comp: for y in range(sy): for x in range(sx): put(x, y, z, struct.unpack_from("