-/*
- * Copyright (c) 2009-2010 jMonkeyEngine
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * * Neither the name of 'jMonkeyEngine' nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package com.jme3.post;
-
-import com.jme3.asset.AssetManager;
-import com.jme3.export.InputCapsule;
-import com.jme3.export.JmeExporter;
-import com.jme3.export.JmeImporter;
-import com.jme3.export.OutputCapsule;
-import com.jme3.export.Savable;
-import com.jme3.material.Material;
-import com.jme3.renderer.Caps;
-import com.jme3.renderer.RenderManager;
-import com.jme3.renderer.Renderer;
-import com.jme3.renderer.ViewPort;
-import com.jme3.texture.FrameBuffer;
-import com.jme3.texture.Image.Format;
-import com.jme3.texture.Texture2D;
-import java.io.IOException;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * Filters are 2D effects applied to the rendered scene.<br>
- * The filter is fed with the rendered scene image rendered in an offscreen frame buffer.<br>
- * This texture is applied on a fullscreen quad, with a special material.<br>
- * This material uses a shader that aplly the desired effect to the scene texture.<br>
- * <br>
- * This class is abstract, any Filter must extend it.<br>
- * Any filter holds a frameBuffer and a texture<br>
- * The getMaterial must return a Material that use a GLSL shader immplementing the desired effect<br>
- *
- * @author Rémy Bouquet aka Nehon
- */
-public abstract class Filter implements Savable {
-
-
- private String name;
- protected Pass defaultPass;
- protected List<Pass> postRenderPasses;
- protected Material material;
- protected boolean enabled = true;
- protected FilterPostProcessor processor;
-
- public Filter(String name) {
- this.name = name;
- }
-
- /**
- * Inner class Pass
- * Pass are like filters in filters.
- * Some filters will need multiple passes before the final render
- */
- public class Pass {
-
- protected FrameBuffer renderFrameBuffer;
- protected Texture2D renderedTexture;
- protected Texture2D depthTexture;
- protected Material passMaterial;
-
- /**
- * init the pass called internally
- * @param renderer
- * @param width
- * @param height
- * @param textureFormat
- * @param depthBufferFormat
- * @param numSamples
- */
- public void init(Renderer renderer, int width, int height, Format textureFormat, Format depthBufferFormat, int numSamples, boolean renderDepth) {
- Collection<Caps> caps = renderer.getCaps();
- if (numSamples > 1 && caps.contains(Caps.FrameBufferMultisample) && caps.contains(Caps.OpenGL31)) {
- renderFrameBuffer = new FrameBuffer(width, height, numSamples);
- renderedTexture = new Texture2D(width, height, numSamples, textureFormat);
- if(renderDepth){
- depthTexture = new Texture2D(width, height, numSamples, depthBufferFormat);
- renderFrameBuffer.setDepthTexture(depthTexture);
- }
- } else {
- renderFrameBuffer = new FrameBuffer(width, height, 1);
- renderedTexture = new Texture2D(width, height, textureFormat);
- if(renderDepth){
- depthTexture = new Texture2D(width, height, depthBufferFormat);
- renderFrameBuffer.setDepthTexture(depthTexture);
- }
- }
-
- renderFrameBuffer.setColorTexture(renderedTexture);
- renderFrameBuffer.setDepthBuffer(depthBufferFormat);
-
- }
-
- /**
- * init the pass called internally
- * @param renderer
- * @param width
- * @param height
- * @param textureFormat
- * @param depthBufferFormat
- */
- public void init(Renderer renderer, int width, int height, Format textureFormat, Format depthBufferFormat) {
- init(renderer, width, height, textureFormat, depthBufferFormat, 1);
- }
-
- public void init(Renderer renderer, int width, int height, Format textureFormat, Format depthBufferFormat, int numSamples) {
- init(renderer, width, height, textureFormat, depthBufferFormat, numSamples, false);
- }
-
- /**
- * init the pass called internally
- * @param renderer
- * @param width
- * @param height
- * @param textureFormat
- * @param depthBufferFormat
- * @param numSample
- * @param material
- */
- public void init(Renderer renderer, int width, int height, Format textureFormat, Format depthBufferFormat, int numSample, Material material) {
- init(renderer, width, height, textureFormat, depthBufferFormat, numSample);
- passMaterial = material;
- }
-
- public boolean requiresSceneAsTexture() {
- return false;
- }
-
- public boolean requiresDepthAsTexture() {
- return false;
- }
-
- public void beforeRender() {
- }
-
- public FrameBuffer getRenderFrameBuffer() {
- return renderFrameBuffer;
- }
-
- public void setRenderFrameBuffer(FrameBuffer renderFrameBuffer) {
- this.renderFrameBuffer = renderFrameBuffer;
- }
-
- public Texture2D getDepthTexture() {
- return depthTexture;
- }
-
- public Texture2D getRenderedTexture() {
- return renderedTexture;
- }
-
- public void setRenderedTexture(Texture2D renderedTexture) {
- this.renderedTexture = renderedTexture;
- }
-
- public Material getPassMaterial() {
- return passMaterial;
- }
-
- public void setPassMaterial(Material passMaterial) {
- this.passMaterial = passMaterial;
- }
-
- public void cleanup(Renderer r) {
- }
- }
-
- /**
- * returns the default pass texture format
- * @return
- */
- protected Format getDefaultPassTextureFormat() {
- return Format.RGBA8;
- }
-
- /**
- * returns the default pass depth format
- * @return
- */
- protected Format getDefaultPassDepthFormat() {
- return Format.Depth;
- }
-
- /**
- * contruct a Filter
- */
- protected Filter() {
- this("filter");
- }
-
- /**
- *
- * initialize this filter
- * use InitFilter for overriding filter initialization
- * @param manager the assetManager
- * @param renderManager the renderManager
- * @param vp the viewport
- * @param w the width
- * @param h the height
- */
- protected final void init(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
- // cleanup(renderManager.getRenderer());
- defaultPass = new Pass();
- defaultPass.init(renderManager.getRenderer(), w, h, getDefaultPassTextureFormat(), getDefaultPassDepthFormat());
- initFilter(manager, renderManager, vp, w, h);
- }
-
- /**
- * cleanup this filter
- * @param r
- */
- protected final void cleanup(Renderer r) {
- processor = null;
- if (defaultPass != null) {
- defaultPass.cleanup(r);
- }
- if (postRenderPasses != null) {
- for (Iterator<Pass> it = postRenderPasses.iterator(); it.hasNext();) {
- Pass pass = it.next();
- pass.cleanup(r);
- }
- }
- cleanUpFilter(r);
- }
-
- /**
- * Initialization of sub classes filters
- * This method is called once when the filter is added to the FilterPostProcessor
- * It should contain Material initializations and extra passes initialization
- * @param manager the assetManager
- * @param renderManager the renderManager
- * @param vp the viewPort where this filter is rendered
- * @param w the width of the filter
- * @param h the height of the filter
- */
- protected abstract void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h);
-
- /**
- * override this method if you have some cleanup to do
- * @param r the renderer
- */
- protected void cleanUpFilter(Renderer r) {
- }
-
- ;
-
- /**
- * Must return the material used for this filter.
- * this method is called every frame.
- *
- * @return the material used for this filter.
- */
- protected abstract Material getMaterial();
-
- /**
- * Override this method if you want to make a pre pass, before the actual rendering of the frame
- * @param renderManager
- * @param viewPort
- */
- protected void postQueue(RenderManager renderManager, ViewPort viewPort) {
- }
-
- /**
- * Override this method if you want to modify parameters according to tpf before the rendering of the frame.
- * This is usefull for animated filters
- * Also it can be the place to render pre passes
- * @param tpf the time used to render the previous frame
- */
- protected void preFrame(float tpf) {
- }
-
- /**
- * Override this method if you want to make a pass just after the frame has been rendered and just before the filter rendering
- * @param renderManager
- * @param viewPort
- * @param prevFilterBuffer
- * @param sceneBuffer
- */
- protected void postFrame(RenderManager renderManager, ViewPort viewPort, FrameBuffer prevFilterBuffer, FrameBuffer sceneBuffer) {
- }
-
- /**
- * Override this method if you want to save extra properties when the filter is saved else only basic properties of the filter will be saved
- * This method should always begin by super.write(ex);
- * @param ex
- * @throws IOException
- */
- public void write(JmeExporter ex) throws IOException {
- OutputCapsule oc = ex.getCapsule(this);
- oc.write(name, "name", "");
- oc.write(enabled, "enabled", true);
- }
-
- /**
- * Override this method if you want to load extra properties when the filter
- * is loaded else only basic properties of the filter will be loaded
- * This method should always begin by super.read(im);
- */
- public void read(JmeImporter im) throws IOException {
- InputCapsule ic = im.getCapsule(this);
- name = ic.readString("name", "");
- enabled = ic.readBoolean("enabled", true);
- }
-
- /**
- * returns the name of the filter
- * @return
- */
- public String getName() {
- return name;
- }
-
- /**
- * Sets the name of the filter
- * @param name
- */
- public void setName(String name) {
- this.name = name;
- }
-
- /**
- * returns the default pass frame buffer
- * @return
- */
- protected FrameBuffer getRenderFrameBuffer() {
- return defaultPass.renderFrameBuffer;
- }
-
- /**
- * sets the default pas frame buffer
- * @param renderFrameBuffer
- */
- protected void setRenderFrameBuffer(FrameBuffer renderFrameBuffer) {
- this.defaultPass.renderFrameBuffer = renderFrameBuffer;
- }
-
- /**
- * returns the rendered texture of this filter
- * @return
- */
- protected Texture2D getRenderedTexture() {
- return defaultPass.renderedTexture;
- }
-
- /**
- * sets the rendered texture of this filter
- * @param renderedTexture
- */
- protected void setRenderedTexture(Texture2D renderedTexture) {
- this.defaultPass.renderedTexture = renderedTexture;
- }
-
- /**
- * Override this method and return true if your Filter needs the depth texture
- *
- * @return true if your Filter need the depth texture
- */
- protected boolean isRequiresDepthTexture() {
- return false;
- }
-
- /**
- * Override this method and return false if your Filter does not need the scene texture
- *
- * @return false if your Filter does not need the scene texture
- */
- protected boolean isRequiresSceneTexture() {
- return true;
- }
-
- /**
- * returns the list of the postRender passes
- * @return
- */
- protected List<Pass> getPostRenderPasses() {
- return postRenderPasses;
- }
-
- /**
- * Enable or disable this filter
- * @param enabled true to enable
- */
- public void setEnabled(boolean enabled) {
- if (processor != null) {
- processor.setFilterState(this, enabled);
- } else {
- this.enabled = enabled;
- }
- }
-
- /**
- * returns ttrue if the filter is enabled
- * @return enabled
- */
- public boolean isEnabled() {
- return enabled;
- }
-
- /**
- * sets a reference to the FilterPostProcessor ti which this filter is attached
- * @param proc
- */
- protected void setProcessor(FilterPostProcessor proc) {
- processor = proc;
- }
-}
+/*\r
+ * Copyright (c) 2009-2010 jMonkeyEngine\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are\r
+ * met:\r
+ *\r
+ * * Redistributions of source code must retain the above copyright\r
+ * notice, this list of conditions and the following disclaimer.\r
+ *\r
+ * * Redistributions in binary form must reproduce the above copyright\r
+ * notice, this list of conditions and the following disclaimer in the\r
+ * documentation and/or other materials provided with the distribution.\r
+ *\r
+ * * Neither the name of 'jMonkeyEngine' nor the names of its contributors\r
+ * may be used to endorse or promote products derived from this software\r
+ * without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED\r
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\r
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\r
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\r
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\r
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+package com.jme3.post;\r
+\r
+import com.jme3.asset.AssetManager;\r
+import com.jme3.export.InputCapsule;\r
+import com.jme3.export.JmeExporter;\r
+import com.jme3.export.JmeImporter;\r
+import com.jme3.export.OutputCapsule;\r
+import com.jme3.export.Savable;\r
+import com.jme3.material.Material;\r
+import com.jme3.renderer.Caps;\r
+import com.jme3.renderer.RenderManager;\r
+import com.jme3.renderer.Renderer;\r
+import com.jme3.renderer.ViewPort;\r
+import com.jme3.texture.FrameBuffer;\r
+import com.jme3.texture.Image.Format;\r
+import com.jme3.texture.Texture2D;\r
+import java.io.IOException;\r
+import java.util.Collection;\r
+import java.util.Iterator;\r
+import java.util.List;\r
+\r
+/**\r
+ * Filters are 2D effects applied to the rendered scene.<br>\r
+ * The filter is fed with the rendered scene image rendered in an offscreen frame buffer.<br>\r
+ * This texture is applied on a fullscreen quad, with a special material.<br>\r
+ * This material uses a shader that aplly the desired effect to the scene texture.<br>\r
+ * <br>\r
+ * This class is abstract, any Filter must extend it.<br>\r
+ * Any filter holds a frameBuffer and a texture<br>\r
+ * The getMaterial must return a Material that use a GLSL shader immplementing the desired effect<br>\r
+ *\r
+ * @author Rémy Bouquet aka Nehon\r
+ */\r
+public abstract class Filter implements Savable {\r
+\r
+\r
+ private String name;\r
+ protected Pass defaultPass;\r
+ protected List<Pass> postRenderPasses;\r
+ protected Material material;\r
+ protected boolean enabled = true;\r
+ protected FilterPostProcessor processor;\r
+\r
+ public Filter(String name) {\r
+ this.name = name;\r
+ }\r
+\r
+ /**\r
+ * Inner class Pass\r
+ * Pass are like filters in filters.\r
+ * Some filters will need multiple passes before the final render\r
+ */\r
+ public class Pass {\r
+\r
+ protected FrameBuffer renderFrameBuffer;\r
+ protected Texture2D renderedTexture;\r
+ protected Texture2D depthTexture;\r
+ protected Material passMaterial;\r
+\r
+ /**\r
+ * init the pass called internally\r
+ * @param renderer\r
+ * @param width\r
+ * @param height\r
+ * @param textureFormat\r
+ * @param depthBufferFormat\r
+ * @param numSamples\r
+ */\r
+ public void init(Renderer renderer, int width, int height, Format textureFormat, Format depthBufferFormat, int numSamples, boolean renderDepth) {\r
+ Collection<Caps> caps = renderer.getCaps();\r
+ if (numSamples > 1 && caps.contains(Caps.FrameBufferMultisample) && caps.contains(Caps.OpenGL31)) {\r
+ renderFrameBuffer = new FrameBuffer(width, height, numSamples);\r
+ renderedTexture = new Texture2D(width, height, numSamples, textureFormat);\r
+ renderFrameBuffer.setDepthBuffer(depthBufferFormat);\r
+ if (renderDepth) {\r
+ depthTexture = new Texture2D(width, height, numSamples, depthBufferFormat);\r
+ renderFrameBuffer.setDepthTexture(depthTexture);\r
+ }\r
+ } else {\r
+ renderFrameBuffer = new FrameBuffer(width, height, 1);\r
+ renderedTexture = new Texture2D(width, height, textureFormat);\r
+ renderFrameBuffer.setDepthBuffer(depthBufferFormat);\r
+ if (renderDepth) {\r
+ depthTexture = new Texture2D(width, height, depthBufferFormat);\r
+ renderFrameBuffer.setDepthTexture(depthTexture);\r
+ }\r
+ }\r
+\r
+ renderFrameBuffer.setColorTexture(renderedTexture);\r
+\r
+\r
+ }\r
+\r
+ /**\r
+ * init the pass called internally\r
+ * @param renderer\r
+ * @param width\r
+ * @param height\r
+ * @param textureFormat\r
+ * @param depthBufferFormat\r
+ */\r
+ public void init(Renderer renderer, int width, int height, Format textureFormat, Format depthBufferFormat) {\r
+ init(renderer, width, height, textureFormat, depthBufferFormat, 1);\r
+ }\r
+\r
+ public void init(Renderer renderer, int width, int height, Format textureFormat, Format depthBufferFormat, int numSamples) {\r
+ init(renderer, width, height, textureFormat, depthBufferFormat, numSamples, false);\r
+ }\r
+\r
+ /**\r
+ * init the pass called internally\r
+ * @param renderer\r
+ * @param width\r
+ * @param height\r
+ * @param textureFormat\r
+ * @param depthBufferFormat\r
+ * @param numSample\r
+ * @param material\r
+ */\r
+ public void init(Renderer renderer, int width, int height, Format textureFormat, Format depthBufferFormat, int numSample, Material material) {\r
+ init(renderer, width, height, textureFormat, depthBufferFormat, numSample);\r
+ passMaterial = material;\r
+ }\r
+\r
+ public boolean requiresSceneAsTexture() {\r
+ return false;\r
+ }\r
+\r
+ public boolean requiresDepthAsTexture() {\r
+ return false;\r
+ }\r
+\r
+ public void beforeRender() {\r
+ }\r
+\r
+ public FrameBuffer getRenderFrameBuffer() {\r
+ return renderFrameBuffer;\r
+ }\r
+\r
+ public void setRenderFrameBuffer(FrameBuffer renderFrameBuffer) {\r
+ this.renderFrameBuffer = renderFrameBuffer;\r
+ }\r
+\r
+ public Texture2D getDepthTexture() {\r
+ return depthTexture;\r
+ }\r
+\r
+ public Texture2D getRenderedTexture() {\r
+ return renderedTexture;\r
+ }\r
+\r
+ public void setRenderedTexture(Texture2D renderedTexture) {\r
+ this.renderedTexture = renderedTexture;\r
+ }\r
+\r
+ public Material getPassMaterial() {\r
+ return passMaterial;\r
+ }\r
+\r
+ public void setPassMaterial(Material passMaterial) {\r
+ this.passMaterial = passMaterial;\r
+ }\r
+\r
+ public void cleanup(Renderer r) {\r
+ }\r
+ }\r
+\r
+ /**\r
+ * returns the default pass texture format\r
+ * @return\r
+ */\r
+ protected Format getDefaultPassTextureFormat() {\r
+ return Format.RGBA8;\r
+ }\r
+\r
+ /**\r
+ * returns the default pass depth format\r
+ * @return\r
+ */\r
+ protected Format getDefaultPassDepthFormat() {\r
+ return Format.Depth;\r
+ }\r
+\r
+ /**\r
+ * contruct a Filter\r
+ */\r
+ protected Filter() {\r
+ this("filter");\r
+ }\r
+\r
+ /**\r
+ *\r
+ * initialize this filter\r
+ * use InitFilter for overriding filter initialization\r
+ * @param manager the assetManager\r
+ * @param renderManager the renderManager\r
+ * @param vp the viewport\r
+ * @param w the width\r
+ * @param h the height\r
+ */\r
+ protected final void init(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {\r
+ // cleanup(renderManager.getRenderer());\r
+ defaultPass = new Pass();\r
+ defaultPass.init(renderManager.getRenderer(), w, h, getDefaultPassTextureFormat(), getDefaultPassDepthFormat());\r
+ initFilter(manager, renderManager, vp, w, h);\r
+ }\r
+\r
+ /**\r
+ * cleanup this filter\r
+ * @param r\r
+ */\r
+ protected final void cleanup(Renderer r) {\r
+ processor = null;\r
+ if (defaultPass != null) {\r
+ defaultPass.cleanup(r);\r
+ }\r
+ if (postRenderPasses != null) {\r
+ for (Iterator<Pass> it = postRenderPasses.iterator(); it.hasNext();) {\r
+ Pass pass = it.next();\r
+ pass.cleanup(r);\r
+ }\r
+ }\r
+ cleanUpFilter(r);\r
+ }\r
+\r
+ /**\r
+ * Initialization of sub classes filters\r
+ * This method is called once when the filter is added to the FilterPostProcessor\r
+ * It should contain Material initializations and extra passes initialization\r
+ * @param manager the assetManager\r
+ * @param renderManager the renderManager\r
+ * @param vp the viewPort where this filter is rendered\r
+ * @param w the width of the filter\r
+ * @param h the height of the filter\r
+ */\r
+ protected abstract void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h);\r
+\r
+ /**\r
+ * override this method if you have some cleanup to do\r
+ * @param r the renderer\r
+ */\r
+ protected void cleanUpFilter(Renderer r) {\r
+ }\r
+\r
+ ;\r
+\r
+ /**\r
+ * Must return the material used for this filter.\r
+ * this method is called every frame.\r
+ *\r
+ * @return the material used for this filter.\r
+ */\r
+ protected abstract Material getMaterial();\r
+\r
+ /**\r
+ * Override this method if you want to make a pre pass, before the actual rendering of the frame\r
+ * @param renderManager\r
+ * @param viewPort\r
+ */\r
+ protected void postQueue(RenderManager renderManager, ViewPort viewPort) {\r
+ }\r
+\r
+ /**\r
+ * Override this method if you want to modify parameters according to tpf before the rendering of the frame.\r
+ * This is usefull for animated filters\r
+ * Also it can be the place to render pre passes\r
+ * @param tpf the time used to render the previous frame\r
+ */\r
+ protected void preFrame(float tpf) {\r
+ }\r
+\r
+ /**\r
+ * Override this method if you want to make a pass just after the frame has been rendered and just before the filter rendering\r
+ * @param renderManager\r
+ * @param viewPort\r
+ * @param prevFilterBuffer\r
+ * @param sceneBuffer\r
+ */\r
+ protected void postFrame(RenderManager renderManager, ViewPort viewPort, FrameBuffer prevFilterBuffer, FrameBuffer sceneBuffer) {\r
+ }\r
+\r
+ /**\r
+ * Override this method if you want to save extra properties when the filter is saved else only basic properties of the filter will be saved\r
+ * This method should always begin by super.write(ex);\r
+ * @param ex\r
+ * @throws IOException\r
+ */\r
+ public void write(JmeExporter ex) throws IOException {\r
+ OutputCapsule oc = ex.getCapsule(this);\r
+ oc.write(name, "name", "");\r
+ oc.write(enabled, "enabled", true);\r
+ }\r
+\r
+ /**\r
+ * Override this method if you want to load extra properties when the filter\r
+ * is loaded else only basic properties of the filter will be loaded\r
+ * This method should always begin by super.read(im);\r
+ */\r
+ public void read(JmeImporter im) throws IOException {\r
+ InputCapsule ic = im.getCapsule(this);\r
+ name = ic.readString("name", "");\r
+ enabled = ic.readBoolean("enabled", true);\r
+ }\r
+\r
+ /**\r
+ * returns the name of the filter\r
+ * @return\r
+ */\r
+ public String getName() {\r
+ return name;\r
+ }\r
+\r
+ /**\r
+ * Sets the name of the filter\r
+ * @param name\r
+ */\r
+ public void setName(String name) {\r
+ this.name = name;\r
+ }\r
+\r
+ /**\r
+ * returns the default pass frame buffer\r
+ * @return\r
+ */\r
+ protected FrameBuffer getRenderFrameBuffer() {\r
+ return defaultPass.renderFrameBuffer;\r
+ }\r
+\r
+ /**\r
+ * sets the default pas frame buffer\r
+ * @param renderFrameBuffer\r
+ */\r
+ protected void setRenderFrameBuffer(FrameBuffer renderFrameBuffer) {\r
+ this.defaultPass.renderFrameBuffer = renderFrameBuffer;\r
+ }\r
+\r
+ /**\r
+ * returns the rendered texture of this filter\r
+ * @return\r
+ */\r
+ protected Texture2D getRenderedTexture() {\r
+ return defaultPass.renderedTexture;\r
+ }\r
+\r
+ /**\r
+ * sets the rendered texture of this filter\r
+ * @param renderedTexture\r
+ */\r
+ protected void setRenderedTexture(Texture2D renderedTexture) {\r
+ this.defaultPass.renderedTexture = renderedTexture;\r
+ }\r
+\r
+ /**\r
+ * Override this method and return true if your Filter needs the depth texture\r
+ *\r
+ * @return true if your Filter need the depth texture\r
+ */\r
+ protected boolean isRequiresDepthTexture() {\r
+ return false;\r
+ }\r
+\r
+ /**\r
+ * Override this method and return false if your Filter does not need the scene texture\r
+ *\r
+ * @return false if your Filter does not need the scene texture\r
+ */\r
+ protected boolean isRequiresSceneTexture() {\r
+ return true;\r
+ }\r
+\r
+ /**\r
+ * returns the list of the postRender passes\r
+ * @return\r
+ */\r
+ protected List<Pass> getPostRenderPasses() {\r
+ return postRenderPasses;\r
+ }\r
+\r
+ /**\r
+ * Enable or disable this filter\r
+ * @param enabled true to enable\r
+ */\r
+ public void setEnabled(boolean enabled) {\r
+ if (processor != null) {\r
+ processor.setFilterState(this, enabled);\r
+ } else {\r
+ this.enabled = enabled;\r
+ }\r
+ }\r
+\r
+ /**\r
+ * returns ttrue if the filter is enabled\r
+ * @return enabled\r
+ */\r
+ public boolean isEnabled() {\r
+ return enabled;\r
+ }\r
+\r
+ /**\r
+ * sets a reference to the FilterPostProcessor ti which this filter is attached\r
+ * @param proc\r
+ */\r
+ protected void setProcessor(FilterPostProcessor proc) {\r
+ processor = proc;\r
+ }\r
+}\r