added suppor of color in OFF format.
This commit is contained in:
parent
f2e6bfa8eb
commit
0bdd7975b0
|
@ -25,6 +25,9 @@
|
||||||
History
|
History
|
||||||
|
|
||||||
$Log: not supported by cvs2svn $
|
$Log: not supported by cvs2svn $
|
||||||
|
Revision 1.6 2006/11/04 14:01:00 granzuglia
|
||||||
|
fixed bug: &(*filename.end()) ---> &(*filename.rbegin())
|
||||||
|
|
||||||
Revision 1.5 2006/07/09 05:32:15 cignoni
|
Revision 1.5 2006/07/09 05:32:15 cignoni
|
||||||
Uncommented obj export. Now obj saving is enabled by default
|
Uncommented obj export. Now obj saving is enabled by default
|
||||||
|
|
||||||
|
@ -106,7 +109,7 @@ static int Save(OpenMeshType &m, const char *filename, const int mask, CallBackP
|
||||||
}
|
}
|
||||||
else if(FileExtension(filename,"off"))
|
else if(FileExtension(filename,"off"))
|
||||||
{
|
{
|
||||||
err = ExporterOFF<OpenMeshType>::Save(m,filename);
|
err = ExporterOFF<OpenMeshType>::Save(m,filename,mask);
|
||||||
LastType()=KT_OFF;
|
LastType()=KT_OFF;
|
||||||
}
|
}
|
||||||
else if(FileExtension(filename,"dxf"))
|
else if(FileExtension(filename,"dxf"))
|
||||||
|
|
|
@ -24,6 +24,9 @@
|
||||||
History
|
History
|
||||||
|
|
||||||
$Log: not supported by cvs2svn $
|
$Log: not supported by cvs2svn $
|
||||||
|
Revision 1.13 2007/11/06 10:58:25 cignoni
|
||||||
|
Changed the return value to the standard 0 in case of success and notzero for failures
|
||||||
|
|
||||||
Revision 1.12 2007/03/12 16:40:17 tarini
|
Revision 1.12 2007/03/12 16:40:17 tarini
|
||||||
Texture coord name change! "TCoord" and "Texture" are BAD. "TexCoord" is GOOD.
|
Texture coord name change! "TCoord" and "Texture" are BAD. "TexCoord" is GOOD.
|
||||||
|
|
||||||
|
@ -70,8 +73,8 @@ namespace vcg {
|
||||||
|
|
||||||
|
|
||||||
if( m.HasPerVertexNormal() && (mask & io::Mask::IOM_VERTNORMAL)) fprintf(fpout,"N");
|
if( m.HasPerVertexNormal() && (mask & io::Mask::IOM_VERTNORMAL)) fprintf(fpout,"N");
|
||||||
if( m.HasPerVertexColor() && (mask & io::Mask::IOM_VERTCOLOR)) fprintf(fpout,"C");
|
if( tri::HasPerVertexColor(m) && (mask & io::Mask::IOM_VERTCOLOR)) fprintf(fpout,"C");
|
||||||
if( m.HasPerVertexTexCoord() && (mask & io::Mask::IOM_VERTTEXCOORD)) fprintf(fpout,"ST");
|
if( tri::HasPerVertexTexCoord(m) && (mask & io::Mask::IOM_VERTTEXCOORD)) fprintf(fpout,"ST");
|
||||||
fprintf(fpout,"OFF\n");
|
fprintf(fpout,"OFF\n");
|
||||||
fprintf(fpout,"%d %d 0\n", m.vn, m.fn); // note that as edge number we simply write zero
|
fprintf(fpout,"%d %d 0\n", m.vn, m.fn); // note that as edge number we simply write zero
|
||||||
typename SaveMeshType::FaceIterator fi;
|
typename SaveMeshType::FaceIterator fi;
|
||||||
|
@ -88,15 +91,18 @@ namespace vcg {
|
||||||
if( ! vp->IsD() )
|
if( ! vp->IsD() )
|
||||||
{ // ***** ASCII *****
|
{ // ***** ASCII *****
|
||||||
|
|
||||||
fprintf(fpout,"%g %g %g\n" ,vp->P()[0],vp->P()[1],vp->P()[2]);
|
fprintf(fpout,"%g %g %g " ,vp->P()[0],vp->P()[1],vp->P()[2]);
|
||||||
if( m.HasPerVertexColor() && (mask & io::Mask::IOM_VERTCOLOR) )
|
if( tri::HasPerVertexColor(m) && (mask & io::Mask::IOM_VERTCOLOR) )
|
||||||
fprintf(fpout,"%d %d %d %d\n",vp->C()[0],vp->C()[1],vp->C()[2],vp->C()[3] );
|
fprintf(fpout,"%d %d %d %d ",vp->C()[0],vp->C()[1],vp->C()[2],vp->C()[3] );
|
||||||
|
|
||||||
if( m.HasPerVertexNormal() && (mask & io::Mask::IOM_VERTNORMAL) )
|
if( m.HasPerVertexNormal() && (mask & io::Mask::IOM_VERTNORMAL) )
|
||||||
fprintf(fpout,"%g %g %g\n", vp->N()[0],vp->N()[1],vp->N()[2]);
|
fprintf(fpout,"%g %g %g ", vp->N()[0],vp->N()[1],vp->N()[2]);
|
||||||
|
|
||||||
if( m.HasPerVertexTexCoord() && (mask & io::Mask::IOM_VERTTEXCOORD) )
|
if( m.HasPerVertexTexCoord() && (mask & io::Mask::IOM_VERTTEXCOORD) )
|
||||||
fprintf(fpout,"%g %g\n",vp->T().u(),vp->T().v());
|
fprintf(fpout,"%g %g ",vp->T().u(),vp->T().v());
|
||||||
|
|
||||||
|
fprintf(fpout,"\n");
|
||||||
|
|
||||||
|
|
||||||
vp->UberFlags()=j; // Trucco! Nascondi nei flags l'indice del vertice non deletato!
|
vp->UberFlags()=j; // Trucco! Nascondi nei flags l'indice del vertice non deletato!
|
||||||
j++;
|
j++;
|
||||||
|
|
|
@ -24,6 +24,11 @@
|
||||||
History
|
History
|
||||||
|
|
||||||
$Log: not supported by cvs2svn $
|
$Log: not supported by cvs2svn $
|
||||||
|
Revision 1.22 2008/03/13 08:48:10 granzuglia
|
||||||
|
added two missing include files:
|
||||||
|
1) #include <wrap/callback.h>
|
||||||
|
2) #include <wrap/io_trimesh/io_mask.h>
|
||||||
|
|
||||||
Revision 1.21 2007/12/13 17:57:33 cignoni
|
Revision 1.21 2007/12/13 17:57:33 cignoni
|
||||||
removed harmless gcc warnings
|
removed harmless gcc warnings
|
||||||
|
|
||||||
|
@ -157,17 +162,9 @@ namespace vcg
|
||||||
{
|
{
|
||||||
// To obtain the loading mask all the file must be parsed
|
// To obtain the loading mask all the file must be parsed
|
||||||
// to distinguish between per-vertex and per-face color attribute.
|
// to distinguish between per-vertex and per-face color attribute.
|
||||||
|
loadmask=0;
|
||||||
MESH_TYPE dummyMesh;
|
MESH_TYPE dummyMesh;
|
||||||
|
return (Open(dummyMesh, filename, loadmask,0,true)==NoError);
|
||||||
if (Open(dummyMesh, filename, loadmask) == NoError)
|
|
||||||
{
|
|
||||||
dummyMesh.Clear();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int Open(MESH_TYPE &mesh, const char *filename,CallBackPos *cb=0)
|
static int Open(MESH_TYPE &mesh, const char *filename,CallBackPos *cb=0)
|
||||||
|
@ -184,10 +181,8 @@ namespace vcg
|
||||||
* \return the operation result
|
* \return the operation result
|
||||||
*/
|
*/
|
||||||
static int Open(MESH_TYPE &mesh, const char *filename, int &loadmask,
|
static int Open(MESH_TYPE &mesh, const char *filename, int &loadmask,
|
||||||
CallBackPos *cb=0)
|
CallBackPos *cb=0, bool onlyMaskFlag=false )
|
||||||
{
|
{
|
||||||
mesh.Clear();
|
|
||||||
|
|
||||||
std::ifstream stream(filename);
|
std::ifstream stream(filename);
|
||||||
if (stream.fail())
|
if (stream.fail())
|
||||||
return CantOpen;
|
return CantOpen;
|
||||||
|
@ -207,14 +202,10 @@ namespace vcg
|
||||||
{
|
{
|
||||||
for (int u = static_cast<int>(header.rfind("OFF")-1); u>=0; u--)
|
for (int u = static_cast<int>(header.rfind("OFF")-1); u>=0; u--)
|
||||||
{
|
{
|
||||||
if (header[u] == 'C')
|
if (header[u] == 'C') isColorDefined = true;
|
||||||
isColorDefined = true;
|
else if (header[u] == 'N') isNormalDefined = true;
|
||||||
else if (header[u] == 'N')
|
else if (u>0 && header[u-1] == 'S' && header[u] == 'T') isTexCoordDefined = true;
|
||||||
isNormalDefined = true;
|
else if (header[u] == '4') homogeneousComponents = true;
|
||||||
else if (u>0 && header[u-1] == 'S' && header[u] == 'T')
|
|
||||||
isTexCoordDefined = true;
|
|
||||||
else if (header[u] == '4')
|
|
||||||
homogeneousComponents = true;
|
|
||||||
else if (header[u] == 'n')
|
else if (header[u] == 'n')
|
||||||
{
|
{
|
||||||
TokenizeNextLine(stream, tokens);
|
TokenizeNextLine(stream, tokens);
|
||||||
|
@ -230,11 +221,15 @@ namespace vcg
|
||||||
|
|
||||||
loadmask = Mask::IOM_VERTCOORD | Mask::IOM_FACEINDEX;
|
loadmask = Mask::IOM_VERTCOORD | Mask::IOM_FACEINDEX;
|
||||||
|
|
||||||
if (isNormalDefined)
|
if (isNormalDefined) loadmask |= Mask::IOM_VERTNORMAL;
|
||||||
loadmask |= Mask::IOM_VERTNORMAL;
|
if (isTexCoordDefined) loadmask |= Mask::IOM_VERTTEXCOORD;
|
||||||
|
if (isColorDefined) { loadmask |= Mask::IOM_VERTCOLOR;loadmask |= Mask::IOM_FACECOLOR;}
|
||||||
|
|
||||||
if (isTexCoordDefined)
|
|
||||||
loadmask |= Mask::IOM_VERTTEXCOORD;
|
if(onlyMaskFlag) return NoError;
|
||||||
|
|
||||||
|
|
||||||
|
mesh.Clear();
|
||||||
|
|
||||||
// check on next 2 lines to detect corrupted files
|
// check on next 2 lines to detect corrupted files
|
||||||
if(tokens.size() < 3)
|
if(tokens.size() < 3)
|
||||||
|
@ -320,7 +315,7 @@ namespace vcg
|
||||||
loadmask |= Mask::IOM_VERTCOLOR;
|
loadmask |= Mask::IOM_VERTCOLOR;
|
||||||
|
|
||||||
// Store color components
|
// Store color components
|
||||||
if (VertexType::HasColor())
|
if (tri::HasPerVertexColor(mesh))
|
||||||
{
|
{
|
||||||
// Read color components
|
// Read color components
|
||||||
|
|
||||||
|
@ -408,7 +403,7 @@ namespace vcg
|
||||||
k++;
|
k++;
|
||||||
|
|
||||||
// Store texture coordinates
|
// Store texture coordinates
|
||||||
if (VertexType::HasTexCoord())
|
if (tri::HasPerWedgeTexCoord(mesh))
|
||||||
{
|
{
|
||||||
//...TODO...
|
//...TODO...
|
||||||
}
|
}
|
||||||
|
@ -488,7 +483,7 @@ namespace vcg
|
||||||
// NOTE: It is assumed that colored face takes exactly one text line
|
// NOTE: It is assumed that colored face takes exactly one text line
|
||||||
// (otherwise it is impossible to parse color information since
|
// (otherwise it is impossible to parse color information since
|
||||||
// color components can vary)
|
// color components can vary)
|
||||||
if (isColorDefined)
|
if (isColorDefined && tri::HasPerFaceColor(mesh))
|
||||||
{
|
{
|
||||||
size_t color_elements = tokens.size() - vert_per_face-1;
|
size_t color_elements = tokens.size() - vert_per_face-1;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue