diff --git a/src/asset/assettype.h b/src/asset/assettype.h index add66c0..d232514 100644 --- a/src/asset/assettype.h +++ b/src/asset/assettype.h @@ -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 }, diff --git a/src/asset/type/assetchunk.c b/src/asset/type/assetchunk.c index 4be78ef..7a3481f 100644 --- a/src/asset/type/assetchunk.c +++ b/src/asset/type/assetchunk.c @@ -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( diff --git a/src/asset/type/assetmap.c b/src/asset/type/assetmap.c index 7ac3347..875db74 100644 --- a/src/asset/type/assetmap.c +++ b/src/asset/type/assetmap.c @@ -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(); } \ No newline at end of file diff --git a/src/asset/type/assetmap.h b/src/asset/type/assetmap.h index a66b054..7411ce3 100644 --- a/src/asset/type/assetmap.h +++ b/src/asset/type/assetmap.h @@ -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. * diff --git a/src/rpg/world/map.c b/src/rpg/world/map.c index 33f22e6..b4f83e6 100644 --- a/src/rpg/world/map.c +++ b/src/rpg/world/map.c @@ -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) { diff --git a/src/scene/scene/scenemap.c b/src/scene/scene/scenemap.c index 4a4e968..22b9baf 100644 --- a/src/scene/scene/scenemap.c +++ b/src/scene/scene/scenemap.c @@ -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 diff --git a/tools/assetstool/processmap.py b/tools/assetstool/processmap.py index e7b049f..bdee00c 100644 --- a/tools/assetstool/processmap.py +++ b/tools/assetstool/processmap.py @@ -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.