NLMISC::CNoiseValue Class Reference

#include <noise_value.h>


Detailed Description

A class which generate noisy value, according to a position
Author:
Lionel Berenguier

Nevrax France

Date:
2001

Definition at line 49 of file noise_value.h.

Public Member Functions

 CNoiseValue (float abs, float rand, float freq)
 CNoiseValue ()
 Default to 0, 1, 1.

float eval (const CVector &posInWorld) const
float evalOneLevelRandom (const CVector &posInWorld) const
void serial (IStream &f)

Data Fields

float Abs
float Frequency
float Rand

Private Member Functions

float evalRandom (const CVector &pos) const
float noise (const CVector &pos) const
 pos scale is in [0..1]


Constructor & Destructor Documentation

NLMISC::CNoiseValue::CNoiseValue  ) 
 

Default to 0, 1, 1.

Definition at line 258 of file noise_value.cpp.

00259 {
00260         Abs= 0;
00261         Rand= 1;
00262         Frequency= 1;
00263 }

NLMISC::CNoiseValue::CNoiseValue float  abs,
float  rand,
float  freq
 

Definition at line 267 of file noise_value.cpp.

00268 {
00269         Abs= abs;
00270         Rand= rand;
00271         Frequency= freq;
00272 }


Member Function Documentation

float NLMISC::CNoiseValue::eval const CVector posInWorld  )  const
 

return Abs + Rand* noise(Pos*Frequency). with noise() E [0..1]. Warning! Use OptFastFloor()! So call must be enclosed with a OptFastFloorBegin()/OptFastFloorEnd().

Definition at line 276 of file noise_value.cpp.

References noise().

Referenced by NLMISC::CNoiseColorGradient::eval(), NL3D::CVegetable::generateGroup(), NL3D::CVegetable::generateGroupBiLinear(), and NL3D::CVegetable::generateInstance().

00277 {
00278         // A single cube in the Grid3d correspond to Frequency==1.
00279         // So enlarging size of the grid3d do not affect the frequency aspect.
00280         return Abs + Rand * noise(posInWorld*Frequency);
00281 }

float NLMISC::CNoiseValue::evalOneLevelRandom const CVector posInWorld  )  const
 

same as eval, but eval just one random level for noise() => act much more like a random. Warning! Use OptFastFloor()! So call must be enclosed with a OptFastFloorBegin()/OptFastFloorEnd().

Definition at line 285 of file noise_value.cpp.

References evalRandom().

Referenced by NL3D::CVegetable::generateGroupBiLinear(), and NL3D::CVegetable::generateGroupEx().

00286 {
00287         // A single cube in the Grid3d correspond to Frequency==1.
00288         // So enlarging size of the grid3d do not affect the frequency aspect.
00289         return Abs + Rand * evalRandom(posInWorld*Frequency);
00290 }

float NLMISC::CNoiseValue::evalRandom const CVector pos  )  const [private]
 

Definition at line 216 of file noise_value.cpp.

Referenced by evalOneLevelRandom().

00217 {
00218         return CRandomGrid3D::evalNearest(pos);
00219 }

float NLMISC::CNoiseValue::noise const CVector pos  )  const [private]
 

pos scale is in [0..1]

Definition at line 223 of file noise_value.cpp.

References level, NL3D_NOISE_LEVEL, and uint.

Referenced by eval().

00224 {
00225         // eval "fractaly".
00226         float           turb;
00227 
00228 #if (NL3D_NOISE_LEVEL != 3)
00229         CVector         vd= pos;
00230         turb=0;
00231         for(uint level=0;level<NL3D_NOISE_LEVEL;level++)
00232         {
00233                 // Add the influence of the ith level.
00234                 turb+= CRandomGrid3D::getLevelSize(level) * 
00235                         CRandomGrid3D::evalBiLinear(vd + CRandomGrid3D::getLevelPhase(level) );
00236                 // Next level at higher frequency
00237                 vd*= 2;
00238         }
00239 #else
00240         // special case. unrolled loop.
00241         // level 0 has no phase.
00242         turb= CRandomGrid3D::getLevelSize(0) * 
00243                 CRandomGrid3D::evalBiLinear(pos);
00244         // level 1
00245         turb+= CRandomGrid3D::getLevelSize(1) * 
00246                 CRandomGrid3D::evalBiLinear(pos*2 + CRandomGrid3D::getLevelPhase(1) );
00247         // level 2
00248         turb+= CRandomGrid3D::getLevelSize(2) * 
00249                 CRandomGrid3D::evalBiLinear(pos*4 + CRandomGrid3D::getLevelPhase(2) );
00250 #endif
00251 
00252         return turb;
00253 }

void NLMISC::CNoiseValue::serial IStream f  ) 
 

Definition at line 294 of file noise_value.cpp.

References NLMISC::IStream::serial(), and NLMISC::IStream::serialVersion().

00295 {
00296         (void)f.serialVersion(0);
00297         f.serial(Abs);
00298         f.serial(Rand);
00299         f.serial(Frequency);
00300 }


Field Documentation

float NLMISC::CNoiseValue::Abs
 

Definition at line 52 of file noise_value.h.

Referenced by NL3D::CVegetable::CVegetable(), and NL3D::CVegetable::generateInstance().

float NLMISC::CNoiseValue::Frequency
 

Definition at line 54 of file noise_value.h.

float NLMISC::CNoiseValue::Rand
 

Definition at line 53 of file noise_value.h.

Referenced by NL3D::CVegetable::CVegetable(), and NL3D::CVegetable::generateInstance().


The documentation for this class was generated from the following files:
Generated on Tue Mar 16 13:23:30 2004 for NeL by doxygen 1.3.6