Hello guys,
I am working with cameras to do some computation I need to retrieve its current view volume. I call view volume, the visible scene's "cone" from the camera pov.
See picture below (this cone is visible when the option "Show Cone" in camera object is switched on):
-
Does it exist a function returning this volume no matter what kind of camera is used?
-
While I can compute it for perspective camera, I couldn't guess the right parameters to compute it for parallel camera.
struct frustum{
Float farVal, nearVal, right, left, top, bottom;
}f;
cam = GetCamera()) {
Float near = 0;
Float far = 1000;
Float focusLength= getParam(CAMERAOBJECT_TARGETDISTANCE, DA_REAL, cam).DReal;
if (getParam(CAMERAOBJECT_NEAR_CLIPPING_ENABLE, DA_LLONG, cam).DLLong != 0) {
near = getParam(CAMERAOBJECT_NEAR_CLIPPING, DA_REAL, cam).DReal;
}
if (getParam(CAMERAOBJECT_FAR_CLIPPING_ENABLE, DA_LLONG, cam).DLLong != 0) {
far = getParam(CAMERAOBJECT_FAR_CLIPPING, DA_REAL, cam).DReal;
}
auto fov_vertical = getParam(CAMERAOBJECT_FOV_VERTICAL, DA_REAL, cam).DReal;
auto widthHalf = focusLength * maxon::Tan(fov / 2.0)/100.0;
auto heightHalf = focusLength * maxon::Tan(fov_vertical / 2.0) / 100.0;
f.farVal = far;
f.nearVal = near;
f.right = widthHalf;
f.left = -f.right;
f.top = heightHalf;
f.bottom = -f.top;
return 0;
}
Any help is welcome.
Thank you in advance