Grid on the terrain

Hello, i want to create a grid on the terrain and when i click in one of the boxes of the grid i want to get the coordinates of it.

Is the Grid debug class the only thing i can use? Is there an option to take the coordinates im asking?

Thanks in advance.

“picking” is what you want

the “picking” tutorial to create the grid?

Oh you were seriously asking for all the code, you don’t even have a grid of boxes? xD Oh my… Please go through the tutorials (again if you feel tempted to say you did so already) and then maybe take a look at this:

Then use normal mouse picking to determine the click location.

Well maybe he wants a gridoverlay above his normal terrain. Thats a tougher topic i have my problems with, too.

At the moment i work with Planes slightly above the ground but this method isnt the best i guess since sometimes planes vanish in the ground if the terrain gets steep all of a sudden or stuff.

I think its just over-the-top to create a custom mesh for unit highlighters or so. Projected textures eat too much resources as far as i got informed…

Maybe the fault is mine,i didn’t write the post clearly. I need to know if there is something else beside the debug Grid class. As KuroSei told,i need grid above my normal terrain.Forget the picking. I know how to implement picking.

Thanks for the “custom meshes” link.

Terrain has 12 textures built-in, just use one of them, that should be fine.

by saying “Terrain” you mean the Terrain.j3md built-in the jmonkey?

Yeah, just create a control that draws the shapes on a texture in memory and then let it set that to the terrain texture. Attach the control to the terrain and voila.

Your idea is nice but i think this will be a problem for me cause ,for example, i want the grid to appear when i press a key. Is this gonna work ? Does it needs re-rendering of the terrain?

You can either add the grid as an additional texture or you can create an overlay of a grid by using a line mesh and using the heightmap points


the line mesh using heightmap points is a good idea, that is just for a grid of squares, correct? or is there a way to get hexagons out of it. can a terraingrid even be made using a hexagonal arrangement?

Yes you can make it into any shape you like, as long as its composed from lines. You can see how to use the line mesh by looking at the source code of the jME3 debug shapes.