Generating navmesh at runtime

I know this has been asked before but there doesn’t seem to be any working examples in the posts I’ve seen for pregenerated only for reading them after attaching in the scenecomposer

I’m trying to generate navmeshes on the fly then I want to save them so my client can load pregenerated navmeshes later because I need to edit them before finalizing. this is possible with the current version of the ai library hopefully?

At the moment I pass in my scene and i get a minute or so of warning messages
[java]Warning, normal of the plane faces downward!!![/java]
With my application timing out even though I am using a callable to generate the navmesh then the whole application locks up

I am currently using Jmonkey SDK stable

I have installed the jM3 AI Library Version: 0.1.831

This is the code I am using to generate the navmesh
[java]public Callable GenerateMap(Node roomRoot)
{
if(navmesh != null)
{
navmesh.clear();
}
Mesh mesh = new Mesh();

    GeometryBatchFactory.mergeGeometries(findGeometries(roomRoot, new LinkedList<Geometry>()), mesh);
    
    navmesh = new NavMesh();
    navmesh.loadFromMesh(mesh);
    
    pathFinder = new NavMeshPathfinder(navmesh);        

    return null;
}

private List<Geometry> findGeometries(Node node, List<Geometry> geoms)
{
for (Iterator<Spatial> it = node.getChildren().iterator(); it.hasNext():wink:
{
Spatial spatial = it.next();
if (spatial instanceof Geometry)
{
geoms.add((Geometry) spatial);
}
else if (spatial instanceof Node)
{
findGeometries((Node) spatial, geoms);
}
}
return geoms;
}[/java]

Does anyone have a working example of dynamic NavMesh loading or know what I am doing wrong please?

I have managed to get this working I will post how i did soon to help others since it seems to be a common issue

I have created an example project that generates dynamic navmeshes
It can add new objects to the scene
It can then regenerate the navmesh and those new objects are included in the new navmesh

The navmeshes generated are identical to the meshes generated within the UI except that they can include dynamically added objects

It allows Jaime to navigate to a clicked position anywhere on the terrain model
It includes physics

Does anyone know where I should put this?

Thats a fork of a git repo that has a one year old checkout of the engine… Why don’t you just use the version in our svn?

I’m not sure what you are referring to?

I fixed the issues I had awhile ago my latest post was where to upload a example I have built to help others since the top 5 or more posts in the AI section are all how do i get dynamic navmeshs working

Are you saying the jM3 AI Library Version: 0.1.831 is a year out of date?

It was the only version available from netbeans plugin menu

Sorry I meant to answer in this thread:
http://hub.jmonkeyengine.org/forum/topic/source-for-the-core-version-of-navmeshgenerator/

Right heh that makes more sense :wink:

Is this the latest version?

http://jmonkeyengine.googlecode.com/svn/trunk/sdk/jme3-navmesh-gen/src/com/jme3/gde/nmgen/NavMeshGenerator.java

Yeah

1 Like