How to only use Detour lib for my own custom generated meshes?

169 views
Skip to first unread message

lhhts...@gmail.com

unread,
Jun 12, 2021, 7:52:48 PM6/12/21
to recastnavigation
Hi,

I have a custom generated navigation polygon meshes (I cannot use the Recast directly because I have an uncommon system so I need some customization). 

Suppose I can load those meshes into code, e.g.
vector<vector<float>> vertices = { {x0, y0, z0}, {x1, y1, z1}, ...};
vector<vector<int>> polygons = { {point0, point1, point2}, {point3, point2, point4, point5...}, ... };
// I can also have neighboring information generated too (not sure if that's an input for Detour);

But what should I do to build the simplest example to only use Detour with my own provided mesh data?

All the examples included in the package are end-2-end, from 3D models to mesh to navigation. I could not extract the mesh information separately.

I took a look at some source code. The usual way is to use the following functions:
dtNavMeshCreateParams params; 
// set all those params ....
dtCreateNavMeshData(&params, &navData, &navDataSize)
// then add tile
navMesh_->addTile(navData, navDataSize, DT_TILE_FREE_DATA, 0, nullptr)

I would think the params.verts are coordinates for all the vertices.
But the params.verts there is unsigned short other than float????

Then I checked the source code for dtCreateNavMeshData():

// DetourNavMeshBuilder.cpp file
for (int i = 0; i < params->vertCount; ++i)
{
const unsigned short* iv = &params->verts[i*3];
float* v = &navVerts[i*3];
v[0] = params->bmin[0] + iv[0] * params->cs;
v[1] = params->bmin[1] + iv[1] * params->ch;
v[2] = params->bmin[2] + iv[2] * params->cs;
}


It looks like the float vertices coordinates are represented as params->cs (float) * iv (integer)?
If so, it will be hard for me to directly use my own meshes since I need to discretize them manually?
The problem is that I have both finner part and coarse part so a single param->cs could not meet my needs. I need precisely the same polygon coordinates.

Any help?
Thanks!

Evgeny Adamenkov

unread,
Jun 15, 2021, 7:21:11 PM6/15/21
to recastna...@googlegroups.com
Hi,

In general, https://github.com/recastnavigation/recastnavigation explicitly says "You can use any navigation mesh with Detour, but of course the data generated with Recast fits perfectly."

In your particular case I think you can just replace the three lines that expect voxel units with yours ones without the multiplication by voxel dimensions.  Or come up with your own version of `dtCreateNavMeshData`.  Or add a Boolean parameter to it, like bInVoxelUnits and choose between the existing way and your way.

Evgeny

--

---
You received this message because you are subscribed to the Google Groups "recastnavigation" group.
To unsubscribe from this group and stop receiving emails from it, send an email to recastnavigati...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/recastnavigation/840bbfea-a26c-4946-8106-7a0711cacd4bn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages