| package jme3test.light; |
| |
| import com.jme3.app.SimpleApplication; |
| import com.jme3.asset.TextureKey; |
| import com.jme3.input.ChaseCamera; |
| import com.jme3.material.Material; |
| import com.jme3.math.Vector3f; |
| import com.jme3.post.FilterPostProcessor; |
| import com.jme3.post.filters.BloomFilter; |
| import com.jme3.scene.Geometry; |
| import com.jme3.scene.Node; |
| import com.jme3.scene.Spatial; |
| import com.jme3.texture.Texture; |
| import com.jme3.util.SkyFactory; |
| |
| /** |
| * test |
| * @author nehon |
| */ |
| public class TestEnvironmentMapping extends SimpleApplication { |
| |
| public static void main(String[] args) { |
| TestEnvironmentMapping app = new TestEnvironmentMapping(); |
| app.start(); |
| } |
| |
| @Override |
| public void simpleInitApp() { |
| final Node buggy = (Node) assetManager.loadModel("Models/Buggy/Buggy.j3o"); |
| |
| TextureKey key = new TextureKey("Textures/Sky/Bright/BrightSky.dds", true); |
| key.setGenerateMips(true); |
| key.setAsCube(true); |
| final Texture tex = assetManager.loadTexture(key); |
| |
| for (Spatial geom : buggy.getChildren()) { |
| if (geom instanceof Geometry) { |
| Material m = ((Geometry) geom).getMaterial(); |
| m.setTexture("EnvMap", tex); |
| m.setVector3("FresnelParams", new Vector3f(0.05f, 0.18f, 0.11f)); |
| } |
| } |
| |
| flyCam.setEnabled(false); |
| |
| ChaseCamera chaseCam = new ChaseCamera(cam, inputManager); |
| chaseCam.setLookAtOffset(new Vector3f(0,0.5f,-1.0f)); |
| buggy.addControl(chaseCam); |
| rootNode.attachChild(buggy); |
| rootNode.attachChild(SkyFactory.createSky(assetManager, tex, false)); |
| |
| FilterPostProcessor fpp = new FilterPostProcessor(assetManager); |
| BloomFilter bf = new BloomFilter(BloomFilter.GlowMode.Objects); |
| bf.setBloomIntensity(2.3f); |
| bf.setExposurePower(0.6f); |
| |
| fpp.addFilter(bf); |
| |
| viewPort.addProcessor(fpp); |
| } |
| } |