Add some structure for the ground.

This commit is contained in:
Rémi Oudin 2018-02-13 17:03:11 +01:00
parent 0db091f76e
commit d484a18da5
7 changed files with 44 additions and 0 deletions

6
FlatGround.cpp Normal file
View File

@ -0,0 +1,6 @@
#include "FlatGround.hpp"
double FlatGround::operator() (double, double) const {
return 0. ;
}

6
FlatGround.hpp Normal file
View File

@ -0,0 +1,6 @@
#pragma once
#include "Ground.hpp"
class FlatGround : public Ground {
double operator() (double, double) const;
};

0
Ground.cpp Normal file
View File

8
Ground.hpp Normal file
View File

@ -0,0 +1,8 @@
#pragma once
#include "common_structures.hpp"
class Ground {
public:
virtual double operator() (double, double) const = 0;
};

View File

@ -11,6 +11,9 @@ OBJS=Implicit.o \
Mesh.o \
spheroid.o \
Ball.o \
Ground.o \
FlatGround.o \
PerlinGround.o \
PerlinNoise.o \
util/ObjParser.o \
MarchingCubes.o \

9
PerlinGround.cpp Normal file
View File

@ -0,0 +1,9 @@
#include "PerlinGround.hpp"
PerlinGround::PerlinGround() : surface(PerlinNoise()) {}
PerlinGround::PerlinGround(unsigned int seed) : surface(PerlinNoise(seed)) {}
double PerlinGround::operator() (double x, double z) const {
return surface.noise(x, z);
}

12
PerlinGround.hpp Normal file
View File

@ -0,0 +1,12 @@
#pragma once
#include "Ground.hpp"
#include "PerlinNoise.hpp"
class PerlinGround : public Ground {
public:
PerlinGround();
PerlinGround(unsigned int seed);
double operator() (double, double) const;
private:
PerlinNoise surface;
};