Search in sources :

Example 51 with Terrain

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);
}
Also used : SSAOFilter(com.jme3.post.ssao.SSAOFilter) ColorRGBA(com.jme3.math.ColorRGBA) Quaternion(com.jme3.math.Quaternion) Vector2f(com.jme3.math.Vector2f) Vector3f(com.jme3.math.Vector3f) Material(com.jme3.material.Material) FilterPostProcessor(com.jme3.post.FilterPostProcessor) Texture(com.jme3.texture.Texture) AmbientLight(com.jme3.light.AmbientLight)

Example 52 with Terrain

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);
}
Also used : AbstractHeightMap(com.jme3.terrain.heightmap.AbstractHeightMap) ArrayList(java.util.ArrayList) Material(com.jme3.material.Material) Camera(com.jme3.renderer.Camera) Texture(com.jme3.texture.Texture) TerrainQuad(com.jme3.terrain.geomipmap.TerrainQuad) ImageBasedHeightMap(com.jme3.terrain.heightmap.ImageBasedHeightMap)

Example 53 with 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");
}
Also used : Quaternion(com.jme3.math.Quaternion) HashMap(java.util.HashMap) Node(com.jme3.scene.Node) Box(com.jme3.scene.shape.Box) AnimControl(com.jme3.animation.AnimControl) Geometry(com.jme3.scene.Geometry) SpatialTrack(com.jme3.animation.SpatialTrack) DirectionalLight(com.jme3.light.DirectionalLight) Vector3f(com.jme3.math.Vector3f) Animation(com.jme3.animation.Animation) AmbientLight(com.jme3.light.AmbientLight)

Example 54 with Terrain

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);
}
Also used : Geometry(com.jme3.scene.Geometry) Quad(com.jme3.scene.shape.Quad) Node(com.jme3.scene.Node)

Example 55 with Terrain

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);
}
Also used : Geometry(com.jme3.scene.Geometry) Quad(com.jme3.scene.shape.Quad) Node(com.jme3.scene.Node)

Aggregations

Material (com.jme3.material.Material)54 Vector3f (com.jme3.math.Vector3f)43 Texture (com.jme3.texture.Texture)38 Geometry (com.jme3.scene.Geometry)32 DirectionalLight (com.jme3.light.DirectionalLight)23 TerrainQuad (com.jme3.terrain.geomipmap.TerrainQuad)21 Box (com.jme3.scene.shape.Box)20 TerrainLodControl (com.jme3.terrain.geomipmap.TerrainLodControl)17 AbstractHeightMap (com.jme3.terrain.heightmap.AbstractHeightMap)15 ImageBasedHeightMap (com.jme3.terrain.heightmap.ImageBasedHeightMap)15 AmbientLight (com.jme3.light.AmbientLight)14 DistanceLodCalculator (com.jme3.terrain.geomipmap.lodcalc.DistanceLodCalculator)13 Node (com.jme3.scene.Node)12 Sphere (com.jme3.scene.shape.Sphere)11 Vector2f (com.jme3.math.Vector2f)10 Spatial (com.jme3.scene.Spatial)10 ArrayList (java.util.ArrayList)10 TextureKey (com.jme3.asset.TextureKey)9 RigidBodyControl (com.jme3.bullet.control.RigidBodyControl)9 ColorRGBA (com.jme3.math.ColorRGBA)8