00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00020 #include "ShLib.hpp"
00021
00022 #ifndef SHLIBWORLEY_HPP
00023 #define SHLIBWORLEY_HPP
00024
00025 #include <vector>
00026 #include "ShAttrib.hpp"
00027 #include "ShColor.hpp"
00028
00029 namespace SH {
00030
00060
00061
00062
00063 template<int D, typename T>
00064 struct Generator {
00065 Generator() {}
00066 ShAttrib<D, SH_TEMP, T> pos;
00067 ShAttrib<D, SH_TEMP, T> offset;
00068 ShAttrib<D, SH_TEMP, T> cell;
00069 };
00070
00071
00072
00073
00074 template<int P, int D, typename T>
00075 struct GeneratorFactory {
00076 static const int NUM_POINTS = P;
00077 virtual ~GeneratorFactory() {}
00078 virtual void operator()(const ShGeneric<D, T> &p, Generator<D, T> result[]) const = 0;
00079 };
00080
00081
00082
00083
00084
00085 template<int N, int D, typename T>
00086 struct PropertyFactory {
00087 static const int NUM_PROPS = N;
00088 static const int DIM = D;
00089 typedef T PropType;
00090
00091 virtual ~PropertyFactory() {}
00092 virtual ShGeneric<N, T> operator()(const ShGeneric<D, T> &p, const Generator<D, T> &g) const = 0;
00093 };
00094
00095 #ifndef WIN32
00096
00102 template<int K, int D, typename T>
00103 ShGeneric<K, T> worley(const ShGeneric<D, T> &p, bool useTexture = true);
00105
00109 template<int K, int L, int P, int D, typename T>
00110 void worley(ShGeneric<K, T> result[], const ShGeneric<D, T> &p,
00111 const GeneratorFactory<P, D, T> *genFactory,
00112 const PropertyFactory<L, D, T> *propFactory);
00113
00121 template<int K, int D, typename T>
00122 ShProgram shWorley(bool useTexture);
00123
00124 template<int K, int N, int P, int D, typename T>
00125 ShProgram shWorley(const GeneratorFactory<P, D, T> *genFactory,
00126 const PropertyFactory<N, D, T> *propFactory);
00128
00129 #endif // WIN32
00130
00131 }
00132
00133 #include "ShLibWorleyImpl.hpp"
00134
00135 #endif // SHLIBWORLEY_HPP