Good morning all, this is my first post
I have what I hope is a simple question.
In the code below, I made a 3d tunnel with a camera that goes in it.
if I want to make the tunnel curve, how can I have the camera follow the curvature?
(hope the code will make sense to you). Thanks a lot, as a long time lurker I love this community.
int step=4;
float cameraZ=0;
void setup(){
size(1280,720,P3D);
colorMode(HSB);
}
void draw(){
float tunnelLen=2000;
float __distanza=(tunnelLen+2400-cameraZ)/2; // weird but it does the job :)
background(20);
rectMode(CENTER);
lights();
smooth();
strokeWeight(1);
noFill();
updateCamera(__distanza);
for (int i = 0; i<tunnelLen;i=i+4){
pushMatrix();
translate(0,0,i);
//Uncomment the lines below
//float rotation = (i/4);
//rotateY(radians(rotation));
float hue_=map(i,0, tunnelLen, 10, 200);
float sat_=map(i,0, tunnelLen, 219, 110);
float bri_=map(i,0, tunnelLen, 250, 50);
color colorelinea=color(hue_,sat_,bri_);
stroke(colorelinea);
float x1=width/2-100;
float y1=height/2-100;
float x2=width/2+100;
float y2=height/2+100;
linea(x1,y1,x2,y1);
linea(x2,y1,x2,y2);
linea(x2,y2,x1,y2);
linea(x1,y2,x1,y1);
popMatrix();
}
cameraZ=cameraZ+1;
}
void updateCamera(float _distanza) {
camera(width/2,height/2, _distanza, width/2, height/2, 0.0, 0.0, 1.0, 1.0);
}
void linea(float _x1,float _y1, float _x2, float _y2){
line(_x1,_y1,_x2,_y2);
}