Added OBJ-Reader Texcoords per Halfedge Support

git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@87 fdac6126-5c0c-442c-9429-916003d36597
This commit is contained in:
David Bommes
2009-03-20 12:33:38 +00:00
parent c55b06644d
commit 22bb307868
3 changed files with 37 additions and 0 deletions

View File

@@ -239,6 +239,8 @@ read(std::fstream& _in, BaseImporter& _bi, Options& _opt)
std::vector<Vec3f> normals;
std::vector<Vec2f> texcoords;
std::vector<Vec2f> face_texcoords;
std::map<std::string,Material> materials;
std::string matname;
@@ -343,6 +345,7 @@ read(std::fstream& _in, BaseImporter& _bi, Options& _opt)
int value;
vhandles.clear();
face_texcoords.clear();
// read full line after detecting a face
std::string faceLine;
@@ -419,6 +422,7 @@ read(std::fstream& _in, BaseImporter& _bi, Options& _opt)
assert(!vhandles.empty());
assert((unsigned int)(value-1) < texcoords.size());
_bi.set_texcoord(vhandles.back(), texcoords[value-1]);
face_texcoords.push_back( texcoords[value-1] );
break;
case 2: // normal
@@ -446,6 +450,9 @@ read(std::fstream& _in, BaseImporter& _bi, Options& _opt)
size_t n_faces = _bi.n_faces();
FaceHandle fh = _bi.add_face(vhandles);
if( !vhandles.empty() )
_bi.add_face_texcoords( fh, vhandles[0], face_texcoords );
if ( !matname.empty() && materials_[matname].has_Kd() )
{
std::vector<FaceHandle> newfaces;