Java examples for Game:JME3
Terrain From Scene in jme3
package Chapter8; import com.jme3.app.SimpleApplication; import com.jme3.light.DirectionalLight; import com.jme3.math.ColorRGBA; import com.jme3.math.FastMath; import com.jme3.math.Vector3f; import com.jme3.post.FilterPostProcessor; import com.jme3.post.filters.FogFilter; import com.jme3.renderer.RenderManager; import com.jme3.renderer.queue.RenderQueue.Bucket; import com.jme3.scene.Spatial; /**//w ww .ja v a 2 s . c o m * test * * @author normenhansen */ public class TerrainFromScene extends SimpleApplication { private FilterPostProcessor fpp; private FogFilter fogFilter; public static void main(String[] args) { TerrainFromScene app = new TerrainFromScene(); app.start(); } @Override public void simpleInitApp() { Spatial terrainGeo = assetManager.loadModel("Scenes/myTerrain.j3o"); terrainGeo.setLocalTranslation(0, 0, -120f); rootNode.attachChild(terrainGeo); DirectionalLight sun = new DirectionalLight(); sun.setDirection(new Vector3f(-0.39f, -0.32f, -0.74f)); rootNode.addLight(sun); Spatial treeGeo = assetManager .loadModel("Models/Tree/Tree.mesh.j3o"); treeGeo.scale(5); // make tree bigger treeGeo.setQueueBucket(Bucket.Transparent); // transparent leaves rootNode.attachChild(treeGeo); Vector3f treeLoc = new Vector3f(-30, 0, -30); treeLoc.setY(terrainGeo.getLocalTranslation().getY()); treeGeo.setLocalTranslation(treeLoc); Spatial mySky = assetManager.loadModel("Scenes/mySky.j3o"); mySky.rotate(0, FastMath.DEG_TO_RAD * 30, 0); rootNode.attachChild(mySky); fpp = new FilterPostProcessor(assetManager); viewPort.addProcessor(fpp); //Initialize the FogFilter and //add it to the FilterPostProcesor. fogFilter = new FogFilter(); fogFilter.setFogDistance(155); fogFilter.setFogDensity(1.3f); fogFilter.setFogColor(ColorRGBA.Black); fpp.addFilter(fogFilter); } @Override public void simpleUpdate(float tpf) { //TODO: add update code } @Override public void simpleRender(RenderManager rm) { //TODO: add render code } }