I'm trying to make an RTS style construction mesh

Take this video as an example.
(276) Unity Grid Building System P1 - Calculating Cell Position - YouTube

I’m trying to make something that puts buildings on the grid.
My knowledge of these subjects is too shallow at present.

I know it’s a big topic and I’m hoping someone can briefly walk me through some of the concepts.

  • For example, how do I generate such meshes and how do I get buildings to fit in them?
  • Which of jme’s already-made classes can I use, and recommendations for other libraries that aren’t in jme that I can use?
  • Others have completed literature that I can learn from

(The above was generated by a translator, so please point out any problems, and if you have any questions about my questions, please point out the problems as well.)

I’m not sure what this means.

The linked video just seems to make a quad for the ground. Why would you need anything else? There may be information we are missing.

Quad + Geometry for the ground.

Lemur’s picking (CursorListener) can tell you exactly where on the quad was clicked. From there just turn it into a grid cell coordinate. That’s easy math but my mathd library also has a Grid class that can do it for you.

I suspect these answers will be unsatisfying because we are probably missing information.

1 Like

My current understanding is that I need to make a grid for the ground, and then give the mouse access to the grid coordinates, so that the building can be placed on the grid.

I will try your suggestion.

Where can I get it?

Or in a build.gradle file:

api "com.simsilica:sim-math:1.6.0"

You only need some kind of flat plane for the ground. The “grid” is only imaginary. You do not need to render a grid itself.

You probably want to render additional geometry to represent the selected cell but that’s separate geometry from the ground.

1 Like
cursorButtonEvent(CursorButtonEvent event, com.jme3.scene.Spatial target, com.jme3.scene.Spatial capture) 



Both parameters are of type Spatial

I would like to know what the two parameters “target” and “capture” refer to respectively?

MouseEventControl.addListenersToSpatial(simpleApp.getRootNode().getChild("MapNode"), new DefaultMouseListener(){
 protected void click( MouseButtonEvent event, Spatial target, Spatial capture ) {
    System.out.println("我被点击了:" + target);
    System.out.println("我被点击了:" + capture);

MapNode.attachChild(quadGeometry); I added the quads to the “MapNode”.

I may not have fully understood what you meant.
I’m using this code to determine if the mouse has clicked on the generated quad but it has no effect.

You can give me some hints with some pseudo-code if you want.


The problem is in the 100 things I can’t see. If you want my help then you will have to put together a small but complete test case that illustrates the issue.

Either way, if you want to know where the things were clicked then MouseEventControl is totally useless.

…which is why I suggested a CursorListener instead.

Ok my problem I misread MouseEventControl as CursorEventControl, I wrote a few simple examples I have understood the usage and functionality of the code.
It has solved most of my problems so far thanks for the tips and help!