/** * This computes the "C" value in the geomipmapping paper. See section "2.3.1.2 Pre-calculating d" * * @param cam * @param pixelLimit * @return */ private float getCameraConstant(Camera cam, float pixelLimit) { float n = cam.getFrustumNear(); float t = FastMath.abs(cam.getFrustumTop()); float A = n / t; float v_res = cam.getHeight(); float T = (2f * pixelLimit) / v_res; return A / T; }
public void initialize(RenderManager rm, ViewPort vp) { renderManager = rm; renderer = rm.getRenderer(); viewPort = vp; fsQuad = new Picture("filter full screen quad"); Camera cam = vp.getCamera(); // save view port diensions left = cam.getViewPortLeft(); right = cam.getViewPortRight(); top = cam.getViewPortTop(); bottom = cam.getViewPortBottom(); originalWidth = cam.getWidth(); originalHeight = cam.getHeight(); // first call to reshape reshape(vp, cam.getWidth(), cam.getHeight()); }
// debug only : displays maps protected void displayMap(Renderer r, Picture pic, int left) { Camera cam = vp.getCamera(); rm.setCamera(cam, true); int h = cam.getHeight(); pic.setPosition(left, h / 20f); pic.setWidth(128); pic.setHeight(128); pic.updateGeometricState(); rm.renderGeometry(pic); rm.setCamera(cam, false); }
// debug only : displays depth shadow maps protected void displayShadowMap(Renderer r) { Camera cam = viewPort.getCamera(); renderManager.setCamera(cam, true); int h = cam.getHeight(); for (int i = 0; i < dispPic.length; i++) { dispPic[i].setPosition((128 * i) + (150 + 64 * (i + 1)), h / 20f); dispPic[i].setWidth(128); dispPic[i].setHeight(128); dispPic[i].updateGeometricState(); renderManager.renderGeometry(dispPic[i]); } renderManager.setCamera(cam, false); }
/** * Updates a points arrays with the frustum corners of the provided camera. * * @param viewCam * @param points */ public static void updateFrustumPoints2(Camera viewCam, Vector3f[] points) { int w = viewCam.getWidth(); int h = viewCam.getHeight(); points[0].set(viewCam.getWorldCoordinates(new Vector2f(0, 0), 0)); points[1].set(viewCam.getWorldCoordinates(new Vector2f(0, h), 0)); points[2].set(viewCam.getWorldCoordinates(new Vector2f(w, h), 0)); points[3].set(viewCam.getWorldCoordinates(new Vector2f(w, 0), 0)); points[4].set(viewCam.getWorldCoordinates(new Vector2f(0, 0), 1)); points[5].set(viewCam.getWorldCoordinates(new Vector2f(0, h), 1)); points[6].set(viewCam.getWorldCoordinates(new Vector2f(w, h), 1)); points[7].set(viewCam.getWorldCoordinates(new Vector2f(w, 0), 1)); }
@Override protected void initialize(Application app) { ed = getState(EntityDataState.class).getEntityData(); entities = ed.getEntities(Position.class, ModelType.class); // Calculate how big min/max needs to be to incorporate // the full view + margin at z = 0 Camera cam = app.getCamera(); float z = cam.getViewToProjectionZ(cam.getLocation().z); Vector3f worldMin = cam.getWorldCoordinates(new Vector2f(0, 0), z); Vector3f worldMax = cam.getWorldCoordinates(new Vector2f(cam.getWidth(), cam.getHeight()), z); min = worldMin.addLocal(-margin, -margin, 0); max = worldMax.addLocal(margin, margin, 0); }