/** * <code>setFrustumPerspective</code> defines the frustum for the camera. This * frustum is defined by a viewing angle, aspect ratio, and near/far planes * * @param fovY Frame of view angle along the Y in degrees. * @param aspect Width:Height ratio * @param near Near view plane distance * @param far Far view plane distance */ public void setFrustumPerspective(float fovY, float aspect, float near, float far) { if (Float.isNaN(aspect) || Float.isInfinite(aspect)) { // ignore. logger.log(Level.WARNING, "Invalid aspect given to setFrustumPerspective: {0}", aspect); return; } float h = FastMath.tan(fovY * FastMath.DEG_TO_RAD * .5f) * near; float w = h * aspect; frustumLeft = -w; frustumRight = w; frustumBottom = -h; frustumTop = h; frustumNear = near; frustumFar = far; // Camera is no longer parallel projection even if it was before parallelProjection = false; onFrustumChange(); }
} else { fovY = 2.0f * FastMath.atan(FastMath.tan(fov / 2.0f) / aspect) * FastMath.RAD_TO_DEG;
/** * Zoom the camera by the specified amount. * * @param value zoom amount */ protected void zoomCamera(float value){ // derive fovY value float h = cam.getFrustumTop(); float w = cam.getFrustumRight(); float aspect = w / h; float near = cam.getFrustumNear(); float fovY = FastMath.atan(h / near) / (FastMath.DEG_TO_RAD * .5f); float newFovY = fovY + value * 0.1f * zoomSpeed; if (newFovY > 0f) { // Don't let the FOV go zero or negative. fovY = newFovY; } h = FastMath.tan( fovY * FastMath.DEG_TO_RAD * .5f) * near; w = h * aspect; cam.setFrustumTop(h); cam.setFrustumBottom(-h); cam.setFrustumLeft(-w); cam.setFrustumRight(w); }
spotLight.setSpotOuterAngle(10 * FastMath.DEG_TO_RAD); float radius = FastMath.tan(spotLight.getSpotOuterAngle()) * spotLight.getSpotRange();
/** * <code>setFrustumPerspective</code> defines the frustum for the camera. This * frustum is defined by a viewing angle, aspect ratio, and near/far planes * * @param fovY Frame of view angle along the Y in degrees. * @param aspect Width:Height ratio * @param near Near view plane distance * @param far Far view plane distance */ public void setFrustumPerspective(float fovY, float aspect, float near, float far) { if (Float.isNaN(aspect) || Float.isInfinite(aspect)) { // ignore. logger.log(Level.WARNING, "Invalid aspect given to setFrustumPerspective: {0}", aspect); return; } float h = FastMath.tan(fovY * FastMath.DEG_TO_RAD * .5f) * near; float w = h * aspect; frustumLeft = -w; frustumRight = w; frustumBottom = -h; frustumTop = h; frustumNear = near; frustumFar = far; // Camera is no longer parallel projection even if it was before parallelProjection = false; onFrustumChange(); }
/** * <code>setFrustumPerspective</code> defines the frustum for the camera. This * frustum is defined by a viewing angle, aspect ratio, and near/far planes * * @param fovY Frame of view angle along the Y in degrees. * @param aspect Width:Height ratio * @param near Near view plane distance * @param far Far view plane distance */ public void setFrustumPerspective(float fovY, float aspect, float near, float far) { if (Float.isNaN(aspect) || Float.isInfinite(aspect)) { // ignore. logger.log(Level.WARNING, "Invalid aspect given to setFrustumPerspective: {0}", aspect); return; } float h = FastMath.tan(fovY * FastMath.DEG_TO_RAD * .5f) * near; float w = h * aspect; frustumLeft = -w; frustumRight = w; frustumBottom = -h; frustumTop = h; frustumNear = near; frustumFar = far; // Camera is no longer parallel projection even if it was before parallelProjection = false; onFrustumChange(); }
private void setupCamera(int numberOfCameras, int cameraScansPerSweep, int scanHeight, float fieldOfView, float minRange, float maxRange) { float cameraFoV = fieldOfView / (numberOfCameras); float frustrumX = FastMath.tan(cameraFoV / 2.0f) * minRange; float frustrumY = frustrumX / cameraScansPerSweep * scanHeight; cam.setParallelProjection(false); cam.setFrustum(minRange, maxRange, -frustrumX, frustrumX, frustrumY, -frustrumY); }
private void setupCamera(int numberOfCameras, int cameraScansPerSweep, int scanHeight, float fieldOfView, float minRange, float maxRange) { float cameraFoV = fieldOfView / (numberOfCameras); float frustrumX = FastMath.tan(cameraFoV / 2.0f) * minRange; float frustrumY = frustrumX / cameraScansPerSweep * scanHeight; cam.setParallelProjection(false); cam.setFrustum(minRange, maxRange, -frustrumX, frustrumX, frustrumY, -frustrumY); }
private void updateFrustrum() { int windowWidth = getWidth(); int windowHeight = getHeight(); if (windowWidth != previousWindowWidth || windowHeight != previousWindowHeight || frustrumNeedsUpdating) { float aspect = ((float) getInternalHeight()) / ((float) getInternalWidth()); float w = FastMath.tan(horizontalFoVInRadians * .5f) * clipDistanceNear; float h = w * aspect; frustumLeft = -w; frustumRight = w; frustumBottom = -h; frustumTop = h; frustumNear = clipDistanceNear; frustumFar = clipDistanceFar; onFrustumChange(); previousWindowWidth = windowWidth; previousWindowHeight = windowHeight; frustrumNeedsUpdating = false; } }
private void updateFrustrum() { int windowWidth = getWidth(); int windowHeight = getHeight(); if (windowWidth != previousWindowWidth || windowHeight != previousWindowHeight || frustrumNeedsUpdating) { float aspect = ((float) getInternalHeight()) / ((float) getInternalWidth()); float w = FastMath.tan(horizontalFoVInRadians * .5f) * clipDistanceNear; float h = w * aspect; frustumLeft = -w; frustumRight = w; frustumBottom = -h; frustumTop = h; frustumNear = clipDistanceNear; frustumFar = clipDistanceFar; onFrustumChange(); previousWindowWidth = windowWidth; previousWindowHeight = windowHeight; frustrumNeedsUpdating = false; } }
protected void zoomCamera(float value){ // derive fovY value float h = cam.getFrustumTop(); float w = cam.getFrustumRight(); float aspect = w / h; float near = cam.getFrustumNear(); float fovY = FastMath.atan(h / near) / (FastMath.DEG_TO_RAD * .5f); fovY += value * 0.1f; h = FastMath.tan( fovY * FastMath.DEG_TO_RAD * .5f) * near; w = h * aspect; cam.setFrustumTop(h); cam.setFrustumBottom(-h); cam.setFrustumLeft(-w); cam.setFrustumRight(w); }
/** * Zoom the camera by the specified amount. * * @param value zoom amount */ protected void zoomCamera(float value){ // derive fovY value float h = cam.getFrustumTop(); float w = cam.getFrustumRight(); float aspect = w / h; float near = cam.getFrustumNear(); float fovY = FastMath.atan(h / near) / (FastMath.DEG_TO_RAD * .5f); float newFovY = fovY + value * 0.1f * zoomSpeed; if (newFovY > 0f) { // Don't let the FOV go zero or negative. fovY = newFovY; } h = FastMath.tan( fovY * FastMath.DEG_TO_RAD * .5f) * near; w = h * aspect; cam.setFrustumTop(h); cam.setFrustumBottom(-h); cam.setFrustumLeft(-w); cam.setFrustumRight(w); }