36 printf(
"%sWriting debug output... \r", tileString.c_str());
38 auto debugWrite = [&](
char const* extension,
auto const* data)
40 std::string fileName =
Trinity::StringFormat(
"meshes/{:04}{:02}{:02}.{}", mapID, tileY, tileX, extension);
41 if (FILE* file = fopen(fileName.c_str(),
"wb"))
67 fwrite(&(mesh->cs),
sizeof(
float), 1, file);
68 fwrite(&(mesh->ch),
sizeof(
float), 1, file);
69 fwrite(&(mesh->width),
sizeof(
int), 1, file);
70 fwrite(&(mesh->height),
sizeof(
int), 1, file);
71 fwrite(mesh->bmin,
sizeof(
float), 3, file);
72 fwrite(mesh->bmax,
sizeof(
float), 3, file);
74 for (
int y = 0; y < mesh->height; ++y)
75 for (
int x = 0; x < mesh->width; ++x)
77 rcSpan* span = mesh->spans[x+y*mesh->width];
88 fwrite(&spanCount,
sizeof(
int), 1, file);
91 span = mesh->spans[x+y*mesh->width];
94 fwrite(span,
sizeof(rcSpan), 1, file);
105 fwrite(&(chf->width),
sizeof(chf->width), 1, file);
106 fwrite(&(chf->height),
sizeof(chf->height), 1, file);
107 fwrite(&(chf->spanCount),
sizeof(chf->spanCount), 1, file);
109 fwrite(&(chf->walkableHeight),
sizeof(chf->walkableHeight), 1, file);
110 fwrite(&(chf->walkableClimb),
sizeof(chf->walkableClimb), 1, file);
112 fwrite(&(chf->maxDistance),
sizeof(chf->maxDistance), 1, file);
113 fwrite(&(chf->maxRegions),
sizeof(chf->maxRegions), 1, file);
115 fwrite(chf->bmin,
sizeof(chf->bmin), 1, file);
116 fwrite(chf->bmax,
sizeof(chf->bmax), 1, file);
118 fwrite(&(chf->cs),
sizeof(chf->cs), 1, file);
119 fwrite(&(chf->ch),
sizeof(chf->ch), 1, file);
122 if (chf->cells) tmp |= 1;
123 if (chf->spans) tmp |= 2;
124 if (chf->dist) tmp |= 4;
125 if (chf->areas) tmp |= 8;
127 fwrite(&tmp,
sizeof(tmp), 1, file);
130 fwrite(chf->cells,
sizeof(rcCompactCell), chf->width*chf->height, file);
132 fwrite(chf->spans,
sizeof(rcCompactSpan), chf->spanCount, file);
134 fwrite(chf->dist,
sizeof(
unsigned short), chf->spanCount, file);
136 fwrite(chf->areas,
sizeof(
unsigned char), chf->spanCount, file);
144 fwrite(&(cs->cs),
sizeof(
float), 1, file);
145 fwrite(&(cs->ch),
sizeof(
float), 1, file);
146 fwrite(cs->bmin,
sizeof(
float), 3, file);
147 fwrite(cs->bmax,
sizeof(
float), 3, file);
148 fwrite(&(cs->nconts),
sizeof(
int), 1, file);
149 for (
int i = 0; i < cs->nconts; ++i)
151 fwrite(&cs->conts[i].area,
sizeof(
unsigned char), 1, file);
152 fwrite(&cs->conts[i].reg,
sizeof(
unsigned short), 1, file);
153 fwrite(&cs->conts[i].nverts,
sizeof(
int), 1, file);
154 fwrite(cs->conts[i].verts,
sizeof(
int), cs->conts[i].nverts*4, file);
155 fwrite(&cs->conts[i].nrverts,
sizeof(
int), 1, file);
156 fwrite(cs->conts[i].rverts,
sizeof(
int), cs->conts[i].nrverts*4, file);
165 fwrite(&(mesh->cs),
sizeof(
float), 1, file);
166 fwrite(&(mesh->ch),
sizeof(
float), 1, file);
167 fwrite(&(mesh->nvp),
sizeof(
int), 1, file);
168 fwrite(mesh->bmin,
sizeof(
float), 3, file);
169 fwrite(mesh->bmax,
sizeof(
float), 3, file);
170 fwrite(&(mesh->nverts),
sizeof(
int), 1, file);
171 fwrite(mesh->verts,
sizeof(
unsigned short), mesh->nverts*3, file);
172 fwrite(&(mesh->npolys),
sizeof(
int), 1, file);
173 fwrite(mesh->polys,
sizeof(
unsigned short), mesh->npolys*mesh->nvp*2, file);
174 fwrite(mesh->flags,
sizeof(
unsigned short), mesh->npolys, file);
175 fwrite(mesh->areas,
sizeof(
unsigned char), mesh->npolys, file);
176 fwrite(mesh->regs,
sizeof(
unsigned short), mesh->npolys, file);
184 fwrite(&(mesh->nverts),
sizeof(
int), 1, file);
185 fwrite(mesh->verts,
sizeof(
float), mesh->nverts*3, file);
186 fwrite(&(mesh->ntris),
sizeof(
int), 1, file);
187 fwrite(mesh->tris,
sizeof(
char), mesh->ntris*4, file);
188 fwrite(&(mesh->nmeshes),
sizeof(
int), 1, file);
189 fwrite(mesh->meshes,
sizeof(
int), mesh->nmeshes*4, file);
194 std::string objFileName;
197 FILE* objFile = fopen(objFileName.c_str(),
"wb");
204 G3D::Array<float> allVerts;
205 G3D::Array<int> allTris;
212 float* verts = allVerts.getCArray();
213 int vertCount = allVerts.size() / 3;
214 int* tris = allTris.getCArray();
215 int triCount = allTris.size() / 3;
217 for (
int i = 0; i < allVerts.size() / 3; i++)
218 fprintf(objFile,
"v %f %f %f\n", verts[i*3], verts[i*3 + 1], verts[i*3 + 2]);
220 for (
int i = 0; i < allTris.size() / 3; i++)
221 fprintf(objFile,
"f %i %i %i\n", tris[i*3] + 1, tris[i*3 + 1] + 1, tris[i*3 + 2] + 1);
225 printf(
"[%02u,%02u]: Writing debug output... \r", tileY, tileX);
229 objFile = fopen(objFileName.c_str(),
"wb");
237 fwrite(&b,
sizeof(
char), 1, objFile);
241 objFile = fopen(objFileName.c_str(),
"wb");
248 fwrite(&vertCount,
sizeof(
int), 1, objFile);
249 fwrite(verts,
sizeof(
float), vertCount*3, objFile);
252 fwrite(&triCount,
sizeof(
int), 1, objFile);
253 fwrite(tris,
sizeof(
int), triCount*3, objFile);
static void copyIndices(std::vector< VMAP::MeshTriangle > const &source, G3D::Array< int > &dest, int offset, bool flip)
std::string StringFormat(FormatString< Args... > fmt, Args &&... args)
Default TC string format function.
G3D::Array< float > liquidVerts
G3D::Array< float > solidVerts
G3D::Array< int > liquidTris
G3D::Array< int > solidTris