ok, sorry, here's the whole shebang:
Code:
//import processing.opengl.*;
float radius = 200;
int balls = 15;
Circs[] circs;
void setup(){
size(640, 480, P3D);
circs = new Circs[balls];
float ang = 0;
for(int i=0; i< balls; i++){
circs[i] = new Circs(i, ang);
ang+=radians(random(180));
}
noStroke();
sphereDetail(8);
}
void draw(){
background(255);
lights();
translate(width/2,height/2);
//rotateY(radians(frameCount));
//rotateX(radians(frameCount));
sphereDetail(80, 80);
sphere(radius/2);
sphereDetail(15,15);
for (int i=0; i<circs.length; i++){
circs[i].draw();
}
}
void mousePressed(){
println("frameRate: "+frameRate);
}
class Circs{
float x, y, z, angle;
float sphereSize;
int me;
PVector pos, speed, reverseSpeed;
Circs(int _me, float _angle) {
angle = _angle;
me = _me;
sphereSize= random(15, 30);
float xspeed =random(-5, 5);
//xspeed = constrain(abs(xspeed),0.5,4);
float yspeed =random(-4, 4);
//yspeed = constrain(abs(yspeed),0.5,4);
float zspeed =random(-4, 4);
// zspeed = constrain(abs(zspeed),0.5,4);
speed = new PVector (xspeed, yspeed, zspeed);
x=cos(angle)*(radius/2+sphereSize/2);
y=sin(angle)*(radius/2+sphereSize/2);
z= random(-radius/2, radius/2);
pos = new PVector (x,y,z);
}
void draw(){
update();
fill(255);
pushMatrix();
translate(pos.x, pos.y, pos.z);
sphere(sphereSize);
popMatrix();
}
void update(){
pos.add(speed);
pos.normalize();
pos.mult(radius/2);
println ("x: " + pos.x + "y: " + pos.y + "z: " + pos.z);
println ("speedx: " + speed.x + " speedy: " + speed.y + " speedz: " + speed.z );
}
}