diff --git a/src/Terrain.cpp b/src/Terrain.cpp new file mode 100644 index 0000000..7e7df64 --- /dev/null +++ b/src/Terrain.cpp @@ -0,0 +1,21 @@ +#include "Terrain.h" + +Terrain::Terrain() { + // Create location to store noise values. + std::vector noiseOutput(16 * 16 * 16); + + // Generate noise to the outputs dimentions + this->fnGenerator->GenUniformGrid3D(noiseOutput.data(), 0, 0, 0, 16, 16, 16, + 0.2f, 0); + + int index = 0; + for (int z = 0; z < 16; z++) { + for (int y = 0; y < 16; y++) { + for (int x = 0; x < 16; x++) { + error.log(std::to_string(x) + " " + std::to_string(y) + " " + + std::to_string(z) + ": " + + std::to_string(noiseOutput[index++])); + } + } + } +} diff --git a/src/Terrain.h b/src/Terrain.h new file mode 100644 index 0000000..cd676db --- /dev/null +++ b/src/Terrain.h @@ -0,0 +1,16 @@ +#pragma once +#include "Error.h" +#include +#include + +class Terrain { +private: + Error error = Error("Terrain"); + + // Favourite noise generated values using the NoiseTool for now: + FastNoise::SmartNode<> fnGenerator = FastNoise::NewFromEncodedNodeTree( + "DgAIAAAAAAAAQBkAAwAAAIA/AQcAAAAAAD8AAAAAAAAAAABA"); + +public: + Terrain(); +}; diff --git a/src/main.cpp b/src/main.cpp index 1d04fac..6871fce 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -12,6 +12,7 @@ // Objects #include "Mesh.h" #include "Model.h" +#include "Terrain.h" // Include error class #include "Error.h" @@ -95,6 +96,9 @@ int main(int argc, char **argv) { // glCullFace(GL_FRONT); glClearColor(0.2f, 0.3f, 0.3f, 1.0f); + // Initialise terrain. + Terrain terrain = Terrain(); + // Game loop bool running = true; while (running) {