yes, i play that too,
but not find any info regarding that camera thinking and the specific numbers
- P3D
- z range 310 …0 … - ??
now i see
The default values are: perspective(PI/3.0, width/height, cameraZ/10.0, cameraZ10.0) where cameraZ is ((height/2.0) / tan(PI60.0/360.0));
and that is internal of P3D?
float cameraZ = (height/2.0)/ tan(PI * 60.0/360.0) ;
float fovy, aspect, zNear, zFar;
void my_perspective(){
fovy = PI/3.0;
aspect = width/height;
zNear = cameraZ/10.0;
zFar = cameraZ*10.0;
perspective(fovy, aspect, zNear, zFar);
}
now with above code i can see rect up to z = 330
with zNear = 1; ( instead z = 340 )
( using perspective but not camera !)
test code:
// check on https://discourse.processing.org/t/rectangle-moving-along-the-z-axis/8736/4
int step=10, z = 0;
void setup() {
size(400, 400, P3D);
stroke(200, 0, 0);
fill(0, 200, 0);
rectMode(CENTER);
}
void draw() {
my_perspective();
background(200, 200, 0);
translate(width/2, height/2, z);
// translate(width/2, height/2);
// scale(z);
rect(0, 0, 8, 8); // rect(0, 0, 400, 400);
}
void keyPressed() {
println("key "+key+" keyCode "+keyCode);
if ( keyCode == 38 ) z +=step; // key UP 310 . 320 green to yellow (rect or background/rect invisible )
if ( keyCode == 40 ) z -=step; // key DOWN
println("z "+z+" cameraZ "+cameraZ+" fovy "+fovy+" aspect "+aspect+" zNear "+zNear+" zFar "+zFar);
}
float cameraZ = (height/2.0)/ tan(PI * 60.0/360.0) ;
float fovy, aspect, zNear, zFar;
void my_perspective() {
fovy = PI/3.0;
aspect = width/height;
zNear = cameraZ/10.0; //z 330 cameraZ 86.60254 fovy 1.0471976 aspect 1.0 zNear 8.660254 zFar 866.0254
// zNear = 1; //kll test z 340 cameraZ 86.60254 fovy 1.0471976 aspect 1.0 zNear 1.0 zFar 866.0254
zFar = cameraZ*10.0;
perspective(fovy, aspect, zNear, zFar);
}
float cameraZ = (height/2.0)/ tan(PI * 60.0/360.0) ;
float fovy, aspect, zNear, zFar;
void my_perspective() {
fovy = PI/3.0;
aspect = width/height;
zNear = cameraZ/10.0; //z 330 cameraZ 86.60254 fovy 1.0471976 aspect 1.0 zNear 8.660254 zFar 866.0254
// zNear = 1; //kll test z 340 cameraZ 86.60254 fovy 1.0471976 aspect 1.0 zNear 1.0 zFar 866.0254
zFar = cameraZ*10.0;
perspective(fovy, aspect, zNear, zFar);
}
and that looks like with this you would still not be able to zoom in
( like to see some details on the rect surface… )
as it works with
translate(width/2, height/2);
scale(z);