Generated first chunk of terrain data.
This commit is contained in:
parent
5c135950e0
commit
9fa18286cb
3 changed files with 41 additions and 0 deletions
21
src/Terrain.cpp
Normal file
21
src/Terrain.cpp
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
#include "Terrain.h"
|
||||||
|
|
||||||
|
Terrain::Terrain() {
|
||||||
|
// Create location to store noise values.
|
||||||
|
std::vector<float> 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++]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
16
src/Terrain.h
Normal file
16
src/Terrain.h
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
#pragma once
|
||||||
|
#include "Error.h"
|
||||||
|
#include <FastNoise/FastNoise.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
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();
|
||||||
|
};
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
// Objects
|
// Objects
|
||||||
#include "Mesh.h"
|
#include "Mesh.h"
|
||||||
#include "Model.h"
|
#include "Model.h"
|
||||||
|
#include "Terrain.h"
|
||||||
|
|
||||||
// Include error class
|
// Include error class
|
||||||
#include "Error.h"
|
#include "Error.h"
|
||||||
|
|
@ -95,6 +96,9 @@ int main(int argc, char **argv) {
|
||||||
// glCullFace(GL_FRONT);
|
// glCullFace(GL_FRONT);
|
||||||
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
|
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
|
||||||
|
|
||||||
|
// Initialise terrain.
|
||||||
|
Terrain terrain = Terrain();
|
||||||
|
|
||||||
// Game loop
|
// Game loop
|
||||||
bool running = true;
|
bool running = true;
|
||||||
while (running) {
|
while (running) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue