Page 1 of 1
[2.2] Terra and OgreRecast
Posted: Sun Feb 23, 2020 4:50 pm
by Lax
Hi all,
has anybody Terra working for OgreRecast navigation map?
The old version OgreRecast has usage for Ogre v1 Terrain:
Code: Select all
InputGeom(Ogre::TerrainGroup *terrainGroup, std::vector<Ogre::Entity*> srcMeshes = std::vector<Ogre::Entity*>());
But the implementatino is of course not compatible to terra.
I tried via heightmap code, but without success.
Best Regards
Lax
Re: [2.2] Terra and OgreRecast
Posted: Wed Apr 21, 2021 8:13 am
by Lax
Hi,
no one using Ogre2.x terra and OgreRecast for creating a navigation mesh out of terra?
I already ported OgreRecast for Ogre2.x, so that Ogre::Item's can be mixed with Ogre::v1::Entity's for navigation mesh creation.
I also extended the debug draw mechanisms for OgreRecast.
But I'am still struggeling with terra, getting the vertex information for navigation mesh creation.
Best Regards
Lax
Re: [2.2] Terra and OgreRecast
Posted: Wed Apr 28, 2021 8:08 pm
by Nucleartree
Hi.
I've got a half-baked implementation of recast in my
level editor. I'm not using OgreRecast or any wrapper libraries, so I'm not sure how helpful this will be for you, but if it helps then it helps. I'm still using 2.1 but that shouldn't be a problem for you as I get hold of the height values from terra's height array, not downloaded from the gpu.
Pretty much to include the terrain I just loop over the height data in terra and shovel them into a buffer to give to recast.
Code: Select all
void Terra::writeVertexDataToBuffer(float* bufferStart) const {
for(int y = 0; y < m_depth; y++){
for(int x = 0; x < m_width; x++){
*bufferStart++ = x * m_xzRelativeSize.x;
*bufferStart++ = m_heightMap[x + y * m_width] - (m_height / 2);
*bufferStart++ = y * m_xzRelativeSize.y;
}
}
}
void Terra::writeTriangleDataToBuffer(int offset, int* bufferStart) const {
int newWidth = m_width - 1;
int newDepth = m_depth - 1;
for(int y = 0; y < newDepth; y++){
for(int x = 0; x < newWidth; x++){
//Write out two triangles
*bufferStart++ = offset + x + y * newWidth;
*bufferStart++ = offset + x + 1 + (y+1) * newWidth;
*bufferStart++ = offset + x + 1 + y * newWidth;
*bufferStart++ = offset + x + y * newWidth;
*bufferStart++ = offset + x + 1 + (y+1) * newWidth;
*bufferStart++ = offset + x + (y+1) * newWidth;
}
}
}
Link
I'm using quite an unorthodox solution because I only include physics shapes for the nav mesh, but if terrain is the important bit then that should be fine. Please don't judge me too hard on some of this code base

, I had to de-prioritise nav meshes due to time limits so it's not exactly done yet.
Re: [2.2] Terra and OgreRecast
Posted: Fri Apr 30, 2021 5:08 pm
by Lax
Hi Nucleartree,
thanks! I will try that out, it seems, as its that what I'm looking for
Best Regards
Lax
Re: [2.2] Terra and OgreRecast
Posted: Sat May 22, 2021 10:39 am
by Lax
Hi all,
got OgreRecast with terra working
In the picture below, I activated the recast debug drawing, in order to see, which areas are walkable.
http://www.lukas-kalinowski.com/Homepag ... onMesh.png
I integrated the solution in the OgreRecast project. It can be used the following way:
Code: Select all
this->hasValidNavMesh = this->detourTileCache->TileCacheBuild(terra, entities, items);
What's new too, is that OgreRecast now does work for entities and Ogre v2 items!
If anyone is interested, using my implementation, the source code is available here:
https://sourceforge.net/p/nowa-engine/s ... utGeom.cpp
Best Regards
Lax