If you have ever walked through unfamiliar terrain when it was foggy, you know the eerie feeling. Shadows scurry at the edge of your vision and monsters seem to lurk behind every tree. Isn't that just the atmosphere that you need for your game?
Thanks to the post-processor, adding fog to a scene is very easy:
Make a copy of
Main.java
and name the classFog.java
. Remember to also refactor the first line of themain()
method to the following:Fog app = new Fog();
Load a scene model or terrain of your choice. Re-use code from the previous examples. Remember to add a light.
Create one
FilterPostProcessor
per game, and aFogFilter
(from thecom.jme3.post
package).private FilterPostProcessor fpp; private FogFilter fogFilter;
In the
simpleInitApp()
method, initialize theFilterPostProcessor
, and add it to theviewPort
.public void simpleInitApp() { fpp = new FilterPostProcessor(assetManager); viewPort.addProcessor(fpp); //Initialize the FogFilter and //add...