102 fwrite(&(chf->width),
sizeof(chf->width), 1, file);
103 fwrite(&(chf->height),
sizeof(chf->height), 1, file);
104 fwrite(&(chf->spanCount),
sizeof(chf->spanCount), 1, file);
106 fwrite(&(chf->walkableHeight),
sizeof(chf->walkableHeight), 1, file);
107 fwrite(&(chf->walkableClimb),
sizeof(chf->walkableClimb), 1, file);
109 fwrite(&(chf->maxDistance),
sizeof(chf->maxDistance), 1, file);
110 fwrite(&(chf->maxRegions),
sizeof(chf->maxRegions), 1, file);
112 fwrite(chf->bmin,
sizeof(chf->bmin), 1, file);
113 fwrite(chf->bmax,
sizeof(chf->bmax), 1, file);
115 fwrite(&(chf->cs),
sizeof(chf->cs), 1, file);
116 fwrite(&(chf->ch),
sizeof(chf->ch), 1, file);
119 if (chf->cells) tmp |= 1;
120 if (chf->spans) tmp |= 2;
121 if (chf->dist) tmp |= 4;
122 if (chf->areas) tmp |= 8;
124 fwrite(&tmp,
sizeof(tmp), 1, file);
127 fwrite(chf->cells,
sizeof(rcCompactCell), chf->width*chf->height, file);
129 fwrite(chf->spans,
sizeof(rcCompactSpan), chf->spanCount, file);
131 fwrite(chf->dist,
sizeof(
unsigned short), chf->spanCount, file);
133 fwrite(chf->areas,
sizeof(
unsigned char), chf->spanCount, file);
141 fwrite(&(cs->cs),
sizeof(
float), 1, file);
142 fwrite(&(cs->ch),
sizeof(
float), 1, file);
143 fwrite(cs->bmin,
sizeof(
float), 3, file);
144 fwrite(cs->bmax,
sizeof(
float), 3, file);
145 fwrite(&(cs->nconts),
sizeof(
int), 1, file);
146 for (
int i = 0; i < cs->nconts; ++i)
148 fwrite(&cs->conts[i].area,
sizeof(
unsigned char), 1, file);
149 fwrite(&cs->conts[i].reg,
sizeof(
unsigned short), 1, file);
150 fwrite(&cs->conts[i].nverts,
sizeof(
int), 1, file);
151 fwrite(cs->conts[i].verts,
sizeof(
int), cs->conts[i].nverts*4, file);
152 fwrite(&cs->conts[i].nrverts,
sizeof(
int), 1, file);
153 fwrite(cs->conts[i].rverts,
sizeof(
int), cs->conts[i].nrverts*4, file);
191 char objFileName[255];
192 snprintf(objFileName,
sizeof(objFileName),
"meshes/map%04u_%02u_%02u.obj", mapID, tileY, tileX);
194 FILE* objFile = fopen(objFileName,
"wb");
198 snprintf(message,
sizeof(message),
"Failed to open %s for writing!\n", objFileName);
203 G3D::Array<float> allVerts;
204 G3D::Array<int> allTris;
211 float* verts = allVerts.getCArray();
212 int vertCount = allVerts.size() / 3;
213 int* tris = allTris.getCArray();
214 int triCount = allTris.size() / 3;
216 for (
int i = 0; i < allVerts.size() / 3; i++)
217 fprintf(objFile,
"v %f %f %f\n", verts[i*3], verts[i*3 + 1], verts[i*3 + 2]);
219 for (
int i = 0; i < allTris.size() / 3; i++)
220 fprintf(objFile,
"f %i %i %i\n", tris[i*3] + 1, tris[i*3 + 1] + 1, tris[i*3 + 2] + 1);
226 snprintf(tileString,
sizeof(tileString),
"[%02u,%02u]: ", tileY, tileX);
227 printf(
"%sWriting debug output... \r", tileString);
229 snprintf(objFileName,
sizeof(objFileName),
"meshes/%04u.map", mapID);
231 objFile = fopen(objFileName,
"wb");
235 snprintf(message,
sizeof(message),
"Failed to open %s for writing!\n", objFileName);
241 fwrite(&b,
sizeof(
char), 1, objFile);
244 snprintf(objFileName,
sizeof(objFileName),
"meshes/%04u_%02u_%02u.mesh", mapID, tileY, tileX);
245 objFile = fopen(objFileName,
"wb");
249 snprintf(message,
sizeof(message),
"Failed to open %s for writing!\n", objFileName);
254 fwrite(&vertCount,
sizeof(
int), 1, objFile);
255 fwrite(verts,
sizeof(
float), vertCount*3, objFile);
258 fwrite(&triCount,
sizeof(
int), 1, objFile);
259 fwrite(tris,
sizeof(
int), triCount*3, objFile);