本文整理汇总了Java中com.jme3.terrain.heightmap.ImageBasedHeightMap类的典型用法代码示例。如果您正苦于以下问题:Java ImageBasedHeightMap类的具体用法?Java ImageBasedHeightMap怎么用?Java ImageBasedHeightMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ImageBasedHeightMap类属于com.jme3.terrain.heightmap包,在下文中一共展示了ImageBasedHeightMap类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadTerrain
import com.jme3.terrain.heightmap.ImageBasedHeightMap; //导入依赖的package包/类
public void loadTerrain(TerrainDefinition terrainDefinition) {
Texture grass = assetManager.loadTexture(terrainDefinition.tx1().path());
grass.setWrap(Texture.WrapMode.Repeat);
Texture water = assetManager.loadTexture(terrainDefinition.tx2().path());
water.setWrap(Texture.WrapMode.Repeat);
Texture land = assetManager.loadTexture(terrainDefinition.tx3().path());
land.setWrap(Texture.WrapMode.Repeat);
float scale = 100;
Material mat_terrain = new Material(assetManager, "Common/MatDefs/Terrain/TerrainLighting.j3md");
mat_terrain.setTexture("AlphaMap", assetManager.loadTexture("Maps/Adria/AdriaSmall_alpha.png"));
mat_terrain.setTexture("DiffuseMap", texture(terrainDefinition.tx1().path()));
mat_terrain.setFloat("DiffuseMap_0_scale", terrainDefinition.tx1().scale()); //playing with scales
mat_terrain.setTexture("DiffuseMap_2", texture(terrainDefinition.tx2().path()));
mat_terrain.setFloat("DiffuseMap_2_scale", terrainDefinition.tx2().scale());
mat_terrain.setTexture("DiffuseMap_1", texture(terrainDefinition.tx3().path()));
mat_terrain.setFloat("DiffuseMap_1_scale", terrainDefinition.tx3().scale());
int patchSize = 17;
terrain = terrainDefinition.heightMapPath().map(m -> assetManager.loadTexture(m)
.getImage()).map(i -> new ImageBasedHeightMap(i, 10f))
.map(hm -> {
hm.load();
return new TerrainQuad("Terrain", patchSize, hm.getSize()+1, hm.getHeightMap());
}).map(tq -> {
tq.setMaterial(mat_terrain);
tq.setLocalScale(scale, 1f, scale); // 1pixel 1m * scale * m
tq.addControl(new TerrainLodControl(tq, camera.testCamera()));
tq.setShadowMode(RenderQueue.ShadowMode.Receive);
setLocation(tq,99,512,2048,scale);
rootNode.attachChild(tq);
return tq;
});
}
示例2: getHeightMap
import com.jme3.terrain.heightmap.ImageBasedHeightMap; //导入依赖的package包/类
public float[] getHeightMap() {
if (imageField.getText().isEmpty()) {
return null;
}
String imagePath = Editor.toAssetFilePath(imageField.getText());
Texture tex = am.loadTexture(imagePath);
ImageBasedHeightMap heightMap = new ImageBasedHeightMap(tex.getImage(), new Float(scaleField.getText()));
heightMap.load();
heightMap.smooth(new Float(roughField.getValue()), 2);
return heightMap.getHeightMap();
}
示例3: setBlocksFromHeightmap
import com.jme3.terrain.heightmap.ImageBasedHeightMap; //导入依赖的package包/类
public void setBlocksFromHeightmap(Vector3Int location, String heightmapPath, int maximumHeight, Block block){
try{
Texture heightmapTexture = settings.getAssetManager().loadTexture(heightmapPath);
ImageBasedHeightMap heightmap = new ImageBasedHeightMap(heightmapTexture.getImage(), 1f);
heightmap.load();
heightmap.setHeightScale(maximumHeight / 255f);
setBlocksFromHeightmap(location, getHeightmapBlockData(heightmap.getScaledHeightMap(), heightmap.getSize()), block);
}catch(Exception ex){
System.out.println("Error while loading heightmap '" + heightmapPath + "'.");
}
}
示例4: loadHeightMap
import com.jme3.terrain.heightmap.ImageBasedHeightMap; //导入依赖的package包/类
private void loadHeightMap() {
Texture texhm = manager.loadTexture(heightMap);
this.loadedHeightMap = new ImageBasedHeightMap(texhm.getImage());
}
示例5: createTerrain
import com.jme3.terrain.heightmap.ImageBasedHeightMap; //导入依赖的package包/类
private static Spatial createTerrain(NamedNodeMap map, AssetManager am) {
int patchSize = 65;
String name = XMLUtils.getAttribute("name", map);
String heightMap = XMLUtils.getAttribute("heightmap", map);
String alphaMap = XMLUtils.getAttribute("alphamap", map);
String texture1 = XMLUtils.getAttribute("texture1", map);
float tex1Scale = XMLUtils.parseFloat("tex1scale", map);
String texture2 = XMLUtils.getAttribute("texture2", map);
float tex2Scale = XMLUtils.parseFloat("tex2scale", map);
String texture3 = XMLUtils.getAttribute("texture3", map);
float tex3Scale = XMLUtils.parseFloat("tex3scale", map);
Texture texhm = am.loadTexture(heightMap);
ImageBasedHeightMap loadedHeightMap = new ImageBasedHeightMap(texhm.getImage());
loadedHeightMap.load();
Material terrainMaterial = new Material(am,
"Common/MatDefs/Terrain/Terrain.j3md");
Texture tex1 = am.loadTexture(texture1);
tex1.setWrap(Texture.WrapMode.Repeat);
terrainMaterial.setTexture("Tex1", tex1);
terrainMaterial.setFloat("Tex1Scale", tex1Scale);
Texture tex2 = am.loadTexture(texture2);
tex2.setWrap(Texture.WrapMode.Repeat);
terrainMaterial.setTexture("Tex2", tex2);
terrainMaterial.setFloat("Tex2Scale", tex2Scale);
Texture tex3 = am.loadTexture(texture3);
tex3.setWrap(Texture.WrapMode.Repeat);
terrainMaterial.setTexture("Tex3", tex3);
terrainMaterial.setFloat("Tex3Scale", tex3Scale);
Texture texAlpha = am.loadTexture(alphaMap);
terrainMaterial.setTexture("Alpha", texAlpha);
try {
TerrainQuad terrain = new TerrainQuad(name, patchSize, loadedHeightMap.getSize() + 1, loadedHeightMap.getHeightMap());
terrain.setMaterial(terrainMaterial);
return terrain;
} catch (Exception ex) {
ex.printStackTrace();
}
/*TerrainLodControl control = new TerrainLodControl(terrain, GlobalObjects.getInstance().getCamera().getCamera());
terrain.addControl(control);*/
return null;
}