com.jme3.renderer.ViewPort Java Examples
The following examples show how to use
com.jme3.renderer.ViewPort.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KinematicRagdollControl.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
/** * For internal use only * specific render for the ragdoll(if debugging) * @param rm * @param vp */ public void render(RenderManager rm, ViewPort vp) { if (enabled && space != null && space.getDebugManager() != null) { if (!debug) { attachDebugShape(space.getDebugManager()); } for (Iterator<PhysicsBoneLink> it = boneLinks.values().iterator(); it.hasNext();) { PhysicsBoneLink physicsBoneLink = it.next(); Spatial debugShape = physicsBoneLink.rigidBody.debugShape(); if (debugShape != null) { debugShape.setLocalTranslation(physicsBoneLink.rigidBody.getMotionState().getWorldLocation()); debugShape.setLocalRotation(physicsBoneLink.rigidBody.getMotionState().getWorldRotationQuat()); debugShape.updateGeometricState(); rm.renderScene(debugShape, vp); } } } }
Example #2
Source File: TranslucentBucketFilter.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override protected void initFilter(AssetManager manager, RenderManager rm, ViewPort vp, int w, int h) { this.renderManager = rm; this.viewPort = vp; material = new Material(manager, "Common/MatDefs/Post/Overlay.j3md"); material.setColor("Color", ColorRGBA.White); Texture2D tex = processor.getFilterTexture(); material.setTexture("Texture", tex); if (tex.getImage().getMultiSamples() > 1) { material.setInt("NumSamples", tex.getImage().getMultiSamples()); } else { material.clearParam("NumSamples"); } renderManager.setHandleTranslucentBucket(false); if (enabledSoftParticles && depthTexture != null) { initSoftParticles(vp, true); } }
Example #3
Source File: ParticleEmitter.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
/** * 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(); } }
Example #4
Source File: AbstractCursorEvent.java From Lemur with BSD 3-Clause "New" or "Revised" License | 5 votes |
protected AbstractCursorEvent( ViewPort view, Spatial target, float x, float y, CollisionResult collision ) { this.view = view; this.target = target; this.x = x; this.y = y; this.collision = collision; }
Example #5
Source File: VideoRecorderAppState.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override 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)); } } }
Example #6
Source File: FXAAFilter.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
@Override protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) { material = new Material(manager, "Common/MatDefs/Post/FXAA.j3md"); material.setFloat("SubPixelShift", subPixelShift); material.setFloat("VxOffset", vxOffset); material.setFloat("SpanMax", spanMax); material.setFloat("ReduceMul", reduceMul); }
Example #7
Source File: AwtPanel.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
public void initialize(RenderManager rm, ViewPort vp) { if (this.rm == null){ // First time called in OGL thread this.rm = rm; reshapeInThread(1, 1); } }
Example #8
Source File: CartoonSSAO.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) { this.renderManager = renderManager; this.viewPort = vp; int screenWidth = Math.round(w / downsample); int screenHeight = Math.round(h / downsample); normalPass = new Pass(); normalPass.init(renderManager.getRenderer(), screenWidth, screenHeight, Format.RGBA8, Format.Depth); frustumNearFar = new Vector2f(); float farY = (vp.getCamera().getFrustumTop() / vp.getCamera().getFrustumNear()) * vp.getCamera().getFrustumFar(); float farX = farY * (screenWidth / (float) screenHeight); frustumCorner = new Vector3f(farX, farY, vp.getCamera().getFrustumFar()); frustumNearFar.x = vp.getCamera().getFrustumNear(); frustumNearFar.y = vp.getCamera().getFrustumFar(); //ssao Pass material = new Material(manager, "Common/MatDefs/VR/CartoonSSAO.j3md"); material.setTexture("Normals", normalPass.getRenderedTexture()); material.setVector3("FrustumCorner", frustumCorner); material.setVector2("FrustumNearFar", frustumNearFar); material.setFloat("Distance", applyDistance); if( useOutline == false ) material.setBoolean("disableOutline", true); if( instancedRendering ) material.setBoolean("useInstancing", true); }
Example #9
Source File: LWJGLOpenVRViewManager.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
private ViewPort setupViewBuffers(Camera cam, String viewName) { if (environment != null) { if (environment.getApplication() != null) { // create offscreen framebuffer FrameBuffer offBufferLeft = new FrameBuffer(cam.getWidth(), cam.getHeight(), 1); //offBufferLeft.setSrgb(true); //setup framebuffer's texture Texture2D offTex = new Texture2D(cam.getWidth(), cam.getHeight(), Image.Format.RGBA8); offTex.setMinFilter(Texture2D.MinFilter.BilinearNoMipMaps); offTex.setMagFilter(Texture2D.MagFilter.Bilinear); //setup framebuffer to use texture offBufferLeft.setDepthBuffer(Image.Format.Depth); offBufferLeft.setColorTexture(offTex); ViewPort viewPort = environment.getApplication().getRenderManager().createPreView(viewName, cam); viewPort.setClearFlags(true, true, true); viewPort.setBackgroundColor(ColorRGBA.Black); Iterator<Spatial> spatialIter = environment.getApplication().getViewPort().getScenes().iterator(); while (spatialIter.hasNext()) { viewPort.attachScene(spatialIter.next()); } //set viewport to render to offscreen framebuffer viewPort.setOutputFrameBuffer(offBufferLeft); return viewPort; } else { throw new IllegalStateException("This VR environment is not attached to any application."); } } else { throw new IllegalStateException("This VR view manager is not attached to any VR environment."); } }
Example #10
Source File: TranslucentBucketFilter.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
@Override protected void postFrame(RenderManager renderManager, ViewPort viewPort, FrameBuffer prevFilterBuffer, FrameBuffer sceneBuffer) { renderManager.setCamera(viewPort.getCamera(), false); if (prevFilterBuffer != sceneBuffer) { renderManager.getRenderer().copyFrameBuffer(prevFilterBuffer, sceneBuffer, false); } renderManager.getRenderer().setFrameBuffer(sceneBuffer); viewPort.getQueue().renderQueue(RenderQueue.Bucket.Translucent, renderManager, viewPort.getCamera()); }
Example #11
Source File: OpenVRViewManager.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void setupFinalFullTexture(Camera cam) { if (environment != null){ if (environment.getApplication() != null){ // create offscreen framebuffer FrameBuffer out = new FrameBuffer(cam.getWidth(), cam.getHeight(), 1); //offBuffer.setSrgb(true); //setup framebuffer's texture dualEyeTex = new Texture2D(cam.getWidth(), cam.getHeight(), Image.Format.RGBA8); dualEyeTex.setMinFilter(Texture.MinFilter.BilinearNoMipMaps); dualEyeTex.setMagFilter(Texture.MagFilter.Bilinear); logger.config("Dual eye texture "+dualEyeTex.getName()+" ("+dualEyeTex.getImage().getId()+")"); logger.config(" Type: "+dualEyeTex.getType()); logger.config(" Size: "+dualEyeTex.getImage().getWidth()+"x"+dualEyeTex.getImage().getHeight()); logger.config(" Image depth: "+dualEyeTex.getImage().getDepth()); logger.config(" Image format: "+dualEyeTex.getImage().getFormat()); logger.config(" Image color space: "+dualEyeTex.getImage().getColorSpace()); //setup framebuffer to use texture out.setDepthBuffer(Image.Format.Depth); out.setColorTexture(dualEyeTex); ViewPort viewPort = environment.getApplication().getViewPort(); viewPort.setClearFlags(true, true, true); viewPort.setBackgroundColor(ColorRGBA.Black); viewPort.setOutputFrameBuffer(out); } else { throw new IllegalStateException("This VR environment is not attached to any application."); } } else { throw new IllegalStateException("This VR view manager is not attached to any VR environment."); } }
Example #12
Source File: MapView.java From OpenRTS with MIT License | 5 votes |
public MapView(Node rootNode, Node gui, PhysicsSpace physicsSpace, AssetManager am, ViewPort vp) { this.setRootNode(rootNode); this.physicsSpace = physicsSpace; gui.attachChild(guiNode); this.assetManager = am; this.vp = vp; lightDrawer = new LightDrawer(this, am, rootNode, vp); createSky(); EventManager.register(this); }
Example #13
Source File: OSVRViewManager.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void setupFinalFullTexture(Camera cam) { if (environment != null){ if (environment.getApplication() != null){ // create offscreen framebuffer FrameBuffer out = new FrameBuffer(cam.getWidth(), cam.getHeight(), 1); //offBuffer.setSrgb(true); //setup framebuffer's texture dualEyeTex = new Texture2D(cam.getWidth(), cam.getHeight(), Image.Format.RGBA8); dualEyeTex.setMinFilter(Texture.MinFilter.BilinearNoMipMaps); dualEyeTex.setMagFilter(Texture.MagFilter.Bilinear); logger.config("Dual eye texture "+dualEyeTex.getName()+" ("+dualEyeTex.getImage().getId()+")"); logger.config(" Type: "+dualEyeTex.getType()); logger.config(" Size: "+dualEyeTex.getImage().getWidth()+"x"+dualEyeTex.getImage().getHeight()); logger.config(" Image depth: "+dualEyeTex.getImage().getDepth()); logger.config(" Image format: "+dualEyeTex.getImage().getFormat()); logger.config(" Image color space: "+dualEyeTex.getImage().getColorSpace()); //setup framebuffer to use texture out.setDepthBuffer(Image.Format.Depth); out.setColorTexture(dualEyeTex); ViewPort viewPort = environment.getApplication().getViewPort(); viewPort.setClearFlags(true, true, true); viewPort.setBackgroundColor(ColorRGBA.Black); viewPort.setOutputFrameBuffer(out); } else { throw new IllegalStateException("This VR environment is not attached to any application."); } } else { throw new IllegalStateException("This VR view manager is not attached to any VR environment."); } }
Example #14
Source File: DebugTools.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Render all the debug geometries to the specified view port. * * @param rm the render manager (not null) * @param vp the view port (not null) */ public void show(RenderManager rm, ViewPort vp) { if (!Vector3f.UNIT_X.equals(UNIT_X_CHECK) || !Vector3f.UNIT_Y.equals(UNIT_Y_CHECK) || !Vector3f.UNIT_Z.equals(UNIT_Z_CHECK) || !Vector3f.UNIT_XYZ.equals(UNIT_XYZ_CHECK) || !Vector3f.ZERO.equals(ZERO_CHECK)) { throw new IllegalStateException("Unit vectors compromised!" + "\nX: " + Vector3f.UNIT_X + "\nY: " + Vector3f.UNIT_Y + "\nZ: " + Vector3f.UNIT_Z + "\nXYZ: " + Vector3f.UNIT_XYZ + "\nZERO: " + Vector3f.ZERO); } debugNode.updateLogicalState(0); debugNode.updateGeometricState(); rm.renderScene(debugNode, vp); }
Example #15
Source File: TestNiftyToMesh.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void simpleInitApp() { ViewPort niftyView = renderManager.createPreView("NiftyView", new Camera(1024, 768)); niftyView.setClearFlags(true, true, true); NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(assetManager, inputManager, audioRenderer, niftyView); nifty = niftyDisplay.getNifty(); nifty.fromXml("all/intro.xml", "start"); niftyView.addProcessor(niftyDisplay); Texture2D depthTex = new Texture2D(1024, 768, Format.Depth); FrameBuffer fb = new FrameBuffer(1024, 768, 1); fb.setDepthTexture(depthTex); Texture2D tex = new Texture2D(1024, 768, Format.RGBA8); tex.setMinFilter(MinFilter.Trilinear); tex.setMagFilter(MagFilter.Bilinear); fb.setColorTexture(tex); niftyView.setClearFlags(true, true, true); niftyView.setOutputFrameBuffer(fb); Box b = new Box(1, 1, 1); Geometry geom = new Geometry("Box", b); Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat.setTexture("ColorMap", tex); geom.setMaterial(mat); rootNode.attachChild(geom); }
Example #16
Source File: GhostControl.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
public void render(RenderManager rm, ViewPort vp) { if (enabled && space != null && space.getDebugManager() != null) { if (debugShape == null) { attachDebugShape(space.getDebugManager()); } debugShape.setLocalTranslation(spatial.getWorldTranslation()); debugShape.setLocalRotation(spatial.getWorldRotation()); debugShape.updateLogicalState(0); debugShape.updateGeometricState(); rm.renderScene(debugShape, vp); } }
Example #17
Source File: OpenVRViewManager.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
private ViewPort setupViewBuffers(Camera cam, String viewName){ if (environment != null){ if (environment.getApplication() != null){ // create offscreen framebuffer FrameBuffer offBufferLeft = new FrameBuffer(cam.getWidth(), cam.getHeight(), 1); //offBufferLeft.setSrgb(true); //setup framebuffer's texture Texture2D offTex = new Texture2D(cam.getWidth(), cam.getHeight(), Image.Format.RGBA8); offTex.setMinFilter(Texture.MinFilter.BilinearNoMipMaps); offTex.setMagFilter(Texture.MagFilter.Bilinear); //setup framebuffer to use texture offBufferLeft.setDepthBuffer(Image.Format.Depth); offBufferLeft.setColorTexture(offTex); ViewPort viewPort = environment.getApplication().getRenderManager().createPreView(viewName, cam); viewPort.setClearFlags(true, true, true); viewPort.setBackgroundColor(ColorRGBA.Black); Iterator<Spatial> spatialIter = environment.getApplication().getViewPort().getScenes().iterator(); while(spatialIter.hasNext()){ viewPort.attachScene(spatialIter.next()); } //set viewport to render to offscreen framebuffer viewPort.setOutputFrameBuffer(offBufferLeft); return viewPort; } else { throw new IllegalStateException("This VR environment is not attached to any application."); } } else { throw new IllegalStateException("This VR view manager is not attached to any VR environment."); } }
Example #18
Source File: TestMultiRenderTarget.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override 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(); }
Example #19
Source File: VehicleControl.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
public void render(RenderManager rm, ViewPort vp) { if (enabled && space != null && space.getDebugManager() != null) { if (debugShape == null) { attachDebugShape(space.getDebugManager()); } Node debugNode = (Node) debugShape; debugShape.setLocalTranslation(spatial.getWorldTranslation()); debugShape.setLocalRotation(spatial.getWorldRotation()); int i = 0; for (Iterator<VehicleWheel> it = wheels.iterator(); it.hasNext();) { VehicleWheel physicsVehicleWheel = it.next(); Vector3f location = physicsVehicleWheel.getLocation().clone(); Vector3f direction = physicsVehicleWheel.getDirection().clone(); Vector3f axle = physicsVehicleWheel.getAxle().clone(); float restLength = physicsVehicleWheel.getRestLength(); float radius = physicsVehicleWheel.getRadius(); Geometry locGeom = (Geometry) debugNode.getChild("WheelLocationDebugShape" + i); Geometry dirGeom = (Geometry) debugNode.getChild("WheelDirectionDebugShape" + i); Geometry axleGeom = (Geometry) debugNode.getChild("WheelAxleDebugShape" + i); Geometry wheelGeom = (Geometry) debugNode.getChild("WheelRadiusDebugShape" + i); Arrow locArrow = (Arrow) locGeom.getMesh(); locArrow.setArrowExtent(location); Arrow axleArrow = (Arrow) axleGeom.getMesh(); axleArrow.setArrowExtent(axle.normalizeLocal().multLocal(0.3f)); Arrow wheelArrow = (Arrow) wheelGeom.getMesh(); wheelArrow.setArrowExtent(direction.normalizeLocal().multLocal(radius)); Arrow dirArrow = (Arrow) dirGeom.getMesh(); dirArrow.setArrowExtent(direction.normalizeLocal().multLocal(restLength)); dirGeom.setLocalTranslation(location); axleGeom.setLocalTranslation(location.addLocal(direction)); wheelGeom.setLocalTranslation(location); i++; } debugShape.updateLogicalState(0); debugShape.updateGeometricState(); rm.renderScene(debugShape, vp); } }
Example #20
Source File: ComposeFilter.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
@Override protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) { material = new Material(manager, "Common/MatDefs/Post/Compose.j3md"); }
Example #21
Source File: VideoRecorderAppState.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void reshape(ViewPort vp, int w, int h) { }
Example #22
Source File: SimpleWaterProcessor.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
public void reshape(ViewPort vp, int w, int h) { }
Example #23
Source File: SceneApplication.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
public ViewPort getOverlayView() { return overlayView; }
Example #24
Source File: ScenePreviewProcessor.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
public void initialize(RenderManager rm, ViewPort vp) { this.rm = rm; }
Example #25
Source File: ParticleEmitter.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void render(RenderManager rm, ViewPort vp) { parentEmitter.renderFromControl(rm, vp); }
Example #26
Source File: AwtPanel.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
private void reshapeInThread(int width, int height) { byteBuf = BufferUtils.ensureLargeEnough(byteBuf, width * height * 4); intBuf = byteBuf.asIntBuffer(); if (fb != null) { fb.dispose(); fb = null; } fb = new FrameBuffer(width, height, 1); fb.setDepthBuffer(Format.Depth); fb.setColorBuffer(Format.RGB8); fb.setSrgb(srgb); if (attachAsMain) { rm.getRenderer().setMainFrameBufferOverride(fb); } synchronized (lock) { img = new BufferedImage(width, height, BufferedImage.TYPE_INT_BGR); } // synchronized (lock){ // img = (BufferedImage) getGraphicsConfiguration().createCompatibleImage(width, height); // } AffineTransform tx = AffineTransform.getScaleInstance(1, -1); tx.translate(0, -img.getHeight()); transformOp = new AffineTransformOp(tx, AffineTransformOp.TYPE_NEAREST_NEIGHBOR); for (ViewPort vp : viewPorts) { if (!attachAsMain) { vp.setOutputFrameBuffer(fb); } vp.getCamera().resize(width, height, true); // NOTE: Hack alert. This is done ONLY for custom framebuffers. // Main framebuffer should use RenderManager.notifyReshape(). for (SceneProcessor sp : vp.getProcessors()) { sp.reshape(vp, width, height); } } }
Example #27
Source File: ScreenshotAppState.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void initialize(RenderManager rm, ViewPort vp) { renderer = rm.getRenderer(); this.rm = rm; reshape(vp, vp.getCamera().getWidth(), vp.getCamera().getHeight()); }
Example #28
Source File: NiftyJmeDisplay.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
@Override public void reshape(ViewPort vp, int w, int h) { this.w = w; this.h = h; nifty.resolutionChanged(); }
Example #29
Source File: AWTFrameProcessor.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void reshape(ViewPort vp, int w, int h) { // TODO Auto-generated method stub }
Example #30
Source File: FadeFilter.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) { material = new Material(manager, "Common/MatDefs/Post/Fade.j3md"); }