instead of
ArrayList<PVector> dots = new ArrayList();
you could use your own class Box3D
ArrayList<Box3D> boxes = new ArrayList();
and add many boxes to the ArrayList
like this (short form):
class Box3D {
PVector posBox;
int sizeBox = int (random(2, 55));
color colorBox = color(random(256), random(256), random(256));
// no constructor required
void display() {
pushMatrix();
translate(posBox.x, posBox.y, posBox.z);
fill(colorBox);
box(sizeBox);
popMatrix();
}//method
}//class
full sketch without ArrayList :
Box3D box1;
void setup() {
size(1100, 800, P3D);
background(0);
box1 = new Box3D();
}
void draw() {
background(0);
box1.display();
}
// =============================================
class Box3D {
float dist = 800;
PVector posBox = new PVector(
random(0, dist),
random(0, dist),
random(-dist, 0));
int sizeBox = int (random(22, 55));
color colorBox = color(random(256), random(256), random(256));
// no constructor required
void display() {
pushMatrix();
//posBox.x=440;
//posBox.y=440;
//posBox.z=-330;
translate(posBox.x, posBox.y, posBox.z);
fill(colorBox);
box(sizeBox);
popMatrix();
}//method
}//class