We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOpenGL and 3D Libraries › zNear clipping plane behind the camera in P3D !
Page Index Toggle Pages: 1
zNear clipping plane behind the camera in P3D ! (Read 821 times)
zNear clipping plane behind the camera in P3D !
Oct 29th, 2009, 5:55pm
 
Hello,
I’m not sure about this, but a plain simple experiment bring me to some strange conclusion. Let’s put a sketch of size 400, 400. By default, the position of camera on z axis will be at 346. This is fixed by the formula that anyone could get on reference page : cameraZ is ((height/2.0) / tan(PI*60.0/360.0))
If you translate a plane (a rectangle) in direction of the camera, it will clip right after 381 in P3D, wich is further away and behind the location of camera, and at 312 in OpenGL, which this time is what one would expect.

Use this code if you want to have a look.

import processing.opengl.*;

void setup() {
 size(400,400,P3D);
 //size(400,400,OPENGL);
 background(0);
 noStroke();
 fill(255);
 rectMode(CENTER);
 float cameraZ;
 cameraZ = (height/2.0) / tan(PI*60.0/360.0);
 camera(width/2.0, height/2.0, cameraZ, width/2.0, height/2.0, 0, 0, 1, 0);
}

void draw() {
 background(0);
 translate(width/2,height/2,mouseX);
 rect(0, 0, 100, 100);
 println(mouseX);
 // When the rectangle disappear, the mouseX value shows 382 in P3D,
 // and 312 in OpenGl mode.
}


Both mesures are at 35 pixels of difference between camera position and clipping plane, and roughly the same amount you get by the formula of the z-position of nearest clipping plane (cameraZ/10.0).
But why one clipping plane is in front, and the other is in opposite direction? And also, is it normal that the object you are looking at (in P3D mode) disapear only when it is way back behind where you stand?

JFR
Page Index Toggle Pages: 1