From cdfd0189857b12772abaef73bd27194e07e7a233 Mon Sep 17 00:00:00 2001 From: Dejvino Date: Sun, 5 Feb 2017 17:44:57 +0100 Subject: [PATCH] Added Fog and FOV. --- src/roadtrip/RoadTrip.java | 15 ++++++++++++++- src/roadtrip/view/GameWorldView.java | 4 ++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/roadtrip/RoadTrip.java b/src/roadtrip/RoadTrip.java index 71d5418..80a154c 100644 --- a/src/roadtrip/RoadTrip.java +++ b/src/roadtrip/RoadTrip.java @@ -15,6 +15,7 @@ import com.jme3.material.Material; import com.jme3.math.*; import com.jme3.post.FilterPostProcessor; import com.jme3.post.filters.DepthOfFieldFilter; +import com.jme3.post.filters.FogFilter; import com.jme3.scene.Geometry; import com.jme3.scene.Node; import com.jme3.scene.Spatial; @@ -49,6 +50,7 @@ public class RoadTrip extends GameApplication implements ActionListener, AnalogL private CameraType cameraType = CameraType.FIRST_PERSON; private ChaseCamera chaseCam; + private float camFov = 85; private Player player = new Player(); @@ -118,18 +120,29 @@ public class RoadTrip extends GameApplication implements ActionListener, AnalogL addCompass(); addGameMenu(); + cam.setFrustumPerspective(camFov, settings.getWidth() / ((float)settings.getHeight()), 0.5f, 150f); + chaseCam = new ChaseCamera(cam, player.node, inputManager); chaseCam.setDefaultDistance(60f); chaseCam.setSmoothMotion(true); fpp = new FilterPostProcessor(assetManager); //fpp.setNumSamples(4); - + + FogFilter fog=new FogFilter(); + fog.setFogColor(new ColorRGBA(0.02f, 0.02f, 0.05f, 1.0f)); + fog.setFogDistance(1000); + fog.setFogDensity(3.0f); + fpp.addFilter(fog); + dofFilter = new DepthOfFieldFilter(); dofFilter.setFocusRange(5f); dofFilter.setFocusDistance(6f); dofFilter.setBlurScale(0.6f); fpp.addFilter(dofFilter); + + viewPort.addProcessor(fpp); + viewPort.addProcessor(fpp); } diff --git a/src/roadtrip/view/GameWorldView.java b/src/roadtrip/view/GameWorldView.java index 628582f..d72fe48 100644 --- a/src/roadtrip/view/GameWorldView.java +++ b/src/roadtrip/view/GameWorldView.java @@ -34,6 +34,7 @@ import com.jme3.terrain.noise.filter.SmoothFilter; import com.jme3.terrain.noise.fractal.FractalSum; import com.jme3.terrain.noise.modulator.NoiseModulator; import com.jme3.texture.Texture; +import com.jme3.util.SkyFactory; import java.util.Random; import roadtrip.model.MapObjectInstance; import roadtrip.model.ProceduralMapQuadBlock; @@ -88,6 +89,9 @@ public class GameWorldView { al.setColor(new ColorRGBA(0.5f, 0.5f, 0.5f, 1.0f)); rootNode.addLight(al); + // load sky + rootNode.attachChild(SkyFactory.createSky(assetManager, "Textures/Sky/Bright/BrightSky.dds", false)); + // TERRAIN TEXTURE material terrain.mat_terrain = new Material(assetManager, "Common/MatDefs/Terrain/HeightBasedTerrain.j3md"); if (DEBUG) {