Hi all,
I’m playing around with Dan Shiffmann Perlin noise flow field with Processing 4 and I wondered how to upgrade his example to use it to move particles in a 3D flow field. Currently my code is :
import peasy.*;
PeasyCam cam;
int scale = 50;
int cols, rows, dep;
float zoff = 0.;
float inc = 0.1;
void setup() {
size(800, 800, P3D);
background(250);
cam = new PeasyCam(this, 500);
cols = width / scale;
rows = height / scale;
dep = width / scale;
}
void draw() {
background(250);
translate(-width/2, -height/2);
rotateY(PI/3);
float yoff = .0;
for (int y = 0; y < rows; y++) {
float xoff = .0;
for (int x = 0; x < cols; x++) {
for (int z = 0; z < dep; z++) {
float angle1 = noise(xoff, yoff, zoff) * TWO_PI;
float angle2 = noise(yoff, zoff, xoff) * TWO_PI;
float x1 = cos(angle1) * cos(angle2);
float y1 = sin(angle1) * cos(angle2);
float z1 = sin(angle2);
PVector v = new PVector(x1, y1, z1);
xoff += inc;
push();
translate(x * scale, y * scale, z * scale);
rotate(v.heading());
stroke(0);
line(0, 0, scale, 0);
pop();
}
}
yoff += inc;
zoff += 0.0005;
}
}
I added a third dimension loop and a angle2 variable initialized with noise() function, but I’m not quite sure what maths I should use to combine it with the angle1 noise.
Any help would be greatly appreciated !
Thanks.
