cstool/noise/module/perlin.h
00001 // perlin.h 00002 // 00003 // Copyright (C) 2003, 2004 Jason Bevins 00004 // 00005 // This library is free software; you can redistribute it and/or modify it 00006 // under the terms of the GNU Lesser General Public License as published by 00007 // the Free Software Foundation; either version 2.1 of the License, or (at 00008 // your option) any later version. 00009 // 00010 // This library is distributed in the hope that it will be useful, but WITHOUT 00011 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 00013 // License (COPYING.txt) for more details. 00014 // 00015 // You should have received a copy of the GNU Lesser General Public License 00016 // along with this library; if not, write to the Free Software Foundation, 00017 // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 // 00019 // The developer's email is jlbezigvins@gmzigail.com (for great email, take 00020 // off every 'zig'.) 00021 // 00022 00023 #ifndef NOISE_MODULE_PERLIN_H 00024 #define NOISE_MODULE_PERLIN_H 00025 00026 #include "modulebase.h" 00027 00028 namespace CS { 00029 namespace Math { 00030 namespace Noise { 00031 namespace Module { 00032 00035 00038 00041 00043 const double DEFAULT_PERLIN_FREQUENCY = 1.0; 00044 00046 const double DEFAULT_PERLIN_LACUNARITY = 2.0; 00047 00049 const int DEFAULT_PERLIN_OCTAVE_COUNT = 6; 00050 00052 const double DEFAULT_PERLIN_PERSISTENCE = 0.5; 00053 00055 const CS::Math::Noise::NoiseQuality DEFAULT_PERLIN_QUALITY = QUALITY_STD; 00056 00058 const int DEFAULT_PERLIN_SEED = 0; 00059 00061 const int PERLIN_MAX_OCTAVE = 30; 00062 00159 class CS_CRYSTALSPACE_EXPORT Perlin: public Module 00160 { 00161 00162 public: 00163 00180 Perlin (); 00181 00185 double GetFrequency () const 00186 { 00187 return m_frequency; 00188 } 00189 00196 double GetLacunarity () const 00197 { 00198 return m_lacunarity; 00199 } 00200 00207 CS::Math::Noise::NoiseQuality GetNoiseQuality () const 00208 { 00209 return m_noiseQuality; 00210 } 00211 00218 int GetOctaveCount () const 00219 { 00220 return m_octaveCount; 00221 } 00222 00228 double GetPersistence () const 00229 { 00230 return m_persistence; 00231 } 00232 00236 int GetSeed () const 00237 { 00238 return m_seed; 00239 } 00240 00241 virtual int GetSourceModuleCount () const 00242 { 00243 return 0; 00244 } 00245 00246 virtual double GetValue (double x, double y, double z) const; 00247 00251 void SetFrequency (double frequency) 00252 { 00253 m_frequency = frequency; 00254 } 00255 00265 void SetLacunarity (double lacunarity) 00266 { 00267 m_lacunarity = lacunarity; 00268 } 00269 00276 void SetNoiseQuality (CS::Math::Noise::NoiseQuality noiseQuality) 00277 { 00278 m_noiseQuality = noiseQuality; 00279 } 00280 00297 void SetOctaveCount (int octaveCount) 00298 { 00299 if (octaveCount < 1 || octaveCount > PERLIN_MAX_OCTAVE) { 00300 //throw CS::Math::Noise::ExceptionInvalidParam (); 00301 CS_ASSERT (false); 00302 } 00303 m_octaveCount = octaveCount; 00304 } 00305 00314 void SetPersistence (double persistence) 00315 { 00316 m_persistence = persistence; 00317 } 00318 00322 void SetSeed (int seed) 00323 { 00324 m_seed = seed; 00325 } 00326 00327 protected: 00328 00330 double m_frequency; 00331 00333 double m_lacunarity; 00334 00336 CS::Math::Noise::NoiseQuality m_noiseQuality; 00337 00339 int m_octaveCount; 00340 00342 double m_persistence; 00343 00345 int m_seed; 00346 00347 }; 00348 00350 00352 00354 00355 } // namespace Module 00356 } // namespace Noise 00357 } // namespace Math 00358 } // namespace CS 00359 00360 #endif
Generated for Crystal Space 2.0 by doxygen 1.6.1