A portable, open-source, coherent noise-generating library for C++
Main Page | Modules | Class Hierarchy | Class List | File List | Class Members # 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 noise
    00029 {
    00030
    00031   namespace module
    00032   {
    00033
    00036
    00039
    00042
    00044     const double DEFAULT_PERLIN_FREQUENCY = 1.0;
    00045
    00047     const double DEFAULT_PERLIN_LACUNARITY = 2.0;
    00048
    00050     const int DEFAULT_PERLIN_OCTAVE_COUNT = 6;
    00051
    00053     const double DEFAULT_PERLIN_PERSISTENCE = 0.5;
    00054
    00056     const noise::NoiseQuality DEFAULT_PERLIN_QUALITY = QUALITY_STD;
    00057
    00059     const int DEFAULT_PERLIN_SEED = 0;
    00060
    00062     const int PERLIN_MAX_OCTAVE = 30;
    00063
    00160     class Perlin: public Module
    00161     {
    00162
    00163       public:
    00164
    00181         Perlin ();
    00182
    00186         double GetFrequency () const
    00187         {
    00188           return m_frequency;
    00189         }
    00190
    00197         double GetLacunarity () const
    00198         {
    00199           return m_lacunarity;
    00200         }
    00201
    00208         noise::NoiseQuality GetNoiseQuality () const
    00209         {
    00210           return m_noiseQuality;
    00211         }
    00212
    00219         int GetOctaveCount () const
    00220         {
    00221           return m_octaveCount;
    00222         }
    00223
    00229         double GetPersistence () const
    00230         {
    00231           return m_persistence;
    00232         }
    00233
    00237         int GetSeed () const
    00238         {
    00239           return m_seed;
    00240         }
    00241
    00242         virtual int GetSourceModuleCount () const
    00243         {
    00244           return 0;
    00245         }
    00246
    00247         virtual double GetValue (double x, double y, double z) const;
    00248
    00252         void SetFrequency (double frequency)
    00253         {
    00254           m_frequency = frequency;
    00255         }
    00256
    00266         void SetLacunarity (double lacunarity)
    00267         {
    00268           m_lacunarity = lacunarity;
    00269         }
    00270
    00277         void SetNoiseQuality (noise::NoiseQuality noiseQuality)
    00278         {
    00279           m_noiseQuality = noiseQuality;
    00280         }
    00281
    00298         void SetOctaveCount (int octaveCount)
    00299         {
    00300           if (octaveCount < 1 || octaveCount > PERLIN_MAX_OCTAVE) {
    00301             throw noise::ExceptionInvalidParam ();
    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         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   }
    00356
    00357 }
    00358
    00359 #endif