1
0
mirror of https://github.com/Dejvino/roadtrip synced 2024-11-14 13:03:28 +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.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);
}

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.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) {