1 package jme3test.light;
2 
3 import com.jme3.app.SimpleApplication;
4 import com.jme3.asset.TextureKey;
5 import com.jme3.input.ChaseCamera;
6 import com.jme3.material.Material;
7 import com.jme3.math.Vector3f;
8 import com.jme3.post.FilterPostProcessor;
9 import com.jme3.post.filters.BloomFilter;
10 import com.jme3.scene.Geometry;
11 import com.jme3.scene.Node;
12 import com.jme3.scene.Spatial;
13 import com.jme3.texture.Texture;
14 import com.jme3.util.SkyFactory;
15 
16 /**
17  * test
18  * @author nehon
19  */
20 public class TestEnvironmentMapping extends SimpleApplication {
21 
main(String[] args)22     public static void main(String[] args) {
23         TestEnvironmentMapping app = new TestEnvironmentMapping();
24         app.start();
25     }
26 
27     @Override
simpleInitApp()28     public void simpleInitApp() {
29         final Node buggy = (Node) assetManager.loadModel("Models/Buggy/Buggy.j3o");
30 
31         TextureKey key = new TextureKey("Textures/Sky/Bright/BrightSky.dds", true);
32         key.setGenerateMips(true);
33         key.setAsCube(true);
34         final Texture tex = assetManager.loadTexture(key);
35 
36         for (Spatial geom : buggy.getChildren()) {
37             if (geom instanceof Geometry) {
38                 Material m = ((Geometry) geom).getMaterial();
39                 m.setTexture("EnvMap", tex);
40                 m.setVector3("FresnelParams", new Vector3f(0.05f, 0.18f, 0.11f));
41             }
42         }
43 
44         flyCam.setEnabled(false);
45 
46         ChaseCamera chaseCam = new ChaseCamera(cam, inputManager);
47         chaseCam.setLookAtOffset(new Vector3f(0,0.5f,-1.0f));
48         buggy.addControl(chaseCam);
49         rootNode.attachChild(buggy);
50         rootNode.attachChild(SkyFactory.createSky(assetManager, tex, false));
51 
52         FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
53         BloomFilter bf = new BloomFilter(BloomFilter.GlowMode.Objects);
54         bf.setBloomIntensity(2.3f);
55         bf.setExposurePower(0.6f);
56 
57         fpp.addFilter(bf);
58 
59         viewPort.addProcessor(fpp);
60     }
61 }
62