当前位置: 首页>>代码示例>>Java>>正文


Java ImageBasedHeightMap.load方法代码示例

本文整理汇总了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();
}
 
开发者ID:huliqing,项目名称:LuoYing,代码行数:12,代码来源:TerrainEntityComponentConverter.java

示例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 + "'.");
    }
}
 
开发者ID:jMonkeyEngine-Contributions,项目名称:cubes,代码行数:12,代码来源:BlockTerrainControl.java

示例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;
}
 
开发者ID:samynk,项目名称:DArtE,代码行数:56,代码来源:GameSceneLoader.java


注:本文中的com.jme3.terrain.heightmap.ImageBasedHeightMap.load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。