I have this code to make my terrain:
Material materialTerrain = new Material(assetManager,
"Common/MatDefs/Terrain/Terrain.j3md");
materialTerrain.setTexture("Alpha", assetManager.loadTexture(
"Textures/Terrain/mapa-novo2.png"));
Texture grass = assetManager.loadTexture(
"Textures/Terrain/splat/grass.jpg");
grass.setWrap(WrapMode.Repeat);
materialTerrain.setTexture("Tex2", grass);
materialTerrain.setFloat("Tex1Scale", 64f);
Texture dirt = assetManager.loadTexture(
"Textures/Terrain/splat/dirt.jpg");
dirt.setWrap(WrapMode.Repeat);
materialTerrain.setTexture("Tex1", dirt);
materialTerrain.setFloat("Tex2Scale", 64f);
Texture grassWhite = assetManager.loadTexture(
"Textures/Terrain/grass-white.png");
grassWhite.setWrap(WrapMode.Repeat);
materialTerrain.setTexture("Tex3", grassWhite);
materialTerrain.setFloat("Tex3Scale", 64f);
Texture heightMapImage = assetManager.loadTexture(
"Textures/Terrain/mapa-alpha.png");
AbstractHeightMap heightmap = new ImageBasedHeightMap(heightMapImage.getImage());
heightmap.load();
terrain = new TerrainQuad("my terrain", 3, 129, heightmap.getHeightMap());
terrain.setMaterial(materialTerrain);
then I get the position where the player are with:
Vector3f position = player.getPhysicsLocation().clone();
CollisionResults results = new CollisionResults();
Ray ray = new Ray(position, new Vector3f(0f, -1f, 0f));
terrain.collideWith(ray, results);
The Results is returing my terrain, but I need the exacly texture, because in moment it is the only thing distinguishes.
How I can get this? There is a better solution?
(In my cenary I want to give some damage on player who step in certain texture)