mini-changes at various importer exporters, to maximize compatibility
This commit is contained in:
parent
9768533095
commit
54ca153009
|
@ -28,6 +28,9 @@
|
|||
#include <QtGui/QImage>
|
||||
#include <QtCore/QVector>
|
||||
|
||||
#include <QDateTime>
|
||||
|
||||
|
||||
|
||||
template<typename POINTTYPE>
|
||||
struct CoordNumber{public: static unsigned int coord() { return 0; }};
|
||||
|
@ -762,8 +765,6 @@ namespace Tags
|
|||
}
|
||||
};
|
||||
|
||||
#include <QDateTime>
|
||||
|
||||
class CreatedTag : public XMLLeafTag//added
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -207,7 +207,7 @@ public:
|
|||
_stream.setAutoFormatting(autoformatting);
|
||||
}
|
||||
|
||||
~XMLDocumentWriter()
|
||||
virtual ~XMLDocumentWriter()
|
||||
{
|
||||
_file.close();
|
||||
}
|
||||
|
|
|
@ -165,6 +165,7 @@ namespace io {
|
|||
|
||||
//vert
|
||||
capability |= vcg::tri::io::Mask::IOM_VERTNORMAL;
|
||||
capability |= vcg::tri::io::Mask::IOM_VERTTEXCOORD;
|
||||
|
||||
//face
|
||||
capability |= vcg::tri::io::Mask::IOM_FACECOLOR;
|
||||
|
@ -181,6 +182,15 @@ namespace io {
|
|||
*/
|
||||
static int Save(SaveMeshType &m, const char * filename, int mask, CallBackPos *cb=0)
|
||||
{
|
||||
// texture coord and normal: cannot be saved BOTH per vertex and per wedge
|
||||
if (mask & vcg::tri::io::Mask::IOM_WEDGTEXCOORD &&
|
||||
mask & vcg::tri::io::Mask::IOM_VERTTEXCOORD ) {
|
||||
mask &= ~vcg::tri::io::Mask::IOM_VERTTEXCOORD;
|
||||
}
|
||||
if (mask & vcg::tri::io::Mask::IOM_WEDGCOLOR &&
|
||||
mask & vcg::tri::io::Mask::IOM_VERTCOLOR ) {
|
||||
mask &= ~vcg::tri::io::Mask::IOM_VERTCOLOR;
|
||||
}
|
||||
if(m.vn == 0) return E_NOTVEXTEXVALID;
|
||||
// Commented out this control. You should be allowed to save a point cloud.
|
||||
// if(m.fn == 0) return E_NOTFACESVALID;
|
||||
|
@ -216,7 +226,7 @@ namespace io {
|
|||
{
|
||||
VertexId[vi-m.vert.begin()]=numvert;
|
||||
//saves normal per vertex
|
||||
if((mask & Mask::IOM_VERTNORMAL) || (mask & vcg::tri::io::Mask::IOM_WEDGTEXCOORD) )
|
||||
if (mask & Mask::IOM_WEDGNORMAL )
|
||||
{
|
||||
if(AddNewNormalVertex(NormalVertex,(*vi).N(),curNormalIndex))
|
||||
{
|
||||
|
@ -224,6 +234,15 @@ namespace io {
|
|||
curNormalIndex++;
|
||||
}
|
||||
}
|
||||
if (mask & Mask::IOM_VERTNORMAL ) {
|
||||
fprintf(fp,"vn %f %f %f\n",(*vi).N()[0],(*vi).N()[1],(*vi).N()[2]);
|
||||
}
|
||||
if (mask & Mask::IOM_VERTTEXCOORD ) {
|
||||
fprintf(fp,"vt %f %f\n",(*vi).T().P()[0],(*vi).T().P()[1]);
|
||||
}
|
||||
//if (mask & Mask::IOM_VERTCOLOR ) {
|
||||
// fprintf(fp,"vc %f %f %f\n",(*vi).T().P()[0],(*vi).T().P()[1]);
|
||||
//}
|
||||
|
||||
//saves vertex
|
||||
fprintf(fp,"v %f %f %f\n",(*vi).P()[0],(*vi).P()[1],(*vi).P()[2]);
|
||||
|
@ -265,10 +284,10 @@ namespace io {
|
|||
}
|
||||
}
|
||||
|
||||
//saves texture coord
|
||||
//saves texture coord x wedge
|
||||
if(HasPerWedgeTexCoord(m) && (mask & Mask::IOM_WEDGTEXCOORD))
|
||||
for(unsigned int k=0;k<3;k++)
|
||||
{
|
||||
if(HasPerWedgeTexCoord(m) && (mask & Mask::IOM_WEDGTEXCOORD))
|
||||
{
|
||||
if(AddNewTextureCoord(CoordIndexTexture,(*fi).WT(k),curTexCoordIndex))
|
||||
{
|
||||
|
@ -278,6 +297,7 @@ namespace io {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
fprintf(fp,"f ");
|
||||
for(unsigned int k=0;k<3;k++)
|
||||
{
|
||||
|
@ -289,10 +309,14 @@ namespace io {
|
|||
int vt = -1;
|
||||
if(mask & Mask::IOM_WEDGTEXCOORD)
|
||||
vt = GetIndexVertexTexture(CoordIndexTexture,(*fi).WT(k));//index of vertex texture per face
|
||||
if (mask & Mask::IOM_VERTTEXCOORD)
|
||||
vt = vInd;
|
||||
|
||||
int vn = -1;
|
||||
if((mask & Mask::IOM_VERTNORMAL) || (mask & Mask::IOM_WEDGNORMAL) )
|
||||
if(mask & Mask::IOM_WEDGNORMAL )
|
||||
vn = GetIndexVertexNormal(m, NormalVertex, (*fi).V(k)->cN());//index of vertex normal per face.
|
||||
if (mask & Mask::IOM_VERTNORMAL)
|
||||
vn = vInd;
|
||||
|
||||
//writes elements on file obj
|
||||
WriteFacesElement(fp,vInd,vt,vn);
|
||||
|
|
|
@ -85,6 +85,8 @@ public:
|
|||
int numFaces;
|
||||
/// number of texture coords indexes
|
||||
int numTexCoords;
|
||||
/// number of normals
|
||||
int numNormals;
|
||||
|
||||
}; // end class
|
||||
|
||||
|
@ -643,11 +645,17 @@ public:
|
|||
m.face[i].WT(j).v() = t.v;
|
||||
m.face[i].WT(j).n() = indexedFaces[i].tInd;
|
||||
}
|
||||
|
||||
if (((oi.mask & vcg::tri::io::Mask::IOM_WEDGNORMAL) != 0) && (m.HasPerWedgeNormal()))
|
||||
{
|
||||
m.face[i].WN(j).Import(normals[indexedFaces[i].n[j]]);
|
||||
if ( oi.mask & vcg::tri::io::Mask::IOM_VERTTEXCOORD ) {
|
||||
ObjTexCoord t = texCoords[indexedFaces[i].t[j]];
|
||||
m.face[i].V(j)->T().u() = t.u;
|
||||
m.face[i].V(j)->T().v() = t.v;
|
||||
m.face[i].V(j)->T().n() = indexedFaces[i].tInd;
|
||||
}
|
||||
if ( oi.mask & vcg::tri::io::Mask::IOM_WEDGNORMAL )
|
||||
m.face[i].WN(j).Import(normals[indexedFaces[i].n[j]]);
|
||||
|
||||
if ( oi.mask & vcg::tri::io::Mask::IOM_VERTNORMAL )
|
||||
m.face[i].V(j)->N().Import(normals[indexedFaces[i].n[j]]);
|
||||
|
||||
// set faux edge flags according to internals faces
|
||||
if (indexedFaces[i].edge[j])
|
||||
|
@ -862,6 +870,7 @@ public:
|
|||
oi.numVertices=0;
|
||||
oi.numFaces=0;
|
||||
oi.numTexCoords=0;
|
||||
oi.numNormals=0;
|
||||
int lineCount=0;
|
||||
int totRead=0;
|
||||
std::string line;
|
||||
|
@ -878,23 +887,35 @@ public:
|
|||
{
|
||||
if(line[1]==' ') oi.numVertices++;
|
||||
if(line[1]=='t') oi.numTexCoords++;
|
||||
if(line[1]=='n') bHasNormals = true;
|
||||
if(line[1]=='n') {
|
||||
oi.numNormals ++;
|
||||
bHasNormals = true;
|
||||
}
|
||||
else
|
||||
}
|
||||
else {
|
||||
if((line[0]=='f') || (line[0]=='q')) oi.numFaces++;
|
||||
else
|
||||
if(line[0]=='u' && line[1]=='s') bHasPerFaceColor = true; // there is a usematerial so add per face color
|
||||
}
|
||||
}
|
||||
}
|
||||
oi.mask = 0;
|
||||
if (oi.numTexCoords)
|
||||
{
|
||||
if (oi.numTexCoords==oi.numVertices)
|
||||
oi.mask |= vcg::tri::io::Mask::IOM_VERTTEXCOORD;
|
||||
|
||||
oi.mask |= vcg::tri::io::Mask::IOM_WEDGTEXCOORD;
|
||||
// Usually if you have tex coords you also have materials
|
||||
oi.mask |= vcg::tri::io::Mask::IOM_FACECOLOR;
|
||||
}
|
||||
if(bHasPerFaceColor) oi.mask |= vcg::tri::io::Mask::IOM_FACECOLOR;
|
||||
if (bHasNormals) oi.mask |= vcg::tri::io::Mask::IOM_WEDGNORMAL;
|
||||
if (bHasNormals) {
|
||||
if (oi.numTexCoords==oi.numVertices)
|
||||
oi.mask |= vcg::tri::io::Mask::IOM_VERTNORMAL;
|
||||
else
|
||||
oi.mask |= vcg::tri::io::Mask::IOM_WEDGNORMAL;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -762,7 +762,7 @@ static int Open( OpenMeshType &m, const char * filename, PlyInfo &pi )
|
|||
if( pi.mask & Mask::IOM_VERTTEXCOORD )
|
||||
{
|
||||
(*vi).T().P().X() = va.u;
|
||||
(*vi).T().P().Y() = va.v;
|
||||
(*vi).T().P().Y() = 1.0-va.v; // because "v" attr comes from "t"
|
||||
}
|
||||
|
||||
if( pi.mask & Mask::IOM_VERTCOLOR )
|
||||
|
|
Loading…
Reference in New Issue