Hi there! I’ve been working on some sketches using the contours of a 3D object to draw onto the canvas. In order to give the appearance of the object (in this case a box) moving into the distance, I increment the value of z and subtract it from the z-parameter in translate(). Code here:
int z;
int c;
boolean inc;
void setup() {
size(640, 640, P3D);
colorMode(HSB, 360, 100, 100);
background(0);
z = 0;
c = 0;
inc = true;
}
void draw() {
camera(width/2, height/2, ((height/100.0) / tan(PI/6)), width/2, height/2, 0, 0, 1, 0);
translate(width/2, height/2, -z);
rotateX(radians(z));
rotateY(radians(z));
rotateZ(radians(z));
stroke(360-c,100,100);
//noFill();
box(100);
z+=10;
//z+=frameCount/100.0;
if (c >= 360 && inc){
c--;
inc = false;
}
else if(inc){
c++;
}
else if(c <= 0){
c++;
inc = true;
}
else{
c--;
}
//println(frameCount);
}
What I’ve noticed is that after a while, the object stops moving entirely, as if the draw() loop has stopped executing. However, I can tell by logging the frame count that the sketch is continuing to execute. No matter how quickly the object approaches the stopping point (i.e. how quickly I change the value of z), it always stops at the same distance.
Why does the object stop? Is there a minimum value of translate() that I’m hitting? Is another approach more appropriate if I want the object to vanish to, say, a single point?
As a related, more theoretical question: the maximum width and the maximum height of my image are set when I call size() in setup(). What determines the maximum depth of the image, if one exists? I have searched the forums and documentation but haven’t yet found a good answer, so any answers you can provide would be helpful!