com.jme3.renderer.queue.RenderQueue Java Examples
The following examples show how to use
com.jme3.renderer.queue.RenderQueue.
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: DirectionalLightShadowRendererVR.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override protected GeometryList getOccludersToRender(int shadowMapIndex, GeometryList shadowMapOccluders) { // update frustum points based on current camera and split ShadowUtil.updateFrustumPoints(viewPort.getCamera(), splitsArray[shadowMapIndex], splitsArray[shadowMapIndex + 1], 1.0f, points); //Updating shadow cam with current split frusta if (lightReceivers.size()==0) { for (Spatial scene : viewPort.getScenes()) { ShadowUtil.getGeometriesInCamFrustum(scene, viewPort.getCamera(), RenderQueue.ShadowMode.Receive, lightReceivers); } } ShadowUtil.updateShadowCamera(viewPort, lightReceivers, shadowCam, points, shadowMapOccluders, stabilize?shadowMapSize:0); return shadowMapOccluders; }
Example #2
Source File: SimpleWaterProcessor.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void postQueue(RenderQueue rq) { Camera sceneCam = rm.getCurrentCamera(); //update refraction cam refractionCam.setLocation(sceneCam.getLocation()); refractionCam.setRotation(sceneCam.getRotation()); refractionCam.setFrustum(sceneCam.getFrustumNear(), sceneCam.getFrustumFar(), sceneCam.getFrustumLeft(), sceneCam.getFrustumRight(), sceneCam.getFrustumTop(), sceneCam.getFrustumBottom()); refractionCam.setParallelProjection(sceneCam.isParallelProjection()); //update reflection cam WaterUtils.updateReflectionCam(reflectionCam, plane, sceneCam); //Rendering reflection and refraction rm.renderViewPort(reflectionView, savedTpf); rm.renderViewPort(refractionView, savedTpf); rm.getRenderer().setFrameBuffer(vp.getOutputFrameBuffer()); rm.setCamera(sceneCam, false); }
Example #3
Source File: RenderManager.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
/** * If a spatial is not inside the eye frustum, it * is still rendered in the shadow frustum (shadow casting queue) * through this recursive method. */ private void renderShadow(Spatial s, RenderQueue rq) { if (s instanceof Node) { Node n = (Node) s; List<Spatial> children = n.getChildren(); for (int i = 0; i < children.size(); i++) { renderShadow(children.get(i), rq); } } else if (s instanceof Geometry) { Geometry gm = (Geometry) s; RenderQueue.ShadowMode shadowMode = s.getShadowMode(); if (shadowMode != RenderQueue.ShadowMode.Off && shadowMode != RenderQueue.ShadowMode.Receive) { //forcing adding to shadow cast mode, culled objects doesn't have to be in the receiver queue rq.addToShadowQueue(gm, RenderQueue.ShadowMode.Cast); } } }
Example #4
Source File: TestJaime.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void setupFloor() { Quad q = new Quad(20, 20); q.scaleTextureCoordinates(Vector2f.UNIT_XY.mult(10)); Geometry geom = new Geometry("floor", q); Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md"); mat.setColor("Diffuse", ColorRGBA.White); mat.setColor("Specular", ColorRGBA.White); mat.setColor("Ambient", ColorRGBA.Black); mat.setBoolean("UseMaterialColors", true); mat.setFloat("Shininess", 0); geom.setMaterial(mat); geom.rotate(-FastMath.HALF_PI, 0, 0); geom.center(); geom.setShadowMode(RenderQueue.ShadowMode.Receive); rootNode.attachChild(geom); }
Example #5
Source File: TestBlendEquations.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Adds a "transparent" quad to the scene, that shows an inverse blue value sight of the scene behind. */ private void createLeftQuad() { Material material = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); // This color creates a blue value image. The effect will have a strength of 80% (set by the alpha value). material.setColor("Color", new ColorRGBA(0f, 0f, 1f, 0.8f)); // Result.RGB = Source.A * Source.RGB - Source.A * Destination.RGB // Result.A = Destination.A material.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Custom); material.getAdditionalRenderState().setBlendEquation(RenderState.BlendEquation.Subtract); material.getAdditionalRenderState().setBlendEquationAlpha(RenderState.BlendEquationAlpha.Add); material.getAdditionalRenderState().setCustomBlendFactors( RenderState.BlendFunc.Src_Alpha, RenderState.BlendFunc.Src_Alpha, RenderState.BlendFunc.Zero, RenderState.BlendFunc.One); leftQuad = new Geometry("LeftQuad", new Quad(1f, 1f)); leftQuad.setMaterial(material); leftQuad.setQueueBucket(RenderQueue.Bucket.Transparent); rootNode.attachChild(leftQuad); }
Example #6
Source File: Spatial.java From jmonkeybuilder with Apache License 2.0 | 6 votes |
public void write(JmeExporter ex) throws IOException { OutputCapsule capsule = ex.getCapsule(this); capsule.write(name, "name", null); capsule.write(worldBound, "world_bound", null); capsule.write(cullHint, "cull_mode", CullHint.Inherit); capsule.write(batchHint, "batch_hint", BatchHint.Inherit); capsule.write(queueBucket, "queue", RenderQueue.Bucket.Inherit); capsule.write(shadowMode, "shadow_mode", ShadowMode.Inherit); capsule.write(localTransform, "transform", Transform.IDENTITY); capsule.write(localLights, "lights", null); capsule.writeSavableArrayList(new ArrayList(localOverrides), "overrides", null); // Shallow clone the controls array to convert its type. capsule.writeSavableArrayList(new ArrayList(controls), "controlsList", null); capsule.writeStringSavableMap(userData, "user_data", null); }
Example #7
Source File: ModelFileEditor.java From jmonkeybuilder with Apache License 2.0 | 6 votes |
@Override @FxThread public void notifyFxRemovedChild(@NotNull final Object parent, @NotNull final Object removed) { super.notifyFxRemovedChild(parent, removed); final ModelEditor3DPart editor3DState = getEditor3DPart(); if (removed instanceof Spatial) { final Spatial spatial = (Spatial) removed; final boolean isSky = spatial.getQueueBucket() == RenderQueue.Bucket.Sky; if (isSky) { editor3DState.removeCustomSky(spatial); editor3DState.updateLightProbe(); } } EXECUTOR_MANAGER.addFxTask(() -> getBulletState().notifyRemoved(removed)); }
Example #8
Source File: InstancedNode.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
private InstancedGeometry lookUpByGeometry(Geometry geom) { lookUp.mesh = geom.getMesh(); lookUp.material = geom.getMaterial(); lookUp.lodLevel = geom.getLodLevel(); InstancedGeometry ig = instancesMap.get(lookUp); if (ig == null) { ig = new InstancedGeometry( "mesh-" + System.identityHashCode(lookUp.mesh) + "," + "material-" + lookUp.material.getMaterialDef().getName() + "," + "lod-" + lookUp.lodLevel); ig.setMaterial(lookUp.material); ig.setMesh(lookUp.mesh); ig.setUserData(UserData.JME_PHYSICSIGNORE, true); ig.setCullHint(CullHint.Never); ig.setShadowMode(RenderQueue.ShadowMode.Inherit); instancesMap.put(lookUp.clone(), ig); attachChild(ig); } return ig; }
Example #9
Source File: ModelFileEditor.java From jmonkeybuilder with Apache License 2.0 | 6 votes |
@Override @FxThread protected void handleRemovedObject(@NotNull final Spatial model) { super.handleRemovedObject(model); final ModelEditor3DPart editor3DState = getEditor3DPart(); final Array<Geometry> geometries = ArrayFactory.newArray(Geometry.class); NodeUtils.addGeometry(model, geometries); if (!geometries.isEmpty()) { geometries.forEach(geometry -> { if (geometry.getQueueBucket() == RenderQueue.Bucket.Sky) { editor3DState.removeCustomSky(geometry); } }); } }
Example #10
Source File: ModelFileEditor.java From jmonkeybuilder with Apache License 2.0 | 6 votes |
@Override @FxThread protected void handleAddedObject(@NotNull final Spatial model) { super.handleAddedObject(model); final ModelEditor3DPart editor3DState = getEditor3DPart(); final Array<Geometry> geometries = ArrayFactory.newArray(Geometry.class); NodeUtils.addGeometry(model, geometries); if (!geometries.isEmpty()) { geometries.forEach(geometry -> { if (geometry.getQueueBucket() == RenderQueue.Bucket.Sky) { editor3DState.addCustomSky(geometry); } }); } }
Example #11
Source File: ShadowUtil.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Helper function used to recursively populate the outputGeometryList * with geometry children of scene node * * @param camera * @param scene * @param outputGeometryList */ private static void addGeometriesInCamFrustumFromNode(Camera camera, Node scene, RenderQueue.ShadowMode mode, GeometryList outputGeometryList) { if (scene.getCullHint() == Spatial.CullHint.Always) return; camera.setPlaneState(0); if (camera.contains(scene.getWorldBound()) != Camera.FrustumIntersect.Outside) { for (Spatial child: scene.getChildren()) { if (child instanceof Node) addGeometriesInCamFrustumFromNode(camera, (Node)child, mode, outputGeometryList); else if (child instanceof Geometry && child.getCullHint() != Spatial.CullHint.Always) { camera.setPlaneState(0); if (checkShadowMode(child.getShadowMode(), mode) && !((Geometry)child).isGrouped() && camera.contains(child.getWorldBound()) != Camera.FrustumIntersect.Outside) { outputGeometryList.add((Geometry)child); } } } } }
Example #12
Source File: DetailedProfiler.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void vpStep(VpStep step, ViewPort vp, RenderQueue.Bucket bucket) { if (data != null) { vpPath.setLength(0); vpPath.append(vp.getName()).append("/").append((bucket == null ? step.name() : bucket.name() + " Bucket")); path.setLength(0); if ((lastVpStep == VpStep.PostQueue || lastVpStep == VpStep.PostFrame) && bucket != null) { path.append(curAppPath).append("/").append(curVpPath).append(curSpPath).append("/").append(vpPath); curVpPath = vpPath.toString(); } else { if (bucket != null) { path.append(curAppPath).append("/").append(curVpPath).append("/").append(bucket.name() + " Bucket"); } else { path.append(curAppPath).append("/").append(vpPath); curVpPath = vpPath.toString(); } } lastVpStep = step; addStep(path.toString(), System.nanoTime()); } }
Example #13
Source File: AbstractShadowFilter.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override protected void postQueue(RenderQueue queue) { shadowRenderer.postQueue(queue); if(shadowRenderer.skipPostPass){ //removing the shadow map so that the post pass is skipped material.setTexture("ShadowMap0", null); } }
Example #14
Source File: ShadowUtil.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Helper function to recursively collect the geometries for getLitGeometriesInViewPort function. * * @param vpCamera the viewPort camera * @param cameras the camera array to check geometries against, representing the light viewspace * @param scene the Node to traverse or geometry to possibly add * @param outputGeometryList the output list of all geometries that are in the camera frustum */ private static void addGeometriesInCamFrustumAndViewPortFromNode(Camera vpCamera, Camera[] cameras, Spatial scene, RenderQueue.ShadowMode mode, GeometryList outputGeometryList) { if (scene.getCullHint() == Spatial.CullHint.Always) return; boolean inFrustum = false; for (int j = 0; j < cameras.length && inFrustum == false; j++) { Camera camera = cameras[j]; int planeState = camera.getPlaneState(); camera.setPlaneState(0); inFrustum = camera.contains(scene.getWorldBound()) != Camera.FrustumIntersect.Outside && scene.checkCulling(vpCamera); camera.setPlaneState(planeState); } if (inFrustum) { if (scene instanceof Node) { Node node = (Node)scene; for (Spatial child: node.getChildren()) { addGeometriesInCamFrustumAndViewPortFromNode(vpCamera, cameras, child, mode, outputGeometryList); } } else if (scene instanceof Geometry) { if (checkShadowMode(scene.getShadowMode(), mode) && !((Geometry)scene).isGrouped() ) { outputGeometryList.add((Geometry)scene); } } } }
Example #15
Source File: PointLightShadowRenderer.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override protected GeometryList getOccludersToRender(int shadowMapIndex, GeometryList shadowMapOccluders) { for (Spatial scene : viewPort.getScenes()) { ShadowUtil.getGeometriesInCamFrustum(scene, shadowCams[shadowMapIndex], RenderQueue.ShadowMode.Cast, shadowMapOccluders); } return shadowMapOccluders; }
Example #16
Source File: Spatial.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override @SuppressWarnings("unchecked") public void read(JmeImporter im) throws IOException { InputCapsule ic = im.getCapsule(this); name = ic.readString("name", null); worldBound = (BoundingVolume) ic.readSavable("world_bound", null); cullHint = ic.readEnum("cull_mode", CullHint.class, CullHint.Inherit); batchHint = ic.readEnum("batch_hint", BatchHint.class, BatchHint.Inherit); queueBucket = ic.readEnum("queue", RenderQueue.Bucket.class, RenderQueue.Bucket.Inherit); shadowMode = ic.readEnum("shadow_mode", ShadowMode.class, ShadowMode.Inherit); localTransform = (Transform) ic.readSavable("transform", Transform.IDENTITY); localLights = (LightList) ic.readSavable("lights", null); localLights.setOwner(this); ArrayList<MatParamOverride> localOverridesList = ic.readSavableArrayList("overrides", null); if (localOverridesList == null) { localOverrides = new SafeArrayList<>(MatParamOverride.class); } else { localOverrides = new SafeArrayList(MatParamOverride.class, localOverridesList); } worldOverrides = new SafeArrayList<>(MatParamOverride.class); //changed for backward compatibility with j3o files //generated before the AnimControl/SkeletonControl split //the AnimControl creates the SkeletonControl for old files and add it to the spatial. //The SkeletonControl must be the last in the stack //so we add the list of all other control before it. //When backward compatibility won't be needed anymore this can be replaced by : //controls = ic.readSavableArrayList("controlsList", null)); controls.addAll(0, ic.readSavableArrayList("controlsList", null)); userData = (HashMap<String, Savable>) ic.readStringSavableMap("user_data", null); }
Example #17
Source File: CartoonEdgeFilter.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
@Override protected void postQueue(RenderQueue queue) { Renderer r = renderManager.getRenderer(); r.setFrameBuffer(normalPass.getRenderFrameBuffer()); renderManager.getRenderer().clearBuffers(true, true, true); renderManager.setForcedTechnique("PreNormalPass"); renderManager.renderViewPortQueues(viewPort, false); renderManager.setForcedTechnique(null); renderManager.getRenderer().setFrameBuffer(viewPort.getOutputFrameBuffer()); }
Example #18
Source File: ReflectionProcessor.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
public void postQueue(RenderQueue rq) { //we need special treatement for the sky because it must not be clipped rm.getRenderer().setFrameBuffer(reflectionBuffer); reflectionCam.setProjectionMatrix(null); rm.setCamera(reflectionCam, false); rm.getRenderer().clearBuffers(true, true, true); //Rendering the sky whithout clipping rm.getRenderer().setDepthRange(1, 1); vp.getQueue().renderQueue(RenderQueue.Bucket.Sky, rm, reflectionCam, true); rm.getRenderer().setDepthRange(0, 1); //setting the clip plane to the cam reflectionCam.setClipPlane(reflectionClipPlane, Plane.Side.Positive);//,1 rm.setCamera(reflectionCam, false); }
Example #19
Source File: SpotLightShadowRenderer.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override protected GeometryList getOccludersToRender(int shadowMapIndex, GeometryList shadowMapOccluders) { for (Spatial scene : viewPort.getScenes()) { ShadowUtil.getGeometriesInCamFrustum(scene, shadowCam, RenderQueue.ShadowMode.Cast, shadowMapOccluders); } return shadowMapOccluders; }
Example #20
Source File: Spatial.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
/** * Returns this spatial's renderqueue bucket. If the mode is set to inherit, * then the spatial gets its renderqueue bucket from its parent. * * @return The spatial's current renderqueue mode. */ public RenderQueue.Bucket getQueueBucket() { if (queueBucket != RenderQueue.Bucket.Inherit) { return queueBucket; } else if (parent != null) { return parent.getQueueBucket(); } else { return RenderQueue.Bucket.Opaque; } }
Example #21
Source File: TestSkeletonControlRefresh.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void setupFloor() { Quad q = new Quad(20, 20); q.scaleTextureCoordinates(Vector2f.UNIT_XY.mult(10)); Geometry geom = new Geometry("floor", q); Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat.setColor("Color", ColorRGBA.White); geom.setMaterial(mat); geom.rotate(-FastMath.HALF_PI, 0, 0); geom.center(); geom.move(0, -0.3f, 0); geom.setShadowMode(RenderQueue.ShadowMode.Receive); rootNode.attachChild(geom); }
Example #22
Source File: CartoonEdgeFilter.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override protected void postQueue(RenderQueue queue) { Renderer r = renderManager.getRenderer(); r.setFrameBuffer(normalPass.getRenderFrameBuffer()); renderManager.getRenderer().clearBuffers(true, true, true); renderManager.setForcedTechnique("PreNormalPass"); renderManager.renderViewPortQueues(viewPort, false); renderManager.setForcedTechnique(null); renderManager.getRenderer().setFrameBuffer(viewPort.getOutputFrameBuffer()); }
Example #23
Source File: MapDrawer.java From OpenRTS with MIT License | 5 votes |
public MapDrawer(MapView view, AssetManager am) { this.view = view; groundTexture = new TerrainSplatTexture(ModelManager.getBattlefield().getMap().getAtlas(), am); coverTexture = new TerrainSplatTexture(ModelManager.getBattlefield().getMap().getCover(), am); coverTexture.transp = true; this.am = am; castAndReceiveNode.setShadowMode(RenderQueue.ShadowMode.CastAndReceive); receiveNode.setShadowMode(RenderQueue.ShadowMode.Receive); mainNode.attachChild(castAndReceiveNode); mainNode.attachChild(receiveNode); EventManager.register(this); }
Example #24
Source File: NiftyJmeDisplay.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void postQueue(RenderQueue rq) { // render nifty before anything else renderManager.setCamera(vp.getCamera(), true); nifty.render(false); renderManager.setCamera(vp.getCamera(), false); }
Example #25
Source File: PreDepthProcessor.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
public void postQueue(RenderQueue rq) { // lay depth first rm.setForcedMaterial(preDepth); rq.renderQueue(RenderQueue.Bucket.Opaque, rm, vp.getCamera(), false); rm.setForcedMaterial(null); rm.setForcedRenderState(forcedRS); }
Example #26
Source File: SSAOFilter.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override protected void postQueue(RenderQueue queue) { if(!approximateNormals) { Renderer r = renderManager.getRenderer(); r.setFrameBuffer(normalPass.getRenderFrameBuffer()); renderManager.getRenderer().clearBuffers(true, true, true); renderManager.setForcedTechnique("PreNormalPass"); renderManager.renderViewPortQueues(viewPort, false); renderManager.setForcedTechnique(null); renderManager.getRenderer().setFrameBuffer(viewPort.getOutputFrameBuffer()); } }
Example #27
Source File: TranslucentBucketFilter.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
private void makeSoftParticleEmitter(Spatial scene, boolean enabled) { if (scene instanceof Node) { Node n = (Node) scene; for (Spatial child : n.getChildren()) { makeSoftParticleEmitter(child, enabled); } } if (scene instanceof ParticleEmitter) { ParticleEmitter emitter = (ParticleEmitter) scene; if (enabled) { enabledSoftParticles = enabled; if( processor.getNumSamples()>1){ emitter.getMaterial().selectTechnique("SoftParticles15", renderManager); emitter.getMaterial().setInt("NumSamplesDepth", processor.getNumSamples()); }else{ emitter.getMaterial().selectTechnique("SoftParticles", renderManager); } emitter.getMaterial().setTexture("DepthTexture", processor.getDepthTexture()); emitter.setQueueBucket(RenderQueue.Bucket.Translucent); logger.log(Level.FINE, "Made particle Emitter {0} soft.", emitter.getName()); } else { emitter.getMaterial().clearParam("DepthTexture"); emitter.getMaterial().selectTechnique("Default", renderManager); // emitter.setQueueBucket(RenderQueue.Bucket.Transparent); logger.log(Level.FINE, "Particle Emitter {0} is not soft anymore.", emitter.getName()); } } }
Example #28
Source File: AbstractShadowRendererVR.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@SuppressWarnings("fallthrough") @Override public void postQueue(RenderQueue rq) { lightReceivers.clear(); skipPostPass = false; if ( !checkCulling(viewPort.getCamera()) ) { skipPostPass = true; return; } updateShadowCams(viewPort.getCamera()); Renderer r = renderManager.getRenderer(); renderManager.setForcedMaterial(preshadowMat); renderManager.setForcedTechnique("PreShadow"); for (int shadowMapIndex = 0; shadowMapIndex < nbShadowMaps; shadowMapIndex++) { if (debugfrustums) { doDisplayFrustumDebug(shadowMapIndex); } renderShadowMap(shadowMapIndex); } debugfrustums = false; //restore setting for future rendering r.setFrameBuffer(viewPort.getOutputFrameBuffer()); renderManager.setForcedMaterial(null); renderManager.setForcedTechnique(null); renderManager.setCamera(viewPort.getCamera(), false); }
Example #29
Source File: BaseMaterialFileEditor.java From jmonkeybuilder with Apache License 2.0 | 5 votes |
/** * Handle changing the bucket type. */ @FxThread private void changeBucketType(@NotNull final RenderQueue.Bucket newValue) { final T editor3DState = getEditor3DPart(); editor3DState.changeBucketType(newValue); final EditorMaterialEditorState editorState = getEditorState(); if (editorState != null) editorState.setBucketType(newValue); }
Example #30
Source File: Spatial.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
/** * @return The shadow mode of this spatial, if the local shadow * mode is set to inherit, then the parent's shadow mode is returned. * * @see Spatial#setShadowMode(com.jme3.renderer.queue.RenderQueue.ShadowMode) * @see ShadowMode */ public RenderQueue.ShadowMode getShadowMode() { if (shadowMode != RenderQueue.ShadowMode.Inherit) { return shadowMode; } else if (parent != null) { return parent.getShadowMode(); } else { return ShadowMode.Off; } }