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

@@ -73,7 +73,7 @@ static const assettypedef_t ASSET_TYPE_DEFINITIONS[ASSET_TYPE_COUNT] = {
[ASSET_TYPE_MAP] = {
.header = "DMF",
.loadStrategy = ASSET_LOAD_STRAT_ENTIRE,
.dataSize = sizeof(assetmap_t),
.dataSize = sizeof(1),
.entire = assetMapLoad
},

View File

@@ -111,7 +111,6 @@ errorret_t assetChunkLoad(assetcustom_t custom) {
errorThrow("Failed to read chunk model vertex data.");
}
// Init the mesh
mesh_t *mesh = &chunk->meshes[i];
meshInit(

View File

@@ -13,19 +13,7 @@ errorret_t assetMapLoad(void *data, void *output) {
assertNotNull(data, "Data cannot be NULL");
assertNotNull(output, "Output cannot be NULL");
assetmap_t *mapData = (assetmap_t *)data;
assetmap_t *out = (assetmap_t *)output;
memoryCopy(out, mapData, sizeof(assetmap_t));
meshInit(
&out->models[0].mesh,
MESH_PRIMITIVE_TRIANGLES,
out->models[0].vertexCount,
out->models[0].vertices
);
printf("Load asset\n");
assertUnreachable("map not finished");
errorOk();
}

View File

@@ -10,21 +10,6 @@
#include "rpg/world/map.h"
#include "display/mesh/mesh.h"
typedef struct {
uint32_t vertexCount;
meshvertex_t vertices[6 * CHUNK_TILE_COUNT];
mesh_t mesh;
} assetmapmodel_t;
#pragma pack(push, 1)
typedef struct {
uint32_t tileCount;
uint8_t modelCount;
tile_t tiles[CHUNK_TILE_COUNT];
assetmapmodel_t models[1];
} assetmap_t;
#pragma pack(pop)
/**
* Loads a map asset from the given data pointer into the output map structure.
*

View File

@@ -172,7 +172,7 @@ chunkindex_t mapGetChunkIndexAt(const chunkpos_t position) {
chunk_t* mapGetChunk(const uint8_t index) {
if(index >= MAP_CHUNK_COUNT) return NULL;
return &MAP.chunks[index];
return MAP.chunkOrder[index];
}
tile_t mapGetTile(const worldpos_t position) {

View File

@@ -26,7 +26,7 @@ errorret_t sceneMapInit(scenedata_t *data) {
data->sceneMap.camera.projType = CAMERA_PROJECTION_TYPE_PERSPECTIVE_FLIPPED;
data->sceneMap.camera.viewType = CAMERA_VIEW_TYPE_LOOKAT_PIXEL_PERFECT;
glm_vec3_zero(data->sceneMap.camera.lookatPixelPerfect.offset);
data->sceneMap.camera.lookatPixelPerfect.offset[2] = 32.0f;
data->sceneMap.camera.lookatPixelPerfect.offset[1] = TILE_HEIGHT;
glm_vec3_copy(
(vec3){ 0.0f, 0.0f, 0.0f },
data->sceneMap.camera.lookatPixelPerfect.target

View File

@@ -18,18 +18,31 @@ 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
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
@@ -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.