From 34f343233e52ee7a3cbc6329951b778e4b53dd7a Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 2 Sep 2020 21:49:20 +0200 Subject: [PATCH] 3ml: fix xml parsing. --- code/AssetLib/3MF/D3MFImporter.cpp | 13 ++++++++----- code/AssetLib/3MF/D3MFOpcPackage.cpp | 6 +++--- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/code/AssetLib/3MF/D3MFImporter.cpp b/code/AssetLib/3MF/D3MFImporter.cpp index 6b4eeb445..089a680cf 100644 --- a/code/AssetLib/3MF/D3MFImporter.cpp +++ b/code/AssetLib/3MF/D3MFImporter.cpp @@ -93,9 +93,12 @@ public: std::vector children; std::string nodeName; - XmlNode node = mXmlParser->getRootNode(); - - for (XmlNode currentNode = node.first_child(); currentNode; currentNode = currentNode.next_sibling()) { + XmlNode node = mXmlParser->getRootNode().child("model"); + if (node.empty()) { + return; + } + XmlNode resNode = node.child("resources"); + for (XmlNode currentNode = resNode.first_child(); currentNode; currentNode = currentNode.next_sibling()) { const std::string ¤tNodeName = currentNode.name(); if (currentNodeName == D3MF::XmlTag::object) { children.push_back(ReadObject(currentNode, scene)); @@ -151,7 +154,7 @@ private: if (!attr.empty()) { name = attr.as_string(); } - attr = node.attribute(D3MF::XmlTag::id.c_str()); + attr = node.attribute(D3MF::XmlTag::type.c_str()); if (!attr.empty()) { type = attr.as_string(); } @@ -227,7 +230,7 @@ private: aiVector3D ReadVertex(XmlNode &node) { aiVector3D vertex; vertex.x = ai_strtof(node.attribute(D3MF::XmlTag::x.c_str()).as_string(), nullptr); - vertex.x = ai_strtof(node.attribute(D3MF::XmlTag::y.c_str()).as_string(), nullptr); + vertex.y = ai_strtof(node.attribute(D3MF::XmlTag::y.c_str()).as_string(), nullptr); vertex.z = ai_strtof(node.attribute(D3MF::XmlTag::z.c_str()).as_string(), nullptr); return vertex; diff --git a/code/AssetLib/3MF/D3MFOpcPackage.cpp b/code/AssetLib/3MF/D3MFOpcPackage.cpp index 85050b4b4..39bd210e3 100644 --- a/code/AssetLib/3MF/D3MFOpcPackage.cpp +++ b/code/AssetLib/3MF/D3MFOpcPackage.cpp @@ -103,9 +103,9 @@ public: std::string name = currentNode.name(); if (name == "Relationship") { OpcPackageRelationshipPtr relPtr(new OpcPackageRelationship()); - relPtr->id = node.attribute(XmlTag::RELS_ATTRIB_ID.c_str()).as_string(); - relPtr->type = node.attribute(XmlTag::RELS_ATTRIB_TYPE.c_str()).as_string(); - relPtr->target = node.attribute(XmlTag::RELS_ATTRIB_TARGET.c_str()).as_string(); + relPtr->id = currentNode.attribute(XmlTag::RELS_ATTRIB_ID.c_str()).as_string(); + relPtr->type = currentNode.attribute(XmlTag::RELS_ATTRIB_TYPE.c_str()).as_string(); + relPtr->target = currentNode.attribute(XmlTag::RELS_ATTRIB_TARGET.c_str()).as_string(); if (validateRels(relPtr)) { m_relationShips.push_back(relPtr); }