use of com.jme3.terrain.Terrain in project jmonkeyengine by jMonkeyEngine.
the class TestSSAO method simpleInitApp.
@Override
public void simpleInitApp() {
cam.setLocation(new Vector3f(68.45442f, 8.235511f, 7.9676695f));
cam.setRotation(new Quaternion(0.046916496f, -0.69500375f, 0.045538206f, 0.7160271f));
flyCam.setMoveSpeed(50);
Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
Texture diff = assetManager.loadTexture("Textures/Terrain/BrickWall/BrickWall.jpg");
diff.setWrap(Texture.WrapMode.Repeat);
Texture norm = assetManager.loadTexture("Textures/Terrain/BrickWall/BrickWall_normal.jpg");
norm.setWrap(Texture.WrapMode.Repeat);
mat.setTexture("DiffuseMap", diff);
mat.setTexture("NormalMap", norm);
mat.setFloat("Shininess", 2.0f);
AmbientLight al = new AmbientLight();
al.setColor(new ColorRGBA(1.8f, 1.8f, 1.8f, 1.0f));
rootNode.addLight(al);
model = (Geometry) assetManager.loadModel("Models/Sponza/Sponza.j3o");
model.getMesh().scaleTextureCoordinates(new Vector2f(2, 2));
model.setMaterial(mat);
rootNode.attachChild(model);
FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
SSAOFilter ssaoFilter = new SSAOFilter(2.9299974f, 32.920483f, 5.8100376f, 0.091000035f);
;
ssaoFilter.setApproximateNormals(true);
fpp.addFilter(ssaoFilter);
SSAOUI ui = new SSAOUI(inputManager, ssaoFilter);
viewPort.addProcessor(fpp);
}
use of com.jme3.terrain.Terrain in project jmonkeyengine by jMonkeyEngine.
the class TestDepthOfField method createTerrain.
private void createTerrain(Node rootNode) {
matRock = new Material(assetManager, "Common/MatDefs/Terrain/TerrainLighting.j3md");
matRock.setBoolean("useTriPlanarMapping", false);
matRock.setBoolean("WardIso", true);
matRock.setTexture("AlphaMap", assetManager.loadTexture("Textures/Terrain/splat/alphamap.png"));
Texture heightMapImage = assetManager.loadTexture("Textures/Terrain/splat/mountains512.png");
Texture grass = assetManager.loadTexture("Textures/Terrain/splat/grass.jpg");
grass.setWrap(WrapMode.Repeat);
matRock.setTexture("DiffuseMap", grass);
matRock.setFloat("DiffuseMap_0_scale", 64);
Texture dirt = assetManager.loadTexture("Textures/Terrain/splat/dirt.jpg");
dirt.setWrap(WrapMode.Repeat);
matRock.setTexture("DiffuseMap_1", dirt);
matRock.setFloat("DiffuseMap_1_scale", 16);
Texture rock = assetManager.loadTexture("Textures/Terrain/splat/road.jpg");
rock.setWrap(WrapMode.Repeat);
matRock.setTexture("DiffuseMap_2", rock);
matRock.setFloat("DiffuseMap_2_scale", 128);
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);
matRock.setTexture("NormalMap", normalMap0);
matRock.setTexture("NormalMap_1", normalMap2);
matRock.setTexture("NormalMap_2", normalMap2);
AbstractHeightMap heightmap = null;
try {
heightmap = new ImageBasedHeightMap(heightMapImage.getImage(), 0.25f);
heightmap.load();
} catch (Exception e) {
e.printStackTrace();
}
terrain = new TerrainQuad("terrain", 65, 513, heightmap.getHeightMap());
List<Camera> cameras = new ArrayList<Camera>();
cameras.add(getCamera());
terrain.setMaterial(matRock);
terrain.setLocalScale(new Vector3f(5, 5, 5));
terrain.setLocalTranslation(new Vector3f(0, -30, 0));
// unlock it so we can edit the height
terrain.setLocked(false);
terrain.setShadowMode(ShadowMode.Receive);
rootNode.attachChild(terrain);
}
use of com.jme3.terrain.Terrain in project jmonkeyengine by jMonkeyEngine.
the class TestSpatialAnim method simpleInitApp.
@Override
public void simpleInitApp() {
AmbientLight al = new AmbientLight();
rootNode.addLight(al);
DirectionalLight dl = new DirectionalLight();
dl.setDirection(Vector3f.UNIT_XYZ.negate());
rootNode.addLight(dl);
// Create model
Box box = new Box(1, 1, 1);
Geometry geom = new Geometry("box", box);
geom.setMaterial(assetManager.loadMaterial("Textures/Terrain/BrickWall/BrickWall.j3m"));
Node model = new Node("model");
model.attachChild(geom);
Box child = new Box(0.5f, 0.5f, 0.5f);
Geometry childGeom = new Geometry("box", child);
childGeom.setMaterial(assetManager.loadMaterial("Textures/Terrain/BrickWall/BrickWall.j3m"));
Node childModel = new Node("childmodel");
childModel.setLocalTranslation(2, 2, 2);
childModel.attachChild(childGeom);
model.attachChild(childModel);
//animation parameters
float animTime = 5;
int fps = 25;
float totalXLength = 10;
//calculating frames
int totalFrames = (int) (fps * animTime);
float dT = animTime / totalFrames, t = 0;
float dX = totalXLength / totalFrames, x = 0;
float[] times = new float[totalFrames];
Vector3f[] translations = new Vector3f[totalFrames];
Quaternion[] rotations = new Quaternion[totalFrames];
Vector3f[] scales = new Vector3f[totalFrames];
for (int i = 0; i < totalFrames; ++i) {
times[i] = t;
t += dT;
translations[i] = new Vector3f(x, 0, 0);
x += dX;
rotations[i] = Quaternion.IDENTITY;
scales[i] = Vector3f.UNIT_XYZ;
}
SpatialTrack spatialTrack = new SpatialTrack(times, translations, rotations, scales);
//creating the animation
Animation spatialAnimation = new Animation("anim", animTime);
spatialAnimation.setTracks(new SpatialTrack[] { spatialTrack });
//create spatial animation control
AnimControl control = new AnimControl();
HashMap<String, Animation> animations = new HashMap<String, Animation>();
animations.put("anim", spatialAnimation);
control.setAnimations(animations);
model.addControl(control);
rootNode.attachChild(model);
//run animation
control.createChannel().setAnim("anim");
}
use of com.jme3.terrain.Terrain in project jmonkeyengine by jMonkeyEngine.
the class TestParallax method setupFloor.
public void setupFloor() {
mat = assetManager.loadMaterial("Textures/Terrain/BrickWall/BrickWall.j3m");
Node floorGeom = new Node("floorGeom");
Quad q = new Quad(100, 100);
q.scaleTextureCoordinates(new Vector2f(10, 10));
Geometry g = new Geometry("geom", q);
g.setLocalRotation(new Quaternion().fromAngleAxis(-FastMath.HALF_PI, Vector3f.UNIT_X));
floorGeom.attachChild(g);
TangentBinormalGenerator.generate(floorGeom);
floorGeom.setLocalTranslation(-50, 22, 60);
//floorGeom.setLocalScale(100);
floorGeom.setMaterial(mat);
rootNode.attachChild(floorGeom);
}
use of com.jme3.terrain.Terrain in project jmonkeyengine by jMonkeyEngine.
the class TestParallaxPBR method setupFloor.
public void setupFloor() {
mat = assetManager.loadMaterial("Textures/Terrain/BrickWall/BrickWallPBR.j3m");
//mat = assetManager.loadMaterial("Textures/Terrain/BrickWall/BrickWallPBR2.j3m");
Node floorGeom = new Node("floorGeom");
Quad q = new Quad(100, 100);
q.scaleTextureCoordinates(new Vector2f(10, 10));
Geometry g = new Geometry("geom", q);
g.setLocalRotation(new Quaternion().fromAngleAxis(-FastMath.HALF_PI, Vector3f.UNIT_X));
floorGeom.attachChild(g);
TangentBinormalGenerator.generate(floorGeom);
floorGeom.setLocalTranslation(-50, 22, 60);
//floorGeom.setLocalScale(100);
floorGeom.setMaterial(mat);
rootNode.attachChild(floorGeom);
}
Aggregations