MCPcopy Create free account
hub / github.com/ddiakopoulos/polymer / export_obj_data

Function export_obj_data

libraries/lib-model-io/src/model-io.cpp:298–313  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

296}
297
298void export_obj_data(std::ofstream & file, runtime_mesh & mesh)
299{
300 file << "# vertices\n";
301 for (auto & v : mesh.vertices) file << "v " << std::fixed << v.x << " " << std::fixed << v.y << " " << std::fixed << v.z << std::endl;
302
303 float3 normalSum{ 0.f };
304 float2 texcoordSum{ 0.f };
305 for (auto v : mesh.normals) normalSum += v;
306 for (auto v : mesh.texcoord0) texcoordSum += v;
307
308 if (normalSum > float3(0.f)) for (auto & v : mesh.normals) file << "vn " << std::fixed << v.x << " " << std::fixed << v.y << " " << std::fixed << v.z << std::endl;
309 if (texcoordSum > float2(0.f)) for (auto & v : mesh.texcoord0) file << "vt " << std::fixed << v.x << " " << std::fixed << v.y << std::endl;
310
311 file << "# faces\n";
312 for (auto & v : mesh.faces) file << "f " << v.x + 1 << " " << v.y + 1 << " " << v.z + 1 << std::endl;
313}
314
315bool polymer::export_obj_model(const std::string & name, const std::string & filename, runtime_mesh & mesh)
316{

Callers 2

export_obj_modelMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected