Added managment of face color in saving off files

This commit is contained in:
Paolo Cignoni 2014-10-29 22:24:45 +00:00
parent 54875ffa0a
commit 7364bbdb61
1 changed files with 119 additions and 118 deletions

View File

@ -59,7 +59,6 @@ namespace vcg {
if(fpout==NULL) return 1; // 1 is the error code for cant'open, see the ErrorMsg function
if( tri::HasPerVertexColor(m) && (mask & io::Mask::IOM_VERTNORMAL))
fprintf(fpout,"N");
if( tri::HasPerVertexColor(m) && (mask & io::Mask::IOM_VERTCOLOR))
@ -75,7 +74,6 @@ namespace vcg {
polynumber = m.fn;
fprintf(fpout,"%d %d 0\n", m.vn, polynumber); // note that as edge number we simply write zero
typename SaveMeshType::FaceIterator fi;
//vertices
int j;
@ -93,7 +91,7 @@ namespace vcg {
if( tri::HasPerVertexColor(m) && (mask & io::Mask::IOM_VERTCOLOR) )
fprintf(fpout,"%d %d %d %d ",vp->C()[0],vp->C()[1],vp->C()[2],vp->C()[3] );
if( tri::HasPerVertexColor(m) && (mask & io::Mask::IOM_VERTNORMAL) )
if( tri::HasPerVertexNormal(m) && (mask & io::Mask::IOM_VERTNORMAL) )
fprintf(fpout,"%g %g %g ", vp->N()[0],vp->N()[1],vp->N()[2]);
if( tri::HasPerVertexTexCoord(m) && (mask & io::Mask::IOM_VERTTEXCOORD) )
@ -114,7 +112,7 @@ namespace vcg {
tri::RequireFFAdjacency(m);
std::vector<VertexPointer> polygon;
tri::UpdateFlags<SaveMeshType>::FaceClearV(m);
for(fi=m.face.begin();fi!=m.face.end();++fi) if (!fi->IsD()) if (!fi->IsV()) {
for(FaceIterator fi=m.face.begin();fi!=m.face.end();++fi) if (!fi->IsD()) if (!fi->IsV()) {
vcg::tri::PolygonSupport<SaveMeshType,SaveMeshType>::ExtractPolygon(&*fi,polygon);
if(!polygon.empty())
{
@ -125,12 +123,14 @@ namespace vcg {
}
}
else {
for(fi=m.face.begin();fi!=m.face.end();++fi)
for(FaceIterator fi=m.face.begin();fi!=m.face.end();++fi)
{
FacePointer fp=&(*fi);
if( ! fp->IsD() )
{ fprintf(fpout,"3 %d %d %d\n",
fp->cV(0)->Flags(), fp->cV(1)->Flags(), fp->cV(2)->Flags() );
if( ! fi->IsD() )
{
if( tri::HasPerFaceColor(m) && (mask & io::Mask::IOM_FACECOLOR) )
fprintf(fpout,"3 %d %d %d %i %i %i\n", fi->cV(0)->Flags(), fi->cV(1)->Flags(), fi->cV(2)->Flags(), fi->C()[0],fi->C()[1],fi->C()[2] );
else
fprintf(fpout,"3 %d %d %d\n", fi->cV(0)->Flags(), fi->cV(1)->Flags(), fi->cV(2)->Flags() );
}
}
}
@ -168,6 +168,7 @@ namespace vcg {
capability |= vcg::tri::io::Mask::IOM_VERTCOLOR;
capability |= vcg::tri::io::Mask::IOM_VERTTEXCOORD;
capability |= vcg::tri::io::Mask::IOM_FACEINDEX;
capability |= vcg::tri::io::Mask::IOM_FACECOLOR;
capability |= vcg::tri::io::Mask::IOM_BITPOLYGONAL;
return capability;
}