class Render {
float t1,t2,t3;
Render(float tempT1,float tempT2,float tempT3) {
t1 = tempT1;
t2 = tempT2;
t3 = tempT3;
}
void move() {
x = (noise(t1)*width);
y = (noise(t2)*height);
z = (noise(t3)*width);
t1+=noiseValue;
t2+=noiseValue;
t3+=noiseValue;
}
void display() {
pushMatrix();
translate(x,y,z);
fill(constrain((d/2.5),20,255));
noStroke();
sphereDetail(15);
sphere(constrain((d/50),5,100));
popMatrix();
}
}
/////////////////////////////////////
//Constellations3D - by Yser C. //
// June 09 - Processing 1.0.5 //
/////////////////////////////////////
import peasy.*;
PeasyCam cam;
int n = 100;
float range;
float rangeCount = 65;
float noiseValue = 0.01;
Render[] render;
float[][] pos;
float x,y,z,d,a;
void setup() {
size(800,600,P3D);
cam = new PeasyCam(this, width/2,height/2,height/2,width);
range = rangeCount;
render = new Render[n];
pos = new float[n][3];
for(int i = 0; i< render.length;i++) {
render[i] = new Render(random(width),random(height),random(height/2));
}
}
void draw() {
background(0);
frameRate(24);
lights();
for(int i = 0; i< n;i++) {
pos[i][0] = x;
pos[i][1] = y;
pos[i][2] = z;
int j = 1;
for (j +=i; j<n;j++) {
d = dist(pos[i][0],pos[i][1],pos[i][2],pos[j][0],pos[j][1],pos[j][2]);
if(d<=range) {
a = constrain((range - d)*3,0,255);
strokeWeight(1);
stroke(255,a);
line(pos[i][0],pos[i][1],pos[i][2],pos[j][0],pos[j][1],pos[j][2]);
}
}
render[i].move();
render[i].display();
}
println(frameRate);
}
void keyPressed() {
range = constrain(rangeCount,0,125);
if (keyCode==UP) {
rangeCount+=1;
}
if (keyCode==DOWN) {
rangeCount-=1;
}
if (keyCode==RIGHT) {
noiseValue+=0.001;
}
if (keyCode==LEFT) {
noiseValue-=0.001;
}
}