Skip to content

Commit

Permalink
Transferred walls to the sk_map structure
Browse files Browse the repository at this point in the history
  • Loading branch information
iWas-Coder committed Apr 15, 2024
1 parent 2fcb356 commit ba877bf
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 7 deletions.
3 changes: 3 additions & 0 deletions include/sk_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ typedef struct {
sk_map_kind kind;
Shader pbr_shader;
Model floor;
Model wall1;
Model wall2;
Model wall3;
} sk_map;

sk_map sk_map_create(sk_map_kind kind);
Expand Down
39 changes: 36 additions & 3 deletions src/sk_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,60 @@ sk_map sk_map_create(sk_map_kind kind) {

void sk_map_destroy(sk_map *m) {
UnloadModel(m->floor);
UnloadModel(m->wall1);
UnloadModel(m->wall2);
UnloadModel(m->wall3);
UnloadShader(m->pbr_shader);
}

void sk_map_load(sk_map *m) {
m->floor = LoadModelFromMesh(GenMeshPlane(32, 32, 1, 1));
assert(m->floor.meshCount == 1);
assert(m->floor.materialCount == 1);
m->pbr_shader.locs[SHADER_LOC_MAP_ALBEDO] = GetShaderLocation(m->pbr_shader, "albedoMap");
m->pbr_shader.locs[SHADER_LOC_MAP_METALNESS] = GetShaderLocation(m->pbr_shader, "mraMap");
m->pbr_shader.locs[SHADER_LOC_MAP_NORMAL] = GetShaderLocation(m->pbr_shader, "normalMap");
m->pbr_shader.locs[SHADER_LOC_MAP_EMISSION] = GetShaderLocation(m->pbr_shader, "emissiveMap");
m->pbr_shader.locs[SHADER_LOC_COLOR_DIFFUSE] = GetShaderLocation(m->pbr_shader, "albedoColor");
m->pbr_shader.locs[SHADER_LOC_VECTOR_VIEW] = GetShaderLocation(m->pbr_shader, "viewPos");
m->floor = LoadModelFromMesh(GenMeshPlane(32, 32, 1, 1));
assert(m->floor.meshCount == 1);
assert(m->floor.materialCount == 1);
// m->floor.materials[0].shader = m->pbr_shader;
m->floor.materials[0].maps[MATERIAL_MAP_ALBEDO].texture = LoadTexture("assets/textures/wood/albedo.png");
m->floor.materials[0].maps[MATERIAL_MAP_NORMAL].texture = LoadTexture("assets/textures/wood/normal.png");
m->floor.materials[0].maps[MATERIAL_MAP_ROUGHNESS].texture = LoadTexture("assets/textures/wood/roughness.png");
m->floor.materials[0].maps[MATERIAL_MAP_HEIGHT].texture = LoadTexture("assets/textures/wood/height.png");
m->floor.materials[0].maps[MATERIAL_MAP_OCCLUSION].texture = LoadTexture("assets/textures/wood/ao.png");
m->wall1 = LoadModelFromMesh(GenMeshCube(1, 5, 32));
assert(m->wall1.meshCount == 1);
assert(m->wall1.materialCount == 1);
// m->wall1.materials[0].shader = m->pbr_shader;
m->wall1.materials[0].maps[MATERIAL_MAP_ALBEDO].texture = LoadTexture("assets/textures/stone1/albedo.png");
m->wall1.materials[0].maps[MATERIAL_MAP_NORMAL].texture = LoadTexture("assets/textures/stone1/normal.png");
m->wall1.materials[0].maps[MATERIAL_MAP_ROUGHNESS].texture = LoadTexture("assets/textures/stone1/roughness.png");
m->wall1.materials[0].maps[MATERIAL_MAP_HEIGHT].texture = LoadTexture("assets/textures/stone1/height.png");
m->wall1.materials[0].maps[MATERIAL_MAP_OCCLUSION].texture = LoadTexture("assets/textures/stone1/ao.png");
m->wall2 = LoadModelFromMesh(GenMeshCube(1, 5, 32));
assert(m->wall2.meshCount == 1);
assert(m->wall2.materialCount == 1);
// m->wall2.materials[0].shader = m->pbr_shader;
m->wall2.materials[0].maps[MATERIAL_MAP_ALBEDO].texture = LoadTexture("assets/textures/stone1/albedo.png");
m->wall2.materials[0].maps[MATERIAL_MAP_NORMAL].texture = LoadTexture("assets/textures/stone1/normal.png");
m->wall2.materials[0].maps[MATERIAL_MAP_ROUGHNESS].texture = LoadTexture("assets/textures/stone1/roughness.png");
m->wall2.materials[0].maps[MATERIAL_MAP_HEIGHT].texture = LoadTexture("assets/textures/stone1/height.png");
m->wall2.materials[0].maps[MATERIAL_MAP_OCCLUSION].texture = LoadTexture("assets/textures/stone1/ao.png");
m->wall3 = LoadModelFromMesh(GenMeshCube(32, 5, 1));
assert(m->wall3.meshCount == 1);
assert(m->wall3.materialCount == 1);
// m->wall3.materials[0].shader = m->pbr_shader;
m->wall3.materials[0].maps[MATERIAL_MAP_ALBEDO].texture = LoadTexture("assets/textures/stone1/albedo.png");
m->wall3.materials[0].maps[MATERIAL_MAP_NORMAL].texture = LoadTexture("assets/textures/stone1/normal.png");
m->wall3.materials[0].maps[MATERIAL_MAP_ROUGHNESS].texture = LoadTexture("assets/textures/stone1/roughness.png");
m->wall3.materials[0].maps[MATERIAL_MAP_HEIGHT].texture = LoadTexture("assets/textures/stone1/height.png");
m->wall3.materials[0].maps[MATERIAL_MAP_OCCLUSION].texture = LoadTexture("assets/textures/stone1/ao.png");
}

void sk_map_draw(sk_map *m) {
DrawModel(m->floor, (Vector3) { 0, 0, 0 }, 1, WHITE);
DrawModel(m->wall1, (Vector3) { -16, 2.5f, 0 }, 1, WHITE);
DrawModel(m->wall2, (Vector3) { 16, 2.5f, 0 }, 1, WHITE);
DrawModel(m->wall3, (Vector3) { 0, 2.5f, 16 }, 1, WHITE);
}
4 changes: 0 additions & 4 deletions src/sk_renderer_draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,6 @@ static void __draw_gameplay_world(sk_state *s) {
sk_weapon_draw(&s->player.weapon, &s->player.camera, (Vector3) { 1, -1, -3 }, 0.5f);
sk_player_draw(&s->player);
sk_map_draw(&s->map);
// DrawPlane((Vector3) { 0, 0, 0 }, (Vector2) { 32, 32 }, DARKGRAY);
DrawCube((Vector3) { -16, 2.5f, 0 }, 1, 5, 32, MAROON);
DrawCube((Vector3) { 16, 2.5f, 0 }, 1, 5, 32, LIME);
DrawCube((Vector3) { 0, 2.5f, 16 }, 32, 5, 1, GOLD);
EndMode3D();
}

Expand Down

0 comments on commit ba877bf

Please sign in to comment.