Thank you mate - the light globe just went off and i think i finally get it.
thanks to everyone that helped.
ive tried to apply this to a separate problem and again am coming up short. I dont want to waste anyone’s time but if you could point me in the right direction it would be greatly appreciated.
re the below - the objects now move right to left and a much slower speed. i have changed the perspective but am still working on that. what i want to do is connect each box/rectangle using a line. it will help the user view how the current point is related to past points. how would i do this?
thanks
color[] colors = {
color(0, 0, 255, 200),
color(255, 0, 0, 200),
color(255, 255, 255, 200),
color(255, 255, 255, 0)
};
class SingleBar {
float px, py, pz;
float sx, sy, sz;
color c;
SingleBar(float ipx, float ipy, float ipz, float h, int type) {
px = ipx;
py = ipy;
pz = ipz;
sx = sz = 10;
sy = h;
c = colors[type];
}
void draw() {
pushMatrix();
translate(px, py, pz);
translate(0,-sy/2,0);
fill(c);
box(5, sz, 0);
popMatrix();
}
}
ArrayList<SingleBar> sbs = new ArrayList();
int offset = 0;
final int OFFSET_SPEED = 1;
float atX = 0;
float atZ = 0;
void setup() {
size(600, 400, P3D);
noStroke();
}
void draw() {
background(0);
translate(width, height/2);
lights();
//rotateY(-map(mouseX, 0, width, -HALF_PI, HALF_PI));
//rotateX(map(mouseY, 0, height, -PI, PI));
println(atZ);
if( offset > 20 ){
atZ -= 20;
offset %= 20;
for( int i = -1; i < 1; i+=2){
sbs.add( 0, new SingleBar(-atZ, 120, 20*i, random(60,300),1) );
}
}
rotateX(-PI/3);
//rotateY(-PI/10);
float cameraY = height/2.0;
float fov = 500/float(width) * PI/2;
float cameraZ = cameraY / tan(fov / 2.0);
float aspect = float(width)/float(height);
if (mousePressed) {
aspect = aspect / 2.0;
}
perspective(fov, aspect, cameraZ/10.0, cameraZ*10.0);
//rotateX(-PI/4);
// rotateY(PI/3);
translate(atZ-offset,0,0);
for( int i = 0; i< sbs.size(); i++){
sbs.get(i).draw();
}
offset+=OFFSET_SPEED;
}