com.jme3.renderer.RenderManager Java Examples
The following examples show how to use
com.jme3.renderer.RenderManager.
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: RenderQueue.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
private void renderGeometryList(GeometryList list, RenderManager rm, Camera cam, boolean clear) { list.setCamera(cam); // select camera for sorting list.sort(); for (int i = 0; i < list.size(); i++) { Spatial obj = list.get(i); assert obj != null; if (obj instanceof Geometry) { Geometry g = (Geometry) obj; rm.renderGeometry(g); // make sure to reset queue distance } if (obj != null) { obj.queueDistance = Float.NEGATIVE_INFINITY; } } if (clear) { list.clear(); } }
Example #2
Source File: LegacyApplication.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * 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); }
Example #3
Source File: RenderQueue.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
public void renderQueue(Bucket bucket, RenderManager rm, Camera cam, boolean clear) { switch (bucket) { case Gui: renderGeometryList(guiList, rm, cam, clear); break; case Opaque: renderGeometryList(opaqueList, rm, cam, clear); break; case Sky: renderGeometryList(skyList, rm, cam, clear); break; case Transparent: renderGeometryList(transparentList, rm, cam, clear); break; case Translucent: renderGeometryList(translucentList, rm, cam, clear); break; default: throw new UnsupportedOperationException("Unsupported bucket type: " + bucket); } }
Example #4
Source File: ParticleEmitter.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" 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 #5
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 #6
Source File: VRApplication.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * 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); }
Example #7
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 #8
Source File: Material.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Preloads this material for the given render manager. * <p> * Preloading the material can ensure that when the material is first * used for rendering, there won't be any delay since the material has * been already been setup for rendering. * * @param renderManager The render manager to preload for */ public void preload(RenderManager renderManager, Geometry geometry) { if (technique == null) { selectTechnique(TechniqueDef.DEFAULT_TECHNIQUE_NAME, renderManager); } TechniqueDef techniqueDef = technique.getDef(); Renderer renderer = renderManager.getRenderer(); EnumSet<Caps> rendererCaps = renderer.getCaps(); if (techniqueDef.isNoRender()) { return; } // Get world overrides SafeArrayList<MatParamOverride> overrides = geometry.getWorldMatParamOverrides(); Shader shader = technique.makeCurrent(renderManager, overrides, null, null, rendererCaps); updateShaderMaterialParameters(renderer, shader, overrides, null); renderManager.getRenderer().setShader(shader); }
Example #9
Source File: RenderQueue.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void renderQueue(Bucket bucket, RenderManager rm, Camera cam, boolean clear) { switch (bucket) { case Gui: renderGeometryList(guiList, rm, cam, clear); break; case Opaque: renderGeometryList(opaqueList, rm, cam, clear); break; case Sky: renderGeometryList(skyList, rm, cam, clear); break; case Transparent: renderGeometryList(transparentList, rm, cam, clear); break; case Translucent: renderGeometryList(translucentList, rm, cam, clear); break; default: throw new UnsupportedOperationException("Unsupported bucket type: " + bucket); } }
Example #10
Source File: PreNormalCaching.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Get pre-normals from the given rendering. * @param renderManager the render manager. * @param normalPass the normal pass. * @param viewPort the viewport. */ public static void getPreNormals(RenderManager renderManager, Pass normalPass, ViewPort viewPort) { curCount++; // do we already have a valid cache to set the framebuffer to? Renderer r = renderManager.getRenderer(); if( cachedPreNormals != null ) { r.copyFrameBuffer(cachedPreNormals, normalPass.getRenderFrameBuffer(), false); } else { // lets make the prenormals r.setFrameBuffer(normalPass.getRenderFrameBuffer()); renderManager.getRenderer().clearBuffers(true, true, true); if( renderManager.getRenderer().getCaps().contains(Caps.GLSL150) ) { renderManager.setForcedTechnique("PreNormalPass15"); } else { renderManager.setForcedTechnique("PreNormalPass"); } renderManager.renderViewPortQueues(viewPort, false); renderManager.setForcedTechnique(null); // if we should cache this, do it now if( lastNormalPassesCount > 1 ) { cachedPreNormals = normalPass.getRenderFrameBuffer(); } } renderManager.getRenderer().setFrameBuffer(viewPort.getOutputFrameBuffer()); }
Example #11
Source File: SkeletonControl.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
private boolean testHardwareSupported(RenderManager rm) { for (Material m : materials) { // Some of the animated mesh(es) do not support hardware skinning, // so it is not supported by the model. if (m.getMaterialDef().getMaterialParam("NumberOfBones") == null) { Logger.getLogger(SkeletonControl.class.getName()).log(Level.WARNING, "Not using hardware skinning for {0}, " + "because material {1} doesn''t support it.", new Object[]{spatial, m.getMaterialDef().getName()}); return false; } } switchToHardware(); try { rm.preloadScene(spatial); return true; } catch (RendererException e) { Logger.getLogger(SkeletonControl.class.getName()).log(Level.WARNING, "Could not enable HW skinning due to shader compile error:", e); return false; } }
Example #12
Source File: BulletDebugAppState.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Render this state. Should be invoked only by a subclass or by the * AppStateManager. Invoked once per frame, provided the state is attached * and enabled. * * @param rm the render manager (not null) */ @Override public void render(RenderManager rm) { super.render(rm); if (viewPort != null) { rm.renderScene(physicsDebugRootNode, viewPort); } }
Example #13
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 #14
Source File: SkeletonControl.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
@Override protected void controlRender(RenderManager rm, ViewPort vp) { if (!wasMeshUpdated) { updateTargetsAndMaterials(spatial); // Prevent illegal cases. These should never happen. assert hwSkinningTested || (!hwSkinningTested && !hwSkinningSupported && !hwSkinningEnabled); assert !hwSkinningEnabled || (hwSkinningEnabled && hwSkinningTested && hwSkinningSupported); if (hwSkinningDesired && !hwSkinningTested) { hwSkinningTested = true; hwSkinningSupported = testHardwareSupported(rm); if (hwSkinningSupported) { hwSkinningEnabled = true; Logger.getLogger(SkeletonControl.class.getName()).log(Level.INFO, "Hardware skinning engaged for " + spatial); } else { switchToSoftware(); } } else if (hwSkinningDesired && hwSkinningSupported && !hwSkinningEnabled) { switchToHardware(); hwSkinningEnabled = true; } else if (!hwSkinningDesired && hwSkinningEnabled) { switchToSoftware(); hwSkinningEnabled = false; } if (hwSkinningEnabled) { controlRenderHardware(); } else { controlRenderSoftware(); } wasMeshUpdated = true; } }
Example #15
Source File: BulletAppState.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Render this state. Should be invoked only by a subclass or by the * AppStateManager. Invoked once per frame, provided the state is attached * and enabled. * * @param rm the render manager (not null) */ @Override public void render(RenderManager rm) { super.render(rm); if (!active) { return; } if (threadingType == ThreadingType.PARALLEL) { physicsFuture = executor.submit(parallelPhysicsUpdate); } else if (threadingType == ThreadingType.SEQUENTIAL) { pSpace.update(active ? tpf * speed : 0); } else { } }
Example #16
Source File: DepthOfFieldFilter.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
@Override protected void initFilter(AssetManager assets, RenderManager renderManager, ViewPort vp, int w, int h) { material = new Material(assets, "Common/MatDefs/Post/DepthOfField.j3md"); material.setFloat("FocusDistance", focusDistance); material.setFloat("FocusRange", focusRange); xScale = 1.0f / w; yScale = 1.0f / h; material.setFloat("XScale", blurScale * xScale); material.setFloat("YScale", blurScale * yScale); }
Example #17
Source File: LodControl.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override protected void controlRender(RenderManager rm, ViewPort vp) { BoundingVolume bv = spatial.getWorldBound(); Camera cam = vp.getCamera(); float atanNH = FastMath.atan(cam.getFrustumNear() * cam.getFrustumTop()); float ratio = (FastMath.PI / (8f * atanNH)); float newDistance = bv.distanceTo(vp.getCamera().getLocation()) / ratio; int level; if (Math.abs(newDistance - lastDistance) <= distTolerance) { level = lastLevel; // we haven't moved relative to the model, send the old measurement back. } else if (lastDistance > newDistance && lastLevel == 0) { level = lastLevel; // we're already at the lowest setting and we just got closer to the model, no need to keep trying. } else if (lastDistance < newDistance && lastLevel == numLevels - 1) { level = lastLevel; // we're already at the highest setting and we just got further from the model, no need to keep trying. } else { lastDistance = newDistance; // estimate area of polygon via bounding volume float area = AreaUtils.calcScreenArea(bv, lastDistance, cam.getWidth()); float trisToDraw = area * trisPerPixel; level = numLevels - 1; for (int i = numLevels; --i >= 0;) { if (trisToDraw - numTris[i] < 0) { break; } level = i; } lastLevel = level; } spatial.setLodLevel(level); }
Example #18
Source File: Material.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void updateRenderState(RenderManager renderManager, Renderer renderer, TechniqueDef techniqueDef) { if (renderManager.getForcedRenderState() != null) { renderer.applyRenderState(renderManager.getForcedRenderState()); } else { if (techniqueDef.getRenderState() != null) { renderer.applyRenderState(techniqueDef.getRenderState().copyMergedTo(additionalState, mergedRenderState)); } else { renderer.applyRenderState(RenderState.DEFAULT.copyMergedTo(additionalState, mergedRenderState)); } } }
Example #19
Source File: VideoRecorderAppState.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override 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)); } } }
Example #20
Source File: CartoonEdgeFilter.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) { this.renderManager = renderManager; this.viewPort = vp; normalPass = new Pass(); normalPass.init(renderManager.getRenderer(), w, h, Format.RGBA8, Format.Depth); material = new Material(manager, "Common/MatDefs/Post/CartoonEdge.j3md"); material.setFloat("EdgeWidth", edgeWidth); material.setFloat("EdgeIntensity", edgeIntensity); material.setFloat("NormalThreshold", normalThreshold); material.setFloat("DepthThreshold", depthThreshold); material.setFloat("NormalSensitivity", normalSensitivity); material.setFloat("DepthSensitivity", depthSensitivity); material.setColor("EdgeColor", edgeColor); }
Example #21
Source File: Material.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
private void autoSelectTechnique(RenderManager rm) { if (technique == null) { // NOTE: Not really needed anymore since we have technique // selection by caps. Rename all "FixedFunc" techniques to "Default" // and remove this hack. if (!rm.getRenderer().getCaps().contains(Caps.GLSL100)) { selectTechnique("FixedFunc", rm); } else { selectTechnique("Default", rm); } } else if (technique.isNeedReload()) { technique.makeCurrent(def.getAssetManager(), paramValues); } }
Example #22
Source File: AbstractShadowRendererVR.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Initialize this shadow renderer prior to its first update. * * @param rm the render manager * @param vp the viewport */ @Override public void initialize(RenderManager rm, ViewPort vp) { renderManager = rm; viewPort = vp; postTechniqueName = "PostShadow"; if(zFarOverride>0 && frustumCam == null){ initFrustumCam(); } }
Example #23
Source File: StaticPassLightingLogic.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public Shader makeCurrent(AssetManager assetManager, RenderManager renderManager, EnumSet<Caps> rendererCaps, LightList lights, DefineList defines) { // TODO: if it ever changes that render isn't called // right away with the same geometry after makeCurrent, it would be // a problem. // Do a radix sort. tempDirLights.clear(); tempPointLights.clear(); tempSpotLights.clear(); for (Light light : lights) { switch (light.getType()) { case Directional: tempDirLights.add((DirectionalLight) light); break; case Point: tempPointLights.add((PointLight) light); break; case Spot: tempSpotLights.add((SpotLight) light); break; } } defines.set(numDirLightsDefineId, tempDirLights.size()); defines.set(numPointLightsDefineId, tempPointLights.size()); defines.set(numSpotLightsDefineId, tempSpotLights.size()); return techniqueDef.getShader(assetManager, rendererCaps, defines); }
Example #24
Source File: AppStateManager.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
/** * Calls render for all attached and initialized states, do not call directly. * @param rm The RenderManager */ public void render(RenderManager rm){ AppState[] array = getStates(); for (AppState state : array){ if (state.isEnabled()) { state.render(rm); } } }
Example #25
Source File: FXAAFilter.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) { 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 #26
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 #27
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 #28
Source File: CartoonEdgeFilter.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; normalPass = new Pass(); normalPass.init(renderManager.getRenderer(), w, h, Format.RGBA8, Format.Depth); material = new Material(manager, "Common/MatDefs/Post/CartoonEdge.j3md"); material.setFloat("EdgeWidth", edgeWidth); material.setFloat("EdgeIntensity", edgeIntensity); material.setFloat("NormalThreshold", normalThreshold); material.setFloat("DepthThreshold", depthThreshold); material.setFloat("NormalSensitivity", normalSensitivity); material.setFloat("DepthSensitivity", depthSensitivity); material.setColor("EdgeColor", edgeColor); }
Example #29
Source File: AWTFrameProcessor.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Bind this processor. * * @param destination the destination. * @param application the application. */ public void bind(Component destination, Application application) { final RenderManager renderManager = application.getRenderManager(); if (renderManager == null) { throw new RuntimeException("No render manager available from the application."); } List<ViewPort> postViews = renderManager.getPostViews(); if (postViews.isEmpty()) { throw new RuntimeException("the list of a post view is empty."); } bind(destination, application, postViews.get(postViews.size() - 1), true); }
Example #30
Source File: BulletAppState.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
public void render(RenderManager rm) { if (!active) { return; } if (threadingType == ThreadingType.PARALLEL) { physicsFuture = executor.submit(parallelPhysicsUpdate); } else if (threadingType == ThreadingType.SEQUENTIAL) { pSpace.update(active ? tpf * speed : 0); } else { } }