oh yes. i didnt find any connection between the ellipses and the solids until i rearranged the code a little bit. class would help you with keeping the overview.
you really just draw only a single solid. its at the position of the last ball, because after the loop you translate to its position.
so make translation,rotation for all agents. pushing and poping the transformation.
ramin
Code:
int PTS = 3;
float angle = 0;
float radius = 10;
float cylinderLength = 10;
//vertices
PVector vertices[][];
boolean isPyramid = false;
float angleInc;
int max_Agents = 100, Agents = 20;
float inc = 0.0045; // speed
Agent[] agents = new Agent[max_Agents];
int frameX = 640, frameY = 480;
void setup(){
size(frameX, frameY, P3D);
noStroke();
angleInc = PI/300.0;
// set arrays
for (int i = 0; i < max_Agents; i++) {
agents[i] = new Agent();
}
}
void draw(){
background(0);
lights();
fill(255,0,0);
stroke(1);
for (int i = 0; i < Agents; i++) {
agents[i].render();
}
}
class Agent {
PVector pos,pts;
public Agent() {
pos = new PVector(random(frameX),random(frameY));
pts = new PVector(pos.x,pos.y);
}
void render() {
pos.set(noise(pts.x)* frameX,noise(pts.y)* frameY,0);
pts.add(inc,inc,0);
ellipse(pos.x, pos.y, 10 , 10 );
pushMatrix();
translate(pos.x,pos.y);
rotateX(frameCount*PI/185);
rotateY(frameCount*PI/-200);
vertices = new PVector[2][PTS+1];
fill(200,200);
// fill arrays
for (int m = 0; m < 2; m++){
for(int n = 0; n <= PTS; n++){
vertices[m][n] = new PVector();
if (isPyramid){
if (m==1){
vertices[m][n].x = 0;
vertices[m][n].y = 0;
}
else {
vertices[m][n].x = cos(radians(angle)) * radius;
vertices[m][n].y = sin(radians(angle)) * radius;
}
}
else {
vertices[m][n].x = cos(radians(angle)) * radius;
vertices[m][n].y = sin(radians(angle)) * radius;
}
vertices[m][n].z = cylinderLength;
// the .0 after the 360 is critical
angle += 360.0/PTS;
}
cylinderLength *= -1;
}
// draw cylinder tube
beginShape(QUAD_STRIP);
for(int n = 0; n <= PTS; n++){
vertex(vertices[0][n].x, vertices[0][n].y, vertices[0][n].z);
vertex(vertices[1][n].x, vertices[1][n].y, vertices[1][n].z);
}
endShape();
//draw cylinder ends
for (int m = 0; m < 2; m++){
beginShape();
for(int n = 0; n < PTS; n++){
vertex(vertices[m][n].x, vertices[m][n].y, vertices[m][n].z);
}
endShape(CLOSE);
}
popMatrix();
}
}