Empeld
Empeld plugin documentation.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events
pluginbase.Helpers.Computative.Algorithms.SmoothPerlin Class Reference
Inheritance diagram for pluginbase.Helpers.Computative.Algorithms.SmoothPerlin:
pluginbase.Helpers.Computative.ValuePoint3D

Public Member Functions

 SmoothPerlin (IPseudoRandom provider, int frequency, int levels)
 
 SmoothPerlin (int seed, int frequency, int levels)
 
override float GetValue (int x, int y, int z)
 Get a value between 0-1 More...
 
override float GetValue (int x, int y)
 Get a 2D value between 0-1 More...
 
- Public Member Functions inherited from pluginbase.Helpers.Computative.ValuePoint3D
ValuePoint3D Mix (ValuePoint3D with, float sourceOpacity)
 Mix this value with another one at a certain ratio More...
 
ValuePoint3D Lighten (ValuePoint3D with)
 Lighten this value by another one More...
 
ValuePoint3D Darken (ValuePoint3D with)
 Darken this value by another one More...
 
ValuePoint3D CustomCombine (ValuePoint3D with, Combiner3D.CombinerOperator func)
 Combine two values using a custom combiner More...
 
ValuePoint3D CustomManipulator (Manip3D.ManipOperator func)
 Manipulate this value with a custom manipulator More...
 
ValuePoint3D Abs ()
 Absolute value More...
 
ValuePoint3D Invert ()
 Invert the value from a 0-1 range More...
 
ValuePoint3D Brightness (float amount)
 Adjust brightness. Takes in -1 to 1f More...
 
ValuePoint3D Contrast (float amount)
 Adjusts contract from -1 to 1 More...
 
ValuePoint3D Scale (float factor)
 Scale the specified factor and clamp More...
 
ValuePoint3D LinearBounds (float min, float max)
 Linearly interpolates to squish between the bounds More...
 
ValuePoint3D Threshold (float threshold)
 Threshold the specified threshold. Returns 0 if below, otherwise 1f More...
 
ValuePoint3D Gamma (float gamma)
 Gamma the specified gamma. Range 0f - 2f More...
 
ValuePoint3D Clamp ()
 Clamp this value between 0 and 1 More...
 
ValuePoint3D Clamp (float min, float max)
 Clamp this value between a min and max More...
 

Public Attributes

readonly int Frequency
 
readonly int Levels
 

Additional Inherited Members

- Static Public Member Functions inherited from pluginbase.Helpers.Computative.ValuePoint3D
static ValuePoint3D operator+ (ValuePoint3D a, ValuePoint3D b)
 Add two value points together More...
 
static ValuePoint3D operator- (ValuePoint3D a, ValuePoint3D b)
 Subtract two value points More...
 
static ValuePoint3D operator* (ValuePoint3D a, ValuePoint3D b)
 Multiply two value points More...
 
static ValuePoint3D operator/ (ValuePoint3D a, ValuePoint3D b)
 Divide one value by another More...
 

Constructor & Destructor Documentation

pluginbase.Helpers.Computative.Algorithms.SmoothPerlin.SmoothPerlin ( IPseudoRandom  provider,
int  frequency,
int  levels 
)

Attribute: levels

;

Attribute: levels

;

Attribute: level

= (int)(Frequency / (float)Math.Pow(2, level));

Attribute: level

= (1f / (float)Math.Pow(2, level)) / (float)maxWeight;

17  {
18  random = new Random3D(provider);
19  Frequency = frequency;
20  Levels = levels;
21 
22  double maxWeight = 2.0 * (1.0 - Math.Pow(0.5, levels)); //Sum of halves to determine max weight value to scale
23  _sizeTable = new int[levels];
24  _weightTable = new float[levels];
25  for (int level = 0; level < Levels; ++level)
26  {
27  _sizeTable[level] = (int)(Frequency / (float)Math.Pow(2, level));
28  _weightTable[level] = (1f / (float)Math.Pow(2, level)) / (float)maxWeight;
29  }
30  }
A value instance of pure random numbers
Definition: Random3D.cs:9
readonly int Levels
Definition: SmoothPerlin.cs:10
readonly int Frequency
Definition: SmoothPerlin.cs:9
pluginbase.Helpers.Computative.Algorithms.SmoothPerlin.SmoothPerlin ( int  seed,
int  frequency,
int  levels 
)
33  :this(new PseudoRandom(seed), frequency, levels)
34  {}
A basic implementation of a random number generator
Definition: PseudoRandom.cs:7

Member Function Documentation

override float pluginbase.Helpers.Computative.Algorithms.SmoothPerlin.GetValue ( int  x,
int  y,
int  z 
)
virtual

Get a value between 0-1

Parameters
xA System.Int32
yA System.Int32
zA System.Int32
Returns
A System.Int32

Attribute: level

;

Attribute: level

;

Implements pluginbase.Helpers.Computative.ValuePoint3D.

52  {
53  int levelSize;
54  int bX, bY, bZ;
55  float dX, dY, dZ;
56  float val = 0f;
57  for (int level = 0; level < Levels; ++level)
58  {
59  levelSize = _sizeTable[level];
60  if (levelSize <= 0){
61  break;
62  }
63 
64  bX = x - MExt.mmod(x, levelSize);
65  bY = y - MExt.mmod(y, levelSize);
66  bZ = z - MExt.mmod(z, levelSize);
67 
68  dX = (x - bX) / (float)levelSize;
69  dY = (y - bY) / (float)levelSize;
70  dZ = (z - bZ) / (float)levelSize;
71 
72  dX = dX * dX * (3f - 2f * dX);
73  dY = dY * dY * (3f - 2f * dY);
74  dZ = dZ * dZ * (3f - 2f * dZ);
75 
76  val += (
77  ((random.Rand(bX, bY, bZ) * (1f - dX) + random.Rand(bX + levelSize, bY, bZ) * dX) * (1f - dY)
78  + (random.Rand(bX, bY + levelSize, bZ) * (1f - dX) + random.Rand(bX + levelSize, bY + levelSize, bZ) * dX) * dY) * (1f - dZ)
79  + ((random.Rand(bX, bY, bZ + levelSize) * (1f - dX) + random.Rand(bX + levelSize, bY, bZ + levelSize) * dX) * (1f - dY)
80  + (random.Rand(bX, bY + levelSize, bZ + levelSize) * (1f - dX) + random.Rand(bX + levelSize, bY + levelSize, bZ + levelSize) * dX) * dY) * dZ
81  ) * _weightTable[level];
82  }
83  return val;
84  }
readonly int Levels
Definition: SmoothPerlin.cs:10
float Rand(int x)
Returns 0-1 float
Definition: Random3D.cs:41
override float pluginbase.Helpers.Computative.Algorithms.SmoothPerlin.GetValue ( int  x,
int  y 
)
virtual

Get a 2D value between 0-1

Parameters
xA System.Int32
yA System.Int32
Returns
A System.Int32

Attribute: level

;

Attribute: level

;

Implements pluginbase.Helpers.Computative.ValuePoint3D.

99  {
100  int bX, bY;
101  float dX, dY;
102  float val = 0f;
103  for (int level = 0; level < Levels; ++level)
104  {
105  int levelSize = _sizeTable[level];
106  if (levelSize <= 0){
107  break;
108  }
109 
110  bX = x - MExt.mmod(x, levelSize);
111  bY = y - MExt.mmod(y, levelSize);
112 
113  dX = (x - bX) / (float)levelSize;
114  dY = (y - bY) / (float)levelSize;
115 
116  dX = dX * dX * (3f - 2f * dX);
117  dY = dY * dY * (3f - 2f * dY);
118 
119  val += ((random.Rand(bX, bY) * (1f - dX) + random.Rand(bX + levelSize, bY) * dX) * (1f - dY)
120  + (random.Rand(bX, bY + levelSize) * (1f - dX) + random.Rand(bX + levelSize, bY + levelSize) * dX) * dY) * _weightTable[level];
121  }
122  return val;
123  }
readonly int Levels
Definition: SmoothPerlin.cs:10
float Rand(int x)
Returns 0-1 float
Definition: Random3D.cs:41

Member Data Documentation

readonly int pluginbase.Helpers.Computative.Algorithms.SmoothPerlin.Frequency
readonly int pluginbase.Helpers.Computative.Algorithms.SmoothPerlin.Levels

The documentation for this class was generated from the following file: