mirror of
https://github.com/Dejvino/roadtrip
synced 2024-11-13 04:27:30 +00:00
Map: added grass and depth-of-field filter.
This commit is contained in:
parent
94faf05d7e
commit
a32565ef00
23
assets/Materials/Generated/grass-Material_001.j3m
Normal file
23
assets/Materials/Generated/grass-Material_001.j3m
Normal file
@ -0,0 +1,23 @@
|
||||
Material MyMaterial : Common/MatDefs/Light/Lighting.j3md {
|
||||
MaterialParameters {
|
||||
DiffuseMap : Models/grass.png
|
||||
GlowColor : 0.0 0.0 0.0 1.0
|
||||
Specular : 0.0 0.0 0.0 1.0
|
||||
Diffuse : 0.9258238 0.9258238 0.9258238 1.0
|
||||
UseMaterialColors : true
|
||||
ParallaxHeight : 0.05
|
||||
Ambient : 0.9258238 0.9258238 0.9258238 1.0
|
||||
Shininess : 12.5
|
||||
}
|
||||
AdditionalRenderState {
|
||||
FaceCull Off
|
||||
Wireframe Off
|
||||
DepthWrite On
|
||||
PolyOffset 0.0 0.0
|
||||
AlphaTestFalloff 0.0
|
||||
Blend PremultAlpha
|
||||
PointSprite Off
|
||||
ColorWrite On
|
||||
DepthTest On
|
||||
}
|
||||
}
|
BIN
assets/Models/grass.j3o
Normal file
BIN
assets/Models/grass.j3o
Normal file
Binary file not shown.
3
assets/Models/grass.j3odata
Normal file
3
assets/Models/grass.j3odata
Normal file
@ -0,0 +1,3 @@
|
||||
#
|
||||
#Fri Jan 27 21:02:15 CET 2017
|
||||
ORIGINAL_PATH=Models/grass.scene
|
BIN
assets/Models/grass.png
Normal file
BIN
assets/Models/grass.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 554 B |
@ -41,7 +41,8 @@ javac.classpath=\
|
||||
${libs.jme3-test-data.classpath}:\
|
||||
${libs.jme3-libraries-oggvorbis.classpath}:\
|
||||
${libs.jme3-libraries-lwjgl-minimum.classpath}:\
|
||||
${libs.jme3-libraries-terrain.classpath}
|
||||
${libs.jme3-libraries-terrain.classpath}:\
|
||||
${libs.jme3-libraries-effects.classpath}
|
||||
# Space-separated list of extra javac options
|
||||
javac.compilerargs=
|
||||
javac.deprecation=false
|
||||
|
BIN
screenshot.png
BIN
screenshot.png
Binary file not shown.
Before Width: | Height: | Size: 773 KiB After Width: | Height: | Size: 706 KiB |
@ -10,6 +10,8 @@ import com.jme3.light.AmbientLight;
|
||||
import com.jme3.light.DirectionalLight;
|
||||
import com.jme3.material.Material;
|
||||
import com.jme3.math.*;
|
||||
import com.jme3.post.FilterPostProcessor;
|
||||
import com.jme3.post.filters.DepthOfFieldFilter;
|
||||
import com.jme3.scene.Geometry;
|
||||
import com.jme3.scene.Node;
|
||||
import com.jme3.scene.Spatial;
|
||||
@ -53,6 +55,9 @@ public class RoadTrip extends GameApplication implements ActionListener {
|
||||
|
||||
int score = 0;
|
||||
|
||||
private FilterPostProcessor fpp;
|
||||
DepthOfFieldFilter dofFilter;
|
||||
|
||||
@Override
|
||||
public void initializeGame() {
|
||||
super.initializeGame();
|
||||
@ -101,6 +106,16 @@ public class RoadTrip extends GameApplication implements ActionListener {
|
||||
chaseCam = new ChaseCamera(cam, player.node, inputManager);
|
||||
chaseCam.setDefaultDistance(60f);
|
||||
chaseCam.setSmoothMotion(true);
|
||||
|
||||
fpp = new FilterPostProcessor(assetManager);
|
||||
//fpp.setNumSamples(4);
|
||||
|
||||
dofFilter = new DepthOfFieldFilter();
|
||||
dofFilter.setFocusRange(5f);
|
||||
dofFilter.setFocusDistance(6f);
|
||||
dofFilter.setBlurScale(0.6f);
|
||||
fpp.addFilter(dofFilter);
|
||||
viewPort.addProcessor(fpp);
|
||||
}
|
||||
|
||||
protected void addGameMenu()
|
||||
@ -203,6 +218,10 @@ public class RoadTrip extends GameApplication implements ActionListener {
|
||||
Vector3f playerLocation = player.node.getWorldTranslation();
|
||||
Vector3f newLocation = new Vector3f(playerLocation).add(new Vector3f(-1f, 1.5f, 2.4f).mult(20f));
|
||||
|
||||
float focusDist = cam.getLocation().distance(player.node.getWorldTranslation()) / 10f;
|
||||
dofFilter.setFocusDistance(focusDist * 1.1f);
|
||||
dofFilter.setFocusRange(focusDist * 0.9f);
|
||||
|
||||
for (VehicleNode vehicle : gameWorldState.vehicles) {
|
||||
vehicle.update(tpf);
|
||||
}
|
||||
|
@ -12,6 +12,8 @@ import com.jme3.material.Material;
|
||||
import com.jme3.math.ColorRGBA;
|
||||
import com.jme3.math.Vector2f;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.post.FilterPostProcessor;
|
||||
import com.jme3.post.filters.DepthOfFieldFilter;
|
||||
import com.jme3.renderer.Camera;
|
||||
import com.jme3.scene.Node;
|
||||
import com.jme3.scene.Spatial;
|
||||
@ -47,7 +49,7 @@ public class GameWorldView {
|
||||
private final Camera camera;
|
||||
private final Node rootNode;
|
||||
private final PhysicsSpace physicsSpace;
|
||||
|
||||
|
||||
public TerrainView terrain = new TerrainView(new TerrainDataProvider());
|
||||
|
||||
public GameWorldView(GameWorldState gameWorldState, AssetManager assetManager, Camera camera, Node rootNode, PhysicsSpace physicsSpace) {
|
||||
@ -171,12 +173,13 @@ public class GameWorldView {
|
||||
|
||||
final Spatial treeModel = assetManager.loadModel("Models/tree.j3o");
|
||||
final Spatial houseModel = assetManager.loadModel("Models/house1.j3o");
|
||||
final Spatial grassModel = assetManager.loadModel("Models/grass.j3o");
|
||||
|
||||
final FineTerrainGrid terrainGrid = terrain.terrainGrid;
|
||||
terrainGrid.addListener(new TerrainGridListener() {
|
||||
|
||||
@Override
|
||||
public void gridMoved(Vector3f newCenter) {
|
||||
public void gridMoved(Vector3f newCenter) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -240,10 +243,29 @@ public class GameWorldView {
|
||||
modelPhysics.isActive();
|
||||
modelInstance.addControl(modelPhysics);
|
||||
modelPhysics.setPhysicsLocation(pos);
|
||||
physicsSpace.add(modelPhysics);
|
||||
//physicsSpace.add(modelPhysics);
|
||||
}
|
||||
objects.attachChild(modelInstance);
|
||||
}
|
||||
|
||||
for (int i = 0; i < rand.nextInt(10000); i++) {
|
||||
Vector3f pos = new Vector3f((rand.nextFloat() - 0.5f) * 128f, 0f, (rand.nextFloat() - 0.5f) * 128f).addLocal(quad.getWorldTranslation());
|
||||
pos.addLocal(0f, getHeight(quad, pos), 0f);
|
||||
Vector3f scale = Vector3f.UNIT_XYZ;
|
||||
Spatial modelInstance;
|
||||
switch ("grass") {
|
||||
case "grass":
|
||||
modelInstance = grassModel.clone();
|
||||
float s = 0.2f + rand.nextFloat() * 2f;
|
||||
scale = new Vector3f(s, s, s);
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException("Unhandled object type");
|
||||
}
|
||||
modelInstance.setLocalTranslation(pos);
|
||||
modelInstance.setLocalScale(scale);
|
||||
objects.attachChild(modelInstance);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user