Handle stairs better

This commit is contained in:
2025-11-11 23:40:50 -06:00
parent 84593867dc
commit 542aeadf0f
4 changed files with 67 additions and 21 deletions

View File

@@ -14,21 +14,21 @@ TILE_WIDTH = 16.0
TILE_HEIGHT = 16.0
TILE_DEPTH = 11.36
def processTile(tileIndex, x=0, y=0, z=0):
def processTile(tileIndex, x=0, y=0, z=0, chunkX=0, chunkY=0, chunkZ=0):
vertices = []
indices = []
tileType = tileIndex
# Placement X, Y, Z
px = x * TILE_WIDTH
py = y * TILE_HEIGHT
pz = z * TILE_DEPTH
px = (x * TILE_WIDTH) + (chunkX * CHUNK_WIDTH * TILE_WIDTH)
py = (y * TILE_HEIGHT) + (chunkY * CHUNK_HEIGHT * TILE_HEIGHT)
pz = (z * TILE_DEPTH) + (chunkZ * CHUNK_DEPTH * TILE_DEPTH)
if tileIndex == 0:
# Tile 0, nothing
return None
elif tileIndex == 2:
elif tileIndex == 5:
# Tile 2, ramp up
color = (255,0,0)
vertices = [
@@ -44,7 +44,7 @@ def processTile(tileIndex, x=0, y=0, z=0):
else:
# Determine color for checkerboard pattern
if tileIndex == 1:
color = (0, 255, 0)
color = (255, 255, 255)
else:
color = (0, 0, 255)
@@ -73,7 +73,17 @@ def processChunk(path):
with open(path, 'r') as f:
inData = json.load(f)
# Filename must contain chunk coordinates as X_Y_Z
fileName = os.path.basename(path)
nameParts = os.path.splitext(fileName)[0].split('_')
if len(nameParts) != 3:
print(f"Error: Chunk filename {fileName} does not contain valid chunk coordinates.")
sys.exit(1)
chunk = {
'chunkX': int(nameParts[0]),
'chunkY': int(nameParts[1]),
'chunkZ': int(nameParts[2]),
'tiles': [0] * CHUNK_TILE_COUNT,
'models': []
}
@@ -97,7 +107,7 @@ def processChunk(path):
z = i // (CHUNK_WIDTH * CHUNK_HEIGHT)
# Add tile 3D model
result = processTile(tile, x, y, z)
result = processTile(tile, x, y, z, chunk['chunkX'], chunk['chunkY'], chunk['chunkZ'])
if result is not None and len(result['vertices']) > 0:
base = len(baseModel['vertices'])
quad_indices = [base + idx for idx in result['indices']]