// Copyright (C) 2012 Rémi Bèges // This file is part of the "Nazara Engine". // For conditions of distribution and use, see copyright notice in Config.hpp #include #include #include #include #include #include using namespace std; template NzFBM2D::NzFBM2D(nzNoises source, int seed) : NzComplexNoiseBase() { switch(source) { case PERLIN: m_source = new NzPerlin2D; break; default: m_source = new NzSimplex2D; break; } m_source->SetNewSeed(seed); m_source->ShufflePermutationTable(); m_noiseType = source; } template T NzFBM2D::GetValue(T x, T y, T resolution) { this->RecomputeExponentArray(); m_value = 0.0; for (int i(0); i < this->m_octaves; ++i) { m_value += m_source->GetValue(x,y,resolution) * this->exponent_array[i]; resolution *= this->m_lacunarity; } //cout<m_sum<m_octaves - static_cast(this->m_octaves); //if(!NzNumberEquals(remainder, static_cast(0.0))) // m_value += remainder * Get2DSimplexNoiseValue(x,y,resolution) * exponent_array[(int)m_octaves-1]; //0.65 is an experimental value to make the noise stick closer to [-1 , 1] return m_value / (this->m_sum * 0.65); } template NzFBM2D::~NzFBM2D() { switch(m_noiseType) { case PERLIN: delete dynamic_cast*>(m_source); break; default: delete dynamic_cast*>(m_source); break; } } #include