From 0b62550f548e3d2f728ff9cf7bff03a37614542e Mon Sep 17 00:00:00 2001 From: Warwick Date: Tue, 30 Aug 2022 14:04:50 +0100 Subject: [PATCH] Using models seems to be harder than just generating the chunk manually. So to make this possible and less tedious and time consuming I'm now going to move to place models on top of a marching cube terrain using a triangulation table. --- src/MarchingCubeShapeMap.cpp | 84 ++++++++++++++++++++++++++++++------ src/main.cpp | 16 +++++-- 2 files changed, 84 insertions(+), 16 deletions(-) diff --git a/src/MarchingCubeShapeMap.cpp b/src/MarchingCubeShapeMap.cpp index 447d92f..bb17d29 100644 --- a/src/MarchingCubeShapeMap.cpp +++ b/src/MarchingCubeShapeMap.cpp @@ -64,18 +64,78 @@ const std::map MarchingCubeChunkRenderer::RenderMap = { {-1.000000, 0.000000, -0.000000, 0.000000}, {0.000000, 0.000000, 0.000000, 1.000000}), 3}}, - {11, {glm::mat4(0.0f), 0}}, - {12, {glm::mat4(0.0f), 0}}, - {13, {glm::mat4(0.0f), 0}}, - {14, {glm::mat4(0.0f), 0}}, - {15, {glm::mat4(0.0f), 0}}, - {16, {glm::mat4(0.0f), 0}}, - {17, {glm::mat4(0.0f), 0}}, - {18, {glm::mat4(0.0f), 0}}, - {19, {glm::mat4(0.0f), 0}}, - {20, {glm::mat4(0.0f), 0}}, - {21, {glm::mat4(0.0f), 0}}, - {22, {glm::mat4(0.0f), 0}}, + {11, + {glm::mat4({-0.000000, -1.000000, 0.000000, 0.000000}, + {-0.000000, 0.000000, -1.000000, 0.000000}, + {1.000000, -0.000000, -0.000000, 0.000000}, + {0.000000, 0.000000, 0.000000, 1.000000}), + 5}}, + {12, + {glm::mat4({-0.000000, 0.000000, 1.000000, 0.000000}, + {0.000000, 1.000000, 0.000000, 0.000000}, + {-1.000000, 0.000000, -0.000000, 0.000000}, + {0.000000, 0.000000, 0.000000, 1.000000}), + 2}}, + {13, + {glm::mat4({1.000000, 0.000000, 0.000000, 0.000000}, + {0.000000, -0.000000, -1.000000, 0.000000}, + {0.000000, 1.000000, -0.000000, 0.000000}, + {0.000000, 0.000000, 0.000000, 1.000000}), + 5}}, + {14, + {glm::mat4({-0.000000, 1.000000, 0.000000, 0.000000}, + {0.000000, 0.000000, -1.000000, 0.000000}, + {-1.000000, -0.000000, -0.000000, 0.000000}, + {0.000000, 0.000000, 0.000000, 1.000000}), + 5}}, + {15, + {glm::mat4({1.000000, 0.000000, 0.000000, 0.000000}, + {0.000000, -0.000000, -1.000000, 0.000000}, + {0.000000, 1.000000, -0.000000, 0.000000}, + {0.000000, 0.000000, 0.000000, 1.000000}), + 8}}, + {16, + {glm::mat4({0.000000, 1.000000, -0.000000, 0.000000}, + {1.000000, -0.000000, -0.000000, 0.000000}, + {-0.000000, 0.000000, -1.000000, 0.000000}, + {0.000000, 0.000000, 0.000000, 1.000000}), + 1}}, + {17, + {glm::mat4({-1.000000, -0.000000, 0.000000, 0.000000}, + {0.000000, -1.000000, 0.000000, 0.000000}, + {0.000000, 0.000000, 1.000000, 0.000000}, + {0.000000, 0.000000, 0.000000, 1.000000}), + 2}}, + {18, + {glm::mat4({-0.000000, 1.000000, 0.000000, 0.000000}, + {-1.000000, -0.000000, 0.000000, 0.000000}, + {0.000000, 0.000000, 1.000000, 0.000000}, + {0.000000, 0.000000, 0.000000, 1.000000}), + 3}}, + {19, + {glm::mat4({1.000000, 0.000000, 0.000000, 0.000000}, + {0.000000, -1.000000, 0.000000, 0.000000}, + {0.000000, 0.000000, -1.000000, 0.000000}, + {0.000000, 0.000000, 0.000000, 1.000000}), + 5}}, + {20, + {glm::mat4({1.000000, 0.000000, 0.000000, 0.000000}, + {0.000000, 1.000000, 0.000000, 0.000000}, + {0.000000, 0.000000, 1.000000, 0.000000}, + {0.000000, 0.000000, 0.000000, 1.000000}), + 4}}, + {21, + {glm::mat4({-0.000000, 1.000000, 0.000000, 0.000000}, + {1.000000, 0.000000, -0.000000, 0.000000}, + {-0.000000, -0.000000, -1.000000, 0.000000}, + {0.000000, 0.000000, 0.000000, 1.000000}), + 6}}, + {22, + {glm::mat4({-0.000000, 0.000000, 1.000000, 0.000000}, + {-1.000000, -0.000000, -0.000000, 0.000000}, + {0.000000, -1.000000, 0.000000, 0.000000}, + {0.000000, 0.000000, 0.000000, 1.000000}), + 6}}, {23, {glm::mat4(0.0f), 0}}, {24, {glm::mat4(0.0f), 0}}, {25, {glm::mat4(0.0f), 0}}, diff --git a/src/main.cpp b/src/main.cpp index d83dbc6..f98bde4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -90,14 +90,22 @@ int main(int argc, char **argv) { Model debugSphere = Model(ROOT_DIR "data/game-models/DebugSphere/DebugSphere.obj"); debugSphere.resize(glm::vec3(0.1f)); - bool index[8] = {false, false, false, false, true, false, true, false}; + bool index[8] = {false, false, false, true, false, true, true, true}; // bool index[8] = {true, true, true, true, true, true, true, true}; - Model debugMCsegment = Model(ROOT_DIR "data/game-models/3/MetalFloor.obj"); + Model debugMCsegment = Model(ROOT_DIR "data/game-models/14/MetalFloor.obj"); // debugMCsegment.worldRotate(180.0f, glm::vec3(1, 0, 1)); + // debugMCsegment.worldRotate(180.0f, glm::vec3(0, 1, 0)); + debugMCsegment.worldRotate(90.0f, glm::vec3(0, 1, 0)); + // debugMCsegment.worldRotate(180.0f, glm::vec3(0, 0, 1)); + // debugMCsegment.worldRotate(180.0f, glm::vec3(0, 0, 1)); + // debugMCsegment.worldRotate(180.0f, glm::vec3(0, 1, 0)); + // debugMCsegment.worldRotate(180.0f, glm::vec3(1, 0, 0)); + // debugMCsegment.worldRotate(-90.0f, glm::vec3(0, 0, 1)); + // debugMCsegment.worldRotate(-90.0f, glm::vec3(0, 1, 0)); + // debugMCsegment.worldRotate(90.0f, glm::vec3(0, 0, 1)); + // debugMCsegment.worldRotate(180.0f, glm::vec3(1, 0, 0)); // debugMCsegment.worldRotate(-90.0f, glm::vec3(0, 1, 0)); - // debugMCsegment.worldRotate(90.0f, glm::vec3(1, 0, 0)); - debugMCsegment.worldRotate(-90.0f, glm::vec3(0, 1, 0)); debugMCsegment.printModel(); // Game loop