Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int d=180, num=250, l=100, v=3;
- PVector[] location = new PVector[num];
- PVector[] velocity = new PVector[num];
- float r=-.25, sz=15;
- void setup() {
- size(500, 500, P3D);
- colorMode(HSB, 360, 100, 100);
- smooth(8);
- sphereDetail(30);
- for (int i=0; i<num; i++) {
- location[i] = new PVector(random(-l, l), random(-l, l), random(-l, l));
- velocity[i] = new PVector(random(-v, v), random(-v, v), random(-v, v));
- }
- }
- void draw() {
- randomSeed(1234);
- background(#000000);
- for (int i=0; i<num; i++) {
- location[i].add(velocity[i]);
- }
- translate(width/2, height/2, -170);
- rotateY(r);
- noFill();
- stroke(#ffffff, 150);
- box(2*d, 2*d, 2*d);
- for (int i=0; i<num; i++) {
- pushMatrix();
- translate(location[i].x, location[i].y, location[i].z);
- if (location[i].x<-d+sz || location[i].x>d-sz) velocity[i].x *= -1;
- if (location[i].y<-d+sz || location[i].y>d-sz) velocity[i].y *= -1;
- if (location[i].z<-d+sz || location[i].z>d-sz) velocity[i].z *= -1;
- noStroke();
- fill(random(180,360), 90, 90);
- //fill(255);
- lights();
- sphere(sz);
- popMatrix();
- }
- r += 0.005;
- //saveFrame("image-###.tif");
- //if (frameCount>130) noLoop();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement