Hi Guys…
I have a NavMesh which was generated by the sceenComposer, which works “ok”. But there are some cells in the NavMesh which i would like remove so that
final Cell findClosestCell = navMesh.findClosestCell(location);
will not chose it…
I know that i can modify the triangle in the mesh
VertexBuffer uv = g.getMesh().getBuffer(Type.TexCoord);
If i am not wrong
Each Cell is linked to 3 cells around it (if any cell exist in it’s surrounding) in JME-AI
You can first get cell you want to remove by providing it’s world position using findClosestCell(Vector3f point) method in NavMesh class. Then iterate through it’s linked cells using getLink(int side) and remove link to this cell (which you want to remove)
from them (by setting null link). Then path finder will not consider this cell when path finding.
Note that calling linkCells() on navmesh will relink cells again.
I also want to make my navmesh to be dynamic. For now it is semi dynamic thanks to Blender (Using Blender NavMesh generator and Boolean Modifier). Means it is dynamic in Level Design/Prototyping time but static at runtime.
I have not tested this myself you can try it and let me know if it works.
There is no remove link method in Cell. you can remove link by calling setLink(int Side, null); in neighbor cells to this cell.
In above image, suppose we want to remove cell which is in the center, so path finder will never find path trough this cell, to do that we should remove links from neighbor cells to this cell (green links in image) and for doing this we can call setLink(int Side, null); on all neighbor cells (here cell 0 , 1 are neighbors) to remove link from neighbors to the central cell.
Oops!
I did not notice it is private when looking to javadoc, really sorry about it.
I have no idea about any other way, maybe you should do this with editing mesh buffer as you mentioned in your first post.
Or hack through code and make that method public for your self !!
Actually i do create/edit my navmesh in blender then load it to NavMesh in JME AI.
Hope some one with more knowledge using JME AI can help. Maybe @Darkchaos can help.