We can easily convert the Sol LeWitt wall drawing sketch to a 3D sketch by adding the camera function and including a z coordinate.
The sketch in the video above uses the code below as a foundation to integrate random movement and sound responsiveness that affects the magnitude of that movement. You can dowload that sketch here.
//List to hold random point positions
ArrayList<PVector> pts = new ArrayList<PVector> ();
//declare a variable ot hold the number of poitns
int numpts = 100;
//declare a variable to check if points are
//close enough to connect
float dist_limit = 120;
///camera varibles
int oldx = mouseX;
int oldy = mouseY;
float rotx = 0;
float roty = 0;
float zcam = -300;
void setup(){
size(800,800,P3D);
//use a loop to create the initial set of random points
for(int i = 0; i < numpts; i++){
float posx = random(-300/2,300/2);
float posy = random(-300/2,300/2);
float posz = random(-300/2,300/2);
pts.add(new PVector(posx,posy,posz));
}
}
void draw(){
background(0);
cam();
//loop to draw the random points
for(int i = 0; i < pts.size(); i++){
PVector pt = pts.get(i);
stroke(255);
strokeWeight(6);
point(pt.x,pt.y,pt.z);
//this is the inner nested loop to draw
//the lines. We need a new variable for the
//loop so we will use j here.
for(int j = 0; j < pts.size(); j++){
//We also need a new variable for the second point
PVector pt2 = pts.get(j);
//create a conditional to check if the distance
//between points is under the distance limit
float distance = dist(pt.x,pt.y,pt.z,pt2.x,pt2.y,pt2.z);
if(distance < dist_limit){
//draw a line between the point in the outer loop and pt2
stroke(255,100);
strokeWeight(1);
line(pt.x,pt.y,pt.z,pt2.x,pt2.y,pt2.z);
}
}
}
}
void cam() {
int newx = mouseX;
int newy = mouseY;
translate(width/2, height/2,zcam);
rotateY(rotx);
rotateX(roty);
//rotateZ(PI);
if ((mousePressed == true)) {
rotx = rotx + (oldx-newx)/50.0;
roty = roty + (oldy-newy)/50.0;
}
oldx = newx;
oldy = newy;
}
void mouseWheel(MouseEvent event) {
float e = event.getCount();
zcam = zcam - e*5;
}