- collada format is now fully compliant to the collada standard v 1.4.1
This commit is contained in:
parent
a445902e56
commit
48065edaf2
|
@ -60,6 +60,7 @@ namespace io
|
||||||
//capability |= MeshModel::IOM_CAMERA;
|
//capability |= MeshModel::IOM_CAMERA;
|
||||||
|
|
||||||
//vert
|
//vert
|
||||||
|
capability |= Mask::IOM_VERTCOORD;
|
||||||
capability |= Mask::IOM_VERTNORMAL;
|
capability |= Mask::IOM_VERTNORMAL;
|
||||||
capability |= Mask::IOM_VERTTEXCOORD;
|
capability |= Mask::IOM_VERTTEXCOORD;
|
||||||
capability |= Mask::IOM_VERTCOLOR;
|
capability |= Mask::IOM_VERTCOLOR;
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
//importer for collada's files
|
//importer for collada's files
|
||||||
|
|
||||||
#include <wrap/dae/util_dae.h>
|
#include <wrap/dae/util_dae.h>
|
||||||
|
#include <wrap/dae/poly_triangulator.h>
|
||||||
|
|
||||||
// uncomment one of the following line to enable the Verbose debugging for the parsing
|
// uncomment one of the following line to enable the Verbose debugging for the parsing
|
||||||
//#define QDEBUG if(1) ; else {assert(0);}
|
//#define QDEBUG if(1) ; else {assert(0);}
|
||||||
|
@ -119,20 +120,29 @@ namespace io {
|
||||||
return indtx;
|
return indtx;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int VertexColorAttribute(ColladaMesh& m,const QStringList face,const QStringList wc,const QDomNode wcsrc,const int meshfaceind,const int faceind, const int vertind,const int component)
|
//static int VertexColorAttribute(ColladaMesh& m,const QStringList face,const QStringList wc,const QDomNode wcsrc,const int meshfaceind,const int faceind, const int vertind,const int component)
|
||||||
{
|
//{
|
||||||
int indcl = -1;
|
// int indcl = -1;
|
||||||
if (!wcsrc.isNull())
|
// if (!wcsrc.isNull())
|
||||||
{
|
// {
|
||||||
indcl = face.at(faceind).toInt();
|
// indcl = face.at(faceind).toInt();
|
||||||
assert(indcl * 3 < wc.size());
|
// assert(indcl * component < wc.size());
|
||||||
m.vert[vertind].C() = vcg::Color4b( (unsigned char)(wc.at(indcl * 3).toFloat()*255.0),
|
// assert((component == 4) || (component == 3));
|
||||||
(unsigned char)(wc.at(indcl * 3 + 1).toFloat()*255.0),
|
// vcg::Color4b c;
|
||||||
(unsigned char)(wc.at(indcl * 3 + 2).toFloat()*255.0),
|
// if (component == 3)
|
||||||
1.0);
|
// c[3] = 255;
|
||||||
}
|
// for(unsigned int ii = 0;ii < component;++ii)
|
||||||
return indcl;
|
// c[ii] = (unsigned char)(wc.at(indcl * component + ii).toFloat()*255.0);
|
||||||
}
|
// /*m.vert[vertind].C() = vcg::Color4b( (unsigned char)(wc.at(indcl * component).toFloat()*255.0),
|
||||||
|
// (unsigned char)(wc.at(indcl * component + 1).toFloat()*255.0),
|
||||||
|
// (unsigned char)(wc.at(indcl * component + 2).toFloat()*255.0),
|
||||||
|
// (unsigned char)(wc.at(indcl * component + 3).toFloat()*255.0));*/
|
||||||
|
// m.vert[vertind].C() = c;
|
||||||
|
|
||||||
|
// }
|
||||||
|
// return indcl;
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
static void FindStandardWedgeAttributes(WedgeAttribute& wed,const QDomNode nd,const QDomDocument doc)
|
static void FindStandardWedgeAttributes(WedgeAttribute& wed,const QDomNode nd,const QDomDocument doc)
|
||||||
{
|
{
|
||||||
|
@ -146,17 +156,30 @@ namespace io {
|
||||||
if (isThereTag(src,"accessor"))
|
if (isThereTag(src,"accessor"))
|
||||||
{
|
{
|
||||||
QDomNodeList wedatts = src.toElement().elementsByTagName("accessor");
|
QDomNodeList wedatts = src.toElement().elementsByTagName("accessor");
|
||||||
wed.stride = wedatts.at(0).toElement().attribute("stride").toInt();
|
wed.stridetx = wedatts.at(0).toElement().attribute("stride").toInt();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
wed.stride = 2;
|
wed.stridetx = 2;
|
||||||
}
|
}
|
||||||
else
|
//else
|
||||||
wed.stride = 2;
|
// wed.stridetx = 2;
|
||||||
|
|
||||||
wed.offtx = findStringListAttribute(wed.wt,wed.wtsrc,nd,doc,"TEXCOORD");
|
wed.offtx = findStringListAttribute(wed.wt,wed.wtsrc,nd,doc,"TEXCOORD");
|
||||||
|
|
||||||
wed.wcsrc = findNodeBySpecificAttributeValue(nd,"input","semantic","COLOR");
|
wed.wcsrc = findNodeBySpecificAttributeValue(nd,"input","semantic","COLOR");
|
||||||
|
if (!wed.wtsrc.isNull())
|
||||||
|
{
|
||||||
|
QDomNode src = attributeSourcePerSimplex(nd,doc,"COLOR");
|
||||||
|
if (isThereTag(src,"accessor"))
|
||||||
|
{
|
||||||
|
QDomNodeList wedatts = src.toElement().elementsByTagName("accessor");
|
||||||
|
wed.stridecl = wedatts.at(0).toElement().attribute("stride").toInt();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
wed.stridecl = 3;
|
||||||
|
}
|
||||||
|
/*else
|
||||||
|
wed.stridecl = 3;*/
|
||||||
wed.offcl = findStringListAttribute(wed.wc,wed.wcsrc,nd,doc,"COLOR");
|
wed.offcl = findStringListAttribute(wed.wc,wed.wcsrc,nd,doc,"COLOR");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,7 +252,7 @@ namespace io {
|
||||||
polyTemp._pv[tt] = &(m.vert[indvt + offset]);
|
polyTemp._pv[tt] = &(m.vert[indvt + offset]);
|
||||||
faceIndexCnt +=faceAttributeNum;
|
faceIndexCnt +=faceAttributeNum;
|
||||||
|
|
||||||
WedgeTextureAttribute(polyTemp._txc[tt],faceIndexList,ind_txt, wa.wt ,wa.wtsrc, jj + wa.offtx,wa.stride);
|
WedgeTextureAttribute(polyTemp._txc[tt],faceIndexList,ind_txt, wa.wt ,wa.wtsrc, jj + wa.offtx,wa.stridetx);
|
||||||
|
|
||||||
/****************
|
/****************
|
||||||
|
|
||||||
|
@ -396,12 +419,16 @@ namespace io {
|
||||||
assert(indvt + offset < m.vert.size());
|
assert(indvt + offset < m.vert.size());
|
||||||
m.face[ff].V(tt) = &(m.vert[indvt + offset]);
|
m.face[ff].V(tt) = &(m.vert[indvt + offset]);
|
||||||
|
|
||||||
if(tri::HasPerWedgeNormal(m)) WedgeNormalAttribute(m,face,wa.wn,wa.wnsrc,ff,jj + wa.offnm,tt);
|
//if(tri::HasPerWedgeNormal(m))
|
||||||
if(tri::HasPerVertexColor(m)) VertexColorAttribute(m,face,wa.wc,wa.wcsrc,ff,jj + wa.offcl,indvt + offset,tt);
|
// //WedgeNormalAttribute(m,face,wa.wn,wa.wnsrc,ff,jj + wa.offnm,tt);
|
||||||
|
//if(tri::HasPerVertexColor(m))
|
||||||
|
//{
|
||||||
|
// //VertexColorAttribute(m,face,wa.wc,wa.wcsrc,ff,jj + wa.offcl,indvt + offset,wa.stridecl);
|
||||||
|
//}
|
||||||
|
|
||||||
if(tri::HasPerWedgeTexCoord(m) && ind_txt != -1)
|
if(tri::HasPerWedgeTexCoord(m) && ind_txt != -1)
|
||||||
{
|
{
|
||||||
WedgeTextureAttribute(m,face,ind_txt,wa.wt,wa.wtsrc,ff,jj + wa.offtx,tt,wa.stride);
|
WedgeTextureAttribute(m,face,ind_txt,wa.wt,wa.wtsrc,ff,jj + wa.offtx,tt,wa.stridetx);
|
||||||
}
|
}
|
||||||
|
|
||||||
jj += faceAttributeNum;
|
jj += faceAttributeNum;
|
||||||
|
@ -503,6 +530,8 @@ namespace io {
|
||||||
valueStringList(geosrcverttext,srcnodetext,"float_array");
|
valueStringList(geosrcverttext,srcnodetext,"float_array");
|
||||||
|
|
||||||
QDomNode srcnodecolor = attributeSourcePerSimplex(vertices.at(0),*(info.doc),"COLOR");
|
QDomNode srcnodecolor = attributeSourcePerSimplex(vertices.at(0),*(info.doc),"COLOR");
|
||||||
|
QDomNodeList accesslist = srcnodecolor.toElement().elementsByTagName("accessor");
|
||||||
|
|
||||||
QStringList geosrcvertcol;
|
QStringList geosrcvertcol;
|
||||||
if (!srcnodecolor.isNull())
|
if (!srcnodecolor.isNull())
|
||||||
valueStringList(geosrcvertcol,srcnodecolor,"float_array");
|
valueStringList(geosrcvertcol,srcnodecolor,"float_array");
|
||||||
|
@ -524,8 +553,15 @@ namespace io {
|
||||||
|
|
||||||
if (!srcnodecolor.isNull())
|
if (!srcnodecolor.isNull())
|
||||||
{
|
{
|
||||||
//assert((ii * 4 < geosrcvertcol.size()) && (ii * 4 + 1 < geosrcvertcol.size()) && (ii * 4 + 2 < geosrcvertcol.size()) && (ii * 4 + 1 < geosrcvertcol.size()));
|
if (accesslist.size() > 0)
|
||||||
m.vert[vv].C() = vcg::Color4b(geosrcvertcol[ii * 3].toFloat()*255.0,geosrcvertcol[ii * 3 + 1].toFloat()*255.0,geosrcvertcol[ii * 3 + 2].toFloat()*255.0,1.0);
|
{
|
||||||
|
//component per color...obviously we assume they are RGB or RGBA if ARGB you get fancy effects....
|
||||||
|
if (accesslist.at(0).childNodes().size() == 4)
|
||||||
|
m.vert[vv].C() = vcg::Color4b(geosrcvertcol[ii * 4].toFloat()*255.0,geosrcvertcol[ii * 4 + 1].toFloat()*255.0,geosrcvertcol[ii * 4 + 2].toFloat()*255.0,geosrcvertcol[ii * 4 + 3].toFloat()*255.0);
|
||||||
|
else
|
||||||
|
if (accesslist.at(0).childNodes().size() == 3)
|
||||||
|
m.vert[vv].C() = vcg::Color4b(geosrcvertcol[ii * 3].toFloat()*255.0,geosrcvertcol[ii * 3 + 1].toFloat()*255.0,geosrcvertcol[ii * 3 + 2].toFloat()*255.0,255.0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!srcnodetext.isNull())
|
if (!srcnodetext.isNull())
|
||||||
|
|
Loading…
Reference in New Issue