From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- docs/doxygen/nel/a03303.html | 516 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 516 insertions(+) create mode 100644 docs/doxygen/nel/a03303.html (limited to 'docs/doxygen/nel/a03303.html') diff --git a/docs/doxygen/nel/a03303.html b/docs/doxygen/nel/a03303.html new file mode 100644 index 00000000..10503b83 --- /dev/null +++ b/docs/doxygen/nel/a03303.html @@ -0,0 +1,516 @@ + + +NeL: NLMISC::CRandomGrid3D class Reference + + + +
+

NLMISC::CRandomGrid3D Class Reference


Detailed Description

+A static 3D array of random value + other infos for noise. +

+ +

+Definition at line 49 of file noise_value.cpp. + + + + + + + + + + + + + + + + + + + + + + + + + +

Public Member Functions

 CRandomGrid3D ()

Static Public Member Functions

float evalBiLinear (const CVector &pos)
float evalNearest (const CVector &pos)
const CVectorgetLevelPhase (uint level)
float getLevelSize (uint level)

Static Private Member Functions

void easeInEaseOut (float &y, float x)
float lookup (uint ux, uint uy, uint uz)

Static Private Attributes

CVector _LevelPhase [3]
float _Sizes [3]
uint8 _Texture3d [(1<< 5)*(1<< 5)*(1<< 5)]
+


Constructor & Destructor Documentation

+

+ + + + +
+ + + + + + + + + +
NLMISC::CRandomGrid3D::CRandomGrid3D  )  [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 54 of file noise_value.cpp. +

+References _LevelPhase, _Sizes, _Texture3d, NLMISC::frand(), NL3D_NOISE_GRID_SIZE, NL3D_NOISE_GRID_SIZE_SHIFT, NL3D_NOISE_LEVEL, uint, v, NLMISC::CVector::x, x, NLMISC::CVector::y, y, NLMISC::CVector::z, and z. +

+

00055         {
+00056                 //seed
+00057                 srand(0);
+00058 
+00059                 // init the grid
+00060                 for(uint z=0; z<NL3D_NOISE_GRID_SIZE; z++)
+00061                 {
+00062                         for(uint y=0; y<NL3D_NOISE_GRID_SIZE; y++)
+00063                         {
+00064                                 for(uint x=0; x<NL3D_NOISE_GRID_SIZE; x++)
+00065                                 {
+00066                                         uint    id= x + (y<<NL3D_NOISE_GRID_SIZE_SHIFT) + (z<<(NL3D_NOISE_GRID_SIZE_SHIFT*2));
+00067                                         // take higher bits of rand gives better result.
+00068                                         uint    v= rand() >> 5;
+00069                                         _Texture3d[id]= v&255;
+00070                                 }
+00071                         }
+00072                 }
+00073 
+00074                 // init sizes.
+00075                 uint    i;
+00076                 // sum of sizes must be 1, and each level must be /2.
+00077                 float   sizeSum=0;
+00078                 for(i=0; i<NL3D_NOISE_LEVEL; i++)
+00079                 {
+00080                         _Sizes[i]= 1.0f / (1<<i);
+00081                         sizeSum+= _Sizes[i];
+00082                 }
+00083                 // normalize
+00084                 for(i=0; i<NL3D_NOISE_LEVEL; i++)
+00085                 {
+00086                         _Sizes[i]/= sizeSum;
+00087                 }
+00088 
+00089                 // init LevelPhases.
+00090                 for(i=0; i<NL3D_NOISE_LEVEL; i++)
+00091                 {
+00092                         _LevelPhase[i].x= frand(NL3D_NOISE_GRID_SIZE);
+00093                         _LevelPhase[i].y= frand(NL3D_NOISE_GRID_SIZE);
+00094                         _LevelPhase[i].z= frand(NL3D_NOISE_GRID_SIZE);
+00095                 }
+00096                 // not for level 0.
+00097                 _LevelPhase[0]= CVector::Null;
+00098         }
+
+


Member Function Documentation

+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NLMISC::CRandomGrid3D::easeInEaseOut float &  y,
float  x
[inline, static, private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 191 of file noise_value.cpp. +

+References x, and y. +

+Referenced by evalBiLinear(). +

+

00192         {
+00193                 // cubic such that f(0)=0, f'(0)=0, f(1)=1, f'(1)=0.
+00194                 float   x2=x*x;
+00195                 float   x3=x2*x;
+00196                 y= -2*x3 + 3*x2;
+00197         }
+
+

+ + + + +
+ + + + + + + + + + +
float NLMISC::CRandomGrid3D::evalBiLinear const CVector pos  )  [inline, static]
+
+ + + + + +
+   + + +

+ +

+Definition at line 119 of file noise_value.cpp. +

+References easeInEaseOut(), lookup(), NL3D_NOISE_GRID_SIZE, NLMISC::NL3D_OO255, NLMISC::OptFastFloor(), sint, uint, NLMISC::CVector::x, x, NLMISC::CVector::y, y, NLMISC::CVector::z, and z. +

+

00120         {
+00121                 // compute integer part.
+00122                 sint    x= OptFastFloor(pos.x);
+00123                 sint    y= OptFastFloor(pos.y);
+00124                 sint    z= OptFastFloor(pos.z);
+00125                 // index in texture.
+00126                 uint    ux= x& (NL3D_NOISE_GRID_SIZE-1);
+00127                 uint    uy= y& (NL3D_NOISE_GRID_SIZE-1);
+00128                 uint    uz= z& (NL3D_NOISE_GRID_SIZE-1);
+00129                 uint    ux2= (x+1)& (NL3D_NOISE_GRID_SIZE-1);
+00130                 uint    uy2= (y+1)& (NL3D_NOISE_GRID_SIZE-1);
+00131                 uint    uz2= (z+1)& (NL3D_NOISE_GRID_SIZE-1);
+00132                 // delta.
+00133                 float   dx2;
+00134                 float   dy2;
+00135                 float   dz2;
+00136                 easeInEaseOut(dx2, pos.x-x);
+00137                 easeInEaseOut(dy2, pos.y-y);
+00138                 easeInEaseOut(dz2, pos.z-z);
+00139                 float   dx= 1-dx2;
+00140                 float   dy= 1-dy2;
+00141                 float   dz= 1-dz2;
+00142                 // TriLinear in texture3D.
+00143                 float   turb=0;
+00144                 float   dxdy= dx*dy;
+00145                 turb+= lookup(ux,uy,uz)* dxdy*dz;
+00146                 turb+= lookup(ux,uy,uz2)* dxdy*dz2;
+00147                 float   dxdy2= dx*dy2;
+00148                 turb+= lookup(ux,uy2,uz)* dxdy2*dz;
+00149                 turb+= lookup(ux,uy2,uz2)* dxdy2*dz2;
+00150                 float   dx2dy= dx2*dy;
+00151                 turb+= lookup(ux2,uy,uz)* dx2dy*dz;
+00152                 turb+= lookup(ux2,uy,uz2)* dx2dy*dz2;
+00153                 float   dx2dy2= dx2*dy2;
+00154                 turb+= lookup(ux2,uy2,uz)* dx2dy2*dz;
+00155                 turb+= lookup(ux2,uy2,uz2)* dx2dy2*dz2;
+00156 
+00157                 // End!
+00158                 return turb*NL3D_OO255;
+00159         }
+
+

+ + + + +
+ + + + + + + + + + +
float NLMISC::CRandomGrid3D::evalNearest const CVector pos  )  [inline, static]
+
+ + + + + +
+   + + +

+ +

+Definition at line 101 of file noise_value.cpp. +

+References lookup(), NL3D_NOISE_GRID_SIZE, NLMISC::NL3D_OO255, NLMISC::OptFastFloor(), sint, uint, NLMISC::CVector::x, x, NLMISC::CVector::y, y, NLMISC::CVector::z, and z. +

+

00102         {
+00103                 // compute integer part.
+00104                 sint    x= OptFastFloor(pos.x);
+00105                 sint    y= OptFastFloor(pos.y);
+00106                 sint    z= OptFastFloor(pos.z);
+00107                 // index in texture.
+00108                 uint    ux= x& (NL3D_NOISE_GRID_SIZE-1);
+00109                 uint    uy= y& (NL3D_NOISE_GRID_SIZE-1);
+00110                 uint    uz= z& (NL3D_NOISE_GRID_SIZE-1);
+00111 
+00112                 // read the texture.
+00113                 float   turb= lookup(ux,uy,uz);
+00114 
+00115                 return turb*NL3D_OO255;
+00116         }
+
+

+ + + + +
+ + + + + + + + + + +
const CVector& NLMISC::CRandomGrid3D::getLevelPhase uint  level  )  [inline, static]
+
+ + + + + +
+   + + +

+ +

+Definition at line 169 of file noise_value.cpp. +

+References _LevelPhase, level, and uint. +

+

00170         {
+00171                 return _LevelPhase[level];
+00172         }
+
+

+ + + + +
+ + + + + + + + + + +
float NLMISC::CRandomGrid3D::getLevelSize uint  level  )  [inline, static]
+
+ + + + + +
+   + + +

+ +

+Definition at line 163 of file noise_value.cpp. +

+References _Sizes, level, and uint. +

+

00164         {
+00165                 return _Sizes[level];
+00166         }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
float NLMISC::CRandomGrid3D::lookup uint  ux,
uint  uy,
uint  uz
[inline, static, private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 184 of file noise_value.cpp. +

+References _Texture3d, NL3D_NOISE_GRID_SIZE_SHIFT, and uint. +

+Referenced by evalBiLinear(), and evalNearest(). +

+

00185         {
+00186                 uint    id= ux + (uy<<NL3D_NOISE_GRID_SIZE_SHIFT) + (uz<<(NL3D_NOISE_GRID_SIZE_SHIFT*2));
+00187                 return  _Texture3d[id];
+00188         }
+
+


Field Documentation

+

+ + + + +
+ + +
CVector NLMISC::CRandomGrid3D::_LevelPhase [static, private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 204 of file noise_value.cpp. +

+Referenced by CRandomGrid3D(), and getLevelPhase().

+

+ + + + +
+ + +
float NLMISC::CRandomGrid3D::_Sizes [static, private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 203 of file noise_value.cpp. +

+Referenced by CRandomGrid3D(), and getLevelSize().

+

+ + + + +
+ + +
uint8 NLMISC::CRandomGrid3D::_Texture3d [static, private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 202 of file noise_value.cpp. +

+Referenced by CRandomGrid3D(), and lookup().

+


The documentation for this class was generated from the following file: +
Generated on Tue Mar 16 13:31:04 2004 for NeL by + +doxygen +1.3.6
+ + -- cgit v1.2.1