import struct import vec3 vertex_table = [ ((-1.0, 1.0, -1.0), (0.0, 1.0, 0.0), (1.0, 0.0)), ((1.0, 1.0, 1.0), (0.0, 1.0, 0.0), (0.0, 1.0)), ((1.0, 1.0, -1.0), (0.0, 1.0, 0.0), (0.0, 0.0)), ((1.0, 1.0, 1.0), (0.0, 0.0, 1.0), (1.0, 1.0)), ((-1.0, -1.0, 1.0), (0.0, 0.0, 1.0), (0.0, 0.0)), ((1.0, -1.0, 1.0), (0.0, 0.0, 1.0), (1.0, 0.0)), ((-1.0, 1.0, 1.0), (-1.0, 0.0, 0.0), (1.0, 1.0)), ((-1.0, -1.0, -1.0), (-1.0, 0.0, 0.0), (0.0, 0.0)), ((-1.0, -1.0, 1.0), (-1.0, 0.0, 0.0), (1.0, 0.0)), ((1.0, -1.0, -1.0), (0.0, -1.0, 0.0), (1.0, 0.0)), ((-1.0, -1.0, 1.0), (0.0, -1.0, 0.0), (0.0, 1.0)), ((-1.0, -1.0, -1.0), (0.0, -1.0, 0.0), (0.0, 0.0)), ((1.0, 1.0, -1.0), (1.0, 0.0, 0.0), (1.0, 1.0)), ((1.0, -1.0, 1.0), (1.0, 0.0, 0.0), (0.0, 0.0)), ((1.0, -1.0, -1.0), (1.0, 0.0, 0.0), (1.0, 0.0)), ((-1.0, 1.0, -1.0), (0.0, 0.0, -1.0), (1.0, 1.0)), ((1.0, -1.0, -1.0), (0.0, 0.0, -1.0), (0.0, 0.0)), ((-1.0, -1.0, -1.0), (0.0, 0.0, -1.0), (1.0, 0.0)), ((-1.0, 1.0, 1.0), (0.0, 1.0, 0.0), (1.0, 1.0)), ((-1.0, 1.0, 1.0), (0.0, 0.0, 1.0), (0.0, 1.0)), ((-1.0, 1.0, -1.0), (-1.0, 0.0, 0.0), (0.0, 1.0)), ((1.0, -1.0, 1.0), (0.0, -1.0, 0.0), (1.0, 1.0)), ((1.0, 1.0, 1.0), (1.0, 0.0, 0.0), (0.0, 1.0)), ((1.0, 1.0, -1.0), (0.0, 0.0, -1.0), (0.0, 1.0)) ] faces_by_normal = { (-1.0, 0.0, 0.0): [6, 7, 8, 6, 20, 7], (0.0, -1.0, 0.0): [9, 10, 11, 9, 21, 10], (0.0, 0.0, -1.0): [15, 16, 17, 15, 23, 16], (0.0, 0.0, 1.0): [3, 4, 5, 3, 19, 4], (0.0, 1.0, 0.0): [0, 1, 2, 0, 18, 1], (1.0, 0.0, 0.0): [12, 13, 14, 12, 22, 13] } normals = [ (-1.0, 0.0, 0.0), (0.0, -1.0, 0.0), (0.0, 0.0, -1.0), (0.0, 0.0, 1.0), (0.0, 1.0, 0.0), (1.0, 0.0, 0.0), ] def build_configuration_index_buffers(f): offset = 0 configuration_offsets = [] for configuration in range(64): configuration_offsets.append(offset) for i in range(6): if (configuration & (1 << i)) == 0: continue normal = normals[i] indices = faces_by_normal[normal] for index in indices: f.write(struct.pack("