Heightmap from array problem

Here is my new problem, with terrain: I have tried to follow the tutorial (https://wiki.jmonkeyengine.org/legacy/doku.php/jme2:terrains_heightmaps_texturing) on generating heightmaps from an array, and I’m getting an error on the TerrainBlock saying “cannot find symbol” I have tried setting up the array, and variables exactly as I saw in the ‘heightmap from array’ portion of the tutorial. I am wondering what is missing, do I need to setup some sort of private variable, or do I need to import somthing.


You should move up to jme3, we don’t really support jme2 any more.

I’m using jME3, but couldn’t find a tutorial for it, in jME3.

jme3 has a completely different terrain system than jme2 and is not backwards compatible.

To create a heightmap from raw float data just pass in the float array into the TerrainQuad constructor.

Umm, I’m kinda new to jME3, could you post a code example (when you get the time, I realize that you’re a developer, so you’re probably busy), you don’t have to post the array in the code, just where I would plug it in.

Look at TerrainTest line 160:


terrain = new TerrainQuad(“terrain”, 65, 513, heightmap.getHeightMap());


The “heightmap.getHeightMap()” returns a float[].

If you already have a float array of height values, pass that in instead.

Heightmaps, such as ImageHeightMap, are just a way to convert an image or something else into raw height values: a float array.


float[] hieghts = new float[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, etc…};

TerrainQuad terrain = new TerrainQuad(“terrain”, 65, 513, heights);


1 Like

Ohh, I get it know, thanks! I must admit that I’m really impressed with you and the team of Developers, not only have you managed to make my favorite IDE, the only game engine, I’ll ever use, but you also have really fast response time to problems on the forums.

Our pleasure :slight_smile:

[I’m waiting for scripts to run right now so I have some more spare time than normal to answer questions :wink: ]

One quick question, does the heightmap have to be a float array, or could you use an integer array?

Float array, but you can convert the integers into floats.

Ok, just wondering.

Is there a tutorial that’s the same as the ‘heightmap based textures’ in the jME2 tutorial that I found (the one that explains how to do terrain texturing based on height rather than an image), that works for jME3?

Not a tutorial on it. Jme3 does textures with shaders where jme2 did not for the most part. You can take a look at HeightBasedTerrain.j3md, it uses slopes to draw various textures.

Or you can use the height on the terrain (sample the height every unit or so) to generate an alpha map, and use that alpha map with the regular TerrainLighting.j3md material.

Ok thanks I’ll give it a try. How would you generate the alpha map?