Browse Source

More noise work

testing
= 3 years ago
parent
commit
7bcf4480d5

+ 1
- 1
include/terrain/noise.h View File

@@ -7,7 +7,7 @@
#include "terrain/open_simplex_noise.h"
#include "terrain/noisemodule.h"

namespace vtk {
namespace vtk::noise {

class Noise : public NoiseModule {
public:

+ 1
- 1
include/terrain/noisemodule.h View File

@@ -4,7 +4,7 @@

#pragma once

namespace vtk {
namespace vtk::noise {

class NoiseModule {
public:

+ 1
- 1
include/terrain/ygradient.h View File

@@ -6,7 +6,7 @@

#include "terrain/noisemodule.h"

namespace vtk {
namespace vtk::noise {

class YGradient : public NoiseModule {
public:

+ 23
- 0
include/terrain/yturbulence.h View File

@@ -0,0 +1,23 @@
/*
* Y Axis turbulence
*/

#pragma once
#include <memory>

#include "terrain/noisemodule.h"

namespace vtk::noise {

class YTurbulence : public NoiseModule {
public:
YTurbulence(std::shared_ptr<NoiseModule> input, std::shared_ptr<NoiseModule> modifier);
YTurbulence(std::shared_ptr<NoiseModule> input, std::shared_ptr<NoiseModule> modifier, const double& multiplier);
double get3D(const double&x, const double&y, const double&z);

protected:
std::shared_ptr<NoiseModule> mInput;
std::shared_ptr<NoiseModule> mModifier;
double mMultiplier;
};
}

+ 2
- 1
include/terraingen.h View File

@@ -20,6 +20,7 @@

#include <map>
#include <utility>
#include <memory>

#include "terrain/noisemodule.h"

@@ -34,7 +35,7 @@ public:
void generateChunk(Chunk* chunk);

protected:
NoiseModule* mNoise;
std::shared_ptr<noise::NoiseModule> mNoise;

//variables (replace by config)
double mTerrainScale;

+ 0
- 1
src/scenes/testscene.h View File

@@ -55,7 +55,6 @@ protected:
World world;
Skybox mSkybox;
noise::module::Perlin noiseMod;

//stuff
float sensitivity;

+ 1
- 1
src/terrain/noise.cpp View File

@@ -1,6 +1,6 @@
#include "terrain/noise.h"

namespace vtk {
namespace vtk::noise {

Noise::Noise(const int64_t& seed) {
mScale = 32.0;

+ 1
- 1
src/terrain/ygradient.cpp View File

@@ -1,6 +1,6 @@
#include "terrain/ygradient.h"

namespace vtk {
namespace vtk::noise {

YGradient::YGradient() {
mStart = 0.0;

+ 23
- 0
src/terrain/yturbulence.cpp View File

@@ -0,0 +1,23 @@
#include <iostream>

#include "terrain/yturbulence.h"

namespace vtk::noise {

YTurbulence::YTurbulence(std::shared_ptr<NoiseModule> input, std::shared_ptr<NoiseModule> modifier) {
mInput = input;
mModifier = modifier;
}

YTurbulence::YTurbulence(std::shared_ptr<NoiseModule> input, std::shared_ptr<NoiseModule> modifier, const double& multiplier) {
mInput = input;
mModifier = modifier;
mMultiplier = multiplier;
}

double YTurbulence::get3D(const double&x, const double&y, const double&z) {
double mod = mModifier->get3D(x,y,z) * mMultiplier;
return mInput->get3D(x, y + mod, z);
}

}

+ 4
- 1
src/terraingen.cpp View File

@@ -21,6 +21,7 @@
#include "mathplus.h"
#include "terrain/noise.h"
#include "terrain/ygradient.h"
#include "terrain/yturbulence.h"

#include <iostream>
#include <time.h>
@@ -29,7 +30,9 @@
namespace vtk {

TerrainGen::TerrainGen() {
mNoise = new YGradient(0.0, 128.0);
std::shared_ptr<noise::NoiseModule> noise = std::make_shared<noise::Noise>(6969696);
std::shared_ptr<noise::NoiseModule> yGrad = std::make_shared<noise::YGradient>(0.0, 128.0);
mNoise = std::make_shared<noise::YTurbulence>(yGrad, noise, 40.0);

mTerrainScale = 32.0;
}

Loading…
Cancel
Save