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”);
grass.setWrap(WrapMode.Repeat);
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”);
dirt.setWrap(WrapMode.Repeat);
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”);
rock.setWrap(WrapMode.Repeat);
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));
heightmap.load();
/* 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.setMaterial(terrain_mat);
terrain.setLocalTranslation(0, -100, 0);
terrain.setLocalScale(2f, 1f, 2f);
rootNode.attachChild(terrain);
/* 5. The LOD (level of detail) depends on were the camera is: */
List cameras = new ArrayList();
cameras.add(getCamera());
TerrainLodControl control = new TerrainLodControl(terrain, cameras);
terrain.addControl(control);[/java]
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.