204 char objFileName[255];
205 sprintf(objFileName,
"meshes/map%03u%02u%02u.obj", mapID, tileY, tileX);
207 FILE* objFile = fopen(objFileName,
"wb");
211 sprintf(message,
"Failed to open %s for writing!\n", objFileName);
219 allTris.
append(meshData.liquidTris);
220 allVerts.
append(meshData.liquidVerts);
222 allVerts.
append(meshData.solidVerts);
225 int vertCount = allVerts.
size() / 3;
227 int triCount = allTris.
size() / 3;
229 for (
int i = 0; i < allVerts.
size() / 3; i++)
230 fprintf(objFile,
"v %f %f %f\n", verts[i*3], verts[i*3 + 1], verts[i*3 + 2]);
232 for (
int i = 0; i < allTris.
size() / 3; i++)
233 fprintf(objFile,
"f %i %i %i\n", tris[i*3] + 1, tris[i*3 + 1] + 1, tris[i*3 + 2] + 1);
239 sprintf(tileString,
"[%02u,%02u]: ", tileY, tileX);
240 printf(
"%sWriting debug output... \r", tileString);
242 sprintf(objFileName,
"meshes/%03u.map", mapID);
244 objFile = fopen(objFileName,
"wb");
248 sprintf(message,
"Failed to open %s for writing!\n", objFileName);
254 fwrite(&b,
sizeof(
char), 1, objFile);
257 sprintf(objFileName,
"meshes/%03u%02u%02u.mesh", mapID, tileY, tileX);
258 objFile = fopen(objFileName,
"wb");
262 sprintf(message,
"Failed to open %s for writing!\n", objFileName);
267 fwrite(&vertCount,
sizeof(
int), 1, objFile);
268 fwrite(verts,
sizeof(
float), vertCount*3, objFile);
271 fwrite(&triCount,
sizeof(
int), 1, objFile);
272 fwrite(tris,
sizeof(
int), triCount*3, objFile);
FMT_API int fprintf(std::FILE *f, CStringRef format, ArgList args)
T * getCArray()
Definition: Array.h:256
std::string sprintf(CStringRef format, ArgList args)
Definition: format.h:3096
int size() const
Definition: Array.h:430
void append(const T &value)
Definition: Array.h:583
static void copyIndices(std::vector< VMAP::MeshTriangle > &source, G3D::Array< int > &dest, int offest, bool flip)
Definition: TerrainBuilder.cpp:807
void printf(BasicWriter< Char > &w, BasicCStringRef< Char > format, ArgList args)
Definition: format.h:3083