@Override
        public void onAction(String name, boolean pressed, float tpf) {
            if (name.equals("wireframe") && !pressed) {
                wireframe = !wireframe;
                if (wireframe) {
                    terrain.setMaterial(matWire);
                } else {
                    terrain.setMaterial(matTerrain);
                }
            } else if (name.equals("triPlanar") && !pressed) {
                triPlanar = !triPlanar;
                if (triPlanar) {
                    matTerrain.setBoolean("useTriPlanarMapping", true);
                    // Planar textures don't use the mesh's texture coordinates but real-world coordinates,
                    // so we need to convert these texture coordinate scales into real-world scales, so it looks
                    // the same when we switch to/from tri-planar mode. (1024 is the alphamap size.)
                    matTerrain.setFloat("DiffuseMap_0_scale", 1f / (1024f / dirtScale));
                    matTerrain.setFloat("DiffuseMap_1_scale", 1f / (1024f / darkRockScale));
                    matTerrain.setFloat("DiffuseMap_2_scale", 1f / (1024f / pinkRockScale));
                    matTerrain.setFloat("DiffuseMap_3_scale", 1f / (1024f / riverRockScale));
                    matTerrain.setFloat("DiffuseMap_4_scale", 1f / (1024f / grassScale));
                    matTerrain.setFloat("DiffuseMap_5_scale", 1f / (1024f / brickScale));
                    matTerrain.setFloat("DiffuseMap_6_scale", 1f / (1024f / roadScale));
                } else {
                    matTerrain.setBoolean("useTriPlanarMapping", false);
                    
                    matTerrain.setFloat("DiffuseMap_0_scale", dirtScale);
                    matTerrain.setFloat("DiffuseMap_1_scale", darkRockScale);
                    matTerrain.setFloat("DiffuseMap_2_scale", pinkRockScale);
                    matTerrain.setFloat("DiffuseMap_3_scale", riverRockScale);
                    matTerrain.setFloat("DiffuseMap_4_scale", grassScale);
                    matTerrain.setFloat("DiffuseMap_5_scale", brickScale);
                    matTerrain.setFloat("DiffuseMap_6_scale", roadScale);
                    
                    
                    
                }
            } if (name.equals("DetachControl") && !pressed) {
                TerrainLodControl control = terrain.getControl(TerrainLodControl.class);
                if (control != null)
                    control.detachAndCleanUpControl();
                else {
                    control = new TerrainLodControl(terrain, cam);
                    terrain.addControl(control);
                }
                    
            }
        }
Uses the terrain's lighting texture with normal maps and lights.

@author bowens
jme3-examples/src/main/java/jme3test/terrain/TerrainTestAdvanced.java