From ffb1128951638fb462fe1e24aa2963aab6246b07 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Tue, 26 Apr 2011 15:38:42 +0300 Subject: tested out and commented out some new stuff for the terrain generator, to be used in the future. --- src/noise.cpp | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) (limited to 'src/noise.cpp') diff --git a/src/noise.cpp b/src/noise.cpp index 00772455a..6362f5b2c 100644 --- a/src/noise.cpp +++ b/src/noise.cpp @@ -20,6 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include #include "noise.h" #include +#include "debug.h" #define NOISE_MAGIC_X 1619 #define NOISE_MAGIC_Y 31337 @@ -221,3 +222,107 @@ double noise3d_perlin_abs(double x, double y, double z, int seed, return a; } +/* + NoiseBuffer +*/ + +NoiseBuffer::NoiseBuffer(): + m_data(NULL) +{ +} + +NoiseBuffer::~NoiseBuffer() +{ + clear(); +} + +void NoiseBuffer::clear() +{ + if(m_data) + delete[] m_data; + m_data = NULL; + m_size_x = 0; + m_size_y = 0; + m_size_z = 0; +} + +void NoiseBuffer::create(int seed, int octaves, double persistence, + double pos_scale, + double first_x, double first_y, double first_z, + double last_x, double last_y, double last_z, + double samplelength_x, double samplelength_y, double samplelength_z) +{ + clear(); + + m_start_x = first_x - samplelength_x; + m_start_y = first_y - samplelength_y; + m_start_z = first_z - samplelength_z; + m_samplelength_x = samplelength_x; + m_samplelength_y = samplelength_y; + m_samplelength_z = samplelength_z; + + m_size_x = (last_x - m_start_x)/samplelength_x + 2; + m_size_y = (last_y - m_start_y)/samplelength_y + 2; + m_size_z = (last_z - m_start_z)/samplelength_z + 2; + + /*dstream<<"m_size_x="<