Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cRandomPerlin.h
Go to the documentation of this file.
1 //
4 //
5 
6 #ifndef _INC_cRandomPerlin_H
7 #define _INC_cRandomPerlin_H
8 #ifndef NO_PRAGMA_ONCE
9 #pragma once
10 #endif
11 
12 #include "cRandomFloat.h"
16 
17 // MIDL_INTERFACE("85C31227-3DE5-4f00-9B3A-F11AC38C18B5") IDirect3DTexture9;
18 
19 namespace GrayLib
20 {
21  UNITTEST2_PREDEF(cRandomPerlin);
22 
24  {
27  protected:
29 
30  protected:
32  : m_rnd(rnd)
33  {
34  }
35 
36  inline float GRAYCALL SCurve(float a);
37  inline float GRAYCALL LinearInterpolation(float t, float a, float b);
38  inline float GRAYCALL RandomFloat();
39  inline void GRAYCALL Setup(float i, int& b0, int& b1, float& r0, float& r1);
40 
41  public:
42  static void normalize2(float v[2]); // static
43  static void normalize3(float v[3]); // static
44 
45  UNITTEST2_PREDEF(cRandomPerlin );
46  };
47 
49  {
53 
54  public:
55  static const int k_SIZE = 256;
56 
57  int m_p[k_SIZE + k_SIZE];
58  float m_g2[k_SIZE + k_SIZE][2];
59 
60  private:
61  float GetNoise2D(float x, float y);
62  // float GenData(float x, float y, float freq, int octaves, float pers);
63  void InitPerlinTables();
64 
65  public:
67 
68  HRESULT CreateData2D(float* pData, int size, float freq, float& fMin, float& fMax);
69  HRESULT CreateFileTexture(const FILECHAR_t* pszFilename, int size, float freq);
70  // HRESULT UpdateNoiseTexture(int size, float freq, IDirect3DTexture9* pTexture);
71  };
72 
74  {
79 
80  private:
81  static const int k_SIZE = 0x1000;
82 
83  int m_p[k_SIZE + k_SIZE + 2];
84  float m_g3[k_SIZE + k_SIZE + 2][3];
85  float m_g2[k_SIZE + k_SIZE + 2][2];
86  float m_g1[k_SIZE + k_SIZE + 2];
87 
88  public:
90 
91  float GetNoise1D(const float x);
92  float GetNoise2D(const float x, const float y);
93  float GetNoise3D(const float x, const float y, const float z);
94 
95  float turbulence2(const float x, const float y, float freq);
96  float turbulence3(const float x, const float y, const float z, float freq);
97 
98  float tileableNoise1(const float x, const float w);
99  float tileableNoise2(const float x, const float y, const float w, const float h);
100  float tileableNoise3(const float x, const float y, const float z, const float w, const float h, const float d);
101 
102  float tileableTurbulence2(const float x, const float y, const float w, const float h, float freq);
103  float tileableTurbulence3(const float x, const float y, const float z, const float w, const float h, const float d, float freq);
104 
105  void InitPerlinTables();
106  };
107 };
108 
109 #endif
#define GRAYCALL
declare calling convention for static functions so everyone knows the arg passing scheme....
Definition: GrayCore.h:36
#define GRAYLIB_LINK
Definition: GrayLibBase.h:35
INT32 HRESULT
_WIN32 style error codes. INT32
Definition: SysTypes.h:465
Definition: cRandomFloat.h:21
Definition: cRandomPerlin.h:49
Definition: cRandomPerlin.h:74
Definition: cRandomPerlin.h:24
cRandomPerlinBase(cRandomFloat &rnd)
Definition: cRandomPerlin.h:31
cRandomFloat & m_rnd
Definition: cRandomPerlin.h:28
UNITTEST2_PREDEF(cRandomPerlin)
Definition: cMesh.h:22
UNITTEST2_PREDEF(cQuadtree)
char FILECHAR_t
a UTF8 char in a file name. like TCHAR
Definition: FileName.h:22