Java Code Examples for com.jme3.terrain.heightmap.AbstractHeightMap#getHeightMap()

The following examples show how to use com.jme3.terrain.heightmap.AbstractHeightMap#getHeightMap() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AddTerrainAction.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
protected Spatial generateTerrain(Node parent, final WizardDescriptor wizardDescriptor) throws IOException {
    org.openide.nodes.Node selectedNode = (org.openide.nodes.Node) wizardDescriptor.getProperty("main_node");
    final Spatial spatial = selectedNode.getLookup().lookup(Spatial.class);
    

    String sceneName = selectedNode.getLookup().lookup(DataObject.class).getName();

    int totalSize = (Integer) wizardDescriptor.getProperty("totalSize");
    int patchSize = (Integer) wizardDescriptor.getProperty("patchSize");
    int alphaTextureSize = (Integer) wizardDescriptor.getProperty("alphaTextureSize");

    float[] heightmapData = null;
    AbstractHeightMap heightmap = (AbstractHeightMap) wizardDescriptor.getProperty("abstractHeightMap");
    if (heightmap != null) {
        heightmap.load(); // can take a while
        heightmapData = heightmap.getHeightMap();
    }

    return doCreateTerrain(parent, totalSize, patchSize, alphaTextureSize, heightmapData, sceneName, selectedNode);
}
 
Example 2
Source File: TerrainCollisionTest.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Before
public void initQuad() {
    Texture heightMapImage = getAssetManager().loadTexture("Textures/Terrain/splat/mountains512.png");
    AbstractHeightMap map = new ImageBasedHeightMap(heightMapImage.getImage(), 0.25f);
    map.load();
    quad = new TerrainQuad("terrain", 65, 513, map.getHeightMap());
}
 
Example 3
Source File: TerrainEditorTopComponent.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
protected void generateTerrain(final WizardDescriptor wizardDescriptor) {
    final Spatial node = selectedSpat.getLookup().lookup(Spatial.class);

    int totalSize = (Integer) wizardDescriptor.getProperty("totalSize");
    int patchSize = (Integer) wizardDescriptor.getProperty("patchSize");
    int alphaTextureSize = (Integer) wizardDescriptor.getProperty("alphaTextureSize");

    float[] heightmapData = null;
    AbstractHeightMap heightmap = (AbstractHeightMap) wizardDescriptor.getProperty("abstractHeightMap");
    if (heightmap != null) {
        heightmap.load(); // can take a while
        heightmapData = heightmap.getHeightMap();
    }

    // eg. Scenes/newScene1.j3o
    String[] split1 = currentRequest.getWindowTitle().split("/");
    String[] split2 = split1[split1.length - 1].split("\\.");

    Terrain terrain = null;
    try {
        terrain = editorController.createTerrain((Node) node,
                totalSize,
                patchSize,
                alphaTextureSize,
                heightmapData,
                split2[0],
                selectedSpat);
    } catch (IOException ex) {
        Exceptions.printStackTrace(ex);
    }

    addSaveNode(selectedSpat);

    editorController.setNeedsSave(true);

    editorController.enableTextureButtons();

    reinitTextureTable(); // update the UI

    refreshSelected();

    //createTerrainButton.setEnabled(false); // only let the user add one terrain

}