Commit ee1c359a authored by Patrik Huber's avatar Patrik Huber

write_obj will now always write out texcoords if they're available

Also removed trailing space from vertex/colour data
parent bd72c78d
...@@ -68,12 +68,20 @@ inline void write_obj(Mesh mesh, std::string filename) ...@@ -68,12 +68,20 @@ inline void write_obj(Mesh mesh, std::string filename)
if (mesh.colors.empty()) { if (mesh.colors.empty()) {
for (std::size_t i = 0; i < mesh.vertices.size(); ++i) { for (std::size_t i = 0; i < mesh.vertices.size(); ++i) {
obj_file << "v " << mesh.vertices[i][0] << " " << mesh.vertices[i][1] << " " << mesh.vertices[i][2] << " " << std::endl; obj_file << "v " << mesh.vertices[i][0] << " " << mesh.vertices[i][1] << " " << mesh.vertices[i][2] << std::endl;
} }
} }
else { else {
for (std::size_t i = 0; i < mesh.vertices.size(); ++i) { for (std::size_t i = 0; i < mesh.vertices.size(); ++i) {
obj_file << "v " << mesh.vertices[i][0] << " " << mesh.vertices[i][1] << " " << mesh.vertices[i][2] << " " << mesh.colors[i][0] << " " << mesh.colors[i][1] << " " << mesh.colors[i][2] << " " << std::endl; obj_file << "v " << mesh.vertices[i][0] << " " << mesh.vertices[i][1] << " " << mesh.vertices[i][2] << " " << mesh.colors[i][0] << " " << mesh.colors[i][1] << " " << mesh.colors[i][2] << std::endl;
}
}
if (!mesh.texcoords.empty())
{
for (auto&& tc : mesh.texcoords)
{
obj_file << "vt " << tc[0] << " " << tc[1] << std::endl;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment