OSDN Git Service

Who let the doc out?
authorremy.bouquet@gmail.com <remy.bouquet@gmail.com@75d07b2b-3a1a-0410-a2c5-0572b91ccdca>
Mon, 13 Jun 2011 21:26:11 +0000 (21:26 +0000)
committerremy.bouquet@gmail.com <remy.bouquet@gmail.com@75d07b2b-3a1a-0410-a2c5-0572b91ccdca>
Mon, 13 Jun 2011 21:26:11 +0000 (21:26 +0000)
- javadoc for com.jme.post
- javadoc for com.jme.post.filters
remain SSAO, Water, shadows and HDR to complete the package

git-svn-id: http://jmonkeyengine.googlecode.com/svn/trunk@7618 75d07b2b-3a1a-0410-a2c5-0572b91ccdca

16 files changed:
engine/src/core/com/jme3/post/Filter.java
engine/src/core/com/jme3/post/FilterPostProcessor.java
engine/src/core/com/jme3/post/SceneProcessor.java
engine/src/desktop-fx/com/jme3/post/filters/BloomFilter.java
engine/src/desktop-fx/com/jme3/post/filters/CartoonEdgeFilter.java
engine/src/desktop-fx/com/jme3/post/filters/ColorOverlayFilter.java
engine/src/desktop-fx/com/jme3/post/filters/CrossHatchFilter.java
engine/src/desktop-fx/com/jme3/post/filters/DepthOfFieldFilter.java
engine/src/desktop-fx/com/jme3/post/filters/FadeFilter.java
engine/src/desktop-fx/com/jme3/post/filters/FogFilter.java
engine/src/desktop-fx/com/jme3/post/filters/LightScatteringFilter.java
engine/src/desktop-fx/com/jme3/post/filters/PosterizationFilter.java
engine/src/desktop-fx/com/jme3/post/filters/RadialBlurFilter.java
engine/src/desktop-fx/com/jme3/post/filters/TranslucentBucketFilter.java
engine/src/desktop-fx/com/jme3/post/ssao/SSAOFilter.java
engine/src/desktop-fx/com/jme3/water/WaterFilter.java

index 93e65b2..0c00c8f 100644 (file)
@@ -51,10 +51,16 @@ import java.util.Iterator;
 import java.util.List;
 
 /**
- * Filter abstract class
- * Any Filter must extends this class
- * Holds a frameBuffer and a texture
- * The getMaterial must return a Material that use a GLSL shader immplementing the desired effect
+ * 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 {
 
@@ -69,6 +75,11 @@ public abstract class Filter implements Savable {
         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;
@@ -76,28 +87,52 @@ public abstract class Filter implements Savable {
         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) {
             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);             
-                //  depthTexture = new Texture2D(width, height, numSamples, depthBufferFormat);
+                renderedTexture = new Texture2D(width, height, numSamples, textureFormat);
             } else {
                 renderFrameBuffer = new FrameBuffer(width, height, 1);
                 renderedTexture = new Texture2D(width, height, textureFormat);
-               //                depthTexture = new Texture2D(width, height,  depthBufferFormat);
             }
 
             renderFrameBuffer.setColorTexture(renderedTexture);
             renderFrameBuffer.setDepthBuffer(depthBufferFormat);
-            //          renderFrameBuffer.setDepthTexture(depthTexture);
 
         }
 
+        /**
+         *  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);
         }
 
+        /**
+         *  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;
@@ -146,26 +181,51 @@ public abstract class Filter implements Savable {
         }
     }
 
+    /**
+     * 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;
     }
 
-    public Filter() {
+    /**
+     * contruct a Filter 
+     */
+    protected Filter() {
         this("filter");
     }
 
-    public void init(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
+    /**
+     * 
+     * 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);
     }
 
-    public void cleanup(Renderer r) {
+    /**
+     * cleanup this filter
+     * @param r 
+     */
+    protected final void cleanup(Renderer r) {
         processor = null;
         if (defaultPass != null) {
             defaultPass.cleanup(r);
@@ -180,36 +240,49 @@ public abstract class Filter implements Savable {
     }
 
     /**
-     * This method is called once xhen the filter is added to the FilterPostProcessor
-     * It should contain Maerial initializations and extra passes initialization
-     * @param manager
+     * 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
      */
-    public abstract void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h);
+    protected void cleanUpFilter(Renderer r) {
+    }
 
-    public abstract void cleanUpFilter(Renderer r);
+    ;
 
     /**
-     * Returns the material used for this filter.
+     * Must return the material used for this filter.
      * this method is called every frame.
      * 
      * @return the material used for this filter.
      */
-    public abstract Material getMaterial();
+    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
      */
-    public void postQueue(RenderManager renderManager, ViewPort viewPort) {
+    protected void postQueue(RenderManager renderManager, ViewPort viewPort) {
     }
 
     /**
-     * Use this method if you want to modify parameters according to tpf before the rendering of the frame.
+     * 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
      */
-    public void preFrame(float tpf) {
+    protected void preFrame(float tpf) {
     }
 
     /**
@@ -217,7 +290,7 @@ public abstract class Filter implements Savable {
      * @param renderManager
      * @param viewPort
      */
-    public void postFrame(RenderManager renderManager, ViewPort viewPort, FrameBuffer prevFilterBuffer, FrameBuffer sceneBuffer) {
+    protected void postFrame(RenderManager renderManager, ViewPort viewPort, FrameBuffer prevFilterBuffer, FrameBuffer sceneBuffer) {
     }
 
     /**
@@ -243,56 +316,84 @@ public abstract class Filter implements Savable {
         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;
     }
 
-    public FrameBuffer getRenderFrameBuffer() {
+    /**
+     * returns the default pass frame buffer
+     * @return 
+     */
+    protected FrameBuffer getRenderFrameBuffer() {
         return defaultPass.renderFrameBuffer;
     }
 
-    public void setRenderFrameBuffer(FrameBuffer renderFrameBuffer) {
+    /**
+     * sets the default pas frame buffer
+     * @param renderFrameBuffer 
+     */
+    protected void setRenderFrameBuffer(FrameBuffer renderFrameBuffer) {
         this.defaultPass.renderFrameBuffer = renderFrameBuffer;
     }
 
-    public Texture2D getRenderedTexture() {
+    /**
+     * returns the rendered texture of this filter
+     * @return 
+     */
+    protected Texture2D getRenderedTexture() {
         return defaultPass.renderedTexture;
     }
 
-    public void setRenderedTexture(Texture2D 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 need the depth texture
+     * Override this method and return true if your Filter needs the depth texture
      * 
      * @return true if your Filter need the depth texture
      */
-    public boolean isRequiresDepthTexture() {
+    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
      */
-    public boolean isRequiresSceneTexture() {
+    protected boolean isRequiresSceneTexture() {
         return true;
     }
 
-    public List<Pass> getPostRenderPasses() {
+    /**
+     * returns the list of the postRender passes
+     * @return 
+     */
+    protected List<Pass> getPostRenderPasses() {
         return postRenderPasses;
     }
 
-    public void setPostRenderPasses(List<Pass> postRenderPasses) {
-        this.postRenderPasses = postRenderPasses;
-    }
-
+    /**
+     * Enable or disable this filter
+     * @param enabled true to enable
+     */
     public void setEnabled(boolean enabled) {
         if (processor != null) {
             processor.setFilterState(this, enabled);
@@ -301,10 +402,18 @@ public abstract class Filter implements Savable {
         }
     }
 
+    /**
+     * 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;
     }
index cb2b50f..b35c00a 100644 (file)
@@ -55,6 +55,11 @@ import java.util.Collection;
 import java.util.Iterator;\r
 import java.util.List;\r
 \r
+/**\r
+ * A FilterPostProcessor is a processor that can apply several {@link Filter}s to a rendered scene<br>\r
+ * It manages a list of filters that will be applied in the order in which they've been added to the list\r
+ * @author Rémy Bouquet aka Nehon\r
+ */\r
 public class FilterPostProcessor implements SceneProcessor, Savable {\r
 \r
     private RenderManager renderManager;\r
@@ -81,25 +86,26 @@ public class FilterPostProcessor implements SceneProcessor, Savable {
     private int originalHeight;\r
     private int lastFilterIndex = -1;\r
     private boolean cameraInit = false;\r
-//    private boolean handleTranslucentBucket = false;\r
-//    private FrameBuffer transFrameBuffer;\r
-//    private Material transMaterial;\r
-//    private boolean isTransparencyRendered=false;\r
 \r
     /**\r
-     * Create a FilterProcessor constructor\r
-     * @param assetManager the Asset Manager\r
+     * Create a FilterProcessor \r
+     * @param assetManager the assetManager\r
      */\r
     public FilterPostProcessor(AssetManager assetManager) {\r
         this.assetManager = assetManager;\r
     }\r
 \r
     /**\r
-     * Don't use this constructor use FilterPostProcessor(AssetManager assetManager)\r
+     * Don't use this constructor use {@link FilterPostProcessor(AssetManager assetManager)}<br>\r
+     * This constructor is used for serialization only\r
      */\r
     public FilterPostProcessor() {\r
     }\r
 \r
+    /**\r
+     * Adds a filter to the filters list<br>\r
+     * @param filter the filter to add\r
+     */\r
     public void addFilter(Filter filter) {\r
         filters.add(filter);\r
         filter.setProcessor(this);\r
@@ -112,6 +118,10 @@ public class FilterPostProcessor implements SceneProcessor, Savable {
 \r
     }\r
 \r
+    /**\r
+     * removes this filters from the filters list\r
+     * @param filter \r
+     */\r
     public void removeFilter(Filter filter) {\r
         for (Iterator<Filter> it = filters.iterator(); it.hasNext();) {\r
             if (it.next() == filter) {\r
@@ -140,6 +150,11 @@ public class FilterPostProcessor implements SceneProcessor, Savable {
         reshape(vp, cam.getWidth(), cam.getHeight());\r
     }\r
 \r
+    /**\r
+     * init the given filter\r
+     * @param filter\r
+     * @param vp \r
+     */\r
     private void initFilter(Filter filter, ViewPort vp) {\r
         filter.init(assetManager, renderManager, vp, width, height);\r
         if (filter.isRequiresDepthTexture()) {\r
@@ -152,6 +167,12 @@ public class FilterPostProcessor implements SceneProcessor, Savable {
         }\r
     }\r
 \r
+    /**\r
+     * renders a filter on a fullscreen quad\r
+     * @param r\r
+     * @param buff\r
+     * @param mat \r
+     */\r
     private void renderProcessing(Renderer r, FrameBuffer buff, Material mat) {\r
         if (buff == outputBuffer) {\r
             fsQuad.setWidth(width);\r
@@ -199,7 +220,12 @@ public class FilterPostProcessor implements SceneProcessor, Savable {
     }\r
     Picture pic = new Picture("debug");\r
 \r
-    public void renderFilterChain(Renderer r, FrameBuffer sceneFb) {\r
+    /**\r
+     * iterate through the filter list and renders filters\r
+     * @param r\r
+     * @param sceneFb \r
+     */\r
+    private void renderFilterChain(Renderer r, FrameBuffer sceneFb) {\r
         Texture2D tex = filterTexture;\r
         FrameBuffer buff = sceneFb;\r
         boolean msDepth = depthTexture != null && depthTexture.getImage().getMultiSamples() > 1;\r
@@ -268,7 +294,7 @@ public class FilterPostProcessor implements SceneProcessor, Savable {
         }\r
         renderFilterChain(renderer, sceneBuffer);\r
         renderManager.setCamera(viewPort.getCamera(), false);\r
-        \r
+\r
         renderer.setFrameBuffer(outputBuffer);\r
 \r
     }\r
@@ -305,6 +331,11 @@ public class FilterPostProcessor implements SceneProcessor, Savable {
 \r
     }\r
 \r
+    /**\r
+     * sets the filter to enabled or disabled\r
+     * @param filter\r
+     * @param enabled \r
+     */\r
     protected void setFilterState(Filter filter, boolean enabled) {\r
         if (filters.contains(filter)) {\r
             filter.enabled = enabled;\r
@@ -312,6 +343,9 @@ public class FilterPostProcessor implements SceneProcessor, Savable {
         }\r
     }\r
 \r
+    /**\r
+     * compute the index of the last filter to render\r
+     */\r
     private void updateLastFilterIndex() {\r
         lastFilterIndex = -1;\r
         for (int i = filters.size() - 1; i >= 0 && lastFilterIndex == -1; i--) {\r
@@ -423,32 +457,32 @@ public class FilterPostProcessor implements SceneProcessor, Savable {
         this.assetManager = assetManager;\r
     }\r
 \r
-    /**\r
-     * Writes the processor\r
-     * @param ex\r
-     * @throws IOException\r
-     */\r
     public void write(JmeExporter ex) throws IOException {\r
         OutputCapsule oc = ex.getCapsule(this);\r
         oc.write(numSamples, "numSamples", 0);\r
         oc.writeSavableArrayList((ArrayList) filters, "filters", null);\r
     }\r
 \r
-    /**\r
-     * Reads the processor\r
-     * @param im\r
-     * @throws IOException\r
-     */\r
     public void read(JmeImporter im) throws IOException {\r
         InputCapsule ic = im.getCapsule(this);\r
         numSamples = ic.readInt("numSamples", 0);\r
         filters = ic.readSavableArrayList("filters", null);\r
     }\r
 \r
+    /**\r
+     * For internal use only<br>\r
+     * returns the depth texture of the scene\r
+     * @return \r
+     */\r
     public Texture2D getDepthTexture() {\r
         return depthTexture;\r
     }\r
 \r
+    /**\r
+     * For internal use only<br>\r
+     * returns the rendered texture of the scene\r
+     * @return \r
+     */\r
     public Texture2D getFilterTexture() {\r
         return filterTexture;\r
     }\r
index 7b986c7..80301cb 100644 (file)
@@ -37,9 +37,15 @@ import com.jme3.renderer.ViewPort;
 import com.jme3.renderer.queue.RenderQueue;
 import com.jme3.texture.FrameBuffer;
 
+/**
+ * Scene processors are used to compute/render things before and after the classic render of the scene.
+ * They have to be added to a viewport and are rendered in the order they've been added
+ * @author Kirill Vainer aka Shadowislord aka Momoko_Fan
+ */
 public interface SceneProcessor {
 
     /**
+     * For internal use only<br>
      * Called in the render thread to initialize the scene processor.
      *
      * @param rm The render manager to which the SP was added to
@@ -48,6 +54,7 @@ public interface SceneProcessor {
     public void initialize(RenderManager rm, ViewPort vp);
 
     /**
+     * For internal use only<br>
      * Called when the resolution of the viewport has been changed.
      * @param vp
      */
@@ -60,6 +67,7 @@ public interface SceneProcessor {
     public boolean isInitialized();
 
     /**
+     * For internal use only<br>
      * Called before a frame
      *
      * @param tpf Time per frame
@@ -67,6 +75,7 @@ public interface SceneProcessor {
     public void preFrame(float tpf);
 
     /**
+     * For internal use only<br>
      * Called after the scene graph has been queued, but before it is flushed.
      *
      * @param rq The render queue
@@ -74,6 +83,7 @@ public interface SceneProcessor {
     public void postQueue(RenderQueue rq);
 
     /**
+     * For internal use only<br>
      * Called after a frame has been rendered and the queue flushed.
      *
      * @param out The FB to which the scene was rendered.
@@ -81,6 +91,7 @@ public interface SceneProcessor {
     public void postFrame(FrameBuffer out);
 
     /**
+     * For internal use only<br>
      * Called when the SP is removed from the RM.
      */
     public void cleanup();
index b1e4875..8f549ac 100644 (file)
@@ -40,36 +40,37 @@ import com.jme3.material.Material;
 import com.jme3.math.ColorRGBA;
 import com.jme3.post.Filter;
 import com.jme3.renderer.RenderManager;
-import com.jme3.renderer.Renderer;
 import com.jme3.renderer.ViewPort;
 import com.jme3.texture.Image.Format;
 import java.io.IOException;
 import java.util.ArrayList;
 
 /**
- * <code>BloomFilter</code> is used to make objects in the scene have a 
- * "soap opera" glow effect.
- *
- * @author Nehon
+ * BloomFilter is used to make objects in the scene have a glow effect.<br>
+ * There are 2 mode : Scene and Objects.<br>
+ * Scene mode extracts the bright parts of the scene to make them glow<br>
+ * Object mode make objects glow according to their material's glowMap or their GlowColor<br>
+ * see {@link http://jmonkeyengine.org/wiki/doku.php/jme3:advanced:bloom_and_glow} for more details
+ * 
+ * @author Rémy Bouquet aka Nehon
  */
 public class BloomFilter extends Filter {
 
     /**
-     * <code>GlowMode</code> specifies if bright objects or objects
-     * with glow map will be bloomed.
+     * GlowMode specifies if the glow will be applied to the whole scene,or to objects that have aglow color or a glow map
      */
     public enum GlowMode {
 
         /**
-         * Apply bloom filter to bright objects in the scene.
+         * Apply bloom filter to bright areas in the scene.
          */
         Scene,
         /**
-         * Apply bloom only to objects that have a glow map.
+         * Apply bloom only to objects that have a glow map or a glow color.
          */
         Objects,
         /**
-         * Apply bloom to both bright objects and objects with glow map.
+         * Apply bloom to both bright parts of the scene and objects with glow map.
          */
         SceneAndObjects;
     }
@@ -93,14 +94,14 @@ public class BloomFilter extends Filter {
     private ColorRGBA backupColor;
 
     /**
-     * creates a Bloom filter
+     * Creates a Bloom filter
      */
     public BloomFilter() {
         super("BloomFilter");
     }
 
     /**
-     * Crete the bloom filter with the specific glow mode
+     * Creates the bloom filter with the specific glow mode
      * @param glowMode
      */
     public BloomFilter(GlowMode glowMode) {
@@ -109,7 +110,7 @@ public class BloomFilter extends Filter {
     }
 
     @Override
-    public void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
+    protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
         screenWidth = (int) (w / downSamplingFactor);
         screenHeight = (int) (h / downSamplingFactor);
         //    System.out.println(screenWidth + " " + screenHeight);
@@ -178,31 +179,15 @@ public class BloomFilter extends Filter {
         material.setTexture("BloomTex", verticalalBlur.getRenderedTexture());
     }
 
-    @Override
-    public void cleanUpFilter(Renderer r) {
-
-        if (preGlowPass != null) {
-            preGlowPass.cleanup(r);
-        }
-        if (extractPass != null) {
-            extractPass.cleanup(r);
-        }
-        if (horizontalBlur != null) {
-            horizontalBlur.cleanup(r);
-        }
-        if (verticalalBlur != null) {
-            verticalalBlur.cleanup(r);
-        }
-    }
 
     @Override
-    public Material getMaterial() {
+    protected Material getMaterial() {
         material.setFloat("BloomIntensity", bloomIntensity);
         return material;
     }
 
     @Override
-    public void postQueue(RenderManager renderManager, ViewPort viewPort) {
+    protected void postQueue(RenderManager renderManager, ViewPort viewPort) {
         if (glowMode != GlowMode.Scene) {
             backupColor = viewPort.getBackgroundColor();
             viewPort.setBackgroundColor(ColorRGBA.Black);
@@ -216,30 +201,43 @@ public class BloomFilter extends Filter {
         }
     }
 
+    /**
+     * returns the bloom intensity
+     * @return 
+     */
     public float getBloomIntensity() {
         return bloomIntensity;
     }
 
     /**
-     * intensity of the bloom effect
+     * intensity of the bloom effect default is 2.0
      * @param bloomIntensity
      */
     public void setBloomIntensity(float bloomIntensity) {
         this.bloomIntensity = bloomIntensity;
     }
 
+    /**
+     * returns the blur scale
+     * @return 
+     */
     public float getBlurScale() {
         return blurScale;
     }
 
     /**
-     * The spread of the bloom
+     * sets The spread of the bloom default is 1.5f
      * @param blurScale
      */
     public void setBlurScale(float blurScale) {
         this.blurScale = blurScale;
     }
 
+    /**
+     * returns the exposure cutoff<br>
+     * for more details see {@link setExposureCutOff(float exposureCutOff)}
+     * @return 
+     */    
     public float getExposureCutOff() {
         return exposureCutOff;
     }
@@ -252,12 +250,18 @@ public class BloomFilter extends Filter {
         this.exposureCutOff = exposureCutOff;
     }
 
+    /**
+     * returns the exposure power<br>
+     * form more details see {@link setExposurePower(float exposurePower)}
+     * @return 
+     */
     public float getExposurePower() {
         return exposurePower;
     }
 
     /**
-     * the power of the bloomed color
+     * defines how many time the bloom extracted color will be multiplied by itself. default id 5.0<br>
+     * a high value will reduce rough edges in the bloom and somhow the range of the bloom area     * 
      * @param exposurePower
      */
     public void setExposurePower(float exposurePower) {
@@ -265,7 +269,8 @@ public class BloomFilter extends Filter {
     }
 
     /**
-     * returns the downSampling factor
+     * returns the downSampling factor<br>
+     * form more details see {@link setDownSamplingFactor(float downSamplingFactor)}
      * @return
      */
     public float getDownSamplingFactor() {
@@ -273,7 +278,7 @@ public class BloomFilter extends Filter {
     }
 
     /**
-     * Sets the downSampling factor : the size of the computed texture will be divided by this factor.
+     * Sets the downSampling factor : the size of the computed texture will be divided by this factor. default is 1 for no downsampling
      * A 2 value is a good way of widening the blur
      * @param downSamplingFactor
      */
index a6c347d..3e9998b 100644 (file)
@@ -55,19 +55,22 @@ public class CartoonEdgeFilter extends Filter {
     private float depthThreshold = 0.1f;
     private float normalSensitivity = 1.0f;
     private float depthSensitivity = 10.0f;
-    private ColorRGBA edgeColor=new ColorRGBA(0, 0, 0, 1);
+    private ColorRGBA edgeColor = new ColorRGBA(0, 0, 0, 1);
 
+    /**
+     * Creates a CartoonEdgeFilter
+     */
     public CartoonEdgeFilter() {
         super("CartoonEdgeFilter");
     }
 
     @Override
-    public boolean isRequiresDepthTexture() {
+    protected boolean isRequiresDepthTexture() {
         return true;
     }
 
     @Override
-    public void postQueue(RenderManager renderManager, ViewPort viewPort) {
+    protected void postQueue(RenderManager renderManager, ViewPort viewPort) {
         Renderer r = renderManager.getRenderer();
         r.setFrameBuffer(normalPass.getRenderFrameBuffer());
         renderManager.getRenderer().clearBuffers(true, true, true);
@@ -78,13 +81,13 @@ public class CartoonEdgeFilter extends Filter {
     }
 
     @Override
-    public Material getMaterial() {
+    protected Material getMaterial() {
         material.setTexture("NormalsTexture", normalPass.getRenderedTexture());
         return material;
     }
 
     @Override
-    public void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
+    protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
         normalPass = new Pass();
         normalPass.init(renderManager.getRenderer(), w, h, Format.RGBA8, Format.Depth);
         material = new Material(manager, "Common/MatDefs/Post/CartoonEdge.j3md");
@@ -97,17 +100,20 @@ public class CartoonEdgeFilter extends Filter {
         material.setColor("EdgeColor", edgeColor);
     }
 
-    @Override
-    public void cleanUpFilter(Renderer r) {
-        if (normalPass != null) {
-            normalPass.cleanup(r);
-        }
-    }
-
+    /**
+     * Return the depth sensitivity<br>
+     * for more details see {@link setDepthSensitivity(float depthSensitivity)}
+     * @return 
+     */
     public float getDepthSensitivity() {
         return depthSensitivity;
     }
 
+    /**
+     * sets the depth sensitivity<br>
+     * defines how much depth will influence edges, default is 10
+     * @param depthSensitivity 
+     */
     public void setDepthSensitivity(float depthSensitivity) {
         this.depthSensitivity = depthSensitivity;
         if (material != null) {
@@ -115,10 +121,20 @@ public class CartoonEdgeFilter extends Filter {
         }
     }
 
+    /**
+     * returns the depth threshold<br>
+     * for more details see {@link setDepthThreshold(float depthThreshold)}
+     * @return 
+     */
     public float getDepthThreshold() {
         return depthThreshold;
     }
 
+    /**
+     * sets the depth threshold<br>
+     * Defines at what threshold of difference of depth an edge is outlined default is 0.1f
+     * @param depthThreshold 
+     */
     public void setDepthThreshold(float depthThreshold) {
         this.depthThreshold = depthThreshold;
         if (material != null) {
@@ -126,10 +142,20 @@ public class CartoonEdgeFilter extends Filter {
         }
     }
 
+    /**
+     * returns the edge intensity<br>
+     * for more details see {@link setEdgeIntensity(float edgeIntensity) }
+     * @return 
+     */
     public float getEdgeIntensity() {
         return edgeIntensity;
     }
 
+    /**
+     * sets the edge intensity<br>
+     * Defineshow visilble will be the outlined edges
+     * @param edgeIntensity 
+     */
     public void setEdgeIntensity(float edgeIntensity) {
         this.edgeIntensity = edgeIntensity;
         if (material != null) {
@@ -137,10 +163,18 @@ public class CartoonEdgeFilter extends Filter {
         }
     }
 
+    /**
+     * returns the width of the edges
+     * @return 
+     */
     public float getEdgeWidth() {
         return edgeWidth;
     }
 
+    /**
+     * sets the witdh of the edge in pixels default is 1
+     * @param edgeWidth 
+     */
     public void setEdgeWidth(float edgeWidth) {
         this.edgeWidth = edgeWidth;
         if (material != null) {
@@ -149,10 +183,19 @@ public class CartoonEdgeFilter extends Filter {
 
     }
 
+    /**
+     * returns the normals sensitivity<br>
+     * form more details see {@link setNormalSensitivity(float normalSensitivity)}
+     * @return 
+     */
     public float getNormalSensitivity() {
         return normalSensitivity;
     }
 
+    /**
+     * sets the normals sensitivity default is 1
+     * @param normalSensitivity 
+     */
     public void setNormalSensitivity(float normalSensitivity) {
         this.normalSensitivity = normalSensitivity;
         if (material != null) {
@@ -160,10 +203,20 @@ public class CartoonEdgeFilter extends Filter {
         }
     }
 
+    /**
+     * returns the normal threshold<br>
+     * for more details see {@link setNormalThreshold(float normalThreshold)}
+     * 
+     * @return 
+     */
     public float getNormalThreshold() {
         return normalThreshold;
     }
 
+    /**
+     * sets the normal threshold default is 0.5
+     * @param normalThreshold 
+     */
     public void setNormalThreshold(float normalThreshold) {
         this.normalThreshold = normalThreshold;
         if (material != null) {
@@ -185,10 +238,8 @@ public class CartoonEdgeFilter extends Filter {
      */
     public void setEdgeColor(ColorRGBA edgeColor) {
         this.edgeColor = edgeColor;
-        if(material!=null){
+        if (material != null) {
             material.setColor("EdgeColor", edgeColor);
         }
     }
-
-
 }
index 5a18346..a7f30f8 100644 (file)
@@ -40,44 +40,58 @@ import com.jme3.material.Material;
 import com.jme3.math.ColorRGBA;
 import com.jme3.post.Filter;
 import com.jme3.renderer.RenderManager;
-import com.jme3.renderer.Renderer;
 import com.jme3.renderer.ViewPort;
 import java.io.IOException;
 
 /** 
- *
- * @author nehon
+ * This filter simply multiply the whole scene by a color
+ * @author Rémy Bouquet aka Nehon
  */
 public class ColorOverlayFilter extends Filter {
 
     private ColorRGBA color = ColorRGBA.White;
 
+    /**
+     * creates a colorOverlayFilter with a white coor (transparent)
+     */
     public ColorOverlayFilter() {
         super("Color Overlay");
     }
 
+    /**
+     * creates a colorOverlayFilter with the given color
+     * @param color 
+     */
     public ColorOverlayFilter(ColorRGBA color) {
         this();
         this.color = color;
     }
 
     @Override
-    public Material getMaterial() {
+    protected Material getMaterial() {
 
         material.setColor("Color", color);
         return material;
     }
 
+    /**
+     * returns the color
+     * @return color
+     */
     public ColorRGBA getColor() {
         return color;
     }
 
+    /**
+     * sets the color 
+     * @param color 
+     */
     public void setColor(ColorRGBA color) {
         this.color = color;
     }
 
     @Override
-    public void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
+    protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
         material = new Material(manager, "Common/MatDefs/Post/Overlay.j3md");
     }
 
@@ -94,8 +108,4 @@ public class ColorOverlayFilter extends Filter {
         InputCapsule ic = im.getCapsule(this);
         color = (ColorRGBA) ic.readSavable("color", ColorRGBA.White);
     }
-
-    @Override
-    public void cleanUpFilter(Renderer r) {
-    }
 }
index 388e52d..0eb2049 100644 (file)
@@ -36,7 +36,6 @@ import com.jme3.material.Material;
 import com.jme3.math.ColorRGBA;
 import com.jme3.post.Filter;
 import com.jme3.renderer.RenderManager;
-import com.jme3.renderer.Renderer;
 import com.jme3.renderer.ViewPort;
 
 /*
@@ -64,10 +63,18 @@ public class CrossHatchFilter extends Filter {
     private float lineThickness = 1.0f;
     private float lineDistance = 4.0f;
 
+    /**
+     * Creates a crossHatch filter
+     */
     public CrossHatchFilter() {
         super("CrossHatchFilter");
     }
 
+    /**
+     * Creates a crossHatch filter
+     * @param lineColor the colors of the lines
+     * @param paperColor the paper color
+     */
     public CrossHatchFilter(ColorRGBA lineColor, ColorRGBA paperColor) {
         this();
         this.lineColor = lineColor;
@@ -75,12 +82,12 @@ public class CrossHatchFilter extends Filter {
     }
 
     @Override
-    public boolean isRequiresDepthTexture() {
+    protected boolean isRequiresDepthTexture() {
         return false;
     }
 
     @Override
-    public void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
+    protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
         material = new Material(manager, "Common/MatDefs/Post/CrossHatch.j3md");
         material.setColor("LineColor", lineColor);
         material.setColor("PaperColor", paperColor);
@@ -101,16 +108,13 @@ public class CrossHatchFilter extends Filter {
     }
 
     @Override
-    public Material getMaterial() {
+    protected Material getMaterial() {
         return material;
     }
 
-    @Override
-    public void cleanUpFilter(Renderer r) {
-    }
-
-    /*
+    /**
      * Sets color used to draw lines
+     * @param lineColor 
      */
     public void setLineColor(ColorRGBA lineColor) {
         this.lineColor = lineColor;
@@ -119,8 +123,9 @@ public class CrossHatchFilter extends Filter {
         }
     }
 
-    /*
+    /**
      * Sets color used as background
+     * @param paperColor 
      */
     public void setPaperColor(ColorRGBA paperColor) {
         this.paperColor = paperColor;
@@ -128,10 +133,11 @@ public class CrossHatchFilter extends Filter {
             material.setColor("PaperColor", paperColor);
         }
     }
-    /*
+
+    /**
      * Sets color influence of original image on lines drawn
+     * @param colorInfluenceLine 
      */
-
     public void setColorInfluenceLine(float colorInfluenceLine) {
         this.colorInfluenceLine = colorInfluenceLine;
         if (material != null) {
@@ -139,8 +145,9 @@ public class CrossHatchFilter extends Filter {
         }
     }
 
-    /*
+    /**
      * Sets color influence of original image on non-line areas
+     * @param colorInfluencePaper 
      */
     public void setColorInfluencePaper(float colorInfluencePaper) {
         this.colorInfluencePaper = colorInfluencePaper;
@@ -149,9 +156,10 @@ public class CrossHatchFilter extends Filter {
         }
     }
 
-    /*
+    /**
      * Sets line/paper color ratio for areas with values < luminance5,
      * really dark areas get no lines but a filled blob instead
+     * @param fillValue 
      */
     public void setFillValue(float fillValue) {
         this.fillValue = fillValue;
@@ -160,13 +168,14 @@ public class CrossHatchFilter extends Filter {
         }
     }
 
-    /*
+    /**
+     *
      * Sets minimum luminance levels for lines drawn
-     * Luminance1: Top-left to down right 1
-     * Luminance2: Top-right to bottom left 1
-     * Luminance3: Top-left to down right 2
-     * Luminance4: Top-right to bottom left 2
-     * Luminance5: Blobs
+     * @param luminance1 Top-left to down right 1
+     * @param luminance2 Top-right to bottom left 1
+     * @param luminance3 Top-left to down right 2
+     * @param luminance4 Top-right to bottom left 2
+     * @param luminance5 Blobs
      */
     public void setLuminanceLevels(float luminance1, float luminance2, float luminance3, float luminance4, float luminance5) {
         this.luminance1 = luminance1;
@@ -184,8 +193,9 @@ public class CrossHatchFilter extends Filter {
         }
     }
 
-    /*
+    /**
      * Sets the thickness of lines drawn
+     * @param lineThickness 
      */
     public void setLineThickness(float lineThickness) {
         this.lineThickness = lineThickness;
@@ -194,10 +204,11 @@ public class CrossHatchFilter extends Filter {
         }
     }
 
-    /*
+    /**
      * Sets minimum distance between lines drawn
      * Primary lines are drawn at 2*lineDistance
      * Secondary lines are drawn at lineDistance
+     * @param lineDistance 
      */
     public void setLineDistance(float lineDistance) {
         this.lineDistance = lineDistance;
@@ -206,84 +217,86 @@ public class CrossHatchFilter extends Filter {
         }
     }
 
-    /*
+    /**
      * Returns line color
+     * @return 
      */
     public ColorRGBA getLineColor() {
         return lineColor;
     }
 
-    /*
+    /**
      * Returns paper background color
+     * @return 
      */
     public ColorRGBA getPaperColor() {
         return paperColor;
     }
 
-    /*
+    /**
      * Returns current influence of image colors on lines
      */
     public float getColorInfluenceLine() {
         return colorInfluenceLine;
     }
 
-    /*
+    /**
      * Returns current influence of image colors on paper background
      */
     public float getColorInfluencePaper() {
         return colorInfluencePaper;
     }
 
-    /*
+    /**
      * Returns line/paper color ratio for blobs
      */
     public float getFillValue() {
         return fillValue;
     }
 
-    /*
+    /**
      * Returns the thickness of the lines drawn
      */
     public float getLineThickness() {
         return lineThickness;
     }
 
-    /*
+    /**
      * Returns minimum distance between lines
      */
     public float getLineDistance() {
         return lineDistance;
     }
 
-    /*
+    /**
      * Returns treshold for lines 1
      */
     public float getLuminance1() {
         return luminance1;
     }
 
-    /*
+    /**
      * Returns treshold for lines 2
      */
     public float getLuminance2() {
         return luminance2;
     }
 
-    /*
+    /**
      * Returns treshold for lines 3
      */
     public float getLuminance3() {
         return luminance3;
     }
 
-    /*
+    /**
      * Returns treshold for lines 4
      */
     public float getLuminance4() {
         return luminance4;
     }
 
-    /*
+    /**
      * Returns treshold for blobs
      */
     public float getLuminance5() {
index 238fe06..b360e5c 100644 (file)
@@ -35,7 +35,6 @@ import com.jme3.asset.AssetManager;
 import com.jme3.post.Filter;
 import com.jme3.material.Material;
 import com.jme3.renderer.RenderManager;
-import com.jme3.renderer.Renderer;
 import com.jme3.renderer.ViewPort;
 
 /**
@@ -55,28 +54,31 @@ public class DepthOfFieldFilter extends Filter {
     private float xScale;
     private float yScale;
 
+    /**
+     * Creates a DepthOfField filter
+     */
     public DepthOfFieldFilter() {
         super("Depth Of Field");
     }
 
     @Override
-    public boolean isRequiresDepthTexture() {
+    protected boolean isRequiresDepthTexture() {
         return true;
     }
 
     @Override
-    public Material getMaterial() {
+    protected Material getMaterial() {
 
         return material;
     }
 
     @Override
-    public void initFilter(AssetManager assets, RenderManager renderManager,
+    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;
@@ -85,10 +87,6 @@ public class DepthOfFieldFilter extends Filter {
         material.setFloat("YScale", blurScale * yScale);
     }
 
-    @Override
-    public void cleanUpFilter(Renderer r) {
-    }
-
     /**
      *  Sets the distance at which objects are purely in focus.
      */
@@ -101,6 +99,10 @@ public class DepthOfFieldFilter extends Filter {
 
     }
 
+    /**
+     * returns the focus distance
+     * @return 
+     */
     public float getFocusDistance() {
         return focusDistance;
     }
@@ -118,6 +120,10 @@ public class DepthOfFieldFilter extends Filter {
 
     }
 
+    /**
+     * returns the focus range
+     * @return 
+     */
     public float getFocusRange() {
         return focusRange;
     }
@@ -142,6 +148,10 @@ public class DepthOfFieldFilter extends Filter {
         }
     }
 
+    /**
+     * returns the blur scale
+     * @return 
+     */
     public float getBlurScale() {
         return blurScale;
     }
index 9832c83..bf5a841 100644 (file)
@@ -39,13 +39,13 @@ import com.jme3.export.OutputCapsule;
 import com.jme3.material.Material;
 import com.jme3.post.Filter;
 import com.jme3.renderer.RenderManager;
-import com.jme3.renderer.Renderer;
 import com.jme3.renderer.ViewPort;
 import java.io.IOException;
 
 /**
  *
- * @author Nehon
+ * Fade Filter allows you to make an animated fade effect on a scene.
+ * @author Rémy Bouquet aka Nehon
  * implemented from boxjar implementation
  * see http://jmonkeyengine.org/groups/graphics/forum/topic/newbie-question-general-fade-inout-effect/#post-105559
  */
@@ -56,29 +56,35 @@ public class FadeFilter extends Filter {
     private float direction = 1;
     private float duration = 1;
 
+    /**
+     * Creates a FadeFilter
+     */
     public FadeFilter() {
         super("Fade In/Out");
     }
 
+    /**
+     * Creates a FadeFilter with the given duration
+     * @param duration 
+     */
     public FadeFilter(float duration) {
         this();
         this.duration = duration;
     }
 
     @Override
-    public Material getMaterial() {
+    protected Material getMaterial() {
         material.setFloat("Value", value);
         return material;
     }
 
-
     @Override
-    public void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
+    protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
         material = new Material(manager, "Common/MatDefs/Post/Fade.j3md");
     }
 
     @Override
-    public void preFrame(float tpf) {
+    protected void preFrame(float tpf) {
         if (playing) {
             value += tpf * direction / duration;
 
@@ -95,20 +101,34 @@ public class FadeFilter extends Filter {
         }
     }
 
+    /**
+     * returns the duration of the effect 
+     * @return 
+     */
     public float getDuration() {
         return duration;
     }
 
+    /**
+     * Sets the duration of the filter default is 1 second
+     * @param duration 
+     */
     public void setDuration(float duration) {
         this.duration = duration;
     }
 
+    /**
+     * fades the scene in (black to scene)
+     */
     public void fadeIn() {
         setEnabled(true);
         direction = 1;
         playing = true;
     }
 
+    /**
+     * fades the scene out (scene to black)
+     */
     public void fadeOut() {
         setEnabled(true);
         direction = -1;
@@ -130,15 +150,21 @@ public class FadeFilter extends Filter {
         duration = ic.readFloat("duration", 1);
     }
 
+    /**
+     * return the current value of the fading
+     * can be used to chack if fade is complete (eg value=1)
+     * @return 
+     */
     public float getValue() {
         return value;
     }
 
+    /**
+     * sets the fade value
+     * can be used to force complete black or compete scene
+     * @param value 
+     */
     public void setValue(float value) {
         this.value = value;
     }
-
-    @Override
-    public void cleanUpFilter(Renderer r) {
-    }
 }
index b075476..ff61797 100644 (file)
@@ -40,13 +40,12 @@ import com.jme3.material.Material;
 import com.jme3.math.ColorRGBA;
 import com.jme3.post.Filter;
 import com.jme3.renderer.RenderManager;
-import com.jme3.renderer.Renderer;
 import com.jme3.renderer.ViewPort;
 import java.io.IOException;
 
 /**
  * A filter to render a fog effect
- * @author Nehon
+ * @author Rémy Bouquet aka Nehon
  */
 public class FogFilter extends Filter {
 
@@ -54,6 +53,9 @@ public class FogFilter extends Filter {
     private float fogDensity = 0.7f;
     private float fogDistance = 1000;
 
+    /**
+     * Creates a FogFilter
+     */
     public FogFilter() {
         super("FogFilter");
     }
@@ -72,12 +74,12 @@ public class FogFilter extends Filter {
     }
 
     @Override
-    public boolean isRequiresDepthTexture() {
+    protected boolean isRequiresDepthTexture() {
         return true;
     }
 
     @Override
-    public void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
+    protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
         material = new Material(manager, "Common/MatDefs/Post/Fog.j3md");
         material.setColor("FogColor", fogColor);
         material.setFloat("FogDensity", fogDensity);
@@ -85,7 +87,7 @@ public class FogFilter extends Filter {
     }
 
     @Override
-    public Material getMaterial() {
+    protected Material getMaterial() {
 
         return material;
     }
@@ -166,7 +168,5 @@ public class FogFilter extends Filter {
         fogDistance = ic.readFloat("fogDistance", 1000);
     }
 
-    @Override
-    public void cleanUpFilter(Renderer r) {
-    }
+
 }
index 0056506..953f10a 100644 (file)
@@ -41,13 +41,14 @@ import com.jme3.math.Vector3f;
 import com.jme3.post.Filter;
 import com.jme3.renderer.Camera;
 import com.jme3.renderer.RenderManager;
-import com.jme3.renderer.Renderer;
 import com.jme3.renderer.ViewPort;
 import java.io.IOException;
 
 /**
+ * LightScattering filters creates rays comming from a light sources 
+ * This is often reffered as god rays.
  *
- * @author nehon
+ * @author Rémy Bouquet aka Nehon
  */
 public class LightScatteringFilter extends Filter {
 
@@ -59,25 +60,32 @@ public class LightScatteringFilter extends Filter {
     private float lightDensity = 1.4f;
     private boolean adaptative = true;
     Vector3f viewLightPos = new Vector3f();
-    private boolean display=true;
+    private boolean display = true;
     private float innerLightDensity;
 
+    /**
+     * creates a lightScaterring filter
+     */
     public LightScatteringFilter() {
         super("Light Scattering");
     }
 
+    /**
+     * Creates a lightScatteringFilter
+     * @param lightPosition 
+     */
     public LightScatteringFilter(Vector3f lightPosition) {
         this();
         this.lightPosition = lightPosition;
     }
 
     @Override
-    public boolean isRequiresDepthTexture() {
+    protected boolean isRequiresDepthTexture() {
         return true;
     }
 
     @Override
-    public Material getMaterial() {
+    protected Material getMaterial() {
         material.setVector3("LightPosition", screenLightPos);
         material.setInt("NbSamples", nbSamples);
         material.setFloat("BlurStart", blurStart);
@@ -88,7 +96,7 @@ public class LightScatteringFilter extends Filter {
     }
 
     @Override
-    public void postQueue(RenderManager renderManager, ViewPort viewPort) {
+    protected void postQueue(RenderManager renderManager, ViewPort viewPort) {
         getClipCoordinates(lightPosition, screenLightPos, viewPort.getCamera());
         //  screenLightPos.x = screenLightPos.x / viewPort.getCamera().getWidth();
         //  screenLightPos.y = screenLightPos.y / viewPort.getCamera().getHeight();
@@ -101,12 +109,12 @@ public class LightScatteringFilter extends Filter {
 //System.err.println("screenLightPos "+screenLightPos);
         if (adaptative) {
             innerLightDensity = Math.max(lightDensity - Math.max(screenLightPos.x, screenLightPos.y), 0.0f);
-        }else{
-            innerLightDensity=lightDensity;
+        } else {
+            innerLightDensity = lightDensity;
         }
     }
 
-    public Vector3f getClipCoordinates(Vector3f worldPosition, Vector3f store, Camera cam) {
+    private Vector3f getClipCoordinates(Vector3f worldPosition, Vector3f store, Camera cam) {
 
         float w = cam.getViewProjectionMatrix().multProj(worldPosition, store);
         store.divideLocal(w);
@@ -119,46 +127,92 @@ public class LightScatteringFilter extends Filter {
     }
 
     @Override
-    public void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
+    protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
         material = new Material(manager, "Common/MatDefs/Post/LightScattering.j3md");
     }
 
+    /**
+     * returns the blur start of the scattering 
+     * see {@link  setBlurStart(float blurStart)}
+     * @return 
+     */
     public float getBlurStart() {
         return blurStart;
     }
 
+    /**
+     * sets the blur start<br>
+     * at which distance from the light source the effect starts default is 0.02
+     * @param blurStart 
+     */
     public void setBlurStart(float blurStart) {
         this.blurStart = blurStart;
     }
 
+    /**
+     * returns the blur width<br>
+     * see {@link setBlurWidth(float blurWidth)}
+     * @return 
+     */
     public float getBlurWidth() {
         return blurWidth;
     }
 
+    /**
+     * sets the blur width default is 0.9
+     * @param blurWidth 
+     */
     public void setBlurWidth(float blurWidth) {
         this.blurWidth = blurWidth;
     }
 
+    /**
+     * retiurns the light density<br>
+     * see {@link setLightDensity(float lightDensity)}
+     * 
+     * @return 
+     */
     public float getLightDensity() {
         return lightDensity;
     }
 
+    /**
+     * sets how much the effect is visible over the rendered scene default is 1.4
+     * @param lightDensity 
+     */
     public void setLightDensity(float lightDensity) {
         this.lightDensity = lightDensity;
     }
 
+    /**
+     * returns the light position
+     * @return 
+     */
     public Vector3f getLightPosition() {
         return lightPosition;
     }
 
+    /**
+     * sets the light position
+     * @param lightPosition 
+     */
     public void setLightPosition(Vector3f lightPosition) {
         this.lightPosition = lightPosition;
     }
 
+    /**
+     * returns the nmber of samples for the radial blur
+     * @return 
+     */
     public int getNbSamples() {
         return nbSamples;
     }
 
+    /**
+     * sets the number of samples for the radial blur default is 50
+     * the higher the value the higher the quality, but the slower the performances.
+     * @param nbSamples 
+     */
     public void setNbSamples(int nbSamples) {
         this.nbSamples = nbSamples;
     }
@@ -186,8 +240,4 @@ public class LightScatteringFilter extends Filter {
         lightDensity = ic.readFloat("lightDensity", 1.4f);
         adaptative = ic.readBoolean("adaptative", true);
     }
-
-    @Override
-    public void cleanUpFilter(Renderer r) {
-    }
 }
index 6a98143..c980eda 100644 (file)
@@ -35,7 +35,6 @@ import com.jme3.asset.AssetManager;
 import com.jme3.material.Material;
 import com.jme3.post.Filter;
 import com.jme3.renderer.RenderManager;
-import com.jme3.renderer.Renderer;
 import com.jme3.renderer.ViewPort;
 
 /**
@@ -56,27 +55,34 @@ public class PosterizationFilter extends Filter {
     private float gamma = 0.6f;
     private float strength = 1.0f;
 
+    /**
+     * Creates a posterization Filter
+     */
     public PosterizationFilter() {
         super("PosterizationFilter");
     }
 
+    /**
+     * Creates a posterization Filter with the given number of colors
+     * @param numColors 
+     */
     public PosterizationFilter(int numColors) {
         this();
         this.numColors = numColors;
     }
 
+    /**
+     * Creates a posterization Filter with the given number of colors and gamma
+     * @param numColors
+     * @param gamma 
+     */
     public PosterizationFilter(int numColors, float gamma) {
         this(numColors);
         this.gamma = gamma;
     }
 
     @Override
-    public boolean isRequiresDepthTexture() {
-        return false;
-    }
-
-    @Override
-    public void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
+    protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
         material = new Material(manager, "Common/MatDefs/Post/Posterization.j3md");
         material.setInt("NumColors", numColors);
         material.setFloat("Gamma", gamma);
@@ -84,16 +90,11 @@ public class PosterizationFilter extends Filter {
     }
 
     @Override
-    public Material getMaterial() {
+    protected Material getMaterial() {
         return material;
     }
 
-
-    @Override
-    public void cleanUpFilter(Renderer r) {
-    }
-
-    /*
+    /**
      * Sets number of color levels used to draw the screen
      */
     public void setNumColors(int numColors) {
@@ -103,7 +104,7 @@ public class PosterizationFilter extends Filter {
         }
     }
 
-    /*
+    /**
      * Sets gamma level used to enhange visual quality
      */
     public void setGamma(float gamma) {
@@ -113,7 +114,7 @@ public class PosterizationFilter extends Filter {
         }
     }
 
-    /*
+    /**
      * Sets urrent strength value, i.e. influence on final image
      */
     public void setStrength(float strength) {
@@ -123,21 +124,21 @@ public class PosterizationFilter extends Filter {
         }
     }
 
-    /*
+    /**
      * Returns number of color levels used
      */
     public int getNumColors() {
         return numColors;
     }
 
-    /*
+    /**
      * Returns current gamma value
      */
     public float getGamma() {
         return gamma;
     }
 
-    /*
+    /**
      * Returns current strength value, i.e. influence on final image
      */
     public float getStrength() {
index e52b239..db0b4ed 100644 (file)
@@ -39,14 +39,13 @@ import com.jme3.export.OutputCapsule;
 import com.jme3.material.Material;
 import com.jme3.post.Filter;
 import com.jme3.renderer.RenderManager;
-import com.jme3.renderer.Renderer;
 import com.jme3.renderer.ViewPort;
 import com.jme3.shader.VarType;
 import java.io.IOException;
 
 /**
- *
- * @author nehon
+ * Radially blurs the scene from the center of it
+ * @author Rémy Bouquet aka Nehon
  */
 public class RadialBlurFilter extends Filter {
 
@@ -54,10 +53,18 @@ public class RadialBlurFilter extends Filter {
     private float sampleStrength = 2.2f;
     private float[] samples = {-0.08f, -0.05f, -0.03f, -0.02f, -0.01f, 0.01f, 0.02f, 0.03f, 0.05f, 0.08f};
 
+    /**
+     * Creates a RadialBlurFilter
+     */
     public RadialBlurFilter() {
         super("Radial blur");
     }
 
+    /**
+     * Creates a RadialBlurFilter
+     * @param sampleDist the distance between samples
+     * @param sampleStrength the strenght of each sample
+     */
     public RadialBlurFilter(float sampleDist, float sampleStrength) {
         this();
         this.sampleDist = sampleDist;
@@ -65,7 +72,7 @@ public class RadialBlurFilter extends Filter {
     }
 
     @Override
-    public Material getMaterial() {
+    protected Material getMaterial() {
 
         material.setFloat("SampleDist", sampleDist);
         material.setFloat("SampleStrength", sampleStrength);
@@ -74,25 +81,60 @@ public class RadialBlurFilter extends Filter {
         return material;
     }
 
+    /**
+     * return the sample distance
+     * @return 
+     */
+    public float getSampleDistance() {
+        return sampleDist;
+    }
 
+    /**
+     * sets the samples distances default is 1
+     * @param sampleDist 
+     */
+    public void setSampleDistance(float sampleDist) {
+        this.sampleDist = sampleDist;
+    }
+
+    /**
+     * 
+     * @return 
+     * @deprecated use {@link getSampleDistance()}
+     */
+    @Deprecated
     public float getSampleDist() {
         return sampleDist;
     }
 
+    /**
+     * 
+     * @param sampleDist
+     * @deprecated use {@link setSampleDistance(float sampleDist)}
+     */
+    @Deprecated
     public void setSampleDist(float sampleDist) {
         this.sampleDist = sampleDist;
     }
 
+    /**
+     * Returns the sample Strength
+     * @return 
+     */
     public float getSampleStrength() {
         return sampleStrength;
     }
 
+    /**
+     * sets the sample streanght default is 2.2
+     * @param sampleStrength 
+     */
     public void setSampleStrength(float sampleStrength) {
         this.sampleStrength = sampleStrength;
     }
 
     @Override
-    public void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
+    protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
         material = new Material(manager, "Common/MatDefs/Blur/RadialBlur.j3md");
     }
 
@@ -111,8 +153,4 @@ public class RadialBlurFilter extends Filter {
         sampleDist = ic.readFloat("sampleDist", 1.0f);
         sampleStrength = ic.readFloat("sampleStrength", 2.2f);
     }
-
-    @Override
-    public void cleanUpFilter(Renderer r) {
-    }
 }
index 12016d4..47be413 100644 (file)
@@ -16,7 +16,8 @@ import com.jme3.texture.FrameBuffer;
 import com.jme3.texture.Texture2D;
 
 /**
- *
+ * A filter to handle translucent objects when rendering a scene with filters that uses depth like WaterFilter and SSAOFilter
+ * just create a TranslucentBucketFilter and add it to the Filter list of a FilterPostPorcessor
  * @author Nehon
  */
 public final class TranslucentBucketFilter extends Filter {
@@ -24,7 +25,7 @@ public final class TranslucentBucketFilter extends Filter {
     private RenderManager renderManager;
 
     @Override
-    public void initFilter(AssetManager manager, RenderManager rm, ViewPort vp, int w, int h) {
+    protected void initFilter(AssetManager manager, RenderManager rm, ViewPort vp, int w, int h) {
         this.renderManager = rm;
         material = new Material(manager, "Common/MatDefs/Post/Overlay.j3md");
         material.setColor("Color", ColorRGBA.White);
@@ -37,19 +38,20 @@ public final class TranslucentBucketFilter extends Filter {
         }
         renderManager.setHandleTranslucentBucket(false);
     }
-    
-     /**
+
+    /**
      * Override this method and return false if your Filter does not need the scene texture
      * @return
      */
-    public boolean isRequiresSceneTexture() {
+    @Override
+    protected boolean isRequiresSceneTexture() {
         return false;
     }
 
     @Override
-    public void postFrame(RenderManager renderManager, ViewPort viewPort, FrameBuffer prevFilterBuffer, FrameBuffer sceneBuffer) {
+    protected void postFrame(RenderManager renderManager, ViewPort viewPort, FrameBuffer prevFilterBuffer, FrameBuffer sceneBuffer) {
         renderManager.setCamera(viewPort.getCamera(), false);
-        if(prevFilterBuffer != sceneBuffer){
+        if (prevFilterBuffer != sceneBuffer) {
             renderManager.getRenderer().copyFrameBuffer(prevFilterBuffer, sceneBuffer, false);
         }
         renderManager.getRenderer().setFrameBuffer(sceneBuffer);
@@ -57,14 +59,14 @@ public final class TranslucentBucketFilter extends Filter {
     }
 
     @Override
-    public void cleanUpFilter(Renderer r) {
+    protected void cleanUpFilter(Renderer r) {
         if (renderManager != null) {
             renderManager.setHandleTranslucentBucket(true);
         }
     }
 
     @Override
-    public Material getMaterial() {
+    protected Material getMaterial() {
         return material;
     }
 
index a2281ec..fc5fdd6 100644 (file)
@@ -96,12 +96,12 @@ public class SSAOFilter extends Filter {
     }
 
     @Override
-    public boolean isRequiresDepthTexture() {
+    protected boolean isRequiresDepthTexture() {
         return true;
     }
 
     @Override
-    public void postQueue(RenderManager renderManager, ViewPort viewPort) {
+    protected void postQueue(RenderManager renderManager, ViewPort viewPort) {
         Renderer r = renderManager.getRenderer();
         r.setFrameBuffer(normalPass.getRenderFrameBuffer());
         renderManager.getRenderer().clearBuffers(true, true, true);
@@ -112,12 +112,12 @@ public class SSAOFilter extends Filter {
     }
 
     @Override
-    public Material getMaterial() {
+    protected Material getMaterial() {
         return material;
     }
 
     @Override
-    public void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
+    protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
         int screenWidth = w;
         int screenHeight = h;
         postRenderPasses = new ArrayList<Pass>();
@@ -270,7 +270,5 @@ public class SSAOFilter extends Filter {
         bias = ic.readFloat("bias", 0.1f);
     }
 
-    @Override
-    public void cleanUpFilter(Renderer r) {
-    }
+
 }
index 49927b0..2f35f6e 100644 (file)
@@ -112,7 +112,6 @@ public class WaterFilter extends Filter {
     private boolean underWater;
     private float underWaterFogDistance = 120;
     private float causticsIntensity = 0.5f;
-    
     private RenderManager renderManager;
     private ViewPort viewPort;
 
@@ -130,12 +129,12 @@ public class WaterFilter extends Filter {
     }
 
     @Override
-    public boolean isRequiresDepthTexture() {
+    protected boolean isRequiresDepthTexture() {
         return true;
     }
 
     @Override
-    public void preFrame(float tpf) {
+    protected void preFrame(float tpf) {
         time = time + (tpf * speed);
         material.setFloat("Time", time);
         Camera sceneCam = viewPort.getCamera();
@@ -172,7 +171,7 @@ public class WaterFilter extends Filter {
         float planeDistance = plane.pseudoDistance(vars.vect1);
         vars.vect2.set(plane.getNormal()).multLocal(planeDistance * 2.0f);
         vars.vect3.set(vars.vect1.subtractLocal(vars.vect2)).subtractLocal(loc).normalizeLocal().negateLocal();
-        
+
         reflectionCam.lookAt(targetLocation, vars.vect3);
 
         assert vars.unlock();
@@ -193,8 +192,8 @@ public class WaterFilter extends Filter {
             }
             renderManager.setCamera(sceneCam, false);
             renderManager.getRenderer().setFrameBuffer(viewPort.getOutputFrameBuffer());
-                        
-            
+
+
             underWater = false;
         } else {
             underWater = true;
@@ -202,21 +201,14 @@ public class WaterFilter extends Filter {
     }
 
     @Override
-    public void init(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
-        super.init(manager, renderManager, vp, w, h);
-        this.renderManager=renderManager;
-        this.viewPort=vp;
-    }
-      
-
-    @Override
-    public Material getMaterial() {
+    protected Material getMaterial() {
         return material;
     }
 
     @Override
-    public void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
-
+    protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
+        this.renderManager = renderManager;
+        this.viewPort = vp;
         reflectionPass = new Pass();
         reflectionPass.init(renderManager.getRenderer(), reflectionMapSize, reflectionMapSize, Format.RGBA8, Format.Depth);
         reflectionCam = new Camera(reflectionMapSize, reflectionMapSize);
@@ -746,13 +738,6 @@ public class WaterFilter extends Filter {
         this.reflectionMapSize = reflectionMapSize;
     }
 
-    @Override
-    public void cleanUpFilter(Renderer r) {
-        if (reflectionPass != null) {
-            reflectionPass.cleanup(r);
-        }
-    }
-
     /**
      * returns true if the water uses foam
      * @return