From 1abba4a694cb18a3ad965ce1b5ddb55b536fc328 Mon Sep 17 00:00:00 2001 From: John Senneker Date: Mon, 21 Nov 2016 18:36:20 -0500 Subject: [PATCH] Initial commit --- wrap/io_trimesh/export_obj.h | 2 +- wrap/io_trimesh/import_obj.h | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/wrap/io_trimesh/export_obj.h b/wrap/io_trimesh/export_obj.h index effb733f..98fc3053 100644 --- a/wrap/io_trimesh/export_obj.h +++ b/wrap/io_trimesh/export_obj.h @@ -205,7 +205,7 @@ public: { if((mask & Mask::IOM_FACECOLOR) || (mask & Mask::IOM_WEDGTEXCOORD) || (mask & Mask::IOM_VERTTEXCOORD)) { - int index = Materials::CreateNewMaterial(m,materialVec,material_num,fi); + int index = (*fi).mInd; if(index == (int)materialVec.size())//inserts a new element material { diff --git a/wrap/io_trimesh/import_obj.h b/wrap/io_trimesh/import_obj.h index 84c06cba..9debd142 100644 --- a/wrap/io_trimesh/import_obj.h +++ b/wrap/io_trimesh/import_obj.h @@ -51,6 +51,8 @@ namespace vcg { template class ImporterOBJ { + private: + std::vector materials; public: static int &MRGBLineCount(){static int _MRGBLineCount=0; return _MRGBLineCount;} @@ -113,6 +115,7 @@ namespace vcg { int tInd; bool edge[3];// useless if the face is a polygon, no need to have variable length array Color4b c; + int mInd; }; struct ObjEdge @@ -254,7 +257,9 @@ namespace vcg { stream.close(); return E_CANTOPEN; } - std::vector materials; // materials vector + typename OpenMeshType::template PerMeshAttributeHandle> hMaterial = + vcg::tri::Allocator:: template GetPerMeshAttribute>(m, std::string("materials")); + std::vector materials = hMaterial(); // materials vector std::vector texCoords; // texture coordinates std::vector normals; // vertex normals std::vector indexedFaces; @@ -585,6 +590,8 @@ namespace vcg { // assigning face color if( oi.mask & vcg::tri::io::Mask::IOM_FACECOLOR) ff.c = currentColor; + ff.mInd = currentMaterialIdx; + ++numTriangles; indexedFaces.push_back(ff); }