now load file without instance_geometry
This commit is contained in:
parent
ab38499165
commit
2f79d55207
|
@ -12,79 +12,10 @@ namespace io {
|
||||||
template<typename OpenMeshType>
|
template<typename OpenMeshType>
|
||||||
class ImporterDAE : public UtilDAE
|
class ImporterDAE : public UtilDAE
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
|
|
||||||
//merge all meshes in the collada's file in the templeted mesh m
|
private:
|
||||||
//I assume the mesh
|
static int LoadMesh(OpenMeshType& m,InfoDAE* info,const QDomNode& geo)
|
||||||
|
|
||||||
static int Open(OpenMeshType& m,const char* filename,AdditionalInfo*& addinfo)
|
|
||||||
{
|
{
|
||||||
AdditionalInfoDAE* inf = new AdditionalInfoDAE();
|
|
||||||
inf->dae = new InfoDAE();
|
|
||||||
InfoDAE* info = inf->dae;
|
|
||||||
|
|
||||||
QDomDocument* doc = new QDomDocument(filename);
|
|
||||||
QFile file(filename);
|
|
||||||
if (!file.open(QIODevice::ReadOnly))
|
|
||||||
return E_CANTOPEN;
|
|
||||||
if (!doc->setContent(&file))
|
|
||||||
{
|
|
||||||
file.close();
|
|
||||||
return E_CANTOPEN;
|
|
||||||
}
|
|
||||||
file.close();
|
|
||||||
|
|
||||||
info->doc = doc;
|
|
||||||
QDomNodeList& scenes = info->doc->elementsByTagName("scene");
|
|
||||||
int scn_size = scenes.size();
|
|
||||||
if (scn_size == 0)
|
|
||||||
return E_NO3DSCENE;
|
|
||||||
|
|
||||||
//Is there geometry in the file?
|
|
||||||
bool geoinst_found = false;
|
|
||||||
//for each scene in COLLADA FILE
|
|
||||||
for(int scn = 0;scn < scn_size;++scn)
|
|
||||||
{
|
|
||||||
QDomNodeList& instscenes = scenes.at(scn).toElement().elementsByTagName("instance_visual_scene");
|
|
||||||
int instscn_size = instscenes.size();
|
|
||||||
if (instscn_size == 0)
|
|
||||||
return E_INCOMPATIBLECOLLADA141FORMAT;
|
|
||||||
|
|
||||||
//for each scene instance in a COLLADA scene
|
|
||||||
for(int instscn = 0;instscn < instscn_size; ++instscn)
|
|
||||||
{
|
|
||||||
QString libscn_url;
|
|
||||||
referenceToANodeAttribute(instscenes.at(instscn),"url",libscn_url);
|
|
||||||
QDomNode nd = QDomNode(*(info->doc));
|
|
||||||
QDomNode visscn = findNodeBySpecificAttributeValue(*(info->doc),"visual_scene","id",libscn_url);
|
|
||||||
if(visscn.isNull())
|
|
||||||
return E_UNREFERENCEBLEDCOLLADAATTRIBUTE;
|
|
||||||
|
|
||||||
//for each node in the libscn_url visual scene
|
|
||||||
QDomNodeList& visscn_child = visscn.childNodes();
|
|
||||||
|
|
||||||
//for each direct child of a libscn_url visual scene find if there is some geometry instance
|
|
||||||
for(int chdind = 0; chdind < visscn_child.size();++chdind)
|
|
||||||
{
|
|
||||||
QDomNodeList& geoinst = visscn_child.at(chdind).toElement().elementsByTagName("instance_geometry");
|
|
||||||
int geoinst_size = geoinst.size();
|
|
||||||
if (geoinst_size != 0)
|
|
||||||
{
|
|
||||||
geoinst_found |= true;
|
|
||||||
QDomNodeList& geolib = info->doc->elementsByTagName("library_geometries");
|
|
||||||
int geolib_size = geolib.size();
|
|
||||||
assert(geolib_size == 1);
|
|
||||||
//!!!!!!!!!!!!!!!!!here will be the code for geometry transformations!!!!!!!!!!!!!!!!!!!!!!
|
|
||||||
for(int geoinst_ind = 0;geoinst_ind < geoinst_size;++geoinst_ind)
|
|
||||||
{
|
|
||||||
QString geo_url;
|
|
||||||
referenceToANodeAttribute(geoinst.at(geoinst_ind),"url",geo_url);
|
|
||||||
|
|
||||||
QDomNode geo = findNodeBySpecificAttributeValue(geolib.at(0),"geometry","id",geo_url);
|
|
||||||
if (geo.isNull())
|
|
||||||
return E_UNREFERENCEBLEDCOLLADAATTRIBUTE;
|
|
||||||
|
|
||||||
|
|
||||||
if (isThereTag(geo,"mesh"))
|
if (isThereTag(geo,"mesh"))
|
||||||
{
|
{
|
||||||
/*QDomNodeList geosrc = geo.toElement().elementsByTagName("source");
|
/*QDomNodeList geosrc = geo.toElement().elementsByTagName("source");
|
||||||
|
@ -294,7 +225,84 @@ namespace io {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return E_NOERROR;
|
||||||
}
|
}
|
||||||
|
else return E_NOMESH;
|
||||||
|
}
|
||||||
|
public:
|
||||||
|
|
||||||
|
//merge all meshes in the collada's file in the templeted mesh m
|
||||||
|
//I assume the mesh
|
||||||
|
|
||||||
|
static int Open(OpenMeshType& m,const char* filename,AdditionalInfo*& addinfo)
|
||||||
|
{
|
||||||
|
AdditionalInfoDAE* inf = new AdditionalInfoDAE();
|
||||||
|
inf->dae = new InfoDAE();
|
||||||
|
InfoDAE* info = inf->dae;
|
||||||
|
|
||||||
|
QDomDocument* doc = new QDomDocument(filename);
|
||||||
|
QFile file(filename);
|
||||||
|
if (!file.open(QIODevice::ReadOnly))
|
||||||
|
return E_CANTOPEN;
|
||||||
|
if (!doc->setContent(&file))
|
||||||
|
{
|
||||||
|
file.close();
|
||||||
|
return E_CANTOPEN;
|
||||||
|
}
|
||||||
|
file.close();
|
||||||
|
|
||||||
|
info->doc = doc;
|
||||||
|
QDomNodeList& scenes = info->doc->elementsByTagName("scene");
|
||||||
|
int scn_size = scenes.size();
|
||||||
|
if (scn_size == 0)
|
||||||
|
return E_NO3DSCENE;
|
||||||
|
|
||||||
|
//Is there geometry in the file?
|
||||||
|
bool geoinst_found = false;
|
||||||
|
//for each scene in COLLADA FILE
|
||||||
|
for(int scn = 0;scn < scn_size;++scn)
|
||||||
|
{
|
||||||
|
QDomNodeList& instscenes = scenes.at(scn).toElement().elementsByTagName("instance_visual_scene");
|
||||||
|
int instscn_size = instscenes.size();
|
||||||
|
if (instscn_size == 0)
|
||||||
|
return E_INCOMPATIBLECOLLADA141FORMAT;
|
||||||
|
|
||||||
|
//for each scene instance in a COLLADA scene
|
||||||
|
for(int instscn = 0;instscn < instscn_size; ++instscn)
|
||||||
|
{
|
||||||
|
QString libscn_url;
|
||||||
|
referenceToANodeAttribute(instscenes.at(instscn),"url",libscn_url);
|
||||||
|
QDomNode nd = QDomNode(*(info->doc));
|
||||||
|
QDomNode visscn = findNodeBySpecificAttributeValue(*(info->doc),"visual_scene","id",libscn_url);
|
||||||
|
if(visscn.isNull())
|
||||||
|
return E_UNREFERENCEBLEDCOLLADAATTRIBUTE;
|
||||||
|
|
||||||
|
//for each node in the libscn_url visual scene
|
||||||
|
QDomNodeList& visscn_child = visscn.childNodes();
|
||||||
|
|
||||||
|
//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)
|
||||||
|
{
|
||||||
|
QDomNodeList& geoinst = visscn_child.at(chdind).toElement().elementsByTagName("instance_geometry");
|
||||||
|
int geoinst_size = geoinst.size();
|
||||||
|
if (geoinst_size != 0)
|
||||||
|
{
|
||||||
|
geoinst_found |= true;
|
||||||
|
QDomNodeList& geolib = info->doc->elementsByTagName("library_geometries");
|
||||||
|
int geolib_size = geolib.size();
|
||||||
|
assert(geolib_size == 1);
|
||||||
|
//!!!!!!!!!!!!!!!!!here will be the code for geometry transformations!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
for(int geoinst_ind = 0;geoinst_ind < geoinst_size;++geoinst_ind)
|
||||||
|
{
|
||||||
|
QString geo_url;
|
||||||
|
referenceToANodeAttribute(geoinst.at(geoinst_ind),"url",geo_url);
|
||||||
|
|
||||||
|
QDomNode geo = findNodeBySpecificAttributeValue(geolib.at(0),"geometry","id",geo_url);
|
||||||
|
if (geo.isNull())
|
||||||
|
return E_UNREFERENCEBLEDCOLLADAATTRIBUTE;
|
||||||
|
problem |= LoadMesh(m,info,geo);
|
||||||
|
if (problem) return problem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -302,7 +310,19 @@ namespace io {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!geoinst_found)
|
if (!geoinst_found)
|
||||||
return E_NOGEOMETRYLIBRARY;
|
{
|
||||||
|
QDomNodeList& geolib = info->doc->elementsByTagName("library_geometries");
|
||||||
|
int geolib_size = geolib.size();
|
||||||
|
assert(geolib_size == 1);
|
||||||
|
QDomNodeList& geochild = geolib.at(0).childNodes();
|
||||||
|
int geochild_size = geochild.size();
|
||||||
|
int problem = 0;
|
||||||
|
for(int chd = 0;chd < geochild_size;++chd)
|
||||||
|
{
|
||||||
|
problem |= LoadMesh(m,info,geochild.at(chd));
|
||||||
|
if (problem) return problem;
|
||||||
|
}
|
||||||
|
}
|
||||||
addinfo = inf;
|
addinfo = inf;
|
||||||
return E_NOERROR;
|
return E_NOERROR;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue