3D tunnel #1 - OpenProcessing
3D tunnel #1
@author
float distance = 0.0;
float speed = 3;
float objStep = 35;
color c1, c2;
boolean useRect;
void setup(){
size(640, 640, P3D);
rectMode(CENTER);
mousePressed();
}
void mousePressed(){
c1 = color(random(255), random(255), random(255));
c2 = color(random(255), random(255), random(255));
useRect = random(1) < 0.5 ? true: false;
}
void draw(){
background(c1);
translate(width / 2, height / 2);
float camX = map(mouseX, 0, width, -30, 30);
float camY = map(mouseY, 0, height, -30, 30);
camera(camX, camY, 0, 0, 0, -100, 0, 1, 0);
stroke(c2);
strokeWeight(2);
noFill();
for(float depth = 0; depth > -1500; depth -= objStep){
pushMatrix();
translate(0, 0, depth + distance % objStep);
if(useRect){
rect(0, 0, 200, 200);
} else {
ellipse(0, 0, 200, 200);
}
popMatrix();
}
distance += speed;
if(distance > objStep){
distance -= objStep;
}
}