Grids in JME 3.0

Hi All,

I browsed the forum and it seems that in JME 3.0 people recommend drawing grids using a grid mesh. I presume that this is just a normal mesh? If so, is there any specific material for it?

The following is my approach to this. My question is whether there is a better one? Using Line from JME 2.0 was much more intuitive to me…any suggestions?

private void createGrid() {

Mesh m = new Mesh();


Vector3f[] positions = {

new Vector3f(0, 0, 0),

new Vector3f(1, 0, 0)


// Define indices etc…

m.setBuffer(Type.Position, 3, BufferUtils.createFloatBuffer(positions));

Material mat = new Material(assetManager, “Common/MatDefs/Terrain/Terrain.j3md”);

gridGeometry = new Geometry(“Grid”, m);



Last time i needed a grid i made it in blender and imported it as a ogre xml, because i’m lazy…

But if your approach works…it’s good :stuck_out_tongue:

It’s not my place to complain (apologies :slight_smile: ), however this approach seems a lot more tedious.

The previous seemed more intuitive. i.e.

for (int x = -300; x <= 300; x=x+10)


Line l = new Line(“xLine” + x, new Vector3f[]{

new Vector3f((float) x, 0f, -300f),

new Vector3f((float) x, 0f, 300f)

}, null, null, null);


l.setModelBound(new BoundingBox());





maybe we should make a grid primitive…

I could create one if you guys want…

EDIT: Try that is.

And you’ll be very welcome! :smiley:

:slight_smile: Cool, I’ll look into it and get back to you within the next couple of days.

Benjamin, your code from first post in this thread probably wouldn’t work for showing a proper grid. First, you should set mesh mode to lines, so that triangles will not be drawn. And then I suggest you to use SolidColor material with grid (which is not affected by light, and you can easily apply any color to it…). But material is already a matter of Geometry, so it doesn’t really concern Mesh. :slight_smile:

1 Like

Thanks! So that’s why it was behaving rather oddly :wink:

nehon said:
maybe we should make a grid primitive...

There is a grid primitive. In com.jme3.scene.debug.Grid.
1 Like

Cool. I’ll take a look at it. Thanks.