Hi.
I am new to the jmonkeyengine and I still try to find out how all the cool stuff works.
I need grass on my terrain, so I try to setup the Forester plugin.
The following Code is based on Code i found here at the forum:
[java]
public void simpleInitApp() {
Forester forester = Forester.getInstance();
Spatial scene = assetManager.loadModel("Scenes/TestScene.j3o");
rootNode.attachChild(scene);
Node n = (Node)scene;
Terrain terrain = (Terrain)n.getChild("terrain");
forester.initialize(rootNode, cam, terrain, this);
GrassLoader grassLoader = forester.createGrassLoader(1026, 4, 300f, 20f);
MapGrid grid = grassLoader.createMapGrid();
grid.addDensityMap(assetManager.loadTexture("Textures/terrain/densityMap.jpg"), 0, 0, 0);
Material grassMat = assetManager.loadMaterial("Materials/Grass/Grass.j3m");
GrassLayer layer = grassLoader.addLayer(grassMat, MeshType.CROSSQUADS);
layer.setDensityTextureData(0, Channel.Red);
layer.setDensityMultiplier(0.5f);
layer.setMaxHeight(2.4f);
layer.setMinHeight(2.f);
layer.setMaxWidth(2.4f);
layer.setMinWidth(2.f);
((GPAUniform) layer.getPlantingAlgorithm()).setThreshold(0.6f);
grassLoader.setWind(new Vector2f(1, 0));
}
[/java]
My grass material looks like this:
The game does not throw any errors, but there is no grass on the terrain.