libnoise logo

A portable, open-source, coherent noise-generating library for C++


turbulence.h

00001 // turbulence.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_TURBULENCE_H
00024 #define NOISE_MODULE_TURBULENCE_H
00025 
00026 #include "perlin.h"
00027 
00028 namespace noise
00029 {
00030 
00031   namespace module 
00032   {
00033 
00036 
00039 
00042 
00044     const double DEFAULT_TURBULENCE_FREQUENCY = DEFAULT_PERLIN_FREQUENCY;
00045 
00047     const double DEFAULT_TURBULENCE_POWER = 1.0;
00048 
00050     const int DEFAULT_TURBULENCE_ROUGHNESS = 3;
00051 
00053     const int DEFAULT_TURBULENCE_SEED = DEFAULT_PERLIN_SEED;
00054 
00113     class Turbulence: public Module
00114     {
00115 
00116       public:
00117 
00131         Turbulence ();
00132 
00139         double GetFrequency () const;
00140 
00147         double GetPower () const
00148         {
00149           return m_power;
00150         }
00151 
00160         int GetRoughnessCount () const
00161         {
00162           return m_xDistortModule.GetOctaveCount ();
00163         }
00164 
00173         int GetSeed () const;
00174 
00175         virtual int GetSourceModuleCount () const
00176         {
00177           return 1;
00178         }
00179 
00180         virtual double GetValue (double x, double y, double z) const;
00181 
00188         void SetFrequency (double frequency)
00189         {
00190           // Set the frequency of each Perlin-noise module.
00191           m_xDistortModule.SetFrequency (frequency);
00192           m_yDistortModule.SetFrequency (frequency);
00193           m_zDistortModule.SetFrequency (frequency);
00194         }
00195 
00202         void SetPower (double power)
00203         {
00204           m_power = power;
00205         }
00206 
00221         void SetRoughness (int roughness)
00222         {
00223           // Set the octave count for each Perlin-noise module.
00224           m_xDistortModule.SetOctaveCount (roughness);
00225           m_yDistortModule.SetOctaveCount (roughness);
00226           m_zDistortModule.SetOctaveCount (roughness);
00227         }
00228 
00241         void SetSeed (int seed);
00242 
00243       protected:
00244 
00246         double m_power;
00247 
00249         Perlin m_xDistortModule;
00250 
00252         Perlin m_yDistortModule;
00253 
00255         Perlin m_zDistortModule;
00256 
00257     };
00258 
00260 
00262 
00264 
00265   }
00266 
00267 }
00268 
00269 #endif