Hi,
I’ve tried to set different parameters to the Forester, my intent is to create grass. I have a splatted terrain, with grass, dirt and some metal thingie. I want the Forester grass to grow only on a certain type of terrain, i.e. on the grass. How can I achieve this?
Here is a part of my terrain initing:
[java]
/**
* 1. Create terrain material and load four textures into it.
*/
matTerrain = new Material(assetManager,
“Common/MatDefs/Terrain/TerrainLighting.j3md”);
matTerrain.setBoolean(“useTriPlanarMapping”, false);
matTerrain.setBoolean(“WardIso”, false);
/**
* 1.1) Add ALPHA map (for red-blue-green coded splat textures)
*/
matTerrain.setTexture("AlphaMap", assetManager.loadTexture(
"Maps/" + map + "_alpha.png"));
// matTerrain.setTexture(“AlphaMap_1”, assetManager.loadTexture(
// “Maps/” +map+"_alpha2.png"));
// GRASS texture
Texture grass = assetManager.loadTexture("Textures/CityScape/grass.png");
grass.setWrap(WrapMode.Repeat);
matTerrain.setTexture("DiffuseMap_1", grass);
matTerrain.setFloat("DiffuseMap_1_scale", grassScale);
[/java]
Here is my Forester init:
[java]
forester = Forester.getInstance();
forester.initialize(((Main) app).getRootNode(), ((Main) app).getCamera(), (Terrain) ((Main) app).getRootNode().getChild(“Terrain”), ((Main) app));
// forester.getForesterNode().setLocalTranslation(terrain.getRoot().getLocalTranslation());
//Adding some grass as well.
GrassLoader grassLoader = forester.createGrassLoader(1024, 4, 300f, 20f);
MapGrid grid = grassLoader.createMapGrid();
Texture density = ((Terrain) ((Main) app).getRootNode().getChild("Terrain")).getMaterial().getTextureParam("DiffuseMap_1").getTextureValue();
grid.addDensityMap(density, 0, 0, 0);
Material grassMat = ((Main) app).getAssetManager().loadMaterial("Materials/Grass/Grass.j3m");
GrassLayer layer = grassLoader.addLayer(grassMat, MeshType.CROSSQUADS);
layer.setDensityTextureData(0, Channel.Green);
layer.setDensityMultiplier(1.5f);
layer.setMaxHeight(1.5f);
layer.setMinHeight(1.f);
layer.setMaxWidth(2.4f);
layer.setMinWidth(2.f);
// layer.setMaxTerrainSlope(30);
// ((GPAUniform) layer.getPlantingAlgorithm()).setThreshold(0.6f);
grassLoader.setWind(new Vector2f(1, 0));[/java]