[Solved] Problem with importing terrain from L3DT to JME using TerrainQuad

Hi friends

Using L3DT to create my terrain then export it both as a object and as a height map (to create terrain in JME using TerrainQuad).

but :

The above terrain is .obj mesh created by L3DT and the below one is created in jme with exported height map from L3DT.
As you see under sea heights (negative height) is not over lapping with original mesh.
Any one knows what may goes wrong here ?
As I know there are a few guys also using L3DT for their games , Do you have the same issue too ?

Edit : height map settings

Your code looks fine from here :slight_smile: (couldn#t resist, sorry)

1 Like

lol… man this is copyrighted by @pspeed :wink:

1 Like

What ? … Code ?
… Ah , Yes :chimpanzee_facepalm:

here is the code

public class TerrainCreator  {

    private TerrainQuad terrain;
    private Material matTerrain;
    public TerrainCreator(Material mat,Texture heightMap,float heightScale,Texture diffuseMap , Texture alphaMap ,Camera cam){
        // TERRAIN  material
        matTerrain =mat;
        matTerrain.setBoolean("useTriPlanarMapping", false);
        matTerrain.setFloat("Shininess", 0);

        // ALPHA map (for splat textures)
         matTerrain.setTexture("AlphaMap", alphaMap);

        // DIFFUSE texture
        matTerrain.setTexture("DiffuseMap", diffuseMap);
        matTerrain.setFloat("DiffuseMap_0_scale", 1);
        AbstractHeightMap heightmap = null;
        try {
            //heightmap = new HillHeightMap(1025, 1000, 50, 100, (byte) 3);

            heightmap = new ImageBasedHeightMap(heightMap.getImage(), heightScale);

        } catch (Exception e) {

        terrain = new TerrainQuad("terrain", 65, 513, heightmap.getHeightMap());
        TerrainLodControl control = new TerrainLodControl(terrain, cam);
        control.setLodCalculator( new DistanceLodCalculator(65, 2.7f) ); // patch size, and a multiplier
    public TerrainQuad getTerrainQuad(){
        return terrain;

in my app :

 private void initScene() {
        Material mat=new Material(assetManager,"Common/MatDefs/Terrain/TerrainLighting.j3md");
        TerrainCreator terrain = new TerrainCreator(mat,assetManager.loadTexture("Textures/terrain/MagoTribe/HM.png"),1,assetManager.loadTexture("Textures/terrain/MagoTribe/DM.jpg"),assetManager.loadTexture("Textures/terrain/MagoTribe/AM.png"),cam);

I think the problem is with jme terrain generator or L3DT height map exporter or maybe i do not know how to export height map from l3dt properly.

Solved :blush:

I exported height map to .raw file (16bit-unsigned) reloaded it in l3dt. set min =0 ; max=255 then exported as jpg.
in jme set heightScale = 0.4578

this post helped me