Create a method that accepts 4 PVector objects to represent the corners then inside this method call the drawLine() method created by James four times one for each side.
Something like should do the trick.
Code:
void drawBox(PVector c1, PVector c2, PVector c3, PVector c4, float weight, int strokeColour){
drawLine(c1, c2, weight, strokeColour);
drawLine(c2, c3, weight, strokeColour);
drawLine(c3, c4, weight, strokeColour);
drawLine(c4, c1, weight, strokeColour);
}
// method created by James Carruthers (parameters have been
// changed to PVectors and 'color' to int)
void drawLine(PVector p1, PVector p2, float weight, int strokeColour)
{
PVector v1 = PVector.sub(p2, p1);
float rho = sqrt(pow(v1.x,2)+pow(v1.y,2)+pow(v1.z,2));
float phi = acos(v1.z/rho);
float the = atan2(v1.y,v1.x);
v1.mult(0.5);
pushMatrix();
translate(x1,y1,z1);
translate(v1.x, v1.y, v1.z);
rotateZ(the);
rotateY(phi);
noStroke();
fill(strokeColour);
box(weight,weight,p1.dist(p2)*1.2);
popMatrix();
}
Alternatively since a rectangle with thickness is a box you can use the
Shapes 3D library and the Box class now you're used to Tubes.