simplify some ttributes access in loaded xml.
parent
0730eebe6f
commit
30a4eae17f
|
@ -116,21 +116,12 @@ ColladaParser::ColladaParser(IOSystem *pIOHandler, const std::string &pFile) :
|
||||||
throw DeadlyImportError("Failed to open file '" + pFile + "'.");
|
throw DeadlyImportError("Failed to open file '" + pFile + "'.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pugi::xml_node *rootPtr = mXmlParser.parse(daefile.get());
|
|
||||||
// generate a XML reader for it
|
// generate a XML reader for it
|
||||||
|
pugi::xml_node *rootPtr = mXmlParser.parse(daefile.get());
|
||||||
if (nullptr == rootPtr) {
|
if (nullptr == rootPtr) {
|
||||||
ThrowException("Unable to read file, malformed XML");
|
ThrowException("Unable to read file, malformed XML");
|
||||||
}
|
}
|
||||||
// bool res = rootPtr->empty();
|
|
||||||
//if (!res) {
|
|
||||||
//XmlNode node = *rootPtr;
|
|
||||||
/*for (XmlNode currentNode = node.first_child(); currentNode; currentNode = currentNode.next_sibling()) {
|
|
||||||
const std::string nm = currentNode.name();
|
|
||||||
}*/
|
|
||||||
//XmlNode node = root->first_child();
|
|
||||||
//std::string name = node.name();
|
|
||||||
//}
|
|
||||||
|
|
||||||
// start reading
|
// start reading
|
||||||
XmlNode node = *rootPtr;
|
XmlNode node = *rootPtr;
|
||||||
std::string name = rootPtr->name();
|
std::string name = rootPtr->name();
|
||||||
|
@ -537,34 +528,20 @@ void ColladaParser::ReadAnimation(XmlNode &node, Collada::Animation *pParent) {
|
||||||
|
|
||||||
// it turned out to have channels - add them
|
// it turned out to have channels - add them
|
||||||
if (!channels.empty()) {
|
if (!channels.empty()) {
|
||||||
// FIXME: Is this essentially doing the same as "single-anim-node" codepath in
|
if (nullptr == anim) {
|
||||||
// ColladaLoader::StoreAnimations? For now, this has been deferred to after
|
|
||||||
// all animations and all clips have been read. Due to handling of
|
|
||||||
// <library_animation_clips> this cannot be done here, as the channel owner
|
|
||||||
// is lost, and some exporters make up animations by referring to multiple
|
|
||||||
// single-channel animations from an <instance_animation>.
|
|
||||||
/*
|
|
||||||
// special filtering for stupid exporters packing each channel into a separate animation
|
|
||||||
if( channels.size() == 1)
|
|
||||||
{
|
|
||||||
pParent->mChannels.push_back( channels.begin()->second);
|
|
||||||
} else
|
|
||||||
*/
|
|
||||||
{
|
|
||||||
// else create the animation, if not done yet, and store the channels
|
|
||||||
if (!anim) {
|
|
||||||
anim = new Animation;
|
anim = new Animation;
|
||||||
anim->mName = animName;
|
anim->mName = animName;
|
||||||
pParent->mSubAnims.push_back(anim);
|
pParent->mSubAnims.push_back(anim);
|
||||||
}
|
}
|
||||||
for (ChannelMap::const_iterator it = channels.begin(); it != channels.end(); ++it)
|
|
||||||
|
for (ChannelMap::const_iterator it = channels.begin(); it != channels.end(); ++it) {
|
||||||
anim->mChannels.push_back(it->second);
|
anim->mChannels.push_back(it->second);
|
||||||
|
}
|
||||||
|
|
||||||
if (idAttr >= 0) {
|
if (idAttr >= 0) {
|
||||||
mAnimationLibrary[animID] = anim;
|
mAnimationLibrary[animID] = anim;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
@ -573,25 +550,25 @@ void ColladaParser::ReadAnimationSampler(XmlNode &node, Collada::AnimationChanne
|
||||||
for (XmlNode currentNode = node.first_child(); currentNode; currentNode = currentNode.next_sibling()) {
|
for (XmlNode currentNode = node.first_child(); currentNode; currentNode = currentNode.next_sibling()) {
|
||||||
const std::string currentName = currentNode.name();
|
const std::string currentName = currentNode.name();
|
||||||
if (currentName == "input") {
|
if (currentName == "input") {
|
||||||
pugi::xml_attribute semanticAttr = currentNode.attribute("semantic");
|
if (XmlParser::hasAttribute(currentNode, "semantic")) {
|
||||||
if (!semanticAttr.empty()) {
|
std::string semantic, sourceAttr;
|
||||||
const char *semantic = semanticAttr.as_string();
|
XmlParser::getStdStrAttribute(currentNode, "semantic", semantic);
|
||||||
pugi::xml_attribute sourceAttr = currentNode.attribute("source");
|
if (XmlParser::hasAttribute(currentNode, "source")) {
|
||||||
if (!sourceAttr.empty()) {
|
XmlParser::getStdStrAttribute(currentNode, "source", sourceAttr);
|
||||||
const char *source = sourceAttr.as_string();
|
const char *source = sourceAttr.c_str();
|
||||||
if (source[0] != '#')
|
if (source[0] != '#')
|
||||||
ThrowException("Unsupported URL format");
|
ThrowException("Unsupported URL format");
|
||||||
source++;
|
source++;
|
||||||
|
|
||||||
if (strcmp(semantic, "INPUT") == 0)
|
if (semantic == "INPUT")
|
||||||
pChannel.mSourceTimes = source;
|
pChannel.mSourceTimes = source;
|
||||||
else if (strcmp(semantic, "OUTPUT") == 0)
|
else if (semantic == "OUTPUT" )
|
||||||
pChannel.mSourceValues = source;
|
pChannel.mSourceValues = source;
|
||||||
else if (strcmp(semantic, "IN_TANGENT") == 0)
|
else if (semantic == "IN_TANGENT" )
|
||||||
pChannel.mInTanValues = source;
|
pChannel.mInTanValues = source;
|
||||||
else if (strcmp(semantic, "OUT_TANGENT") == 0)
|
else if ( semantic == "OUT_TANGENT" )
|
||||||
pChannel.mOutTanValues = source;
|
pChannel.mOutTanValues = source;
|
||||||
else if (strcmp(semantic, "INTERPOLATION") == 0)
|
else if ( semantic == "INTERPOLATION" )
|
||||||
pChannel.mInterpolationValues = source;
|
pChannel.mInterpolationValues = source;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue