public void onAnalog(String name, float value, float tpf) { // Instead of moving closer/farther to object, we zoom in/out. if (name.equals("Size-")) frustumSize += 0.3f * tpf; else frustumSize -= 0.3f * tpf; float aspect = (float) cam.getWidth() / cam.getHeight(); cam.setFrustum(-1000, 1000, -aspect * frustumSize, aspect * frustumSize, frustumSize, -frustumSize); } }
public void initialize(RenderManager rm, ViewPort viewPort) { this.camera = viewPort.getCamera(); this.width = camera.getWidth(); this.height = camera.getHeight(); this.renderManager = rm; this.isInitilized = true; if (freeItems == null) { freeItems = new LinkedBlockingQueue<WorkItem>(); for (int i = 0; i < numCpus; i++) { freeItems.add(new WorkItem(width, height)); } } }
public void initialize(RenderManager rm, ViewPort viewPort) { logger.log(Level.INFO, "initialize in VideoProcessor"); this.camera = viewPort.getCamera(); this.width = camera.getWidth(); this.height = camera.getHeight(); this.renderManager = rm; this.isInitilized = true; if (freeItems == null) { freeItems = new LinkedBlockingQueue<WorkItem>(); for (int i = 0; i < numCpus; i++) { freeItems.add(new WorkItem(width, height)); } } }
public void onAnalog(String name, float value, float tpf) { if (cam.isParallelProjection()) { // Instead of moving closer/farther to object, we zoom in/out. if (name.equals("Size-")) { frustumSize += 5f * tpf; } else { frustumSize -= 5f * tpf; } float aspect = (float) cam.getWidth() / cam.getHeight(); cam.setFrustum(-1000, 1000, -aspect * frustumSize, aspect * frustumSize, frustumSize, -frustumSize); } }
public void initialize(RenderManager rm, ViewPort vp) { renderManager = rm; viewPort = vp; reshape(vp, vp.getCamera().getWidth(), vp.getCamera().getHeight()); }
private void initialize( final AssetManager assetManager, final InputManager inputManager, final AudioRenderer audioRenderer, final ViewPort viewport) { this.assetManager = assetManager; this.inputManager = inputManager; this.w = viewport.getCamera().getWidth(); this.h = viewport.getCamera().getHeight(); this.soundDev = new SoundDeviceJme(assetManager, audioRenderer); this.inputSys = new InputSystemJme(inputManager); }
public void initialize(RenderManager rm, ViewPort vp) { renderer = rm.getRenderer(); this.rm = rm; reshape(vp, vp.getCamera().getWidth(), vp.getCamera().getHeight()); }
public void update(){ int w = image.getWidth(); int h = image.getHeight(); float wr = (float) cam.getWidth() / image.getWidth(); float hr = (float) cam.getHeight() / image.getHeight(); scene.updateGeometricState(); for (int y = 0; y < h; y++){ for (int x = 0; x < w; x++){ Vector2f v = new Vector2f(x * wr,y * hr); Vector3f pos = cam.getWorldCoordinates(v, 0.0f); Vector3f dir = cam.getWorldCoordinates(v, 0.3f); dir.subtractLocal(pos).normalizeLocal(); Ray r = new Ray(pos, dir); results.clear(); scene.collideWith(r, results); if (results.size() > 0){ image.setRGB(x, h - y - 1, 0xFFFFFFFF); }else{ image.setRGB(x, h - y - 1, 0xFF000000); } } } label.repaint(); }
public void initialize(RenderManager rm, ViewPort vp) { renderManager = rm; renderer = rm.getRenderer(); viewPort = vp; fsQuad = new Picture("filter full screen quad"); fsQuad.setWidth(1); fsQuad.setHeight(1); if (!renderer.getCaps().contains(Caps.PackedFloatTexture)) { if (!renderer.getCaps().contains(Caps.FloatTexture)) { fbFormat = Format.RGB8; } else { fbFormat = Format.RGB16F; } } 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()); }
/** * @see Camera#getWorldCoordinates */ public Vector3f getWorldCoordinates(Vector2f screenPosition, float projectionZPos, Vector3f store) { if (store == null) { store = new Vector3f(); } Matrix4f inverseMat = new Matrix4f(viewProjectionMatrix); inverseMat.invertLocal(); store.set( (screenPosition.x / getWidth() - viewPortLeft) / (viewPortRight - viewPortLeft) * 2 - 1, (screenPosition.y / getHeight() - viewPortBottom) / (viewPortTop - viewPortBottom) * 2 - 1, projectionZPos * 2 - 1); float w = inverseMat.multProj(store, store); store.multLocal(1f / w); return store; }
@Override protected void onEnable() { // Set the number of visible frames to the current width of the screen setFrameCount(getApplication().getCamera().getWidth()); getApplication().setAppProfiler(profiler); Node gui = ((SimpleApplication)getApplication()).getGuiNode(); gui.attachChild(graph); gui.attachChild(background); }
public void initialize(RenderManager rm, ViewPort vp) { reshape(vp, vp.getCamera().getWidth(), vp.getCamera().getHeight()); viewPort.setOutputFrameBuffer(fb); guiViewPort.setClearFlags(true, true, true); guiNode.attachChild(display); // guiNode.attachChild(display1); guiNode.attachChild(display2); // guiNode.attachChild(display3); // guiNode.attachChild(display4); guiNode.updateGeometricState(); }
public void onWayPointReach(MotionEvent control, int wayPointIndex) { if (path.getNbWayPoints() == wayPointIndex + 1) { wayPointsText.setText(control.getSpatial().getName() + " Finish!!! "); } else { wayPointsText.setText(control.getSpatial().getName() + " Reached way point " + wayPointIndex); } wayPointsText.setLocalTranslation((cam.getWidth() - wayPointsText.getLineWidth()) / 2, cam.getHeight(), 0); } });
public void onWayPointReach(MotionEvent control, int wayPointIndex) { if (path.getNbWayPoints() == wayPointIndex + 1) { wayPointsText.setText(control.getSpatial().getName() + "Finished!!! "); } else { wayPointsText.setText(control.getSpatial().getName() + " Reached way point " + wayPointIndex); } wayPointsText.setLocalTranslation((cam.getWidth() - wayPointsText.getLineWidth()) / 2, cam.getHeight(), 0); } });
/** * Callback from Control.render(), do not use. * * @param rm * @param vp */ private void renderFromControl(RenderManager rm, ViewPort vp) { Camera cam = vp.getCamera(); if (meshType == ParticleMesh.Type.Point) { float C = cam.getProjectionMatrix().m00; C *= cam.getWidth() * 0.5f; // send attenuation params this.getMaterial().setFloat("Quadratic", C); } Matrix3f inverseRotation = Matrix3f.IDENTITY; TempVars vars = null; if (!worldSpace) { vars = TempVars.get(); inverseRotation = this.getWorldRotation().toRotationMatrix(vars.tempMat3).invertLocal(); } particleMesh.updateParticleData(particles, cam, inverseRotation); if (!worldSpace) { vars.release(); } }
public void simpleInitApp() { Geometry teaGeom = (Geometry) assetManager.loadModel("Models/Teapot/Teapot.obj"); DirectionalLight dl = new DirectionalLight(); dl.setColor(ColorRGBA.White); dl.setDirection(Vector3f.UNIT_XYZ.negate()); rootNode.addLight(dl); rootNode.attachChild(teaGeom); // Setup first view cam.setParallelProjection(true); float aspect = (float) cam.getWidth() / cam.getHeight(); cam.setFrustum(-1000, 1000, -aspect * frustumSize, aspect * frustumSize, frustumSize, -frustumSize); inputManager.addListener(this, "Size+", "Size-"); inputManager.addMapping("Size+", new KeyTrigger(KeyInput.KEY_W)); inputManager.addMapping("Size-", new KeyTrigger(KeyInput.KEY_S)); }
/** * 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); }
protected void setupInstructionsNote() { // Add some instructional text String instructions = "WASD/Cursor Keys = scroll\n" + "+/- = zoom\n" + "space = reset view\n" + "0 = reset zoom\n"; BitmapText note = new BitmapText(guiFont); note.setText(instructions); note.setColor(new ColorRGBA(0, 0.3f, 0, 1)); note.updateLogicalState(0.1f); BoundingBox bb = (BoundingBox)note.getWorldBound(); note.setLocalTranslation(cam.getWidth() - bb.getXExtent() * 2 - 20, cam.getHeight() - 20, 10); guiNode.attachChild(note); BitmapText note2 = note.clone(); note2.setColor(ColorRGBA.Black); note2.move(1, -1, -2); guiNode.attachChild(note2); BitmapText note3 = note.clone(); note3.setColor(ColorRGBA.White); note3.move(-1, 1, -1); guiNode.attachChild(note3); }
/** * 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); }
/** * 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)); }