1) removed problems with gcc
2) removed stupid bug setContent 3) removed the diamond inherits in AddiotionalInfoDAE 4) removed some compiler warnings
This commit is contained in:
parent
deb5402d35
commit
609ee7db96
|
@ -32,9 +32,9 @@ private:
|
||||||
// n.appendChild(el);
|
// n.appendChild(el);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
static void SaveTextureName(QDomDocument& doc,QDomNode& lbim,const std::vector<std::string>& stv)
|
static void SaveTextureName(QDomDocument doc,QDomNode lbim,const std::vector<std::string>& stv)
|
||||||
{
|
{
|
||||||
for(int img = 0;img < stv.size();++img)
|
for(unsigned int img = 0;img < stv.size();++img)
|
||||||
{
|
{
|
||||||
QDomElement imgnode = doc.createElement("image");
|
QDomElement imgnode = doc.createElement("image");
|
||||||
imgnode.setAttribute("id","file"+QString::number(img));
|
imgnode.setAttribute("id","file"+QString::number(img));
|
||||||
|
@ -47,23 +47,23 @@ private:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SaveTexture(QDomDocument& doc,QDomNode& n,const std::vector<std::string>& stv)
|
static void SaveTexture(QDomDocument doc,QDomNode n,const std::vector<std::string>& stv)
|
||||||
{
|
{
|
||||||
QDomElement el = doc.createElement("library_images");
|
QDomElement el = doc.createElement("library_images");
|
||||||
SaveTextureName(doc,el,stv);
|
SaveTextureName(doc,el,stv);
|
||||||
n.appendChild(el);
|
n.appendChild(el);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SaveTexture(QDomDocument& doc,const std::vector<std::string>& stv)
|
static void SaveTexture(QDomDocument doc,const std::vector<std::string>& stv)
|
||||||
{
|
{
|
||||||
QDomNodeList lbim = doc.elementsByTagName("library_images");
|
QDomNodeList lbim = doc.elementsByTagName("library_images");
|
||||||
assert(lbim.size() == 1);
|
if (lbim.size() == 1)
|
||||||
removeChildNode(lbim.at(0));
|
removeChildNode(lbim.at(0));
|
||||||
|
|
||||||
SaveTextureName(doc,lbim.at(0),stv);
|
SaveTextureName(doc,lbim.at(0),stv);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CreateVertInput(QDomDocument& doc,QDomNode& vert,const QString& attr,const QString& ref)
|
static void CreateVertInput(QDomDocument doc,QDomNode vert,const QString& attr,const QString& ref)
|
||||||
{
|
{
|
||||||
QDomElement vinp_pos = doc.createElement("input");
|
QDomElement vinp_pos = doc.createElement("input");
|
||||||
vinp_pos.setAttribute("semantic",attr);
|
vinp_pos.setAttribute("semantic",attr);
|
||||||
|
@ -71,7 +71,7 @@ private:
|
||||||
vert.appendChild(vinp_pos);
|
vert.appendChild(vinp_pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CreateFaceInput(QDomDocument& doc,QDomNode& tri,const QString& attr,const QString& ref,const int offset)
|
static void CreateFaceInput(QDomDocument doc,QDomNode tri,const QString& attr,const QString& ref,const int offset)
|
||||||
{
|
{
|
||||||
QDomElement tinp_vert = doc.createElement("input");
|
QDomElement tinp_vert = doc.createElement("input");
|
||||||
tinp_vert.setAttribute("offset",QString::number(offset));
|
tinp_vert.setAttribute("offset",QString::number(offset));
|
||||||
|
@ -80,7 +80,7 @@ private:
|
||||||
tri.appendChild(tinp_vert);
|
tri.appendChild(tinp_vert);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CreateSource(QDomDocument& doc,QDomNode& meshnode,const QString& attr,const QDomText& val,int nvert)
|
static void CreateSource(QDomDocument doc,QDomNode meshnode,const QString& attr,const QDomText& val,int nvert)
|
||||||
{
|
{
|
||||||
int nel;
|
int nel;
|
||||||
std::vector<QString> coord;
|
std::vector<QString> coord;
|
||||||
|
@ -137,7 +137,7 @@ private:
|
||||||
meshnode.appendChild(srcnmnode);
|
meshnode.appendChild(srcnmnode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int SaveMesh(SaveMeshType& m,QDomDocument& doc,QDomNode& meshnode,const int mask)
|
static int SaveMesh(SaveMeshType& m,QDomDocument& doc,QDomNode meshnode,const int mask)
|
||||||
{
|
{
|
||||||
QString arrp;
|
QString arrp;
|
||||||
arrp.reserve(10 * 3 * m.vert.size());
|
arrp.reserve(10 * 3 * m.vert.size());
|
||||||
|
@ -333,7 +333,7 @@ public:
|
||||||
QFile file(filename);
|
QFile file(filename);
|
||||||
if (!file.open(QIODevice::ReadWrite | QIODevice::Truncate))
|
if (!file.open(QIODevice::ReadWrite | QIODevice::Truncate))
|
||||||
return E_CANTOPEN;
|
return E_CANTOPEN;
|
||||||
doc.setContent(&file);
|
|
||||||
file.write(st.toAscii());
|
file.write(st.toAscii());
|
||||||
file.close();
|
file.close();
|
||||||
return E_NOERROR;
|
return E_NOERROR;
|
||||||
|
@ -351,7 +351,7 @@ public:
|
||||||
InfoDAE* info = inf->dae;
|
InfoDAE* info = inf->dae;
|
||||||
QDomNodeList scenelst = info->doc->elementsByTagName("scene");
|
QDomNodeList scenelst = info->doc->elementsByTagName("scene");
|
||||||
//removeChildNode(scenelst,"instance_visual_scene");
|
//removeChildNode(scenelst,"instance_visual_scene");
|
||||||
assert(scenelst.size() == 1);
|
//assert(scenelst.size() == 1);
|
||||||
|
|
||||||
if (m.textures.size() != 0)
|
if (m.textures.size() != 0)
|
||||||
SaveTexture(*(info->doc),m.textures);
|
SaveTexture(*(info->doc),m.textures);
|
||||||
|
@ -359,6 +359,7 @@ public:
|
||||||
|
|
||||||
|
|
||||||
QDomNodeList geolib = info->doc->elementsByTagName("library_geometries");
|
QDomNodeList geolib = info->doc->elementsByTagName("library_geometries");
|
||||||
|
|
||||||
assert(geolib.size() == 1);
|
assert(geolib.size() == 1);
|
||||||
|
|
||||||
if (info->doc->elementsByTagName("instance_geometry").size() != 0)
|
if (info->doc->elementsByTagName("instance_geometry").size() != 0)
|
||||||
|
@ -408,7 +409,8 @@ public:
|
||||||
/*QDomElement mshnode;
|
/*QDomElement mshnode;
|
||||||
mshnode.setTagName("mesh");*/
|
mshnode.setTagName("mesh");*/
|
||||||
|
|
||||||
removeChildNode(geolib.at(0),QString("geometry"),QString("id"),QString("vcg-mesh-lib"));
|
geolib.at(0).childNodes().size();
|
||||||
|
removeChildNode(geolib.at(0),QString("geometry"),QString("id"),QString("vcg-mesh-lib"));
|
||||||
QDomElement geonode = info->doc->createElement("geometry");
|
QDomElement geonode = info->doc->createElement("geometry");
|
||||||
geonode.setAttribute("id","vcg-mesh-lib");
|
geonode.setAttribute("id","vcg-mesh-lib");
|
||||||
geonode.setAttribute("name","vcg-mesh");
|
geonode.setAttribute("name","vcg-mesh");
|
||||||
|
@ -417,12 +419,13 @@ public:
|
||||||
|
|
||||||
|
|
||||||
int res = SaveMesh(m,*(info->doc),meshnode,mask);
|
int res = SaveMesh(m,*(info->doc),meshnode,mask);
|
||||||
|
if (res != 0) return res;
|
||||||
geonode.appendChild(meshnode);
|
geonode.appendChild(meshnode);
|
||||||
geolib.at(0).appendChild(geonode);
|
geolib.at(0).appendChild(geonode);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
removeChildNodeList(scenelst,QString("instance_visual_scene"));
|
/* removeChildNodeList(scenelst,QString("instance_visual_scene")); */
|
||||||
for(int vsscn = 0;vsscn < scenelst.size();++vsscn)
|
for(int vsscn = 0;vsscn < scenelst.size();++vsscn)
|
||||||
{
|
{
|
||||||
QString url = scenelst.at(vsscn).toElement().attribute("url");
|
QString url = scenelst.at(vsscn).toElement().attribute("url");
|
||||||
|
@ -432,9 +435,9 @@ public:
|
||||||
vsnode.setAttribute("url","#vcg-scene-node");
|
vsnode.setAttribute("url","#vcg-scene-node");
|
||||||
scenelst.at(0).appendChild(vsnode);
|
scenelst.at(0).appendChild(vsnode);
|
||||||
|
|
||||||
int vsscene_size = vsscene.size();
|
|
||||||
assert(vsscene.size() == 1);
|
assert(vsscene.size() == 1);
|
||||||
removeChildNodeList(vsscene,QString("visual_scene"),QString("id"),QString("vcg-scene-node"));
|
removeChildNodeList(vsscene,QString("visual_scene"),QString("id"),QString("vcg-scene-node"));
|
||||||
QDomElement vslnode = info->doc->createElement("visual_scene");
|
QDomElement vslnode = info->doc->createElement("visual_scene");
|
||||||
vslnode.setAttribute("id","vcg-scene-node");
|
vslnode.setAttribute("id","vcg-scene-node");
|
||||||
vslnode.setAttribute("name","vcg-untitled");
|
vslnode.setAttribute("name","vcg-untitled");
|
||||||
|
@ -453,7 +456,7 @@ public:
|
||||||
QDomNodeList geolib = info->doc->elementsByTagName("library_geometries");
|
QDomNodeList geolib = info->doc->elementsByTagName("library_geometries");
|
||||||
assert(geolib.size() == 1);
|
assert(geolib.size() == 1);
|
||||||
|
|
||||||
removeChildNode(geolib.at(0),QString("geometry"),QString("id"),QString("vcg-mesh-lib"));
|
removeChildNode(geolib.at(0),QString("geometry"),QString("id"),QString("vcg-mesh-lib"));
|
||||||
QDomElement geonode = info->doc->createElement("geometry");
|
QDomElement geonode = info->doc->createElement("geometry");
|
||||||
geonode.setAttribute("id","vcg-mesh-lib");
|
geonode.setAttribute("id","vcg-mesh-lib");
|
||||||
geonode.setAttribute("name","vcg-mesh");
|
geonode.setAttribute("name","vcg-mesh");
|
||||||
|
@ -464,13 +467,16 @@ public:
|
||||||
geonode.appendChild(meshnode);
|
geonode.appendChild(meshnode);
|
||||||
geolib.at(0).appendChild(geonode);
|
geolib.at(0).appendChild(geonode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString st = info->doc->toString();
|
QString st = info->doc->toString();
|
||||||
QFile file(filename);
|
QFile file(filename);
|
||||||
if (!file.open(QIODevice::ReadWrite | QIODevice::Truncate))
|
if (!file.open(QIODevice::ReadWrite | QIODevice::Truncate))
|
||||||
return E_CANTOPEN;
|
return E_CANTOPEN;
|
||||||
info->doc->setContent(&file);
|
|
||||||
file.write(st.toAscii());
|
file.write(st.toAscii());
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
return E_NOERROR;
|
return E_NOERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace io {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
static int LoadMesh(OpenMeshType& m,InfoDAE* info,const QDomNode& geo,const vcg::Matrix44f& t, CallBackPos *cb=0)
|
static int LoadMesh(OpenMeshType& m,AdditionalInfoDAE* info,const QDomNode& geo,const vcg::Matrix44f& t, CallBackPos *cb=0)
|
||||||
{
|
{
|
||||||
if (isThereTag(geo,"mesh"))
|
if (isThereTag(geo,"mesh"))
|
||||||
{
|
{
|
||||||
|
@ -31,7 +31,7 @@ namespace io {
|
||||||
if (vertices_size != 1)
|
if (vertices_size != 1)
|
||||||
return E_INCOMPATIBLECOLLADA141FORMAT;
|
return E_INCOMPATIBLECOLLADA141FORMAT;
|
||||||
|
|
||||||
QDomNode srcnode = attributeSourcePerSimplex(vertices.at(0),*(info->doc),"POSITION");
|
QDomNode srcnode = attributeSourcePerSimplex(vertices.at(0),*(info->dae->doc),"POSITION");
|
||||||
if (srcnode.isNull())
|
if (srcnode.isNull())
|
||||||
return E_NOVERTEXPOSITION;
|
return E_NOVERTEXPOSITION;
|
||||||
|
|
||||||
|
@ -43,202 +43,205 @@ namespace io {
|
||||||
return E_CANTOPEN;
|
return E_CANTOPEN;
|
||||||
int nvert = geosrcposarr_size / 3;
|
int nvert = geosrcposarr_size / 3;
|
||||||
size_t offset = m.vert.size();
|
size_t offset = m.vert.size();
|
||||||
vcg::tri::Allocator<OpenMeshType>::AddVertices(m,nvert);
|
if (geosrcposarr_size != 0)
|
||||||
|
|
||||||
QDomNode srcnodenorm = attributeSourcePerSimplex(vertices.at(0),*(info->doc),"NORMAL");
|
|
||||||
QStringList geosrcvertnorm;
|
|
||||||
if (!srcnodenorm.isNull())
|
|
||||||
valueStringList(geosrcvertnorm,srcnodenorm,"float_array");
|
|
||||||
|
|
||||||
QDomNode srcnodetext = attributeSourcePerSimplex(vertices.at(0),*(info->doc),"TEXCOORD");
|
|
||||||
QStringList geosrcverttext;
|
|
||||||
if (!srcnodetext.isNull())
|
|
||||||
valueStringList(geosrcverttext,srcnodetext,"float_array");
|
|
||||||
|
|
||||||
QDomNode srcnodecolor = attributeSourcePerSimplex(vertices.at(0),*(info->doc),"COLOR");
|
|
||||||
QStringList geosrcvertcol;
|
|
||||||
if (!srcnodecolor.isNull())
|
|
||||||
valueStringList(geosrcvertcol,srcnodecolor,"float_array");
|
|
||||||
|
|
||||||
int ii = 0;
|
|
||||||
for(size_t vv = offset;vv < m.vert.size();++vv)
|
|
||||||
{
|
{
|
||||||
|
vcg::tri::Allocator<OpenMeshType>::AddVertices(m,nvert);
|
||||||
assert((ii * 3 < geosrcposarr_size) && (ii * 3 + 1 < geosrcposarr_size) && (ii * 3 + 2 < geosrcposarr_size));
|
|
||||||
vcg::Point4f tmp = t * vcg::Point4f(geosrcposarr[ii * 3].toFloat(),geosrcposarr[ii * 3 + 1].toFloat(),geosrcposarr[ii * 3 + 2].toFloat(),1.0f);
|
|
||||||
m.vert[vv].P() = vcg::Point3f(tmp.X(),tmp.Y(),tmp.Z());
|
|
||||||
|
|
||||||
|
QDomNode srcnodenorm = attributeSourcePerSimplex(vertices.at(0),*(info->dae->doc),"NORMAL");
|
||||||
|
QStringList geosrcvertnorm;
|
||||||
if (!srcnodenorm.isNull())
|
if (!srcnodenorm.isNull())
|
||||||
{
|
valueStringList(geosrcvertnorm,srcnodenorm,"float_array");
|
||||||
assert((ii * 3 < geosrcvertnorm.size()) && (ii * 3 + 1 < geosrcvertnorm.size()) && (ii * 3 + 2 < geosrcvertnorm.size()));
|
|
||||||
vcg::Matrix44f intr44 = vcg::Inverse(t);
|
|
||||||
vcg::Transpose(intr44);
|
|
||||||
Matrix33f intr33;
|
|
||||||
for(unsigned int rr = 0; rr < 2; ++rr)
|
|
||||||
{
|
|
||||||
for(unsigned int cc = 0;cc < 2;++cc)
|
|
||||||
intr33[rr][cc] = intr44[rr][cc];
|
|
||||||
}
|
|
||||||
m.vert[vv].N() = (intr33 * vcg::Point3f(geosrcvertnorm[ii * 3].toFloat(),geosrcvertnorm[ii * 3 + 1].toFloat(),geosrcvertnorm[ii * 3 + 2].toFloat())).Normalize();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*if (!srcnodecolor.isNull())
|
|
||||||
{
|
|
||||||
assert((ii * 4 < geosrcvertcol.size()) && (ii * 4 + 1 < geosrcvertcol.size()) && (ii * 4 + 2 < geosrcvertcol.size()) && (ii * 4 + 1 < geosrcvertcol.size()));
|
|
||||||
m.vert[vv].C() = vcg::Color4b(geosrcvertcol[ii * 4].toFloat(),geosrcvertcol[ii * 4 + 1].toFloat(),geosrcvertcol[ii * 4 + 2].toFloat(),geosrcvertcol[ii * 4 + 3].toFloat());
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
QDomNode srcnodetext = attributeSourcePerSimplex(vertices.at(0),*(info->dae->doc),"TEXCOORD");
|
||||||
|
QStringList geosrcverttext;
|
||||||
if (!srcnodetext.isNull())
|
if (!srcnodetext.isNull())
|
||||||
|
valueStringList(geosrcverttext,srcnodetext,"float_array");
|
||||||
|
|
||||||
|
QDomNode srcnodecolor = attributeSourcePerSimplex(vertices.at(0),*(info->dae->doc),"COLOR");
|
||||||
|
QStringList geosrcvertcol;
|
||||||
|
if (!srcnodecolor.isNull())
|
||||||
|
valueStringList(geosrcvertcol,srcnodecolor,"float_array");
|
||||||
|
|
||||||
|
int ii = 0;
|
||||||
|
for(size_t vv = offset;vv < m.vert.size();++vv)
|
||||||
{
|
{
|
||||||
assert((ii * 2 < geosrcverttext.size()) && (ii * 2 + 1 < geosrcverttext.size()));
|
|
||||||
m.vert[vv].T() = vcg::TCoord2<float>();
|
assert((ii * 3 < geosrcposarr_size) && (ii * 3 + 1 < geosrcposarr_size) && (ii * 3 + 2 < geosrcposarr_size));
|
||||||
m.vert[vv].T().u() = geosrcverttext[ii * 2].toFloat();
|
vcg::Point4f tmp = t * vcg::Point4f(geosrcposarr[ii * 3].toFloat(),geosrcposarr[ii * 3 + 1].toFloat(),geosrcposarr[ii * 3 + 2].toFloat(),1.0f);
|
||||||
m.vert[vv].T().v() = geosrcverttext[ii * 2 + 1].toFloat();
|
m.vert[vv].P() = vcg::Point3f(tmp.X(),tmp.Y(),tmp.Z());
|
||||||
}
|
|
||||||
++ii;
|
|
||||||
}
|
|
||||||
|
|
||||||
QDomNodeList tripatch = geo.toElement().elementsByTagName("triangles");
|
if (!srcnodenorm.isNull())
|
||||||
int tripatch_size = tripatch.size();
|
{
|
||||||
if (tripatch_size == 0)
|
assert((ii * 3 < geosrcvertnorm.size()) && (ii * 3 + 1 < geosrcvertnorm.size()) && (ii * 3 + 2 < geosrcvertnorm.size()));
|
||||||
return E_NOTRIANGLES;
|
vcg::Matrix44f intr44 = vcg::Inverse(t);
|
||||||
|
vcg::Transpose(intr44);
|
||||||
|
Matrix33f intr33;
|
||||||
|
for(unsigned int rr = 0; rr < 2; ++rr)
|
||||||
|
{
|
||||||
|
for(unsigned int cc = 0;cc < 2;++cc)
|
||||||
|
intr33[rr][cc] = intr44[rr][cc];
|
||||||
|
}
|
||||||
|
m.vert[vv].N() = (intr33 * vcg::Point3f(geosrcvertnorm[ii * 3].toFloat(),geosrcvertnorm[ii * 3 + 1].toFloat(),geosrcvertnorm[ii * 3 + 2].toFloat())).Normalize();
|
||||||
|
}
|
||||||
|
|
||||||
for(int tript = 0; tript < tripatch_size;++tript)
|
/*if (!srcnodecolor.isNull())
|
||||||
{
|
{
|
||||||
|
assert((ii * 4 < geosrcvertcol.size()) && (ii * 4 + 1 < geosrcvertcol.size()) && (ii * 4 + 2 < geosrcvertcol.size()) && (ii * 4 + 1 < geosrcvertcol.size()));
|
||||||
|
m.vert[vv].C() = vcg::Color4b(geosrcvertcol[ii * 4].toFloat(),geosrcvertcol[ii * 4 + 1].toFloat(),geosrcvertcol[ii * 4 + 2].toFloat(),geosrcvertcol[ii * 4 + 3].toFloat());
|
||||||
|
}*/
|
||||||
|
|
||||||
int nfcatt = tripatch.at(tript).toElement().elementsByTagName("input").size();
|
if (!srcnodetext.isNull())
|
||||||
|
{
|
||||||
QStringList face;
|
assert((ii * 2 < geosrcverttext.size()) && (ii * 2 + 1 < geosrcverttext.size()));
|
||||||
valueStringList(face,tripatch.at(tript),"p");
|
m.vert[vv].T() = vcg::TCoord2<float>();
|
||||||
int face_size = face.size();
|
m.vert[vv].T().u() = geosrcverttext[ii * 2].toFloat();
|
||||||
int offsetface = (int)m.face.size();
|
m.vert[vv].T().v() = geosrcverttext[ii * 2 + 1].toFloat();
|
||||||
if (face_size == 0) return E_NOMESH;
|
}
|
||||||
vcg::tri::Allocator<OpenMeshType>::AddFaces(m,face_size / (nfcatt * 3));
|
++ii;
|
||||||
QDomNode wnsrc = QDomNode();
|
|
||||||
QStringList wn;
|
|
||||||
wnsrc = findNodeBySpecificAttributeValue(tripatch.at(tript),"input","semantic","NORMAL");
|
|
||||||
int offnm;
|
|
||||||
if (!wnsrc.isNull())
|
|
||||||
{
|
|
||||||
offnm = wnsrc.toElement().attribute("offset").toInt();
|
|
||||||
QDomNode sn = attributeSourcePerSimplex(tripatch.at(tript),*(info->doc),"NORMAL");
|
|
||||||
valueStringList(wn,sn,"float_array");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QDomNode wtsrc = QDomNode();
|
QDomNodeList tripatch = geo.toElement().elementsByTagName("triangles");
|
||||||
QStringList wt;
|
int tripatch_size = tripatch.size();
|
||||||
wtsrc = findNodeBySpecificAttributeValue(tripatch.at(tript),"input","semantic","TEXCOORD");
|
if (tripatch_size == 0)
|
||||||
int offtx;
|
return E_NOTRIANGLES;
|
||||||
if (!wtsrc.isNull())
|
|
||||||
|
for(int tript = 0; tript < tripatch_size;++tript)
|
||||||
{
|
{
|
||||||
offtx = wtsrc.toElement().attribute("offset").toInt();
|
|
||||||
QDomNode st = attributeSourcePerSimplex(tripatch.at(tript),*(info->doc),"TEXCOORD");
|
|
||||||
valueStringList(wt,st,"float_array");
|
|
||||||
}
|
|
||||||
|
|
||||||
QDomNode wcsrc = QDomNode();
|
int nfcatt = tripatch.at(tript).toElement().elementsByTagName("input").size();
|
||||||
QStringList wc;
|
|
||||||
wcsrc = findNodeBySpecificAttributeValue(tripatch.at(tript),"input","semantic","COLOR");
|
|
||||||
int offcl;
|
|
||||||
if (!wcsrc.isNull())
|
|
||||||
{
|
|
||||||
offcl = wcsrc.toElement().attribute("offset").toInt();
|
|
||||||
QDomNode sc = attributeSourcePerSimplex(tripatch.at(tript),*(info->doc),"COLOR");
|
|
||||||
valueStringList(wc,sc,"float_array");
|
|
||||||
}
|
|
||||||
|
|
||||||
int jj = 0;
|
QStringList face;
|
||||||
//int dd = m.face.size();
|
valueStringList(face,tripatch.at(tript),"p");
|
||||||
for(int ff = offsetface;ff < (int) m.face.size();++ff)
|
int face_size = face.size();
|
||||||
{
|
int offsetface = (int)m.face.size();
|
||||||
int indvt = face.at(jj).toInt();
|
if (face_size == 0) return E_NOMESH;
|
||||||
assert(indvt + offset < m.vert.size());
|
vcg::tri::Allocator<OpenMeshType>::AddFaces(m,face_size / (nfcatt * 3));
|
||||||
m.face[ff].V(0) = &(m.vert[indvt + offset]);
|
QDomNode wnsrc = QDomNode();
|
||||||
|
QStringList wn;
|
||||||
int indnm;
|
wnsrc = findNodeBySpecificAttributeValue(tripatch.at(tript),"input","semantic","NORMAL");
|
||||||
|
int offnm;
|
||||||
if (!wnsrc.isNull())
|
if (!wnsrc.isNull())
|
||||||
{
|
{
|
||||||
indnm = face.at(jj + offnm).toInt();
|
offnm = wnsrc.toElement().attribute("offset").toInt();
|
||||||
assert(indnm * 3 < wn.size());
|
QDomNode sn = attributeSourcePerSimplex(tripatch.at(tript),*(info->dae->doc),"NORMAL");
|
||||||
m.face[ff].WN(0) = vcg::Point3f(wn.at(indnm * 3).toFloat(),wn.at(indnm * 3 + 1).toFloat(),wn.at(indnm * 3 + 2).toFloat());
|
valueStringList(wn,sn,"float_array");
|
||||||
}
|
}
|
||||||
|
|
||||||
int indtx;
|
QDomNode wtsrc = QDomNode();
|
||||||
|
QStringList wt;
|
||||||
|
wtsrc = findNodeBySpecificAttributeValue(tripatch.at(tript),"input","semantic","TEXCOORD");
|
||||||
|
int offtx;
|
||||||
if (!wtsrc.isNull())
|
if (!wtsrc.isNull())
|
||||||
{
|
{
|
||||||
indtx = face.at(jj + offtx).toInt();
|
offtx = wtsrc.toElement().attribute("offset").toInt();
|
||||||
assert(indtx * 2 < wt.size());
|
QDomNode st = attributeSourcePerSimplex(tripatch.at(tript),*(info->dae->doc),"TEXCOORD");
|
||||||
m.face[ff].WT(0) = vcg::TCoord2<float>();
|
valueStringList(wt,st,"float_array");
|
||||||
m.face[ff].WT(0).u() = wt.at(indtx * 2).toFloat();
|
|
||||||
m.face[ff].WT(0).v() = wt.at(indtx * 2 + 1).toFloat();
|
|
||||||
m.face[ff].WT(0).n() = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*int indcl;
|
QDomNode wcsrc = QDomNode();
|
||||||
|
QStringList wc;
|
||||||
|
wcsrc = findNodeBySpecificAttributeValue(tripatch.at(tript),"input","semantic","COLOR");
|
||||||
|
int offcl;
|
||||||
if (!wcsrc.isNull())
|
if (!wcsrc.isNull())
|
||||||
{
|
{
|
||||||
indcl = face.at(jj + offcl).toInt();
|
offcl = wcsrc.toElement().attribute("offset").toInt();
|
||||||
assert(indcl * 4 < wc.size());
|
QDomNode sc = attributeSourcePerSimplex(tripatch.at(tript),*(info->dae->doc),"COLOR");
|
||||||
m.face[ff].WC(0) = vcg::Color4b(wc.at(indcl * 4).toFloat(),wc.at(indcl * 4 + 1).toFloat(),wc.at(indcl * 4 + 2).toFloat(),wc.at(indcl * 4 + 3).toFloat());
|
valueStringList(wc,sc,"float_array");
|
||||||
}*/
|
|
||||||
jj += nfcatt;
|
|
||||||
|
|
||||||
indvt = face.at(jj).toInt();
|
|
||||||
assert(indvt + offset < m.vert.size());
|
|
||||||
m.face[ff].V(1) = &(m.vert[indvt + offset]);
|
|
||||||
if (!wnsrc.isNull())
|
|
||||||
{
|
|
||||||
indnm = face.at(jj + offnm).toInt();
|
|
||||||
assert(indnm * 3 < wn.size());
|
|
||||||
m.face[ff].WN(1) = vcg::Point3f(wn.at(indnm * 3).toFloat(),wn.at(indnm * 3 + 1).toFloat(),wn.at(indnm * 3 + 2).toFloat());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!wtsrc.isNull())
|
int jj = 0;
|
||||||
{
|
//int dd = m.face.size();
|
||||||
indtx = face.at(jj + offtx).toInt();
|
for(int ff = offsetface;ff < (int) m.face.size();++ff)
|
||||||
assert(indtx * 2 < wt.size());
|
{
|
||||||
m.face[ff].WT(1) = vcg::TCoord2<float>();
|
int indvt = face.at(jj).toInt();
|
||||||
m.face[ff].WT(1).u() = wt.at(indtx * 2).toFloat();
|
assert(indvt + offset < m.vert.size());
|
||||||
m.face[ff].WT(1).v() = wt.at(indtx * 2 + 1).toFloat();
|
m.face[ff].V(0) = &(m.vert[indvt + offset]);
|
||||||
m.face[ff].WT(1).n() = 1;
|
|
||||||
|
int indnm;
|
||||||
|
if (!wnsrc.isNull())
|
||||||
|
{
|
||||||
|
indnm = face.at(jj + offnm).toInt();
|
||||||
|
assert(indnm * 3 < wn.size());
|
||||||
|
m.face[ff].WN(0) = vcg::Point3f(wn.at(indnm * 3).toFloat(),wn.at(indnm * 3 + 1).toFloat(),wn.at(indnm * 3 + 2).toFloat());
|
||||||
|
}
|
||||||
|
|
||||||
|
int indtx;
|
||||||
|
if (!wtsrc.isNull())
|
||||||
|
{
|
||||||
|
indtx = face.at(jj + offtx).toInt();
|
||||||
|
assert(indtx * 2 < wt.size());
|
||||||
|
m.face[ff].WT(0) = vcg::TCoord2<float>();
|
||||||
|
m.face[ff].WT(0).u() = wt.at(indtx * 2).toFloat();
|
||||||
|
m.face[ff].WT(0).v() = wt.at(indtx * 2 + 1).toFloat();
|
||||||
|
m.face[ff].WT(0).n() = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*int indcl;
|
||||||
|
if (!wcsrc.isNull())
|
||||||
|
{
|
||||||
|
indcl = face.at(jj + offcl).toInt();
|
||||||
|
assert(indcl * 4 < wc.size());
|
||||||
|
m.face[ff].WC(0) = vcg::Color4b(wc.at(indcl * 4).toFloat(),wc.at(indcl * 4 + 1).toFloat(),wc.at(indcl * 4 + 2).toFloat(),wc.at(indcl * 4 + 3).toFloat());
|
||||||
|
}*/
|
||||||
|
jj += nfcatt;
|
||||||
|
|
||||||
|
indvt = face.at(jj).toInt();
|
||||||
|
assert(indvt + offset < m.vert.size());
|
||||||
|
m.face[ff].V(1) = &(m.vert[indvt + offset]);
|
||||||
|
if (!wnsrc.isNull())
|
||||||
|
{
|
||||||
|
indnm = face.at(jj + offnm).toInt();
|
||||||
|
assert(indnm * 3 < wn.size());
|
||||||
|
m.face[ff].WN(1) = vcg::Point3f(wn.at(indnm * 3).toFloat(),wn.at(indnm * 3 + 1).toFloat(),wn.at(indnm * 3 + 2).toFloat());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!wtsrc.isNull())
|
||||||
|
{
|
||||||
|
indtx = face.at(jj + offtx).toInt();
|
||||||
|
assert(indtx * 2 < wt.size());
|
||||||
|
m.face[ff].WT(1) = vcg::TCoord2<float>();
|
||||||
|
m.face[ff].WT(1).u() = wt.at(indtx * 2).toFloat();
|
||||||
|
m.face[ff].WT(1).v() = wt.at(indtx * 2 + 1).toFloat();
|
||||||
|
m.face[ff].WT(1).n() = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*if (!wcsrc.isNull())
|
||||||
|
{
|
||||||
|
indcl = face.at(jj + offcl).toInt();
|
||||||
|
assert(indcl * 4 < wc.size());
|
||||||
|
m.face[ff].WC(1) = vcg::Color4b(wc.at(indcl * 4).toFloat(),wc.at(indcl * 4 + 1).toFloat(),wc.at(indcl * 4 + 2).toFloat(),wc.at(indcl * 4 + 3).toFloat());
|
||||||
|
}*/
|
||||||
|
jj += nfcatt;
|
||||||
|
|
||||||
|
indvt = face.at(jj).toInt();
|
||||||
|
assert(indvt + offset < m.vert.size());
|
||||||
|
m.face[ff].V(2) = &(m.vert[indvt + offset]);
|
||||||
|
if (!wnsrc.isNull())
|
||||||
|
{
|
||||||
|
indnm = face.at(jj + offnm).toInt();
|
||||||
|
assert(indnm * 3 < wn.size());
|
||||||
|
m.face[ff].WN(2) = vcg::Point3f(wn.at(indnm * 3).toFloat(),wn.at(indnm * 3 + 1).toFloat(),wn.at(indnm * 3 + 2).toFloat());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!wtsrc.isNull())
|
||||||
|
{
|
||||||
|
indtx = face.at(jj + offtx).toInt();
|
||||||
|
assert(indtx * 2 < wt.size());
|
||||||
|
m.face[ff].WT(2) = vcg::TCoord2<float>();
|
||||||
|
m.face[ff].WT(2).u() = wt.at(indtx * 2).toFloat();
|
||||||
|
m.face[ff].WT(2).v() = wt.at(indtx * 2 + 1).toFloat();
|
||||||
|
m.face[ff].WT(2).n() = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*if (!wcsrc.isNull())
|
||||||
|
{
|
||||||
|
indcl = face.at(jj + offcl).toInt();
|
||||||
|
assert(indcl * 4 < wc.size());
|
||||||
|
m.face[ff].WC(2) = vcg::Color4b(wc.at(indcl * 4).toFloat(),wc.at(indcl * 4 + 1).toFloat(),wc.at(indcl * 4 + 2).toFloat(),wc.at(indcl * 4 + 3).toFloat());
|
||||||
|
}*/
|
||||||
|
jj += nfcatt;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*if (!wcsrc.isNull())
|
|
||||||
{
|
|
||||||
indcl = face.at(jj + offcl).toInt();
|
|
||||||
assert(indcl * 4 < wc.size());
|
|
||||||
m.face[ff].WC(1) = vcg::Color4b(wc.at(indcl * 4).toFloat(),wc.at(indcl * 4 + 1).toFloat(),wc.at(indcl * 4 + 2).toFloat(),wc.at(indcl * 4 + 3).toFloat());
|
|
||||||
}*/
|
|
||||||
jj += nfcatt;
|
|
||||||
|
|
||||||
indvt = face.at(jj).toInt();
|
|
||||||
assert(indvt + offset < m.vert.size());
|
|
||||||
m.face[ff].V(2) = &(m.vert[indvt + offset]);
|
|
||||||
if (!wnsrc.isNull())
|
|
||||||
{
|
|
||||||
indnm = face.at(jj + offnm).toInt();
|
|
||||||
assert(indnm * 3 < wn.size());
|
|
||||||
m.face[ff].WN(2) = vcg::Point3f(wn.at(indnm * 3).toFloat(),wn.at(indnm * 3 + 1).toFloat(),wn.at(indnm * 3 + 2).toFloat());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!wtsrc.isNull())
|
|
||||||
{
|
|
||||||
indtx = face.at(jj + offtx).toInt();
|
|
||||||
assert(indtx * 2 < wt.size());
|
|
||||||
m.face[ff].WT(2) = vcg::TCoord2<float>();
|
|
||||||
m.face[ff].WT(2).u() = wt.at(indtx * 2).toFloat();
|
|
||||||
m.face[ff].WT(2).v() = wt.at(indtx * 2 + 1).toFloat();
|
|
||||||
m.face[ff].WT(2).n() = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*if (!wcsrc.isNull())
|
|
||||||
{
|
|
||||||
indcl = face.at(jj + offcl).toInt();
|
|
||||||
assert(indcl * 4 < wc.size());
|
|
||||||
m.face[ff].WC(2) = vcg::Color4b(wc.at(indcl * 4).toFloat(),wc.at(indcl * 4 + 1).toFloat(),wc.at(indcl * 4 + 2).toFloat(),wc.at(indcl * 4 + 3).toFloat());
|
|
||||||
}*/
|
|
||||||
jj += nfcatt;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return E_NOERROR;
|
return E_NOERROR;
|
||||||
|
@ -254,7 +257,7 @@ namespace io {
|
||||||
QDomNodeList nlst = txlst.at(img).toElement().elementsByTagName("init_from");
|
QDomNodeList nlst = txlst.at(img).toElement().elementsByTagName("init_from");
|
||||||
if (nlst.size() > 0)
|
if (nlst.size() > 0)
|
||||||
{
|
{
|
||||||
inf->dae->texturefile.push_back(nlst.at(0).firstChild().nodeValue());
|
inf->texturefile.push_back(nlst.at(0).firstChild().nodeValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -264,12 +267,11 @@ namespace io {
|
||||||
//merge all meshes in the collada's file in the templeted mesh m
|
//merge all meshes in the collada's file in the templeted mesh m
|
||||||
//I assume the mesh
|
//I assume the mesh
|
||||||
|
|
||||||
static int Open(OpenMeshType& m,const char* filename,AdditionalInfo*& addinfo, CallBackPos *cb=0)
|
static int Open(OpenMeshType& m,const char* filename,AdditionalInfo*& info, CallBackPos *cb=0)
|
||||||
{
|
{
|
||||||
AdditionalInfoDAE* inf = new AdditionalInfoDAE();
|
AdditionalInfoDAE* inf = new AdditionalInfoDAE();
|
||||||
inf->dae = new InfoDAE();
|
inf->dae = new InfoDAE();
|
||||||
InfoDAE* info = inf->dae;
|
|
||||||
|
|
||||||
QDomDocument* doc = new QDomDocument(filename);
|
QDomDocument* doc = new QDomDocument(filename);
|
||||||
QFile file(filename);
|
QFile file(filename);
|
||||||
if (!file.open(QIODevice::ReadOnly))
|
if (!file.open(QIODevice::ReadOnly))
|
||||||
|
@ -281,10 +283,10 @@ namespace io {
|
||||||
}
|
}
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
info->doc = doc;
|
inf->dae->doc = doc;
|
||||||
//GetTexture(*(info->doc),inf);
|
//GetTexture(*(info->doc),inf);
|
||||||
|
|
||||||
QDomNodeList scenes = info->doc->elementsByTagName("scene");
|
QDomNodeList scenes = inf->dae->doc->elementsByTagName("scene");
|
||||||
int scn_size = scenes.size();
|
int scn_size = scenes.size();
|
||||||
if (scn_size == 0)
|
if (scn_size == 0)
|
||||||
return E_NO3DSCENE;
|
return E_NO3DSCENE;
|
||||||
|
@ -304,8 +306,8 @@ namespace io {
|
||||||
{
|
{
|
||||||
QString libscn_url;
|
QString libscn_url;
|
||||||
referenceToANodeAttribute(instscenes.at(instscn),"url",libscn_url);
|
referenceToANodeAttribute(instscenes.at(instscn),"url",libscn_url);
|
||||||
QDomNode nd = QDomNode(*(info->doc));
|
QDomNode nd = QDomNode(*(inf->dae->doc));
|
||||||
QDomNode visscn = findNodeBySpecificAttributeValue(*(info->doc),"visual_scene","id",libscn_url);
|
QDomNode visscn = findNodeBySpecificAttributeValue(*(inf->dae->doc),"visual_scene","id",libscn_url);
|
||||||
if(visscn.isNull())
|
if(visscn.isNull())
|
||||||
return E_UNREFERENCEBLEDCOLLADAATTRIBUTE;
|
return E_UNREFERENCEBLEDCOLLADAATTRIBUTE;
|
||||||
|
|
||||||
|
@ -322,9 +324,8 @@ namespace io {
|
||||||
{
|
{
|
||||||
|
|
||||||
geoinst_found |= true;
|
geoinst_found |= true;
|
||||||
QDomNodeList geolib = info->doc->elementsByTagName("library_geometries");
|
QDomNodeList geolib = inf->dae->doc->elementsByTagName("library_geometries");
|
||||||
int geolib_size = geolib.size();
|
assert(geolib.size() == 1);
|
||||||
assert(geolib_size == 1);
|
|
||||||
//!!!!!!!!!!!!!!!!!here will be the code for geometry transformations!!!!!!!!!!!!!!!!!!!!!!
|
//!!!!!!!!!!!!!!!!!here will be the code for geometry transformations!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
|
||||||
for(int geoinst_ind = 0;geoinst_ind < geoinst_size;++geoinst_ind)
|
for(int geoinst_ind = 0;geoinst_ind < geoinst_size;++geoinst_ind)
|
||||||
|
@ -338,7 +339,7 @@ namespace io {
|
||||||
vcg::Matrix44f tr;
|
vcg::Matrix44f tr;
|
||||||
tr.SetIdentity();
|
tr.SetIdentity();
|
||||||
TransfMatrix(visscn,geoinst.at(geoinst_ind),tr);
|
TransfMatrix(visscn,geoinst.at(geoinst_ind),tr);
|
||||||
problem |= LoadMesh(m,info,geo,tr);
|
problem |= LoadMesh(m,inf,geo,tr);
|
||||||
if (problem) return problem;
|
if (problem) return problem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -348,9 +349,8 @@ namespace io {
|
||||||
|
|
||||||
if (!geoinst_found)
|
if (!geoinst_found)
|
||||||
{
|
{
|
||||||
QDomNodeList geolib = info->doc->elementsByTagName("library_geometries");
|
QDomNodeList geolib = inf->dae->doc->elementsByTagName("library_geometries");
|
||||||
int geolib_size = geolib.size();
|
assert(geolib.size() == 1);
|
||||||
assert(geolib_size == 1);
|
|
||||||
QDomNodeList geochild = geolib.at(0).childNodes();
|
QDomNodeList geochild = geolib.at(0).childNodes();
|
||||||
int geochild_size = geochild.size();
|
int geochild_size = geochild.size();
|
||||||
int problem = 0;
|
int problem = 0;
|
||||||
|
@ -358,11 +358,11 @@ namespace io {
|
||||||
{
|
{
|
||||||
vcg::Matrix44f tmp;
|
vcg::Matrix44f tmp;
|
||||||
tmp.SetIdentity();
|
tmp.SetIdentity();
|
||||||
problem |= LoadMesh(m,info,geochild.at(chd),tmp);
|
problem |= LoadMesh(m,inf,geochild.at(chd),tmp);
|
||||||
if (problem) return problem;
|
if (problem) return problem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
addinfo = inf;
|
info = inf;
|
||||||
return E_NOERROR;
|
return E_NOERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -375,9 +375,9 @@ namespace io {
|
||||||
bool bHasPerVertexNormal = false;
|
bool bHasPerVertexNormal = false;
|
||||||
bool bHasPerVertexText = false;
|
bool bHasPerVertexText = false;
|
||||||
|
|
||||||
AdditionalInfoDAE* inf = new AdditionalInfoDAE();
|
AdditionalInfoDAE* info = new AdditionalInfoDAE();
|
||||||
inf->dae = new InfoDAE();
|
info->dae = new InfoDAE();
|
||||||
InfoDAE* info = inf->dae;
|
|
||||||
|
|
||||||
QDomDocument* doc = new QDomDocument(filename);
|
QDomDocument* doc = new QDomDocument(filename);
|
||||||
QFile file(filename);
|
QFile file(filename);
|
||||||
|
@ -391,9 +391,9 @@ namespace io {
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
|
|
||||||
info->doc = doc;
|
info->dae->doc = doc;
|
||||||
GetTexture(*(info->doc),inf);
|
GetTexture(*(info->dae->doc),info);
|
||||||
QDomNodeList scenes = info->doc->elementsByTagName("scene");
|
QDomNodeList scenes = info->dae->doc->elementsByTagName("scene");
|
||||||
int scn_size = scenes.size();
|
int scn_size = scenes.size();
|
||||||
|
|
||||||
|
|
||||||
|
@ -412,8 +412,8 @@ namespace io {
|
||||||
{
|
{
|
||||||
QString libscn_url;
|
QString libscn_url;
|
||||||
referenceToANodeAttribute(instscenes.at(instscn),"url",libscn_url);
|
referenceToANodeAttribute(instscenes.at(instscn),"url",libscn_url);
|
||||||
QDomNode nd = QDomNode(*(info->doc));
|
QDomNode nd = QDomNode(*(info->dae->doc));
|
||||||
QDomNode visscn = findNodeBySpecificAttributeValue(*(info->doc),"visual_scene","id",libscn_url);
|
QDomNode visscn = findNodeBySpecificAttributeValue(*(info->dae->doc),"visual_scene","id",libscn_url);
|
||||||
if(visscn.isNull())
|
if(visscn.isNull())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -422,7 +422,6 @@ namespace io {
|
||||||
QDomNodeList visscn_child = visscn.childNodes();
|
QDomNodeList visscn_child = visscn.childNodes();
|
||||||
|
|
||||||
//for each direct child of a libscn_url visual scene find if there is some geometry instance
|
//for each direct child of a libscn_url visual scene find if there is some geometry instance
|
||||||
int problem = 0;
|
|
||||||
for(int chdind = 0; chdind < visscn_child.size();++chdind)
|
for(int chdind = 0; chdind < visscn_child.size();++chdind)
|
||||||
{
|
{
|
||||||
//QDomNodeList& geoinst = visscn_child.at(chdind).toElement().elementsByTagName("instance_geometry");
|
//QDomNodeList& geoinst = visscn_child.at(chdind).toElement().elementsByTagName("instance_geometry");
|
||||||
|
@ -432,9 +431,8 @@ namespace io {
|
||||||
{
|
{
|
||||||
|
|
||||||
geoinst_found |= true;
|
geoinst_found |= true;
|
||||||
QDomNodeList geolib = info->doc->elementsByTagName("library_geometries");
|
QDomNodeList geolib = info->dae->doc->elementsByTagName("library_geometries");
|
||||||
int geolib_size = geolib.size();
|
assert(geolib.size() == 1);
|
||||||
assert(geolib_size == 1);
|
|
||||||
//!!!!!!!!!!!!!!!!!here will be the code for geometry transformations!!!!!!!!!!!!!!!!!!!!!!
|
//!!!!!!!!!!!!!!!!!here will be the code for geometry transformations!!!!!!!!!!!!!!!!!!!!!!
|
||||||
info->numvert = 0;
|
info->numvert = 0;
|
||||||
info->numface = 0;
|
info->numface = 0;
|
||||||
|
@ -490,9 +488,8 @@ namespace io {
|
||||||
|
|
||||||
if (!geoinst_found)
|
if (!geoinst_found)
|
||||||
{
|
{
|
||||||
QDomNodeList geolib = info->doc->elementsByTagName("library_geometries");
|
QDomNodeList geolib = info->dae->doc->elementsByTagName("library_geometries");
|
||||||
int geolib_size = geolib.size();
|
assert(geolib.size() == 1);
|
||||||
assert(geolib_size == 1);
|
|
||||||
QDomNodeList geochild = geolib.at(0).toElement().elementsByTagName("geometry");
|
QDomNodeList geochild = geolib.at(0).toElement().elementsByTagName("geometry");
|
||||||
//!!!!!!!!!!!!!!!!!here will be the code for geometry transformations!!!!!!!!!!!!!!!!!!!!!!
|
//!!!!!!!!!!!!!!!!!here will be the code for geometry transformations!!!!!!!!!!!!!!!!!!!!!!
|
||||||
info->numvert = 0;
|
info->numvert = 0;
|
||||||
|
@ -554,8 +551,9 @@ namespace io {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
delete (info->doc);
|
delete (info->dae->doc);
|
||||||
addinfo = inf;
|
info->dae->doc = NULL;
|
||||||
|
addinfo = info;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -19,41 +19,41 @@
|
||||||
namespace vcg {
|
namespace vcg {
|
||||||
namespace tri {
|
namespace tri {
|
||||||
namespace io {
|
namespace io {
|
||||||
class InfoDAE : public AdditionalInfo
|
class InfoDAE
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
InfoDAE()
|
InfoDAE()
|
||||||
{
|
{
|
||||||
mask = 0;
|
|
||||||
numvert = 0;
|
|
||||||
numface = 0;
|
|
||||||
doc = NULL;
|
doc = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
~InfoDAE()
|
~InfoDAE()
|
||||||
{
|
{
|
||||||
delete doc;
|
delete doc;
|
||||||
texturefile.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QDomDocument* doc;
|
QDomDocument* doc;
|
||||||
std::vector<QString> texturefile;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class AdditionalInfoDAE : public AdditionalInfo
|
class AdditionalInfoDAE : public AdditionalInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
vcg::tri::io::InfoDAE* dae;
|
vcg::tri::io::InfoDAE* dae;
|
||||||
|
std::vector<QString> texturefile;
|
||||||
|
|
||||||
AdditionalInfoDAE()
|
AdditionalInfoDAE()
|
||||||
:AdditionalInfo()
|
:AdditionalInfo()
|
||||||
{
|
{
|
||||||
|
mask = 0;
|
||||||
|
numvert = 0;
|
||||||
|
numface = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
~AdditionalInfoDAE()
|
~AdditionalInfoDAE()
|
||||||
{
|
{
|
||||||
delete dae;
|
delete dae;
|
||||||
|
texturefile.clear();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ namespace io {
|
||||||
else return dae_error_msg[error];
|
else return dae_error_msg[error];
|
||||||
};
|
};
|
||||||
protected:
|
protected:
|
||||||
inline static void referenceToANodeAttribute(const QDomNode& n,const QString& attr,QString& url_st)
|
inline static void referenceToANodeAttribute(const QDomNode n,const QString& attr,QString& url_st)
|
||||||
{
|
{
|
||||||
url_st = n.toElement().attribute(attr);
|
url_st = n.toElement().attribute(attr);
|
||||||
int sz = url_st.size() - 1;
|
int sz = url_st.size() - 1;
|
||||||
|
@ -116,12 +116,12 @@ namespace io {
|
||||||
return QDomNode();
|
return QDomNode();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline static QDomNode findNodeBySpecificAttributeValue(const QDomNode& n,const QString& tag,const QString& attrname,const QString& attrvalue)
|
inline static QDomNode findNodeBySpecificAttributeValue(const QDomNode n,const QString& tag,const QString& attrname,const QString& attrvalue)
|
||||||
{
|
{
|
||||||
return findNodeBySpecificAttributeValue(n.toElement().elementsByTagName(tag),attrname,attrvalue);
|
return findNodeBySpecificAttributeValue(n.toElement().elementsByTagName(tag),attrname,attrvalue);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline static QDomNode findNodeBySpecificAttributeValue(const QDomDocument& n,const QString& tag,const QString& attrname,const QString& attrvalue)
|
inline static QDomNode findNodeBySpecificAttributeValue(const QDomDocument n,const QString& tag,const QString& attrname,const QString& attrvalue)
|
||||||
{
|
{
|
||||||
return findNodeBySpecificAttributeValue(n.elementsByTagName(tag),attrname,attrvalue);
|
return findNodeBySpecificAttributeValue(n.elementsByTagName(tag),attrname,attrvalue);
|
||||||
}
|
}
|
||||||
|
@ -131,18 +131,18 @@ namespace io {
|
||||||
return ((list.size() > 0) ? true : false);
|
return ((list.size() > 0) ? true : false);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline static bool isThereTag(const QDomNode& n,const QString& tagname)
|
inline static bool isThereTag(const QDomNode n,const QString& tagname)
|
||||||
{
|
{
|
||||||
return isThereTag(n.toElement().elementsByTagName(tagname));
|
return isThereTag(n.toElement().elementsByTagName(tagname));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline static bool isThereTag(const QDomDocument& n,const QString& tagname)
|
inline static bool isThereTag(const QDomDocument n,const QString& tagname)
|
||||||
{
|
{
|
||||||
return isThereTag(n.elementsByTagName(tagname));
|
return isThereTag(n.elementsByTagName(tagname));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline static QDomNode attributeSourcePerSimplex(const QDomNode& n,const QDomDocument& startpoint,const QString& sem)
|
inline static QDomNode attributeSourcePerSimplex(const QDomNode n,const QDomDocument startpoint,const QString& sem)
|
||||||
{
|
{
|
||||||
QDomNodeList vertattr = n.toElement().elementsByTagName("input");
|
QDomNodeList vertattr = n.toElement().elementsByTagName("input");
|
||||||
for(int ind = 0;ind < vertattr.size();++ind)
|
for(int ind = 0;ind < vertattr.size();++ind)
|
||||||
|
@ -157,11 +157,10 @@ namespace io {
|
||||||
return QDomNode();
|
return QDomNode();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline static void valueStringList(QStringList& res,const QDomNode& srcnode,const QString& tag)
|
inline static void valueStringList(QStringList& res,const QDomNode srcnode,const QString& tag)
|
||||||
{
|
{
|
||||||
QDomNodeList list = srcnode.toElement().elementsByTagName(tag);
|
QDomNodeList list = srcnode.toElement().elementsByTagName(tag);
|
||||||
int list_size = list.size();
|
assert(list.size() == 1);
|
||||||
assert(list_size == 1);
|
|
||||||
QString nd = list.at(0).firstChild().nodeValue();
|
QString nd = list.at(0).firstChild().nodeValue();
|
||||||
res = nd.split(" ");
|
res = nd.split(" ");
|
||||||
if (res.last() == "")
|
if (res.last() == "")
|
||||||
|
@ -175,13 +174,13 @@ namespace io {
|
||||||
{
|
{
|
||||||
for(int jj = 0;jj < nodelst.size();++jj)
|
for(int jj = 0;jj < nodelst.size();++jj)
|
||||||
{
|
{
|
||||||
removeChildNode(nodelst.at(jj),tag,attribname,attribvalue);
|
removeChildNode(nodelst.at(jj),tag,attribname,attribvalue);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline static bool removeChildNode(QDomNode& node,const QString& tag = "", const QString& attribname = "", const QString& attribvalue = "")
|
inline static bool removeChildNode(QDomNode node,const QString& tag = "", const QString& attribname = "", const QString& attribvalue = "")
|
||||||
{
|
{
|
||||||
QDomNodeList clst = node.childNodes();
|
QDomNodeList clst = node.childNodes();
|
||||||
for(int ii = 0;ii < clst.size();++ii)
|
for(int ii = 0;ii < clst.size();++ii)
|
||||||
|
@ -208,55 +207,6 @@ namespace io {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//inline static bool removeChildNode(QDomDocument& node,const QString& tag = "", const QString& attribname = "", const QString& attribvalue = "")
|
|
||||||
////inline static bool removeChildNode(QDomNode node,const QString& tag = "", const QString& attribname = "", const QString& attribvalue = "")
|
|
||||||
//{
|
|
||||||
// QDomNodeList clst = node.childNodes();
|
|
||||||
// for(int ii = 0;ii < clst.size();++ii)
|
|
||||||
// {
|
|
||||||
// QDomNode oldchild = node.childNodes().at(ii);
|
|
||||||
// if (tag != "")
|
|
||||||
// {
|
|
||||||
// if ((attribname != "") && (attribvalue != ""))
|
|
||||||
// {
|
|
||||||
// if (clst.at(ii).toElement().attribute(attribname) == attribvalue)
|
|
||||||
// node.removeChild(oldchild);
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// QString nm = clst.at(ii).nodeName();
|
|
||||||
// if (clst.at(ii).nodeName() == tag)
|
|
||||||
// {
|
|
||||||
// node.removeChild(oldchild);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// else node.removeChild(oldchild);
|
|
||||||
// }
|
|
||||||
// return true;
|
|
||||||
//}
|
|
||||||
|
|
||||||
/*inline static bool removeChildNode(QDomDocument node,const QString& tag = "", const QString& attribname = "", const QString& attribvalue = "")
|
|
||||||
{
|
|
||||||
QDomNodeList clst = node.childNodes();
|
|
||||||
for(int ii = 0;ii < clst.size();++ii)
|
|
||||||
{
|
|
||||||
QDomNode oldchild = node.childNodes().at(ii);
|
|
||||||
if (tag != "")
|
|
||||||
{
|
|
||||||
if ((attribname != "") && (attribvalue != ""))
|
|
||||||
{
|
|
||||||
if (clst.at(ii).toElement().attribute(attribname) == attribvalue)
|
|
||||||
node.removeChild(oldchild);
|
|
||||||
}
|
|
||||||
else if (clst.at(ii).nodeName() == tag)
|
|
||||||
node.removeChild(oldchild);
|
|
||||||
}
|
|
||||||
else node.removeChild(oldchild);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
static void ParseRotationMatrix(vcg::Matrix44f& m,const std::vector<QDomNode>& t)
|
static void ParseRotationMatrix(vcg::Matrix44f& m,const std::vector<QDomNode>& t)
|
||||||
{
|
{
|
||||||
vcg::Matrix44f tmp;
|
vcg::Matrix44f tmp;
|
||||||
|
@ -273,7 +223,7 @@ namespace io {
|
||||||
m = m * tmp;
|
m = m * tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void AddTranslation(vcg::Matrix44f& m,const QDomNode& t)
|
static void AddTranslation(vcg::Matrix44f& m,const QDomNode t)
|
||||||
{
|
{
|
||||||
QDomNode tr = t.firstChild();
|
QDomNode tr = t.firstChild();
|
||||||
QString coord = tr.nodeValue();
|
QString coord = tr.nodeValue();
|
||||||
|
@ -290,7 +240,7 @@ namespace io {
|
||||||
m[2][3] = coordlist.at(2).toFloat();
|
m[2][3] = coordlist.at(2).toFloat();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void TransfMatrix(const QDomNode& parentnode,const QDomNode& presentnode,vcg::Matrix44f& m)
|
static void TransfMatrix(const QDomNode parentnode,const QDomNode presentnode,vcg::Matrix44f& m)
|
||||||
{
|
{
|
||||||
if (presentnode == parentnode) return;
|
if (presentnode == parentnode) return;
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue