| 40 | } |
| 41 | |
| 42 | void AnimationRetargeter::Load(const char* _path) { |
| 43 | static const int kBufSize = 512; |
| 44 | char buf[kBufSize]; |
| 45 | if (FindFilePath(_path, buf, kBufSize, kDataPaths | kModPaths) == -1) { |
| 46 | FatalError("Error", "Could not find: %s", _path); |
| 47 | } |
| 48 | void* mem; |
| 49 | if (!LoadText(mem, buf)) { |
| 50 | FatalError("Error", "Could not read: %s", _path); |
| 51 | } |
| 52 | TiXmlDocument doc; |
| 53 | doc.Parse((const char*)mem); |
| 54 | OG_FREE(mem); |
| 55 | |
| 56 | if (doc.Error()) { |
| 57 | LOGE << "Unable to load xml file " << _path << ". Error: \"" << doc.ErrorDesc() << "\" on row " << doc.ErrorRow() << std::endl; |
| 58 | } else { |
| 59 | path = buf; |
| 60 | date_modified = GetDateModifiedInt64(buf); |
| 61 | |
| 62 | anim_skeleton.clear(); |
| 63 | |
| 64 | TiXmlHandle h_doc(&doc); |
| 65 | TiXmlHandle h_root = h_doc.FirstChildElement(); |
| 66 | TiXmlElement* field = h_root.ToElement()->FirstChildElement(); |
| 67 | if (!field) { |
| 68 | FatalError("Error", "Retargeter file has no first field"); |
| 69 | } |
| 70 | for (; field; field = field->NextSiblingElement()) { |
| 71 | std::string field_str(field->Value()); |
| 72 | if (field_str == "rig") { |
| 73 | const char* path_str = field->Attribute("path"); |
| 74 | if (!path_str) { |
| 75 | FatalError("Error", "Retargeter field has no path attribute"); |
| 76 | } |
| 77 | std::string skeleton_path = path_str; |
| 78 | TiXmlElement* anim = field->FirstChildElement(); |
| 79 | while (anim) { |
| 80 | anim_skeleton[anim->GetText()] = skeleton_path; |
| 81 | const char* path_str = anim->Attribute("no_retarget"); |
| 82 | if (path_str && strcmp(path_str, "true") == 0) { |
| 83 | anim_no_retarget[anim->GetText()] = true; |
| 84 | } |
| 85 | anim = anim->NextSiblingElement(); |
| 86 | } |
| 87 | } |
| 88 | } |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | const std::string& AnimationRetargeter::GetSkeletonFile(const std::string& anim) { |
| 93 | std::map<std::string, std::string>::iterator iter = anim_skeleton.find(anim); |
nothing calls this directly
no test coverage detected