-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathNoiseGenerator.pde
More file actions
55 lines (48 loc) · 1.14 KB
/
NoiseGenerator.pde
File metadata and controls
55 lines (48 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
class NoiseGenerator
{
float noiseScale;
float forceScale;
float noiseZInc;
float noiseZ;
int noiseOctave;
float noiseFalloff;
NoiseGenerator(float noiseScale, float forceScale)
{
this.noiseScale = noiseScale;
this.forceScale = forceScale;
this.noiseZInc = 0.0;
this.noiseZ = 0.0;
this.noiseOctave = 4;
this.noiseFalloff = 0.5;
}
float getNoiseAt( float x, float y )
{
return noise(x*noiseScale, y*noiseScale, noiseZ);
}
void setNoiseOctaveParam(int octaves, float fallOff)
{
this.noiseOctave = octaves;
this.noiseFalloff = fallOff;
}
void setZNoise( float startZNoise, float zNoiseInc)
{
this.noiseZInc = zNoiseInc;
this.noiseZ = startZNoise;
}
PVector getForceAt(float x, float y)
{
float n = noise(x * noiseScale, y * noiseScale, noiseZ )*TWO_PI;
PVector force = PVector.fromAngle(n);
force = force.mult(forceScale);
return force;
}
void init()
{
//println("NoiseGenerator::init - octave "+this.noiseOctave+" falloff "+this.noiseFalloff+"");
noiseDetail(this.noiseOctave, this.noiseFalloff);
}
void update()
{
noiseZ += noiseZInc;
}
}