Panda3D
Public Member Functions | Protected Types | Static Protected Member Functions | Protected Attributes

PerlinNoise2 Class Reference

This class provides an implementation of Perlin noise for 2 variables. More...

#include "perlinNoise2.h"

Inheritance diagram for PerlinNoise2:
PerlinNoise

List of all members.

Public Member Functions

 PerlinNoise2 ()
 Randomizes the tables to make a unique noise function.
 PerlinNoise2 (double sx, double sy, int table_size=256, unsigned long seed=0)
 Randomizes the tables to make a unique noise function.
 PerlinNoise2 (const PerlinNoise2 &copy)
 Makes an exact copy of the existing PerlinNoise object, including its random seed.
unsigned long get_seed ()
 Returns a unique seed value based on the seed value passed to this PerlinNoise object (and on its current state).
double noise (double x, double y) const
 Returns the noise function of the three inputs.
float noise (const LVecBase2f &value) const
 Returns the noise function of the three inputs.
double noise (const LVecBase2d &value) const
 Returns the noise function of the three inputs.
double operator() (const LVecBase2d &value) const
 Returns the noise function of the two inputs.
float operator() (const LVecBase2f &value) const
 Returns the noise function of the two inputs.
double operator() (double x, double y) const
 Returns the noise function of the two inputs.
void operator= (const PerlinNoise2 &copy)
 Makes an exact copy of the existing PerlinNoise object, including its random seed.
void set_scale (double sx, double sy)
 Changes the scale (frequency) of the noise.
void set_scale (double scale)
 Changes the scale (frequency) of the noise.
void set_scale (const LVecBase2f &scale)
 Changes the scale (frequency) of the noise.
void set_scale (const LVecBase2d &scale)
 Changes the scale (frequency) of the noise.

Protected Types

typedef vector_int Index

Static Protected Member Functions

static double fade (double t)
 Returns a smooth interpolation spline from 0 .
static double lerp (double t, double a, double b)
 Returns the smoothly lerped value from a to b.

Protected Attributes

Index _index
Randomizer _randomizer
int _table_size
int _table_size_mask

Detailed Description

This class provides an implementation of Perlin noise for 2 variables.

This code is loosely based on the reference implementation at http://mrl.nyu.edu/~perlin/noise/ .

Definition at line 28 of file perlinNoise2.h.


Constructor & Destructor Documentation

PerlinNoise2::PerlinNoise2 ( ) [inline]

Randomizes the tables to make a unique noise function.

Uses a default scale (noise frequency), table size, and seed.

Definition at line 24 of file perlinNoise2.I.

PerlinNoise2::PerlinNoise2 ( double  sx,
double  sy,
int  table_size = 256,
unsigned long  seed = 0 
) [inline]

Randomizes the tables to make a unique noise function.

If seed is nonzero, it is used to define the tables; if it is zero a random seed is generated.

Definition at line 41 of file perlinNoise2.I.

References set_scale().

PerlinNoise2::PerlinNoise2 ( const PerlinNoise2 copy) [inline]

Makes an exact copy of the existing PerlinNoise object, including its random seed.

Definition at line 56 of file perlinNoise2.I.


Member Function Documentation

double PerlinNoise::fade ( double  t) [inline, static, protected, inherited]

Returns a smooth interpolation spline from 0 .

. 1 for t.

Definition at line 23 of file perlinNoise.I.

Referenced by noise(), and PerlinNoise3::noise().

unsigned long PerlinNoise::get_seed ( ) [inline, inherited]

Returns a unique seed value based on the seed value passed to this PerlinNoise object (and on its current state).

Definition at line 46 of file perlinNoise.I.

References Randomizer::get_seed().

Referenced by StackedPerlinNoise2::StackedPerlinNoise2(), and StackedPerlinNoise3::StackedPerlinNoise3().

double PerlinNoise::lerp ( double  t,
double  a,
double  b 
) [inline, static, protected, inherited]

Returns the smoothly lerped value from a to b.

Definition at line 34 of file perlinNoise.I.

Referenced by noise(), and PerlinNoise3::noise().

double PerlinNoise2::noise ( const LVecBase2d value) const

Returns the noise function of the three inputs.

Definition at line 24 of file perlinNoise2.cxx.

References PerlinNoise::fade(), PerlinNoise::lerp(), and LMatrix3d::xform_point().

float PerlinNoise2::noise ( const LVecBase2f value) const [inline]

Returns the noise function of the three inputs.

Definition at line 132 of file perlinNoise2.I.

References noise().

double PerlinNoise2::noise ( double  x,
double  y 
) const [inline]

Returns the noise function of the three inputs.

Definition at line 122 of file perlinNoise2.I.

Referenced by noise(), operator()(), and PNMImage::perlin_noise_fill().

double PerlinNoise2::operator() ( double  x,
double  y 
) const [inline]

Returns the noise function of the two inputs.

Definition at line 142 of file perlinNoise2.I.

References noise().

float PerlinNoise2::operator() ( const LVecBase2f value) const [inline]

Returns the noise function of the two inputs.

Definition at line 152 of file perlinNoise2.I.

References noise().

double PerlinNoise2::operator() ( const LVecBase2d value) const [inline]

Returns the noise function of the two inputs.

Definition at line 162 of file perlinNoise2.I.

References noise().

void PerlinNoise2::operator= ( const PerlinNoise2 copy) [inline]

Makes an exact copy of the existing PerlinNoise object, including its random seed.

Definition at line 70 of file perlinNoise2.I.

void PerlinNoise2::set_scale ( double  scale) [inline]

Changes the scale (frequency) of the noise.

Definition at line 82 of file perlinNoise2.I.

Referenced by PerlinNoise2(), and set_scale().

void PerlinNoise2::set_scale ( double  sx,
double  sy 
) [inline]

Changes the scale (frequency) of the noise.

Definition at line 92 of file perlinNoise2.I.

References set_scale().

void PerlinNoise2::set_scale ( const LVecBase2d scale) [inline]

Changes the scale (frequency) of the noise.

Definition at line 112 of file perlinNoise2.I.

References LMatrix3d::scale_mat().

void PerlinNoise2::set_scale ( const LVecBase2f scale) [inline]

Changes the scale (frequency) of the noise.

Definition at line 102 of file perlinNoise2.I.

References set_scale().


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations