polygonalmesh changes
This commit is contained in:
parent
a1502da3fd
commit
2a4549f7ef
|
@ -74,16 +74,19 @@ namespace io {
|
||||||
|
|
||||||
static DAEError LoadPolygonalListMesh(QDomNodeList& polylist,OpenMeshType& m,const size_t offset,AdditionalInfoDAE* info)
|
static DAEError LoadPolygonalListMesh(QDomNodeList& polylist,OpenMeshType& m,const size_t offset,AdditionalInfoDAE* info)
|
||||||
{
|
{
|
||||||
PolygonalMesh pm;
|
typedef PolygonalMesh< MyPolygon<typename OpenMeshType::VertexType> > PolyMesh;
|
||||||
|
PolyMesh pm;
|
||||||
for(typename OpenMeshType::VertexIterator itv = m.vert.begin();itv != m.vert.end();++itv)
|
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());
|
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();
|
int polylist_size = polylist.size();
|
||||||
for(int pl = 0; pl < polylist_size;++pl)
|
for(int pl = 0; pl < polylist_size;++pl)
|
||||||
{
|
{
|
||||||
PolygonalMesh::PERWEDGEATTRIBUTETYPE att = PolygonalMesh::NONE;
|
PolyMesh::PERWEDGEATTRIBUTETYPE att = PolyMesh::NONE;
|
||||||
WedgeAttribute wa;
|
WedgeAttribute wa;
|
||||||
FindStandardWedgeAttributes(wa,polylist.at(pl),*(info->dae->doc));
|
FindStandardWedgeAttributes(wa,polylist.at(pl),*(info->dae->doc));
|
||||||
|
|
||||||
|
@ -97,18 +100,24 @@ namespace io {
|
||||||
for(unsigned int ii = 0;ii < npolig;++ii)
|
for(unsigned int ii = 0;ii < npolig;++ii)
|
||||||
{
|
{
|
||||||
int nvert = vertcount.at(ii).toInt();
|
int nvert = vertcount.at(ii).toInt();
|
||||||
MyPolygon p(nvert);
|
typename PolyMesh::FaceType p(nvert);
|
||||||
if (!wa.wnsrc.isNull())
|
|
||||||
p.usePerWedgeNormal();
|
|
||||||
if (!wa.wcsrc.isNull())
|
|
||||||
p.usePerWedgeColor();
|
|
||||||
if (!wa.wtsrc.isNull())
|
|
||||||
p.usePerWedgeMultiTexture();
|
|
||||||
|
|
||||||
for(unsigned int iv = 0;iv < nvert;++iv)
|
for(unsigned int iv = 0;iv < nvert;++iv)
|
||||||
{
|
{
|
||||||
int index = offset + polyind.at(offpols + iv * indforpol).toInt();
|
int index = offset + polyind.at(offpols + iv * indforpol).toInt();
|
||||||
p._pv[iv] = &(pm.vert[index]);
|
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);
|
pm._pols.push_back(p);
|
||||||
offpols += nvert * indforpol;
|
offpols += nvert * indforpol;
|
||||||
|
|
|
@ -84,92 +84,46 @@ namespace io {
|
||||||
E_NOPOLYGONALMESH
|
E_NOPOLYGONALMESH
|
||||||
};
|
};
|
||||||
|
|
||||||
class MyPolygon;
|
template<typename VERTEX_TYPE>
|
||||||
class MyEdge;
|
|
||||||
class MyVertex:public vcg::VertexVNf<MyEdge , MyPolygon, MyEdge>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
MyVertex()
|
|
||||||
:vcg::VertexVNf<MyEdge , MyPolygon, MyEdge>()
|
|
||||||
{
|
|
||||||
_flags = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
MyVertex(MyVertex::CoordType& v)
|
|
||||||
{
|
|
||||||
_flags = 0;
|
|
||||||
P() = v;
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class MyPolygon
|
class MyPolygon
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
typedef VERTEX_TYPE BaseVertexType;
|
||||||
|
|
||||||
int _nvert;
|
int _nvert;
|
||||||
std::vector<MyVertex*> _pv;
|
std::vector<VERTEX_TYPE*> _pv;
|
||||||
std::vector< std::vector<vcg::TexCoord2<> > > _wtx;
|
|
||||||
std::vector<vcg::Point3f> _wnm;
|
|
||||||
std::vector< std::vector<vcg::Color4f> > _wcl;
|
|
||||||
|
|
||||||
|
|
||||||
MyPolygon(int n)
|
MyPolygon(int n)
|
||||||
:_nvert(n),_pv(_nvert)
|
:_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<MyEdge,MyVertex>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
MyEdge(MyVertex* v1,MyVertex* v2)
|
|
||||||
:vcg::Edge<MyEdge,MyVertex>(v1,v2)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename POLYGONAL_TYPE>
|
||||||
class PolygonalMesh
|
class PolygonalMesh
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
typedef POLYGONAL_TYPE FaceType;
|
||||||
|
|
||||||
enum PERWEDGEATTRIBUTETYPE {NONE = 0,NORMAL = 1,MULTITEXTURECOORD = 2,MULTICOLOR = 4};
|
enum PERWEDGEATTRIBUTETYPE {NONE = 0,NORMAL = 1,MULTITEXTURECOORD = 2,MULTICOLOR = 4};
|
||||||
|
|
||||||
typedef MyVertex::BaseVertexType VertexType;
|
typedef typename FaceType::BaseVertexType VertexType;
|
||||||
typedef VertexType* VertexPointer;
|
typedef VertexType* VertexPointer;
|
||||||
typedef std::vector<MyVertex>::iterator VertexIterator;
|
typedef typename std::vector<VertexType>::iterator VertexIterator;
|
||||||
typedef std::vector<MyPolygon>::iterator PolygonIterator;
|
typedef typename std::vector<FaceType>::iterator PolygonIterator;
|
||||||
|
|
||||||
vcg::Box3<float> bbox;
|
vcg::Box3<float> bbox;
|
||||||
|
|
||||||
std::vector<MyVertex> vert;
|
std::vector<VertexType> vert;
|
||||||
std::vector<MyPolygon> _pols;
|
std::vector<FaceType> _pols;
|
||||||
|
|
||||||
void generatePointsVector(std::vector<std::vector<vcg::Point3f> >& v)
|
void generatePointsVector(std::vector<std::vector<vcg::Point3f> >& v)
|
||||||
{
|
{
|
||||||
for(PolygonalMesh::PolygonIterator itp = _pols.begin();itp != _pols.end();++itp)
|
for(PolygonalMesh::PolygonIterator itp = _pols.begin();itp != _pols.end();++itp)
|
||||||
{
|
{
|
||||||
v.push_back(std::vector<vcg::Point3f>());
|
v.push_back(std::vector<vcg::Point3f>());
|
||||||
for(std::vector<MyVertex*>::iterator itv = itp->_pv.begin();itv != itp->_pv.end();++itv)
|
for(std::vector<VertexPointer>::iterator itv = itp->_pv.begin();itv != itp->_pv.end();++itv)
|
||||||
{
|
{
|
||||||
v[v.size() - 1].push_back((*itv)->P());
|
v[v.size() - 1].push_back((*itv)->P());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue