How to debug NavMesh?

Hello sir, I want to debug my NavMesh or in other words I want to see navMesh in my map. Like “bulletAppState.getPhysicsSpace().enableDebug(assetManager);” is there any method to display navMesh in my map. Sorry if my question is not relevant but after adding my AI code I am not able to see NavMesh in my Map. I added the following line for creating my navMesh. Can anybody tell the below code is fine or not?.

Geometry navGeom = (Geometry)rootNode.getChild(“NavMesh”);
Mesh mesh = navGeom.getMesh();
NavMesh navMesh = new NavMesh(mesh);
navi = new NavMeshPathfinder(navMesh);
navi.setPosition(model.model_player.getWorldTranslation());

My application is running fine with not error. But I am not sure whether my navMesh created or not. Many thanks for the help.

Just assign a wireframe material and set the cullhint to inherit or never.

Thanks for reply normen. I added wireframe material and i got following output. It is showing map in wireframe view. But I want to see nodes in the map after creating NavMesh. below are the image after adding wireframe.

If you little bit more elaborate will help full to me. many thanks

… assign it to the NavMesh, not to the whole scene … You can also just select the NavMesh in the SceneExplorer, you should see it when it gets created really.

Sorry normen, The above output showing in image was because i enabled this line “bulletAppState.getPhysicsSpace().enableDebug(assetManager);” in my code. Now I commented this line and I got the output showing in image displaying below. Actually I had gone through this link https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:debugging and I created seperate file for “wireProcessor” code and then i used viewPort.addProcessor(new WireProcessor(assetManager)); in my main file. I got black sceen with one blue line diagonally. Moreover How to assign this processor to my navMesh only?

Please help me.

Make a WireFrame material, apply it to the NavMesh geometry.

Thanks again for the reply. As per my understanding I applied the material to the navMesh but still nothing is displaying in the map. Sceenshot of the map attached below. I dont know whether my code is correct or not. Below are the modified line in my code.

Material wireMaterial = new Material(assetManager, “/Common/MatDefs/Misc/Unshaded.j3md”);
wireMaterial.getAdditionalRenderState().setWireframe(true);
Geometry navGeom = (Geometry)rootNode.getChild(“NavMesh”);
navGeom.setMaterial(wireMaterial);
Mesh mesh = navGeom.getMesh();
NavMesh navMesh = new NavMesh(mesh);

You forgot the cullhint.

Thank you normen. Now i think its working after setting cullhint to never. I have 3 confusion.

  1. why all accessible path showing like mesh not nodes?
  2. some house’s roof showing mesh on top mean it is accessible too?
  3. Can I highlight the path in my map selected by NPC to reach player?

The mesh shows the areas for each node, looks exactly as it should. The areas on the roof would only be usable if there are multiple next to each other and you spawn your character on the roof. You can’t go from floor to roof but you can walk on the roof.

1 Like

I want to highlight the path selected by NPC(mean my enemy) to reach player. How can I do that? Is it possible to know which path NPC selected to reach the player?. Many thanks for all your replies.

You could query the path and use Arrow debug shapes that you place at these coordinates. Or make your own mesh with the path inside.