Here is a fork in a more object-oriented programming style :
Code:class Arc3D {
int tubeRes = 32;
float[] tubeX;
float[] tubeY;
float angleStart, angleWidth;
float radius, thickness, elevation;
color fillColor;
public Arc3D(float angleStart, float angleWidth, float radius, float thickness, float elevation, color fillColor) {
this.angleStart = angleStart;
this.angleWidth = angleWidth;
this.radius = radius;
this.thickness = thickness;
this.elevation = elevation;
this.fillColor = fillColor;
this.tubeX = new float[this.tubeRes];
this.tubeY = new float[this.tubeRes];
float angle = this.angleWidth / (this.tubeRes - 1);
for (int i = 0; i < this.tubeRes; i++) {
this.tubeX[i] = cos(i * angle);
this.tubeY[i] = sin(i * angle);
}
}
void display() {
fill(this.fillColor);
pushMatrix();
rotateY(this.angleStart);
// outside
beginShape(QUAD_STRIP);
for (int i = 0; i < this.tubeRes; i++) {
float x = this.tubeX[i] * (this.radius + this.thickness/2);
float z = this.tubeY[i] * (this.radius + this.thickness/2);
vertex(x, 0, z);
vertex(x, this.elevation, z);
}
endShape();
// inside
beginShape(QUAD_STRIP);
for (int i = 0; i < this.tubeRes; i++) {
float x = this.tubeX[i] * (this.radius - this.thickness/2);
float z = this.tubeY[i] * (this.radius - this.thickness/2);
vertex(x, 0, z);
vertex(x, this.elevation, z);
}
endShape();
// start
beginShape(QUAD_STRIP);
vertex(this.tubeX[0] * (this.radius + this.thickness/2), 0, this.tubeY[0] * (this.radius + this.thickness/2));
vertex(this.tubeX[0] * (this.radius + this.thickness/2), elevation, this.tubeY[0] * (this.radius + this.thickness/2));
vertex(this.tubeX[0] * (this.radius - this.thickness/2), 0, this.tubeY[0] * (this.radius - this.thickness/2));
vertex(this.tubeX[0] * (this.radius - this.thickness/2), elevation, this.tubeY[0] * (this.radius - this.thickness/2));
endShape();
// end
beginShape(QUAD_STRIP);
vertex(this.tubeX[this.tubeRes - 1] * (this.radius + this.thickness/2), 0, this.tubeY[this.tubeRes - 1] * (this.radius + this.thickness/2));
vertex(this.tubeX[this.tubeRes - 1] * (this.radius + this.thickness/2), elevation, this.tubeY[this.tubeRes - 1] * (this.radius + this.thickness/2));
vertex(this.tubeX[this.tubeRes - 1] * (this.radius - this.thickness/2), 0, this.tubeY[this.tubeRes - 1] * (this.radius - this.thickness/2));
vertex(this.tubeX[this.tubeRes - 1] * (this.radius - this.thickness/2), elevation, this.tubeY[this.tubeRes - 1] * (this.radius - this.thickness/2));
endShape();
// up
beginShape(QUAD_STRIP);
for (int i = 0; i < this.tubeRes; i++) {
float x = this.tubeX[i] * (this.radius - this.thickness/2);
float z = this.tubeY[i] * (this.radius - this.thickness/2);
vertex(x, this.elevation, z);
x = this.tubeX[i] * (this.radius + this.thickness/2);
z = this.tubeY[i] * (this.radius + this.thickness/2);
vertex(x, this.elevation, z);
}
endShape();
// bottom
beginShape(QUAD_STRIP);
for (int i = 0; i < this.tubeRes; i++) {
float x = this.tubeX[i] * (this.radius - this.thickness/2);
float z = this.tubeY[i] * (this.radius - this.thickness/2);
vertex(x, 0, z);
x = this.tubeX[i] * (this.radius + this.thickness/2);
z = this.tubeY[i] * (this.radius + this.thickness/2);
vertex(x, 0, z);
}
endShape();
popMatrix();
}
}
Arc3D[] arcs;
void setup() {
size(640, 360, P3D);
arcs = new Arc3D[3];
arcs[0] = new Arc3D(TWO_PI*0.00, TWO_PI*0.90, 100, 20, 50, #8c5418);
arcs[1] = new Arc3D(TWO_PI*0.10, TWO_PI*0.60, 60, 5, 30, #fb8b00);
arcs[2] = new Arc3D(TWO_PI*0.20, TWO_PI*0.40, 50, 5, 20, #d40404);
noStroke();
}
void draw() {
background(51);
lights();
translate(width / 2, height / 2);
rotateX(map(mouseY, 0, height, -PI, PI));
rotateY(map(mouseX, 0, width, -PI, PI));
for (int i = 0; i < arcs.length; i++) {
arcs[i].display();
}
}