OpenMesh::IO::write_mesh not writing out FaceTexCoord
Via Mailinglist:
Hi there,
First time poster. I have a question regarding writing out an OBJ with face texture coordinates. Is it possible?
To write my texture coordinates, I've done the following with my textures being std::vectorOpenMesh::Vec6f:
this->_mesh.request_halfedge_texcoords2D();
if (!this->_mesh.has_halfedge_texcoords2D())
return false;
//iterate through faces
int f_idx = 0;
for (Mesh::FaceIter it = _mesh.faces_begin(); it != _mesh.faces_end(); ++it)
{
Mesh::FaceHalfedgeIter fh_it = _mesh.fh_iter(*it);
int k = 0;
OpenMesh::Vec6f uv = textures->at(f_idx);
for(; fh_it.is_valid(); ++fh_it) {
_mesh.set_texcoord2D(*fh_it, Mesh::TexCoord2D(uv[2*k], uv[2*k + 1]));
k ++;
}
f_idx ++;
}
I write out the OBJ with:
OpenMesh::IO::Options wopt;
if (_mesh->has_halfedge_texcoords2D()) {
wopt += OpenMesh::IO::Options::FaceTexCoord;
}
std::string path = "out.obj";
if (OpenMesh::IO::write_mesh(*_mesh, path, wopt)) {
return true;
}
Is this correct? The "has_halfedge_texcoords2D" does pass.
Thanks, Jan-Michael