Removed bug in the creation of the material filename
This commit is contained in:
parent
7310eb3f58
commit
391470c093
|
@ -25,6 +25,9 @@
|
|||
History
|
||||
|
||||
$Log: not supported by cvs2svn $
|
||||
Revision 1.3 2006/03/07 13:19:29 cignoni
|
||||
First Release with OBJ import support
|
||||
|
||||
Revision 1.2 2006/02/28 14:38:09 corsini
|
||||
remove qt include
|
||||
|
||||
|
@ -167,19 +170,20 @@ namespace io {
|
|||
std::vector<Material> materials;
|
||||
|
||||
std::string fn(filename);
|
||||
int i=fn.size()-1;
|
||||
while(fn[--i]!='/');
|
||||
int LastSlash=fn.size()-1;
|
||||
while(LastSlash>=0 && fn[LastSlash]!='/')
|
||||
--LastSlash;
|
||||
|
||||
FILE *fp;
|
||||
fp = fopen(filename,"w");
|
||||
if(fp == NULL)return E_CANTOPENFILE;
|
||||
|
||||
fprintf(fp,"####\n#\n# OBJ File Generated by Meshlab\n#\n####\n");
|
||||
fprintf(fp,"# Object %s\n#\n# Vertices: %d\n# Faces: %d\n#\n####\n",fn.substr(i+1).c_str(),m.vert.size(),m.face.size());
|
||||
fprintf(fp,"# Object %s\n#\n# Vertices: %d\n# Faces: %d\n#\n####\n",fn.substr(LastSlash+1).c_str(),m.vert.size(),m.face.size());
|
||||
|
||||
//library materials
|
||||
if(mask & vcg::tri::io::Mask::IOM_FACECOLOR)
|
||||
fprintf(fp,"mtllib ./%s.mtl\n\n",fn.substr(i+1).c_str());
|
||||
fprintf(fp,"mtllib ./%s.mtl\n\n",fn.substr(LastSlash+1).c_str());
|
||||
|
||||
//vertexs + normal
|
||||
VertexIterator vi;
|
||||
|
@ -201,10 +205,9 @@ namespace io {
|
|||
//saves vertex
|
||||
fprintf(fp,"v %f %f %f\n",(*vi).P()[0],(*vi).P()[1],(*vi).P()[2]);
|
||||
|
||||
if (cb !=NULL)
|
||||
(*cb)((100*++current)/max, "writing vertices ");
|
||||
else
|
||||
{ fclose(fp); return E_ABORTED;}
|
||||
if (cb !=NULL) {
|
||||
if(*cb)((100*++current)/max, "writing vertices ");
|
||||
else { fclose(fp); return E_ABORTED;} }
|
||||
}
|
||||
fprintf(fp,"# %d vertices, %d vertices normals\n\n",m.vert.size(),NormalVertex.size());
|
||||
|
||||
|
@ -273,10 +276,10 @@ namespace io {
|
|||
else
|
||||
fprintf(fp,"\n");
|
||||
}
|
||||
if (cb !=NULL)
|
||||
(*cb)((100*++current)/max, "writing faces ");
|
||||
else
|
||||
{ fclose(fp); return E_ABORTED;}
|
||||
if (cb !=NULL) {
|
||||
if(*cb)((100*++current)/max, "writing vertices ");
|
||||
else { fclose(fp); return E_ABORTED;} }
|
||||
|
||||
}//for
|
||||
fprintf(fp,"# %d faces, %d coords texture\n\n",m.face.size(),CoordIndexTexture.size());
|
||||
|
||||
|
|
Loading…
Reference in New Issue