Advertisement
lucasmontec

Untitled

Nov 5th, 2018
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.59 KB | None | 0 0
  1. ArrayList<PVector> points = new ArrayList<PVector>();
  2. ArrayList<Float> hlist = new ArrayList<Float>();
  3.  
  4. float rotation = 0;
  5.  
  6. float v = 0;
  7.  
  8. void setup() {
  9.   size(500,500,P3D);
  10.   background(0);
  11.  
  12.   noiseDetail(2,0.75);
  13.  
  14.   float r = 100;
  15.  
  16.   for(int i=0;i<1500;i++){
  17.     /*
  18.     x = r * cos(s) * sin(t)
  19.     y = r * sin(s) * sin(t)
  20.     z = r * cos(t)
  21.     */
  22.    
  23.     /*
  24.     float s = random(-180,180);
  25.     float t = random(-180,180);
  26.     */
  27.    
  28.     float s = -180 + (i/1500f)*360;
  29.     float t = (i/1500f)*v;
  30.    
  31.     float x = r * cos(s) * sin(t);
  32.     float y = r * sin(s) * sin(t);
  33.     float z = r * cos(t);
  34.    
  35.     r = 100 + noise(s,t)*50;
  36.    
  37.     //PVector pt = new PVector(random(-100,100),random(-100,100), 0);
  38.     PVector pt = new PVector(x, y, z);
  39.     points.add(pt);
  40.     hlist.add(r);
  41.   }
  42. }
  43.  
  44. void updateSphere(){
  45.    float r = 100;
  46.    for(int i=0;i<1500;i++){
  47.    
  48.     float s = -180 + (i/1500f)*360;
  49.     float t = (i/1500f)*v;
  50.    
  51.     float x = r * cos(s) * sin(t);
  52.     float y = r * sin(s) * sin(t);
  53.     float z = r * cos(t);
  54.    
  55.     r = 100 + noise(s,t)*50;
  56.    
  57.     PVector pt = points.get(i);
  58.     pt.set(x,y,z);
  59.   }
  60. }
  61.  
  62. void draw(){
  63.   v += 0.05f;
  64.  
  65.   background(0);
  66.   translate(250,250,0);
  67.   rotateY(rotation);
  68.  
  69.   stroke(255);
  70.   strokeWeight(4);
  71.  
  72.   updateSphere();
  73.  
  74.   for(int i=0;i<points.size();i++){
  75.     PVector vec = points.get(i);
  76.     float h = 255*((hlist.get(i)-100)/50);
  77.  
  78.     stroke(h,255-h,255);
  79.     pushMatrix();
  80.     translate(vec.x,vec.y,vec.z);
  81.     point(0,0,0);
  82.     popMatrix();
  83.   }
  84.  
  85.   rotation += 0.025f;
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement