com.jme3.terrain.heightmap.ImageBasedHeightMap Java Examples

The following examples show how to use com.jme3.terrain.heightmap.ImageBasedHeightMap. 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: 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 #2
Source File: CreateTerrainWizardPanel2.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void storeSettings(Object settings) {

        CreateTerrainVisualPanel2 comp = (CreateTerrainVisualPanel2) getComponent();

        if ("Flat".equals(comp.getHeightmapTypeComboBox().getSelectedItem()) ) {
            heightmap = new FlatHeightmap(terrainTotalSize);
        }
        else if ("Image Based".equals(comp.getHeightmapTypeComboBox().getSelectedItem()) ) {
            
            BufferedImage bi = null;
            try {
                bi = ImageIO.read(new File(comp.getImageBrowseTextField().getText()));
            } catch (IOException e) {
                e.printStackTrace();
            }
                ImageBasedHeightMap ibhm = new ImageBasedHeightMap(bi, 1f);

            heightmap = ibhm;
        }
        else if ("Hill".equals(comp.getHeightmapTypeComboBox().getSelectedItem()) ) {
            int iterations = new Integer(comp.getHillIterationsTextField().getText());
            byte flattening = new Byte(comp.getHillFlatteningTextField().getText());
            float min = new Float(comp.getHillMinRadiusTextField().getText());
            float max = new Float(comp.getHillMaxRadiusTextField().getText());
            try {
                heightmap = new HillHeightMap(terrainTotalSize, iterations, min, max, flattening);
            } catch (Exception ex) {
                Exceptions.printStackTrace(ex);
            }
        }

        WizardDescriptor wiz = (WizardDescriptor) settings;
        wiz.putProperty("abstractHeightMap", heightmap);
    }