00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #if !defined(AFX_PNOISE_H__C1CDB3F2_6FDA_49C8_BF27_1DEDA73F3EE5__INCLUDED_)
00024 #define AFX_PNOISE_H__C1CDB3F2_6FDA_49C8_BF27_1DEDA73F3EE5__INCLUDED_
00025
00026 #if _MSC_VER > 1000
00027 #pragma once
00028 #endif // _MSC_VER > 1000
00029
00030 class PNoise
00031 {
00032 public:
00033 PNoise();
00034 PNoise(int seed);
00035 virtual ~PNoise();
00036
00037 void seed();
00038 void seed(int s);
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 double PerlinNoise1D(double x,int n =1, double alpha =2,double beta =2);
00051 double PerlinNoise2D(double x,double y,int n =1,double alpha =2,double beta =2);
00052 double PerlinNoise3D(double x,double y,double z,int n =1,double alpha =2,double beta =2);
00053
00054
00055 double PerlinNoise3DABS(double x,double y,double z,int n =1, double alpha =2,double beta =2);
00056
00057
00058 void setParams(int n, double alpha =2, double beta =2);
00059 double PN1D(double x);
00060 double PN2D(double x, double y);
00061 double PN3D(double x, double y, double z);
00062 double PN3DA(double x, double y, double z);
00063
00064
00065
00066 private:
00067 void init(void);
00068 double noise1(double);
00069 double noise2(double *);
00070 double noise3(double *);
00071 void normalize3(double *);
00072 void normalize2(double *);
00073
00074 int *p;
00075 double **g3;
00076 double **g2;
00077 double *g1;
00078 int start;
00079
00080 inline int random();
00081
00082 double _alpha;
00083 double _beta;
00084 int _n;
00085
00086 };
00087
00088
00089
00090
00091
00092
00093 void gen2DPerlinTexture(float *&data, unsigned int sx, unsigned int sy,
00094 unsigned int components,
00095 int octaves = 4,
00096 float frequencyScale = 2,
00097 float amplitudeScale = 2,
00098 bool absNoise = false);
00099
00100 void gen3DPerlinTexture(float *&data, unsigned int sx, unsigned int sy, unsigned int sz,
00101 unsigned int components,
00102 int octaves = 4,
00103 float frequencyScale = 2,
00104 float amplitudeScale = 2,
00105 bool absNoise = false);
00106
00107
00108
00109
00110 #endif // !defined(AFX_PNOISE_H__C1CDB3F2_6FDA_49C8_BF27_1DEDA73F3EE5__INCLUDED_)