00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00027 #ifndef SHUTIL_NOISE_HPP
00028 #define SHUTIL_NOISE_HPP
00029
00030 #include "ShAttrib.hpp"
00031 #include "ShArray.hpp"
00032 #include "ShTypeInfo.hpp"
00033
00034
00035 #define CT1T2 typename ShCommonType<T1, T2>::type
00036
00037 namespace ShUtil {
00038
00039
00040 using namespace SH;
00041
00050 template<int M, typename T, int P = 16>
00051 class ShNoise
00052 {
00053 public:
00058 template<int K>
00059 static ShGeneric<M, T> perlin(const ShGeneric<K, T> &p, bool useTexture);
00060
00062 template<int K>
00063 static ShGeneric<M, T> cellnoise(const ShGeneric<K, T> &p, bool useTexture);
00064
00065 private:
00066 static ShAttrib<1, SH_CONST, T> constP, invP;
00067 static bool m_init;
00068 static ShArray3D<ShColor<M, SH_TEMP, T> > noiseTex;
00069
00070 static void init();
00071 };
00072
00073 #ifndef WIN32
00074
00075
00076
00077 template<int N, int M, typename T>
00078 ShGeneric<N, T> perlin(const ShGeneric<M, T> &p, bool useTexture = true);
00079
00080 template<int N, int M, int K, typename T1, typename T2>
00081 ShGeneric<N, CT1T2> perlin(const ShGeneric<M, T1> &p, const ShGeneric<K, T2> &, bool useTexture = true);
00082
00083
00084
00085
00086 template<int N, int M, typename T>
00087 ShGeneric<N, T> sperlin(const ShGeneric<M, T> &p, bool useTexture = true);
00088
00089 template<int N, int M, int K, typename T1, typename T2>
00090 ShGeneric<N, CT1T2> sperlin(const ShGeneric<M, T1> &p, const ShGeneric<K, T2> &, bool useTexture = true);
00091
00092
00093
00094
00095 template<int N, int M, typename T>
00096 ShGeneric<N, T> cellnoise(const ShGeneric<M, T> &p, bool useTexture = true);
00097
00098 template<int N, int M, int K, typename T1, typename T2>
00099 ShGeneric<N, CT1T2> cellnoise(const ShGeneric<M, T1> &p, const ShGeneric<K, T2> &,
00100 bool useTexture = true);
00101
00102
00103
00104
00105 template<int N, int M, typename T>
00106 ShGeneric<N, T> scellnoise(const ShGeneric<M, T> &p, bool useTexture = true);
00107
00108 template<int N, int M, int K, typename T1, typename T2>
00109 ShGeneric<N, CT1T2> scellnoise(const ShGeneric<M, T1> &p, const ShGeneric<K, T2> &,
00110 bool useTexture = true);
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123 template<int N, int M, typename T>
00124 ShGeneric<N, T> turbulence(const ShGeneric<M, T> &p, bool useTexture = true);
00125
00126 template<int N, int M, int K, typename T1, typename T2>
00127 ShGeneric<N, CT1T2> turbulence(const ShGeneric<M, T1> &p, const ShGeneric<K, T2> &,
00128 bool useTexture = true);
00129
00130
00134 template<int N, int M, typename T>
00135 ShGeneric<N, T> sturbulence(const ShGeneric<M, T> &p, bool useTexture = true);
00136
00137 template<int N, int M, int K, typename T1, typename T2>
00138 ShGeneric<N, CT1T2> sturbulence(const ShGeneric<M, T1> &p, const ShGeneric<K, T2> &,
00139 bool useTexture = true);
00140
00141
00142 #endif // ifndef WIN32
00143
00144 }
00145 #include "ShNoiseImpl.hpp"
00146
00147
00148 #undef CT1T2
00149 #endif