#include <noise_value.h>
Nevrax France
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< CRGBAF > | Gradients |
| CNoiseValue | NoiseValue |
| Abs and Rand should be 0 and 1 here. If not, some colors may not be generated... | |
|
||||||||||||
|
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 }
|
|
|
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 }
|
|
|
Definition at line 94 of file noise_value.h. |
|
|
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. |
1.3.6