NLMISC::CNoiseColorGradient Class Reference

#include <noise_value.h>


Detailed Description

A noisy color generator
Author:
Lionel Berenguier

Nevrax France

Date:
2001

Definition at line 89 of file noise_value.h.

Public Member Functions

void eval (const CVector &posInWorld, CRGBAF &result) const
void serial (IStream &f)

Data Fields

std::vector< CRGBAFGradients
CNoiseValue NoiseValue
 Abs and Rand should be 0 and 1 here. If not, some colors may not be generated...


Member Function Documentation

void NLMISC::CNoiseColorGradient::eval const CVector posInWorld,
CRGBAF result
const
 

Use NoiseValue to compute a PerlinNoise E [0..1], and peek in Gradients, with linear interpolation. result unmodified if no colors. If only one color, copied into result. Warning! Use OptFastFloor()! So call must be enclosed with a OptFastFloorBegin()/OptFastFloorEnd().

Definition at line 309 of file noise_value.cpp.

References NLMISC::clamp(), NLMISC::CNoiseValue::eval(), Gradients, NoiseValue, NLMISC::OptFastFloor(), and uint.

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

00310 {
00311         // test if not null grads.
00312         uint    nGrads= Gradients.size();
00313         if(nGrads==0)
00314                 return;
00315         // if only one color, easy
00316         if(nGrads==1)
00317         {
00318                 result= Gradients[0];
00319         }
00320         else
00321         {
00322                 // eval noise
00323                 float   f= NoiseValue.eval(posInWorld) * (nGrads-1);
00324                 clamp(f, 0.f, (float)(nGrads-1));
00325                 // look up in table of gradients.
00326                 uint    id= OptFastFloor(f);
00327                 clamp(id, 0U, nGrads-2);
00328                 // fractionnal part.
00329                 f= f-id;
00330                 clamp(f, 0, 1);
00331                 // interpolate the gradient.
00332                 result= Gradients[id]*(1-f) + Gradients[id+1]*f;
00333         }
00334 }

void NLMISC::CNoiseColorGradient::serial IStream f  ) 
 

Definition at line 337 of file noise_value.cpp.

References Gradients, NoiseValue, NLMISC::IStream::serial(), NLMISC::IStream::serialCont(), and NLMISC::IStream::serialVersion().

00338 {
00339         (void)f.serialVersion(0);
00340         f.serial(NoiseValue);
00341         f.serialCont(Gradients);
00342 }


Field Documentation

std::vector<CRGBAF> NLMISC::CNoiseColorGradient::Gradients
 

Definition at line 94 of file noise_value.h.

Referenced by eval(), and serial().

CNoiseValue NLMISC::CNoiseColorGradient::NoiseValue
 

Abs and Rand should be 0 and 1 here. If not, some colors may not be generated...

Definition at line 93 of file noise_value.h.

Referenced by eval(), and serial().


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