diff --git a/wrap/io_trimesh/import_dae.h b/wrap/io_trimesh/import_dae.h index 409a4d84..13d51045 100644 --- a/wrap/io_trimesh/import_dae.h +++ b/wrap/io_trimesh/import_dae.h @@ -74,16 +74,19 @@ namespace io { static DAEError LoadPolygonalListMesh(QDomNodeList& polylist,OpenMeshType& m,const size_t offset,AdditionalInfoDAE* info) { - PolygonalMesh pm; + typedef PolygonalMesh< MyPolygon > PolyMesh; + PolyMesh pm; for(typename OpenMeshType::VertexIterator itv = m.vert.begin();itv != m.vert.end();++itv) { vcg::Point3f p(itv->P().X(),itv->P().Y(),itv->P().Z()); - pm.vert.push_back(p); + PolyMesh::VertexType v; + v.P() = p; + pm.vert.push_back(v); } int polylist_size = polylist.size(); for(int pl = 0; pl < polylist_size;++pl) { - PolygonalMesh::PERWEDGEATTRIBUTETYPE att = PolygonalMesh::NONE; + PolyMesh::PERWEDGEATTRIBUTETYPE att = PolyMesh::NONE; WedgeAttribute wa; FindStandardWedgeAttributes(wa,polylist.at(pl),*(info->dae->doc)); @@ -97,18 +100,24 @@ namespace io { for(unsigned int ii = 0;ii < npolig;++ii) { int nvert = vertcount.at(ii).toInt(); - MyPolygon p(nvert); - if (!wa.wnsrc.isNull()) - p.usePerWedgeNormal(); - if (!wa.wcsrc.isNull()) - p.usePerWedgeColor(); - if (!wa.wtsrc.isNull()) - p.usePerWedgeMultiTexture(); + typename PolyMesh::FaceType p(nvert); for(unsigned int iv = 0;iv < nvert;++iv) { int index = offset + polyind.at(offpols + iv * indforpol).toInt(); p._pv[iv] = &(pm.vert[index]); + int nmindex = -1; + if (!wa.wnsrc.isNull()) + { + nmindex = offset + polyind.at(offpols + iv * indforpol + wa.offnm).toInt(); + + } + + int txindex = -1; + if (!wa.wtsrc.isNull()) + { + txindex = offset + polyind.at(offpols + iv * indforpol + wa.offtx).toInt(); + } } pm._pols.push_back(p); offpols += nvert * indforpol; diff --git a/wrap/io_trimesh/util_dae.h b/wrap/io_trimesh/util_dae.h index 5e32f976..50965f20 100644 --- a/wrap/io_trimesh/util_dae.h +++ b/wrap/io_trimesh/util_dae.h @@ -84,92 +84,46 @@ namespace io { E_NOPOLYGONALMESH }; - class MyPolygon; - class MyEdge; - class MyVertex:public vcg::VertexVNf - { - public: - MyVertex() - :vcg::VertexVNf() - { - _flags = 0; - } - - MyVertex(MyVertex::CoordType& v) - { - _flags = 0; - P() = v; - - } - }; - + template class MyPolygon { public: + typedef VERTEX_TYPE BaseVertexType; + int _nvert; - std::vector _pv; - std::vector< std::vector > > _wtx; - std::vector _wnm; - std::vector< std::vector > _wcl; + std::vector _pv; MyPolygon(int n) :_nvert(n),_pv(_nvert) { } - - void usePerWedgeColor(const unsigned int multicolor = 1) - { - _wcl.resize(_nvert); - for(unsigned int ii = 0;ii < multicolor;++ii) - _wcl[ii].resize(multicolor); - } - - void usePerWedgeNormal() - { - _wnm.resize(_nvert); - } - - void usePerWedgeMultiTexture(const unsigned int multitex = 1) - { - _wtx.resize(_nvert); - for(unsigned int ii = 0;ii < multitex;++ii) - _wtx[ii].resize(multitex); - } - - }; - - class MyEdge: public vcg::Edge - { - public: - MyEdge(MyVertex* v1,MyVertex* v2) - :vcg::Edge(v1,v2) - { - } }; + template class PolygonalMesh { public: + typedef POLYGONAL_TYPE FaceType; enum PERWEDGEATTRIBUTETYPE {NONE = 0,NORMAL = 1,MULTITEXTURECOORD = 2,MULTICOLOR = 4}; - typedef MyVertex::BaseVertexType VertexType; + typedef typename FaceType::BaseVertexType VertexType; typedef VertexType* VertexPointer; - typedef std::vector::iterator VertexIterator; - typedef std::vector::iterator PolygonIterator; + typedef typename std::vector::iterator VertexIterator; + typedef typename std::vector::iterator PolygonIterator; vcg::Box3 bbox; - std::vector vert; - std::vector _pols; + std::vector vert; + std::vector _pols; void generatePointsVector(std::vector >& v) { for(PolygonalMesh::PolygonIterator itp = _pols.begin();itp != _pols.end();++itp) { v.push_back(std::vector()); - for(std::vector::iterator itv = itp->_pv.begin();itv != itp->_pv.end();++itv) + for(std::vector::iterator itv = itp->_pv.begin();itv != itp->_pv.end();++itv) { v[v.size() - 1].push_back((*itv)->P()); }