Files

68 lines
2.8 KiB
Java

/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.jme3.app.SimpleApplication
* com.jme3.material.Material
* com.jme3.scene.Spatial
* com.jme3.scene.control.Control
* com.jme3.terrain.Terrain
* com.jme3.terrain.geomipmap.TerrainLodControl
* com.jme3.terrain.geomipmap.TerrainQuad
* com.jme3.terrain.heightmap.ImageBasedHeightMap
* com.jme3.texture.Texture
* com.jme3.texture.Texture$WrapMode
*/
package jme3.hello;
import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.scene.Spatial;
import com.jme3.scene.control.Control;
import com.jme3.terrain.Terrain;
import com.jme3.terrain.geomipmap.TerrainLodControl;
import com.jme3.terrain.geomipmap.TerrainQuad;
import com.jme3.terrain.heightmap.ImageBasedHeightMap;
import com.jme3.texture.Texture;
public class HelloTerrain
extends SimpleApplication {
private TerrainQuad terrain;
Material mat_terrain;
public static void main(String[] agrs) {
HelloTerrain app = new HelloTerrain();
app.start();
}
public void simpleInitApp() {
this.flyCam.setMoveSpeed(50.0f);
this.mat_terrain = new Material(this.assetManager, "Common/MatDefs/Terrain/Terrain.j3md");
this.mat_terrain.setTexture("Alpha", this.assetManager.loadTexture("Textures/Terrain/splat/alphamap.png"));
Texture grass = this.assetManager.loadTexture("Textures/Terrain/splat/grass.jpg");
grass.setWrap(Texture.WrapMode.Repeat);
this.mat_terrain.setTexture("Tex1", grass);
this.mat_terrain.setFloat("Tex1Scale", 64.0f);
Texture dirt = this.assetManager.loadTexture("Textures/Terrain/splat/dirt.jpg");
dirt.setWrap(Texture.WrapMode.Repeat);
this.mat_terrain.setTexture("Tex2", dirt);
this.mat_terrain.setFloat("Tex2Scale", 32.0f);
Texture rock = this.assetManager.loadTexture("Textures/Terrain/splat/road.jpg");
rock.setWrap(Texture.WrapMode.Repeat);
this.mat_terrain.setTexture("Tex3", rock);
this.mat_terrain.setFloat("Tex3Scale", 128.0f);
ImageBasedHeightMap heightmap = null;
Texture heightMapImage = this.assetManager.loadTexture("Textures/Terrain/splat/mountains512.png");
heightmap = new ImageBasedHeightMap(heightMapImage.getImage());
heightmap.load();
int patchSize = 65;
this.terrain = new TerrainQuad("My terrain", patchSize, 513, heightmap.getHeightMap());
this.terrain.setMaterial(this.mat_terrain);
this.terrain.setLocalTranslation(0.0f, -100.0f, 0.0f);
this.terrain.setLocalScale(2.0f, 1.0f, 2.0f);
this.rootNode.attachChild((Spatial)this.terrain);
TerrainLodControl control = new TerrainLodControl((Terrain)this.terrain, this.getCamera());
this.terrain.addControl((Control)control);
}
}