本文整理汇总了Java中com.jme3.terrain.heightmap.ImageBasedHeightMap.load方法的典型用法代码示例。如果您正苦于以下问题:Java ImageBasedHeightMap.load方法的具体用法?Java ImageBasedHeightMap.load怎么用?Java ImageBasedHeightMap.load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jme3.terrain.heightmap.ImageBasedHeightMap
的用法示例。
在下文中一共展示了ImageBasedHeightMap.load方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
示例2: 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 + "'.");
}
}
示例3: 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;
}