@Override protected void updateShadowCams(Camera viewCam) { if (light == null) { logger.warning("The light can't be null for a " + getClass().getName()); return; } float zFar = zFarOverride; if (zFar == 0) { zFar = viewCam.getFrustumFar(); } //We prevent computing the frustum points and splits with zeroed or negative near clip value float frustumNear = Math.max(viewCam.getFrustumNear(), 0.001f); ShadowUtil.updateFrustumPoints(viewCam, frustumNear, zFar, 1.0f, points); //shadowCam.setDirection(direction); shadowCam.setFrustumPerspective(light.getSpotOuterAngle() * FastMath.RAD_TO_DEG * 2.0f, 1, 1f, light.getSpotRange()); shadowCam.getRotation().lookAt(light.getDirection(), shadowCam.getUp()); shadowCam.setLocation(light.getPosition()); shadowCam.update(); shadowCam.updateViewProjection(); }
@Override public Camera clone() { try { Camera cam = (Camera) super.clone(); cam.viewportChanged = true; cam.planeState = 0; cam.worldPlane = new Plane[MAX_WORLD_PLANES]; for (int i = 0; i < worldPlane.length; i++) { cam.worldPlane[i] = worldPlane[i].clone(); } cam.coeffLeft = new float[2]; cam.coeffRight = new float[2]; cam.coeffBottom = new float[2]; cam.coeffTop = new float[2]; cam.location = location.clone(); cam.rotation = rotation.clone(); if (projectionMatrixOverride != null) { cam.projectionMatrixOverride = projectionMatrixOverride.clone(); } cam.viewMatrix = viewMatrix.clone(); cam.projectionMatrix = projectionMatrix.clone(); cam.viewProjectionMatrix = viewProjectionMatrix.clone(); cam.guiBounding = (BoundingBox) guiBounding.clone(); cam.update(); return cam; } catch (CloneNotSupportedException ex) { throw new AssertionError(); } }
shadowCam.update(); shadowCam.updateViewProjection();
@Override public void simpleInitApp() { Geometry cube = new Geometry("blue cube", new Box(1, 1, 1)); Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat.setColor("Color", ColorRGBA.Blue); cube.setMaterial(mat); rootNode.attachChild(cube); // Trying to update the viewport: cam.setViewPortBottom(0.5f); cam.resize(640, 480 / 2, false); cam.setFrustumPerspective(40, 640f / (480 / 2), 0.05f, 500f); cam.update(); } }
shadowCam.update(); shadowCam.updateViewProjection();
@Override public void simpleInitApp() { viewPort.setBackgroundColor(ColorRGBA.Gray); cam.setLocation(new Vector3f(-5.6310086f, 5.0892987f, -13.000479f)); cam.setRotation(new Quaternion(0.1779095f, 0.20036356f, -0.03702727f, 0.96272093f)); cam.update(); cam.setFrustumFar(300); flyCam.setMoveSpeed(30); rootNode.setCullHint(CullHint.Never); setupLighting(); setupModel(); setupFilters(); }
@Override protected void updateShadowCams(Camera viewCam) { if (light == null) { logger.warning("The light can't be null for a " + getClass().getName()); return; } //bottom shadowCams[0].setAxes(Vector3f.UNIT_X.mult(-1f), Vector3f.UNIT_Z.mult(-1f), Vector3f.UNIT_Y.mult(-1f)); //top shadowCams[1].setAxes(Vector3f.UNIT_X.mult(-1f), Vector3f.UNIT_Z, Vector3f.UNIT_Y); //forward shadowCams[2].setAxes(Vector3f.UNIT_X.mult(-1f), Vector3f.UNIT_Y, Vector3f.UNIT_Z.mult(-1f)); //backward shadowCams[3].setAxes(Vector3f.UNIT_X, Vector3f.UNIT_Y, Vector3f.UNIT_Z); //left shadowCams[4].setAxes(Vector3f.UNIT_Z, Vector3f.UNIT_Y, Vector3f.UNIT_X.mult(-1f)); //right shadowCams[5].setAxes(Vector3f.UNIT_Z.mult(-1f), Vector3f.UNIT_Y, Vector3f.UNIT_X); for (int i = 0; i < CAM_NUMBER; i++) { shadowCams[i].setFrustumPerspective(90f, 1f, 0.1f, light.getRadius()); shadowCams[i].setLocation(light.getPosition()); shadowCams[i].update(); shadowCams[i].updateViewProjection(); } }
@Override public void simpleInitApp() { cam.setLocation(new Vector3f(-32.295086f, 54.80136f, 79.59805f)); cam.setRotation(new Quaternion(0.074364014f, 0.92519957f, -0.24794696f, 0.27748522f)); cam.update(); cam.setFrustumFar(300); flyCam.setMoveSpeed(30); rootNode.setCullHint(CullHint.Never); setupBasicShadow(); setupHdr(); setupLighting(); setupSkyBox(); // setupTerrain(); setupFloor(); // setupRobotGuy(); setupSignpost(); }
public void preFrame(float tpf) { if (filters.isEmpty() || lastFilterIndex == -1) { //If the camera is initialized and there are no filter to render, the camera viewport is restored as it was if (cameraInit) { viewPort.getCamera().resize(originalWidth, originalHeight, true); viewPort.getCamera().setViewPort(left, right, bottom, top); viewPort.setOutputFrameBuffer(outputBuffer); cameraInit = false; } } else { setupViewPortFrameBuffer(); //if we are ina multiview situation we need to resize the camera //to the viewportsize so that the backbuffer is rendered correctly if (multiView) { viewPort.getCamera().resize(width, height, false); viewPort.getCamera().setViewPort(0, 1, 0, 1); viewPort.getCamera().update(); renderManager.setCamera(viewPort.getCamera(), false); } } for (Filter filter : filters.getArray()) { if (filter.isEnabled()) { if (prof != null) prof.spStep(SpStep.ProcPreFrame, FPP, filter.getName()); filter.preFrame(tpf); } } }
shadowCam.update(); shadowCam.updateViewProjection();
@Override public Camera clone() { try { Camera cam = (Camera) super.clone(); cam.viewportChanged = true; cam.planeState = 0; cam.worldPlane = new Plane[MAX_WORLD_PLANES]; for (int i = 0; i < worldPlane.length; i++) { cam.worldPlane[i] = worldPlane[i].clone(); } cam.coeffLeft = new float[2]; cam.coeffRight = new float[2]; cam.coeffBottom = new float[2]; cam.coeffTop = new float[2]; cam.location = location.clone(); cam.rotation = rotation.clone(); if (projectionMatrixOverride != null) { cam.projectionMatrixOverride = projectionMatrixOverride.clone(); } cam.viewMatrix = viewMatrix.clone(); cam.projectionMatrix = projectionMatrix.clone(); cam.viewProjectionMatrix = viewProjectionMatrix.clone(); cam.guiBounding = (BoundingBox) guiBounding.clone(); cam.update(); return cam; } catch (CloneNotSupportedException ex) { throw new AssertionError(); } }
@Override protected void updateShadowCams(Camera viewCam) { if (light == null) { logger.warning("The light can't be null for a " + getClass().getName()); return; } float zFar = zFarOverride; if (zFar == 0) { zFar = viewCam.getFrustumFar(); } //We prevent computing the frustum points and splits with zeroed or negative near clip value float frustumNear = Math.max(viewCam.getFrustumNear(), 0.001f); ShadowUtil.updateFrustumPoints(viewCam, frustumNear, zFar, 1.0f, points); //shadowCam.setDirection(direction); shadowCam.setFrustumPerspective(light.getSpotOuterAngle() * FastMath.RAD_TO_DEG * 2.0f, 1, 1f, light.getSpotRange()); shadowCam.getRotation().lookAt(light.getDirection(), shadowCam.getUp()); shadowCam.setLocation(light.getPosition()); shadowCam.update(); shadowCam.updateViewProjection(); }
@Override public Camera clone() { try { Camera cam = (Camera) super.clone(); cam.viewportChanged = true; cam.planeState = 0; cam.worldPlane = new Plane[MAX_WORLD_PLANES]; for (int i = 0; i < worldPlane.length; i++) { cam.worldPlane[i] = worldPlane[i].clone(); } cam.coeffLeft = new float[2]; cam.coeffRight = new float[2]; cam.coeffBottom = new float[2]; cam.coeffTop = new float[2]; cam.location = location.clone(); cam.rotation = rotation.clone(); if (projectionMatrixOverride != null) { cam.projectionMatrixOverride = projectionMatrixOverride.clone(); } cam.viewMatrix = viewMatrix.clone(); cam.projectionMatrix = projectionMatrix.clone(); cam.viewProjectionMatrix = viewProjectionMatrix.clone(); cam.guiBounding = (BoundingBox) guiBounding.clone(); cam.update(); return cam; } catch (CloneNotSupportedException ex) { throw new AssertionError(); } }
shadowCam.update(); shadowCam.updateViewProjection();
@Override public void simpleInitApp() { Vector3f[] points = generatePoints(NUMPOINTS); ColorRGBA[] colors = generateColors(NUMPOINTS); PointCloud generator = new PointCloud(assetManager); try { rootNode.attachChild(generator.generatePointCloudGraph(points, colors,0.75f)); } catch (Exception e) { this.handleError(e.getMessage(), e); } cam.setFrustumPerspective(45.0f, ((float) cam.getWidth()) / ((float) cam.getHeight()), 0.05f, 100.0f); cam.setLocation(new Vector3f(0, 0, -5)); cam.lookAtDirection(Vector3f.UNIT_Z, Vector3f.UNIT_Y); cam.update(); }
@Override protected void updateShadowCams(Camera viewCam) { if (light == null) { logger.warning("The light can't be null for a " + getClass().getName()); return; } //bottom shadowCams[0].setAxes(Vector3f.UNIT_X.mult(-1f), Vector3f.UNIT_Z.mult(-1f), Vector3f.UNIT_Y.mult(-1f)); //top shadowCams[1].setAxes(Vector3f.UNIT_X.mult(-1f), Vector3f.UNIT_Z, Vector3f.UNIT_Y); //forward shadowCams[2].setAxes(Vector3f.UNIT_X.mult(-1f), Vector3f.UNIT_Y, Vector3f.UNIT_Z.mult(-1f)); //backward shadowCams[3].setAxes(Vector3f.UNIT_X, Vector3f.UNIT_Y, Vector3f.UNIT_Z); //left shadowCams[4].setAxes(Vector3f.UNIT_Z, Vector3f.UNIT_Y, Vector3f.UNIT_X.mult(-1f)); //right shadowCams[5].setAxes(Vector3f.UNIT_Z.mult(-1f), Vector3f.UNIT_Y, Vector3f.UNIT_X); for (int i = 0; i < CAM_NUMBER; i++) { shadowCams[i].setFrustumPerspective(90f, 1f, 0.1f, light.getRadius()); shadowCams[i].setLocation(light.getPosition()); shadowCams[i].update(); shadowCams[i].updateViewProjection(); } }
public void preFrame(float tpf) { if (filters.isEmpty() || lastFilterIndex == -1) { //If the camera is initialized and there are no filter to render, the camera viewport is restored as it was if (cameraInit) { viewPort.getCamera().resize(originalWidth, originalHeight, true); viewPort.getCamera().setViewPort(left, right, bottom, top); viewPort.setOutputFrameBuffer(outputBuffer); cameraInit = false; } } else { setupViewPortFrameBuffer(); //if we are ina multiview situation we need to resize the camera //to the viewportsize so that the backbuffer is rendered correctly if (multiView) { viewPort.getCamera().resize(width, height, false); viewPort.getCamera().setViewPort(0, 1, 0, 1); viewPort.getCamera().update(); renderManager.setCamera(viewPort.getCamera(), false); } } for (Filter filter : filters.getArray()) { if (filter.isEnabled()) { if (prof != null) prof.spStep(SpStep.ProcPreFrame, FPP, filter.getName()); filter.preFrame(tpf); } } }
public void initCam() { /** Configure cam to look at scene */ cam.setLocation(new Vector3f(appSize / 2, 0, appSize / 2)); cam.lookAt(new Vector3f(appSize / 2, 0, appSize / 2), Vector3f.UNIT_Y); cam.setFrustumNear(1f); cam.setFrustumFar(appSize * 5); app.getFlyByCamera().setEnabled(false); this.isoCam = new IsoCamera(cam, inputManager, app); camNode = isoCam.getCamNode(); rootNode.attachChild(camNode); cam_map = new Camera(150, 150); cam_map.setAxes(new Vector3f(1, 0, 0), new Vector3f(0, 1, 0), new Vector3f(0, 0, 0)); cam_map.setFrustumNear(1f); cam_map.setFrustumFar(appSize * 5); cam_map.setFrustumPerspective(45f, 1, 1, appSize * 5); cam_map.setLocation(new Vector3f(appSize / 2, appSize / 1.5f, appSize / 2f)); cam_map.lookAt(new Vector3f(appSize / 2, 0, appSize / 2), Vector3f.UNIT_Y); ViewPort view_map = this.app.getRenderManager().createMainView("MapView", cam_map); view_map.setEnabled(true); view_map.setClearFlags(true, true, true); view_map.attachScene(rootNode); view_map.setBackgroundColor(ColorRGBA.White); cam_map.update(); }