Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ArrayList<PVector> points = new ArrayList<PVector>();
- ArrayList<Float> hlist = new ArrayList<Float>();
- float rotation = 0;
- float v = 0;
- void setup() {
- size(500,500,P3D);
- background(0);
- noiseDetail(2,0.75);
- float r = 100;
- for(int i=0;i<1500;i++){
- /*
- x = r * cos(s) * sin(t)
- y = r * sin(s) * sin(t)
- z = r * cos(t)
- */
- /*
- float s = random(-180,180);
- float t = random(-180,180);
- */
- float s = -180 + (i/1500f)*360;
- float t = (i/1500f)*v;
- float x = r * cos(s) * sin(t);
- float y = r * sin(s) * sin(t);
- float z = r * cos(t);
- r = 100 + noise(s,t)*50;
- //PVector pt = new PVector(random(-100,100),random(-100,100), 0);
- PVector pt = new PVector(x, y, z);
- points.add(pt);
- hlist.add(r);
- }
- }
- void updateSphere(){
- float r = 100;
- for(int i=0;i<1500;i++){
- float s = -180 + (i/1500f)*360;
- float t = (i/1500f)*v;
- float x = r * cos(s) * sin(t);
- float y = r * sin(s) * sin(t);
- float z = r * cos(t);
- r = 100 + noise(s,t)*50;
- PVector pt = points.get(i);
- pt.set(x,y,z);
- }
- }
- void draw(){
- v += 0.05f;
- background(0);
- translate(250,250,0);
- rotateY(rotation);
- stroke(255);
- strokeWeight(4);
- updateSphere();
- for(int i=0;i<points.size();i++){
- PVector vec = points.get(i);
- float h = 255*((hlist.get(i)-100)/50);
- stroke(h,255-h,255);
- pushMatrix();
- translate(vec.x,vec.y,vec.z);
- point(0,0,0);
- popMatrix();
- }
- rotation += 0.025f;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement