private void parseCamera(Attributes attribs) throws SAXException { camera = new Camera(DEFAULT_CAM_WIDTH, DEFAULT_CAM_HEIGHT); if (SAXUtil.parseString(attribs.getValue("projectionType"), "perspective").equals("parallel")){ camera.setParallelProjection(true); } float fov = SAXUtil.parseFloat(attribs.getValue("fov"), 45f); if (fov < FastMath.PI) { // XXX: Most likely, it is in radians.. fov = fov * FastMath.RAD_TO_DEG; } camera.setFrustumPerspective(fov, (float)DEFAULT_CAM_WIDTH / DEFAULT_CAM_HEIGHT, 1, 1000); cameraNode = new CameraNode(attribs.getValue("name"), camera); cameraNode.setControlDir(ControlDirection.SpatialToCamera); node.attachChild(cameraNode); node = null; }
/** * Creates an off camera * * @param mapSize the size * @param worldPos the position * @param axisX the x axis * @param axisY the y axis * @param axisZ tha z axis * @return */ protected Camera createOffCamera(final int mapSize, final Vector3f worldPos, final Vector3f axisX, final Vector3f axisY, final Vector3f axisZ) { final Camera offCamera = new Camera(mapSize, mapSize); offCamera.setLocation(worldPos); offCamera.setAxes(axisX, axisY, axisZ); offCamera.setFrustumPerspective(90f, 1f, 0.1f, 1000); offCamera.setLocation(position); return offCamera; }
aspect = ((Number) structure.getFieldValue("ortho_scale")).floatValue(); camera.setFrustumPerspective(aspect, camera.getWidth() / camera.getHeight(), clipsta, clipend); camera.setName(structure.getName()); return camera;
@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(); }
camera.setFrustumPerspective(fovY, aspect, clipsta, clipend); camera.setName(structure.getName()); return camera;
Float zfar = getAsFloat(camData, "zfar", znear * 1000f); cam.setFrustumPerspective(yfov * FastMath.RAD_TO_DEG, aspectRatio, znear, zfar); cam = customContentManager.readExtensionAndExtras("camera.perspective", camData, cam);
@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(); } }
@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(); } }
/** * Creates the camera to use for rendering. Default values are perspective * projection with 45° field of view, with near and far values 1 and 1000 * units respectively. */ private void initCamera(){ cam = new Camera(settings.getWidth(), settings.getHeight()); cam.setFrustumPerspective(45f, (float)cam.getWidth() / cam.getHeight(), 1f, 1000f); cam.setLocation(new Vector3f(0f, 0f, 10f)); cam.lookAt(new Vector3f(0f, 0f, 0f), Vector3f.UNIT_Y); renderManager = new RenderManager(renderer); //Remy - 09/14/2010 setted the timer in the renderManager renderManager.setTimer(timer); viewPort = renderManager.createMainView("Default", cam); viewPort.setClearFlags(true, true, true); // Create a new cam for the gui Camera guiCam = new Camera(settings.getWidth(), settings.getHeight()); guiViewPort = renderManager.createPostView("Gui Default", guiCam); guiViewPort.setClearFlags(false, false, false); }
/** * Creates the camera to use for rendering. Default values are perspective * projection with 45° field of view, with near and far values 1 and 1000 * units respectively. */ private void initCamera(){ cam = new Camera(settings.getWidth(), settings.getHeight()); cam.setFrustumPerspective(45f, (float)cam.getWidth() / cam.getHeight(), 1f, 1000f); cam.setLocation(new Vector3f(0f, 0f, 10f)); cam.lookAt(new Vector3f(0f, 0f, 0f), Vector3f.UNIT_Y); renderManager = new RenderManager(renderer); //Remy - 09/14/2010 setted the timer in the renderManager renderManager.setTimer(timer); if (prof != null) { renderManager.setAppProfiler(prof); } viewPort = renderManager.createMainView("Default", cam); viewPort.setClearFlags(true, true, true); // Create a new cam for the gui Camera guiCam = new Camera(settings.getWidth(), settings.getHeight()); guiViewPort = renderManager.createPostView("Gui Default", guiCam); guiViewPort.setClearFlags(false, false, false); }
shadowCam.setFrustum(-1, 1, -1, 1, 1, -1); } else { shadowCam.setFrustumPerspective(45, 1, 1, 150);
@Before public void setUp() { filter = new DefaultLightFilter(); cam = new Camera(512, 512); cam.setFrustumPerspective(45, 1, 1, 1000); cam.setLocation(Vector3f.ZERO); cam.lookAtDirection(Vector3f.UNIT_Z, Vector3f.UNIT_Y); filter.setCamera(cam); Box box = new Box(1, 1, 1); geom = new Geometry("geom", box); geom.setLocalTranslation(0, 0, 10); geom.updateGeometricState(); list = new LightList(geom); }
offCamera.setFrustumPerspective(45f, 1f, 1f, 1000f); offCamera.setLocation(new Vector3f(0f, 0f, -5f)); offCamera.lookAt(new Vector3f(0f, 0f, 0f), Vector3f.UNIT_Y);
float hFov = fp.LeftTan() + fp.RightTan(); float vFov = fp.UpTan() + fp.DownTan(); getLeftCamera().setFrustumPerspective(hFov / FastMath.TWO_PI * 360, vFov / hFov, fNear, fFar);
offCamera.setFrustumPerspective(45f, 1f, 1f, 1000f); offCamera.setLocation(new Vector3f(0f, 0f, -5f)); offCamera.lookAt(new Vector3f(0f, 0f, 0f), Vector3f.UNIT_Y);
leftCamera.setFrustumPerspective(environment.getDefaultFOV(), environment.getDefaultAspect(), fNear, fFar);
offCamera.setFrustumPerspective(45f, 1f, 1f, 1000f); offCamera.setLocation(new Vector3f(0f, 0f, -5f)); offCamera.lookAt(new Vector3f(0f, 0f, 0f), Vector3f.UNIT_Y);
getLeftCamera().setFrustumPerspective(environment.getDefaultFOV(), environment.getDefaultAspect(), fNear, fFar);
getLeftCamera().setFrustumPerspective(environment.getDefaultFOV(), environment.getDefaultAspect(), fNear, fFar);
@Override public void simpleInitApp() { setTimer(new EraseTimer()); cam.setFrustumPerspective(45f, (float) cam.getWidth() / cam.getHeight(), 0.1f, 100f); viewPort.setBackgroundColor(ColorRGBA.DarkGray); rootNode.addLight(new DirectionalLight(new Vector3f(-1, -1, -1).normalizeLocal()));