getHeight() does not work for ImageBasedHeightMap

Probe the routine that allows to move an object on the area and for the created ones with ImageBasedHeightMap it does not work, some solution for this?


protected void simpleInitGame() {








  protected void simpleUpdate() {


      float camMinHeight = page.getHeight(cam.getLocation()) + 2f;  //  This line gives the following mistake:


        if (!Float.isInfinite(camMinHeight) && !Float.isNaN(camMinHeight)

                && cam.getLocation().y <= camMinHeight) {

            cam.getLocation().y = camMinHeight;



        float characterMinHeight = page.getHeight(m_character

                .getLocalTranslation())+((BoundingBox)m_character.getWorldBound()).yExtent;    //  This line gives the following mistake:


        if (!Float.isInfinite(characterMinHeight) && !Float.isNaN(characterMinHeight)) {

            m_character.getLocalTranslation().y = characterMinHeight;





    private void setupCharacter() {

        URL model=Cliente.class.getClassLoader().getResource("cliente/personajes/jugador.jme");



            maggie.setModelBound(new BoundingBox());


            m_character = new Node("char node");





            chaser = new ChaseCamera(cam,m_character);


            chaser.setTargetOffset(new Vector3f(0,0,0));





    public Node cargarJugador(URL nombre) {

        try {

            Node modelo=(Node)BinaryImporter.getInstance().load(nombre.openStream());

            return modelo;

        } catch (IOException e) {  // Just in case anything happens

            System.out.println("Damn exceptions!" + e);



            return new Node();




    public void setupInput() {

            HashMap<String, Object> handlerProps = new HashMap<String, Object>();

            handlerProps.put(ThirdPersonHandler.PROP_DOGRADUAL, "true");

            handlerProps.put(ThirdPersonHandler.PROP_TURNSPEED, ""+(1.0f * FastMath.PI));

            handlerProps.put(ThirdPersonHandler.PROP_LOCKBACKWARDS, "false");

            handlerProps.put(ThirdPersonHandler.PROP_CAMERAALIGNEDMOVE, "true");

            input = new ThirdPersonHandler(m_character, cam, handlerProps);




    private void complexTerrain() {

        URL grayScale=Cliente.class.getClassLoader().getResource("jmetest/data/texture/bubble.jpg");

        URL waterImage=Cliente.class.getClassLoader().getResource("jmetest/data/texture/water.png");

        URL dirtImage=Cliente.class.getClassLoader().getResource("jmetest/data/texture/dirt.jpg");

        URL highest=Cliente.class.getClassLoader().getResource("jmetest/data/texture/highest.jpg");

        ImageBasedHeightMap ib=new ImageBasedHeightMap(

                new ImageIcon(grayScale).getImage()


        TerrainPage page=new TerrainPage("image icon",33,(ib.getSize())+1,

                new Vector3f(.5f,.05f,.5f),ib.getHeightMap()


        //  Create an object to generate textured terrain from the image based height map.

        ProceduralTextureGenerator pg=new ProceduralTextureGenerator(ib);

        //  Look like water from height 0-60 with the strongest "water look" at 30

        pg.addTexture(new ImageIcon(waterImage),0,30,60);

        //  Look like dirt from height 40-120 with the strongest "dirt look" at 80

        pg.addTexture(new ImageIcon(dirtImage),40,80,120);

        //  Look like highest (pure white) from height 110-256 with the strongest "white look" at 130

        pg.addTexture(new ImageIcon(highest),110,130,256);

        //  Tell pg to create a texture from the ImageIcon's it has recieved.


        TextureState ts=display.getRenderer().createTextureState();

        // Load the texture and assign it.










        // Give the terrain a bounding box

        page.setModelBound(new BoundingBox());


        // Move the terrain in front of the camera

        page.setLocalTranslation(new Vector3f(0,0,-50));

        // Attach the terrain to our rootNode.



I go days trying to move an object on the surface of the area but I have not could. There is algun different method that works?

Someone knows because it gives error on having used getHeight when the area this one based on ImageBasedHeightMap?

08/10/2006 10:22:09 PM com.jme.scene.Node attachChild

INFO: Child (image icon) attached to this node (rootNode)


        at Cliente.simpleUpdate(

float characterMinHeight = page.getHeight(m_character



You must to declare page variable out of complexTerrain Method.

Thank you but "page" already this defined as you comment only that I should not give the complete code. I have realized more proofs and it seems that the command does not generate the heights.

Some expert who knows like to control an object on an terrain created with ImageBasedHeightMap?

please  :smiley:

Already solve the problem, now I can do an easy area in " Monke World 3d " to my taste am necessary to import it with a few lines. It looks like to me a mistake that "ImageBasedHeightMap" does not allow to use the command "getHeight" directly, if it is not a mistake that someone explains to me because.

If someone this been interested in the code warns me.

i don't understand what you are saying…but if you look at TestProceduralSplatTexture it uses an ImageBasedHeightMap and it works flawlessly with getHeight etc…

Greetings friend.

The example studies it. It seems that you don't understand to that refer.

Using the method to determine the height in a given point moves a cube on the terrain "page.getHeight (cam.getLocation ()) you will give yourself that this instruction gives you an error, although alone with the terrain created with "ImageBasedHeightMap."

The example that places at the beginning go and your same one has the test. 

i probably don't understand your english (could someone else please help me?).

but modifying the TestProceduralSplatTexture to use a TerrainPage + forcing the camera to stick on the ground using "cam.getLocation().y = page.getHeight( cam.getLocation() )" works…

like this:

package jmetest.terrain;

import com.jme.bounding.BoundingBox;
import com.jme.image.Texture;
import com.jme.light.PointLight;
import com.jme.math.Vector3f;
import com.jme.renderer.Renderer;
import com.jme.scene.state.CullState;
import com.jme.scene.state.FogState;
import com.jme.scene.state.TextureState;
import com.jme.util.TextureManager;
import com.jmex.terrain.TerrainPage;
import com.jmex.terrain.util.ImageBasedHeightMap;
import com.jmex.terrain.util.ProceduralSplatTextureGenerator;

import javax.swing.*;

 * <code>TestProceduralSplatTexture</code>
 * @author Chris Gray
 * @version $Id:,v 1.2 2006/03/15 23:56:04 llama Exp $
public class TestProceduralSplatTexture extends SimpleGame {
   TerrainPage tb;

    * Entry point for the test
    * @param args
   public static void main( String[] args ) {
      TestProceduralSplatTexture app = new TestProceduralSplatTexture();
      app.setDialogBehaviour( ALWAYS_SHOW_PROPS_DIALOG );

   protected void simpleUpdate() {
      float camMinHeight = tb.getHeight( cam.getLocation() ) + 2f;

      if( !Float.isInfinite( camMinHeight ) && !Float.isNaN( camMinHeight ) ) {
         cam.getLocation().y = camMinHeight;

    * builds the trimesh.
    * @throws IOException
    * @see
   protected void simpleInitGame() {
      try {
         display.setTitle( "ProceduralSplatTexture Test" );

         FogState fs = display.getRenderer().createFogState();
         fs.setEnabled( false );
         rootNode.setRenderState( fs );

         CullState cs = display.getRenderer().createCullState();
         cs.setCullMode( CullState.CS_BACK );
         cs.setEnabled( true );

         lightState.setTwoSidedLighting( true );
         ((PointLight) lightState.get( 0 )).setLocation( new Vector3f( 100, 500, 50 ) );

         URL grayScale = TestProceduralSplatTexture.class.getClassLoader().getResource( "jmetest/data/texture/terrain.png" );

         ImageBasedHeightMap heightMap = new ImageBasedHeightMap( new ImageIcon( grayScale ).getImage() );

         Vector3f terrainScale = new Vector3f( 5, 0.25f, 5 );

         tb = new TerrainPage( "image icon", 33, (heightMap.getSize()) + 1,