use of com.jme3.terrain.Terrain in project jmonkeyengine by jMonkeyEngine.
the class TestPssmShadow method loadScene.
public void loadScene() {
obj = new Spatial[2];
mat = new Material[2];
mat[0] = assetManager.loadMaterial("Common/Materials/RedColor.j3m");
mat[1] = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m");
mat[1].setBoolean("UseMaterialColors", true);
mat[1].setColor("Ambient", ColorRGBA.White.mult(0.5f));
mat[1].setColor("Diffuse", ColorRGBA.White.clone());
obj[0] = new Geometry("sphere", new Sphere(30, 30, 2));
obj[0].setShadowMode(ShadowMode.CastAndReceive);
obj[1] = new Geometry("cube", new Box(1.0f, 1.0f, 1.0f));
obj[1].setShadowMode(ShadowMode.CastAndReceive);
TangentBinormalGenerator.generate(obj[1]);
TangentBinormalGenerator.generate(obj[0]);
for (int i = 0; i < 60; i++) {
Spatial t = obj[FastMath.nextRandomInt(0, obj.length - 1)].clone(false);
t.setLocalScale(FastMath.nextRandomFloat() * 10f);
t.setMaterial(mat[FastMath.nextRandomInt(0, mat.length - 1)]);
rootNode.attachChild(t);
t.setLocalTranslation(FastMath.nextRandomFloat() * 200f, FastMath.nextRandomFloat() * 30f + 20, 30f * (i + 2f));
}
Box b = new Box(1000, 2, 1000);
b.scaleTextureCoordinates(new Vector2f(10, 10));
ground = new Geometry("soil", b);
ground.setLocalTranslation(0, 10, 550);
matGroundU = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
matGroundU.setColor("Color", ColorRGBA.Green);
matGroundL = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
Texture grass = assetManager.loadTexture("Textures/Terrain/splat/grass.jpg");
grass.setWrap(WrapMode.Repeat);
matGroundL.setTexture("DiffuseMap", grass);
ground.setMaterial(matGroundL);
ground.setShadowMode(ShadowMode.CastAndReceive);
rootNode.attachChild(ground);
l = new DirectionalLight();
l.setDirection(new Vector3f(-1, -1, -1));
rootNode.addLight(l);
AmbientLight al = new AmbientLight();
al.setColor(ColorRGBA.White.mult(0.5f));
rootNode.addLight(al);
Spatial sky = SkyFactory.createSky(assetManager, "Scenes/Beach/FullskiesSunset0068.dds", false);
sky.setLocalScale(350);
rootNode.attachChild(sky);
}
use of com.jme3.terrain.Terrain in project jmonkeyengine by jMonkeyEngine.
the class TestShadowBug method makeFloor.
protected Geometry makeFloor() {
Box box = new Box(220, .2f, 220);
box.scaleTextureCoordinates(new Vector2f(10, 10));
Geometry floor = new Geometry("the Floor", box);
floor.setLocalTranslation(200, -9, 200);
Material matGroundL = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
Texture grass = assetManager.loadTexture("Textures/Terrain/splat/grass.jpg");
grass.setWrap(WrapMode.Repeat);
matGroundL.setTexture("DiffuseMap", grass);
floor.setMaterial(matGroundL);
floor.setShadowMode(ShadowMode.CastAndReceive);
return floor;
}
use of com.jme3.terrain.Terrain in project jmonkeyengine by jMonkeyEngine.
the class TestSpotLight method setupFloor.
public void setupFloor() {
Material mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m");
mat.getTextureParam("DiffuseMap").getTextureValue().setWrap(WrapMode.Repeat);
mat.getTextureParam("NormalMap").getTextureValue().setWrap(WrapMode.Repeat);
// mat.getTextureParam("ParallaxMap").getTextureValue().setWrap(WrapMode.Repeat);
mat.setFloat("Shininess", 3);
// mat.setBoolean("VertexLighting", true);
Box floor = new Box(50, 1f, 50);
TangentBinormalGenerator.generate(floor);
floor.scaleTextureCoordinates(new Vector2f(5, 5));
Geometry floorGeom = new Geometry("Floor", floor);
floorGeom.setMaterial(mat);
floorGeom.setShadowMode(ShadowMode.Receive);
rootNode.attachChild(floorGeom);
}
use of com.jme3.terrain.Terrain in project jmonkeyengine by jMonkeyEngine.
the class TestSpotLightTerrain method makeTerrain.
private void makeTerrain() {
// TERRAIN TEXTURE material
matTerrain = new Material(assetManager, "Common/MatDefs/Terrain/TerrainLighting.j3md");
matTerrain.setBoolean("useTriPlanarMapping", false);
matTerrain.setBoolean("WardIso", true);
// ALPHA map (for splat textures)
matTerrain.setTexture("AlphaMap", assetManager.loadTexture("Textures/Terrain/splat/alpha1.png"));
matTerrain.setTexture("AlphaMap_1", assetManager.loadTexture("Textures/Terrain/splat/alpha2.png"));
// HEIGHTMAP image (for the terrain heightmap)
Texture heightMapImage = assetManager.loadTexture("Textures/Terrain/splat/mountains512.png");
// GRASS texture
Texture grass = assetManager.loadTexture("Textures/Terrain/splat/grass.jpg");
grass.setWrap(WrapMode.Repeat);
matTerrain.setTexture("DiffuseMap", grass);
matTerrain.setFloat("DiffuseMap_0_scale", grassScale);
// DIRT texture
Texture dirt = assetManager.loadTexture("Textures/Terrain/splat/dirt.jpg");
dirt.setWrap(WrapMode.Repeat);
matTerrain.setTexture("DiffuseMap_1", dirt);
matTerrain.setFloat("DiffuseMap_1_scale", dirtScale);
// ROCK texture
Texture rock = assetManager.loadTexture("Textures/Terrain/splat/road.jpg");
rock.setWrap(WrapMode.Repeat);
matTerrain.setTexture("DiffuseMap_2", rock);
matTerrain.setFloat("DiffuseMap_2_scale", rockScale);
// BRICK texture
Texture brick = assetManager.loadTexture("Textures/Terrain/BrickWall/BrickWall.jpg");
brick.setWrap(WrapMode.Repeat);
matTerrain.setTexture("DiffuseMap_3", brick);
matTerrain.setFloat("DiffuseMap_3_scale", rockScale);
// RIVER ROCK texture
Texture riverRock = assetManager.loadTexture("Textures/Terrain/Pond/Pond.jpg");
riverRock.setWrap(WrapMode.Repeat);
matTerrain.setTexture("DiffuseMap_4", riverRock);
matTerrain.setFloat("DiffuseMap_4_scale", rockScale);
Texture normalMap0 = assetManager.loadTexture("Textures/Terrain/splat/grass_normal.jpg");
normalMap0.setWrap(WrapMode.Repeat);
Texture normalMap1 = assetManager.loadTexture("Textures/Terrain/splat/dirt_normal.png");
normalMap1.setWrap(WrapMode.Repeat);
Texture normalMap2 = assetManager.loadTexture("Textures/Terrain/splat/road_normal.png");
normalMap2.setWrap(WrapMode.Repeat);
matTerrain.setTexture("NormalMap", normalMap0);
matTerrain.setTexture("NormalMap_1", normalMap2);
matTerrain.setTexture("NormalMap_2", normalMap2);
matTerrain.setTexture("NormalMap_4", normalMap2);
// WIREFRAME material
matWire = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
matWire.getAdditionalRenderState().setWireframe(true);
matWire.setColor("Color", ColorRGBA.Green);
createSky();
// CREATE HEIGHTMAP
AbstractHeightMap heightmap = null;
try {
//heightmap = new HillHeightMap(1025, 1000, 50, 100, (byte) 3);
heightmap = new ImageBasedHeightMap(heightMapImage.getImage(), 1f);
heightmap.load();
} catch (Exception e) {
e.printStackTrace();
}
//, new LodPerspectiveCalculatorFactory(getCamera(), 4)); // add this in to see it use entropy for LOD calculations
terrain = new TerrainQuad("terrain", 65, 513, heightmap.getHeightMap());
TerrainLodControl control = new TerrainLodControl(terrain, getCamera());
control.setLodCalculator(new DistanceLodCalculator(65, 2.7f));
terrain.addControl(control);
terrain.setMaterial(matTerrain);
terrain.setModelBound(new BoundingBox());
terrain.updateModelBound();
terrain.setLocalTranslation(0, -100, 0);
terrain.setLocalScale(1f, 1f, 1f);
rootNode.attachChild(terrain);
}
use of com.jme3.terrain.Terrain in project jmonkeyengine by jMonkeyEngine.
the class TestTangentCube method simpleInitApp.
@Override
public void simpleInitApp() {
Box aBox = new Box(1, 1, 1);
Geometry aGeometry = new Geometry("Box", aBox);
TangentBinormalGenerator.generate(aBox);
Material aMaterial = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
aMaterial.setTexture("DiffuseMap", assetManager.loadTexture("Textures/Terrain/BrickWall/BrickWall.jpg"));
aMaterial.setTexture("NormalMap", assetManager.loadTexture("Textures/Terrain/BrickWall/BrickWall_normal.jpg"));
aMaterial.setBoolean("UseMaterialColors", false);
aMaterial.setColor("Diffuse", ColorRGBA.White);
aMaterial.setColor("Specular", ColorRGBA.White);
aMaterial.setFloat("Shininess", 64f);
aGeometry.setMaterial(aMaterial);
// Rotate 45 degrees to see multiple faces
aGeometry.rotate(FastMath.QUARTER_PI, FastMath.QUARTER_PI, 0.0f);
rootNode.attachChild(aGeometry);
/**
* Must add a light to make the lit object visible!
*/
PointLight aLight = new PointLight();
aLight.setPosition(new Vector3f(0, 3, 3));
aLight.setColor(ColorRGBA.Red);
rootNode.addLight(aLight);
//
// AmbientLight bLight = new AmbientLight();
// bLight.setColor(ColorRGBA.Gray);
// rootNode.addLight(bLight);
ChaseCameraAppState chaser = new ChaseCameraAppState();
chaser.setTarget(aGeometry);
getStateManager().attach(chaser);
}
Aggregations