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(¶ms, &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 = ¶ms->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!