Grass system

I watched this video:

Can i somewhere find that plugin?

That is by @ghoust. Take a look in This thread :slight_smile:

foxhavendesigns hit the nail on the head. In that thread should be everything you need. If you are missing something, or get stuck, then just ask…

I downloaded all your source code from 2 links u gave. How put that all as a plugin?

Grass is really easy to make.

public Spatial createGrassSpatial()
float angle = 90 * FastMath.DEG_TO_RAD;

    Quad q = new Quad(2f, 2f);
    Geometry g = new Geometry("Grass4_Quad1", q);

    Material mat = assetManager.loadMaterial("MatDefs/Vegetation/Grass_4.j3m");

    g.setLocalTranslation(-1f, 0, 0);

    Quad q2 = new Quad(2f, 2f);
    Geometry g2 = new Geometry("Grass4_Quad2", q2);

    g2.setLocalTranslation(0, 0, 1f);
    g2.setLocalRotation(new Quaternion(new float[] { 0, angle, 0 }));

    Node bb = new Node("Grass4_Billboard");


    return bb;


That just makes two quads, rotates one of them 90 degrees and applies a material to each one.
Using that, you add a ton of grass to a node, set their locations and then use GeometryBatchFactory on it to merge it into one mesh.

for example:
Spatial spatial = createGrassSpatial();

Node grassNode = new Node(“grassPatch”);

for (int i = 0; i < 200; i++)
float x = FastMath.rand.nextInt(129)
float z = FastMath.rand.nextInt(129)
float y = myTerrainQuad.getHeight(new Vector2f(x, z));

Spatial grass = spatial.clone();
grass.setLocalTranslation(x, y, z);



Node optimizedGrass = GeometryBatchFactory.optimize(grassNode, true);

1 Like

when you checkout the plugin in netbeans you can activate it right out of the box:

you could also use ‘Create NBM’ to create a jar archive (placed in build/modules subdirectory) for distribution I guess.