int num = 6000;
float[] x01 = new float[num];
float[] y01 = new float[num];
float[] z01 = new float[num];
float[] x02 = new float[num];
float[] y02 = new float[num];
float[] z02 = new float[num];
float[] deg01 = new float[num];
float[] deg02 = new float[num];
float rot_x;
float rot_y;
float rot_z;
float amp01;
float amp02;
float range;
void setup () {
amp01 = 200.0;
rot_x = 0.0;
rot_y = 0.0;
rot_z = 0.0;
range = 4.0;
size (1920, 1080, P3D);
colorMode (RGB, 256);
background (0);
frameRate (60);
for (int i = 0; i < num; i++) {
deg01[i] = random (360);
deg02[i] = random (360);
}
for (int i = 0; i < num; i++) {
x01[i] = amp01 * cos (radians (deg01[i])) * sin (radians (deg02[i]));
y01[i] = amp01 * sin (radians (deg01[i]));
z01[i] = amp01 * cos (radians (deg01[i])) * cos (radians (deg02[i]));
}
}
void draw () {
background (0);
camera (mouseX - (width / 2), mouseY - (height / 2), 0.0,
width / 2, height / 2, 0.0,
0.0, 1.0, 0.0);
translate (width / 2, height / 2);
rotateX (radians (rot_x));
rotateY (radians (rot_y));
rotateZ (radians (rot_z));
for (int i = 0; i < num; i++) {
float offsetx = mouseX - (width / 2);
float offsety = mouseY - (height / 2);
float diffx = abs (offsetx - x01[i]);
float diffy = abs (offsety - y01[i]);
amp02 = (4000 / (diffx + diffy + 1)) + amp01 + 1;
x02[i] = amp02 * cos (radians (deg01[i])) * sin (radians (deg02[i]));
y02[i] = amp02 * sin (radians (deg01[i]));
z02[i] = amp02 * cos (radians (deg01[i])) * cos (radians (deg02[i]));
stroke (int (abs (x01[i])), int (abs (y01[i])), int (abs (z01[i])));
strokeWeight (1);
noFill ();
line (x01[i], y01[i], z01[i], x02[i], y02[i], z02[i]);
}
rot_x += map (mouseY, 0, height, -range, range);
rot_y += map (mouseX, 0, width, -range, range);
rot_z += ((map (mouseY, 0, height, -range, range) + map (mouseX, 0, width, -range, range)) / 2);
//saveFrame ();
}
1 Like