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