JME3 Terrain Tutorial not working

I’ve tried to implement the terrain tutorial as such;

[java] /** 1. Create terrain material and load four textures into it. /

terrain_mat = new Material(assetManager, “resources/MatDefs/Terrain/Terrain.j3md”);

* 1.1) Add ALPHA map (for red-blue-green coded splat textures) /

terrain_mat.setTexture(“Alpha”, assetManager.loadTexture(“resources/Textures/Terrain/splat/alphamap.png”));

* 1.2) Add GRASS texture into the red layer (m_Tex1). /

Texture grass = assetManager.loadTexture(“resources/Textures/Terrain/splat/grass.jpg”);


terrain_mat.setTexture(“Texture1”, grass);

terrain_mat.setFloat(“Texture1Scale”, 64f);

* 1.3) Add DIRT texture into the green layer (m_Tex2) /

Texture dirt = assetManager.loadTexture(“resources/Textures/Terrain/splat/dirt.jpg”);


terrain_mat.setTexture(“Texture2”, dirt);

terrain_mat.setFloat(“Texture1Scale”, 32f);

* 1.4) Add ROAD texture into the blue layer (m_Tex3) /

Texture rock = assetManager.loadTexture(“resources/Textures/Terrain/splat/road.jpg”);


terrain_mat.setTexture(“Texture3”, rock);

terrain_mat.setFloat(“Texture1Scale”, 128f);

* 2. Create the height map /

AbstractHeightMap heightmap = null;

Texture heightMapImage = assetManager.loadTexture(“resources/Textures/Terrain/splat/mountains512.png”);

heightmap = new ImageBasedHeightMap(

ImageToAwt.convert(heightMapImage.getImage(), false, true, 0));


* 3. We have prepared material and heightmap. Now we create the actual terrain:

  • 3.1) We create a TerrainQuad and name it “my terrain”.
  • 3.2) A good value for terrain tiles is 64x64 – so we supply 64+1=65.
  • 3.3) We prepared a heightmap of size 512x512 – so we supply 512+1=513.
  • 3.4) As LOD step scale we supply Vector3f(1,1,1).
  • 3.5) At last, we supply the prepared heightmap itself.


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

    * 4. We give the terrain its material, position & scale it, and attach it. /


    terrain.setLocalTranslation(0, -100, 0);

    terrain.setLocalScale(2f, 1f, 2f);


    * 5. The LOD (level of detail) depends on were the camera is: */

    List cameras = new ArrayList();


    TerrainLodControl control = new TerrainLodControl(terrain, cameras);


    I had to change the setTexture calls because the .j3md file had different names and wouldn’t run, it runs now but the problem is the map is all black except for some red text that seems gibberish along one side of the map. The textures are all in the right places and all from the SVN, i’ve checked in the folders and they are the pics. The code is the same as the tutorial except for that change as I mentioned.

Remove the /resources/ part from the texture names and put the Textures folder in the assets folder if you are using jMP. When you start the program you probably get lots of warnings about missing textures. The tutorials are for all IDE’s and dont necessarily take the jMP folder structure into account.



Tried that. Same issue. jpg

pic shows what’s happening. removes the space between the 7s and before jpg of course.

I saw from your tutorial that you are apparently using the jme3testdata.jar directly. You dont need to do that, its available as a “library” (Project Properties/Add Library…) in jMP. You should always use these libraries as they also provide the javadoc etc. for class libraries. I fixed the tutorial.



Thanks, I’ll get good at this eventually. Hopefully I’ll help someone else along the way.