00001 /* -*- C++ -*- */ 00002 00003 /* COPYRIGHT 00004 * 00005 * This file is part of the Visual Effects Engine - VEE 00006 * 00007 * Read the "VEE-LICENSE" file for the license. 00008 * 00009 * Authors & Copyright: 00010 * 00011 * Tommi Ilmonen, Tuukka Heikura, Marko Myllymaa and 00012 * Janne Kontkanen 2001-2004 00013 * 00014 * Additional copyrights: Tekes 2003-2004 00015 * 00016 * firstname.lastname@hut.fi 00017 * 00018 */ 00019 00020 #ifndef VEE_PERLIN_NOISE_H 00021 #define VEE_PERLIN_NOISE_H 00022 00023 #include <perlinNoise.h> 00024 00025 #include <vee_vector2.h> 00026 #include <vee_vector3.h> 00027 00028 class VEE_PerlinNoise 00029 { 00030 public: 00031 static float noise(float x) { return perlinNoise::noise(x); } 00032 static float noise(float x, float y) { return perlinNoise::noise(x, y); } 00033 static float noise(float x, float y, float z) 00034 { return perlinNoise::noise(x, y, z); } 00035 00036 static float noise(const VEE_Vector3 & v) 00037 { return perlinNoise::noise3d(v.data()); } 00038 static float noise(const VEE_Vector2 & v) 00039 { return perlinNoise::noise2d(v.data()); } 00040 00041 static float noise1d(float x, 00042 float octaveAttenuation, unsigned octaves); 00043 static float noise2d(float x, float y, 00044 float octaveAttenuation, unsigned octaves); 00045 static float noise3d(float x, float y, float z, 00046 float octaveAttenuation, unsigned octaves); 00047 }; 00048 00049 /* 00050 class VEE_PerlinNoise 00051 { 00052 public: 00053 00054 enum Interpolation { 00055 LINEAR, 00056 WEIGHT 00057 }; 00058 00059 static const uint MAX_OCTAVES = 10; 00060 00061 static double octaveNoise1d(double x, 00062 double scale, 00063 uint octave, 00064 Interpolation); 00065 00066 static double noise1d(double x, 00067 double octaveAttenuation, 00068 uint octaves, 00069 Interpolation ip); 00070 00071 static double octaveNoise2d(double x, 00072 double y, 00073 double scale, 00074 uint octave, 00075 Interpolation, 00076 uint seed); 00077 00078 static double noise2d(double x, 00079 double y, 00080 double octaveAttenuation, 00081 uint octaves, 00082 Interpolation ip, 00083 uint seed = 0); 00084 00085 static double octaveNoise3d(double x, 00086 double y, 00087 double z, 00088 double scale, 00089 uint octave, 00090 Interpolation, 00091 uint seed, 00092 double range, 00093 double beyondRange); 00094 00095 static double noise3d(double x, 00096 double y, 00097 double z, 00098 double octaveAttenuation, 00099 uint octaves, 00100 Interpolation ip = WEIGHT, 00101 uint seed = 0, 00102 double range = 0.0, 00103 double beyondRange = 0.0); 00104 00105 00106 static double noise3d(double x, double y, double z); 00107 00108 static double octaveNoise4d(double x, 00109 double y, 00110 double z, 00111 double w, 00112 double scale, 00113 uint octave, 00114 Interpolation, 00115 uint seed); 00116 00117 static double noise4d(double x, 00118 double y, 00119 double z, 00120 double w, 00121 double octaveAttenuation, 00122 uint octaves, 00123 Interpolation ip, 00124 uint seed = 0); 00125 00126 static void checkRand(); 00127 00128 protected: 00129 static inline double moduloRand(uint source, uint octave); 00130 static inline uint ra(uint source, uint mul, uint seed); 00131 00132 static uint m_randMultipliers[MAX_OCTAVES + 1]; 00133 static uint m_randMultipliers2[MAX_OCTAVES + 1]; 00134 00135 }; 00136 */ 00137 #endif