From 73ed783085291a039914a30ffb69eb120675e69b Mon Sep 17 00:00:00 2001 From: cignoni Date: Thu, 17 Dec 2009 17:49:51 +0000 Subject: [PATCH] Significant change. Now obj with non-convex polygonal faces are correctly managed (and faux edges are supported too). Warning it requires GLU because it relies on glu tessellation. --- wrap/io_trimesh/import_obj.h | 198 ++++++++++++++++++----------------- 1 file changed, 101 insertions(+), 97 deletions(-) diff --git a/wrap/io_trimesh/import_obj.h b/wrap/io_trimesh/import_obj.h index b97a0ff5..f6c6e8d6 100644 --- a/wrap/io_trimesh/import_obj.h +++ b/wrap/io_trimesh/import_obj.h @@ -21,69 +21,6 @@ * * ****************************************************************************/ -/**************************************************************************** -History - -$Log: not supported by cvs2svn $ -Revision 1.19 2008/01/17 18:02:02 cignoni -added missing cast for normal assignments - -Revision 1.18 2007/12/13 17:57:33 cignoni -removed harmless gcc warnings - -Revision 1.17 2007/10/17 09:49:50 cignoni -correct management of point only files - -Revision 1.16 2007/07/20 14:49:46 cignoni -Added in load mask the face color bit when there is a generic material used - -Revision 1.15 2007/07/05 14:47:04 cignoni -Added face coloring when there is a texture (and therefore a material) - -Revision 1.14 2007/04/18 13:33:11 cignoni -resolved issue related to the parsing of CR LF under *nixes - -Revision 1.13 2007/04/18 07:01:26 cignoni -Added managment of map_Ka textures (and not only map_Kd) - -Revision 1.12 2006/12/21 00:36:17 cignoni -Removed a bug in the managment of non triangular faces - -Revision 1.11 2006/12/12 02:47:12 cignoni -Removed use of tellg that is broken in current version of mingw - -Revision 1.10 2006/11/21 10:56:41 cignoni -ReWrote loadMask. Now shorter and faster. - -Revision 1.9 2006/10/09 19:58:08 cignoni -Added casts to remove warnings - -Revision 1.8 2006/07/09 05:41:17 cignoni -Major rewrite. Now shorter and more robust. - -Revision 1.7 2006/06/21 04:26:26 cignoni -added initial test on end of file in the tokenize - -Revision 1.6 2006/05/21 07:01:04 cignoni -Added mask clamping to the effective capabilities of the mesh - -Revision 1.5 2006/04/11 09:48:00 zifnab1974 -changes needed for compilation on linux 64b with gcc 3.4.5 - -Revision 1.4 2006/03/29 09:27:07 cignoni -Added managemnt of non critical errors - -Revision 1.3 2006/03/29 08:51:16 corsini -reset to zero warnings - -Revision 1.2 2006/03/27 07:18:22 cignoni -added missing std:: - -Revision 1.1 2006/03/07 13:19:29 cignoni -First Release with OBJ import support - -Initial Working version coded by Buzzelli. -****************************************************************************/ #ifndef __VCGLIB_IMPORT_OBJ #define __VCGLIB_IMPORT_OBJ @@ -92,6 +29,9 @@ Initial Working version coded by Buzzelli. #include #include #include +#ifdef __gl_h_ +#include +#endif #include #include @@ -388,14 +328,9 @@ public: int vertexesPerFace = static_cast(tokens.size()-1); if( (vertexesPerFace>3) && OpenMeshType::FaceType::HasPolyInfo() ){ - //_BEGIN___ if you are loading a GENERIC POLYGON mesh - + //_BEGIN___ if you are loading a GENERIC POLYGON mesh ff.set(vertexesPerFace); - - std::string vertex; - std::string texcoord; - std::string normal; - for(int i=0;i > polygonVect(1); // it is a vector of polygon loops + polygonVect[0].resize(vertexesPerFace); + std::vector indexVVect(vertexesPerFace); + std::vector indexNVect(vertexesPerFace); + std::vector indexTVect(vertexesPerFace); + std::vector indexTriangulatedVect; + + for(int pi=0;pi(polygonVect, indexTriangulatedVect); + extraTriangles+=((indexTriangulatedVect.size()/3) -1); + if( (indexTriangulatedVect.size()/3) != vertexesPerFace-2) + { + qDebug("Warning there is a degenerate poligon of %i verteces that was triangulated into %i triangles",vertexesPerFace,indexTriangulatedVect.size()/3); + for(int qq=0;qq",tokens[qq].c_str()); + } + + //qDebug("Triangulated a face of %i vertexes into %i triangles",polygonVect[0].size(),indexTriangulatedVect.size()); + + for(int pi=0;pi