Closed GoogleCodeExporter closed 9 years ago
Serializing the mesh as simple as follows, there is no need to create classes
for
that. I could have it included in some example, though. (untested code, could
use few
sanity checks).
// Write
unsigned char* navData = 0;
int navDataSize = 0;
dtCreateNavMeshData(m_pmesh->verts, m_pmesh->nverts, m_pmesh->polys,
m_pmesh->npolys, m_pmesh->nvp,
m_cfg.bmin, m_cfg.bmax, m_cfg.cs, m_cfg.ch,
m_dmesh->meshes, m_dmesh->verts, m_dmesh->nverts,
m_dmesh->tris, m_dmesh->ntris,
&navData, &navDataSize);
FILE* fp = fopen("navmesh.nm", "rb");
fwrite(navData, navDataSize, 1, fp);
fclose(fp);
// Read
FILE* fp = fopen(fileName, "rb");
fseek(fp, 0, SEEK_END);
int navDataSize = ftell(fp);
fseek(fp, 0, SEEK_SET);
unsigned char* navData = new unsigned char[navDataSize];
fread(navData, navDataSize, 1, fp);
fclose(fp);
m_navMesh = new dtStatNavMesh;
m_navMesh->init(navData, navDataSize, true);
Original comment by memono...@gmail.com
on 9 Nov 2009 at 6:05
Original issue reported on code.google.com by
seaninaf...@gmail.com
on 7 Nov 2009 at 12:45