We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi all, I want to know how far can I go with PeasyCam, when I right-click and drag my mouse to zoom out.
I saw here: https://github.com/jdf/peasycam/blob/master/src/peasy/PeasyCam.java this line 58: private double maximumDistance = Double.MAX_VALUE;
but, when I use getDistance(); to my PeasyCam, and I println() the values, I get around 5300 before my object disappear.
I thought this was caused by the fact that it's a floating number and the values after the float reach the max lenght for a double, but I don't think this is the case, because I can zoom out more and more and getting higher values.
It's just my object disappear..
Can I move this point?
Thank you in advance
import peasy.*;
import peasy.org.apache.commons.math.*;
import peasy.org.apache.commons.math.geometry.*;
PeasyCam cam;
void setup() {
size(800, 600, P3D);
cam = new PeasyCam(this, 100);
}
void draw() {
background(255);
println(cam.getDistance());
sphere(100);
}
Answers
OpenGL uses a fustrum to represent the volume of space that will be rendered on the screen. There are two important measurements,
The near zone distance - anything less than this distance will not be rendered
the far zone distance - anything beyond that will not be rendered.
I don't know whether you can change the far zone distance in PeasyCam
Thank you quark :)
Ok, so there are a Front Clipping Plane and a Back Clipping Plane. There are some ways to "break" those clipping boundaries?
perspective() in the reference has the formula it uses for calculating the clipping distances and other versions which allow you to override the defaults.
But I haven't looked to see whether peasycam works with this or whether it uses its own.
The reference for PeasyCam does not appear to have an option to change the back clipping distance. You might add it as a feature request.
I've taken a look to perspective() reference, but it seems I wasn't able to make it works :(
now I found this thread: https://forum.processing.org/two/discussion/8776/help-goemetry-shifted-when-toggling-btw-ortho-and-perspective-in-peasycam
and his use of perspective() works perfectly!!!
Here is my modified and simplified code:
as you can see now the sphere() will disappear when cam.getDistance() reach 10.000 :)
If you don't mind, I have some questions (maybe I should post it in the original thread...):
why do we have to set two difference perspective(), one for the setupCamera() method and one for updateCam()?
Why fov = PI/3; ? What this means? And why we have to update it in draw? Isn't PI/3 a costant?
Thank you :)
Fov is field of view (it's even in the comments there), how much of an angle you can see. It's a standard graphics concept that you could Google.
Those two calls to perspective are identical. I don't think that code is all that great. You don't need both.
Don't post additional questions in 2 year old threads. Processing has changed major versions twice in that time.
Thank you :)