00001
00002
00003
00004
00005
00006 #ifndef PERLIN_TEX_H_IS_INCLUDED
00007 #define PERLIN_TEX_H_IS_INCLUDED
00008
00009 #include "geom/texturegl.H"
00010 #include "util.H"
00011
00012
00013 #define START_FREQ 4
00014 #define NUM_OCTAVES 4
00015 #define PRESISTANCE 2
00016
00017 #define SEED_1 107
00018 #define SEED_2 1616
00019 #define SEED_3 4151984
00020 #define SEED_4 112000
00021
00022
00023 class Perlin {
00024
00025 public:
00026
00027 Perlin();
00028 virtual ~Perlin();
00029
00030
00031
00032
00033
00034 TEXTUREglptr create_perlin_texture3(int tex_stage = TexUnit::PERLIN);
00035 TEXTUREglptr create_perlin_texture2(int tex_stage = TexUnit::PERLIN);
00036
00037
00038
00039
00040
00041 Vec4 noise1(double x);
00042 Vec4 noise2(double x, double y);
00043 Vec4 noise3(double x, double y, double z);
00044 Vec4 noise4(double x, double y, double z, double t);
00045
00046
00047
00048 inline double getval_1D(int freq, double x, unsigned int seed);
00049 inline double getval_2D(int freq, double x, double y, unsigned int seed);
00050 inline double getval_3D(int freq, double x, double y, double z, unsigned int seed);
00051 double getval_4D(int freq, double x, double y, double z, double t, unsigned int seed);
00052
00053
00054 static Perlin* get_instance() { return _instance; };
00055
00056 protected:
00057
00058
00059
00060 inline double noise(unsigned int input);
00061 inline double cubic(double v0, double v1, double v2, double v3, double t);
00062 inline double frac(double);
00063
00064
00065 TEXTUREglptr perlin2d_tex;
00066 TEXTUREglptr perlin3d_tex;
00067
00068 static Perlin* _instance;
00069
00070
00071
00072 Perlin* _previous_instance;
00073
00074 };
00075
00076 #endif // PERLIN_TEX_H_IS_INCLUDED
00077
00078