Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import peasy.*;
- PeasyCam camera;
- int maxSize = 1000; //number of stars
- int mult = 800;
- float size = 1;
- PVector [] pos = new PVector [maxSize];
- void setup(){
- background(0);
- size(800,800,P3D);
- noStroke();
- frameRate(120);
- PVector midPoint = new PVector(width/2, height/2, mult/2);
- camera = new PeasyCam(this, midPoint.x, midPoint.y, midPoint.z, 0);
- for (int i = 1; i < maxSize; i++){
- pos[i] = (PVector.random3D());
- pos[i].mult(mult);
- pos[i].add(midPoint);
- //pos[i].x += width/2;
- //pos[i].y += height/2;
- //pos[i].z += mult/2;
- }
- }//end setup
- void draw(){
- background(0);
- for (int i = 1; i < maxSize; i++){
- pushMatrix();
- fill(255.-(float)i/maxSize*255,255,255);
- translate(pos[i].x, pos[i].y, pos[i].z);
- sphere(random(size,size*2));
- popMatrix();
- }
- }
Add Comment
Please, Sign In to add comment