Help with Forester plugin grass

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]

Also some shadow issues, I seem to have these alot…:
[video]http://youtu.be/9hN7hqMHZNk[/video]

Not totally sure, but I thought this plugin was unsupported.

Out of curiosity… why is the object count so high in the scene? Is that from the Forester plugin? If so, I think you may be better suited to find a different solution for vegetation. That is a crazy high object count.

The object count is so high because I have no paging system (apart from what the Forester uses for the grass). I have a whole city loaded in the same scene. S*tload of trees and roads and what not. All should be destructive as well, so not easy to batch them…? I am a novice in 3D and jMonkeyEngine…

Is there any other easy solution for the vegetation? I’ve searched the forums and it seems many have started on a plugin or just fiddling by themselves. But no other than the Forester plugin could be found in the official plugins…?

You might want to try Simple Grass Control since it has no errors. I think that someone might have improved upon it already so you might want to search for that as well. I can’t remember where in the forums.

@tonihele said: The object count is so high because I have no paging system (apart from what the Forester uses for the grass). I have a whole city loaded in the same scene. S*tload of trees and roads and what not. All should be destructive as well, so not easy to batch them..? I am a novice in 3D and jMonkeyEngine...

Is there any other easy solution for the vegetation? I’ve searched the forums and it seems many have started on a plugin or just fiddling by themselves. But no other than the Forester plugin could be found in the official plugins…?

Sorry, it wasn’t a criticism, by any means. I was curious if it was the plugin or not is all :wink:

@Pixelapp Thanks, maybe I’ll try it. I had keep my eyes on it, but I prefer plugins one can easily download from the IDE. Feels a bit more official and updates. There is also this one: http://hub.jmonkeyengine.org/forum/topic/grass-utility-in-the-sdk/

@t0neg0d Not taken as a criticism :slight_smile: Even though such is welcomed as well. The more and earlier I learn, the easier it gets, I hope. I do code JAVA as a living. But 3D is giving me a hard time :slight_smile:

Hello, can You send me Your grass material file? When i do mine i get error: Material base not supported.

My material file seems to be broken as well, maybe the Forester plugin got updated at some point. However, I never got it to work sufficiently well. And I have moved on to another projects for now. I suggest you follow the other solutions provided in this thread already. There are plenty of implementations available, sadly none of which require zero work…