This commit is contained in:
2025-11-11 15:50:57 -06:00
parent 5adf8a0773
commit 9953d7d388
11 changed files with 135 additions and 86 deletions

View File

@@ -16,8 +16,11 @@
#include "rpg/rpgcamera.h"
#include "util/memory.h"
#define TILE_SIZE 16
assetmapmodel_t mesh;
#define TILE_WIDTH 16.0f
#define TILE_HEIGHT 16.0f
#define TILE_DEPTH 11.36f
assetmap_t TEST_MAP;
bool_t TEST_MAP_READY = false;
errorret_t sceneMapInit(scenedata_t *data) {
// Init the camera.
@@ -37,7 +40,8 @@ errorret_t sceneMapInit(scenedata_t *data) {
data->sceneMap.camera.lookatPixelPerfect.pixelsPerUnit = 1.0f;
errorChain(assetLoad("map/map.dmf", &mesh));
errorChain(assetLoad("map/map.dmf", &TEST_MAP));
TEST_MAP_READY = true;
errorOk();
}
@@ -48,9 +52,9 @@ void sceneMapUpdate(scenedata_t *data) {
void sceneMapGetWorldPosition(const worldpos_t pos, vec3 outPosition) {
assertNotNull(outPosition, "Output position cannot be NULL");
outPosition[0] = pos.x * TILE_SIZE;
outPosition[1] = pos.y * TILE_SIZE;
outPosition[2] = pos.z * TILE_SIZE;
outPosition[0] = pos.x * TILE_WIDTH;
outPosition[1] = pos.y * TILE_HEIGHT;
outPosition[2] = pos.z * TILE_DEPTH;
}
void sceneMapEntityGetPosition(const entity_t *entity, vec3 outPosition) {
@@ -70,13 +74,13 @@ void sceneMapEntityGetPosition(const entity_t *entity, vec3 outPosition) {
vec3 offset = {
(
(float_t)entity->position.x - (float_t)entity->lastPosition.x
) * TILE_SIZE * -animPercentage,
) * TILE_WIDTH * -animPercentage,
(
(float_t)entity->position.y - (float_t)entity->lastPosition.y
) * TILE_SIZE * -animPercentage,
) * TILE_HEIGHT * -animPercentage,
(
(float_t)entity->position.z - (float_t)entity->lastPosition.z
) * TILE_SIZE * -animPercentage
) * TILE_DEPTH * -animPercentage
};
glm_vec3_add(outPosition, offset, outPosition);
break;
@@ -117,7 +121,7 @@ void sceneMapRender(scenedata_t *data) {
// sceneMapRenderMap();
textureBind(NULL);
meshDraw(&mesh.mesh, -1, -1);
meshDraw(&TEST_MAP.models[0].mesh, -1, -1);
// Render ents
entity_t *ent = ENTITIES;
@@ -136,7 +140,7 @@ void sceneMapRenderEntity(entity_t *entity) {
if(entity->type == ENTITY_TYPE_NULL) return;
vec3 posMin, posMax;
vec3 size = { TILE_SIZE, TILE_SIZE, TILE_SIZE };
vec3 size = { TILE_WIDTH, TILE_HEIGHT, TILE_DEPTH };
sceneMapEntityGetPosition(entity, posMin);
glm_vec3_add(posMin, size, posMax);
@@ -172,12 +176,12 @@ void sceneMapRenderMap() {
chunk_t *chunk = MAP.chunkOrder[i];
vec3 min, max;
min[0] = chunk->position.x * CHUNK_WIDTH * TILE_SIZE;
min[1] = chunk->position.y * CHUNK_HEIGHT * TILE_SIZE;
min[2] = chunk->position.z * CHUNK_DEPTH * TILE_SIZE;
min[0] = chunk->position.x * CHUNK_WIDTH * TILE_WIDTH;
min[1] = chunk->position.y * CHUNK_HEIGHT * TILE_HEIGHT;
min[2] = chunk->position.z * CHUNK_DEPTH * TILE_DEPTH;
max[0] = min[0] + (CHUNK_WIDTH * TILE_SIZE);
max[1] = min[1] + (CHUNK_HEIGHT * TILE_SIZE);
max[0] = min[0] + (CHUNK_WIDTH * TILE_WIDTH);
max[1] = min[1] + (CHUNK_HEIGHT * TILE_HEIGHT);
max[2] = min[2];
color_t color = COLOR_WHITE;
@@ -199,5 +203,5 @@ void sceneMapRenderMap() {
}
void sceneMapDispose(scenedata_t *data) {
meshDispose(&mesh.mesh);
meshDispose(&TEST_MAP.models[0].mesh);
}

View File

@@ -9,11 +9,15 @@
#include "scene/scene.h"
#include "rpg/entity/entity.h"
#include "display/camera.h"
#include "asset/asset.h"
typedef struct {
camera_t camera;
} scenemap_t;
extern assetmap_t TEST_MAP;
extern bool_t TEST_MAP_READY;
errorret_t sceneMapInit(scenedata_t *data);
void sceneMapUpdate(scenedata_t *data);
void sceneMapRender(scenedata_t *data);