MachoChen / recastnavigation

Automatically exported from code.google.com/p/recastnavigation
zlib License
0 stars 0 forks source link

how to merge two all_tiles_navmesh.bin #170

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
it's too hard to handle big terrain,how to merge two all_tiles_navmesh.bin

Original issue reported on code.google.com by sandy...@gmail.com on 16 May 2011 at 7:53

GoogleCodeExporter commented 8 years ago
Hi,

Each piece in the navmesh is stored as binary chunk. That is, the data that is 
returned by dtCreateNavMeshData() can be written directly to disk.

You can for example save each tile at a time when you generate them.

--mikko

--mikko

Original comment by memono...@gmail.com on 16 May 2011 at 8:11

GoogleCodeExporter commented 8 years ago
thanks,i'll try it:)

Original comment by sandy...@gmail.com on 16 May 2011 at 9:04

GoogleCodeExporter commented 8 years ago
i'v tried it.
i opened two ".bin" files,and read mesh data in them,but the new merged 
dtNavMesh need a dtNavMeshParams to init itself,and the 
dtNavMeshParams.maxPolys and dtNavMeshParams.maxTiles in two ".bin" files are 
different.
how to get a proper maxPolys and maxTiles?if maxPolys and maxTiles are not 
right,the merged dtNavMesh won't be correct,only a part of tiles be added.

thanks!

Original comment by sandy...@gmail.com on 17 May 2011 at 4:11

GoogleCodeExporter commented 8 years ago
You should make maxTiles a constant. It should be close to the maximum number 
of tiles you plan to use at runtime. For example if you load only parts of the 
level at a time, then maxTiles should reflect the max number of tiles being 
loaded at the same time.

--mikko

Original comment by memono...@gmail.com on 17 May 2011 at 5:50

GoogleCodeExporter commented 8 years ago
no need to merge now:)
in rcMeshLoaderObj::load
        fseek(fp, 0, SEEK_END);
    int bufSize = ftell(fp);
    fseek(fp, 0, SEEK_SET);
    buf = new char[bufSize];

if the bufSize is too big,memory will not be enough when addTriangle,so i use 
fgets to read a line one time to resolve this problem.The code is:

        const int MAX_CHAR_COUNT_A_LINE = 512;
    char row[MAX_CHAR_COUNT_A_LINE];
    int face[32];
    float x,y,z;
    int nv;
    int vcap = 0;
    int tcap = 0;
    while (fgets(row, MAX_CHAR_COUNT_A_LINE, fp) != NULL)
    {
        if (row[0] == '#') continue;
        if (row[0] == 'v' && row[1] != 'n' && row[1] != 't')
        {
            // Vertex pos
            sscanf(row+1, "%f %f %f", &x, &y, &z);
            addVertex(x, y, z, vcap);
        }
        if (row[0] == 'f')
        {
            // Faces
            nv = parseFace(row+1, face, 32, m_vertCount);
            for (int i = 2; i < nv; ++i)
            {
                const int a = face[0];
                const int b = face[i-1];
                const int c = face[i];
                if (a < 0 || a >= m_vertCount || b < 0 || b >= m_vertCount || c < 0 || c >= m_vertCount)
                    continue;
                addTriangle(a, b, c, tcap);
            }
        }
    }
    fclose(fp);

Original comment by sandy...@gmail.com on 19 May 2011 at 9:44

GoogleCodeExporter commented 8 years ago

Original comment by memono...@gmail.com on 11 Sep 2011 at 11:25