Guest User

Untitled

a guest
Nov 21st, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. import peasy.*;
  2. PeasyCam camera;
  3.  
  4.  
  5. int maxSize = 1000; //number of stars
  6. int mult = 800;
  7. float size = 1;
  8.  
  9. PVector [] pos = new PVector [maxSize];
  10.  
  11. void setup(){
  12. background(0);
  13.  
  14. size(800,800,P3D);
  15. noStroke();
  16. frameRate(120);
  17. PVector midPoint = new PVector(width/2, height/2, mult/2);
  18.  
  19. camera = new PeasyCam(this, midPoint.x, midPoint.y, midPoint.z, 0);
  20.  
  21. for (int i = 1; i < maxSize; i++){
  22. pos[i] = (PVector.random3D());
  23. pos[i].mult(mult);
  24. pos[i].add(midPoint);
  25. //pos[i].x += width/2;
  26. //pos[i].y += height/2;
  27. //pos[i].z += mult/2;
  28.  
  29.  
  30. }
  31.  
  32. }//end setup
  33.  
  34. void draw(){
  35. background(0);
  36. for (int i = 1; i < maxSize; i++){
  37. pushMatrix();
  38. fill(255.-(float)i/maxSize*255,255,255);
  39. translate(pos[i].x, pos[i].y, pos[i].z);
  40. sphere(random(size,size*2));
  41.  
  42.  
  43. popMatrix();
  44.  
  45.  
  46. }
  47.  
  48.  
  49.  
  50.  
  51. }
Add Comment
Please, Sign In to add comment