3ml: fix xml parsing.

pull/2966/head
Kim Kulling 2020-09-02 21:49:20 +02:00
parent 0c05398602
commit 34f343233e
2 changed files with 11 additions and 8 deletions

View File

@ -93,9 +93,12 @@ public:
std::vector<aiNode *> 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 &currentNodeName = 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;

View File

@ -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);
}