diff --git a/Data/resources/textures/skyboxes/sky50e2dd1d496fc.jpg b/Data/resources/textures/skyboxes/sky50e2dd1d496fc.jpg new file mode 100644 index 0000000..fad07b5 Binary files /dev/null and b/Data/resources/textures/skyboxes/sky50e2dd1d496fc.jpg differ diff --git a/Data/resources/textures/skyboxes/sky8.jpg b/Data/resources/textures/skyboxes/sky8.jpg new file mode 100644 index 0000000..28ca7d7 Binary files /dev/null and b/Data/resources/textures/skyboxes/sky8.jpg differ diff --git a/Data/resources/textures/skyboxes/sky9.jpg b/Data/resources/textures/skyboxes/sky9.jpg new file mode 100644 index 0000000..6bc7442 Binary files /dev/null and b/Data/resources/textures/skyboxes/sky9.jpg differ diff --git a/Data/resources/textures/skyboxes/skybox.jpg b/Data/resources/textures/skyboxes/skybox.jpg new file mode 100644 index 0000000..e9d07fd Binary files /dev/null and b/Data/resources/textures/skyboxes/skybox.jpg differ diff --git a/Data/resources/textures/skyboxes/skybox_11.jpg b/Data/resources/textures/skyboxes/skybox_11.jpg new file mode 100644 index 0000000..15eb340 Binary files /dev/null and b/Data/resources/textures/skyboxes/skybox_11.jpg differ diff --git a/Data/resources/textures/skyboxes/skybox_14.jpg b/Data/resources/textures/skyboxes/skybox_14.jpg new file mode 100644 index 0000000..5d1ccd1 Binary files /dev/null and b/Data/resources/textures/skyboxes/skybox_14.jpg differ diff --git a/Data/resources/textures/skyboxes/skybox_15.jpg b/Data/resources/textures/skyboxes/skybox_15.jpg new file mode 100644 index 0000000..97cab2c Binary files /dev/null and b/Data/resources/textures/skyboxes/skybox_15.jpg differ diff --git a/Data/resources/textures/skyboxes/skybox_3.jpg b/Data/resources/textures/skyboxes/skybox_3.jpg new file mode 100644 index 0000000..2655507 Binary files /dev/null and b/Data/resources/textures/skyboxes/skybox_3.jpg differ diff --git a/Data/sandbox-log.txt b/Data/sandbox-log.txt index 44f16d5..806d1ca 100644 --- a/Data/sandbox-log.txt +++ b/Data/sandbox-log.txt @@ -1,70 +1,45 @@ -[11:46:03 PM] Info: Starting... +[03:20:37 PM] Info: Starting... KP3D version 2 =============================== Copyright (C) kpworld.xyz 2018-2024 Contact me! @kp_cftsz -[11:46:03 PM] Info: Initializing SDL -[11:46:03 PM] Info: Initializing OpenGL -[11:46:03 PM] Info: OpenGL version: 4.6.0 NVIDIA 536.23 -[11:46:03 PM] Info: Initializing GLEW -[11:46:03 PM] Info: Initializing SDL_mixer -[11:46:03 PM] Info: Reticulating splines... -[11:46:03 PM] Info: Ready! -[11:46:03 PM] Info: Loading script: build-cylinder.scm -[11:46:03 PM] Info: Loading script: build-stairs.scm -[11:46:03 PM] Info: Loading material resource: block.png -[11:46:03 PM] Info: Found normal map texture: materials/block_n.png -[11:46:03 PM] Info: Loading material resource: brick2.jpg -[11:46:03 PM] Info: Found normal map texture: materials/brick2_n.jpg -[11:46:03 PM] Info: Loading material resource: bricks.jpg -[11:46:03 PM] Info: Found normal map texture: materials/bricks_n.jpg -[11:46:03 PM] Info: Loading material resource: FLAT5_7.png -[11:46:03 PM] Info: Found normal map texture: materials/FLAT5_7_n.png -[11:46:03 PM] Info: Loading material resource: floor0.png -[11:46:03 PM] Info: Found normal map texture: materials/floor0_n.png -[11:46:03 PM] Info: Loading material resource: floor1.png -[11:46:03 PM] Info: Found normal map texture: materials/floor1_n.png -[11:46:03 PM] Info: Loading material resource: GRASS2.png -[11:46:03 PM] Info: Found normal map texture: materials/GRASS2_n.png -[11:46:03 PM] Info: Loading material resource: hardwood.jpg -[11:46:03 PM] Info: Found normal map texture: materials/hardwood_n.jpg -[11:46:03 PM] Info: Map init -[11:46:03 PM] Info: Finalized mesh with 49 batches -[11:46:06 PM] Info: Finalized mesh with 54 batches -[11:46:07 PM] Info: Finalized mesh with 48 batches -[11:46:08 PM] Info: Finalized mesh with 54 batches -[11:46:09 PM] Info: Finalized mesh with 48 batches -[11:46:09 PM] Info: Finalized mesh with 54 batches -[11:46:09 PM] Info: Finalized mesh with 48 batches -[11:46:09 PM] Info: Finalized mesh with 54 batches -[11:46:09 PM] Info: Finalized mesh with 48 batches -[11:46:09 PM] Info: Finalized mesh with 54 batches -[11:46:09 PM] Info: Finalized mesh with 48 batches -[11:46:09 PM] Info: Finalized mesh with 54 batches -[11:46:10 PM] Info: Finalized mesh with 48 batches -[11:46:10 PM] Info: Finalized mesh with 54 batches -[11:46:10 PM] Info: Finalized mesh with 48 batches -[11:46:10 PM] Info: Finalized mesh with 54 batches -[11:46:10 PM] Info: Finalized mesh with 48 batches -[11:46:10 PM] Info: Finalized mesh with 54 batches -[11:46:10 PM] Info: Finalized mesh with 48 batches -[11:46:10 PM] Info: Finalized mesh with 54 batches -[11:46:11 PM] Info: Finalized mesh with 48 batches -[11:46:12 PM] Info: Finalized mesh with 54 batches -[11:46:12 PM] Info: Finalized mesh with 48 batches -[11:46:14 PM] Info: Finalized mesh with 54 batches -[11:46:14 PM] Info: Finalized mesh with 48 batches -[11:46:15 PM] Info: Finalized mesh with 54 batches -[11:46:15 PM] Info: Finalized mesh with 48 batches -[11:46:15 PM] Info: Finalized mesh with 54 batches -[11:46:15 PM] Info: Finalized mesh with 48 batches -[11:46:16 PM] Info: Finalized mesh with 54 batches -[11:46:16 PM] Info: Finalized mesh with 54 batches -[11:46:17 PM] Info: Finalized mesh with 54 batches -[11:46:17 PM] Info: Finalized mesh with 48 batches -[11:46:17 PM] Info: Finalized mesh with 54 batches -[11:46:18 PM] Info: Finalized mesh with 54 batches -[11:46:19 PM] Info: Finalized mesh with 54 batches -[11:46:19 PM] Info: Finalized mesh with 54 batches +[03:20:37 PM] Info: Initializing SDL +[03:20:37 PM] Info: Initializing OpenGL +[03:20:37 PM] Info: OpenGL version: 4.6.0 NVIDIA 536.23 +[03:20:37 PM] Info: Initializing GLEW +[03:20:37 PM] Info: Initializing SDL_mixer +[03:20:37 PM] Info: Reticulating splines... +[03:20:37 PM] Info: Ready! +[03:20:37 PM] Info: Loading script: build-cylinder.scm +[03:20:37 PM] Info: Loading script: build-stairs.scm +[03:20:37 PM] Info: Loading material resource: block.png +[03:20:37 PM] Info: Found normal map texture: materials/block_n.png +[03:20:37 PM] Info: Loading material resource: brick2.jpg +[03:20:37 PM] Info: Found normal map texture: materials/brick2_n.jpg +[03:20:37 PM] Info: Loading material resource: bricks.jpg +[03:20:37 PM] Info: Found normal map texture: materials/bricks_n.jpg +[03:20:37 PM] Info: Loading material resource: FLAT5_7.png +[03:20:37 PM] Info: Found normal map texture: materials/FLAT5_7_n.png +[03:20:37 PM] Info: Loading material resource: floor0.png +[03:20:37 PM] Info: Found normal map texture: materials/floor0_n.png +[03:20:37 PM] Info: Loading material resource: floor1.png +[03:20:37 PM] Info: Found normal map texture: materials/floor1_n.png +[03:20:37 PM] Info: Loading material resource: GRASS2.png +[03:20:37 PM] Info: Found normal map texture: materials/GRASS2_n.png +[03:20:37 PM] Info: Loading material resource: hardwood.jpg +[03:20:37 PM] Info: Found normal map texture: materials/hardwood_n.jpg +[03:20:37 PM] Info: Map init +[03:20:37 PM] Info: Finalized mesh with 49 batches +[03:20:41 PM] Info: Finalized mesh with 54 batches +[03:20:56 PM] Info: Finalized mesh with 60 batches +[03:21:07 PM] Info: Finalized mesh with 67 batches +[03:21:13 PM] Info: Finalized mesh with 75 batches +[03:21:19 PM] Info: Finalized mesh with 83 batches +[03:21:21 PM] Info: Finalized mesh with 84 batches +[03:21:36 PM] Info: Finalized mesh with 91 batches +[03:21:37 PM] Info: Finalized mesh with 92 batches +[03:21:47 PM] Info: Finalized mesh with 99 batches +[03:21:49 PM] Info: Finalized mesh with 107 batches +[03:21:49 PM] Info: Finalized mesh with 108 batches diff --git a/KP3Dii/src/KP3D_Map.cpp b/KP3Dii/src/KP3D_Map.cpp index 34f3b25..de088b9 100644 --- a/KP3Dii/src/KP3D_Map.cpp +++ b/KP3Dii/src/KP3D_Map.cpp @@ -668,6 +668,8 @@ void Map::Rebuild(NormalGenType gen_normals) Sector& potential_parent = *spp; if (sector.id == potential_parent.id) continue; + if (sector.floor.base_height >= potential_parent.ceiling.base_height) // room-over-room support + continue; if (SectorContains(potential_parent, sector)) { potential_parent.children.push_back(§or); @@ -878,10 +880,15 @@ void Map::RenderSkybox() glEnable(GL_DEPTH_TEST); } -void Map::BuildGrid() +void Map::BuildGrid(float y) { - m_grid_shader.Load(".kp3d/map_grid_v.glsl", ".kp3d/map_grid_f.glsl"); - m_grid_texture.Load(".kp3d/map_grid.png", false, kp3d::Texture::FILTER_LINEAR); + m_grid_y = y; + if (m_grid_texture.GetPath().empty()) + { + m_grid_shader.Load(".kp3d/map_grid_v.glsl", ".kp3d/map_grid_f.glsl"); + m_grid_texture.Load(".kp3d/map_grid.png", false, kp3d::Texture::FILTER_LINEAR); + } + m_grid_mesh.Reset(); m_grid_mesh.AddBatch(&m_grid_texture, { Vertex3D(Vec3(-0.5f, 0.0f, 0.5f), Vec2(0.0f, 1.0f)), Vertex3D(Vec3(-0.5f, 0.0f, -0.5f), Vec2(0.0f, 0.0f)), @@ -893,14 +900,18 @@ void Map::BuildGrid() m_grid_mesh.Finalize(); for (const RenderBatch3D& batch: m_grid_mesh.GetBatchesRef()) for (int i = 0; i < batch.vertex_data.size(); i++) - grid_box[i] = batch.vertex_data[i].position * 1000.0f; + grid_box[i] = { + batch.vertex_data[i].position.x * 1000.0f, + batch.vertex_data[i].position.y + m_grid_y, + batch.vertex_data[i].position.z * 1000.0f + }; } void Map::RenderGrid() { Renderer3D::PushShader(m_grid_shader); Vec3 camera_pos = Renderer3D::GetPrimaryCamera()->position; - camera_pos.y = 0.01f; + camera_pos.y = 0.01f + m_grid_y; Transform grid_transform(camera_pos, {0.0, 0.0, 0.0}, {1000.0, 0.0, 1000.0}); glDisable(GL_CULL_FACE); Renderer3D::DrawMesh(m_grid_mesh, grid_transform); diff --git a/KP3Dii/src/KP3D_Map.h b/KP3Dii/src/KP3D_Map.h index 858006f..8fa74b7 100644 --- a/KP3Dii/src/KP3D_Map.h +++ b/KP3Dii/src/KP3D_Map.h @@ -157,7 +157,7 @@ public: void BuildSkybox(const std::string& texture_path, float scale = 128.0f); void RenderSkybox(); - void BuildGrid(); + void BuildGrid(float y = 0.0f); void RenderGrid(); StaticMesh& GetMeshRef(); @@ -175,6 +175,7 @@ private: StaticMesh m_mesh; StaticMesh m_grid_mesh; Shader m_grid_shader; + float m_grid_y = 0.0f; Texture m_grid_texture; Skybox m_skybox_data; Transform m_transform; diff --git a/Sandbox/src/Editor.cpp b/Sandbox/src/Editor.cpp index baf2f26..d1bd054 100644 --- a/Sandbox/src/Editor.cpp +++ b/Sandbox/src/Editor.cpp @@ -312,8 +312,8 @@ void Editor::UpdateModeBuild() s->ceiling.material = kp3d::res::material_cache["block.png"].get(); s->floor.material = kp3d::res::material_cache["block.png"].get(); s->floor.floor = true; - s->floor.base_height = 0.0f; - s->ceiling.base_height = 2.0f; + s->floor.base_height = m_grid_y; + s->ceiling.base_height = m_grid_y + 4.0f; s->id = sandbox->map.sectors.size() + 1; s->parent_id = 0; s->inverted = false; @@ -369,8 +369,8 @@ void Editor::UpdateModeBuild() s->ceiling.material = kp3d::res::material_cache["block.png"].get(); s->floor.material = kp3d::res::material_cache["block.png"].get(); s->floor.floor = true; - s->floor.base_height = 0.0f; - s->ceiling.base_height = 4.0f; + s->floor.base_height = m_grid_y; + s->ceiling.base_height = m_grid_y + 4.0f; s->id = sandbox->map.sectors.size() + 1; s->parent_id = 0; s->inverted = false; @@ -1174,19 +1174,27 @@ void Editor::OnScrollWheel(const kp3d::ScrollWheelEvent* e) { using namespace kp3d; - if (editor_hovered_batch.empty()) - return; - - auto factor = (2.0f / 128.0f) * e->length; - for (auto* batch: editor_hovered_batch) + if (m_mode == MODE_NORMAL) { - auto info = std::any_cast(batch->userdata); - if (info.flat) + if (editor_hovered_batch.empty()) + return; + + auto factor = (2.0f / 128.0f) * e->length; + for (auto* batch : editor_hovered_batch) { - info.flat->base_height += factor; - RebuildMap(); + auto info = std::any_cast(batch->userdata); + if (info.flat) + { + info.flat->base_height += factor; + RebuildMap(); + } } } + else if (m_mode == MODE_BUILD) + { + m_grid_y += (2.0f / 128.0f) * e->length; + sandbox->map.BuildGrid(m_grid_y); + } } void Editor::OnKeyPress(const kp3d::KeyPressEvent* e) diff --git a/Sandbox/src/Editor.h b/Sandbox/src/Editor.h index d051755..eb4267a 100644 --- a/Sandbox/src/Editor.h +++ b/Sandbox/src/Editor.h @@ -80,6 +80,7 @@ private: kp3d::Texture m_banner; kp3d::Texture m_stem; kp3d::Vec3 m_stem_pos; + float m_grid_y = 0.0f; EditMode m_mode; // TODO: Refactor me!