Big grid galore


I'm having trouble figuring out the best way to draw a large grid of objects.

I need to be able to catch which cells have been clicked and change the object at that location. (either place or remove an object)

I also want to be able to save the (relevant part of the) grid in a bitmask or similar, to be able to save it to file, e.g.:

1 1 1 1 1

1 0 0 0 0

1 0 1 0 0

0 0 0 0 1

1 1 1 1 1

Also, zoom in/out functionality would be nice…

Things I've come up with:

  • Using GeometryBatchCreator to make a grid of instances of boxes/quads. Slow on large grids, frustum culling doesn't seem to work.
  • Using shingoki's Grid class, found on these forums. Slow on large grids, frustum culling doesn't seem to work.
  • Using ProjectedGrid. Fast, but I think it's not suited since the grid reso looks the same at all zoomlvls and cells can't be isolated. (?)
  • Using a line group with horizontal and vertical lines in one array. Fast. Picking and cell-isolation tricky… (?)
  • Brute force adding objects to the rootNode. Huge memory load. Slow. Only one where picking is easy though…

    I thought I'd check here first, before I start implementing dynamic off-screen cell-adding/-loading stuff, although that might be needed anyway?

    Any thoughts?

    Thanks in advance,


The approach I would take is that there are two grids, one which holds state of grids ( a simple int array), the other is of the objects displayed via jme.

All you need to do to save the grid is to save the int array.

You could also use a terrain page, that is the route we decided to take when developing a tile based game.  The terrain can be written to a RAW file and can also be picked to find what 'cell' was selected.  Performance will be much better than using individual objects, however the area must be a square and 2^n +1 in size (where 2^n is the number of 'cells' per side).


I'm now using a TerrainPage as a grid / for picking and adding instances to a GeometryBatchCreator on top of the gridcell that was clicked…

I'll have to see how that works out for large maps…

What's the best way to draw gridlines on the terrainpage you think?

Texture? Wireframe mode (if i can hide the diagonal lines from the tri's?) Something else?

Thanks again,


if you want grid lines on a page purely as an artistic reason - use a texture

You can use the line drawing mode (using the Line geometry class). See RenParticleEditor for an example on how to make a line grid.