| 296 | } |
| 297 | |
| 298 | void 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 | |
| 315 | bool polymer::export_obj_model(const std::string & name, const std::string & filename, runtime_mesh & mesh) |
| 316 | { |
no outgoing calls
no test coverage detected