How to get mesh from TerrainQuad?

Hi all!

This is my first post here. I downloaded JME about a week ago, and I have been walking through all beginner tutorials, and some intermediate and advanced tutorials as well. I´ve never created my own game before, but I took a bunch of courses at university in computer graphics, some I´m fairly familiar with the concepts of scenes, objects, geometries, vectors, vertices, vector math etc. I´ve also been working as a Java programmer for about seven years now.

Anyway, I´m currently still exploring the SDK, and what you can do with it (which seems to be alot).
I´ve made a mashup of the beginner tutorials, and added some own stuff to it. Now I want to add some kind of basic AI logic, that will follow the camera/player for example. I found normens post about the AI plugin, so I downloaded that to try it out.

I´m currently using the code from HelloTerrain to generate my terrain. From what I understand from normens example, I need a mesh to be able to generate a NavMesh, like so:

Mesh mesh = myLevel.getGeometry(“NavMesh”).getMesh();
NavMesh navMesh = new NavMesh(mesh);

Since I have a TerrainQuad, I can only get a list of TerrainPatches, from which I can get the mesh:
List tp = new ArrayList();

Is there some way for me to get a mesh straight from the TerrainQuad, or to merge the meshes that I can get from the list of TerrainPatches into one single mesh?


That mesh has to be a NavMesh, generated with the NavMeshGenerator in the SDK.

That is done through the SceneExplorer if I understand correctly?
Guess I cannot use that when generating the terrain in code from a heighmap?
Any workaround?

Right click a node in your scene and select ‘Add Spatial → NavMesh…’ When you run the navmesh generator on the scene (terrain, buildings, trees etc) it will create a mesh and attach it to the scene. This shape can be seen in the scene explorer and if you select it you can see it in the scene composer. Just save the scene then and when you load it, look for the mesh with the name “NavMesh”. It will be a child of the node that you selected when generating the mesh. You do not want to use the terrain mesh as your nav mesh.

Thanks alot, got it working now!

I have followed your instructions on generating a NavMesh, but I don’t understand what class “myLevel” is.

Sory to dig up such an old topic but what about procedurally generated terrain???
I have already aquired a navmesh generator which takes in a float array of verticies and another for indicies. These arrays can be only obtained from a mesh object. Therefore there has to be a way to retrieve the Mesh of the TerrainQuad. If I understand correctly you can only bake a navmesh for an already defined object (the ‘Add Spatial → NavMesh…’ method). The problem is that the QuadTerrain is generated during runtime. I assume that if you have a function (in the SDK) to bake a navmesh, there has to be a piece of code that does that. Maybe using the built in function of the engine “In Code” would be better than using a custom navmesh generator???