AI plugin now with NavMesh pathfinding

Well. It would be very useful if there were any source attached. Since the sources are not on the JME svn either… We are let just with guessing from the functions profile. There is not even javadoc available !

@yang71 said: Well. It would be very useful if there were any source attached. Since the sources are not on the JME svn either.... We are let just with guessing from the functions profile. There is not even javadoc available !
No there isn't. I could have waited with uploading it until I'd have found the time to add all that, you'd have liked that better? ;) The source is available here, like for all contrib projects: https://code.google.com/p/jmonkeyplatform-contributions/source/browse/#svn%2Ftrunk%2Fjme3-artificial-intelligence%2FAI

Thanks for the link @Normen. Sorry I missed this one. I feel so stupid…

We’re always on the forefront here, with commercial packages you’d see everything a year later, when its done :wink:

So I added the sources and existing javadoc to the build, I guess the docs are not yet trustworthy though, I didn’t check or clean them yet in the navmesh parts at least.

1 Like

Unfortunately I’m having issues with the plugin, Instead of a path being created there are 3 waypoints generated:
1st one is x: 0, y: 0, z: 0
2nd one is x: 0, y: 0, z: 0 aswell
3rd waypoint is the destination waypoint with xyz coordinates of the navi.computePath vector, ignoring the navmesh completely

Regards

Make sure you are using right parameters. You are probably passing the wrong parameters.

It does indeed generates a double starting position, but that can be easily fixed by you, Just check distance between first 2 waypoints after generating it and check if it’s really small.

Hi,

I trying, use NavMesh from AI-plugin creating NavMesh via editor and just initializing via code, but i not found way to used like @normen did. I not found this method getGeometry, Did i missing something?

[java]
//initialization
Mesh mesh = myLevel.getGeometry(“NavMesh”).getMesh();
NavMesh navMesh = new NavMesh(mesh);
NavMeshPathfinder navi = new NavMeshPathfinder(navMesh);
navi.setPosition(myPlayer.getWorldTranslation());

//compute new path (probably should do that on another thread, note the class is not “thread safe” per se)
navi.computePath(targetLocation);
[/java]

thanks.

@drr00t said: Hi,

I trying, use NavMesh from AI-plugin creating NavMesh via editor and just initializing via code, but i not found way to used like @normen did. I not found this method getGeometry, Did i missing something?

[java]
//initialization
Mesh mesh = myLevel.getGeometry(“NavMesh”).getMesh();
NavMesh navMesh = new NavMesh(mesh);
NavMeshPathfinder navi = new NavMeshPathfinder(navMesh);
navi.setPosition(myPlayer.getWorldTranslation());

//compute new path (probably should do that on another thread, note the class is not “thread safe” per se)
navi.computePath(targetLocation);
[/java]

thanks.

Hi,

I don’t know if is right, but i did this way.

[java]
Spatial navSpatial = worldRootNode.getChild(“NavMesh”);
List geometrys = new LinkedList();
GeometryBatchFactory.gatherGeoms(navSpatial, geometrys); //will be only one geometry in this list
navMesh = new NavMesh(geometrys.get(0).getMesh()); // so i can get.
navPathFinder = new NavMeshPathfinder(navMesh);
[/java]

You can cast the spatial to geometry:

Geometry geom = (Geometry)worldRootNode.getChild("NavMesh"); Mesh mesh= geom.getMesh();

@normen said: You can cast the spatial to geometry: [code]Geometry geom = (Geometry)worldRootNode.getChild("NavMesh"); Mesh mesh= geom.getMesh();[/code]

Hi,

I did now. I was reading code from RigidBodyControl and i saw a cast from Spatial to Geometry to use getMesh, i so constrained.

thank you for help.

Wasn’t sure where to post this, but I think this is the best spot.

So I downloaded the navmesh pathfinding code from http://code.google.com/p/jmonkeyplatform-contributions/

Then I ran into trouble and in the end I found the problem. When I load my scene, I scale and after scaling I get the init the navmesh, I noticed that the navmesh isn’t being completely scaled. It seems the info of the cells doesn’t scale, like Vector3f center, now I fixed this by just scaling any info I gave navmesh and also then scaled the other direction every info I got out of it.

I just wanted to let you know, incase someone else runs into this problem or if someone is still working on it.

1 Like

How can a nav mesh be generated using code?. I would like to load some “.scene” and generate it nav mesh on runtime.

I think I have it (thanks to MonkeyZone):

public Geometry createNavMesh(Node node) {
        Mesh mesh = new Mesh();
        NavMesh navMesh = new NavMesh();
        NavMeshGenerator generator = new NavMeshGenerator();
        generator.setCellHeight(1f);
        
        GeometryBatchFactory.mergeGeometries(findGeometries(node, new LinkedList<Geometry>()), mesh);
        Mesh optiMesh = generator.optimize(mesh);

        navMesh.loadFromMesh(optiMesh);

        Geometry navGeom = new Geometry("NavMesh");
        navGeom.setMesh(optiMesh);
        Material green = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
        green.setColor("Color", ColorRGBA.Green);
        green.getAdditionalRenderState().setWireframe(true);
        navGeom.setMaterial(green);
        
        return navGeom;
}
1 Like

I seem to have fixed a very common exception I was getting with NavMeshPathfinder, and apparently others, here:

http://hub.jmonkeyengine.org/forum/topic/reuse-navmeshpathfinder/#post-278566

Hi,

I’me very interested by this development, and curious to see the steering behaviors.

I’ve implemented myself a A* (unused) , steering behaviors, finite state machine, and flow fields for my RTS game engine project (Watch the videos to see them in action).

Feel free to ask if you think one of these algorithms may help. Note that my code is JME independant (but all java).

Ben

Can’t go to the link. Is it still available?

i guess the link changed to this [Project] RTS game engine : OpenRTS is released

Yes thanks, I edited my link.

Already found it a while ago.
Nevertheless, thanks for posting the correct link.
Also I’m one of your project gitHub stars.

THAT is reactivity :smiley: (thx for the start ^^)