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.

This commit is contained in:
Warwick 2022-08-30 14:04:50 +01:00
parent 5ece3c455f
commit 0b62550f54
2 changed files with 84 additions and 16 deletions

View file

@ -64,18 +64,78 @@ const std::map<int, CubeData> 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}},

View file

@ -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