vcglib/wrap/io_trimesh/export_dae.h

81 lines
1.9 KiB
C
Raw Normal View History

#ifndef __VCGLIB_EXPORTERDAE
#define __VCGLIB_EXPORTERDAE
2006-11-03 00:58:33 +01:00
#include<wrap/io_trimesh/util_dae.h>
namespace vcg {
namespace tri {
namespace io {
//FCollada Library assumes that SaveMeshType::ScalarType is always a float
template<typename SaveMeshType>
2006-11-03 00:58:33 +01:00
class ExporterDAE : public UtilDAE
{
public:
2006-09-22 08:04:22 +02:00
static int Save(SaveMeshType &m, const char * filename,AdditionalInfo*& in)
{
2006-11-03 00:58:33 +01:00
/*unsigned int ncomp = sizeof(SaveMeshType::CoordType) / sizeof(SaveMeshType::ScalarType);*/
2006-09-22 08:04:22 +02:00
assert(in != NULL);
AdditionalInfoDAE* inf = static_cast<AdditionalInfoDAE*>(in);
InfoDAE* info = inf->dae;
2006-11-03 00:58:33 +01:00
QDomNodeList scenelst = info->doc->elementsByTagName("scene");
//removeChildNode(scenelst,"instance_visual_scene");
for(int vsscn = 0;vsscn < scenelst.size();++vsscn)
2006-09-22 08:04:22 +02:00
{
2006-11-03 00:58:33 +01:00
QString url = scenelst.at(vsscn).toElement().attribute("url");
2006-09-22 08:04:22 +02:00
}
2006-11-03 00:58:33 +01:00
QDomElement vsnode = info->doc->createElement("instance_visual_scene");
vsnode.setAttribute("url","#vcg-scene-node");
scenelst.at(0).appendChild(vsnode);
2006-09-22 08:04:22 +02:00
2006-11-03 00:58:33 +01:00
QDomNodeList geolib = info->doc->elementsByTagName("library_geometries");
assert(geolib.size() == 1);
removeChildNode(geolib.at(0));
2006-09-22 08:04:22 +02:00
2006-11-03 00:58:33 +01:00
/*QDomElement mshnode;
mshnode.setTagName("mesh");*/
QDomElement mshnode = info->doc->createElement("mesh");
geolib.at(0).appendChild(mshnode);
QString st = info->doc->toString();
QFile file(filename);
if (!file.open(QIODevice::ReadWrite | QIODevice::Truncate))
return 1;
info->doc->setContent(&file);
file.write(st.toAscii());
file.close();
2006-09-22 08:04:22 +02:00
return 0;
}
static int GetExportMaskCapability()
{
int capability = 0;
//camera
//capability |= MeshModel::IOM_CAMERA;
//vert
//capability |= MeshModel::IOM_VERTTEXCOORD;
//face
capability |= MeshModel::IOM_FACEFLAGS;
//capability |= MeshModel::IOM_FACECOLOR;
capability |= MeshModel::IOM_FACENORMAL;
//wedg
//capability |= MeshModel::IOM_WEDGTEXCOORD;
capability |= MeshModel::IOM_WEDGNORMAL;
return capability;
}
};
}
}
}
#endif