Corrected various bug, involving spurious commas, and pervertex color saved as per wedge color.

This commit is contained in:
Paolo Cignoni 2008-02-21 17:23:57 +00:00
parent e4c62fec6d
commit 130442663c
1 changed files with 51 additions and 70 deletions

View File

@ -23,6 +23,9 @@
/**************************************************************************** /****************************************************************************
History History
$Log: not supported by cvs2svn $ $Log: not supported by cvs2svn $
Revision 1.6 2007/06/12 10:15:35 cignoni
Very important change. No more scaling and translation in the saved file!
Revision 1.5 2007/03/20 16:47:49 cignoni Revision 1.5 2007/03/20 16:47:49 cignoni
Update to the new texture syntax Update to the new texture syntax
@ -110,19 +113,12 @@ namespace vcg {
// Vertici // Vertici
for(ind=0,vi=m.vert.begin(); vi!=m.vert.end(); ++vi, ++ind) for(ind=0,vi=m.vert.begin(); vi!=m.vert.end(); ++vi, ++ind)
if(!(*vi).IsD())
{ {
if(ind%4==0) if(vi!=m.vert.begin()) fprintf(fp,", ");
fprintf(fp, if(ind%4==0) fprintf(fp, "\n " );
"\n " fprintf(fp, "%g %g %g" ,(*vi).P()[0] ,(*vi).P()[1] ,(*vi).P()[2] );
);
fprintf(fp,
"%g %g %g, "
,(*vi).P()[0]
,(*vi).P()[1]
,(*vi).P()[2]
);
index[&*vi] = ind; index[&*vi] = ind;
} }
fprintf(fp,"\n" fprintf(fp,"\n"
" ]\n" " ]\n"
@ -130,7 +126,7 @@ namespace vcg {
); );
if( m.HasPerVertexColor() && (mask & vcg::tri::io::Mask::IOM_VERTCOLOR)) if( HasPerVertexColor(m) && (mask & vcg::tri::io::Mask::IOM_VERTCOLOR))
{ {
fprintf(fp, fprintf(fp,
" color Color\n" " color Color\n"
@ -139,37 +135,24 @@ namespace vcg {
" [" " ["
); );
for(ind=0,vi=m.vert.begin();vi!=m.vert.end();++vi,++ind) for(ind=0,vi=m.vert.begin();vi!=m.vert.end();++vi,++ind)
if(!(*vi).IsD())
{ {
if(vi!=m.vert.begin()) fprintf(fp,", ");
float r = float(vi->C()[0])/255; float r = float(vi->C()[0])/255;
float g = float(vi->C()[1])/255; float g = float(vi->C()[1])/255;
float b = float(vi->C()[2])/255; float b = float(vi->C()[2])/255;
if(ind%4==0) if(ind%4==0)
fprintf(fp,"\n "); fprintf(fp,"\n ");
fprintf(fp,"%g %g %g,",r,g,b); fprintf(fp,"%g %g %g",r,g,b);
} }
fprintf(fp, fprintf(fp,
"\n" "\n"
" ]\n" " ]\n"
" }\n" " }\n"
" colorIndex\n"
" ["
);
for(ind=0,fi=m.face.begin(); fi!=m.face.end(); ++fi,++ind)
{
if(ind%4==0)
fprintf(fp,"\n ");
for (int j = 0; j < 3; j++)
fprintf(fp,"%i,",index[(*fi).V(j)]);
fprintf(fp,"-1,");
}
fprintf(fp,
"\n"
" ]\n"
); );
} }
else if( m.HasPerWedgeColor() && (mask & vcg::tri::io::Mask::IOM_WEDGCOLOR )) else if( HasPerWedgeColor(m) && (mask & vcg::tri::io::Mask::IOM_WEDGCOLOR ))
{ {
fprintf(fp, fprintf(fp,
" color Color\n" " color Color\n"
@ -177,15 +160,17 @@ namespace vcg {
" color\n" " color\n"
" [" ); " [" );
for(ind=0,fi=m.face.begin();fi!=m.face.end();++fi,++ind) for(ind=0,fi=m.face.begin();fi!=m.face.end();++fi,++ind)
if(!(*fi).IsD())
{ {
if(fi!=m.face.begin()) fprintf(fp,", ");
if(ind%4==0) fprintf(fp,"\n ");
for(int z=0;z<3;++z) for(int z=0;z<3;++z)
{ {
if(z!=0) fprintf(fp,", ");
float r = float(fi->WC(z)[0])/255; float r = float(fi->WC(z)[0])/255;
float g = float(fi->WC(z)[1])/255; float g = float(fi->WC(z)[1])/255;
float b = float(fi->WC(z)[2])/255; float b = float(fi->WC(z)[2])/255;
if(ind%4==0) fprintf(fp,"%g %g %g",r,g,b);
fprintf(fp,"\n ");
fprintf(fp,"%g %g %g,",r,g,b);
} }
} }
fprintf(fp, fprintf(fp,
@ -196,15 +181,14 @@ namespace vcg {
" [" ); " [" );
int nn = 0; int nn = 0;
for(ind=0,fi=m.face.begin(); fi!=m.face.end(); ++fi,++ind) for(ind=0,fi=m.face.begin(); fi!=m.face.end(); ++fi,++ind)
if(!(*fi).IsD())
{ {
if(ind%4==0) //if(fi!=m.face.begin()) fprintf(fp,", ");
fprintf(fp,"\n "); if(ind%4==0) fprintf(fp,"\n ");
for (int j = 0; j < 3; j++) fprintf(fp,"%i",nn++);
{ fprintf(fp,"%i",nn++);
fprintf(fp,"%i,",nn); fprintf(fp,"%i",nn++);
++nn; fprintf(fp,"-1");
}
fprintf(fp,"-1,");
} }
fprintf(fp, fprintf(fp,
"\n" "\n"
@ -221,13 +205,12 @@ namespace vcg {
" [\n" " [\n"
); );
for(ind=0,fi=m.face.begin(); fi!=m.face.end(); ++fi,++ind) for(ind=0,fi=m.face.begin(); fi!=m.face.end(); ++fi,++ind)
if(!(*fi).IsD())
{ {
if(ind%4==0) if(fi!=m.face.begin()) fprintf(fp,", ");
fprintf(fp,"\n "); if(ind%4==0) fprintf(fp,"\n ");
for (int j = 0; j < 3; j++) for (int j = 0; j < 3; j++)
{ fprintf(fp,"%g %g ",fi->WT(j).u(),fi->WT(j).v());
fprintf(fp,"%g %g, ",fi->WT(j).u(),fi->WT(j).v());
}
} }
fprintf(fp, fprintf(fp,
"\n" "\n"
@ -238,14 +221,12 @@ namespace vcg {
); );
int nn = 0; int nn = 0;
for(ind=0,fi=m.face.begin(); fi!=m.face.end(); ++fi,++ind) for(ind=0,fi=m.face.begin(); fi!=m.face.end(); ++fi,++ind)
if(!(*fi).IsD())
{ {
if(ind%4==0) if(fi!=m.face.begin()) fprintf(fp,", ");
fprintf(fp,"\n "); if(ind%4==0) fprintf(fp,"\n ");
for (int j = 0; j < 3; j++) for (int j = 0; j < 3; j++)
{ fprintf(fp,"%d,",nn++);
fprintf(fp,"%d,",nn);
++nn;
}
fprintf(fp,"-1,"); fprintf(fp,"-1,");
} }
fprintf(fp, fprintf(fp,
@ -259,14 +240,14 @@ namespace vcg {
); );
// Facce // Facce
for(ind=0,fi=m.face.begin(); fi!=m.face.end(); ++fi,++ind) for(ind=0,fi=m.face.begin(); fi!=m.face.end(); ++fi,++ind)
if(!(*fi).IsD())
{ {
if(ind%6==0) if(fi!=m.face.begin()) fprintf(fp,", ");
{ if(ind%6==0) fprintf(fp,"\n ");
fprintf(fp,"\n ");
}
for (int j = 0; j < 3; j++) for (int j = 0; j < 3; j++)
fprintf(fp,"%i,",index[(*fi).V(j)]); fprintf(fp,"%i,",index[(*fi).V(j)]);
fprintf(fp,"-1,");
fprintf(fp,"-1");
} }
fprintf(fp, fprintf(fp,
"\n" "\n"