1
0
mirror of https://github.com/Dejvino/roadtrip synced 2024-11-22 07:52:36 +00:00

Added Fog and FOV.

This commit is contained in:
Dejvino 2017-02-05 17:44:57 +01:00
parent 66039dfa8e
commit cdfd018985
2 changed files with 18 additions and 1 deletions

View File

@ -15,6 +15,7 @@ import com.jme3.material.Material;
import com.jme3.math.*; import com.jme3.math.*;
import com.jme3.post.FilterPostProcessor; import com.jme3.post.FilterPostProcessor;
import com.jme3.post.filters.DepthOfFieldFilter; import com.jme3.post.filters.DepthOfFieldFilter;
import com.jme3.post.filters.FogFilter;
import com.jme3.scene.Geometry; import com.jme3.scene.Geometry;
import com.jme3.scene.Node; import com.jme3.scene.Node;
import com.jme3.scene.Spatial; import com.jme3.scene.Spatial;
@ -49,6 +50,7 @@ public class RoadTrip extends GameApplication implements ActionListener, AnalogL
private CameraType cameraType = CameraType.FIRST_PERSON; private CameraType cameraType = CameraType.FIRST_PERSON;
private ChaseCamera chaseCam; private ChaseCamera chaseCam;
private float camFov = 85;
private Player player = new Player(); private Player player = new Player();
@ -118,6 +120,8 @@ public class RoadTrip extends GameApplication implements ActionListener, AnalogL
addCompass(); addCompass();
addGameMenu(); addGameMenu();
cam.setFrustumPerspective(camFov, settings.getWidth() / ((float)settings.getHeight()), 0.5f, 150f);
chaseCam = new ChaseCamera(cam, player.node, inputManager); chaseCam = new ChaseCamera(cam, player.node, inputManager);
chaseCam.setDefaultDistance(60f); chaseCam.setDefaultDistance(60f);
chaseCam.setSmoothMotion(true); chaseCam.setSmoothMotion(true);
@ -125,11 +129,20 @@ public class RoadTrip extends GameApplication implements ActionListener, AnalogL
fpp = new FilterPostProcessor(assetManager); fpp = new FilterPostProcessor(assetManager);
//fpp.setNumSamples(4); //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 = new DepthOfFieldFilter();
dofFilter.setFocusRange(5f); dofFilter.setFocusRange(5f);
dofFilter.setFocusDistance(6f); dofFilter.setFocusDistance(6f);
dofFilter.setBlurScale(0.6f); dofFilter.setBlurScale(0.6f);
fpp.addFilter(dofFilter); fpp.addFilter(dofFilter);
viewPort.addProcessor(fpp);
viewPort.addProcessor(fpp); viewPort.addProcessor(fpp);
} }

View File

@ -34,6 +34,7 @@ import com.jme3.terrain.noise.filter.SmoothFilter;
import com.jme3.terrain.noise.fractal.FractalSum; import com.jme3.terrain.noise.fractal.FractalSum;
import com.jme3.terrain.noise.modulator.NoiseModulator; import com.jme3.terrain.noise.modulator.NoiseModulator;
import com.jme3.texture.Texture; import com.jme3.texture.Texture;
import com.jme3.util.SkyFactory;
import java.util.Random; import java.util.Random;
import roadtrip.model.MapObjectInstance; import roadtrip.model.MapObjectInstance;
import roadtrip.model.ProceduralMapQuadBlock; import roadtrip.model.ProceduralMapQuadBlock;
@ -88,6 +89,9 @@ public class GameWorldView {
al.setColor(new ColorRGBA(0.5f, 0.5f, 0.5f, 1.0f)); al.setColor(new ColorRGBA(0.5f, 0.5f, 0.5f, 1.0f));
rootNode.addLight(al); rootNode.addLight(al);
// load sky
rootNode.attachChild(SkyFactory.createSky(assetManager, "Textures/Sky/Bright/BrightSky.dds", false));
// TERRAIN TEXTURE material // TERRAIN TEXTURE material
terrain.mat_terrain = new Material(assetManager, "Common/MatDefs/Terrain/HeightBasedTerrain.j3md"); terrain.mat_terrain = new Material(assetManager, "Common/MatDefs/Terrain/HeightBasedTerrain.j3md");
if (DEBUG) { if (DEBUG) {