Last active
November 1, 2018 21:43
-
-
Save jumahe/a95b2f1d4bd1bd4cddcc1a7d4e2f90ae to your computer and use it in GitHub Desktop.
Codevember 2018 - #1 infinity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import toxi.processing.*; | |
import toxi.geom.*; | |
import toxi.geom.mesh.*; | |
import peasy.*; | |
PeasyCam cam; | |
ToxiclibsSupport gfx; | |
ArrayList<Star> stars; | |
int MAX_STARS = 1000; | |
int fc = 0; | |
int index = 0; | |
void setup() | |
{ | |
size(800,800,P3D); | |
frameRate(60); | |
smooth(); | |
background(0); | |
cam = new PeasyCam(this, 1000); | |
cam.setMinimumDistance(50); | |
cam.setMaximumDistance(5000); | |
gfx = new ToxiclibsSupport(this); | |
stars = new ArrayList<Star>(); | |
int i = 0; | |
for(i=0; i < MAX_STARS; i++) | |
{ | |
stars.add( new Star(i) ); | |
} | |
} | |
void draw() | |
{ | |
noStroke(); | |
fill(0,0,0,50); | |
rect(-width,-height,width*2,height*2); | |
fill(255); | |
int i; | |
for(i = 0; i < MAX_STARS; i++) | |
{ | |
Star sp = stars.get(i); | |
sp.update(); | |
} | |
for(i = 0; i < MAX_STARS; i++) | |
{ | |
Star sp = stars.get(i); | |
gfx.mesh(sp.m, true); | |
} | |
/* | |
fc++; | |
if(fc >= 40) | |
{ | |
index++; | |
save("export/" + index + ".png"); | |
} | |
*/ | |
} | |
class Star | |
{ | |
int sid; | |
float x,y,z; | |
Vec3D v; | |
Sphere s; | |
Mesh3D m; | |
int speed; | |
Star(int id) | |
{ | |
sid = id; | |
speed = int(random(1,10)); | |
v = initdVector(); | |
buildMesh(v); | |
} | |
void update() | |
{ | |
z += speed; | |
if(z >= 1000) v = initdVector(); | |
v = new Vec3D(x,y,z); | |
buildMesh(v); | |
} | |
Vec3D initdVector() | |
{ | |
x = random(-600,600); | |
y = random(-600,600); | |
z = random(0,-4000); | |
return new Vec3D(x,y,z); | |
} | |
void buildMesh(Vec3D vv) | |
{ | |
s = new Sphere(vv,1); | |
m = s.toMesh(5); | |
} | |
} |
Author
jumahe
commented
Nov 1, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment