This commit is contained in:
2025-11-11 19:52:09 -06:00
parent d39ed1ea5a
commit 7d7a3f30e6
7 changed files with 36 additions and 51 deletions

View File

@@ -18,27 +18,40 @@ def processTile(tileIndex, x=0, y=0, z=0):
vertices = []
indices = []
# Tile 0, nothing
if tileIndex == 0:
return None
# Determine color for checkerboard pattern
color = (255,255,255) if (x + y) % 2 == 0 else (0,0,0)
if tileIndex == 2:
color = (255,0,0)
# Use TILE_WIDTH for positions
# Placement X, Y, Z
px = x * TILE_WIDTH
py = y * TILE_HEIGHT
pz = z * TILE_DEPTH
vertices = [
{'position': (px, py, pz), 'color': color, 'uv': (0,0)}, # 0,0
{'position': (px + TILE_WIDTH, py, pz), 'color': color, 'uv': (1,0)}, # 1,0
{'position': (px + TILE_WIDTH, py + TILE_HEIGHT, pz), 'color': color, 'uv': (1,1)}, # 1,1
{'position': (px, py, pz), 'color': color, 'uv': (0,0)}, # 0,0 (repeat)
{'position': (px + TILE_WIDTH, py + TILE_HEIGHT, pz), 'color': color, 'uv': (1,1)}, # 1,1 (repeat)
{'position': (px, py + TILE_HEIGHT, pz), 'color': color, 'uv': (0,1)} # 0,1
]
indices = [0, 1, 2, 3, 4, 5]
if tileIndex == 0:
# Tile 0, nothing
return None
elif tileIndex == 2:
# Tile 2, ramp up
color = (255,0,0)
vertices = [
{'position': (px, py, pz), 'color': color, 'uv': (0,0)}, # 0,0
{'position': (px + TILE_WIDTH, py, pz), 'color': color, 'uv': (1,0)}, # 1,0
{'position': (px + TILE_WIDTH, py + TILE_HEIGHT, pz + TILE_DEPTH), 'color': color, 'uv': (1,1)}, # 1,1
{'position': (px, py, pz), 'color': color, 'uv': (0,0)}, # 0,0 (repeat)
{'position': (px + TILE_WIDTH, py + TILE_HEIGHT, pz + TILE_DEPTH), 'color': color, 'uv': (1,1)}, # 1,1 (repeat)
{'position': (px, py + TILE_HEIGHT, pz + TILE_DEPTH), 'color': color, 'uv': (0,1)} # 0,1
]
indices = [0, 1, 2, 3, 4, 5]
else:
# Determine color for checkerboard pattern
color = (255,255,255) if (x + y) % 2 == 0 else (0,0,0)
vertices = [
{'position': (px, py, pz), 'color': color, 'uv': (0,0)}, # 0,0
{'position': (px + TILE_WIDTH, py, pz), 'color': color, 'uv': (1,0)}, # 1,0
{'position': (px + TILE_WIDTH, py + TILE_HEIGHT, pz), 'color': color, 'uv': (1,1)}, # 1,1
{'position': (px, py, pz), 'color': color, 'uv': (0,0)}, # 0,0 (repeat)
{'position': (px + TILE_WIDTH, py + TILE_HEIGHT, pz), 'color': color, 'uv': (1,1)}, # 1,1 (repeat)
{'position': (px, py + TILE_HEIGHT, pz), 'color': color, 'uv': (0,1)} # 0,1
]
indices = [0, 1, 2, 3, 4, 5]
return {
'vertices': vertices,
@@ -102,7 +115,7 @@ def processChunk(path):
for model in chunk['models']:
# Write vertex count and index count
buffer.extend(model['vertexCount'].to_bytes(4, 'little'))
# buffer.extend(model['indexCount'].to_bytes(4, 'little'))
# For each vertex
for vertex in model['vertices']:
# This is not tightly packed in memory.